<div class="content-wrapper" >
  <section class="content-header">
    <h1>
       <?= $page_title ?>
        <small><?= $page_desc ?></small>
    </h1>
    <ol class="breadcrumb">
     <li><a href="<?= base_url() ?>"><i class="fa fa-star-o" aria-hidden="true"></i>Home</a></li>
     <li><?= $menu ?></li>
     <li class="active"><?= $sub_menu ?></li>
   </ol>
  </section>

  <section class="content">
    <div class="row">
      <div class="col-md-12">
          <?php if($this->session->flashdata('message')) { 
              $flashdata = $this->session->flashdata('message'); ?>
              <div class="alert alert-<?= $flashdata['class'] ?>">
                 <button class="close" data-dismiss="alert" type="button">×</button>
                 <?= $flashdata['message'] ?>
              </div>
          <?php } ?>
      </div>
      <div class="col-xs-12">
      <div class="box box-warning"> 
      <div class="box-body">
        <table id="driverTable" class="table table-bordered table-striped datatable ">
          <thead>
            <tr>
              <th class="hidden">ID</th>
              <th width="150px;">Vehicle Model</th> 
              <th width="80px;">model</th> 
              <th width="100px;">Vehicle Type</th>
              <th width="200px;">Vehicle Registration</th> 
              <th width="50px;">Status</th>
              <th width="500px;">Action</th>
            </tr>
          </thead> 
          <tbody>
            <?php
            if(!empty($vehicle_data)){
              foreach($vehicle_data as $vehicle) {
               ?>
               <tr>
                 <th class="hidden"><?= $vehicle->vehicle_id ?></th>
                 <th class="center"><?= $vehicle->vehicle_model ?></th>
                 <td class="center"><?= $vehicle->model ?></th> 
                 <td class="center"><?= $vehicle->vehicle_type ?></th>
                 <td class="center"><?= $vehicle->vehicle_reg_no ?></th> 
                 <td class="center"><?= ($vehicle->status == '1')?'Active':'Inactive'?></td>
                 <td class="center">   
                    <a class="btn btn-sm btn-primary" id="viewRegProof" img_src="<?= $vehicle->vehicle_reg_image ?>">
                      <i class="fa fa-fw fa-edit"></i>View Registration Proof
                    </a>
                    <a class="btn btn-sm btn-danger" href="<?= base_url('Vehicle/editVehicle/'.encode_param($vehicle->vehicle_id)) ?>">
                      <i class="fa fa-fw fa-trash"></i>Edit
                    </a> 
                    <a class="btn btn-sm btn-danger" href="<?= base_url("Vehicle/changeVehicleStatus/".encode_param($vehicle->vehicle_id))."/2" ?>" 
                      onClick="return doconfirm()">
                      <i class="fa fa-fw fa-trash"></i>Delete
                    </a>    
                    <?php if($vehicle->status == 1){ ?>
                      <a class="btn btn-sm btn-success" style="background-color:#ac2925" href="<?= base_url("Vehicle/changeVehicleStatus/".encode_param($vehicle->vehicle_id))."/0" ?>">
                        <i class="fa fa-cog"></i> De-activate
                      </a>
                    <?php } else { ?>
                      <a class="btn btn-sm btn-success" href="<?= base_url("Vehicle/changeVehicleStatus/".encode_param($vehicle->vehicle_id))."/1" ?>">
                        <i class="fa fa-cog"></i> Activate
                      </a>
                    <?php } ?>
                  </td>
                </tr>
            <?php 
              } 
            }?>
          </tbody>
        </table>
      </div>
    </div>
  </section>
</div>

<script type="text/javascript">
  jQuery('[id="viewRegProof"]').on('click',function() {
    var img_src = jQuery(this).attr('img_src');
    modalTrigger('Registration Proof','');
    addModalLoader();
    html = '<div class="form-group has-feedback" style="text-align:center;"> '+
             '<img id="proofImg" src="'+base_url+img_src+'" height="400px" width="auto" />'+
           '</div>'; 
    jQuery('[id="modal_content"]').html(html);
    remModalLoader();

    jQuery('[id="proofImg"]').error(function() {
      jQuery('[id="proofImg"]').attr('src',base_url+'assets/images/no_image.png');
    });
  });
</script>