Bug 31157: Allow selection for overdue from address in the UI
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 14 Jul 2022 16:11:45 +0000 (17:11 +0100)
committerTomas Cohen Arazi <tomascohen@theke.io>
Fri, 22 Jul 2022 18:14:42 +0000 (15:14 -0300)
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 <caroline.cyr-la-rose@inlibro.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
installer/data/mysql/atomicupdate/bug_31157.pl [new file with mode: 0644]
installer/data/mysql/mandatory/sysprefs.sql
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
misc/cronjobs/overdue_notices.pl

diff --git a/installer/data/mysql/atomicupdate/bug_31157.pl b/installer/data/mysql/atomicupdate/bug_31157.pl
new file mode 100644 (file)
index 0000000..0165a43
--- /dev/null
@@ -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')
+        });
+    },
+};
index 242de0d..a94351c 100644 (file)
@@ -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'),
index 1490530..cd3fc97 100644 (file)
@@ -408,6 +408,14 @@ Circulation:
                   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
               class: integer
index 9fdafe1..28b748e 100755 (executable)
@@ -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