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/qcr24/app/application/views/admin/rent_out/list.php
<!-- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> -->
<!-- <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script> -->

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.4/jquery-confirm.min.css" integrity="sha512-0V10q+b1Iumz67sVDL8LPFZEEavo6H/nBSyghr7mm9JEQkOAm91HNoZQRvQdjennBb/oEuW+8oZHVpIKq+d25g==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.4/jquery-confirm.min.js" integrity="sha512-zP5W8791v1A6FToy+viyoyUUyjCzx+4K8XZCKzW28AnCoepPNIXecxh9mvGuy3Rt78OzEsU+VCvcObwAMvBAww==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<!-- ! Main -->
<style>
  .modal-overlay .opened {
    display: block;
  }

  .modal .opened {
    display: block;
  }
  .various-status{
    display:flex;
    align-items: center;
  }
  .draft-status{display:flex; align-items:center; background-color: #2196F3;color:#FFF;padding:3px 5px;border-radius:3px;margin: 2px;}
  .delete-status{display:flex; align-items:center; background-color: red;color:#FFF;padding:3px 5px;border-radius:3px;margin: 2px;}
  .pending-status{display:flex; align-items:center;}
  .active-status{display:flex; align-items:center;}
  .pending-status span:last-child{background-color: #e8e752;color:#FFF;padding:3px 5px;border-radius:3px;margin: 2px;}
  .active-status span:last-child{background-color: #5ab114;color:#FFF;padding:3px 5px;border-radius:3px;margin: 2px;}

  /* .opened{

  } */
</style>
<main class="main users job-role-page" id="">
  <div class="container">
    <!-- <h2 class="main-title">Job Role</h2> -->
    <?php if ($this->session->flashdata('success_msg')) : ?>
      <div class="alert alert-success">
        <a href="" class="close" data-dismiss="alert" aria-label="close" title="close" style="position: absolute;right: 15px;font-size: 30px;top: 5px;">×</a>
        <?php echo $this->session->flashdata('success_msg') ?>
      </div>
    <?php endif ?>
    <?php if ($this->session->flashdata('error_msg')) : ?>
      <div class="alert alert-danger">
        <a href="" class="close" data-dismiss="alert" aria-label="close" title="close" style="position: absolute;right: 15px;font-size: 30px;top: 5px;">×</a>
        <?php echo $this->session->flashdata('error_msg') ?>
      </div>
    <?php endif ?>
    <div class="row justify-content-between">
      <div class="col-auto">
        <h2 class="app-page-title mrg15B">List of Rent out Vehicles</h2>
      </div>
      <div class="col-auto">
        <div class="page-utilities">
          <div class="row">
            <div class="col-auto">
              <form class="table-search-form row gx-1 align-items-center">
                <!-- <div class="col-auto">
                        <input type="text" id="search-orders" name="searchorders" class="form-control search-orders"
                          placeholder="Search">
                      </div>
                      <div class="col-auto">
                        <select class="form-select w-auto">
                          <option selected="" value="option-1">All</option>
                          <option value="option-2">Active</option>
                          <option value="option-3">Inactive</option>
                        </select>
                      </div>
                      <div class="col-auto">
                        <button type="submit" class="btn btn-secondary">Search</button>
                      </div> -->
              </form>
            </div>
            <div class="col-auto">
              <a class="btn app-btn-primary" style="margin-bottom: 5px;" href="<?= base_url('admin/rentOut/add') ?>">
                Add New Rent out Vehicle
              </a>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-lg-12">

        <div class="users-table table-wrapper">
          <table class="table" id="example">
            <thead>
              <tr class="users-table-info">
                <th>SL No.</th>
                <th>Action</th>
                <th>Driver Name </th>
                <th>Car No</th>
                <th>Date Time</th>
                <th>ODOMETER READING</th>
                <th>WEEKLY RENT</th>
                <th>PAYMENT METHOD</th>
                <th>BOND</th>
                <th>Rental Status</th>
              </tr>
            </thead>
            <tbody>

              <?php if (!empty($rentoutDetails)) {
                $i = 0;
                foreach ($rentoutDetails as $row) {
                  $i++;
              ?>
                  <tr>
                    <td><?= $i ?></td>
                    <td>
                      <a class="btn-sm app-btn-secondary" style="margin:3px; padding:4px 12px; float:left;" href="<?= base_url('admin/rentOut/editrentout/' . $row['rent_out_id']) ?>">Edit</a>
                      <a class="btn-sm app-btn-secondary" style="margin:3px; padding:4px 12px; float:left;" href="<?= base_url('admin/rentOut/viewrentout/' . $row['rent_out_id']) ?>">View</a><br>
                      <a target="_blank" class="btn-sm app-btn-secondary" style="margin:3px; padding:4px 12px; float:left;" href="<?= base_url('admin/rentOut/generatePdf/' . $row['rent_out_id']) ?>">Generate pdf</a>
                      <br>
                      <?php
                      $direct_debit_response = json_decode($row['direct_debit_response'], true);
                      if ($row['is_authorised'] == 0 && !empty($direct_debit_response)) { ?>

                          <a>
                            <buttton type="button" class="btn-sm app-btn-secondary authorize_btn" style="margin:3px; padding:4px 12px; float:left;" data-authorization_url="<?= $direct_debit_response['AuthorisationLink']['Link'] ?>" data-rent_out_id="<?=$row['rent_out_id']?>">Authorize</button>
                          </a>

                        <?php } ?>

                    </td> 
                    <td><?= $row['first_name'] . ' ' . $row['middle_name'] . ' ' . $row['last_name'] ?></td>
                    <td><?= $row['car_no'] ?></td>
                    <td><?= date('d/m/Y H:i:s', strtotime($row['created_ts'])) ?></td>  
                    <td><?= $row['odometer_reading'] ?></td>
                    <td><?= $row['weekly_rent'] ?></td>
                    <td>
                      <?= $row['payment_method'] ?>
                   
                   <?php if($row['payment_method'] == 'Direct Debit'){

                    
                        $Draft ='<div class="draft-status">Draft</div>';
                        $Pending ='<div class="pending-status"><span><i class="fa fa-long-arrow-right"></i></span> <span>Pending</span></div>';
                        $Active ='<div class="active-status"><span><i class="fa fa-long-arrow-right"></i></span> <span>Active</span></div>';
                        $Delete ='<div class="delete-status"><span>Deleted</span></div>';
                    
                      ?>
                        
                        <?='<div class="various-status">'.(($row['is_deleted_direct_debit'] == 1)?$Delete:(($row['is_authorised'] == 0)?$Draft:(($row['is_authorised'] == 2)?$Draft.$Pending:(($row['is_authorised'] == 1)?$Draft.$Pending.$Active:'')))).'</div>'?>

                      <?php } ?>
                    </td>
                    <td><?= $row['bond_amount'] ?></td>
                    <td><span class="<?=(($row['is_rent_in'] == 1)?'badge-success':'badge-pending')?>"><?=(($row['is_rent_in'] == 1)?'Rent In':'Rent Out')?></span></td>
                  </tr>
              <?php }
              } ?>
            </tbody>
          </table>
        </div>
      </div>

    </div>
  </div>
</main>

<div class="modal-overlay" id="modal-overlay" style="display:none;"></div>

<div class="modal" id="modal" style="display:none;">
  <button class="close-button close" id="close-button">
    <i class="fa fa-times" aria-hidden="true"></i>
  </button>
  <div class="modal-guts">
    <h3 class="guts-title">Customer Authorisation Required</h3>
    <ul class="authorisation-list">
      <!-- <li class="authorisation-list-detail">
                    <img src="<?= base_url('public/admin_assets/img/verbal-authority.png') ?>" width="36">
                    <div class="authorisation-list-detail-body">
                        <h5 class="mt-0">Verbal Authority</h5>
                        <p>Will be provided by the customer.</p>
                    </div>
                </li> -->
      <li class="authorisation-list-detail" data-authorization_type="customer_self">
        <img src="<?= base_url('public/admin_assets/img/customer-sign.png') ?>" width="36">
        <div class="authorisation-list-detail-body">
          <h5 class="mt-0">Customer is with you now</h5>
          <p>And can authorise on your device.</p>
        </div>
      </li>
      <li class="authorisation-list-detail" data-authorization_type="whatsapp">
        <img src="<?= base_url('public/admin_assets/img/whatsapp.png') ?>" width="36">
        <div class="authorisation-list-detail-body">
          <h5 class="mt-0">You send an Authorisation Link</h5>
          <p>Using your own mobile, Sharing via Whatsapp.</p>
        </div>
      </li>
      <li class="authorisation-list-detail" data-authorization_type="email">
        <img src="<?= base_url('public/admin_assets/img/link-click.png') ?>" width="36">
        <div class="authorisation-list-detail-body">
          <h5 class="mt-0">We send an Authorisation Link</h5>
          <p>To the Customer's email or mobile on your behalf.</p>
        </div>
      </li>
      <li class="authorisation-list-detail" data-authorization_type="copy">
        <img src="<?= base_url('public/admin_assets/img/copy.png') ?>" width="36">
        <div class="authorisation-list-detail-body">
          <h5 class="mt-0">Copy Authorization Link</h5>
          <p>Copy authorization link & you can send it to customer from anywhere</p>
        </div>
      </li>
    </ul>
    <a class="btn app-btn-primary close" href="#.">CANCEL</a>
  </div>
</div>
<script>
  $(".close").click(function() {
    $(".modal,.modal-overlay").hide();
  });
  $(".authorize_btn").click(function() {
    $(".modal,.modal-overlay").show();
    $(".authorisation-list-detail").data('authorization_url', $(this).data('authorization_url'));
    $(".authorisation-list-detail").data('rent_out_id', $(this).data('rent_out_id'));
  });

  $(".authorisation-list-detail").click(function() {
    var authorization_type = $(this).data('authorization_type');
    var authorization_url = $(this).data('authorization_url');
    var rent_out_id = $(this).data('rent_out_id');
    if (authorization_type == 'customer_self') {
      
      window.open(authorization_url, '_blank');
    
    } else if (authorization_type == 'whatsapp') {
      
      var text = "Hi, %0aPlease click on the below link to complete direct debit authorization process.";
      var url = $(this).data("authorization_url");
      var message = text + " %0aAuthorization Link : " + encodeURIComponent(url);
      var whatsapp_url = "https://api.whatsapp.com/send?text=" + message;
      window.open(whatsapp_url,'name','width=1380,height=768');
    
    } else if (authorization_type == 'copy') {
      
      var text = "Please click on the below link to complete direct debit authorization process.";
      var url = $(this).data("authorization_url");
      var message = text + " Authorization Link : " + url;
      var temp = $("<input>");
      $("body").append(temp);
      temp.val(message).select();
      document.execCommand("copy");
      temp.remove();
      $.alert({
          title: 'Copied!',
          content: 'Authorization Link Copied Successfully',
          type: 'green',
          typeAnimated: true,
      })
    
    } else if (authorization_type == 'email') {

      $("#loader_div").show();

      $.ajax({
              url: '<?php echo base_url("admin/rentOut/send_email_authorization"); ?>',
              method: 'post',
              dataType: 'json',
              data: {
                rent_out_id: rent_out_id
              },
      success: function(response) {
        $("#loader_div").hide();
          if (response.status) {
            $.alert({
                title: 'Success',
                content: 'Mail Sent Successfully',
                type: 'green',
                typeAnimated: true,
            })
          } else {
            $.alert({
                title: 'Alert!',
                content: 'Unable to send mail',
                type: 'red',
                typeAnimated: true,
            })
          }
        }
      })
      
      
      
    
    } 

  })
</script>