mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 12:20:22 +00:00
@@ -26,25 +26,16 @@ class StockService extends BaseService
|
|||||||
|
|
||||||
$sql = 'SELECT * FROM stock_current WHERE best_before_date IS NOT NULL UNION SELECT id, 0, 0, null, 0, 0, 0 FROM ' . $missingProductsView . ' WHERE id NOT IN (SELECT product_id FROM stock_current)';
|
$sql = 'SELECT * FROM stock_current WHERE best_before_date IS NOT NULL UNION SELECT id, 0, 0, null, 0, 0, 0 FROM ' . $missingProductsView . ' WHERE id NOT IN (SELECT product_id FROM stock_current)';
|
||||||
}
|
}
|
||||||
|
$currentStockMapped = $this->DatabaseService->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_GROUP|\PDO::FETCH_OBJ);
|
||||||
$current_stock = $this->DatabaseService->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_OBJ);
|
|
||||||
$stock_array = [];
|
$relevantProducts = $this->Database->products()->where('id IN (SELECT product_id FROM (' . $sql . ') x)');
|
||||||
|
foreach ($relevantProducts as $product)
|
||||||
foreach ($current_stock as $cur) {
|
{
|
||||||
$stock_array[$cur->product_id] = $cur;
|
$currentStockMapped[$product->id][0]->product_id = $product->id;
|
||||||
|
$currentStockMapped[$product->id][0]->product = $product;
|
||||||
}
|
}
|
||||||
|
|
||||||
$list_of_product_ids = implode(",", array_keys($stock_array));
|
return array_column($currentStockMapped, 0);
|
||||||
|
|
||||||
$sql = 'SELECT * FROM products WHERE id in (' . $list_of_product_ids . ')';
|
|
||||||
|
|
||||||
$products = $this->DatabaseService->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_OBJ);
|
|
||||||
|
|
||||||
foreach ($products as $product) {
|
|
||||||
$stock_array[$product->id]->product = $product;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $stock_array;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function GetCurrentStockLocationContent()
|
public function GetCurrentStockLocationContent()
|
||||||
|
Reference in New Issue
Block a user