<?php  
	require "commonincludefiles.php";	
if ($_SESSION['VedantnrCollegeId']!="" && isset($_SESSION['VedantnrCollegeId'])) {

$objAssignSubject = new assign_subject_masterMgmt();
		
$objAssignSubject->assign_id=$_POST['assign_id'];
$objAssignSubject->employee_id=$_POST['employee_hidden'];		
				
		
		if($objAssignSubject->assign_id == "0")
		{
			if (isset($_POST["griddata_subdetails"]))
							 {
								$griddata_subdetails= stripcslashes( $_POST["griddata_subdetails"]);
							 }
					  $arr_dest = array();
					  $arr_dest = json_decode($griddata_subdetails,true);
					  foreach($arr_dest as $key => $value)
						{
							if(is_array($value))
											{
												
											$objAssignSubject->subject_id=$value['subject_id'];
											$objAssignSubject->add();
											}
						}
				
			
		} 
		else
		 {			
			if($_REQUEST['act'] == "del")
			   {
				$employee_id = $_POST['employee_hidden'];							
				$objAssignSubject->deleteAll($employee_id);
			   }
			else
			    {
							$employee_id = $_POST['employee_hidden'];							
				            $objAssignSubject->deleteAll($employee_id);
						
							if (isset($_POST["griddata_subdetails"]))
							 {
								$griddata_subdetails= stripcslashes( $_POST["griddata_subdetails"]);
							 }
								  $arr_dest = array();
								  $arr_dest = json_decode($griddata_subdetails,true);
								  foreach($arr_dest as $key => $value)
									{
										if(is_array($value))
														{
															
														$objAssignSubject->subject_id=$value['subject_id'];
														$objAssignSubject->add();
														}
									}		
								
				
				}
		 }
		echo '{"success":"true"}';
	} else{
		echo '{"success":"false","msg":"session expiry"}';
	}

function add_records($sup_id)
{
	$Objsup_other= new sup_otherdataMgmt();
			   // start Contact data save ..................
				
						if (isset($_POST["griddata_contact"]))
							 {
								$griddata_contact= stripcslashes( $_POST["griddata_contact"]);
							 }
					  $arr_dest = array();
					  $arr_dest = json_decode($griddata_contact,true);
					  foreach($arr_dest as $key => $value)
						{
							if(is_array($value))
											{
												
											$Objsup_other->item_id=$value['item_id'];
											$Objsup_other->item_data1=$value['item_data1'];
											$Objsup_other->item_data2=$value['item_data2'];
											$Objsup_other->sup_id=$sup_id;
											$Objsup_other->type_id=1; // for contact data
										    $Objsup_other->add();
											}
						}
				// end Contact data ..................
				
				 // start Email info  ..................
				
						if (isset($_POST["griddata_email"]))
							 {
								$griddata_email= stripcslashes( $_POST["griddata_email"]);
							 }
					  $arr_dest = array();
					  $arr_dest = json_decode($griddata_email,true);
					  foreach($arr_dest as $key => $value)
						{
							if(is_array($value))
											{
												
											$Objsup_other->item_id=$value['item_id'];
											$Objsup_other->item_data1=$value['item_data1'];
											$Objsup_other->item_data2=$value['item_data2'];
											$Objsup_other->sup_id=$sup_id;
											$Objsup_other->type_id=2; // for Email data
										    $Objsup_other->add();
											}
						}
				// end Email info  ...................
				
				 // start Email info  ..................
				
						if (isset($_POST["griddata_web"]))
							 {
								$griddata_web= stripcslashes( $_POST["griddata_web"]);
							 }
					  $arr_dest = array();
					  $arr_dest = json_decode($griddata_web,true);
					  foreach($arr_dest as $key => $value)
						{
							if(is_array($value))
											{
												
											$Objsup_other->item_id=$value['item_id'];
											$Objsup_other->item_data1=$value['item_data1'];
											$Objsup_other->item_data2=$value['item_data2'];
											$Objsup_other->sup_id=$sup_id;
											$Objsup_other->type_id=3; // for Web data
										    $Objsup_other->add();
											}
						}
				// end Email info  ...................
				 // start Address info  ..................
				
						if (isset($_POST["griddata_address"]))
							 {
								$griddata_address= stripcslashes( $_POST["griddata_address"]);
							 }
					  $arr_dest = array();
					  $arr_dest = json_decode($griddata_address,true);
					  foreach($arr_dest as $key => $value)
						{
							if(is_array($value))
											{
												
											$Objsup_other->item_id=$value['item_id'];
											$Objsup_other->item_data1=$value['item_data1'];
											$Objsup_other->item_data2=$value['item_data2'];
											$Objsup_other->sup_id=$sup_id;
											$Objsup_other->type_id=4; // for Address data
										    $Objsup_other->add();
											}
						}
				// end Address info  ...................
			// start bank data
			$Objsup_bank= new sup_bankdetailMgmt();
			if (isset($_POST["griddata_bankdetail"]))
							 {
								$griddata_bankdetail= stripcslashes( $_POST["griddata_bankdetail"]);
							 }
					  $arr_dest = array();
					  $arr_dest = json_decode($griddata_bankdetail,true);
					  foreach($arr_dest as $key => $value)
						{
							if(is_array($value))
											{
												
											$Objsup_bank->supbank_id=$value['supbank_id'];
											$Objsup_bank->acno=$value['acno'];
											$Objsup_bank->beneficiary=$value['beneficiary'];
											$Objsup_bank->swiftcode=$value['swiftcode'];
											$Objsup_bank->branch=$value['branch'];
											$Objsup_bank->sup_id=$sup_id;
										    $Objsup_bank->add();
											}
						}
			//end	
				
}

?>