<?php
	require "../commonincludefiles.php";
   	$objSubject = new SubjectMgmt();
	$i=0;
	$order_field=" subject_name ";
	$order_type=" ASC ";
	$where = "";
	
	if(isset($_REQUEST['branch_name']) && $_REQUEST['branch_name'] != ""){
		$where .= " AND branch_id = ".Escape($_REQUEST['branch_name']);
	}
	if(isset($_REQUEST['semester_name']) && $_REQUEST['semester_name'] != ""){
		$where .= " AND semester_id = ".Escape($_REQUEST['semester_name']);
	}
	
	$rs = $objSubject->getAllRecords($limit,$start,$where,$order_field,$order_type);
	$total = dbRows($rs);
	$SubjectData = array("count" => $total, "data" => array());
	if(dbRows($rs) > 0){
		while($row = dbArray($rs)){
			$temparray["branch_id"]  	= $row["branch_id"];
			$temparray["semester_id"]  	= $row["semester_id"];
			$temparray["subject_id"]  	= $row["subject_id"];
			$temparray["subject_name"]	= $row["subject_name"];
			$temparray["subject_code"]	= $row["subject_code"];
			$temparray["short_name"]	= $row["short_name"];
			$temparray["subject_practical"]	= $row["subject_practical"];
			$temparray["theory_hrs"]	= $row["theory_hrs"];
			$temparray["tutorial_hrs"]	= $row["tutorial_hrs"];
			$temparray["practical_hrs"]	= $row["practical_hrs"];
			$temparray["subject_active"]	= $row["subject_active"];
			$SubjectData["data"][$i] 	= $temparray;   
			$i++;
		}
	}
	echo json_encode($SubjectData);	
?>