Add std deviation in custom report

This commit is contained in:
Laurent Destailleur 2024-11-11 21:51:51 +01:00
parent 982c356493
commit 40aca2803f
2 changed files with 17 additions and 18 deletions

View File

@ -788,6 +788,9 @@ if (!empty($search_measures) && !empty($search_xaxis)) {
} elseif (preg_match('/\-max$/', $val)) {
$tmpval = preg_replace('/\-max$/', '', $val);
$sql .= "MAX(".$db->ifsql($tmpval.' IS NULL', '0', $tmpval).") as y_".$key.", ";
} elseif (preg_match('/\-stddevpop$/', $val)) {
$tmpval = preg_replace('/\-stddevpop$/', '', $val);
$sql .= "STDDEV_POP(".$db->ifsql($tmpval.' IS NULL', '0', $tmpval).") as y_".$key.", ";
}
}
$sql = preg_replace('/,\s*$/', '', $sql);

View File

@ -97,15 +97,13 @@ function fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesu
'table' => $object->table_element,
'tablefromt' => $tablepath
);
if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
$arrayofmesures[$tablealias.'.'.$key.'-stddevpop'] = array(
'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("StandardDeviationPop").')</span>',
'labelnohtml' => $labelofobject.': '.$langs->trans($val['label']),
'position' => ($position + ($count * 100000)).'.5',
'table' => $object->table_element,
'tablefromt' => $tablepath
);
}
$arrayofmesures[$tablealias.'.'.$key.'-stddevpop'] = array(
'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("StandardDeviationPop").')</span>',
'labelnohtml' => $labelofobject.': '.$langs->trans($val['label']),
'position' => ($position + ($count * 100000)).'.5',
'table' => $object->table_element,
'tablefromt' => $tablepath
);
}
}
// Add extrafields to Measures
@ -142,15 +140,13 @@ function fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesu
'table' => $object->table_element,
'tablefromt' => $tablepath
);
if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
$arrayofmesures[preg_replace('/^t/', 'te', $tablealias).'.'.$key.'-stddevpop'] = array(
'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("StandardDeviationPop").')</span>',
'labelnohtml' => $labelofobject.': '.$langs->trans($val),
'position' => ($position + ($count * 100000)).'.5',
'table' => $object->table_element,
'tablefromt' => $tablepath
);
}
$arrayofmesures[preg_replace('/^t/', 'te', $tablealias).'.'.$key.'-stddevpop'] = array(
'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("StandardDeviationPop").')</span>',
'labelnohtml' => $labelofobject.': '.$langs->trans($val),
'position' => ($position + ($count * 100000)).'.5',
'table' => $object->table_element,
'tablefromt' => $tablepath
);
}
}
}