phpnuxbill/system/controllers/autoload.php

60 lines
1.8 KiB
PHP
Raw Normal View History

2017-03-11 03:51:06 +08:00
<?php
2023-08-23 13:11:07 +08:00
2017-03-11 03:51:06 +08:00
/**
2023-08-23 13:11:07 +08:00
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
* used for ajax
**/
2022-09-18 01:00:40 +08:00
2017-03-11 03:51:06 +08:00
_admin();
2022-10-13 15:00:54 +08:00
$ui->assign('_title', $_L['Network']);
2017-03-11 03:51:06 +08:00
$ui->assign('_system_menu', 'network');
$action = $routes['1'];
$admin = Admin::_info();
$ui->assign('_admin', $admin);
switch ($action) {
case 'pool':
2023-08-23 13:11:07 +08:00
$routers = _get('routers');
$d = ORM::for_table('tbl_pool')->where('routers', $routers)->find_many();
$ui->assign('d', $d);
2017-03-11 03:51:06 +08:00
$ui->display('autoload-pool.tpl');
break;
2022-09-01 15:52:32 +08:00
2017-03-11 03:51:06 +08:00
case 'server':
2023-08-23 13:11:07 +08:00
$d = ORM::for_table('tbl_routers')->where('enabled', '1')->find_many();
$ui->assign('d', $d);
2022-09-01 15:52:32 +08:00
2017-03-11 03:51:06 +08:00
$ui->display('autoload-server.tpl');
break;
2022-09-01 15:52:32 +08:00
2017-03-11 03:51:06 +08:00
case 'plan':
2023-08-23 13:11:07 +08:00
$server = _post('server');
$jenis = _post('jenis');
$d = ORM::for_table('tbl_plans')->where('routers', $server)->where('type', $jenis)->where('enabled', '1')->find_many();
$ui->assign('d', $d);
2022-09-01 15:52:32 +08:00
2017-03-11 03:51:06 +08:00
$ui->display('autoload.tpl');
break;
2023-08-23 13:11:07 +08:00
case 'customer_select2':
$s = addslashes(_get('s'));
if (empty($s)) {
$c = ORM::for_table('tbl_customers')->limit(30)->find_many();
} else {
2023-08-23 16:00:34 +08:00
$c = ORM::for_table('tbl_customers')->where_raw("(`username` LIKE '%$s%' OR `fullname` LIKE '%$s%' OR `phonenumber` LIKE '%$s%' OR `email` LIKE '%$s%')", [$s, $s, $s, $s])->limit(30)->find_many();
2023-08-23 13:11:07 +08:00
}
header('Content-Type: application/json');
2023-08-23 16:00:34 +08:00
foreach ($c as $cust) {
2023-08-23 13:11:07 +08:00
$json[] = [
'id' => $cust['id'],
2023-08-23 16:00:34 +08:00
'text' => $cust['username'] . ' - ' . $cust['fullname'] . ' - ' . $cust['email']
2023-08-23 13:11:07 +08:00
];
}
2023-08-23 16:00:34 +08:00
echo json_encode(['results' => $json]);
2023-08-23 13:11:07 +08:00
die();
break;
2017-03-11 03:51:06 +08:00
default:
echo 'action not defined';
2023-08-23 13:11:07 +08:00
}