Fix expired list widget

This commit is contained in:
iBNu Maksum 2025-03-14 10:26:47 +07:00
parent 66d67cb61d
commit 009040cd3c
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5

View File

@ -7,13 +7,13 @@ class customer_expired
public function getWidget()
{
global $ui, $current_date;
global $ui, $current_date, $config;
//user expire
$query = ORM::for_table('tbl_user_recharges')
->table_alias('tur')
->selects([
'tur.id',
'c.id',
'tur.username',
'c.fullname',
'c.phonenumber',
@ -25,7 +25,7 @@ class customer_expired
'tur.namebp',
'tur.routers'
])
->join('tbl_customers', ['tur.customer_id', '=', 'c.id'], 'c')
->innerJoin('tbl_customers', ['tur.customer_id', '=', 'c.id'], 'c')
->where_lte('expiration', $current_date)
->order_by_desc('expiration');
$expire = Paginator::findMany($query);
@ -38,6 +38,23 @@ class customer_expired
// Pass the total count and current page to the paginator
$paginator['total_count'] = $totalCount;
if(!empty($_COOKIE['expdef']) && $_COOKIE['expdef'] != $config['customer_expired_expdef']) {
$d = ORM::for_table('tbl_appconfig')->where('setting', 'customer_expired_expdef')->find_one();
if ($d) {
$d->value = $_COOKIE['expdef'];
$d->save();
} else {
$d = ORM::for_table('tbl_appconfig')->create();
$d->setting = 'customer_expired_expdef';
$d->value = $_COOKIE['expdef'];
$d->save();
}
}
if(!empty($config['customer_expired_expdef']) && empty($_COOKIE['expdef'])){
$_COOKIE['expdef'] = $config['customer_expired_expdef'];
setcookie('expdef', $config['customer_expired_expdef'], time() + (86400 * 30), "/");
}
// Assign the pagination HTML to the template variable
$ui->assign('expire', $expire);
$ui->assign('cookie', $_COOKIE);