From cbd825e52618017d836f3b3794e2b2e2396fd724 Mon Sep 17 00:00:00 2001 From: xgerhard Date: Tue, 5 Oct 2021 00:03:00 +0200 Subject: [PATCH 1/2] FIX|Fix #18890 Fix disabled button if sum real qty is 0 Instead of counting the sum of the 'real qty' input, only disable the button if no input has been given, or if all input is the same as the expected qty. '$object->status' check seems unnecessary here since the button is only there when the status is 'STATUS_VALIDATED'. --- htdocs/product/inventory/inventory.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 2ebde580db7..f9fd832b138 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -716,7 +716,7 @@ if ($object->id > 0) { $num = $db->num_rows($resql); $i = 0; - $totalfound = 0; + $hasinput = false; $totalarray = array(); while ($i < $num) { $obj = $db->fetch_object($resql); @@ -766,7 +766,10 @@ if ($object->id > 0) { print ''; if ($object->status == $object::STATUS_VALIDATED) { $qty_view = GETPOST("id_".$obj->rowid) && price2num(GETPOST("id_".$obj->rowid), 'MS') >= 0 ? GETPOST("id_".$obj->rowid) : $obj->qty_view; - $totalfound += price2num($qty_view, 'MS'); + if (!$hasinput && $qty_view !== null && $obj->qty_stock != $qty_view) { + $hasinput = true; + } + print ''; print ''; print ''; @@ -777,7 +780,6 @@ if ($object->id > 0) { print ''; } else { print $obj->qty_view; - $totalfound += $obj->qty_view; print ''; } print ''; @@ -799,7 +801,7 @@ if ($object->id > 0) { print ''; // Call method to disable the button if no qty entered yet for inventory - if ($object->status != $object::STATUS_VALIDATED || $totalfound == 0) { + if (!$hasinput) { print '