<?php
include("../../db.php");
error_reporting(E_ALL);
header("Access-Control-Allow-Origin: * ");


    $session= $_REQUEST['session'];
    $school_id= $_REQUEST['school_id'];
    $added_by= $_REQUEST['added_by'];
    $class = $_REQUEST['class'];
    $section = $_REQUEST['section'];

    $where = "session = '$session' and class='$class' ";
    
    $status=0;
    $msg='';
    $data=array();
    $array = array();

    if($section != ""){
        $where .= " and section ='$section' ";
    }
    
    $allStudent = $db->getRows("select * from student where $where ORDER BY name");
    if(count($allStudent)>0){
        $status=1;
        $msg= 'Data found Successfully..!';
        foreach($allStudent as $student){

           //$bus_route=$db->getVal("select root from bus where id=$student[bus] ");

           $attendance = $db->getRow("select * from allattandence where idno=$student[idno] and session ='$session' ");

            array_push($data, ["idno"=>"$student[idno]","name"=>"$student[name]","roll_no"=>"$student[fincome]", "admissionno"=>"$student[admissionno]", "father"=>"$student[fname]",
                "term1_att"=>"$attendance[term1_att]","term2_att"=>"$attendance[term2_att]", "teacher_rem_term_1"=>"$attendance[teacher_remarks_term1]",
            "teacher_rem_term_2"=>"$attendance[teacher_remarks_term2]", "spec_part_term_1"=>"$attendance[specific_participation_term1]", "spec_part_term_2"=>"$attendance[specific_participation_term2]"
            ]);

        }
    }
    
    $array['status']=$status;
    $array['msg']=$msg;
    $array['data']=$data;
    
    echo json_encode($array);

?>