From 5525c3e4f131f9df2ac747fd96431a8678a27b84 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Mon, 29 Jul 2024 10:58:48 +0000 Subject: [PATCH] Bug 30300: Add a patron expiry messaging preference Signed-off-by: Roman Dolny Signed-off-by: Nick Clemens --- ...add_expiration_to_messaging_preferences.pl | 51 +++++++++++++++++++ .../sample_notices_message_attributes.sql | 3 +- .../sample_notices_message_transports.sql | 5 +- .../en/includes/messaging-preference-form.inc | 1 + .../prog/en/modules/admin/categories.tt | 1 + .../bootstrap/en/modules/opac-messaging.tt | 1 + 6 files changed, 60 insertions(+), 2 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_30300-add_expiration_to_messaging_preferences.pl diff --git a/installer/data/mysql/atomicupdate/bug_30300-add_expiration_to_messaging_preferences.pl b/installer/data/mysql/atomicupdate/bug_30300-add_expiration_to_messaging_preferences.pl new file mode 100755 index 00000000000..db212f19b26 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_30300-add_expiration_to_messaging_preferences.pl @@ -0,0 +1,51 @@ +use Modern::Perl; + +return { + bug_number => "30300", + description => "Add Patron expiry to messaging preference", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + my $attribute = $dbh->do( + q{ + SELECT message_attribute_id + FROM message_attributes + WHERE message_name = "Patron_Expiry" + } + ); + unless ( $attribute == 1 ) { + $dbh->do( + q{ + INSERT IGNORE INTO `message_attributes` + (message_name, `takes_days`) + VALUES ('Patron_Expiry', 0) + } + ); + say $out "Message attribute added"; + my $query = q{ + SELECT message_attribute_id + FROM message_attributes + WHERE message_name = "Patron_Expiry" + }; + my $sth = $dbh->prepare($query); + $sth->execute(); + my $results = $sth->fetchrow_hashref; + my $message_attribute_id = $results->{message_attribute_id}; + + $dbh->do( + q{ + INSERT IGNORE INTO `message_transports` + (`message_attribute_id`, `message_transport_type`, `is_digest`, `letter_module`, `letter_code`) + VALUES (?, 'email', 0, 'circulation', 'MEMBERSHIP_EXPIRY'), + (?, 'sms', 0, 'circulation', 'MEMBERSHIP_EXPIRY'), + (?, 'phone', 0, 'circulation', 'MEMBERSHIP_EXPIRY'), + ( ?, 'itiva', 0, 'circulation', 'MEMBERSHIP_EXPIRY' ) + }, {}, $message_attribute_id, $message_attribute_id, $message_attribute_id, $message_attribute_id + + ); + say $out "MEMBERSHIP_EXPIRY added to message_transports"; + } else { + say $out "Patron_Expiry message attribute exists, skipping update"; + } + }, + } diff --git a/installer/data/mysql/mandatory/sample_notices_message_attributes.sql b/installer/data/mysql/mandatory/sample_notices_message_attributes.sql index 31bf6d0b371..1b1659a67ef 100644 --- a/installer/data/mysql/mandatory/sample_notices_message_attributes.sql +++ b/installer/data/mysql/mandatory/sample_notices_message_attributes.sql @@ -12,4 +12,5 @@ values (10, 'Hold_Reminder', 0), (11, 'Ill_update', 0), (12, 'Recall_Waiting', 0), -(13, 'Recall_Requested', 0); +(13, 'Recall_Requested', 0), +(14, 'Patron_Expiry', 0); diff --git a/installer/data/mysql/mandatory/sample_notices_message_transports.sql b/installer/data/mysql/mandatory/sample_notices_message_transports.sql index 762fdb7ee50..c0395e09c92 100644 --- a/installer/data/mysql/mandatory/sample_notices_message_transports.sql +++ b/installer/data/mysql/mandatory/sample_notices_message_transports.sql @@ -52,4 +52,7 @@ values (12, "phone", 0, "circulation", "PICKUP_RECALLED_ITEM"), (13, "email", 0, "circulation", "RETURN_RECALLED_ITEM"), (13, "sms", 0, "circulation", "RETURN_RECALLED_ITEM"), -(13, "phone", 0, "circulation", "RETURN_RECALLED_ITEM"); +(13, "phone", 0, "circulation", "RETURN_RECALLED_ITEM"), +(14, "email", 0, "members", "MEMBERSHIP_EXPIRY"), +(14, "sms", 0, "members", "MEMBERSHIP_EXPIRY"), +(14, "phone", 0, "members", "MEMBERSHIP_EXPIRY"); 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 ecf35310f3f..9a0d4f5886c 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 @@ -31,6 +31,7 @@ [% ELSE %] Item checkout [% END %] + [% ELSIF ( messaging_preference.Patron_Expiry ) %]Patron expiry [% ELSIF ( messaging_preference.Ill_ready ) %]Interlibrary loan ready [% ELSIF ( messaging_preference.Ill_unavailable ) %]Interlibrary loan unavailable [% ELSIF ( messaging_preference.Ill_update ) %]Interlibrary loan updated 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 440da9eadeb..768adc05a0e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt @@ -715,6 +715,7 @@ [% ELSIF ( prefs.Ill_update ) %]Interlibrary loan updated [% ELSIF ( prefs.Auto_Renewals ) %]Auto renewal [% ELSIF ( prefs.Hold_Reminder ) %]Hold reminder + [% ELSIF ( prefs.Patron_Expiry ) %]Patron expiry [% ELSE %]Unknown [% END %]: [% transport.transport | html %]
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 c25147453d1..5e45443173a 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt @@ -73,6 +73,7 @@ [% ELSE %] Item checkout [% END %] + [% ELSIF ( messaging_preference.Patron_Expiry ) %]Patron expiry [% ELSIF ( messaging_preference.Ill_ready ) %]Interlibrary loan ready [% ELSIF ( messaging_preference.Ill_unavailable ) %]Interlibrary loan unavailable [% ELSIF ( messaging_preference.Ill_update ) %]Interlibrary loan updated -- 2.39.3 (Apple Git-146)