<?php $__env->startSection('content'); ?>
        @parent
        <?php echo $__env->make('global.status', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
        <div class="row m-t-30 widgets">
            <!-- Column -->
            <div class="col-md-6 col-lg-2 col-xlg-2">
                <div class="card card-inverse bg-primary">
                    <div class="box text-center">
                        <h1 class="font-light text-white"><?php echo e($company->clients()->createdIn('year', $year)->count()); ?></h1>
                        <h6 class="text-white"><?php echo e(trans('dashboard.counter.clients')); ?></h6>
                    </div>
                </div>
            </div>
            <!-- Column -->
            <div class="col-md-6 col-lg-2 col-xlg-2">
                <div class="card card-inverse bg-purple">
                    <div class="box text-center">
                        <h1 class="font-light text-white"><?php echo e($company->policies()->createdIn('year', $year)->count()); ?></h1>
                        <h6 class="text-white"><?php echo e(trans('dashboard.counter.policies')); ?></h6>
                    </div>
                </div>
            </div>
            <!-- Column -->
            <div class="col-md-6 col-lg-2 col-xlg-2">
                <div class="card card-inverse bg-danger">
                    <div class="box text-center">
                        <h1 class="font-light text-white"><?php echo e($company->currency_symbol); ?><?php echo e($company->policies()->createdIn('year', $year)->sum('premium') + 0); ?></h1>
                        <h6 class="text-white"><?php echo e(trans('dashboard.counter.sales')); ?></h6>
                    </div>
                </div>
            </div>
            <!-- Column -->
            <div class="col-md-6 col-lg-2 col-xlg-2">
                <div class="card card-inverse bg-primary">
                    <div class="box text-center">
                        <h1 class="font-light text-white"><?php echo e($company->currency_symbol); ?><?php echo e($company->payments()->madeWithin('year', $year)->sum('amount') + 0); ?></h1>
                        <h6 class="text-white"><?php echo e(trans('dashboard.counter.conversions')); ?></h6>
                    </div>
                </div>
            </div>
            <!-- Column -->
            <div class="col-md-6 col-lg-2 col-xlg-2">
                <div class="card card-inverse bg-success">
                    <div class="box text-center">
                        <h1 class="font-light text-white"><?php echo e($company->currency_symbol); ?><?php echo e($company->payments()->madeWithin('year', $year)->sum('amount') - ($company->brokers->reduce(function($count, $broker) use($year) {
                            return $count + ($broker->inviteePayments()->madeWithin('year', $year)->sum('amount') * $broker->company->commission_rate / 100);
                        }, 0) + $company->staff->reduce(function($count, $staff) use($year) {
                            return $count + ($staff->inviteePayments()->madeWithin('year', $year)->sum('amount') * $staff->company->commission_rate / 100);
                        }, 0))); ?></h1>
                        <h6 class="text-white"><?php echo e(trans('dashboard.counter.income')); ?></h6>
                    </div>
                </div>
            </div>
            <!-- Column -->
            <div class="col-md-6 col-lg-2 col-xlg-2">
                <div class="card card-inverse bg-warning">
                    <div class="box text-center">
                        <h1 class="font-light text-white"><?php echo e($company->policies()->createdIn('year', $year)->expiring('after', 30)->count()); ?></h1>
                        <h6 class="text-white"><?php echo e(trans('dashboard.counter.expiring')); ?></h6>
                    </div>
                </div>
            </div>
        </div>
        <?php /* <div class="row m-t-30 widgets">
            <!-- Statistic -->
            <div class="col-md-6 col-lg-4 col-xlg-4 m-b-15 text-center">
                <div class="ui teal statistic">
                    <div class="value">
                        <i class="users icon"></i>
                    </div>
                    <div class="value">
                        <?php echo e($company->clients()->createdIn('year', $year)->count()); ?>

                    </div>
                    <div class="label">
                        <?php echo e(trans('dashboard.counter.clients')); ?>

                    </div>
                </div>
            </div>
            <!-- Statistic -->
            <div class="col-md-6 col-lg-4 col-xlg-4 m-b-15 text-center">
                <div class="ui purple statistic">
                    <div class="value">
                        <i class="file archive outline icon"></i>
                    </div>
                    <div class="value">
                        <?php echo e($company->policies()->createdIn('year', $year)->count()); ?>

                    </div>
                    <div class="label">
                        <?php echo e(trans('dashboard.counter.policies')); ?>

                    </div>
                </div>
            </div>
            <!-- Statistic -->
            <div class="col-md-6 col-lg-4 col-xlg-4 m-b-15 text-center">
                <div class="ui red statistic">
                    <div class="value">
                        <i class="handshake outline icon"></i>
                    </div>
                    <div class="value">
                        <?php echo e($company->currency_symbol); ?><?php echo e($company->policies()->createdIn('year', $year)->count()); ?>

                    </div>
                    <div class="label">
                        <?php echo e(trans('dashboard.counter.sales')); ?>

                    </div>
                </div>
            </div>
            <!-- Statistic -->
            <div class="col-md-6 col-lg-4 col-xlg-4 m-b-15 text-center">
                <div class="ui brown statistic">
                    <div class="value">
                        <i class="cart plus icon"></i>
                    </div>
                    <div class="value">
                        <?php echo e($company->currency_symbol); ?><?php echo e($company->payments()->madeWithin('year', $year)->sum('amount') + 0); ?>

                    </div>
                    <div class="label">
                        <?php echo e(trans('dashboard.counter.conversions')); ?>

                    </div>
                </div>
            </div>
            <!-- Statistic -->
            <div class="col-md-6 col-lg-4 col-xlg-4 m-b-15 text-center">
                <div class="ui green statistic">
                    <div class="value">
                        <i class="money icon"></i>
                    </div>
                    <div class="value">
                        <?php echo e($company->currency_symbol); ?><?php echo e($company->payments()->madeWithin('year', $year)->sum('amount') - ($company->brokers->reduce(function($count, $broker) use($year) {
                            return $count + ($broker->inviteePayments()->madeWithin('year', $year)->sum('amount') * $broker->company->commission_rate / 100);
                        }, 0) + $company->staff->reduce(function($count, $staff) use($year) {
                            return $count + ($staff->inviteePayments()->madeWithin('year', $year)->sum('amount') * $staff->company->commission_rate / 100);
                        }, 0))); ?>

                    </div>
                    <div class="label">
                        <?php echo e(trans('dashboard.counter.income')); ?>

                    </div>
                </div>
            </div>
            <!-- Statistic -->
            <div class="col-md-6 col-lg-4 col-xlg-4 m-b-15 text-center">
                <div class="ui yellow statistic">
                    <div class="value">
                        <i class="calendar times outline icon"></i>
                    </div>
                    <div class="value">
                        <?php echo e($company->policies()->createdIn('year', $year)->expiring('after', 30)->count()); ?>

                    </div>
                    <div class="label">
                        <?php echo e(trans('dashboard.counter.expiring')); ?>

                    </div>
                </div>
            </div>
        </div> */ ?>
        <div class="row">
            <div class="col-md-12 m-t-15">
                <div class="ui segment white">
                    <div class="segment-header">
                        <h3><i class="chart area icon"></i><?php echo e(trans('reports.graph.header.clients_vs_policies')); ?></h3>
                    </div>
                    <div id="clientsVsPolicies"></div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12 m-t-30">
                <div class="ui segment white">
                    <div class="segment-header">
                        <h3><i class="chart bar outline icon"></i><?php echo e(trans('reports.graph.header.annual')); ?></h3>
                    </div>
                    <div id="annualIncome"></div>
                </div>
            </div>
        </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('extra_scripts'); ?>
    <script type="text/javascript">
        (function($) {
            $(document).ready(function() {
                // Income
                Morris.Bar({
                    element: 'annualIncome',
                    data: [
                        {
                            month: '<?php echo e(trans('reports.graph.label.annual.jan')); ?>',
                            sales: <?php echo e($company->payments()->madeWithin('year', $year)->madeWithin('month', '01')->get()->sum('amount') - ($company->brokers->reduce(function($count, $broker) use($year) {
                                return $count + ($broker->inviteePayments()->madeWithin('year', $year)->madeWithin('month', '01')->sum('amount') * $broker->company->commission_rate / 100);
                            }, 0) + $company->staff->reduce(function($count, $staff) use($year) {
                                return $count + ($staff->inviteePayments()->madeWithin('year', $year)->madeWithin('month', '01')->sum('amount') * $staff->company->commission_rate / 100);
                            }, 0))); ?>

                        },
                        {
                            month: '<?php echo e(trans('reports.graph.label.annual.feb')); ?>',
                            sales: <?php echo e($company->payments()->madeWithin('year', $year)->madeWithin('month', '02')->get()->sum('amount') - ($company->brokers->reduce(function($count, $broker) use($year) {
                                return $count + ($broker->inviteePayments()->madeWithin('year', $year)->madeWithin('month', '02')->sum('amount') * $broker->company->commission_rate / 100);
                            }, 0) + $company->staff->reduce(function($count, $staff) use($year) {
                                return $count + ($staff->inviteePayments()->madeWithin('year', $year)->madeWithin('month', '02')->sum('amount') * $staff->company->commission_rate / 100);
                            }, 0))); ?>

                        },
                        {
                            month: '<?php echo e(trans('reports.graph.label.annual.mar')); ?>',
                            sales: <?php echo e($company->payments()->madeWithin('year', $year)->madeWithin('month', '03')->get()->sum('amount') - ($company->brokers->reduce(function($count, $broker) use($year) {
                                return $count + ($broker->inviteePayments()->madeWithin('year', $year)->madeWithin('month', '03')->sum('amount') * $broker->company->commission_rate / 100);
                            }, 0) + $company->staff->reduce(function($count, $staff) use($year) {
                                return $count + ($staff->inviteePayments()->madeWithin('year', $year)->madeWithin('month', '03')->sum('amount') * $staff->company->commission_rate / 100);
                            }, 0))); ?>

                        },
                        {
                            month: '<?php echo e(trans('reports.graph.label.annual.apr')); ?>',
                            sales: <?php echo e($company->payments()->madeWithin('year', $year)->madeWithin('month', '04')->get()->sum('amount') - ($company->brokers->reduce(function($count, $broker) use($year) {
                                return $count + ($broker->inviteePayments()->madeWithin('year', $year)->madeWithin('month', '04')->sum('amount') * $broker->company->commission_rate / 100);
                            }, 0) + $company->staff->reduce(function($count, $staff) use($year) {
                                return $count + ($staff->inviteePayments()->madeWithin('year', $year)->madeWithin('month', '04')->sum('amount') * $staff->company->commission_rate / 100);
                            }, 0))); ?>

                        },
                        {
                            month: '<?php echo e(trans('reports.graph.label.annual.may')); ?>',
                            sales: <?php echo e($company->payments()->madeWithin('year', $year)->madeWithin('month', '05')->get()->sum('amount') - ($company->brokers->reduce(function($count, $broker) use($year) {
                                return $count + ($broker->inviteePayments()->madeWithin('year', $year)->madeWithin('month', '05')->sum('amount') * $broker->company->commission_rate / 100);
                            }, 0) + $company->staff->reduce(function($count, $staff) use($year) {
                                return $count + ($staff->inviteePayments()->madeWithin('year', $year)->madeWithin('month', '05')->sum('amount') * $staff->company->commission_rate / 100);
                            }, 0))); ?>

                        },
                        {
                            month: '<?php echo e(trans('reports.graph.label.annual.jun')); ?>',
                            sales: <?php echo e($company->payments()->madeWithin('year', $year)->madeWithin('month', '06')->get()->sum('amount') - ($company->brokers->reduce(function($count, $broker) use($year) {
                                return $count + ($broker->inviteePayments()->madeWithin('year', $year)->madeWithin('month', '06')->sum('amount') * $broker->company->commission_rate / 100);
                            }, 0) + $company->staff->reduce(function($count, $staff) use($year) {
                                return $count + ($staff->inviteePayments()->madeWithin('year', $year)->madeWithin('month', '06')->sum('amount') * $staff->company->commission_rate / 100);
                            }, 0))); ?>

                        },
                        {
                            month: '<?php echo e(trans('reports.graph.label.annual.jul')); ?>',
                            sales: <?php echo e($company->payments()->madeWithin('year', $year)->madeWithin('month', '07')->get()->sum('amount') - ($company->brokers->reduce(function($count, $broker) use($year) {
                                return $count + ($broker->inviteePayments()->madeWithin('year', $year)->madeWithin('month', '07')->sum('amount') * $broker->company->commission_rate / 100);
                            }, 0) + $company->staff->reduce(function($count, $staff) use($year) {
                                return $count + ($staff->inviteePayments()->madeWithin('year', $year)->madeWithin('month', '07')->sum('amount') * $staff->company->commission_rate / 100);
                            }, 0))); ?>

                        },
                        {
                            month: '<?php echo e(trans('reports.graph.label.annual.aug')); ?>',
                            sales: <?php echo e($company->payments()->madeWithin('year', $year)->madeWithin('month', '08')->get()->sum('amount') - ($company->brokers->reduce(function($count, $broker) use($year) {
                                return $count + ($broker->inviteePayments()->madeWithin('year', $year)->madeWithin('month', '08')->sum('amount') * $broker->company->commission_rate / 100);
                            }, 0) + $company->staff->reduce(function($count, $staff) use($year) {
                                return $count + ($staff->inviteePayments()->madeWithin('year', $year)->madeWithin('month', '08')->sum('amount') * $staff->company->commission_rate / 100);
                            }, 0))); ?>

                        },
                        {
                            month: '<?php echo e(trans('reports.graph.label.annual.sep')); ?>',
                            sales: <?php echo e($company->payments()->madeWithin('year', $year)->madeWithin('month', '09')->get()->sum('amount') - ($company->brokers->reduce(function($count, $broker) use($year) {
                                return $count + ($broker->inviteePayments()->madeWithin('year', $year)->madeWithin('month', '09')->sum('amount') * $broker->company->commission_rate / 100);
                            }, 0) + $company->staff->reduce(function($count, $staff) use($year) {
                                return $count + ($staff->inviteePayments()->madeWithin('year', $year)->madeWithin('month', '09')->sum('amount') * $staff->company->commission_rate / 100);
                            }, 0))); ?>

                        },
                        {
                            month: '<?php echo e(trans('reports.graph.label.annual.oct')); ?>',
                            sales: <?php echo e($company->payments()->madeWithin('year', $year)->madeWithin('month', '10')->get()->sum('amount') - ($company->brokers->reduce(function($count, $broker) use($year) {
                                return $count + ($broker->inviteePayments()->madeWithin('year', $year)->madeWithin('month', '10')->sum('amount') * $broker->company->commission_rate / 100);
                            }, 0) + $company->staff->reduce(function($count, $staff) use($year) {
                                return $count + ($staff->inviteePayments()->madeWithin('year', $year)->madeWithin('month', '10')->sum('amount') * $staff->company->commission_rate / 100);
                            }, 0))); ?>

                        },
                        {
                            month: '<?php echo e(trans('reports.graph.label.annual.nov')); ?>',
                            sales: <?php echo e($company->payments()->madeWithin('year', $year)->madeWithin('month', '11')->get()->sum('amount') - ($company->brokers->reduce(function($count, $broker) use($year) {
                                return $count + ($broker->inviteePayments()->madeWithin('year', $year)->madeWithin('month', '11')->sum('amount') * $broker->company->commission_rate / 100);
                            }, 0) + $company->staff->reduce(function($count, $staff) use($year) {
                                return $count + ($staff->inviteePayments()->madeWithin('year', $year)->madeWithin('month', '11')->sum('amount') * $staff->company->commission_rate / 100);
                            }, 0))); ?>

                        },
                        {
                            month: '<?php echo e(trans('reports.graph.label.annual.dec')); ?>',
                            sales: <?php echo e($company->payments()->madeWithin('year', $year)->madeWithin('month', '12')->get()->sum('amount') - ($company->brokers->reduce(function($count, $broker) use($year) {
                                return $count + ($broker->inviteePayments()->madeWithin('year', $year)->madeWithin('month', '12')->sum('amount') * $broker->company->commission_rate / 100);
                            }, 0) + $company->staff->reduce(function($count, $staff) use($year) {
                                return $count + ($staff->inviteePayments()->madeWithin('year', $year)->madeWithin('month', '12')->sum('amount') * $staff->company->commission_rate / 100);
                            }, 0))); ?>

                        }
                    ],
                    xkey: 'month',
                    ykeys: ['sales'],
                    labels: ['<?php echo e(trans('reports.graph.pop_over.annual', array(
                        'currency_symbol'  => $company->currency_symbol
                    ))); ?>'],
                    barColors: ['#4D7CFE'],
                    resize: true
                });

                // Clients vs Policies comparison
                Morris.Area({
                    element: 'clientsVsPolicies',
                    data: [
                        {
                            month: '<?php echo e(trans('reports.graph.label.annual.jan')); ?>',
                            clients: <?php echo e($company->clients()->createdIn('year', $year)->createdIn('month', '01')->count()); ?>,
                            policies: <?php echo e($company->policies()->createdIn('year', $year)->createdIn('month', '01')->count()); ?>

                        },
                        {
                            month: '<?php echo e(trans('reports.graph.label.annual.feb')); ?>',
                            clients: <?php echo e($company->clients()->createdIn('year', $year)->createdIn('month', '02')->count()); ?>,
                            policies: <?php echo e($company->policies()->createdIn('year', $year)->createdIn('month', '02')->count()); ?>

                        },
                        {
                            month: '<?php echo e(trans('reports.graph.label.annual.mar')); ?>',
                            clients: <?php echo e($company->clients()->createdIn('year', $year)->createdIn('month', '03')->count()); ?>,
                            policies: <?php echo e($company->policies()->createdIn('year', $year)->createdIn('month', '03')->count()); ?>

                        },
                        {
                            month: '<?php echo e(trans('reports.graph.label.annual.apr')); ?>',
                            clients: <?php echo e($company->clients()->createdIn('year', $year)->createdIn('month', '04')->count()); ?>,
                            policies: <?php echo e($company->policies()->createdIn('year', $year)->createdIn('month', '04')->count()); ?>

                        },
                        {
                            month: '<?php echo e(trans('reports.graph.label.annual.mar')); ?>',
                            clients: <?php echo e($company->clients()->createdIn('year', $year)->createdIn('month', '05')->count()); ?>,
                            policies: <?php echo e($company->policies()->createdIn('year', $year)->createdIn('month', '05')->count()); ?>

                        },
                        {
                            month: '<?php echo e(trans('reports.graph.label.annual.jun')); ?>',
                            clients: <?php echo e($company->clients()->createdIn('year', $year)->createdIn('month', '06')->count()); ?>,
                            policies: <?php echo e($company->policies()->createdIn('year', $year)->createdIn('month', '06')->count()); ?>

                        },
                        {
                            month: '<?php echo e(trans('reports.graph.label.annual.jul')); ?>',
                            clients: <?php echo e($company->clients()->createdIn('year', $year)->createdIn('month', '07')->count()); ?>,
                            policies: <?php echo e($company->policies()->createdIn('year', $year)->createdIn('month', '07')->count()); ?>

                        },
                        {
                            month: '<?php echo e(trans('reports.graph.label.annual.aug')); ?>',
                            clients: <?php echo e($company->clients()->createdIn('year', $year)->createdIn('month', '08')->count()); ?>,
                            policies: <?php echo e($company->policies()->createdIn('year', $year)->createdIn('month', '08')->count()); ?>

                        },
                        {
                            month: '<?php echo e(trans('reports.graph.label.annual.sep')); ?>',
                            clients: <?php echo e($company->clients()->createdIn('year', $year)->createdIn('month', '09')->count()); ?>,
                            policies: <?php echo e($company->policies()->createdIn('year', $year)->createdIn('month', '09')->count()); ?>

                        },
                        {
                            month: '<?php echo e(trans('reports.graph.label.annual.oct')); ?>',
                            clients: <?php echo e($company->clients()->createdIn('year', $year)->createdIn('month', '10')->count()); ?>,
                            policies: <?php echo e($company->policies()->createdIn('year', $year)->createdIn('month', '10')->count()); ?>

                        },
                        {
                            month: '<?php echo e(trans('reports.graph.label.annual.nov')); ?>',
                            clients: <?php echo e($company->clients()->createdIn('year', $year)->createdIn('month', '11')->count()); ?>,
                            policies: <?php echo e($company->policies()->createdIn('year', $year)->createdIn('month', '11')->count()); ?>

                        },
                        {
                            month: '<?php echo e(trans('reports.graph.label.annual.dec')); ?>',
                            clients: <?php echo e($company->clients()->createdIn('year', $year)->createdIn('month', '12')->count()); ?>,
                            policies: <?php echo e($company->policies()->createdIn('year', $year)->createdIn('month', '12')->count()); ?>

                        }
                    ],
                    xkey: 'month',
                    ykeys: ['clients', 'policies'],
                    labels: ['<?php echo e(trans('reports.graph.pop_over.clients')); ?>', '<?php echo e(trans('reports.graph.pop_over.policies')); ?>'],
                    lineColors: ['grey', '#21ba45'],
                    parseTime: false
                });
            });
        })(window.jQuery);
    </script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('templates.reports', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>