<?php include "layouts/menu.php"; ?>
		<script type="text/javascript">
	  $(function() {
   $("#datepicker").datepicker({ dateFormat: 'dd-mm-yy' });
  });
</script>
<script type="text/javascript">
function zp(n){
return n<10?("0"+n):n;
}
function insertDate(t,format){
var now=new Date();
var DD=zp(now.getDate());
var MM=zp(now.getMonth()+1);
var YYYY=now.getFullYear();
format=format.replace(/DD/,DD);
format=format.replace(/MM/,MM);
format=format.replace(/YYYY/,YYYY);
t.value=format;
}
</script>
    <script>
  $(function() {
   $("#datepicker1").datepicker({ dateFormat: 'dd-mm-yy' });
  });
  </script>
    <script>
  $(function() {
   $("#datepicker2").datepicker({ dateFormat: 'dd-mm-yy' });
  });
  </script>
      <script>
  $(function() {
   $("#datepicker8").datepicker({ dateFormat: 'dd-mm-yy' });
  });
  </script>
    <script>
  $(function() {
   $("#datepicker9").datepicker({ dateFormat: 'dd-mm-yy' });
  });
  </script>
   <script>
function add()
{
var x = document.getElementById("txt1").value;
var y = document.getElementById("txt2").value;
document.getElementById("bal").value =(x*1)-(y*1);
}
</script>
     
  <?php include "layouts/menu1.php"; ?>
            <!-- Right side column. Contains the navbar and content of the page -->
           <div class="right_col" role="main">
                <!-- Content Header (Page header) -->
                <section class="content-header">
                    <h1>
                       VEHICLE Details
                      
                    </h1>
                   
                </section>
                   <div class="panel-body">
                            <div class="row">
   <div class="alert alert-info">Register VEHICLE  Details</div>
   <form name="form1" class="form-horizontal" method="post" action="vehicle.php" enctype="multipart/form-data">
   <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">VEHICLE NO</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="inputPassword3" name="debit" value="" placeholder="" required>
    </div>
  </div>
   <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">INSURANCE DATE</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="inputPassword3" name="cat" value="" placeholder="DD/MM/YYYY" onfocus="insertDate(this,'DD-MM-YYYY')">
	 
	  
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">FC Date</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="datepicker" name="date" value="" placeholder="DD/MM/YYYY" onfocus="insertDate(this,'DD-MM-YYYY')">
    </div>
  </div>
	    <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">NEXT OIL SERVICE</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="inputPassword3" name="oil" value="" placeholder="" >
    </div></div>
			 <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">NEXT WHEEL BALANCE</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="inputPassword3" name="wheel" value="" placeholder="" >
    </div></div>
				 <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">NEXT WATER SERVICE</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="inputPassword3" name="water" value="" placeholder="" >
    </div></div>
    <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">NEXT BATTERY SERVICE</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="inputPassword3" name="bat" value="" placeholder="" >
    </div></div>
    <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Details</label>
    <div class="col-sm-4">
      <textarea class="form-control" rows="3" name="details" value="" placeholder=""></textarea>
    </div>
  </div>  
  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <button type="submit" class="btn btn-default" name="s1">Save This</button>
    </div>
  </div>
      <div class="alert alert-success">
	 <?php
							if(isset($_POST['s1']))
							{
								extract($_POST);
								$insert=mysqli_query($conn, "insert into veh(mfin,scode,debit,date,cat,oil,wheel,water,bat,details)
											 values('$mfin','$scode','$debit','$date','$cat','$oil','$wheel','$water','$bat','$details')");
								
								if($insert)
								{
									
									echo "Registered Successfully";
									
								}
								else
								{
									echo "Failure";
								}
							}
?>
	  </div>
</form>
</div>
 
 
</div>
  		
				
                    <?php
					
						$qry=mysqli_query($conn, "select * from veh");
						$n=mysqli_num_rows($qry);
						if($n==0)
						{
							echo "Nothing To Display";
						}
						else
						
					{ 
						?>
                <!-- Main content -->
                <section class="content">
                    <div class="row">
                        <div class="col-xs-12"> 
                            <div class="box">
                               <!-- /.box-header -->
                                <div class="box-body table-responsive">
                                    <table id="table2" class="table table-bordered table-striped">
                                        <thead>
                                            <tr>
											
												<th>NO</th>
												<th>INS DATE</th>
												<th>FC DATE</th>
												<th>OIL SERVICE</th>
												<th>WHEEL ALN</th>
												<th>WATER SER</th>
												<th>DETAILS</th>
												<th>UPDATE</th>
                                            </tr>
                                        </thead>
										<?php 
					while($row2=mysqli_fetch_array($qry))
						{
					?>
                                        <tbody>
                                           <tr>
                                              
						<td><?php echo $row2['debit']; ?></td><td><?php echo $row2['cat']; ?></td>
						<td><?php echo $row2['date']; ?></td>
											   <td><?php echo $row2['oil']; ?></td>
											   <td><?php echo $row2['wheel']; ?></td>
											   <td><?php echo $row2['water']; ?></td>
											   <td><?php echo $row2['details']; ?></td>
						<td><a href="uvehicle.php?did=<?php echo $row2['did'];?>">Edit</a></td>
                                            </tr>
                                          </tbody>
                                        <?php
						}
					}
				
					?>
					                    
                                    </table>		
                                </div><!-- /.box-body -->
                            </div><!-- /.box -->
                        </div>
                    </div>

                </section><!-- /.content -->
            </aside><!-- /.right-side -->
        </div><!-- ./wrapper -->


        <!-- jQuery 2.0.2 -->
       <?php include "layouts/footer.php"; ?>

    </body>
</html>