<?php
session_start();
ob_start();
include('includes/config.php');
if($_SESSION['name'] == '')
 {
     header("location:index.php");
 }
    else{
        ?>

<!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">
        <title>Forcecrypto Admin</title>
        <link rel="stylesheet" href="css/bootstrap.min.css" media="screen" >
        <link rel="stylesheet" href="css/font-awesome.min.css" media="screen" >
        <link rel="stylesheet" href="css/animate-css/animate.min.css" media="screen" >
        <link rel="stylesheet" href="css/lobipanel/lobipanel.min.css" media="screen" >
        <link rel="stylesheet" href="css/toastr/toastr.min.css" media="screen" >
        <link rel="stylesheet" href="css/icheck/skins/line/blue.css" >
        <link rel="stylesheet" href="css/icheck/skins/line/red.css" >
        <link rel="stylesheet" href="css/icheck/skins/line/green.css" >
        <link rel="stylesheet" href="css/main.css" media="screen" >
        <script src="js/modernizr/modernizr.min.js"></script>
    </head>
    <body class="top-navbar-fixed">
        <div class="main-wrapper">
              <?php include('includes/topbar.php');?>
            <div class="content-wrapper">
                <div class="content-container">

                    <?php include('includes/leftbar.php');?>  

                    <div class="main-page">
                        <div class="container-fluid">
                            <div class="row page-title-div">
                                <div class="col-sm-6">
                                    <h2 class="title">Dashboard</h2>
                                  
                                </div>
                                <!-- /.col-sm-6 -->
                            </div>
                            <!-- /.row -->
                      
                        </div>
                        <!-- /.container-fluid -->

                        <section class="section">
                            <div class="container-fluid">
                                <div class="row">
                                    <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12 ">
                                        <a class="dashboard-stat " style="background:#4ffb76 !important;">
                                            <span class="number counter">
                                                <?php
 	$sql = "SELECT * from loginuser";
	if ($tbl_user = mysqli_query($com, $sql)) {
	$rowcount = mysqli_num_rows( $tbl_user );
	printf(" %d\n", $rowcount);
}
?>
                                            </span>
                                            <span class="name">Registered Users</span>
                                            <span class="bg-icon"><i style="color:#0258f0;" class="fa fa-users"></i></span>
                                        </a>
                                    </div>
                                    
                                    <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                                        <a class="dashboard-stat " style="background:#ff6675 !important;">

                                            <span class="number counter"><?php
	$sql = "SELECT sum(amount)as trecharge from `walletsummery` where `actiontype`='recharge' and status=0";
	$tbl_rechrage = mysqli_query($com, $sql); 
        
     	 $rowcount12 = mysqli_fetch_assoc( $tbl_rechrage );
     	 
     	  
         	echo $rowcount12['trecharge'];

?></span>
                                            <span class="name">Recharge Request</span>
                                            <span class="bg-icon"><i style="color:#ffbc00;" class="fa fa-ticket"></i></span>
                                        </a>
                                        </div>
                                        
                                    <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                                        <a class="dashboard-stat " style="background:#5ba6f7!important;">
                                       
                                            <span class="number counter">
                                             <?php
      	   $sql = "SELECT sum(amount)as twithdraw from withdrawal where status='0'";
        	$tbl_withdrawal = mysqli_query($com, $sql); 
        
     	 $rowcount = mysqli_fetch_assoc($tbl_withdrawal);
     	 
     	  
         echo $rowcount['twithdraw'];

?>
                                            
                                              </span>
                                            <span class="name">Withdrawal Request</span>
                                            <span class="bg-icon"><i style="color:#f53b31;" class="fa fa-bank"></i></span>
                                        </a>
                                    </div>
                                    
                                    <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                                        <a class="dashboard-stat " style="background:#f9cd4a !important;">
                                           <span class="number counter"><?php
	$sql = "SELECT * from `walletsummery` where `actiontype`='recharge' and `status`='1'";
	$tbl_rechrage12 = mysqli_query($com, $sql); 
        	$bb2 = 0;
     	 while( $rowcount122 = mysqli_fetch_array( $tbl_rechrage12 ))
     	 {
     	     $bb2 = $bb2 + $rowcount122['amount'];
     	 }
     	  
         	printf(" %d\n", $bb2);

?></span>
                                            <span class="name">Total Recharge</span>
                                            <span class="bg-icon"><i style="color:#2bce38;" class="fa fa-file-text"></i></span>
                                        </a>
                                    </div>
                            </div>
                            
                            
                     <br><br>    
                            
                                                <div class="row">
                                    <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                                        <a class="dashboard-stat " style="background:#5ba6f7!important;">
                                            <span class="number counter">
                                                <?php
      	   $sql = "SELECT * from `withdrawal` where `status`='1'";
        	$tbl_withdrawal123 = mysqli_query($com, $sql); 
        	$aa123 = 0;
     	 while( $rowcount123 = mysqli_fetch_array( $tbl_withdrawal123 ))
     	 {
     	     $aa123 = $aa123 + $rowcount123['amount'];
     	 }
     	  
         	printf(" %d\n", $aa123);

?>
                                            </span>
                                            <span class="name">Total Withdraw</span>
                                            <span class="bg-icon"><i style="color:#239606;" class="fa fa-money" ></i></span>
                                        </a>
                                    </div>
                                    
                                    <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                                        <a class="dashboard-stat " style="background:#f9cd4a !important;">

                                            <span class="number counter"><?php
      	   $sqlreward = "SELECT * from `obtain`";
        	$queryreward = mysqli_query($com, $sqlreward); 
        	$cc = 0;
     	 while( $rowcountreward = mysqli_fetch_array( $queryreward ))
     	 {
     	     $cc = $cc + $rowcountreward['amount'];
     	 }
     	  
         	printf(" %d\n", $cc);

?></span>
                                            <span class="name">Total Obtain</span>
                                            <span class="bg-icon"><i style="color:#3e27ff;" class="fa fa-trophy"></i></span>
                                        </a>
                                        </div>
                                        
                                    <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                                        <a class="dashboard-stat" style="background:#4ffb76 !important;">
                                       
                                            <span class="number counter"><?php
      	   $sqlbonus = "SELECT * from `bonus`";
        	$querybonus = mysqli_query($com, $sqlbonus); 
        	$cccc = 0;
     	 while( $rowcountbunus = mysqli_fetch_array( $querybonus ))
     	 {
     	     $cccc = $cccc + $rowcountbunus['amount'];
     	 }
     	  
         	printf(" %d\n", $cccc);

?></span>
                                            <span class="name">Total Promotion</span>
                                            <span class="bg-icon"><i style="color:#083047;" class="fa fa-bullhorn" ></i></span>
                                        </a>
                                    </div>
                                    
                                    <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                                        <a class="dashboard-stat " style="background:#5ba6f7!important;">
                                           <span class="number counter"><?php
       	$amount=0;              
    $sql_user = mysqli_query($com,"select * from loginuser");
    while($query_data = mysqli_fetch_array($sql_user)){
    $user_id = $query_data['id'];
	$sql = mysqli_query($com,"select * from wallet where userid ='$user_id'");
    $rowcount = mysqli_fetch_array($sql);

	$amount=$amount+$rowcount['amount'];
	
    }
	printf(" %d\n",$amount);

?></span>
                                            <span class="name">Wallet Balance</span>
                                            <span class="bg-icon"><i style="color:#ffc2b5;" class="fa fa-balance-scale" ></i></span>
                                        </a>
                                    </div>
                            </div>   
                            </div>
                            <!-- /.container-fluid -->
                        </section>
                        <!-- /.section -->

                    </div>
                    <!-- /.main-page -->

                    
                </div>
                <!-- /.content-container -->
            </div>
            <!-- /.content-wrapper -->

        </div>
        <!-- /.main-wrapper -->

        <!-- ========== COMMON JS FILES ========== -->
        <script src="js/jquery/jquery-2.2.4.min.js"></script>
        <script src="js/jquery-ui/jquery-ui.min.js"></script>
        <script src="js/bootstrap/bootstrap.min.js"></script>
        <script src="js/pace/pace.min.js"></script>
        <script src="js/lobipanel/lobipanel.min.js"></script>
        <script src="js/iscroll/iscroll.js"></script>

        <!-- ========== PAGE JS FILES ========== -->
        <script src="js/prism/prism.js"></script>
        <script src="js/waypoint/waypoints.min.js"></script>
        <script src="js/counterUp/jquery.counterup.min.js"></script>
        <script src="js/amcharts/amcharts.js"></script>
        <script src="js/amcharts/serial.js"></script>
        <script src="js/amcharts/plugins/export/export.min.js"></script>
        <link rel="stylesheet" href="js/amcharts/plugins/export/export.css" type="text/css" media="all" />
        <script src="js/amcharts/themes/light.js"></script>
        <script src="js/toastr/toastr.min.js"></script>
        <script src="js/icheck/icheck.min.js"></script>

        <!-- ========== THEME JS ========== -->
        <script src="js/main.js"></script>
        <script src="js/production-chart.js"></script>
        <script src="js/traffic-chart.js"></script>
        <script src="js/task-list.js"></script>
        <script>
            $(function(){

                // Counter for dashboard stats
                $('.counter').counterUp({
                    delay: 10,
                    time: 1000
                });

                // Welcome notification
                toastr.options = {
                  "closeButton": true,
                  "debug": false,
                  "newestOnTop": false,
                  "progressBar": false,
                  "positionClass": "toast-top-right",
                  "preventDuplicates": false,
                  "onclick": null,
                  "showDuration": "300",
                  "hideDuration": "1000",
                  "timeOut": "5000",
                  "extendedTimeOut": "1000",
                  "showEasing": "swing",
                  "hideEasing": "linear",
                  "showMethod": "fadeIn",
                  "hideMethod": "fadeOut"
                }
                toastr["success"]( "Welcome to Admin!");

            });
        </script>
    </body>
</html>
<?php } ?>
