OTC-Overlay im Home

This commit is contained in:
2026-06-15 13:29:20 +02:00
parent 457fa0316f
commit 69a9420c03
4 changed files with 360 additions and 3 deletions
+31
View File
@@ -19,6 +19,37 @@ function get_default_location_ids(PDO $pdo): array
];
}
function get_otc_order_form_products(PDO $pdo): array
{
$stmt = $pdo->query(
"SELECT
p.id,
p.name,
COALESCE(SUM(v.qty_net), 0) AS available_qty
FROM product p
INNER JOIN stock_lot sl
ON sl.product_id = p.id
AND sl.status = 'current'
INNER JOIN v_stock_lot_balance v
ON v.stock_lot_id = sl.id
WHERE p.status = 'active'
GROUP BY p.id, p.name
HAVING COALESCE(SUM(v.qty_net), 0) > 0
ORDER BY p.name ASC, p.id ASC"
);
$products = [];
foreach ($stmt->fetchAll() as $row) {
$products[] = [
'id' => (int) $row['id'],
'name' => (string) $row['name'],
'available_qty' => (float) $row['available_qty'],
];
}
return $products;
}
function get_current_lot_balance_for_update(PDO $pdo, int $productId): array
{
$stmt = $pdo->prepare(