<?php
	require "../commonincludefiles.php";
	$where = '';
	
 	$school_id	=	$_SESSION["VedantnrCollegeId"];
	//$year_id	=	$_SESSION["aYear"];
	
	$start   = isset($_REQUEST['start'])  ? $_REQUEST['start']  :  0;
	$limit   = isset($_REQUEST['limit'])  ? $_REQUEST['limit']  :  0;
	$sort    = isset($_REQUEST['sort'])   ? $_REQUEST['sort']   : '';
	$dir     = isset($_REQUEST['dir'])    ? $_REQUEST['dir']    : 'ASC';
	$filters = isset($_REQUEST['filter']) ? $_REQUEST['filter'] : null;
	
	$order_field = " sa.work_allotment_subject_id";
	$order_type  = "ASC";
	$objallocationMgmt = new cms_subject_allocationMgmt();
	$arr = array();
	$k=0;
	$i=0;
	
	if($_REQUEST['branch_name']!=""){
		$where.=" AND sa.branch_id='".Escape($_REQUEST['branch_name'])."'";
	}
	
	if($_REQUEST['semester_name']!=""){
		$where.=" AND sa.semester_id='".Escape($_REQUEST['semester_name'])."'";
	}

	
	if($_REQUEST['year_name']!=""){
		$where.=" AND sa.year_id='".Escape($_REQUEST['year_name'])."'";
	}
	

	
	if($_REQUEST['branchyear_name']!=""){
		$where.=" AND sa.branchyear_id='".Escape($_REQUEST['branchyear_name'])."'";
	}
	
	
	if($_REQUEST['employee_id']!=""){
		$where.=" AND sa.employee_id='".Escape($_REQUEST['employee_id'])."'";
	}
	//$where.=" AND sa.year_id= ".$_SESSION["VedantnrYearId"];
	
	$order_field=" branch_id ASC,semester_id ASC, employee_name ";
	$order_type=" ASC";
	$rs = $objallocationMgmt->getAllRecords1($limit,$start,$where,$order_field,$order_type);
	$total = dbRows($rs);
	$EmpData = array("count" => $total, "data" => array());
	if($total > 0){
		while($row = dbArray($rs)){	
			$temparray["work_allotment_subject_id"]  		= $row["work_allotment_subject_id"];    	
		//$temparray["college_id"] 					= $row["college_id"];
			$temparray["branch_id"]  					= $row["branch_id"]; 	
			$temparray["year_id"]  					= $row["year_id"]; 	
			$temparray["branchyear_id"]  				= $row["branchyear_id"]; 	
			$temparray["semester_id"]  				= $row["semester_id"]; 	
			$temparray["div_id"]  						= $row["div_id"]; 	
//		$temparray["batch_id"]  					= $row["batch_id"]; 	
			$temparray["subject_id"]  				= $row["subject_id"]; 	
			$temparray["subject_name"]  				= $row["subject_name"]; 	
			$temparray["day_name"]  					= $row["day_name"]; 	
			$temparray["lectype"]  						= $row["lectype"]; 	
			$temparray["lectype_name"]  			= $row["lectype_name"]; 	
//		$temparray["shift"]  							= $row["shift"]; 	
			$temparray["employee_id"]  				= $row["employee_id"]; 	
			$temparray["branch_name"]  				= $row["branch_name"]; 	
			$temparray["year_name"]  				= $row["year_name"]; 	
			$temparray["branchyear_name"]  				= $row["branchyear_name"]; 	
			$temparray["semester_name"]  			= $row["semester_name"];  	
			$temparray["time_name"]  					= $row["time_name"].'-'.$row["time_name1"];  	
			$temparray["time_id"]  						= $row["time_id"];  	
			$temparray["lec_id"]  						= $row["lec_id"];  
			$temparray["lec_name"]  						= $row["lec_name"];  
			$temparray["room_name"]  						= $row["room_name1"].'-'.$row["room_name"];  	
																																							
			$temparray["room_id"]  						= $row["room_id"];  																																					
	//	$temparray["batch_name"]  				= $row["batch_name"]; 	
			$temparray["subject_name"]  			= $row["subject_name"].'-'.$row["subject_name1"];
			$temparray["employee_name"] 			= $row["employee_name"];
//		$temparray["shift"] 							= $row["shift"];
			
			$EmpData["data"][$i] = $temparray;   
			$i++;
		}
	}
	echo json_encode($EmpData);	
?>
