From 777814a2608a2376cd44ce2b410bb0b7fa465190 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 9 Sep 2013 16:58:22 +0200 Subject: [PATCH] Bug 10845: Multi transport types for holds The HOLD_PRINT and HOLD_PHONE notices become useless. This patch modifies existing notices in order to group them into the main notice type 'HOLD', with any pre-existing print and phone templates in the appropriate places. Test plan: - Apply the patch and execute the update database entry. - Verify that your previous HOLD_PHONE and HOLD_PRINT are displayed when editing the HOLD notice (under phone and print). - Choose a patron and check SMS, email, phone for "Hold filled" (on the patron messaging preferences). - Place a hold. - Check the item in and confirm the hold. - If the patron has an email *and* a SMS number, 2 new messages are put into the message_queue table: 1 sms and 1 email. If the patron does not have 1 of them, there are 2 new messages: 1 sms/email and 1 print. If the user has neither of them, there is 1 new message: 1 print. - The generated messages should correspond with the notices defined, depending the message transport type. Signed-off-by: Olli-Antti Kivilahti Signed-off-by: Marcel de Rooy Just noting that if email and SMS are disabled in the msg prefs, the user will not have a print message. And if the SMS driver fails, the record status in message_queue is 'failed', but staff may not be aware of that. Signed-off-by: Galen Charlton --- C4/Reserves.pm | 58 ++++++------------- installer/data/mysql/updatedatabase.pl | 20 +++++++ .../prog/en/modules/help/tools/letter.tt | 8 +-- .../thirdparty/TalkingTech_itiva_outbound.pl | 5 +- 4 files changed, 41 insertions(+), 50 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 49f8c11443..6c06e2c54a 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -1890,15 +1890,11 @@ sub _koha_notify_reserve { # Try to get the borrower's email address my $to_address = C4::Members::GetNoticeEmailAddress($borrowernumber); - - my $letter_code; - my $print_mode = 0; - my $messagingprefs; - if ( $to_address || $borrower->{'smsalertnumber'} ) { - $messagingprefs = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $borrowernumber, message_name => 'Hold_Filled' } ); - } else { - $print_mode = 1; - } + + my $messagingprefs = C4::Members::Messaging::GetMessagingPreferences( { + borrowernumber => $borrowernumber, + message_name => 'Hold_Filled' + } ); my $sth = $dbh->prepare(" SELECT * @@ -1925,43 +1921,23 @@ sub _koha_notify_reserve { substitute => { today => C4::Dates->new()->output() }, ); - - if ( $print_mode ) { - $letter_params{ 'letter_code' } = 'HOLD_PRINT'; - my $letter = C4::Letters::GetPreparedLetter ( %letter_params ) or die "Could not find a letter called '$letter_params{'letter_code'}' in the 'reserves' module"; + my $print_sent = 0; + while ( my ( $mtt, $letter_code ) = each %{ $messagingprefs->{transports} } ) { + if ( ($mtt eq 'email' and not $to_address) or ($mtt eq 'sms' and not $borrower->{smsalertnumber}) ) { + # email or sms is requested but not exist, do a print. + $mtt = 'print'; + } + $letter_params{letter_code} = $letter_code; + $letter_params{message_transport_type} = $mtt; + my $letter = C4::Letters::GetPreparedLetter ( %letter_params ) + or die "Could not find a letter called '$letter_params{'letter_code'}' in the 'reserves' module"; C4::Letters::EnqueueLetter( { letter => $letter, borrowernumber => $borrowernumber, - message_transport_type => 'print', + from_address => $admin_email_address, + message_transport_type => $mtt, } ); - - return; - } - - if ( $to_address && defined $messagingprefs->{transports}->{'email'} ) { - $letter_params{ 'letter_code' } = $messagingprefs->{transports}->{'email'}; - my $letter = C4::Letters::GetPreparedLetter ( %letter_params ) or die "Could not find a letter called '$letter_params{'letter_code'}' in the 'reserves' module"; - - C4::Letters::EnqueueLetter( - { letter => $letter, - borrowernumber => $borrowernumber, - message_transport_type => 'email', - from_address => $admin_email_address, - } - ); - } - - if ( $borrower->{'smsalertnumber'} && defined $messagingprefs->{transports}->{'sms'} ) { - $letter_params{ 'letter_code' } = $messagingprefs->{transports}->{'sms'}; - my $letter = C4::Letters::GetPreparedLetter ( %letter_params ) or die "Could not find a letter called '$letter_params{'letter_code'}' in the 'reserves' module"; - - C4::Letters::EnqueueLetter( - { letter => $letter, - borrowernumber => $borrowernumber, - message_transport_type => 'sms', - } - ); } } diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 433e70fbe3..af7cbc6ce0 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -8295,6 +8295,26 @@ if ( CheckVersion($DBversion) ) { } + + + + +$DBversion = "3.15.00.XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do(q| + UPDATE message_transports SET letter_code='HOLD' WHERE letter_code='HOLD_PHONE' OR letter_code='HOLD_PRINT' + |); + $dbh->do(q| + UPDATE letter SET code='HOLD', message_transport_type='print' WHERE code='HOLD_PRINT' + |); + $dbh->do(q| + UPDATE letter SET code='HOLD', message_transport_type='phone' WHERE code='HOLD_PHONE' + |); + print "Upgrade to $DBversion done (Bug 10845: Multi transport types for holds)\n"; + SetVersion($DBversion); +} + + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/help/tools/letter.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/help/tools/letter.tt index 2f1f9d3b58..18d90a19f2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/help/tools/letter.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/help/tools/letter.tt @@ -99,12 +99,6 @@
  • This notice requires the emailLibrarianWhenHoldIsPlaced system preference to be set to 'Enable'
  • When this notice references the branches table it is referring to the pickup library information.
  • - -
  • HOLD_PRINT (Printed notice when hold available for pickup) -
      -
    • This notice is used for hold confirmation notices that are sent out in print format. This will not effect what the email notice looks like.
    • -
    • When this notice references the branches table it is referring to the pickup library information.
    • -
  • ODUE (Overdue Notice)
      @@ -159,4 +153,4 @@

      See the full documentation for Notices in the manual (online).

      -[% INCLUDE 'help-bottom.inc' %] \ No newline at end of file +[% INCLUDE 'help-bottom.inc' %] diff --git a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl index b4d4e9c989..42728d6bc0 100755 --- a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl +++ b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl @@ -70,7 +70,7 @@ my $type_module_map = { my $type_notice_map = { 'PREOVERDUE' => 'PREDUE_PHONE', 'OVERDUE' => 'OVERDUE_PHONE', - 'RESERVE' => 'HOLD_PHONE', + 'RESERVE' => 'HOLD', }; GetOptions( @@ -133,7 +133,8 @@ foreach my $type (@types) { tables => { borrowers => $issues->{'borrowernumber'}, biblio => $issues->{'biblionumber'}, - biblioitems => $issues->{'biblionumber'} + biblioitems => $issues->{'biblionumber'}, + message_transport_type => 'phone', }, ); -- 2.39.5