<?php
session_start();
if($_SESSION["username"]=="")
{
 	echo "You are not Logged in Please <a href='index.html'>Sign in </a> First ";
}
else
{


include 'dbc.php';
$class_name=$_REQUEST["cname"];
$userid=$_SESSION["userid"];
$today=date("Y-m-d");
$month = date("m",strtotime($today));
		$year = date("Y",strtotime($today));
		 $month_name = date("F", mktime(0, 0, 0, $month, 10));
		
		
		 $my=$month_name . " " . $year;
		 $month_name=$_POST["adate"];
$status=$_POST["status"];

		
?>
<!doctype html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang=""> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8" lang=""> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9" lang=""> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js" lang="en">
<!--<![endif]-->

<head>
   <?php include("includes/header.php") ?>
</head>

<body>


    <!-- Left Panel -->

    <!-- /#left-panel -->

    <!-- Left Panel -->

    <!-- Right Panel -->

    <div id="right-panel" class="right-panel">

        <!-- Header-->
        <header id="header" class="header">

            

        </header><!-- /header -->
        <!-- Header-->

        

        <div class="content mt-3">

           


          
<div class="col-md-14">
                        <div class="card">
                            <div class="card-header">
							 <strong class="card-title"> <center> <img src="logo1.jpg" align="middle" /></center></strong>
                        <h2><center><? echo "" . $_SESSION["userid"]; ?></center></h2>
                                <strong class="card-title"><center> Staff Attendance Report for the month of: <? echo $month_name; ?> </center></strong>
                            </div>
                            <div class="card-body">
							<?php

include 'dbc.php';


$userid=$_SESSION["userid"];

$sql11 = "SELECT * FROM teacher where status = 'Active' and user_id='$userid' order by id";
$result11=$conn->query($sql11);
?>
                                <table id="bootstrap-data-table-export" class="table table-striped table-bordered">
                                    <thead>
									<?php
                                       echo "<tr>";
echo "<th > S.no</th>";
echo "<th > Teacher Id </th>";
echo "<th > Staff Name </th>";
echo "<th > Father Name </th>";
echo "<th > Desg</th>";
echo "<th >Staff Level </th>";

echo "<th > Present </th>";
echo "<th > Absent </th>";
echo "<th > Leave </th>";
echo "<th > InTime </th>";
echo "<th > Late</th>";

echo "</tr>";
?>
                                    </thead>
									
                                    <tbody>
									<?php
                                       while($ppp = $result11->fetch_assoc())
 
  {
  $cnt=$cnt + 1;
  $p=0;
$a=0;
$l=0;
$le=0;
$i=0;
   $rollno = $ppp['id'];	
  $sql3p = "select * from attendence_tech where rollno='$rollno'  and month_name = '$month_name' and status = 'P' and user_id='$userid'";
  $result3p=$conn->query($sql3p);

while($row3p = $result3p->fetch_assoc())
  {
 $p=$p +1;
   
  } 
  $sql3a = "select * from attendence_tech where rollno='$rollno'  and month_name = '$month_name' and status = 'A' and user_id='$userid'";
  $result3a=$conn->query($sql3a);

while($row3a = $result3a->fetch_assoc())
  {
 $a=$a +1;
   
  } 
  $sql3le = "select * from attendence_tech where rollno='$rollno'  and month_name = '$month_name' and status = 'L' and user_id='$userid'";
  $result3le=$conn->query($sql3le);

while($row3le = $result3le->fetch_assoc())
  {
 $le=$le +1;
   
  } 

 $sql3l = "select * from attendence_tech where rollno='$rollno'  and month_name = '$month_name' and portal_id = 'Late' and user_id='$userid'";
  $result3l=$conn->query($sql3l);

while($row3l = $result3l->fetch_assoc())
  {
 $l=$l +1;
   
  } 

 $sql3i = "select * from attendence_tech where rollno='$rollno'  and month_name = '$month_name' and portal_id = 'In Time' and user_id='$userid'";
  $result3i=$conn->query($sql3i);

while($row3i = $result3i->fetch_assoc())
  {
 $i=$i +1;
   
  } 

  echo "<tr>";
   echo "<td >"  .$cnt . "</td>" ;
   echo "<td >"  .$ppp["teacher_id"] . "</td>" ;
   echo "<td >"  .$ppp["tech_name"] . "</td>" ;
   echo "<td >"  .$ppp["father_name"] . "</td>" ;
    echo "<td >"  .$ppp["class_name"] . "</td>" ;
    echo "<td >"  .$ppp["marital"] . "</td>" ;
	  
   
   echo "<td >"  .$p . "</td>" ;
    echo "<td >"  .$a . "</td>" ;
	 echo "<td >"  .$le . "</td>" ;
	  echo "<td >"  .$i . "</td>" ;
	 echo "<td >"  .$l . "</td>" ;
   
    
	 
     echo"<th> <a href ='Teacher_Attendance_Report_Monthly.php?rollno=$rollno&month_name=$month_name' target=_blank>"?><button type="button" class="btn btn-primary">  Monthly Report</button><?php "</a>";

   echo "</tr>";
    
   }
   echo "<tr>";
 echo "<th  colspan=8>" ."Toatl  Staff   :     " .$cnt . "</th>";
 echo "</tr>";
 
   echo "</table>";


	
  ?>
                                       
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
            


        </div> <!-- .content -->
    </div><!-- /#right-panel -->

    <!-- Right Panel -->

   <?php include("includes/footermenu.php") ?>

</body>

</html>
<?php
}

?>