more cleanup in admin_customers for add/edit form

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2022-02-18 12:41:49 +01:00
parent 0fd7b9a551
commit c1c09da18d
5 changed files with 109 additions and 236 deletions

View File

@@ -148,7 +148,7 @@ if ($page == 'customers' && $userinfo['customers'] != '0') {
$row['custom_notes'] = ($row['custom_notes'] != '') ? nl2br($row['custom_notes']) : '';
eval("\$customers.=\"" . \Froxlor\UI\Template::getTemplate("customers/customers_customer") . "\";");
$count ++;
$count++;
}
$customercount = $result['count'] . " / " . $paging->getEntries();
@@ -201,7 +201,7 @@ if ($page == 'customers' && $userinfo['customers'] != '0') {
$target = (isset($_GET['target']) ? $_GET['target'] : 'index');
$redirect = "customer_" . $target . ".php";
if (! file_exists(\Froxlor\Froxlor::getInstallDir() . "/" . $redirect)) {
if (!file_exists(\Froxlor\Froxlor::getInstallDir() . "/" . $redirect)) {
$redirect = "customer_index.php";
}
\Froxlor\UI\Response::redirectTo($redirect, array(
@@ -285,17 +285,7 @@ if ($page == 'customers' && $userinfo['customers'] != '0') {
));
} else {
$diskspace_ul = \Froxlor\UI\HTML::makecheckbox('diskspace_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$traffic_ul = \Froxlor\UI\HTML::makecheckbox('traffic_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$subdomains_ul = \Froxlor\UI\HTML::makecheckbox('subdomains_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$emails_ul = \Froxlor\UI\HTML::makecheckbox('emails_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$email_accounts_ul = \Froxlor\UI\HTML::makecheckbox('email_accounts_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$email_forwarders_ul = \Froxlor\UI\HTML::makecheckbox('email_forwarders_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$email_quota_ul = \Froxlor\UI\HTML::makecheckbox('email_quota_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$ftps_ul = \Froxlor\UI\HTML::makecheckbox('ftps_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$mysqls_ul = \Froxlor\UI\HTML::makecheckbox('mysqls_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$phpconfigs = array();
$phpconfigs = [];
$configs = Database::query("
SELECT c.*, fc.description as interpreter
FROM `" . TABLE_PANEL_PHPCONFIGS . "` c
@@ -347,23 +337,6 @@ if ($page == 'customers' && $userinfo['customers'] != '0') {
}
$result = json_decode($json_result, true)['data'];
/*
* information for moving customer
*/
$available_admins_stmt = Database::prepare("
SELECT * FROM `" . TABLE_PANEL_ADMINS . "`
WHERE (`customers` = '-1' OR `customers` > `customers_used`)");
Database::pexecute($available_admins_stmt);
$admin_select = \Froxlor\UI\HTML::makeoption("-----", 0, true, true, true);
$admin_select_cnt = 0;
while ($available_admin = $available_admins_stmt->fetch()) {
$admin_select .= \Froxlor\UI\HTML::makeoption($available_admin['name'] . " (" . $available_admin['loginname'] . ")", $available_admin['adminid'], null, true, true);
$admin_select_cnt ++;
}
/*
* end of moving customer stuff
*/
if ($result['loginname'] != '') {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
@@ -377,69 +350,15 @@ if ($page == 'customers' && $userinfo['customers'] != '0') {
's' => $s
));
} else {
$language_options = '';
foreach ($languages as $language_file => $language_name) {
$language_options .= \Froxlor\UI\HTML::makeoption($language_name, $language_file, $result['def_language'], true);
}
$dec_places = Settings::Get('panel.decimal_places');
$result['traffic'] = round($result['traffic'] / (1024 * 1024), $dec_places);
$result['diskspace'] = round($result['diskspace'] / 1024, $dec_places);
$result['email'] = $idna_convert->decode($result['email']);
$diskspace_ul = \Froxlor\UI\HTML::makecheckbox('diskspace_ul', $lng['customer']['unlimited'], '-1', false, $result['diskspace'], true, true);
if ($result['diskspace'] == '-1') {
$result['diskspace'] = '';
}
$traffic_ul = \Froxlor\UI\HTML::makecheckbox('traffic_ul', $lng['customer']['unlimited'], '-1', false, $result['traffic'], true, true);
if ($result['traffic'] == '-1') {
$result['traffic'] = '';
}
$subdomains_ul = \Froxlor\UI\HTML::makecheckbox('subdomains_ul', $lng['customer']['unlimited'], '-1', false, $result['subdomains'], true, true);
if ($result['subdomains'] == '-1') {
$result['subdomains'] = '';
}
$emails_ul = \Froxlor\UI\HTML::makecheckbox('emails_ul', $lng['customer']['unlimited'], '-1', false, $result['emails'], true, true);
if ($result['emails'] == '-1') {
$result['emails'] = '';
}
$email_accounts_ul = \Froxlor\UI\HTML::makecheckbox('email_accounts_ul', $lng['customer']['unlimited'], '-1', false, $result['email_accounts'], true, true);
if ($result['email_accounts'] == '-1') {
$result['email_accounts'] = '';
}
$email_forwarders_ul = \Froxlor\UI\HTML::makecheckbox('email_forwarders_ul', $lng['customer']['unlimited'], '-1', false, $result['email_forwarders'], true, true);
if ($result['email_forwarders'] == '-1') {
$result['email_forwarders'] = '';
}
$email_quota_ul = \Froxlor\UI\HTML::makecheckbox('email_quota_ul', $lng['customer']['unlimited'], '-1', false, $result['email_quota'], true, true);
if ($result['email_quota'] == '-1') {
$result['email_quota'] = '';
}
$ftps_ul = \Froxlor\UI\HTML::makecheckbox('ftps_ul', $lng['customer']['unlimited'], '-1', false, $result['ftps'], true, true);
if ($result['ftps'] == '-1') {
$result['ftps'] = '';
}
$mysqls_ul = \Froxlor\UI\HTML::makecheckbox('mysqls_ul', $lng['customer']['unlimited'], '-1', false, $result['mysqls'], true, true);
if ($result['mysqls'] == '-1') {
$result['mysqls'] = '';
}
$result = \Froxlor\PhpHelper::htmlentitiesArray($result);
$gender_options = \Froxlor\UI\HTML::makeoption($lng['gender']['undef'], 0, ($result['gender'] == '0' ? true : false), true, true);
$gender_options .= \Froxlor\UI\HTML::makeoption($lng['gender']['male'], 1, ($result['gender'] == '1' ? true : false), true, true);
$gender_options .= \Froxlor\UI\HTML::makeoption($lng['gender']['female'], 2, ($result['gender'] == '2' ? true : false), true, true);
$phpconfigs = array();
$phpconfigs = [];
$configs = Database::query("
SELECT c.*, fc.description as interpreter
FROM `" . TABLE_PANEL_PHPCONFIGS . "` c
@@ -448,38 +367,49 @@ if ($page == 'customers' && $userinfo['customers'] != '0') {
while ($row = $configs->fetch(PDO::FETCH_ASSOC)) {
if ((int) Settings::Get('phpfpm.enabled') == 1) {
$phpconfigs[] = array(
'label' => $row['description'] . " [" . $row['interpreter'] . "]<br />",
'label' => $row['description'] . " [" . $row['interpreter'] . "]",
'value' => $row['id']
);
} else {
$phpconfigs[] = array(
'label' => $row['description'] . "<br />",
'label' => $row['description'],
'value' => $row['id']
);
}
}
// hosting plans
$hosting_plans = "";
$plans = Database::query("
SELECT *
FROM `" . TABLE_PANEL_PLANS . "`
ORDER BY name ASC
");
if (Database::num_rows() > 0) {
$hosting_plans .= \Froxlor\UI\HTML::makeoption("---", 0, 0, true, true);
}
$hosting_plans = [
0 => "---"
];
while ($row = $plans->fetch(PDO::FETCH_ASSOC)) {
$hosting_plans .= \Froxlor\UI\HTML::makeoption($row['name'], $row['id'], 0, true, true);
$hosting_plans[$row['id']] = $row['name'];
}
$available_admins_stmt = Database::prepare("
SELECT * FROM `" . TABLE_PANEL_ADMINS . "`
WHERE (`customers` = '-1' OR `customers` > `customers_used`)
AND adminid <> :currentadmin
");
Database::pexecute($available_admins_stmt, ['currentadmin' => $result['adminid']]);
$admin_select = [
0 => "---"
];
while ($available_admin = $available_admins_stmt->fetch()) {
$admin_select[$available_admin['adminid']] = $available_admin['name'] . " (" . $available_admin['loginname'] . ")";
}
$customer_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/customer/formfield.customer_edit.php';
$customer_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($customer_edit_data);
$title = $customer_edit_data['customer_edit']['title'];
$image = $customer_edit_data['customer_edit']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate("customers/customers_edit") . "\";");
UI::TwigBuffer('user/form.html.twig', [
'formdata' => $customer_edit_data['customer_edit']
]);
UI::TwigOutputBuffer();
}
}
}