diff --git a/fid/config/vufind/fid.ini b/fid/config/vufind/fid.ini index fd434cd589fa8a65605fcd57f7a053e40205f53d..3d2e511df3a6e584bb810e385e0419a0336324be 100644 --- a/fid/config/vufind/fid.ini +++ b/fid/config/vufind/fid.ini @@ -38,9 +38,22 @@ user_list_export_file_prefix = 'export' ; of not given, options will be job_title_0, job_title_1 ;jobTitleOptions = "0,1" -; examples on configure admin order listings -;[OrderList] -;displayCols[] = 'type' +;configure columns of user's order listings +[OrderListUser] +displayCols[] = 'date' +displayCols[] = 'type' +displayCols[] = 'user' +displayCols[] = 'record' +;displayCols[] = 'status' +;displayCols[] = 'dueDate' + +;configure columns of admins's order listings +;additional columns like user, edit & delete +[OrderListAdmin] +displayCols[] = 'date' +displayCols[] = 'type' +displayCols[] = 'user' +displayCols[] = 'record' ;displayCols[] = 'status' ;displayCols[] = 'dueDate' ;displayCols[] = 'edit' diff --git a/module/fid/src/Controller/UserController.php b/module/fid/src/Controller/UserController.php index a960f90cc3c6cd8227fb89964416498a4f79f0f0..67297a6c6beda95405427420af7cf8045ea40330 100644 --- a/module/fid/src/Controller/UserController.php +++ b/module/fid/src/Controller/UserController.php @@ -997,9 +997,9 @@ class UserController extends AbstractBase $user = $this->client->requestUserDetails(null, true); $viewModel = $this->createViewModel(); $orders = $user->getOrders(); - $displayCols = $this->config['OrderList']['displayCols']; + $displayCols = $this->config['OrderListUser']['displayCols']; $viewModel->setVariables(compact('orders', 'displayCols')); - $viewModel->setTemplate('fid/user/orders'); + $viewModel->setTemplate('fid/order/order-list'); return $viewModel; } catch (ClientException $exception) { $this->getMessenger()->addErrorMessage('fid::orders_error'); @@ -1020,9 +1020,9 @@ class UserController extends AbstractBase try { $orders = $this->client->requestOrderList(); $viewModel = $this->createViewModel(); - $displayCols = $this->config['OrderList']['displayCols']; + $displayCols = $this->config['OrderListAdmin']['displayCols']; $viewModel->setVariables(compact('orders', 'displayCols')); - $viewModel->setTemplate('fid/user/admin-orders'); + $viewModel->setTemplate('fid/order/order-list-admin'); return $viewModel; } catch (UserNotAuthorizedException $exception) { $this->getMessenger() diff --git a/module/finc/src/finc/Controller/CustomTraits/EmailHoldTrait.php b/module/finc/src/finc/Controller/CustomTraits/EmailHoldTrait.php index 65c6bec4845b9b91b142aabca3f8e3c269d7e636..8568a4b8da5083519ded0bbbba0062fef4d74106 100644 --- a/module/finc/src/finc/Controller/CustomTraits/EmailHoldTrait.php +++ b/module/finc/src/finc/Controller/CustomTraits/EmailHoldTrait.php @@ -29,8 +29,8 @@ */ namespace finc\Controller\CustomTraits; -use VuFind\Exception\Mail as MailException; use finc\Mailer\Mailer as Mailer; +use VuFind\Exception\Mail as MailException; use Zend\Mail\Address as Address; /** @@ -161,10 +161,12 @@ trait EmailHoldTrait 'Email/journalhold-plain.phtml', $details ); - $subject = "Zeitschrift von " . - $details['patron']['lastname'] . ", " . - $details['patron']['firstname'] . - " | Signatur: " . $details['callnumber']; + $subject = sprintf( + $emailProfile->subject, + $details['patron']['lastname'], + $details['patron']['firstname'], + $details['callnumber'] + ); $from = $reply = ( isset($details['patron']['email']) diff --git a/module/finc/src/finc/View/Helper/Root/Factory.php b/module/finc/src/finc/View/Helper/Root/Factory.php index cefff99a0a9776e86830d915d1fa23799e1fc473..02bc100e51034fe15eb82b8ce14163138c07c221 100644 --- a/module/finc/src/finc/View/Helper/Root/Factory.php +++ b/module/finc/src/finc/View/Helper/Root/Factory.php @@ -221,4 +221,14 @@ class Factory { return new ExternalLink(); } + + /** + * Construct RenderArray + * + * @return RenderArray + */ + public static function getRenderArray() + { + return new RenderArray(); + } } diff --git a/module/finc/src/finc/View/Helper/Root/RenderArray.php b/module/finc/src/finc/View/Helper/Root/RenderArray.php new file mode 100644 index 0000000000000000000000000000000000000000..e955a35db3d2d134ee9e3b10e3524815060a39b5 --- /dev/null +++ b/module/finc/src/finc/View/Helper/Root/RenderArray.php @@ -0,0 +1,72 @@ +<?php +/** + * View helper to render a portion of an array. + * + * PHP version 7 + * + * Copyright (C) Leipzig University Library 2021. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * @category VuFind + * @package View_Helpers + * @author Demian Katz <demian.katz@villanova.edu> + * @author Alexander Purr <purr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ +namespace finc\View\Helper\Root; + + +/** + * View helper to render a portion of an array. + * + * @category VuFind + * @package View_Helpers + * @author Demian Katz <demian.katz@villanova.edu> + * @author Alexander Purr <purr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ +class RenderArray extends \VuFind\View\Helper\Root\RenderArray +{ + /** + * Render a portion of an array. + * + * @param string $tpl A template for displaying each row. This should + * include %%LABEL%% and %%VALUE%% placeholders + * @param array $arr An associative array of possible values to display + * @param array $rows A label => profile key associative array specifying + * which rows of $arr to display + * @param bool $hideEmpty enable hiding entry / row if value is empty + * + * @return string + */ + public function __invoke($tpl, $arr, $rows, $hideEmpty = false) + { + $html = ''; + foreach ($rows as $label => $key) { + if (isset($arr[$key])) { + if (!($hideEmpty && empty($arr[$key]))) { + $html .= str_replace( + ['%%LABEL%%', '%%VALUE%%'], + [$label, $this->view->escapeHtml($arr[$key])], + $tpl + ); + } + } + } + return $html; + } +} diff --git a/themes/fid/templates/fid/order/list/entry.phtml b/themes/fid/templates/fid/order/list/entry.phtml new file mode 100644 index 0000000000000000000000000000000000000000..84151437c2dd663edd2adce42f1fef2cca9f060d --- /dev/null +++ b/themes/fid/templates/fid/order/list/entry.phtml @@ -0,0 +1,52 @@ +<!-- fid: fid - order - list - entry --> +<?php foreach($this->displayCols as $col): ?> + <?php switch ($col): + case 'user': ?> + <td> + <?php + /** @var \fid\Service\DataTransferObject\User $user */ + if ($user = $order->getUser()) : ?> + <?= $user->getFirstname() ?> <?= $user->getLastname() ?> + <?php else: ?> + <?= $this->translate('fid::user_deleted') ?> + <?php endif; ?> + </td> + <?php break; ?> + <?php case 'type': ?> + <td> + <?=$this->translate("fid::acquisition_{$order->getType()}")?> + </td> + <?php break; ?> + <?php case 'date': ?> + <td> + <?=$this->escapeHtml($order->getCreatedAt()->format('d.m.Y'))?> + </td> + <?php break; ?> + <?php case 'record': ?> + <td> + <?=$this->render('fid/order/list/field-record')?> + </td> + <?php break; ?> + <?php case 'status': ?> + <td> + <?=$order->getStatus() ? $this->translate('fid::status_'.$order->getStatus()) : ''?> + </td> + <?php break; ?> + <?php case 'dueDate': ?> + <td> + <?=$this->render('fid/order/list/field-due-date')?> + </td> + <?php break; ?> + <?php case 'edit': ?> + <td> + <?=$this->render('fid/order/list/field-edit')?> + </td> + <?php break; ?> + <?php case 'delete': ?> + <td> + coming soon + </td> + <?php break; ?> + <?php endswitch; ?> +<?php endforeach; ?> +<!-- fid: fid - order - list - entry - END --> \ No newline at end of file diff --git a/themes/fid/templates/fid/order/list/field-due-date.phtml b/themes/fid/templates/fid/order/list/field-due-date.phtml new file mode 100644 index 0000000000000000000000000000000000000000..e1af24af30cb9dd140d3069eb05a7849588d1e9e --- /dev/null +++ b/themes/fid/templates/fid/order/list/field-due-date.phtml @@ -0,0 +1,8 @@ +<!-- fid: fid - order - list - field-due-date --> +<?php +use fid\Controller\RecordController; +?> +<?= ($order->getType() == RecordController::PDA) && ($order->isOverdue()) && ($order->getStatus() != 'completed') + ? "<div class=\"alert alert-danger\" role=\"alert\"><i aria-hidden=\"true\" class=\"fa fa-warning\"></i>{$order->displayDueDate()}</div>" + : $order->displayDueDate() ?> +<!-- fid: fid - order - list - field-due-date - END --> diff --git a/themes/fid/templates/fid/order/list/field-edit.phtml b/themes/fid/templates/fid/order/list/field-edit.phtml new file mode 100644 index 0000000000000000000000000000000000000000..afc8b212e3888eb3be50363afe1378a6b7f09089 --- /dev/null +++ b/themes/fid/templates/fid/order/list/field-edit.phtml @@ -0,0 +1,5 @@ +<!-- fid: fid - order - list - field-edit --> +<a href="<?=$this->url('fid/admin/editOrder', ['orderid' => $order->getId()])?>"> + <i aria-hidden="true" class="fa fa-edit"> +</a> +<!-- fid: fid - order - list - field-edit - END --> diff --git a/themes/fid/templates/fid/user/orders/additionals-data.phtml b/themes/fid/templates/fid/order/list/field-record.phtml similarity index 78% rename from themes/fid/templates/fid/user/orders/additionals-data.phtml rename to themes/fid/templates/fid/order/list/field-record.phtml index 4a718d37c3daa66eb59053866d4b8c41d6d62bca..949aab79c33fb4bbce91eeac1c78a734dc891bdd 100644 --- a/themes/fid/templates/fid/user/orders/additionals-data.phtml +++ b/themes/fid/templates/fid/order/list/field-record.phtml @@ -1,14 +1,13 @@ -<!-- fid: fid - user - orders - data --> -<td> +<!-- fid: fid - order - list - field-record --> <?php - $recordId = $this->order->getData()['record']['id'] ?? null; - $recordLabel = $this->order->getLabel(); + $recordId = $order->getData()['record']['id'] ?? null; + $recordLabel = $order->getLabel(); if ($recordId && $recordLink = $this->recordLink()->getRecordLink($recordId, 'id')): ?> <a onClick="$('#modal').modal('hide');" target="_self" href="<?=$recordLink?>"><?=$recordLabel?></a> <?php else: ?> <?php - $externalUrl = $this->order->getData()['digitization']['external_url'] ?? null; + $externalUrl = $order->getData()['digitization']['external_url'] ?? null; if ($externalUrl) : ?> <?= $this->externalLink($externalUrl, $recordLabel, ['data-lightbox-ignore' => '']) ?> <?php else: ?> @@ -27,9 +26,9 @@ $this->transEsc('fid::acquisition_label_language') => 'language', $this->transEsc('fid::acquisition_label_library') => 'library', $this->transEsc('fid::acquisition_label_signature') => 'signature' - ] + ], + true ) ?> </dl> <?php endif; ?> -</td> -<!-- fid: fid - user - orders - data - END --> +<!-- fid: fid - order - list - field-record - END --> diff --git a/themes/fid/templates/fid/order/list/headers.phtml b/themes/fid/templates/fid/order/list/headers.phtml new file mode 100644 index 0000000000000000000000000000000000000000..3196ce965304ca1724a7ea5857cd67ce0f4678cf --- /dev/null +++ b/themes/fid/templates/fid/order/list/headers.phtml @@ -0,0 +1,30 @@ +<!-- fid: fid - order - list - headers --> +<?php foreach($displayCols as $col): ?> + <?php switch ($col): + case 'user': ?> + <th><?=$this->translate('fid::order_user')?></th> + <?php break; ?> + <? case 'type': ?> + <th><?=$this->translate('fid::order_type')?></th> + <?php break; ?> + <?php case 'date': ?> + <th><?=$this->translate('Date')?></th> + <?php break; ?> + <?php case 'record': ?> + <th><?=$this->translate('fid::order_record')?></th> + <?php break; ?> + <?php case 'status': ?> + <th><?=$this->translate('fid::order_label_status')?></th> + <?php break; ?> + <?php case 'dueDate': ?> + <th><?=$this->translate('fid::order_label_due_date')?></th> + <?php break; ?> + <?php case 'edit': ?> + <th></th> + <?php break; ?> + <?php case 'delete': ?> + <th></th> + <?php break; ?> + <?php endswitch; ?> +<?php endforeach; ?> +<!-- fid: fid - order - list - headers - END --> \ No newline at end of file diff --git a/themes/fid/templates/fid/order/list/table.phtml b/themes/fid/templates/fid/order/list/table.phtml new file mode 100644 index 0000000000000000000000000000000000000000..4d1dbd23acdde696ddd64c022f550ee7f099a5aa --- /dev/null +++ b/themes/fid/templates/fid/order/list/table.phtml @@ -0,0 +1,15 @@ +<!-- fid: fid - order - list - table --> +<table class="table"> + <?php /* Table head */ ?> + <tr> + <?=$this->render('fid/order/list/headers')?> + </tr> + <?php /* Table contents */ ?> + <?php foreach ($orders as $order): + /** @var $order \fid\Service\DataTransferObject\Order */?> + <tr name="order-<?=$this->escapeHtml($order->getId())?>"> + <?=$this->context($this)->renderInContext('fid/order/list/entry', compact('order'))?> + </tr> + <?php endforeach; ?> +</table> +<!-- fid: fid - order - list - table - END --> diff --git a/themes/fid/templates/fid/order/order-list-admin.phtml b/themes/fid/templates/fid/order/order-list-admin.phtml new file mode 100644 index 0000000000000000000000000000000000000000..10fa927552e320c3a3870bbd1d87312a1c5901e9 --- /dev/null +++ b/themes/fid/templates/fid/order/order-list-admin.phtml @@ -0,0 +1,10 @@ +<!-- fid: fid - order - admin-list --> +<h1><?= $this->translate('fid::order_list') ?></h1> +<?= $this->flashmessages() ?> + +<?php if (empty($orders)): ?> + <?=$this->translate('fid::user_orders_empty')?> +<?php else: ?> + <?=$this->render('fid/order/list/table')?> +<?php endif; ?> +<!-- fid: fid - order - admin-list - END --> \ No newline at end of file diff --git a/themes/fid/templates/fid/order/order-list.phtml b/themes/fid/templates/fid/order/order-list.phtml new file mode 100644 index 0000000000000000000000000000000000000000..a9f065b16a591fc13c1537059fe70988b97373e3 --- /dev/null +++ b/themes/fid/templates/fid/order/order-list.phtml @@ -0,0 +1,7 @@ +<!-- fid: fid - order - list --> +<?php if (empty($orders)): ?> + <?=$this->translate('fid::user_orders_empty')?> +<?php else: ?> + <?=$this->render('fid/order/list/table')?> +<?php endif; ?> +<!-- fid: fid - order - list - END --> diff --git a/themes/fid/templates/fid/user/admin-orders.phtml b/themes/fid/templates/fid/user/admin-orders.phtml deleted file mode 100644 index 69ecaa94b96fd61764d029916ea48eae0df1bfa8..0000000000000000000000000000000000000000 --- a/themes/fid/templates/fid/user/admin-orders.phtml +++ /dev/null @@ -1,67 +0,0 @@ -<!-- fid: fid - admin - orders --> -<?php - use fid\Controller\RecordController; -?> - -<h1><?= $this->translate('fid::order_list') ?></h1> -<?= $this->flashmessages() ?> - -<?php if (empty($orders)): ?> - <?=$this->translate('fid::user_orders_empty')?> -<?php else: ?> - <table class="table"> - - <tr> - <?= in_array('type',$this->displayCols) - ? "<th>{$this->translate('fid::order_type')}</th>" - : ''?> - <th><?=$this->translate('Date')?></th> - <th><?=$this->translate('fid::order_record')?></th> - <th><?=$this->translate('fid::order_user')?></th> - <?= in_array('status',$this->displayCols) - ? "<th>{$this->translate('fid::order_label_status')}</th>" - : ''?> - <?= in_array('dueDate',$this->displayCols) - ? "<th>{$this->translate('fid::order_label_due_date')}</th>" - : '' ?> - <?= in_array('edit',$this->displayCols) - ? "<th></th>" - : ''?> - </tr> - - <?php foreach ($orders as $order): - /** @var $order \fid\Service\DataTransferObject\Order */?> - - <tr name="order-<?=$this->escapeHtml($order->getId())?>"> - <?= in_array('status',$this->displayCols) - ? "<td>" . $this->translate("fid::acquisition_{$order->getType()}") . "</td>" - : '' ?> - <td><?=$this->escapeHtml($order->getCreatedAt()->format('d.m.Y'))?></td> - - <?=$this->render('fid/user/orders/additionals-data', compact('order'))?> - <td> - <?php - /** @var \fid\Service\DataTransferObject\User $user */ - if ($user = $order->getUser()) : ?> - <?= $user->getFirstname() ?> <?= $user->getLastname() ?> - <?php else: ?> - <?= $this->translate('fid::user_deleted') ?> - <?php endif; ?> - </td> - <?= in_array('status',$this->displayCols) - ? "<td>" . ($order->getStatus() ? $this->translate('fid::status_'.$order->getStatus()) : '' . "</td>") - : '' ?> - <?php if(in_array('dueDate',$this->displayCols)): ?> - <?= ($order->getType() == RecordController::PDA) && ($order->isOverdue()) && ($order->getStatus() != 'completed') - ? "<td><div class=\"alert alert-danger\" role=\"alert\">{$this->icon('warning')}{$order->displayDueDate()}</div></td>" - : "<td>{$order->displayDueDate()}</td>" ?> - <?php endif; ?> - <?= in_array('edit',$this->displayCols) - ? "<td><a href=\"{$this->url('fid/admin/editOrder', ['orderid' => $order->getId()])}\">{$this->icon('pen')}</td>" - : '' ?> - </tr> - - <?php endforeach; ?> - </table> -<?php endif; ?> -<!-- fid: fid - admin - orders - END --> \ No newline at end of file diff --git a/themes/fid/templates/fid/user/orders.phtml b/themes/fid/templates/fid/user/orders.phtml deleted file mode 100644 index 9c3448e863909d0770a1218aacb3f37b1d4c1d86..0000000000000000000000000000000000000000 --- a/themes/fid/templates/fid/user/orders.phtml +++ /dev/null @@ -1,18 +0,0 @@ -<!-- fid: fid - user - orders --> -<?php if (empty($orders)): ?> - <?=$this->translate('fid::user_orders_empty')?> -<?php else: ?> - <table class="table"> - <tr> - <th><?=$this->translate('Date')?></th> - <?=$this->render('fid/user/orders/additionals-headers');?> - <?= in_array('status',$this->displayCols) - ? "<th>{$this->translate('fid::order_label_status')}</th>" - : ''?> - </tr> - <?php foreach ($orders as $order): ?> - <?=$this->render('fid/user/orders/entry', compact('order','displayCols'))?> - <?php endforeach; ?> - </table> -<?php endif; ?> -<!-- fid: fid - user - orders - END --> diff --git a/themes/fid/templates/fid/user/orders/additionals-headers.phtml b/themes/fid/templates/fid/user/orders/additionals-headers.phtml deleted file mode 100644 index 071f9041c26d61cb4bb592b318ae2325d3786d37..0000000000000000000000000000000000000000 --- a/themes/fid/templates/fid/user/orders/additionals-headers.phtml +++ /dev/null @@ -1,3 +0,0 @@ -<!-- fid: fid - user - orders - additionals-headers --> -<th><?=$this->translate('fid::order_record')?></th> -<!-- fid: fid - user - orders - additionals-headers - END --> \ No newline at end of file diff --git a/themes/fid/templates/fid/user/orders/entry.phtml b/themes/fid/templates/fid/user/orders/entry.phtml deleted file mode 100644 index daecf9de8e5104e2c4bca6451b0ad0ecb82a4878..0000000000000000000000000000000000000000 --- a/themes/fid/templates/fid/user/orders/entry.phtml +++ /dev/null @@ -1,9 +0,0 @@ -<!-- fid: fid - user - orders - entry --> -<tr name="order-<?=$this->escapeHtml($this->order->getId())?>"> - <td><?=$this->escapeHtml($this->order->getCreatedAt()->format('d.m.Y'))?></td> - <?=$this->render('fid/user/orders/additionals-data', compact('order'))?> - <?= in_array('status',$this->displayCols) - ? "<td>" . ($order->getStatus() ? $this->translate('fid::status_'.$order->getStatus()) : '' . "</td>") - : '' ?> -</tr> -<!-- fid: fid - user - orders - entry - END --> \ No newline at end of file diff --git a/themes/finc/theme.config.php b/themes/finc/theme.config.php index 652545a3d02d4d550bb1be2fc57cace7edd3cac8..3ef3ecf92de34db3394a590422ae5dcfa8c41f7f 100644 --- a/themes/finc/theme.config.php +++ b/themes/finc/theme.config.php @@ -18,6 +18,7 @@ return [ 'record' => 'finc\View\Helper\Root\Record', 'flashmessages' => 'finc\View\Helper\Root\Flashmessages', 'externalLink' => 'finc\View\Helper\Root\ExternalLink', + 'renderArray' => 'finc\View\Helper\Root\RenderArray', ], 'factories' => [ 'finc\View\Helper\Root\BranchInfo' => @@ -44,6 +45,8 @@ return [ 'VuFind\View\Helper\Root\FlashmessagesFactory', 'finc\View\Helper\Root\ExternalLink' => 'finc\View\Helper\Root\Factory::getExternalLink', + 'finc\View\Helper\Root\RenderArray' => + 'finc\View\Helper\Root\Factory::getRenderArray', ] ] ];