<?php
	include'session.php';
	include'connection.php';
	include'../Retailers/functions.php';
	
	$selfIncome=0;
	$spoIncome=0;
	$Level1=0;
	$Level2=0;
	$Level3=0;
	$Level4=0;
	$Level5=0;
	$totalIncme=0;
	$gst=0;
	$netIncme=0;
	
	$query="SELECT * FROM MLM_Income WHERE Userid='$userid'";
	$result=mysqli_query($con,$query);
	while($data=mysqli_fetch_array($result))
	{
	    if($data['TxnType']=="SelfIncome")
	    {
	        $selfIncome=$selfIncome+$data['Amount'];
	    }
	    if($data['TxnType']=="SponsorIncome")
	    {
	        $spoIncome=$spoIncome+$data['Amount'];
	    }
	    if($data['TxnType']=="Level1")
	    {
	        $Level1=$Level1+$data['Amount'];
	    }
	    if($data['TxnType']=="Level2")
	    {
	        $Level2=$Level2+$data['Amount'];
	    }
	    if($data['TxnType']=="Level3")
	    {
	        $Level3=$Level3+$data['Amount'];
	    }
	    if($data['TxnType']=="Level4")
	    {
	        $Level4=$Level4+$data['Amount'];
	    }
	    if($data['TxnType']=="Level5")
	    {
	        $Level5=$Level5+$data['Amount'];
	    }
	}
	
		$totalIncme=$selfIncome+$spoIncome+$Level1+$Level2+$Level3+$Level4+$Level5;
		$gst=$totalIncme*18/100;
		$netIncme=$totalIncme-$gst;
?>
<html>
<head>
	<title>Income Summary</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:100%;
			height:550px;
			display:flex;
			justify-content:center;
		}
		.bank{
			background:#f7f7f7;
			width:350px;
			height:420px;
			border-radius:5px;
			box-shadow:5px 5px 15px 4px #aaaaaa;
			text-align:center;
			margin-top:20px;
		}
		.bank h3{margin:5px 0px;}
		.bank table{
			width:330px;
			margin:10px;
		}
		
		.bank table th{ height:35px; width:55%; text-align:right; padding-right:10px; font-size:15px;}
		.bank table td{ height:35px; text-align:left; padding-left:50px; font-size:15px;}
		.bank table tr{background:#ebf8ee;}
		#sponser{background:#cff9d8; color:; font-size:18px;}
		#commission{background:gray; color:white; font-size:18px;}
		#gst{background:gray; color:white; font-size:18px;}
		#total{background:green; color:white; font-size:18px;}
		@media(max-width:768px)
		{
			.div1{
				background:;
				width:100%;
				height:auto;
				margin-top:10px;
				text-align:center;
				padding:1%;
			}
			.bank{
				width:96%;
				margin:2%;
			}
			.bank table{
				width:95%;
				font-size:14px;
			}
			
		
		}
	</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>Income Summary :-</p></div>
				<div class="msg"><marquee><?php include'msg.php'; ?></marquee></msg>
			</div><hr>
			<div class="data-content">
				<div class="div1">
					<div class='bank'>
						<h3>Income Summary</h3><hr>
						<table border='0'>
							<tr id="sponser"><th>Self Income : </th><td><i class="fa fa-inr"></i> <?php echo $selfIncome; ?></td></tr>
							<tr id="sponser"><th>Sponser Income : </th><td><i class="fa fa-inr"></i> <?php echo $spoIncome; ?></td></tr>
							<tr><th> Level 1 Income : </th><td><i class="fa fa-inr"></i> <?php echo $Level1; ?></td></tr>
							<tr><th> Level 2 Income : </th><td><i class="fa fa-inr"></i> <?php echo $Level2; ?></td></tr>
							<tr><th> Level 3 Income : </th><td><i class="fa fa-inr"></i> <?php echo $Level3; ?></td></tr>
							<tr><th> Level 4 Income : </th><td><i class="fa fa-inr"></i> <?php echo $Level4; ?></td></tr>
							<tr><th> Level 5 Income : </th><td><i class="fa fa-inr"></i> <?php echo $Level5; ?></td></tr>
							<tr style="background:gray; color:white"><th>Total Income : </th><td><i class="fa fa-inr"></i> <?php echo $totalIncme; ?></td></tr>
							<tr style="background:gray; color:white"><th>GST (18%) : </th><td><i class="fa fa-inr"></i> <?php echo $gst; ?></td></tr>
							<tr id="total"><th>Net Income : </th><td><i class="fa fa-inr"></i> <?php echo $netIncme; ?></td></tr>
						</table>
					</div>
				</div>
			</div>
		</div>
	</div>
	<?php
		require'footer.php';
	?>
</body>
</html>