Bugzilla – Attachment 27472 Details for
Bug 10833
Multi transport types for advanced notices
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10833: Multi transport types for advanced notices
Bug-10833-Multi-transport-types-for-advanced-notic.patch (text/plain), 11.42 KB, created by
Jonathan Druart
on 2014-04-23 13:10:09 UTC
(
hide
)
Description:
Bug 10833: Multi transport types for advanced notices
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2014-04-23 13:10:09 UTC
Size:
11.42 KB
patch
obsolete
>From aa2ae015d5294aeadd3c5a1e6c3daa2dc5f511ad Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Fri, 6 Sep 2013 11:39:51 +0200 >Subject: [PATCH] Bug 10833: Multi transport types for advanced notices > >Test plan: >- Choose 2 patrons P1 and P2 >- Edit "Patron messaging preferences" and >check SMS + email with 2 days in advance for P1 >check email with 5 days in advance for P2 >- defined a message for the letter code PREDUE for sms and email > (tools/letters.pl). >- select 2 barcodes (B1, B2). > * checkout B1 to P1 with a due date = NOW - 2 days > * checkout B2 to P2 with a due date = NOW - 5 days >- into the mysql cli, note the value of unsent message: > select count(*) from message_queue where status != "send"; >- launch the cronjob: > perl misc/cronjobs/advance_notices.pl -c >- retry the previous sql query, you should have X + 3 unsent messages > (depending of current checkouts in your DB!). >- view all unsent message: > select borrowernumber, letter_code, message_transport_type, content > from message_queue where status != "send"; > You should see: > 2 messages for P1, 1 for sms, 1 for email and the letter code PREDUE > 1 message for P2, email and the letter code PREDUE > >Signed-off-by: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> >--- > misc/cronjobs/advance_notices.pl | 146 +++++++++++++++++++++++--------------- > 1 file changed, 88 insertions(+), 58 deletions(-) > >diff --git a/misc/cronjobs/advance_notices.pl b/misc/cronjobs/advance_notices.pl >index 4e7149d..d81ad89 100755 >--- a/misc/cronjobs/advance_notices.pl >+++ b/misc/cronjobs/advance_notices.pl >@@ -222,13 +222,13 @@ END_SQL > > my $admin_adress = C4::Context->preference('KohaAdminEmailAddress'); > >+my @letters; > UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { > warn 'examining ' . $upcoming->{'itemnumber'} . ' upcoming due items' if $verbose; > # warn( Data::Dumper->Dump( [ $upcoming ], [ 'overdue' ] ) ); > > my $from_address = $upcoming->{branchemail} || $admin_adress; > >- my $letter; > my $borrower_preferences; > if ( 0 == $upcoming->{'days_until_due'} ) { > # This item is due today. Send an 'item due' message. >@@ -253,14 +253,18 @@ UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { > } > > ## Get branch info for borrowers home library. >- $letter = parse_letter( { letter_code => $letter_type, >+ foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) { >+ my $letter = parse_letter( { letter_code => $letter_type, > borrowernumber => $upcoming->{'borrowernumber'}, > branchcode => $upcoming->{'branchcode'}, > biblionumber => $biblio->{'biblionumber'}, > itemnumber => $upcoming->{'itemnumber'}, >- substitute => { 'items.content' => $titles } >+ substitute => { 'items.content' => $titles }, >+ message_transport_type => $transport, > } ) >- or die "no letter of type '$letter_type' found. Please see sample_notices.sql"; >+ or die "no letter of type '$letter_type' found. Please see sample_notices.sql"; >+ push @letters, $letter; >+ } > } > } else { > $borrower_preferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $upcoming->{'borrowernumber'}, >@@ -285,29 +289,35 @@ UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { > } > > ## Get branch info for borrowers home library. >- $letter = parse_letter( { letter_code => $letter_type, >+ foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) { >+ my $letter = parse_letter( { letter_code => $letter_type, > borrowernumber => $upcoming->{'borrowernumber'}, > branchcode => $upcoming->{'branchcode'}, > biblionumber => $biblio->{'biblionumber'}, > itemnumber => $upcoming->{'itemnumber'}, >- substitute => { 'items.content' => $titles } >+ substitute => { 'items.content' => $titles }, >+ message_transport_type => $transport, > } ) >- or die "no letter of type '$letter_type' found. Please see sample_notices.sql"; >+ or die "no letter of type '$letter_type' found. Please see sample_notices.sql"; >+ push @letters, $letter; >+ } > } > } > > # If we have prepared a letter, send it. >- if ($letter) { >+ if ( @letters ) { > if ($nomail) { >- local $, = "\f"; >- print $letter->{'content'}; >+ for my $letter ( @letters ) { >+ local $, = "\f"; >+ print $letter->{'content'}; >+ } > } > else { >- foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) { >+ for my $letter ( @letters ) { > C4::Letters::EnqueueLetter( { letter => $letter, > borrowernumber => $upcoming->{'borrowernumber'}, > from_address => $from_address, >- message_transport_type => $transport } ); >+ message_transport_type => $letter->{message_transport_type} } ); > } > } > } >@@ -326,7 +336,7 @@ SELECT biblio.*, items.*, issues.* > AND issues.borrowernumber = ? > AND (TO_DAYS(date_due)-TO_DAYS(NOW()) = ?) > END_SQL >- >+@letters = (); > PATRON: while ( my ( $borrowernumber, $digest ) = each %$upcoming_digest ) { > my $count = $digest->{count}; > my $from_address = $digest->{email}; >@@ -349,34 +359,44 @@ PATRON: while ( my ( $borrowernumber, $digest ) = each %$upcoming_digest ) { > ## Get branch info for borrowers home library. > my %branch_info = get_branch_info( $borrowernumber ); > >- my $letter = parse_letter( >- { >- letter_code => $letter_type, >- borrowernumber => $borrowernumber, >- substitute => { >- count => $count, >- 'items.content' => $titles, >- %branch_info, >- }, >- branchcode => $branch_info{ "branches.branchcode" }, >- } >- ) >- or die "no letter of type '$letter_type' found. Please see sample_notices.sql"; >- if ($nomail) { >- local $, = "\f"; >- print $letter->{'content'}; >+ foreach my $transport ( keys %{ $borrower_preferences->{'transports'} } ) { >+ my $letter = parse_letter( >+ { >+ letter_code => $letter_type, >+ borrowernumber => $borrowernumber, >+ substitute => { >+ count => $count, >+ 'items.content' => $titles, >+ %branch_info, >+ }, >+ branchcode => $branch_info{"branches.branchcode"}, >+ message_transport_type => $transport, >+ } >+ ) >+ or die "no letter of type '$letter_type' found. Please see sample_notices.sql"; >+ push @letters, $letter; > } >- else { >- foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) { >- C4::Letters::EnqueueLetter( { letter => $letter, >- borrowernumber => $borrowernumber, >- from_address => $from_address, >- message_transport_type => $transport } ); >+ >+ if ( @letters ) { >+ if ($nomail) { >+ for my $letter ( @letters ) { >+ local $, = "\f"; >+ print $letter->{'content'}; >+ } >+ } >+ else { >+ for my $letter ( @letters ) { >+ C4::Letters::EnqueueLetter( { letter => $letter, >+ borrowernumber => $borrowernumber, >+ from_address => $from_address, >+ message_transport_type => $letter->{message_transport_type} } ); >+ } > } > } > } > > # Now, run through all the people that want digests and send them >+@letters = (); > PATRON: while ( my ( $borrowernumber, $digest ) = each %$due_digest ) { > my $count = $digest->{count}; > my $from_address = $digest->{email}; >@@ -397,32 +417,41 @@ PATRON: while ( my ( $borrowernumber, $digest ) = each %$due_digest ) { > ## Get branch info for borrowers home library. > my %branch_info = get_branch_info( $borrowernumber ); > >- my $letter = parse_letter( >- { >- letter_code => $letter_type, >- borrowernumber => $borrowernumber, >- substitute => { >- count => $count, >- 'items.content' => $titles, >- %branch_info, >- }, >- branchcode => $branch_info{ "branches.branchcode" }, >- } >- ) >- or die "no letter of type '$letter_type' found. Please see sample_notices.sql"; >- >- if ($nomail) { >- local $, = "\f"; >- print $letter->{'content'}; >+ for my $transport ( keys %{ $borrower_preferences->{'transports'} } ) { >+ my $letter = parse_letter( >+ { >+ letter_code => $letter_type, >+ borrowernumber => $borrowernumber, >+ substitute => { >+ count => $count, >+ 'items.content' => $titles, >+ %branch_info, >+ }, >+ branchcode => $branch_info{"branches.branchcode"}, >+ message_transport_type => $transport, >+ } >+ ) >+ or die "no letter of type '$letter_type' found. Please see sample_notices.sql"; >+ push @letters, $letter; > } >- else { >- foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) { >- C4::Letters::EnqueueLetter( { letter => $letter, >- borrowernumber => $borrowernumber, >- from_address => $from_address, >- message_transport_type => $transport } ); >+ >+ if ( @letters ) { >+ if ($nomail) { >+ for my $letter ( @letters ) { >+ local $, = "\f"; >+ print $letter->{'content'}; >+ } >+ } >+ else { >+ for my $letter ( @letters ) { >+ C4::Letters::EnqueueLetter( { letter => $letter, >+ borrowernumber => $borrowernumber, >+ from_address => $from_address, >+ message_transport_type => $letter->{message_transport_type} } ); >+ } > } > } >+ > } > > =head1 METHODS >@@ -457,6 +486,7 @@ sub parse_letter { > branchcode => $table_params{'branches'}, > substitute => $params->{'substitute'}, > tables => \%table_params, >+ message_transport_type => $params->{message_transport_type}, > ); > } > >-- >1.7.10.4
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 10833
:
20820
|
23901
|
23902
|
27472
|
27473
|
27528
|
27529