

  <h3 class=" py-4  fw-bold">COD SUMMARY</h3>
<!-- div for the wallet summarary  -->
<?php if($this->session->flashdata('message_name')): ?>
      <p  class="py-2 text-success text-center ">
         <?php echo $this->session->flashdata('message_name');?>
      </p>
       <?php endif; ?>
 <div class="container  mb-4 border rounded-2 py-3 px-2 bg-white " id="w-sum">
      
         <div class="row mx-0 justify-content-between ">
            <div class="col-md-3">
             
            </div>
            <div class="col-md-9">

            <caption >
               <div class="row justify-content-end col-12 mx-0">
                   
                      <div class="gap-2 col-lg-6">
                         <div class="d-flex justify-content-end align-items-center gap-2 ">
                            <i class="fa fa-filter text-primary fw-bolder" aria-hidden="true"></i>
                            <label class="fw-bolder">Filter</label>
                            <input type="text" name="daterange" id="daterange" class="form-control w-75 mb-0" value="" placeholder="Select Date" autocomplete="off">
                           <select class="form-control mb-0 text-success fw-bold" id="cod_stsfltr" name="cod_sts"   >
                          <option value=""  >All</option>
                           <option  value ="2" >Pending</option>
                           <option value="1">Collected</option>
                           
                            </select>
                         </div>
                         
                      </div>
                      
                      <div class="d-flex gap-1 col-md-6 px-0"> 
                         <input type="text" name="search_filter" id="search_filter" class="form-control  mb-0" value="" placeholder="Search Here" autocomplete="off">
                         <button class="btn btn-primary searchBtn">Search</button>
                         <a href="javascript:void(0)" class="btn btn-warning text-white" 
                         onclick="resetfilter()">ResetAll</a>   
                      </div>
                   
              </div>
            </caption>


                
            </div>
        </div><br>
         <!-- ======table==== -->
         <div class="table-responsive">
            <table class="table align-center table-hover " id="add-table" style="width:100% !important">
            </table>
              
        </div>
     </div>


     <script>
   /*****************start for admin***************/
 
   $('#daterange').daterangepicker({
       locale: {
       format: 'DD/MM/YYYY'
       },
       maxDate: new Date(),
       
   });
   
    $('input[name="daterange"]').val('');
    loadData();
   function loadData()
   {

       var searchvalue = $('#search_filter').val();
       var se = $('#cod_stsfltr').val();
      
       
       var table = 'add-table' ;
        $('#'+table).DataTable({
         "ordering": false,
       'order': [[0, 'desc']], 
       'retrieve': true,
        'processing': true,
        'serverSide': true,
        'searching': false,
        //'serverMethod': 'post',
        'ajax': {
         'url':'<?php echo base_url();?>index.php/Admin/all_delivery_cod_summary',
          "type": "POST",
          "data": {
       		"daterange": $('#daterange').val(),       		
            'searchvalue':searchvalue,
            "sts_fltr" : se  
       	}
        },
        'columns': [
            { title:'S.No',data: 'id' },
            
            { title:' Date/Time',data: 'dl_date' },
            { title:'Booking Id',data: 'book_id' },  
             { title:'Driver  ID',data: 'user_id' },  
             { title:'Driver  Name',data: 'd_name' }, 
             { title:'Amount',data: 'amount' },  
               
            
            { title:'Status',data: 'status' },
                { title:'Action',data: 'act' },      
            
            
          
           
        ]
       });
       
       }
       
       $('body').on('click','.applyBtn',function(){
       $('#add-table').DataTable().destroy();
       loadData();
       });

       $('body').on('click','.searchBtn',function(){
         $('#add-table').DataTable().destroy();
         loadData();
         });

        $('body').on('change','#cod_stsfltr',function(){
       	$('#add-table').DataTable().destroy();
       	loadData();
   });
       $('body').on('click','.cancelBtn',function(){
            $('#daterange').val('');
            $('#daterange').daterangepicker({
       		locale: {
       			format: 'DD/MM/YYYY'
       		 },
       		 maxDate: new Date(),
            });
           
       
       	$('#add-table').DataTable().destroy();
       	loadData();
       });
   
       function resetfilter()
      {
            $('input[name="daterange"]').val('');
            $('input[name="search_filter"]').val('');
             $('#add-table').DataTable().destroy();
           loadData();
      }
   
</script>