diff --git a/module/fid/config/module.config.php b/module/fid/config/module.config.php index 136603486a2cf34d155f670a6d28e69c680fac8d..f80bb7d8be1cee5d85d05782ab9a2090fd90debf 100644 --- a/module/fid/config/module.config.php +++ b/module/fid/config/module.config.php @@ -293,7 +293,17 @@ return [ 'action' => 'updateUsername', ], ], - ] + ], + 'orders' => [ + 'type' => 'literal', + 'options' => [ + 'route' => '/orders', + 'defaults' => [ + 'controller' => UserController::class, + 'action' => 'orders', + ], + ], + ], ], ], 'admin' => [ diff --git a/module/fid/src/Controller/UserController.php b/module/fid/src/Controller/UserController.php index 976ae2f35823e6a0294317bbac03a1db29425092..4f32010a402b708e726e14de03dc54bc39703e87 100644 --- a/module/fid/src/Controller/UserController.php +++ b/module/fid/src/Controller/UserController.php @@ -682,4 +682,21 @@ class UserController extends AbstractBase return $viewModel; } + public function ordersAction() + { + if (!$this->getUser()) { + return $this->forceLogin(); + } + try { + $user = $this->client->requestUserDetails(); + $viewModel = $this->createViewModel(); + $viewModel->setVariable('orders',$user->getOrders()); + $viewModel->setVariable('addresses',$user->getAddresses()); + $viewModel->setTemplate('fid/user/orders'); + return $viewModel; + } catch (ClientException $exception) { + $this->getMessenger()->addErrorMessage('fid::orders_error'); + $this->redirect()->toRoute('myresearch-profile'); + } + } } diff --git a/themes/fid/languages/fid/de.ini b/themes/fid/languages/fid/de.ini index 171ada33fdf9e9be0cd3dd4f92dd148abbb1caca..141566f29e1671282f9b17b2757a0e7250bec015 100644 --- a/themes/fid/languages/fid/de.ini +++ b/themes/fid/languages/fid/de.ini @@ -73,6 +73,12 @@ user_update_error_403 = "Es ist ein Fehler beim Aktualisieren Ihres Profils aufg user_update_error_expired = "Bitte loggen Sie sich ein, um Ihr Profil zu editieren." user_update_success = "Ihr Profil wurde erfolgreich aktualisiert." +user_my_orders = "Buchbestellungen" +orders_error = "Fehler beim Abrufen der Bestellungen" +user_orders_empty = "Für Ihr Profil liegen in den letzten 3 Monaten keine Bestellungen vor." +order_delivery_address = "Lieferadresse" +order_record = "Bestellter Titel" + password_reset_error = "Es ist ein unerwarteter Fehler aufgetreten." password_reset_error_username = "Bitte überprüfen Sie die angegebende E-Mail-Adresse %s." password_reset_success = "Ein Link zum Ändern Ihres Passworts wurde soeben an Ihre angegebene E-Mail-Adresse %s gesendet. Die Zustellung kann einige Minuten in Anspruch nehmen. Bitte schauen Sie ggf. auch in Ihren Spamordner." diff --git a/themes/fid/languages/fid/en.ini b/themes/fid/languages/fid/en.ini index 46d63548cf7202750593e4e766ace96c9c8b0533..562e9f54be4b8ef8ef73ddf75ad7f21da3637434 100644 --- a/themes/fid/languages/fid/en.ini +++ b/themes/fid/languages/fid/en.ini @@ -73,6 +73,12 @@ user_update_error = "An unexpected error has occurred when updating your profile user_update_error_403 = "An error has occurred when updating your profile: Forbidden." user_update_error_expired = "Please log in to edit your profile." +user_my_orders = "PDA Order Items" +orders_error = "Error when retrieving list of orders" +user_orders_empty = "There are no orders for your profile within the last 3 months." +order_delivery_address = "Delivery Address" +order_record = "Ordered Record" + password_reset_error = "An unexpected error has occurred." password_reset_error_username = "Please check if the email address %s is valid." password_reset_success = "We have sent you an e-mail to %s containing a link for changing your password. This may take several minutes. Please check also the junk folder of your mailbox." diff --git a/themes/fid/templates/fid/user/address-display-inline.phtml b/themes/fid/templates/fid/user/address-display-inline.phtml new file mode 100644 index 0000000000000000000000000000000000000000..2a4f6007cdb6a8e949d23de587f37fc1ea6c5f81 --- /dev/null +++ b/themes/fid/templates/fid/user/address-display-inline.phtml @@ -0,0 +1,5 @@ +<!-- fid: fid - user - address-display-inline --> +<span class="address-inline"> + <?=$this->escapeHtml($address->getLine1())?><?=$address->getLine2() ? ' '.$this->escapeHtml($address->getLine2()) : ''?>; <?=$this->escapeHtml($address->getZip())?> <?=$this->escapeHtml($address->getCity())?>, <?=$this->escapeHtml($address->getCountry())?> +</span> +<!-- fid: fid - user - address-display-inline - 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 new file mode 100644 index 0000000000000000000000000000000000000000..27c692d023e16439c4be116c2731931652dff166 --- /dev/null +++ b/themes/fid/templates/fid/user/orders.phtml @@ -0,0 +1,15 @@ +<!-- 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');?> + </tr> + <?php foreach ($orders as $order): ?> + <?=$this->render('fid/user/orders/entry', compact('order', 'addresses'))?> + <?php endforeach; ?> + </table> +<?php endif; ?> +<!-- fid: fid - user - orders - END --> diff --git a/themes/fid/templates/fid/user/orders/additionals-data.phtml b/themes/fid/templates/fid/user/orders/additionals-data.phtml new file mode 100644 index 0000000000000000000000000000000000000000..3b352ec39a5f9fd1e7174a0d88d0aa88face618e --- /dev/null +++ b/themes/fid/templates/fid/user/orders/additionals-data.phtml @@ -0,0 +1,20 @@ +<!-- fid: fid - user - orders - data --> +<td> + <?php $recordId = $data['recordId']; + $recordLabel = $data['recordTitle'] ?? $recordId; + //$recordLabel = "ʙ"; + if ($recordLink = $this->recordLink()->getRecordLink($recordId, 'id')): + ?> + <a onClick="$('#modal').modal('hide');" target="_self" href="<?=$recordLink?>"><?=$this->escapeHtml($recordLabel)?></a> + <?php else: ?> + <?=$this->escapeHtml($recordLabel)?> + <?php endif; ?> +</td> +<td> + <?php $addressId = $data['deliveryAddress']; + if (isset($addresses[$addressId])): + ?> + <?=$this->render('fid/user/address-display-inline', ['address' => $addresses[$addressId]])?> + <?php endif; ?> +</td> +<!-- fid: fid - user - orders - data - END --> diff --git a/themes/fid/templates/fid/user/orders/additionals-headers.phtml b/themes/fid/templates/fid/user/orders/additionals-headers.phtml new file mode 100644 index 0000000000000000000000000000000000000000..33716cf0adf1906ecf076386107055524824a639 --- /dev/null +++ b/themes/fid/templates/fid/user/orders/additionals-headers.phtml @@ -0,0 +1,4 @@ +<!-- fid: fid - user - orders - additionals-headers --> +<th><?=$this->translate('fid::order_record')?></th> +<th><?=$this->translate('fid::order_delivery_address')?></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 new file mode 100644 index 0000000000000000000000000000000000000000..706274c226d6a3a9fc5f5ac21f7b84cd3279fa45 --- /dev/null +++ b/themes/fid/templates/fid/user/orders/entry.phtml @@ -0,0 +1,7 @@ +<!-- fid: fid - user - orders - entry --> +<tr name="order-<?=$this->escapeHtml($order->getId())?>"> + <td><?=$this->escapeHtml($order->getCreatedAt()->format('d.m.Y'))?></td> + <?php $data = $order->getData() ?> + <?=$this->render('fid/user/orders/additionals-data', compact('data', 'addresses'))?> +</tr> +<!-- fid: fid - user - orders - entry - END --> \ No newline at end of file diff --git a/themes/fid/templates/myresearch/menu.phtml b/themes/fid/templates/myresearch/menu.phtml index e5ec96b1f33a5ce1680fa3e5b3319affec95d98d..8d8d8aa4c5ed1b46fef6fe900770a49f13ed48a3 100644 --- a/themes/fid/templates/myresearch/menu.phtml +++ b/themes/fid/templates/myresearch/menu.phtml @@ -13,8 +13,6 @@ <!-- fid: myresearch - menu.phtml --> <?php $user = $this->auth()->isLoggedIn(); - $patron = $user ? $this->auth()->getILSPatron() : false; - $capabilityParams = $patron ? ['patron' => $patron] : []; ?> <?php /* Offcanvas closing button missing in BS3! CK*/ ?> <button class="close-offcanvas btn btn-link" data-toggle="offcanvas"><?=$this->transEsc('navigate_back') ?></button> @@ -23,66 +21,26 @@ <h4><?=$this->transEsc('Your Account')?></h4> <div class="myresearch-menu account-menu"> <?php if ('ils-none' !== $this->ils()->getOfflineMode()): ?> - <?php if ($this->ils()->checkCapability('getMyTransactions', $capabilityParams)): ?> - <a href="<?=$this->url('myresearch-checkedout')?>" class="flex checkedout<?=$this->active == 'checkedout' ? ' active' : ''?>"> - <span class="flex-col"><i class="fa fa-fw fa-book" aria-hidden="true"></i> <?=$this->transEsc('Checked Out Items')?></span> - <span class="checkedout-status status hidden"><i class="fa fa-spin fa-spinner" aria-hidden="true"></i></span> - </a> - <?php endif; ?> - <?php if ($this->ils()->checkFunction('getMyTransactionHistory', $capabilityParams)): ?> - <a href="<?=$this->url('myresearch-historicloans')?>"<?=$this->active == 'historicloans' ? ' class="active"' : ''?>> - <i class="fa fa-fw fa-history" aria-hidden="true"></i> <?=$this->transEsc('Loan History')?> - </a> - <?php endif; ?> - <?php if ($this->ils()->checkCapability('getMyHolds', $capabilityParams)): ?> - <a href="<?=$this->url('myresearch-holds')?>" class="flex<?=$this->active == 'holds' ? ' active' : ''?>"> - <span class="flex-col"><i class="fa fa-fw fa-flag" aria-hidden="true"></i> <?=$this->transEsc('Holds and Recalls')?></span> - <span class="holds-status status hidden"><i class="fa fa-spin fa-spinner" aria-hidden="true"></i></span> - </a> - <?php endif; ?> - <?php if ($this->ils()->checkFunction('StorageRetrievalRequests', $capabilityParams)): ?> - <a href="<?=$this->url('myresearch-storageretrievalrequests')?>" class="flex<?=$this->active == 'storageRetrievalRequests' ? ' active' : ''?>"> - <span class="flex-col"><i class="fa fa-fw fa-archive" aria-hidden="true"></i> <?=$this->transEsc('Storage Retrieval Requests')?></span> - <span class="storageretrievalrequests-status status hidden"><i class="fa fa-spin fa-spinner" aria-hidden="true"></i></span> - </a> - <?php endif; ?> - <?php if ($this->ils()->checkFunction('ILLRequests', $capabilityParams)): ?> - <a href="<?=$this->url('myresearch-illrequests')?>" class="flex<?=$this->active == 'ILLRequests' ? ' active' : ''?>"> - <span class="flex-col"><i class="fa fa-fw fa-exchange" aria-hidden="true"></i> <?=$this->transEsc('Interlibrary Loan Requests')?></span> - <span class="illrequests-status status hidden"><i class="fa fa-spin fa-spinner" aria-hidden="true"></i></span> - </a> - <?php endif; ?> - <?php if ($this->ils()->checkCapability('getMyFines', $capabilityParams)): ?> - <a href="<?=$this->url('myresearch-fines')?>" class="flex<?=$this->active == 'fines' ? ' active' : ''?>"> - <span class="flex-col"><i class="fa fa-fw fa-usd" aria-hidden="true"></i> <?=$this->transEsc('Fines')?></span> - <span class="fines-status status hidden"><i class="fa fa-spin fa-spinner" aria-hidden="true"></i></span> - </a> - <?php endif; ?> <a href="<?=$this->url('myresearch-profile')?>"<?=$this->active == 'profile' ? ' class="active"' : ''?>> <i class="fa fa-fw fa-user" aria-hidden="true"></i> <?=$this->transEsc('Profile')?> </a> <?php /* refs #15480 add password change to fid profile */ ?> - <?php if ($this->auth()->isLoggedIn()): ?> <a href="<?=$this->url('fid/user/reset-password')?>" data-lightbox> <span class="no-padding"> <i class="fa fa-fw fa-lock" aria-hidden="true"></i> </span> <?=$this->transEsc('Change Password')?> </a> - <? endif; ?> - <?php if ($this->auth()->isLoggedIn()): ?> <a href="<?=$this->url('fid/user/change-username')?>" data-lightbox> <span class="no-padding"> <i class="fa fa-fw fa-envelope" aria-hidden="true"></i> </span> <?=$this->transEsc('fid::username_change_link')?> </a> - <? endif; ?> - <?php if ($user = $this->auth()->isLoggedIn()): ?> <span class="logout-button"> <a href="<?=$this->url('myresearch-logout')?>"> <span class="no-padding"> @@ -92,9 +50,8 @@ <?=$this->transEsc("Logout")?> </a> </span> - <? endif; ?> - <?php if ($user && $user->libraryCardsEnabled()): ?> + <?php if ($user->libraryCardsEnabled()): ?> <a href="<?=$this->url('librarycards-home')?>"<?=$this->active == 'librarycards' ? ' class="active"' : ''?>> <i class="fa fa-fw fa-barcode" aria-hidden="true"></i> <?=$this->transEsc('Library Cards')?> </a> @@ -103,7 +60,7 @@ </div> <br /> - <?php if ($user && $this->userlist()->getMode() !== 'disabled'): ?> + <?php if ($this->userlist()->getMode() !== 'disabled'): ?> <h4><?=$this->transEsc('Your Lists')?></h4> <div class="myresearch-menu">