HEX
Server: Apache/2.4.41 (Amazon) OpenSSL/1.0.2k-fips PHP/5.6.40
System: Linux ip-172-31-40-18 4.14.146-93.123.amzn1.x86_64 #1 SMP Tue Sep 24 00:45:23 UTC 2019 x86_64
User: apache (48)
PHP: 5.6.40
Disabled: NONE
Upload Files
File: /var/www/html/taxicamera/old/applicationold/views/admin/report/accident/accident_report_list.php
<div class="main-content">
  <div class="content-wrapper">
    <div class="container-fluid">
      <!-- Basic form layout section start -->
      <section id="basic-form-layouts">
      	<div class="row">
      		<div class="col-md-12">
      			<div class="card">
      				<div class="card-header">
      					<div class="page-title-wrap">
      						<h4 class="card-title">Accident Report</h4>      						
      					</div>
      				</div>
      				<div class="card-body">
      					<div class="px-3">
      						<form id="bond_report_form" action="" method="Post" class="form custom_form_style">
                      <div class="form-body">
                        <div class="user_permission_top">
                          <div class="row">
                            <div class="col-md-3">
                              <div class="form-group">
                                <label>Driver Name</label>
                                <select id="driver_id" name="driver_id" class="js-select2" data-show-subtext="true" data-live-search="true">
                                  <option value="">Select Driver</option>
                                  <?php if($driver_list): ?>
                                  <?php   foreach($driver_list as $list): ?>
                                      <option value="<?php echo $list['user_id']; ?>"><?php echo $list['full_name'].' - '.$list['dc_no']; ?></option>
                                  <?php endforeach; ?>
                                  <?php endif; ?>
                                </select>
                              </div>
                            </div>
                            <div class="col-md-3">
                              <div class="form-group">
                                <label>Car Name</label>
                                <select id="car_id" name="car_id" class="js-select2" data-show-subtext="true" data-live-search="true">
                                  <option value="">Select Car</option>                                  
                                </select>
                              </div>
                            </div>
                            <div class="col-md-2">
                              <div class="form-group">
                                <label>From Date</label>
                                <div class="input-group">
                                  <input id="from_dt" name="from_dt" type="text" style="font-size:12px" class="form-control pickadate" value="" placeholder="DD/MM/YYYY" />
                                  <div class="input-group-append">
                                    <span class="input-group-text">
                                      <span class="fa fa-calendar-o"></span>
                                    </span>
                                  </div>
                                </div>
                              </div>
                            </div>
                            <div class="col-md-2">
                              <div class="form-group">
                                <label>To Date</label>
                                <div class="input-group">
                                  <input id="to_dt" name="to_dt" type="text" style="font-size:12px" class="form-control pickadate" value="" placeholder="DD/MM/YYYY" />
                                  <div class="input-group-append">
                                    <span class="input-group-text">
                                      <span class="fa fa-calendar-o"></span>
                                    </span>
                                  </div>
                                </div>
                              </div>
                            </div>
                            <div class="col-md-2" style="margin-top:2.5%">
                              <div class="form-group">
                                <button type="button" class="btn btn-success" id="search_btn">
                                  <i class="fa fa-search" aria-hidden="true"></i> Search
                                </button>
                              </div>
                            </div>                            
                          </div>
                        </div>
                      </div>
                  </form>
                  <div id="report_list">
                      <div class="row">
                        <div class="table-responsive custom_table_area export_table_area">
                          <table class="table table-striped table-bordered export_btn_dt c_table_style accident_report_table">
                            <thead>
                                <tr>
                                  <th>SL No.</th>
                                  <th>Driver DC</th>
                                  <th>Driver Name</th>
                                  <th>Car No</th>
                                  <th>Accident Date</th>
                                  <th>Total Amount</th>
                                  <th>Status</th>
                                  <th>Action</th>
                                </tr>
                            </thead>
                            <tbody>
                              <?php if(!empty($accd_report_data)): ?>
                              <?php   foreach($accd_report_data as $key => $list): 
                                        if($list['middle_name']!=''){
                                          $middle_name  = $list['middle_name'].' ';
                                        }
                                        else{
                                          $middle_name  ='';
                                        }
                              ?>  
                                        <tr>
                                          <td><?php echo $key+1; ?></td>
                                          <td><?php echo $list['dc_no']; ?></td>
                                          <td><?php echo $list['first_name'].' '.$middle_name.$list['last_name']; ?></td>
                                          <td><?php echo $list['car_no']; ?></td>
                                          <td><?php echo date('d/m/Y',strtotime($list['accident_date'])); ?></td>
                                          <td><?php echo $list['total_amt']; ?></td>
                                          <td>
                                            <?php if(empty($list['accident_installment'])): ?>
                                                <a href="javascript:void(0);" class="active_txt_btn">Active</a>
                                            <?php else: ?>
                                                <a href="javascript:void(0);" class="setteld_txt_btn">Settled</a>
                                            <?php endif; ?>
                                          </td>
                                          <td class="action_td text-center"><a href="<?php echo base_url().'admin/AccidentReport/ReportDetails/'.$list['accident_id']; ?>" class="btn_action edit_icon"><i class="fa fa-eye" aria-hidden="true"></i></a></td>
                                        </tr>
                              <?php   endforeach; ?>                  
                              <?php else: ?>
                                        <tr>
                                          <td colspan="6" style="text-align: center";><h5>No data found</h5></td>                    
                                        </tr>
                              <?php endif; ?>
                            </tbody>
                          </table>
                        </div>
                      </div>
                  </div>
      					</div>                
      				</div>
      			</div>            
      		</div>
      	</div>
      </section>
      <!-- // Basic form layout section end -->      
    </div>
  </div>
</div>
<script>
$(document).ready(function() {
  var now = new Date();
  var date = now.getFullYear() + "-" + now.getMonth() + "-" + now.getDate();  
  $('.accident_report_table').DataTable({
    pageLength: 100,
    dom: 'Bfrtip',
    buttons: [{
        extend: 'excel',        
        text: 'Download Excel',
        className: 'btn btn-outline-primary mr-1',
        filename: 'accident_report_' + date,
        exportOptions: {
                columns: [0,1,2,3,4,5,6]
        }
      }
      //'copy', 'csv', 'excel', 'pdf', 'print'
    ]
  });
  $(".js-select2").select2();
    var from_dt       = $('#from_dt').pickadate({format:'dd/mm/yyyy',autoclose:true}),
    from_dt_picker    = from_dt.pickadate('picker');

    var to_dt         = $('#to_dt').pickadate({format:'dd/mm/yyyy',autoclose:true}),
    to_dt_picker      = to_dt.pickadate('picker');
      
    // Check if there’s a “from” or “to” date to start with.
    // if ( from_dt_picker.get('value') ) {
    //     to_dt_picker.set('min', from_dt_picker.get('select'))
    // }
    // if ( to_dt_picker.get('value') ) {
    //     from_dt_picker.set('max', to_dt_picker.get('select'))
    // }

    // When something is selected, update the “from” and “to” limits.
    from_dt_picker.on('set', function(event) {
    
      if ( event.select ) {
        to_dt_picker.set('min', from_dt_picker.get('select'));    
      }
      else if ( 'clear' in event ) {
        to_dt_picker.set('min', false);
      }
    })

    to_dt_picker.on('set', function(event) {
    
      if ( event.select ) {
        from_dt_picker.set('max', to_dt_picker.get('select'));    
      }
      else if ( 'clear' in event ) {
        from_dt_picker.set('max', false);
      }
    })
});
$(document).on('change','#driver_id',function(event){
    var driver_id   = $("#driver_id").val();
    $.ajax({
        type: "POST",
        url: '<?php echo base_url('admin/AccidentReport/GetCarList')?>',
        data:{driver_id : driver_id},
        dataType:'json',
        success: function(response){            
          if(response != 'Blank')
          {
            $('#car_id').find('option').remove().end();
            $("<option></option>", {value: '', text: 'Select Car'}).appendTo('#car_id');
            $.each( response, function( key, value ) {
              var name = response[key].car_no;
               var carid = response[key].car_id;         
              $("<option></option>", {value: carid, text: name}).appendTo('#car_id');
            });
          }
          else{
            $('#car_id').find('option').remove().end();
            $("<option></option>", {value: '', text: 'Select car'}).appendTo('#car_id');
          }      
        },
        error:function(response){
          alert("error");
        }
    });
});

$(document).on('click','#search_btn',function(event){
    event.preventDefault();
    var driver_id   = $("#driver_id").val();
    var car_id      = $("#car_id").val();
    var from_date   = $("#from_dt").val();
    var to_date     = $("#to_dt").val();
    var cnt =0;
    if(driver_id == ""){
      alert("Please select driver.");
      cnt++;
    }
    else{
      //nothing to do
    }
    if(car_id == ""){
      alert("Please select Car.");
      cnt++;
    }
    else{
      //nothing to do
    }
    if(from_date == ""){
      alert("Please select  from date.");
      cnt++;
    }
    else{
      //nothing to do
    }
    if(to_date == ""){
      alert("Please select  to date.");
      cnt++;
    }
    else{
      //nothing to do
    }
    if(cnt == 0){
      $.ajax({
          type: "POST",
          url: '<?php echo base_url('admin/AccidentReport/AccidentReportGenerate')?>',
          data:{driver_id : driver_id,car_id : car_id,from_date:from_date,to_date:to_date},
          dataType:'JSON',
          success: function(response){  
            //alert(response);          
            $("#report_list").html(response['html']);
            var now = new Date();
            var date = now.getFullYear() + "-" + now.getMonth() + "-" + now.getDate();  
            $('.accident_report_table').DataTable({
              pageLength: 100,
              dom: 'Bfrtip',
              buttons: [{
                  extend: 'excel',
                  text: 'Download Excel',
                  className: 'btn btn-outline-primary mr-1',
                  filename: 'accident_report_' + date,
                  exportOptions: {
                    columns: [0,1,2,3,4,5,6]
                  }
                }
                //'copy', 'csv', 'excel', 'pdf', 'print'
              ]
            });      
          },
          error:function(response){
            alert("error");
          }
      });
    }
});
</script>