<div class="page-header">
	<h3 class="page-title">
		<span class="page-title-icon bg-gradient-primary text-white mr-2">
			<i class="mdi mdi-history"></i>
		</span>
		Package Order History
	</h3>
	<nav aria-label="breadcrumb">
		<ul class="breadcrumb">
			<li class="breadcrumb-item active" aria-current="page">
				<span></span>Overview
				<i class="mdi mdi-alert-circle-outline icon-sm text-primary align-middle"></i>
			</li>
		</ul>
	</nav>
</div>

<div class="row">
	<div class="col-12 grid-margin">
		<div class="card shadow border10">
			<div class="card-body">
				<h4 class="card-title">All Package Order</h4>
				<div class="table-responsive">
					<table id="datatable" class="table dataTable display">
						<thead>
							<tr>
								<th>
									Serial
								</th>
								<th>
									Package Amount
								</th>
								<th>
									Sender Number
								</th>
								<th>
									Transaction ID
								</th>
								<th>
									Bank Account
								</th>
								<th>
									Bank Slip
								</th>
								<th>
									Payment Method
								</th>
								<th>
									Requested At
								</th>
								<th>
									Checked At
								</th>
								<th>
									Status
								</th>
							</tr>
						</thead>
						<tbody>
							<?php $serial = 1;
							foreach ($orders as $order) : ?>
								<tr>
									<td><?= $serial++ ?></td>
									<td><?= $order->package_amount ?></td>
									<td><?= $order->sender_number == null ? 'null' : $order->sender_number ?></td>
									<td><?= $order->transaction_id == null ? 'null' : $order->transaction_id ?></td>
									<td><?= $order->bank_account == null ? 'null' : $order->bank_account ?></td>
									<td><a href="https://work.mali-mart.com/uploads/payment_slip/<?= $order->bank_slip ?>" target="_blank">
											<?= $order->bank_slip == null ? 'null' : '<img src="https://work.mali-mart.com/uploads/payment_slip/' . $order->bank_slip . '" style="width:150px;height:93px;border-radius:0px"' ?>
									</td>
									<td><?= $order->payment_method ?></td>
									<td><?= nice_date($order->created_at, 'd-M-y') ?></td>
									<td><?= nice_date($order->updated_at, 'd-M-y') ?></td>
									<td>
										<span class="badge <?php if ($order->status == 2) {
																echo 'badge-danger';
															} elseif ($order->status == 1) {
																echo 'badge-success';
															} else {
																echo 'badge-info';
															} ?>">

											<?php if ($order->status == 1) : ?>
												Accepted
											<?php elseif ($order->status == 2) : ?>
												Rejected
											<?php else : ?>
												Pending
											<?php endif; ?>
										</span>
									</td>
								</tr>
							<?php endforeach ?>
						</tbody>
					</table>
				</div>
			</div>
		</div>
	</div>
</div>



<script>
	$(document).ready(function() {
		$('#datatable').DataTable();
		$(".a_ldr,.r_ldr").hide();
	}); {
		let id = $(e).data('id');
		let data = {
			id: id
		};
		if (confirm('Are You sure to Decline ?')) {
			$(".a_ldr").show();
			$.ajax({
				type: "post",
				url: "<?= base_url('FlexiloadCtrl/fund_rejected') ?>",
				data: data,
				dataType: 'json',
				success: function(response) {
					if (response.success === true) {

						location.reload();
					} else {
						location.reload();


					}
				},
				error: function() {
					alert("Error");
				}
			});
		}

	}
</script>