Bug 39866: Acquisitions statistics fails when filling only the To date

This patch fixes the exection of the report Acquisitions statistics if you fill only the To date
Test plan:
1 Execute the report Acquisitions statistics filling only To date filter in Placed on or Received on (/cgi-bin/koha/reports/acquisitions_stats.pl) Koha returns an Internal Server Error
2 Apply patch, restart services
3 Repeat step 1, now the report returns the results page as expected

Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
[EDIT] Removed superfluous COALESCEs.
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 856a85d3af)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Adolfo Rodríguez 2025-05-09 11:00:22 +02:00 committed by Paul Derscheid
parent b48f5c432d
commit 169b255f9d
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
1 changed files with 6 additions and 2 deletions

View File

@ -310,10 +310,12 @@ sub calculate {
$strsth .= " ORDER BY $line";
my $sth = $dbh->prepare($strsth);
if ( (@linefilter) and ( $linefilter[1] ) ) {
if ( (@linefilter) and ( $linefilter[0] && $linefilter[1] ) ) {
$sth->execute( $linefilter[0], $linefilter[1] );
} elsif ( $linefilter[0] ) {
$sth->execute( $linefilter[0] );
} elsif ( $linefilter[1] ) {
$sth->execute( $linefilter[1] );
} else {
$sth->execute;
}
@ -364,10 +366,12 @@ sub calculate {
my $sth2 = $dbh->prepare($strsth2);
if ( (@colfilter) and ( $colfilter[1] ) ) {
if ( (@colfilter) and ( $colfilter[0] and $colfilter[1] ) ) {
$sth2->execute( $colfilter[0], $colfilter[1] );
} elsif ( $colfilter[0] ) {
$sth2->execute( $colfilter[0] );
} elsif ( $colfilter[1] ) {
$sth2->execute( $colfilter[1] );
} else {
$sth2->execute;
}