<?php
	include'session.php';
	include'connection.php';
	include'../Retailers/functions.php';
?>
<html>
<head>
	<title>View Diff</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:;
			width:96%;
			padding:10px;
			margin:0 2%;
		}
		.div1 input, .div1 select{
			height:30px;
			width:180px;
			font-size:16px;
			padding:5px 8px;
			border-radius:5px;
			border:solid #6b5127 1px;
			overflow:auto;
			margin:10px 10px 0 5px;
		}
		input[type=submit]{
			background:#6b5127;
			color:white;
			transition:1s;
			cursor:pointer;
		}
		input[type=submit]:hover{
			background:white;
			color:#6b5127;
			transition:1s;
		}
		.div2{
			background:#f7f7f7;
			width:100%;
			float:left;
			text-align:center;
			padding:0 10px 10px 10px;
			overflow:auto;
			margin-bottom:20px;
		}
		.div2 table{
			width:96%;
			text-align:center;
			font-size:14px;
			border-collapse:collapse;
			padding:2px 10px;
			margin:0 2%;
		}
		table th{
			background:#6b5127;
			color:white;
			height:40px;
			border:solid white 1px;
			padding:2px 5px;
		}
		table td{
			background:white;
			height:40px;
			border:solid black 1px;
			padding:2px 5px;
		}
		@media(max-width:768px)
		{
			.div1{
				background:;
				width:100%;
				height:auto;
				margin:10px 0 0 0;
				padding:0;
				text-align:center;
			}.div1 input{
				width:90%;
				margin:10px;
			}
			.div2{
				width:100%;
				margin:10px 0 0 0;
				padding:0px;
				text-align:center;
			}
		}
	</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';
		?>
		<div class="content">
			<div class="head">
				<div class="title"><p>View Diff :-</p></div>
				<div class="msg"><marquee><?php include'msg.php'; ?></marquee></msg>
			</div><hr>
			<div class="data-content">
				<form method="post">
					<div class="div1">
					    <?php
					        if(isset($_POST['submit']))
					        {
					            $date1Value=$_POST['fdate'];
					            $date2Value=$_POST['ldate'];
					        }
					        else
					        {
					            $date1Value=$date;
					            $date2Value=$date;
					        }
					    
					    ?>
						<input type="date" name="fdate" value="<?php echo $date1Value; ?>">
						<input type="date" name="ldate" value="<?php echo $date2Value; ?>">
						<input type="submit" name="submit" value="Submit"  onclick='showLoader()'>
					</div>
				</form>
				<div class="div2">
					<table cellpadding="20" border="2"> 
						<tr>
							<th>Sl.</th>
							<th>Id</th>
							<th>Date</th>
							<th>Time</th>
							<th>Admin</th>
							<th>Md</th>
							<th>Dis</th>
							<th>Ret</th>
							<th>MLM</th>
							<th>Comm</th>
							<th>TUBal</th>
							<th>Airtel</th>
							<th>Idea</th>
							<th>Voda</th>
							<th>Jio</th>
							<th>BSNL</th>
							<th>Dizi</th>
							<th>PP</th>
							<th>Ozzy</th>
							<th>Ambika</th>
							<th>TABal</th>
							<th>Diff</th>
							<th>BizDiff</th>
						</tr>
						<?php
						    $sl=0;
						    $flag=0;
							if(isset($_POST['submit']))
							{
								$fdate = $_POST['fdate'];
								$ldate = $_POST['ldate'];
								$flag=1;
								$quDiff="SELECT * FROM Diff WHERE Date>='$fdate' AND Date<='$ldate'";
							}
							else
							{
							    $flag=1;
							    $quDiff="SELECT * FROM Diff ORDER BY Id DESC LIMIT 10";
							}
							
							if($flag==1)
							{
								$reDiff=mysqli_query($con,$quDiff);
								while($dataDiff=mysqli_fetch_array($reDiff))
								{
								    $sl=$sl+1;
									echo "<tr>";
										echo "<td>".$sl."</td>";
										echo "<td>".$dataDiff['Id']."</td>";
										echo "<td>".$dataDiff['Date']."</td>";
										echo "<td>".$dataDiff['Time']."</td>";
										echo "<td>".floor($dataDiff['AdminBal'])."</td>";
										echo "<td>".floor($dataDiff['MdBal'])."</td>";
										echo "<td>".floor($dataDiff['DisBal'])."</td>";
										echo "<td>".floor($dataDiff['RetBal'])."</td>";
										echo "<td>".floor($dataDiff['MLMBal'])."</td>";
										echo "<td>".floor($dataDiff['CommBal'])."</td>";
										echo "<td>".floor($dataDiff['TotUsrBal'])."</td>";
										echo "<td>".floor($dataDiff['AirtelBal'])."</td>";
										echo "<td>".floor($dataDiff['IdeaBal'])."</td>";
										echo "<td>".floor($dataDiff['VodaBal'])."</td>";
										echo "<td>".floor($dataDiff['JioBal'])."</td>";
										echo "<td>".floor($dataDiff['BSNL'])."</td>";
										echo "<td>".floor($dataDiff['DiziApi'])."</td>";
										echo "<td>".floor($dataDiff['PpApi'])."</td>";
										echo "<td>".floor($dataDiff['OzzyApi'])."</td>";
										echo "<td>".floor($dataDiff['AmbikaApi'])."</td>";
										echo "<td>".floor($dataDiff['TotApiBal'])."</td>";
										echo "<td>".floor($dataDiff['Diff'])."</td>";
										echo "<td>".floor($dataDiff['BizDiff'])."</td>";
					        		echo "</tr>";
								}
							}
						?>
					</table>
				</div>
			</div>
		</div>
	</div>
	<?php
		require'footer.php';
	?>
</body>
</html>