From 8de4b0614fd7386f2e2d97b830dd0058a6dee458 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. Signed-off-by: Niamh Walker-Headon Sponsored-by: PTFS Europe --- Koha/Illrequest.pm | 2 +- Koha/REST/V1/Library.pm | 2 ++ admin/branches.pl | 1 + .../atomicupdate/bug_22818_add_ill_notices.perl | 38 ++++++++++++++++++++++ installer/data/mysql/kohastructure.sql | 1 + installer/data/mysql/sysprefs.sql | 2 ++ .../prog/en/includes/messaging-preference-form.inc | 2 ++ .../prog/en/modules/admin/branches.tt | 6 ++++ .../prog/en/modules/admin/categories.tt | 2 ++ .../en/modules/admin/preferences/circulation.pref | 8 +++++ .../bootstrap/en/modules/opac-messaging.tt | 2 ++ 11 files changed, 65 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 1ca2991628..14c4ce7c91 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -1064,7 +1064,7 @@ EOF my @address = map { $branch->$_ } 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/REST/V1/Library.pm b/Koha/REST/V1/Library.pm index 0bf16ee60b..6139d93645 100644 --- a/Koha/REST/V1/Library.pm +++ b/Koha/REST/V1/Library.pm @@ -276,6 +276,7 @@ our $to_api_mapping = { branchphone => 'phone', branchfax => 'fax', branchemail => 'email', + branchillemail => 'illemail', branchreplyto => 'reply_to_email', branchreturnpath => 'return_path_email', branchurl => 'url', @@ -303,6 +304,7 @@ our $to_model_mapping = { phone => 'branchphone', fax => 'branchfax', email => 'branchemail', + illemail => 'branchillemail', reply_to_email => 'branchreplyto', return_path_email => 'branchreturnpath', url => 'branchurl', diff --git a/admin/branches.pl b/admin/branches.pl index 68b9c25ce5..cbda36eea0 100755 --- a/admin/branches.pl +++ b/admin/branches.pl @@ -66,6 +66,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 94cac768ca..4380f1125b 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -261,6 +261,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/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 6ce6ee15e0..00cb80d3e7 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -230,6 +230,8 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('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'), +('ILLDefaultStaffEmail', '', NULL, 'Fallback email address for staff ILL notices to be sent to in the absence of a branch address', 'Free'), +('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 e0c880f652..b6eaf1ad35 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 @@ -21,6 +21,8 @@ [% ELSIF ( messaging_preference.Hold_Filled ) %]Hold filled [% ELSIF ( messaging_preference.Item_Check_in ) %]Item check-in [% ELSIF ( messaging_preference.Item_Checkout ) %]Item checkout + [% 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 119b555f8e..3f11b29fd8 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
  • @@ -221,6 +225,8 @@
    Fax: [% library.branchfax | html %][% END %] [% IF library.branchemail %]
    [% library.branchemail | html %][% END %] + [% IF library.branchillemail && Koha.Preference('ILLModule') %] +
    [% library.branchillemail | html %][% END %] [% IF library.branchurl %]
    [% library.branchurl | html %][% END %] [% IF library.opac_info %] 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 f2704e9b57..eb39199ca2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt @@ -485,6 +485,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 199809f139..314a13e029 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 @@ -827,6 +827,14 @@ Circulation: yes: Enable no: Disable - unmediated Interlibrary loan requests. If enabled and the ILL backend supports it, the newly created requests are immediately requested by backend. + - + - "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: - - Calculate fines based on days overdue 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 fdd5571580..abfba3dac7 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt @@ -52,6 +52,8 @@ [% ELSIF ( messaging_preference.Hold_Filled ) %]Hold filled [% ELSIF ( messaging_preference.Item_Check_in ) %]Item check-in [% ELSIF ( messaging_preference.Item_Checkout ) %]Item checkout + [% ELSIF ( messaging_preference.Ill_ready ) %]Interlibrary loan ready + [% ELSIF ( messaging_preference.Ill_unavailable ) %]Interlibrary loan unavailable [% ELSE %]Unknown [% END %] [% IF ( messaging_preference.takes_days ) %]