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



<?php

$id=$_REQUEST['branch'];



$sql = "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='$id' and sec.branch_id='$id' ORDER BY cls.orderno asc";

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



$data=array();

$SubData=array();

foreach ($classes_sections as $cls_sec) {



$clsID=$cls_sec['class_id'];

$secID=$cls_sec['section_id'];

$clsName=$cls_sec['Class_Name'];

$secName=$cls_sec['section_name'];

$sessionIDs=$_SESSION['current_session'];



   $std = $m->query("SELECT COUNT(*) as total, COUNT(IF(std.gender = 'Male', 1, NULL)) 'Boys', COUNT(IF(std.gender = 'Female', 1, NULL)) 'Girls' FROM edu_student_details as std  where std.class_id='$clsID'and std.section_id='$secID' and std.status='0' and std.branch_id='$id'");

   

   $students_data = array(

  "ClassName" => $clsName,

  "SectionName" => $secName,

  "Students" => $std[0]['total'],

  "Boys" => $std[0]['Boys'],

  "Girls" => $std[0]['Girls'],

  "ClassId" => $clsID,

  "SectionId" => $secID

);

  

   

     $data[$cls_sec['class_id'].$cls_sec['section_id']]=$students_data;

 

    

}

//echo "<pre>"; print_r($data); echo "</pre>";



 echo json_encode($data);

?>



	 

