<?php
 require "../commonincludefiles.php";
 
 $arr = array();
 $total = 0;
		/* $qry = "SELECT 
	  		sm.student_id,
				sm.student_gturegno,
				sm.student_admdate, 
				CONCAT(sm.student_surname , ' ' , sm.student_firstname , ' ' ,sm.student_lastname) AS studentname,
				sm.student_birthdate,
				sm.student_gender,
				sm.student_admby,
				sm.student_category,	
				sm.student_mobilestudents,
				sm.student_mobileparents,
				sm.tfw_scheme,  		  
				sm.leave_type,
				(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    "; */		              
		if($_REQUEST['active']=="true")
		{
		  $where .= " AND sd.current_active = '1'";
		  $where .= " AND sm.leave_type != 's'";
		  $where .= " AND sm.leave_type != 'd'";
		  $where .= " AND sm.leave_type != 'c'";
		  $where .= " AND sm.leave_type != 'a'";
		}
		if($_REQUEST['suspend']=="true")
		{
		  $where .= " AND sm.leave_type = 's'";
		}
		if($_REQUEST['detain']=="true")
		{
		  $where .= " AND sm.leave_type = 'd'";
		}
		if($_REQUEST['alumni']=="true")
		{
		  $where .= " AND sm.leave_type = 'a'";
		}
		if($_REQUEST['cancel']=="true")
		{
		  $where .= " AND sm.leave_type = 'c'";
		}
		if($_REQUEST['barnch'] != "" && $_REQUEST['barnch'] != "All"){
			$where .= " and sd.cur_branchid = '".Escape($_REQUEST['barnch'])."'";
		}
		if($_REQUEST['year'] != "" && $_REQUEST['year'] != "All"){
			$where .= " and sd.year_id = '".Escape($_REQUEST['year'])."'";
		}
		if($_REQUEST['barnchyear'] != "" && $_REQUEST['barnchyear'] != "All"){
			$where .= " and sd.cur_branchyearid = '".Escape($_REQUEST['barnchyear'])."'";
		}
		
		if($_REQUEST['semester']!="")
		{
			$where .= " and sd.cur_semesterid = '".Escape($_REQUEST['semester'])."'";
		}
		if($_REQUEST['birthdate']!="")
		{
			$where .= " and sm.student_birthdate = '".Escape($_REQUEST['birthdate'])."'";
		}
		if($_REQUEST['cast']!="")
		{
			$where .= " and sm.student_cast = '".Escape($_REQUEST['cast'])."'";
		}
		if($_REQUEST['lastname']!="")
		{
			$where .= " and sm.student_lastname LIKE '%".Escape($_REQUEST['lastname'])."%'";
		}
		if($_REQUEST['surname']!="")
		{
			$where .= " and sm.student_surname LIKE '%".Escape($_REQUEST['surname'])."%'";
		}
		if($_REQUEST['firstname']!="")
		{
			$where .= " and sm.student_firstname LIKE  '%".Escape($_REQUEST['firstname'])."%'";
		}
		if($_REQUEST['gender']!="")
		{
			$where .= " and sm.student_gender = '".Escape($_REQUEST['gender'])."'";
		}
		if($_REQUEST['gturegno']!="")
		{
			$where .= " and sm.student_gturegno IN(".Escape($_REQUEST['gturegno']).")";
		}
		if($_REQUEST['student_admby']!="")
		{
			$where .= " and sm.student_admby = '".Escape($_REQUEST['student_admby'])."'";
		}
		if($_REQUEST['student_category']!="")
		{
			$where .= " and sm.student_category = '".Escape($_REQUEST['student_category'])."'";
		}
		if($_REQUEST['chkTFW']=="true")
		{
			$where .= " and sm.tfw_scheme = '1'";
		}
	/*	$qry.=	$where;
		$rs = dbQuery($qry);	*/

		$obgStudentMgmt= new StudentMgmt();
		$rs=$obgStudentMgmt->getstudentsearch($where);
		$k=0;
		$total = dbRows($rs);
		
		while($obj = dbObject($rs)) {
		
			$arr[$k] = $obj;   
		   $k++;
		}
	echo '{"total":"'.$total.'","data":'.json_encode($arr).'}';
	
		
?>
