Change paginator, to make easy customization using pagination.tpl
This commit is contained in:
parent
36a24238ef
commit
0767c6ab23
@ -2,6 +2,15 @@
|
||||
|
||||
# CHANGELOG
|
||||
|
||||
## 2024.3.26
|
||||
|
||||
- Change paginator, to make easy customization using pagination.tpl
|
||||
|
||||
## 2024.3.25
|
||||
|
||||
- Fix maps on HTTP
|
||||
- Fix Cancel payment
|
||||
|
||||
## 2024.3.23
|
||||
|
||||
- Maps full height
|
||||
|
@ -8,22 +8,86 @@
|
||||
|
||||
class Paginator
|
||||
{
|
||||
public static function build($table, $colVal = [], $query='', $per_page = '10')
|
||||
public static function generate($query, $search = [], $per_page = '10')
|
||||
{
|
||||
global $routes;
|
||||
$adjacents = "2";
|
||||
$page = _get('p', 1);
|
||||
$page = (empty($page) ? 1 : $page);
|
||||
$url = U . implode('/', $routes);
|
||||
if (count($search) > 0) {
|
||||
$url .= '&' . http_build_query($search);
|
||||
}
|
||||
$url .= '&p=';
|
||||
$totalReq = $query->count();
|
||||
$next = $page + 1;
|
||||
$lastpage = ceil($totalReq / $per_page);
|
||||
$lpm1 = $lastpage - 1;
|
||||
$limit = $per_page;
|
||||
$startpoint = ($page * $limit) - $limit;
|
||||
if ($lastpage >= 1) {
|
||||
$pages = [];
|
||||
if ($lastpage < 7 + ($adjacents * 2)) {
|
||||
for ($counter = 1; $counter <= $lastpage; $counter++) {
|
||||
$pages[] = $counter;
|
||||
}
|
||||
} elseif ($lastpage > 5 + ($adjacents * 2)) {
|
||||
if ($page < 1 + ($adjacents * 2)) {
|
||||
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) {
|
||||
$pages[] = $counter;
|
||||
}
|
||||
$pages[] = "...";
|
||||
$pages[] = $lpm1;
|
||||
$pages[] = $lastpage;
|
||||
} elseif ($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) {
|
||||
$pages[] = "1";
|
||||
$pages[] = "2";
|
||||
$pages[] = "...";
|
||||
for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) {
|
||||
$pages[] = $counter;
|
||||
}
|
||||
$pages[] = "...";
|
||||
$pages[] = $lpm1;
|
||||
$pages[] = $lastpage;
|
||||
} else {
|
||||
$pages[] = "1";
|
||||
$pages[] = "2";
|
||||
$pages[] = "...";
|
||||
for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) {
|
||||
$pages[] = $counter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$result = [
|
||||
'count' => $lastpage,
|
||||
'limit' => $per_page,
|
||||
'startpoint' => $startpoint,
|
||||
'url' => $url,
|
||||
'page' => $page,
|
||||
'pages' => $pages,
|
||||
'prev' => ($page>0) ? ($page-1): "0",
|
||||
'next' => ($page>= $lastpage) ? $lastpage : $page+1
|
||||
];
|
||||
print_r($result);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
public static function build($table, $colVal = [], $query = '', $per_page = '10')
|
||||
{
|
||||
global $routes;
|
||||
global $_L;
|
||||
$url = U . implode('/', $routes);
|
||||
$query = urlencode($query);
|
||||
$adjacents = "2";
|
||||
$page = (int)(empty(_get('p')) ? 1 : _get('p'));
|
||||
$pagination = "";
|
||||
foreach($colVal as $k=>$v) {
|
||||
if(!is_array($v) && strpos($v,'%') === false) {
|
||||
foreach ($colVal as $k => $v) {
|
||||
if (!is_array($v) && strpos($v, '%') === false) {
|
||||
$table = $table->where($k, $v);
|
||||
}else{
|
||||
if(is_array($v)){
|
||||
} else {
|
||||
if (is_array($v)) {
|
||||
$table = $table->where_in($k, $v);
|
||||
}else{
|
||||
} else {
|
||||
$table = $table->where_like($k, $v);
|
||||
}
|
||||
}
|
||||
@ -103,7 +167,7 @@ class Paginator
|
||||
$page = (int)(!isset($routes['2']) ? 1 : $routes['2']);
|
||||
$pagination = "";
|
||||
|
||||
if(is_object($table)){
|
||||
if (is_object($table)) {
|
||||
if ($w1 != '') {
|
||||
$totalReq = $table->where($w1, $c1)->count();
|
||||
} elseif ($w2 != '') {
|
||||
@ -115,7 +179,7 @@ class Paginator
|
||||
} else {
|
||||
$totalReq = $table->count();
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
if ($w1 != '') {
|
||||
$totalReq = ORM::for_table($table)->where($w1, $c1)->count();
|
||||
} elseif ($w2 != '') {
|
||||
@ -209,13 +273,13 @@ class Paginator
|
||||
$adjacents = "2";
|
||||
$page = (int)(!isset($routes['2']) ? 1 : $routes['2']);
|
||||
$pagination = "";
|
||||
if(is_object($table)){
|
||||
if (is_object($table)) {
|
||||
if ($w1 != '') {
|
||||
$totalReq = $table->where_raw($w1, $c1)->count();
|
||||
} else {
|
||||
$totalReq = $table->count();
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
if ($w1 != '') {
|
||||
$totalReq = ORM::for_table($table)->where_raw($w1, $c1)->count();
|
||||
} else {
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
||||
* by https://t.me/ibnux
|
||||
@ -12,30 +13,32 @@ $action = $routes['1'];
|
||||
$ui->assign('_admin', $admin);
|
||||
|
||||
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
|
||||
r2(U."dashboard",'e',Lang::T('You do not have permission to access this page'));
|
||||
r2(U . "dashboard", 'e', Lang::T('You do not have permission to access this page'));
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
case 'list':
|
||||
$ui->assign('xfooter', '<script type="text/javascript" src="ui/lib/c/bandwidth.js"></script>');
|
||||
$ui->assign('xfooter', '<script type="text/javascript" src="ui/lib/c/bandwidth.js"></script>');
|
||||
run_hook('view_list_bandwidth'); #HOOK
|
||||
$name = _post('name');
|
||||
if ($name != ''){
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_bandwidth'), ['name_bw' => '%' . $name . '%'], $name);
|
||||
$d = ORM::for_table('tbl_bandwidth')->where_like('name_bw','%'.$name.'%')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
}else{
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_bandwidth'));
|
||||
$d = ORM::for_table('tbl_bandwidth')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
}
|
||||
$name = _post('name');
|
||||
if ($name != '') {
|
||||
$query = ORM::for_table('tbl_bandwidth')->where_like('name_bw', '%' . $name . '%');
|
||||
$paginator = Paginator::generate($query, ['name' => $name]);
|
||||
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
} else {
|
||||
$query = ORM::for_table('tbl_bandwidth');
|
||||
$paginator = Paginator::generate($query);
|
||||
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
}
|
||||
|
||||
$ui->assign('d',$d);
|
||||
$ui->assign('paginator',$paginator);
|
||||
$ui->assign('d', $d);
|
||||
$ui->assign('paginator', $paginator);
|
||||
$ui->display('bandwidth.tpl');
|
||||
break;
|
||||
|
||||
case 'add':
|
||||
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
|
||||
_alert(Lang::T('You do not have permission to access this page'),'danger', "dashboard");
|
||||
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
|
||||
}
|
||||
run_hook('view_add_bandwidth'); #HOOK
|
||||
$ui->display('bandwidth-add.tpl');
|
||||
@ -43,28 +46,28 @@ switch ($action) {
|
||||
|
||||
case 'edit':
|
||||
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
|
||||
_alert(Lang::T('You do not have permission to access this page'),'danger', "dashboard");
|
||||
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
|
||||
}
|
||||
$id = $routes['2'];
|
||||
run_hook('view_edit_bandwith'); #HOOK
|
||||
$d = ORM::for_table('tbl_bandwidth')->find_one($id);
|
||||
if($d){
|
||||
$ui->assign('burst',explode(" ", $d['burst']));
|
||||
$ui->assign('d',$d);
|
||||
if ($d) {
|
||||
$ui->assign('burst', explode(" ", $d['burst']));
|
||||
$ui->assign('d', $d);
|
||||
$ui->display('bandwidth-edit.tpl');
|
||||
}else{
|
||||
} else {
|
||||
r2(U . 'bandwidth/list', 'e', $_L['Account_Not_Found']);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
|
||||
_alert(Lang::T('You do not have permission to access this page'),'danger', "dashboard");
|
||||
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
|
||||
}
|
||||
$id = $routes['2'];
|
||||
run_hook('delete_bandwidth'); #HOOK
|
||||
$d = ORM::for_table('tbl_bandwidth')->find_one($id);
|
||||
if($d){
|
||||
if ($d) {
|
||||
$d->delete();
|
||||
r2(U . 'bandwidth/list', 's', Lang::T('Data Deleted Successfully'));
|
||||
}
|
||||
@ -72,40 +75,48 @@ switch ($action) {
|
||||
|
||||
case 'add-post':
|
||||
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
|
||||
_alert(Lang::T('You do not have permission to access this page'),'danger', "dashboard");
|
||||
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
|
||||
}
|
||||
$name = _post('name');
|
||||
$rate_down = _post('rate_down');
|
||||
$rate_down_unit = _post('rate_down_unit');
|
||||
$rate_up = _post('rate_up');
|
||||
$rate_up_unit = _post('rate_up_unit');
|
||||
$rate_up = _post('rate_up');
|
||||
$rate_up_unit = _post('rate_up_unit');
|
||||
run_hook('add_bandwidth'); #HOOK
|
||||
$isBurst = true;
|
||||
$burst = "";
|
||||
if(isset($_POST['burst'])){
|
||||
foreach($_POST['burst'] as $b){
|
||||
if(empty($b)){
|
||||
if (isset($_POST['burst'])) {
|
||||
foreach ($_POST['burst'] as $b) {
|
||||
if (empty($b)) {
|
||||
$isBurst = false;
|
||||
}
|
||||
}
|
||||
if($isBurst){
|
||||
if ($isBurst) {
|
||||
$burst = implode(' ', $_POST['burst']);
|
||||
};
|
||||
}
|
||||
$msg = '';
|
||||
if(Validator::Length($name,16,4) == false){
|
||||
$msg .= 'Name should be between 5 to 15 characters'. '<br>';
|
||||
if (Validator::Length($name, 16, 4) == false) {
|
||||
$msg .= 'Name should be between 5 to 15 characters' . '<br>';
|
||||
}
|
||||
|
||||
if($rate_down_unit == 'Kbps'){ $unit_rate_down = $rate_down * 1024; }else{ $unit_rate_down = $rate_down * 1048576; }
|
||||
if($rate_up_unit == 'Kbps'){ $unit_rate_up = $min_up * 1024; }else{ $unit_rate_up = $min_up * 1048576; }
|
||||
|
||||
$d = ORM::for_table('tbl_bandwidth')->where('name_bw',$name)->find_one();
|
||||
if($d){
|
||||
$msg .= Lang::T('Name Bandwidth Already Exist'). '<br>';
|
||||
if ($rate_down_unit == 'Kbps') {
|
||||
$unit_rate_down = $rate_down * 1024;
|
||||
} else {
|
||||
$unit_rate_down = $rate_down * 1048576;
|
||||
}
|
||||
if ($rate_up_unit == 'Kbps') {
|
||||
$unit_rate_up = $min_up * 1024;
|
||||
} else {
|
||||
$unit_rate_up = $min_up * 1048576;
|
||||
}
|
||||
|
||||
if($msg == ''){
|
||||
$d = ORM::for_table('tbl_bandwidth')->where('name_bw', $name)->find_one();
|
||||
if ($d) {
|
||||
$msg .= Lang::T('Name Bandwidth Already Exist') . '<br>';
|
||||
}
|
||||
|
||||
if ($msg == '') {
|
||||
$d = ORM::for_table('tbl_bandwidth')->create();
|
||||
$d->name_bw = $name;
|
||||
$d->rate_down = $rate_down;
|
||||
@ -116,53 +127,53 @@ switch ($action) {
|
||||
$d->save();
|
||||
|
||||
r2(U . 'bandwidth/list', 's', Lang::T('Data Created Successfully'));
|
||||
}else{
|
||||
} else {
|
||||
r2(U . 'bandwidth/add', 'e', $msg);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'edit-post':
|
||||
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
|
||||
_alert(Lang::T('You do not have permission to access this page'),'danger', "dashboard");
|
||||
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
|
||||
}
|
||||
$name = _post('name');
|
||||
$rate_down = _post('rate_down');
|
||||
$rate_down_unit = _post('rate_down_unit');
|
||||
$rate_up = _post('rate_up');
|
||||
$rate_up_unit = _post('rate_up_unit');
|
||||
run_hook('edit_bandwidth'); #HOOK
|
||||
$rate_up = _post('rate_up');
|
||||
$rate_up_unit = _post('rate_up_unit');
|
||||
run_hook('edit_bandwidth'); #HOOK
|
||||
$isBurst = true;
|
||||
$burst = "";
|
||||
if(isset($_POST['burst'])){
|
||||
foreach($_POST['burst'] as $b){
|
||||
if(empty($b)){
|
||||
if (isset($_POST['burst'])) {
|
||||
foreach ($_POST['burst'] as $b) {
|
||||
if (empty($b)) {
|
||||
$isBurst = false;
|
||||
}
|
||||
}
|
||||
if($isBurst){
|
||||
if ($isBurst) {
|
||||
$burst = implode(' ', $_POST['burst']);
|
||||
};
|
||||
}
|
||||
$msg = '';
|
||||
if(Validator::Length($name,16,4) == false){
|
||||
$msg .= 'Name should be between 5 to 15 characters'. '<br>';
|
||||
if (Validator::Length($name, 16, 4) == false) {
|
||||
$msg .= 'Name should be between 5 to 15 characters' . '<br>';
|
||||
}
|
||||
|
||||
$id = _post('id');
|
||||
$d = ORM::for_table('tbl_bandwidth')->find_one($id);
|
||||
if($d){
|
||||
}else{
|
||||
$msg .= Lang::T('Data Not Found'). '<br>';
|
||||
if ($d) {
|
||||
} else {
|
||||
$msg .= Lang::T('Data Not Found') . '<br>';
|
||||
}
|
||||
|
||||
if($d['name_bw'] != $name){
|
||||
$c = ORM::for_table('tbl_bandwidth')->where('name_bw',$name)->find_one();
|
||||
if($c){
|
||||
$msg .= Lang::T('Name Bandwidth Already Exist'). '<br>';
|
||||
if ($d['name_bw'] != $name) {
|
||||
$c = ORM::for_table('tbl_bandwidth')->where('name_bw', $name)->find_one();
|
||||
if ($c) {
|
||||
$msg .= Lang::T('Name Bandwidth Already Exist') . '<br>';
|
||||
}
|
||||
}
|
||||
|
||||
if($msg == ''){
|
||||
if ($msg == '') {
|
||||
$d->name_bw = $name;
|
||||
$d->rate_down = $rate_down;
|
||||
$d->rate_down_unit = $rate_down_unit;
|
||||
@ -172,11 +183,11 @@ switch ($action) {
|
||||
$d->save();
|
||||
|
||||
r2(U . 'bandwidth/list', 's', Lang::T('Data Updated Successfully'));
|
||||
}else{
|
||||
r2(U . 'bandwidth/edit/'.$id, 'e', $msg);
|
||||
} else {
|
||||
r2(U . 'bandwidth/edit/' . $id, 'e', $msg);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$ui->display('a404.tpl');
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ $ui->assign('_system_menu', 'customers');
|
||||
$action = $routes['1'];
|
||||
$ui->assign('_admin', $admin);
|
||||
|
||||
if (empty ($action)) {
|
||||
if (empty($action)) {
|
||||
$action = 'list';
|
||||
}
|
||||
|
||||
@ -21,35 +21,6 @@ $leafletpickerHeader = <<<EOT
|
||||
EOT;
|
||||
|
||||
switch ($action) {
|
||||
case 'list':
|
||||
$search = _post('search');
|
||||
run_hook('list_customers'); #HOOK
|
||||
if ($search != '') {
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_customers'), [
|
||||
'username' => '%' . $search . '%',
|
||||
'fullname' => '%' . $search . '%',
|
||||
'phonenumber' => '%' . $search . '%',
|
||||
'email' => '%' . $search . '%',
|
||||
'service_type' => '%' . $search . '%'
|
||||
], $search);
|
||||
$d = ORM::for_table('tbl_customers')
|
||||
->where_raw("(`username` LIKE '%$search%' OR `fullname` LIKE '%$search%' OR `phonenumber` LIKE '%$search%' OR `email` LIKE '%$search%')")
|
||||
->offset($paginator['startpoint'])
|
||||
->limit($paginator['limit'])
|
||||
->order_by_asc('username')
|
||||
->find_many();
|
||||
} else {
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_customers'));
|
||||
$d = ORM::for_table('tbl_customers')
|
||||
->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
}
|
||||
|
||||
$ui->assign('search', htmlspecialchars($search));
|
||||
$ui->assign('d', $d);
|
||||
$ui->assign('paginator', $paginator);
|
||||
$ui->display('customers.tpl');
|
||||
break;
|
||||
|
||||
case 'csv':
|
||||
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
|
||||
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
|
||||
@ -216,14 +187,14 @@ switch ($action) {
|
||||
->where('customer_id', $customer['id'])
|
||||
->find_many();
|
||||
$v = $routes['3'];
|
||||
if (empty ($v)) {
|
||||
if (empty($v)) {
|
||||
$v = 'activation';
|
||||
}
|
||||
if ($v == 'order') {
|
||||
$v = 'order';
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_payment_gateway'), ['username' => $customer['username']]);
|
||||
$order = ORM::for_table('tbl_payment_gateway')
|
||||
->where('username', $customer['username'])
|
||||
$query = ORM::for_table('tbl_transactions')->where('username', $customer['username']);
|
||||
$paginator = Paginator::generate($query);
|
||||
$order = $query
|
||||
->offset($paginator['startpoint'])
|
||||
->limit($paginator['limit'])
|
||||
->order_by_desc('id')
|
||||
@ -231,10 +202,9 @@ switch ($action) {
|
||||
$ui->assign('paginator', $paginator);
|
||||
$ui->assign('order', $order);
|
||||
} else if ($v == 'activation') {
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_transactions'), ['username' => $customer['username']]);
|
||||
$activation = ORM::for_table('tbl_transactions')
|
||||
->where('username', $customer['username'])
|
||||
->offset($paginator['startpoint'])
|
||||
$query = ORM::for_table('tbl_transactions')->where('username', $customer['username']);
|
||||
$paginator = Paginator::generate($query);
|
||||
$activation = $query->offset($paginator['startpoint'])
|
||||
->limit($paginator['limit'])
|
||||
->order_by_desc('id')
|
||||
->find_many();
|
||||
@ -376,13 +346,13 @@ switch ($action) {
|
||||
// Retrieve the customer ID of the newly created customer
|
||||
$customerId = $d->id();
|
||||
// Save Customers Attributes details
|
||||
if (!empty ($custom_field_names) && !empty ($custom_field_values)) {
|
||||
if (!empty($custom_field_names) && !empty($custom_field_values)) {
|
||||
$totalFields = min(count($custom_field_names), count($custom_field_values));
|
||||
for ($i = 0; $i < $totalFields; $i++) {
|
||||
$name = $custom_field_names[$i];
|
||||
$value = $custom_field_values[$i];
|
||||
|
||||
if (!empty ($name)) {
|
||||
if (!empty($name)) {
|
||||
$customField = ORM::for_table('tbl_customers_fields')->create();
|
||||
$customField->customer_id = $customerId;
|
||||
$customField->field_name = $name;
|
||||
@ -475,7 +445,7 @@ switch ($action) {
|
||||
// Update Customers Attributes values in tbl_customers_fields table
|
||||
foreach ($customFields as $customField) {
|
||||
$fieldName = $customField['field_name'];
|
||||
if (isset ($_POST['custom_fields'][$fieldName])) {
|
||||
if (isset($_POST['custom_fields'][$fieldName])) {
|
||||
$customFieldValue = $_POST['custom_fields'][$fieldName];
|
||||
$customField->set('field_value', $customFieldValue);
|
||||
$customField->save();
|
||||
@ -483,7 +453,7 @@ switch ($action) {
|
||||
}
|
||||
|
||||
// Add new Customers Attributess
|
||||
if (isset ($_POST['custom_field_name']) && isset ($_POST['custom_field_value'])) {
|
||||
if (isset($_POST['custom_field_name']) && isset($_POST['custom_field_value'])) {
|
||||
$newCustomFieldNames = $_POST['custom_field_name'];
|
||||
$newCustomFieldValues = $_POST['custom_field_value'];
|
||||
|
||||
@ -506,7 +476,7 @@ switch ($action) {
|
||||
}
|
||||
|
||||
// Delete Customers Attributess
|
||||
if (isset ($_POST['delete_custom_fields'])) {
|
||||
if (isset($_POST['delete_custom_fields'])) {
|
||||
$fieldsToDelete = $_POST['delete_custom_fields'];
|
||||
foreach ($fieldsToDelete as $fieldName) {
|
||||
// Delete the Customers Attributes with the given field name
|
||||
@ -536,7 +506,7 @@ switch ($action) {
|
||||
Mikrotik::removeHotspotActiveUser($client, $d['username']);
|
||||
} else {
|
||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||
if (!empty ($d['pppoe_password'])) {
|
||||
if (!empty($d['pppoe_password'])) {
|
||||
Mikrotik::setPpoeUser($client, $c['username'], $d['pppoe_password']);
|
||||
} else {
|
||||
Mikrotik::setPpoeUser($client, $c['username'], $password);
|
||||
@ -553,5 +523,25 @@ switch ($action) {
|
||||
break;
|
||||
|
||||
default:
|
||||
r2(U . 'customers/list', 'e', 'action not defined');
|
||||
$search = _post('search');
|
||||
run_hook('list_customers'); #HOOK
|
||||
if ($search != '') {
|
||||
$query = ORM::for_table('tbl_customers')->where_raw("(`username` LIKE '%$search%' OR `fullname` LIKE '%$search%' OR `phonenumber` LIKE '%$search%' OR `email` LIKE '%$search%')");
|
||||
$paginator = Paginator::generate($query, ['search' => $search]);
|
||||
$d = $query->offset($paginator['startpoint'])
|
||||
->limit($paginator['limit'])
|
||||
->order_by_asc('username')
|
||||
->find_many();
|
||||
} else {
|
||||
$query = ORM::for_table('tbl_customers');
|
||||
$paginator = Paginator::generate($query);
|
||||
$d = ORM::for_table('tbl_customers')
|
||||
->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
}
|
||||
|
||||
$ui->assign('search', htmlspecialchars($search));
|
||||
$ui->assign('d', $d);
|
||||
$ui->assign('paginator', $paginator);
|
||||
$ui->display('customers.tpl');
|
||||
break;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ $month_n = date('n');
|
||||
$iday = ORM::for_table('tbl_transactions')
|
||||
->where('recharged_on', $mdate)
|
||||
->where_not_equal('method', 'Customer - Balance')
|
||||
->where_not_equal('method', 'Recharge Balance - Administrator')
|
||||
->where_not_equal('method', 'Recharge Balance - Administrator')
|
||||
->sum('price');
|
||||
|
||||
if ($iday == '') {
|
||||
@ -54,9 +54,10 @@ $ui->assign('c_all', $c_all);
|
||||
|
||||
if ($config['hide_uet'] != 'yes') {
|
||||
//user expire
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_user_recharges'));
|
||||
$expire = ORM::for_table('tbl_user_recharges')
|
||||
->where_lte('expiration', $mdate)
|
||||
$query = ORM::for_table('tbl_user_recharges')
|
||||
->where_lte('expiration', $mdate);
|
||||
$paginator = Paginator::generate($query);
|
||||
$expire = $query
|
||||
->offset($paginator['startpoint'])
|
||||
->limit($paginator['limit'])
|
||||
->order_by_desc('expiration')
|
||||
@ -150,7 +151,7 @@ if (file_exists($cacheMSfile) && time() - filemtime($cacheMSfile) < 43200) {
|
||||
->select_expr('SUM(price)', 'total')
|
||||
->where_raw("YEAR(recharged_on) = YEAR(CURRENT_DATE())") // Filter by the current year
|
||||
->where_not_equal('method', 'Customer - Balance')
|
||||
->where_not_equal('method', 'Recharge Balance - Administrator')
|
||||
->where_not_equal('method', 'Recharge Balance - Administrator')
|
||||
->group_by_expr('MONTH(recharged_on)')
|
||||
->find_many();
|
||||
|
||||
|
@ -26,11 +26,13 @@ switch ($action) {
|
||||
r2(U . "logs/list/", 's', "Delete logs older than $keep days");
|
||||
}
|
||||
if ($q != '') {
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_logs'), ['description' => '%' . $q . '%'], $q);
|
||||
$d = ORM::for_table('tbl_logs')->where_like('description', '%' . $q . '%')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
$query = ORM::for_table('tbl_logs')->where_like('description', '%' . $q . '%');
|
||||
$paginator = Paginator::generate($query, ['q' => $q]);
|
||||
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
} else {
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_logs'));
|
||||
$d = ORM::for_table('tbl_logs')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
$query = ORM::for_table('tbl_logs');
|
||||
$paginator = Paginator::generate($query);
|
||||
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
}
|
||||
|
||||
$ui->assign('d', $d);
|
||||
@ -46,11 +48,13 @@ switch ($action) {
|
||||
r2(U . "logs/radius/", 's', "Delete logs older than $keep days");
|
||||
}
|
||||
if ($q != '') {
|
||||
$paginator = Paginator::build(ORM::for_table('radpostauth', 'radius'), ['username' => '%' . $q . '%'], $q);
|
||||
$d = ORM::for_table('radpostauth', 'radius')->where_like('username', '%' . $q . '%')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
$query = ORM::for_table('radpostauth', 'radius')->where_like('username', '%' . $q . '%');
|
||||
$paginator = Paginator::generate($query, ['q' => $q]);
|
||||
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
} else {
|
||||
$paginator = Paginator::build(ORM::for_table('radpostauth', 'radius'));
|
||||
$d = ORM::for_table('radpostauth', 'radius')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
$query = ORM::for_table('radpostauth', 'radius');
|
||||
$paginator = Paginator::generate($query);
|
||||
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
}
|
||||
|
||||
$ui->assign('d', $d);
|
||||
|
@ -19,9 +19,9 @@ switch ($action) {
|
||||
break;
|
||||
case 'history':
|
||||
$ui->assign('_system_menu', 'history');
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_payment_gateway'), ['username' => $user['username']]);
|
||||
$d = ORM::for_table('tbl_payment_gateway')
|
||||
->where('username', $user['username'])
|
||||
$query = ORM::for_table('tbl_payment_gateway')->where('username', $user['username']);
|
||||
$paginator = Paginator::generate($query);
|
||||
$d = $query
|
||||
->order_by_desc('id')
|
||||
->offset($paginator['startpoint'])->limit($paginator['limit'])
|
||||
->find_many();
|
||||
|
@ -68,11 +68,13 @@ switch ($action) {
|
||||
$ui->assign('_title', Lang::T('Customer'));
|
||||
$search = _post('search');
|
||||
if ($search != '') {
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_user_recharges'), ['username' => '%' . $search . '%'], $search);
|
||||
$d = ORM::for_table('tbl_user_recharges')->where_like('username', '%' . $search . '%')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
$query = ORM::for_table('tbl_user_recharges')->where_like('username', '%' . $search . '%');
|
||||
$paginator = Paginator::generate($query, ['search' => $search]);
|
||||
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
} else {
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_user_recharges'));
|
||||
$d = ORM::for_table('tbl_user_recharges')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_array();
|
||||
$query = ORM::for_table('tbl_user_recharges');
|
||||
$paginator = Paginator::generate($query);
|
||||
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_array();
|
||||
}
|
||||
run_hook('view_list_billing'); #HOOK
|
||||
if ($isApi) {
|
||||
|
@ -23,11 +23,13 @@ switch ($action) {
|
||||
|
||||
$name = _post('name');
|
||||
if ($name != '') {
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_pool'), ['pool_name' => '%' . $name . '%'], $name);
|
||||
$d = ORM::for_table('tbl_pool')->where_like('pool_name', '%' . $name . '%')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
$query = ORM::for_table('tbl_pool')->where_like('pool_name', '%' . $name . '%');
|
||||
$paginator = Paginator::generate($query, ['name' => $name]);
|
||||
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
} else {
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_pool'));
|
||||
$d = ORM::for_table('tbl_pool')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
$query = ORM::for_table('tbl_pool');
|
||||
$paginator = Paginator::generate($query);
|
||||
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
}
|
||||
|
||||
$ui->assign('d', $d);
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
||||
* by https://t.me/ibnux
|
||||
@ -12,7 +13,7 @@ $ui->assign('_admin', $admin);
|
||||
|
||||
|
||||
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
|
||||
_alert(Lang::T('You do not have permission to access this page'),'danger', "dashboard");
|
||||
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
@ -134,20 +135,18 @@ switch ($action) {
|
||||
$ui->assign('_title', "Network Access Server");
|
||||
$name = _post('name');
|
||||
if (empty($name)) {
|
||||
$paginator = Paginator::build(ORM::for_table('nas', 'radius'));
|
||||
$nas = ORM::for_table('nas', 'radius')->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
|
||||
$query = ORM::for_table('nas', 'radius');
|
||||
$paginator = Paginator::generate($query);
|
||||
$nas = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
|
||||
} else {
|
||||
$paginator = Paginator::build(ORM::for_table('nas', 'radius'), [
|
||||
'nasname' => '%'.$search.'%',
|
||||
'shortname' => '%'.$search.'%',
|
||||
'description' => '%'.$search.'%'
|
||||
]);
|
||||
$nas = ORM::for_table('nas', 'radius')
|
||||
->where_like('nasname', $search)
|
||||
->where_like('shortname', $search)
|
||||
->where_like('description', $search)
|
||||
->offset($paginator['startpoint'])->limit($paginator['limit'])
|
||||
->find_many();
|
||||
$query = ORM::for_table('nas', 'radius')
|
||||
->where_like('nasname', $search)
|
||||
->where_like('shortname', $search)
|
||||
->where_like('description', $search);
|
||||
$paginator = Paginator::generate($query, ['name' => $name]);
|
||||
$nas = $query
|
||||
->offset($paginator['startpoint'])->limit($paginator['limit'])
|
||||
->find_many();
|
||||
}
|
||||
$ui->assign('paginator', $paginator);
|
||||
$ui->assign('name', $name);
|
||||
|
@ -30,11 +30,13 @@ switch ($action) {
|
||||
r2(U . "logs/list/", 's', "Delete logs older than $keep days");
|
||||
}
|
||||
if ($q != '') {
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_transactions'), ['invoice' => '%' . $q . '%'], $q);
|
||||
$d = ORM::for_table('tbl_transactions')->where_like('invoice', '%' . $q . '%')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
$query = ORM::for_table('tbl_transactions')->where_like('invoice', '%' . $q . '%');
|
||||
$paginator = Paginator::generate($query, ['q' => $q]);
|
||||
$d = $where->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
} else {
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_transactions'));
|
||||
$d = ORM::for_table('tbl_transactions')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
$query = ORM::for_table('tbl_transactions');
|
||||
$paginator = Paginator::generate($query);
|
||||
$d = $where->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
}
|
||||
|
||||
$ui->assign('activation', $d);
|
||||
@ -43,9 +45,10 @@ switch ($action) {
|
||||
$ui->display('reports-activation.tpl');
|
||||
break;
|
||||
case 'daily-report':
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_transactions'), ['recharged_on' => $mdate]);
|
||||
$d = ORM::for_table('tbl_transactions')->where('recharged_on', $mdate)->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
$dr = ORM::for_table('tbl_transactions')->where('recharged_on', $mdate)->sum('price');
|
||||
$query = ORM::for_table('tbl_transactions')->where('recharged_on', $mdate);
|
||||
$paginator = Paginator::generate($query);
|
||||
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
$dr = $query->sum('price');
|
||||
|
||||
$ui->assign('d', $d);
|
||||
$ui->assign('dr', $dr);
|
||||
|
@ -17,7 +17,7 @@ use PEAR2\Net\RouterOS;
|
||||
require_once 'system/autoload/PEAR2/Autoload.php';
|
||||
|
||||
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
|
||||
_alert(Lang::T('You do not have permission to access this page'),'danger', "dashboard");
|
||||
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
@ -26,11 +26,13 @@ switch ($action) {
|
||||
|
||||
$name = _post('name');
|
||||
if ($name != '') {
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_routers'), ['name' => '%' . $name . '%'], $name);
|
||||
$d = ORM::for_table('tbl_routers')->where_like('name', '%' . $name . '%')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
$query = ORM::for_table('tbl_routers')->where_like('name', '%' . $name . '%');
|
||||
$paginator = Paginator::generate($query, ['name' => $name]);
|
||||
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
} else {
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_routers'));
|
||||
$d = ORM::for_table('tbl_routers')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
$query = ORM::for_table('tbl_routers');
|
||||
$paginator = Paginator::generate($query);
|
||||
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
}
|
||||
|
||||
$ui->assign('d', $d);
|
||||
|
@ -119,11 +119,13 @@ switch ($action) {
|
||||
|
||||
$name = _post('name');
|
||||
if ($name != '') {
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_plans'), ['name_plan' => '%' . $name . '%', 'type' => 'Hotspot'], $name);
|
||||
$d = ORM::for_table('tbl_bandwidth')->join('tbl_plans', array('tbl_bandwidth.id', '=', 'tbl_plans.id_bw'))->where('tbl_plans.type', 'Hotspot')->where_like('tbl_plans.name_plan', '%' . $name . '%')->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
|
||||
$query = ORM::for_table('tbl_bandwidth')->join('tbl_plans', array('tbl_bandwidth.id', '=', 'tbl_plans.id_bw'))->where('tbl_plans.type', 'Hotspot')->where_like('tbl_plans.name_plan', '%' . $name . '%');
|
||||
$paginator = Paginator::generate($query, ['name'=> $name]);
|
||||
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
|
||||
} else {
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_plans'), ['type' => 'Hotspot']);
|
||||
$d = ORM::for_table('tbl_bandwidth')->join('tbl_plans', array('tbl_bandwidth.id', '=', 'tbl_plans.id_bw'))->where('tbl_plans.type', 'Hotspot')->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
|
||||
$query = ORM::for_table('tbl_bandwidth')->join('tbl_plans', array('tbl_bandwidth.id', '=', 'tbl_plans.id_bw'))->where('tbl_plans.type', 'Hotspot');
|
||||
$paginator = Paginator::generate($query);
|
||||
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
|
||||
}
|
||||
|
||||
$ui->assign('d', $d);
|
||||
@ -393,11 +395,13 @@ switch ($action) {
|
||||
|
||||
$name = _post('name');
|
||||
if ($name != '') {
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_plans'), ['name_plan' => '%' . $name . '%', 'type' => 'PPPOE'], $name);
|
||||
$d = ORM::for_table('tbl_bandwidth')->join('tbl_plans', array('tbl_bandwidth.id', '=', 'tbl_plans.id_bw'))->where('tbl_plans.type', 'PPPOE')->where_like('tbl_plans.name_plan', '%' . $name . '%')->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
|
||||
$query = ORM::for_table('tbl_bandwidth')->join('tbl_plans', array('tbl_bandwidth.id', '=', 'tbl_plans.id_bw'))->where('tbl_plans.type', 'PPPOE')->where_like('tbl_plans.name_plan', '%' . $name . '%');
|
||||
$paginator = Paginator::generate($query, ['name' => $name]);
|
||||
$d =$query->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
|
||||
} else {
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_plans'), ['type' => 'PPPOE'], $name);
|
||||
$d = ORM::for_table('tbl_bandwidth')->join('tbl_plans', array('tbl_bandwidth.id', '=', 'tbl_plans.id_bw'))->where('tbl_plans.type', 'PPPOE')->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
|
||||
$query = ORM::for_table('tbl_bandwidth')->join('tbl_plans', array('tbl_bandwidth.id', '=', 'tbl_plans.id_bw'))->where('tbl_plans.type', 'PPPOE');
|
||||
$paginator = Paginator::generate($query);
|
||||
$d =$query->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
|
||||
}
|
||||
|
||||
$ui->assign('d', $d);
|
||||
@ -646,11 +650,13 @@ switch ($action) {
|
||||
$ui->assign('_title', Lang::T('Balance Plans'));
|
||||
$name = _post('name');
|
||||
if ($name != '') {
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_plans'), ['name_plan' => '%' . $name . '%', 'type' => 'Balance'], $name);
|
||||
$d = ORM::for_table('tbl_plans')->where('tbl_plans.type', 'Balance')->where_like('tbl_plans.name_plan', '%' . $name . '%')->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
|
||||
$query = ORM::for_table('tbl_plans')->where('tbl_plans.type', 'Balance')->where_like('tbl_plans.name_plan', '%' . $name . '%');
|
||||
$paginator = Paginator::generate($query, ['name' => $name]);
|
||||
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
|
||||
} else {
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_plans'), ['type' => 'Balance'], $name);
|
||||
$d = ORM::for_table('tbl_plans')->where('tbl_plans.type', 'Balance')->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
|
||||
$query = ORM::for_table('tbl_plans')->where('tbl_plans.type', 'Balance');
|
||||
$paginator = Paginator::generate($query);
|
||||
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
|
||||
}
|
||||
|
||||
$ui->assign('d', $d);
|
||||
|
@ -30,7 +30,7 @@ switch ($action) {
|
||||
r2(U . "settings/app", 's', 'Test Telegram has been send<br>Result: ' . $result);
|
||||
}
|
||||
|
||||
$UPLOAD_URL_PATH = str_replace($root_path,'', $UPLOAD_PATH);
|
||||
$UPLOAD_URL_PATH = str_replace($root_path, '', $UPLOAD_PATH);
|
||||
if (file_exists($UPLOAD_PATH . DIRECTORY_SEPARATOR . 'logo.png')) {
|
||||
$logo = $UPLOAD_URL_PATH . DIRECTORY_SEPARATOR . 'logo.png?' . time();
|
||||
} else {
|
||||
@ -276,59 +276,58 @@ switch ($action) {
|
||||
$search = _req('search');
|
||||
if ($search != '') {
|
||||
if ($admin['user_type'] == 'SuperAdmin') {
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_users'), ['username' => '%' . $search . '%'], $search);
|
||||
$d = ORM::for_table('tbl_users')
|
||||
->where_like('username', '%' . $search . '%')
|
||||
$query = ORM::for_table('tbl_users')
|
||||
->where_like('username', '%' . $search . '%');
|
||||
$paginator = Paginator::generate($query, ['search' => $search]);
|
||||
$d = $query
|
||||
->offset($paginator['startpoint'])
|
||||
->limit($paginator['limit'])->order_by_asc('id')->findArray();
|
||||
} else if ($admin['user_type'] == 'Admin') {
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_users'), [
|
||||
'username' => '%' . $search . '%',
|
||||
['user_type' => 'Report'],
|
||||
['user_type' => 'Agent'],
|
||||
['user_type' => 'Sales'],
|
||||
['id' => $admin['id']]
|
||||
], $search);
|
||||
$d = ORM::for_table('tbl_users')
|
||||
->where_like('username', '%' . $search . '%')
|
||||
->where_any_is([
|
||||
$query = ORM::for_table('tbl_users')
|
||||
->where_like('username', '%' . $search . '%')->where_any_is([
|
||||
['user_type' => 'Report'],
|
||||
['user_type' => 'Agent'],
|
||||
['user_type' => 'Sales'],
|
||||
['id' => $admin['id']]
|
||||
])
|
||||
]);
|
||||
$paginator = Paginator::generate($query, ['search' => $search]);
|
||||
$d = $query
|
||||
->offset($paginator['startpoint'])
|
||||
->limit($paginator['limit'])->order_by_asc('id')->findArray();
|
||||
} else {
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_users'), ['username' => '%' . $search . '%'], $search);
|
||||
$d = ORM::for_table('tbl_users')
|
||||
$query = ORM::for_table('tbl_users')
|
||||
->where_like('username', '%' . $search . '%')
|
||||
->where_any_is([
|
||||
['id' => $admin['id']],
|
||||
['root' => $admin['id']]
|
||||
])
|
||||
]);
|
||||
$paginator = Paginator::generate($query, ['search' => $search]);
|
||||
$d = $query
|
||||
->offset($paginator['startpoint'])
|
||||
->limit($paginator['limit'])->order_by_asc('id')->findArray();
|
||||
}
|
||||
} else {
|
||||
if ($admin['user_type'] == 'SuperAdmin') {
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_users'));
|
||||
$d = ORM::for_table('tbl_users')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_asc('id')->findArray();
|
||||
$query = ORM::for_table('tbl_users');
|
||||
$paginator = Paginator::generate($query);
|
||||
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_asc('id')->findArray();
|
||||
} else if ($admin['user_type'] == 'Admin') {
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_users'));
|
||||
$d = ORM::for_table('tbl_users')->where_any_is([
|
||||
$query = ORM::for_table('tbl_users')->where_any_is([
|
||||
['user_type' => 'Report'],
|
||||
['user_type' => 'Agent'],
|
||||
['user_type' => 'Sales'],
|
||||
['id' => $admin['id']]
|
||||
])->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_asc('id')->findArray();
|
||||
]);
|
||||
$paginator = Paginator::generate($query);
|
||||
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_asc('id')->findArray();
|
||||
} else {
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_users'));
|
||||
$d = ORM::for_table('tbl_users')
|
||||
$query = ORM::for_table('tbl_users')
|
||||
->where_any_is([
|
||||
['id' => $admin['id']],
|
||||
['root' => $admin['id']]
|
||||
])
|
||||
]);
|
||||
$paginator = Paginator::generate($query);
|
||||
$d = $query
|
||||
->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_asc('id')->findArray();
|
||||
}
|
||||
}
|
||||
|
@ -40,8 +40,9 @@ switch ($action) {
|
||||
|
||||
case 'list-activated':
|
||||
$ui->assign('_system_menu', 'list-activated');
|
||||
$paginator = Paginator::build(ORM::for_table('tbl_transactions'), ['username' => $user['username']]);
|
||||
$d = ORM::for_table('tbl_transactions')->where('username', $user['username'])->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
$query = ORM::for_table('tbl_transactions')->where('username', $user['username']);
|
||||
$paginator = Paginator::generate($query);
|
||||
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
|
||||
|
||||
$ui->assign('d', $d);
|
||||
$ui->assign('paginator', $paginator);
|
||||
|
@ -46,7 +46,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{$paginator['contents']}
|
||||
{include file="pagination.tpl"}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
@ -48,7 +48,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{$paginator['contents']}
|
||||
{include file="pagination.tpl"}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -228,7 +228,7 @@
|
||||
{/if}
|
||||
</table>
|
||||
</div>
|
||||
{$paginator['contents']}
|
||||
{include file="pagination.tpl"}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
<div class="panel-body">
|
||||
<div class="md-whiteframe-z1 mb20 text-center" style="padding: 15px">
|
||||
<div class="col-md-8">
|
||||
<form id="site-search" method="post" action="{$_url}customers/list/">
|
||||
<form id="site-search" method="post" action="{$_url}customers/">
|
||||
<div class="input-group">
|
||||
<input type="text" id="search-input" name="search" value="{$search}"
|
||||
class="form-control" placeholder="{Lang::T('Search')}...">
|
||||
@ -90,7 +90,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{$paginator['contents']}
|
||||
{include file="pagination.tpl"}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -163,7 +163,7 @@
|
||||
{/foreach}
|
||||
</table>
|
||||
</div>
|
||||
{$paginator['contents']}
|
||||
{include file="pagination.tpl"}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
@ -85,7 +85,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{$paginator['contents']}
|
||||
{include file="pagination.tpl"}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
@ -53,7 +53,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{$paginator['contents']}
|
||||
{include file="pagination.tpl"}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -50,7 +50,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{$paginator['contents']}
|
||||
{include file="pagination.tpl"}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
19
ui/ui/pagination.tpl
Normal file
19
ui/ui/pagination.tpl
Normal file
@ -0,0 +1,19 @@
|
||||
{if $paginator}
|
||||
<nav aria-label="Page navigation pagination-sm">
|
||||
<ul class="pagination">
|
||||
<li {if empty($paginator['prev'])}class="disabled" {/if}>
|
||||
<a href="{$paginator['url']}{$paginator['prev']}" aria-label="Previous">
|
||||
<span aria-hidden="true">prev</span>
|
||||
</a>
|
||||
</li>
|
||||
{foreach $paginator['pages'] as $page}
|
||||
<li class="{if $paginator['page'] == $page}active{elseif $page == '...'}disabled{/if}"><a href="{$paginator['url']}{$page}">{$page}</a></li>
|
||||
{/foreach}
|
||||
<li {if $paginator['count']==$paginator['next']}class="disabled" {/if}>
|
||||
<a href="{$paginator['url']}{$paginator['next']}" aria-label="Next">
|
||||
<span aria-hidden="true">next</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
{/if}
|
@ -79,7 +79,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{$paginator['contents']}
|
||||
{include file="pagination.tpl"}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -61,7 +61,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{$paginator['contents']}
|
||||
{include file="pagination.tpl"}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -82,7 +82,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{$paginator['contents']}
|
||||
{include file="pagination.tpl"}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -64,7 +64,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{$paginator['contents']}
|
||||
{include file="pagination.tpl"}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -61,7 +61,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{$paginator['contents']}
|
||||
{include file="pagination.tpl"}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -51,7 +51,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{$paginator['contents']}
|
||||
{include file="pagination.tpl"}
|
||||
|
||||
<div class="clearfix text-right total-sum mb10">
|
||||
<h4 class="text-uppercase text-bold">{Lang::T('Total Income')}:</h4>
|
||||
|
@ -61,7 +61,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{$paginator['contents']}
|
||||
{include file="pagination.tpl"}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -34,7 +34,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{$paginator['contents']}
|
||||
{include file="pagination.tpl"}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -46,7 +46,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{$paginator['contents']}
|
||||
{include file="pagination.tpl"}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -71,7 +71,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{$paginator['contents']}
|
||||
{include file="pagination.tpl"}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"version": "2024.3.23"
|
||||
"version": "2024.3.26"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user