From 1be4678a57200ba895b73e3b3d38f331a9b8cbb4 Mon Sep 17 00:00:00 2001 From: Sophie Meynieux Date: Tue, 30 Aug 2011 16:54:42 +0200 Subject: [PATCH] Bug 6292 : Followup 2. several letters where generated if a borrower had overdues with different due_date triggering the same level This patch fixes the SQL request giving the list of borrowers Signed-off-by: Chris Cormack Signed-off-by: Paul Poulain --- misc/cronjobs/overdue_notices.pl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl index 4feb3eed64..27941da7bd 100755 --- a/misc/cronjobs/overdue_notices.pl +++ b/misc/cronjobs/overdue_notices.pl @@ -426,7 +426,7 @@ END_SQL # my $borrower_sql = <<'END_SQL'; -SELECT distinct(issues.borrowernumber), firstname, surname, address, address2, city, zipcode, country, email, date_due +SELECT distinct(issues.borrowernumber), firstname, surname, address, address2, city, zipcode, country, email FROM issues,borrowers,categories WHERE issues.borrowernumber=borrowers.borrowernumber AND borrowers.categorycode=categories.categorycode @@ -442,10 +442,10 @@ END_SQL } $borrower_sql .= ' AND categories.overduenoticerequired=1 '; if($triggered) { - $borrower_sql .= ' HAVING TO_DAYS(NOW())-TO_DAYS(date_due) = ?'; + $borrower_sql .= ' AND TO_DAYS(NOW())-TO_DAYS(date_due) = ?'; push @borrower_parameters, $mindays; } else { - $borrower_sql .= ' HAVING TO_DAYS(NOW())-TO_DAYS(date_due) BETWEEN ? and ? ' ; + $borrower_sql .= ' AND TO_DAYS(NOW())-TO_DAYS(date_due) BETWEEN ? and ? ' ; push @borrower_parameters, $mindays, $maxdays; } @@ -455,8 +455,8 @@ END_SQL $verbose and warn $borrower_sql . "\n $branchcode | " . $overdue_rules->{'categorycode'} . "\n ($mindays, $maxdays)\nreturns " . $sth->rows . " rows"; while ( my ( $borrowernumber, $firstname, $lastname, - $address1, $address2, $city, $postcode, $country, $email, - $date_due ) = $sth->fetchrow ) + $address1, $address2, $city, $postcode, $country, $email + ) = $sth->fetchrow ) { $verbose and warn "borrower $firstname, $lastname ($borrowernumber) has items triggering level $i."; -- 2.39.5