mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-05 17:18:13 +01:00
Fix migration for compatibility
This commit is contained in:
@@ -467,7 +467,7 @@ function show_stats_for_company($product, $socid)
|
||||
* @param int $unit Unit key (-3,0,3,98,99...)
|
||||
* @param string $measuring_style Style of unit: weight, volume,...
|
||||
* @return string Unit string
|
||||
* @see formproduct->load_measuring_units
|
||||
* @see formproduct->selectMeasuringUnits
|
||||
*/
|
||||
function measuring_units_string($unit, $measuring_style = '')
|
||||
{
|
||||
@@ -496,7 +496,7 @@ function measuring_units_string($unit, $measuring_style = '')
|
||||
*
|
||||
* @param int $unit Unit key (-3,-2,-1,0,98,99...)
|
||||
* @return int Squared unit key (-6,-4,-2,0,98,99...)
|
||||
* @see formproduct->load_measuring_units
|
||||
* @see formproduct->selectMeasuringUnits
|
||||
*/
|
||||
function measuring_units_squared($unit)
|
||||
{
|
||||
@@ -516,7 +516,7 @@ function measuring_units_squared($unit)
|
||||
*
|
||||
* @param int $unit Unit key (-3,-2,-1,0,98,99...)
|
||||
* @return int Cubed unit key (-9,-6,-3,0,88,89...)
|
||||
* @see formproduct->load_measuring_units
|
||||
* @see formproduct->selectMeasuringUnits
|
||||
*/
|
||||
function measuring_units_cubed($unit)
|
||||
{
|
||||
|
||||
@@ -996,7 +996,7 @@ if ($action == 'create')
|
||||
print '<tr><td>';
|
||||
print $langs->trans("Weight");
|
||||
print '</td><td colspan="3"><input name="weight" size="4" value="'.GETPOST('weight', 'int').'"> ';
|
||||
$text=$formproduct->select_measuring_units("weight_units", "weight", GETPOST('weight_units', 'int'));
|
||||
$text=$formproduct->selectMeasuringUnits("weight_units", "weight", GETPOST('weight_units', 'int'));
|
||||
$htmltext=$langs->trans("KeepEmptyForAutoCalculation");
|
||||
print $form->textwithpicto($text, $htmltext);
|
||||
print '</td></tr>';
|
||||
@@ -1007,7 +1007,7 @@ if ($action == 'create')
|
||||
print ' x <input name="sizeH" size="4" value="'.GETPOST('sizeH', 'int').'">';
|
||||
print ' x <input name="sizeS" size="4" value="'.GETPOST('sizeS', 'int').'">';
|
||||
print ' ';
|
||||
$text=$formproduct->select_measuring_units("size_units", "size");
|
||||
$text=$formproduct->selectMeasuringUnits("size_units", "size");
|
||||
$htmltext=$langs->trans("KeepEmptyForAutoCalculation");
|
||||
print $form->textwithpicto($text, $htmltext);
|
||||
print '</td></tr>';
|
||||
@@ -1820,7 +1820,7 @@ elseif ($id || $ref)
|
||||
print '<input name="id" value="'.$object->id.'" type="hidden">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input id="trueWeight" name="trueWeight" value="'.$object->trueWeight.'" type="text">';
|
||||
print $formproduct->select_measuring_units("weight_units", "weight", $object->weight_units);
|
||||
print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units);
|
||||
print ' <input class="button" name="modify" value="'.$langs->trans("Modify").'" type="submit">';
|
||||
print ' <input class="button" name="cancel" value="'.$langs->trans("Cancel").'" type="submit">';
|
||||
print '</form>';
|
||||
@@ -1857,7 +1857,7 @@ elseif ($id || $ref)
|
||||
print '<input name="id" value="'.$object->id.'" type="hidden">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input id="trueHeight" name="trueHeight" value="'.$object->trueHeight.'" type="text">';
|
||||
print $formproduct->select_measuring_units("size_units", "size", $object->size_units);
|
||||
print $formproduct->selectMeasuringUnits("size_units", "size", $object->size_units);
|
||||
print ' <input class="button" name="modify" value="'.$langs->trans("Modify").'" type="submit">';
|
||||
print ' <input class="button" name="cancel" value="'.$langs->trans("Cancel").'" type="submit">';
|
||||
print '</form>';
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
-- ========================================================================
|
||||
|
||||
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('T', '3','WeightUnitton','T', 'weight', 1);
|
||||
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('KG', '0','WeightUnitkg','Kg', 'weight', 1);
|
||||
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('KG', '0','WeightUnitkg','kg', 'weight', 1);
|
||||
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('G', '-3','WeightUnitg','g', 'weight', 1);
|
||||
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('MG','-6','WeightUnitmg','mg', 'weight', 1);
|
||||
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('OZ','98','WeightUnitounce','Oz', 'weight', 1);
|
||||
|
||||
@@ -120,7 +120,7 @@ CREATE TABLE llx_c_units(
|
||||
ALTER TABLE llx_c_units ADD UNIQUE uk_c_units_code(code);
|
||||
|
||||
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('T','3','WeightUnitton','T', 'weight', 1);
|
||||
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('KG','0','WeightUnitkg','Kg', 'weight', 1);
|
||||
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('KG','0','WeightUnitkg','kg', 'weight', 1);
|
||||
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('G','-3','WeightUnitg','g', 'weight', 1);
|
||||
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('MG','-6','WeightUnitmg','mg', 'weight', 1);
|
||||
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('OZ','98','WeightUnitounce','Oz', 'weight', 1);
|
||||
@@ -163,6 +163,17 @@ INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VAL
|
||||
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('Y','31557600','year','y', 'time', 1);
|
||||
|
||||
UPDATE llx_c_units SET short_label = 'i' WHERE code = 'MI';
|
||||
UPDATE llx_c_units SET unit_type = 'weight', short_label = 'kg' WHERE code = 'KG';
|
||||
UPDATE llx_c_units SET unit_type = 'weight', short_label = 'g' WHERE code = 'G';
|
||||
UPDATE llx_c_units SET unit_type = 'time' WHERE code IN ('S','H','D');
|
||||
UPDATE llx_c_units SET unit_type = 'size' WHERE code IN ('M','LM');
|
||||
UPDATE llx_c_units SET label = 'SizeUnitm' WHERE code IN ('M');
|
||||
UPDATE llx_c_units SET active = 0 WHERE code IN ('LM');
|
||||
UPDATE llx_c_units SET unit_type = 'surface' WHERE code IN ('M2');
|
||||
UPDATE llx_c_units SET unit_type = 'volume' WHERE code IN ('M3','L');
|
||||
UPDATE llx_c_units SET scale = -3, active = 0 WHERE code IN ('L');
|
||||
UPDATE llx_c_units SET label = 'VolumeUnitm3' WHERE code IN ('M3');
|
||||
UPDATE llx_c_units SET label = 'SurfaceUnitm2' WHERE code IN ('M2');
|
||||
|
||||
|
||||
-- Default Warehouse id for a user
|
||||
|
||||
@@ -181,19 +181,19 @@ class ActionsCardProduct
|
||||
|
||||
// Weight
|
||||
$this->tpl['weight'] = $this->object->weight;
|
||||
$this->tpl['weight_units'] = $formproduct->load_measuring_units("weight_units", "weight", $this->object->weight_units);
|
||||
$this->tpl['weight_units'] = $formproduct->selectMeasuringUnits("weight_units", "weight", $this->object->weight_units);
|
||||
|
||||
// Length
|
||||
$this->tpl['length'] = $this->object->length;
|
||||
$this->tpl['length_units'] = $formproduct->load_measuring_units("length_units", "size", $this->object->length_units);
|
||||
$this->tpl['length_units'] = $formproduct->selectMeasuringUnits("length_units", "size", $this->object->length_units);
|
||||
|
||||
// Surface
|
||||
$this->tpl['surface'] = $this->object->surface;
|
||||
$this->tpl['surface_units'] = $formproduct->load_measuring_units("surface_units", "surface", $this->object->surface_units);
|
||||
$this->tpl['surface_units'] = $formproduct->selectMeasuringUnits("surface_units", "surface", $this->object->surface_units);
|
||||
|
||||
// Volume
|
||||
$this->tpl['volume'] = $this->object->volume;
|
||||
$this->tpl['volume_units'] = $formproduct->load_measuring_units("volume_units", "volume", $this->object->volume_units);
|
||||
$this->tpl['volume_units'] = $formproduct->selectMeasuringUnits("volume_units", "volume", $this->object->volume_units);
|
||||
}
|
||||
|
||||
if ($action == 'view')
|
||||
|
||||
@@ -1026,7 +1026,7 @@ else
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="3">';
|
||||
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 $formproduct->selectMeasuringUnits("duration_unit", "time", GETPOST('duration_value', 'alpha'), 0, 1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
@@ -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->load_measuring_units("weight_units", "weight", (empty($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?0:$conf->global->MAIN_WEIGHT_DEFAULT_UNIT));
|
||||
print $formproduct->selectMeasuringUnits("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))
|
||||
@@ -1050,7 +1050,7 @@ else
|
||||
print '<input name="size" size="4" value="'.GETPOST('size').'"> x ';
|
||||
print '<input name="sizewidth" size="4" value="'.GETPOST('sizewidth').'"> x ';
|
||||
print '<input name="sizeheight" size="4" value="'.GETPOST('sizeheight').'">';
|
||||
print $formproduct->select_measuring_units("size_units", "size");
|
||||
print $formproduct->selectMeasuringUnits("size_units", "size");
|
||||
print '</td></tr>';
|
||||
}
|
||||
if (empty($conf->global->PRODUCT_DISABLE_SURFACE))
|
||||
@@ -1058,7 +1058,7 @@ else
|
||||
// Surface
|
||||
print '<tr><td>'.$langs->trans("Surface").'</td><td colspan="3">';
|
||||
print '<input name="surface" size="4" value="'.GETPOST('surface').'">';
|
||||
print $formproduct->select_measuring_units("surface_units", "surface");
|
||||
print $formproduct->selectMeasuringUnits("surface_units", "surface");
|
||||
print '</td></tr>';
|
||||
}
|
||||
if (empty($conf->global->PRODUCT_DISABLE_VOLUME))
|
||||
@@ -1066,7 +1066,7 @@ else
|
||||
// Volume
|
||||
print '<tr><td>'.$langs->trans("Volume").'</td><td colspan="3">';
|
||||
print '<input name="volume" size="4" value="'.GETPOST('volume').'">';
|
||||
print $formproduct->select_measuring_units("volume_units", "volume");
|
||||
print $formproduct->selectMeasuringUnits("volume_units", "volume");
|
||||
print '</td></tr>';
|
||||
}
|
||||
}
|
||||
@@ -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->load_measuring_units("duration_unit", "time", $object->duration_unit, 0, 1);
|
||||
print $formproduct->selectMeasuringUnits("duration_unit", "time", $object->duration_unit, 0, 1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
else
|
||||
@@ -1416,7 +1416,7 @@ else
|
||||
// Weight
|
||||
print '<tr><td>'.$langs->trans("Weight").'</td><td colspan="3">';
|
||||
print '<input name="weight" size="5" value="'.$object->weight.'"> ';
|
||||
print $formproduct->select_measuring_units("weight_units", "weight", $object->weight_units);
|
||||
print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units);
|
||||
print '</td></tr>';
|
||||
if (empty($conf->global->PRODUCT_DISABLE_SIZE))
|
||||
{
|
||||
@@ -1425,7 +1425,7 @@ else
|
||||
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->select_measuring_units("size_units", "size", $object->length_units);
|
||||
print $formproduct->selectMeasuringUnits("size_units", "size", $object->length_units);
|
||||
print '</td></tr>';
|
||||
}
|
||||
if (empty($conf->global->PRODUCT_DISABLE_SURFACE))
|
||||
@@ -1433,7 +1433,7 @@ else
|
||||
// Surface
|
||||
print '<tr><td>'.$langs->trans("Surface").'</td><td colspan="3">';
|
||||
print '<input name="surface" size="5" value="'.$object->surface.'"> ';
|
||||
print $formproduct->select_measuring_units("surface_units", "surface", $object->surface_units);
|
||||
print $formproduct->selectMeasuringUnits("surface_units", "surface", $object->surface_units);
|
||||
print '</td></tr>';
|
||||
}
|
||||
if (empty($conf->global->PRODUCT_DISABLE_VOLUME))
|
||||
@@ -1441,7 +1441,7 @@ else
|
||||
// Volume
|
||||
print '<tr><td>'.$langs->trans("Volume").'</td><td colspan="3">';
|
||||
print '<input name="volume" size="5" value="'.$object->volume.'"> ';
|
||||
print $formproduct->select_measuring_units("volume_units", "volume", $object->volume_units);
|
||||
print $formproduct->selectMeasuringUnits("volume_units", "volume", $object->volume_units);
|
||||
print '</td></tr>';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,14 +291,14 @@ class FormProduct
|
||||
* @param int $adddefault Add empty unit called "Default"
|
||||
* @param int $mode 1=Use short label as value, 0=Use rowid
|
||||
* @return void
|
||||
* @deprecated
|
||||
*/
|
||||
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, $mode);
|
||||
print $this->selectMeasuringUnits($name, $measuring_style, $default, $adddefault, $mode);
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Return a combo box with list of units
|
||||
* For the moment, units labels are defined in measuring_units_string
|
||||
@@ -310,14 +310,14 @@ class FormProduct
|
||||
* @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, $mode = 0)
|
||||
public function selectMeasuringUnits($name = 'measuring_units', $measuring_style = '', $default = '0', $adddefault = 0, $mode = 0)
|
||||
{
|
||||
//phpcs:enable
|
||||
global $langs, $conf, $mysoc, $db;
|
||||
$langs->load("other");
|
||||
|
||||
$return = '';
|
||||
|
||||
// TODO Use a cache
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/cunits.class.php';
|
||||
$measuringUnits = new CUnits($db);
|
||||
$result = $measuringUnits->fetchAll(
|
||||
@@ -332,13 +332,16 @@ class FormProduct
|
||||
);
|
||||
if ($result < 0) {
|
||||
dol_print_error($db);
|
||||
return - 1;
|
||||
return -1;
|
||||
} else {
|
||||
$return .= '<select class="flat" name="' . $name . '">';
|
||||
if ($adddefault)
|
||||
{
|
||||
$return .= '<option value="0">' . $langs->trans("Default") . '</option>';
|
||||
}
|
||||
|
||||
foreach ($measuringUnits->records as $lines) {
|
||||
foreach ($measuringUnits->records as $lines)
|
||||
{
|
||||
$return .= '<option value="';
|
||||
if ($mode == 1) $return .= $lines->short_label;
|
||||
else $return .= $lines->id;
|
||||
|
||||
@@ -840,7 +840,7 @@ if ($action == 'create')
|
||||
print '<tr><td>';
|
||||
print $langs->trans("Weight");
|
||||
print '</td><td colspan="3"><input name="weight" size="4" value="'.GETPOST('weight', 'int').'"> ';
|
||||
$text=$formproduct->select_measuring_units("weight_units", "weight", GETPOST('weight_units', 'int'));
|
||||
$text=$formproduct->selectMeasuringUnits("weight_units", "weight", GETPOST('weight_units', 'int'));
|
||||
$htmltext=$langs->trans("KeepEmptyForAutoCalculation");
|
||||
print $form->textwithpicto($text, $htmltext);
|
||||
print '</td></tr>';
|
||||
@@ -851,7 +851,7 @@ if ($action == 'create')
|
||||
print ' x <input name="sizeH" size="4" value="'.GETPOST('sizeH', 'int').'">';
|
||||
print ' x <input name="sizeS" size="4" value="'.GETPOST('sizeS', 'int').'">';
|
||||
print ' ';
|
||||
$text=$formproduct->select_measuring_units("size_units", "size");
|
||||
$text=$formproduct->selectMeasuringUnits("size_units", "size");
|
||||
$htmltext=$langs->trans("KeepEmptyForAutoCalculation");
|
||||
print $form->textwithpicto($text, $htmltext);
|
||||
print '</td></tr>';
|
||||
@@ -1447,7 +1447,7 @@ elseif ($id || $ref)
|
||||
print '<input name="id" value="'.$object->id.'" type="hidden">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input id="trueWeight" name="trueWeight" value="'.$object->trueWeight.'" type="text">';
|
||||
print $formproduct->select_measuring_units("weight_units", "weight", $object->weight_units);
|
||||
print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units);
|
||||
print ' <input class="button" name="modify" value="'.$langs->trans("Modify").'" type="submit">';
|
||||
print ' <input class="button" name="cancel" value="'.$langs->trans("Cancel").'" type="submit">';
|
||||
print '</form>';
|
||||
@@ -1484,7 +1484,7 @@ elseif ($id || $ref)
|
||||
print '<input name="id" value="'.$object->id.'" type="hidden">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input id="trueHeight" name="trueHeight" value="'.$object->trueHeight.'" type="text">';
|
||||
print $formproduct->select_measuring_units("size_units", "size", $object->size_units);
|
||||
print $formproduct->selectMeasuringUnits("size_units", "size", $object->size_units);
|
||||
print ' <input class="button" name="modify" value="'.$langs->trans("Modify").'" type="submit">';
|
||||
print ' <input class="button" name="cancel" value="'.$langs->trans("Cancel").'" type="submit">';
|
||||
print '</form>';
|
||||
|
||||
Reference in New Issue
Block a user