diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 82747fb8360..95c9e2972cb 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -630,7 +630,10 @@ if ($object->id > 0) { errortab3 = []; errortab4 = []; - if(textarray[0] != ""){ + textarray = textarray.filter(function(value){ + return value != ""; + }); + if(textarray.some((element) => element != "")){ $(".expectedqty").each(function(){ id = this.id; console.log("Analyze line "+id+" in inventory"); @@ -851,7 +854,7 @@ if ($object->id > 0) { print ''; print ''.$langs->trans("Warehouse").''; print ''.$langs->trans("Product").''; - if ($conf->productbatch->enabled) { + if (!empty($conf->productbatch->enabled)) { print ''; print $langs->trans("Batch"); print ''; @@ -881,7 +884,7 @@ if ($object->id > 0) { print ''; print $form->select_produits((GETPOSTISSET('fk_product') ? GETPOST('fk_product', 'int') : $object->fk_product), 'fk_product', '', 0, 0, -1, 2, '', 0, null, 0, '1', 0, 'maxwidth300'); print ''; - if ($conf->productbatch->enabled) { + if (!empty($conf->productbatch->enabled)) { print ''; print ''; print ''; @@ -927,6 +930,7 @@ if ($object->id > 0) { } // Load real stock we have now + $option = ''; if (isset($cacheOfProducts[$obj->fk_product])) { $product_static = $cacheOfProducts[$obj->fk_product]; } else { @@ -948,7 +952,7 @@ if ($object->id > 0) { print $product_static->getNomUrl(1).' - '.$product_static->label; print ''; - if ($conf->productbatch->enabled) { + if (!empty($conf->productbatch->enabled)) { print ''; print $obj->batch; print ''; @@ -959,7 +963,7 @@ if ($object->id > 0) { $valuetoshow = $obj->qty_stock; // For inventory not yet close, we overwrite with the real value in stock now if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) { - if ($conf->productbatch->enabled && $product_static->hasbatch()) { + if (!empty($conf->productbatch->enabled) && $product_static->hasbatch()) { $valuetoshow = $product_static->stock_warehouse[$obj->fk_warehouse]->detail_batch[$obj->batch]->qty; } else { $valuetoshow = $product_static->stock_warehouse[$obj->fk_warehouse]->real;