paystack/views/admin/transactions.php
2025-01-19 12:18:55 +00:00

169 lines
8.5 KiB
PHP

<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<?php init_head(); ?>
<div id="wrapper">
<div class="content">
<div class="row">
<div class="col-md-12">
<div class="panel_s">
<div class="panel-body">
<h4 class="no-margin">
<?php echo _l('paystack_transactions'); ?>
</h4>
<hr class="hr-panel-heading" />
<!-- Filters -->
<div class="row">
<div class="col-md-12">
<?php echo form_open('', ['method' => 'GET']); ?>
<div class="col-md-3">
<?php echo render_date_input('start_date', 'start_date', $this->input->get('start_date')); ?>
</div>
<div class="col-md-3">
<?php echo render_date_input('end_date', 'end_date', $this->input->get('end_date')); ?>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="status"><?php echo _l('status'); ?></label>
<select name="status" id="status" class="selectpicker" data-width="100%">
<option value=""><?php echo _l('all'); ?></option>
<option value="success" <?php if($this->input->get('status') == 'success'){echo 'selected';} ?>>
<?php echo _l('success'); ?>
</option>
<option value="failed" <?php if($this->input->get('status') == 'failed'){echo 'selected';} ?>>
<?php echo _l('failed'); ?>
</option>
</select>
</div>
</div>
<div class="col-md-3 mtop25">
<button type="submit" class="btn btn-primary"><?php echo _l('filter'); ?></button>
<a href="<?php echo admin_url('paystack/admin/transactions'); ?>" class="btn btn-default">
<?php echo _l('clear'); ?>
</a>
</div>
<?php echo form_close(); ?>
</div>
</div>
<div class="clearfix mtop20"></div>
<!-- Transactions Table -->
<table class="table dt-table table-transactions">
<thead>
<tr>
<th><?php echo _l('date'); ?></th>
<th><?php echo _l('reference'); ?></th>
<th><?php echo _l('invoice_dt_number'); ?></th>
<th><?php echo _l('client'); ?></th>
<th><?php echo _l('amount'); ?></th>
<th><?php echo _l('status'); ?></th>
<th><?php echo _l('options'); ?></th>
</tr>
</thead>
<tbody>
<?php foreach($transactions as $transaction) { ?>
<tr>
<td><?php echo _dt($transaction['date']); ?></td>
<td><?php echo $transaction['reference']; ?></td>
<td>
<a href="<?php echo admin_url('invoices/list_invoices/' . $transaction['invoice_id']); ?>">
<?php echo format_invoice_number($transaction['invoice_id']); ?>
</a>
</td>
<td><?php echo $transaction['email']; ?></td>
<td><?php echo app_format_money($transaction['amount'], get_base_currency()); ?></td>
<td>
<?php
$status_class = 'default';
if($transaction['status'] == 'success') {
$status_class = 'success';
} else if($transaction['status'] == 'failed') {
$status_class = 'danger';
}
?>
<span class="label label-<?php echo $status_class; ?>">
<?php echo _l($transaction['status']); ?>
</span>
</td>
<td>
<a href="#" class="btn btn-default btn-icon" onclick="view_transaction(<?php echo $transaction['id']; ?>)">
<i class="fa fa-eye"></i>
</a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Transaction Details Modal -->
<div class="modal fade" id="transaction_modal" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title"><?php echo _l('transaction_details'); ?></h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-12">
<table class="table table-striped">
<tbody>
<tr>
<td><strong><?php echo _l('reference'); ?>:</strong></td>
<td id="td_reference"></td>
</tr>
<tr>
<td><strong><?php echo _l('amount'); ?>:</strong></td>
<td id="td_amount"></td>
</tr>
<tr>
<td><strong><?php echo _l('status'); ?>:</strong></td>
<td id="td_status"></td>
</tr>
<tr>
<td><strong><?php echo _l('date'); ?>:</strong></td>
<td id="td_date"></td>
</tr>
<tr>
<td><strong><?php echo _l('email'); ?>:</strong></td>
<td id="td_email"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><?php echo _l('close'); ?></button>
</div>
</div>
</div>
</div>
<?php init_tail(); ?>
<script>
function view_transaction(id) {
$.get(admin_url + 'paystack/admin/get_transaction_details/' + id, function(response) {
var data = JSON.parse(response);
$('#td_reference').html(data.reference);
$('#td_amount').html(format_money(data.amount));
$('#td_status').html(data.status);
$('#td_date').html(data.date);
$('#td_email').html(data.email);
$('#transaction_modal').modal('show');
});
}
$(function() {
var TableTransactions = $('.table-transactions').DataTable({
"order": [[ 0, "desc" ]],
"pageLength": 25
});
});
</script>