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

<?php include('Sessioncheck.php');?>

<?php   


     $branch=$_SESSION['branch'];

     $classes = $m->query("select * from edu_class_config where branch_id=".$branch." order by class_id asc limit 1");

     // print_r($classes);

   $session;

   if($_REQUEST['session']!=NULL){

      $session=$_REQUEST['session'];

    } else {

      $session=$_SESSION['current_session'];

    }

     /* code for advance Search*/


$sql = "SELECT * FROM  edu_student_details  WHERE branch_id='$branch' and status='0' and session_id='$session' ";


    if($_REQUEST['class_id']!=NULL){ 

    if($_REQUEST['class_id']=="All"){

      $sql;

    } else {

    $sql .= " AND class_id = '" .$_REQUEST['class_id']. "' ";

    }



    if($_REQUEST['section']!=''){

        $sql .= " AND section_id ='" . $_REQUEST['section']. "' ";

   }


    if($_REQUEST['gender']!=''){      

        $sql .= " AND gender ='" . $_REQUEST['gender']. "' ";

   }

   if($_REQUEST['orderby']=="class"){
      $sql .= " ORDER BY class_id, CAST(ref_no AS SIGNED) ASC";
    } else {
      $sql .= " ORDER BY CAST(ref_no AS SIGNED) ASC";

    }

  //echo $sql;

  $WorkAssignListings = $m->query($sql);

}

 else {

  $sql = "SELECT * FROM  edu_student_details  WHERE branch_id='$branch' and status='0'";

  $WorkAssignListings = $m->query($sql); 

}

 ?>

<!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">

<title>Print gender wise Sheet</title>

<link rel="icon" type="image/png" href="img/favicon.png" sizes="32x32" />

<script type="text/javascript">

// window.print();

</script>

<style type="text/css">



tr th {border-top:1px solid gray;border-left:1px solid black;border-bottom:1px solid black;text-align:center;background-color:lightgray;font-size:14px; padding:3px;}

tr td {border-bottom:1px solid gray;border-left:1px solid black;font-size:14px; padding:3px;}

  

.border{border:1px solid black;}

.center{text-align:center;}

.alignment{padding-left:1%;text-align:left;}

.borderTop{

  border-top: none;

}

</style>

</head>

<body style="font-size:12px;">



<div style="width:100%; text-align:center; height:80px;float:left;">
<div style="width:20%;font-size:13px;text-align:center;float:left;height:80px;">

<img src="<?php echo DOMAIN;?>Production/img/<?php echo $brid[0]['logo']; ?>" style="height:100px;width:100px;"  />

</div>

<div style="width:60%; float:left;">

         <span style="font-size:25px; text-align:center;font-family:times new roman;font-weight:bold;color: black;">  <?php echo $brid[0]['Branch_Name'];?> </span>

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



      </div>
</div>
<br><br>


<div style="text-align:center;font-size:24px;font-weight:bold;">Students Gender Wise Reports

 </div>

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

<div style="width:25%;float:left;font-size:16px;">  <b> Order By:</b> 

<?php if ($_REQUEST['orderby']=="class") {
    echo "Class Wise";
} else {
    echo "Admission Wise"; }?> 

</div>

<br>

    <table id="listofstudents" class="table table-striped table-bordered" style="width:100%">

        <thead>

            <tr>

                <th width="5%">S.No</th>

                <th width="17%">Student</th>

                <th width="5%">Roll#</th>

                <th width="10%">Adm No</th>

                <th width="10%"> Cell </th>

                <th width="20%"> Class </th>

                <th width="10%" style="border-right: 1px solid black;"> Gender </th>

                                

            </tr>

        </thead>

        <tbody>
     

     <?php 

$count=1;

      foreach($WorkAssignListings as $WorkAssignListVal)

      { 



        $m->where("class_id", $WorkAssignListVal['class_id']);

        $class=$m->get("edu_class_config");



        $m->where("section_id", $WorkAssignListVal['section_id']);

        $section=$m->get("edu_adm_section_detail");



        $m->where("session_id", $WorkAssignListVal['session_id']);

        $session=$m->get("edu_session_config");



        if ($_REQUEST['orderby']=="class") {
            $usrCls=$WorkAssignListVal['class_id'];
            $clsUsrName="Class Name: ". getClassName($m, $WorkAssignListVal['class_id']);
        }





            // Check if the class has changed, print the class-wise total, and update the overall total
            if ($currentClass !== $usrCls) {
                
                // Reset the class-wise total for the new class
                
                $classSerialNumber = 1; // Reset the serial number for the new class

                // Print the heading for the new class
                echo "<tr style='background-color:lightblue;'>
                        <td colspan='7' style='text-align:center;'><b> " . $clsUsrName . "</b></td>
                      </tr>";
                $currentClass = $usrCls;
            }
          $totalRecord=$count++;

            // Process the current record, you can display the data as needed
            echo "<tr>
                    <td>" . $classSerialNumber++ . "</td>
                    <td style='padding: 2px;'>";

                    if ($WorkAssignListVal['image'] != NULL) {
                    echo "<img style='border-radius: 50%; height: 30px; width: 30px;' src='" . DOMAIN.AgentDirectory . "/students_pics/" . $WorkAssignListVal['image'] . "' />";
                    } else {
                    echo "<img style='border-radius: 50%; height: 30px; width: 30px;' src='images/student.png' />";
                    }
                    echo "&nbsp;&nbsp;" . $WorkAssignListVal['first_name'] . "</td>
                    <td>" . $WorkAssignListVal['candidate_roll_no'] . "</td>
                    <td>" . $WorkAssignListVal['ref_no'] . "</td>
                    <td>" . $WorkAssignListVal['cell_no'] . "</td>
                    <td>" . getClassName($m,$WorkAssignListVal['class_id']).'/'.getSectionName($m,$WorkAssignListVal['section_id']) . "</td>
                    <td>" . $WorkAssignListVal['gender'] . "</td>                    
                  </tr>";                  
          
        }

        // Print the total settlement for the last class in the result set

        
                 
                  if ($currentClass !== null) {
            echo "<tr style='background-color:lightgray;'>
                    <td colspan='3' style='text-align:center;'>Total Record: $totalRecord</td>
                    <td colspan='4' style='text-align:center;'></td>                  
                  </tr>";           
        }

        


      ?>
        

        </tbody>

        

    </table><br>

     

      

      



</body>

</html>

