<?php

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

$deposits = $db_handle->runBaseQuery("SELECT * FROM fixed_deposits");

 ?>
 <div class="main-content app-content">
 	<div class="container-fluid">
<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"> All Fixed Deposits </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">Name</th>
                                        <th scope="col">Principal</th>
                                        <th scope="col">Balance</th>
                                       <!-- <th scope="col">Payment Type</th> -->
                                        <th scope="col">Interest</th>
                                        <th scope="col">Start Date</th>
                                        <th scope="col">Expiring Date</th>
                                        <th scope="col">Status</th>
                                        <!--<th scope="col">Action</th>-->
                                       
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php
                                    if($deposits){
                                        $i = 1;
                                    foreach($deposits as $deposit){
                                        $userID = ($deposit['user_id']);

                                                    $user = $db_handle->runBaseQuery("SELECT * FROM users WHERE id = $userID");

                                                    $name = $user[0]['first_name']." ".$user[0]['surname'];
                                               
                                   echo "<tr>";
                                    echo '<td class="fw-medium">'.$i.'</td>';
                                    echo '<td class="fw-medium">'.$name.'</td>';
                                      echo '<td class="fw-medium">NGN'.number_format($deposit['principal']).'</td>';
                                      echo '<td class="fw-medium">NGN'.number_format($deposit['balance']).'</td>';
                                        echo '<td> <span class="fw-medium">'.$deposit['interest_rate'].'%</span></td>';
                                       
                                        
                                        echo '<td> <span class="">'.$deposit['start_date'].'</span> </td>';
                                        
                                        echo '<td> <span class="">'.$deposit['maturity_date'].'</span> </td>';
                                        
                                        echo '<td> <span class="">'.$deposit['status'].'</span> </td>';

                                      /*  echo '<td>
                                            <div class="btn-list"> <button class="btn btn-sm btn-icon btn-success-light rounded-circle" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="Edit"><i class="ri-pencil-line lh-1 align-middle"></i></button> <button class="btn btn-sm btn-icon btn-danger-light rounded-circle" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="Delete"><i class="ri-delete-bin-line lh-1 align-middle"></i></button> </div>
                                        </td>';*/
                                       
                                    echo '</tr>';

                                    $i++;
                                    
                                    }

                                }

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

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