

<?php $__env->startSection('title'); ?>
    Dashboard
<?php $__env->stopSection(); ?>

<?php $__env->startSection('css'); ?>
    <link href="<?php echo e(asset('plugins/components/chartist-js/dist/chartist.min.css')); ?>" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css" />
    <style>
         .graphbox{
            position: relative;
            width: 100%;
            display: grid;
            grid-template-columns: 1fr 1fr 1fr 1fr;
            grid-gap: 30px;
            margin-bottom: 13px;
        }
        .graphbox .box{
            position: relative;
            background: #fff;
            width: 100%;
            box-shadow: 0 7px 25px rgba(0, 0, 0, 0.08);
            border-radius: 5px;
            /* margin-top: 60px; */
        }
        #FirstChart{
            margin-left: 45px;
        }
        #SecondChart{
            margin-left: 23px;
        }
        #ThirdChart{
            margin-left: 50px
        }
        /* Responsivness */
        @media (max-width: 991px){
            .graphbox{
                grid-template-columns: 1fr;
                height: auto;
            }
        }
    </style>
<?php $__env->stopSection(); ?>


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

    <div class=" container-fluid">

        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('isSuperAdmin')): ?>
        <?php echo $__env->make('partial.multiproject_select', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
       <?php endif; ?>
        <br>

    <div id='updatecontent' style="margin-top: 60px;">
    <div class="white-box" style="margin-bottom: 10px;">
    <h3 class="box-title" style="font-size: 23px; font-weight: 600;">Dashboard</h3>
    </div>
      


          <div class="row colorbox-group-widget">
            <div class="col-md-6 col-sm-6 info-color-box">

                <div class="white-box">
                    <div class="media bg-primary">
                        <div class="media-body">

                            <h3 class="info-count"><?php echo e(number_format($totalBankBalance)); ?> <span class="pull-right"><i
                                        class="mdi mdi-checkbox-marked-circle-outline"></i></span></h3>
                            <p class="info-text font-12">Bank Balances</p>
                            <?php $__currentLoopData = $banks; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $b): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <?php if($bankBalance[$b->id] != 0): ?>
                                    <p class="info-ot font-15"><?php echo e($b->number); ?> - <?php echo e($b->name); ?><span
                                            class="label label-rounded">
                                            <?php if($bankBalance[$b->id] < 0): ?>
                                                <td class="text-right">(<?php echo e(number_format(abs($bankBalance[$b->id]))); ?>)</td>
                                            <?php else: ?>
                                                <td class="text-right">
                                                    <?php echo e($bankBalance[$b->id] > 0 ? number_format($bankBalance[$b->id]) : '-'); ?>

                                                </td>
                                            <?php endif; ?>
                                        </span></p>
                                <?php endif; ?>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-3 col-sm-6 info-color-box">
                <div class="white-box">
                    <div class="media bg-success">
                        <div class="media-body">

                            <h3 class="info-count"><?php echo e(number_format(abs($accountReceivable))); ?> <span class="pull-right"><i
                                        class="mdi mdi-comment-text-outline"></i></span></h3>
                            <p class="info-text font-12">Accounts Receivable</p>
                            <p class="info-ot font-15"></p>

                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-3 col-sm-6 info-color-box">
                <div class="white-box">
                    <div class="media bg-danger">
                        <div class="media-body">

                            <h3 class="info-count"><?php echo e(number_format(abs($accountPayable))); ?> <span class="pull-right"><i
                                        class="mdi mdi-coin"></i></span></h3>
                            <p class="info-text font-12">Accounts Payable</p>
                            <p class="info-ot font-15"></p>

                        </div>
                    </div>
                </div>
            </div>

        </div> 

        <div class="row">
            <div class="col-sm-12">
                <label style="font-weight: 900;">Closing Report : </label>
                <form target="_blank" method="post" action="<?php echo e(route('account-closing-report')); ?>">
                    <?php echo e(csrf_field()); ?>

                    <input type='hidden' name='multipro_id' id='multipro_id_input' value='all'>
                    <div class="col-sm-4">
                        <div class="input-group" style="width:100%">
                            <select class="form-control chosen-select" name="bank_id" id="bank_id">
                                <?php $__currentLoopData = $banks; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $b): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($b->id); ?>"><?php echo e($b->number); ?> - <?php echo e($b->name); ?>

                                    </option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                    </div>

                    <div class="col-sm-4">
                        <div class="input-group" style="width:100%">

                            <input type="text" class="form-control "id="daterange-btn" value='<?php echo e(old('date_range')); ?>'
                                name='date_range'>
                        </div>
                    </div>

                    <div class="col-sm-3">
                        <div class="input-group" style="width:100%">

                            <span class="input-group-btn">
                                <button type="submit" id="check-minutes"
                                    class="btn waves-effect waves-light btn-success">Generate</button>
                            </span>
                        </div>
                    </div>
                </form>
           </div>
         </div>
        </div>
   
        <br>


        <!-- /row -->
        <div class="row" id="update-table">
            <div class="col-sm-12">
                <div class="white-box">
                    <div class="pull-right">

                    </div>
                    <h3 class="box-title">List of unPosted Entries</h3>

                    <div class="table-responsive">
                        <table id="myTable" class="table table-striped table-bordered">
                            <thead>
                                <tr>
                                    <th>Type</th>
                                    <th>Checked</th>
                                    <th>Posted</th>
                                    <th>Date</th>
                                    <!-- <th>Entry No.</th> -->
                                    <th>Cheque No.</th>
                                    <th>Account</th>
                                    <!-- <th>Memo</th> -->
                                    <!-- <th>Class</th> -->
                                    <th>Debit/Credit (+/-)</th>
                                    <th>Action</th>

                                </tr>
                            </thead>
                            <tbody>
                                <?php $__currentLoopData = $allEntries; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $entry): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr ondblclick="showEntry('<?php echo e($entry->entry_no); ?>')">

                                        <?php if($entry->voucher_type == \App\GeneralJournalEntry::CRV): ?>
                                            <td>CRV-<?php echo e($entry->voucher_no); ?></td>
                                        <?php elseif($entry->voucher_type == \App\GeneralJournalEntry::BRV): ?>
                                            <td>BRV-<?php echo e($entry->voucher_no); ?></td>
                                        <?php elseif($entry->voucher_type == \App\GeneralJournalEntry::CPV): ?>
                                            <td>CPV-<?php echo e($entry->voucher_no); ?></td>
                                        <?php elseif($entry->voucher_type == \App\GeneralJournalEntry::BPV): ?>
                                            <td>BPV-<?php echo e($entry->voucher_no); ?></td>
                                        <?php elseif($entry->voucher_type == \App\GeneralJournalEntry::JV): ?>
                                            <td>JV-<?php echo e($entry->voucher_no); ?></td>
                                        <?php else: ?>
                                            <td></td>
                                        <?php endif; ?>

                                        <td>
                                            <?php if($entry->is_check): ?>
                                                <i class="fa fa-check" style="color:green"></i>
                                            <?php else: ?>
                                                <i class="fa fa-close" style="color: red;"></i>
                                            <?php endif; ?>

                                        <td>
                                            <?php if($entry->is_post): ?>
                                                <i class="fa fa-check" style="color:green"></i>
                                            <?php else: ?>
                                                <i class="fa fa-close" style="color: red;"></i>
                                            <?php endif; ?>
                                        </td>

                                        <td><?php echo e(date('d/m/Y', strtotime($entry->date))); ?></td>
                                        <!--  <td>Cehk nyumber</td>  -->
                                        <td>
                                            <?php echo e($entry->cheaque_no ? $entry->cheaque_no : ''); ?>

                                        </td>
                                        <td><?php echo e($entry->account ? $entry->account->name : ''); ?></td>
                                        <!-- <td><?php echo e($entry->memo); ?></td> -->
                                        <!-- <td><?php echo e($entry->class ? $entry->class->name : ''); ?></td> -->
                                        <td class="text-right"><?php echo e(number_format($totalAmount[$entry->entry_no])); ?></td>
                                        <td>
                                            <!-- <span onclick="showEntry('<?php echo e($entry->entry_no); ?>')" style="cursor: pointer;" class="btn btn-sm btn-primary"> Show</span> -->

                                            <a href="<?php echo e(route('voucher-detail', ['id' => $entry->entry_no])); ?>"
                                                class="btn btn-default">View</a>

                                            <?php if(!$entry->is_approved): ?>
                                                <br><br>
                                                <span onclick="approveEntryModal('<?php echo e($entry->entry_no); ?>')"
                                                    style="cursor: pointer;" class="btn btn-default btn-sm"> Approve</span>
                                            <?php endif; ?>

                                        </td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <!-- /.row -->




        <br>


        <!--.row-->


        <div class="row" id="update-table">

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




        <!-- /row -->



        <!-- /.container-fluid -->
    </div>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('js'); ?>
    <script src="<?php echo e(asset('plugins/components/chartist-js/dist/chartist.min.js')); ?>"></script>
    <script src="<?php echo e(asset('plugins/components/chartist-plugin-tooltip-master/dist/chartist-plugin-tooltip.min.js')); ?>">
    </script>
    <script src="<?php echo e(asset('plugins/components/knob/jquery.knob.js')); ?>"></script>
    <script src="<?php echo e(asset('plugins/components/custom-chart/chart.js')); ?>"></script>
    <script src="<?php echo e(asset('js/db3.js')); ?>"></script>

    <script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/chart.js@4.3.0/dist/chart.umd.min.js"></script>
    <script>
        function callFunction(){
        const year = new Date().getFullYear();

        const this_fiscal_year_start_date = new Date(year + '-' + <?php echo e(\App\ChartOfAccount::FISCAL_YEAR_START); ?> + '-01');

        const this_fiscal_year_end_date = new Date((year + 1) + '-' + <?php echo e(\App\ChartOfAccount::FISCAL_YEAR_END); ?> + '-30');

        const last_fiscal_year_start_date = new Date((year - 1) + '-' + <?php echo e(\App\ChartOfAccount::FISCAL_YEAR_START); ?> +
            '-01');

        const last_fiscal_year_end_date = new Date(year + '-' + <?php echo e(\App\ChartOfAccount::FISCAL_YEAR_END); ?> + '-30');




        $('#daterange-btn').daterangepicker({

                ranges: {
                    'Today': [moment(), moment()],
                    'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
                    'Last 7 Days': [moment().subtract(6, 'days'), moment()],
                    'Last 30 Days': [moment().subtract(29, 'days'), moment()],
                    'This Month': [moment().startOf('month'), moment().endOf('month')],
                    'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf(
                        'month')],
                    'This Fiscal Year': [this_fiscal_year_start_date, this_fiscal_year_end_date],
                    'Last Fiscal Year': [last_fiscal_year_start_date, last_fiscal_year_end_date]
                },
                startDate: moment().subtract(29, 'days'),
                endDate: moment()
            },
            function(start, end) {
                $('#daterange-btn span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
            }
        );
        }
        callFunction();
    </script>

    <script>
        $(function() {
            $('#myTable1').DataTable({
                'pageLength': 25,
                'paging': false,
                'info': false,
                'searching': false
            });
        });




        function updateStatus(value) {
            $('.preloader').fadeIn();

            if (value === 'search') {

                $('.preloader').fadeOut();
                return false;
            }
            var data = {
                'multipro_id': value,
            };
           
            $.get('<?php echo e(route('account-dashboard')); ?>', data, function(data) {
                $('.preloader').fadeOut();
                $('#myTable tbody').empty();



                $('#updatecontent').empty();
                document.getElementById('updatecontent').innerHTML = data;

                $('#myTable1').DataTable({
                'pageLength': 25,
                'paging': false,
                'info': false,
                'searching': false
            });
            
            callFunction();
            $('#multipro_id_input').val(value);
                toastr.success("Search updated.");


                $('.preloader').fadeOut();
            });

        }
    </script>
    <!-- Graphs Start From Here -->
    <script>
    const ctx = document.getElementById('FirstChart').getContext('2d');
    new Chart(ctx, {
    type: 'polarArea',
    data: {
      labels: ['Bank Balances <?php echo number_format($totalBankBalance) ?>',

      ],
      datasets: [{
        data: [ <?php echo number_format($totalBankBalance) ?>,
        200,
       ],
        backgroundColor: [
            'rgb(60, 179, 113)',
            'rgb(60, 179, 113)',
        ],
      }]
    },
    options: {
      responsive: true,
    },
  });
</script>

<!-- Seconf Graph -->
<script>
 const ctxx = document.getElementById('SecondChart').getContext('2d');
    new Chart(ctxx, {
    type: 'bar',
    data: {
      labels: ['Accounts Receivable <?php echo number_format(abs($accountReceivable))?>',
      ],
      datasets: [{
        data: [
            <?php echo number_format(abs($accountReceivable))?>,
            550,
       ],
        backgroundColor: [
            '#DE3163',
            '#36A00E',
        ],
      }]
    },
    options: {
        plugins: {
    legend: {
      display: false
    }
  }
},
  });
</script>
<script>
 const ctxxx = document.getElementById('ThirdChart').getContext('2d');
    new Chart(ctxxx, {
    type: 'pie',
    data: {
      labels: ['Accounts Payable <?php echo number_format(abs($accountPayable)) ?>',
      ],
      datasets: [{
        data: [ 
            <?php echo number_format(abs($accountPayable)) ?>,
            10000,
       ],
        backgroundColor: [
            '#FF6384',
            '#FF6384',
        ],
      }]
    },
    options: {
        responsive: true,
    }
    });
</script>

<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\akram-city.projecterp.net\resources\views/account/dashboard.blade.php ENDPATH**/ ?>