<?php
require_once("../../app/config.php");
$title="Withdraw deposit";
require_once('../include/user_header.php');
require_once('../include/user_navbar.php');
require_once('../include/user_sidebar.php');
$trans = mysqli_query($dbc, "SELECT * FROM w_history order by w_history.id DESC");
?>
<div class="content-wrapper">

      <!-- Page header -->
      <div class="page-header page-header-light">
        <div class="page-header-content header-elements-md-inline">
          <div class="page-title d-flex">
            <h4><i class="icon-cash mr-2"></i><span class="font-weight-semibold">Withdraw cash request History</span></h4>
          </div>
        </div>

        <div class="breadcrumb-line breadcrumb-line-light header-elements-md-inline">
          <div class="d-flex">
            <div class="breadcrumb">
              <a href="./dashboard" class="breadcrumb-item"><i class="icon-home2 mr-2"></i> Home</a>
              <a href="./withdraw_cash" class="breadcrumb-item">withdraw</a>
            </div>
          </div>

          <div class="header-elements d-none">
            <div class="breadcrumb justify-content-center">
            </div>
          </div>
        </div>
      </div>
  <div class="content">
  <?php if(!empty($_SESSION['smtp'])){?>
      <div class="col-md-12 col-sm-12 col-xs-12 center-col">
          <div class="alert bg-white text-black alt-font alert-dismissible">
              <button type="button" class="close" data-dismiss="alert"><span>&times;</span></button>
              Error sending automated emails to clients, do know that some system functionality will be currently disabled till your smtp server comesback online, so try again later. If your smtp details are correct, and this error still persists, contact your hosting company.
          </div>
      </div>
  <?php }?>
    <div class="row">
      <div class="col-md-12">
        <div class="card">
          <div class="card-header header-elements-inline">
            <h6 class="card-title font-weight-semibold">Withdraw log</h6>
          </div>
          <table class="table datatable-show-all">
            <thead>
              <tr>
                <th>S/N</th>
                <th>Name</th>
                <th>Amount</th>                                                                       
                <th>Method</th>
                <th>Details</th>
                <th>Date</th>
                <th class="text-center">Action</th>    
                <th class="text-center">Action</th>    
              </tr>
            </thead>
            <tbody>
<?php while($row1 = mysqli_fetch_array($trans)){
$cast=mysqli_fetch_array(mysqli_query($dbc, "SELECT * FROM users WHERE id='".$row1['user_id']."'"));
$winfo= mysqli_fetch_array(mysqli_query($dbc, "SELECT * FROM wallet_address WHERE user_id='".$row1['user_id']."' AND coin_id='".$row1['coin_id']."'"));
$coin=mysqli_fetch_array(mysqli_query($dbc, "SELECT * FROM withdrawm WHERE id='".$row1['coin_id']."'"));
$bank=mysqli_fetch_array(mysqli_query($dbc, "SELECT * FROM bank WHERE user_id='".$row1['user_id']."'"));
?>
              <tr>
              	<td><?php echo $index++;?>.</td>
              	<td><a href="manage_users/<?php echo $cast['id'];?>"><?php echo $cast['name'];?></a></td>
                <td><?php echo number_format($row1['amount']).$scan2['currency'];?></td>
                <td><?php echo $coin['method'];?></td>
                <td><?php echo $row1['details'];?></td>
                <td><?php echo date("Y/m/d", strtotime($row1['date']));?></td>
<?php if($row1['status']==1){?>
<td class="text-center"><span class="badge badge-primary">Paid</span></td>
<td class="text-center">-</td>
<?php }else if($row1['status']==0){?>
<td class="text-center"><a href="../app/admin?id=pay&stat=<?php echo $row1['id'];?>" class="text-uppercase" title="Confirm payment"><span class="badge badge-success">pay</span></a></td>
<td class="text-center"><a href="../app/admin?id=dpay&stat=<?php echo $row1['id'];?>" class="text-uppercase" title="Decline payment"><span class="badge badge-danger">decline</span></a></td>
<?php }else if($row1['status']==2){?>
<td class="text-center"><span class="badge badge-danger">Declined</span></td>
<td class="text-center">-</td>
<?php } ?>
              </tr>
<?php }?>
                        </tbody>
                    </table>
                </div>
    </div>
  </div>
</div>
</br>