Fixed Customer List Bug

fix the package not listing on next page in customer list
This commit is contained in:
Focuslinkstech 2024-08-03 14:16:51 +01:00
parent de85d30a9e
commit dec4258a6f
2 changed files with 25 additions and 6 deletions

View File

@ -655,12 +655,28 @@ switch ($action) {
$query = ORM::for_table('tbl_customers'); $query = ORM::for_table('tbl_customers');
$query->where("status", $filter); $query->where("status", $filter);
} }
if ($orderby == 'asc') { if ($orderby == 'asc') {
$query->order_by_asc($order); $query->order_by_asc($order);
} else { } else {
$query->order_by_desc($order); $query->order_by_desc($order);
} }
$d = $query->findMany();
$customers = $query->findMany();
foreach ($customers as $customer) {
$d = ORM::for_table('tbl_user_recharges')->where('customer_id', $customer->id)->findOne();
if ($d) {
if ($d['status'] == 'on') {
$customer->recharge_status = '<span class="label label-success" title="Expired ' . Lang::dateAndTimeFormat($d['expiration'], $d['time']) . '">' . $d['namebp'] . '</span>';
} else {
$customer->recharge_status = '<span class="label label-danger" title="Expired ' . Lang::dateAndTimeFormat($d['expiration'], $d['time']) . '">' . $d['namebp'] . '</span>';
}
} else {
$customer->recharge_status = '<span class="label label-danger">&bull;</span>';
}
}
if (_post('export', '') == 'csv') { if (_post('export', '') == 'csv') {
$h = false; $h = false;
set_time_limit(-1); set_time_limit(-1);
@ -680,13 +696,14 @@ switch ($action) {
'email', 'email',
'balance', 'balance',
'service_type', 'service_type',
'recharge_status'
]; ];
$fp = fopen('php://output', 'wb'); $fp = fopen('php://output', 'wb');
if (!$h) { if (!$h) {
fputcsv($fp, $headers, ";"); fputcsv($fp, $headers, ";");
$h = true; $h = true;
} }
foreach ($d as $c) { foreach ($customers as $c) {
$row = [ $row = [
$c['id'], $c['id'],
$c['username'], $c['username'],
@ -696,14 +713,16 @@ switch ($action) {
$c['email'], $c['email'],
$c['balance'], $c['balance'],
$c['service_type'], $c['service_type'],
$c->recharge_status
]; ];
fputcsv($fp, $row, ";"); fputcsv($fp, $row, ";");
} }
fclose($fp); fclose($fp);
die(); die();
} }
$ui->assign('xheader', '<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.11.3/css/jquery.dataTables.min.css">'); $ui->assign('xheader', '<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.11.3/css/jquery.dataTables.min.css">');
$ui->assign('d', $d); $ui->assign('customers', $customers);
$ui->assign('statuses', ORM::for_table('tbl_customers')->getEnum("status")); $ui->assign('statuses', ORM::for_table('tbl_customers')->getEnum("status"));
$ui->assign('filter', $filter); $ui->assign('filter', $filter);
$ui->assign('search', $search); $ui->assign('search', $search);

View File

@ -99,7 +99,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{foreach $d as $ds} {foreach $customers as $ds}
<tr {if $ds['status'] != 'Active'}class="danger"{/if}> <tr {if $ds['status'] != 'Active'}class="danger"{/if}>
<td onclick="window.location.href = '{$_url}customers/view/{$ds['id']}'" <td onclick="window.location.href = '{$_url}customers/view/{$ds['id']}'"
style="cursor:pointer;">{$ds['username']}</td> style="cursor:pointer;">{$ds['username']}</td>
@ -122,8 +122,8 @@
class="glyphicon glyphicon-map-marker"></i></a> class="glyphicon glyphicon-map-marker"></i></a>
{/if} {/if}
</td> </td>
<td align="center" api-get-text="{$_url}autoload/customer_is_active/{$ds['id']}"> <td align="center">
<span class="label label-default">&bull;</span> {$ds.recharge_status}
</td> </td>
<td>{$ds['service_type']}</td> <td>{$ds['service_type']}</td>
<td>{Lang::T($ds['status'])}</td> <td>{Lang::T($ds['status'])}</td>