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/application/views/admin/driver_settlement/driver_settlement_edit.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">Driver Settlement Details</h4>
                </div>
                <!--<p class="mb-0">This is the most basic and cost estimation form is the default position.</p>-->
              </div>
              <div class="card-body">
                <div class="px-3">
                  <?php if (!empty($driver_settlement_data)) : $dr_settlement_id = $driver_settlement_data['dr_settlement_id'];
                  else : $dr_settlement_id = "";
                  endif; ?>
                  <form id="update_driver_settle_frm" class="form custom_form_style" action="<?php echo base_url() . 'admin/DriverSettlement/EditDriversettlement/' . $dr_settlement_id; ?>" method="post">
                    <input type="hidden" name="dr_settlement_id" id="dr_settlement_id" value="<?php echo $dr_settlement_id; ?>">
                    <div class="daily_stl_top_box">
                      <div class="filter_area">
                        <div class="row clearfix">
                          <div class="col-sm-6">
                            <div class="form-group" style="margin-bottom: 0;"></div>
                          </div>
                          <div class="col-sm-12">
                            <div id="drive_data_div" class="table_row repeat">
                              <?php $name = '';
                              if (!empty($driver_settlement_data) && $driver_settlement_data['first_name']) :
                                if ($driver_settlement_data['middle_name']) :
                                  $middle_name  = '';
                                  $middle_name . ' ';
                                else :
                                  $middle_name  = '';
                                endif;
                                $name = $driver_settlement_data['first_name'] . ' ' . $middle_name . $driver_settlement_data['last_name'];
                              endif; ?>
                              <?php if (!empty($driver_settlement_data['profile_photo'])) : ?>
                                <?php $profile_photo  = $driver_settlement_data['profile_photo']; ?>
                              <?php else : ?>
                                <?php $profile_photo  = 'no_image.jpg'; ?>
                              <?php endif; ?>
                              <img src="<?php echo base_url() . 'public/upload_image/profile_photo/' . $profile_photo; ?>" alt="" width="100px" height="100px" />
                              <h3><?php echo $name; ?></h3>
                              <div class="list_filter_sett">
                                <ul>
                                  <li id="DC"><strong>DC </strong> <?php if (!empty($driver_settlement_data) && !empty($driver_settlement_data['dc_no'])) : echo $driver_settlement_data['dc_no'];
                                                                    endif; ?></li>
                                  <li id="dr_dc_expiry"><strong>DC Exp. Date </strong><?php if (!empty($driver_settlement_data) && !empty($driver_settlement_data['dr_dc_expiry'])) : echo date('d/m/Y', strtotime($driver_settlement_data['dr_dc_expiry']));
                                                                                      endif; ?></li>
                                  <li id="dr_dl_expiry"><strong>DL Exp. Date </strong><?php if (!empty($driver_settlement_data) && !empty($driver_settlement_data['dr_licence_expiry'])) : echo date('d/m/Y', strtotime($driver_settlement_data['dr_licence_expiry']));
                                                                                      endif; ?></li>
                                  <li id="dr_rental_li"><strong>Rental </strong><?php if (!empty($driver_settlement_data) && !empty($driver_settlement_data['dr_rental'])) : echo $driver_settlement_data['dr_rental'];
                                                                                endif; ?></li>
                                </ul>
                              </div>
                            </div>
                            <div class="table_row repeat">
                              <!--<h4 class="cash_summary">Driver Settlement</h4>-->
                              <div class="table-responsive custom_table_area">
                                <table class="table table-striped table-bordered daily_stl_table">
                                  <thead>
                                    <tr>
                                      <th>Shift No.</th>
                                      <th>Car No.</th>
                                      <th>Shift Date</th>
                                      <th>Payout/Payin Amount</th>
                                      <th>Settlement Amount</th>
                                      <th>Due</th>
                                    </tr>
                                  </thead>
                                  <tbody>
                                    <?php if (!empty($driver_settlement_data)) : ?>
                                      <tr>
                                        <td><?php if (!empty($driver_settlement_data['shift_no'])) : echo $driver_settlement_data['shift_no'];
                                              endif; ?></td>
                                        <td><?php if (!empty($driver_settlement_data['car_no'])) : echo $driver_settlement_data['car_no'];
                                              endif; ?></td>
                                        <td><?php if (!empty($driver_settlement_data['shift_dt'])) : echo date('d/m/Y', strtotime($driver_settlement_data['shift_dt']));
                                              endif; ?></td>
                                        <td style="text-align: right;"><?php echo $driver_settlement_data['total_payin_payout']; ?></td>
                                        <td><?php echo $driver_settlement_data['settlement_amt']; ?></td>
                                        <td><?php echo $driver_settlement_data['final_due_amt']; ?></td>
                                      </tr>
                                    <?php endif; ?>
                                  </tbody>
                                </table>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                      <div class="row">
                        <div class="col-sm-12">
                          <div class="col-md-12">
                            <div class="table_row repeat">
                              <h4 class="cash_summary">Driver Settlement</h4>
                              <div class="table-responsive custom_table_area">
                                <table class="table table-striped table-bordered daily_stl_table">
                                  <thead>
                                    <tr>
                                      <th>Start Reading</th>
                                      <th>Name of Reading</th>
                                      <th>Finish Reading</th>
                                    </tr>
                                  </thead>
                                  <tbody>
                                    <tr class="total_extra_tr">
                                      <td>
                                        <?php if ($this->role_id != 1) : ?>
                                          <div id="total_extra_start_div" class="total_extra_div"><?php if (!empty($driver_settlement_data)) : echo $driver_settlement_data['total_extra_start'];
                                                                                                    endif; ?></div>
                                        <?php else : ?>
                                          <input type="text" name="total_extra_start" id="total_extra_start" style="width:65%" value="<?php if (!empty($driver_settlement_data)) : echo $driver_settlement_data['total_extra_start'];
                                                                                                                                        endif; ?>">
                                        <?php endif; ?>
                                      </td>
                                      <td>Total + Extra</td>
                                      <td>
                                        <?php if ($this->role_id != 1) : ?>
                                          <div id="total_extra_end_div" class="total_extra_div"><?php if (!empty($driver_settlement_data)) : echo $driver_settlement_data['total_extra_end'];
                                                                                                  endif; ?></div>
                                        <?php else : ?>
                                          <input type="text" name="total_extra_end" style="width:65%" id="total_extra_end" value="<?php if (!empty($driver_settlement_data)) : echo $driver_settlement_data['total_extra_end'];
                                                                                                                                    endif; ?>">
                                        <?php endif; ?>
                                      </td>
                                    </tr>
                                    <tr class="paid_km_tr">
                                      <td>
                                        <?php if ($this->role_id != 1) : ?>
                                          <div id="paid_km_start_div" class="paid_km_div"><?php if (!empty($driver_settlement_data)) : echo $driver_settlement_data['paid_km_start'];
                                                                                            endif; ?></div>
                                        <?php else : ?>
                                          <input type="text" style="width:65%" name="paid_km_start" id="paid_km_start" value="<?php if (!empty($driver_settlement_data)) : echo $driver_settlement_data['paid_km_start'];
                                                                                                                                endif; ?>">
                                        <?php endif; ?>
                                      </td>
                                      <td>Paid KM</td>
                                      <td>
                                        <?php if ($this->role_id != 1) : ?>
                                          <div id="paid_km_end_div" class="paid_km_div"><?php if (!empty($driver_settlement_data)) : echo $driver_settlement_data['paid_km_end'];
                                                                                          endif; ?></div>
                                        <?php else : ?>
                                          <input type="text" style="width:65%" name="paid_km_end" id="paid_km_end" value="<?php if (!empty($driver_settlement_data)) : echo $driver_settlement_data['paid_km_end'];
                                                                                                                            endif; ?>">
                                        <?php endif; ?>
                                      </td>
                                    </tr>
                                    <tr class="total_km_tr">
                                      <td>
                                        <?php if ($this->role_id != 1) : ?>
                                          <div id="total_km_start_div" class="total_km_div"><?php if (!empty($driver_settlement_data)) : echo $driver_settlement_data['total_km_start'];
                                                                                              endif; ?></div>
                                        <?php else : ?>
                                          <input type="text" style="width:65%" name="total_km_start" id="total_km_start" value="<?php if (!empty($driver_settlement_data)) : echo $driver_settlement_data['total_km_start'];
                                                                                                                                  endif; ?>">
                                        <?php endif; ?>
                                      </td>
                                      <td>Total KM</td>
                                      <td>
                                        <?php if ($this->role_id != 1) : ?>
                                          <div id="total_km_end_div" class="total_km_div"><?php if (!empty($driver_settlement_data)) : echo $driver_settlement_data['total_km_end'];
                                                                                            endif; ?></div>
                                        <?php else : ?>
                                          <input type="text" style="width:65%" name="total_km_end" id="total_km_end" value="<?php if (!empty($driver_settlement_data)) : echo $driver_settlement_data['total_km_end'];
                                                                                                                              endif; ?>">
                                        <?php endif; ?>
                                      </td>
                                    </tr>
                                    <tr class="extra_tr">
                                      <td>
                                        <?php if ($this->role_id != 1) : ?>
                                          <div id="extra_start_div" class="extra_div"><?php if (!empty($driver_settlement_data)) : echo $driver_settlement_data['extra_start'];
                                                                                        endif; ?></div>
                                        <?php else : ?>
                                          <input type="text" style="width:65%" name="extra_start" id="extra_start" value="<?php if (!empty($driver_settlement_data)) : echo $driver_settlement_data['extra_start'];
                                                                                                                            endif; ?>">
                                        <?php endif; ?>
                                      </td>
                                      <td>Extra</td>
                                      <td>
                                        <?php if ($this->role_id != 1) : ?>
                                          <div id="extra_end_div" class="extra_div"><?php if (!empty($driver_settlement_data)) : echo $driver_settlement_data['extra_end'];
                                                                                      endif; ?></div>
                                        <?php else : ?>
                                          <input type="text" style="width:65%" name="extra_end" id="extra_end" value="<?php if (!empty($driver_settlement_data)) : echo $driver_settlement_data['extra_end'];
                                                                                                                        endif; ?>">
                                        <?php endif; ?>
                                      </td>
                                    </tr>
                                    <tr class="no_of_hiring_tr">
                                      <td>
                                        <?php if ($this->role_id != 1) : ?>
                                          <div id="no_of_hiring_start_div" class="no_of_hiring_div"><?php if (!empty($driver_settlement_data)) : echo $driver_settlement_data['no_of_hiring_start'];
                                                                                                      endif; ?></div>
                                        <?php else : ?>
                                          <input type="text" style="width:65%" name="no_of_hiring_start" id="no_of_hiring_start" value="<?php if (!empty($driver_settlement_data)) : echo $driver_settlement_data['no_of_hiring_start'];
                                                                                                                                          else : '0.00';
                                                                                                                                          endif; ?>">
                                        <?php endif; ?>
                                      </td>
                                      <td>Number of Hiring</td>
                                      <td>
                                        <?php if ($this->role_id != 1) : ?>
                                          <div id="no_of_hiring_end_div" class="no_of_hiring_div"><?php if (!empty($driver_settlement_data)) : echo $driver_settlement_data['no_of_hiring_end'];
                                                                                                    endif; ?></div>
                                        <?php else : ?>
                                          <input type="text" style="width:65%" name="no_of_hiring_end" id="no_of_hiring_end" value="<?php if (!empty($driver_settlement_data)) : echo $driver_settlement_data['no_of_hiring_end'];
                                                                                                                                      endif; ?>">
                                        <?php endif; ?>
                                      </td>
                                    </tr>
                                    <tr class="speedo_reading_tr">
                                      <td>
                                        <?php if ($this->role_id != 1) : ?>
                                          <div id="speedo_reading_start_div" class="speedo_reading_div"><?php if (!empty($driver_settlement_data)) : echo $driver_settlement_data['speedo_reading_start'];
                                                                                                          endif; ?></div>
                                        <?php else : ?>
                                          <input type="text" style="width:65%" name="speedo_reading_start" id="speedo_reading_start" value="<?php if (!empty($driver_settlement_data)) : echo $driver_settlement_data['speedo_reading_start'];
                                                                                                                                              endif; ?>">
                                        <?php endif; ?>
                                      </td>
                                      <td>Speedo Reading</td>
                                      <td>
                                        <?php if ($this->role_id != 1) : ?>
                                          <div id="speedo_reading_end_div" class="speedo_reading_div"><?php if (!empty($driver_settlement_data)) : echo $driver_settlement_data['speedo_reading_end'];
                                                                                                        endif; ?></div>
                                        <?php else : ?>
                                          <input type="text" style="width:65%" name="speedo_reading_end" id="speedo_reading_end" value="<?php if (!empty($driver_settlement_data)) : echo $driver_settlement_data['speedo_reading_end'];
                                                                                                                                          endif; ?>">
                                        <?php endif; ?>
                                      </td>
                                    </tr>
                                  </tbody>
                                </table>
                              </div>
                            </div>
                            <div class="table_row repeat">
                              <h4 class="cash_summary">Dockets Details</h4>
                              <div class="table-responsive custom_table_area">
                                <table class="table table-striped table-bordered daily_stl_table">
                                  <thead>
                                    <tr>
                                      <th>Dockets Name</th>
                                      <th>Photo</th>
                                      <th>Amount($)</th>
                                    </tr>
                                  </thead>
                                  <tbody>
                                    <?php if (!empty($settlement_dockets_data)) : ?>
                                      <?php foreach ($settlement_dockets_data as $dockets) : ?>
                                        <tr class="driver_docket_tr">
                                          <td><?php echo $dockets['docket_name']; ?></td>
                                          <td>
                                            <div class="ds_td_img">
                                              <a href="<?php echo base_url() . 'public/upload_image/payin_images/' . $dockets['docket_img']; ?>" data-fancybox data-caption="Driver Picture">
                                                <img src="<?php echo base_url() . 'public/upload_image/payin_images/' . $dockets['docket_img']; ?>" alt="<?php echo $dockets['docket_name']; ?>" width="50px" height="50px" />
                                              </a>
                                              <!--<input class="input_file" type="hidden" name="docket_img" style="width:100px">-->
                                            </div>
                                          </td>
                                          <td class="td_amount_left driver_docket_price" align="left">
                                            <?php if ($this->role_id != 1) : ?>
                                              <div class="docket_price_div"><?php echo $dockets['docket_amount']; ?></div>
                                            <?php else : ?>
                                              <input class="docket_pr_input" type="text" name="docket_price[<?php echo $dockets['dr_settlement_docket_id']; ?>]" value="<?php echo $dockets['docket_amount']; ?>" style="width:60px">
                                            <?php endif; ?>
                                          </td>
                                        </tr>
                                      <?php endforeach; ?>
                                    <?php else : ?>
                                      <tr>
                                        <td colspan="4">No data found</td>
                                      </tr>
                                    <?php endif; ?>
                                  </tbody>
                                </table>
                              </div>
                            </div>
                            <div class="table_row repeat">
                              <h4 class="cash_summary">Expense Details</h4>
                              <div class="table-responsive custom_table_area">
                                <table class="table table-striped table-bordered daily_stl_table">
                                  <thead>
                                    <tr>
                                      <th>Expense Name</th>
                                      <th>Photo</th>
                                      <th>Amount($)</th>
                                    </tr>
                                  </thead>
                                  <tbody>
                                    <?php if (!empty($settlement_expense_data)) : ?>
                                      <?php foreach ($settlement_expense_data as $expense) : ?>
                                        <tr class="driver_expenses_tr">
                                          <td><?php echo $expense['expense_name']; ?></td>
                                          <td>
                                            <div class="ds_td_img">
                                              <a href="<?php echo base_url() . 'public/upload_image/payin_images/' . $expense['expense_img']; ?>" data-fancybox data-caption="Driver Picture">
                                                <img src="<?php echo base_url() . 'public/upload_image/payin_images/' . $expense['expense_img']; ?>" alt="<?php echo $expense['expense_name']; ?>" width="50px" height="50px" />
                                              </a>
                                            </div>
                                          </td>
                                          <td class="td_amount_left expense_price_td">
                                            <?php if ($this->role_id != 1) : ?>
                                              <div class="expense_price_div"><?php echo $expense['expense_amount']; ?></div>
                                            <?php else : ?>
                                              <input type="text" class="expense_price_inp" name="expense_price[<?php echo $expense['dr_settlement_expense_id']; ?>]" value="<?php echo $expense['expense_amount']; ?>">
                                            <?php endif; ?>
                                          </td>
                                        </tr>
                                      <?php endforeach; ?>
                                    <?php else : ?>
                                      <tr>
                                        <td colspan="4">No data found</td>
                                      </tr>
                                    <?php endif; ?>
                                  </tbody>
                                </table>
                              </div>
                            </div>
                            <div class="table_row repeat">
                              <!--<h4 class="cash_summary">Fuel Details</h4>-->
                              <div class="table-responsive custom_table_area">
                                <table class="table table-striped table-bordered daily_stl_table">
                                  <thead>
                                    <tr>
                                      <th>Title</th>
                                      <th>Commission Based</th>
                                      <th>Rental Based</th>
                                    </tr>
                                  </thead>

                                  <tbody>
                                    <tr>
                                      <td style="color: #000;font-weight: 500; width: 50%;">Docket Total</td>
                                      <td class="td_amount_right">
                                        <div class="input-group">
                                          <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">$</span>
                                          </div>
                                          <input type="text" class="form-control" name="total_dockets" id="total_dockets" aria-label="Username" aria-describedby="basic-addon1" value="<?php echo $driver_settlement_data['total_docket']; ?>" readonly>
                                        </div>
                                      </td>
                                      <td class="td_amount_right">
                                        <div class="input-group">
                                          <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">$</span>
                                          </div>
                                          <input type="text" class="form-control" id="total_dockets_rental" name="total_dockets_rental" aria-label="Username" aria-describedby="basic-addon1" value="<?php echo $driver_settlement_data['total_docket']; ?>" readonly>
                                        </div>
                                      </td>
                                    </tr>
                                    <tr>
                                      <td style="color: #000;font-weight: 500; width: 50%;">Expense Total</td>
                                      <td class="td_amount_right">
                                        <div class="input-group">
                                          <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">$</span>
                                          </div>
                                          <input type="text" class="form-control" name="total_expense" id="total_expense" aria-label="Username" aria-describedby="basic-addon1" value="<?php echo $driver_settlement_data['total_expense']; ?>" readonly>
                                        </div>
                                      </td>
                                      <td class="td_amount_right">
                                        <div class="input-group">
                                          <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">$</span>
                                          </div>
                                          <input type="text" class="form-control" id="total_expense" aria-label="Username" aria-describedby="basic-addon1" value="<?= isset($driver_settlement_data['total_expense']) ? $driver_settlement_data['total_expense'] : '' ?>" readonly>
                                        </div>
                                      </td>
                                    </tr>
                                    <tr>
                                      <td style="color: #000;font-weight: 500; width: 50%;">Shift Levy</td>
                                      <td class="td_amount_right">
                                        <div class="input-group">
                                          <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">$</span>
                                          </div>
                                          <input type="text" class="form-control" name="levy_total" id="levy_total" aria-label="" aria-describedby="basic-addon1" value="<?php echo $driver_settlement_data['shift_levy']; ?>" readonly>
                                        </div>
                                      </td>
                                      <td class="td_amount_right">
                                        <div class="input-group">
                                          <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">$</span>
                                          </div>
                                          <input type="text" class="form-control" id="levy_total" aria-label="" aria-describedby="basic-addon1" value="<?php echo $driver_settlement_data['shift_levy']; ?>" readonly>
                                        </div>
                                      </td>
                                    </tr>
                                    <tr>
                                      <td style="color: #000;font-weight: 500; width: 50%;">WHL</td>
                                      <td class="td_amount_right">
                                        <div class="input-group">
                                          <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">$</span>
                                          </div>
                                          <input type="text" class="form-control" name="no_of_whl" id="no_of_whl" aria-label="" aria-describedby="basic-addon1" value="<?php echo $driver_settlement_data['no_of_whl']; ?>" readonly>
                                        </div>
                                      </td>
                                      <td class="td_amount_right">
                                        <div class="input-group">
                                          <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">$</span>
                                          </div>
                                          <input type="text" class="form-control" id="no_of_whl" aria-label="" aria-describedby="basic-addon1" value="<?php echo $driver_settlement_data['no_of_whl']; ?>" readonly>
                                        </div>
                                      </td>
                                    </tr>
                                  </tbody>
                                </table>
                              </div>
                            </div>
                            <div class="table_row repeat">
                              <!--<h4 class="cash_summary">Fuel Details</h4>-->
                              <div class="table-responsive custom_table_area">
                                <table class="table table-striped table-bordered daily_stl_table">
                                  <thead>
                                    <tr>
                                      <th>Title</th>
                                      <th>Commission Based</th>
                                      <th>Rental Based</th>
                                    </tr>
                                  </thead>
                                  <tbody>
                                    <tr>
                                      <td style="color: #000;font-weight: 500; width: 50%;">Accident Installment</td>
                                      <td class="td_amount_right">
                                        <div class="input-group">
                                          <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">$</span>
                                          </div>
                                          <input type="text" class="form-control" name="accident_installment" id="accident_installment" aria-label="Username" aria-describedby="basic-addon1" value="<?php echo $driver_settlement_data['accident_installment']; ?>" <?php if ($this->role_id != 1) : echo "readonly";
                                                                                                                                                                                                                                                                      endif; ?>>
                                        </div>
                                      </td>
                                      <td class="td_amount_right">
                                        <div class="input-group">
                                          <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">$</span>
                                          </div>
                                          <input type="text" class="form-control calculate_due_amt" data-rental_commission="rental" id="accident_installment_rental" aria-label="Username" aria-describedby="basic-addon1" value="<?php echo $driver_settlement_data['accident_installment']; ?>">
                                        </div>

                                      </td>
                                    </tr>
                                    <tr>
                                      <td style="color: #000;font-weight: 500; width: 50%;">Bond Installment</td>
                                      <td class="td_amount_right">
                                        <div class="input-group">
                                          <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">$</span>
                                          </div>
                                          <input type="text" class="form-control" name="bond_total" id="bond_total" aria-label="Username" aria-describedby="basic-addon1" value="<?php echo $driver_settlement_data['bond_installment']; ?>" <?php if ($this->role_id != 1) : echo "readonly";
                                                                                                                                                                                                                                              endif; ?>>
                                        </div>
                                      </td>
                                      <td class="td_amount_right">
                                        <div class="input-group">
                                          <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">$</span>
                                          </div>
                                          <input type="text" class="form-control calculate_due_amt" data-rental_commission="rental" id="bond_total_rental" aria-label="Username" aria-describedby="basic-addon1" value="<?= !empty($driver_settlement_data['dr_rental']) ? (isset($driver_settlement_data['bond_installment']) ? $driver_settlement_data['bond_installment'] : '0.00') : '0.00'; ?>">
                                        </div>
                                      </td>
                                    </tr>
                                    <tr>
                                      <td style="color: #000;font-weight: 500; width: 50%;">Others</td>
                                      <td class="td_amount_right">
                                        <div class="input-group">
                                          <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">$</span>
                                          </div>
                                          <input type="text" class="form-control" name="other" id="other" aria-label="" aria-describedby="basic-addon1" value="<?php echo $driver_settlement_data['other']; ?>" <?php if ($this->role_id != 1) : echo "readonly";
                                                                                                                                                                                                                endif; ?>>
                                        </div>
                                      </td>
                                      <td class="td_amount_right">
                                        <div class="input-group">
                                          <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">$</span>
                                          </div>
                                          <input type="text" class="form-control calculate_due_amt" id="other_rental" aria-label="" aria-describedby="basic-addon1" data-rental_commission="rental" value="<?php echo $driver_settlement_data['other']; ?>">
                                        </div>
                                      </td>
                                    </tr>




                                    <?php

                                    $dr_rental = (!empty($driver_settlement_data) && !empty($driver_settlement_data['dr_rental'])) ? $driver_settlement_data['dr_rental'] : 0;
                                    $total_dockets = isset($driver_settlement_data['total_docket']) ? $driver_settlement_data['total_docket'] : 0;
                                    $total_expense = isset($driver_settlement_data['total_expense']) ? $driver_settlement_data['total_expense'] : 0;
                                    $total_levy = isset($driver_settlement_data['levy_total']) ? $driver_settlement_data['levy_total'] : 0;
                                    $bond = !empty($driver_settlement_data['dr_rental']) ? (isset($driver_settlement_data['bond_installment']) ? $driver_settlement_data['bond_installment'] : 0) : 0;
                                    $accident = isset($driver_settlement_data['accident_installment']) ? $driver_settlement_data['accident_installment'] : 0;
                                    $other = isset($driver_settlement_data['other']) ? $driver_settlement_data['other'] : 0;
                                    $amount_paid = 0;
                                    $amount_paid = $driver_settlement_data['settlement_amt'] - $driver_settlement_data['final_due_amt'];

                                    $rental_payout = !empty($driver_settlement_data['dr_rental']) ? ($dr_rental - $total_dockets + $total_levy + $bond + $accident + $other - $amount_paid) : '0.00';
                                    $discount = !empty($driver_settlement_data['dr_rental']) ? ($driver_settlement_data['amount_due'] - $rental_payout - $amount_paid) : '0.00';
                                    //$driver_payout = $actual_payout - $discount;
                                    ?>
                                    <tr>
                                      <td style="color: #000;font-weight: 500;">Discount</td>
                                      <td class="td_amount_right">
                                        <div class="input-group">
                                          <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">$</span>
                                          </div>
                                          <input type="text" class="form-control calculate_due_amt" id="discount" data-rental_commission="commission" aria-label="" aria-describedby="basic-addon1" value="<?= ($driver_settlement_data['rental_commission_flag'] == 'C') ? number_format($driver_settlement_data['discount'], 2, '.', '') : 0 ?>">
                                        </div>
                                      </td>
                                      <td class="td_amount_right">
                                        <div class="input-group">
                                          <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">$</span>
                                          </div>
                                          <input type="text" class="form-control calculate_due_amt" id="discount_rental" data-rental_commission="rental" aria-label="" aria-describedby="basic-addon1" value="<?= ($driver_settlement_data['rental_commission_flag'] == 'R') ? number_format($discount, 2, '.', '') : 0 ?>">
                                        </div>
                                      </td>
                                    </tr>

                                    <tr>
                                      <td style="color: #000;font-weight: 500; width: 50%;"><Strong>Amount Paid</Strong></td>
                                      <td class="td_amount_right">
                                        <div class="input-group">
                                          <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">$</span>
                                          </div>

                                          <input type="text" class="form-control calculate_due_amt" id="amount_paid" data-rental_commission="commission" aria-label="" aria-describedby="basic-addon1" value="<?= ($driver_settlement_data['rental_commission_flag'] == 'C') ? number_format($driver_settlement_data['amount_paid'], 2, '.', '') : '0.00' ?>" readonly>

                                        </div>
                                      </td>
                                      <td class="td_amount_right">
                                        <div class="input-group">
                                          <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">$</span>
                                          </div>

                                          <input type="text" class="form-control calculate_due_amt" id="amount_paid_rental" data-rental_commission="rental" aria-label="" aria-describedby="basic-addon1" value="<?= ($driver_settlement_data['rental_commission_flag'] == 'R') ? number_format($amount_paid, 2, '.', '') : '0.00' ?>" readonly>

                                        </div>
                                      </td>
                                    </tr>


                                    <tr>
                                      <td style="color: #000;font-weight: 500; width: 50%;"><Strong>Amount Due</Strong></td>
                                      <td class="td_amount_right">
                                        <div class="input-group">
                                          <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">$</span>
                                          </div>

                                          <input type="text" class="form-control calculate_due_amt" id="amount_due" data-rental_commission="commission" aria-label="" aria-describedby="basic-addon1" value="<?= ($driver_settlement_data['rental_commission_flag'] == 'C') ? number_format($driver_settlement_data['amount_due'], 2, '.', '') : 0 ?>" readonly>

                                        </div>
                                      </td>
                                      <td class="td_amount_right">
                                        <div class="input-group">
                                          <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">$</span>
                                          </div>

                                          <input type="text" class="form-control calculate_due_amt" id="amount_due_rental" data-rental_commission="rental" aria-label="" aria-describedby="basic-addon1" value="<?= ($driver_settlement_data['rental_commission_flag'] == 'R') ? number_format($rental_payout, 2, '.', '') : 0 ?>" readonly>

                                        </div>
                                      </td>
                                    </tr>
                                    <!-- <tr>
                                                    <td style="color: #000;font-weight: 800;"<Strong>Total</Strong></td>
                                                    <td class="td_amount_right">
                                                      <div class="input-group">
                                                          <div class="input-group-prepend">
                                                              <span class="input-group-text" id="basic-addon1">$</span>
                                                          </div>
                                                          <input type="text" id="total" name="total" class="form-control" aria-label="" aria-describedby="basic-addon1" value="<?php if (!empty($driver_settlement_data['final_settlement_amt'])) : echo $driver_settlement_data['final_settlement_amt'];
                                                                                                                                                                                else : echo '0.00';
                                                                                                                                                                                endif; ?>" readonly>
                                                      </div>
                                                    </td>
                                                </tr> -->
                                  </tbody>
                                </table>
                              </div>
                            </div>
                            <div class="table_row repeat">
                              <h4 class="cash_summary">Payment Details</h4>
                              <div class="table-responsive custom_table_area">
                                <table class="table table-striped table-bordered daily_stl_table">
                                  <tbody>
                                    <tr>
                                      <td style="width: 50%;color: #000;font-weight: 800;"><strong>Credit card</strong></td>
                                      <td>
                                        <div class="input-group">
                                          <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">$</span>
                                          </div>
                                          <input type="text" name="credit_card_amt" class="form-control payment_opn" value="<?php if (!empty($driver_settlement_data['credit_card_amt'])) : echo $driver_settlement_data['credit_card_amt'];
                                                                                                                            else : echo '0.00';
                                                                                                                            endif; ?>" <?php if ($this->role_id != 1) : echo "readonly";
                                                                                                                                                                                                                                                                        endif; ?>>
                                        </div>
                                      </td>
                                    </tr>
                                    <tr>
                                      <td style="width: 50%;color: #000;font-weight: 800;"><strong>Bank transfer</strong></td>
                                      <td>
                                        <div class="input-group">
                                          <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">$</span>
                                          </div>
                                          <input type="text" name="bank_transfer_amt" class="form-control payment_opn" value="<?php if (!empty($driver_settlement_data['bank_transfer_amt'])) : echo $driver_settlement_data['bank_transfer_amt'];
                                                                                                                              else : echo '0.00';
                                                                                                                              endif; ?>" <?php if ($this->role_id != 1) : echo "readonly";
                                                                                                                                                                                                                                                                              endif; ?>>
                                        </div>
                                      </td>
                                    </tr>
                                    <tr>
                                      <td style="width: 50%;color: #000;font-weight: 800;"><strong>Cash</strong></td>
                                      <td>
                                        <div class="input-group">
                                          <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">$</span>
                                          </div>
                                          <input type="text" name="cash_amt" class="form-control payment_opn" value="<?php if (!empty($driver_settlement_data['cash_amt'])) : echo $driver_settlement_data['cash_amt'];
                                                                                                                      else : echo '0.00';
                                                                                                                      endif; ?>" <?php if ($this->role_id != 1) : echo "readonly";
                                                                                                                                                                                                                                                  endif; ?>>
                                        </div>
                                      </td>
                                    </tr>
                                    <tr>
                                      <td style="width: 50%;color: #000;font-weight: 800;"><strong>Accumulate</strong></td>
                                      <td>
                                        <div class="input-group">
                                          <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">$</span>
                                          </div>
                                          <input type="text" name="admin_total_payment" id="admin_total_payment" name="admin_total_payment" value="<?php if (!empty($driver_settlement_data['final_settlement_amt'])) : echo $driver_settlement_data['final_settlement_amt'];
                                                                                                                                                    else : echo '0.00';
                                                                                                                                                    endif; ?>" class="form-control" value="" readonly>
                                        </div>
                                      </td>
                                    </tr>
                                  </tbody>
                                </table>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                </div>
                <div class="form-actions">
                  <input type="hidden" id="driver_id" value="<?php if (!empty($driver_settlement_data)) : echo $driver_settlement_data['driver_id'];
                                                              endif; ?>">
                  <input type="hidden" id="shift_id" value="<?php if (!empty($driver_settlement_data)) : echo $driver_settlement_data['shift_id'];
                                                            endif; ?>">
                  <input type="hidden" id="payin_id" value="<?php if (!empty($driver_settlement_data)) : echo $driver_settlement_data['payin_id'];
                                                            endif; ?>">
                  <a class="btn btn-danger mr-1" href="<?php echo base_url() . 'admin/driver-settlement/list'; ?>">
                    <i class="fa fa-times" aria-hidden="true"></i> Cancel
                  </a>
                  <button type="submit" id="submit_driver_settlement" class="btn btn-success">
                    <!-- style="display:none>-->
                    <i class="fa fa-floppy-o" aria-hidden="true"></i> Submit
                  </button>
                </div>
                </form>
              </div>
            </div>
          </div>
        </div>
    </div>
    </section>
    <!-- // Basic form layout section end -->
  </div>
</div>
</div>
<script>
  $(document).ready(function() {
    $(".js-select2").select2();
  })
  $(document).on('change', '#driver_list', function() {
    var driver_id = $(this).val();
    $.ajax({
      type: "POST",
      url: '<?php echo base_url('admin/DriverSettlement/ajaxDriverShiftDetails') ?>',
      data: {
        driver_id: driver_id
      },
      dataType: 'JSON',
      success: function(response) {
        //alert(response);
        if (response['html'] != '') {
          $("#drive_data_div").html(response['html']);
        }
        if (response['html'] != '1') {
          $("#driver_settlement_div").html('');
        }
      },
      error: function(response) {
        $.alert({
          type: 'red',
          title: 'Alert!',
          content: 'error',
        });
      }
    });
  });
  $(document).on('click', '.driver_shift', function() {
    var shift_id = $(this).attr('id');
    var driver_id = $('#driver_list').val();
    $.ajax({
      type: "POST",
      url: '<?php echo base_url('admin/DriverSettlement/ajaxDriverSettlement') ?>',
      data: {
        shift_id: shift_id,
        driver_id: driver_id
      },
      dataType: 'json',
      success: function(response) {
        //alert(response);
        if (response['html'] != '') {
          $("#driver_settlement_div").html(response['html']);
        }
      },
      error: function(response) {
        $.alert({
          type: 'red',
          title: 'Alert!',
          content: 'error',
        });
      }
    });
  });
  $(document).on('click', '.total_extra_edit', function() {
    $(".total_extra_div").hide();
    $("#total_extra_start").attr('type', 'text');
    $("#total_extra_end").attr('type', 'text');
    $(".total_extra_save").prop('checked', false);
    $(".total_extra_save").attr('disabled', false);
  });
  $(document).on('click', '.paid_km_edit', function() {
    $(".paid_km_div").hide();
    $("#paid_km_start").attr('type', 'text');
    $("#paid_km_end").attr('type', 'text');
    $(".paid_km_save").prop('checked', false);
    $(".paid_km_save").attr('disabled', false);
  });
  $(document).on('click', '.total_km_edit', function() {
    $(".total_km_div").hide();
    $("#total_km_start").attr('type', 'text');
    $("#total_km_end").attr('type', 'text');
    $(".total_km_save").prop('checked', false);
    $(".total_km_save").attr('disabled', false);
  });
  $(document).on('click', '.extra_edit', function() {
    $(".extra_div").hide();
    $("#extra_start").attr('type', 'text');
    $("#extra_end").attr('type', 'text');
    $(".extra_save").prop('checked', false);
    $(".extra_save").attr('disabled', false);
  });
  $(document).on('click', '.no_of_hiring_edit', function() {
    $(".no_of_hiring_div").hide();
    $("#no_of_hiring_start").attr('type', 'text');
    $("#no_of_hiring_end").attr('type', 'text');
    $(".no_of_hiring_save").prop('checked', false);
    $(".no_of_hiring_save").attr('disabled', false);
  });
  $(document).on('click', '.speedo_reading_edit', function() {
    $(".speedo_reading_div").hide();
    $("#speedo_reading_start").attr('type', 'text');
    $("#speedo_reading_end").attr('type', 'text');
    $(".speedo_reading_save").prop('checked', false);
    $(".speedo_reading_save").attr('disabled', false);
  });

  $(document).on('click', '.total_extra_save', function() {
    if ($(this).is(':checked')) {
      var payin_id = $(this).attr('rel');
      var driver_id = $("#driver_id").val();
      var shift_id = $("#shift_id").val();
      var total_ext_start = $('.total_extra_tr > td:nth-of-type(1) > input:nth-of-type(1)').val();
      var total_ext_end = $('.total_extra_tr > td:nth-of-type(3) > input:nth-of-type(1)').val();

      if (parseFloat(total_ext_end) < parseFloat(total_ext_start)) {
        $('.total_extra_tr > td:nth-of-type(3) > input:nth-of-type(1)').css('border-color', 'red');
        $.alert({
          type: 'red',
          title: 'Alert!',
          content: 'Total + Extra Finish Reading Should Be Greater Than Start Reading',
        });

        return false;
      } else {
        $.ajax({
          type: "POST",
          url: '<?php echo base_url('admin/DriverSettlement/saveDriverSettlement') ?>',
          data: {
            payin_id: payin_id,
            start_value: total_ext_start,
            end_value: total_ext_end,
            start_colmn: 'total_extra_start',
            end_colmn: 'total_extra_end',
            driver_id: driver_id,
            shift_id: shift_id
          },
          dataType: 'JSON',
          success: function(response) {
            if (response['process'] == 'success') {
              //alert("Successfully updated.");
              $("#total_extra_start_div").html(total_ext_start);
              $("#total_extra_end_div").html(total_ext_end);
              $(".total_extra_div").show();
              $("#total_extra_start").attr('type', 'hidden');
              $("#total_extra_end").attr('type', 'hidden');
              $(".total_extra_save").prop('disabled', true);
            } else {
              $.alert({
                type: 'red',
                title: 'Alert!',
                content: 'Some problem occure.Please try again.',
              });
            }
            $("#total_dockets").val(response['total_settlement']['total_dockets']);
            $("#total_expense").val(response['total_settlement']['total_dockets']);
            $("#accident_installment").val(response['total_settlement']['accident_installment']);
            $("#bond_total").val(response['total_settlement']['bond_total']);
            $("#other").val(response['total_settlement']['other']);
            $("#levy_total").val(response['total_settlement']['levy_total']);
            $("#no_of_whl").val(response['total_settlement']['no_of_whl']);
            $("#amount_due").val(response['total_settlement']['amount_due']);
            $("#discount").val(response['total_settlement']['discount']);
            $("#total").val(response['total_settlement']['total']);
          },
          error: function(response) {
            $.alert({
              type: 'red',
              title: 'Alert!',
              content: 'Error',
            });
          }
        });
      }
    }
  });
  $(document).on('click', '.paid_km_save', function() {
    var payin_id = $(this).attr('rel');
    var driver_id = $("#driver_id").val();
    var shift_id = $("#shift_id").val();
    var paid_km_start = $('.paid_km_tr > td:nth-of-type(1) > input:nth-of-type(1)').val();
    var paid_km_end = $('.paid_km_tr > td:nth-of-type(3) > input:nth-of-type(1)').val();
    if (parseFloat(paid_km_end) < parseFloat(paid_km_start)) {
      $('.paid_km_tr > td:nth-of-type(3) > input:nth-of-type(1)').css('border-color', 'red');
      $.alert({
        type: 'red',
        title: 'Alert!',
        content: 'Paid km Finish Reading Should Be Greater Than Start Reading',
      });
      return false;
    } else {
      $.ajax({
        type: "POST",
        url: '<?php echo base_url('admin/DriverSettlement/saveDriverSettlement') ?>',
        data: {
          payin_id: payin_id,
          start_value: paid_km_start,
          end_value: paid_km_end,
          start_colmn: 'paid_km_start',
          end_colmn: 'paid_km_end',
          driver_id: driver_id,
          shift_id: shift_id
        },
        dataType: 'JSON',
        success: function(response) {
          if (response['process'] == 'success') {
            //alert("Successfully updated.");
            $("#paid_km_start_div").html(paid_km_start);
            $("#paid_km_end_div").html(paid_km_end);
            $(".paid_km_div").show();
            $("#paid_km_start").attr('type', 'hidden');
            $("#paid_km_end").attr('type', 'hidden');
            $(".paid_km_save").prop('disabled', true);
          } else {
            $.alert({
              type: 'red',
              title: 'Alert!',
              content: 'Some problem occure.Please try again.',
            });
          }
          $("#total_dockets").val(response['total_settlement']['total_dockets']);
          $("#total_expense").val(response['total_settlement']['total_dockets']);
          $("#accident_installment").val(response['total_settlement']['accident_installment']);
          $("#bond_total").val(response['total_settlement']['bond_total']);
          $("#other").val(response['total_settlement']['other']);
          $("#levy_total").val(response['total_settlement']['levy_total']);
          $("#no_of_whl").val(response['total_settlement']['no_of_whl']);
          $("#amount_due").val(response['total_settlement']['amount_due']);
          $("#discount").val(response['total_settlement']['discount']);
          $("#total").val(response['total_settlement']['total']);
        },
        error: function(response) {
          $.alert({
            type: 'red',
            title: 'Alert!',
            content: 'Error',
          });
        }
      });
    }
  });
  $(document).on('click', '.total_km_save', function() {
    var payin_id = $(this).attr('rel');
    var driver_id = $("#driver_id").val();
    var shift_id = $("#shift_id").val();
    var total_km_start = $('.total_km_tr > td:nth-of-type(1) > input:nth-of-type(1)').val();
    var total_km_end = $('.total_km_tr > td:nth-of-type(3) > input:nth-of-type(1)').val();
    if (parseFloat(total_km_end) < parseFloat(total_km_start)) {
      $('.total_km_tr > td:nth-of-type(3) > input:nth-of-type(1)').css('border-color', 'red');
      $.alert({
        type: 'red',
        title: 'Alert!',
        content: 'Total km Finish Reading Should Be Greater Than Start Reading.',
      });
      return false;
    } else {
      $.ajax({
        type: "POST",
        url: '<?php echo base_url('admin/DriverSettlement/saveDriverSettlement') ?>',
        data: {
          payin_id: payin_id,
          start_value: total_km_start,
          end_value: total_km_end,
          start_colmn: 'total_km_start',
          end_colmn: 'total_km_end',
          driver_id: driver_id,
          shift_id: shift_id
        },
        dataType: 'JSON',
        success: function(response) {
          if (response['process'] == 'success') {
            //alert("Successfully updated.");
            $("#total_km_start_div").html(total_km_start);
            $("#total_km_end_div").html(total_km_end);
            $(".total_km_div").show();
            $("#total_km_start").attr('type', 'hidden');
            $("#total_km_end").attr('type', 'hidden');
            $(".total_km_save").prop('disabled', true);
          } else {
            $.alert({
              type: 'red',
              title: 'Alert!',
              content: 'Some problem occure.Please try again.',
            });
          }
          $("#total_dockets").val(response['total_settlement']['total_dockets']);
          $("#total_expense").val(response['total_settlement']['total_dockets']);
          $("#accident_installment").val(response['total_settlement']['accident_installment']);
          $("#bond_total").val(response['total_settlement']['bond_total']);
          $("#other").val(response['total_settlement']['other']);
          $("#levy_total").val(response['total_settlement']['levy_total']);
          $("#no_of_whl").val(response['total_settlement']['no_of_whl']);
          $("#amount_due").val(response['total_settlement']['amount_due']);
          $("#discount").val(response['total_settlement']['discount']);
          $("#total").val(response['total_settlement']['total']);
        },
        error: function(response) {
          $.alert({
            type: 'red',
            title: 'Alert!',
            content: 'Error',
          });
        }
      });
    }
  });
  $(document).on('click', '.extra_save', function() {
    var payin_id = $(this).attr('rel');
    var driver_id = $("#driver_id").val();
    var shift_id = $("#shift_id").val();
    var extra_start = $('.extra_tr > td:nth-of-type(1) > input:nth-of-type(1)').val();
    var extra_end = $('.extra_tr > td:nth-of-type(3) > input:nth-of-type(1)').val();
    //alert(extra_start);alert(extra_end);
    if (parseFloat(extra_end) < parseFloat(extra_start)) {
      $('.extra_tr > td:nth-of-type(3) > input:nth-of-type(1)').css('border-color', 'red');
      $.alert({
        type: 'red',
        title: 'Alert!',
        content: 'Extra Finish Reading Should Be Greater Than Start Reading.',
      });
      return false;
    } else {
      $.ajax({
        type: "POST",
        url: '<?php echo base_url('admin/DriverSettlement/saveDriverSettlement') ?>',
        data: {
          payin_id: payin_id,
          start_value: extra_start,
          end_value: extra_end,
          start_colmn: 'extra_start',
          end_colmn: 'extra_end',
          driver_id: driver_id,
          shift_id: shift_id
        },
        dataType: 'JSON',
        success: function(response) {
          if (response['process'] == 'success') {
            //alert("Successfully updated.");
            $("#extra_start_div").html(extra_start);
            $("#extra_end_div").html(extra_end);
            $(".extra_div").show();
            $("#extra_start").attr('type', 'hidden');
            $("#extra_end").attr('type', 'hidden');
            $(".extra_save").prop('disabled', true);
          } else {
            $.alert({
              type: 'red',
              title: 'Alert!',
              content: 'Some problem occure.Please try again.',
            });
          }
          $("#total_dockets").val(response['total_settlement']['total_dockets']);
          $("#total_expense").val(response['total_settlement']['total_dockets']);
          $("#accident_installment").val(response['total_settlement']['accident_installment']);
          $("#bond_total").val(response['total_settlement']['bond_total']);
          $("#other").val(response['total_settlement']['other']);
          $("#levy_total").val(response['total_settlement']['levy_total']);
          $("#no_of_whl").val(response['total_settlement']['no_of_whl']);
          $("#amount_due").val(response['total_settlement']['amount_due']);
          $("#discount").val(response['total_settlement']['discount']);
          $("#total").val(response['total_settlement']['total']);
        },
        error: function(response) {
          $.alert({
            type: 'red',
            title: 'Alert!',
            content: 'Error',
          });
        }
      });
    }
  });
  $(document).on('click', '.no_of_hiring_save', function() {
    var payin_id = $(this).attr('rel');
    var driver_id = $("#driver_id").val();
    var shift_id = $("#shift_id").val();
    var no_of_hiring_start = $('.no_of_hiring_tr > td:nth-of-type(1) > input:nth-of-type(1)').val();
    var no_of_hiring_end = $('.no_of_hiring_tr > td:nth-of-type(3) > input:nth-of-type(1)').val();
    if (parseFloat(no_of_hiring_end) < parseFloat(no_of_hiring_start)) {
      $('.no_of_hiring_tr > td:nth-of-type(3) > input:nth-of-type(1)').css('border-color', 'red');
      $.alert({
        type: 'red',
        title: 'Alert!',
        content: 'No of Hiring Finish Reading Should Be Greater Than Start Reading.',
      });

      return false;
    } else {
      $.ajax({
        type: "POST",
        url: '<?php echo base_url('admin/DriverSettlement/saveDriverSettlement') ?>',
        data: {
          payin_id: payin_id,
          start_value: no_of_hiring_start,
          end_value: no_of_hiring_end,
          start_colmn: 'no_of_hiring_start',
          end_colmn: 'no_of_hiring_end',
          driver_id: driver_id,
          shift_id: shift_id
        },
        dataType: 'JSON',
        success: function(response) {
          if (response['process'] == 'success') {
            //alert("Successfully updated.");
            $("#no_of_hiring_start_div").html(no_of_hiring_start);
            $("#no_of_hiring_end_div").html(no_of_hiring_end);
            $(".no_of_hiring_div").show();
            $("#no_of_hiring_start").attr('type', 'hidden');
            $("#no_of_hiring_end").attr('type', 'hidden');
            $(".no_of_hiring_save").prop('disabled', true);
          } else {
            $.alert({
              type: 'red',
              title: 'Alert!',
              content: 'Some problem occured.Please try again.',
            });
          }
          $("#total_dockets").val(response['total_settlement']['total_dockets']);
          $("#total_expense").val(response['total_settlement']['total_dockets']);
          $("#accident_installment").val(response['total_settlement']['accident_installment']);
          $("#bond_total").val(response['total_settlement']['bond_total']);
          $("#other").val(response['total_settlement']['other']);
          $("#levy_total").val(response['total_settlement']['levy_total']);
          $("#no_of_whl").val(response['total_settlement']['no_of_whl']);
          $("#amount_due").val(response['total_settlement']['amount_due']);
          $("#discount").val(response['total_settlement']['discount']);
          $("#total").val(response['total_settlement']['total']);
        },
        error: function(response) {
          $.alert({
            type: 'red',
            title: 'Alert!',
            content: 'Error',
          });
        }
      });
    }
  });
  $(document).on('click', '.speedo_reading_save', function() {
    var payin_id = $(this).attr('rel');
    var driver_id = $("#driver_id").val();
    var shift_id = $("#shift_id").val();
    var speedo_reading_start = $('.speedo_reading_tr > td:nth-of-type(1) > input:nth-of-type(1)').val();
    var speedo_reading_end = $('.speedo_reading_tr > td:nth-of-type(3) > input:nth-of-type(1)').val();
    if (parseFloat(speedo_reading_end) < parseFloat(speedo_reading_start)) {
      $('.speedo_reading_tr > td:nth-of-type(3) > input:nth-of-type(1)').css('border-color', 'red');
      $.alert({
        type: 'red',
        title: 'Alert!',
        content: 'Speedo Finish Reading Should Be Greater Than Start Reading.',
      });
      return false;
    } else {
      $.ajax({
        type: "POST",
        url: '<?php echo base_url('admin/DriverSettlement/saveDriverSettlement') ?>',
        data: {
          payin_id: payin_id,
          start_value: speedo_reading_start,
          end_value: speedo_reading_end,
          start_colmn: 'speedo_reading_start',
          end_colmn: 'speedo_reading_end',
          driver_id: driver_id,
          shift_id: shift_id
        },
        dataType: 'JSON',
        success: function(response) {
          if (response['process'] == 'success') {
            //alert("Successfully updated.");
            $("#speedo_reading_start_div").html(speedo_reading_start);
            $("#speedo_reading_end_div").html(speedo_reading_end);
            $(".speedo_reading_div").show();
            $("#speedo_reading_start").attr('type', 'hidden');
            $("#speedo_reading_end").attr('type', 'hidden');
            $(".speedo_reading_save").prop('disabled', true);

          } else {
            $.alert({
              type: 'red',
              title: 'Alert!',
              content: 'Some problem occure.Please try again.',
            });
          }
          $("#total_dockets").val(response['total_settlement']['total_dockets']);
          $("#total_expense").val(response['total_settlement']['total_dockets']);
          $("#accident_installment").val(response['total_settlement']['accident_installment']);
          $("#bond_total").val(response['total_settlement']['bond_total']);
          $("#other").val(response['total_settlement']['other']);
          $("#levy_total").val(response['total_settlement']['levy_total']);
          $("#no_of_whl").val(response['total_settlement']['no_of_whl']);
          $("#amount_due").val(response['total_settlement']['amount_due']);
          $("#discount").val(response['total_settlement']['discount']);
          $("#total").val(response['total_settlement']['total']);
        },
        error: function(response) {
          $.alert({
            type: 'red',
            title: 'Alert!',
            content: 'Error',
          });
        }
      });
    }
  });
  $(document).on('click', '.driver_docket_edit', function() {
    $(this).parents('.driver_docket_tr').find('input.docket_pr_input').attr('type', 'number');
    $(this).parents('.driver_docket_tr').find('input.docket_pr_input').attr('min', '1');
    //$(this).parents('.driver_docket_tr').find('input.input_file').attr('type','file');

    $(this).parents('tr').find('.docket_price_div').hide();
  });
  $(document).on('click', '.driver_docket_save', function() {
    var currnt_obj = $(this);
    var payin_dockets_id = $(this).attr('id');
    var driver_docket_pr = $(this).parents('tr').find('input').val();
    var driver_id = $("#driver_id").val();
    var shift_id = $("#shift_id").val();
    var payin_id = $("#payin_id").val();
    //alert(driver_id+"&&"+shift_id+"$$"+payin_id);
    $.ajax({
      type: "POST",
      url: '<?php echo base_url('admin/DriverSettlement/saveDriverDocket') ?>',
      data: {
        payin_dockets_id: payin_dockets_id,
        driver_docket_pr: driver_docket_pr,
        driver_id: driver_id,
        shift_id: shift_id,
        payin_id: payin_id
      },
      dataType: 'JSON',
      success: function(response) {
        //alert(response);
        if (response['process'] == 'success') {
          alert("Successfully updated.");
          currnt_obj.parents('.driver_docket_tr').find('input.docket_pr_input').attr('type', 'hidden');
          currnt_obj.parents('tr').find('.docket_price_div').show();
          currnt_obj.parents('tr').find('.docket_price_div').html(driver_docket_pr);
        } else {
          $.alert({
            type: 'red',
            title: 'Alert!',
            content: 'Some problem occure.Please try again.',
          });
        }
        $("#total_dockets").val(response['total_settlement']['total_dockets']);
        $("#total_expense").val(response['total_settlement']['total_expense']);
        $("#accident_installment").val(response['total_settlement']['accident_installment']);
        $("#bond_total").val(response['total_settlement']['bond_total']);
        $("#other").val(response['total_settlement']['other']);
        $("#levy_total").val(response['total_settlement']['levy_total']);
        $("#no_of_whl").val(response['total_settlement']['no_of_whl']);
        $("#amount_due").val(response['total_settlement']['amount_due']);
        $("#discount").val(response['total_settlement']['discount']);
        $("#total").val(response['total_settlement']['total']);
      },
      error: function(response) {
        $.alert({
          type: 'red',
          title: 'Alert!',
          content: 'ERROR',
        });
      }
    });
  });
  $(document).on('click', '.driver_expense_edit', function() {
    $(this).parents('.driver_expenses_tr').find('input.expense_price_inp').attr('type', 'number');
    $(this).parents('.driver_expenses_tr').find('input.expense_price_inp').attr('min', '1');
    //$(this).parents('.driver_docket_tr').find('input.input_file').attr('type','file');

    $(this).parents('tr').find('.expense_price_div').hide();
  });
  $(document).on('click', '.driver_expense_save', function() {
    var currnt_obj = $(this);
    var payin_expense_id = $(this).attr('id');
    var driver_expense_pr = $(this).parents('tr').find('input').val();
    var driver_id = $("#driver_id").val();
    var shift_id = $("#shift_id").val();
    var payin_id = $("#payin_id").val();
    $.ajax({
      type: "POST",
      url: '<?php echo base_url('admin/DriverSettlement/saveDriverExpense') ?>',
      data: {
        payin_expense_id: payin_expense_id,
        driver_expense_pr: driver_expense_pr,
        driver_id: driver_id,
        shift_id: shift_id,
        payin_id: payin_id
      },
      dataType: 'JSON',
      success: function(response) {
        if (response['process'] == 'success') {
          alert("Successfully updated.");
          currnt_obj.parents('.driver_expenses_tr').find('input.expense_price_inp').attr('type', 'hidden');
          currnt_obj.parents('tr').find('.expense_price_div').show();
          currnt_obj.parents('tr').find('.expense_price_div').html(driver_expense_pr);
        } else {
          $.alert({
            type: 'red',
            title: 'Alert!',
            content: 'Some problem occure.Please try again.',
          });
        }
        $("#total_dockets").val(response['total_settlement']['total_dockets']);
        $("#total_expense").val(response['total_settlement']['total_expense']);
        $("#accident_installment").val(response['total_settlement']['accident_installment']);
        $("#bond_total").val(response['total_settlement']['bond_total']);
        $("#other").val(response['total_settlement']['other']);
        $("#levy_total").val(response['total_settlement']['levy_total']);
        $("#no_of_whl").val(response['total_settlement']['no_of_whl']);
        $("#amount_due").val(response['total_settlement']['amount_due']);
        $("#discount").val(response['total_settlement']['discount']);
        $("#total").val(response['total_settlement']['total']);
      },
      error: function(response) {
        $.alert({
          type: 'red',
          title: 'Alert!',
          content: 'ERROR',
        });
      }
    });
  });
  $(document).on('focusout', '#discount', function(event) {
    calculate_TOTAL();
  });
  $(document).on('keyup', '#discount', function(event) {
    calculate_TOTAL();
  });
  $(document).on('keyup', '#other', function(event) {
    calculate_TOTAL();
  });
  $(document).on('focusout', '#other', function(event) {
    calculate_TOTAL();
  });
  $(document).on('keyup', '#bond_total', function(event) {
    calculate_TOTAL();
  });
  $(document).on('focusout', '#bond_total', function(event) {
    calculate_TOTAL();
  });
  $(document).on('keyup', '#accident_installment', function(event) {
    calculate_TOTAL();
  });
  $(document).on('focusout', '#accident_installment', function(event) {
    calculate_TOTAL();
  });

  function calculate_TOTAL() {
    event.preventDefault();
    var driver_id = $("#driver_id").val();
    var shift_id = $("#shift_id").val();
    var payin_id = $("#payin_id").val();
    if ($("#other").val() != "") {
      var other = $("#other").val();
    } else {
      $("#other").val('0.00');
      var other = 0;
    }
    if ($("#bond_total").val() != "") {
      var bond_total = $("#bond_total").val();
    } else {
      $("#bond_total").val('0.00');
      var bond_total = 0;
    }
    if ($("#accident_installment").val() != "") {
      var accident_installment = $("#accident_installment").val();
    } else {
      $("#accident_installment").val('0.00');
      var accident_installment = 0;
    }
    if ($("#discount").val() != "") {
      var discount = $("#discount").val();
    } else {
      $("#discount").val('0.00');
      var discount = 0;
    }

    //alert("driver id: "+driver_id+"\n"+"shift id: "+shift_id+"\n"+"payin id: "+payin_id+"\n"+"discount: "+discount+"\n"+"other: "+other+"\n"+"bond total: "+bond_total+"\n"+"accident installment: "+accident_installment+"\n");
    $.ajax({
      type: "POST",
      url: '<?php echo base_url('admin/DriverSettlement/calculateDiscount') ?>',
      data: {
        driver_id: driver_id,
        shift_id: shift_id,
        payin_id: payin_id,
        discount: discount,
        other: other,
        bond_total: bond_total,
        accident_installment: accident_installment,
        flag: 1
      },
      dataType: 'json',
      success: function(response) {
        //alert(response);
        //alert(response['total']+'\n'+response['amount_due']);
        if (response['total'] != '') {
          $("#total").val(response['total']);
          $("#amount_due").val(response['amount_due']);
        }
      },
      error: function(response) {
        $.alert({
          type: 'red',
          title: 'Alert!',
          content: 'ERROR',
        });
      }
    });
  }
  $(document).on('focusout', '.payment_opn', function() {
    var accumulate_amount = 0;
    var values = $("input.payment_opn");

    var payment_opn_arr = $.map(values, function(element) {
      return element.value;
    });
    $.each(payment_opn_arr, function() {
      accumulate_amount += parseFloat(this) || 0;
    });
    $("#admin_total_payment").val(accumulate_amount.toFixed(2));
    var total = $("#total").val();

  });
  $(document).on('keyup', '.payment_opn', function() {
    var accumulate_amount = 0;
    var values = $("input.payment_opn");

    var payment_opn_arr = $.map(values, function(element) {
      return element.value;
    });
    $.each(payment_opn_arr, function() {
      accumulate_amount += parseFloat(this) || 0;
    });
    $("#admin_total_payment").val(accumulate_amount.toFixed(2));
    var total = $("#total").val();
    var admin_total_pay = $("#admin_total_payment").val();

    if (admin_total_pay > total) {
      $.alert({
        type: 'red',
        title: 'Alert!',
        content: 'Accumulate amount should be equal to total amount.',
      });
    }
  });
  $(document).on('click', '#submit_driver_settlement', function(event) {
    event.preventDefault();
    var total = $("#total").val();
    var admin_total_payment = $("#admin_total_payment").val();

    if (isNaN(total) || isNaN(admin_total_payment) || total != admin_total_payment) {
      $.alert({
        type: 'red',
        title: 'Alert!',
        content: 'Total amount is not matching with accumulate amount.',
      });
      return false;
    } else {

      $("#update_driver_settle_frm").submit();
    }
  });

  $(document).on('keyup', '.calculate_amt', function() {
    var qty = $(this).val();
    var dollar_price = $(this).data('dollar_price');
    var amount = parseFloat(Number(qty) * Number(dollar_price)).toFixed(2);
    var total_cash_amount = $("#3").val();
    var total_amount = 0 * 1;

    $(this).next('input[type=hidden]').val(amount);
    $(this).parent().parent().children('.dollar_amount').html(amount);


    $('.dollar_amount').each(function() {
      total_amount += Number($(this).text());
    })

    if (total_cash_amount < total_amount) {
      $.alert({
        type: 'red',
        title: 'Alert!',
        content: 'Cash amount not matched with denominations total',
      });
      $(this).val('');
      $(this).next('input[type=hidden]').val('');
      $(this).parent().parent().children('.dollar_amount').html('');
    } else {
      $(".total_amount").text(parseFloat(total_amount).toFixed(2));
      $("#total_amount").val(total_amount);
    }

  })

  // function calculate_total_amount(){
  //   var total_amount =0 * 1;

  //   $('.dollar_amount').each(function(){
  //       total_amount +=Number($(this).text());
  //   })
  //   $(".total_amount").text(parseFloat(total_amount).toFixed(2));
  //   $("#total_amount").val(total_amount);
  //   return total_amount;
  // } 
</script>