<?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'];

$type = $_REQUEST['type'];

$where = "session = '$session' and class='$class' and status = '1' ";

$status=0;
$msg='';
$data=array();
$array = array();

if($section != ""){
    $where .= " and section ='$section' ";
}

$allStudent = $db->getRows("select * from student where $where and status=1 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' ");

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

      //  echo "select * from attendance_remark where idno=$student[idno] and session ='$session' and type = '$type' ";

        array_push($data, ["idno"=>"$student[idno]","name"=>"$student[name]","roll_no"=>"$student[fincome]", "admissionno"=>"$student[admissionno]", "father"=>"$student[fname]",
            "class" => $student['class'], "section" => $student['section'],
            "term1_att"=>"$attendance[present]", "teacher_rem_term_1"=>"$attendance[remark]"]);

    }
}

$array['status']=$status;
$array['msg']=$msg;
$array['data']=$data;

echo json_encode($array);

?>