<?php
	include "../db_connection/db_connection.php";
	include "../config/config.php";
	
	if($_GET['flag']==1){
		$current_time = date('d-m-Y') ;
		$part_id = base64_decode(base64_decode(base64_decode($_GET['part_id'])));
		$SLCT = "SELECT * FROM cheque_collection_list WHERE cheque_status = 'pending' AND reminder_status = 'waiting' AND party_det_id = '$part_id' AND STR_TO_DATE(collection_date,'%d-%m-%Y') <= STR_TO_DATE('".$current_time."','%d-%m-%Y')";
		$QURY = mysqli_query($connect,$SLCT);
		if(mysqli_num_rows($QURY)> 0)
		{
			$FTCH_sk = mysqli_fetch_object($QURY);
			$emp_det_id 	= $FTCH_sk->emp_det_id;
			$cheque_no  	= $FTCH_sk->cheque_no;
			$bank_name  	= $FTCH_sk->bank_name;
			$branch_name    = $FTCH_sk->branch_name;
			$cheque_amount  = $FTCH_sk->cheque_amount;
			$SLCT_emp = "SELECT  * FROM emp_det WHERE key_person = 'yes' AND emp_det_id =".$emp_det_id;
			$QURY_emp = mysqli_query($connect,$SLCT_emp);
			$FTCH_emp = mysqli_fetch_object($QURY_emp);
			$name = $FTCH_emp->name;
			echo $emp_det_id."###".$cheque_no."###".$bank_name."###".$branch_name."###".$name."###".$cheque_amount."###".$FTCH_sk->cheque_collection_list_id;
		}
		else
		{
			echo "";
		}
	}else if($_GET['flag']==2){
		$_id = $_GET['_id'];
		$SLCT = "SELECT * FROM cheque_collection_list WHERE cheque_collection_list_id = '$_id'";
		$QURY = mysqli_query($connect,$SLCT);
		if(mysqli_num_rows($QURY)> 0)
		{
			$FTCH_sk = mysqli_fetch_object($QURY);
			$emp_det_id 	= $FTCH_sk->emp_det_id;
			$cheque_no  	= $FTCH_sk->cheque_no;
			$bank_name  	= $FTCH_sk->bank_name;
			$branch_name    = $FTCH_sk->branch_name;
			$cheque_amount  = $FTCH_sk->cheque_amount;
			$SLCT_emp = "SELECT  * FROM emp_det WHERE key_person = 'yes' AND emp_det_id =".$emp_det_id;
			$QURY_emp = mysqli_query($connect,$SLCT_emp);
			$FTCH_emp = mysqli_fetch_object($QURY_emp);
			$name = $FTCH_emp->name;
			echo $emp_det_id."###".$cheque_no."###".$bank_name."###".$branch_name."###".$name."###".$cheque_amount."###".$FTCH_sk->cheque_collection_list_id;
		}
		else
		{
			echo "";
		}
	}
	
	
	
		
?>
		
     
 	
	
	