<?php
	session_start();
	if($_SESSION['subadm'])
	{
		$userid=1111;
	}
	else
	{
		header('location:../login.php');
	}
?>
<?php
	include'connection.php';
	$id=$_GET['id'];
	$query="select * from paymentreq where Id=$id";
	$result=mysqli_query($con,$query);
	$data=mysqli_fetch_array($result);
	$amount=$data['Amount'];
	$uid=$data['Userid'];
	
	$sub=substr($uid,"0","2");
	if($sub==50)
	{
	    $quGetUser="select * from retailer where Userid='$uid'";
		$reGetUser=mysqli_query($con,$quGetUser);
		$data=mysqli_fetch_array($reGetUser);
		$Mobile=$data['Mobile'];
		$UsrMailId=$data['Email'];
	}
	elseif($sub==20)
	{      
	    $quGetUser="select * from distributer where Userid='$uid'";
		$reGetUser=mysqli_query($con,$quGetUser);
		$data=mysqli_fetch_array($reGetUser);
		$Mobile=$data['Mobile'];
		$UsrMailId=$data['Email'];
	}
	elseif($sub==30)
	{
	    echo "proggramme Not Found For Master Distributer";
		exit();
	}
	
	date_default_timezone_set("asia/Kolkata");
	$date= Date("y-m-d");
	$status="REJECTED";
	
	if(isset($_POST['submit']))
	{
		$respmsg=$_POST['respmsg'];
		$bankcharge=$_POST['bc'];
		if(empty($bankcharge))
		{
			$bankcharge=0;
		}
		
		$actualamount=$amount-$bankcharge;
		
		$query1="UPDATE paymentreq SET SettleStatus='SETTELED', Responsemsg='$respmsg', Bankcharge='$bankcharge', Status='$status', Active='1' WHERE Id='$id'";
		if(mysqli_query($con,$query1))
		{
	        $msg="Your Payment Request [ ".$id." ] For Rs.".$actualamount." has been Rejected. To know Reason Please Check Your Penal. Call For Any Query- 9897095971";
			$Mmsg=$msg;
			$subject="Payment_Rejected";
			$to=$UsrMailId;
			include'../mail.php';
			echo "Request Have Been Rejected !";
		}
		else
		{
			echo "error";
	    }
	}
?>
<html>
<head>

</head>
<body>
	<form method="post">
	<table border="0" cellpadding="10">
		<tr>
			<td>Request Amount : </td><td><?php echo $amount; ?></td>
		</tr>
		<tr>
			<td>Response Messege : </td><td>
			    <select name="respmsg">
			        <option>Transaction Not Found</option>
			        <option>Transaction Number Not Matched</option>
			        <option>Request Amount Not Matched</option>
			        <option>Bank Name Not Matched</option>
			        <option>Rejected By Admin</option>
			    </select></td>
		</tr>
		<tr>
			<td>Bank Charge : </td><td><input type="text" name="bc"></td>
		</tr>
		<tr>
			<td></td><td><input type="submit" name="submit" value="Reject"></td>
		</tr>
	</table>
	</form>
</body>
</html>