From 19fc6220fa97c31f6dbe746fdf6bcded05284bfe Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 14 Jul 2022 17:11:45 +0100 Subject: [PATCH] Bug 31157: Allow selection for overdue from address in the UI This patch adds a new system preference to allow systems librarians the option to pick wich address to use for overdues notices. We default to 'cron' to allow existing uses of '--frombranch' on the command line to continue to function but now allow end users to override this option via the new OverdueNoticeFrom preference. Signed-off-by: Caroline Cyr La Rose Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- installer/data/mysql/atomicupdate/bug_31157.pl | 15 +++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../en/modules/admin/preferences/circulation.pref | 8 ++++++++ misc/cronjobs/overdue_notices.pl | 1 + 4 files changed, 25 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/bug_31157.pl diff --git a/installer/data/mysql/atomicupdate/bug_31157.pl b/installer/data/mysql/atomicupdate/bug_31157.pl new file mode 100644 index 0000000000..0165a438b8 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_31157.pl @@ -0,0 +1,15 @@ +use Modern::Perl; + +return { + bug_number => "31157", + description => "Add OverdueNoticeFrom preference", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + + $dbh->do(q{ + INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES + ('OverdueNoticeFrom', 'cron', 'cron|item-issuebranch|item-homebranch', 'Use the choice as the from address when generating overdue notices', 'Choice') + }); + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 242de0d463..a94351c65b 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -521,6 +521,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OverDrivePasswordRequired','0',NULL,'Does the library require passwords for OverDrive SIP authentication','YesNo'), ('OverDriveUsername','cardnumber','cardnumber|userid','Which patron information should be passed as OverDrive username','Choice'), ('OverdueNoticeCalendar',0,NULL,'Take the calendar into consideration when generating overdue notices','YesNo'), +('OverdueNoticeFrom', 'cron', 'cron|item-issuebranch|item-homebranch', 'Use the choice as the from address when generating overdue notices', 'Choice'), ('OverduesBlockCirc','noblock','noblock|confirmation|block','When checking out an item should overdues block checkout, generate a confirmation dialogue, or allow checkout','Choice'), ('OverduesBlockRenewing','allow','allow|blockitem|block','If any of patron checked out documents is late, should renewal be allowed, blocked only on overdue items or blocked on whatever checked out document','Choice'), ('PassItemMarcToXSLT','0',NULL,'If enabled, item fields in the MARC record will be made avaiable to XSLT sheets. Otherwise they will be removed.','YesNo'), 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 149053073b..cd3fc97fa3 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 @@ -407,6 +407,14 @@ Circulation: 1: "Use calendar" 0: "Ignore calendar" - "when working out the period for overdue notices." + - + - "Use the" + - pref: OverdueNoticeFrom + choices: + cron: "system default" + item-issuebranch: "checkout library" + item-homebranch: "item home library" + - "as the from address when generating overdue notices." - - Include up to - pref: PrintNoticesMaxLines diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl index 9fdafe13b4..28b748eceb 100755 --- a/misc/cronjobs/overdue_notices.pl +++ b/misc/cronjobs/overdue_notices.pl @@ -338,6 +338,7 @@ if ( defined $csvfilename && $csvfilename =~ /^-/ ) { die "--frombranch takes item-homebranch or item-issuebranch only" unless ( $frombranch eq 'item-issuebranch' || $frombranch eq 'item-homebranch' ); +$frombranch = C4::Context->preference('OverdueNoticeFrom') ne 'cron' ? C4::Context->preference('OverdueNoticeFrom') : $frombranch; my $owning_library = ( $frombranch eq 'item-homebranch' ) ? 1 : 0; my @overduebranches = C4::Overdues::GetBranchcodesWithOverdueRules(); # Branches with overdue rules -- 2.39.5