<?php
 require "../commonincludefiles.php";
 
 $arr = array();
 $total = 0;
      	
		 /*$qry = "SELECT 
	  			sm.student_id,
				sm.student_gturegno,
				CONCAT(sm.student_surname , ' ' , sm.student_firstname , ' ' ,sm.student_lastname) AS studentname,
					sd.student_rollno,
				(SELECT branch_name FROM cms_branchmaster sec WHERE sec.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and sec.branch_id = sd.cur_branchid) AS branch_name,
	  		  	(SELECT year_name FROM cms_yearmaster ym WHERE  ym.year_id = sd.year_id) AS year_name,
				(SELECT semester_name FROM cms_semestermaster sem  WHERE  sem.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND sem.semester_id = sd.cur_semesterid) AS semester_name,
				(SELECT branchyear_name  FROM cms_branchyear bry  WHERE  bry.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "'AND bry.branchyear_id = sd.cur_branchyearid) AS branchyear_name		    	 	   	 	
		  	  FROM
			  	cms_studentmaster sm,
				cms_studentdetail sd				
		  	  WHERE								
				sm.college_id  = '".$_SESSION["VedantnrCollegeId"]."' AND
				sm.student_id = sd.student_id  AND 
				sm.student_active=1 AND 
				sd.current_active = 1";*/
		
				$where ="";
				if($_REQUEST['barnch'] != "" && $_REQUEST['barnch'] != "All"){
					$where .= " and sd.cur_branchid = '".Escape($_REQUEST['barnch'])."'";
				}
				if($_REQUEST['semester']!="")
				{
					$where .= " and sd.cur_semesterid = '".Escape($_REQUEST['semester'])."'";
				}
				if($_REQUEST['branchyear'] != "" && $_REQUEST['branchyear'] != "All"){
					$where .= " and sd.cur_branchyearid = '".Escape($_REQUEST['branchyear'])."'";
				}
				if($_REQUEST['year'] != "" && $_REQUEST['year'] != "All"){
					$where .= " and sd.year_id = '".Escape($_REQUEST['year'])."'";
				}		
				
		$where .= " order By sm.student_lastname ASC ";
		
		
		//$qry.=	$where;	
		$k=0;
			
		//echo $qry;
		//$rs = dbQuery($qry);
		$objStudentMgmt= new StudentMgmt();
		$rs=$objStudentMgmt->getstudentrollno($where);
		$total = dbRows($rs);
		
		while($obj = dbObject($rs)) {
		
			$arr[$k] = $obj;   
		   $k++;
		}
	echo '{"total":"'.$total.'","data":'.json_encode($arr).'}';
	
		
?>
