<?php
	//Connects to your Database
	include "../db_connection/db_connection.php";
	include "../config/config.php";		
	
	$party_id   =	base64_decode(base64_decode(base64_decode($_POST['co_cod'])));
	$r_dt 		=	$_POST['rec_date'];
	$c_dt 		=	$_POST['coll_date'];
	$rec_date	=	str_replace("/", "-", $_POST['rec_date']);
	$coll_date	=	str_replace("/", "-", $_POST['coll_date']);
	$chk_rec	= 	$_POST['chk_rec']; 
	$chq_no 	=	$_POST['chq_no'];
	$bn_name 	=	$_POST['bn_name'];
	$bran_name	=	$_POST['bran_name'];
	$amount   	=	$_POST['amount'];
	
	$INSRT_cq	= 	"INSERT INTO cheque_collection_list(`party_det_id`, `received_date`, `collection_date`,`emp_det_id`,`cheque_no`,`bank_name`,`branch_name`,`cheque_amount`, `created_date`) VALUES('$party_id','$rec_date','$coll_date','$chk_rec','$chq_no','$bn_name','$bran_name','$amount','$cur_time')";		
	$QURY_cq	= 	mysqli_query($connect,$INSRT_cq);
	
	$SLCTaap 	= 	"SELECT email_id_1,cmp_name,con_no_1 FROM party_det WHERE party_det_id='$party_id'";			
	$QURYaap 	= 	mysqli_query($connect,$SLCTaap);		
	$FTCHaap 	= 	mysqli_fetch_object($QURYaap);
	
	$cli_emailid =  $FTCHaap->email_id_1;
	$com_name 	 =	$FTCHaap->cmp_name;  
	$mobile_no 	 =	$FTCHaap->con_no_1;
	
	$SLCTemp 	= 	"SELECT name FROM emp_det WHERE emp_det_id='$chk_rec'";			
	$QURYemp 	= 	mysqli_query($connect,$SLCTemp);		
	$FTCHemp 	= 	mysqli_fetch_object($QURYemp);
	
	$emp_nm 	=	$FTCHemp->name;
	
	include "../mail/cheque_mail.php";
	$tto=$cli_emailid;
	$subject="Reg:Cheque Receiving Acknowledgement";
	$headers = "MIME-Version: 1.0" . "\r\n";
	$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
	$headers .= 'From: Thahaayaa Accounts <accounts@thahaayaa.com>' . "\r\n";		
	$headers .= 'Bcc:'.$cc_id. "\r\n";	
	
	mail("$tto",$subject,$mail_body,$headers);
	if($mobile_no!='')
	{
		$to = $mobile_no;
		$sms = "Thahaayaa thanks you for your cheque no ".$chq_no." for date ".$c_dt." is received on ".$r_dt." for Rs.".$amount."/-. Further contact - 9843214151 Accounts Dept.";
		$sms_url   	= 	sprintf($sms_domain, $workingkey, $to , $senderid, urlencode($sms));
		openurl($sms_url);
	}
	header('location:../cheque_collection_list.php');			
?>
	
