<?php  
	require "commonincludefiles.php";
	//print_r($_REQUEST);
	if($_SESSION["VedantnrCollegeId"]!="" && isset($_SESSION["VedantnrCollegeId"]))
	{
		/* start new code */
		
		$objSetup = new ExamsetupMgmt();
		$branch_id 		= $_POST['branch_hidden'];	//1
		$semester_id 	= $_POST['semester_hidden'];//2
		$exam_id 		= $_POST['exam_hidden'];	//1
		$subject_id 	= explode(",",$_POST['subject_id']);		//4,5,6,7,8,9
		$total_marks	= explode(",",$_POST['totalmark']);		//25,25,25,15,51454,4541
		$passing_marks 	= explode(",",$_POST['passingmark']);	//18,8,155,15,454,454
		$total_marks_pr	= explode(",",$_POST['totalmark_pr']);		//25,25,25,15,51454,4541
		$passing_marks_pr 	= explode(",",$_POST['passingmark_pr']);	//18,8,155,15,454,454
		$total_marks_pr_ese	= explode(",",$_POST['totalmark_pr_ese']);		//25,25,25,15,51454,4541
		$passing_marks_pr_ese 	= explode(",",$_POST['passingmark_pr_ese']);
		$total_marks_pr_pa	= explode(",",$_POST['totalmark_pr_pa']);		//25,25,25,15,51454,4541
		$passing_marks_pr_pa 	= explode(",",$_POST['passingmark_pr_pa']);
		$sql_select = "SELECT * FROM cms_examsetup WHERE branch_id = '".$branch_id."' AND 
		               semester_id = '".$semester_id."' AND exam_id = '".$exam_id."' AND year_id = ".$_SESSION["VedantnrYearId"];
		$res_select = dbQuery($sql_select);
		if(dbRows($res_select) > 0){
			$sql_delete = "DELETE FROM cms_examsetup WHERE branch_id = '".$branch_id."' AND 
		                   semester_id = '".$semester_id."' AND exam_id = '".$exam_id."' AND year_id = ".$_SESSION["VedantnrYearId"];
			$res_delete = dbQuery($sql_delete);
		}
		
		$objSetup->branch_id	 = $branch_id;
		$objSetup->semester_id	 = $semester_id;
		$objSetup->exam_id		 = $exam_id;
		for($i = 0; $i < count($subject_id); $i++){
			$objSetup->subject_id	 = $subject_id[$i];
			$objSetup->total_marks	 = $total_marks[$i];
			$objSetup->passing_marks = $passing_marks[$i];
			$objSetup->total_marks_pr	 = $total_marks_pr[$i];
			$objSetup->passing_marks_pr = $passing_marks_pr[$i];
			$objSetup->total_marks_pr_ese	 = $total_marks_pr_ese[$i];
			$objSetup->passing_marks_pr_ese = $passing_marks_pr_ese[$i];
			$objSetup->total_marks_pr_pa	 = $total_marks_pr_pa[$i];
			$objSetup->passing_marks_pr_pa = $passing_marks_pr_pa[$i];
			$objSetup->add();
		}
		/* end new code */
		
		echo '{"success":"true"}';
	}
	else
	{
		echo '{"success":"false","msg":"session expiry"}';
	}
?>