<?php

include("includes/header.php"); 
include("includes/sidebar.php"); 

$withdrawals = $db_handle->runBaseQuery("SELECT * FROM withdrawals WHERE userID = $id ORDER BY id DESC");

 ?>
 
 
 <div class="main-content app-content">
 	<div class="container-fluid">
 	    
 	    <div class="d-flex justify-content-between align-items-center mb-3 mt-3 p-4 rounded-4 shadow-sm text-white" 
     style="background: #C81D25;">
  
  <div>
    <h5 class="fw-bold mb-1 text-light">Withdrawals History</h5>
    <p class="mb-0 opacity-75">View all your withdrawal transactions.</p>
  </div>

  <div>
    <i class="bi bi-piggy-bank-fill" style="font-size: 2.5rem;"></i>
  </div>
</div>
<div class="row mt-3">
            <div class="col-xl-12">
                <div class="card custom-card">
                    <div class="card-header justify-content-between border-bottom-0">
                        <div class="card-title">Withdrawal Transactions </div>
                        <div class="d-flex flex-wrap ms-auto gap-2">
                           
                            
                        </div>
                    </div>
                    <div class="card-body p-3">
                        <div class="table-responsive">
                            <table class="table text-nowrap table-bordered" id="TableTab">
                                <thead>
                                    <tr>
                                        <th scope="col">#</th>
                                       
                                        <th scope="col">Amount</th>
                                        <th scope="col">Bank</th>
                                        <th scope="col">Account Number</th>
                                        <th scope="col">Account Name</th>
                                        <th scope="col">Status</th>
                                        <th scope="col">Date</th>
                                        
                                        
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php
                                        if($withdrawals){
                                            
                                            $i = 1;
                                            foreach($withdrawals as $withdrawal){
                                              
                                               if($withdrawal['status'] == 0){
                                                $status = "PENDING";
                                            }elseif($withdrawal['status'] == 1){
                                                $status = "APPROVED";
                                            }else{
                                                $status = "DECLINED";

                                            }
                                               
                                   echo "<tr>";
                                   echo '<td> <span class="fw-medium">'.$i.'</span> </td>';
                                       
                                        echo '<td class="fw-medium">NGN'.number_format($withdrawal['amount']).'</td>';
                                        echo '<td> <span class="fw-medium">'.$withdrawal['bank'].'</span> </td>';
                                        echo '<td> <span class="fw-medium">'.$withdrawal['acc_no'].'</span> </td>';
                                        echo '<td> <span class="fw-medium">'.$withdrawal['acc_name'].'</span> </td>';
                                       
                                       echo '<td> <span class="">'.$status.'</span> </td>';
                                        echo '<td> <span class="">'.$withdrawal['date'].'</span> </td>';
                                        
                                        
                                   echo "</tr>";
                                   
                                   $i++;

                               }
                           }
                                    
                           ?>         
                                   
                                   
                                </tbody>
                            </table>
                        </div>
                    </div>
                    
                </div>
            </div>
        </div>
        
        
        
    </div>
 </div>
  <?php

include("includes/footer.php"); 
 ?>