<?php

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

$deposits = $db_handle->runBaseQuery("SELECT * FROM account_funding 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">Funding History</h5>
    <p class="mb-0 opacity-75">View your savings progress and past 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"> Your 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">Payment Type</th>
                                        <th scope="col">Status</th>
                                        <th scope="col">Date</th>
                                        
                                        
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php
                                        if($deposits){
                                            
                                            $i = 1;
                                            foreach($deposits as $deposit){
                                                
                                            if($deposit['status'] == 1){
                                                $status = "SUCCESSFUL";
                                            }elseif($deposit['status'] == 0){
                                                $status = "PENDING";
                                                    
                                                }else{
                                                     $status = "UNSUCCESSFUL";
                                                }
                                               
                                   echo "<tr>";
                                   echo '<td> <span class="fw-medium">'.$i.'</span> </td>';
                                      
                                        

                                        echo '<td class="fw-medium">NGN'.number_format($deposit['amount']).'</td>';
                                        echo '<td> <span class="fw-medium">BANK TRANSFER</span> </td>';
                                       
                                       echo '<td> <span class="">'.$status.'</span> </td>';
                                        echo '<td> <span class="">'.$deposit['date'].'</span> </td>';
                                        
                                        
                                   echo "</tr>";
                                   
                                   $i++;

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

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