  <?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 Operation</a></li>
       <li><a href="#">All Payment To Collect</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>All Payment To Collect</h3>
           </div>
         </div>

       </div>
     </div>
   </div>
   <form action="<?php echo e(url('realty/report-all-payment-to-collection-print')); ?>" method="POST">
     <?php echo csrf_field(); ?>
     <div class="form-search">
       <div class="row">
         <div class="col-xs-12 col-sm-4 col-md-4 ">
           <div class="form-group">
             <strong>Form Date</strong>
             <?php echo Form::text('start_date', null, array('placeholder' => 'Start Date','class' => 'form-control date_picker start_date','autocomplete' => 'off')); ?>

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

           </div>
         </div>
         <div class="col-xs-12 col-sm-4 col-md-4 ">
           <div class="form-group">
             <strong>Phone</strong>
             <?php echo Form::text('phone', null, array('placeholder' => 'phone','class' => 'form-control phone','autocomplete' => 'off')); ?>

           </div>
         </div>
         <div class="col-xs-12 col-sm-4 col-md-4 ">
           <div class="form-group">
             <strong>Project</strong>
             <?php echo Form::select('projects', $projects, null, ['class' => 'form-control select2 projects']); ?>

           </div>
         </div>
         <div class="col-xs-12 col-sm-4 col-md-4 ">
           <div class="form-group">
             <strong>Category</strong>
             <?php echo Form::select('categories', $categories, null, ['class' => 'form-control select2 categories']); ?>

           </div>
         </div>
         <div class="col-xs-12 col-sm-4 col-md-4 ">
           <div class="form-group">
             <strong>Client</strong>
             <?php echo Form::select('clients', $clients, null, ['class' => 'form-control select2 clients']); ?>

           </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
           <button type="submit" class="button_primary btn-sm search"><span class="fa fa-print"> Print</span></button>
         </div>
       </div>
     </div>
     <?php echo Form::close(); ?>

     <div class="box-body table-responsive">
       <table id="datatable_payment_collection_report" class="table table-striped table-bordered table-hover nowrap">
         <thead>
           <tr>
             <th>No</th>
             <th>Due Date</th>
             <th>Project</th>
             <th>Category</th>
             <th>Item</th>
             <th>Client Name</th>
             <th>Contact</th>
             <th>Principle</th>
             <th>Interest</th>
             <th>Total</th>
           </tr>
         </thead>
         <tbody class="tbody"></tbody>
         <tfoot class="tfoot">
           <tr>
             <td colspan="7" class="text-right">Total :</td>
             <td></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/all-payment-to-collection-administrator.js')); ?>"></script>
 <script type="text/javascript">
   function searching() {
     $('#datatable_payment_collection_report').DataTable().destroy();
     var start_date = $('.start_date').val();
     var end_date = $('.end_date').val();
     var project_id = $('.projects').val();
     var category_id = $('.categories').val();
     var client_id = $('.clients').val();
     var phone = $('.phone').val();
     var index = $('#datatable_payment_collection_report').DataTable({
       "lengthMenu": [
         [20, 25, 50, 100, 500],
         [20, 25, 50, 100, 500]
       ],
       dom: 'Blfrtip',
       buttons: [
         'copyHtml5',
         'excelHtml5',
         'csvHtml5',
         'pdfHtml5'
       ],
       serverSide: true,
       ajax: {
         type: "POST",
         url: "<?php echo e(route('report-all-payment-to-collection')); ?>",
         data: {
           _token: "<?php echo e(csrf_token()); ?>",
           start_date: start_date,
           end_date: end_date,
           project_id: project_id,
           category_id: category_id,
           client_id: client_id,
           phone: phone
         }
       },
       columns: [{
           data: 'DT_RowIndex',
           orderable: false,
           searchable: false
         },
         {
           data: 'due_date',
           name: 'nso007_loan_process.loanprocess_datepayment'
         },
         {
           data: 'project_name',
           name: 'nso007_project_stock.project_name'
         },
         {
           data: 'category_name',
           name: 'nso007_category_stock.category_name'
         },
         {
           data: 'item_code',
           name: 'nso007_item_stock.item_house'
         },
         {
           data: 'client_name',
           name: 'nso007_client.client_firstname'
         },
         {
           data: 'client_contact',
           name: 'nso007_client.client_phone1'
         },
         {
           data: 'principle',
           name: 'nso007_loan_process.loanprocess_principle'
         },
         {
           data: 'interest',
           name: 'nso007_loan_process.loanprocess_interest'
         },
         {
           data: 'payment',
           name: 'nso007_loan_process.loanprocess_owe'
         },

       ],
       "initComplete": function(settings, json) {
         $('.main-spinner').hide();
       },


       "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 principle_Total = api
           .column(7)
           .data()
           .reduce(function(a, b) {
             return intVal(a) + intVal(b);
           }, 0);

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

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

         var numFormat = $.fn.dataTable.render.number('\,', '.', 2, '$ ').display;
         $(api.column(7).footer()).html(numFormat(principle_Total));
         $(api.column(8).footer()).html(numFormat(interest_Total));
         $(api.column(9).footer()).html(numFormat(payment_Total));
       },
     });
     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(); ?>