<?php
	include'session.php';
	include'connection.php';
	include'../Retailers/functions.php';
	
	
?>
<html>
<head>
	<title>Edit Generate Amount</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{
			background:#f7f7f7;
			width:50%;
			height:500px;
			float:right;
			text-align:center;
			padding-top:50px;
		}
		.div1 i{
			font-size:300px;
			color:#6b5127;
			margin:0 10px;
			
		}
		.div1 input, select{
			width:90%;
			height:55px;
			margin:10px;
			padding:2px 10px;
			border-radius:5px;
			border:1px solid #6b5127;
			font-size:19px;
		}
		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;
		}
		
		@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';
			include'connection.php';
			
			$eWalletId=$_GET['id'];
			
			if(isset($_POST['submit']))
			{
				$PayTo=$_POST['PayTo'];
				$service=$_POST['service'];
				$BankId=$_POST['BankId'];
				
				$quBankId="SELECT BankName FROM bank WHERE Id='$BankId'";
				$reBankId=mysqli_query($con,$quBankId);
				$dataBankId=mysqli_fetch_array($reBankId);
				$BankName=$dataBankId['BankName'];
				
				$quUpdateBank="UPDATE Bank_Account_Txn SET Bank_Id='$BankId', Bank_Name='$BankName' WHERE Txn_Id='$eWalletId' && Disc='Generate_Amount'";
				
				if(mysqli_query($con,$quUpdateBank))
				{
				    $queryupdate="UPDATE wallet SET TxnWith='$PayTo', TxnBy='$BankId', Paymentto='$service' WHERE Id='$eWalletId'";
				    if(mysqli_query($con,$queryupdate))
				    {
				    	echo "<div class='msg-div'>
						    <form method='post'>
						    <h3>E-Wallet has been Update 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>";
				    }
				    else
				    {
				    	echo "<div class='msg-div'>
			                    <form method='post'>
				                    <h3>Something Error !</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>";
				    }
				}
			}
			$query="select * from wallet where Id='$eWalletId'";
			$result=mysqli_query($con,$query);
			$row=mysqli_fetch_array($result);
	
		?>
		<div class="content">
			<div class="head">
				<div class="title"><p>Edit Generate Amount :-</p></div>
				<div class="msg"><marquee><?php include'msg.php'; ?></marquee></msg>
			</div><hr>
			<div class="data-content">
				<div class="div1">
				</div>
				<div class="div1">
				    <form method="post">
				        <select name="PayTo" "firmName()" id="Seller">
				            <option>--Select Seller--</option>
				            <?php
				                $quGetSeller="SELECT * FROM Seller WHERE Status='Active' ORDER BY Name ASC";
				                $reGetSeller=mysqli_query($con,$quGetSeller);
				                while($dataGetSeller=mysqli_fetch_array($reGetSeller))
				                {
				                    if($row['TxnWith']==$dataGetSeller['Name'])
				                    {
				                        echo "<option selected>".$dataGetSeller['Name']."</option>";
				                    }
				                    else
				                    {
				                        echo "<option>".$dataGetSeller['Name']."</option>";
				                    }
				                }
				            ?>
				            <option>Other</option>
				        </select>
				        <select name="BankId">
			                <option>--Select Bank--</option>
			                <option>Pay By Cash</option>
			                <option>Pay LLP Fund</option>
			                <?php
			                    $GetBank="SELECT * FROM bank";
    			                $reGetbank=mysqli_query($con,$GetBank);
	    		                while($dataGetbank=mysqli_fetch_array($reGetbank))
		    	                {
			                        echo "<option value='".$dataGetbank['Id']."'>".$dataGetbank['Bankname']." - ".$dataGetbank['Accname']."</option>"; 
			                    }
			                ?>
    			        </select>
						<input type="submit" name="submit" value="Submit"  onclick='showLoader()'>
				    </form>
				</div>
			</div>
		</div>
	</div>
	<?php
		require'footer.php';
	?>
</body>
</html>