<?php
	require "../commonincludefiles.php";
   	
	$i=0;
	
	$sql = "
		SELECT
			CONCAT(sm.student_surname,' ',sm.student_firstname) AS student_name,
			sm.student_id,
			sm.student_gturegno,
			am.status
		FROM
			cms_studentmaster sm LEFT JOIN cms_atktmaster am ON sm.student_id = am.student_id 
				AND am.subject_id = ".Escape($_REQUEST['subject_name'])."
				AND am.status = 1,
			cms_studentdetail sd	 
		WHERE 
			sm.student_id = sd.student_id AND
			
			sm.student_active = 1 AND
			sd.cur_branchid = ".Escape($_REQUEST['branch_name'])." AND 
				sd.cur_semesterid = ".Escape($_REQUEST['semester_name'])." AND
				sd.cur_branchyearid = '".Escape($_REQUEST['branchyear_name'])."' AND
				sd.year_id = '".Escape($_REQUEST['year_name'])."' 
		ORDER BY student_gturegno ASC";	
			
	$rs = dbQuery($sql);		
	$total = dbRows($rs);
	
	$SetupData = array("count" => $total, "data" => array());
	if(dbRows($rs) > 0){
		while($row = dbArray($rs)){
			$temparray["student_name"]  	= $row["student_name"];
			$temparray["student_id"] 		= $row["student_id"];
			$temparray["student_gturegno"]	= $row["student_gturegno"];
			$temparray["status"]			= $row["status"];
			$SetupData["data"][$i] 			= $temparray;   
			$i++;
		}
	}
	echo json_encode($SetupData);	
?>