<?php
require_once("../app/config.php");
$title="E-currency";
require_once('include/user_header.php');
require_once('include/user_navbar.php');
require_once('include/user_sidebar.php');
?>
<div class="content-wrapper">

      <!-- Page header -->
      <div class="page-header page-header-light">
        <div class="page-header-content header-elements-md-inline">
        </div>
      </div>

  <div class="content">
<?php 
if(!empty($_SESSION['offshore_withdraw'])){?>
        <div class="row">
            <div class="col-lg-12">
              <div class="alert <?php if($_SESSION['offshore_withdraw']=='pending') {echo 'bg-success';}else{echo 'bg-danger';}?> text-white alert-styled-left alert-dismissible">
                <button type="button" class="close" data-dismiss="alert"><span>&times;</span></button>
          <?php if($_SESSION['offshore_withdraw']=='insufficient') {
            echo'Insufficient fund.';
          } else if($_SESSION['offshore_withdraw']=='pending') {
            echo'Withdraw request has been submitted.';
          }else if($_SESSION['offshore_withdraw']=='limit') {
            echo'Withdraw limit has been exceeded.';
          }
          unset($_SESSION['offshore_withdraw']);?>                 
                </div>
              </div>
          </div>
<?php }?>
    <div class="row">
      <div class="col-md-12">

        <!-- Basic layout-->
        <div class="card">
          <div class="card-header header-elements-inline">
            <h6 class="card-title font-weight-semibold">E-currency</h6>
                <div class="header-elements">
                  <div class="list-icons text-orange-600">
                  <a class="list-icons-item" data-action="collapse"></a>
  
                </div>
              </div>
          </div>

          <div class="card-body">
            <form action="../app/user/withdraw" method="post">
              <div class="form-group row">
                <label class="col-form-label col-lg-2">Amount</label>
                <div class="col-lg-10">
                  <div class="input-group">
                    <span class="input-group-append">
                      <span class="input-group-text"><?php echo $scan2['currency'];?></span>
                    </span>
                    <input type="number" name="amount" maxlength="10" class="form-control" required="">
                    <input type="hidden" name="user_id" value="<?php echo $row['id'];?>"> 
                  </div>
                </div>
              </div> 
              <div class="form-group row">
                <label class="col-form-label col-lg-2">Payout method</label>
                <div class="col-lg-10">
                <select class="form-control select" name="coin" data-dropdown-css-class="bg-white" data-fouc required>
                <?php
                $catquery=mysqli_query($dbc, "SELECT * FROM withdrawm WHERE status=1");
                while($fcat=mysqli_fetch_array($catquery)){
                echo "<option value='".$fcat['id']."'>".$fcat['method']."</option>";}
                ?> 
                </select>
              </div>
              </div> 
              <div class="form-group row">
                <label class="col-form-label col-lg-2">Details</label>
                <div class="col-lg-10">
                  <textarea name="details" class="form-control" rows="4" required></textarea>
                </div>
              </div>                
              <div class="text-right">
                <button type="submit" class="btn bg-<?php echo $set['dashboard_color'];?>">Submit<i class="icon-paperplane ml-2"></i></button>
              </div>
            </form>
          </div>
        </div>
        <!-- /basic layout -->

      </div>
    </div>
    <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">Cashout History</h6>
          </div>
          <div class="table-responsive">
          <table class="table datatable-show-all">
            <thead>
              <tr>
              <th>Method</th>
              <th>Amount</th>
              <th>Details</th>
              <th>Date</th>                                                                         
              <th>Status</th>   
              </tr>
            </thead>
            <tbody>  
<?php
$trans=mysqli_query($dbc, "SELECT * FROM w_history WHERE user_id= '".$row['id']."' order by w_history.date DESC");
while($row1 = mysqli_fetch_array($trans)){
  $coin=mysqli_fetch_array(mysqli_query($dbc, "SELECT * FROM withdrawm WHERE id='".$row1['coin_id']."'"));
?>
<tr>

              <td><?php if($row1['coin_id']=='bank'){echo'Bank';}else{echo $coin['method'];}?></td>
              <td><?php echo $scan2['currency'].number_format($row1['amount']);?></td>
              <td><?php echo $row1['details'];?></td>
              <td><?php echo date("D, M Y", strtotime($row1['date']));?></td>
              <td><?php if($row1['status']==0){echo '<span class="badge badge-danger">Pending</span>';}else if($row1['status']==1){echo '<span class="badge badge-success">Paid</span>';}else if($row1['status']==2){echo '<span class="badge badge-primary">Declined</span>';}?></td>
</tr>
<?php }?> 
            </tbody>
          </table>
</div>
        </div>
      </div>
    </div>
  </div>
<?php require_once('include/user_footer.php');?>