This commit is contained in:
Laurent Destailleur 2019-09-27 20:02:33 +02:00
parent 981c5c877a
commit fd37a81e19

View File

@ -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;