<?php
session_start();
require('../db.php');

include('inc/session.php');

include('../inc/logo.php');
include('../inc/count.php');
?>

<?php include('inc/header.php');?>

<body class="fixed-nav sticky-footer bg-dark" id="page-top">
  <!-- Navigation-->
  
  <?php include('inc/nav.php');?>         
        
  <!-- Navigation Ends-->      
        
    
      </ul>
      <ul class="navbar-nav sidenav-toggler">
        <li class="nav-item">
          <a class="nav-link text-center" id="sidenavToggler">
            <i class="fa fa-fw fa-angle-left"></i>
          </a>
        </li>
      </ul>
      <ul class="navbar-nav ml-auto">
        <li class="nav-item dropdown">
          
        </li>
        <li class="nav-item dropdown">
         
          
            
           
        </li>
        <li class="nav-item">
         
        </li>
        <li class="nav-item">
        <a class="btn btn-secondary" href="logout.php">Logout</a>
          
        </li>
      </ul>
    </div>
  </nav>
    <?php 
		$user = $_SESSION['user'];
								
		$ins = mysqli_query($conn,"SELECT * FROM users WHERE email='$user' ");
		$data = mysqli_fetch_array($ins);
								
		$email = $data['email'];
		$rowpas = $data['pass'];
		$bal = $data['bal'];
							

	
							
	?> 
  
  <div class="content-wrapper">
    <div class="container-fluid">
      <!-- Breadcrumbs-->
      <ol class="breadcrumb">
        <li class="breadcrumb-item">
          <a href="dashboard.php">Dashboard</a>
        </li>
        <li class="breadcrumb-item active">Pending Registrations/</li>
      </ol>
     
<br> <br>




                        
                        
    




<div class="float-right">

 <button class="btn btn-success" onClick="excsv()">Export  CSV</button> <button class="btn btn-danger" onClick="expdf()">Export PDF</button></div>
        
     
          
          </div>
          
          <script>
              
            function excsv(){
                
            window.location.href="csv_export.php";    
            }  
              
              
               function expdf(){
                
            window.location.href="pdf_export.php";    
            }  
          </script>
        <div class="card-body">
          <div class="table-responsive">
            <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
            <thead>
              <tr>
                <th>Name</td>
                <th>Email Address</td>
                <th>Phone</td>
                 <th>OTP</td>
                <th>Email Code</td>
                <th>Date Registered</td>
               <th>Status</td>
                <th></td>
              </tr>
              </thead>
              <tfoot>
              <tr>
                <th>Name</td>
                <th>Email Address</td>
                <th>Phone</td>
                <th>OTP</td>
                <th>Email Code</td>
              
              
                <th>Date Registered</td>
               <th>Status</td>
                 <th></td>
              </tr>
              </tfoot>
              <tbody>
              
             <?php 
			$sql_trans = "SELECT * FROM users2  ORDER BY `joining_date` DESC";
									

$Show_trans = $conn->query($sql_trans);
										
						while($trow = $Show_trans->fetch_assoc())
											
											{
							
							if($trow['level'] === 'reseller'){
							    
							    $accType = '<badge class="badge badge-pill badge-success">Portal Owner</badge>';
							}elseif($trow['level'] === 'agent'){
							    
							    $accType = '<badge class="badge badge-pill badge-info">Agent/Reseller</badge>';
                                                          }elseif($trow['level'] === 'special'){
							    
							    $accType = '<badge class="badge badge-pill badge-success">Special User</badge>';
                                                         }else{
                                                             $accType = '<badge class="badge badge-pill badge-danger">Normal User</badge>';
							}				
								

                                                          if($trow['status'] === 'Active'){
							    
							    $status = '<badge class="badge badge-pill badge-success">Active</badge>';
							}elseif($trow['status'] === 'Pending'){
							    
							    $status = '<badge class="badge badge-pill badge-info">Pending</badge>';
                                                          }elseif($trow['status'] === 'Error'){
							    
							    $status = '<badge class="badge badge-pill badge-danger">Invalid BVN</badge>';
                                                         }else{
                                                             $status = '<badge class="badge badge-pill badge-danger">Pending</badge>';
							}
                                                   		?> 
              
             
                <tr>
                  <td><?php echo $trow['firstname']; ?> <?php echo $trow['lastname']; ?></td>
                  <td><?php echo $trow['email']; ?> </td>
                  <td><?php echo $trow['phone']; ?></td>
                 <td><?php echo $trow['credit']; ?></td>
                  <td><?php echo $trow['accno']; ?></td>
               
                     <td> <?php echo $trow['joining_date']; ?> </td>
                     <td> <?php echo $trow['status']; ?> </td>
                  
               

                   <td><a href="remov.php?user=<?php echo $trow['email']; ?>" onclick="window.confirm('Are you sure you want to delete user? ');"> <?php echo $trow['del']; ?> </a></td>
                  
                </tr>
                
                <?php } ?>
                </tbody>
            </table>
          </div>
        </div>
        <div class="card-footer small text-muted"></div>
      </div>
    </div>
    <!-- /.container-fluid-->
        </div>
      </div>
    </div>
    <!-- /.container-fluid-->
    <!-- /.content-wrapper-->
    <?php include('inc/footer.php');?>

