Actualiser api/index.php
CI / PHP Syntax Check (push) Has been cancelled
CI / JavaScript Lint (push) Has been cancelled
CI / Docker Build Test (push) Has been cancelled
CI / Validate Translation Files (push) Has been cancelled
CI / Auto-merge develop → main (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
Security Scan (Trivy) / Trivy — Docker image scan (push) Has been cancelled
Security Scan (Trivy) / Trivy — Filesystem scan (push) Has been cancelled
CI / PHP Syntax Check (push) Has been cancelled
CI / JavaScript Lint (push) Has been cancelled
CI / Docker Build Test (push) Has been cancelled
CI / Validate Translation Files (push) Has been cancelled
CI / Auto-merge develop → main (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
Security Scan (Trivy) / Trivy — Docker image scan (push) Has been cancelled
Security Scan (Trivy) / Trivy — Filesystem scan (push) Has been cancelled
This commit is contained in:
+7
-5
@@ -3158,8 +3158,9 @@ function addToInventory(PDO $db): void {
|
||||
// NOTE: default_quantity is the PACKAGE SIZE, not the quantity being added —
|
||||
// do NOT overwrite it here. It is managed via product_save / the edit form.
|
||||
if ($unit) {
|
||||
$stmt = $db->prepare("UPDATE products SET unit = ?, updated_at = CURRENT_TIMESTAMP WHERE id = ?");
|
||||
$stmt->execute([$unit, $productId]);
|
||||
$displayUnitKey = $input['display_unit_key'] ?? null;
|
||||
$stmt = $db->prepare("UPDATE products SET unit = ?, display_unit_key = ?, updated_at = CURRENT_TIMESTAMP WHERE id = ?");
|
||||
$stmt->execute([$unit, $displayUnitKey, $productId]);
|
||||
} else {
|
||||
// Auto-set default_quantity if product has none (first add sets package size)
|
||||
$stmt = $db->prepare("SELECT default_quantity, unit FROM products WHERE id = ?");
|
||||
@@ -3764,12 +3765,13 @@ function updateInventory(PDO $db): void {
|
||||
// silently revert the user's correction on the next scan.
|
||||
if (isset($input['unit']) && isset($input['product_id'])) {
|
||||
$newUnit = $input['unit'];
|
||||
$newDisplayUnitKey = $input['display_unit_key'] ?? null;
|
||||
if ($newUnit === 'pz') {
|
||||
$stmt = $db->prepare("UPDATE products SET unit = ?, default_quantity = CASE WHEN default_quantity < 1 THEN 1 ELSE default_quantity END, updated_at = CURRENT_TIMESTAMP WHERE id = ?");
|
||||
$stmt = $db->prepare("UPDATE products SET unit = ?, display_unit_key = ?, default_quantity = CASE WHEN default_quantity < 1 THEN 1 ELSE default_quantity END, updated_at = CURRENT_TIMESTAMP WHERE id = ?");
|
||||
} else {
|
||||
$stmt = $db->prepare("UPDATE products SET unit = ?, updated_at = CURRENT_TIMESTAMP WHERE id = ?");
|
||||
$stmt = $db->prepare("UPDATE products SET unit = ?, display_unit_key = ?, updated_at = CURRENT_TIMESTAMP WHERE id = ?");
|
||||
}
|
||||
$stmt->execute([$newUnit, $input['product_id']]);
|
||||
$stmt->execute([$newUnit, $newDisplayUnitKey, $input['product_id']]);
|
||||
}
|
||||
|
||||
// Update package info if provided
|
||||
|
||||
Reference in New Issue
Block a user