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/application/views/admin/driver_settlement/bulk_settlement_list_new.php
<style>
  td.details-control {
    background: url('http://www.datatables.net/examples/resources/details_open.png') no-repeat center center;
    cursor: pointer;
  }

  tr.shown td.details-control {
    background: url('http://www.datatables.net/examples/resources/details_close.png') no-repeat center center;
  }
</style>
<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">Bulk Shift Settlement List</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-4">
                            <div class="form-group">
                              <label>From Date</label>
                              <div class="input-group">
                                <input id="from_dt" name="from_dt" type="text" 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-4">
                            <div class="form-group">
                              <label>To Date</label>
                              <div class="input-group">
                                <input id="to_dt" name="to_dt" type="text" 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-4" style="margin-top:30px;">
                            <div class="form-group">
                              <button type="submit" 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">
                    <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 bktrns_report_table" id="docket_table">
                          <thead>
                            <tr>
                              <th>View</th>
                              <th>SL No.</th>
                              <th>Date</th>
                              <th>Shift Id</th>
                              <th>Driver Name</th>
                              <th>DC</th>
                              <th>Acc. No</th>
                              <th>Amount($)</th>
                              <th>Bank($)</th>
                              <th>Cash($)</th>
                              <th>Credit Card($)</th>

                            </tr>
                          </thead>
                          <tbody id="bulk_settlement_tbody">
                          </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();
    // $('.bktrns_report_table').DataTable({
    //   pageLength: 100,
    //   dom: 'Bfrtip',
    //   buttons: [{
    //       extend: 'excel',
    //       text: 'Download Excel',
    //       className: 'btn btn-outline-primary mr-1',
    //       filename: 'bond_report_' + date,
    //       exportOptions: {
    //         columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    //       }
    //     }
    //     //'copy', 'csv', 'excel', 'pdf', 'print'
    //   ]
    // });

    var from_dt = $('#from_dt').pickadate({
        format: 'dd/mm/yyyy',
        autoclose: true,
        max:new Date()
      }),
      from_dt_picker = from_dt.pickadate('picker');

    var to_dt = $('#to_dt').pickadate({
        format: 'dd/mm/yyyy',
        autoclose: true,
        max:new Date()

      }),
      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'))
    // }

    var current_date = new Date();
    var firstDayPrevMonth = new Date(current_date.getFullYear(), current_date.getMonth() - 2, 1);
    from_dt_picker.set('select', firstDayPrevMonth);
    to_dt_picker.set('select', current_date);

    // 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);
      }
    })

    populateData();

  });
  // $(document).on('click','.pay_btn',function(){



  //})
  $(document).on('click', '#search_btn', function(event) {
    event.preventDefault();
    populateData();

  });

  function populateData() {

    var from_date = $("#from_dt").val();
    var to_date = $("#to_dt").val();
    $.ajax({
      type: "POST",
      url: '<?php echo base_url('admin/DriverSettlement/BulkSettlementReportGenerate') ?>',
      data: {
        from_date: from_date,
        to_date: to_date
      },
      dataType: 'json',
    }).done(function(response) {
      var total_docket_amt = Number(0);
        var child_value = '';
        var sl_no = 0;
        var resultHTML = '';
        var base_url = '<?=base_url()?>';
        if (response.status) {
          $.each(response.bnk_trnf_report_data, function(index, value) {
            child_value = '';
            sl_no = 0;

            $.each(response.driver_settlement_list, function(index1, value1) {
              //console.log(new Date(value1.updated_on));
              //console.log(new Date(value.updated_on));
              if ((new Date(value1.updated_on).getTime() == new Date(value.updated_on).getTime()) && value1.driver_id == value.driver_id) {
                sl_no++;
                child_value += '<tr>';
                child_value += '<td>' + sl_no + '</td>';
                child_value += '<td><a target="_blank" title="Detail/View" href="'+base_url+'admin/DriverSettlement/DriverSettlementDetail/' + value1.dr_settlement_id + '" class="ser_book_btn"><i class="fa fa-eye" aria-hidden="true"></i></a>';
                if (value1.driver_settlement_flag != 1) {
                  child_value += '<a target="_blank" title="Edit" href="'+base_url+'admin/DriverSettlement/DriverSettlementEditView/' + value1.dr_settlement_id + '/edit' + '" class="ser_book_btn"><i class="fa fa-pencil" aria-hidden="true"></i></a>';
                }
                child_value += '</td>';

                child_value += '<td>' + value1.shift_no + '</td>';
                child_value += '<td>' + value1.final_due_amt + '</td>';
                child_value += '</tr>';
              }


            });


            resultHTML += `<tr data-child-value='` + child_value + `'>
                    <td><button type="button" class="btn btn-success btn-sm settlement_details_btn"><i class="fa fa-eye" aria-hidden="true"></i></button></td>
                    <td>` + (Number(index) + Number(1)) + `</td>
                    <td>` + value.latest_update_ts + `</td>
                    <td>` + value.shift_no + `</td>
                    <td>` + value.FULLNAME + `</td>
                    <td>` + value.dc_no + `</td>
                    <td>` + value.account_no + `</td>
                    <td>` + value.total_amount + `</td>
                    <td>` + ((value.bank_transfer_amt_bulk)?value.bank_transfer_amt_bulk:'') + `</td>
                    <td>` + ((value.cash_amt_bulk)?value.cash_amt_bulk:'') + `</td>
                    <td>` + ((value.credit_card_amt_bulk)?value.credit_card_amt_bulk:'') + `</td>
                   
                </tr>`;


          });
        } else {

          resultHTML = '<tr><td colspan="11">No Data Available</td></tr>'
        }

        $("#docket_table").dataTable().fnDestroy(); 
        $("#bulk_settlement_tbody").html(resultHTML);
        var table = $('#docket_table').DataTable();
        // $('#docket_table').on('click', 'td.details-control', function() {
          
        //   var tr = $(this).closest('tr');
        //   var row = table.row(tr);
          

        //   var childRow = tr.next('.child-row');
        //   console.log(childRow);
        //   if (childRow.length) {
        //     // If the child row already exists, toggle its visibility
        //     childRow.toggle();
        //     tr.removeClass('shown');
        // } else {
        //     tr.after(format(tr.data('child-value')));
        //       tr.addClass('shown');

        // }


        //   //   if (row.child.isShown()) {
        //   //     // This row is already open - close it
        //   //     row.child.hide();
        //   //     tr.removeClass('shown');
        //   //   } else {
        //   //     // Open this row
        //   // //     row.child( format(tr.data('child-value')), 'no-padding' ).show();
        //   // // tr.addClass('shown');
        //   // // $('div.slider', row.child()).slideDown();

        //   //     row.child(format(tr.data('child-value'))).show();
        //   //     tr.addClass('shown');
        //   //   }
        // });
        

    })
    .fail(function(response) {

      $.alert({
          type: 'red',
          title: 'Alert!',
          content: 'error',
        });
    })  
}

$(document).on('click','#docket_table .settlement_details_btn',function(){

  $("#bulk_settlement_details_modal_body").html('');
  $("#bulk_settlement_details_modal").modal('show');
  var tr = $(this).closest('tr');
  $("#bulk_settlement_details_modal_body").html(format(tr.data('child-value')));
})




  /* Formatting function for row details - modify as you need */
  function format(value) {
    return '<table width="100%" class="table table-striped table-border child-row"><thead><tr style="background-color:#1db5bd !important;"><th>Sl. No</th><th>Action</th><th>Shift</th><th>Due Amount</th></tr></thead><tbody>' + value + '</tbody></table>';
  }
</script>