<?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;
		 
		
?>
<!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"> Studnet Attendance Report All Classes</strong>
                            </div>
                            <div class="card-body">
							<?php

include 'dbc.php';


$userid=$_SESSION["userid"];
$adate=$_POST["adate"];
$status=$_POST["status"];


?>
                                <table id="bootstrap-data-table-export" class="table table-striped table-bordered">
                                    <thead>
									<?php
                                       echo "<tr>";
echo "<th > Date</th>";
echo "<th > Class</th>";
echo "<th > Total Students</th>";

echo "<th > Present </th>";
echo "<th > Absent </th>";
echo "<th > Leave </th>";
echo "<th > Holidays</th>";
echo "<th > Present Percentage</th>";

echo "</tr>";
$sql = "SELECT * FROM addclass where  user_id='$userid'";
$result=$conn->query($sql);
  while($row = $result->fetch_assoc())
   {
   $class_name=$row["cname"];
?>
                                    </thead>
									
                                    <tbody>
									<?php
                                     
  $cnt=$cnt + 1;
  $p=0;
$a=0;
$l=0;
$i=0;
$t=0;
$per=0;
   $sql3= "select * from admission where class_name = '$class_name' and user_id='$userid'";
  $result3=$conn->query($sql3);

while($row3 = $result3->fetch_assoc())
  {
 $t=$t +1;
   
  } 
 
  
  $sql3p = "select * from attendence where class_name = '$class_name' and date = '$adate' and status = 'P' and user_id='$userid'";
  $result3p=$conn->query($sql3p);

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

while($row3a = $result3a->fetch_assoc())
  {
 $a=$a +1;
   
  } 

 $sql3l = "select * from attendence where  class_name = '$class_name' and date = '$adate' and status = 'L' and user_id='$userid'";
  $result3l=$conn->query($sql3l);

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

 $sql3i = "select * from attendence where  month_name = '$month_name' and date = '$adate' and status = 'H' and user_id='$userid'";
  $result3i=$conn->query($sql3i);

while($row3i = $result3i->fetch_assoc())
  {
 $i=$i +1;
   
  } 
$per=$p / $t * 100;
  echo "<tr>";
   echo "<td >"      .$adate . "</td>" ;
    echo "<td >"      .$class_name. "</td>" ;
	  
   echo "<td >" .$t . "</td>" ;
   echo "<td >" .$p . "</td>" ;
    echo "<td >"  .$a . "</td>" ;
	  echo "<td >"  .$l . "</td>" ;
	 echo "<td >"  .$i . "</td>" ;
	 echo "<td >"  . round($per,0) .  "%" . "</td>" ;
   
   
   echo "</tr>";
    
   $tp=$tp + $p;
   $ta=$ta + $a;
   $ti=$ti + $i;
   $tl=$tl + $l;
 $tstd=$tp + $ta + $ti + $tl;
 $tper=$tp / $tstd * 100;
 $tper=round($tper,0);
  }
  echo "<tr>";
  
 echo "<th colspan=2>Total</th>";
 echo "<th> $tstd </th>";
  echo "<th> $tp </th>";
   echo "<th> $ta </th>";
    echo "<th> $tl </th>";
   echo "<th> $ti </th>";
   echo "<th> $tper% </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
}

?>