<?php include('common/header.php'); ?>
  <!-- Main Sidebar Container -->
<?php include('common/sidenav.php'); ?>

<?php

//for admin brands

include('includes/config.php');
$d = '';

$query = "SELECT * FROM `vehicles` ORDER BY name ASC";
$result = mysqli_query($con, $query);
while($row = mysqli_fetch_array($result))
{
 $d .= '<option value="'.$row["vehicle_id"].'">'.$row["name"].'</option>';
}
?>
  


  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
  

    <!-- Content Header (Page header) -->
    <section class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1>Driver List</h1>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"> <button id="formButton" type="button"  class="btn btn-danger"><i class="fa fa-plus">Add New</i></button></li>
             
            <!--  <li class="breadcrumb-item active"><a href="#">Dashboard</a></li>-->
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>

    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-12">


            <div class="card">
              <div class="card-header">
                                  
    <!-- add driver -->
    
      	<form id="form1" class="form-hidden" method="post">
          			<h3>Add Info</h3>

          	    <div class="row">
          	        <div class="col-md-4">
          	            <div class="form-group">
          	                  <label>Name</label>
                 <input type="text" placeholder="Full Name" required="required" class="form-control" name="name">
          	            </div>
          	            
          	        </div>
                     <div class="col-md-4">
                        <div class="form-group">
                              <label>Vehicle</label>
                            <select class="form-control action" name="vehicle" id="vehicle" required="required">
                                <option value="">Select Model</option>
                              <?php echo  $d ; ?>
                            </select>
                        </div>
                        
                    </div>
          	      
          	       <div class="col-md-4">
                        
                        
                        <div class="form-group">
                              <label>Reg No#</label>
                            <select readonly class="form-control action" id="regno" name="regno" required="required">
                                <option value="">Select Reg No#</option>
                               
                            </select>
                        </div>
                        
                    </div>
          	    </div>

                <div class="row">
                     <div class="col-md-4">
                       <div class="form-group">
                              <label>Phone No#</label>
                                <input type="number" placeholder="Phone No" required="required" class="form-control" name="phone">
                      </div>       
                        
                    </div>
                    <div class="col-md-4">
                       <div class="form-group">
                              <label>Cnic</label>
                 <input type="number" placeholder="Cnic" required="required" class="form-control" name="cnic">
                        </div>
                        
                        
                    </div>
                     <div class="col-md-4">
                       <div class="form-group">
                              <label>City</label>
                                <input type="number" placeholder="City Name" required="required" class="form-control" name="city">
                      </div>       
                        
                    </div>
                  
                      
                </div>
                <div class="row">
                    <div class="col-md-4">
                         <div class="form-group">
                        <label>Address</label>
                        <textarea name="address" placeholder="Address" class="form-control"></textarea>
                    </div></div>
                </div>

                <div class="row">
                  <div class="col-md-6">
                      <div class="form-group">
                           
                      <div class="form-example-int mg-t-15">
                            <button name="submit" class="btn btn-danger notika-btn-success">Submit</button>
                        </div>
                     
                  </div>
                </div>
                </div>
           </form>
              

    <!-- end add driver -->
                <h3 class="card-title">Lists</h3>
              </div>
        
              <!-- /.card-header -->
              <div class="card-body">
               <table id="example1" class="table table-striped">
                  <thead class="bg bg-danger">
                  <tr>
                    <th>S No</th>
                    <th>Name</th>
                    <th>Cnic</th>
                    <th>Phone</th>
                    <th>Vehicle</th>
                    <th>City</th>
                    <th>Address</th>
                    <th>Action</th>
                  </tr>
                  </thead>
                  <tbody>

  <?php
    /*include('admin/includes/config.php');
               
      $no=0;
      $result = mysqli_query($con, "SELECT * FROM `laptops` as l JOIN brands as b ON l.brand_id = b.brand_id ORDER BY l.laptop_id ASC");
       while($row = mysqli_fetch_assoc($result)) {
       $no++; 
      */ 
          
  ?>
                  <tr>
                      <?php //$id = $row['laptop_id']; ?>
                    <td>1<?php //echo $no; ?></td>
                    <!--<td><center><img src="uploads/laptop/<?php// echo $row['image'];?>" height="100px" width="70px"/></center>
                          </td>-->
                    <td>Saad</td>
                    <td>4213-3*****2-1</td>
                    <td>0334292***</td>
                    <td>Shezor</td>
                    <td>Karachi</td>
                    <td>Site Area</td>
                    <td>
                        <a href="?id=<?php echo $row['laptop_id']; ?>">
                  <i class="fas fa-edit"></i>
                          ||
                        <a  onclick="return confirm('Are you sure <?php echo $row['laptop_title']; ?> ?')" href="?id=<?php echo $id; ?>"  ><i style="font-size:15px; color:red;"  class="fa fa-trash"></i></a>
                        
                    </td>
                    
                  </tr>

                    


    <?php
   // }

  
  ?>
 
                  </tbody>
                </table>
                     
                
                
                
                
                
              </div>
              <!-- /.card-body -->
            </div>
            <!-- /.card -->
          </div>
          <!-- /.col -->
        </div>
        <!-- /.row -->
      </div>
      <!-- /.container-fluid -->
    </section>
    <!-- /.content -->



<script>
  //show a confirmation and redirect to the delete profile script
  function deleteProfile() {
    if (confirm("Do you really want to delete your profile?")) {
        //location.href = '/deleteuser.php';
    }
}

//dropdown
 //select 2
 //select drop2
  $('.action').change(function(){
  if($(this).val() != '')
  {
   var action = $(this).attr("id");
   var query = $(this).val();
   var result = '';
   if(action == "vehicle")
   {
    result = 'regno';
   }
   $.ajax({
    url:"fetch_model.php",
    method:"POST",
    data:{action:action, query:query},
    success:function(data){
     $('#'+result).html(data);
    }
   })
  }
  //select drop2
  });

</script>


  </div>
  <!-- /.content-wrapper -->


<?php include('common/footer.php'); ?>