<?php
	session_start();
	if($_SESSION['subadm'])
	{
		$userid=1111;
	}
	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'];
	
?>
<html>
    <title>Diffrence</title>
<head>
<style>
body{background:#e6d9c8; background-size:cover; background-repeat:repeat; background-repeat:repeat-x; margin:0; padding:0; width:1580px;}
.head{background:; width:1580px; height:80px; 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;}

#link0{float:right; margin:10 10 0 0px; font-size:20px; text-decoration:none; color:white; background:red; padding:5px; border-radius:4px;}
 #link1{float:right; margin:10 10 0 0px; font-size:20px; text-decoration:none; color:white; background:green; padding:5px; border-radius:4px;}
#link0:hover{ padding:5px; border-radius:4px; color:black;}

.menu{background:#996420; height:40px; width:1450px; margin-left:10px; padding:0; line-height:40px;}
.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;}
#AFLI{background:white; width:200px;}
#AFLI:hover{background:#f5f5f5;}
 #inp{width:200px; height:35px; padding:3 10px; font-size:20px;}
 #srchby{margin-left:20px; font-family:calibri; font-size:22px;}
 .date{background:; margin:10 0 0 20px;}
 .rechreport{width:1560px; height:40px; background:#996420; color:white; line-height:40px; margin:0 0 0 20px;}
 .rechreport p{margin-left:20px;}
.notifi{background:#995702; width:800px; height:70px; margin:5 5 5 300px; border-radius:8px;}
.imgdiv{background:; width:60px; height:60px; float:left; margin:0 20px;}
#notifidiv{background:red; width:40px; height:40px; margin:0 0 0 30px; border-radius:50%; text-align:center; line-height:40px;
color:white; font-size:20px; z-index:4; float:left; position:absolute;}
img{width:60px; height:60px; float:left; margin:7px;}
#myInput{width:200px; height:40px; font-size:17px; margin:0 10px; border-radius:8px;}
#t1{ width:1560px; text-align:center; border-collapse:collapse; border-color:black; margin-left:20px; font-size:20px;}
#t1 th{font-family:calibri; background:#94928f; color:white;}
#t1 td{font-family:calibri; }
#tda a{text-decoration:none; font-size:18px; font-family:sans-serif; color:#0b52e2;}
#rechId{text-decoration:none; background:; color:blue; font-size:18px; padding:2 5px; border-radius:4px; font-weight:bold;}
#green{background:green; color:white; font-size:18px; padding:2 5px; border-radius:4px; font-weight:bold;}
#red{background:red; color:white; font-size:18px; padding:2 5px; border-radius:4px; font-weight:bold;}
#blue{background:blue; color:white; font-size:18px; padding:2 5px; border-radius:4px; font-weight:bold;}
#lightPink{background:#f4cfd7;}
#pink{background:#f6f0e8;}
 .foot{float:left; margin:10 0 0 100px; width:1350px;}
 </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="link0" href="logout.php">Log Out</a>
		<p id="link1"><?php echo "Welcome $userid Admin";  ?></p>
    </div>
	<?php include 'menu.php'; ?>
	<div class="date">
	    <?php
	        date_default_timezone_set("asia/Kolkata");
			$datetime= Date("Y-m-d - h:i:s A");
			$time= Date("h:i:s A");
			$date= Date("Y-m-d");
			
	    ?>
	    <form method="post">
		From Date : <input type="date" name="fdate" value="<?php echo $date; ?>" id="inp">
		To Date : <input type="date" name="ldate" value="<?php echo $date; ?>" id="inp">
		<input type="submit" name="submit" id="inp">
		</form>
	</div>
	<div class="rechreport">
		<p>Adminstrator's Differances</p>
	</div>
	
	<table border="1" cellpadding="5" id="t1">
		<tr>
			<th>Date | Time</th>
			<th>Rech Id</th>
			<th>AdminBal</th>
			<th>MdBal</th>
			<th>DisBal</th>
			<th>RetBal</th>
			<th>CommBal</th>
			<th>Total User Bal</th>
			<th>AirtelBal</th>
			<th>IdeaBal</th>
			<th>VodaBal</th>
			<th>JioBal</th>
			<th>UniqBal</th>
			<th>KwikBal</th>
			<th>RechBal</th>
			<th>DiziApi</th>
			<th>PpApi</th>
			<th>OzzyApi</th>
			<th>Total Api Bal</th>
			<th>Diff</th>
		</tr>
	<?php
			include'connection.php';
			include'time.php';
		if(isset($_POST['submit']))
		{
			    $fdate=$_POST['fdate'];
			    $ldate=$_POST['ldate'];
			    $stats=$_POST['stats'];
			    
			    $quGetDiffByDate="select * from Diff where Date>='$fdate' and Date<='$ldate'";
			    $reGetDiffByDate=mysqli_query($con,$quGetDiffByDate);
			    $sl=0;
			   
			    while($dataByDate=mysqli_fetch_array($reGetDiffByDate))
			    {
			        $sl=$sl+1;
			        
			    	echo "<tr>";
    					echo "<td>".$dataByDate['Date']." | ".$dataByDate['Time']."</td>";
    					echo "<td title='Rech Id'>".floor($dataByDate['Rechid'])."</td>";
    					echo "<td title='Admin Bal'>".floor($dataByDate['AdminBal'])."</td>";
    					echo "<td title='MD Bal'>".floor($dataByDate['MdBal'])."</td>";
    					echo "<td title='Distributer Bal'>".floor($dataByDate['DisBal'])."</td>";
    					echo "<td title='Retailer Bal'>".floor($dataByDate['RetBal'])."</td>";
    					echo "<td title='Commission'>".floor($dataByDate['CommBal'])."</td>";
    					echo "<td title='Total User Bal'>".floor($dataByDate['TotUsrBal'])."</td>";
    					echo "<td title='Airtel Bal'>".floor($dataByDate['AirtelBal'])."</td>";
    					echo "<td title='Idea Bal'>".floor($dataByDate['IdeaBal'])."</td>";
    					echo "<td title='Vodafone Bal'>".floor($dataByDate['VodaBal'])."</td>";
    					echo "<td title='Jio Bal'>".floor($dataByDate['JioBal'])."</td>";
    					echo "<td title='Unique Api Bal'>".floor($dataByDate['UniqBal'])."</td>";
    					echo "<td title='Kwik Api Bal'>".floor($dataByDate['KwikBal'])."</td>";
    					echo "<td title='Rech Api Bal'>".floor($dataByDate['RechBal'])."</td>";
    					echo "<td title='DiziApi Bal'>".floor($dataByDate['DiziApi'])."</td>";
    					echo "<td title='PpApi Bal'>".floor($dataByDate['PpApi'])."</td>";
    					echo "<td title='OzzyApi Bal'>".floor($dataByDate['OzzyApi'])."</td>";
    					echo "<td title='Total Api Bal'>".floor($dataByDate['TotApiBal'])."</td>";
    					echo "<td title='Differences'>".floor($dataByDate['Diff'])."</td>";
    				echo "</tr>";
			    }
		}
		else
		{  
			    $sl=0;
			    
    			$quGetDiffByDate="select * from Diff where Date='$date' order by Id desc Limit 100";
			    $reGetDiffByDate=mysqli_query($con,$quGetDiffByDate);
			    $sl=0;
			   
			    while($dataByDate=mysqli_fetch_array($reGetDiffByDate))
			    {
			        $sl=$sl+1;
			        
			    	echo "<tr>";
    					echo "<td>".$dataByDate['Date']." | ".$dataByDate['Time']."</td>";
    					echo "<td title='Rech Id'>".floor($dataByDate['Rechid'])."</td>";
    					echo "<td title='Admin Bal'>".floor($dataByDate['AdminBal'])."</td>";
    					echo "<td title='MD Bal'>".floor($dataByDate['MdBal'])."</td>";
    					echo "<td title='Distributer Bal'>".floor($dataByDate['DisBal'])."</td>";
    					echo "<td title='Retailer Bal'>".floor($dataByDate['RetBal'])."</td>";
    					echo "<td title='Commission'>".floor($dataByDate['CommBal'])."</td>";
    					echo "<td title='Total User Bal'>".floor($dataByDate['TotUsrBal'])."</td>";
    					echo "<td title='Airtel Bal'>".floor($dataByDate['AirtelBal'])."</td>";
    					echo "<td title='Idea Bal'>".floor($dataByDate['IdeaBal'])."</td>";
    					echo "<td title='Vodafone Bal'>".floor($dataByDate['VodaBal'])."</td>";
    					echo "<td title='Jio Bal'>".floor($dataByDate['JioBal'])."</td>";
    					echo "<td title='Unique Api Bal'>".floor($dataByDate['UniqBal'])."</td>";
    					echo "<td title='Kwik Api Bal'>".floor($dataByDate['KwikBal'])."</td>";
    					echo "<td title='Rech Api Bal'>".floor($dataByDate['RechBal'])."</td>";
    					echo "<td title='DiziApi Bal'>".floor($dataByDate['DiziApi'])."</td>";
    					echo "<td title='PpApi Bal'>".floor($dataByDate['PpApi'])."</td>";
    					echo "<td title='OzzyApi Bal'>".floor($dataByDate['OzzyApi'])."</td>";
    					echo "<td title='Total Api Bal'>".floor($dataByDate['TotApiBal'])."</td>";
    					echo "<td title='Differences'>".floor($dataByDate['Diff'])."</td>";
    				echo "</tr>";
			    }
    	}
	?>
	</table>
	<div class="foot">
		<p>Copyright &copy; 2018 Long Life Product Pvt. Ltd.</p>
	</div>
</body>
</html>