<?php
        $reqType = $_POST['reqType'];
		$amount  = $_POST['amount'];
		$Pdate   = $_POST['date'];
		$BankId  = $_POST['BankId'];
		$mode    = $_POST['mode'];
		$txn     = $_POST['txn'];
		$msg     = $_POST['msg'];
		
		$allowAmount=500000;
		$minimumAmount="5000";
		if($reqType=="BANKING")
		{
		    $minimumAmount = "2000";
		}
		if(empty($amount))
		{
		    echo "<div class='msg-div'>
			        <form method='post'>
				        <h3>Fill All Fields Please !</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>";
		}
		elseif($amount<$minimumAmount || $amount>$allowAmount)
		{
		    echo "<div class='msg-div'>
			        <form method='post'>
				        <h3>Amount Must Be $minimumAmount To .$allowAmount. Only !</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>";
		}
		elseif($bank=="--Select Bank--" && $reqType=="BANKING")
		{
		    echo "<div class='msg-div'>
			        <form method='post'>
				        <h3>Select Bank Please !</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>";
		}
		elseif($mode=="--Select Mode--" && $reqType=="BANKING")
		{
		    echo "<div class='msg-div'>
			        <form method='post'>
				        <h3>Select Payment Mode !</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>";
		}
		else
		{	
		    if($reqType=="BANKING")
		    {
			    $condition1 = "Amount='$amount' AND TxnNo='$txn' AND Userid='$userid' AND Status='PENDING'";
			    $condition2 = "OR Amount='$amount' AND TxnNo='$txn' AND Userid='$userid' AND Status='APPROVED'";
		    }
		    else
		    {
		        $condition1 = "Amount='$amount' AND Date='$date' AND Userid='$userid' AND Status='PENDING'";
			    $condition2 = "OR Amount='$amount' AND Date='$date' AND Userid='$userid' AND Status='APPROVED'";
		    }
			$quDupTxn="SELECT * FROM order_req WHERE $condition1 $condition2";
			$reDupTxn=mysqli_query($con,$quDupTxn);
			$countDupTxn=mysqli_num_rows($reDupTxn);
			if($countDupTxn>=1)
			{
			    echo "<div class='msg-div'>
			        <form method='post'>
				        <h3>Duplicate Transaction Not Allowed !</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>";
			}
			else
			{
			    if($reqType=="BANKING")
			    {
	    		    $quInsertRequest="INSERT INTO order_req(Date,Time,Userid,ReqType,Amount,BankId,TxnNo,Mode,Remarks)
		    		VALUES('$date','$time','$userid','$reqType','$amount','$BankId','$txn','$mode','$msg')";
			    }
			    else
			    {
			        $quInsertRequest="INSERT INTO order_req(Date,Time,Userid,ReqType,Amount)
		    		VALUES('$date','$time','$userid','$reqType','$amount')"; 
			    }
				if(mysqli_query($con,$quInsertRequest))
				{
					echo "<div class='msg-div'>
							<form method='post'>
							<h3>Payment Request Submited Successfully !</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>";
				}
			}
		}
?>