Lines 484-497
END_SQL
Link Here
|
484 |
# <date> <itemcount> <firstname> <lastname> <address1> <address2> <address3> <city> <postcode> <country> |
484 |
# <date> <itemcount> <firstname> <lastname> <address1> <address2> <address3> <city> <postcode> <country> |
485 |
|
485 |
|
486 |
my $borrower_sql = <<'END_SQL'; |
486 |
my $borrower_sql = <<'END_SQL'; |
487 |
SELECT issues.borrowernumber, firstname, surname, address, address2, city, zipcode, country, email, emailpro, B_email, smsalertnumber, |
487 |
SELECT issues.borrowernumber, firstname, surname, address, address2, city, zipcode, country, email, emailpro, B_email, smsalertnumber, |
488 |
TO_DAYS(?)-TO_DAYS(date_due) as difference, date_due |
488 |
TO_DAYS(?)-TO_DAYS(date_due) as difference, date_due |
489 |
FROM issues,borrowers,categories |
489 |
FROM issues,borrowers,categories |
490 |
WHERE issues.borrowernumber=borrowers.borrowernumber |
490 |
WHERE issues.borrowernumber=borrowers.borrowernumber |
491 |
AND borrowers.categorycode=categories.categorycode |
491 |
AND borrowers.categorycode=categories.categorycode |
492 |
END_SQL |
492 |
END_SQL |
493 |
my @borrower_parameters; |
493 |
my @borrower_parameters; |
494 |
push @borrower_parameters, $date_to_run->datetime(); |
494 |
push @borrower_parameters, $date_to_run->datetime(); |
495 |
if ($branchcode) { |
495 |
if ($branchcode) { |
496 |
$borrower_sql .= ' AND issues.branchcode=? '; |
496 |
$borrower_sql .= ' AND issues.branchcode=? '; |
497 |
push @borrower_parameters, $branchcode; |
497 |
push @borrower_parameters, $branchcode; |
Lines 501-511
END_SQL
Link Here
|
501 |
push @borrower_parameters, $overdue_rules->{categorycode}; |
501 |
push @borrower_parameters, $overdue_rules->{categorycode}; |
502 |
} |
502 |
} |
503 |
$borrower_sql .= ' AND categories.overduenoticerequired=1 ORDER BY issues.borrowernumber'; |
503 |
$borrower_sql .= ' AND categories.overduenoticerequired=1 ORDER BY issues.borrowernumber'; |
504 |
|
504 |
|
505 |
# $sth gets borrower info iff at least one overdue item has triggered the overdue action. |
505 |
# $sth gets borrower info iff at least one overdue item has triggered the overdue action. |
506 |
my $sth = $dbh->prepare($borrower_sql); |
506 |
my $sth = $dbh->prepare($borrower_sql); |
507 |
$sth->execute(@borrower_parameters); |
507 |
$sth->execute(@borrower_parameters); |
508 |
|
508 |
|
509 |
$verbose and warn $borrower_sql . "\n $branchcode | " . $overdue_rules->{'categorycode'} . "\n ($mindays, $maxdays, ". $date_to_run->datetime() .")\nreturns " . $sth->rows . " rows"; |
509 |
$verbose and warn $borrower_sql . "\n $branchcode | " . $overdue_rules->{'categorycode'} . "\n ($mindays, $maxdays, ". $date_to_run->datetime() .")\nreturns " . $sth->rows . " rows"; |
510 |
my $borrowernumber; |
510 |
my $borrowernumber; |
511 |
while ( my $data = $sth->fetchrow_hashref ) { |
511 |
while ( my $data = $sth->fetchrow_hashref ) { |
512 |
- |
|
|