From dc9d9b8b98eea7abfbb861b72107a0c6fc0b7149 Mon Sep 17 00:00:00 2001 From: Raphael Straub Date: Fri, 29 Sep 2023 08:48:31 +0000 Subject: [PATCH] Bug 20755: Add separate email configuration for acquisition and serial emails This patch allows every library to define the From and Reply-to email addresses for acquisition and serial emails (orders and claims) sent by Koha. Especially in large libraries with dedicated acquisition departments we need a way that vendors/booksellers can reply directly to the acquisition team and not to the library default email. The library email in the library configuration can then be used for circulation purposes only. 1) Apply patch, run database update 2) Make sure you have set up Koha to send up email (SMTP server, KohaAdminEmailAdress, etc.) 3) Make sure you have a vendor set up with a valid email address. 4) Check that you have four new system preferences: - AcquisitionsDefaultEMailAddress - SerialsDefaultEMailAddress - AcquisitionsDefaultReplyTo - SerialsDefaultReplyTo 5) Check that there is no change in behaviour if the four new system preferences are left empty: All acquisition and serial emails are sent from the library email (or KohaAdminEmailAddress if no library email is set) 6) Create an order with at least one order line. Send the order to your vendor by email. 7) Create an acquisition claim notice and send it to your vendor. 8) Create a subscription linked to your vendor and with at least one late issue. Claim the issue. 9) There should be no change in behaviour: emails should be sent from library email (or KohaAdminEmailAddress if nothing is set on library level) 10) Configure different email addresses for system preferences: - First email address: AcquisitionsDefaultEMailAddress, SerialsDefaultEMailAddress - Second email address: AcquisitionsDefaultReplyTo, SerialsDefaultReplyTo 11) Repeat steps 6-8 12) Verify that the library specific acquisition and serial email addresses are used as From and Reply-to. Sponsored-by: Karlsruhe Institute of Technology (KIT) Signed-off-by: Martin Renvoize --- C4/Letters.pm | 19 +++++++++- ...acquisitionsdefaultemailaddress_syspref.pl | 38 +++++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 4 ++ .../admin/preferences/acquisitions.pref | 24 ++++++++++++ 4 files changed, 83 insertions(+), 2 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_20755-add_acquisitionsdefaultemailaddress_syspref.pl diff --git a/C4/Letters.pm b/C4/Letters.pm index dc9385ad345..46e3c0f1e3d 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -493,8 +493,23 @@ sub SendAlerts { ? ( bcc => $userenv->{emailaddress} ) : () ), - from => $library->branchemail - || C4::Context->preference('KohaAdminEmailAddress'), + from => ( + $type eq 'claimissues' + ? C4::Context->preference('SerialsDefaultEMailAddress') + : C4::Context->preference('AcquisitionsDefaultEMailAddress') + ) + || $library->branchemail + || C4::Context->preference('KohaAdminEmailAddress'), + ( + $type eq 'claimissues' && C4::Context->preference('SerialsDefaultReplyTo') + ? ( reply_to => C4::Context->preference('SerialsDefaultReplyTo') ) + : ( + ( $type eq 'claimacquisition' || $type eq 'orderacquisition' ) + && C4::Context->preference('AcquisitionsDefaultReplyTo') + ? ( reply_to => C4::Context->preference('AcquisitionsDefaultReplyTo') ) + : () + ) + ), subject => "" . $letter->{title}, } ); diff --git a/installer/data/mysql/atomicupdate/bug_20755-add_acquisitionsdefaultemailaddress_syspref.pl b/installer/data/mysql/atomicupdate/bug_20755-add_acquisitionsdefaultemailaddress_syspref.pl new file mode 100755 index 00000000000..a4f8eb0bbf1 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_20755-add_acquisitionsdefaultemailaddress_syspref.pl @@ -0,0 +1,38 @@ +use Modern::Perl; + +return { + bug_number => "20755", + description => "Add sysprefs for email addresses in acquisitions and serials", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + $dbh->do( + q{ + INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('AcquisitionsDefaultEMailAddress', '', NULL, NULL, NULL); + } + ); + say $out "Added new system preference 'AcquisitionsDefaultEMailAddress'"; + + $dbh->do( + q{ + INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('AcquisitionsDefaultReplyTo', '', NULL, NULL, NULL); + } + ); + say $out "Added new system preference 'AcquisitionsDefaultReplyTo'"; + + $dbh->do( + q{ + INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('SerialsDefaultEMailAddress', '', NULL, NULL, NULL); + } + ); + say $out "Added new system preference 'SerialsDefaultEMailAddress'"; + + $dbh->do( + q{ + INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('SerialsDefaultReplyTo', '', NULL, NULL, NULL); + } + ); + say $out "Added new system preference 'SerialsDefaultReplyTo'"; + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 2b2794106ec..9bd74476262 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -7,6 +7,8 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('AcqItemSetSubfieldsWhenReceived','','','Upon receiving items, update their subfields if they were created when placing an order (e.g. o=5|a="foo bar")','Free'), ('AcquisitionDetails', '1', '', 'Hide/Show acquisition details on the biblio detail page.', 'YesNo'), ('AcquisitionLog','0',NULL,'If ON, log acquisitions activity','YesNo'), +('AcquisitionsDefaultEMailAddress', '', NULL, NULL, NULL), +('AcquisitionsDefaultReplyTo', '', NULL, NULL, NULL), ('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: their own only, any within their branch, or all','Choice'), ('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'), ('ActionLogsTraceDepth', '0', '', 'Sets the maximum depth of the action logs stack trace', 'Integer'), @@ -667,6 +669,8 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('SendAllEmailsTo','',NULL,'All emails will be redirected to this email if it is not empty','free'), ('SeparateHoldings','0',NULL,'Separate current branch holdings from other holdings','YesNo'), ('SeparateHoldingsBranch','homebranch','homebranch|holdingbranch','Branch used to separate holdings','Choice'), +('SerialsDefaultEMailAddress', '', NULL, NULL, NULL), +('SerialsDefaultReplyTo', '', NULL, NULL, NULL), ('SessionRestrictionByIP','1','Check for change in remote IP address for session security. Disable only when remote IP address changes frequently.','','YesNo'), ('SessionStorage','mysql','mysql|Pg|tmp','Use database or a temporary file for storing session data','Choice'), ('ShelfBrowserUsesCcode','1','0','Use the item collection code when finding items for the shelf browser.','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref index 4e2c18512e1..4317cb0e5be 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref @@ -113,6 +113,30 @@ Acquisitions: - '
If you choose EmailAddressForSuggestions you have to enter a valid email address:' - pref: EmailAddressForSuggestions class: email + - + - Use the from email address + - pref: AcquisitionsDefaultEMailAddress + class: email + - 'when sending acquisitions order and claim notices.' + - '
If left empty, it will fall back to the first defined address in the following list: Library Email, KohaAdminEmailAddress.' + - + - Use the from email address + - pref: SerialsDefaultEMailAddress + class: email + - 'when sending serial claim notices.' + - '
If left empty, it will fall back to the first defined address in the following list: Library Email, KohaAdminEmailAddress.' + - + - Use the reply-to email address + - pref: AcquisitionsDefaultReplyTo + class: email + - 'when sending acquisitions order and claim notices.' + - '
If left empty, it will fall back to the first defined address in the following list: Library ReplyTo, Library Email, ReplytoDefault, KohaAdminEmailAddress.' + - + - Use the reply-to email address + - pref: SerialsDefaultReplyTo + class: email + - 'when sending serial claim notices.' + - '
If left empty, it will fall back to the first defined address in the following list: Library ReplyTo, Library Email, ReplytoDefault, KohaAdminEmailAddress.' Printing: - - Use the -- 2.41.0