From 3b51ae67db6b8a6f3fb5035eb5b263e571eb05c7 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Sun, 21 Apr 2024 23:13:33 +0000 Subject: [PATCH] Bug 23781: SMS notices and messaging preferences for recalls This patch adds recalls notices (pick up a waiting recall or return a requested recall) to the messaging preferences. To test: 1) Apply Bug 19532 2) Apply this bug 3) Update database, restart services 4) Ensure UseRecalls syspref is enabled and values have been set in the circulation rules for recalls 5) Go to a borrower (Person A) account page in the Intranet or the OPAC 6) Go to messaging preferences 7) Notice there are now preferences for two recalls notices 8) Select email as a preference 9) Find a different borrower (Person B) and set their messaging preferences to SMS 10) Check out any item to Person B 11) Go to the OPAC logged in as Person A and find that item 12) Recall the item 13) In the terminal, look at the message_queue in the database. There should be a 'RETURN_RECALLED_ITEM' recall notice sent to Person B via SMS 14) Go back to the Intranet and check in the item. Confirm the recall when checking in 15) Look at the message_queue in the database again. There should be a 'PICKUP_RECALLED_ITEM' recall notice sent to Person A via email. 16) Confirm tests pass t/db_dependent/Koha/Recall.t t/db_dependent/Koha/Recalls.t 17) Confirm that 'Unknown' doesn't show in the the staff and OPAC messaging preferences tables when UseRecalls syspref is disabled Sponsored-by: Toi Ohomai Institute of Technology Signed-off-by: David Nind Signed-off-by: Kyle M Hall Signed-off-by: Martin Renvoize --- Koha/Recall.pm | 6 +++++- Koha/Recalls.pm | 7 ++++++- .../prog/en/includes/messaging-preference-form.inc | 3 +++ koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt | 3 +++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Koha/Recall.pm b/Koha/Recall.pm index 6f3678f691..a060a5bf3a 100644 --- a/Koha/Recall.pm +++ b/Koha/Recall.pm @@ -358,7 +358,11 @@ sub set_waiting { }, ); - C4::Message->enqueue($letter, $self->patron, 'email'); + my $messaging_preferences = C4::Members::Messaging::GetMessagingPreferences( + { borrowernumber => $self->patron_id, message_name => 'Recall_Waiting' } ); + while ( my ( $transport, $letter_code ) = each %{ $messaging_preferences->{transports} } ) { + C4::Message->enqueue( $letter, $self->patron, $transport ); + } return $self; } diff --git a/Koha/Recalls.pm b/Koha/Recalls.pm index 29be68ce05..9f6d14e364 100644 --- a/Koha/Recalls.pm +++ b/Koha/Recalls.pm @@ -167,7 +167,12 @@ sub add_recall { }, ); - C4::Message->enqueue( $letter, $checkout->patron, 'email' ); + my $messaging_preferences = C4::Members::Messaging::GetMessagingPreferences( + { borrowernumber => $checkout->borrowernumber, message_name => 'Recall_Requested' } ); + + while ( my ( $transport, $letter_code ) = each %{ $messaging_preferences->{transports} } ) { + C4::Message->enqueue( $letter, $checkout->patron, $transport ); + } $item = Koha::Items->find( $itemnumber ); # add to statistics table 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 6e08c2ee16..b3cadaa435 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 @@ -18,6 +18,7 @@ [% FOREACH messaging_preference IN messaging_preferences %] [% NEXT IF !Koha.Preference( 'ILLModule' ) && messaging_preference.message_name.match('^Ill_') %] [% NEXT IF messaging_preference.Auto_Renewals && Koha.Preference('AutoRenewalNotices') != 'preferences' %] + [% NEXT IF !Koha.Preference('UseRecalls') && messaging_preference.message_name.match('^Recall_') %] [% IF ( messaging_preference.Item_Due ) %]Item due [% ELSIF ( messaging_preference.Advance_Notice ) %]Advance notice @@ -34,6 +35,8 @@ [% 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.Recall_Waiting ) %]Recall awaiting pickup + [% ELSIF ( messaging_preference.Recall_Requested ) %]Return recalled item [% ELSE %]Unknown [% END %] 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 5026b17dd5..4a34272063 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt @@ -60,6 +60,7 @@ [% FOREACH messaging_preference IN messaging_preferences %] [% NEXT IF !Koha.Preference( 'ILLModule' ) && messaging_preference.message_name.match('^Ill_') %] [% NEXT IF messaging_preference.Auto_Renewals && Koha.Preference('AutoRenewalNotices') != 'preferences' %] + [% NEXT IF !Koha.Preference('UseRecalls') && messaging_preference.message_name.match('^Recall_') %] [% IF ( messaging_preference.Item_Due ) %]Item due [% ELSIF ( messaging_preference.Advance_Notice ) %]Advance notice @@ -76,6 +77,8 @@ [% 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.Recall_Waiting ) %]Recall awaiting pickup + [% ELSIF ( messaging_preference.Recall_Requested ) %]Return recalled item [% ELSE %]Unknown [% END %] [% IF ( messaging_preference.takes_days ) %]