Hi there,
I haven't read through this entire thread, but I was experiencing an issue with rev 104 where, when I filtered by manufacturer, it would still show a date with orders, where that manufacturer had no orders, as having orders on the report. The product totals were zero, but the tax and discounts were still there, throwing off numbers. Additionally, I did not want to see any orders for the time period if that manufacturer had no orders.
So, I changed the query that retrieves the order numbers to consider the manufacturer filter and it appears to have resolved the issue. This is a code snippet starting at line 164:
PHP Code:
// build the SQL query of order numbers within the current timeframe
$sql = "SELECT DISTINCT o.orders_id from " . TABLE_ORDERS . " o \n";
if ($this->date_target == 'status') {
if ($this->manufacturer) {
$sql .= "INNER JOIN " . TABLE_ORDERS_PRODUCTS . " op on o.orders_id = op.orders_id \n";
$sql .= "INNER JOIN " . TABLE_PRODUCTS . " p on p.products_id = op.products_id and p.manufacturers_id = " . $this->manufacturer . " \n";
}
$sql .= "LEFT JOIN " . TABLE_ORDERS_STATUS_HISTORY . " osh ON o.orders_id = osh.orders_id \n";
$sql .= "WHERE osh.date_added >= '" . date("Y-m-d H:i:s", $sd) . "' AND osh.date_added < '" . date("Y-m-d H:i:s", $ed) . "' \n";
$sql .= "AND osh.orders_status_id = '" . $this->date_status . "' \n";
}
else {
if ($this->manufacturer) {
$sql .= "INNER JOIN " . TABLE_ORDERS_PRODUCTS . " op on o.orders_id = op.orders_id \n";
$sql .= "INNER JOIN " . TABLE_PRODUCTS . " p on p.products_id = op.products_id and p.manufacturers_id = " . $this->manufacturer . " \n";
}
$sql .= "WHERE o.date_purchased >= '" . date("Y-m-d H:i:s", $sd) . "' AND o.date_purchased < '" . date("Y-m-d H:i:s", $ed) . "' \n";
}
Hope this helps someone else in the same predicament. Thanks for the great report!
Bookmarks