<?php $__env->startSection('content'); ?>
<div class="col-md-12 content-header" >
    <h1><i class="fa fa-dashboard"></i> <?php echo e(trans('application.dashboard')); ?></h1>
</div>
<section class="content">
    <div class="row">
        <div class="col-md-3 col-sm-6 col-xs-12">
            <div class="info-box">
                <span class="info-box-icon bg-aqua"><i class="fa fa-users"></i></span>
                <div class="info-box-content">
                    <span class="info-box-text"><?php echo e(trans('application.clients')); ?></span>
                    <span class="info-box-number"><?php echo e($clients); ?></span>
                </div><!-- /.info-box-content -->
            </div><!-- /.info-box -->
        </div><!-- /.col -->
        <div class="col-md-3 col-sm-6 col-xs-12">
            <div class="info-box">
                <span class="info-box-icon bg-green"><i class="fa fa-file-pdf-o"></i></span>
                <div class="info-box-content">
                    <span class="info-box-text"><?php echo e(trans('application.invoices')); ?></span>
                    <span class="info-box-number"><?php echo e($invoices); ?></span>
                </div><!-- /.info-box-content -->
            </div><!-- /.info-box -->
        </div><!-- /.col -->
        <div class="col-md-3 col-sm-6 col-xs-12">
            <div class="info-box">
                <span class="info-box-icon bg-yellow"><i class="fa fa-quote-left"></i></span>
                <div class="info-box-content">
                    <span class="info-box-text"><?php echo e(trans('application.estimates')); ?></span>
                    <span class="info-box-number"><?php echo e($estimates); ?></span>
                </div><!-- /.info-box-content -->
            </div><!-- /.info-box -->
        </div><!-- /.col -->
        <div class="col-md-3 col-sm-6 col-xs-12">
            <div class="info-box">
                <span class="info-box-icon bg-red"><i class="fa fa-puzzle-piece"></i></span>
                <div class="info-box-content">
                    <span class="info-box-text"><?php echo e(trans('application.products')); ?></span>
                    <span class="info-box-number"><?php echo e($products); ?></span>
                </div><!-- /.info-box-content -->
            </div><!-- /.info-box -->
        </div><!-- /.col -->
    </div>
    <div class="row">
        <div class="col-lg-3">
            <div class="panel panel-primary">
                <div class="panel-heading">
                    <div class="row">
                        <div class="col-xs-3">
                            <i class="fa fa-usd fa-5x"></i>
                        </div>
                        <div class="col-xs-9 text-right">
                            <p><?php echo e($invoice_stats['partiallyPaid']); ?></p>
                            <p><?php echo e(trans('application.invoices_partially_paid')); ?></p>
                        </div>
                    </div>
                </div>

            </div>
        </div>
        <div class="col-lg-3">
            <div class="panel bg-yellow">
                <div class="panel-heading">
                    <div class="row">
                        <div class="col-xs-3">
                            <i class="fa fa-money fa-5x"></i>
                        </div>
                        <div class="col-xs-9 text-right">
                            <p><?php echo e($invoice_stats['unpaid']); ?></p>
                            <p><?php echo e(trans('application.unpaid_invoices')); ?></p>
                        </div>
                    </div>
                </div>

            </div>
        </div>
        <div class="col-lg-3">
            <div class="panel bg-red">
                <div class="panel-heading">
                    <div class="row">
                        <div class="col-xs-3">
                            <i class="fa fa-times fa-5x"></i>
                        </div>
                        <div class="col-xs-9 text-right">
                            <p><?php echo e($invoice_stats['overdue']); ?></p>
                            <p><?php echo e(trans('application.invoices_overdue')); ?> </p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-lg-3">
            <div class="panel bg-green">
                <div class="panel-heading">
                    <div class="row">
                        <div class="col-xs-3">
                            <i class="fa fa-check fa-5x"></i>
                        </div>
                        <div class="col-xs-9 text-right">
                            <p><?php echo e($invoice_stats['paid']); ?></p>
                            <p><?php echo e(trans('application.paid_invoices')); ?></p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12">
            <div class="box box-solid">
                <div class="box-header">
                    <h3 class="box-title"><?php echo e(trans('application.invoices_generated')); ?></h3>
                    <ul class="nav nav-pills ranges pull-right">
                        <li class="active"><a href="#" data-range="7" data-rel="invoices">7 <?php echo e(trans('application.days')); ?></a></li>
                        <li class=""><a href="#" data-range="30" data-rel="invoices">30 <?php echo e(trans('application.days')); ?></a></li>
                        <li class=""><a href="#" data-range="60" data-rel="invoices">60 <?php echo e(trans('application.days')); ?></a></li>
                        <li class=""><a href="#" data-range="90" data-rel="invoices">90 <?php echo e(trans('application.days')); ?></a></li>
                    </ul>
                </div><!-- /.box-header -->
                <div class="box-body">
                    <div class="row">
                        <div class="col-md-12">
                            <div class="chart-responsive">
                                <div id="invoices-chart" style="height: 350px;"></div>
                                <div class="alert" id="legend"></div>
                            </div><!-- /.chart-responsive -->
                        </div><!-- /.col -->

                    </div><!-- /.row -->
                </div><!-- ./box-body -->

            </div>
        </div>
    </div>
    <div class="row">


        <div class="col-md-12">
            <div class="box box-solid">
                <div class="box-header">
                    <h3 class="box-title"> <?php echo e(trans('application.recent_invoices')); ?></h3>
                </div>
                <div class="box-body">

                    <table class="table table-bordered table-striped table-hover">
                        <thead>
                        <tr>
                            <th></th>
                            <th><?php echo e(trans('application.invoice_number')); ?></th>
                            <th><?php echo e(trans('application.invoice_status')); ?></th>
                            <th><?php echo e(trans('application.client')); ?></th>
                            <th><?php echo e(trans('application.date')); ?></th>
                            <th><?php echo e(trans('application.due_date')); ?></th>
                            <th><?php echo e(trans('application.amount')); ?></th>
                            <th width="20%"><?php echo e(trans('application.action')); ?> </th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php foreach($recentInvoices as $count=>$invoice): ?>
                        <tr>
                            <td><?php echo e($count+1); ?></td>
                            <td><a href="<?php echo e(route('invoices.show', $invoice->id)); ?>"><?php echo e($invoice->number); ?></a> </td>
                            <td><span class="label <?php echo e(statuses()[$invoice->status]['class']); ?>"><?php echo e(ucwords(statuses()[$invoice->status]['label'])); ?> </span></td>
                            <td><a href="<?php echo e(route('clients.show', $invoice->client_id)); ?>"><?php echo e($invoice->client->name); ?></a> </td>
                            <td><?php echo e($invoice->invoice_date); ?> </td>
                            <td><?php echo e($invoice->due_date); ?> </td>
                            <td><?php echo e($invoice->currency.''.$invoice->totals['grandTotal']); ?> </td>
                            <td>
                                <a href="<?php echo route('invoices.show',$invoice->id); ?>" class="btn btn-sm btn-info"><i class="fa fa-eye"></i> <?php echo e(trans('application.view')); ?> </a>
                                <a href="<?php echo route('invoices.edit',$invoice->id); ?>" class="btn btn-sm btn-success"><i class="fa fa-pencil"></i> <?php echo e(trans('application.edit')); ?> </a>
                            </td>
                        </tr>
                        <?php endforeach; ?>
                        </tbody>
                    </table>

                </div><!-- /.box-body -->
            </div><!-- /.box -->
        </div>
        <div class="col-md-12">
            <div class="box box-solid">
                <div class="box-header">
                    <h3 class="box-title"> <?php echo e(trans('application.recent_estimates')); ?></h3>
                </div>
                <div class="box-body">
                    <table class="table table-bordered table-striped table-hover">
                        <thead>
                        <tr>
                            <th></th>
                            <th><?php echo e(trans('application.estimate_number')); ?></th>
                            <th><?php echo e(trans('application.client')); ?></th>
                            <th><?php echo e(trans('application.date')); ?></th>
                            <th><?php echo e(trans('application.amount')); ?></th>
                            <th width="20%"><?php echo e(trans('application.action')); ?> </th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php foreach($recentEstimates as $count=>$estimate): ?>
                        <tr>
                            <td><?php echo e($count+1); ?></td>
                            <td><a href="<?php echo e(route('estimates.show', $estimate->id)); ?>"><?php echo e($estimate->estimate_no); ?> </a></td>
                            <td><a href="<?php echo e(route('clients.show', $estimate->client_id)); ?>"><?php echo e($estimate->client->name); ?></a> </td>
                            <td><?php echo e($estimate->estimate_date); ?> </td>
                            <td><?php echo e($estimate->currency.''.$estimate->totals['grandTotal']); ?> </td>
                            <td>
                                <a href="<?php echo route('estimates.show',$estimate->id); ?>" class="btn btn-sm btn-info"><i class="fa fa-eye"></i> <?php echo e(trans('application.view')); ?> </a>
                                <a href="<?php echo route('estimates.edit',$estimate->id); ?>" class="btn btn-sm btn-success"><i class="fa fa-pencil"></i> <?php echo e(trans('application.edit')); ?> </a>
                            </td>
                        </tr>
                        <?php endforeach; ?>
                        </tbody>
                    </table>
                </div><!-- /.box-body -->
            </div><!-- /.box -->
        </div>
    </div>
</section>
<style>
    .alert{
        padding:5px;
        text-transform: uppercase;
    }
</style>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('scripts'); ?>
<script src="<?php echo e(asset('assets/js/raphael.min.js')); ?>"></script>
<script src="<?php echo e(asset('assets/js/morris.min.js')); ?>"></script>
<script src="<?php echo e(asset('assets/js/spin.min.js')); ?>"></script>
<link rel="stylesheet" href="<?php echo e(asset('assets/css/morris.min.css')); ?>">
<script>
$(function() {
    function requestData(days,category){
        $('#'+category+'-chart').empty();
        var spinTarget = document.getElementById(category+'-chart');
        $('#'+category+'-chart').addClass('spinner');
        //var spinner = new Spinner().spin(spinTarget);
        $.ajax({
            type: "POST",
            url: "<?php echo e(url('reports/ajaxData')); ?>",
            data: { days: days, chart:category, _token:'<?php echo e(csrf_token()); ?>' }
        })
            .done(function( data ) {
                var total = 0;
              var chart = Morris.Line({
                    element: category+'-chart',
                    data:[
                        { y: '2012-01', a: 100, b: 90 },
                        { y: '2012-02', a: 75,  b: 65 },
                        { y: '2012-03', a: 50,  b: 40 },
                        { y: '2012-04', a: 75,  b: 65 },
                        { y: '2012-05', a: 50,  b: 40 },
                        { y: '2012-06', a: 75,  b: 65 },
                        { y: '2012-07', a: 100, b: 90 },
                        { y: '2012-08', a: 100, b: 90 },
                        { y: '2012-09', a: 100, b: 90 },
                        { y: '2012-10', a: 100, b: 90 },
                        { y: '2012-11', a: 100, b: 90 },
                        { y: '2012-12', a: 100, b: 90 }
                    ],
                    xkey: 'y',
                    ykeys: ['a','b'],
                    labels: ['Expenses','Paid Amount'],
                    resize:true,
                    lineColors:['#ff5b57','#2fa4e7'],
                    pointSize:5,
                    hideHover:"auto"
                });
                for (var i = 0; i < data.length; i++) {
                    total += parseFloat(data[i].value);
                }
            })
            .fail(function() {
                alert( "error occured" );
            }).always(function () {
                $('#'+category+'-chart').removeClass('spinner');
            });;
    }
    // Request initial data for the past 7 days:
    requestData(7, 'invoices');

    $('ul.ranges a').click(function(e){
        e.preventDefault();

        var el = $(this);
        days = el.attr('data-range');
        chart = el.attr('data-rel');

        requestData(days,chart);

        el.parent().addClass('active');
        el.parent().siblings().removeClass('active');
    });

});
</script>
<?php $__env->stopSection(); ?>


<?php echo $__env->make('app', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>