continue activate package, when it cannot connect to Device, let admin sync it manual

This commit is contained in:
Ibnu Maksum 2024-08-01 09:25:13 +07:00
parent 67e383375e
commit 721ef32e12
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
2 changed files with 62 additions and 19 deletions

View File

@ -20,7 +20,7 @@ class Package
*/ */
public static function rechargeUser($id_customer, $router_name, $plan_id, $gateway, $channel, $note = '') public static function rechargeUser($id_customer, $router_name, $plan_id, $gateway, $channel, $note = '')
{ {
global $config, $admin, $c, $p, $b, $t, $d, $zero, $trx, $_app_stage; global $config, $admin, $c, $p, $b, $t, $d, $zero, $trx, $_app_stage, $isChangePlan;
$date_now = date("Y-m-d H:i:s"); $date_now = date("Y-m-d H:i:s");
$date_only = date("Y-m-d"); $date_only = date("Y-m-d");
$time_only = date("H:i:s"); $time_only = date("H:i:s");
@ -216,6 +216,7 @@ class Package
} }
if ($b) { if ($b) {
$isChangePlan = false;
if ($config['extend_expiry'] != 'no') { if ($config['extend_expiry'] != 'no') {
if ($b['namebp'] == $p['name_plan'] && $b['status'] == 'on') { if ($b['namebp'] == $p['name_plan'] && $b['status'] == 'on') {
// if it same internet plan, expired will extend // if it same internet plan, expired will extend
@ -237,18 +238,40 @@ class Package
$date_exp = $datetime[0]; $date_exp = $datetime[0];
$time = $datetime[1]; $time = $datetime[1];
} }
} else {
$isChangePlan = true;
} }
} }
//if ($b['status'] == 'on') { //if ($b['status'] == 'on') {
$dvc = Package::getDevice($p); $dvc = Package::getDevice($p);
if ($_app_stage != 'demo') { if ($_app_stage != 'demo') {
try {
if (file_exists($dvc)) { if (file_exists($dvc)) {
require_once $dvc; require_once $dvc;
(new $p['device'])->add_customer($c, $p); (new $p['device'])->add_customer($c, $p);
} else { } else {
new Exception(Lang::T("Devices Not Found")); new Exception(Lang::T("Devices Not Found"));
} }
} catch (Throwable $e) {
Message::sendTelegram(
"Sistem Error. When activate Package. You need to sync manually\n" .
"Router: $router_name\n" .
"Customer: u$c[username]\n" .
"Plan: p$p[name_plan]\n" .
$e->getMessage() . "\n" .
$e->getTraceAsString()
);
} catch (Exception $e) {
Message::sendTelegram(
"Sistem Error. When activate Package. You need to sync manually\n" .
"Router: $router_name\n" .
"Customer: u$c[username]\n" .
"Plan: p$p[name_plan]\n" .
$e->getMessage() . "\n" .
$e->getTraceAsString()
);
}
} }
//} //}
@ -328,12 +351,32 @@ class Package
// active plan not exists // active plan not exists
$dvc = Package::getDevice($p); $dvc = Package::getDevice($p);
if ($_app_stage != 'demo') { if ($_app_stage != 'demo') {
try {
if (file_exists($dvc)) { if (file_exists($dvc)) {
require_once $dvc; require_once $dvc;
(new $p['device'])->add_customer($c, $p); (new $p['device'])->add_customer($c, $p);
} else { } else {
new Exception(Lang::T("Devices Not Found")); new Exception(Lang::T("Devices Not Found"));
} }
} catch (Throwable $e) {
Message::sendTelegram(
"Sistem Error. When activate Package. You need to sync manually\n" .
"Router: $router_name\n" .
"Customer: u$c[username]\n" .
"Plan: p$p[name_plan]\n" .
$e->getMessage() . "\n" .
$e->getTraceAsString()
);
} catch (Exception $e) {
Message::sendTelegram(
"Sistem Error. When activate Package. You need to sync manually\n" .
"Router: $router_name\n" .
"Customer: u$c[username]\n" .
"Plan: p$p[name_plan]\n" .
$e->getMessage() . "\n" .
$e->getTraceAsString()
);
}
} }
$d = ORM::for_table('tbl_user_recharges')->create(); $d = ORM::for_table('tbl_user_recharges')->create();

View File

@ -242,8 +242,8 @@
<label class="col-md-2 control-label">{Lang::T('Allow Extend')}</label> <label class="col-md-2 control-label">{Lang::T('Allow Extend')}</label>
<div class="col-md-6"> <div class="col-md-6">
<select name="extend_expired" id="extend_expired" class="form-control text-muted"> <select name="extend_expired" id="extend_expired" class="form-control text-muted">
<option value="0">No</option>
<option value="1" {if $_c['extend_expired']}selected="selected" {/if}>Yes</option> <option value="1" {if $_c['extend_expired']}selected="selected" {/if}>Yes</option>
<option value="0">No</option>
</select> </select>
</div> </div>
<p class="help-block col-md-4">Customer can request to extend expirations</p> <p class="help-block col-md-4">Customer can request to extend expirations</p>