<?php
include("../../db.php");
header('Content-Type: application/json');

	$session=$_REQUEST['session'];
	$fromdate=$_REQUEST['fromdate'];
	$todate=$_REQUEST['todate'];
	$class=$_REQUEST['class'];
	$section=$_REQUEST['section'];

	$array = array();
	$status=0;

    $homeworkArray=array();

    $where = " assignment.date BETWEEN '$fromdate' and '$todate'";

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

    $getHomework = $db->getRows("select * from assignment LEFT JOIN staff ON staff.idno=assignment.Added_by where $where and assignment.status=1 and assignment.school_id='1' and assignment.session='".$session."' ");
    if(count($getHomework) > 0){
        $status = 1;

    foreach($getHomework as $homework){
        array_push($homeworkArray,["name"=>"$homework[name]","designation"=>"$homework[designation]","class"=>"$homework[class] - $homework[section]","homework_detail"=>"$homework[detail]","download"=>"$homework[upload_assignment]","image"=>"$homework[photo]"]);

        }
    }

    $array['status'] = $status;
    $array['teacherlist'] = $homeworkArray;

    echo json_encode($array);
?>
