Fix inventory/inventory.php

This commit is contained in:
lmarcouiller 2021-05-28 09:57:21 +02:00
parent 819e6e1122
commit e87d175041
2 changed files with 10 additions and 3 deletions

View File

@ -255,3 +255,4 @@ MakeMovementsAndClose=Generate movements and close
AutofillWithExpected=Fill real quantity with expected quantity
ShowAllBatchByDefault=By default, show batch details on product "stock" tab
CollapseBatchDetailHelp=You can set batch detail default display in stocks module configuration
FieldCannotBeNegative=Field "%s" cannot be negative

View File

@ -185,8 +185,11 @@ if ($action =='updateinventorylines' && $permissiontoadd) {
if (GETPOST("id_".$lineid, 'alpha') != '') { // If a value was set ('0' or something else)
$qtytoupdate = price2num(GETPOST("id_".$lineid, 'alpha'), 'MS');
$result = $inventoryline->fetch($lineid);
if ($qtytoupdate < 0) {
$result = -1;
setEventMessages($langs->trans("FieldCannotBeNegative", $langs->transnoentitiesnoconv("RealQty")), null, 'errors');
}
if ($result > 0) {
$inventoryline->qty_view = $qtytoupdate;
$resultupdate = $inventoryline->update($user);
@ -251,7 +254,10 @@ if (empty($reshook)) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors');
}
if (GETPOST('qtytoadd') < 0) {
$error++;
setEventMessages($langs->trans("FieldCannotBeNegative", $langs->transnoentitiesnoconv("RealQty")), null, 'errors');
}
if (!$error && !empty($conf->productbatch->enabled)) {
$tmpproduct = new Product($db);
$result = $tmpproduct->fetch($fk_product);
@ -654,7 +660,7 @@ if ($object->id > 0) {
// Real quantity
print '<td class="center">';
if ($object->status == $object::STATUS_VALIDATED) {
$qty_view = GETPOST("id_".$obj->rowid) ? GETPOST("id_".$obj->rowid) : $obj->qty_view;
$qty_view = GETPOST("id_".$obj->rowid) && GETPOST("id_".$obj->rowid) >= 0 ? GETPOST("id_".$obj->rowid) : $obj->qty_view;
$totalfound += price2num($qty_view, 'MS');
print '<input type="text" class="maxwidth75 right realqty" name="id_'.$obj->rowid.'" id="id_'.$obj->rowid.'_input" value="'.$qty_view.'">';
print '</td>';