@@ -, +, @@
messages and use them instead of patron category level preferences
---
.../bug_30515-add_system_preferences.pl | 16 +++++++++++++
.../en/includes/messaging-preference-form.inc | 3 +++
.../prog/en/modules/admin/categories.tt | 3 +++
.../admin/preferences/circulation.pref | 17 ++++++++++++-
misc/cronjobs/overdue_notices.pl | 24 +++++++++++++++----
5 files changed, 58 insertions(+), 5 deletions(-)
create mode 100644 installer/data/mysql/atomicupdate/bug_30515-add_system_preferences.pl
--- a/installer/data/mysql/atomicupdate/bug_30515-add_system_preferences.pl
+++ a/installer/data/mysql/atomicupdate/bug_30515-add_system_preferences.pl
@@ -0,0 +1,16 @@
+use Modern::Perl;
+
+return {
+ bug_number => "30515",
+ description => "Add system preferences for patron specific overdue notice preferences",
+ up => sub {
+ my ($args) = @_;
+ my ($dbh, $out) = @$args{qw(dbh out)};
+
+ $dbh->do(q{INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('UsePatronPreferencesForOverdueNotices', '0', null, 'Use patron specific messaging preferences for overdue notices if available', 'YesNo')});
+ say $out "UsePatronPreferencesForOverdueNotices system preference added";
+
+ dbh->do(q{INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('UsePatronPreferencesForOverdueNoticesPrint', 'always', 'always|fallback|never', 'When to send print notices when using patron specific messaging preferences for overdue notices', 'Choice')});
+ say $out "UsePatronPreferencesForOverdueNoticesPrint system preference added";
+ },
+}
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/messaging-preference-form.inc
+++ a/koha-tmpl/intranet-tmpl/prog/en/includes/messaging-preference-form.inc
@@ -34,6 +34,9 @@
[% ELSIF ( messaging_preference.Ill_unavailable ) %]Interlibrary loan unavailable
[% ELSIF ( messaging_preference.Ill_update ) %]Interlibrary loan updated
[% ELSIF ( messaging_preference.Auto_Renewals ) %]Auto renewal
+ [% ELSIF ( messaging_preference.Overdue1 ) %]Overdue 1
+ [% ELSIF ( messaging_preference.Overdue2 ) %]Overdue 2
+ [% ELSIF ( messaging_preference.Overdue3 ) %]Overdue 3
[% ELSE %]Unknown
[% END %]
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt
@@ -653,6 +653,9 @@
[% ELSIF ( prefs.Ill_update ) %]Interlibrary loan updated
[% ELSIF ( prefs.Auto_Renewals ) %]Auto renewal
[% ELSIF ( prefs.Hold_Reminder ) %]Hold reminder
+ [% ELSIF ( prefs.Overdue1 ) %]Overdue 1
+ [% ELSIF ( prefs.Overdue2 ) %]Overdue 2
+ [% ELSIF ( prefs.Overdue3 ) %]Overdue 3
[% ELSE %]Unknown
[% END %]:
[% transport.transport | html %]
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
@@ -571,7 +571,22 @@ Circulation:
- This is a list of value pairs. When an item is checked out, if the not for loan value on the left matches the items not for loan value
- "it will be updated to the right-hand value. For example, '-1: 0' will cause an item that was set to 'Ordered' to now be available for loan."
- Each pair of values should be on a separate line.
- Checkin policy:
+ -
+ - Use message preferences based on
+ - pref: UsePatronPreferencesForOverdueNotices
+ choices:
+ 1: individual patron preference
+ 0: patron category
+ - when sending overdue notices.
+ -
+ - When using individual patron preferences for overdue notices
+ - pref: UsePatronPreferencesForOverdueNoticesPrint
+ choices:
+ always: always
+ fallback: when no other transport set
+ never: never
+ - print notice.
+ Checkin Policy:
-
- pref: TrapHoldsOnOrder
choices:
--- a/misc/cronjobs/overdue_notices.pl
+++ a/misc/cronjobs/overdue_notices.pl
@@ -25,12 +25,14 @@ use Pod::Usage qw( pod2usage );
use Text::CSV_XS;
use DateTime;
use DateTime::Duration;
+use List::MoreUtils qw( uniq );
use Koha::Script -cron;
use C4::Context;
use C4::Letters;
use C4::Overdues qw( GetOverdueMessageTransportTypes parse_overdues_letter );
use C4::Log qw( cronlogaction );
+use C4::Members::Messaging qw( GetMessagingPreferences );
use Koha::Patron::Debarments qw( AddUniqueDebarment );
use Koha::DateUtils qw( dt_from_string output_pref );
use Koha::Calendar;
@@ -711,11 +713,25 @@ END_SQL
push @items, $item_info;
}
$sth2->finish;
-
- my @message_transport_types = @{ GetOverdueMessageTransportTypes( $branchcode, $overdue_rules->{categorycode}, $i) };
- @message_transport_types = @{ GetOverdueMessageTransportTypes( q{}, $overdue_rules->{categorycode}, $i) }
+ my @message_transport_types;
+ if (C4::Context->preference('UsePatronPreferencesForOverdueNotices')) {
+ my $patronpref = GetMessagingPreferences(
+ { borrowernumber => $borrowernumber, message_name => "Overdue$i"});
+ if ($patronpref && $patronpref->{'transports'}) {
+ @message_transport_types = keys %{$patronpref->{'transports'}};
+ }
+ my $print_behavior = C4::Context->preference('UsePatronPreferencesForOverdueNoticesPrint');
+ if (
+ $print_behavior eq 'always' ||
+ $print_behavior eq 'fallback' && !@message_transport_types
+ ) {
+ unshift(@message_transport_types, 'shift');
+ }
+ } else {
+ @message_transport_types = @{ GetOverdueMessageTransportTypes( $branchcode, $overdue_rules->{categorycode}, $i) };
+ @message_transport_types = @{ GetOverdueMessageTransportTypes( q{}, $overdue_rules->{categorycode}, $i) }
unless @message_transport_types;
-
+ }
my $print_sent = 0; # A print notice is not yet sent for this patron
for my $mtt ( @message_transport_types ) {
--