<?php
require_once("../app/config.php");
$title="Alerts";
require_once('include/user_header.php');
require_once('include/user_navbar.php');
require_once('include/user_sidebar.php');
mysqli_query($dbc, "UPDATE tran_acct SET seen=1 WHERE user_id='".$row['id']."'");
?>
<div class="content-wrapper">
      <!-- Page header -->
      <div class="page-header">
        <div class="page-header-content header-elements-md-inline">
          <div class="page-title d-flex">
          <h4><i class="icon-certificate mr-2"></i> <span class="font-weight-semibold">Account statement</span></h4>
          </div>
        </div>
      </div>
      <!-- /page header -->
<div class="content">
  <div class="row">
    <div class="col-md-12">
      <div class="card">
        <div class="card-body">
          <ul class="nav nav-tabs justify-content-center nav-tabs-highlight nav-justified">
            <li class="nav-item"><a href="#basic-tab1" class="nav-link active" data-toggle="tab">Credit</a></li>
            <li class="nav-item"><a href="#basic-tab2" class="nav-link" data-toggle="tab">Debit</a></li>
          </ul>
          <div class="tab-content">
            <div class="tab-pane fade show active" id="basic-tab1">
              <table class="table datatable-show-all">
                  <a href="javascript:void;" onclick="window.print();" class="pull-right text-default"><i class="icon-printer2 mr-2"></i>PRINT</a>
                <thead>
                  <tr>
                    <th>#</th>                                                                       
                    <th>Reference</th>                                                                       
                    <th>Amount</th>                                                                       
                    <th>Details</th>                                                                       
                    <th>Date</th>      
                  </tr>
                </thead>
                <tbody>  
                  <?php
                  $trans = mysqli_query($dbc, "SELECT * FROM tran_acct WHERE user_id = '".$row['id']."' AND type=1  ORDER BY tran_acct.date DESC");
                  while($row1 = mysqli_fetch_array($trans)){?>
                  <tr>
                    <td><?php echo $index++;?>.</td>
                    <td>#<?php echo $row1['ref'];?></td>
                    <td><?php echo number_format($row1['amount']).$scan2['currency'];?></td>
                    <td><?php echo $row1['content'];?></td>
                    <td><?php echo date("Y/m/d h:i:A", strtotime($row1['date'])); ?></td>
                  </tr>
                  <?php }?> 
                </tbody>
              </table>
              </div>
            <div class="tab-pane fade" id="basic-tab2">
              <table class="table datatable-show-all">
                <a href="javascript:void;" onclick="window.print();" class="pull-right text-default"><i class="icon-printer2 mr-2"></i>PRINT</a>
                <thead>
                  <tr>
                    <th>#</th>                                                                       
                    <th>Reference</th>                                                                       
                    <th>Amount</th>                                                                       
                    <th>Details</th>                                                                       
                    <th>Date</th>   
                  </tr>
                </thead>
                <tbody>  
                 <?php
                  $trans = mysqli_query($dbc, "SELECT * FROM tran_acct WHERE user_id = '".$row['id']."' AND type=2  ORDER BY tran_acct.date DESC");
                   $index=1;
                  while($row1 = mysqli_fetch_array($trans)){?>
                  <tr>
                    <td><?php echo $index++;?>.</td>
                    <td>#<?php echo $row1['ref'];?></td>
                    <td><?php echo number_format($row1['amount']).$scan2['currency'];?></td>
                    <td><?php echo $row1['content'];?></td>
                    <td><?php echo date("Y/m/d h:i:A", strtotime($row1['date'])); ?></td>
                  </tr>
                  <?php }?>
                </tbody>
              </table>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>