From 410d0e8927724183accfe2dffd0940703250c05a 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/Library.pm | 1 + admin/branches.pl | 1 + .../bug_22818_add_ill_notices.perl | 38 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 1 + installer/data/mysql/sysprefs.sql | 2 + .../en/includes/messaging-preference-form.inc | 2 + .../prog/en/modules/admin/branches.tt | 6 +++ .../prog/en/modules/admin/categories.tt | 2 + .../admin/preferences/circulation.pref | 8 ++++ .../bootstrap/en/modules/opac-messaging.tt | 2 + 11 files changed, 64 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 5ab0adc210..3962a9803c 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -1312,7 +1312,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/Library.pm b/Koha/Library.pm index b3f763a9ef..8c0c8d176e 100644 --- a/Koha/Library.pm +++ b/Koha/Library.pm @@ -129,6 +129,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 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 740b5958c8..2dc155b917 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -262,6 +262,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 2c5b01fba8..8613b5f27f 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -240,6 +240,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 2f948c6236..3f70aa1d64 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 @@ -20,6 +20,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 68488d79be..b6f08bf52c 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 c77dbdd502..c74a902882 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 645609785a..f26b6323f3 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 @@ -876,6 +876,14 @@ Circulation: yes: Check no: Don't check - external sources for availability during the request process + - + - "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 7fd4786503..ed039f0683 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 ) %]