<?php  
session_start(); 
	include("connect.php");	
	include("connectp.php");
	header("Access-Control-Allow-Origin: *");

	
	
	$brmid = $_SESSION['linkarisebranchid'];
	$cmpmid = $_SESSION['linkarisecmpmid'];
	$umid = $_SESSION['linkariseumid'];	
	
		$q = $db7->prepare("select * from res_bookingpayment_detail where cmpmid=$cmpmid ");
	//$q->bindValue(':p1', "$par1");
	//$q->bindValue(':p2',  "$par2");
	$q->execute();

	$response = array();
	$posts = array();
	
	$result="0";
	
	if ($q->rowCount() > 0)
	{
		$i=1;
		while($i<=$q->rowCount())
		{
			$rt = $q->fetch(PDO::FETCH_ASSOC);
			
			 	$bookingmid=$rt['bookingmid'];
			 	$receivedamount=$rt['bookingreceivedamount'];
			 	$receiptdetail=$rt['paymentremark'];
				
				$uedit="<a href='paymentreceiptedit.php?id=".$rt['bookingpaydid']."' data-toggle='tooltip' data-placement='top' title='Edit' class='fa fa-edit fa-lg'>  </a>";
			
				$udelete="<a href='paymentreceiptdelete.php?id=".$rt['bookingpaydid']."' onclick='return confirm(&#39;Are you sure you want to delete ?&#39;);' data-toggle='tooltip' data-placement='top' title='Delete' class='far fa-trash-alt fa-lg'>  </a>";
				
				$view="<a href='paymentreceiptdetail.php?id=".$rt['bookingpaydid']."' data-toggle='tooltip' data-placement='top' title='Detail' class='fa fa-eye fa-lg'>  </a>";
				
				
				$op=$view."&nbsp;&nbsp;&nbsp; ".$uedit."&nbsp;&nbsp;&nbsp; ".$udelete;
				
				$paymentmode=$rt['paymentmode'];

				$partymid=0;
				
				$eve1 = "select * from res_booking_master where bookingmid ='$bookingmid'";

				$re1 = mysqli_query($conn, $eve1);
																			
				if(mysqli_num_rows($re1) > 0)

				{											
																				
				while($rt1 = mysqli_fetch_assoc($re1))
				{
					$partymid=$rt1['partymid'];
					$spotmid=$rt1['spotmid'];
					$bookingtotalamount=$rt1['bookingtotalamount'];
					$bookingdate=implode('-', array_reverse(explode('-', $rt1['bookingdate'])));	
				}
																				 
				}
					
				

				$partyname='';
				
				
				$eve2 = "select * from res_party_master where partymid ='$partymid'";

				$re2 = mysqli_query($conn, $eve2);
																			
				if(mysqli_num_rows($re2) > 0)

				{											
																				
				while($rt2 = mysqli_fetch_assoc($re2))
				{
					$partyname=$rt2['partyname'];
					
						
				}
																				 
				}
				
				$spotname='';
				
				
				$eve21 = "select * from res_spot_master where spotmid ='$spotmid'";

				$re21 = mysqli_query($conn, $eve21);
																			
				if(mysqli_num_rows($re21) > 0)

				{											
																				
				while($rt21 = mysqli_fetch_assoc($re21))
				{
					$spotname=$rt21['spotname'];
					
						
				}
																				 
				}
				
				$bookingmid1=$bookingmid." (".$bookingdate.")";
				$receiptdate=implode('-', array_reverse(explode('-', $rt['paymentdate'])));
				
				
				$posts[] = array('srno'=> $i++, 'partymid'=> $partyname,'receiptrefrenceid'=> $bookingmid1,'receiptdate'=> $receiptdate,'receiptamont'=> $receivedamount, 'cmpmid'=> $cmpmid,'receiptdetail'=> $receiptdetail,'receiptmode'=>$paymentmode,'spotname'=>$spotname,'totalamount'=>$bookingtotalamount);
		}
		 
		$response['posts'] = $posts;
		echo stripslashes(json_encode( array('data' => $posts)));
		//mysqli_close($conn);
		//return;
	}
	
   else
	{
		$result="0";
		$msg="Invalid Error";
		
		$posts[] = array('p1'=> $result,'p2'=> $msg);
	
		$response['posts'] = $posts;
		echo stripslashes(json_encode( array('item' => $posts)));
	}
   
	mysqli_close($conn);	
?>