Skip to content

Commit

Permalink
Fix #huntr76f3b405-9f5d-44b1-8434-b52b56ee395f
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jan 29, 2022
1 parent 26700f8 commit 37fb02e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
24 changes: 12 additions & 12 deletions htdocs/product/card.php
Expand Up @@ -1870,40 +1870,40 @@
if (empty($conf->global->PRODUCT_DISABLE_WEIGHT)) {
// Brut Weight
print '<tr><td>'.$langs->trans("Weight").'</td><td>';
print '<input name="weight" size="5" value="'.$object->weight.'"> ';
print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units, 0, 2);
print '<input name="weight" size="5" value="'.(GETPOSTISSET('weight') ? GETPOST('weight') : $object->weight).'"> ';
print $formproduct->selectMeasuringUnits("weight_units", "weight", GETPOSTISSET('weight_units') ? GETPOST('weight_units') : $object->weight_units, 0, 2);
print '</td></tr>';
}

if (empty($conf->global->PRODUCT_DISABLE_SIZE)) {
// Brut Length
print '<tr><td>'.$langs->trans("Length").' x '.$langs->trans("Width").' x '.$langs->trans("Height").'</td><td>';
print '<input name="size" size="5" value="'.$object->length.'">x';
print '<input name="sizewidth" size="5" value="'.$object->width.'">x';
print '<input name="sizeheight" size="5" value="'.$object->height.'"> ';
print $formproduct->selectMeasuringUnits("size_units", "size", $object->length_units, 0, 2);
print '<input name="size" size="5" value="'.(GETPOSTISSET('size') ? GETPOST('size') : $object->length).'">x';
print '<input name="sizewidth" size="5" value="'.(GETPOSTISSET('sizewidth') ? GETPOST('sizewidth') : $object->width).'">x';
print '<input name="sizeheight" size="5" value="'.(GETPOSTISSET('sizeheight') ? GETPOST('sizeheight') : $object->height).'"> ';
print $formproduct->selectMeasuringUnits("size_units", "size", GETPOSTISSET('size_units') ? GETPOST('size_units') : $object->length_units, 0, 2);
print '</td></tr>';
}
if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) {
// Brut Surface
print '<tr><td>'.$langs->trans("Surface").'</td><td>';
print '<input name="surface" size="5" value="'.$object->surface.'"> ';
print $formproduct->selectMeasuringUnits("surface_units", "surface", $object->surface_units, 0, 2);
print '<input name="surface" size="5" value="'.(GETPOSTISSET('surface') ? GETPOST('surface') : $object->surface).'"> ';
print $formproduct->selectMeasuringUnits("surface_units", "surface", GETPOSTISSET('surface_units') ? GETPOST('surface_units') : $object->surface_units, 0, 2);
print '</td></tr>';
}
if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) {
// Brut Volume
print '<tr><td>'.$langs->trans("Volume").'</td><td>';
print '<input name="volume" size="5" value="'.$object->volume.'"> ';
print $formproduct->selectMeasuringUnits("volume_units", "volume", $object->volume_units, 0, 2);
print '<input name="volume" size="5" value="'.(GETPOSTISSET('volume') ? GETPOST('volume') : $object->volume).'"> ';
print $formproduct->selectMeasuringUnits("volume_units", "volume", GETPOSTISSET('volume_units') ? GETPOST('volume_units') : $object->volume_units, 0, 2);
print '</td></tr>';
}

if (!empty($conf->global->PRODUCT_ADD_NET_MEASURE)) {
// Net Measure
print '<tr><td>'.$langs->trans("NetMeasure").'</td><td>';
print '<input name="net_measure" size="5" value="'.$object->net_measure.'"> ';
print $formproduct->selectMeasuringUnits("net_measure_units", "", $object->net_measure_units, 0, 0);
print '<input name="net_measure" size="5" value="'.(GETPOSTISSET('net_measure') ? GETPOST('net_measure') : $object->net_measure).'"> ';
print $formproduct->selectMeasuringUnits("net_measure_units", "", GETPOSTISSET('net_measure_units') ? GETPOST('net_measure_units') : $object->net_measure_units, 0, 0);
print '</td></tr>';
}
}
Expand Down
11 changes: 11 additions & 0 deletions htdocs/product/class/product.class.php
Expand Up @@ -860,6 +860,8 @@ public function create($user, $notrigger = 0)
*/
public function verify()
{
global $langs;

$this->errors = array();

$result = 0;
Expand All @@ -870,6 +872,15 @@ public function verify()
$result = -2;
}

$arrayofnonnegativevalue = array('weight'=>'Weight', 'width'=>'Width', 'height'=>'Height', 'length'=>'Length', 'surface'=>'Surface', 'volume'=>'Volume');
foreach ($arrayofnonnegativevalue as $key => $value) {
if (property_exists($this, $key) && $this->$key < 0) {
$langs->load("other");
$this->errors[] = $langs->trans("FieldCannotBeNegative", $langs->transnoentitiesnoconv($value));
$result = -4;
}
}

$rescode = $this->check_barcode($this->barcode, $this->barcode_type_code);
if ($rescode) {
if ($rescode == -1) {
Expand Down

0 comments on commit 37fb02e

Please sign in to comment.