 <?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="#">Repport Deposit</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 Deposit</h3>
           </div>
         </div>

       </div>
     </div>
   </div>
   <form action="<?php echo e(route('deposit_report.print_report_deposit')); ?>" 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_item_deposit" class="table table-striped table-bordered table-hover nowrap" width="100%">
         <thead>
           <tr>
           <th>No</th>
            <th>Date</th>
            <th>Sale Date</th>
            <th>Name</th>
            <th>Phone</th>
            <th>Project Name</th>
            <th>Category</th>
            <th>Item Code</th>
            <th>Contract Date</th>
            <th>Payment Policy</th>
            <th>Total Sale Price</th>
            <th>Sale Discount</th>
            <th>Sale Amount</th>
            <th>Deposit Amount</th>
           </tr>
         </thead>
         <tbody class="tbody"></tbody>
         <tfoot class="tfoot">
           <tr>
             <td colspan="10" class="text-right">Total :</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">
     $(document).ready(function() {
         $('#main-spinner').show();
           $('#datatable_item_deposit').DataTable({
             ordering: false,
             "serverSide": true,
             ajax: {
               url:"<?php echo e(route('deposit_report.get_data_report_deposit')); ?>",
               type:"GET",
               data:function(d){
                d.start_date = $(".start_date").val();
                d.end_date = $(".end_date").val();
                d.phone = $(".phone").val();
                d.project = $(".projects").val();
                d.category = $(".categories").val();
                d.client = $(".clients").val();
               }
             },
             columns: [
                  {
                     data: 'DT_RowIndex'
                 },
                 {
                     data: 'deposit_date'
                 },
                 {
                     data: 'sale_date'
                 },
                 {
                     data: 'client_fullname'
                 },
                 {
                     data: 'client_phone1'
                 },
                 {
                     data: 'project_name'
                 },
                 {
                     data: 'category_name',
                     width: '5px'
                 },
                 {
                     data: 'item_name'
                 },
                 {
                     data: 'contract_date'
                 },
                 {
                    data:'payment_policy'
                 },
                 {
                     data: 'item_price'
                 },
                 {
                    data: 'sale_discount'
                 },
                 {
                     data: 'sale_amount'
                 },
                 {
                     data: 'sale_receive'
                 }
             ],

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

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

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

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

         var numFormat = $.fn.dataTable.render.number('\,', '.', 2, '$ ').display;
         $(api.column(10).footer()).html(numFormat(total_sale));
         $(api.column(11).footer()).html(numFormat(total_discount));
         $(api.column(12).footer()).html(numFormat(total_sale_amount));
         $(api.column(13).footer()).html(numFormat(total_deposit_amount));
       },
         });
     });
     function searching(){
      $('#datatable_item_deposit').DataTable().draw(true);
     }
 </script>
 <?php $__env->stopSection(); ?>
<?php echo $__env->make('adminlte::page', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>