From 0cf5483353b45d26fc9faa97a71961bb6076b61c Mon Sep 17 00:00:00 2001 From: iBNu Maksum Date: Thu, 17 Oct 2024 09:44:21 +0700 Subject: [PATCH] check expired payments --- system/controllers/home.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/system/controllers/home.php b/system/controllers/home.php index 82d91d9a..fd54423c 100644 --- a/system/controllers/home.php +++ b/system/controllers/home.php @@ -326,10 +326,24 @@ $vpn = ORM::for_table('tbl_port_pool') $ui->assign('cf', $tcf); $ui->assign('vpn', $vpn); -$ui->assign('unpaid', ORM::for_table('tbl_payment_gateway') +$unpaids = []; +$unpaid = ORM::for_table('tbl_payment_gateway') ->where('username', $user['username']) ->where('status', 1) - ->find_one()); + ->find_one(); + +// check expired payments +foreach($unpaid as $up) { + if(strtotime($up['expired_date']) < time() || strtotime($up['created_date'], "+24 HOUR") < time()){ + $up->status = 4; + $up->save(); + }else{ + $unpaids[] = $up; + } +} + + +$ui->assign('unpaid', $unpaids); $ui->assign('code', alphanumeric(_get('code'), "-")); $abills = User::getAttributes("Bill");