From daf2410527c68a8be49f1506ca68aa976bb49343 Mon Sep 17 00:00:00 2001 From: David Gustafsson Date: Mon, 24 Feb 2025 13:32:19 +0100 Subject: [PATCH] Bug 30515: Fix messaging options order and add database changes --- C4/Members/Messaging.pm | 5 +- .../bug_30515-add_system_preferences.pl | 16 ----- ...nsports_to_patron_messaging_preferences.pl | 66 +++++++++++++++++++ .../mysql/en/mandatory/sample_notices.yml | 62 +++++++++++++++++ .../sample_notices_message_attributes.sql | 5 +- .../sample_notices_message_transports.sql | 8 ++- 6 files changed, 143 insertions(+), 19 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/bug_30515-add_system_preferences.pl create mode 100644 installer/data/mysql/atomicupdate/bug_30515-move_overdue_transports_to_patron_messaging_preferences.pl diff --git a/C4/Members/Messaging.pm b/C4/Members/Messaging.pm index 81e1e2c6c3f..910c2f35a5f 100644 --- a/C4/Members/Messaging.pm +++ b/C4/Members/Messaging.pm @@ -230,7 +230,10 @@ END_SQL 'Auto_Renewals' => 9, 'Advance_Notice' => 10, 'Item_Due' => 11, - 'Item_Check_in' => 12 + 'Item_Check_in' => 12, + 'Overdue1' => 13, + 'Overdue2' => 14, + 'Overdue3' => 15, ); @return = diff --git a/installer/data/mysql/atomicupdate/bug_30515-add_system_preferences.pl b/installer/data/mysql/atomicupdate/bug_30515-add_system_preferences.pl deleted file mode 100644 index 202c211d2e3..00000000000 --- a/installer/data/mysql/atomicupdate/bug_30515-add_system_preferences.pl +++ /dev/null @@ -1,16 +0,0 @@ -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"; - }, -}; diff --git a/installer/data/mysql/atomicupdate/bug_30515-move_overdue_transports_to_patron_messaging_preferences.pl b/installer/data/mysql/atomicupdate/bug_30515-move_overdue_transports_to_patron_messaging_preferences.pl new file mode 100644 index 00000000000..748b2a74614 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_30515-move_overdue_transports_to_patron_messaging_preferences.pl @@ -0,0 +1,66 @@ +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 `message_attributes` + (`message_attribute_id`, `message_name`, `takes_days`) + VALUES + (15, 'Overdue1', 0), + (16, 'Overdue2', 0), + (17, 'Overdue3', 0) + } + ); + say $out "Message attributes for overdue notices added"; + + $dbh->do( + q{ + INSERT IGNORE INTO `message_transports` + (`message_attribute_id`, `message_transport_type`, `is_digest`, `letter_module`, `letter_code`) + VALUES + (15, 'email', 0, 'circulation', 'ODUE'), + (15, 'sms', 0, 'circulation', 'ODUE'), + (16, 'email', 0, 'circulation', 'ODUE2'), + (16, 'sms', 0, 'circulation', 'ODUE2'), + (17, 'email', 0, 'circulation', 'ODUE3'), + (17, 'sms', 0, 'circulation', 'ODUE3') + } + ); + say $out "Message transports for overdue notices added"; + + $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"; + }, +} diff --git a/installer/data/mysql/en/mandatory/sample_notices.yml b/installer/data/mysql/en/mandatory/sample_notices.yml index de3eb334f59..792be0e815b 100644 --- a/installer/data/mysql/en/mandatory/sample_notices.yml +++ b/installer/data/mysql/en/mandatory/sample_notices.yml @@ -886,6 +886,68 @@ tables: - "According to our current records, you have items that are overdue." - "Please return or renew your overdue items at the library as soon as possible." - "" + - "<>" + - "<>" + - "<> <>" + - "Phone: <>" + - "Fax: <>" + - "Email: <>" + - "" + - "If you have registered a password with the library, and you have a renewal available, you may renew online. If an item becomes more than 30 days overdue, you will be unable to use your library card until the item is returned." + - "" + - "The following item(s) is/are currently overdue:" + - "" + - "\"<>\" by <>, <>, Barcode: <> Fine: <>" + - "" + - "Thank-you for your prompt attention to this matter." + - "" + - "<> Staff" + - "" + + - module: circulation + code: ODUE2 + branchcode: "" + name: "Overdue notice" + is_html: 0 + title: "Item overdue" + message_transport_type: email + lang: default + content: + - "Dear <> <>," + - "" + - "According to our current records, you have items that are overdue. This is the second reminder. Your library does not charge late fines, but please return or renew them at the branch below as soon as possible." + - "" + - "<>" + - "<>" + - "<> <>" + - "Phone: <>" + - "Fax: <>" + - "Email: <>" + - "" + - "If you have registered a password with the library, and you have a renewal available, you may renew online. If an item becomes more than 30 days overdue, you will be unable to use your library card until the item is returned." + - "" + - "The following item(s) is/are currently overdue:" + - "" + - "\"<>\" by <>, <>, Barcode: <> Fine: <>" + - "" + - "Thank-you for your prompt attention to this matter." + - "" + - "<> Staff" + - "" + + - module: circulation + code: ODUE3 + branchcode: "" + name: "Overdue notice" + is_html: 0 + title: "Item overdue" + message_transport_type: email + lang: default + content: + - "Dear <> <>," + - "" + - "According to our current records, you have items that are overdue. This is the final reminder. Your library does not charge late fines, but please return or renew them at the branch below as soon as possible." + - "" - "[% branch.branchname %]" - "[% branch.branchaddress1 %]" - "[% branch.branchaddress2 %] [% branch.branchaddress3 %]" diff --git a/installer/data/mysql/mandatory/sample_notices_message_attributes.sql b/installer/data/mysql/mandatory/sample_notices_message_attributes.sql index 1b1659a67ef..6d65711ccc2 100644 --- a/installer/data/mysql/mandatory/sample_notices_message_attributes.sql +++ b/installer/data/mysql/mandatory/sample_notices_message_attributes.sql @@ -13,4 +13,7 @@ values (11, 'Ill_update', 0), (12, 'Recall_Waiting', 0), (13, 'Recall_Requested', 0), -(14, 'Patron_Expiry', 0); +(14, 'Patron_Expiry', 0) +(15, 'Overdue1', 0), +(16, 'Overdue2', 0), +(17, 'Overdue3', 0); diff --git a/installer/data/mysql/mandatory/sample_notices_message_transports.sql b/installer/data/mysql/mandatory/sample_notices_message_transports.sql index c0395e09c92..15b3fa43e81 100644 --- a/installer/data/mysql/mandatory/sample_notices_message_transports.sql +++ b/installer/data/mysql/mandatory/sample_notices_message_transports.sql @@ -55,4 +55,10 @@ values (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"); +(14, "phone", 0, "members", "MEMBERSHIP_EXPIRY") +(15, 'email', 0, 'circulation', 'ODUE'), +(15, 'sms', 0, 'circulation', 'ODUE'), +(16, 'email', 0, 'circulation', 'ODUE2'), +(16, 'sms', 0, 'circulation', 'ODUE2'), +(17, 'email', 0, 'circulation', 'ODUE3'), +(17, 'sms', 0, 'circulation', 'ODUE3'),; -- 2.34.1