  <?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="#">Reports</a></li>
       <li><a href="#">Report Operation</a></li>
       <li><a href="#">Installment Completed</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>Installment Completed</h3>
           </div>
         </div>
       </div>
     </div>
   </div>
   <form action="<?php echo e(url('realty/report-payment-completed-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>Item Code</strong>
             <?php echo Form::text('item_name', null, array('placeholder' => 'item code','class' => 'form-control item_name','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','multiple']); ?>

           </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','multiple']); ?>

           </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','multiple']); ?>

           </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>
           <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_completed_report" class="table table-striped table-bordered table-hover nowrap">
         <thead>
           <tr>
             <th>No</th>
             <th>End Date</th>
             <th>Project</th>
             <th>Category</th>
             <th>Item</th>
             <th>Client Name</th>
             <th>Contact</th>
             <th>Sale Cost</th>
             <th>Sale Discount</th>
             <th>Sale Price</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/payment-completed-administrator.js')); ?>"></script>
 <script type="text/javascript">
   function searching() {
     var start_date = $('.start_date').val();
     var end_date = $('.end_date').val();
     var projects = $('.projects').val();
     var categories = $('.categories').val();
     var clients = $('.clients').val();
     var item_name = $('.item_name').val();
     $('#datatable_payment_completed_report').DataTable().destroy();
     var index = $('#datatable_payment_completed_report').DataTable({
       "lengthMenu": [
         [20, 25, 50, 100, 500],
         [20, 25, 50, 100, 500]
       ],
       ordering: false,
       serverSide: true,
       "scrollY":"600px",
       "scrollCollapse": true,
       dom: 'Blfrtip',
       buttons: [
         'copyHtml5',
         'excelHtml5',
         'csvHtml5',
         'pdfHtml5'
       ],
       ajax: {
         type: 'POST',
         url: "<?php echo e(route('report-payment-completed')); ?>",
         data: {
           _token: "<?php echo e(csrf_token()); ?>",
           start_date: start_date,
           end_date: end_date,
           project: projects,
           category: categories,
           client: clients,
           item_name: item_name
         }
       },
       columns: [{
           data: 'DT_RowIndex',
           'searchable': false
         },
         {
           data: 'end_date'
         },
         {
           data: 'project_name'
         },
         {
           data: 'category_name'
         },
         {
           data: 'item_code'
         },
         {
           data: 'client_name'
         },
         {
           data: 'client_contact'
         },
         {
           data: 'sale_cost'
         },
         {
           data: 'sale_discount'
         },
         {
           data: 'sale_price',
           'searchable': false
         }
       ],
       "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(); ?>