  <?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="#">Sale and Payment Summary</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>Sale and Payment Summary</h3>
           </div>
         </div>
       </div>
     </div>
   </div>
   <form action="<?php echo e(url('realty/report-payment-client-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>Item Name</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-6 col-md-6 ">
          <div class="form-group">
            <strong>Client</strong>
            <?php echo Form::select('client_id[]', $clients, null, ['class' => 'form-control select2 clients','multiple']); ?>

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

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

          </div>
        </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>
     <?php echo Form::close(); ?>

     <div class="box-body table-responsive">
       <table id="datatable_payment_client_report" class="table table-striped table-bordered table-hover nowrap">
         <thead>
           <tr>
             <th>No</th>
             <th>Client Name</th>
             <th>Project</th>
             <th>Category</th>
             <th>Item</th>
             <th>Sale Cost</th>
             <th>Discount</th>
             <th>Sell Price</th>
             <th>Deposit Amount</th>
             <th>Received Payment Loan</th>
             <th>Payment Due</th>
             <th>Date Transfer House</th>
             <th>Other</th>
           </tr>
         </thead>
         <tbody class="tbody"></tbody>
         <tfoot>
           <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
             <td class="text-right">Total :</td>
             <td></td>
             <td></td>
             <td></td>
             <td></td>
             <td></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-client-administrator.js')); ?>"></script>
 <script type="text/javascript">
   function searching() {
     $('#datatable_payment_client_report').DataTable().destroy();
     var project = $('.projects').val();
     var category = $('.categories').val();
     var client = $('.clients').val();
     var item_name = $('.item_name').val();
     var index = $('#datatable_payment_client_report').DataTable({
       "lengthMenu": [
         [20, 25, 50, 100, 500],
         [20, 25, 50, 100, 500]
       ],
       serverSide: true,
       "autoWidth": false,
       dom: 'Blfrtip',
       buttons: [
         'copyHtml5',
         {
              extend: 'excel',
              footer: true
          },
       ],
       ajax: {
         type: "POST",
         url: "<?php echo e(route('report-payment-client')); ?>",
         data: {
           _token: "<?php echo e(csrf_token()); ?>",
           project_id: project,
           category_id: category,
           client_id: client,
           item_name: item_name
         }
       },
       columns: [{
           data: 'DT_RowIndex',
           name: 'DT_RowIndex',
           orderable: false,
           searchable: false
         },
         {
           data: 'client_name',
           name: 'nso007_client.client_fullname'
         },
         {
           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: 'sale_amount',
           'className': "text-right",
           name: 'nso007_sale_stock.sale_amount'
         },
         {
           data: 'sale_discount',
           'className': "text-right",
           name: 'nso007_loan.loan_discount'
         },
         {
           data: 'sale_price',
           'className': "text-right",
           searchable: false
         },
         {
           data: 'deposit_amount',
           'className': "text-right",
           name: 'nso007_sale_stock.sale_receive'
         },
         {
           data: 'payment_receive',
           'className': "text-right",
           searchable: false,
         },
         {
           data: 'amount_due',
           'className': "text-right",
           name: 'nso007_loan.loan_amountos'
         }
         ,
         {
           data : 'transfer_ownership_status',searchable: false
         },
      {
        data: 'other',orderable: false, searchable: false
      }
       ],
       "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 column6 = api
           .column(5)
           .data()
           .reduce(function(a, b) {
             return intVal(a) + intVal(b);
           }, 0);

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

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

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

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

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

         var numFormat = $.fn.dataTable.render.number('\,', '.', 2, '$ ').display;
         $(api.column(5).footer()).html(numFormat(column6));
         $(api.column(6).footer()).html(numFormat(column7));
         $(api.column(7).footer()).html(numFormat(column8));
         $(api.column(8).footer()).html(numFormat(column9));
         $(api.column(9).footer()).html(numFormat(column10));
         $(api.column(10).footer()).html(numFormat(column11));
       },
     });
     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(); ?>