<?PHP
	include'session.php';
	include'connection.php';
	include'../Retailers/functions.php';
	include'time.php';
	include'../Admin1/insertDiff.php';
?>
<html>
<head>
	<title>Recharge Panel</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:left;
			text-align:center;
			padding:10px;
		}
		.div1 table{
			width:94%;
			text-align:center;
			font-size:13px;
			border-collapse:collapse;
			margin:10px;
			padding:2px 10px;
		}
		.div1 hr{
			margin:5px 10px;
			padding:0 10px;
		}
		table th{
			background:#6b5127;
			color:white;
			height:40px;
			border:solid white 1px;
			padding:2px;
		}
		table td{
			background:white;
			height:40px;
			border:solid black 1px;
			padding:2px 4px;
		}
		.div1 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;
		}
		#BalGreen{background:green; color:white; padding:4px 10px; border-radius:5px;}
		#BalRed{background:red; color:white; padding:4px 10px; border-radius:5px;}
		
		.subdiv1{background:; margin:10px 5%; width:90%;}
		.subdiv1 button{background:white; width:27%; height:30px; margin:5px; font-size:17px; border-radius:8px 0px 8px 0px;}
		.subdiv1 button i{font-size:20px;}
		#prepaid{background:lime;}
		#List1,#sbmt1{display:inline;}
		#List2,#sbmt2{display:none;}
		#List3,#sbmt3{display:none;}
		
		
		textarea{
			height:100px;
			padding:5px 10px;
		}
		input[type=submit]{
			background:#6b5127;
			color:white;
			font-size:30px;
			transition:1s;
		}
		input[type=radio]{
			width:25%;
			font-size:30px;
		}
		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';
			$totalTxn=gettxn($userid);
			if(getUser($userid)['TotalTxn']!=$totalTxn)
			{
			    $update="UPDATE MLM_Users SET TotalTxn='$totalTxn' WHERE Userid='$userid'";
			    mysqli_query($con,$update);
			}
			
			
			if(isset($_POST['submit1']))
	        {
		        $opOwnCode = $_POST['op1'];
		        include'recharge_code.php';
	        }
	        elseif(isset($_POST['submit2']))
	        {
		        $opOwnCode = $_POST['op2'];
		        include'recharge_code.php';
	        }
	        elseif(isset($_POST['submit3']))
	        {
		        $opOwnCode = $_POST['op3'];
		        include'recharge_code.php';
	        }
		?>
		<div class="content">
			<div class="head">
				<div class="title"><p>Recharge Panel :-</p></div>
				<div class="msg"><marquee><?php include'msg.php'; ?></marquee></msg>
			</div><hr>
			<div class="data-content">
			    <script>
			        function serviceType(Arg)
			        {
			            if(Arg==1)
			            {
			                document.getElementById("prepaid").style.background = "lime";
			                document.getElementById("dth").style.background = "white";
			                
			                document.getElementById("List1").style.display = "inline";
			                document.getElementById("List2").style.display = "none";
			                
			                document.getElementById("sbmt1").style.display = "inline";
			                document.getElementById("sbmt2").style.display = "none";
			            }
			            else if(Arg==2)
			            {
			                document.getElementById("prepaid").style.background = "white";
			                document.getElementById("dth").style.background = "lime";
			                
			                document.getElementById("List1").style.display = "none";
			                document.getElementById("List2").style.display = "inline";
			                
			                document.getElementById("sbmt1").style.display = "none";
			                document.getElementById("sbmt2").style.display = "inline";
			            }   
			            
			        }
			    </script>
				<form method="post">
					<div class="div1">
					    <br><b>My Wallet Balance : 
					        <?php
					            if($usrBal<500){
					                $bId="BalRed";
					            }else{
					                $bId="BalGreen";
					           }
					           echo "<b id='".$bId."'><i class='fa fa-inr'></i> ".number_format($usrBal, 2)."</b>" ?>
					     </b><br><br>
					    <div class="subdiv1">
					        <button type="button" name="service" id="prepaid" onclick='serviceType(1)'><i class="fa fa-mobile"></i> Mobile</button>
					        <button type="button" name="service" id="dth"  onclick='serviceType(2)'><i class="fa fa-television"></i> DTH</button>
					        <!--<button type="button" name="service" id="postpaid"  onclick='serviceType(3)'><i class="fa fa-mobile"></i> POSTPAID</button>-->
					    </div>
						    <select name="op1" id="List1" >
						        <option>--Select Operator--</option>
						    <?php
						        $quGetRet="SELECT * FROM operator WHERE Serviceid='1' AND Active='0'";
						        $reGetRet=mysqli_query($con,$quGetRet);
						        while($dataGetRet=mysqli_fetch_array($reGetRet))
						        {
						            if($dataGetRet['OwnApiCode']==31 || $dataGetRet['OwnApiCode']==32)
						            {
						                
						            }
						            else
						            {
						                echo "<option value='".$dataGetRet['OwnApiCode']."'>".$dataGetRet['Operator']."</option>";
						            }
						        }
						        
						        
						    ?>
						</select>
						    <select name="op2" id="List2" >
						        <option>--Select Operator--</option>
						    <?php
						        $quGetRet="SELECT * FROM operator WHERE Serviceid='2' AND Active='0'";
						        $reGetRet=mysqli_query($con,$quGetRet);
						        while($dataGetRet=mysqli_fetch_array($reGetRet))
						        {
						            echo "<option value='".$dataGetRet['OwnApiCode']."'>".$dataGetRet['Operator']."</option>";
						        }
						        
						        
						    ?>
						</select>
						    <select name="op3" id="List3" >
						        <option>--Select Operator--</option>
						    <?php
						        $quGetRet="SELECT * FROM operator WHERE Serviceid='3' AND Active='0'";
						        $reGetRet=mysqli_query($con,$quGetRet);
						        while($dataGetRet=mysqli_fetch_array($reGetRet))
						        {
						            echo "<option value='".$dataGetRet['OwnApiCode']."'>".$dataGetRet['Operator']."</option>";
						        }
						        
						        
						    ?>
						</select>
						<input type="number" name="mobileNo1" placeholder="Enter Mobile/DTH Number...">
						<input type="number" name="mobileNo2" placeholder="Confirm Mobile/DTH Number...">
						<input type="number" name="amount" placeholder="Enter Amount...">
						<input type="submit" Action="recharge_code.php" id="sbmt1" name="submit1" value="Recharge Now"  onclick='showLoader()'>
						<input type="submit" Action="recharge_code.php" id="sbmt2" name="submit2" value="Recharge Now"  onclick='showLoader()'>
						<input type="submit" Action="recharge_code.php" id="sbmt3" name="submit3" value="Recharge Now"  onclick='showLoader()'>
					</div>
				</form>
				<div class="div1">
					<center><h1>Recent Transaction</h1></center><hr>
					<table cellpadding="20" border="2">
						<tr>
							<th>Order Id</th>
							<th>Discription</th>
							<th>Status</th>
						</tr>
						<?php
							$quGetTxn="SELECT * FROM recharge WHERE Userid='$userid' ORDER BY Id DESC LIMIT 10";
							$reGetTxn=mysqli_query($con,$quGetTxn);
							while($dataGetTxn=mysqli_fetch_array($reGetTxn))
							{
								if($dataGetTxn['Status']=="FAILED")
								{
									$color="red";
								}
								elseif($dataGetTxn['Status']=="SUCCESS")
								{
									$color="green";
								}
								else
								{
									$color="blue";
								}
								echo "<tr>";
									echo "<td>".$dataGetTxn['Id']."</td>";
									echo "<td>".$dataGetTxn['Mobile']." - ".$dataGetTxn['Companyname']." - <i class='fa fa-inr'></i>".$dataGetTxn['Amount']." - ".$dataGetTxn['Operatorid']."</td>";
									echo "<td><p id='".$color."'>".$dataGetTxn['Status']."</p></td>";
								echo "</tr>";
							}
						?>
					</table>
				</div>
			</div>
		</div>
	</div>
	<?php
		require'footer.php';
	?>
</body>
</html>