<?php
	require "commonincludefiles.php";
   	$objUploadfilesMgmt = new cms_uploadMgmt();
	$i=0;
	
	if(isset($_SESSION['cur_semesterid']) && isset($_SESSION['cur_branchid']))
	{
		$where=" And up.semester_id = $_SESSION[cur_semesterid] AND up.branch_id=$_SESSION[cur_branchid]";
	}
	if($_REQUEST['subject'])
	{
		$where.=" And up.subject_id = ".Escape($_REQUEST['subject']);
	}
	$order_field=" branch_name ASC, semester_id ";
	$order_type=" ASC ";
	$rs = $objUploadfilesMgmt->getAllRecords($limit,$start,$where,$order_field,$order_type);
	$total = dbRows($rs);
	$SemesterData = array("count" => $total, "data" => array());
	if(dbRows($rs) > 0){
		while($row = dbArray($rs)){
			$temparray["upload_id"]  = $row["upload_id"];
			$temparray["branch_id"]  = $row["branch_id"];
			$temparray["branch_name"]  = $row["branch_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"]==""?'All':$row["subject_name"]);
			$temparray["title"]  = $row["title"];
			$temparray["description"]  = $row["description"];
			$temparray["active"]  = $row["active"];
			$temparray["file_name"]  = $row["file_name"];
			$temparray["assignment_date"]  = ($row["assignment_date"]!='0000-00-00'?$row["assignment_date"]:'');
			$temparray["submission_date"]  = ($row["submission_date"]!="0000-00-00"?$row["submission_date"]:'');
			$temparray["user_name"]  = $row["user_name"];
			$SemesterData["data"][$i] = $temparray;   
			$i++;
		}
	}
	echo json_encode($SemesterData);	
?>