<?PHP
	include'session.php';
	include'connection.php';
	include'../Retailers/functions.php';
	
?>
<html>
<head>
	<title>Payment Reject</title>
	<!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    
	<link rel="icon" href="images/logo.png" type="image/gif" sizes="16x16">
	
	<!-- Admin CSS File Link -->
	<link rel="stylesheet" href="css/style.css">
	
	<!-- User JAVA SCRIPT File Link -->
	<script type="text/javascript" src="js/script.js"></script>

	
	<!-- Font Awesome Icone -->
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
	
	<style>
		.div1, .div3{
			background:#f7f7f7;
			width:50%;
			height:auto;
			float:left;
			text-align:center;
			padding:10px;
		}
		.div1 table,.div3 table{
			width:94%;
			text-align:center;
			font-size:13px;
			border-collapse:collapse;
			margin:10px;
			padding:5px;
		}
		.div1 hr, div3 hr{
			margin:5px 10px;
			padding:0 10px;
		}
		table th{
			background:#6b5127;
			color:white;
			height:40px;
			border:solid white 1px;
			padding:4px 8px;
		}
		table td{
			background:white;
			height:40px;
			border:solid black 1px;
			padding:4px 8px;
		}
		.div1 hr, .div3 hr{width:94%;}
		.div1 input,select, textarea{
			width:90%;
			height:45px;
			margin:5px 10px;
			padding:2px 10px;
			border-radius:5px;
			border:1px solid #6b5127;
			font-size:18px;
		}
		
		
		textarea{
			height:100px;
			padding:5px 10px;
		}
		input[type=submit]{
			background:#6b5127;
			color:white;
			font-size:30px;
			transition:1s;
		}
		input[type=submit]:hover{
			background:white;
			color:#6b5127;
			border:1px solid #6b5127;
			cursor:pointer;
			transition:1s;
		}
		.div3{width:96%; text-align:left;}
		.div3 input, .div3 select{
			width:120px;
			height:35px;
			margin:10px 5px;
			padding:2px 5px;
			border-radius:5px;
			border:1px solid #6b5127;
			font-size:13px;
		}
		@media(max-width:768px)
		{
			.div1{
				width:100%;
				height:auto;
			}
			.nav,.container{
				height:auto;
			}
		}
	</style>
	<link rel="stylesheet" href="css/mediaStyle.css">
</head>
<body>
	<!--Header Divison-->
	<?php
		require'header.php';
	?>
	
	<!--Container Division-->
	<div class="container">
	    <?php include'menu.php'; ?>
		<div class="content">
			<div class="head">
				<div class="title"><p>Payment Reject :-</p></div>
				<div class="msg"><marquee><?php include'msg.php'; ?></marquee></msg>
			</div><hr>
			
<?php
	ini_set('memory_limit', '-1');

	$reqId=$_GET['reqId'];
	$query="select * from paymentreq where Id=$reqId";
	$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='$reqId'";
		if(mysqli_query($con,$query1))
		{
	        $msg="Your Payment Request [ ".$reqId." ] 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 "<div class='msg-div'>
			        <form method='post'>
					    <h3 style='color:blue'>Payment Request Have Been Rejected !</h3><br>
						<i class='fa fa-check-circle' aria-hidden='true' id='okIcon'></i><br><br>
						<button type='submit' class='btnPopup'>OK</button><br><br>
					</form>
				</div>";
		}
		else
		{
			$msg= "Something Error !";
			            echo "<div class='msg-div'>
			                    <form method='post'>
				                    <h3>".$msg."</h3><br>
				                    <i class='fa fa-ban' aria-hidden='true' id='NotokIcon'></i><br><br>
				                    <button type='submit' class='btnPopup'>OK</button><br><br>
			                    </form>
		                    </div>";
	    }
	}
?>
			<div class="data-content">
				<div class="div1">
				    <form method="post">
					    <input type="number" placeholder="Enter Bank Charge..." name="bc">
				        <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>
		                
		                <input type="submit" name="submit" value="Reject">
				    </form>
				</div>
			</div>
		</div>
	</div>
	<?php
		require'footer.php';
	?>
</body>
</html>