mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Rename variables to avoid confusion between id and scale.
This commit is contained in:
parent
9114162a42
commit
607f2708fc
|
|
@ -1472,7 +1472,7 @@ class BOM extends CommonObject
|
|||
} else {
|
||||
// Convert qty of line into hours
|
||||
$unitforline = measuringUnitString($line->fk_unit, '', '', 1);
|
||||
$qtyhourforline = convertDurationtoHour($line->qty, $unitforline);
|
||||
$qtyhourforline = convertDurationtoHour((float) $line->qty, $unitforline);
|
||||
|
||||
if (isModEnabled('workstation') && !empty($line->fk_default_workstation)) {
|
||||
$workstation = new Workstation($this->db);
|
||||
|
|
|
|||
|
|
@ -858,31 +858,31 @@ function show_stats_for_batch($batch, $socid)
|
|||
* Return translation label of a unit key.
|
||||
* Function kept for backward compatibility.
|
||||
*
|
||||
* @param string $scale Scale of unit: '0', '-3', '6', ...
|
||||
* @param string $unitscale Scale of unit: '0', '-3', '6', ...
|
||||
* @param string $measuring_style Style of unit: weight, volume,...
|
||||
* @param int $unit ID of unit (rowid in llx_c_units table)
|
||||
* @param int $unitid ID of unit (rowid in llx_c_units table)
|
||||
* @param int $use_short_label 1=Use short label ('g' instead of 'gram'). Short labels are not translated.
|
||||
* @param Translate $outputlangs Language object
|
||||
* @return string Unit string
|
||||
* @see measuringUnitString() formproduct->selectMeasuringUnits()
|
||||
*/
|
||||
function measuring_units_string($scale = '', $measuring_style = '', $unit = 0, $use_short_label = 0, $outputlangs = null)
|
||||
function measuring_units_string($unitscale = '', $measuring_style = '', $unitid = 0, $use_short_label = 0, $outputlangs = null)
|
||||
{
|
||||
return measuringUnitString($unit, $measuring_style, $scale, $use_short_label, $outputlangs);
|
||||
return measuringUnitString($unitid, $measuring_style, $unitscale, $use_short_label, $outputlangs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return translation label of a unit key
|
||||
*
|
||||
* @param int $unit ID of unit (rowid in llx_c_units table)
|
||||
* @param int $unitid ID of unit (rowid in llx_c_units table)
|
||||
* @param string $measuring_style Style of unit: 'weight', 'volume', ..., '' = 'net_measure' for option PRODUCT_ADD_NET_MEASURE
|
||||
* @param string $scale Scale of unit: '0', '-3', '6', ...
|
||||
* @param string $unitscale Scale of unit: '0', '-3', '6', ...
|
||||
* @param int $use_short_label 1=Use very short label ('g' instead of 'gram'), not translated. 2=Use translated short label.
|
||||
* @param Translate $outputlangs Language object
|
||||
* @return string|-1 Unit string if OK, -1 if KO
|
||||
* @see formproduct->selectMeasuringUnits()
|
||||
*/
|
||||
function measuringUnitString($unit, $measuring_style = '', $scale = '', $use_short_label = 0, $outputlangs = null)
|
||||
function measuringUnitString($unitid, $measuring_style = '', $unitscale = '', $use_short_label = 0, $outputlangs = null)
|
||||
{
|
||||
global $langs, $db;
|
||||
global $measuring_unit_cache;
|
||||
|
|
@ -891,24 +891,24 @@ function measuringUnitString($unit, $measuring_style = '', $scale = '', $use_sho
|
|||
$outputlangs = $langs;
|
||||
}
|
||||
|
||||
if (empty($measuring_unit_cache[$unit.'_'.$measuring_style.'_'.$scale.'_'.$use_short_label])) {
|
||||
if (empty($measuring_unit_cache[$unitid.'_'.$measuring_style.'_'.$unitscale.'_'.$use_short_label])) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php';
|
||||
$measuringUnits = new CUnits($db);
|
||||
|
||||
if ($measuring_style == '' && $scale == '') {
|
||||
if ($measuring_style == '' && $unitscale == '') {
|
||||
$arrayforfilter = array(
|
||||
't.rowid' => $unit,
|
||||
't.rowid' => $unitid,
|
||||
't.active' => 1
|
||||
);
|
||||
} elseif ($scale !== '') {
|
||||
} elseif ($unitscale !== '') {
|
||||
$arrayforfilter = array(
|
||||
't.scale' => $scale,
|
||||
't.scale' => $unitscale,
|
||||
't.unit_type' => $measuring_style,
|
||||
't.active' => 1
|
||||
);
|
||||
} else {
|
||||
$arrayforfilter = array(
|
||||
't.rowid' => $unit,
|
||||
't.rowid' => $unitid,
|
||||
't.unit_type' => $measuring_style,
|
||||
't.active' => 1
|
||||
);
|
||||
|
|
@ -929,22 +929,22 @@ function measuringUnitString($unit, $measuring_style = '', $scale = '', $use_sho
|
|||
} else {
|
||||
$labeltoreturn = '';
|
||||
}
|
||||
$measuring_unit_cache[$unit.'_'.$measuring_style.'_'.$scale.'_'.$use_short_label] = $labeltoreturn;
|
||||
$measuring_unit_cache[$unitid.'_'.$measuring_style.'_'.$unitscale.'_'.$use_short_label] = $labeltoreturn;
|
||||
return $labeltoreturn;
|
||||
}
|
||||
} else {
|
||||
return $measuring_unit_cache[$unit.'_'.$measuring_style.'_'.$scale.'_'.$use_short_label];
|
||||
return $measuring_unit_cache[$unitid.'_'.$measuring_style.'_'.$unitscale.'_'.$use_short_label];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform a given unit scale into the square of that unit, if known.
|
||||
*
|
||||
* @param int $unit Unit scale key (-3,-2,-1,0,98,99...)
|
||||
* @param int $unitscale Unit scale key (-3,-2,-1,0,98,99...)
|
||||
* @return int Squared unit key (-6,-4,-2,0,98,99...)
|
||||
* @see formproduct->selectMeasuringUnits
|
||||
*/
|
||||
function measuring_units_squared($unit)
|
||||
function measuring_units_squared($unitscale)
|
||||
{
|
||||
$measuring_units = array();
|
||||
$measuring_units[0] = 0; // m -> m3
|
||||
|
|
@ -953,7 +953,7 @@ function measuring_units_squared($unit)
|
|||
$measuring_units[-3] = -6; // mm -> mm2
|
||||
$measuring_units[98] = 98; // foot -> foot2
|
||||
$measuring_units[99] = 99; // inch -> inch2
|
||||
return $measuring_units[$unit];
|
||||
return $measuring_units[$unitscale];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user