responsive

This commit is contained in:
Roland Gruber 2019-09-28 11:24:47 +02:00
parent 426e1cf80f
commit af9f714ffb
2 changed files with 100 additions and 126 deletions

View File

@ -2,7 +2,7 @@
/* /*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2013 - 2018 Roland Gruber Copyright (C) 2013 - 2019 Roland Gruber
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -225,7 +225,7 @@ class pykotaPrinter extends baseModule {
* @return htmlElement HTML meta data * @return htmlElement HTML meta data
*/ */
function display_html_attributes() { function display_html_attributes() {
$container = new htmlTable(); $container = new htmlResponsiveRow();
// cn // cn
$this->addSimpleInputTextField($container, 'cn', _('Printer name'), true); $this->addSimpleInputTextField($container, 'cn', _('Printer name'), true);
// job size // job size
@ -239,10 +239,9 @@ class pykotaPrinter extends baseModule {
if (!empty($this->attributes['pykotaPassThrough'][0])) { if (!empty($this->attributes['pykotaPassThrough'][0])) {
$pykotaPassThroughOption = $this->attributes['pykotaPassThrough'][0]; $pykotaPassThroughOption = $this->attributes['pykotaPassThrough'][0];
} }
$pykotaPassThroughSelect = new htmlTableExtendedSelect('pykotaPassThrough', $this->passThroughOptions, array($pykotaPassThroughOption), _('Passthrough'), 'pykotaPassThrough'); $pykotaPassThroughSelect = new htmlResponsiveSelect('pykotaPassThrough', $this->passThroughOptions, array($pykotaPassThroughOption), _('Passthrough'), 'pykotaPassThrough');
$pykotaPassThroughSelect->setHasDescriptiveElements(true); $pykotaPassThroughSelect->setHasDescriptiveElements(true);
$container->addElement($pykotaPassThroughSelect); $container->add($pykotaPassThroughSelect, 12);
$container->addElement(new htmlSpacer('150px', null), true); // layout fix if many parent groups exist
// description // description
$this->addMultiValueInputTextField($container, 'description', _('Description'), false, null, true); $this->addMultiValueInputTextField($container, 'description', _('Description'), false, null, true);
// printer groups // printer groups
@ -254,21 +253,19 @@ class pykotaPrinter extends baseModule {
$parentPrinters[] = $this->printerCache[$groupDN]['cn']; $parentPrinters[] = $this->printerCache[$groupDN]['cn'];
} }
if (sizeof($parentPrinters) > 0) { if (sizeof($parentPrinters) > 0) {
$container->addElement(new htmlOutputText(_('Printer groups'))); $container->addLabel(new htmlOutputText(_('Printer groups')));
$parentPrinterText = new htmlOutputText(implode(', ', $parentPrinters)); $parentPrinterText = new htmlOutputText(implode(', ', $parentPrinters));
$parentPrinterText->colspan = 5; $container->addField($parentPrinterText, true);
$container->addElement($parentPrinterText, true);
} }
} }
// printer members // printer members
$memberLabel = new htmlOutputText(_('Group members')); $memberLabel = new htmlOutputText(_('Group members'));
$memberLabel->alignment = htmlElement::ALIGN_TOP; $container->addLabel($memberLabel);
$container->addElement($memberLabel);
$addMemberButton = new htmlAccountPageButton(get_class($this), 'members', 'open', 'add.png', true); $addMemberButton = new htmlAccountPageButton(get_class($this), 'members', 'open', 'add.png', true);
$addMemberButton->setTitle(_('Add')); $addMemberButton->setTitle(_('Add'));
$addMemberButton->alignment = htmlElement::ALIGN_TOP; $memberHelp = new htmlHelpLink('uniqueMember');
if (!empty($this->attributes['uniqueMember'][0])) {
$memberTable = new htmlTable(); $memberTable = new htmlTable();
if (!empty($this->attributes['uniqueMember'][0])) {
$memberTable->alignment = htmlElement::ALIGN_TOP; $memberTable->alignment = htmlElement::ALIGN_TOP;
for ($i = 0; $i < sizeof($this->attributes['uniqueMember']); $i++) { for ($i = 0; $i < sizeof($this->attributes['uniqueMember']); $i++) {
$member = $this->attributes['uniqueMember'][$i]; $member = $this->attributes['uniqueMember'][$i];
@ -281,17 +278,16 @@ class pykotaPrinter extends baseModule {
$memberTable->addElement($delButton); $memberTable->addElement($delButton);
if ($i == (sizeof($this->attributes['uniqueMember']) - 1)) { if ($i == (sizeof($this->attributes['uniqueMember']) - 1)) {
$memberTable->addElement($addMemberButton); $memberTable->addElement($addMemberButton);
$memberTable->addElement($memberHelp);
} }
$memberTable->addNewLine(); $memberTable->addNewLine();
} }
$container->addElement($memberTable);
} }
else { else {
$container->addElement($addMemberButton); $memberTable->addElement($addMemberButton);
$memberTable->addElement($memberHelp);
} }
$memberHelp = new htmlHelpLink('uniqueMember'); $container->addField($memberTable);
$memberHelp->alignment = htmlElement::ALIGN_TOP;
$container->addElement($memberHelp, true);
return $container; return $container;
} }
@ -382,13 +378,7 @@ class pykotaPrinter extends baseModule {
* @return htmlElement HTML meta data * @return htmlElement HTML meta data
*/ */
function display_html_members() { function display_html_members() {
$return = new htmlTable(); $return = new htmlResponsiveRow();
$userFilter = '';
$userFilterRegex = '';
if (isset($_POST['newFilter'])) {
$userFilter = $_POST['newFilter'];
$userFilterRegex = '/' . str_replace(array('*', '(', ')'), array('.*', '\(', '\)'), $_POST['newFilter']) . '/ui';
}
$options = array(); $options = array();
$this->loadPrinterNameCache(); $this->loadPrinterNameCache();
foreach ($this->printerCache as $dn => $attrs) { foreach ($this->printerCache as $dn => $attrs) {
@ -398,10 +388,6 @@ class pykotaPrinter extends baseModule {
else { else {
$label = $attrs['cn']; $label = $attrs['cn'];
} }
// skip filtered printers
if (!empty($userFilter) && !preg_match($userFilterRegex, $label)) {
continue;
}
// skip own entry // skip own entry
if (!$this->getAccountContainer()->isNewAccount && ($this->getAccountContainer()->dn_orig == $dn)) { if (!$this->getAccountContainer()->isNewAccount && ($this->getAccountContainer()->dn_orig == $dn)) {
continue; continue;
@ -413,22 +399,28 @@ class pykotaPrinter extends baseModule {
$options[$label] = $dn; $options[$label] = $dn;
} }
$size = 20; $size = 20;
if (sizeof($options) < 20) $size = sizeof($options); if (sizeof($options) < 20) {
$size = sizeof($options);
}
$membersSelect = new htmlSelect('members', $options, array(), $size); $membersSelect = new htmlSelect('members', $options, array(), $size);
$membersSelect->setHasDescriptiveElements(true); $membersSelect->setHasDescriptiveElements(true);
$membersSelect->setMultiSelect(true); $membersSelect->setMultiSelect(true);
$membersSelect->setTransformSingleSelect(false); $membersSelect->setTransformSingleSelect(false);
$return->addElement($membersSelect, true); $return->add($membersSelect, 12);
$filterGroup = new htmlGroup(); $filterGroup = new htmlGroup();
$filterGroup->addElement(new htmlInputField('newFilter', $userFilter)); $filterGroup->addElement(new htmlOutputText(_('Filter')));
$filterGroup->addElement(new htmlButton('setFilter', _('Filter'))); $filterInput = new htmlInputField('newFilter', null);
$filterInput->setCSSClasses(array('maxwidth20'));
$filterInput->filterSelectBox('members');
$filterGroup->addElement($filterInput);
$filterGroup->addElement(new htmlHelpLink('filter')); $filterGroup->addElement(new htmlHelpLink('filter'));
$return->addElement($filterGroup, true); $return->add($filterGroup, 12);
$return->addElement(new htmlSpacer(null, '10px'), true); $return->addVerticalSpacer('2rem');
$buttonTable = new htmlTable(); $buttonTable = new htmlGroup();
$buttonTable->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'addMembers', _('Add'))); $buttonTable->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'addMembers', _('Add')));
$buttonTable->addElement(new htmlSpacer('0.5rem', null));
$buttonTable->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'cancel', _('Cancel'))); $buttonTable->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'cancel', _('Cancel')));
$return->addElement($buttonTable); $return->add($buttonTable, 12);
return $return; return $return;
} }

View File

@ -296,7 +296,7 @@ class pykotaUser extends baseModule {
* @return htmlElement HTML meta data * @return htmlElement HTML meta data
*/ */
function display_html_attributes() { function display_html_attributes() {
$container = new htmlTable(); $container = new htmlResponsiveRow();
$modules = $this->getAccountContainer()->get_type()->getModules(); $modules = $this->getAccountContainer()->get_type()->getModules();
if ($this->isStructural() || (isset($this->attributes['objectClass']) && in_array('pykotaAccount', $this->attributes['objectClass']))) { if ($this->isStructural() || (isset($this->attributes['objectClass']) && in_array('pykotaAccount', $this->attributes['objectClass']))) {
// uid // uid
@ -315,8 +315,7 @@ class pykotaUser extends baseModule {
$page = $this->getAccountContainer()->getAccountModule('inetOrgPerson')->get_alias(); $page = $this->getAccountContainer()->getAccountModule('inetOrgPerson')->get_alias();
} }
$msg = new htmlStatusMessage('INFO', sprintf(_("Please enter an user name on this page: %s"), $page)); $msg = new htmlStatusMessage('INFO', sprintf(_("Please enter an user name on this page: %s"), $page));
$msg->colspan = 5; $container->add($msg, 12);
$container->addElement($msg, true);
} }
} }
// pykotaUserName // pykotaUserName
@ -326,42 +325,31 @@ class pykotaUser extends baseModule {
if (isset($this->attributes['pykotaBalance'][0])) { if (isset($this->attributes['pykotaBalance'][0])) {
$pykotaBalance = $this->attributes['pykotaBalance'][0]; $pykotaBalance = $this->attributes['pykotaBalance'][0];
} }
$container->addElement(new htmlOutputText(_('Balance'))); $container->addLabel(new htmlOutputText(_('Balance')));
$container->addElement(new htmlOutputText($pykotaBalance)); $balanceGroup = new htmlGroup();
$container->addElement(new htmlHelpLink('pykotaBalance'), true); $balanceGroup->addElement(new htmlOutputText($pykotaBalance));
// new payment and balance history $balanceGroup->addElement(new htmlSpacer('0.5rem', null));
$container->addElement(new htmlOutputText(_('Payment'))); $balanceGroup->addElement(new htmlHelpLink('pykotaBalance'));
$newPaymentGroup = new htmlGroup(); $container->addField($balanceGroup);
$newPaymentAmount = new htmlInputField('pykotaBalanceAdd', '', '5em'); $container->addLabel(new htmlOutputText('&nbsp;', false));
$newPaymentAmount->setTitle(_('Amount'));
$newPaymentGroup->addElement($newPaymentAmount);
$newPaymentComment = new htmlInputField('pykotaBalanceComment', '', '20em');
$newPaymentComment->setTitle(_('Comment'));
$newPaymentGroup->addElement($newPaymentComment);
$newPaymentBtn = new htmlButton('addPayment', _('Add'));
$newPaymentBtn->setIconClass('createButton');
$newPaymentGroup->addElement($newPaymentBtn);
$container->addElement($newPaymentGroup);
$container->addElement(new htmlHelpLink('pykotaPaymentsAdd'), true);
$container->addElement(new htmlOutputText(''));
$historyGroup = new htmlGroup(); $historyGroup = new htmlGroup();
$historyGroup->addElement(new htmlAccountPageButton(get_class($this), 'payments', 'open', _('Payment history'))); $historyGroup->addElement(new htmlAccountPageButton(get_class($this), 'payments', 'open', _('Payment history')));
if (!$this->getAccountContainer()->isNewAccount && !empty($this->moduleSettings['pykotaUser_jobSuffix'][0])) { if (!$this->getAccountContainer()->isNewAccount && !empty($this->moduleSettings['pykotaUser_jobSuffix'][0])) {
$historyGroup->addElement(new htmlSpacer('5px', null)); $historyGroup->addElement(new htmlSpacer('5px', null));
$historyGroup->addElement(new htmlAccountPageButton(get_class($this), 'jobs', 'open', _('Job history'))); $historyGroup->addElement(new htmlAccountPageButton(get_class($this), 'jobs', 'open', _('Job history')));
} }
$container->addElement($historyGroup); $historyGroup->addElement(new htmlSpacer('5px', null));
$container->addElement(new htmlHelpLink('pykotaPayments'), true); $historyGroup->addElement(new htmlHelpLink('pykotaPayments'), true);
$container->addElement(new htmlSpacer(null, '10px'), true); $container->addField($historyGroup);
// limit by // limit by
$limitOption = 'quota'; $limitOption = 'quota';
if (!empty($this->attributes['pykotaLimitBy'][0])) { if (!empty($this->attributes['pykotaLimitBy'][0])) {
$limitOption = $this->attributes['pykotaLimitBy'][0]; $limitOption = $this->attributes['pykotaLimitBy'][0];
} }
$limitSelect = new htmlTableExtendedSelect('pykotaLimitBy', $this->limitOptions, array($limitOption), _('Limit type'), 'pykotaLimitBy'); $limitSelect = new htmlResponsiveSelect('pykotaLimitBy', $this->limitOptions, array($limitOption), _('Limit type'), 'pykotaLimitBy');
$limitSelect->setHasDescriptiveElements(true); $limitSelect->setHasDescriptiveElements(true);
$limitSelect->setSortElements(false); $limitSelect->setSortElements(false);
$container->addElement($limitSelect, true); $container->add($limitSelect, 12);
// overcharge factor // overcharge factor
$this->addSimpleInputTextField($container, 'pykotaOverCharge', _('Overcharge factor')); $this->addSimpleInputTextField($container, 'pykotaOverCharge', _('Overcharge factor'));
// cn // cn
@ -376,17 +364,29 @@ class pykotaUser extends baseModule {
if ($this->manageDescription($modules)) { if ($this->manageDescription($modules)) {
$this->addMultiValueInputTextField($container, 'description', _('Description'), false, null, true); $this->addMultiValueInputTextField($container, 'description', _('Description'), false, null, true);
} }
// new payment
$container->add(new htmlSubTitle(_('Payment')), 12);
$newPaymentAmount = new htmlResponsiveInputField(_('Amount'), 'pykotaBalanceAdd', '', '5em');
$container->add($newPaymentAmount, 12);
$newPaymentComment = new htmlResponsiveInputField(_('Comment'), 'pykotaBalanceComment', '', '20em');
$container->add($newPaymentComment, 12);
$newPaymentBtn = new htmlButton('addPayment', _('Add'));
$newPaymentBtn->setIconClass('createButton');
$newPaymentGroup = new htmlGroup();
$newPaymentGroup->addElement($newPaymentBtn);
$newPaymentGroup->addElement(new htmlSpacer('0.5rem', null));
$newPaymentGroup->addElement(new htmlHelpLink('pykotaPaymentsAdd'));
$container->add($newPaymentGroup, 12, 12, 12, 'text-center');
// remove button // remove button
if (!$this->isStructural()) { if (!$this->isStructural()) {
$container->addElement(new htmlSpacer(null, '20px'), true); $container->addVerticalSpacer('2rem');
$remButton = new htmlButton('remObjectClass', _('Remove PyKota extension')); $remButton = new htmlButton('remObjectClass', _('Remove PyKota extension'));
$remButton->colspan = 5; $container->add($remButton, 12, 12, 12, 'text-center');
$container->addElement($remButton);
} }
} }
else { else {
// add button // add button
$container->addElement(new htmlButton('addObjectClass', _('Add PyKota extension'))); $container->add(new htmlButton('addObjectClass', _('Add PyKota extension')), 12);
} }
return $container; return $container;
} }
@ -542,48 +542,44 @@ class pykotaUser extends baseModule {
* @return htmlElement HTML meta data * @return htmlElement HTML meta data
*/ */
function display_html_payments() { function display_html_payments() {
$container = new htmlTable(); $container = new htmlResponsiveRow();
$container->setCSSClasses(array('maxrow'));
// total paid // total paid
$total = ''; $total = '';
if (!empty($this->attributes['pykotaLifeTimePaid'][0])) { if (!empty($this->attributes['pykotaLifeTimePaid'][0])) {
$total = $this->attributes['pykotaLifeTimePaid'][0]; $total = $this->attributes['pykotaLifeTimePaid'][0];
} }
$container->addElement(new htmlOutputText(_('Total paid'))); $container->addLabel(new htmlOutputText(_('Total paid')));
$container->addElement(new htmlOutputText($total)); $totalPaidGroup = new htmlGroup();
$container->addElement(new htmlHelpLink('pykotaLifeTimePaid'), true); $totalPaidGroup->addElement(new htmlOutputText($total));
$totalPaidGroup->addElement(new htmlSpacer('0.5rem', null));
$totalPaidGroup->addElement(new htmlHelpLink('pykotaLifeTimePaid'));
$container->addField($totalPaidGroup, 12);
// payment/job history // payment/job history
if (!empty($this->attributes['pykotaPayments'][0])) { if (!empty($this->attributes['pykotaPayments'][0])) {
$container->addElement(new htmlSubTitle(_('Payment history')), true); $container->add(new htmlSubTitle(_('Payment history')), 12);
$spacer = new htmlSpacer('10px', null); $labels = array(_('Date'), _('Amount'), _('Comment'));
$historyTable = new htmlTable(); $data = array();
$historyTable->colspan = 5;
$historyTable->addElement(new htmlOutputText(_('Date')), false, true);
$historyTable->addElement($spacer);
$historyTable->addElement(new htmlOutputText(_('Amount')), false, true);
$historyTable->addElement($spacer);
$historyTable->addElement(new htmlOutputText(_('Comment')), true, true);
rsort($this->attributes['pykotaPayments']); rsort($this->attributes['pykotaPayments']);
foreach ($this->attributes['pykotaPayments'] as $payment) { foreach ($this->attributes['pykotaPayments'] as $payment) {
$parts = explode(' # ', $payment); $parts = explode(' # ', $payment);
$historyTable->addElement(new htmlOutputText($parts[0])); $comment = empty($parts[2]) ? '' : base64_decode($parts[2]);
$historyTable->addElement($spacer); $commentField = new htmlOutputText($comment);
$amount = new htmlOutputText($parts[1]); $amountFied = new htmlOutputText($parts[1]);
$amount->alignment = htmlElement::ALIGN_RIGHT; $data[] = array(
$historyTable->addElement($amount); new htmlOutputText($parts[0]),
$historyTable->addElement($spacer); $amountFied,
if (!empty($parts[2])) { $commentField
$historyTable->addElement(new htmlOutputText(base64_decode($parts[2]))); );
} }
$historyTable->addNewLine(); $historyTable = new htmlResponsiveTable($labels, $data);
} $historyTable->setWidths(array('20%', '15%', '65%'));
$container->addElement($historyTable, true); $container->add($historyTable, 12);
} }
// back button // back button
$container->addElement(new htmlSpacer(null, '20px'), true); $container->addVerticalSpacer('2rem');
$backButton = new htmlAccountPageButton(get_class($this), 'attributes', 'back', _('Back')); $backButton = new htmlAccountPageButton(get_class($this), 'attributes', 'back', _('Back'));
$backButton->colspan = 5; $container->add($backButton, 12);
$backButton->alignment = htmlElement::ALIGN_LEFT;
$container->addElement($backButton, true);
return $container; return $container;
} }
@ -603,44 +599,30 @@ class pykotaUser extends baseModule {
* @return htmlElement HTML meta data * @return htmlElement HTML meta data
*/ */
function display_html_jobs() { function display_html_jobs() {
$container = new htmlTable(); $container = new htmlResponsiveRow();
$container->setCSSClasses(array('maxrow'));
// jobs // jobs
$jobs = $this->getJobs($this->getCurrentUserName(), $this->moduleSettings['pykotaUser_jobSuffix'][0]); $jobs = $this->getJobs($this->getCurrentUserName(), $this->moduleSettings['pykotaUser_jobSuffix'][0]);
$spacer = new htmlSpacer('10px', null); $titles = array(
// header _('Date'), _('Printer'), _('Price'), _('Size'), _('Title')
$container->addElement(new htmlOutputText(_('Date')), false, true); );
$container->addElement($spacer); $data = array();
$container->addElement(new htmlOutputText(_('Printer')), false, true);
$container->addElement($spacer);
$container->addElement(new htmlOutputText(_('Price')), false, true);
$container->addElement($spacer);
$container->addElement(new htmlOutputText(_('Size')), false, true);
$container->addElement($spacer);
$title = new htmlOutputText(_('Title'));
$title->alignment = htmlElement::ALIGN_LEFT;
$container->addElement($title, true, true);
// jobs
foreach ($jobs as $job) { foreach ($jobs as $job) {
$container->addElement(new htmlOutputText(formatLDAPTimestamp($job['createtimestamp'][0]))); $data[] = array(
$container->addElement($spacer); new htmlOutputText(formatLDAPTimestamp($job['createtimestamp'][0])),
$container->addElement(new htmlOutputText($job['pykotaprintername'][0])); new htmlOutputText($job['pykotaprintername'][0]),
$container->addElement($spacer); new htmlOutputText($job['pykotajobprice'][0]),
$price = new htmlOutputText($job['pykotajobprice'][0]); new htmlOutputText($job['pykotajobsize'][0]),
$price->alignment = htmlElement::ALIGN_RIGHT; new htmlOutputText($job['pykotatitle'][0])
$container->addElement($price); );
$container->addElement($spacer);
$size = new htmlOutputText($job['pykotajobsize'][0]);
$size->alignment = htmlElement::ALIGN_RIGHT;
$container->addElement($size);
$container->addElement($spacer);
$container->addElement(new htmlOutputText($job['pykotatitle'][0]), true);
} }
$table = new htmlResponsiveTable($titles, $data);
$table->setWidths(array('20%', '20%', '15%', '15%', '30%'));
$container->add($table, 12);
// back button // back button
$container->addElement(new htmlSpacer(null, '20px'), true); $container->addVerticalSpacer('2rem');
$backButton = new htmlAccountPageButton(get_class($this), 'attributes', 'back', _('Back')); $backButton = new htmlAccountPageButton(get_class($this), 'attributes', 'back', _('Back'));
$backButton->colspan = 5; $container->add($backButton, 12);
$backButton->alignment = htmlElement::ALIGN_LEFT;
$container->addElement($backButton, true);
return $container; return $container;
} }