<?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">Withdrawals</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">Withdrawal'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">Withdrawals's Data Import</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>Username</th>
											<th>Email</th>
											<th>Account Number</th>
											<th>Account Name</th>
											<th>Bank Name</th>
											<th>Amount</th>
											<th>Previous Balance</th>
											<th>New Balance</th>
											<th>Status</th>
											<th>Dated Added</th>
											<th colspan="1" class="text-center">Action</th>
										</tr>
									</thead>
									<tbody>
										<tr>
										<?php
											$sel_post = $conn->query("SELECT * FROM withdrawals ORDER BY id DESC ");
											$i=1;
											if ($sel_post->num_rows == 0) {
												echo "<td style='color:red; text-align:center;'>No Withdrawal Yet</td>";
											}
											foreach ($sel_post as $key) {
												$id = $key['id'];
										?>
											<td><?php echo $i;?></td>
											<td><?php echo $key['username'];?></td>
											<td><?php echo $key['email'];?></td>
											<td><?php echo $key['acc_no'];?></td>
											<td><?php echo $key['account_name'];?></td>
											<td><?php echo $key['bank_name'];?></td>
											<td><?php echo $key['amount'];?></td>
											<td><?php echo $key['prev_bal'];?></td>
											<td><?php echo $key['new_bal'];?></td>
											<td><?php echo $key['status'];?></td>
											<td><?php echo $key['date_added'];?></td>
											<td><a href="approve-withdrawal?id=<?php echo $id; ?>" class="btn btn-success" onclick="return confirm('Are you sure you want to Approve?')">Approve</a>&nbsp;&nbsp;
												<a href="create-paid-withdrawals?id=<?php echo $id; ?>" class="btn btn-info" onclick="return confirm('Are you sure you want to update status to paid?')">Create Paid</a>&nbsp;&nbsp;
												<a href="delete_withdrawals?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>Username</th>
											<th>Email</th>
											<th>Account Number</th>
											<th>Account Name</th>
											<th>Bank Name</th>
											<th>Amount</th>
											<th>Previous Balance</th>
											<th>New Balance</th>
											<th>Status</th>
											<th>Dated Added</th>
											<th colspan="1" 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';