forked from kevinowino869/mitrobill
auto renewal from deposit
This commit is contained in:
@ -19,9 +19,9 @@ ORM::configure('logging', true);
|
||||
include "autoload/Hookers.php";
|
||||
|
||||
// notification message
|
||||
if(file_exists("uploads/notifications.json")){
|
||||
$_notifmsg =json_decode(file_get_contents('uploads/notifications.json'), true);
|
||||
}else{
|
||||
if (file_exists("uploads/notifications.json")) {
|
||||
$_notifmsg = json_decode(file_get_contents('uploads/notifications.json'), true);
|
||||
} else {
|
||||
$_notifmsg = json_decode(file_get_contents('uploads/notifications.default.json'), true);
|
||||
}
|
||||
|
||||
@ -87,6 +87,21 @@ foreach ($d as $ds) {
|
||||
//update database user dengan status off
|
||||
$u->status = 'off';
|
||||
$u->save();
|
||||
|
||||
// autorenewal from deposit
|
||||
if ($config['enable_balance'] == 'yes' && $c['auto_renewal']) {
|
||||
$p = ORM::for_table('tbl_plans')->where('id', $u['plan_id'])->find_one();
|
||||
if ($p && $p['enabled'] && $c['balance'] >= $p['price']) {
|
||||
if (Package::rechargeUser($ds['customer_id'], $p['routers'], $p['id'], 'Customer', 'Balance')) {
|
||||
// if success, then get the balance
|
||||
Balance::min($ds['customer_id'], $p['price']);
|
||||
} else {
|
||||
Message::sendTelegram("FAILED RENEWAL #cron\n\n#u$c[username] #buy #Hotspot \n" . $p['name_plan'] .
|
||||
"\nRouter: " . $router_name .
|
||||
"\nPrice: " . $p['price']);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else echo " : ACTIVE \r\n";
|
||||
} else {
|
||||
$date_now = strtotime(date("Y-m-d H:i:s"));
|
||||
@ -107,6 +122,21 @@ foreach ($d as $ds) {
|
||||
|
||||
$u->status = 'off';
|
||||
$u->save();
|
||||
|
||||
// autorenewal from deposit
|
||||
if ($config['enable_balance'] == 'yes' && $c['auto_renewal']) {
|
||||
$p = ORM::for_table('tbl_plans')->where('id', $u['plan_id'])->find_one();
|
||||
if ($p && $p['enabled'] && $c['balance'] >= $p['price']) {
|
||||
if (Package::rechargeUser($ds['customer_id'], $p['routers'], $p['id'], 'Customer', 'Balance')) {
|
||||
// if success, then get the balance
|
||||
Balance::min($ds['customer_id'], $p['price']);
|
||||
} else {
|
||||
Message::sendTelegram("FAILED RENEWAL #cron\n\n#u$c[username] #buy #Hotspot \n" . $p['name_plan'] .
|
||||
"\nRouter: " . $router_name .
|
||||
"\nPrice: " . $p['price']);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else echo " : ACTIVE \r\n";
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
"2023.8.14": [
|
||||
"ALTER TABLE `tbl_customers` ADD `pppoe_password` varchar(45) NOT NULL DEFAULT '1' COMMENT 'For PPPOE Login' AFTER `password`;",
|
||||
"ALTER TABLE `tbl_plans` CHANGE `type` `type` ENUM('Hotspot','PPPOE','Balance') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;",
|
||||
"ALTER TABLE `tbl_transactions` CHANGE `type` `type` ENUM('Hotspot','PPPOE','Balance') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;"
|
||||
"ALTER TABLE `tbl_transactions` CHANGE `type` `type` ENUM('Hotspot','PPPOE','Balance') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;",
|
||||
"ALTER TABLE `tbl_customers` ADD `auto_renewal` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Auto renewall using balance' AFTER `balance`;"
|
||||
]
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"user_notification_expired_text": "Hello [[name]], your internet package [[package]] has been expired.",
|
||||
"expired": "Hello [[name]], your internet package [[package]] has been expired.",
|
||||
"reminder_7_day": "Hello *[[name]]*, \r\nyour internet package *[[package]]* will be expired in 7 days.",
|
||||
"reminder_3_day": "Hello *[[name]]*, \r\nyour internet package *[[package]]* will be expired in 3 days.",
|
||||
"reminder_1_day": "Hello *[[name]]*,\r\n your internet package *[[package]]* will be expired tomorrow.",
|
||||
|
Reference in New Issue
Block a user