<?php  
	require "commonincludefiles.php";
	
	if($_SESSION["VedantnrCollegeId"]!="" && isset($_SESSION["VedantnrCollegeId"]))
	{
		$objSubject = new SubjectMgmt();
		$objSubject->subject_id		= $_POST['subject_id'];
		$objSubject->branch_id		= $_POST['branch_hidden'];
		$objSubject->year_id		= $_POST['year_hidden'];
		$objSubject->branchyear_id	= $_POST['branchyear_hidden'];
		$objSubject->semester_id	= $_POST['semester_hidden'];
		$objSubject->subject_name 	= $_POST['subject_name'];
		
		$objSubject->subject_code 	= $_POST['subject_code'];
		$objSubject->short_name 	= $_POST['short_name'];
		
		$objSubject->theory_hrs 	= $_POST['theory_hrs'];
		$objSubject->tutorial_hrs 	= $_POST['tutorial_hrs'];
		$objSubject->practical_hrs 	= $_POST['practical_hrs'];
	
		
		if($_REQUEST['subject_practical']=='on')
		{
			$objSubject->subject_practical 	= 1;
		
		}else
		{
			$objSubject->subject_practical 	= 0;
		}
		
		
		if($_REQUEST['subject_active'] == 'on')
		{
			$objSubject->subject_active = 1;		
		}
		else
		{
			$objSubject->subject_active = 0;
		}
		
		
		if($objSubject->subject_id == "0"){
			$objSubject->add();
		}
		else{			
			if($_REQUEST['act'] == "del")
				$objSubject->delete();
			else
				$objSubject->edit();
		}
		echo '{"success":"true"}';
	}
	else
	{
		echo '{"success":"false","msg":"session expiry"}';
	}
?>