Show is Customer Online in the customer list
This commit is contained in:
parent
9016ecbb98
commit
4f3647beae
@ -85,15 +85,56 @@ switch ($action) {
|
|||||||
$ui->display('autoload.tpl');
|
$ui->display('autoload.tpl');
|
||||||
break;
|
break;
|
||||||
case 'customer_is_active':
|
case 'customer_is_active':
|
||||||
$d = ORM::for_table('tbl_user_recharges')->where('customer_id', $routes['2'])->findOne();
|
$c = ORM::for_table('tbl_customers')->where('username', $routes['2'])->find_one();
|
||||||
if ($d) {
|
$p = ORM::for_table('tbl_plans')->find_one($routes['3']);
|
||||||
if ($d['status'] == 'on') {
|
$dvc = Package::getDevice($p);
|
||||||
die('<span class="label label-success" title="Expired ' . Lang::dateAndTimeFormat($d['expiration'], $d['time']) . '">' . $d['namebp'] . '</span>');
|
if ($_app_stage != 'demo') {
|
||||||
} else {
|
if (file_exists($dvc)) {
|
||||||
die('<span class="label label-danger" title="Expired ' . Lang::dateAndTimeFormat($d['expiration'], $d['time']) . '">' . $d['namebp'] . '</span>');
|
require_once $dvc;
|
||||||
|
try {
|
||||||
|
//don't wait more than 5 seconds for response from device, otherwise we get timeout error.
|
||||||
|
ini_set('default_socket_timeout', 5);
|
||||||
|
if ((new $p['device'])->online_customer($c, $p['routers'])) {
|
||||||
|
echo '<span class="label label-success" title="online"> </span>';
|
||||||
}
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo '<span class="label label-danger" title="error"> </span>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'plan_is_active':
|
||||||
|
$ds = ORM::for_table('tbl_user_recharges')->where('customer_id', $routes['2'])->find_array();
|
||||||
|
if ($ds) {
|
||||||
|
$ps = [];
|
||||||
|
$c = ORM::for_table('tbl_customers')->find_one($routes['2']);
|
||||||
|
foreach ($ds as $d) {
|
||||||
|
if ($d['status'] == 'on') {
|
||||||
|
$p = ORM::for_table('tbl_plans')->find_one($d['plan_id']);
|
||||||
|
$dvc = Package::getDevice($p);
|
||||||
|
$status = "";
|
||||||
|
if ($_app_stage != 'demo') {
|
||||||
|
if (file_exists($dvc)) {
|
||||||
|
require_once $dvc;
|
||||||
|
try {
|
||||||
|
//don't wait more than 5 seconds for response from device, otherwise we get timeout error.
|
||||||
|
ini_set('default_socket_timeout', 5);
|
||||||
|
if ((new $p['device'])->online_customer($c, $p['routers'])) {
|
||||||
|
$status = '<span class="label label-success" title="online"> </span>';
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$status = '<span class="label label-danger" title="error"> </span>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$ps[] = ('<span class="label label-primary m-1" title="Expired ' . Lang::dateAndTimeFormat($d['expiration'], $d['time']) . '">' . $d['namebp'] . ' ' . $status . '</span>');
|
||||||
} else {
|
} else {
|
||||||
die('<span class="label label-danger">•</span>');
|
$ps[] = ('<span class="label label-danger m-1" title="Expired ' . Lang::dateAndTimeFormat($d['expiration'], $d['time']) . '">' . $d['namebp'] . '</span>');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo implode("<br>", $ps);
|
||||||
|
} else {
|
||||||
|
die('');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'customer_select2':
|
case 'customer_select2':
|
||||||
|
@ -109,9 +109,10 @@ class MikrotikHotspot
|
|||||||
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$printRequest = new RouterOS\Request(
|
$printRequest = new RouterOS\Request(
|
||||||
'/ip hotspot active print',
|
'/ip hotspot active print',
|
||||||
RouterOS\Query::where('name', $customer['username'])
|
RouterOS\Query::where('user', $customer['username'])
|
||||||
);
|
);
|
||||||
return $client->sendSync($printRequest)->getProperty('.id');
|
$id = $client->sendSync($printRequest)->getProperty('.id');
|
||||||
|
return $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function connect_customer($customer, $ip, $mac_address, $router_name)
|
function connect_customer($customer, $ip, $mac_address, $router_name)
|
||||||
|
@ -132,7 +132,7 @@
|
|||||||
class="glyphicon glyphicon-map-marker"></i></a>
|
class="glyphicon glyphicon-map-marker"></i></a>
|
||||||
{/if}
|
{/if}
|
||||||
</td>
|
</td>
|
||||||
<td align="center" api-get-text="{$_url}autoload/customer_is_active/{$ds['id']}">
|
<td align="center" api-get-text="{$_url}autoload/plan_is_active/{$ds['id']}">
|
||||||
<span class="label label-default">•</span>
|
<span class="label label-default">•</span>
|
||||||
</td>
|
</td>
|
||||||
<td>{$ds['service_type']}</td>
|
<td>{$ds['service_type']}</td>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user