<?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();
var H=now.getHours();
var M=now.getMinutes();
var S=now.getSeconds();
format=format.replace(/DD/,DD);
format=format.replace(/MM/,MM);
format=format.replace(/YYYY/,YYYY);
format=format.replace(/H/,H);
format=format.replace(/M/,M);
format=format.replace(/S/,S);
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>
                       LEAVE APPLY
                      
                    </h1>
                   
                </section>
                   <div class="panel-body">
                            <div class="row">
   <div class="alert alert-info">Staff Leave Apply</div>
  <form name="form1" class="form-horizontal" method="post" action="" enctype="multipart/form-data">
	<?php
				$qry=mysqli_query($conn, "select * from customer");
				$row=mysqli_fetch_array($qry);
				?>
				 <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Employee Name</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="bm12" name="name"  value="" placeholder="Name">
    </div>   
</div>	
	 <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Leave Type</label>
    <div class="col-sm-4">
      <Select type="text" class="form-control" id="bm12" name="ltype"  value="" placeholder="Type" required>
	  	  <option> Sick Leave</option> 
		   <option> General Leave</option>
		    <option> LOP Leave</option>
			 <option> Half Day</option>
		   </select>
    </div>   
</div>	
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">From Date & Time</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="bm12" name="fdate"  value="" placeholder="From" onfocus="insertDate(this,'DD-MM-YYYY-H:M:S')">
    </div>   
</div>	

  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">To Date & Time</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="bm12" name="tdate"  value="" placeholder="To" onfocus="insertDate(this,'DD-MM-YYYY-H:M:S')">
    </div>   
</div>	  
<div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Comments</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="bm12" name="comments"  value="" placeholder="Comments" required>
    </div>   
</div>	
        <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <button type="submit" class="btn btn-primary  btn-lg btn-block" name="s12">Apply</button>
    </div>
  </div>
													<div class="alert alert-warning">
							<?php
							if(isset($_POST['s12']))
							{
								extract($_POST);
								$insert=mysqli_query($conn, "INSERT INTO lapply(ltype,fdate,tdate,comment,name) 
								VALUES ('$ltype', '$fdate', '$tdate', '$comments','$name')");
								if($insert)
								{
									
									echo "Registered Successfully";
									
								}
								else
								{
									echo "Failure";
								}
							}		
							
						   
								
?>	

	  </div>
</form>
</div>
 
 
</div>

                    <?php
					
						$qry=mysqli_query($conn, "select * from lapply");
						$n=mysqli_num_rows($qry);
						if($n==0)
						{
							echo "Nothing To Display";
						}
						else
						
					{ 
						?>
					
  <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>Name</th>
												<th>Leave Type</th>
												<th>From Date</th>
												<th>To Date</th>
												<th>Comments</th>
                                            </tr>
                                        </thead>
										<?php 
					while($row2=mysqli_fetch_array($qry))
						{
					?>
                                        <tbody>
                                           <tr>
                                               <td><?php echo $row2['name'];?></td>
						<td><?php echo $row2['ltype']; ?></td><td><?php echo $row2['fdate']; ?></td>
						<td><?php echo $row2['tdate']; ?></td><td><?php echo $row2['comment']; ?></td>
                                            </tr>
                                          </tbody>
                                        <?php
						}
					}
				
					?>
					                    
                                    </table>		
                                </div><!-- /.box-body -->
                            </div><!-- /.box -->
                        </div>
                    </div>

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

					
					<!-- /.box-body -->
                         <!-- /.box -->
                        </div>
                    </div>

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


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

    </body>
</html>