Bugzilla – Attachment 80925 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
Bug-17649-Only-one-message-per-borrower-and-overdu.patch (text/plain), 5.29 KB, created by
Victor Grousset/tuxayo
on 2018-10-19 10:13:45 UTC
(
hide
)
Description:
Bug 17649 Only one message per borrower and overdue level
Filename:
MIME Type:
Creator:
Victor Grousset/tuxayo
Created:
2018-10-19 10:13:45 UTC
Size:
5.29 KB
patch
obsolete
>From 6002b2da39df47723e8854c693b4aceb00da2f2f 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 8c42335..e0c8e06 100755 >--- a/misc/cronjobs/overdue_notices.pl >+++ b/misc/cronjobs/overdue_notices.pl >@@ -74,7 +74,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 >@@ -182,6 +182,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 >@@ -303,6 +310,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, >@@ -322,6 +330,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; >@@ -443,6 +452,8 @@ elsif ( defined $text_filename ) { > } > } > >+my %already_queued; >+my %seen = map { $_ => 1 } @branches; > foreach my $branchcode (@branches) { > my $calendar; > if ( C4::Context->preference('OverdueNoticeCalendar') ) { >@@ -452,14 +463,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 >@@ -467,10 +478,11 @@ SELECT biblio.*, items.*, issues.*, biblioitems.itemtype, branchname > AND b.branchcode = items.homebranch > AND biblio.biblionumber = biblioitems.biblionumber > AND issues.borrowernumber = ? >- AND issues.branchcode = ? > AND items.itemlost = 0 > 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); >@@ -574,6 +586,7 @@ END_SQL > next; > } > $borrowernumber = $data->{'borrowernumber'}; >+ next if ($all_in_one && $already_queued{"$borrowernumber$i"}); > my $borr = > $data->{'firstname'} . ', ' > . $data->{'surname'} . ' (' >@@ -617,7 +630,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); >@@ -663,6 +676,7 @@ END_SQL > $exceededPrintNoticesMaxLines = 1; > last; > } >+ next if $all_in_one and ! grep {$seen{$item_info->{branchcode}}} @branches; > $j++; > > $titles .= C4::Letters::get_item_content( { item => $item_info, item_content_fields => \@item_content_fields, dateonly => 1 } ); >@@ -773,6 +787,7 @@ END_SQL > } > } > } >+ $already_queued{"$borrowernumber$i"} = 1; > } > $sth->finish; > } >-- >2.7.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