<?php
	require "../commonincludefiles.php";
   	
	$i=0;
	$order_field=" setup_id ";
	$order_type=" ASC ";
	
	$where = "";
	
	$sql = "
		SELECT
			sm.subject_id,
			sm.subject_name,
			es.total_marks,
			es.passing_marks,
			es.total_marks_pr,
			sm.subject_code,
			es.passing_marks_pr,
			es.total_marks_pr_ese,
			es.passing_marks_pr_ese,
			es.total_marks_pr_pa,
			es.passing_marks_pr_pa
		FROM
			cms_subjectmaster sm LEFT JOIN cms_examsetup es ON sm.subject_id = es.subject_id 
			AND es.year_id = ".$_SESSION["VedantnrYearId"]."
			AND es.exam_id = ".$_REQUEST['exam_name']."
			AND sm.branch_id = es.branch_id 
			AND sm.semester_id = es.semester_id 
		WHERE 
			sm.subject_active = '1'
			AND sm.branch_id = ".$_REQUEST['branch_name']."
			AND sm.semester_id = ".$_REQUEST['semester_name'];
		
	$sql .= $where;
	
	$sql .= " ORDER BY subject_id ASC ";
	
	$rs = dbQuery($sql);		
	$total = dbRows($rs);
	
	$SetupData = array("count" => $total, "data" => array());
	if(dbRows($rs) > 0){
		while($row = dbArray($rs)){
			$temparray["subject_id"]  	= $row["subject_id"];
			$temparray["subject_name"] 	= $row["subject_name"];
			$temparray["subject_code"]  = $row["subject_code"];
			$temparray["total_marks"]  	= $row["total_marks"];
			$temparray["passing_marks"] = $row["passing_marks"];
			$temparray["total_marks_pr"]  	= $row["total_marks_pr"];
			$temparray["passing_marks_pr"] = $row["passing_marks_pr"];
			
			$temparray["total_marks_pr_ese"]  	= $row["total_marks_pr_ese"];
			$temparray["passing_marks_pr_ese"] = $row["passing_marks_pr_ese"];
			$temparray["total_marks_pr_pa"]  	= $row["total_marks_pr_pa"];
			$temparray["passing_marks_pr_pa"] = $row["passing_marks_pr_pa"];
			
			$SetupData["data"][$i] 		= $temparray;   
			$i++;
		}
	}
	echo json_encode($SetupData);	
?>
