<?php include('parent/callMe.php');?>
<?php include('Sessioncheck.php');?>
<?php 


  $m->where("branch_id", $_SESSION['branch']);
  $branch=$m->get("edu_branch_config");


$brnch=$_SESSION['branch'];
$date=date('Y-m-d');

$WorkAssignListings = $m->query("SELECT sec.*, cls.* FROM edu_adm_section_detail as sec LEFT JOIN edu_class_config as cls ON sec.class_id = cls.class_id where cls.class_id!='' and cls.branch_id='$brnch' ORDER BY cls.class_id asc");


      $m->where("status", 0);
      $m->where("branch_id", $_SESSION['branch']);
      $total_students=$m->get("edu_student_details");
 
?>
 <!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Favicons-->
<link rel="icon" type="image/png" href="img/favicon.png" sizes="32x32" />
<title> Print Students Report </title>

<script type="text/javascript">
 // window.print();
</script>
<style type="text/css">
.border{border:1px solid black;}
.center{text-align:center;}
.alignment{padding-left:1%;text-align:left;}

tr th {padding:1.5%;font-size:16px; }
tr td {padding:1%;}



@media print {
    #Header, #Footer { display: none !important; }
}
@media screen
   {
      p.bodyText {font-family:verdana, arial, sans-serif;}
   }

   @media print
   {
      p.bodyText {font-family:georgia, times, serif;}
   }
   @media screen, print
   {
      p.bodyText {font-size:10pt}
   }
   @media print {
  a[href]:after {
    content: none !important;
  }
}
</style>
</head>
<body style="padding:2%;">



<div style="text-align:center;font-size:25px;font-weight:bold;margin:0 auto;"><b><?php echo $branch[0]['Branch_Name'];?> </b> </div>

<div style="text-align:center;font-size:14px;"><?php echo $branch[0]['Branch_Location']." Cell: ".$branch[0]['Owner_no'];?> </div>

<div style="text-align:center;font-size:18px;font-weight:bold;margin:0 auto;">Students Report </div>

<hr style="width:100%;">

<div style="width:40%;float:left;">  <b> Date:</b> <?php echo date("d-M-Y");?> </div>

<div style="width:20%; float:left; "> <!-- <b> Total Presents:</b> --> </div>

<div style="width:20%; float:left; "><!--  <b> Total Absents:</b> -->  </div>

<div style="width:20%; float:right; "> <b> Total Students:</b> <?php echo count($total_students);?> </div>

<br>



    <table  class="table table-striped table-bordered" cellspacing="0" style="width:100%;border-collapse: collapse;">
        <thead>
            <tr style="background:#042954;color: white;">

                
                <th width="40%" class="border "> Class </th>
                <th width="20%" class="border "> Boys </th>
                <th width="20%" class="border "> Girls </th>
                <th width="20%" class="border "> Total </th>
                
                
            </tr>
        </thead>
        <tbody>


   
     
     <?php 
    $Classes = $m->query("SELECT * FROM edu_class_config where branch_id='$brnch' ORDER BY class_id asc");
   
     $count=1;
      foreach($Classes as $Class)
      { 

    $cls=$Class['class_id'];
    $sectionID=$WorkAssignListVal['section_id'];

    $sections = $m->query("SELECT * FROM edu_adm_section_detail where branch_id='$brnch' and class_id='$cls' ORDER BY section_id asc");  


// getting strength of students class wise 

$stds_record_cls = $m->query("SELECT COUNT(*) as total, COUNT(IF(gender = 'Male', 1, NULL)) 'Boys', COUNT(IF(gender = 'Female', 1, NULL)) 'Girls' FROM edu_student_details  where class_id=$cls and STATUS=0 and branch_id=".$_SESSION['branch']);

$std0+=count($total); 

$totalStudent+=$stds_record_cls[0]['total']; 
$totalBoys+=$stds_record_cls[0]['Boys'];
$totalGirls+=$stds_record_cls[0]['Girls'];
      
      
     
      ?>

<tr style="background: lightgrey;font-weight: bold;">

<td class="border" style="padding-left:1%;"> <?php echo  $Class['Class_Name']; ?> </td>
<td class="border" style="text-align:center;"><?php echo $stds_record_cls[0]['Boys'];?></td>
<td class="border" style="text-align:center;"><?php echo $stds_record_cls[0]['Girls'];?></td>
<td class="border" style="text-align:center;"><?php echo $stds_record_cls[0]['total'];?></td>

</tr>


<?php
foreach($sections as $section)
{ 

// getting strength of students section wise 
$secID=$section['section_id'];
$stds_record = $m->query("SELECT COUNT(*) as total, COUNT(IF(gender = 'Male', 1, NULL)) 'Boys', COUNT(IF(gender = 'Female', 1, NULL)) 'Girls' FROM edu_student_details  where class_id=$cls and section_id=$secID and STATUS=0 and branch_id=".$_SESSION['branch']);

$std+=count($total);
//echo $std;
?>
<tr>
<td class="border" style="padding-left:5%;"> <?php echo  $section['section_name']; ?> </td> 

<td class="border" style="text-align:center;"><?php echo $stds_record[0]['Boys'];?></td>
<td class="border" style="text-align:center;"><?php echo $stds_record[0]['Girls'];?></td>
<td class="border" style="text-align:center;"><?php echo $stds_record[0]['total'];?></td>
</tr>

<?php } ?>



              <?php
      } ?>


<tr style="background:#042954;color: white;">
<td class="border" style="text-align:center;">Total</td>
<td class="border" style="text-align:center;"><?php echo $totalBoys;?></td>
<td class="border" style="text-align:center;"><?php echo $totalGirls;?></td>
<td class="border" style="text-align:center;"><?php echo $totalStudent;?></td>

</tr>
           
            
           
        </tbody>
        
    </table>

</body>
</html>
