<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>assets-bustracking/css/style-drivers.css">

<main class="common_margin" id="main">
    <div class="row dash-main-row">
        <div class="col-md-12 col-lg-12 p-0">
            <div class="block-head">                
                    <h3 class="dash-tab-head">Trips</h3>                    
            </div>
                <div class="block-head">
                    <div class="block-head-left">
                        <form id="" method="post" action="<?php echo base_url('trips') ?>"> 
                            <div class="block-head-left-2-2-students">
                                <p class="block-head-left-2-2-filter">Dates</p>
                                <input type="text" class="form-control trip-dates" value="<?php echo $search_date; ?>" id="search_date" name="search_date">
                            </div>
                           
                           <div class="block-head-left-2-2-students">
                                <input type="submit" name="submit" class="btn btn-info mt-4">                   
                            </div>
                        </form>
                    </div>

                    
            </div>
            <table class="table dash-table">
                <thead>
                  <tr>
                    <th scope="col" class="dash-th">S.NO</th>
                    <th scope="col" class="dash-th rooms-th">Route Name</th>
                    <th scope="col" class="dash-th rooms-th">Driver</th>
                    <th scope="col" class="dash-th rooms-th">Bus</th>
                    <th scope="col" class="dash-th rooms-th">No of Stops</th>
                    <th scope="col" class="dash-th rooms-th">Trip Type</th>
                    <th scope="col" class="dash-th rooms-th">Status</th>
                    <th scope="col" class="dash-th rooms-th">Action</th>
                  </tr>
                </thead>
                <tbody>

                  
            <?php 
                if(isset($search) && !empty($search)){
                    $i = 1;
                    foreach($search as $key => $value){ ?>
                    <tr>
                        <td class=""><?= $i ?></td>
                        <td class="rooms-td"><?= $value['route_name'] ?></td>
                        <td class="rooms-td"><?= $value['driver_name']; ?></td>
                        <td class="rooms-td"><?= $value['reg_no']; ?></td>
                        <td class="rooms-td"><?= $value['stops']; ?></td>
                        <td class="rooms-td"><?= ucfirst($value['trip_type']); ?></td>        
                        <td class="rooms-td"><?= $value['status']; ?></td>
                      
                        <td class="rooms-td"><button class="btn student-manage-btn trip-details-btn"><a href="<?php echo base_url() ?>BustrackingAdmin/trip_details/<?php echo base64_encode('_hello_ '.$value['route_id'].' _hello_ '. $value['trip_type'].' _hello_ '.$search_date .' _hello_ '. $value['trip_id']); ?>">View Details</a> </button></td>
                        
                      </tr>
            <?php $i++; }
                }
             ?>                  

                </tbody>
              </table>

              <div class="table-footer">
                  <div class="table-footer-left">
                    <p>Showing 1 of 200 entries</p>
                  </div>
                  <div class="table-footer-right">
                      <p class="footer-right-prev">Previous</p>
                      <p class="tab-footer-count">1</p>
                      <p class="footer-right-next">Next</p>
                  </div>

              </div>
    </div>
    </div>
</main> 
                <!--End right-top side-->   
    </div>

    <script src="<?php echo base_url();?>assets-bustracking/js/jquery-3.4.1.min.js" ></script>
    <script src="<?php echo base_url();?>assets-bustracking/js/popper.min.js"></script>
    <script src="<?php echo base_url();?>assets-bustracking/js/bootstrap.min.js"></script>
    <script src="https://cdn.datatables.net/1.10.22/js/jquery.dataTables.min.js"></script>
    <script defer src="<?php echo base_url();?>assets-bustracking/js/all.js"></script>
    <script defer src="<?php echo base_url();?>assets-bustracking/js/main.js"></script> 
    <script src="<?php echo base_url();?>assets-bustracking/owl-carousel/js/owl.carousel.min.js"></script>
     <script src="<?php echo base_url(); ?>assets-bustracking/js/nepali.datepicker.v3.7.min.js" type="text/javascript"></script>
    <script>
        $(document).ready(function(){
            /* Select your element */
                let NDate = NepaliFunctions.GetCurrentBsDate();
                let todayDate = `${NDate.year}-${NDate.month}-${NDate.day}`;
                /* Initialize Datepicker with options */
                $('.trip-dates').nepaliDatePicker({
                    disableAfter: todayDate,
                    language:'english',

                });

            // nepali date end

            $('.user-drpdown').click(function(){
                $('.drpdown-items').toggle();
            });
        }); 
        //table js
        $('#tbl').DataTable( {
            "lengthMenu": [[5,10, 25, 50, -1], [5,10, 25, 50, "All"]]
        } );
        //table js end
    </script> 
    <script>
        function goBack() {
          window.history.back();
        }
      </script>
</body>
</html>