View | Details | Raw Unified | Return to bug 20144
Collapse All | Expand All

(-)a/C4/Acquisition.pm (-4 / +3 lines)
Lines 2150-2156 sub GetLateOrders { Link Here
2150
        AND aqbasket.closedate IS NOT NULL
2150
        AND aqbasket.closedate IS NOT NULL
2151
        AND (aqorders.datecancellationprinted IS NULL OR aqorders.datecancellationprinted='0000-00-00')
2151
        AND (aqorders.datecancellationprinted IS NULL OR aqorders.datecancellationprinted='0000-00-00')
2152
    ";
2152
    ";
2153
    my $having = "";
2154
    if ($dbdriver eq "mysql") {
2153
    if ($dbdriver eq "mysql") {
2155
        $select .= "
2154
        $select .= "
2156
        aqorders.quantity - COALESCE(aqorders.quantityreceived,0)                 AS quantity,
2155
        aqorders.quantity - COALESCE(aqorders.quantityreceived,0)                 AS quantity,
Lines 2161-2167 sub GetLateOrders { Link Here
2161
            $from .= " AND (closedate <= DATE_SUB(CAST(now() AS date),INTERVAL ? DAY)) " ;
2160
            $from .= " AND (closedate <= DATE_SUB(CAST(now() AS date),INTERVAL ? DAY)) " ;
2162
            push @query_params, $delay;
2161
            push @query_params, $delay;
2163
        }
2162
        }
2164
        $having = "HAVING quantity <> 0";
2163
        $from .= " AND aqorders.quantity - COALESCE(aqorders.quantityreceived,0) <> 0";
2165
    } else {
2164
    } else {
2166
        # FIXME: account for IFNULL as above
2165
        # FIXME: account for IFNULL as above
2167
        $select .= "
2166
        $select .= "
Lines 2173-2178 sub GetLateOrders { Link Here
2173
            $from .= " AND (closedate <= (CAST(now() AS date) -(INTERVAL ? DAY)) ";
2172
            $from .= " AND (closedate <= (CAST(now() AS date) -(INTERVAL ? DAY)) ";
2174
            push @query_params, $delay;
2173
            push @query_params, $delay;
2175
        }
2174
        }
2175
        $from .= " AND aqorders.quantity <> 0";
2176
    }
2176
    }
2177
    if (defined $supplierid) {
2177
    if (defined $supplierid) {
2178
        $from .= ' AND aqbasket.booksellerid = ? ';
2178
        $from .= ' AND aqbasket.booksellerid = ? ';
Lines 2203-2209 sub GetLateOrders { Link Here
2203
        push @query_params, C4::Context->userenv->{branch};
2203
        push @query_params, C4::Context->userenv->{branch};
2204
    }
2204
    }
2205
    $from .= " AND orderstatus <> 'cancelled' ";
2205
    $from .= " AND orderstatus <> 'cancelled' ";
2206
    my $query = "$select $from $having\nORDER BY latesince, basketno, borrowers.branchcode, supplier";
2206
    my $query = "$select $from \nORDER BY latesince, basketno, borrowers.branchcode, supplier";
2207
    $debug and print STDERR "GetLateOrders query: $query\nGetLateOrders args: " . join(" ",@query_params);
2207
    $debug and print STDERR "GetLateOrders query: $query\nGetLateOrders args: " . join(" ",@query_params);
2208
    my $sth = $dbh->prepare($query);
2208
    my $sth = $dbh->prepare($query);
2209
    $sth->execute(@query_params);
2209
    $sth->execute(@query_params);
2210
- 

Return to bug 20144