Bugzilla – Attachment 162377 Details for
Bug 23781
Recalls notices and messaging preferences
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23781: SMS notices and messaging preferences for recalls
Bug-23781-SMS-notices-and-messaging-preferences-fo.patch (text/plain), 15.10 KB, created by
Kyle M Hall (khall)
on 2024-02-23 14:47:44 UTC
(
hide
)
Description:
Bug 23781: SMS notices and messaging preferences for recalls
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2024-02-23 14:47:44 UTC
Size:
15.10 KB
patch
obsolete
>From 00be31366ec4b0f97a0466c7259da02a96889f25 Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Tue, 12 May 2020 22:07:56 +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, rebuild dbix files >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 > >Sponsored-by: Toi Ohomai Institute of Technology >Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/Recall.pm | 10 +++++- > Koha/Recalls.pm | 11 +++++- > .../bug_23781-recalls_message_attributes.pl | 12 +++++++ > .../bug_23781-recalls_message_transports.pl | 12 +++++++ > .../bug_23781-recalls_sms_notices.pl | 24 +++++++++++++ > .../mysql/en/mandatory/sample_notices.yml | 35 +++++++++++++++++++ > .../sample_notices_message_attributes.sql | 5 +-- > .../sample_notices_message_transports.sql | 6 +++- > .../en/includes/messaging-preference-form.inc | 2 ++ > .../bootstrap/en/modules/opac-messaging.tt | 2 ++ > t/db_dependent/Koha/Recall.t | 6 ++++ > t/db_dependent/Koha/Recalls.t | 8 ++++- > 12 files changed, 127 insertions(+), 6 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_23781-recalls_message_attributes.pl > create mode 100644 installer/data/mysql/atomicupdate/bug_23781-recalls_message_transports.pl > create mode 100644 installer/data/mysql/atomicupdate/bug_23781-recalls_sms_notices.pl > >diff --git a/Koha/Recall.pm b/Koha/Recall.pm >index c70acb89dd1..10ca9901c67 100644 >--- a/Koha/Recall.pm >+++ b/Koha/Recall.pm >@@ -358,7 +358,15 @@ 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} } ) { >+ if ( $transport eq 'email' ){ >+ C4::Message->enqueue($letter, $self->patron, 'email'); >+ } >+ if ( $transport eq 'sms' ){ >+ C4::Message->enqueue($letter, $self->patron, 'sms'); >+ } >+ } > > return $self; > } >diff --git a/Koha/Recalls.pm b/Koha/Recalls.pm >index 29be68ce05a..02e22867a37 100644 >--- a/Koha/Recalls.pm >+++ b/Koha/Recalls.pm >@@ -167,7 +167,16 @@ 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} } ) { >+ if ( $transport eq 'email' ){ >+ C4::Message->enqueue( $letter, $checkout->patron, 'email' ); >+ } >+ if ( $transport eq 'sms' ){ >+ C4::Message->enqueue( $letter, $checkout->patron, 'sms' ); >+ } >+ } > > $item = Koha::Items->find( $itemnumber ); > # add to statistics table >diff --git a/installer/data/mysql/atomicupdate/bug_23781-recalls_message_attributes.pl b/installer/data/mysql/atomicupdate/bug_23781-recalls_message_attributes.pl >new file mode 100644 >index 00000000000..598ebebcf4c >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_23781-recalls_message_attributes.pl >@@ -0,0 +1,12 @@ >+use Modern::Perl; >+ >+return { >+ bug_number => "23781", >+ description => "Adding message attributes for recalls: Recall_Waiting, Recall_Requested", >+ 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 (12, 'Recall_Waiting', 0), (13, 'Recall_Requested', 0) }); >+ }, >+}; >diff --git a/installer/data/mysql/atomicupdate/bug_23781-recalls_message_transports.pl b/installer/data/mysql/atomicupdate/bug_23781-recalls_message_transports.pl >new file mode 100644 >index 00000000000..c9b8226f2ec >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_23781-recalls_message_transports.pl >@@ -0,0 +1,12 @@ >+use Modern::Perl; >+ >+return { >+ bug_number => "23781", >+ description => "Adding message transports for recalls notices", >+ up => sub { >+ my ($args) = @_; >+ my ($dbh, $out) = @$args{qw(dbh out)}; >+ >+ $dbh->do(q{ INSERT IGNORE INTO message_transports (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code, branchcode) VALUES (12, "email", 0, "circulation", "PICKUP_RECALLED_ITEM", null), (12, "sms", 0, "circulation", "PICKUP_RECALLED_ITEM", null), (13, "email", 0, "circulation", "RETURN_RECALLED_ITEM", null), (13, "sms", 0, "circulation", "RETURN_RECALLED_ITEM", null) }); >+ }, >+}; >diff --git a/installer/data/mysql/atomicupdate/bug_23781-recalls_sms_notices.pl b/installer/data/mysql/atomicupdate/bug_23781-recalls_sms_notices.pl >new file mode 100644 >index 00000000000..61aa730ee9f >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_23781-recalls_sms_notices.pl >@@ -0,0 +1,24 @@ >+use Modern::Perl; >+ >+return { >+ bug_number => "23781", >+ description => "Add recalls SMS notices: RETURN_RECALLED_ITEM, PICKUP_RECALLED_ITEM", >+ up => sub { >+ my ($args) = @_; >+ my ($dbh, $out) = @$args{qw(dbh out)}; >+ >+ $dbh->do(q{ INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`) VALUES ('circulation','RETURN_RECALLED_ITEM','','Notification to return a recalled item','0','Notification to return a recalled item','Date: <<today>> >+ >+<<borrowers.firstname>> <<borrowers.surname>>, >+ >+A recall has been placed on the following item: <<biblio.title>> / <<biblio.author>> (<<items.barcode>>). The due date has been updated, and is now <<issues.date_due>>. Please return the item before the due date. >+ >+Thank you!','sms'), ('circulation','PICKUP_RECALLED_ITEM','','Recalled item awaiting pickup','0','Recalled item awaiting pickup','Date: <<today>> >+ >+<<borrowers.firstname>> <<borrowers.surname>>, >+ >+A recall that you requested on the following item: <<biblio.title>> / <<biblio.author>> (<<items.barcode>>) is now ready for you to pick up at <<recalls.branchcode>>. Please pick up your item by <<recalls.expirationdate>>. >+ >+Thank you!','sms') }); >+ }, >+}; >diff --git a/installer/data/mysql/en/mandatory/sample_notices.yml b/installer/data/mysql/en/mandatory/sample_notices.yml >index 9675b3eb4f1..76c60b54ccb 100644 >--- a/installer/data/mysql/en/mandatory/sample_notices.yml >+++ b/installer/data/mysql/en/mandatory/sample_notices.yml >@@ -2278,6 +2278,41 @@ tables: > - "" > - "Thank you!" > >+ - module: circulation >+ code: RETURN_RECALLED_ITEM >+ branchcode: "" >+ name: "Notification to return a recalled item" >+ is_html: 0 >+ title: "Notification to return a recalled item" >+ message_transport_type: sms >+ lang: default >+ content: >+ - "Date: <<today>>" >+ - "" >+ - "<<borrowers.firstname>> <<borrowers.surname>>," >+ - "" >+ - "A recall has been placed on the following item: <<biblio.title>> / <<biblio.author>> (<<items.barcode>>). The due date has been updated, and is now <<issues.date_due>>. Please return the item before the due date." >+ - "" >+ - "Thank you!" >+ >+ - module: circulation >+ code: PICKUP_RECALLED_ITEM >+ branchcode: "" >+ name: "Recalled item awaiting pickup" >+ is_html: 0 >+ title: "Recalled item awaiting pickup" >+ message_transport_type: sms >+ lang: default >+ content: >+ - "Date: <<today>>" >+ - "" >+ - "<<borrowers.firstname>> <<borrowers.surname>>," >+ - "" >+ - "A recall that you requested on the following item: <<biblio.title>> / <<biblio.author>> (<<items.barcode>>) is now ready for you to pick up at <<recalls.branchcode>>. Please pick up your item by <<recalls.expirationdate>>." >+ - "" >+ - "Thank you!" >+ >+ > - module: circulation > code: RECALL_REQUESTER_DET > branchcode: "" >diff --git a/installer/data/mysql/mandatory/sample_notices_message_attributes.sql b/installer/data/mysql/mandatory/sample_notices_message_attributes.sql >index bd0294c960e..31bf6d0b371 100644 >--- a/installer/data/mysql/mandatory/sample_notices_message_attributes.sql >+++ b/installer/data/mysql/mandatory/sample_notices_message_attributes.sql >@@ -10,5 +10,6 @@ values > (8, 'Ill_unavailable', 0), > (9, 'Auto_Renewals', 0), > (10, 'Hold_Reminder', 0), >-(11, 'Ill_update', 0); >- >+(11, 'Ill_update', 0), >+(12, 'Recall_Waiting', 0), >+(13, 'Recall_Requested', 0); >diff --git a/installer/data/mysql/mandatory/sample_notices_message_transports.sql b/installer/data/mysql/mandatory/sample_notices_message_transports.sql >index 55ed683d6bc..631e5de2ccc 100644 >--- a/installer/data/mysql/mandatory/sample_notices_message_transports.sql >+++ b/installer/data/mysql/mandatory/sample_notices_message_transports.sql >@@ -44,4 +44,8 @@ values > (10, 'itiva', 0, 'circulation', 'HOLD_REMINDER'), > (11, 'email', 0, 'ill', 'ILL_REQUEST_UPDATE'), > (11, 'sms', 0, 'ill', 'ILL_REQUEST_UPDATE'), >-(11, 'phone', 0, 'ill', 'ILL_REQUEST_UPDATE'); >+(11, 'phone', 0, 'ill', 'ILL_REQUEST_UPDATE'), >+(12, "email", 0, "circulation", "PICKUP_RECALLED_ITEM"), >+(12, "sms", 0, "circulation", "PICKUP_RECALLED_ITEM"), >+(13, "email", 0, "circulation", "RETURN_RECALLED_ITEM"), >+(13, "sms", 0, "circulation", "RETURN_RECALLED_ITEM"); >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 6e08c2ee160..b416fcc9a57 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 >@@ -34,6 +34,8 @@ > [% ELSIF ( messaging_preference.Ill_unavailable ) %]<span>Interlibrary loan unavailable</span> > [% ELSIF ( messaging_preference.Ill_update ) %]<span>Interlibrary loan updated</span> > [% ELSIF ( messaging_preference.Auto_Renewals ) %]<span>Auto renewal</span> >+ [% ELSIF ( Koha.Preference('UseRecalls') && messaging_preference.Recall_Waiting ) %]<span>Recall awaiting pickup</span> >+ [% ELSIF ( Koha.Preference('UseRecalls') && messaging_preference.Recall_Requested ) %]<span>Return recalled item</span> > [% ELSE %]<span>Unknown</span> > [% END %] > </td> >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 3b5d5e95a76..eda2b5818c1 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt >@@ -76,6 +76,8 @@ > [% ELSIF ( messaging_preference.Ill_unavailable ) %]<span>Interlibrary loan unavailable</span> > [% ELSIF ( messaging_preference.Ill_update ) %]<span>Interlibrary loan updated</span> > [% ELSIF ( messaging_preference.Auto_Renewals ) %]<span>Auto renewal</span> >+ [% ELSIF ( Koha.Preference('UseRecalls') && messaging_preference.Recall_Waiting ) %]<span>Recall awaiting pickup</span> >+ [% ELSIF ( Koha.Preference('UseRecalls') && messaging_preference.Recall_Requested ) %]<span>Return recalled item</span> > [% ELSE %]<span>Unknown</span> [% END %]</td> > [% IF ( messaging_preference.takes_days ) %] > <td><select class="input-mini" name="[% messaging_preference.message_attribute_id | html %]-DAYS" aria-label="Choose how many days in advance you wish to receive the message"> >diff --git a/t/db_dependent/Koha/Recall.t b/t/db_dependent/Koha/Recall.t >index 1b4f8f70ebb..55cec9c0690 100755 >--- a/t/db_dependent/Koha/Recall.t >+++ b/t/db_dependent/Koha/Recall.t >@@ -126,6 +126,12 @@ $expected_expirationdate = dt_from_string->add({ days => 3 }); > $expirationdate = $recall2->calc_expirationdate; > is( t::lib::Dates::compare( $expirationdate, $expected_expirationdate ), 0, "Expiration date calculated based on circulation rules" ); > >+C4::Members::Messaging::SetMessagingPreference({ >+ borrowernumber => $patron1->borrowernumber, >+ message_attribute_id => 12, # Recall_Waiting >+ message_transport_types => [ qw( email sms ) ], >+}); >+ > $recall2->set_waiting({ expirationdate => $expirationdate }); > is( $recall2->waiting, 1, "Recall is waiting" ); > >diff --git a/t/db_dependent/Koha/Recalls.t b/t/db_dependent/Koha/Recalls.t >index 546bbf21c45..04f845b8e6b 100755 >--- a/t/db_dependent/Koha/Recalls.t >+++ b/t/db_dependent/Koha/Recalls.t >@@ -68,6 +68,12 @@ Koha::CirculationRules->set_rules({ > C4::Circulation::AddIssue( $patron3, $item1->barcode ); > C4::Circulation::AddIssue( $patron3, $item2->barcode ); > >+C4::Members::Messaging::SetMessagingPreference({ >+ borrowernumber => $patron3->borrowernumber, >+ message_attribute_id => 13, # Recall_Requested >+ message_transport_types => [ qw( email sms ) ], >+}); >+ > my ( $recall, $due_interval, $due_date ) = Koha::Recalls->add_recall({ > patron => undef, > biblio => $biblio1, >@@ -147,7 +153,7 @@ is( > is( t::lib::Dates::compare( $due_date, $expected_due_date ), 0, "Due date correctly returned" ); > > my $messages_count = Koha::Notice::Messages->search({ borrowernumber => $patron3->borrowernumber, letter_code => 'RETURN_RECALLED_ITEM' })->count; >-is( $messages_count, 3, "RETURN_RECALLED_ITEM notice successfully sent to checkout borrower" ); >+is( $messages_count, 6, "RETURN_RECALLED_ITEM notice successfully sent to checkout borrower" ); > > my $message = Koha::Recalls->move_recall; > is( $message, 'no recall_id provided', "Can't move a recall without specifying which recall" ); >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23781
:
93905
|
104984
|
131702
|
132044
|
140242
|
140244
|
147107
|
148248
|
148260
|
150430
|
150441
|
155346
|
158696
|
158697
|
158698
|
159013
|
159014
|
159015
|
162377
|
162378
|
162379
|
162380
|
165240
|
165241
|
165242
|
165593
|
165614
|
165615
|
165616
|
165617
|
169201
|
169202
|
169203
|
169204
|
169205