<?php 
//set_time_limit(60);

	require "commonincludefiles.php";
	require "data/sendingsms_studentpresant.php";
	error_reporting(1);
	if($_SESSION["VedantnrCollegeId"]!="" && isset($_SESSION["VedantnrCollegeId"]))
	{							
		
		$recivedamt=json_decode(stripslashes($_REQUEST['recivedamt']));
		$headid = json_decode(stripslashes($_REQUEST['headid']));
	

		$objStudentFeesRecMgmt  = new StudentFeesRecMgmt();	
		$objStudentFeesRecMgmtdetail = new StudentFeesRecDetailMgmt();		
		$objStudentFeesRecMgmt->feesreceive_id	= $_REQUEST["ID"] ; 	
		$objStudentFeesRecMgmt->semester_id		= $_REQUEST['semester_hidden'];  
		$objStudentFeesRecMgmt->branch_id		= $_REQUEST['branch_hidden'];  
		$objStudentFeesRecMgmt->branchyear_id		= $_REQUEST['branchyear_hidden'];  
		$objStudentFeesRecMgmt->year_id		= $_REQUEST['year_hidden'];  
		$objStudentFeesRecMgmt->student_id		= $_REQUEST['student_hidden']; 		  
     	$objStudentFeesRecMgmt->fee_type 	= $_REQUEST['fee_typehidden'];     
	   	$objStudentFeesRecMgmt->receipt_no		= $_REQUEST['receipt_no']; 
		
		$_SESSION["receiptno1"]= $objStudentFeesRecMgmt->receipt_no;	  
	//	$_SESSION["student_id"]= $objStudentFeesRecMgmt->student_id;
	  
		$objStudentFeesRecMgmt->receipt_date  	= $_REQUEST['receipt_date'];				
		$objStudentFeesRecMgmt->receive_amt	 	= $_REQUEST['receive_amt'];		
		$objStudentFeesRecMgmt->ref_no  		= $_REQUEST['ref_no'];				
		$objStudentFeesRecMgmt->cheque_no  		= $_REQUEST['cheque_no'];				
		$objStudentFeesRecMgmt->bank_name 		= $_REQUEST['bank_name'];				
		$objStudentFeesRecMgmt->comment_show  	= $_REQUEST['comment_show'];
		$objStudentFeesRecMgmt->comments  		= $_REQUEST['comment'];
	
		$objStudentFeesRecMgmt->discount  		= $_REQUEST['discount']; 
		$objStudentFeesRecMgmt->total_receive_amt  		= $_REQUEST['total_receive_amt']; 
		$objStudentFeesRecMgmt->amount_discount  		= $_REQUEST['amount_discount']; 		
	
			
		if ($objStudentFeesRecMgmt->feesreceive_id== 0 && isset($objStudentFeesRecMgmt->feesreceive_id)){		
			$objStudentFeesRecMgmt -> add();
 		}
		 else 
		 { 
			$objStudentFeesRecMgmt -> feesreceive_id = $_REQUEST["ID"] ; 
		  
			 $objStudentFeesRecMgmt -> edit();
 
			 $objStudentFeesRecMgmtdetail -> feesreceive_id = $_REQUEST["ID"] ; 
			
			 $objStudentFeesRecMgmtdetail -> delete();
		 } 
		$feesreceive_id=$objStudentFeesRecMgmt->feesreceive_id;
		
		if($objStudentFeesRecMgmt->feesreceive_id !=0 )
		{
			$j=count($headid);
		
				
		
			 
			for($i=0;$i < $j;$i++)
			{				
				$objStudentFeesRecMgmtdetail-> feesreceive_id   = $objStudentFeesRecMgmt->feesreceive_id;	 
				$objStudentFeesRecMgmtdetail-> head_id  		= $headid[$i];
				$objStudentFeesRecMgmtdetail-> recdetail_amt    = $recivedamt[$i];		
				$objStudentFeesRecMgmtdetail  -> add();						
			} 
				
		}
		
		echo '{"success":"true","feesreceive_id":"'.$objStudentFeesRecMgmtdetail-> feesreceive_id.'"}';exit;			
}
else
{
	echo '{"success":"false","msg":"session expiry"}';exit;
}
?>
