<?php
	require "../commonincludefiles.php";
	
   	$objSubject = new SubjectMgmt();
	$i=0;
	$order_field=" subject_name ";
	$order_type=" ASC ";
	$where = "";
	
	if(isset($_REQUEST['branch_id']) && $_REQUEST['branch_id'] != ""){
		$where .= " AND branch_id = ".Escape($_REQUEST['branch_id']);
	}
	if(isset($_REQUEST['year_id']) && $_REQUEST['year_id'] != ""){
		$where .= " AND year_id = ".Escape($_REQUEST['year_id']);
	}
	
	if(isset($_REQUEST['branchyear_id']) && $_REQUEST['branchyear_id'] != ""){
		$where .= " AND branchyear_id = ".Escape($_REQUEST['branchyear_id']);
	}
	
	if(isset($_REQUEST['semester_id']) && $_REQUEST['semester_id'] != ""){
		$where .= " AND semester_id = ".Escape($_REQUEST['semester_id']);
	}
	
	$rs = $objSubject->getAllRecord($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["branch_name"]  	= $row["branch_name"];
			$temparray["year_id"]  	= $row["year_id"];
			$temparray["year_name"]  	= $row["year_name"];
			$temparray["branchyear_id"]  	= $row["branchyear_id"];
			$temparray["branchyear_name"]  	= $row["branchyear_name"];
			$temparray["semester_id"]  	= $row["semester_id"];
			$temparray["semester_name"]  	= $row["semester_name"];
			$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);	
?>