<?php
session_start();
require('../db.php');
include('inc/access.php');
	
include('../inc/logo.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>

  
  <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">Administrator/</li>
      </ol>
      <div class="row">
        <div class="col-12">
          
           
       
          <div class="card mb-3">
        <div class="card-header">
        
        
          <button class="alert alert-info"><i class="fa fa-signal"></i> Gateway Balance:
              <b><font color="blue">VTUAFRICA:</font> &#x20A6;<?php
			  
			 
              
        $query_rec = mysqli_query($conn,"SELECT * FROM api_setting");
			
			$apib = mysqli_fetch_array($query_rec); 
			
		

$apikey =  $apib['APIkey'];
$url = $apib['baseurl'];

$host = "https://$url/api/balance?apikey=$apikey";


//Initialize cURL.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $host);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

$data = curl_exec($ch);
$result = json_decode($data);

//Close the cURL handle.
curl_close($ch);


$num = $result; echo number_format($num, 2, '.', ',');?> 
          
          </b> </strong>
          
          
 <b><font color="blue">GETPAY:</font> &#x20A6;<?php
 
     $qryApi = mysqli_query($conn,"SELECT * FROM payment");
    $apidata = mysqli_fetch_array($qryApi);

	 $getpaykey = $apidata['getpaykey']; //email address()
    $getpaysec = $apidata['getpaysec'];
	$getpayurl = $apidata['getpayurl'];
    
$host = "https://$getpayurl/api/v1/balance?apikey=$getpaykey";

//Initialize cURL.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $host);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

$data = curl_exec($ch);
$result = json_decode($data);

//Close the cURL handle.
curl_close($ch);

$bal =  $result->data->Balance;
echo number_format($bal, 2, '.', ',');
?>
          
          </b>          
          
          </button>  
          
          
 <br> 

        
     
          
          </div>
          

        <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>Level</td>
                <th>Status</td>
                <th>Balance</td>
                <th>Referal</td>
                 <th></td>
                <td></td>
                <th></td>
                
                
                <td></td>
              </tr>
              </thead>
              <tfoot>
              <tr>
                <th>Name</td>
                <th>Email Address</td>
                <th>Phone</td>
                <th>Level</td>
                 <th>Status</td>
                <th>Balance</td>
                <th>Referal</td>
                 <th></td>
                <th></td>
                <th></td>
                <th></td>
                
              
              </tr>
              </tfoot>
              <tbody>
              
             <?php 
$sql_trans = "SELECT * FROM users  ORDER BY `serial` DESC";
$Show_trans = $conn->query($sql_trans);
										
						while($trow = $Show_trans->fetch_assoc())
											
											{
							
							if($trow['level'] === 'free'){
							    
							    $accType = '<badge class="badge badge-pill badge-danger">Normal</badge>';
							}else{
							    
							    $accType = '<badge class="badge badge-pill badge-success">Reseller</badge>';
							}
							
							
									if($trow['blockstat'] === 'Blocked'){
							    
							    $accStat = '<badge class="badge badge-pill badge-danger">Blocked</badge>';
							}else{
							    
							    $accStat = '<badge class="badge badge-pill badge-success">Active</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 $accType; ?> </td>
                    <td><?php echo $accStat; ?> </td>
                  
                  <td>₦<?php  $num = $trow['bal']; echo number_format($num, 2, '.', ',');?></td>
                  <td>₦<?php  $num = $trow['refwallet']; echo number_format($num, 2, '.', ',');?></td>
                  
                  <td><a href="credit-member.php?id=<?php echo $trow['accno']; ?>" class="btn btn-info">Credit</a></td>
                   
                  <td><a href="account_upgrade.php?email=<?php echo $trow['email']; ?>" class="btn btn-success">Upgrade</a></td>
                  <td><a href="account_activate.php?email=<?php echo $trow['email']; ?>" class="btn btn-primary">Activate</a></td>
                   <td><a href="remov.php?email=<?php echo $trow['email']; ?>" onClick="window.confirm('Are you sure you want to delete user? ');" class="btn btn-danger"> Delete </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');?>

