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

if (isset($_GET['accNo']) && $_GET['accNo'] > 0) {
	$acc_no = $_GET['accNo'];
} else {
	header('Location: index.php');
}

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

?> 
<p align="center" id="mainHead">Account Statement</p>
<p style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px; margin-bottom:40px;">
View list of all credit/ debit / fund transfer transaction summary by this user.</p>

<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="text">
  <tr align="center" id="listTableHeader"> 
   <th width="80" scope="col">Transaction Date</th>
   <th width="70">Refrence No#</th>
   <th width="250">Description</th>
   <th width="60">Debit</th>
   <th width="60">Credit</th>
   <th width="60">Status</th>
   <th width="60">Delete</th>
  </tr>
<?php
if(dbNumRows($result) > 0) {
while($row = dbFetchAssoc($result)) {
	extract($row);
	if ($i%2) {$class = 'row1';}
	else {$class = 'row2';}
	$i += 1;
?>
  <tr class="<?php echo $class; ?>"> 
   <td><?php echo $date; ?></td>
   <td><div align="center"><?php echo $tx_no; ?></div></td>
   <td width="250"><?php echo $description; ?></td>
   <td width="50" align="center"><?php echo $tx_type == "debit" ? "$&nbsp;" . number_format($amount, 2) : ""; ?></td>
   <td width="50" align="center"><?php echo $tx_type == "credit" ? "$&nbsp;" . number_format($amount, 2) : ""; ?></td>
   <td width="60" align="center"><?php echo $status; ?></td>
   <td width="60" align="center">
      <form method="POST" action="deletetransaction.php" style="display:inline;">
        <input type="hidden" name="tx_no" value="<?php echo $tx_no; ?>">
        <input type="hidden" name="accNo" value="<?php echo $acc_no; ?>">
        <input type="submit" value="Delete" onclick="return confirm('Are you sure you want to delete this transaction?');">
      </form>
    </td>
  </tr>
<?php
}// end while
?>
  <tr> 
   <td colspan="5">&nbsp;</td>
  </tr>
  <tr> 
   <td colspan="5" align="right"></td>
  </tr>
<?php 
}//
else {
?> 
  <tr> 
   <td colspan="5">&nbsp;</td>
  </tr>
  <tr> 
   <td colspan="5" align="right">No Transaction / Fund transfer done.</td>
  </tr>
<?php 
}//else
?>
 </table>
 <p>&nbsp;</p>
