<?php
	session_start();
	if($_SESSION['kbuid'])
	{
		$userid= $_SESSION['kbuid'];
	}
	else
	{
		header('location:../login.php');
	}
?>
<?php
	include'connection.php';
	
	$quIncome="SELECT * FROM income WHERE Userid='$userid'";
	$reIncome=mysqli_query($con,$quIncome);
	$totalIncome=0;
	while($dataIncome=mysqli_fetch_array($reIncome))
	{
		$totalIncome=$totalIncome+$dataIncome['Txn'];
	}
	
	$quDownline="SELECT * FROM user WHERE Parent1='$userid' OR Parent1='$userid' OR Parent2='$userid' OR Parent3='$userid' OR Parent4='$userid' OR Parent5='$userid'";
	$reDownline=mysqli_query($con,$quDownline);
	$countDownline=mysqli_num_rows($reDownline);
	
	$quSponser="SELECT * FROM user WHERE SponserId='$userid'";
	$reSponser=mysqli_query($con,$quSponser);
	$countSponser=mysqli_num_rows($reSponser);
?>
<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;
		}
	</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>Total Income</h3>
						<i class="fa fa-inr"></i> <?php echo $totalIncome; ?>
					</div>
					<a href="income_summary.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-tasks"></i></div>
					<div class="div2">
						<h3>Downline</h3>
						<i class="fa fa-users"></i> <?php echo $countDownline; ?>
					</div>
					<a href="downline.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:blue;">
					<div class="div1"><i class="fa fa-sitemap"></i></div>
					<div class="div2">
						<h3>Direct Sponser</h3>
						<i class="fa fa-sitemap"></i> <?php echo $countSponser; ?>
					</div>
					<a href="direct_downline.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:red;">
					<div class="div1"><i class="fa fa-support"></i></div>
					<div class="div2">
						<h3>Total Team</h3>
						<i class="fa fa-inr"></i>
					</div>
					<a href="#"><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>
		</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>