From 1a05cdfaa1811980455007284a29d83fc15aa1c7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Mar 2019 11:42:50 +0100 Subject: [PATCH] Fix regressions in selecting duration of service --- htdocs/product/card.php | 12 +++---- .../product/class/html.formproduct.class.php | 34 +++++++++++-------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 15835361191..8ebf9268398 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1025,9 +1025,9 @@ else if ($type == 1) { print ''.$langs->trans("Duration").''; - print ''; - print $formproduct->select_measuring_units("duration_unit", "time"); - print ''; + print ''; + print $formproduct->load_measuring_units("duration_unit", "time", GETPOST('duration_value', 'alpha'), 0, 1); + print ''; } if ($type != 1) // Nature, Weight and volume only applies to products and not to services @@ -1041,7 +1041,7 @@ else // Weight print ''.$langs->trans("Weight").''; print ''; - print $formproduct->select_measuring_units("weight_units", "weight", (empty($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?0:$conf->global->MAIN_WEIGHT_DEFAULT_UNIT)); + print $formproduct->load_measuring_units("weight_units", "weight", (empty($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?0:$conf->global->MAIN_WEIGHT_DEFAULT_UNIT)); print ''; // Length if (empty($conf->global->PRODUCT_DISABLE_SIZE)) @@ -1402,7 +1402,7 @@ else // Duration print ''.$langs->trans("Duration").''; print ' '; - print $formproduct->select_measuring_units("duration_unit", "time", $object->duration_unit); + print $formproduct->load_measuring_units("duration_unit", "time", $object->duration_unit, 0, 1); print ''; } else @@ -1412,7 +1412,7 @@ else $statutarray=array('-1'=>' ', '1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); print $form->selectarray('finished', $statutarray, $object->finished); print ''; - + // Weight print ''.$langs->trans("Weight").''; print ' '; diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index efe6b261e83..5663e8c5987 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -286,15 +286,16 @@ class FormProduct * pour l'instant on ne definit pas les unites dans la base * * @param string $name Name of HTML field - * @param string $measuring_style Unit to show: weight, size, surface, volume - * @param string $default Force unit + * @param string $measuring_style Unit to show: weight, size, surface, volume, time + * @param string $default Preselected value * @param int $adddefault Add empty unit called "Default" + * @param int $mode 1=Use short label as value, 0=Use rowid * @return void */ - public function select_measuring_units($name = 'measuring_units', $measuring_style = '', $default = '0', $adddefault = 0) + public function select_measuring_units($name = 'measuring_units', $measuring_style = '', $default = '0', $adddefault = 0, $mode = 0) { //phpcs:enable - print $this->load_measuring_units($name, $measuring_style, $default, $adddefault); + print $this->load_measuring_units($name, $measuring_style, $default, $adddefault, $mode); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -303,12 +304,13 @@ class FormProduct * For the moment, units labels are defined in measuring_units_string * * @param string $name Name of HTML field - * @param string $measuring_style Unit to show: weight, size, surface, volume - * @param string $default Force unit - * @param int $adddefault Add empty unit called "Default" + * @param string $measuring_style Unit to show: weight, size, surface, volume, time + * @param string $default Preselected value + * @param int $adddefault Add empty unit called "Default" + * @param int $mode 1=Use short label as value, 0=Use rowid * @return string */ - public function load_measuring_units($name = 'measuring_units', $measuring_style = '', $default = '0', $adddefault = 0) + public function load_measuring_units($name = 'measuring_units', $measuring_style = '', $default = '0', $adddefault = 0, $mode = 0) { //phpcs:enable global $langs, $conf, $mysoc, $db; @@ -337,12 +339,16 @@ class FormProduct $return .= ''; foreach ($measuringUnits->records as $lines) { - $return .= ''; - $return .= '>' . $langs->transnoentitiesnoconv($lines->label) . ''; + $return .= ''; } $return .= ''; }