Bugzilla – Attachment 58398 Details for
Bug 17649
Create only one message per borrower and overdue level
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17649 - Only one message per borrower and overdue level
0001-Bug-17649-Only-one-message-per-borrower-and-overdue-.patch (text/plain), 5.36 KB, created by
Koha Team University Lyon 3
on 2016-12-22 17:19:23 UTC
(
hide
)
Description:
Bug 17649 - Only one message per borrower and overdue level
Filename:
MIME Type:
Creator:
Koha Team University Lyon 3
Created:
2016-12-22 17:19:23 UTC
Size:
5.36 KB
patch
obsolete
>From 9a207400a91ca8fbb3e96905201d90c122236b20 Mon Sep 17 00:00:00 2001 >From: Olivier Crouzet <koha@univ-lyon-fr> >Date: Thu, 22 Dec 2016 18:06:07 +0100 >Subject: [PATCH] Bug 17649 Only one message per borrower and overdue level > >The added option (-a|--all_in_one) allows to create only one message per borrower and delay level >including overdues from whatever branches. >A branchcode value (branches.branchcode) has to be given to choose which sender address will be set. >--- > misc/cronjobs/overdue_notices.pl | 25 ++++++++++++++++++++----- > 1 file changed, 20 insertions(+), 5 deletions(-) > >diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl >index 0aaf22a..65addea 100755 >--- a/misc/cronjobs/overdue_notices.pl >+++ b/misc/cronjobs/overdue_notices.pl >@@ -73,7 +73,7 @@ overdue_notices.pl > -list-all list all overdues > -date <yyyy-mm-dd> emulate overdues run for this date > -email <email_type> type of email that will be used. Can be 'email', 'emailpro' or 'B_email'. Repeatable. >- >+ -a <branchcode> Create only one message per borrower and delay level including overdues from all branches. > =head1 OPTIONS > > =over 8 >@@ -181,6 +181,13 @@ use it in order to send overdues on a specific date and not Now. Format: YYYY-MM > > Allows to specify which type of email will be used. Can be email, emailpro or B_email. Repeatable. > >+=item B<-a> | B<--all_in_one> >+ >+Create only one message per borrower and for each delay level including overdues from all branches. >+Branchcode value (branches.branchcode) has to be given to choose which sender address will be set. >+It's recommended to use this option only with default notice(s) defined for 'All branches' >+in Notices & Slips and no specific ones. >+ > =back > > =head1 DESCRIPTION >@@ -302,6 +309,7 @@ my $itemscontent = join( ',', qw( date_due title barcode author itemnumber ) ); > my @myborcat; > my @myborcatout; > my ( $date_input, $today ); >+my $all_in_one; > > GetOptions( > 'help|?' => \$help, >@@ -321,6 +329,7 @@ GetOptions( > 'borcat=s' => \@myborcat, > 'borcatout=s' => \@myborcatout, > 'email=s' => \@emails, >+ 'a|all_in_one=s' => \$all_in_one, > ) or pod2usage(2); > pod2usage(1) if $help; > pod2usage( -verbose => 2 ) if $man; >@@ -442,6 +451,8 @@ elsif ( defined $text_filename ) { > } > } > >+my %already_queued; >+my %seen = map { $_ => 1 } @branches; > foreach my $branchcode (@branches) { > if ( C4::Context->preference('OverdueNoticeCalendar') ) { > my $calendar = Koha::Calendar->new( branchcode => $branchcode ); >@@ -450,14 +461,14 @@ foreach my $branchcode (@branches) { > } > } > >- my $library = Koha::Libraries->find($branchcode); >+ my $library = $all_in_one ? Koha::Libraries->find($all_in_one) : Koha::Libraries->find($branchcode); > my $admin_email_address = $library->branchemail > || C4::Context->preference('KohaAdminEmailAddress'); > my @output_chunks; # may be sent to mail or stdout or csv file. > > $verbose and warn sprintf "branchcode : '%s' using %s\n", $branchcode, $admin_email_address; > >- my $sth2 = $dbh->prepare( <<"END_SQL" ); >+ my $overduequery = <<"END_SQL"; > SELECT biblio.*, items.*, issues.*, biblioitems.itemtype, branchname > FROM issues,items,biblio, biblioitems, branches b > WHERE items.itemnumber=issues.itemnumber >@@ -465,9 +476,10 @@ SELECT biblio.*, items.*, issues.*, biblioitems.itemtype, branchname > AND b.branchcode = items.homebranch > AND biblio.biblionumber = biblioitems.biblionumber > AND issues.borrowernumber = ? >- AND issues.branchcode = ? > AND TO_DAYS($date)-TO_DAYS(issues.date_due) >= 0 > END_SQL >+ $overduequery.= " AND issues.branchcode = ?" unless $all_in_one; >+ my $sth2 = $dbh->prepare($overduequery); > > my $query = "SELECT * FROM overduerules WHERE delay1 IS NOT NULL AND branchcode = ? "; > $query .= " AND categorycode IN (".join( ',' , ('?') x @myborcat ).") " if (@myborcat); >@@ -571,6 +583,7 @@ END_SQL > next; > } > $borrowernumber = $data->{'borrowernumber'}; >+ next if ($all_in_one && $already_queued{"$borrowernumber$i"}); > my $borr = > $data->{'firstname'} . ', ' > . $data->{'surname'} . ' (' >@@ -614,7 +627,7 @@ END_SQL > ) unless $test_mode; > $verbose and warn "debarring $borr\n"; > } >- my @params = ($borrowernumber,$branchcode); >+ my @params = $all_in_one ? ($borrowernumber) : ($borrowernumber, $branchcode); > $verbose and warn "STH2 PARAMS: borrowernumber = $borrowernumber"; > > $sth2->execute(@params); >@@ -662,6 +675,7 @@ END_SQL > $exceededPrintNoticesMaxLines = 1; > last; > } >+ next if $all_in_one and ! grep {$seen{$item_info->{branchcode}}} @branches; > $j++; > my @item_info = map { $_ =~ /^date|date$/ ? > eval { output_pref( { dt => dt_from_string( $item_info->{$_} ), dateonly => 1 } ); } >@@ -775,6 +789,7 @@ END_SQL > } > } > } >+ $already_queued{"$borrowernumber$i"} = 1; > } > $sth->finish; > } >-- >2.1.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 17649
:
57594
|
58398
|
80925
|
125298
|
145695
|
148927