<?php
session_start();

if (isset($_SESSION['username']) == true) {
	include 'master.php';
	$username = $_SESSION['username'];
}else{
	header("location:login");
}
?>
		<!--page-wrapper-->
		<div class="page-wrapper">
			<!--page-content-wrapper-->
			<div class="page-content-wrapper">
				<div class="page-content">
					<!--breadcrumb-->
					<div class="page-breadcrumb d-none d-md-flex align-items-center mb-3">
						<div class="breadcrumb-title pr-3">Transfers</div>
						<div class="pl-3">
							<nav aria-label="breadcrumb">
								<ol class="breadcrumb mb-0 p-0">
									<li class="breadcrumb-item"><a href="javascript:;"><i class='bx bx-home-alt'></i></a>
									</li>
									<li class="breadcrumb-item active" aria-current="page">Transfer's Data</li>
								</ol>
							</nav>
						</div>
						<div class="ml-auto">
							<div class="btn-group">
								<button type="button" class="btn btn-primary">Active</button>
							</div>
						</div>
					</div><br><br>
					<div class="card">
						<div class="card-body">
							<div class="card-title">
								<h4 class="mb-0">International Transfers</h4>
							</div>
							<hr/>
							<div class="table-responsive">
								<table id="example" class="table table-striped table-bordered" style="width:100%">
									<thead>
										<tr>
											<th>S/N</th>
											<th>Receiver Full Name</th>
											<th>Receiver Account No</th>
											<th>Receiver Account Type</th>
											<th>Receiver Bank Name</th>
											<th>Receiver Bank Address</th>
											<th>Iban / Routing Number</th>
											<th>Amount</th>
											<th>Reason</th>
											<th>Dated Added</th>
											<th class="text-center">Action</th>
										</tr>
									</thead>
									<tbody>
										<tr>
										<?php
											$sel_post = $conn->query("SELECT * FROM transactions WHERE stat = 'International Transfer' ORDER BY id DESC ");
											$i=1;
											if ($sel_post->num_rows == 0) {
												echo "<td style='color:red; text-align:center;'>No Transfer Yet</td>";
											}
											foreach ($sel_post as $key) {
												$id = $key['id'];
										?>
											<td><?php echo $i;?></td>
											<td><?php echo $key['receiver_fullname'];?></td>
											<td><?php echo $key['account_number'];?></td>
											<td><?php echo $key['acc_type'];?></td>
											<td><?php echo $key['other_bank_name'];?></td>
											<td><?php echo $key['other_bank_address'];?></td>
											<td><?php echo $key['iban'];?></td>
											<td><?php echo $key['amount'];?></td>
											<td><?php echo $key['transaction_details'];?></td>
											<td><?php echo $key['date_added'];?></td>
											<td>
												<a href="delete-transfer?id=<?php echo $id; ?>" class="btn btn-danger" onclick="return confirm('Are you sure you want to delete?')">Delete</a>
											</td>
										</tr>
										<?php $i++;
										}	?>
									</tbody>
									<tfoot>
										<tr>
											<th>S/N</th>
											<th>Receiver Full Name</th>
											<th>Receiver Account No</th>
											<th>Receiver Account Type</th>
											<th>Receiver Bank Name</th>
											<th>Receiver Bank Address</th>
											<th>Iban / Routing Number</th>
											<th>Amount</th>
											<th>Reason</th>
											<th>Dated Added</th>
											<th class="text-center">Action</th>
										</tr>
									</tfoot>
								</table>
							</div>
						</div>
					</div><br><br><br><br><br>
					<div class="card">
						<div class="card-body">
							<div class="card-title">
								<h4 class="mb-0">Local Transfer</h4>
							</div>
							<hr/>
							<div class="table-responsive">
								<table id="example" class="table table-striped table-bordered" style="width:100%">
									<thead>
										<tr>
											<th>S/N</th>
											<th>Receiver Bank</th>
											<th>Receiver Account Type</th>
											<th>Receiver Account No</th>
											<th>Amount</th>
											<th>Dated Added</th>
											<th class="text-center">Action</th>
										</tr>
									</thead>
									<tbody>
										<tr>
										<?php
											$sel_post = $conn->query("SELECT * FROM transactions WHERE stat = 'Local Transfer' ORDER BY id DESC ");
											$i=1;
											if ($sel_post->num_rows == 0) {
												echo "<td style='color:red; text-align:center;'>No Local Transfer Yet</td>";
											}
											foreach ($sel_post as $key) {
												$id = $key['id'];
										?>
											<td><?php echo $i;?></td>
											<td><?php echo $key['other_bank_name'];?></td>
											<td><?php echo $key['acc_type'];?></td>
											<td><?php echo $key['account_number'];?></td>
											<td><?php echo $key['amount'];?></td>
											<td><?php echo $key['date_added'];?></td>
											<td>
												<a href="delete-transfer?id=<?php echo $id; ?>" class="btn btn-danger" onclick="return confirm('Are you sure you want to delete?')">Delete</a>
											</td>
										</tr>
										<?php $i++;
										}	?>
									</tbody>
									<tfoot>
										<tr>
											<th>S/N</th>
											<th>Receiver Bank</th>
											<th>Receiver Account Type</th>
											<th>Receiver Account No</th>
											<th>Amount</th>
											<th>Dated Added</th>
											<th class="text-center">Action</th>
										</tr>
									</tfoot>
								</table>
							</div>
						</div>
					</div>
				</div>
			</div>
			<!--end page-content-wrapper-->
		</div>
		<!--end page-wrapper-->
		<!--start overlay-->
		<div class="overlay toggle-btn-mobile"></div>
		<!--end overlay-->
		<!--Start Back To Top Button--> <a href="javaScript:;" class="back-to-top"><i class='bx bxs-up-arrow-alt'></i></a>
		<!--End Back To Top Button-->

<script>
		$(document).ready(function () {
			//Default data table
			$('#example').DataTable();
			// var table = $('#example2').DataTable({
			// 	lengthChange: false,
			// 	buttons: ['copy', 'excel', 'pdf', 'print', 'colvis']
			// });
			// table.buttons().container().appendTo('#example2_wrapper .col-md-6:eq(0)');
		});
	</script>
<?php
include 'footer.php';