add option for check is customer online

This commit is contained in:
iBNu Maksum 2024-10-11 11:37:45 +07:00
parent 155b2959b5
commit d5cba4b3c1
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
3 changed files with 50 additions and 27 deletions

View File

@ -85,20 +85,22 @@ switch ($action) {
$ui->display('autoload.tpl'); $ui->display('autoload.tpl');
break; break;
case 'customer_is_active': case 'customer_is_active':
$c = ORM::for_table('tbl_customers')->where('username', $routes['2'])->find_one(); if ($config['check_customer_online'] == 'yes') {
$p = ORM::for_table('tbl_plans')->find_one($routes['3']); $c = ORM::for_table('tbl_customers')->where('username', $routes['2'])->find_one();
$dvc = Package::getDevice($p); $p = ORM::for_table('tbl_plans')->find_one($routes['3']);
if ($_app_stage != 'demo') { $dvc = Package::getDevice($p);
if (file_exists($dvc)) { if ($_app_stage != 'demo') {
require_once $dvc; if (file_exists($dvc)) {
try { require_once $dvc;
//don't wait more than 5 seconds for response from device, otherwise we get timeout error. try {
ini_set('default_socket_timeout', 5); //don't wait more than 5 seconds for response from device, otherwise we get timeout error.
if ((new $p['device'])->online_customer($c, $p['routers'])) { ini_set('default_socket_timeout', 5);
echo '<span class="label label-success" title="online">&nbsp;</span>'; if ((new $p['device'])->online_customer($c, $p['routers'])) {
echo '<span class="label label-success" title="online">&nbsp;</span>';
}
} catch (Exception $e) {
echo '<span class="label label-danger" title="error">&nbsp;</span>';
} }
} catch (Exception $e) {
echo '<span class="label label-danger" title="error">&nbsp;</span>';
} }
} }
} }
@ -110,20 +112,22 @@ switch ($action) {
$c = ORM::for_table('tbl_customers')->find_one($routes['2']); $c = ORM::for_table('tbl_customers')->find_one($routes['2']);
foreach ($ds as $d) { foreach ($ds as $d) {
if ($d['status'] == 'on') { if ($d['status'] == 'on') {
$p = ORM::for_table('tbl_plans')->find_one($d['plan_id']); if ($config['check_customer_online'] == 'yes') {
$dvc = Package::getDevice($p); $p = ORM::for_table('tbl_plans')->find_one($d['plan_id']);
$status = ""; $dvc = Package::getDevice($p);
if ($_app_stage != 'demo') { $status = "";
if (file_exists($dvc)) { if ($_app_stage != 'demo') {
require_once $dvc; if (file_exists($dvc)) {
try { require_once $dvc;
//don't wait more than 5 seconds for response from device, otherwise we get timeout error. try {
ini_set('default_socket_timeout', 5); //don't wait more than 5 seconds for response from device, otherwise we get timeout error.
if ((new $p['device'])->online_customer($c, $p['routers'])) { ini_set('default_socket_timeout', 5);
$status = '<span class="label label-success" title="online">&nbsp;</span>'; if ((new $p['device'])->online_customer($c, $p['routers'])) {
$status = '<span class="label label-success" title="online">&nbsp;</span>';
}
} catch (Exception $e) {
$status = '<span class="label label-danger" title="error">&nbsp;</span>';
} }
} catch (Exception $e) {
$status = '<span class="label label-danger" title="error">&nbsp;</span>';
} }
} }
} }

View File

@ -693,5 +693,8 @@
"This_will_allow_you_to_download_plugin_from_private_paid_repository": "Ini akan memungkinkan Anda mengunduh plugin dari repositori pribadi\/berbayar", "This_will_allow_you_to_download_plugin_from_private_paid_repository": "Ini akan memungkinkan Anda mengunduh plugin dari repositori pribadi\/berbayar",
"Expired_Cronjob_Every_5_Minutes": "Cronjob Kedaluwarsa Setiap 5 Menit", "Expired_Cronjob_Every_5_Minutes": "Cronjob Kedaluwarsa Setiap 5 Menit",
"Expired_Cronjob_Every_1_Hour": "Cronjob Kedaluwarsa Setiap 1 Jam", "Expired_Cronjob_Every_1_Hour": "Cronjob Kedaluwarsa Setiap 1 Jam",
"Reminder_Cronjob_Every_7_AM": "Pengingat Cronjob Setiap Jam 7 Pagi" "Reminder_Cronjob_Every_7_AM": "Pengingat Cronjob Setiap Jam 7 Pagi",
"Check_if_Customer_Online": "Periksa apakah Pelanggan Online",
"Active_Customers": "Pelanggan Aktif",
"This_will_show_is_Customer_currently_is_online_or_not": "Ini akan menunjukkan apakah Pelanggan sedang online atau tidak"
} }

View File

@ -740,6 +740,22 @@
phpnuxbill-login-hotspot</a> phpnuxbill-login-hotspot</a>
</p> </p>
</div> </div>
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Check if Customer Online')}</label>
<div class="col-md-6">
<select name="check_customer_online" id="check_customer_online" class="form-control">
<option value="no">
{Lang::T('No')}
</option>
<option value="yes" {if $_c['check_customer_online']=='yes' }selected="selected" {/if}>
{Lang::T('Yes')}
</option>
</select>
</div>
<p class="help-block col-md-4">
{Lang::T('This will show is Customer currently is online or not')}
</p>
</div>
</div> </div>
<div class="panel-heading"> <div class="panel-heading">