Optionally show out of stock products on the location content sheet (closes #1641)

This commit is contained in:
Bernd Bestel
2022-04-01 21:55:06 +02:00
parent ebfc55064e
commit f7c33a4579
6 changed files with 42 additions and 3 deletions

View File

@@ -628,9 +628,15 @@ class StockService extends BaseService
return array_column($currentStockMapped, 0);
}
public function GetCurrentStockLocationContent()
public function GetCurrentStockLocationContent($includeOutOfStockProductsAtTheDefaultLocation = false)
{
$sql = 'SELECT sclc.* FROM stock_current_location_content sclc JOIN products p ON sclc.product_id = p.id ORDER BY p.name';
$leftJoin = '';
if ($includeOutOfStockProductsAtTheDefaultLocation)
{
$leftJoin = 'LEFT';
}
$sql = 'SELECT IFNULL(sclc.location_id, p.location_id) AS location_id, p.id AS product_id, IFNULL(sclc.amount, 0) AS amount, IFNULL(sclc.amount_opened, 0) AS amount_opened FROM products p ' . $leftJoin . ' JOIN stock_current_location_content sclc ON sclc.product_id = p.id WHERE p.active = 1 ORDER BY p.name';
return $this->getDatabaseService()->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_OBJ);
}