<?php
    include'session.php';
	include'../connection.php';
	include'../functions.php';
?>
<html>
<head>
	<title>Dashboard</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">
	
	<!-- User CSS File Link -->
	<link rel="stylesheet" href="css/style.css">
	
	<!-- User JAVA SCRIPT File Link -->
	<script type="text/javascript" src="js/script.js"></script>


    <!-- Custom fonts for this template-->
    <!--<link href="fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">-->
	
	<!-- Font Awesome Icone -->
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
	
	<style>
		/* Content Style Coding*/
		.data-content{
			background:#f7f7f7;
			width:100%;
			min-height:500px;
			padding:10px;
		}
		.display{
			width:240px;
			height:130px;
			border-radius:5px;
			float:left;
			margin:10px;
			box-shadow:8px 8px 8px #aaaaaa;
		}
		.div1{
			background:;
			width:30%;
			height:90px;
			float:left;
			border-radius:5px 0 0 0;
			color:white;
		}
		.div1 i{
			font-size:60px;
			margin:10px;
		}
		.div2{
			background:;
			width:70%;
			height:90px;
			float:left;
			text-align:right;
			color:white;
			padding:10px 10px 0 0;
			border-radius:0 5px 0 0 ;
		}
		.div2 h3{
			padding:2px 0px;
			font-size:22px;
		}
		.div3{
			background:gray;
			width:100%;
			height:40px;
			float:left;
			border-radius:0 0 5px 5px;
			border-top:1px solid white;
			line-height:40px;
			color:white;
		}
		.div4{
			background:;
			float:left;
			height:39px;
			margin-left:15px;
		}
		.div5{
			background:;
			float:right;
			height:39px;
			margin-right:15px;
		}
		.div5 i{
			margin-top:10px;
			font-size:19px;
		}
		
		table{width:auto; margin:10px; border-collapse:collapse; background:white; float:left;}
		table th{background:gray; color:white; padding:5px 10px;text-align:center; border-left:white solid 1px;}
		table td{padding:5px 10px; border-collapse:collapse; 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>Dashboard :-</p></div>
				<div class="msg"><marquee><?php include'../msg.php'; ?></marquee></msg>
			</div><hr>
			<div class="data-content">
				<div class="display" style="background:orange;">
					<div class="div1"><i class="fa fa-inr"></i></div>
					<div class="div2">
						<h3>Income Of The Day</h3>
						<i class="fa fa-inr"></i> <?php echo floor($totalIncome); ?>
					</div>
					<a href="redeem_commission.php"><div class="div3">
						<div class="div4"><p>View List</p></div>
						<div class="div5"><i class="fa fa-arrow-circle-right"></i></div>
					</div></a>
				</div>
				<div class="display" style="background:green;">
					<div class="div1"><i class="fa fa-sitemap"></i></div>
					<div class="div2">
						<h3>Total Retailers</h3>
						<i class="fa fa-users"></i> <?php echo $countDownline; ?>
					</div>
					<a href="retailers_list.php"><div class="div3">
						<div class="div4"><p>View List</p></div>
						<div class="div5"><i class="fa fa-arrow-circle-right"></i></div>
					</div></a>
				</div>
				<div class="display" style="background:purple;">
					<div class="div1"><i class="fa fa-shopping-cart"></i></div>
					<div class="div2">
						<h3>Purchase Of The Day</h3>
						<i class="fa fa-shopping-cart"></i> <?php echo $reqAmount; ?>
					</div>
					<a href="topup_reports.php"><div class="div3">
						<div class="div4"><p>View List</p></div>
						<div class="div5"><i class="fa fa-arrow-circle-right"></i></div>
					</div></a>
				</div>
				<div class="data_rech">
				    <table border="1" cellpadding="10">
				        <tr>
				            <th style="border-left:solid black 1px">User</th>
				            <th>Bal</th>
				        </tr>
				        <tr>
				            <td>Admin</td>
				            <td><?php echo floor($AdminBal) ?></td>
				        </tr>
				        <tr>
				            <td>MD BAL</td>
				            <td><?php echo floor($totalMdBal) ?></td>
				        </tr>
				        <tr>
				            <td>DIS BAL</td>
				            <td><?php echo floor($DiswalletBal) ?></td>
				        </tr>
				        <tr>
				            <td>RET BAL</td>
				            <td><?php echo floor($RetWalletBal) ?></td>
				        </tr>
				        <tr>
				            <td>MLM User</td>
				            <td><?php echo floor($mlmWalletBal) ?></td>
				        </tr>
				        <tr>
				            <td>Commission</td>
				            <td><?php echo floor($Commission) ?></td>
				        </tr>
				        <tr>
				            <td>TOT USER</td>
				            <td><?php echo floor($totalUserWalletBal) ?></td>
				        </tr>
				        <tr>
				            <td>TOT BIZ</td>
				            <td><?php echo floor($TotalBizBal) ?></td>
				        </tr>
				        <tr>
				            <td>TOT BANK</td>
				            <td><?php echo floor($AllBankBal) ?></td>
				        </tr>
				        <tr>
				            <td>BIZ DIF</td>
				            <td><?php echo floor($BizDiff) ?></td>
				        </tr>
				        <tr>
				            <td>TOT DIF</td>
				            <td><?php echo floor($BenefitBal) ?></td>
				        </tr>
				    </table>
				    <table border="1" cellpadding="10">
				        <tr>
				            <th>Operator</th>
				            <th>Amount</th>
				            <th>RO</th>
				            <th>RO%</th>
				        </tr>
				        <?php
				            $quRech = "SELECT OpName, SUM(Amount), SUM(R_offer) FROM recharge WHERE Status='SUCCESS' AND Date='$date' GROUP BY OpName ORDER BY OpName";
				            $reRech = mysqli_query($con,$quRech);
				            while($dataRech = mysqli_fetch_array($reRech))
				            {
				                $OpName = $dataRech[0];
				                $Amount = $dataRech[1];
				                $ROffer = getRA($dataRech[2]);
				                $RO_Per = getRA($ROffer*100/$Amount);
				                echo "<tr>";
				                    echo "<td>".$OpName."</td>";
				                    echo "<td>".$Amount."</td>";
				                    echo "<td>".$ROffer."</td>";
				                    echo "<td>".$RO_Per."</td>";
				                echo "</tr>";
				                $totalRech = $totalRech+$Amount;
				                $totalRO = $totalRO+$ROffer;
				            }
				           echo "<tr>"; 
				                echo "<th>Total</th>";
				                echo "<th>".$totalRech."</th>";
				                echo "<th>".$totalRO."</th>";
				                echo "<th></th>";
				           echo "</tr>"; 
				        
				        ?>
				    </table>
				</div>
			</div>
		</div>
	</div>
	<?php
		require'footer.php';
	?>
	<script>
		function submenu(Arg)
    {
	
	var i;
	var d = document.getElementById("submenu"+Arg);
	var a = document.getElementById("angle"+Arg);
	var nol = d.getElementsByTagName('li').length;
	var dh = (35*nol)+8;
	
	d.style.transition = "all 1s";
	a.style.transition = "all .5s";
	if(d.style.height==dh+"px")
	{
		d.style.height = "0px";
		a.style.transform = "rotate(0deg)";
	}
	else
	{
		for(i=1; 1<=10; i++)
		{
			if(i==Arg)
			{	
				d.style.height = dh+"px";
				document.getElementById("angle"+i).style.transform = "rotate(90deg)";

			}
			else
			{	
				var od = document.getElementById("submenu"+i);
				od.style.height = "0px";
				document.getElementById("angle"+i).style.transform = "rotate(0deg)";
			}
		}
	}
}
	</script>
</body>
</html>