From 5603699b0c7a511cf4428bdaaa0be1c375b06157 Mon Sep 17 00:00:00 2001 From: Andrew Isherwood Date: Tue, 7 May 2019 11:09:58 +0100 Subject: [PATCH] Bug 22818: Add notices sysprefs and DB column This patch adds two new sysprefs. 'ILLDefaultEmail', 'ILLSendStaffNotices' and a new column to the branches table called 'branchillemail'. It also adds five ILL related notices. Here we are providing the ability for a branch to have a dedicated email address for it's ILL staff, the idea being that any notices sent by ILL to staff need to go to specific staff, rather than the general branch email address. If no branch specific address is defined, the address specified in the ILLDefaultEmail syspref is used. We're also providing a syspref 'ILLSendStaffNotices' to allow the user to specify which notices should be sent to staff upon certain events. We are also providing patron messaging preferences for the two patron bound notices We are also providing five notices for various ILL related events. Sponsored-by: PTFS Europe Signed-off-by: Niamh Walker-Headon Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- Koha/Illrequest.pm | 2 +- Koha/Library.pm | 1 + admin/branches.pl | 1 + .../atomicupdate/bug_22818_add_ill_notices.perl | 38 ++++++++++++++++++++++ installer/data/mysql/kohastructure.sql | 1 + installer/data/mysql/mandatory/sysprefs.sql | 2 ++ .../prog/en/includes/messaging-preference-form.inc | 2 ++ .../prog/en/modules/admin/branches.tt | 4 +++ .../prog/en/modules/admin/categories.tt | 2 ++ .../en/modules/admin/preferences/circulation.pref | 8 +++++ .../bootstrap/en/modules/opac-messaging.tt | 2 ++ 11 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug_22818_add_ill_notices.perl diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm index 269e45a949..18348663d1 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -1312,7 +1312,7 @@ EOF my @address = map { $library->$_ } qw/ branchname branchaddress1 branchaddress2 branchaddress3 branchzip branchcity branchstate branchcountry branchphone - branchemail /; + branchillemail branchemail /; my $address = ""; foreach my $line ( @address ) { $address .= $line . "\n" if $line; diff --git a/Koha/Library.pm b/Koha/Library.pm index 165d974f44..dd5459f343 100644 --- a/Koha/Library.pm +++ b/Koha/Library.pm @@ -179,6 +179,7 @@ sub to_api_mapping { branchphone => 'phone', branchfax => 'fax', branchemail => 'email', + branchillemail => 'illemail', branchreplyto => 'reply_to_email', branchreturnpath => 'return_path_email', branchurl => 'url', diff --git a/admin/branches.pl b/admin/branches.pl index 98a2d1f49f..9bcb379178 100755 --- a/admin/branches.pl +++ b/admin/branches.pl @@ -75,6 +75,7 @@ if ( $op eq 'add_form' ) { branchphone branchfax branchemail + branchillemail branchreplyto branchreturnpath branchurl diff --git a/installer/data/mysql/atomicupdate/bug_22818_add_ill_notices.perl b/installer/data/mysql/atomicupdate/bug_22818_add_ill_notices.perl new file mode 100644 index 0000000000..9df46a0813 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_22818_add_ill_notices.perl @@ -0,0 +1,38 @@ +$DBversion = 'XXX'; +if( CheckVersion( $DBversion ) ) { + if( !column_exists( 'branches', 'branchillemail' ) ) { + $dbh->do( q| ALTER TABLE branches ADD branchillemail LONGTEXT AFTER branchemail | ); + } + # Add new sysprefs + $dbh->do( q| INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) VALUES ('ILLDefaultStaffEmail', '', 'Fallback email address for staff ILL notices to be sent to in the absence of a branch address', NULL, 'Free'); | ); + $dbh->do( q| INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) VALUES ('ILLSendStaffNotices', NULL, 'Send these ILL notices to staff', NULL, 'multiple'); | ); + # Add new notices + $dbh->do( q| INSERT IGNORE INTO letter(module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES ('ill', 'ILL_PICKUP_READY', '', 'ILL request ready for pickup', 0, "Interlibrary loan request ready for pickup", "Dear <> <>,\n\nThe Interlibrary loans request number <> you placed for:\n\n- <> - <>\n\nis ready for pick up from <>.\n\nKind Regards\n\n<>\n<>\n<>\n<>\n<>\n<>\n<>\n<>\n<>\n<>", 'email', 'default'); | ); + $dbh->do( q| INSERT IGNORE INTO letter(module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES ('ill', 'ILL_REQUEST_UNAVAIL', '', 'ILL request unavailable', 0, "Interlibrary loan request unavailable", "Dear <> <>,\n\nThe Interlibrary loans request number <> you placed for\n\n- <> - <>\n\nis unfortunately unavailable.\n\nKind Regards\n\n<>\n<>\n<>\n<>\n<>\n<>\n<>\n<>\n<>\n<>", 'email', 'default'); | ); + $dbh->do( q| INSERT IGNORE INTO letter(module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES ('ill', 'ILL_REQUEST_CANCEL', '', 'ILL request cancelled', 0, "Interlibrary loan request cancelled", "The patron for interlibrary loans request <>, with the following details, has requested cancellation of this ILL request:\n\n<>", 'email', 'default'); | ); + $dbh->do( q| INSERT IGNORE INTO letter(module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES ('ill', 'ILL_REQUEST_MODIFIED', '', 'ILL request modified', 0, "Interlibrary loan request modified", "The patron for interlibrary loans request <>, with the following details, has modified this ILL request:\n\n<>", 'email', 'default'); | ); + $dbh->do( q| INSERT IGNORE INTO letter(module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES ('ill', 'ILL_PARTNER_REQ', '', 'ILL request to partners', 0, "Interlibrary loan request to partners", "Dear Sir/Madam,\n\nWe would like to request an interlibrary loan for a title matching the following description:\n\n<>\n\nPlease let us know if you are able to supply this to us.\n\nKind Regards\n\n<>\n<>\n<>\n<>\n<>\n<>\n<>\n<>\n<>\n<>", 'email', 'default'); | ); + $dbh->do( q| INSERT IGNORE INTO letter(module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES ('ill', 'ILL_PICKUP_READY', '', 'ILL request ready for pickup', 0, "Interlibrary loan request ready for pickup", "Dear <> <>,\n\nThe Interlibrary loans request number <> you placed for:\n\n- <> - <>\n\nis ready for pick up from <>.\n\nKind Regards\n\n<>\n<>\n<>\n<>\n<>\n<>\n<>\n<>\n<>\n<>", 'sms', 'default'); | ); + $dbh->do( q| INSERT IGNORE INTO letter(module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES ('ill', 'ILL_REQUEST_UNAVAIL', '', 'ILL request unavailable', 0, "Interlibrary loan request unavailable", "Dear <> <>,\n\nThe Interlibrary loans request number <> you placed for\n\n- <> - <>\n\nis unfortunately unavailable.\n\nKind Regards\n\n<>\n<>\n<>\n<>\n<>\n<>\n<>\n<>\n<>\n<>", 'sms', 'default'); | ); + $dbh->do( q| INSERT IGNORE INTO letter(module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES ('ill', 'ILL_REQUEST_CANCEL', '', 'ILL request cancelled', 0, "Interlibrary loan request cancelled", "The patron for interlibrary loans request <>, with the following details, has requested cancellation of this ILL request:\n\n<>", 'sms', 'default'); | ); + $dbh->do( q| INSERT IGNORE INTO letter(module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES ('ill', 'ILL_REQUEST_MODIFIED', '', 'ILL request modified', 0, "Interlibrary loan request modified", "The patron for interlibrary loans request <>, with the following details, has modified this ILL request:\n\n<>", 'sms', 'default'); | ); + $dbh->do( q| INSERT IGNORE INTO letter(module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES ('ill', 'ILL_PARTNER_REQ', '', 'ILL request to partners', 0, "Interlibrary loan request to partners", "Dear Sir/Madam,\n\nWe would like to request an interlibrary loan for a title matching the following description:\n\n<>\n\nPlease let us know if you are able to supply this to us.\n\nKind Regards\n\n<>\n<>\n<>\n<>\n<>\n<>\n<>\n<>\n<>\n<>", 'sms', 'default'); | ); + # Add patron messaging preferences + $dbh->do( q| INSERT IGNORE INTO message_attributes (message_name, takes_days) VALUES ('Ill_ready', 0); | ); + my $ready_id = $dbh->{mysql_insertid}; + if (defined $ready_id) { + $dbh->do( qq(INSERT IGNORE INTO message_transports (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) VALUES ($ready_id, 'email', 0, 'ill', 'ILL_PICKUP_READY');) ); + $dbh->do( qq(INSERT IGNORE INTO message_transports (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) VALUES ($ready_id, 'sms', 0, 'ill', 'ILL_PICKUP_READY');) ); + $dbh->do( qq(INSERT IGNORE INTO message_transports (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) VALUES ($ready_id, 'phone', 0, 'ill', 'ILL_PICKUP_READY');) ); + } + $dbh->do( q| INSERT IGNORE INTO message_attributes (message_name, takes_days) VALUES ('Ill_unavailable', 0); | ); + my $unavail_id = $dbh->{mysql_insertid}; + if (defined $unavail_id) { + $dbh->do( qq(INSERT IGNORE INTO message_transports (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) VALUES ($unavail_id, 'email', 0, 'ill', 'ILL_REQUEST_UNAVAIL');) ); + $dbh->do( qq(INSERT IGNORE INTO message_transports (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) VALUES ($unavail_id, 'sms', 0, 'ill', 'ILL_REQUEST_UNAVAIL');) ); + $dbh->do( qq(INSERT IGNORE INTO message_transports (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) VALUES ($unavail_id, 'phone', 0, 'ill', 'ILL_REQUEST_UNAVAIL');) ); + } + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 22818 - Add ILL notices)\n"; +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index fc9953bb2b..2ea99d4015 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -265,6 +265,7 @@ CREATE TABLE `branches` ( -- information about your libraries or branches are st `branchphone` LONGTEXT, -- the primary phone for your library or branch `branchfax` LONGTEXT, -- the fax number for your library or branch `branchemail` LONGTEXT, -- the primary email address for your library or branch + `branchillemail` LONGTEXT, -- the ILL staff email address for your library or branch `branchreplyto` LONGTEXT, -- the email to be used as a Reply-To `branchreturnpath` LONGTEXT, -- the email to be used as Return-Path `branchurl` LONGTEXT, -- the URL for your library or branch's website diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 890dfcfe8f..952c18fc80 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -239,12 +239,14 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('HTML5MediaYouTube',0,'Embed|Don\'t embed','YouTube links as videos','YesNo'), ('IdRef','0','','Disable/enable the IdRef webservice from the OPAC detail page.','YesNo'), ('IllCheckAvailability', 0, '', 'If ON, during the ILL request process third party sources will be checked for current availability', 'YesNo'), +('ILLDefaultStaffEmail', '', NULL, 'Fallback email address for staff ILL notices to be sent to in the absence of a branch address', 'Free'), ('ILLHiddenRequestStatuses', NULL, NULL, 'ILL statuses that are considered finished and should not be displayed in the ILL module', 'multiple'), ('IllLog', 0, '', 'If ON, log information about ILL requests', 'YesNo'), ('ILLModule','0','If ON, enables the interlibrary loans module.','','YesNo'), ('ILLModuleCopyrightClearance','','70|10','Enter text to enable the copyright clearance stage of request creation. Text will be displayed','Textarea'), ('ILLModuleUnmediated','0','','If enabled, try to immediately progress newly placed ILL requests.','YesNo'), ('ILLOpacbackends',NULL,NULL,'ILL backends to enabled for OPAC initiated requests','multiple'), +('ILLSendStaffNotices', NULL, NULL, 'Send these ILL notices to staff', 'multiple'), ('ILS-DI','0','','Enables ILS-DI services at OPAC.','YesNo'), ('ILS-DI:AuthorizedIPs','','Restricts usage of ILS-DI to some IPs','.','Free'), ('ImageLimit','5','','Limit images stored in the database by the Patron Card image manager to this number.','Integer'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/messaging-preference-form.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/messaging-preference-form.inc index d2faaabb7d..c8f1437423 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/messaging-preference-form.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/messaging-preference-form.inc @@ -25,6 +25,8 @@ [% ELSE %] Item checkout [% END %] + [% ELSIF ( messaging_preference.Ill_ready ) %]Interlibrary loan ready + [% ELSIF ( messaging_preference.Ill_unavailable ) %]Interlibrary loan unavailable [% ELSE %]Unknown [% END %] [% IF ( messaging_preference.takes_days ) %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt index 94a83261e3..ca8412a60e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt @@ -1,3 +1,4 @@ +[% USE Koha %] [% USE raw %] [% USE Asset %] [% SET footerjs = 1 %] @@ -139,6 +140,9 @@
  • + [% IF (Koha.Preference('ILLModule')) %] +
  • + [% END %]

  • Default: ReplyToDefault system preference

  • Default: ReturnpathDefault system preference
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt index d83d7d27d3..0bacd6c126 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt @@ -536,6 +536,8 @@ [% ELSIF ( prefs.Hold_Filled ) %]Hold filled [% ELSIF ( prefs.Item_Check_in ) %]Item check-in [% ELSIF ( prefs.Item_Checkout ) %]Item checkout + [% ELSIF ( prefs.Ill_ready ) %]Interlibrary loan ready + [% ELSIF ( prefs.Ill_unavailable ) %]Interlibrary loan unavailable [% ELSE %]Unknown [% END %]: [% transport.transport | html %]
    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref index 753534cecb..a7ba030b65 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -923,6 +923,14 @@ Circulation: - pref: ILLHiddenRequestStatuses class: multi - (separated with |). If left empty, all ILL requests will be displayed. + - + - "Send these ILL notices to staff when appropriate" + - pref: ILLSendStaffNotices + class: multi + - (separated with |). e.g. ILL_REQUEST_CANCEL|ILL_REQUEST_MODIFIED If left empty, no staff ILL notices will be sent + - + - Fallback email address for staff ILL notices to be sent to in the absence of a branch address + - pref: ILLDefaultStaffEmail Fines Policy: - - pref: finesCalendar diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt index 0b44d80ade..3d376e64ff 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt @@ -66,6 +66,8 @@ [% ELSE %] Item checkout [% END %] + [% ELSIF ( messaging_preference.Ill_ready ) %]Interlibrary loan ready + [% ELSIF ( messaging_preference.Ill_unavailable ) %]Interlibrary loan unavailable [% ELSE %]Unknown [% END %] [% IF ( messaging_preference.takes_days ) %]