<?php
include("../db.php");
header("Access-Control-Allow-Origin: * ");
header('Content-Type: application/json');




$where = "";

if(isset($_REQUEST["fdate"]) && trim($_REQUEST["fdate"])!="" && isset($_REQUEST["tdate"]) && trim($_REQUEST["tdate"])!="" ){
    $fdate=$_REQUEST["fdate"];
    $tdate=$_REQUEST["tdate"];
    $where.="  where m.timestamp between '$fdate' and '$tdate' ";
}

if(isset($_REQUEST["class"]) && trim($_REQUEST["class"])!=""){
    $where.=" and m.class='".$_REQUEST["class"]."' ";
}
if(isset($_REQUEST["section"]) && $_REQUEST["section"]!=""){
    $where.=" and m.section='".$_REQUEST["section"]."' ";
}




$result=$db->getRows("SELECT s.idno, s.name as sname,s.admissionno, s.fincome, m.id, m.class, m.section, m.chapter, m.topic, m.teacher_id, m.timestamp, staff.name as tname
        FROM ((meet_attendance as m
        INNER JOIN student as s ON s.idno = m.student_id)
        INNER JOIN staff ON staff.idno = m.teacher_id) $where GROUP BY m.student_id");

if(count($result) > 0){
    echo json_encode(array("status"=>1, "data"=>$result , "qr"=>$where));
} else {
    echo json_encode(array("status"=>0, "data"=>$result, "qr"=>$where));
}


        