<?php $__env->startSection('content'); ?>
<?php Fun::lang() ?>
<?php

$dataPoints = $graph;

?>
<div class="row">
    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check("Dashboard-Accounting")): ?>
    <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-pie-chart"></i></span>
            <div class="info-box-content">
                <span class="info-box-text">Cash On Hand</span>
                <span class="info-box-number">$<?php echo e(number_format($data["cash_on_hand"],2)); ?></span>
            </div>
        </div>
    </div>
    <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-university"></i></span>
            <div class="info-box-content">
                <span class="info-box-text">Cash In Bank</span>
                <span class="info-box-number">$<?php echo e(number_format($data["cash_in_bank"],2)); ?></span>
            </div>
        </div>
    </div>
    <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-line-chart"></i></span>

            <div class="info-box-content">
                <span class="info-box-text">Income</span>
                <span class="info-box-number">$<?php echo e(number_format($data["income"],2)); ?></span>
            </div>
        </div>
    </div>
    <div class="col-md-3 col-sm-6 col-xs-12">
        <div class="info-box">
            <span class="info-box-icon bg-red"><i class="glyphicon glyphicon-cloud-upload"></i></span>
            <div class="info-box-content">
                <span class="info-box-text">Expense</span>
                <span class="info-box-number">$<?php echo e(number_format($data["expense"],2)); ?></span>
            </div>
        </div>
    </div>
    <div class="col-md-3 col-sm-6 col-xs-12">
        <div class="info-box">
            <span class="info-box-icon bg-blue"><i class="fa fa-cloud-upload"></i></span>
            <div class="info-box-content">
                <span class="info-box-text">Liability</span>
                <span class="info-box-number">$<?php echo e(number_format($data["libility"],2)); ?></span>
            </div>
        </div>
    </div>
    <div class="col-md-3 col-sm-6 col-xs-12">
        <div class="info-box">
            <span class="info-box-icon bg-pink"><i class="fa fa-bar-chart"></i></span>

            <div class="info-box-content">
                <span class="info-box-text">Collection</span>
                <span class="info-box-number">$<?php echo e(number_format($data["collection"],2)); ?></span>
            </div>
        </div>
    </div>
    <div class="col-md-3 col-sm-6 col-xs-12">
        <div class="info-box">
            <span class="info-box-icon bg-pink"><i class="fa fa-bar-chart"></i></span>

            <div class="info-box-content">
                <span class="info-box-text">Collected</span>
                <span class="info-box-number">$<?php echo e(number_format($data["collect"],2)); ?></span>
            </div>
        </div>
    </div>
    <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-check"></i></span>

            <div class="info-box-content">
                <span class="info-box-text">Completed</span>
                <span class="info-box-number">$<?php echo e(number_format($data["completed"],2)); ?></span>
            </div>
        </div>
    </div>
    <?php endif; ?>
    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('Dashboard-Operation')): ?>
    <div class="clearfix visible-sm-block"></div>
    <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-user-plus"></i></span>
            <div class="info-box-content">
                <span class="info-box-text">Total Client</span>
                <span class="info-box-number" id="total_client"></span>
            </div>
        </div>
    </div>
    <div class="col-md-3 col-sm-6 col-xs-12">
        <div class="info-box">
            <span class="info-box-icon bg-pink"><i class="fa fa-spinner"></i></span>
            <div class="info-box-content">
                <span class="info-box-text">Total Deposit</span>
                <span class="info-box-number" id="total_deposit"></span>
            </div>
        </div>
    </div>
    <div class="col-md-3 col-sm-6 col-xs-12">
        <div class="info-box">
            <span class="info-box-icon bg-purple"><i class="fa fa-handshake-o"></i></span>
            <div class="info-box-content">
                <span class="info-box-text">Total Contract</span>
                <span class="info-box-number" id="total_contract"></span>
            </div>
        </div>
    </div>
    <div class="col-md-3 col-sm-6 col-xs-12">
        <div class="info-box">
            <span class="info-box-icon bg-"><i class="fa fa-cubes"></i></span>
            <div class="info-box-content">
                <span class="info-box-text">Total Item</span>
                <span class="info-box-number" id="total_item"></span>
            </div>
        </div>
    </div>
    <?php endif; ?>
</div>
<!-- here -->
<div class="row col-sm-12">

</div>
<?php if(!(\Branch::branch_key())): ?>
<div class="row">
    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('Dashboard-Today-Operation')): ?>
    <div class="col-sm-3">
        <div class="col-lg-12 col-xs-6">
            <div class="small-box bg-aqua">
                <div class="inner">
                    <h3 id="today_collection"></h3>
                    <p>Today Collection :<span id="loan_collection"></span></p>
                </div>
                <div class="icon">
                    <i class="fa fa-shopping-cart"></i>
                </div>
                <a href="#" class="small-box-footer">
                    More info <i class="fa fa-arrow-circle-right"></i>
                </a>
            </div>
        </div>
        <div class="col-lg-12 col-xs-6">
            <div class="small-box bg-green">
                <div class="inner">
                    <h3 id="today_collected"></h3>
                    <p>Today Collected :<span id="loan_collected"></span></p>
                </div>
                <div class="icon">
                    <i class="fa fa-check"></i>
                </div>
                <a href="#" class="small-box-footer">
                    More info <i class="fa fa-arrow-circle-right"></i>
                </a>
            </div>
        </div>
        <div class="col-lg-12 col-xs-6">
            <div class="small-box bg-yellow">
                <div class="inner">
                    <h3 id="today_arrear"><span id="loan_arrear"></span></h3>
                    <p>Today Arrear :<span id="loan_arrear"></span></p>
                </div>
                <div class="icon">
                    <i class="fa fa-times"></i>
                </div>
                <a href="#" class="small-box-footer">
                    More info <i class="fa fa-arrow-circle-right"></i>
                </a>
            </div>
        </div>
    </div>
    <?php endif; ?>
    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('Dashboard-Payment-Chart')): ?>
    <div class="col-sm-9">
        <div class="box box-default color-palette-box">
            <div class="box-header with-border">
                <h3 class="box-title"><i class="fa fa-bar-chart"></i> Chart Data</h3>
            </div>
            <div class="box-body">
                <div class="row">
                    <div class="col-sm-12">
                        <div class="form-group col-sm-5">
                            <label for="" class="col-sm-4">Start Date</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control date_picker" id="start_date">
                            </div>
                        </div>
                        <div class="form-group col-sm-5">
                            <label for="" class="col-sm-4">End Date</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control date_picker" id="end_date">
                            </div>
                        </div>
                        <div class="form-group col-sm-2">
                            <div class="col-sm-12">
                                <button type="button" class="pull-right" class="btn btn-warning" onclick="search()"><span class="fa fa-search"></span> SEARCH</button>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-12" style="margin-top:50px">
                        <div id="chartContainer" style="height: 370px; width: 100%;"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php endif; ?>
</div>
<?php else: ?>
<div class="row col-sm-12">
    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('Dashboard-Item')): ?>
    <div class="box box-default color-palette-box bg-grey" width="100%;">
        <div class="box-header with-border">
            <h3 class="box-title"><i class="fa fa-bar-chart"></i> Chart Data</h3>
        </div>
        <div class="box-body">
            <div class="col-sm-6">
                <div class="col-md-12 col-sm-12 col-xs-12">
                    <div class="info-box">
                        <span class="info-box-icon bg-aqua"><i class="fa fa-envelope-o"></i></span>
                        <div class="info-box-content">
                            <span class="info-box-text">Available Items</span>
                            <span class="info-box-number" id="available-item"></span>
                        </div>
                    </div>
                </div>
                <div class="col-md-12 col-sm-12 col-xs-12">
                    <div class="info-box">
                        <span class="info-box-icon bg-green"><i class="fa fa-flag-o"></i></span>
                        <div class="info-box-content">
                            <span class="info-box-text">Sold Items</span>
                            <span class="info-box-number" id="sold-item"></span>
                        </div>
                    </div>
                </div>
                <div class="col-md-12 col-sm-12 col-xs-12">
                    <div class="info-box">
                        <span class="info-box-icon bg-yellow"><i class="fa fa-files-o"></i></span>
                        <div class="info-box-content">
                            <span class="info-box-text">Blocked Items</span>
                            <span class="info-box-number" id="block-item"></span>
                        </div>
                    </div>
                </div>
            </div>
            <!--Contraction-->
            <div class="col-sm-6">
                <div class="col-md-12 col-sm-12 col-xs-12">
                    <div class="info-box">
                        <span class="info-box-icon bg-aqua"><i class="fa fa-line-chart"></i></span>
                        <div class="info-box-content">
                            <span class="info-box-text">Purchase Amount</span>
                            <span class="info-box-number" id="available-item"><?php echo e("$".number_format($data['amount_purchase'],2)); ?></span>
                        </div>
                    </div>
                </div>
                <div class="col-md-12 col-sm-12 col-xs-12">
                    <div class="info-box">
                        <span class="info-box-icon bg-pink"><i class="fa fa-user-plus"></i></span>
                        <div class="info-box-content">
                            <span class="info-box-text">Contractor</span>
                            <span class="info-box-number" id="block-item"><?php echo e($data['constructor']); ?></span>
                        </div>
                    </div>
                </div>
                <div class="col-md-12 col-sm-12 col-xs-12">
                    <div class="info-box">
                        <span class="info-box-icon bg-green"><i class="fa fa-bar-chart"></i></span>
                        <div class="info-box-content">
                            <span class="info-box-text">Contractor Paid Amount</span>
                            <span class="info-box-number" id="sold-item"><?php echo e($data['contract_paid']); ?></span>
                        </div>
                    </div>
                </div>
            </div>
            <!--End-->
        </div>
        
    </div>
    <?php endif; ?>
</div>
<?php endif; ?>

<!-- here -->


<?php $__env->stopSection(); ?>
<?php $__env->startSection('js'); ?>
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<?php if(!(\Branch::branch_key())): ?>
<script>
    $(document).ready(function() {
        var chart = new CanvasJS.Chart("chartContainer", {
            animationEnabled: true,
            exportEnabled: true,
            theme: "light1",
            title: {
                text: "Bar Chart Based Client Payment"
            },
            data: [{
                type: "column",
                indexLabelFontColor: "#5A5757",
                indexLabelPlacement: "outside",
                dataPoints: <?php echo json_encode($dataPoints, JSON_NUMERIC_CHECK); ?>
            }]
        });
        chart.render();
    });

    function search() {
        var start = $('#start_date').val();
        var end = $('#end_date').val();
        if (start != '' && end != '') {}

        var dataPoints = [];
        var chart = new CanvasJS.Chart("chartContainer", {
            title: {
                text: "Bar Chart Based Client Payment"
            },
            animationEnabled: true,
            exportEnabled: true,
            data: [{
                type: "column",
                dataPoints: dataPoints,
            }]
        });
        $.ajax({
            type: "POST",
            dataType: "json",
            url: "<?php echo e(route('bar-chart')); ?>",
            data: {
                _token: "<?php echo e(csrf_token()); ?>",
                start: start,
                end: end
            },
            success: function(data) {
                $.each(data, function(key, value) {
                    dataPoints.push({
                        label: value['label'],
                        y: parseFloat(value['y']),
                        indexLabel: value['indexLabel']
                    });
                });
                chart.render();
            }
        });
    }
</script>
<?php endif; ?>
<script>
    $(document).ready(function() {
        operationData();
    });

    function operationData() {
        $.ajax({
            type: "GET",
            dataType: "JSON",
            url: "<?php echo e(route('operational-data')); ?>",
            data: {
                _token: "<?php echo e(csrf_token()); ?>"
            },
            success: function(response) {
                $('#total_client').text(response.client);
                $('#total_deposit').text(response.deposit);
                $('#total_contract').text(response.contract);
                $('#total_item').text(response.item);
                $('#today_collection').text("$ " + parseFloat(response.collection_amount).toFixed(2));
                $('#loan_collection').text(response.collection_qty + " client(s)");
                $('#today_collected').text("$ " + parseFloat(response.collected_amount).toFixed(2));
                $('#loan_collected').text(response.collected_qty + " client(s)");
                $('#today_arrear').text('$ ' + parseFloat(response.arrear_amount).toFixed(2));
                $('#loan_arrear').text(response.arrear_qty + " client(s)");
                $('#available-item').text(response.available_item);
                $('#sold-item').text(response.sold_item);
                $('#block-item').text(response.block_item);
            }
        });
    }
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('adminlte::page', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>