   <section class="content-header">
    <h1 class="top-breadcrumb">&nbsp;</h1>
    <ol class="breadcrumb">
      <li><a href="<?php echo site_url('dashboard'); ?>"><i class="fa fa-dashboard"></i> Dashboard</a></li>
      <?php if(!empty($breadcrumbs)){ ?>
        <?php foreach($breadcrumbs as $key => $bc){ ?>
          <?php if($key == (count($breadcrumbs)-1)){ ?>
            <li class="active"><?php echo $bc['title']; ?></li>
          <?php }else{ ?>
            <li><a href="<?php echo $bc['href']; ?>"><?php echo $bc['title']; ?></a></li>
          <?php } ?>
        <?php } ?>
      <?php } ?>
      <a class="btn btn-back" href="javascript:window.history.go(-1);">Back</a>
    </ol>
  </section>

  <section class="content">
    <?php alert(); ?>
    <div class="row">
      <div class="col-lg-12">
        <div class="box box-success">
          <div class="box-header with-border">
            <h3><?php echo $page_title; ?>
            <?php if(strpos($admin_perms['add_perm'],',3,')!== false){ ?>
              <a href="<?=site_url('add-entry');?>" class="btn pull-right btn-add" >Add Entry</a>
            <?php } ?>
          </h3>
        </div>
        <form method="post" id="frm-save" enctype="multipart/form-data">
          <div class="box-body" style="overflow: auto;">
            <div class="container-fluid" style="padding-top: 0px !important;padding-bottom: 0px !important;">

             <div  class="row">
              <div class="col-lg-2 top10">
                <div class="form-group">
                  <span class="badge-label">From Date</span>
                  <div class="input-group temp-group" style1="margin-top: 7px;">
                    <input name="fr_date" id="fr_date" style="margin-top: 0;" value="<?php echo !empty($fr_date)?$fr_date:'';?>" type="text" class="form-control form-temp fr_date date_inp" placeholder="Date" autocomplete="off">
                    <label class="input-group-addon temp-addon" for="fr_date">
                      <span class="glyphicon glyphicon-calendar"></span>
                    </label>
                  </div>
                </div>
              </div>
              <div class="col-lg-2 top10">
                <div class="form-group">
                  <span class="badge-label">To Date</span>
                  <div class="input-group temp-group" style1="margin-top: 7px;">
                    <input name="to_date" id="to_date" style="margin-top: 0;" value="<?php echo !empty($to_date)?$to_date:'';?>" type="text" class="form-control form-temp to_date date_inp" placeholder="Date" autocomplete="off">
                    <label class="input-group-addon temp-addon" for="to_date">
                      <span class="glyphicon glyphicon-calendar"></span>
                    </label>
                  </div>
                </div>
              </div>

              <div class="col-md-4">
                <span class="badge-label">Mobile No.</span>
                <select name="mob_no" class="select form-control mob_no">
                  <option value="0" >Select</option>
                  <?php   
                  if( count($mobnos) > 0){
                    foreach($mobnos as $m){ ?>
                      <option <?php echo(!empty($mob_no) && $mob_no==$m["mobile1"])?'selected':'';?> value="<?= $m["mobile1"] ?>" ><?= $m["mobile1"] ?> </option>
                    <?php } } ?>
                  </select>
                </div>

              </div>

              <div class="row">
                <div class="col-md-4">
                 <span class="badge-label">Vehicle No.</span>
                 <select name="veh_no" class="select form-control veh_no">
                  <option value="0" >Select</option>
                  <?php   
                  if( count($vnos) > 0){
                    foreach($vnos as $v){ ?>
                      <option <?php echo(!empty($veh_no) && $veh_no==$v["veh_no"])?'selected':'';?> value="<?= $v["veh_no"] ?>" ><?= $v["veh_no"] ?> </option>
                    <?php } } ?>
                  </select>
                </div>
                <div class="col-md-4">
                 <span class="badge-label">Vehicle Type</span>
                 <select name="vt_id" class="select form-control vt_id">
                  <option value="0" >Select</option>
                  <?php   
                  if( count($vts) > 0){
                    foreach($vts as $v){ ?>
                      <option <?php echo(!empty($vt_id) && $vt_id==$v["vehicle_type_id"])?'selected':'';?> value="<?= $v["vehicle_type_id"] ?>" ><?= $v["name"] ?> </option>
                    <?php } } ?>
                  </select>
                </div>
                <div class="col-md-4">
                  <span class="badge-label">Material Type</span>
                  <select name="mt_id" class="select form-control mt_id">
                    <option value="0" >Select</option>
                    <?php   
                    if( count($mts) > 0){
                      foreach($mts as $m){ ?>
                        <option <?php echo(!empty($mt_id) && $mt_id==$m["material_type_id"])?'selected':'';?> value="<?= $m["material_type_id"] ?>" ><?= $m["name"] ?> </option>
                      <?php } } ?>
                    </select>

                  </div>
                </div>
                <div  class="row">
                  <div class="col-md-4 pull-right text-right" style="padding-top: 10px;padding-bottom: 10px;">
                    <button class="btn button-save btn-save" type="submit"><i class="fa fa-check" aria-hidden="true"></i> Show</button>
                    <a href="<?=site_url('entry');?>" title="Clear" class="btn btn-clr button-cancel"><i class="fa fa-times" aria-hidden="true"></i> Clear</a>
                  </div>
                </div>
              </div>
            </form>
            <?php if(!empty($recs)){ ?>
             <table style1="width: 100%" class="table table-striped table-hover table-bordered" id="data_table">
              <thead>
               <tr>
                <th class="th-sno">SNo.</th>
                <th class="th-action">Entry No.</th>
                <th class="th-action">Entry Date</th>
                <th class="th-action">Vehicle No.</th>
                <th class="th-action">Vehicle Type</th>
                <th class="th-action">Load Type</th>
                <th class="th-action">Material Type</th>
                <th class="th-action">Total Weight</th>
                <th class="th-action">Empty Weight</th>
                <th class="th-action">Nett Weight</th>
                <th class="th-action">Nett Amount</th>
                <th class="th-name">Action</th>
              </tr>
            </thead>
            <tbody>
             <?php
             if( count($recs) > 0){
              foreach($recs as $key => $rec){ 
               $id = $rec["entry_id"];
               ?>
               <tr class="odd gradeX">
                <td style="text-align:center"><?=$key+1?></td>
                <td><?=$rec['entry_no']?></td>
                <td><?=date('d/m/Y h:i A', $rec['entry_date']); ?></td>
                <td><?=$rec['veh_no']?></td>
                <td><?=$rec['vt_name']?></td>
                <td><?=$rec['load_type']=='E'?'Empty':'Loaded'?></td>
                <td><?=$rec['mt_name']?></td>
                <td><?=$rec['tot_wt']?></td>
                <td><?=$rec['empty_wt']?></td>
                <td><?=$rec['net_wt']?></td>
                <td><?=$rec['net_amt']?></td> 
                <td> 
                  <a target="_blank" style="margin-top:5px" class="btn_edit btn btn-success" href="<?=site_url('entry-pdf/'.$id)?>"><i class="fa fa-file-pdf-o" title="PDF"></i></a>

                  <a target="_blank" style="margin-top:5px;margin-right: 0px !important;padding-left: 10px;padding-right: 10px;" class="btn_edit btn btn-info" href="<?=site_url('entry-print/'.$id)?>"><i class="fa fa-print" title="PDF"></i></a>
                </td>
              </tr>
            <?php  }
          } ?>          
        </tbody>             
      </table>
    <?php }else{ ?>
     <div class="alert alert-info">No Survey added.</div>
   <?php } ?>
 </div>
</div>
</div>
</div>
</section> 

</div>
</div>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
  $('body').addClass('sidebar-collapse');

  $( ".date_inp" ).datepicker({
    dateFormat: "dd-mm-yy",
  });

  $(document).ready(function() {
   $('.select').select2();
   var $tot_cols = parseInt(8);
   $("#btn_add").click(function(){
    $("#entry-content").toggle();
    $('#clk-angle').toggleClass('fa-angle-up').toggleClass('fa-angle-down');
  });
   $('#data_table').DataTable({
    "scrollX": true,
    "columnDefs": [
    { "orderable": false, "targets": [$tot_cols]},
    { "orderable": true, "targets": [0, 1]}
    ],
    "aaSorting": []
  });
 });

  function del_confirm(e) {
    var id = e.value;
    $.confirm({
      icon: 'fa fa-warning',
      title: 'Confirm!',
      content: 'Do you want to Delete ?',
      type: 'red',
      buttons: {
        confirm:  {
          btnClass: 'btn-red',
          action: function(){
            $.confirm({
              icon: 'fa fa-warning',
              title: 'Confirm!',
              content: 'If you Delete, You cant restore this record !',
              type: 'red',
              buttons: {
                Okay: {
                  btnClass: 'btn-red',
                  action: function(){
                    $.ajax({
                      url : "<?= site_url('aj_data') ?>",
                      data: 'action=del_setting&type=entry&type_str=entry&id='+id,
                      success: function (res) {
                        if(res == 'S'){
                          window.location.reload();
                        }
                        else{
                          $.alert(res);
                        }
                      }
                    });
                  }
                },
                Cancel: function () { },
              }
            });
          }
        },
        cancel: function () { },
      }
    });
  }  
</script>
