Bug 10606: Remove MySQLism in GetUpcomingDueIssues
authorTomas Cohen Arazi <tomascohen@gmail.com>
Tue, 13 Aug 2013 13:56:15 +0000 (10:56 -0300)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Wed, 21 Jan 2015 14:06:24 +0000 (11:06 -0300)
To test:

[1] Arrange to have at least one loan in your test database due
    one day from now.
[2] Run misc/cronjobs/advance_notices.pl -c -n -v -m=2
    and note the number of loans reported.
[3] Apply the patch.
[4] Run misc/cronjobs/advance_notices.pl -c -n -v -m=2 again
    and verify that the number of loans reported remains the same.

Sponsored-by: Universidad Nacional de Cordoba
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
All tests and QA script pass.
Also tested with unit tests from bug 10719.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
C4/Circulation.pm

index dd081af..14dfb0e 100644 (file)
@@ -2604,12 +2604,13 @@ sub GetUpcomingDueIssues {
     my $dbh = C4::Context->dbh;
 
     my $statement = <<END_SQL;
-SELECT issues.*, items.itype as itemtype, items.homebranch, TO_DAYS( date_due )-TO_DAYS( NOW() ) as days_until_due, branches.branchemail
+SELECT issues.*, items.itype as itemtype, items.homebranch, DATE( date_due )-DATE( NOW() ) as days_until_due, branches.branchemail
 FROM issues 
 LEFT JOIN items USING (itemnumber)
 LEFT OUTER JOIN branches USING (branchcode)
 WHERE returndate is NULL
-HAVING days_until_due >= 0 AND days_until_due <= ?
+AND (DATE( date_due )-DATE( NOW() )) >= 0
+AND (DATE( date_due )-DATE( NOW() )) <= ?
 END_SQL
 
     my @bind_parameters = ( $params->{'days_in_advance'} );