<?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>
                       Staff Attendance
                      
                    </h1>
                   
                </section>
                   <div class="panel-body">
                            <div class="row">
   <div class="alert alert-info">Staff Attendance</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">Today</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="bm12" name="date" required  value="" placeholder="Pay Date" onfocus="insertDate(this,'DD-MM-YYYY')">
    </div>   
</div>	
<?php $i=1;    $qry=mysqli_query($conn, "select * from customer");
				while($row=mysqli_fetch_array($qry))
				{
?> 
    <div class="row">
  <div class="col-xs-6">
  <?php echo $row['code'];?>    <?php echo $row['name'];?></div>
  <div class="col-xs-6">
   <div class="radio">
  <label class="radio-inline">
  <input type="radio" name="as<?php echo $i; ?>" id="inlineRadio2" value="p" checked> Present
</label>
</div>
 <div class="radio">
<label class="radio-inline">
  <input type="radio" name="as<?php echo $i; ?>" id="inlineRadio3" value="a"> Absent
</label>
</div>
<div class="radio">
<label class="radio-inline">
  <input type="radio" name="as<?php echo $i; ?>" id="inlineRadio3" value="h"> Half
</label>
</div>

<div class="radio">
<label class="radio-inline">
  <input type="radio" name="as<?php echo $i; ?>" id="inlineRadio3" value="P1/2H"> Half Hour Permission
</label>
</div>

<div class="radio">
<label class="radio-inline">
  <input type="radio" name="as<?php echo $i; ?>" id="inlineRadio3" value="P1H"> 1 Hour Permission
</label>
</div>

<div class="radio">
<label class="radio-inline">
  <input type="radio" name="as<?php echo $i; ?>" id="inlineRadio3" value="P2H"> 2 Hour Permission
</label>
</div>

<div class="radio">
<label class="radio-inline">
  <input type="radio" name="as<?php echo $i; ?>" id="inlineRadio3" value="P3H"> 3 Hour Permission
</label>
</div>
<div class="radio">
<label class="radio-inline">
  <input type="radio" name="as<?php echo $i; ?>" id="inlineRadio3" value="P4H"> 4 Hour Permission
</label>
</div>

</br>
</div>
</div>	<?php $i++; } ?>

        <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="s11">Register</button>
    </div>
  </div>
													<div class="alert alert-warning">
							<?php
							if(isset($_POST['s11']))
							{
								extract($_POST);
								$insert=mysqli_query($conn, "INSERT INTO attt(date,std,as1,as2,as3,as4,as5,as6,as7,as8,as9,as10,as11,as12) 
								VALUES ('$date', '$std', '$as1', '$as2', '$as3', '$as4', '$as5', '$as6', '$as7', '$as8', '$as9', '$as10', '$as11', '$as12')");
								if($insert)
								{
									
									echo "Registered Successfully";
									
								}
								else
								{
									echo "Failure";
								}
							}		
							
						   
								
?>	
	  </div>
</form>
</div>
 
 
</div>
  		<?php						$qry=mysqli_query($conn, "select * from customer");
				$row=mysqli_fetch_array($qry);
                $n=mysqli_num_rows($qry);
			$a = 0; $h = 0; $p = 0; $pp = 0; $tot = 0; $dde = 0;	?></p>
					<div class="table-responsive">
  <table class="table table-bordered table-hover"><thead>
  <tr class="info">  
<th>S.No</th>  <th>Date</th>
  <?php 
  $qry=mysqli_query($conn, "select * from customer");
while($row=mysqli_fetch_array($qry))
						{?>
						<th><?php echo $row['name']; ?></th>
						<?php  } ?>
						<?php  if($postt == 'MD') { ?> 	<th>#Cancel</th> <?php } ?>
					</tr></thead>
					<?php $i=1; $ij = 0;
					$qryy=mysqli_query($conn, "select * from attt");
			//	$roww=mysqli_fetch_array($qryy);
					?>
					<tbody>
					<col width="100px">
								<?php		while($roww=mysqli_fetch_array($qryy))
						{ $ij++; ?><tr class="warning">
						    <td><?php echo $ij;?></td>
					<td><?php echo $roww['date'];?></td>
					<?php while($i<=$n) {
                           $as = "as".$i.""; 
						$ax1 = $roww[$as];
						if($ax1 == 'p')
						{ $p = $p + 1; ?>
						<td><font color="green"><?php echo $roww[$as];?></font></td> <?php }
						
						elseif($ax1 == 'a')
						{ $a = $a + 1; ?>
						<td><font color="red"><?php echo $roww[$as];?></font></td> <?php }
						 
						  elseif($ax1 == 'h')
						{ $h = $h + 1; ?>
						<td><font color="blue"><?php echo $roww[$as];?></font></td> <?php }
						else
						{ $pp = $pp + 1; ?>
						<td><font color="black"><?php echo $roww[$as];?></font></td> <?php }
						
						
							$i++; }
						  ?>
						  <?php  if($postt == 'MD') { ?>     
				<td><b>

</br><a href="cancelatt.php?id=<?php echo $roww['id'];?>" class="btn btn-primary btn-xs" onclick="return confirm('Are you sure WANT TO CANCEL?');">Cancel</a></b></td>	
					<?php } ?>
					</tr>
					<?php $i=1;} ?></tbody>					
					</table><?php $tot = $p + ($h / 2) ; ?> Total Days Prensent = <?php echo $tot; ?> For <?php echo $dde; ?> Days                         </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>