<?php
include('extension/connect.php');
include('extension/check-login.php');
include('extension/function.php');
$admin_data = data_records($con);
$fast_loading = fast_loading($con);
$fastpro_loading = fastpro_loading($con);
$userid = $_SESSION['userid'];
$search = $userid;
$active = 'dashboard';
?>

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="keywords" content="<?php include('extension/title.php'); ?>" />
  <meta name="description" content="<?php include('extension/title.php'); ?> - VPN Panel System" />
  <meta name="author" content="<?php include('extension/title.php'); ?>" />
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <title><?php include('extension/title.php'); ?> | Dashboard</title>

  <!-- Favicon -->
  <link rel="shortcut icon" href="<?php include('extension/logo.php'); ?>" />
  
  <!-- Google Font: Source Sans Pro -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="/assets/plugins/fontawesome-free/css/all.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
  <!-- Tempusdominus Bootstrap 4 -->
  <link rel="stylesheet" href="/assets/plugins/tempusdominus-bootstrap-4/css/tempusdominus-bootstrap-4.min.css">
  <!-- iCheck -->
  <link rel="stylesheet" href="/assets/plugins/icheck-bootstrap/icheck-bootstrap.min.css">
  <!-- JQVMap -->
  <link rel="stylesheet" href="/assets/plugins/jqvmap/jqvmap.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="/assets/dist/css/adminlte.min.css">
  <!-- overlayScrollbars -->
  <link rel="stylesheet" href="/assets/plugins/overlayScrollbars/css/OverlayScrollbars.min.css">
  <!-- Daterange picker -->
  <link rel="stylesheet" href="/assets/plugins/daterangepicker/daterangepicker.css">
  <!-- summernote -->
  <link rel="stylesheet" href="/assets/plugins/summernote/summernote-bs4.min.css">
  <!-- modification -->
  <style>
        .dropdown-item.active, .dropdown-item:active {
            color: color: <?php include('extension/theme_text.php'); ?> !important;
            text-decoration: none;
            background-color: <?php include('extension/theme.php'); ?> !important;
        }
  </style>
</head>
<body class="hold-transition sidebar-mini layout-fixed">
<?php
    $query = mysqli_query($con,"select * from users where user_id='$userid'");
    $result = mysqli_fetch_array($query);
    
    //Total Users
    if($result['user_rank']=='superadmin'){
        $que = mysqli_query($con,"select user_name from users where user_rank='normal' || user_rank='export'");
    }else{
        $que = mysqli_query($con,"select user_name from users where (user_rank='normal' || user_rank='export') and user_upline='$userid'");
    }
    $client = mysqli_num_rows($que);
    
    if($client == 0){
        $desc = 'No Users';
    }else{
        $desc = 'View User(s)';
    }
    
    //Users registered in 7days
    if($result['user_rank']=='superadmin'){
        $que7user = mysqli_query($con,"select user_name from users where (user_rank='normal' || user_rank='export') and date(user_created)>=(DATE(NOW()) - INTERVAL 7 DAY)");
    }else{
        $que7user = mysqli_query($con,"select user_name from users where (user_rank='normal' || user_rank='export') and date(user_created)>=(DATE(NOW()) - INTERVAL 7 DAY) and user_upline='$userid'");
    }
    $client7user = mysqli_num_rows($que7user);
    
    if($client7user == 0){
        $desc7user = 'No users';
    }else{
        $desc7user = 'View User(s)';
    }
    
    //Total Bulk Users
    if($result['user_rank']=='superadmin'){
        $queexport = mysqli_query($con,"select user_name from users where user_rank='export'");
    }else{
        $queexport = mysqli_query($con,"select user_name from users where user_rank='export' and user_upline='$userid'");
    }
    $clientexport = mysqli_num_rows($queexport);
    
    if($clientexport == 0){
        $descexport = 'No Bulk';
    }else{
        $descexport = 'View Bulk(s)';
    }
    
    //Bulk users registered in 7days
    if($result['user_rank']=='superadmin'){
        $que7export = mysqli_query($con,"select user_name from users where user_rank='export' and date(user_created)>=(DATE(NOW()) - INTERVAL 7 DAY)");
    }else{
        $que7export = mysqli_query($con,"select user_name from users where user_rank='export' and date(user_created)>=(DATE(NOW()) - INTERVAL 7 DAY) and user_upline='$userid'");
    }
    $client7export = mysqli_num_rows($que7export);
    
    if($client7export == 0){
        $desc7export = 'No Bulk';
    }else{
        $desc7export = 'View Bulk(s)';
    }
    
    //Total Resellers
    if($result['user_rank']=='superadmin'){
        $queres = mysqli_query($con,"select user_name from users where user_rank='reseller'");
    }else{
        $queres = mysqli_query($con,"select user_name from users where user_rank='reseller' and user_upline='$userid'");
    }
    $clientres = mysqli_num_rows($queres);
    
    if($clientres == 0){
        $descres = 'No Resellers';
    }else{
        $descres = 'View Reseller(s)';
    }
    
    //Resellers registered in 7days
    if($result['user_rank']=='superadmin'){
        $que7res = mysqli_query($con,"select user_name from users where user_rank='reseller' and date(user_created)>=(DATE(NOW()) - INTERVAL 7 DAY)");
    }else{
        $que7res = mysqli_query($con,"select user_name from users where user_rank='reseller' and date(user_created)>=(DATE(NOW()) - INTERVAL 7 DAY) and user_upline='$userid'");
    }
    $client7res = mysqli_num_rows($que7res);
    
    if($client7res == 0){
        $desc7res = 'No Resellers';
    }else{
        $desc7res = 'View Reseller(s)';
    }
    
    //Credits
    if($result['user_rank'] == 'superadmin'){
        $credits = '&#8734;';
        $cred_details = 'Unlimited Credits';
    }else{
        $credits = $result['user_credits'];
        $cred_details = 'Available Credit(s)';
    }
    
    if($result['user_credits'] > 0){
        $icon = 'text-success';
    }else{
        $icon = 'text-danger';
    }
    
    //Suspend users
    if($result['user_rank']=='superadmin'){
        $que3 = mysqli_query($con,"select * from users where is_active='1'");
    }else{
        $que3 = mysqli_query($con,"select * from users where is_active='1' and user_upline='$userid'");
    }
    $onl = mysqli_num_rows($que3);
    
    if($onl == 0){
        $desconl = 'No Suspend';
    }else{
        $desconl = 'View Suspend user(s)';
    }
    
?>
<div class="wrapper">

  <!-- Preloader -->
  <div class="preloader flex-column justify-content-center align-items-center">
    <img class="animation__shake" src="<?php include('extension/logo.php'); ?>" alt="Preloader" height="60" width="60">
  </div>

  <?php include('extension/topnav.php'); ?>
  
  <?php include('extension/sidenav.php'); ?>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 class="m-0">Dashboard</h1>
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="#" style="color: <?php include('extension/theme.php'); ?>;">Home</a></li>
              <li class="breadcrumb-item active">Dashboard</li>
            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->

    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <!-- Small boxes (Stat box) -->
        <div class="row">
          
          <div class="col-lg-6 col-6">
            <!-- small box -->
            <div class="small-box" style="color: <?php include('extension/theme_text.php'); ?>; background-color: <?php include('extension/theme.php'); ?>;">
              <div class="inner">
                <h3><?php echo $onl; ?></h3>

                <p>Suspend users</p>
              </div>
              <div class="icon">
                <i class="fas fa-user-clock"></i>
              </div>
              <a href="dashboard" class="small-box-footer"><?php echo $desconl; ?> <i class="fas fa-arrow-circle-right"></i></a>
            </div>
          </div>
          <!-- ./col -->
          
          <div class="col-lg-6 col-6">
            <!-- small box -->
            <div class="small-box" style="color: <?php include('extension/theme_text.php'); ?>; background-color: <?php include('extension/theme.php'); ?>;">
              <div class="inner">
                <h3><?php echo $credits; ?></h3>

                <p>Credits</p>
              </div>
              <div class="icon">
                <i class="fas fa-coins"></i>
              </div>
              <a href="#" class="small-box-footer"><?php echo $cred_details; ?> <i class="fas fa-arrow-circle-right"></i></a>
            </div>
          </div>
          <!-- ./col -->
          
          <div class="col-lg-3 col-6">
            <!-- small box -->
            <div class="small-box" style="color: <?php include('extension/theme_text.php'); ?>; background-color: <?php include('extension/theme.php'); ?>;">
              <div class="inner">
                <h3><?php echo $client; ?></h3>

                <p>Total users</p>
              </div>
              <div class="icon">
                <i class="fas fa-user-plus"></i>
              </div>
              <a href="view_user" class="small-box-footer"><?php echo $desc; ?> <i class="fas fa-arrow-circle-right"></i></a>
            </div>
          </div>
          <!-- ./col -->
          
          <div class="col-lg-3 col-6">
            <!-- small box -->
            <div class="small-box" style="color: <?php include('extension/theme_text.php'); ?>; background-color: <?php include('extension/theme.php'); ?>;">
              <div class="inner">
                <h3><?php echo $client7user; ?></h3>

                <p>Users last 7 days</p>
              </div>
              <div class="icon">
                <i class="fas fa-user-plus"></i>
              </div>
              <a href="view_user7d" class="small-box-footer"><?php echo $desc7user; ?> <i class="fas fa-arrow-circle-right"></i></a>
            </div>
          </div>
          <!-- ./col -->
          
          <!--div class="col-lg-3 col-6">
            <div class="small-box" style="color: <?php include('extension/theme_text.php'); ?>; background-color: <?php include('extension/theme.php'); ?>;">
              <div class="inner">
                <h3><?php echo $clientexport; ?></h3>

                <p>Total bulk</p>
              </div>
              <div class="icon">
                <i class="fas fa-users"></i>
              </div>
              <a href="view_bulk" class="small-box-footer"><?php echo $descexport; ?> <i class="fas fa-arrow-circle-right"></i></a>
            </div>
          </div-->
          <!-- ./col -->
          
          <!--div class="col-lg-3 col-6">
            <div class="small-box" style="color: <?php include('extension/theme_text.php'); ?>; background-color: <?php include('extension/theme.php'); ?>;">
              <div class="inner">
                <h3><?php echo $client7export; ?></h3>

                <p>Bulk last 7 days</p>
              </div>
              <div class="icon">
                <i class="fas fa-users"></i>
              </div>
              <a href="view_bulk7d" class="small-box-footer"><?php echo $desc7export; ?> <i class="fas fa-arrow-circle-right"></i></a>
            </div>
          </div-->
          <!-- ./col -->
          
          <div class="col-lg-3 col-6">
            <!-- small box -->
            <div class="small-box" style="color: <?php include('extension/theme_text.php'); ?>; background-color: <?php include('extension/theme.php'); ?>;">
              <div class="inner">
                <h3><?php echo $clientres; ?></h3>

                <p>Total Resellers</p>
              </div>
              <div class="icon">
                <i class="fas fa-user-shield"></i>
              </div>
              <a href="view_reseller" class="small-box-footer"><?php echo $descres; ?> <i class="fas fa-arrow-circle-right"></i></a>
            </div>
          </div>
          <!-- ./col -->
          
          <div class="col-lg-3 col-6">
            <!-- small box -->
            <div class="small-box" style="color: <?php include('extension/theme_text.php'); ?>; background-color: <?php include('extension/theme.php'); ?>;">
              <div class="inner">
                <h3><?php echo $client7res; ?></h3>

                <p>Resellers last 7 days</p>
              </div>
              <div class="icon">
                <i class="fas fa-user-shield"></i>
              </div>
              <a href="view_reseller7d" class="small-box-footer"><?php echo $desc7res; ?> <i class="fas fa-arrow-circle-right"></i></a>
            </div>
          </div>
          <!-- ./col -->
          
        </div>
        <!-- /.row -->
        
      </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
  <?php include('extension/footer.php'); ?>

  <!-- Control Sidebar -->
  <aside class="control-sidebar control-sidebar-dark">
    <!-- Control sidebar content goes here -->
  </aside>
  <!-- /.control-sidebar -->
</div>
<!-- ./wrapper -->

<!-- jQuery -->
<script src="/assets/plugins/jquery/jquery.min.js"></script>
<!-- jQuery UI 1.11.4 -->
<script src="/assets/plugins/jquery-ui/jquery-ui.min.js"></script>
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<script>
  $.widget.bridge('uibutton', $.ui.button)
</script>
<!-- Bootstrap 4 -->
<script src="/assets/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- ChartJS -->
<script src="/assets/plugins/chart.js/Chart.min.js"></script>
<!-- Sparkline -->
<script src="/assets/plugins/sparklines/sparkline.js"></script>
<!-- JQVMap -->
<script src="/assets/plugins/jqvmap/jquery.vmap.min.js"></script>
<script src="/assets/plugins/jqvmap/maps/jquery.vmap.usa.js"></script>
<!-- jQuery Knob Chart -->
<script src="/assets/plugins/jquery-knob/jquery.knob.min.js"></script>
<!-- daterangepicker -->
<script src="/assets/plugins/moment/moment.min.js"></script>
<script src="/assets/plugins/daterangepicker/daterangepicker.js"></script>
<!-- Tempusdominus Bootstrap 4 -->
<script src="/assets/plugins/tempusdominus-bootstrap-4/js/tempusdominus-bootstrap-4.min.js"></script>
<!-- Summernote -->
<script src="/assets/plugins/summernote/summernote-bs4.min.js"></script>
<!-- overlayScrollbars -->
<script src="/assets/plugins/overlayScrollbars/js/jquery.overlayScrollbars.min.js"></script>
<!-- AdminLTE App -->
<script src="/assets/dist/js/adminlte.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="/assets/dist/js/demo.js"></script>
<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<script src="/assets/dist/js/pages/dashboard.js"></script>
</body>
</html>
