<?php
	require "../commonincludefiles.php";
 	$arr = array();
 	$total = 0;
	$admyear =''; 
	
	//echo $_REQUEST['shift1'];
	
	if($_REQUEST['branch']!="" && $_REQUEST['Year']!="")
	{
		$admyear = substr($_REQUEST['Year'], 0, 4);
		$where .= " and sd.cur_branchid = '".Escape($_REQUEST['branch'])."' 
					and EXTRACT(Year  FROM sm.`student_admdate`) = '".$admyear."'";
	}
	if($_REQUEST['branch_id']!="" && $_REQUEST['year_id']!="")
	{

		$where .= " and student_active  = 1
					and sd.cur_branchid = '".Escape($_REQUEST['branch_id'])."' 
					and sd.year_id = '".Escape($_REQUEST['year_id'])."'";
					if($_REQUEST['branchyear_id']!="" ){
						$where .= " and sd.cur_branchyearid = '".Escape($_REQUEST['branchyear_id'])."'";
					}

					if($_REQUEST['semester_id']!="" ){
						$where .= " and sd.cur_semesterid = '".Escape($_REQUEST['semester_id'])."'";
					}			
		$objStudentMgmt = new StudentMgmt();		
		$i=0;		
		
		$order_field = " sm.student_gturegno";
		$order_type = " ASC ";
		
		$rs = $objStudentMgmt->getAllRecordsyearright($limit,$start,$where,$order_field,$order_type);
		$total= dbRows($rs);
		$HeadData = array("count" => $total, "data" => array());
		$sr=1;
		if(dbRows($rs) > 0)
		{
			while($row = dbArray($rs))
			{
				$name = $sr.' ] '.$row["student_gturegno"].' - '.$row["student_surname"]." ".$row["student_firstname"]." ".$row["student_lastname"]; 
				$qtip = "Enrollment No:".$row["student_gturegno"]."<br/>Gender:".$row["student_gender"] ;
				$temparray["student_id"]  = $row["student_id"];
				$temparray["student_name"]  = "<div qtip=\"".$qtip."\">".$name."</div>";	
				$HeadData["data"][$i] = $temparray;   
				$i++;
				$sr++;
			}
		}
	}
	echo json_encode($HeadData);	
?>
