<?php
	require "../commonincludefiles.php";
   	
	$i=0;
	$order_field=" setup_id ";
	$order_type=" ASC ";
	
	$where = "";
	
	$sql = "
		SELECT
			sm.subject_id,
			sm.subject_name,
			es.daydate,
			es.daytime
		FROM
			cms_subjectmaster sm LEFT JOIN cms_examschedule es ON sm.subject_id = es.subject_id 
			AND es.year_id = ".$_SESSION["VedantnrYearId"]."
			AND es.exam_id = ".Escape($_REQUEST['exam_name'])."
			AND es.test_type = '".Escape($_REQUEST['test_type'])."'
			AND sm.branch_id = es.branch_id 
			AND sm.semester_id = es.semester_id 
		WHERE 
			sm.subject_active = '1'
			AND sm.branch_id = ".Escape($_REQUEST['branch_name'])."
			AND sm.semester_id = ".Escape($_REQUEST['semester_name']);
		
	$sql .= $where;
	
	$sql .= " ORDER BY subject_id ASC ";
	
	$rs = dbQuery($sql);		
	$total = dbRows($rs);
	
	$ScheduleData = array("count" => $total, "data" => array());
	if(dbRows($rs) > 0){
		while($row = dbArray($rs)){
			$temparray["subject_id"]  	= $row["subject_id"];
			$temparray["subject_name"] 	= $row["subject_name"];
			$temparray["daydate"]  		= $row["daydate"];
			$temparray["daytime"] 		= $row["daytime"];
			$ScheduleData["data"][$i] 	= $temparray;   
			$i++;
		}
	}
	echo json_encode($ScheduleData);	
?>