<?php
if (!defined('WEB_ROOT')) {
	exit;
}

$user = $_SESSION['hlBank_user'];
$acc_no = $user['acc_no'];
if (!isset($acc_no) && $acc_no <= 0) {
	header('Location: index.php');
}

$sql = "SELECT * FROM tbl_transaction WHERE to_accno = $acc_no 
		ORDER BY id DESC LIMIT 20";
$result = dbQuery($sql);

?> 

 
<style>
.block {
  display: block;
  width: 100%;
  border: none;
  background-color: red;
  color: white;
  padding: 5px 8px;
  font-size: 16px;
  cursor: pointer;
  text-align: center;
}

.block2 {
  display: block;
  width: 100%;
  border: none;
  background-color: #4CAF50;
  color: white;
  padding: 5px 8px;
  font-size: 16px;
  cursor: pointer;
  text-align: center;
}

 
</style>

  <div class="panel-header bg-primary-gradient">
					<div class="">
						<div class="">
							<div>
								<h2 class="">  <img src="<?php echo WEB_ROOT; ?>include/assets/statement.png" >  My Account Statement</h2>
								<h5 class="">
								    Here is the list of your transactions as recored on your account e-statements
								    
								</h5>
							</div>
						 
						</div>
					</div>
				</div>
		
<div class="container-fluid">
          <div class="row">
            <div class="col-md-12">
              
                  <div class="table-responsive">
                    <table class="table" id="estatement"> 
					  <thead style="background-color:#1C43A9; color:white;" >
                        <th bgcolor="orange">
                         DATE
                        </th>
                        <th>
                          REFERENCE NO
                        </th>
                        <th>
                          Description
                        </th>
                        <th>
                          DEBIT (<?php echo $_SESSION['hlBank_user']['currency'] ?>)
                        </th>
                        <th>
                          CREDIT (<?php echo $_SESSION['hlBank_user']['currency'] ?>)
                        </th>
                        <th>
                          STATUS
                        </th>
                      </thead>
                      <tbody>
                        <tr class="<?php echo $class; ?>">
						
						<?php

if(dbAffectedRows($result) > 0) { //if
$i = 0;
while($row = dbFetchAssoc($result)) {
	extract($row);
	if ($i%2) {$class = 'row1';} 
	else {$class = 'row2';}
	$i += 1;
?>
                          <td>
                            <?php echo $date; ?>
                          </td>
                          <td>
                            <?php echo $tx_no; ?><?php echo $site_initial; ?>
                          </td>
                          <td>
                            <?php echo $description; ?>
                          </td>
                          <td>
                            <button type="button" class="badge badge-danger">  <?php echo $tx_type == "debit" ? "&nbsp;" . number_format($amount, 2) : ""; ?></button>
                          </td>
                          <td class="text-primary">
                            <button type="button" class="badge badge-success">  <?php echo $tx_type == "credit" ? "&nbsp;" . number_format($amount, 2) : ""; ?></button>
                          </td>
                          <td><?php echo $status; ?>
                          </td>
                        </tr>
                          
                        <?php
						} // end while
						}//if
						else {
						?>
						  <tr> 
						   <td colspan="6" align="right">You have no transaction history yet, seems that you haven't done any transaction yet.</td>
						  </tr>
						<?php 
						}//else
	$user_id = $_SESSION['hlBank_user']['user_id'];
	$acc_no = $_SESSION['hlBank_user']['acc_no'];
	  
	$balance_sql = "SELECT balance FROM tbl_accounts WHERE user_id = $user_id AND acc_no = $acc_no";
	$result = dbQuery($balance_sql);
	$row = dbFetchAssoc($result);
?>
</table>
<p>&nbsp;</p>
<strong style="font-size:15px;">updated: <?php echo date("h:i A d M Y"); ?></strong>
                      </tbody>
                    </table>
                  
              </div>
            </div>
           
          </div>
        </div>

 

 
