diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 68a6d9082f2..e966cec8b28 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -485,19 +485,33 @@ function show_stats_for_company($product, $socid) * * @param int $unit ID of unit (rowid in llx_c_units table) * @param string $measuring_style Style of unit: weight, volume,... + * @param string $scale Scale of unit: '0', '-3', '6', ... * @return string Unit string * @see formproduct->selectMeasuringUnits */ -function measuring_units_string($unit, $measuring_style = '') +function measuring_units_string($unit, $measuring_style = '', $scale = '') { global $langs, $db; require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php'; $measuringUnits= new CUnits($db); - $result = $measuringUnits->fetchAll('', '', 0, 0, array( + + if ($scale !== '') + { + $arrayforfilter = array( + 't.scale' => $scale, + 't.unit_type' => $measuring_style, + 't.active' => 1 + ); + } + else + { + $arrayforfilter = array( 't.rowid' => $unit, 't.unit_type' => $measuring_style, 't.active' => 1 - )); + ); + } + $result = $measuringUnits->fetchAll('', '', 0, 0, $arrayforfilter); if ($result<0) { return -1;