<?php
	session_start();
	if($_SESSION['rid'])
	{
		$userid=$_SESSION['rid'];
	}
	else
	{
		header('location:../login.php');
	}
?>
<?php
	include'connection.php';
		
		$query8="select * from wallet where Userid='$userid' order by Id desc";
		$result8=mysqli_query($con,$query8);
		$data8=mysqli_fetch_array($result8);
		$currentbal= $data8['Balance'];
		
		$query2="select * from distributer where Userid=$userid";
		$result2=mysqli_query($con,$query2);
		$data=mysqli_fetch_array($result2);
		$username=$data['Name'];
		$parentid=$data['Parentid'];
?>
<html>
<title>LLP Recharge</title>
<head>
<style>
body{background:url('bg.jpg'); background-size:cover;
width:100%; height:700px; margin:0px;}

.head{background:; width:1350px; height:85px; margin:0px;}
#p1{font-size:34px; float:left; Margin:10 0 0 45px; color:#996420; font-weight:bold;}
#p2{font-size:20px; float:left; margin:28 0 0 -8px; color:#eaa040; font-family:Courier;}
#p3{font-size:15px; font-family:Comic Sans MS; float:left; color:#996420; margin-top:48px; margin-left:-153px;}
.h2{background:white; width:400px; height:70px; margin:10 200px;}
#link1{float:right; margin:10 30 0 0px; font-size:20px; text-decoration:none;
 color:white; background:red; padding:5px; border-radius:4px;}
 #link2{float:right; margin:10 30 0 0px; font-size:20px; background:white;color:Green; padding:5px; border-radius:4px;}
#link1:hover{ padding:5px; border-radius:4px; color:black;}
	
.menu{background:#996420; height:40px; width:1300px; margin:0 0 0 20px; padding:0;}
.menu ul{padding:0; margin:0; position:relative; display:inline-block;}
.menu ul li{list-style:none; float:left; width:170px; line-height:40px;
	text-align:center; font-size:15px; margin:0; padding:0; color:white;}
.menu ul li ul {display:none;}
.menu ul li:hover{background:#d1994a; cursor:pointer;}
.menu ul li:hover ul {display:block; z-index:2;}
.menu ul li:hover ul li{background:#d1994a; border-top:solid white 0.1px;}
.menu ul li ul li:hover{background:#996420; color:white;}
.menu ul li ul li:hover a{ color:white;}
.menu ul li a{ text-decoration:none; color:white;}
 #a1{border:none; color:white;}
 .menu{letter-spacing:1px;}
 #bal:hover{background:#996420; cursor:text;}
 
 .rechhistoryhead{width:1300px; height:40px;
 margin:10 20px;}
 #h3f{margin-left:20px; line-height:40px; color:black;}
 .search{height:70px; width:97%; margin:10 20px;}
 .search input{margin:30 10px;}
.viewstatus1{width:1300px; height:40px; background:#3d8540; margin-left:20px; line-height:40px;}
.viewstatus2{width:1300px; height:40px; background:#3d3d85; margin-left:20px; line-height:40px;}
.viewstatus3{width:1300px; height:40px; background:#cc860d; margin-left:20px; line-height:40px;}
 h3{margin-left:20px; color:white; font-family:sans-serif;}
#t1{ width:1300px; text-align:center; border-collapse:collapse; border-color:black; margin-left:20px;}
#t1 th{font-family:calibri; background:#94928f; color:white; }
#t1 td{font-family:calibri;}
#t1 tr:nth-child(odd){background:#f6f0e8;}
#t1 tr:nth-child(even){background:white; }

#green{color:#19dc42;}
#red{color:red;}
#blue{color:blue;}
 
.foot{margin:50px;}
</style>
</head>
<body>
	<div class="head">
		<p id="p1">LLP</p>
		<p id="p2">Recharge</p>
		<p id="p3">The Complete Solution</p>
		<a id="link1" href="logout.php">Log Out</a>
	</div>
	<div class="menu">
		<ul>
			<li><a href="recharge_home.php" id="a1">Home</a></li>
			<li>Reports
				<ul>
					<li><a href="recharge_history.php">Recharge History</a></li>
					<li><a href="account_reports.php">Account Reports</a></li>
					<li><a href="check_status.php">Check Status</a></li>
				</ul>
			</li>
			<li>Documents
				<ul>
					<li><a href="my_commission.php">My Commission</a></li>
					<li><a href="commision.php">Get Commission</a></li>
					<li><a href="complain.php">Complain</a></li>
				</ul>
			</li>
			<li>Profile
				<ul>
					<li><a href="change_profile.php">Change Profile</a></li>
					<li><a href="change_pwd.php">Change Password</a></li>
				</ul>
			</li>
			<li>Payment Request
				<ul>
					<li><a href="payment_request.php">Update Payment</a></li>
					<li><a href="bank_list.php">Bank List</a></li>
				</ul>
			</li>
			<li id="bal">Balance : <?php echo $currentbal; ?></li>
		</ul>
	</div>
		<div class="rechhistoryhead">
		<h3 id="h3f">Recharge Status<h3>
	</div><hr>
	<div class="search">
	
		<form method="post">
		Recharge Id: <input type="text" name="rechid">
		 <input type="submit" name="submit">
		 </form>
	</div>
	<div class="viewstatus1">
		<h3>View Status</h3>
	</div>
		<table border="1" cellpadding="10" id="t1">
			<tr>
				<th>Recharge Id</th>
				<th>Date | Time</th>
				<th>E-Wallet Id</th>
				<th>Company</th>
				<th>Mobile No.</th>
				<th>Amount</th>
				<th>Operator Id</th>
				<th>Status</th>
			</tr>
	<?php
		include'connection.php';
		if(isset($_POST['submit']))
		{
			$rechid=$_POST['rechid'];
			
			$query="select * from recharge where Userid='$userid' and Id='$rechid'";
			$result=mysqli_query($con,$query);
			$data=mysqli_fetch_array($result);
			
			if($data['Status']=='SUCCESS')
			{
	    		$color="green";
			}
			elseif($data['Status']=='FAILED')
			{
				$color="red";
			}
			else
			{
			    $color="blue";
			}
			
			if($data['Id']==$rechid || $data['Mobile'])
			{
				echo "<tr>";
					echo "<td>".$data['Id']."</td>";
					echo "<td>".$data['Rechargedate']." | ".$data['Time']."</td>";
					echo "<td>".$data['Ewalletid']." , ".$data['Creditewalletid']."</td>";
					echo "<td>".$data['Companyname']."</td>";
					echo "<td>".$data['Mobile']."</td>";
					echo "<td>".$data['Amount']."</td>";
					echo "<td>".$data['Operatorid']."</td>";
					echo "<td id='$color'>".$data['Status']."</td>";
				echo "<tr>";
			}
			else
			{
				echo "Recharge Id Not Found !";
			}
			}
		
	?>
		</table>

	<div class="viewstatus2">
		<h3>Account Status</h3>
	</div>
		<table border="1" cellpadding="10" id="t1">
			<tr>
				<th>Recharge Id</th>
				<th>Date | Time</th>
				<th>E-Wallet Id</th>
				<th>Transaction Type</th>
				<th>Discription</th>
				<th>Opening Bal.</th>
				<th>Credit Amount</th>
				<th>Debit Amount</th>
				<th>Closing Bal.</th>
			</tr>
	<?php
		include'connection.php';
		if(isset($_POST['submit']))
		{
			$rechid=$_POST['rechid'];
			
			$query1="select * from wallet where Userid='$userid' and Paynrechid='$rechid' order by Id asc";
			$result1=mysqli_query($con,$query1);
			$data1=mysqli_fetch_array($result1);
				$mobile=$data1['Mobile'];
				$amount=$data1['Amount'];
				$Operator=$data1['Operator'];
			if($data1['Paynrechid']==$rechid)
			{
				echo "<tr>";
					echo "<td>".$data1['Paynrechid']."</td>";
					echo "<td>".$data1['Date']." | ".$data1['Time']."</td>";
					echo "<td>".$data1['Id']."</td>";
					echo "<td>".$data1['Transactiontype']."</td>";
					echo "<td>".$mobile." || ".$amount." || ".$Operator."</td>";
					echo "<td>".$data1['Openingbalance']."</td>";
					echo "<td>".$data1['Credit']."</td>";
					echo "<td>".$data1['Debit']."</td>";
					echo "<td>".$data1['Balance']."</td>";
				echo "<tr>";
			}
			
			
		}
	?>
		</table>
		
	<div class="viewstatus3">
		<h3>Refund Status</h3>
	</div>
		<table border="1" cellpadding="10" id="t1">
			<tr>
				<th>Recharge Id</th>
				<th>Date | Time</th>
				<th>E-Wallet Id</th>
				<th>Transaction Type</th>
				<th>Discription</th>
				<th>Opening Bal.</th>
				<th>Credit Amount</th>
				<th>Debit Amount</th>
				<th>Closing Bal.</th>
			</tr>
	<?php
		include'connection.php';
		if(isset($_POST['submit']))
		{
			$rechid=$_POST['rechid'];
			
			$query2="select * from wallet where Userid='$userid' and Paynrechid='$rechid' order by Id desc";
			$result2=mysqli_query($con,$query2);
			$data2=mysqli_fetch_array($result2);
				$mobile=$data1['Mobile'];
				$amount=$data1['Amount'];
				$Operator=$data1['Operator'];
			if($data2['Paynrechid']==$rechid && $data2['Transactiontype']=='Recharge_Refund')
			{
				echo "<tr>";
					echo "<td>".$data2['Paynrechid']."</td>";
					echo "<td>".$data2['Date']." | ".$data2['Time']."</td>";
					echo "<td>".$data2['Id']."</td>";
					echo "<td>".$data2['Transactiontype']."</td>";
					echo "<td>".$mobile." || ".$amount." || ".$Operator."</td>";
					echo "<td>".$data2['Openingbalance']."</td>";
					echo "<td>".$data2['Credit']."</td>";
					echo "<td>".$data2['Debit']."</td>";
					echo "<td>".$data2['Balance']."</td>";
				echo "<tr>";
			}
		}
	?>
		</table>
	<div class="foot">
		<p>Copyright &copy; 2018 Long Life Product Pvt. Ltd.</p>
	</div>
</body>
</html>