Fix regressions in selecting duration of service
This commit is contained in:
parent
6970d066f8
commit
1a05cdfaa1
@ -1025,9 +1025,9 @@ else
|
||||
if ($type == 1)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="3">';
|
||||
print '<input name="surface" size="4" value="'.GETPOST('duration_value').'">';
|
||||
print $formproduct->select_measuring_units("duration_unit", "time");
|
||||
print '</td></tr>';
|
||||
print '<input name="surface" size="4" value="'.GETPOST('duration_value', 'alpha').'">';
|
||||
print $formproduct->load_measuring_units("duration_unit", "time", GETPOST('duration_value', 'alpha'), 0, 1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
if ($type != 1) // Nature, Weight and volume only applies to products and not to services
|
||||
@ -1041,7 +1041,7 @@ else
|
||||
// Weight
|
||||
print '<tr><td>'.$langs->trans("Weight").'</td><td colspan="3">';
|
||||
print '<input name="weight" size="4" value="'.GETPOST('weight').'">';
|
||||
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 '</td></tr>';
|
||||
// Length
|
||||
if (empty($conf->global->PRODUCT_DISABLE_SIZE))
|
||||
@ -1402,7 +1402,7 @@ else
|
||||
// Duration
|
||||
print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="3">';
|
||||
print '<input name="surface" size="5" value="'.$object->duration_value.'"> ';
|
||||
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 '</td></tr>';
|
||||
}
|
||||
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 '</td></tr>';
|
||||
|
||||
|
||||
// Weight
|
||||
print '<tr><td>'.$langs->trans("Weight").'</td><td colspan="3">';
|
||||
print '<input name="weight" size="5" value="'.$object->weight.'"> ';
|
||||
|
||||
@ -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 .= '<option value="0">' . $langs->trans("Default") . '</option>';
|
||||
|
||||
foreach ($measuringUnits->records as $lines) {
|
||||
$return .= '<option value="' . $lines->id . '"';
|
||||
if ($lines->id == $default) {
|
||||
$return .= ' selected';
|
||||
}
|
||||
// $return.= '>'.$value.'</option>';
|
||||
$return .= '>' . $langs->transnoentitiesnoconv($lines->label) . '</option>';
|
||||
$return .= '<option value="';
|
||||
if ($mode == 1) $return .= $lines->short_label;
|
||||
else $return .= $lines->id;
|
||||
$return .= '"';
|
||||
if ($mode == 1 && $lines->short_label == $default) $return .= ' selected';
|
||||
if ($mode == 0 && $lines->id == $default) $return .= ' selected';
|
||||
$return .= '>';
|
||||
if ($measuring_style == 'time') $return.= $langs->trans(ucfirst($lines->label));
|
||||
else $return .= $langs->trans($lines->label);
|
||||
$return .= '</option>';
|
||||
}
|
||||
$return .= '</select>';
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user