<?php
	session_start();
	if($_SESSION['rid'])
	{
		$userid=$_SESSION['rid'];
		include'connection.php';
		include'time.php';
	}
	else
	{
		header('location:../login.php');
	}
	
	$TotalPurchase=0;
	$quPurchase="select * from paymentreq where Userid='$userid' and Date='$date' and Status='APPROVED'";
	$rePurchase=mysqli_query($con,$quPurchase);
	$NoPurchase=mysqli_num_rows($rePurchase);
	while($dataPurchase=mysqli_fetch_array($rePurchase))
	{
	    $TotalPurchase=$TotalPurchase+$dataPurchase['Amount'];
	}
	
	$TotalPendingTxn=0;
	$quTxnPending="select * from recharge where Userid='$userid' and Rechargedate='$date' and Status='PENDING'";
	$reTxnPending=mysqli_query($con,$quTxnPending);
	$NoPending=mysqli_num_rows($reTxnPending);
	while($dataTxnPending=mysqli_fetch_array($reTxnPending))
	{
	    $TotalPendingTxn=$TotalPendingTxn+$dataTxnPending['Amount'];
	}
	
	$TotalSuccessTxn=0;
	$quTxnSuccess="select * from recharge where Userid='$userid' and Rechargedate='$date' and Status='SUCCESS'";
	$reTxnSuccess=mysqli_query($con,$quTxnSuccess);
	$NoSuccess=mysqli_num_rows($reTxnSuccess);
	while($dataTxnSuccess=mysqli_fetch_array($reTxnSuccess))
	{
	    $TotalSuccessTxn=$TotalSuccessTxn+$dataTxnSuccess['Amount'];
	}
	
	$TotalFailedTxn=0;
	$quTxnFailed="select * from recharge where Userid='$userid' and Rechargedate='$date' and Status='FAILED'";
	$reTxnFailed=mysqli_query($con,$quTxnFailed);
	$NoFailed=mysqli_num_rows($reTxnFailed);
	while($dataTxnFailed=mysqli_fetch_array($reTxnFailed))
	{
	    $TotalFailedTxn=$TotalFailedTxn+$dataTxnFailed['Amount'];
	}
	
	
?>
<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Dashboard</title>

    <!-- Bootstrap Core CSS -->
    <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- MetisMenu CSS -->
    <link href="vendor/metisMenu/metisMenu.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="dist/css/sb-admin-2.css" rel="stylesheet">
    <link href="dist/css/my-css-code.css" rel="stylesheet">

    <!-- Morris Charts CSS -->
    <link href="vendor/morrisjs/morris.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        .page-heade{background:; width:auto; float:left;}
        .dmorq{float:right; width:75%; margin:15px 30px 0px 0px; font-size:18px;}
        .huge{font-size:20px;}
        #heading{background:#636367; color:white; padding:5px;}
        #rechreport{}
        #rechreport table{text-align:center;}
        #rechreport table th{background:#a2a2b9; color:white; padding:2px; text-align:center;}
        #rechreport table td{text-align:center; line-height:100%; }
        #rechreport table tr:nth-child(odd){background:#f7f8fe;}
	    #rechreport table tr:nth-child(even){background:white; }
	    
	    #green{background:green; color:white; font-size:15px; border-radius:4px; padding:2px; margin:3px;}
        #red{background:red; color:white; font-size:15px; border-radius:4px; padding:2px; margin:3px;}
        #blue{background:blue; color:white; font-size:15px; border-radius:4px; padding:2px; margin:3px;}
    </style>
</head>

<body onload="GetRechReport(), GetBal()">

    <div id="wrapper">
        <!-- Navigation -->
		<?php
			include'navigation.php';
		?>
        <!-- Navigation -->
        <div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <h3 class="page-heade">Today's Activity :</h3>
                    <div class="dmorq">
                		<marquee scrollamount="4" onmouseover="stop()" onmouseout="start()">
                    		<?php
                    		    $dateformat = Date("d/M/Y");
			
                    			$AcOp="select * from operator where Active='1'";
                    			$reAcOp=mysqli_query($con,$AcOp);
                    			$CountRowsAcOp=mysqli_num_rows($reAcOp);
                    			while($dataAcOp=mysqli_fetch_array($reAcOp))
                    			{
                    			    echo $dataAcOp['Operator']." Down, ";
                    			}
                    			if($CountRowsAcOp==0)
                    			{
                    			    echo "ALL OPERATORS ARE WORKING FINE, ";
                    			}
			
                    		    $querymsg="select * from messege where Users='ALL' or Users='RET' order by Id desc";
                    			$resultmsg=mysqli_query($con,$querymsg);
                    			while($datamsg=mysqli_fetch_array($resultmsg))
                    			{
                    			    echo $datamsg['Messege']." ";
                    			}
			
                    		?>
            		    </marquee>
                	</div>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            <div class="row">
                <div class="col-lg-3 col-md-6">
                    <div class="panel panel-yellow">
                        <div class="panel-heading">
                            <div class="row">
                                <div class="col-xs-3">
                                    <i class="fa fa-shopping-cart fa-5x"></i>
                                </div>
                                <div class="col-xs-9 text-right">
                                    <div class="huge">&#8377 <?php echo $TotalPurchase; ?></div>
                                    <div>PURCHASE</div>
                                    <div>No. <?php echo $NoPurchase ;?></div>
                                </div>
                            </div>
                        </div>
                        <a href="#">
                            <div class="panel-footer">
                                <span class="pull-left">View List</span>
                                <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
                                <div class="clearfix"></div>
                            </div>
                        </a>
                    </div>
                </div>
                <div class="col-lg-3 col-md-6">
                    <div class="panel panel-primary">
                        <div class="panel-heading">
                            <div class="row">
                                <div class="col-xs-3">
                                    <i class="fa fa-sitemap fa-5x"></i>
                                </div>
                                <div class="col-xs-9 text-right">
                                    <div class="huge">&#8377 <?php echo $TotalPendingTxn; ?></div>
                                    <div>PENDING</div>
                                    <div>No. <?php echo $NoPending ;?></div>
                                </div>
                            </div>
                        </div>
                        <a href="#">
                            <div class="panel-footer">
                                <span class="pull-left">View List</span>
                                <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
                                <div class="clearfix"></div>
                            </div>
                        </a>
                    </div>
                </div>
                <div class="col-lg-3 col-md-6">
                    <div class="panel panel-green">
                        <div class="panel-heading">
                            <div class="row">
                                <div class="col-xs-3">
                                    <i class="fa fa-tasks fa-5x"></i>
                                </div>
                                <div class="col-xs-9 text-right">
                                    <div class="huge">&#8377 <?php echo $TotalSuccessTxn; ?></div>
                                    <div>SUCCESS</div>
                                    <div>No. <?php echo $NoSuccess ;?></div>
                                </div>
                            </div>
                        </div>
                        <a href="#">
                            <div class="panel-footer">
                                <span class="pull-left">View List</span>
                                <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
                                <div class="clearfix"></div>
                            </div>
                        </a>
                    </div>
                </div>
                <div class="col-lg-3 col-md-6">
                    <div class="panel panel-red">
                        <div class="panel-heading">
                            <div class="row">
                                <div class="col-xs-3">
                                    <i class="fa fa-support fa-5x"></i>
                                </div>
                                <div class="col-xs-9 text-right">
                                    <div class="huge">&#8377 <?php echo $TotalFailedTxn; ?></div>
                                    <div>FAILED</div>
                                    <div>No. <?php echo $NoFailed ;?></div>
                                </div>
                            </div>
                        </div>
                        <a href="#">
                            <div class="panel-footer">
                                <span class="pull-left">View Details</span>
                                <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
                                <div class="clearfix"></div>
                            </div>
                        </a>
                    </div>
                </div>
            </div>
            <!-- /.row -->
            
        <!-- /#page-wrapper -->
        
    
	<input type="text" id="uid" value="<?php echo $userid; ?>" style="display:none;">
		<script>
	    function GetRechReport()
	    {
	        
	        var usrid = document.getElementById("uid").value;
	        
	        var xmlhttp = new XMLHttpRequest();
	        xmlhttp.open("GET","getrechreport.php?uid="+usrid,false);
	        xmlhttp.send(null);
	        
	        document.getElementById("rechreport").innerHTML = xmlhttp.responseText;
	        
	        setTimeout("GetRechReport()", 10000);
	    }
	</script>
	<div id="heading">Recent Transaction (LIVE)</div>
	<div id="rechreport">
	    
	</div>

    </div>
    <!-- /#wrapper -->

    <!-- jQuery -->
    <script src="vendor/jquery/jquery.min.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="vendor/bootstrap/js/bootstrap.min.js"></script>

    <!-- Metis Menu Plugin JavaScript -->
    <script src="vendor/metisMenu/metisMenu.min.js"></script>

    <!-- Morris Charts JavaScript -->
    <script src="vendor/raphael/raphael.min.js"></script>
    <script src="vendor/morrisjs/morris.min.js"></script>
    <script src="data/morris-data.js"></script>

    <!-- Custom Theme JavaScript -->
    <script src="dist/js/sb-admin-2.js"></script>

</body>

</html>
