Change paginator, to make easy customization using pagination.tpl

This commit is contained in:
Ibnu Maksum 2024-03-26 14:39:28 +07:00
parent 36a24238ef
commit 0767c6ab23
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
35 changed files with 336 additions and 224 deletions

View File

@ -2,6 +2,15 @@
# CHANGELOG # 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 ## 2024.3.23
- Maps full height - Maps full height

View File

@ -8,22 +8,86 @@
class Paginator 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 $routes;
global $_L;
$url = U . implode('/', $routes); $url = U . implode('/', $routes);
$query = urlencode($query); $query = urlencode($query);
$adjacents = "2"; $adjacents = "2";
$page = (int)(empty(_get('p')) ? 1 : _get('p')); $page = (int)(empty(_get('p')) ? 1 : _get('p'));
$pagination = ""; $pagination = "";
foreach($colVal as $k=>$v) { foreach ($colVal as $k => $v) {
if(!is_array($v) && strpos($v,'%') === false) { if (!is_array($v) && strpos($v, '%') === false) {
$table = $table->where($k, $v); $table = $table->where($k, $v);
}else{ } else {
if(is_array($v)){ if (is_array($v)) {
$table = $table->where_in($k, $v); $table = $table->where_in($k, $v);
}else{ } else {
$table = $table->where_like($k, $v); $table = $table->where_like($k, $v);
} }
} }
@ -103,7 +167,7 @@ class Paginator
$page = (int)(!isset($routes['2']) ? 1 : $routes['2']); $page = (int)(!isset($routes['2']) ? 1 : $routes['2']);
$pagination = ""; $pagination = "";
if(is_object($table)){ if (is_object($table)) {
if ($w1 != '') { if ($w1 != '') {
$totalReq = $table->where($w1, $c1)->count(); $totalReq = $table->where($w1, $c1)->count();
} elseif ($w2 != '') { } elseif ($w2 != '') {
@ -115,7 +179,7 @@ class Paginator
} else { } else {
$totalReq = $table->count(); $totalReq = $table->count();
} }
}else{ } else {
if ($w1 != '') { if ($w1 != '') {
$totalReq = ORM::for_table($table)->where($w1, $c1)->count(); $totalReq = ORM::for_table($table)->where($w1, $c1)->count();
} elseif ($w2 != '') { } elseif ($w2 != '') {
@ -209,13 +273,13 @@ class Paginator
$adjacents = "2"; $adjacents = "2";
$page = (int)(!isset($routes['2']) ? 1 : $routes['2']); $page = (int)(!isset($routes['2']) ? 1 : $routes['2']);
$pagination = ""; $pagination = "";
if(is_object($table)){ if (is_object($table)) {
if ($w1 != '') { if ($w1 != '') {
$totalReq = $table->where_raw($w1, $c1)->count(); $totalReq = $table->where_raw($w1, $c1)->count();
} else { } else {
$totalReq = $table->count(); $totalReq = $table->count();
} }
}else{ } else {
if ($w1 != '') { if ($w1 != '') {
$totalReq = ORM::for_table($table)->where_raw($w1, $c1)->count(); $totalReq = ORM::for_table($table)->where_raw($w1, $c1)->count();
} else { } else {

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/) * PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
* by https://t.me/ibnux * by https://t.me/ibnux
@ -12,7 +13,7 @@ $action = $routes['1'];
$ui->assign('_admin', $admin); $ui->assign('_admin', $admin);
if (!in_array($admin['user_type'], ['SuperAdmin', '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) { switch ($action) {
@ -20,22 +21,24 @@ switch ($action) {
$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 run_hook('view_list_bandwidth'); #HOOK
$name = _post('name'); $name = _post('name');
if ($name != ''){ if ($name != '') {
$paginator = Paginator::build(ORM::for_table('tbl_bandwidth'), ['name_bw' => '%' . $name . '%'], $name); $query = ORM::for_table('tbl_bandwidth')->where_like('name_bw', '%' . $name . '%');
$d = ORM::for_table('tbl_bandwidth')->where_like('name_bw','%'.$name.'%')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many(); $paginator = Paginator::generate($query, ['name' => $name]);
}else{ $d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
$paginator = Paginator::build(ORM::for_table('tbl_bandwidth')); } else {
$d = ORM::for_table('tbl_bandwidth')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many(); $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('d', $d);
$ui->assign('paginator',$paginator); $ui->assign('paginator', $paginator);
$ui->display('bandwidth.tpl'); $ui->display('bandwidth.tpl');
break; break;
case 'add': case 'add':
if (!in_array($admin['user_type'], ['SuperAdmin', '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");
} }
run_hook('view_add_bandwidth'); #HOOK run_hook('view_add_bandwidth'); #HOOK
$ui->display('bandwidth-add.tpl'); $ui->display('bandwidth-add.tpl');
@ -43,28 +46,28 @@ switch ($action) {
case 'edit': case 'edit':
if (!in_array($admin['user_type'], ['SuperAdmin', '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");
} }
$id = $routes['2']; $id = $routes['2'];
run_hook('view_edit_bandwith'); #HOOK run_hook('view_edit_bandwith'); #HOOK
$d = ORM::for_table('tbl_bandwidth')->find_one($id); $d = ORM::for_table('tbl_bandwidth')->find_one($id);
if($d){ if ($d) {
$ui->assign('burst',explode(" ", $d['burst'])); $ui->assign('burst', explode(" ", $d['burst']));
$ui->assign('d',$d); $ui->assign('d', $d);
$ui->display('bandwidth-edit.tpl'); $ui->display('bandwidth-edit.tpl');
}else{ } else {
r2(U . 'bandwidth/list', 'e', $_L['Account_Not_Found']); r2(U . 'bandwidth/list', 'e', $_L['Account_Not_Found']);
} }
break; break;
case 'delete': case 'delete':
if (!in_array($admin['user_type'], ['SuperAdmin', '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");
} }
$id = $routes['2']; $id = $routes['2'];
run_hook('delete_bandwidth'); #HOOK run_hook('delete_bandwidth'); #HOOK
$d = ORM::for_table('tbl_bandwidth')->find_one($id); $d = ORM::for_table('tbl_bandwidth')->find_one($id);
if($d){ if ($d) {
$d->delete(); $d->delete();
r2(U . 'bandwidth/list', 's', Lang::T('Data Deleted Successfully')); r2(U . 'bandwidth/list', 's', Lang::T('Data Deleted Successfully'));
} }
@ -72,7 +75,7 @@ switch ($action) {
case 'add-post': case 'add-post':
if (!in_array($admin['user_type'], ['SuperAdmin', '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");
} }
$name = _post('name'); $name = _post('name');
$rate_down = _post('rate_down'); $rate_down = _post('rate_down');
@ -82,30 +85,38 @@ switch ($action) {
run_hook('add_bandwidth'); #HOOK run_hook('add_bandwidth'); #HOOK
$isBurst = true; $isBurst = true;
$burst = ""; $burst = "";
if(isset($_POST['burst'])){ if (isset($_POST['burst'])) {
foreach($_POST['burst'] as $b){ foreach ($_POST['burst'] as $b) {
if(empty($b)){ if (empty($b)) {
$isBurst = false; $isBurst = false;
} }
} }
if($isBurst){ if ($isBurst) {
$burst = implode(' ', $_POST['burst']); $burst = implode(' ', $_POST['burst']);
}; };
} }
$msg = ''; $msg = '';
if(Validator::Length($name,16,4) == false){ if (Validator::Length($name, 16, 4) == false) {
$msg .= 'Name should be between 5 to 15 characters'. '<br>'; $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_down_unit == 'Kbps') {
if($rate_up_unit == 'Kbps'){ $unit_rate_up = $min_up * 1024; }else{ $unit_rate_up = $min_up * 1048576; } $unit_rate_down = $rate_down * 1024;
} else {
$d = ORM::for_table('tbl_bandwidth')->where('name_bw',$name)->find_one(); $unit_rate_down = $rate_down * 1048576;
if($d){ }
$msg .= Lang::T('Name Bandwidth Already Exist'). '<br>'; 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 = ORM::for_table('tbl_bandwidth')->create();
$d->name_bw = $name; $d->name_bw = $name;
$d->rate_down = $rate_down; $d->rate_down = $rate_down;
@ -116,14 +127,14 @@ switch ($action) {
$d->save(); $d->save();
r2(U . 'bandwidth/list', 's', Lang::T('Data Created Successfully')); r2(U . 'bandwidth/list', 's', Lang::T('Data Created Successfully'));
}else{ } else {
r2(U . 'bandwidth/add', 'e', $msg); r2(U . 'bandwidth/add', 'e', $msg);
} }
break; break;
case 'edit-post': case 'edit-post':
if (!in_array($admin['user_type'], ['SuperAdmin', '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");
} }
$name = _post('name'); $name = _post('name');
$rate_down = _post('rate_down'); $rate_down = _post('rate_down');
@ -133,36 +144,36 @@ switch ($action) {
run_hook('edit_bandwidth'); #HOOK run_hook('edit_bandwidth'); #HOOK
$isBurst = true; $isBurst = true;
$burst = ""; $burst = "";
if(isset($_POST['burst'])){ if (isset($_POST['burst'])) {
foreach($_POST['burst'] as $b){ foreach ($_POST['burst'] as $b) {
if(empty($b)){ if (empty($b)) {
$isBurst = false; $isBurst = false;
} }
} }
if($isBurst){ if ($isBurst) {
$burst = implode(' ', $_POST['burst']); $burst = implode(' ', $_POST['burst']);
}; };
} }
$msg = ''; $msg = '';
if(Validator::Length($name,16,4) == false){ if (Validator::Length($name, 16, 4) == false) {
$msg .= 'Name should be between 5 to 15 characters'. '<br>'; $msg .= 'Name should be between 5 to 15 characters' . '<br>';
} }
$id = _post('id'); $id = _post('id');
$d = ORM::for_table('tbl_bandwidth')->find_one($id); $d = ORM::for_table('tbl_bandwidth')->find_one($id);
if($d){ if ($d) {
}else{ } else {
$msg .= Lang::T('Data Not Found'). '<br>'; $msg .= Lang::T('Data Not Found') . '<br>';
} }
if($d['name_bw'] != $name){ if ($d['name_bw'] != $name) {
$c = ORM::for_table('tbl_bandwidth')->where('name_bw',$name)->find_one(); $c = ORM::for_table('tbl_bandwidth')->where('name_bw', $name)->find_one();
if($c){ if ($c) {
$msg .= Lang::T('Name Bandwidth Already Exist'). '<br>'; $msg .= Lang::T('Name Bandwidth Already Exist') . '<br>';
} }
} }
if($msg == ''){ if ($msg == '') {
$d->name_bw = $name; $d->name_bw = $name;
$d->rate_down = $rate_down; $d->rate_down = $rate_down;
$d->rate_down_unit = $rate_down_unit; $d->rate_down_unit = $rate_down_unit;
@ -172,8 +183,8 @@ switch ($action) {
$d->save(); $d->save();
r2(U . 'bandwidth/list', 's', Lang::T('Data Updated Successfully')); r2(U . 'bandwidth/list', 's', Lang::T('Data Updated Successfully'));
}else{ } else {
r2(U . 'bandwidth/edit/'.$id, 'e', $msg); r2(U . 'bandwidth/edit/' . $id, 'e', $msg);
} }
break; break;

View File

@ -12,7 +12,7 @@ $ui->assign('_system_menu', 'customers');
$action = $routes['1']; $action = $routes['1'];
$ui->assign('_admin', $admin); $ui->assign('_admin', $admin);
if (empty ($action)) { if (empty($action)) {
$action = 'list'; $action = 'list';
} }
@ -21,35 +21,6 @@ $leafletpickerHeader = <<<EOT
EOT; EOT;
switch ($action) { 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': case 'csv':
if (!in_array($admin['user_type'], ['SuperAdmin', '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");
@ -216,14 +187,14 @@ switch ($action) {
->where('customer_id', $customer['id']) ->where('customer_id', $customer['id'])
->find_many(); ->find_many();
$v = $routes['3']; $v = $routes['3'];
if (empty ($v)) { if (empty($v)) {
$v = 'activation'; $v = 'activation';
} }
if ($v == 'order') { if ($v == 'order') {
$v = 'order'; $v = 'order';
$paginator = Paginator::build(ORM::for_table('tbl_payment_gateway'), ['username' => $customer['username']]); $query = ORM::for_table('tbl_transactions')->where('username', $customer['username']);
$order = ORM::for_table('tbl_payment_gateway') $paginator = Paginator::generate($query);
->where('username', $customer['username']) $order = $query
->offset($paginator['startpoint']) ->offset($paginator['startpoint'])
->limit($paginator['limit']) ->limit($paginator['limit'])
->order_by_desc('id') ->order_by_desc('id')
@ -231,10 +202,9 @@ switch ($action) {
$ui->assign('paginator', $paginator); $ui->assign('paginator', $paginator);
$ui->assign('order', $order); $ui->assign('order', $order);
} else if ($v == 'activation') { } else if ($v == 'activation') {
$paginator = Paginator::build(ORM::for_table('tbl_transactions'), ['username' => $customer['username']]); $query = ORM::for_table('tbl_transactions')->where('username', $customer['username']);
$activation = ORM::for_table('tbl_transactions') $paginator = Paginator::generate($query);
->where('username', $customer['username']) $activation = $query->offset($paginator['startpoint'])
->offset($paginator['startpoint'])
->limit($paginator['limit']) ->limit($paginator['limit'])
->order_by_desc('id') ->order_by_desc('id')
->find_many(); ->find_many();
@ -376,13 +346,13 @@ switch ($action) {
// Retrieve the customer ID of the newly created customer // Retrieve the customer ID of the newly created customer
$customerId = $d->id(); $customerId = $d->id();
// Save Customers Attributes details // 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)); $totalFields = min(count($custom_field_names), count($custom_field_values));
for ($i = 0; $i < $totalFields; $i++) { for ($i = 0; $i < $totalFields; $i++) {
$name = $custom_field_names[$i]; $name = $custom_field_names[$i];
$value = $custom_field_values[$i]; $value = $custom_field_values[$i];
if (!empty ($name)) { if (!empty($name)) {
$customField = ORM::for_table('tbl_customers_fields')->create(); $customField = ORM::for_table('tbl_customers_fields')->create();
$customField->customer_id = $customerId; $customField->customer_id = $customerId;
$customField->field_name = $name; $customField->field_name = $name;
@ -475,7 +445,7 @@ switch ($action) {
// Update Customers Attributes values in tbl_customers_fields table // Update Customers Attributes values in tbl_customers_fields table
foreach ($customFields as $customField) { foreach ($customFields as $customField) {
$fieldName = $customField['field_name']; $fieldName = $customField['field_name'];
if (isset ($_POST['custom_fields'][$fieldName])) { if (isset($_POST['custom_fields'][$fieldName])) {
$customFieldValue = $_POST['custom_fields'][$fieldName]; $customFieldValue = $_POST['custom_fields'][$fieldName];
$customField->set('field_value', $customFieldValue); $customField->set('field_value', $customFieldValue);
$customField->save(); $customField->save();
@ -483,7 +453,7 @@ switch ($action) {
} }
// Add new Customers Attributess // 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']; $newCustomFieldNames = $_POST['custom_field_name'];
$newCustomFieldValues = $_POST['custom_field_value']; $newCustomFieldValues = $_POST['custom_field_value'];
@ -506,7 +476,7 @@ switch ($action) {
} }
// Delete Customers Attributess // Delete Customers Attributess
if (isset ($_POST['delete_custom_fields'])) { if (isset($_POST['delete_custom_fields'])) {
$fieldsToDelete = $_POST['delete_custom_fields']; $fieldsToDelete = $_POST['delete_custom_fields'];
foreach ($fieldsToDelete as $fieldName) { foreach ($fieldsToDelete as $fieldName) {
// Delete the Customers Attributes with the given field name // Delete the Customers Attributes with the given field name
@ -536,7 +506,7 @@ switch ($action) {
Mikrotik::removeHotspotActiveUser($client, $d['username']); Mikrotik::removeHotspotActiveUser($client, $d['username']);
} else { } else {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $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']); Mikrotik::setPpoeUser($client, $c['username'], $d['pppoe_password']);
} else { } else {
Mikrotik::setPpoeUser($client, $c['username'], $password); Mikrotik::setPpoeUser($client, $c['username'], $password);
@ -553,5 +523,25 @@ switch ($action) {
break; break;
default: 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;
} }

View File

@ -54,9 +54,10 @@ $ui->assign('c_all', $c_all);
if ($config['hide_uet'] != 'yes') { if ($config['hide_uet'] != 'yes') {
//user expire //user expire
$paginator = Paginator::build(ORM::for_table('tbl_user_recharges')); $query = ORM::for_table('tbl_user_recharges')
$expire = ORM::for_table('tbl_user_recharges') ->where_lte('expiration', $mdate);
->where_lte('expiration', $mdate) $paginator = Paginator::generate($query);
$expire = $query
->offset($paginator['startpoint']) ->offset($paginator['startpoint'])
->limit($paginator['limit']) ->limit($paginator['limit'])
->order_by_desc('expiration') ->order_by_desc('expiration')

View File

@ -26,11 +26,13 @@ switch ($action) {
r2(U . "logs/list/", 's', "Delete logs older than $keep days"); r2(U . "logs/list/", 's', "Delete logs older than $keep days");
} }
if ($q != '') { if ($q != '') {
$paginator = Paginator::build(ORM::for_table('tbl_logs'), ['description' => '%' . $q . '%'], $q); $query = ORM::for_table('tbl_logs')->where_like('description', '%' . $q . '%');
$d = ORM::for_table('tbl_logs')->where_like('description', '%' . $q . '%')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many(); $paginator = Paginator::generate($query, ['q' => $q]);
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
} else { } else {
$paginator = Paginator::build(ORM::for_table('tbl_logs')); $query = ORM::for_table('tbl_logs');
$d = ORM::for_table('tbl_logs')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many(); $paginator = Paginator::generate($query);
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
} }
$ui->assign('d', $d); $ui->assign('d', $d);
@ -46,11 +48,13 @@ switch ($action) {
r2(U . "logs/radius/", 's', "Delete logs older than $keep days"); r2(U . "logs/radius/", 's', "Delete logs older than $keep days");
} }
if ($q != '') { if ($q != '') {
$paginator = Paginator::build(ORM::for_table('radpostauth', 'radius'), ['username' => '%' . $q . '%'], $q); $query = ORM::for_table('radpostauth', 'radius')->where_like('username', '%' . $q . '%');
$d = ORM::for_table('radpostauth', 'radius')->where_like('username', '%' . $q . '%')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many(); $paginator = Paginator::generate($query, ['q' => $q]);
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
} else { } else {
$paginator = Paginator::build(ORM::for_table('radpostauth', 'radius')); $query = ORM::for_table('radpostauth', 'radius');
$d = ORM::for_table('radpostauth', 'radius')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many(); $paginator = Paginator::generate($query);
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
} }
$ui->assign('d', $d); $ui->assign('d', $d);

View File

@ -19,9 +19,9 @@ switch ($action) {
break; break;
case 'history': case 'history':
$ui->assign('_system_menu', 'history'); $ui->assign('_system_menu', 'history');
$paginator = Paginator::build(ORM::for_table('tbl_payment_gateway'), ['username' => $user['username']]); $query = ORM::for_table('tbl_payment_gateway')->where('username', $user['username']);
$d = ORM::for_table('tbl_payment_gateway') $paginator = Paginator::generate($query);
->where('username', $user['username']) $d = $query
->order_by_desc('id') ->order_by_desc('id')
->offset($paginator['startpoint'])->limit($paginator['limit']) ->offset($paginator['startpoint'])->limit($paginator['limit'])
->find_many(); ->find_many();

View File

@ -68,11 +68,13 @@ switch ($action) {
$ui->assign('_title', Lang::T('Customer')); $ui->assign('_title', Lang::T('Customer'));
$search = _post('search'); $search = _post('search');
if ($search != '') { if ($search != '') {
$paginator = Paginator::build(ORM::for_table('tbl_user_recharges'), ['username' => '%' . $search . '%'], $search); $query = ORM::for_table('tbl_user_recharges')->where_like('username', '%' . $search . '%');
$d = ORM::for_table('tbl_user_recharges')->where_like('username', '%' . $search . '%')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many(); $paginator = Paginator::generate($query, ['search' => $search]);
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
} else { } else {
$paginator = Paginator::build(ORM::for_table('tbl_user_recharges')); $query = 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(); $paginator = Paginator::generate($query);
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_array();
} }
run_hook('view_list_billing'); #HOOK run_hook('view_list_billing'); #HOOK
if ($isApi) { if ($isApi) {

View File

@ -23,11 +23,13 @@ switch ($action) {
$name = _post('name'); $name = _post('name');
if ($name != '') { if ($name != '') {
$paginator = Paginator::build(ORM::for_table('tbl_pool'), ['pool_name' => '%' . $name . '%'], $name); $query = ORM::for_table('tbl_pool')->where_like('pool_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(); $paginator = Paginator::generate($query, ['name' => $name]);
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
} else { } else {
$paginator = Paginator::build(ORM::for_table('tbl_pool')); $query = ORM::for_table('tbl_pool');
$d = ORM::for_table('tbl_pool')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many(); $paginator = Paginator::generate($query);
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
} }
$ui->assign('d', $d); $ui->assign('d', $d);

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/) * PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
* by https://t.me/ibnux * by https://t.me/ibnux
@ -12,7 +13,7 @@ $ui->assign('_admin', $admin);
if (!in_array($admin['user_type'], ['SuperAdmin', '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) { switch ($action) {
@ -134,18 +135,16 @@ switch ($action) {
$ui->assign('_title', "Network Access Server"); $ui->assign('_title', "Network Access Server");
$name = _post('name'); $name = _post('name');
if (empty($name)) { if (empty($name)) {
$paginator = Paginator::build(ORM::for_table('nas', 'radius')); $query = ORM::for_table('nas', 'radius');
$nas = ORM::for_table('nas', 'radius')->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many(); $paginator = Paginator::generate($query);
$nas = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
} else { } else {
$paginator = Paginator::build(ORM::for_table('nas', 'radius'), [ $query = ORM::for_table('nas', 'radius')
'nasname' => '%'.$search.'%',
'shortname' => '%'.$search.'%',
'description' => '%'.$search.'%'
]);
$nas = ORM::for_table('nas', 'radius')
->where_like('nasname', $search) ->where_like('nasname', $search)
->where_like('shortname', $search) ->where_like('shortname', $search)
->where_like('description', $search) ->where_like('description', $search);
$paginator = Paginator::generate($query, ['name' => $name]);
$nas = $query
->offset($paginator['startpoint'])->limit($paginator['limit']) ->offset($paginator['startpoint'])->limit($paginator['limit'])
->find_many(); ->find_many();
} }

View File

@ -30,11 +30,13 @@ switch ($action) {
r2(U . "logs/list/", 's', "Delete logs older than $keep days"); r2(U . "logs/list/", 's', "Delete logs older than $keep days");
} }
if ($q != '') { if ($q != '') {
$paginator = Paginator::build(ORM::for_table('tbl_transactions'), ['invoice' => '%' . $q . '%'], $q); $query = ORM::for_table('tbl_transactions')->where_like('invoice', '%' . $q . '%');
$d = ORM::for_table('tbl_transactions')->where_like('invoice', '%' . $q . '%')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many(); $paginator = Paginator::generate($query, ['q' => $q]);
$d = $where->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
} else { } else {
$paginator = Paginator::build(ORM::for_table('tbl_transactions')); $query = ORM::for_table('tbl_transactions');
$d = ORM::for_table('tbl_transactions')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many(); $paginator = Paginator::generate($query);
$d = $where->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
} }
$ui->assign('activation', $d); $ui->assign('activation', $d);
@ -43,9 +45,10 @@ switch ($action) {
$ui->display('reports-activation.tpl'); $ui->display('reports-activation.tpl');
break; break;
case 'daily-report': case 'daily-report':
$paginator = Paginator::build(ORM::for_table('tbl_transactions'), ['recharged_on' => $mdate]); $query = ORM::for_table('tbl_transactions')->where('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(); $paginator = Paginator::generate($query);
$dr = ORM::for_table('tbl_transactions')->where('recharged_on', $mdate)->sum('price'); $d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
$dr = $query->sum('price');
$ui->assign('d', $d); $ui->assign('d', $d);
$ui->assign('dr', $dr); $ui->assign('dr', $dr);

View File

@ -17,7 +17,7 @@ use PEAR2\Net\RouterOS;
require_once 'system/autoload/PEAR2/Autoload.php'; require_once 'system/autoload/PEAR2/Autoload.php';
if (!in_array($admin['user_type'], ['SuperAdmin', '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) { switch ($action) {
@ -26,11 +26,13 @@ switch ($action) {
$name = _post('name'); $name = _post('name');
if ($name != '') { if ($name != '') {
$paginator = Paginator::build(ORM::for_table('tbl_routers'), ['name' => '%' . $name . '%'], $name); $query = ORM::for_table('tbl_routers')->where_like('name', '%' . $name . '%');
$d = ORM::for_table('tbl_routers')->where_like('name', '%' . $name . '%')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many(); $paginator = Paginator::generate($query, ['name' => $name]);
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
} else { } else {
$paginator = Paginator::build(ORM::for_table('tbl_routers')); $query = ORM::for_table('tbl_routers');
$d = ORM::for_table('tbl_routers')->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many(); $paginator = Paginator::generate($query);
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
} }
$ui->assign('d', $d); $ui->assign('d', $d);

View File

@ -119,11 +119,13 @@ switch ($action) {
$name = _post('name'); $name = _post('name');
if ($name != '') { if ($name != '') {
$paginator = Paginator::build(ORM::for_table('tbl_plans'), ['name_plan' => '%' . $name . '%', 'type' => 'Hotspot'], $name); $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 . '%');
$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(); $paginator = Paginator::generate($query, ['name'=> $name]);
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
} else { } else {
$paginator = Paginator::build(ORM::for_table('tbl_plans'), ['type' => 'Hotspot']); $query = ORM::for_table('tbl_bandwidth')->join('tbl_plans', array('tbl_bandwidth.id', '=', 'tbl_plans.id_bw'))->where('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(); $paginator = Paginator::generate($query);
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
} }
$ui->assign('d', $d); $ui->assign('d', $d);
@ -393,11 +395,13 @@ switch ($action) {
$name = _post('name'); $name = _post('name');
if ($name != '') { if ($name != '') {
$paginator = Paginator::build(ORM::for_table('tbl_plans'), ['name_plan' => '%' . $name . '%', 'type' => 'PPPOE'], $name); $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 . '%');
$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(); $paginator = Paginator::generate($query, ['name' => $name]);
$d =$query->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
} else { } else {
$paginator = Paginator::build(ORM::for_table('tbl_plans'), ['type' => 'PPPOE'], $name); $query = ORM::for_table('tbl_bandwidth')->join('tbl_plans', array('tbl_bandwidth.id', '=', 'tbl_plans.id_bw'))->where('tbl_plans.type', 'PPPOE');
$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(); $paginator = Paginator::generate($query);
$d =$query->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
} }
$ui->assign('d', $d); $ui->assign('d', $d);
@ -646,11 +650,13 @@ switch ($action) {
$ui->assign('_title', Lang::T('Balance Plans')); $ui->assign('_title', Lang::T('Balance Plans'));
$name = _post('name'); $name = _post('name');
if ($name != '') { if ($name != '') {
$paginator = Paginator::build(ORM::for_table('tbl_plans'), ['name_plan' => '%' . $name . '%', 'type' => 'Balance'], $name); $query = ORM::for_table('tbl_plans')->where('tbl_plans.type', 'Balance')->where_like('tbl_plans.name_plan', '%' . $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(); $paginator = Paginator::generate($query, ['name' => $name]);
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
} else { } else {
$paginator = Paginator::build(ORM::for_table('tbl_plans'), ['type' => 'Balance'], $name); $query = ORM::for_table('tbl_plans')->where('tbl_plans.type', 'Balance');
$d = ORM::for_table('tbl_plans')->where('tbl_plans.type', 'Balance')->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many(); $paginator = Paginator::generate($query);
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
} }
$ui->assign('d', $d); $ui->assign('d', $d);

View File

@ -30,7 +30,7 @@ switch ($action) {
r2(U . "settings/app", 's', 'Test Telegram has been send<br>Result: ' . $result); 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')) { if (file_exists($UPLOAD_PATH . DIRECTORY_SEPARATOR . 'logo.png')) {
$logo = $UPLOAD_URL_PATH . DIRECTORY_SEPARATOR . 'logo.png?' . time(); $logo = $UPLOAD_URL_PATH . DIRECTORY_SEPARATOR . 'logo.png?' . time();
} else { } else {
@ -276,59 +276,58 @@ switch ($action) {
$search = _req('search'); $search = _req('search');
if ($search != '') { if ($search != '') {
if ($admin['user_type'] == 'SuperAdmin') { if ($admin['user_type'] == 'SuperAdmin') {
$paginator = Paginator::build(ORM::for_table('tbl_users'), ['username' => '%' . $search . '%'], $search); $query = ORM::for_table('tbl_users')
$d = ORM::for_table('tbl_users') ->where_like('username', '%' . $search . '%');
->where_like('username', '%' . $search . '%') $paginator = Paginator::generate($query, ['search' => $search]);
$d = $query
->offset($paginator['startpoint']) ->offset($paginator['startpoint'])
->limit($paginator['limit'])->order_by_asc('id')->findArray(); ->limit($paginator['limit'])->order_by_asc('id')->findArray();
} else if ($admin['user_type'] == 'Admin') { } else if ($admin['user_type'] == 'Admin') {
$paginator = Paginator::build(ORM::for_table('tbl_users'), [ $query = ORM::for_table('tbl_users')
'username' => '%' . $search . '%', ->where_like('username', '%' . $search . '%')->where_any_is([
['user_type' => 'Report'], ['user_type' => 'Report'],
['user_type' => 'Agent'], ['user_type' => 'Agent'],
['user_type' => 'Sales'], ['user_type' => 'Sales'],
['id' => $admin['id']] ['id' => $admin['id']]
], $search); ]);
$d = ORM::for_table('tbl_users') $paginator = Paginator::generate($query, ['search' => $search]);
->where_like('username', '%' . $search . '%') $d = $query
->where_any_is([
['user_type' => 'Report'],
['user_type' => 'Agent'],
['user_type' => 'Sales'],
['id' => $admin['id']]
])
->offset($paginator['startpoint']) ->offset($paginator['startpoint'])
->limit($paginator['limit'])->order_by_asc('id')->findArray(); ->limit($paginator['limit'])->order_by_asc('id')->findArray();
} else { } else {
$paginator = Paginator::build(ORM::for_table('tbl_users'), ['username' => '%' . $search . '%'], $search); $query = ORM::for_table('tbl_users')
$d = ORM::for_table('tbl_users')
->where_like('username', '%' . $search . '%') ->where_like('username', '%' . $search . '%')
->where_any_is([ ->where_any_is([
['id' => $admin['id']], ['id' => $admin['id']],
['root' => $admin['id']] ['root' => $admin['id']]
]) ]);
$paginator = Paginator::generate($query, ['search' => $search]);
$d = $query
->offset($paginator['startpoint']) ->offset($paginator['startpoint'])
->limit($paginator['limit'])->order_by_asc('id')->findArray(); ->limit($paginator['limit'])->order_by_asc('id')->findArray();
} }
} else { } else {
if ($admin['user_type'] == 'SuperAdmin') { if ($admin['user_type'] == 'SuperAdmin') {
$paginator = Paginator::build(ORM::for_table('tbl_users')); $query = ORM::for_table('tbl_users');
$d = ORM::for_table('tbl_users')->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 if ($admin['user_type'] == 'Admin') { } else if ($admin['user_type'] == 'Admin') {
$paginator = Paginator::build(ORM::for_table('tbl_users')); $query = ORM::for_table('tbl_users')->where_any_is([
$d = ORM::for_table('tbl_users')->where_any_is([
['user_type' => 'Report'], ['user_type' => 'Report'],
['user_type' => 'Agent'], ['user_type' => 'Agent'],
['user_type' => 'Sales'], ['user_type' => 'Sales'],
['id' => $admin['id']] ['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 { } else {
$paginator = Paginator::build(ORM::for_table('tbl_users')); $query = ORM::for_table('tbl_users')
$d = ORM::for_table('tbl_users')
->where_any_is([ ->where_any_is([
['id' => $admin['id']], ['id' => $admin['id']],
['root' => $admin['id']] ['root' => $admin['id']]
]) ]);
$paginator = Paginator::generate($query);
$d = $query
->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_asc('id')->findArray(); ->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_asc('id')->findArray();
} }
} }

View File

@ -40,8 +40,9 @@ switch ($action) {
case 'list-activated': case 'list-activated':
$ui->assign('_system_menu', 'list-activated'); $ui->assign('_system_menu', 'list-activated');
$paginator = Paginator::build(ORM::for_table('tbl_transactions'), ['username' => $user['username']]); $query = ORM::for_table('tbl_transactions')->where('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(); $paginator = Paginator::generate($query);
$d = $query->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
$ui->assign('d', $d); $ui->assign('d', $d);
$ui->assign('paginator', $paginator); $ui->assign('paginator', $paginator);

View File

@ -46,7 +46,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
{$paginator['contents']} {include file="pagination.tpl"}
</div> </div>
</div> </div>

View File

@ -48,7 +48,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
{$paginator['contents']} {include file="pagination.tpl"}
</div> </div>
</div> </div>
</div> </div>

View File

@ -228,7 +228,7 @@
{/if} {/if}
</table> </table>
</div> </div>
{$paginator['contents']} {include file="pagination.tpl"}
</div> </div>
</div> </div>

View File

@ -16,7 +16,7 @@
<div class="panel-body"> <div class="panel-body">
<div class="md-whiteframe-z1 mb20 text-center" style="padding: 15px"> <div class="md-whiteframe-z1 mb20 text-center" style="padding: 15px">
<div class="col-md-8"> <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"> <div class="input-group">
<input type="text" id="search-input" name="search" value="{$search}" <input type="text" id="search-input" name="search" value="{$search}"
class="form-control" placeholder="{Lang::T('Search')}..."> class="form-control" placeholder="{Lang::T('Search')}...">
@ -90,7 +90,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
{$paginator['contents']} {include file="pagination.tpl"}
</div> </div>
</div> </div>
</div> </div>

View File

@ -163,7 +163,7 @@
{/foreach} {/foreach}
</table> </table>
</div> </div>
&nbsp; {$paginator['contents']} &nbsp; {include file="pagination.tpl"}
</div> </div>
{/if} {/if}
</div> </div>

View File

@ -85,7 +85,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
{$paginator['contents']} {include file="pagination.tpl"}
</div> </div>
</div> </div>

View File

@ -53,7 +53,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
{$paginator['contents']} {include file="pagination.tpl"}
</div> </div>
</div> </div>
</div> </div>

View File

@ -50,7 +50,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
{$paginator['contents']} {include file="pagination.tpl"}
</div> </div>
</div> </div>
</div> </div>

19
ui/ui/pagination.tpl Normal file
View 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}

View File

@ -79,7 +79,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
{$paginator['contents']} {include file="pagination.tpl"}
</div> </div>
</div> </div>
</div> </div>

View File

@ -61,7 +61,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
{$paginator['contents']} {include file="pagination.tpl"}
</div> </div>
</div> </div>
</div> </div>

View File

@ -82,7 +82,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
{$paginator['contents']} {include file="pagination.tpl"}
</div> </div>
</div> </div>
</div> </div>

View File

@ -64,7 +64,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
{$paginator['contents']} {include file="pagination.tpl"}
</div> </div>
</div> </div>
</div> </div>

View File

@ -61,7 +61,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
{$paginator['contents']} {include file="pagination.tpl"}
</div> </div>
</div> </div>
</div> </div>

View File

@ -51,7 +51,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
{$paginator['contents']} {include file="pagination.tpl"}
<div class="clearfix text-right total-sum mb10"> <div class="clearfix text-right total-sum mb10">
<h4 class="text-uppercase text-bold">{Lang::T('Total Income')}:</h4> <h4 class="text-uppercase text-bold">{Lang::T('Total Income')}:</h4>

View File

@ -61,7 +61,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
{$paginator['contents']} {include file="pagination.tpl"}
</div> </div>
</div> </div>
</div> </div>

View File

@ -34,7 +34,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
{$paginator['contents']} {include file="pagination.tpl"}
</div> </div>
</div> </div>
</div> </div>

View File

@ -46,7 +46,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
{$paginator['contents']} {include file="pagination.tpl"}
</div> </div>
</div> </div>
</div> </div>

View File

@ -71,7 +71,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
{$paginator['contents']} {include file="pagination.tpl"}
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,3 +1,3 @@
{ {
"version": "2024.3.23" "version": "2024.3.26"
} }