update admins and customers page
This commit is contained in:
@@ -34,6 +34,17 @@ if ($page == 'admins' && $userinfo['change_serversettings'] == '1') {
|
|||||||
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_admins");
|
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_admins");
|
||||||
$admin_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/admin/tablelisting.admin.php';
|
$admin_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/admin/tablelisting.admin.php';
|
||||||
|
|
||||||
|
/*
|
||||||
|
$fields = array(
|
||||||
|
'loginname' => $lng['login']['username'],
|
||||||
|
'name' => $lng['customer']['name'],
|
||||||
|
'diskspace' => $lng['customer']['diskspace'],
|
||||||
|
'diskspace_used' => $lng['customer']['diskspace'] . ' (' . $lng['panel']['used'] . ')',
|
||||||
|
'traffic' => $lng['customer']['traffic'],
|
||||||
|
'traffic_used' => $lng['customer']['traffic'] . ' (' . $lng['panel']['used'] . ')',
|
||||||
|
'deactivated' => $lng['admin']['deactivated']
|
||||||
|
);
|
||||||
|
*/
|
||||||
try {
|
try {
|
||||||
// get total count
|
// get total count
|
||||||
$json_result = Admins::getLocal($userinfo)->listingCount();
|
$json_result = Admins::getLocal($userinfo)->listingCount();
|
||||||
@@ -45,6 +56,63 @@ if ($page == 'admins' && $userinfo['change_serversettings'] == '1') {
|
|||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
$result = json_decode($json_result, true)['data'];
|
||||||
|
|
||||||
|
$admins = '';
|
||||||
|
$sortcode = $paging->getHtmlSortCode($lng, true);
|
||||||
|
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
|
||||||
|
$searchcode = $paging->getHtmlSearchCode($lng);
|
||||||
|
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
|
||||||
|
$count = 0;
|
||||||
|
|
||||||
|
$dec_places = Settings::Get('panel.decimal_places');
|
||||||
|
|
||||||
|
foreach ($result['list'] as $row) {
|
||||||
|
|
||||||
|
$row['traffic_used'] = round($row['traffic_used'] / (1024 * 1024), $dec_places);
|
||||||
|
$row['traffic'] = round($row['traffic'] / (1024 * 1024), $dec_places);
|
||||||
|
$row['diskspace_used'] = round($row['diskspace_used'] / 1024, $dec_places);
|
||||||
|
$row['diskspace'] = round($row['diskspace'] / 1024, $dec_places);
|
||||||
|
|
||||||
|
// percent-values for progressbar
|
||||||
|
// For Disk usage
|
||||||
|
if ($row['diskspace'] > 0) {
|
||||||
|
$disk_percent = round(($row['diskspace_used'] * 100) / $row['diskspace'], 0);
|
||||||
|
$disk_doublepercent = round($disk_percent * 2, 2);
|
||||||
|
} else {
|
||||||
|
$disk_percent = 0;
|
||||||
|
$disk_doublepercent = 0;
|
||||||
|
}
|
||||||
|
// For Traffic usage
|
||||||
|
if ($row['traffic'] > 0) {
|
||||||
|
$traffic_percent = round(($row['traffic_used'] * 100) / $row['traffic'], 0);
|
||||||
|
$traffic_doublepercent = round($traffic_percent * 2, 2);
|
||||||
|
} else {
|
||||||
|
$traffic_percent = 0;
|
||||||
|
$traffic_doublepercent = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// fix progress-bars if value is >100%
|
||||||
|
if ($disk_percent > 100) {
|
||||||
|
$disk_percent = 100;
|
||||||
|
}
|
||||||
|
if ($traffic_percent > 100) {
|
||||||
|
$traffic_percent = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
$row = \Froxlor\PhpHelper::strReplaceArray('-1', 'UL', $row, 'customers domains diskspace traffic mysqls emails email_accounts email_forwarders email_quota ftps subdomains');
|
||||||
|
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
||||||
|
|
||||||
|
$row['custom_notes'] = ($row['custom_notes'] != '') ? nl2br($row['custom_notes']) : '';
|
||||||
|
|
||||||
|
eval("\$admins.=\"" . \Froxlor\UI\Template::getTemplate("admins/admins_admin") . "\";");
|
||||||
|
$count ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$admincount = $result['count'] . " / " . $paging->getEntries();
|
||||||
|
eval("echo \"" . \Froxlor\UI\Template::getTemplate("admins/admins") . "\";");
|
||||||
|
*/
|
||||||
|
|
||||||
UI::twigBuffer('user/table.html.twig', [
|
UI::twigBuffer('user/table.html.twig', [
|
||||||
'api_response' => json_decode($json_result, true)['data'],
|
'api_response' => json_decode($json_result, true)['data'],
|
||||||
|
|||||||
@@ -31,7 +31,9 @@ $id = (int) Request::get('id');
|
|||||||
if ($page == 'customers' && $userinfo['customers'] != '0') {
|
if ($page == 'customers' && $userinfo['customers'] != '0') {
|
||||||
if ($action == '') {
|
if ($action == '') {
|
||||||
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_customers");
|
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_customers");
|
||||||
|
$customer_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/admin/tablelisting.customer.php';
|
||||||
|
|
||||||
|
/*
|
||||||
$fields = array(
|
$fields = array(
|
||||||
'c.loginname' => $lng['login']['username'],
|
'c.loginname' => $lng['login']['username'],
|
||||||
'a.loginname' => $lng['admin']['admin'],
|
'a.loginname' => $lng['admin']['admin'],
|
||||||
@@ -44,17 +46,22 @@ if ($page == 'customers' && $userinfo['customers'] != '0') {
|
|||||||
'c.traffic' => $lng['customer']['traffic'],
|
'c.traffic' => $lng['customer']['traffic'],
|
||||||
'c.traffic_used' => $lng['customer']['traffic'] . ' (' . $lng['panel']['used'] . ')'
|
'c.traffic_used' => $lng['customer']['traffic'] . ' (' . $lng['panel']['used'] . ')'
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
try {
|
try {
|
||||||
// get total count
|
// get total count
|
||||||
$json_result = Customers::getLocal($userinfo)->listingCount();
|
$json_result = Customers::getLocal($userinfo)->listingCount();
|
||||||
$result = json_decode($json_result, true)['data'];
|
$result = json_decode($json_result, true)['data'];
|
||||||
// initialize pagination and filtering
|
// initialize pagination and filtering
|
||||||
|
/*
|
||||||
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
|
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
|
||||||
|
*/
|
||||||
|
$paging = new \Froxlor\UI\Pagination($userinfo, $customer_list_data['customer_list']['columns'], $result);
|
||||||
// get list
|
// get list
|
||||||
$json_result = Customers::getLocal($userinfo, $paging->getApiCommandParams())->listing();
|
$json_result = Customers::getLocal($userinfo, $paging->getApiCommandParams())->listing();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
$result = json_decode($json_result, true)['data'];
|
$result = json_decode($json_result, true)['data'];
|
||||||
|
|
||||||
$customers = '';
|
$customers = '';
|
||||||
@@ -106,9 +113,7 @@ if ($page == 'customers' && $userinfo['customers'] != '0') {
|
|||||||
$row['diskspace'] = round($row['diskspace'] / 1024, $dec_places);
|
$row['diskspace'] = round($row['diskspace'] / 1024, $dec_places);
|
||||||
$last_login = ((int) $row['lastlogin_succ'] == 0) ? $lng['panel']['neverloggedin'] : date('d.m.Y', $row['lastlogin_succ']);
|
$last_login = ((int) $row['lastlogin_succ'] == 0) ? $lng['panel']['neverloggedin'] : date('d.m.Y', $row['lastlogin_succ']);
|
||||||
|
|
||||||
/**
|
// percent-values for progressbar
|
||||||
* percent-values for progressbar
|
|
||||||
*/
|
|
||||||
if ($row['diskspace'] > 0) {
|
if ($row['diskspace'] > 0) {
|
||||||
$disk_percent = round(($row['diskspace_used'] * 100) / $row['diskspace'], 0);
|
$disk_percent = round(($row['diskspace_used'] * 100) / $row['diskspace'], 0);
|
||||||
$disk_doublepercent = round($disk_percent * 2, 2);
|
$disk_doublepercent = round($disk_percent * 2, 2);
|
||||||
@@ -148,6 +153,13 @@ if ($page == 'customers' && $userinfo['customers'] != '0') {
|
|||||||
|
|
||||||
$customercount = $result['count'] . " / " . $paging->getEntries();
|
$customercount = $result['count'] . " / " . $paging->getEntries();
|
||||||
eval("echo \"" . \Froxlor\UI\Template::getTemplate("customers/customers") . "\";");
|
eval("echo \"" . \Froxlor\UI\Template::getTemplate("customers/customers") . "\";");
|
||||||
|
*/
|
||||||
|
|
||||||
|
UI::twigBuffer('user/table.html.twig', [
|
||||||
|
'api_response' => json_decode($json_result, true)['data'],
|
||||||
|
'table_options' => $customer_list_data['customer_list'],
|
||||||
|
]);
|
||||||
|
UI::twigOutputBuffer();
|
||||||
} elseif ($action == 'su' && $id != 0) {
|
} elseif ($action == 'su' && $id != 0) {
|
||||||
try {
|
try {
|
||||||
$json_result = Customers::getLocal($userinfo, array(
|
$json_result = Customers::getLocal($userinfo, array(
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
return [
|
return [
|
||||||
'admin_list' => [
|
'admin_list' => [
|
||||||
'title' => $lng['admin']['admin'],
|
'title' => $lng['admin']['admin'],
|
||||||
'icon' => 'fa-solid fa-user-plus',
|
'icon' => 'fa-solid fa-user',
|
||||||
'columns' => [
|
'columns' => [
|
||||||
'adminid' => [
|
'adminid' => [
|
||||||
'title' => '#',
|
'title' => '#',
|
||||||
|
|||||||
42
lib/tablelisting/admin/admin/tablelisting.customer.php
Normal file
42
lib/tablelisting/admin/admin/tablelisting.customer.php
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file is part of the Froxlor project.
|
||||||
|
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the COPYING
|
||||||
|
* file that was distributed with this source code. You can also view the
|
||||||
|
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||||
|
*
|
||||||
|
* @copyright (c) the authors
|
||||||
|
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||||
|
* @author Maurice Preuß <hello@envoyr.com>
|
||||||
|
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||||
|
* @package Tabellisting
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
return [
|
||||||
|
'customer_list' => [
|
||||||
|
'title' => $lng['admin']['customers'],
|
||||||
|
'icon' => 'fa-solid fa-user',
|
||||||
|
'columns' => [
|
||||||
|
'loginname' => [
|
||||||
|
'title' => $lng['login']['username']
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'visible_columns' => getVisibleColumnsForListing('admin_list', [
|
||||||
|
'loginname',
|
||||||
|
]),
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
// Das müsste dann irgendwie als Klasse ausgelagert werden
|
||||||
|
function getVisibleColumnsForListing($listing, $default_columns)
|
||||||
|
{
|
||||||
|
// Hier käme dann die Logik, die das aus der DB zieht ...
|
||||||
|
// alternativ nimmt er die $default_columns, wenn kein Eintrag
|
||||||
|
// in der DB definiert ist
|
||||||
|
|
||||||
|
return $default_columns;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user