<?php include "connection.php"; ?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <!--<meta http-equiv="refresh" content="180" >-->
  <title>Zeesoft | Dashboard</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="plugins/font-awesome/css/font-awesome.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="dist/css/adminlte.min.css">
  <!-- iCheck -->
  <link rel="stylesheet" href="plugins/iCheck/flat/blue.css">
  <!-- Morris chart -->
  <link rel="stylesheet" href="plugins/morris/morris.css">
  <!-- jvectormap -->
  <link rel="stylesheet" href="plugins/jvectormap/jquery-jvectormap-1.2.2.css">
  <!-- Date Picker -->
  <link rel="stylesheet" href="plugins/datepicker/datepicker3.css">
  <!-- Daterange picker -->
  <link rel="stylesheet" href="plugins/daterangepicker/daterangepicker-bs3.css">
  <!-- bootstrap wysihtml5 - text editor -->
  <link rel="stylesheet" href="plugins/bootstrap-wysihtml5/bootstrap-wysihtml5.min.css">
  <!-- Google Font: Source Sans Pro -->
  <!--    <link rel="stylesheet" href="plugins/datatables/dataTables.bootstrap4.min.css"> -->

<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css" />

 <link rel="stylesheet" href="plugins/bootstrap-wysihtml5/bootstrap-wysihtml5.min.css">
  


<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/dataTables.bootstrap.min.css">
  <link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
  <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
  
  <script src="//cdn.jsdelivr.net/npm/alertifyjs@1.11.4/build/alertify.min.js"></script>

<!-- CSS -->
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/alertifyjs@1.11.4/build/css/alertify.min.css"/>
<!-- Default theme -->
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/alertifyjs@1.11.4/build/css/themes/default.min.css"/>

  <script>
 var ajax_call = function() {
     var check = "true";
   $.post("response.php",{check:check},function(data){
     
              if(data != 'working'){
                 alertify.set('notifier','position', 'top-right');
                alertify.set('notifier','delay', 40);
                 alertify.success('You have New lead from: '+data);
                
              }
            })
};

var interval = 1000 * 60 * 1; // where X is your every X minutes

setInterval(ajax_call, interval);
      
  </script>
  
  
  
</head>
<body class="hold-transition sidebar-mini">
<div class="wrapper">

  <!-- Navbar -->
  <nav class="main-header navbar navbar-expand bg-white navbar-light border-bottom">
    <!-- Left navbar links -->
    <ul class="navbar-nav">
      <li class="nav-item">
        <a class="nav-link" data-widget="pushmenu" href="#"><i class="fa fa-bars"></i></a>
      </li>
      <li class="nav-item d-none d-sm-inline-block">
        <a id="Graph" class="nav-link">Home</a>
      </li>
     
    </ul>
  <form class="form-inline ml-3">
      <div class="input-group input-group-sm">
       
        <input class="form-control form-control-navbar" id="tags" type="search" placeholder="Search" aria-label="Search">
        <div class="input-group-append">
          <a id="search" class="btn btn-default">
            <i class="fa fa-search"></i>
          </a>
        </div>
      </div>
    </form>
    <!-- Right navbar links -->
    <ul class="navbar-nav ml-auto">
      <!-- Messages Dropdown Menu -->
       
      <!-- Messages Dropdown Menu -->
      <li class="nav-item dropdown notidrop stop">
        <a class="nav-link" data-toggle="dropdown" href="#" aria-expanded="false">
          <i class="fa fa-ban" title="Decline"></i>
           <?php
        $query  = "SELECT count(*) as total from notification where veiw = 0 and message = 'DECLINE'";
        $result = mysqli_query($con,$query);
        $row = mysqli_fetch_assoc($result);
        $num = mysqli_num_rows($result);
        if($row['total'] > 0){
        ?>
          <span class="badge badge-danger navbar-badge"><?php echo $row['total']?></span>
          <?php
          }
          ?>
        </a>
        <div class="dropdown-menu dropdown-menu-lg dropdown-menu-right">
        
        <?php
        $query  = "SELECT new_invoice.*,notification.message,notification.create_at,notification.id as notiid FROM notification
                    JOIN new_invoice on new_invoice.id = notification.user_id
                    where notification.veiw = 0
                    and notification.message = 'DECLINE' order by notification.id desc limit 0,10";
        $result = mysqli_query($con,$query);
        while($row = mysqli_fetch_assoc($result)){
            $create = $row['create_at'];
            $datetime = date("Y-m-d H:i:s");
            $datetime1 = new DateTime($create);
            $datetime2 = new DateTime();
            $interval = $datetime1->diff($datetime2);
        ?>
        
          <a  class="dropdown-item notificationView" data-value="<?php echo $row['notiid']?>">
            <!-- Message Start -->
            <div class="media">
              <img src="dist/img/user8-128x128.jpg" alt="User Avatar" class="img-size-50 img-circle mr-3">
              <div class="media-body">
                <h3 class="dropdown-item-title">
                  <?php echo $row['first']." ".$row['last_name']?>
                  <span class="float-right text-sm text-muted"><i class="fa fa-star"></i></span>
                </h3>
                <p class="text-sm">New Sell <?php echo $row['message']?></p>
                <p class="text-sm text-muted"><i class="fa fa-clock-o mr-1"></i><?php echo $interval->format('%a days, %H hours, %I min');?>  </p>
              </div>
            </div>
            <!-- Message End -->
          </a>
          <div class="dropdown-divider"></div>
          
         <?php 
            }
         ?>
          <a href="#" class="dropdown-item dropdown-footer seeall">See All Messages</a>
        </div>
      </li>
      <li class="nav-item dropdown notidrop2 stop">
        <a class="nav-link" data-toggle="dropdown" href="#" aria-expanded="false">
          <i class="fa fa-comments-o" title="pending"></i>
           <?php
       $query  = "SELECT count(*) as total from notification where veiw = 0 and message = 'Pending'";
        $result = mysqli_query($con,$query);
        $row = mysqli_fetch_assoc($result);
        $num = mysqli_num_rows($result);
        if($row['total'] > 0){
        ?>
          <span class="badge badge-danger navbar-badge"><?php echo $row['total']?></span>
          <?php
          }
          ?>
        </a>
        <div class="dropdown-menu dropdown-menu-lg dropdown-menu-right">
        
        <?php
        $query  = "SELECT new_invoice.*,notification.message,notification.create_at,notification.id as notiid FROM notification
                    JOIN new_invoice on new_invoice.id = notification.user_id
                    where notification.veiw = 0
                    and notification.message = 'Pending'  order by notification.id desc limit 0,10";
        $result = mysqli_query($con,$query);
        while($row = mysqli_fetch_assoc($result)){
            $create = $row['create_at'];
            $datetime = date("Y-m-d H:i:s");
            $datetime1 = new DateTime($create);
            $datetime2 = new DateTime();
            $interval = $datetime1->diff($datetime2);
        ?>
        
          <a  class="dropdown-item notificationView" data-value="<?php echo $row['notiid']?>">
            <!-- Message Start -->
            <div class="media">
              <img src="dist/img/user8-128x128.jpg" alt="User Avatar" class="img-size-50 img-circle mr-3">
              <div class="media-body">
                <h3 class="dropdown-item-title">
                  <?php echo $row['first']." ".$row['last_name']?>
                  <span class="float-right text-sm text-muted"><i class="fa fa-star"></i></span>
                </h3>
                <p class="text-sm">New Sell <?php echo $row['message']?></p>
                <p class="text-sm text-muted"><i class="fa fa-clock-o mr-1"></i><?php echo $interval->format('%a days, %H hours, %I min');?> hour Ago </p>
              </div>
            </div>
            <!-- Message End -->
          </a>
          <div class="dropdown-divider"></div>
          
         <?php 
            }
         ?>
          <a href="#" class="dropdown-item dropdown-footer seeall">See All Messages</a>
        </div>
      </li>
      <li class="nav-item dropdown notidrop3 stop">
        <a class="nav-link" data-toggle="dropdown" href="#" aria-expanded="false">
          <i class="fa fa-bell-o" title="Success"></i>
           <?php
        $query  = "SELECT count(*) as total from notification where veiw = 0 and message = 'Success'";
        $result = mysqli_query($con,$query);
        $row = mysqli_fetch_assoc($result);
        $num = mysqli_num_rows($result);
        if($row['total'] > 0){
        ?>
          <span class="badge badge-danger navbar-badge"><?php echo $row['total']?></span>
          <?php
          }
          ?>
        </a>
        <div class="dropdown-menu dropdown-menu-lg dropdown-menu-right">
        
        <?php
        $query  = "SELECT new_invoice.*,notification.message,notification.create_at,notification.id as notiid FROM notification
                    JOIN new_invoice on new_invoice.id = notification.user_id
                    where notification.veiw = 0
                    and notification.message = 'Success'
                    order by notification.id desc limit 0,10";
        $result = mysqli_query($con,$query);
        while($row = mysqli_fetch_assoc($result)){
            $create = $row['create_at'];
            $datetime = date("Y-m-d H:i:s");
            $datetime1 = new DateTime($create);
            $datetime2 = new DateTime();
            $interval = $datetime1->diff($datetime2);
        ?>
        
          <a  class="dropdown-item notificationView" data-value="<?php echo $row['notiid']?>">
            <!-- Message Start -->
            <div class="media">
              <img src="dist/img/user8-128x128.jpg" alt="User Avatar" class="img-size-50 img-circle mr-3">
              <div class="media-body">
                <h3 class="dropdown-item-title">
                  <?php echo $row['first']." ".$row['last_name']?>
                  <span class="float-right text-sm text-muted"><i class="fa fa-star"></i></span>
                </h3>
                <p class="text-sm">New Sell <?php echo $row['message']?></p>
                <p class="text-sm text-muted"><i class="fa fa-clock-o mr-1"></i><?php echo $interval->format('%a days, %H hours, %I min');?> hour Ago </p>
              </div>
            </div>
            <!-- Message End -->
          </a>
          <div class="dropdown-divider"></div>
          
         <?php 
            }
         ?>
          <a href="#" class="dropdown-item dropdown-footer seeall">See All Messages</a>
        </div>
      </li>
      
      <!-- Notifications Dropdown Menu -->
     
      <li class="nav-item">
        <a class="btn btn-warning" href="checklogin.php?logout=true"><i
            class="fa fa-user">LogOut</i></a>
      </li>
    </ul>
  </nav>
  <!-- /.navbar -->

  <!-- Main Sidebar Container -->
  <aside class="main-sidebar sidebar-dark-primary elevation-4">
    <!-- Brand Logo -->
    <a href="index.php" class="brand-link">
      <img src="dist/img/AdminLTELogo.png" alt="AdminLTE Logo" class="brand-image img-circle elevation-3"
           style="opacity: .8">
      <span class="brand-text font-weight-light">ZeeshSoft Panel</span>
    </a>

    <!-- Sidebar -->
    <div class="sidebar">
      <!-- Sidebar user panel (optional) -->
      <div class="user-panel mt-3 pb-3 mb-3 d-flex">
        <div class="image">
          <img src="dist/img/user2-160x160.jpg" class="img-circle elevation-2" alt="User Image">
        </div>
        <div class="info">
          <a href="#" class="d-block"><?php echo $_SESSION['user']['status']?></a>
        </div>
      </div>

      <!-- Sidebar Menu -->
      <nav class="mt-2">
        <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
          <!-- Add icons to the links using the .nav-icon class
               with font-awesome or any other icon font library -->
          
          <li class="nav-item" id="showUsers">
            <a href="javascript:void(0)" class="nav-link">
              <i class="nav-icon fa fa-th"></i>
              <p>
                Users
                <span class="right badge badge-danger">New</span>
              </p>
            </a>
          </li>
          <li class="nav-item has-treeview">
            <a href="#" class="nav-link">
              <i class="nav-icon fa fa-users"></i>
              <p>
                Manage Users
                <i class="right fa fa-angle-left"></i>
              </p>
            </a>
            <ul class="nav nav-treeview">
              <li class="nav-item">
                <a href="javascript:void(0)" id="ipUser" class="nav-link">
                  <i class="fa fa-server"></i>
                  <p>Search User IP</p>
                </a>
              </li>
              <li class="nav-item">
                <a href="javascript:void(0)" id="decline" class="nav-link">
                  <i class="fa fa-ban nav-icon"></i>
                    <?php 
                  $query = "Select distinct(count(*)) as total from user_status where status = 'Decline'";
                   $result = mysqli_query($con,$query);
                   $row = mysqli_fetch_assoc($result);
                   ?>
                  <p>Decline Users
                   <span class="right badge badge-danger"><?php echo $row['total'];?></span></p>
                </a>
              </li>
              <li class="nav-item">
                <a href="javascript:void(0)" id="cancel" class="nav-link">
                  <i class="fa fa-ban nav-icon"></i>
                    <?php 
                  $query = "Select distinct(count(*)) as total from user_status where status = 'Cancel'";
                   $result = mysqli_query($con,$query);
                   $row = mysqli_fetch_assoc($result);
                   ?>
                  <p>Canncel Users
                   <span class="right badge badge-danger"><?php echo $row['total'];?></span>
                  </p>
                </a>
              </li>
              <li class="nav-item">
                <a href="javascript:void(0)" id="pending" class="nav-link">
                     <?php 
                  $query = "Select distinct(count(*)) as total from user_status where status = 'Padding'";
                   $result = mysqli_query($con,$query);
                   $row = mysqli_fetch_assoc($result);
                   ?>
                  <i class="fa fa-ban nav-icon"></i>
                  <p>Pending Users
                   <span class="right badge badge-danger"><?php echo $row['total'];?></span>
                  </p>
                </a>
              </li>
              <li class="nav-item">
                <a href="javascript:void(0)" id="paidUser" class="nav-link">
                  <i class="fa fa-user nav-icon"></i>
                  <?php 
                  $query = "Select distinct(count(*)) as total from user_status where status = 'Success'";
                   $result = mysqli_query($con,$query);
                   $row = mysqli_fetch_assoc($result);
                   ?>
                  <p>Paided Users
                  <span class="right badge badge-danger"><?php echo $row['total'];?></span>
                  </p>
                </a>
              </li>
               <li class="nav-item">
                <a href="javascript:void(0)" id="updateProfile" class="nav-link">
                  <i class="fa fa-refresh nav-icon"></i>
                  <?php 
                  $query = "Select count(distinct(user_id)) as total from user_updates ";
                   $result = mysqli_query($con,$query);
                   $row = mysqli_fetch_assoc($result);
                   ?>
                  <p>Users Update Profile
                  <span class="right badge badge-danger"><?php echo $row['total'];?></span>
                  </p>
                </a>
              </li>
              
            </ul>
          </li>
           <li class="nav-item has-treeview">
            <a href="#" class="nav-link">
              <i class="nav-icon fa fa-users"></i>
              <p>
                Domains With Groups
                <i class="right fa fa-angle-left"></i>
              </p>
            </a>
            <ul class="nav nav-treeview">
              <li class="nav-item">
                <a href="javascript:void(0)" id="Groups" class="nav-link">
                  <i class="fa fa-server"></i>
                  <p>Groups</p>
                </a>
              </li>
        
             <!--  <li class="nav-item">
                <a href="javascript:void(0)" id="groupReport" class="nav-link">
                  <i class="fa fa-ban nav-icon"></i>
                  <p>Group Report</p>
                </a>
              </li>
              <li class="nav-item">
                <a href="" class="nav-link" class="groupLeads">
                  <i class="fa fa-user nav-icon"></i>
                  <p>Groups Leads</p>
                </a>
              </li> -->
            </ul>
          </li>
           <li class="nav-item" id="searchArea">
            <a href="javascript:void(0)" class="nav-link">
              <i class="nav-icon fa fa-search"></i>
              <p>
                Search Report
              </p>
            </a>
          </li>
           <li class="nav-item has-treeview" >
            <a href="#" class="nav-link">
              <i class="nav-icon fa fa-users"></i>
              <p>
               Software Side Report
                <i class="right fa fa-angle-left"></i>
              </p>
            </a>
            <ul class="nav nav-treeview">
              <li class="nav-item">
                <a href="javascript:void(0)" id ="productReport" class="nav-link">
                  <i class="fa fa-ban nav-icon"></i>
                  <p>Report</p>
                </a>
              </li>
              <li class="nav-item">
                <a href="javascript:void(0)" id="productdecline" class="nav-link">
                  <i class="fa fa-ban nav-icon"></i>
                  <p>Decline Users From Product</p>
                </a>
              </li>
              <li class="nav-item">
                <a href="javascript:void(0)" id="productcancel" class="nav-link">
                  <i class="fa fa-ban nav-icon"></i>
                  <p>Canncel Users</p>
                </a>
              </li>
              <li class="nav-item">
                <a href="javascript:void(0)" id="productpending" class="nav-link">
                  <i class="fa fa-ban nav-icon"></i>
                  <p>Pending Users</p>
                </a>
              </li>
              <li class="nav-item">
                <a href="javascript:void(0)" id="productpaid" class="nav-link">
                  <i class="fa fa-user nav-icon"></i>
                  <p>Paided Users</p>
                </a>
              </li>
            </ul>
          </li>
          
            <li class="nav-item has-treeview">
            <a href="#" class="nav-link">
              <i class="nav-icon fa fa-question-circle"></i>
              <p>
                Dispute
                <i class="right fa fa-angle-left"></i>
              </p>
            </a>
            <ul class="nav nav-treeview">
              <li class="nav-item">
                <a href="javascript:void(0)" id="addDispute" class="nav-link">
                  <i class="fa fa-plus"></i>
                  <p>Add Dispute</p>
                </a>
              </li>
              <li class="nav-item">
                <a href="javascript:void(0)" id="disputeManage" class="nav-link">
                  <i class="fa fa-tasks"></i>
                  <p>Manage Dispute</p>
                </a>
              </li>
            </ul>
          </li>
          <li class="nav-item has-treeview">
            <a href="#" class="nav-link">
              <i class="nav-icon fa fa-question-circle"></i>
              <p>
                Refund
                <i class="right fa fa-angle-left"></i>
              </p>
            </a>
            <ul class="nav nav-treeview">
              <li class="nav-item">
                <a href="javascript:void(0)" id="addRefund" class="nav-link">
                  <i class="fa fa-plus"></i>
                  <p>Add Refund</p>
                </a>
              </li>
              <li class="nav-item">
                <a href="javascript:void(0)" id="RefundManage" class="nav-link">
                  <i class="fa fa-tasks"></i>
                  <p>Manage Refund</p>
                </a>
              </li>
              
              
              
            </ul>
          </li>
           <li class="nav-item has-treeview">
            <a href="#" class="nav-link">
              <i class="nav-icon fa fa-question-circle"></i>
              <p>
                Email Template
                <i class="right fa fa-angle-left"></i>
              </p>
            </a>
            <ul class="nav nav-treeview">
              <li class="nav-item">
                <a href="javascript:void(0)" id="addtemplate" class="nav-link">
                  <i class="fa fa-plus"></i>
                  <p>Create New Template</p>
                </a>
              </li>
              <li class="nav-item">
                <a href="javascript:void(0)" onclick="managetemplate()" class="nav-link">
                  <i class="fa fa-tasks"></i>
                  <p>Email Content</p>
                </a>
              </li>
              </ul>
           </li>
              <li class="nav-item" id="showUsers">
            <a href="yearDetail.php" class="nav-link">
              <i class="nav-icon fa fa-th"></i>
              <p>
                Year Report
                <span class="right badge badge-danger">New</span>
              </p>
            </a>
          </li>
            <li class="nav-item" id="showUsers">
            <a href="/seoReport/index.php" class="nav-link">
              <i class="nav-icon fa fa-th"></i>
              <p>
               Seo Report
                <span class="right badge badge-danger">New</span>
              </p>
            </a>
          </li>
            <li class="nav-item" id="showUsers">
            <a href="create_order.php" class="nav-link">
              <i class="nav-icon fa fa-th"></i>
              <p>
               Create Order Link
              </p>
            </a>
          </li>
           <li class="nav-item" id="showUsers">
            <a href="order_link.php" class="nav-link">
              <i class="nav-icon fa fa-th"></i>
              <p>
              Order Link Leads
              </p>
            </a>
          </li>
           <li class="nav-item" id="showUsers">
            <a href="users.php" class="nav-link">
              <i class="nav-icon fa fa-th"></i>
              <p>
              Subadmins
              </p>
            </a>
          </li>
          
        </ul>
      </nav>
      <!-- /.sidebar-menu -->
    </div>
    <!-- /.sidebar -->
  </aside>

  <!-- 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 text-dark">Dashboard</h1>
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="#">Home</a></li>
            
            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->
    
    
    
    
    
    
    
    