From 2e573fd7947c0d99950bb0e5e0f393bf234808d0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 23 Oct 2019 02:58:39 +0200 Subject: [PATCH] Fix save of units Conflicts: htdocs/expedition/card.php htdocs/product/card.php htdocs/product/class/product.class.php --- htdocs/expedition/card.php | 7 ++++--- htdocs/expedition/class/expedition.class.php | 4 ++-- .../canvas/product/actions_card_product.class.php | 8 ++++---- htdocs/product/class/product.class.php | 6 +++++- htdocs/reception/card.php | 12 +++++------- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 946e58587e9..65bb621836c 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -383,7 +383,7 @@ if (empty($reshook)) if (! $error) { - $ret=$object->create($user); // This create shipment (like Odoo picking) and line of shipments. Stock movement will when validating shipment. + $ret=$object->create($user); // This create shipment (like Odoo picking) and lines of shipments. Stock movement will be done when validating shipment. if ($ret <= 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -998,7 +998,7 @@ if ($action == 'create') print ''; print $langs->trans("Weight"); print ' '; - $text=$formproduct->selectMeasuringUnits("weight_units", "weight", GETPOST('weight_units', 'int')); + $text=$formproduct->selectMeasuringUnits("weight_units", "weight", GETPOST('weight_units', 'int'), 0, 2); $htmltext=$langs->trans("KeepEmptyForAutoCalculation"); print $form->textwithpicto($text, $htmltext); print ''; @@ -1009,7 +1009,7 @@ if ($action == 'create') print ' x '; print ' x '; print ' '; - $text=$formproduct->selectMeasuringUnits("size_units", "size"); + $text=$formproduct->selectMeasuringUnits("size_units", "size", GETPOST('size_units', 'int'), 0, 2); $htmltext=$langs->trans("KeepEmptyForAutoCalculation"); print $form->textwithpicto($text, $htmltext); print ''; @@ -2190,6 +2190,7 @@ elseif ($id || $ref) $product_static->id=$lines[$i]->fk_product; $product_static->ref=$lines[$i]->ref; $product_static->status_batch=$lines[$i]->product_tobatch; + $text=$product_static->getNomUrl(1); $text.= ' - '.$label; $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($lines[$i]->description)); diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 1a9a249effc..318e00c15ed 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -325,8 +325,8 @@ class Expedition extends CommonObject $sql.= ", ".$this->sizeS; // TODO Should use this->trueDepth $sql.= ", ".$this->sizeW; // TODO Should use this->trueWidth $sql.= ", ".$this->sizeH; // TODO Should use this->trueHeight - $sql.= ", ".($this->weight_units>0?$this->weight_units:'NULL'); - $sql.= ", ".($this->size_units>0?$this->size_units:'NULL'); + $sql.= ", ".($this->weight_units != '' ? (int) $this->weight_units : 'NULL'); + $sql.= ", ".($this->size_units != '' ? (int) $this->size_units : 'NULL'); $sql.= ", ".(!empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null"); $sql.= ", ".(!empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null"); $sql.= ", ".(!empty($this->model_pdf)?"'".$this->db->escape($this->model_pdf)."'":"null"); diff --git a/htdocs/product/canvas/product/actions_card_product.class.php b/htdocs/product/canvas/product/actions_card_product.class.php index a457b1b99f8..20b3773874b 100644 --- a/htdocs/product/canvas/product/actions_card_product.class.php +++ b/htdocs/product/canvas/product/actions_card_product.class.php @@ -181,19 +181,19 @@ class ActionsCardProduct // Weight $this->tpl['weight'] = $this->object->weight; - $this->tpl['weight_units'] = $formproduct->selectMeasuringUnits("weight_units", "weight", $this->object->weight_units); + $this->tpl['weight_units'] = $formproduct->selectMeasuringUnits("weight_units", "weight", $this->object->weight_units, 0, 2); // Length $this->tpl['length'] = $this->object->length; - $this->tpl['length_units'] = $formproduct->selectMeasuringUnits("length_units", "size", $this->object->length_units); + $this->tpl['length_units'] = $formproduct->selectMeasuringUnits("length_units", "size", $this->object->length_units, 0, 2); // Surface $this->tpl['surface'] = $this->object->surface; - $this->tpl['surface_units'] = $formproduct->selectMeasuringUnits("surface_units", "surface", $this->object->surface_units); + $this->tpl['surface_units'] = $formproduct->selectMeasuringUnits("surface_units", "surface", $this->object->surface_units, 0, 2); // Volume $this->tpl['volume'] = $this->object->volume; - $this->tpl['volume_units'] = $formproduct->selectMeasuringUnits("volume_units", "volume", $this->object->volume_units); + $this->tpl['volume_units'] = $formproduct->selectMeasuringUnits("volume_units", "volume", $this->object->volume_units, 0, 2); } if ($action == 'view') diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 274ba0391ed..ac987d49845 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -256,11 +256,15 @@ class Product extends CommonObject */ public $url; - //! Unites de mesure + //! Metric of products public $weight; public $weight_units; public $length; public $length_units; + public $width; + public $width_units; + public $height; + public $height_units; public $surface; public $surface_units; public $volume; diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 5ce7fbadd57..d606496a843 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -840,7 +840,7 @@ if ($action == 'create') print ''; print $langs->trans("Weight"); print ' '; - $text=$formproduct->selectMeasuringUnits("weight_units", "weight", GETPOST('weight_units', 'int')); + $text=$formproduct->selectMeasuringUnits("weight_units", "weight", GETPOST('weight_units', 'int'), 0, 2); $htmltext=$langs->trans("KeepEmptyForAutoCalculation"); print $form->textwithpicto($text, $htmltext); print ''; @@ -851,7 +851,7 @@ if ($action == 'create') print ' x '; print ' x '; print ' '; - $text=$formproduct->selectMeasuringUnits("size_units", "size"); + $text=$formproduct->selectMeasuringUnits("size_units", "size", GETPOST('size_units', 'int'), 0, 2); $htmltext=$langs->trans("KeepEmptyForAutoCalculation"); print $form->textwithpicto($text, $htmltext); print ''; @@ -1447,7 +1447,7 @@ elseif ($id || $ref) print ''; print ''; print ''; - print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units); + print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units, 0, 2); print ' '; print ' '; print ''; @@ -1475,14 +1475,14 @@ elseif ($id || $ref) // Height print ''.$form->editfieldkey("Height", 'trueHeight', $object->trueHeight, $object, $user->rights->reception->creer).''; - if($action=='edittrueHeight') + if ($action=='edittrueHeight') { print '
'; print ''; print ''; print ''; print ''; - print $formproduct->selectMeasuringUnits("size_units", "size", $object->size_units); + print $formproduct->selectMeasuringUnits("size_units", "size", $object->size_units, 0, 2); print ' '; print ' '; print '
'; @@ -1789,8 +1789,6 @@ elseif ($id || $ref) print ''; - - $text=$lines[$i]->product->getNomUrl(1); $text.= ' - '.$label; $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($lines[$i]->product->description));