<!-- include -->



<div class="page-header">
	<h3 class="page-title">
		<span class="page-title-icon bg-gradient-primary text-white mr-2">
			<i class="mdi mdi-details"></i>
		</span>
		Transaction Reports
	</h3>
</div>

<div class="row justify-content-center">

	<div class="col-12 grid-margin">

		<div class="card shadow border10">

			<div class="card-body">
				<h4 class="m-2 p-2"><?php if(isset($_GET['title'])) echo $_GET['title'].' Flexiload Transaction'?></h4>

				<div class="table-responsive">
					<table id="datatable" class="table display">
						<thead>
						<tr>
							<th>
								#
							</th>
							<th>
								Transaction ID
							</th>
							<th>
								Operator
							</th>
							<th>
								Number Type
							</th>
							<th>
								Mobile No
							</th>
							<th>
								Time
							</th>
							<th>
								Amount
							</th>

						</tr>
						</thead>
						<tbody>
						<?php $serial=1;$total_transaction=0; foreach($transactions as $transaction):?>
							<tr>
								<?php $total_transaction+=$transaction->amount?>
								<td><?= $serial++ ?></td>
								<td>#<?=$transaction->transaction_id?></td>
								<td><?=$transaction->operator?></td>
								<td><?=$transaction->number_type == 1 ? 'Prepaid':'PostPaid'?></td>
								<td> <?=$transaction->phone_number?></td>
								<td><?= date('Y-m-d h:i A', strtotime($transaction->created_at)) ?></td>
								<td>৳ <?=number_format($transaction->amount,2)?></td>
							</tr>

						<?php endforeach?>

						</tbody>
						<tr>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td>Total Flexiload</td>
							<td>৳ <?=number_format($total_transaction,2)?></td>

						</tr>
					</table>
				</div>
			</div>
		</div>
	</div>
</div>
<script>

	$(document).ready(function() {
		$('#datatable_print').DataTable({
			dom: 'Bfrtip',
			buttons: [{
				extend: 'print',
				className: 'btn btn-inverse-info btn-rounded btn-sm'
			}]
		});
	});
	$(document).ready(function() {
		$('.dataTable').DataTable();
	});

	$(window).on('load', function () {
		//$.getScript("<?= base_url() ?>app-assets/js/daterangepicker.min.js");

		$(function () {

			var start = moment().startOf('days');
			var end = moment();

			function cb(start, end) {
				$('#fromDate span').html(start.format('DD-MMM-YY h:m:ss a'));
			}

			$('#fromDate').daterangepicker({
				timePicker: true,
				singleDatePicker: true,
				showDropdowns: true,
				startDate: start,

				ranges: {
					'Today Now': [moment(), moment()],
					'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
					'Last 7 Days': [moment().subtract(6, 'days'), moment()],
					'Last 30 Days': [moment().subtract(29, 'days'), moment()],
					'This Month': [moment().startOf('month'), moment().endOf('month')],
					'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
				}
			}, cb);

			cb(start, end);

		});

		$(function () {

			var start = moment().endOf('days');
			var end = moment();

			function cb(start, end) {
				$('#toDate span').html(start.format('DD-MMM-YY h:m:ss a'));
			}

			$('#toDate').daterangepicker({
				timePicker: true,
				singleDatePicker: true,
				showDropdowns: true,
				startDate: start,

			}, cb);

			cb(start, end);

		});

		$('.dateloading').hide();
	});

	function search(){
		window.location.href = '<?=base_url('ReportCtrl')?>'+ '?from='+$('#from').html() + '&to=' + $('#to').html();
	}
</script>
