diff --git a/config/vufind/config.ini b/config/vufind/config.ini index 6dc6cfa4b75..4317178250b 100644 --- a/config/vufind/config.ini +++ b/config/vufind/config.ini @@ -375,6 +375,10 @@ renewals_enabled = false ; if available, but not supported by all drivers) title_level_holds_mode = "disabled" +; Email submitted request notifications to and from these addresses +;holds_email_to = "no-reply@myuniversity.edu" +;holds_email_from = "no-reply@myuniversity.edu" + ; Determines how holdings are grouped in the record display, using fields from ; the item information provided by the ILS driver. ; diff --git a/languages/en.ini b/languages/en.ini index 56ec648c798..1b001751aff 100644 --- a/languages/en.ini +++ b/languages/en.ini @@ -732,6 +732,7 @@ Item Description = "Item Description" Item Notes = "Notes" Item removed from favorites = "Item removed from saved items" Item removed from list = "Item removed from list" +item_barcode = "Item Barcode" Items = "Items" items = "items" items_added_to_bookbag = "%%count%% item(s) added to your Book Bag" @@ -1066,6 +1067,7 @@ password_only_numeric = "Numbers only" Passwords do not match = "Passwords do not match" past_days = "{range, plural, =1 {Yesterday} =7 {Past Week} other {Past # Days}}" patron_account_expires = "Expires" +patron_barcode = "Patron Barcode" patron_status_address_missing = "Your address is missing." patron_status_card_blocked = "This library card is blocked from borrowing." patron_status_card_expired = "Your library card has expired." @@ -1221,6 +1223,8 @@ renew_success = "Renewal Successful" renew_success_summary = "Successfully renewed {count, plural, =1 {1 item} other {# items}}." Renewed = "Renewed" Request full text = "Request full text" +request_email_item_message = "A request was placed for item: %%id%%" +request_email_subject = "Request Placed for item: %%id%%" request_in_transit = "In Transit to Pickup Location" request_place_text = "Place a Request" request_submit_text = "Submit Request" diff --git a/module/VuFind/src/VuFind/Controller/HoldsTrait.php b/module/VuFind/src/VuFind/Controller/HoldsTrait.php index ff06397c7cf..e0ab4085774 100644 --- a/module/VuFind/src/VuFind/Controller/HoldsTrait.php +++ b/module/VuFind/src/VuFind/Controller/HoldsTrait.php @@ -195,6 +195,7 @@ public function holdAction() // Success: Go to Display Holds if (isset($results['success']) && $results['success'] == true) { + $this->emailRequestPlaced($holdDetails); $msg = [ 'html' => true, 'msg' => empty($gatheredDetails['proxiedUser']) @@ -282,4 +283,57 @@ public function holdAction() $view->setTemplate('record/hold'); return $view; } + + /** + * Email the successful request to staff as a notification. + * + * @param array $holdDetails Details about the successful hold request + * + * @return void + */ + protected function emailRequestPlaced($holdDetails) + { + $config = $this->getConfig(); + $to = $this->getEmailRecipient($holdDetails); + $from = $config->Catalog->holds_email_from ?? null; + if (!$to || !$from) { + return; + } + + $renderer = $this->getViewRenderer(); + $message = $renderer->render( + 'Email/request-placed.phtml', + ['hold_details' => $holdDetails] + ); + + $subject = $this->translate('request_email_subject', [ + '%%id%%' => $holdDetails['id'] ?? '', + '%%barcode%%' => $holdDetails['barcode'] ?? '', + ]); + try { + $mailer = $this->getService(\VuFind\Mailer\Mailer::class); + $mailer->send( + $to, + $from, + $subject, + $message + ); + } catch (\VuFind\Exception\Mail $e) { + return; + } + } + + /** + * Get the appropriate staff email recipient for a hold request. This falls back + * on a configured default but may be overridden to vary based on the hold details. + * + * @param array $holdDetails Details about the successful hold request + * + * @return string The email address + */ + protected function getEmailRecipient($holdDetails) + { + $config = $this->getConfig(); + return $config->Catalog->holds_email_to ?? null; + } } diff --git a/themes/root/templates/Email/request-placed.phtml b/themes/root/templates/Email/request-placed.phtml new file mode 100644 index 00000000000..3dbdc175d5e --- /dev/null +++ b/themes/root/templates/Email/request-placed.phtml @@ -0,0 +1,19 @@ + +translate('request_email_item_message', ['%%id%%' => $hold_details['id']])?> + + +----- + +translate('patron_barcode')?>: + +translate('item_barcode')?>: + +translate('Title')?>: + +translate('Call Number')?>: + +translate('Location')?>: + +translate('Comments')?>: + +translate('request_group')?>: */ ?>