  <?php $__env->startSection('content'); ?>
 <?php Fun::lang() ?>
 <div class="title-page">
     <div class="page-bar">
         <ul class="page-breadcrumb">
             <li><a href="#"><i class="fa fa-dashboard"></i> Dashboard</a></li>
             <li><a href="#">Report Accounting</a></li>
             <li><a href="#">Report Cash on Hand</a></li>
         </ul>
     </div>
 </div>
 <div class="page">
     <div class="top-content">
         <div class="row">
             <div class="col-sm-12 col-xs-12">
                 <div class="title-add">
                     <div class="pull-left">
                         <h3>Report Cash on Hand</h3>
                     </div>
                 </div>
             </div>
         </div>
     </div>
     <form action="<?php echo e(url('/realty/report-account-cash-on-hand-print')); ?>" method="POST">
         <?php echo csrf_field(); ?>
         <div class="form-search">
             <div class="row">
                 <div class="col-xs-12 col-sm-6 col-md-6">
                     <div class="form-group">
                         <strong>Start Date</strong> <?php echo Form::text('start_date', null, array('placeholder' => 'Start Date','class' => 'form-control date_picker start_date','autocomplete' => 'off','required')); ?>

                     </div>
                 </div>
                 <div class="col-xs-12 col-sm-6 col-md-6">
                     <div class="form-group">
                         <strong>End Date</strong> <?php echo Form::text('end_date', null, array('placeholder' => 'End Date','class' => 'form-control date_picker end_date','autocomplete' => 'off','required')); ?>

                     </div>
                 </div>

                 <div class="col-xs-12 col-sm-12 col-md-12 text-right">
                     <button type="button" class="button_primary btn-sm search" onclick="searching()"><span class="fa fa-search"> Search</span></button>&nbsp
                     <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('CashOnHand-Print')): ?>
                     <button type="submit" class="button_primary btn-sm search"><span class="fa fa-print"> Print</span></button>
                     <?php endif; ?>
                 </div>
             </div>
         </div>
         <?php echo Form::close(); ?>

         <div class="box-body table-responsive">
             <table id="datatable_accounting_capital_report" class="table table-striped table-bordered table-hover nowrap">
                 <thead>
                     <tr>
                         <th>No</th>
                         <th>Date</th>
                         <th>Payment Method</th>
                         <th>Reference</th>
                         <th>User Approve</th>
                         <th>User By</th>
                         <th>Description</th>
                         <th>Cash In</th>
                         <th>Cash Out</th>
                     </tr>
                 </thead>
                 <tbody class="tbody">
                 </tbody>
                 <tfoot class="tfoot">
                     <tr>
                         <td colspan="7" class="text-right">Total :</td>
                         <td></td>
                         <td></td>
                     </tr>
                     <tr>
                         <td colspan="7" class="text-right">Balance :</td>
                         <td></td>
                         <td></td>
                     </tr>
                 </tfoot>
             </table>
         </div>
 </div>

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

 <script type="text/javascript" src="<?php echo e(asset('assets/controller/report-cash-on-hand-administrator.js')); ?>"></script>
 <script type="text/javascript">
     function searching() {
         var start_date = $('.start_date').val();
         var end_date = $('.end_date').val();
         var table = '';
         var total_cashIN = 0;
         var total_cashOut = 0;
         $('#datatable_accounting_capital_report').DataTable().destroy();
         var index = $('#datatable_accounting_capital_report').DataTable({
             "lengthMenu": [
                 [20, 25, 50, 100, 200, 500, 1000, 2000, 5000],
                 [20, 25, 50, 100, 200, 500, 1000, 2000, 5000]
             ],
             serverSide: true,
             ordering: false,
             ajax: {
                 type: "POST",
                 url: "<?php echo e(route('report-cash-on-hand.accounting')); ?>",
                 async: false,
                 data: {
                     _token: "<?php echo e(csrf_token()); ?>",
                     start_date: start_date,
                     end_date: end_date
                 }
             },
             dom: 'Blfrtip',
             buttons: [
                 'copyHtml5',
                 'excelHtml5',
                 'csvHtml5',
                 'pdfHtml5'
             ],
             columns: [{
                     data: 'DT_RowIndex',
                     'searchable': false
                 },
                 {
                     data: 'journal_paydate',
                     'name': 'nso007_journal.journal_paydate'
                 },
                 {
                     data: 'acc_name',
                     'name': 'nso007_bank_agency.name'
                 },
                 {
                     data: 'invoice',
                     'name': 'nso007_journal.journal_invoice'
                 },
                 {
                     data: 'user_approve',
                     'searchable': false
                 },
                 {
                     data: 'user_by',
                     'searchable': false
                 },
                 {
                     data: 'des',
                     'name': 'nso007_journal.journal_des'
                 },
                 {
                     data: 'cash_in',
                     'name': 'nso007_journal.journal_debit'
                 },
                 {
                     data: 'cash_out',
                     'name': 'nso007_journal.journal_credit'
                 },
             ],

             "initComplete": function(settings, json) {
                 $('.main-spinner').hide();
             },
             "footerCallback": function(row, data, start, end, display) {
                 var api = this.api(),
                     data;
                 var intVal = function(i) {
                     return typeof i === 'string' ?
                         i.replace(/[\$,]/g, '') * 1 :
                         typeof i === 'number' ?
                         i : 0;
                 };

                 var total_cash_in = api
                     .column(7)
                     .data()
                     .reduce(function(a, b) {
                         return intVal(a) + intVal(b);
                     }, 0);

                 var tatal_cash_out = api
                     .column(8)
                     .data()
                     .reduce(function(a, b) {
                         return intVal(a) + intVal(b);
                     }, 0);

                 var total_balance = (total_cash_in - tatal_cash_out);

                 var numFormat = $.fn.dataTable.render.number('\,', '.', 2, '$ ').display;
                 $(api.column(7).footer()).html(numFormat(total_cash_in));
                 $(api.column(8).footer()).html(numFormat(tatal_cash_out));
                 $('tr:eq(1) td:eq(1)', api.table().footer()).html(numFormat(total_balance));
             },
         });
         index.on('order.dt search.dt', function() {
             index.column(0, {
                 search: 'applied',
                 order: 'applied'
             }).nodes().each(function(cell, i) {
                 cell.innerHTML = i + 1;
             });
         }).draw();
         $.fn.dataTable.ext.errMode = 'throw';
     }
 </script>
 <?php $__env->stopSection(); ?>
<?php echo $__env->make('adminlte::page', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>