<?php
session_start();
error_reporting(0);
include("../config/dbconfig.php");

include("header.php");

if(!(isset($_SESSION['customerid'])))
    header('Location:login.php?error=nologin');

?>
<!-- Site Content Wrapper -->

              <!-- Site Content Wrapper -->
            <div class="dt-content-wrapper">

                <!-- Site Content -->
                <div class="dt-content">

                    <!-- Page Header -->
                    <div class="dt-page__header">
                        <h1 class="dt-page__title">Transfer History
                    </h1>
                    </div>
                    <!-- /page header -->

                    <!-- Grid -->
                    <div class="row">

                        <!-- Grid Item -->
                        <div class="col-xl-12">

                            <!-- Entry Header -->
                            <div class="dt-entry__header">

                                <!-- Entry Heading -->
                                <div class="dt-entry__heading">
                                    <h3 class="dt-entry__title">Recent Transfer</h3>
                                </div>
                                <!-- /entry heading -->

                            </div>
                            <!-- /entry header -->

                            <!-- Card -->
                            <div class="dt-card">

                                <!-- Card Body -->
                                <div class="dt-card__body">

                                    <!-- Tables -->
                                    <div class="table-responsive">

                                        <table id="data-table" class="table table-striped table-bordered table-hover">
                                            <thead>
                                            <tr>
                            <th><b>Transaction ID</b></th>
                            <th></th>
                            <th><b>Account Number</b></th>
                            <th><b>Receivers's Bank</b></th>
                            <th><b>Amount</b></th>
                            <th><b>Status</b></th>
                            </tr>
                            </thead>
                            <tbody>
                            </tr>
<?php
$query="SELECT * FROM transfers where (sender=".$_SESSION['customerid'].") ";
$rectrans=mysql_query($query);
while($recs = mysql_fetch_array($rectrans))
{	
$transid=$recs['id'];
$transdate=$recs['date'];
$receiveid=$recs['receiver'];
$receivebank=$recs['bank'];
    $amount=$recs['amount'];
    $date=$recs['date'];
    $status=$recs['status'];
   $blnce =  number_format($amount,2);
		echo "<tr>
        	      <td>TRANS$transid</td>
        	      <td></td>
        	     
        	      <td>$receiveid</td>
        	      <td>$receivebank</td>
                  <td>$cur $blnce</td>
        	      "; ?>
        	      <td> <span class="badge badge-pill badge-danger mb-1 mr-1"><? if ($status=='0') print "Debit";?></span>
					<span class="badge badge-pill badge-info mb-1 mr-1"><? if ($status=='1') print "Credit";?></span>
				                                                   </td>
<?}
?>
                                            </tr>
                                            </tbody>
                                            <tfoot>
                                            <tr>
                                                 
                                            </tr>
                                            </tfoot>
                                        </table>
                                         <tr>
        	      <td colspan="2"><div align="right">
<input type="button" class="btn btn-secondary" value="Print Transaction Detail" onClick="window.print()"></tr></td></div>
                                    </div>
                                    <!-- /tables -->

                                </div>
                                <!-- /card body -->

                            </div>
                            <!-- /card -->

                        </div>
                        <!-- /grid item -->

                    </div>
                    <!-- /grid -->
                     <link rel="stylesheet" href="../assets/css/custom.css">
                </div></div></div>

                </div>
                <!-- /site content -->



<?php include'footer.php' ?>
    
<script src="../assets/node_modules/datatables.net/js/jquery.dataTables.js"></script>
<script src="../assets/node_modules/datatables.net-bs4/js/dataTables.bootstrap4.js"></script>
<script src="../assets/js/custom/data-table.js"></script>
