Source for file common.php
Documentation is available at common.php
* @package linea21.modules
* @author linea21 <info@linea21.com>
* @license http://opensource.org/licenses/gpl-3.0.html
if ($indicator['sdii_max_value']== 0) {
$max_value= $indicator['sdii_max_value'];
if ($indicator['sdii_min_value']== 0) {
$min_value= $indicator['sdii_min_value'];
if ($indicator['sdii_threshold_relative']== 'Y') {
$unitup = 50 / ($max_value - $threshold_value);
$unitdown = 50 / ( $threshold_value - $min_value);
if ($value > $threshold_value) $result = 50 + (($value - $threshold_value) * $unitup);
else $result = 50 - ( ($threshold_value - $value ) * $unitdown );
if(($max_value - $threshold_value) <> 0) $unitdown = 50 / ($max_value - $threshold_value);
if(($threshold_value - $min_value) <> 0) $unitup = 50 / ($threshold_value - $min_value);
if ($value > $threshold_value) $result= 50 - ( ($value - $threshold_value) * $unitdown);
else $result = 50 + (( $threshold_value - $value ) * $unitup);
$content = "<div class=\"indicator-info ". $class. "\"><p>". ucfirst(_t('dashboard','value')). " : <strong>". $current_value. " (". formatText($indicator['sdii_unit']). ")</strong></p>".
"<p>". ucfirst(_t('sdi','min_value')). " : <strong>". empty_nc($indicator['sdii_min_value']). "</strong></p>".
"<p>". ucfirst(_t('sdi','max_value')). " : <strong>". empty_nc($indicator['sdii_max_value']). "</strong></p>".
"<p>". ucfirst(_t('sdi','threshold_value')). " : <strong>". empty_nc($threshold_value). "</strong></p>".
function getGaugeViz($sql_object, $scale_id, $indicator, $threshold_value, $cursorcssposition) {
//$cursorcssposition is used to adjust cursor position depending on the container/context
$result_value = $sql_object -> DBSelect($req_sdiav);
if ($result_value<> false){
$value_cursor1 = getPositionfromValue ($result_value[0]['sdiv_value'], $indicator, $threshold_value);
$value_cursor = 111 - $value_cursor1 + $cursorcssposition;
if ($result_value== false) {
$gauge= 'gauge_grey.gif';
$current_value = _t('dashboard','novalue');
$cursor_visibility = 'hidden';
$class= "indicator-no-data";
// min, max and threshold are not set together. No display allowed
elseif(is_null($indicator['sdii_max_value']) || is_null($indicator['sdii_min_value']) || is_null($threshold_value)) {
$current_value = $result_value[0]['sdiv_value'];
$cursor_visibility = 'hidden';
$class= "indicator-no-cursor";
// there is at leat one value and min, max and threshold are set together
$current_value = $result_value[0]['sdiv_value'];
$cursor_visibility = 'visible';
$link = "index.php?rub=dashboard&todo=det&id=". $indicator['sdii_id']. "&scale_id=". $scale_id;
$link = HrefMaker(array('rub'=> $GLOBALS['links'][U_L]['dashboard']['linkvalue'],'id'=> $indicator['sdii_id'], 'parentid'=> $scale_id));
$listing = "<div class=\"dashboard-indicator-gauge indicator-info-container\">
<a href=\"". $link. "\" class=\"infobox\">
"\n ". ucfirst(_t('sdi','threshold_value')). " : ". empty_nc($threshold_value). "\" /></a>";
$listing .= "<img src=\"" . THEME_ADMIN_PATH. "images/cursor.gif\" title=\"". _t('dashboard','value'). " : ". $current_value . " ". formatText($indicator['sdii_unit']) . " - ". _t('dashboard','barre'). "\" class=\"cursor\" style=\"visibility:". $cursor_visibility. ";left:-". $value_cursor. "px;\"/>";
$listing .= "\t<span class=\"value\"> (". strtolower($current_value). ")</span>\n";
$listing .= "\t</div>\n";
function getRawViz($sql_object, $scale_id, $indicator, $threshold_value) {
$result_value = $sql_object -> DBSelect($req_sdiav);
$str = '<div class="dashboard-indicator-raw">';
if ($result_value== false) {
$str .= '<span class="infobox no-value">-</span>';
$current_value = _t('dashboard','novalue');
$class= "indicator-no-data";
$str .= '<span class="infobox value">'. $result_value[0]['sdiv_value']. '</span>';
$current_value = $result_value[0]['sdiv_value'];
$str .= '<span class="unit">'. formatText($indicator['sdii_unit']). '</span>';
function getSparklineViz($sql_object, $scale_id, $indicator, $threshold_value) {
$result_value = $sql_object -> DBSelect($req_sdiav);
$str = '<div class="dashboard-indicator-sparkline">';
if ($result_value== false) {
$str .= '<span class="infobox no-value">-</span>';
// we reverse the array to display eldest first
foreach($values as $value) {
$str .= '<p><span class="inlinebar">'. join(',',$data). '</span></p>';
function getViz($sql_object, $scale_id, $indicator, $threshold_value, $overwrite = null, $cursorcssposition = 0) {
$vizualisation_type = $overwrite;
$vizualisation_type = $indicator['sdii_dashboard_viz'];
if($vizualisation_type == 'raw') {
$viz = getRawViz($sql_object, $scale_id, $indicator, $threshold_value);
if($vizualisation_type == 'gauge') {
$viz = getGaugeViz($sql_object, $scale_id, $indicator, $threshold_value, $cursorcssposition);
if($vizualisation_type == 'sparkline') {
$viz = getSparklineViz($sql_object, $scale_id, $indicator, $threshold_value, $cursorcssposition);
* Return indicator tendency based on value
* (not based on performance)
$tendency = '<div class="dashboard-indicator-tendency">';
// if there is a previous value
if (isset ($values[1]['sdiv_value'])) {
$percentage = ($values[0]['sdiv_value'] - $values[1]['sdiv_value']) / $values[1]['sdiv_value'] * 100;
$evolution = ' ('. round($percentage, 0). '%)';
if ($values[0]['sdiv_value'] >= $values[1]['sdiv_value']) {
$tendency.= "<img src=\"" . THEME_ADMIN_PATH. "images/ico_asc.gif\" alt=\"". _t('dashboard','value_tendance'). "\" title=\"". sprintf(_t('dashboard','previous_value'), $values[1]['sdiv_value']). $evolution. "\" />";
$tendency.= "<img src=\"" . THEME_ADMIN_PATH. "images/ico_desc.gif\" alt=\"". _t('dashboard','value_tendance'). "\" title=\"". sprintf(_t('dashboard','previous_value'), $values[1]['sdiv_value']). $evolution. "\" />";
|