<?php
require_once("../../app/config.php");
$title="Intra bank transfer history";
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>
      <!-- /page header -->

  <div class="content">
    <div class="row">
      <div class="col-lg-12">
        <div class="alert bg-white alert-dismissible">
          <button type="button" class="close" data-dismiss="alert"><span>&times;</span></button>
            Transfer charges is <?php echo $scan2['currency'].$set['transfer_charge'];?> per transaction.
          </div>
        </div>
    </div>
    <div class="row">
      <div class="col-md-12">
        <!-- Basic layout-->
        <div class="card">
          <table class="table datatable-show-all">
            <thead>
              <tr>
                  <th>#</th>                                                                       
                  <th>Reference</th>                                                                       
                  <th>Amount</th>                                                                       
                  <th>Sender</th>                                                                       
                  <th>Receiver</th>                                                                      
                  <th>Type</th>                                                                       
                  <th>Date</th>   
                  <th class="text-center">Action</th>   
                  <th class="text-center">Action</th>   
              </tr>
            </thead>
            <tbody>  
              <?php
              $trans = mysqli_query($dbc, "SELECT * FROM transfers ORDER BY transfers.date DESC");
              while($row1 = mysqli_fetch_array($trans)){
              $sender=mysqli_fetch_array(mysqli_query($dbc, "SELECT * FROM users WHERE id='".$row1['sender_id']."'"));
              $receiver=mysqli_fetch_array(mysqli_query($dbc, "SELECT * FROM users WHERE id='".$row1['receiver_id']."'"));?>
              <tr>
              <td><?php echo $index++;?>.</td>
              <td>#<?php echo $row1['ref_id'];?></td>
              <td><?php echo number_format($row1['amount']).$scan2['currency'];?></td>
              <td><a href="manage_users/<?php echo $sender['id'];?>"><?php echo $sender['name'];?></a></td>
              <td><a href="manage_users/<?php echo $receiver['id'];?>"><?php echo $receiver['name'];?></a></td>
              <td><?php if($row1['type']==1){echo'Bank Transfer';}else if($row1['type']==2){echo'Bank charges';}?></td>
              <td><?php echo date("Y/m/d h:i:A", strtotime($row1['date'])); ?></td>
              <?php if($row1['status']==1){?>
              <td class="text-center"><span class="badge badge-primary">Successful</span></td>
              <td class="text-center">-</td>
              <?php }else if($row1['status']==0){?>
              <td class="text-center"><a href="../app/admin?id=ownpay&stat=<?php echo $row1['id'];?>" class="text-uppercase" title="Confirm payment"><span class="badge badge-success">approve</span></a></td>
              <td class="text-center"><a href="../app/admin?id=owndpay&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>
        <!-- /basic layout -->
      </div>
    </div>
  </div>