Пример #1
0
    protected function RenderChart($oPage, $sId, $aValues, $sDrillDown = '', $aRows = array())
    {
        // 1- Compute Open Flash Chart data
        //
        $aValueKeys = array();
        $index = 0;
        if (count($aValues) > 0 && $sDrillDown != '') {
            $oFilter = DBObjectSearch::FromOQL($sDrillDown);
            $sClass = $oFilter->GetClass();
            $sOQLClause = str_replace('SELECT ' . $sClass, '', $sDrillDown);
            $aSQLColNames = array_keys(current($aRows));
            // Read the list of columns from the current (i.e. first) element of the array
            $oAppContext = new ApplicationContext();
            $sURL = utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php?operation=search_oql&search_form=0&oql_class=' . $sClass . '&format=html&' . $oAppContext->GetForLink() . '&oql_clause=';
        }
        $aURLs = array();
        foreach ($aValues as $key => $value) {
            // Make sure that values are integers (so that max() will work....)
            // and build an array of STRING with the keys (numeric keys are transformed into string by PHP :-(
            $aValues[$key] = (int) $value;
            $aValueKeys[] = (string) $key;
            // Build the custom query for the 'drill down' on each element
            if ($sDrillDown != '') {
                $sFilter = $sOQLClause;
                foreach ($aSQLColNames as $sColName) {
                    $sFilter = str_replace(':' . $sColName, "'" . addslashes($aRows[$key][$sColName]) . "'", $sFilter);
                    $aURLs[$index] = $sURL . urlencode($sFilter);
                }
            }
            $index++;
        }
        $oChart = new open_flash_chart();
        if ($this->m_sType == 'bars') {
            $oChartElement = new bar_glass();
            if (count($aValues) > 0) {
                $maxValue = max($aValues);
            } else {
                $maxValue = 1;
            }
            $oYAxis = new y_axis();
            $aMagicValues = array(1, 2, 5, 10);
            $iMultiplier = 1;
            $index = 0;
            $iTop = $aMagicValues[$index % count($aMagicValues)] * $iMultiplier;
            while ($maxValue > $iTop) {
                $index++;
                $iTop = $aMagicValues[$index % count($aMagicValues)] * $iMultiplier;
                if ($index % count($aMagicValues) == 0) {
                    $iMultiplier = $iMultiplier * 10;
                }
            }
            //echo "oYAxis->set_range(0, $iTop, $iMultiplier);\n";
            $oYAxis->set_range(0, $iTop, $iMultiplier);
            $oChart->set_y_axis($oYAxis);
            $aBarValues = array();
            foreach ($aValues as $iValue) {
                $oBarValue = new bar_value($iValue);
                $oBarValue->on_click("ofc_drilldown_{$sId}");
                $aBarValues[] = $oBarValue;
            }
            $oChartElement->set_values($aBarValues);
            //$oChartElement->set_values(array_values($aValues));
            $oXAxis = new x_axis();
            $oXLabels = new x_axis_labels();
            // set them vertical
            $oXLabels->set_vertical();
            // set the label text
            $oXLabels->set_labels($aValueKeys);
            // Add the X Axis Labels to the X Axis
            $oXAxis->set_labels($oXLabels);
            $oChart->set_x_axis($oXAxis);
        } else {
            $oChartElement = new pie();
            $oChartElement->set_start_angle(35);
            $oChartElement->set_animate(true);
            $oChartElement->set_tooltip('#label# - #val# (#percent#)');
            $oChartElement->set_colours(array('#FF8A00', '#909980', '#2C2B33', '#CCC08D', '#596664'));
            $aData = array();
            foreach ($aValues as $sValue => $iValue) {
                $oPieValue = new pie_value($iValue, $sValue);
                //@@ BUG: not passed via ajax !!!
                $oPieValue->on_click("ofc_drilldown_{$sId}");
                $aData[] = $oPieValue;
            }
            $oChartElement->set_values($aData);
            $oChart->x_axis = null;
        }
        // Title given in HTML
        //$oTitle = new title($this->m_sTitle);
        //$oChart->set_title($oTitle);
        $oChart->set_bg_colour('#FFFFFF');
        $oChart->add_element($oChartElement);
        $sData = $oChart->toPrettyString();
        $sData = json_encode($sData);
        // 2- Declare the Javascript function that will render the chart data\
        //
        $oPage->add_script(<<<EOF
function ofc_get_data_{$sId}()
{
\treturn {$sData};
}
EOF
);
        if (count($aURLs) > 0) {
            $sURLList = '';
            foreach ($aURLs as $index => $sURL) {
                $sURLList .= "\taURLs[{$index}] = '" . addslashes($sURL) . "';\n";
            }
            $oPage->add_script(<<<EOF
function ofc_drilldown_{$sId}(index)
{
\tvar aURLs = new Array();
{$sURLList}
\tvar sURL = aURLs[index];
\t
\twindow.location.href = sURL; // Navigate ! 
}
EOF
);
        }
        // 3- Insert the Open Flash chart
        //
        $oPage->add("<div id=\"{$sId}\"><div>\n");
        $oPage->add_ready_script(<<<EOF
swfobject.embedSWF(\t"../images/open-flash-chart.swf", 
\t"{$sId}", 
\t"100%", "300","9.0.0",
\t"expressInstall.swf",
\t{"get-data":"ofc_get_data_{$sId}", "id":"{$sId}"}, 
\t{'wmode': 'transparent'}
);
EOF
);
    }
Пример #2
0
/** flowview_viewchart()
 *
 *  This function is taken from Slowlog.  Given
 *  a title, chart type and chart data, it will
 *  echo the required syntax for the Callback
 *  from the chart page to operate corectly.
 */
function flowview_viewchart()
{
    global $colors, $config;
    include $config['base_path'] . "/plugins/flowview/lib/open-flash-chart-object.php";
    include $config['base_path'] . "/plugins/flowview/lib/open-flash-chart.php";
    $title = $_REQUEST["title"];
    $chart_type = "bar";
    $column = $_REQUEST["type"];
    $sessionid = $_REQUEST["session"];
    /* get the chart data from the session */
    if (isset($_SESSION['flowview_flows'][$sessionid]['data'])) {
        $data = $_SESSION['flowview_flows'][$sessionid]['data'];
    } else {
        $filter = createfilter($sessionid);
        $data = $_SESSION['flowview_flows'][$sessionid]['data'];
    }
    switch ($column) {
        case 'flows':
            $unit = ucfirst($column);
            $suffix = "Total Flows";
            $_SESSION['sess_flows_flows'] = 'on';
            break;
        case 'bytes':
            $unit = ucfirst($column);
            $suffix = "Bytes Exchanged";
            $_SESSION['sess_flows_bytes'] = 'on';
            break;
        case 'packets':
            $unit = ucfirst($column);
            $suffix = "Packets Examined";
            $_SESSION['sess_flows_packets'] = 'on';
            break;
    }
    $columns = $_SESSION['flowview_flows'][$sessionid]['columns'];
    foreach ($columns as $key => $cdata) {
        if (strtolower($cdata) == $column) {
            $column = $key;
        }
    }
    if (sizeof($data)) {
        $elements = array();
        $legend = array();
        $maxvalue = 0;
        if (isset($_REQUEST['exclude']) && $_REQUEST['exclude'] > 0) {
            for ($i = 0; $i < $_REQUEST['exclude']; $i++) {
                array_shift($data);
            }
        }
        foreach ($data as $row) {
            if ($maxvalue < $row[$column]) {
                $maxvalue = $row[$column];
                $scaling = flowview_autoscale($row[$column]);
            }
        }
        $maxvalue = flowview_getmax($maxvalue);
        $autorange = flowview_autoscale($maxvalue);
        $maxvalue = $maxvalue / $autorange[0];
        $i = 0;
        foreach ($data as $row) {
            $elements[$i] = new bar_value(round($row[$column] / $autorange[0], 3));
            $elements[$i]->set_colour(flowview_get_color());
            $elements[$i]->set_tooltip($unit . ": #val# " . $autorange[1]);
            if (sizeof($row) == 4) {
                $legend[] = $row[0];
            } else {
                $legend[] = $row[0] . " -\n" . $row[1];
            }
            $i++;
        }
        $bar = new bar_glass();
        $bar->set_values($elements);
        $title = new title($title . " (" . $suffix . ")");
        $title->set_style("{font-size: 18px; color: #444444; text-align: center;}");
        $x_axis_labels = new x_axis_labels();
        $x_axis_labels->set_size(10);
        $x_axis_labels->rotate(45);
        $x_axis_labels->set_labels($legend);
        $x_axis = new x_axis();
        //$x_axis->set_3d( 3 );
        $x_axis->set_colours('#909090', '#909090');
        $x_axis->set_labels($x_axis_labels);
        $y_axis = new y_axis();
        $y_axis->set_offset(true);
        $y_axis->set_colours('#909090', '#909090');
        $y_axis->set_range(0, $maxvalue, $maxvalue / 10);
        $y_axis->set_label_text("#val# " . $autorange[1]);
        $chart = new open_flash_chart();
        $chart->set_title($title);
        $chart->add_element($bar);
        $chart->set_x_axis($x_axis);
        $chart->add_y_axis($y_axis);
        $chart->set_bg_colour('#FEFEFE');
        echo $chart->toString();
    }
}
Пример #3
0
$chart->x_axis = null;

echo $chart->toPrettyString();
*/
$title = new title("ESTADISTICAS CONTROL DE LEGALIDAD");
$data = array($_SESSION['total1']);
$bar = new bar_glass();
$bar->colour('#0404B4');
$bar->key('SOLICITUDES', 12);
$bar->set_values($data);
$data2 = array($_SESSION['total2']);
$bar2 = new bar_glass();
$bar2->colour('#5FB404');
$bar2->key('RESPUESTAS', 12);
$bar2->set_values($data2);
$data3 = array($_SESSION['total3']);
$bar3 = new bar_glass();
$bar3->colour('#BF3B69');
$bar3->key('EN TRAMITE', 12);
$bar3->set_values($data3);
$y = new y_axis();
$y->set_range(0, $_SESSION['total1'], 25);
$chart = new open_flash_chart();
$chart->set_title($title);
$chart->set_bg_colour('#FFFFFF');
$chart->add_element($bar);
$chart->add_element($bar2);
$chart->add_element($bar3);
$chart->add_y_axis($y);
echo $chart->toString();
 public function get_jx_json_bar($info, $type = '')
 {
     $year = array_keys($info);
     $price = array_values($info);
     $chart = new open_flash_chart();
     $chart->set_bg_colour('#FFFFFF');
     //flash背景颜色
     $x_labels = new x_axis_labels();
     $x_labels->set_steps(1);
     $x_labels->set_size(12);
     $x_labels->set_colour('#000000');
     if (count($year) > 0) {
         $x_labels->set_vertical();
     }
     $x_labels->set_labels($year);
     //		// 插入数据
     $x = new x_axis();
     $x->set_colour('#000000');
     $x->set_grid_colour('#dadada');
     $x->set_offset(true);
     $x->set_steps(1);
     // Add the X Axis Labels to the X Axis
     $x->set_labels($x_labels);
     $x->set_offset(true);
     $chart->set_x_axis($x);
     //		$bar = new bar_filled( '#74b1e0', '#9dc7e8' );
     //		$bar->set_values( $price );
     $price_array = array();
     foreach ($price as $k => $v) {
         $price_array[$k] = new bar_value($v);
         $price_array[$k]->set_colour('#74b1e0');
         if ($type == 'percent') {
             //$y->set_label_text("#val#%");
             $price_array[$k]->set_tooltip($year[$k] . '<br>' . '' . number_format($v) . '%');
         } else {
             $price_array[$k]->set_tooltip($year[$k] . '<br>' . '' . number_format($v));
         }
     }
     $bar = new bar_glass();
     $bar->set_values($price_array);
     $chart->add_element($bar);
     //
     // LOOK:
     //
     //$x_legend = new x_legend( '1983 to 2008' );
     //$x_legend->set_style( '{font-size: 20px; color: #778877}' );
     //$chart->set_x_legend( $x_legend );
     //
     // remove this when the Y Axis is smarter
     //
     $y = new y_axis();
     $max = $this->get_the_right_y(max($price));
     $max = $max > 0 ? $max : 1;
     $y->set_range(0, ($max / 5 + 1) * 5, $max / 5 + 1);
     //		if ($max > 20 && $max <= 100) {
     //
     //			$y->set_range(0, $max, 10);
     //		}elseif($max >= 10&&$max<=20){
     //			$y->set_range(0, $max, 5);
     //		}
     //		else {
     //			$y->set_range(0, $max);
     //		}
     $y->set_colour('#000000');
     $y->set_grid_colour('#dadada');
     if ($type == 'percent') {
         $y->set_label_text("       #val#%");
     } else {
         $y->set_label_text("       #val#");
     }
     $chart->add_y_axis($y);
     $info = $chart->toPrettyString();
     return $info;
 }
Пример #5
0
 $title = new title("\n" . date('l dS F Y', $time) . " (" . round(max($data_tot) - min($data_tot), 2) . " kWh)");
 $title->set_style('{font-size: 20px; color: #778877;}');
 $tooltip = new tooltip();
 $tooltip->set_hover();
 $sline = new scatter_line('#3D3D3D', 3);
 $def = new hollow_dot();
 $def->size(0)->halo_size(0);
 $sline->set_default_dot_style($def);
 $sline->set_key('Leistung (W)', 11);
 $v = array();
 foreach ($data_watt as $key => $val) {
     $v[] = new scatter_value($key, $val);
     $v[] = new scatter_value($key + 1, $val);
 }
 $sline->set_values($v);
 $bars_curr = new bar_glass();
 $bars_curr->set_key('Leistung (W)', 10);
 $bars_curr->set_colour('#EFC01D');
 $bars_curr->set_alpha(0.8);
 $bars_curr->set_tooltip('#val# W');
 for ($i = 0; $i < count($data_watt); $i++) {
     $bval = new bar_value($data_watt[$i]);
     if ($data_watt[$i] == max($data_watt)) {
         $bval->set_tooltip("Tages-Spitzenwert:<br>#val# W um {$time_axis[$i]} Uhr");
         $bval->set_colour('#ef4747');
     }
     $bars_curr->append_value($bval);
 }
 // PEAK
 $max_val = max($data_watt);
 $i = array_search($max_val, $data_watt);
Пример #6
0
$menorvalor = 0;

for($i = 0; $i < $total; $i ++) {
	$resultado = resultadorelatorio_fornecedor ( $idfornecedor [$i], $param );
	$bar->data [] = $resultado;
	if ($resultado > $maiorvalor) {
		$maiorvalor = $resultado;
	}
	if ($resultado < $menorvalor) {
		$menorvalor = $resultado;
	}
}

srand ( ( double ) microtime () * 1000000 );

$bar_1 = new bar_glass ( 55, '#5E83BF', '#424581' );
$bar_1->key ( titulo_selecionado_fornecedor ( $param ), 10 );

for($i = 0; $i < $total; $i ++)
	$bar_1->data [] = ( double ) resultadorelatorio_fornecedor ( $vetor_url [$i], $param );

$g = new graph ( );

//$g->data_sets[] = $bar;
$g->data_sets [] = $bar_1;

$g->set_x_labels ( $nome_fornecedor );

$g->x_axis_colour ( '#FFFFFF', '#D2D2FB' );
$g->y_axis_colour ( '#FFFFFF', '#D2D2FB' );
Пример #7
0
 function loadaverage()
 {
     sleep(1);
     $uptime = trim(shell_exec("cat /proc/uptime  |awk '{print \$1}' |cut -d '.' -f 1"));
     $load_average_1min = trim(shell_exec("cat /proc/loadavg |awk '{print \$1}'"));
     $load_average_5min = trim(shell_exec("cat /proc/loadavg |awk '{print \$2}'"));
     $load_average_15min = trim(shell_exec("cat /proc/loadavg |awk '{print \$3}'"));
     if ($load_average_1min <= 1) {
         $stats = '当前系统空闲';
     } elseif ($load_average_1min <= 4) {
         $stats = '当前系统正常';
     } else {
         $stats = '当前系统繁忙';
     }
     $days = floor($uptime / 86400);
     $hours = floor($uptime % 86400 / 3600);
     $minutes = floor($uptime % 3600 / 60);
     $title = new title("系统平均负载\n{$stats}");
     $title->set_style("{font-size: 12px; font-family: Times New Roman; font-weight: bold; color: #A2ACBA; text-align: center;}");
     settype($load_average_1min, "float");
     settype($load_average_5min, "float");
     settype($load_average_15min, "float");
     $load_average = array($load_average_1min, $load_average_5min, $load_average_15min);
     function colour($value)
     {
         if ($value <= 1) {
             $colour = "#339900";
         } elseif ($value <= 4) {
             $colour = "#FFFF00";
         } else {
             $colour = "#FF0033";
         }
         return $colour;
     }
     if (max($load_average) <= 0.5) {
         $y_axis_max = 0.5;
     } elseif (max($load_average) <= 1) {
         $y_axis_max = 1;
     } elseif (max($load_average) <= 5) {
         $y_axis_max = 5;
     } elseif (max($load_average) <= 10) {
         $y_axis_max = 10;
     } elseif (max($load_average) <= 50) {
         $y_axis_max = 50;
     } else {
         $y_axis_max = 100;
     }
     $y_axis_step = $y_axis_max / 5;
     if ($load_average_1min == 0) {
         $data[0] = new bar_value($y_axis_max / 100);
         $data[0]->set_colour(colour($load_average_1min));
         $data[0]->set_tooltip(0);
     } else {
         $data[0] = new bar_value($load_average_1min);
         $data[0]->set_colour(colour($load_average_1min));
         $data[0]->set_tooltip('#val#');
     }
     if ($load_average_5min == 0) {
         $data[1] = new bar_value($y_axis_max / 100);
         $data[1]->set_colour(colour($load_average_5min));
         $data[1]->set_tooltip(0);
     } else {
         $data[1] = new bar_value($load_average_5min);
         $data[1]->set_colour(colour($load_average_5min));
         $data[1]->set_tooltip('#val#');
     }
     if ($load_average_15min == 0) {
         $data[2] = new bar_value($y_axis_max / 100);
         $data[2]->set_colour(colour($load_average_15min));
         $data[2]->set_tooltip(0);
     } else {
         $data[2] = new bar_value($load_average_15min);
         $data[2]->set_colour(colour($load_average_15min));
         $data[2]->set_tooltip('#val#');
     }
     $bar = new bar_glass();
     $bar->set_values($data);
     $x = new x_axis();
     $x->set_labels_from_array(array('1分钟', '5分钟', '15分钟'));
     $y = new y_axis();
     $y->set_range(0, $y_axis_max, $y_axis_step);
     $chart = new open_flash_chart();
     $chart->set_title($title);
     $chart->add_element($bar);
     $chart->set_bg_colour('#FFFFFF');
     $chart->set_x_axis($x);
     $chart->set_y_axis($y);
     $x_legend = new x_legend("系统当前已运行 {$days} 天 {$hours} 小时 {$minutes} 分钟");
     $x_legend->set_style('{font-size: 12px; color: #778877}');
     $chart->set_x_legend($x_legend);
     header("Cache-Control: cache, must-revalidate");
     header("Pragma: public");
     echo $chart->toString();
 }
Пример #8
0
    protected function renderHTML()
    {
        global $g_BizSystem;
        $sql = "SELECT username, cflags, methods, user_agent, contact from location order by username";
        $db = $g_BizSystem->GetDBConnection("Serdb");
        $resultSet = $db->query($sql);
        if ($resultSet === false) {
            $err = $db->ErrorMsg();
            echo $err;
            exit;
        }
        $chart_colors = array();
        $chart_colors[0] = '#FF0000';
        $chart_colors[1] = '#00FF00';
        $chart_colors[2] = '#0000FF';
        $chart_colors[3] = '#408080';
        $chart_colors[4] = '#330000';
        $chart_colors[5] = '#FDD017';
        $chart_colors[6] = '#52D017';
        $chart_colors[7] = '#6698FF';
        $chart_colors[8] = '#00FFFF';
        $chart_colors[9] = '#FF00FF';
        $chart_colors[10] = '#2554C7';
        $chart_colors[11] = '#806D7E';
        $chart_colors[12] = '#FF8040';
        $chart_colors[13] = '#C0C0C0';
        $chart_colors[14] = '#808000';
        $chart_colors[15] = '#800000';
        $chart_colors_size = 16;
        $ul_contacts = array();
        for ($i = 0; $i <= 5; $i++) {
            $ul_contacts[$i] = 0;
        }
        $prevuser = "******";
        $prevcnt = 1;
        $ul_uas = array();
        $ul_uas['asterisk'] = 0;
        $ul_uas['freeswitch'] = 0;
        $ul_uas['x-lite'] = 0;
        $ul_uas['eyebeam'] = 0;
        $ul_uas['bria'] = 0;
        $ul_uas['ekiga'] = 0;
        $ul_uas['twinkle'] = 0;
        $ul_uas['snom'] = 0;
        $ul_uas['cisco'] = 0;
        $ul_uas['linksys'] = 0;
        $ul_uas['nokia'] = 0;
        $ul_uas['grandstream'] = 0;
        $ul_uas['polycom'] = 0;
        $ul_uas['draytek'] = 0;
        $ul_uas['avm'] = 0;
        $ul_uas['sipura'] = 0;
        $ul_uas['mitel'] = 0;
        $ul_uas['others'] = 0;
        $ul_methods = array();
        $ul_methods['INVITE'] = 0;
        $ul_methods['CANCEL'] = 0;
        $ul_methods['ACK'] = 0;
        $ul_methods['BYE'] = 0;
        $ul_methods['REGISTER'] = 0;
        $ul_methods['OPTIONS'] = 0;
        $ul_methods['UPDATE'] = 0;
        $ul_methods['PRACK'] = 0;
        $ul_methods['SUBSCRIBE'] = 0;
        $ul_methods['NOTIFY'] = 0;
        $ul_methods['PUBLISH'] = 0;
        $ul_methods['MESSAGE'] = 0;
        $ul_methods['INFO'] = 0;
        $ul_methods['REFER'] = 0;
        $ul_methods['OTHERS'] = 0;
        $ul_methods['NONE'] = 0;
        $ul_nat = array();
        $ul_nat['NATTED'] = 0;
        $ul_nat['SIPPING'] = 0;
        $ul_proto = array();
        $ul_proto['UDP'] = 0;
        $ul_proto['TCP'] = 0;
        $ul_proto['TLS'] = 0;
        $ul_proto['SCTP'] = 0;
        $yidx = 0;
        $ousr = 0;
        while ($row = $resultSet->fetch()) {
            $r_username = $row[0];
            $r_cflags = $row[1];
            $r_methods = $row[2];
            $r_user_agent = $row[3];
            $r_contact = $row[4];
            /* statistics for contacts per user */
            if ($yidx == 0) {
                $prevuser = $r_username;
                $prevcnt = 1;
            } else {
                if ($r_username == $prevuser) {
                    $prevcnt = $prevcnt + 1;
                } else {
                    $ousr++;
                    if ($prevcnt < 5) {
                        $ul_contacts[$prevcnt] = $ul_contacts[$prevcnt] + 1;
                    } else {
                        $ul_contacts[5] = $ul_contacts[5] + 1;
                    }
                    $prevuser = $r_username;
                    $prevcnt = 1;
                }
            }
            /* known UA stats */
            if (isset($r_user_agent)) {
                if (preg_match('/asterisk/i', $r_user_agent)) {
                    $ul_uas['asterisk'] = $ul_uas['asterisk'] + 1;
                } else {
                    if (preg_match("/freeswitch/i", $r_user_agent)) {
                        $ul_uas['freeswitch'] = $ul_uas['freeswitch'] + 1;
                    } else {
                        if (preg_match("/x-lite/i", $r_user_agent)) {
                            $ul_uas['x-lite'] = $ul_uas['x-lite'] + 1;
                        } else {
                            if (preg_match("/bria/i", $r_user_agent)) {
                                $ul_uas['bria'] = $ul_uas['bria'] + 1;
                            } else {
                                if (preg_match("/ekiga/i", $r_user_agent)) {
                                    $ul_uas['ekiga'] = $ul_uas['ekiga'] + 1;
                                } else {
                                    if (preg_match("/twinkle/i", $r_user_agent)) {
                                        $ul_uas['twinkle'] = $ul_uas['twinkle'] + 1;
                                    } else {
                                        if (preg_match("/snom/i", $r_user_agent)) {
                                            $ul_uas['snom'] = $ul_uas['snom'] + 1;
                                        } else {
                                            if (preg_match("/cisco/i", $r_user_agent)) {
                                                $ul_uas['cisco'] = $ul_uas['cisco'] + 1;
                                            } else {
                                                if (preg_match("/linksys/i", $r_user_agent)) {
                                                    $ul_uas['linksys'] = $ul_uas['linksys'] + 1;
                                                } else {
                                                    if (preg_match("/nokia/i", $r_user_agent)) {
                                                        $ul_uas['nokia'] = $ul_uas['nokia'] + 1;
                                                    } else {
                                                        if (preg_match("/grandstream/i", $r_user_agent)) {
                                                            $ul_uas['grandstream'] = $ul_uas['grandstream'] + 1;
                                                        } else {
                                                            if (preg_match("/polycom/i", $r_user_agent)) {
                                                                $ul_uas['polycom'] = $ul_uas['polycom'] + 1;
                                                            } else {
                                                                if (preg_match("/draytek/i", $r_user_agent)) {
                                                                    $ul_uas['draytek'] = $ul_uas['draytek'] + 1;
                                                                } else {
                                                                    if (preg_match("/avm/i", $r_user_agent)) {
                                                                        $ul_uas['avm'] = $ul_uas['avm'] + 1;
                                                                    } else {
                                                                        if (preg_match("/sipura/i", $r_user_agent)) {
                                                                            $ul_uas['sipura'] = $ul_uas['sipura'] + 1;
                                                                        } else {
                                                                            if (preg_match("/mitel/i", $r_user_agent)) {
                                                                                $ul_uas['mitel'] = $ul_uas['mitel'] + 1;
                                                                            } else {
                                                                                $ul_uas['others'] = $ul_uas['others'] + 1;
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            /* transports */
            if (isset($r_contact)) {
                if (preg_match('/;transport=tcp/i', $r_contact)) {
                    $ul_proto['TCP'] = $ul_proto['TCP'] + 1;
                } else {
                    if (preg_match("/;transport=tls/i", $r_contact)) {
                        $ul_proto['TLS'] = $ul_proto['TLS'] + 1;
                    } else {
                        if (preg_match("/;transport=sctp/i", $r_contact)) {
                            $ul_proto['SCTP'] = $ul_proto['SCTP'] + 1;
                        } else {
                            $ul_proto['UDP'] = $ul_proto['UDP'] + 1;
                        }
                    }
                }
            }
            /* supported SIP methods stats */
            if (isset($r_methods) && $r_methods != 0) {
                /* 1 - 2^0 INVITE */
                if ($r_methods & 1) {
                    $ul_methods['INVITE'] = $ul_methods['INVITE'] + 1;
                }
                /* 2 - 2^1 CANCEL */
                if ($r_methods & 2) {
                    $ul_methods['CANCEL'] = $ul_methods['CANCEL'] + 1;
                }
                /* 3 - 2^2 ACK */
                if ($r_methods & 4) {
                    $ul_methods['ACK'] = $ul_methods['ACK'] + 1;
                }
                /* 4 - 2^3 BYE */
                if ($r_methods & 8) {
                    $ul_methods['BYE'] = $ul_methods['BYE'] + 1;
                }
                /* 5 - 2^4 INFO */
                if ($r_methods & 16) {
                    $ul_methods['INFO'] = $ul_methods['INFO'] + 1;
                }
                /* 6 - 2^5 REGISTER */
                if ($r_methods & 32) {
                    $ul_methods['REGISTER'] = $ul_methods['REGISTER'] + 1;
                }
                /* 7 - 2^6 SUBSCRIBE */
                if ($r_methods & 64) {
                    $ul_methods['SUBSCRIBE'] = $ul_methods['SUBSCRIBE'] + 1;
                }
                /* 8 - 2^7 NOTIFY */
                if ($r_methods & 128) {
                    $ul_methods['NOTIFY'] = $ul_methods['NOTIFY'] + 1;
                }
                /* 9 - 2^8 MESSAGE */
                if ($r_methods & 256) {
                    $ul_methods['MESSAGE'] = $ul_methods['MESSAGE'] + 1;
                }
                /* 10 - 2^9 OPTIONS */
                if ($r_methods & 512) {
                    $ul_methods['OPTIONS'] = $ul_methods['OPTIONS'] + 1;
                }
                /* 11 - 2^10 PRACK */
                if ($r_methods & 1024) {
                    $ul_methods['PRACK'] = $ul_methods['PRACK'] + 1;
                }
                /* 12 - 2^11 UPDATE */
                if ($r_methods & 2048) {
                    $ul_methods['UPDATE'] = $ul_methods['UPDATE'] + 1;
                }
                /* 13 - 2^12 REFER */
                if ($r_methods & 4096) {
                    $ul_methods['REFER'] = $ul_methods['REFER'] + 1;
                }
                /* 14 - 2^13 PUBLISH */
                if ($r_methods & 8192) {
                    $ul_methods['PUBLISH'] = $ul_methods['PUBLISH'] + 1;
                }
                /* 15 - 2^14 OTHER */
                if ($r_methods & 16384) {
                    $ul_methods['OTHERS'] = $ul_methods['OTHERS'] + 1;
                }
            } else {
                $ul_methods['NONE'] = $ul_methods['NONE'] + 1;
            }
            /* supported NAT stats */
            if (isset($r_cflags) && $r_cflags != 0) {
                if ($r_cflags & 1 << 6) {
                    $ul_nat['NATTED'] = $ul_nat['NATTED'] + 1;
                }
                if ($r_cflags & 1 << 7) {
                    $ul_nat['SIPPING'] = $ul_nat['SIPPING'] + 1;
                }
            }
            $yidx = $yidx + 1;
        }
        if ($yidx > 0) {
            $ousr++;
            if ($prevcnt < 5) {
                $ul_contacts[$prevcnt] = $ul_contacts[$prevcnt] + 1;
            } else {
                $ul_contacts[5] = $ul_contacts[5] + 1;
            }
        }
        /* user agents chart */
        $ua_title = new title('User Agents');
        $ua_x_labels = new x_axis_labels();
        $ua_x_labels->rotate(20);
        $ua_bar = new bar_glass();
        $chart_vals = array();
        $chart_lbls = array();
        $i = 0;
        $ymax = 10;
        foreach ($ul_uas as $key => $val) {
            if ($val > 0) {
                $chart_vals[$i] = new bar_value($val);
                $chart_vals[$i]->set_colour($chart_colors[$i % $chart_colors_size]);
                $chart_vals[$i]->set_tooltip($key . '<br>#val#');
                $chart_lbls[$i] = $key;
                if ($ymax < $val) {
                    $ymax = $val;
                }
                $i = $i + 1;
            }
        }
        $ua_bar->set_values($chart_vals);
        $ua_x_labels->set_labels($chart_lbls);
        $x = new x_axis();
        $x->set_labels($ua_x_labels);
        $y = new y_axis();
        $y->set_range(0, $ymax, $ymax / 10);
        $ul_uas_chart = new open_flash_chart();
        $ul_uas_chart->set_title($ua_title);
        $ul_uas_chart->add_element($ua_bar);
        $ul_uas_chart->set_x_axis($x);
        $ul_uas_chart->add_y_axis($y);
        /* supported SIP Methods chart */
        $mt_title = new title('Supported SIP Methods');
        $mt_x_labels = new x_axis_labels();
        $mt_x_labels->rotate(20);
        $mt_bar = new bar_glass();
        $chart_vals = array();
        $chart_lbls = array();
        $i = 0;
        $ymax = 10;
        foreach ($ul_methods as $key => $val) {
            if ($val > 0) {
                $chart_vals[$i] = new bar_value($val);
                $chart_vals[$i]->set_colour($chart_colors[$i % $chart_colors_size]);
                $chart_vals[$i]->set_tooltip($key . '<br>#val#');
                $chart_lbls[$i] = $key;
                if ($ymax < $val) {
                    $ymax = $val;
                }
                $i = $i + 1;
            }
        }
        $mt_bar->set_values($chart_vals);
        $mt_x_labels->set_labels($chart_lbls);
        $x = new x_axis();
        $x->set_labels($mt_x_labels);
        $y = new y_axis();
        $y->set_range(0, $ymax, $ymax / 10);
        $mt_chart = new open_flash_chart();
        $mt_chart->set_title($mt_title);
        $mt_chart->add_element($mt_bar);
        $mt_chart->set_x_axis($x);
        $mt_chart->add_y_axis($y);
        /* bar stacks - contacts/user, nat stats, ... */
        $cn_title = new title('Contacts and NAT Stats');
        $cn_x_labels = new x_axis_labels();
        $cn_x_labels->rotate(20);
        $bar_stack = new bar_stack();
        $bar_stack->set_colours($chart_colors);
        $chart_lbls = array();
        $c = 0;
        $lidx = 0;
        $chart_vals = array();
        $i = 0;
        $chart_vals[$i] = new bar_stack_value($yidx, $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('Records<br>#val#');
        $bar_stack->append_stack($chart_vals);
        $chart_lbls[$lidx++] = 'All Records';
        $chart_vals = array();
        $i = 0;
        $chart_vals[$i] = new bar_stack_value($ousr, $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('Online<br>#val#');
        $bar_stack->append_stack($chart_vals);
        $chart_lbls[$lidx++] = 'Online Users';
        $chart_vals = array();
        $i = 0;
        $chart_vals[$i] = new bar_stack_value($ul_contacts[1], $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('1 contact<br>#val#');
        $i = $i + 1;
        $chart_vals[$i] = new bar_stack_value($ul_contacts[2], $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('2 contacts<br>#val#');
        $i = $i + 1;
        $chart_vals[$i] = new bar_stack_value($ul_contacts[3], $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('3 contacts<br>#val#');
        $i = $i + 1;
        $chart_vals[$i] = new bar_stack_value($ul_contacts[4], $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('4 contacts<br>#val#');
        $i = $i + 1;
        $chart_vals[$i] = new bar_stack_value($ul_contacts[5], $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('&gt;=5 contacts <br>#val#');
        $i = $i + 1;
        $bar_stack->append_stack($chart_vals);
        $chart_lbls[$lidx++] = 'Contacts per AoR';
        $chart_vals = array();
        $i = 0;
        $chart_vals[$i] = new bar_stack_value($ul_nat['NATTED'], $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('Natted<br>#val#');
        $i = $i + 1;
        $chart_vals[$i] = new bar_stack_value($yidx - $ul_nat['NATTED'], $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('Not-Natted<br>#val#');
        $bar_stack->append_stack($chart_vals);
        $chart_lbls[$lidx++] = 'Natted';
        $chart_vals = array();
        $i = 0;
        $chart_vals[$i] = new bar_stack_value($ul_nat['SIPPING'], $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('SIP Ping<br>#val#');
        $i = $i + 1;
        $chart_vals[$i] = new bar_stack_value($yidx - $ul_nat['SIPPING'], $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('No SIP Ping<br>#val#');
        $bar_stack->append_stack($chart_vals);
        $chart_lbls[$lidx++] = 'SIP Ping';
        $chart_vals = array();
        $i = 0;
        $chart_vals[$i] = new bar_stack_value($ul_proto['UDP'], $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('UDP<br>#val#');
        $i = $i + 1;
        $chart_vals[$i] = new bar_stack_value($ul_proto['TCP'], $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('TCP<br>#val#');
        $i = $i + 1;
        $chart_vals[$i] = new bar_stack_value($ul_proto['TLS'], $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('TLS<br>#val#');
        $i = $i + 1;
        $chart_vals[$i] = new bar_stack_value($ul_proto['SCTP'], $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('SCTP<br>#val#');
        $bar_stack->append_stack($chart_vals);
        $chart_lbls[$lidx++] = 'Transports';
        $cn_x_labels->set_labels($chart_lbls);
        $x = new x_axis();
        $x->set_labels($cn_x_labels);
        $y = new y_axis();
        $y->set_range(0, $yidx, $yidx / 10);
        $cn_chart = new open_flash_chart();
        $cn_chart->set_title($cn_title);
        $cn_chart->add_element($bar_stack);
        $cn_chart->set_x_axis($x);
        $cn_chart->add_y_axis($y);
        $sHTML = '';
        $sHTML .= '
			<div align="center">
				<p><b>Processed ' . $yidx . ' records.</b></p>
			</div>
			';
        if ($yidx > 0) {
            $sHTML .= '
			<script type="text/javascript" src="' . APP_URL . '/js/swfobject.js"></script>
			<script type="text/javascript">
				swfobject.embedSWF(
					"' . APP_URL . '/modules/ser/pages/open-flash-chart.swf",
				   	"div_chart_ul_uas",
					"600", "300", "9.0.0", "expressInstall.swf",
					{"get-data":"get_data_ul_uas"} );
				swfobject.embedSWF(
					"' . APP_URL . '/modules/ser/pages/open-flash-chart.swf",
				   	"div_chart_ul_met",
					"600", "300", "9.0.0", "expressInstall.swf",
					{"get-data":"get_data_ul_met"} );
				swfobject.embedSWF(
					"' . APP_URL . '/modules/ser/pages/open-flash-chart.swf",
				   	"div_chart_ul_cns",
					"600", "300", "9.0.0", "expressInstall.swf",
				{"get-data":"get_data_ul_cns"} );
			</script> 
			';
            $sHTML .= '
			<br />
			<div align="center">
				<div id="div_chart_ul_uas">
				</div>
				<br />
				<br />
				<div id="div_chart_ul_met">
				</div>
				<br />
				<br />
				<div id="div_chart_ul_cns">
				</div>
				<br />
				<br />
			</div>
			';
            $sHTML .= '
			<script type="text/javascript">
				function get_data_ul_uas()
				{
					data = \'' . $ul_uas_chart->toString() . '\';
					return data;
				}

				function get_data_ul_met()
				{
					data = \'' . $mt_chart->toString() . '\';
					return data;
				}

				function get_data_ul_cns()
				{
					data = \'' . $cn_chart->toString() . '\';
					return data;
				}

			</script>
			';
        }
        /* if $yidx */
        return $sHTML;
    }
Пример #9
0
 private static function make_bandwidth_chart($values, $options = array())
 {
     if (!$values || !count($values)) {
         return false;
     }
     $title = !empty($options['title']) ? $options['title'] : 'Chart';
     //array_check_value($options, 'title', 'BI Chart');
     $step = !empty($options['step']) ? $options['step'] : 0.75;
     //array_check_value($options, 'step', 0.75);
     $max = !empty($options['max']) ? $options['max'] : 0;
     //array_check_value($options, 'max', 0);
     $value_mod = !empty($options['value_modifier']) ? $options['value_modifier'] : 1;
     //array_check_value($options, 'value_modifier', 1);
     $input_title = !empty($options['input_title']) ? $options['input_title'] : 'Downloads for :key: #val#';
     //array_check_value($options, 'input_title', 'Downloads for :key: #val#');
     $output_title = !empty($options['output_title']) ? $options['output_title'] : 'Uploads for :key: #val#';
     //array_check_value($options, 'output_title', 'Uploads for :key: #val#');
     $total_title = !empty($options['total_title']) ? $options['total_title'] : 'Total for :key: #val#';
     //array_check_value($options, 'total_title', 'Total for :key: #val#');
     $on_click = !empty($options['on_click']) ? $options['on_click'] : false;
     //array_check_value($options, 'on_click', false);
     $x_labels = !empty($options['x_labels']) ? $options['x_labels'] : array_keys($values);
     //array_check_value($options, 'x_labels', array_keys($values));
     include_once APP_FOLDER . '/libraries/php-ofc-library/ofc_title.php';
     include_once APP_FOLDER . '/libraries/php-ofc-library/open-flash-chart.php';
     //include(APP_FOLDER . '/libraries/php-ofc-library/ofc_bar_glass_value.php');
     include_once APP_FOLDER . '/libraries/php-ofc-library/ofc_line_dot.php';
     include_once APP_FOLDER . '/libraries/php-ofc-library/ofc_line_base.php';
     include_once APP_FOLDER . '/libraries/php-ofc-library/ofc_x_axis.php';
     $title = new title($title);
     $chart = new open_flash_chart();
     $chart->set_title($title);
     $input = array();
     $ouput = array();
     $total = array();
     $clicks = array();
     foreach ($values as $key => $value) {
         $this_value = (double) number_format($value['input'] / $value_mod, 2, '.', '');
         $tmp = new bar_glass_value($this_value);
         $tmp->set_tooltip(preg_replace('/:key/', $key, $input_title));
         $input[] = $tmp;
         $this_value = (double) number_format($value['output'] / $value_mod, 2, '.', '');
         $tmp = new bar_glass_value($this_value);
         $tmp->set_tooltip(preg_replace('/:key/', $key, $output_title));
         $output[] = $tmp;
         $this_value = (double) number_format(($value['input'] + $value['output']) / $value_mod, 2, '.', '');
         $tmp = new dot_value($this_value, '#000066');
         $tmp->set_tooltip(preg_replace('/:key/', $key, $total_title));
         $total[] = $tmp;
         if ($on_click) {
             $tmp = (double) number_format(($value['input'] + $value['output']) / $value_mod, 2, '.', '');
             $clicks[] = $tmp;
         }
         $max = ceil(max(($value['input'] + $value['output']) / $value_mod, $max));
     }
     $x_axis = new x_axis();
     $x_axis->set_labels_from_array($x_labels);
     $x_axis->set_3d(5);
     $x_axis->colour = '#909090';
     if ($max > 0) {
         //Don't know why we sometimes get a division by zero error
         @($max = $max + ($step - $max % $step));
     }
     if ($max / $step > 5) {
         $step = floor($max / 5);
     } else {
         if ($max / $step <= 1) {
             $step = floor($max / 2);
         }
     }
     $y_axis = new y_axis();
     $y_axis->set_range(0, $max, $step);
     $input_bar = new bar_glass();
     $input_bar->set_values($input);
     $input_bar->colour = '#D54C78';
     $output_bar = new bar_glass();
     $output_bar->set_values($output);
     $output_bar->colour = '#78D54C';
     $total_graph = new line_hollow();
     $total_graph->set_colour('#9999FF');
     $total_graph->set_values($total);
     if ($on_click) {
         $click_graph = new line();
         $click_graph->set_values($clicks);
         $click_graph->set_on_click($on_click);
         $chart->add_element($click_graph);
     }
     $chart->set_x_axis($x_axis);
     $chart->set_y_axis($y_axis);
     $chart->add_element($input_bar);
     $chart->add_element($output_bar);
     $chart->add_element($total_graph);
     //$decoded = json_decode($chart->toString());
     return $chart->toString();
 }
Пример #10
0
    public function RenderNoData($oPage, $bEditMode = false, $aExtraParams = array())
    {
        $sTitle = $this->aProperties['title'];
        $aDisplayValues = $this->MakeSimulatedData();
        require_once APPROOT . '/pages/php-ofc-library/open-flash-chart.php';
        $oChart = new open_flash_chart();
        $aGroupBy = array();
        $aLabels = array();
        foreach ($aDisplayValues as $iRow => $aDisplayData) {
            $aLabels[$iRow] = $aDisplayData['label'];
            $aGroupBy[$iRow] = (int) $aDisplayData['count'];
        }
        $oChartElement = new bar_glass();
        $aData = array();
        $aChartLabels = array();
        $maxValue = 0;
        foreach ($aGroupBy as $iRow => $iCount) {
            $oBarValue = new bar_value($iCount);
            $aData[] = $oBarValue;
            if ($iCount > $maxValue) {
                $maxValue = $iCount;
            }
            $aChartLabels[] = html_entity_decode($aLabels[$iRow], ENT_QUOTES, 'UTF-8');
        }
        $oYAxis = new y_axis();
        $aMagicValues = array(1, 2, 5, 10);
        $iMultiplier = 1;
        $index = 0;
        $iTop = $aMagicValues[$index % count($aMagicValues)] * $iMultiplier;
        while ($maxValue > $iTop) {
            $index++;
            $iTop = $aMagicValues[$index % count($aMagicValues)] * $iMultiplier;
            if ($index % count($aMagicValues) == 0) {
                $iMultiplier = $iMultiplier * 10;
            }
        }
        //echo "oYAxis->set_range(0, $iTop, $iMultiplier);\n";
        $oYAxis->set_range(0, $iTop, $iMultiplier);
        $oChart->set_y_axis($oYAxis);
        $oChartElement->set_values($aData);
        $oXAxis = new x_axis();
        $oXLabels = new x_axis_labels();
        // set them vertical
        $oXLabels->set_vertical();
        // set the label text
        $oXLabels->set_labels($aChartLabels);
        // Add the X Axis Labels to the X Axis
        $oXAxis->set_labels($oXLabels);
        $oChart->set_x_axis($oXAxis);
        if (!empty($sTitle)) {
            // The title has been given in an url, and urlencoded...
            // and urlencode transforms utf-8 into something similar to ISO-8859-1
            // Example: é (C3A9 becomes %E9)
            // As a consequence, json_encode (called within open-flash-chart.php)
            // was returning 'null' and the graph was not displayed at all
            // To make sure that the graph is displayed AND to get a correct title
            // (at least for european characters) let's transform back into utf-8 !
            $sTitle = iconv("ISO-8859-1", "UTF-8//IGNORE", $sTitle);
            // If the title is a dictionnary entry, fetch it
            $sTitle = $this->oModelReflection->DictString($sTitle);
            $oTitle = new title($sTitle);
            $oChart->set_title($oTitle);
            $oTitle->set_style("{font-size: 16px; font-family: Tahoma; font-weight: bold; text-align: center;}");
        }
        $oChart->set_bg_colour('#FFFFFF');
        $oChart->add_element($oChartElement);
        $sData = $oChart->toPrettyString();
        $sData = json_encode($sData);
        $oPage->add_script(<<<EOF
function ofc_get_data_dashlet_{$this->sId}()
{
\treturn {$sData};
}
EOF
);
        $oPage->add('<div class="dashlet-content">');
        $oPage->add("<div id=\"dashlet_chart_{$this->sId}\">If the chart does not display, <a href=\"http://get.adobe.com/flash/\" target=\"_blank\">install Flash</a></div>\n");
        $oPage->add('</div>');
        //		$oPage->add_script("function ofc_resize(left, width, top, height) { /* do nothing special */ }");
        $oPage->add_ready_script(<<<EOF
swfobject.embedSWF(\t"../images/open-flash-chart.swf", 
\t"dashlet_chart_{$this->sId}", 
\t"100%", "300","9.0.0",
\t"expressInstall.swf",
\t{"get-data":"ofc_get_data_dashlet_{$this->sId}", "id":"dashlet_chart_{$this->sId}"}, 
\t{'wmode': 'transparent'}
);
EOF
);
    }
 function get_graph($field, $args)
 {
     $defaults = array('ids' => false, 'colors' => array('#EF8C08', '#21759B', '#1C9E05'), 'grid_color' => '#f7e8bf', 'bg_color' => '#FFFFFF', 'odd' => false, 'truncate' => 40, 'truncate_label' => 15, 'response_count' => 10, 'user_id' => false, 'type' => 'default', 'x_axis' => false, 'data_type' => 'count', 'limit' => '', 'x_start' => '', 'x_end' => '', 'show_key' => false, 'min' => '', 'max' => '', 'include_zero' => false, 'width' => 400, 'height' => 400);
     $args = wp_parse_args($args, $defaults);
     $vals = $this->get_graph_values($field, $args);
     extract($args);
     extract($vals);
     $title = new title(preg_replace("/&#?[a-z0-9]{2,8};/i", "", FrmAppHelper::truncate($field->name, $truncate, 0)));
     $chart = new open_flash_chart();
     $chart->set_title($title);
     $bar = new bar_glass();
     $x = new x_axis();
     $y = new y_axis();
     $x_labels = new x_axis_labels();
     if (in_array($field->type, array('select', 'checkbox', 'radio', '10radio', 'scale')) and (!isset($x_inputs) or !$x_inputs)) {
         $x_labels->rotate(340);
         //$x_labels->set_colour( '#A2ACBA' );
         //$x->set_colour( '#A2ACBA' );
     } else {
         if ($field->type == 'user_id') {
             if (!$pie) {
                 $x_labels->rotate(340);
             }
         } else {
             $x_labels->rotate(340);
         }
     }
     $pie = $type == 'default' ? $pie : ($type == 'pie' ? true : false);
     if ($pie) {
         $bar = new pie();
         $bar->set_alpha(0.6);
         $bar->set_start_angle(35);
         $bar->add_animation(new pie_fade());
         $bar->set_tooltip('#val# (#percent#)');
         $bar->set_colours($colors);
         $pie_values = array();
         foreach ($values as $val_key => $val) {
             if ($val) {
                 $pie_values[] = new pie_value($val, "{$labels[$val_key]} (" . round($val / $total_count * 100) . "%)");
             }
         }
         $bar->set_values($pie_values);
     } else {
         $color = $odd ? current($colors) : next($colors);
         if (!$color) {
             $color = reset($colors);
         }
         if ($type == 'line') {
             $bar = new line();
         } else {
             if ($type == 'hbar') {
                 $bar = new hbar($color);
             } else {
                 if ($type == 'area') {
                     $bar = new area();
                 } else {
                     if ($type == 'bar_flat') {
                         $bar = new bar($color);
                     } else {
                         $bar = new bar_glass($color);
                     }
                 }
             }
         }
         $bar->set_colour($color);
         $bar->set_values($values);
         if ($show_key) {
             $bar->set_key(stripslashes($field->name), $show_key);
         }
         $x_labels->set_labels($labels);
         $x->set_labels($x_labels);
         $x->set_grid_colour($grid_color);
         $y->set_grid_colour($grid_color);
         if ($combine_dates and !strpos($width, '%') and count($labels) * 30 > (int) $width) {
             $x_labels->visible_steps(ceil(count($labels) * 30 / (int) $width));
         }
         $set_max = $max;
         if (!empty($values) and empty($max)) {
             $max = abs(max($values) * 1.2);
             if ($max < 3) {
                 $max = 3;
             }
         }
         foreach ($ids as $f_id) {
             $new_max = abs(max($f_values[$f_id]) * 1.2);
             if ($set_max != $max and $new_max > $max) {
                 $max = $new_max;
             }
             unset($f_id);
             unset($new_max);
         }
         $bars = array();
         foreach ($f_values as $f_id => $f_vals) {
             if ($type == 'line') {
                 $bars[$f_id] = new line();
             } else {
                 if ($type == 'hbar') {
                     $bars[$f_id] = new hbar($color);
                 } else {
                     if ($type == 'area') {
                         $bars[$f_id] = new area();
                     } else {
                         if ($type == 'bar_flat') {
                             $bars[$f_id] = new bar();
                         } else {
                             $bars[$f_id] = new bar_glass();
                         }
                     }
                 }
             }
             $color = next($colors);
             if (!$color) {
                 $color = reset($colors);
             }
             $bars[$f_id]->set_colour($color);
             $bars[$f_id]->set_values($f_vals);
             if ($show_key) {
                 $bars[$f_id]->set_key(stripslashes($fields[$f_id]->name), $show_key);
             }
             unset($f_id);
         }
         if (isset($max) and !empty($max)) {
             $step = ceil($max / 10);
             if (empty($min)) {
                 $min = 0;
             }
             $y->set_range($min, $max, $step);
         }
     }
     $chart->add_element($bar);
     if (isset($bars) and !empty($bars)) {
         foreach ($bars as $f_bar) {
             $chart->add_element($f_bar);
         }
     }
     $chart->set_bg_colour($bg_color);
     if (!$pie) {
         $chart->set_y_axis($y);
         $chart->set_x_axis($x);
     }
     return $chart->toPrettyString();
 }
Пример #12
0
$menorvalor = 0;

for($i = 0; $i < $total; $i ++) {
	$resultado = resultadorelatorio ( $idcolecao [$i], $param );
	$bar->data [] = $resultado;
	if ($resultado > $maiorvalor) {
		$maiorvalor = $resultado;
	}
	if ($resultado < $menorvalor) {
		$menorvalor = $resultado;
	}
}

srand ( ( double ) microtime () * 1000000 );

$bar_1 = new bar_glass ( 55, '#5E83BF', '#424581' );
$bar_1->key ( titulo_selecionado ( $param ), 10 );

for($i = 0; $i < $total; $i ++)
	$bar_1->data [] = resultadorelatorio ( $vetor_url [$i], $param );

$g = new graph ( );

$g->data_sets [] = $bar_1;

$g->set_x_labels ( $nome_colecao );

$g->x_axis_colour ( '#FFFFFF', '#D2D2FB' );
$g->y_axis_colour ( '#FFFFFF', '#D2D2FB' );

$g->bg_colour = '#FFFFFF';
Пример #13
0
$tooltip = new tooltip();
$tooltip->set_hover();
$title = new title("\nJahresueberblick");
$title->set_style('{font-size: 20px; color: #778877}');
$bar_last = new bar_glass();
$bar_last->key("Voriges Jahr {$last_year}", 12);
$bar_last->colour('#546656');
$bar_last->set_tooltip('#val# kWh');
$data = array();
for ($i = 0; $i < count($data_last); $i++) {
    $bval = new bar_value($data_last[$i]);
    $bval->{"on-click"} = "load_chart('month',{$ltime_axis[$i]})";
    $data[] = $bval;
}
$bar_last->set_values($data);
$bar_curr = new bar_glass();
$bar_curr->key("Aktuelles Jahr {$curr_year}", 12);
$bar_curr->colour('#EFC01D');
$bar_curr->set_alpha(0.8);
$bar_curr->set_tooltip('#val# kWh');
$data = array();
for ($i = 0; $i < count($data_curr); $i++) {
    $bval = new bar_value($data_curr[$i]);
    $bval->{"on-click"} = "load_chart('month',{$ttime_axis[$i]})";
    $data[] = $bval;
}
$bar_curr->set_values($data);
$lin_soll = new Line();
$lin_soll->set_key("Sollwert {$curr_year}", 11);
$lin_soll->set_colour('#BFA447');
$lin_soll->set_width(1);
Пример #14
0
 function grafico($codigo = '', $mes = '', $anio = '')
 {
     $this->load->library('Graph');
     if (empty($mes) and empty($anio)) {
         return;
     }
     $fechad = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '01';
     $fechah = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '31';
     $mSQL = "SELECT DATE_FORMAT(fecha, '%d')as fecha, codigo, sum(cantidad) cantidad, IF(sum(cantidad)<=salcant,sum(cantidad),salcant)*(salcant>0)as salcant \n\t\tFROM costos \n\t\tWHERE codigo='{$codigo}' AND fecha>='{$fechad}' AND fecha<='{$fechah}' AND origen='3I'\n\t\tGROUP BY fecha HAVING cantidad>0";
     echo $mSQL;
     $maxval = 0;
     $query = $this->db->query($mSQL);
     foreach ($query->result() as $row) {
         if ($row->cantidad > $maxval) {
             $maxval = $row->cantidad;
         }
         $fecha[] = $row->fecha;
         $codigo = $row->codigo;
         $data_1[] = $row->cantidad;
         $data_2[] = $row->salcant;
     }
     $fechadd = dbdate_to_human($fechad);
     $fechahh = dbdate_to_human($fechah);
     $nombre = $this->datasis->dameval("SELECT descrip FROM sinv WHERE codigo='{$codigo}'");
     $om = 1;
     while ($maxval / $om > 100) {
         $om = $om * 10;
     }
     $bar_1 = new bar_glass(55, '#D54C78', '#C31812');
     $bar_1->key('Ventas', 10);
     $bar_2 = new line_dot(3, 5, '#0066CC', 'Downloads', 10);
     $bar_2->key('Existencias', 10);
     for ($i = 0; $i < count($data_1); $i++) {
         $bar_1->add_data_tip($data_1[$i] / $om, graph::esc(number_format($data_1[$i], 2, ',', '.')));
         $bar_2->add_data_tip($data_2[$i] / $om, graph::esc(number_format($data_2[$i], 2, ',', '.')));
         //  $bar_1->links[]= site_url("/inventario/gproductos/mensuales/$anio/".str_replace('/',':slach:',$proveed[$i]));
         //  $bar_1->links[]= site_url("/inventario/gproductos/mensuales/$anio/".raencode($proveed[$i]));
     }
     $g = new graph();
     $g->set_is_decimal_separator_comma(1);
     if ($maxval > 0) {
         $g->title('Grafico de ' . $nombre . ' Desde ' . $fechadd . ' Hasta ' . $fechahh, '{font-size: 16px; color:#0F3054}');
         $g->data_sets[] = $bar_1;
         $g->data_sets[] = $bar_2;
         $g->set_x_labels($fecha);
         $g->set_x_label_style(10, '#000000', 2, 1);
         $g->set_x_axis_steps(10);
         $g->set_x_legend('Fecha', 14, '#004381');
         $g->bg_colour = '#FFFFFF';
         $g->set_tool_tip('#key#<br>Fecha: #x_label# <br>Cantidad: #tip#');
         $g->set_y_max(ceil($maxval / $om));
         $g->y_label_steps(5);
         //$g->set_y_legend('Ventas x '.number_format($om,0,'','.').' (Bs)', 16, '#004381' );
     } else {
         $g->title('No existen datos con la informacion seleccionada', '{font-size:18px; color: #d01f3c}');
     }
     $g->bg_colour = '#FFFFFF';
     echo utf8_encode($g->render());
 }
Пример #15
0
    $MinETotal = min(round((double) $row->MinETotal, 3), $MinETotal);
    $i++;
}
if (defined($_REQUEST['debug'])) {
    print_r($data_curr);
    print_r($data_soll);
}
if ($i == 0) {
    echo 0;
    exit;
}
$title = new title("\n" . date('F Y', $time) . " (" . round($MaxETotal - $MinETotal, 2) . " kWh)");
$title->set_style('{font-size: 20px; color: #778877}');
$tooltip = new tooltip();
$tooltip->set_hover();
$bars_curr = new bar_glass();
$bars_curr->set_key('Ist Tagesleistung (kWh)', 10);
$bars_curr->set_colour('#EFC01D');
$bars_curr->set_alpha(0.8);
$bars_curr->set_tooltip('#val# kWh');
for ($i = 0; $i < count($data_curr); $i++) {
    $bval = new bar_value($data_curr[$i]);
    $bval->{"on-click"} = "load_chart('day',{$ttime_axis[$i]})";
    if ($data_soll[$i] > 0) {
        $perc = round($data_curr[$i] / $data_soll[$i] * 100, 1);
    } else {
        $perc = 0;
    }
    $bval->set_tooltip($data_curr[$i] . ' kWh - ' . $perc . ' %');
    if ($data_curr[$i] == max($data_curr)) {
        $bval->set_colour('#ef4747');
Пример #16
0
 /**
  * Build The Bar Gharph.
  *
  * @param  array  $params  assoc array of name/value pairs          
  *
  * @return object $chart   object of open flash chart.
  * @static
  */
 static function &barChart(&$params)
 {
     $chart = null;
     if (empty($params)) {
         return $chart;
     }
     $values = CRM_Utils_Array::value('values', $params);
     if (!is_array($values) || empty($values)) {
         return $chart;
     }
     // get the required data.
     $xValues = $yValues = array();
     foreach ($values as $xVal => $yVal) {
         $yValues[] = (double) $yVal;
         // we has to have x values as string.
         $xValues[] = (string) $xVal;
     }
     $chartTitle = CRM_Utils_Array::value('legend', $params) ? $params['legend'] : ts('Bar Chart');
     //set y axis parameters.
     $yMin = 0;
     // calculate max scale for graph.
     $yMax = ceil(max($yValues));
     if ($mod = $yMax % str_pad(5, strlen($yMax) - 1, 0)) {
         $yMax += str_pad(5, strlen($yMax) - 1, 0) - $mod;
     }
     $ySteps = $yMax / 5;
     // $bar = new bar( );
     // glass seem to be more cool
     $bar = new bar_glass();
     //set values.
     $bar->set_values($yValues);
     // call user define function to handle on click event.
     if ($onClickFunName = CRM_Utils_Array::value('on_click_fun_name', $params)) {
         $bar->set_on_click($onClickFunName);
     }
     // get the currency.
     require_once 'CRM/Utils/Money.php';
     $config = CRM_Core_Config::singleton();
     $symbol = $config->defaultCurrencySymbol;
     // set the tooltip.
     $tooltip = CRM_Utils_Array::value('tip', $params, "{$symbol} #val#");
     $bar->set_tooltip($tooltip);
     // create x axis label obj.
     $xLabels = new x_axis_labels();
     $xLabels->set_labels($xValues);
     // set angle for labels.
     if ($xLabelAngle = CRM_Utils_Array::value('xLabelAngle', $params)) {
         $xLabels->rotate($xLabelAngle);
     }
     // create x axis obj.
     $xAxis = new x_axis();
     $xAxis->set_labels($xLabels);
     //create y axis and set range.
     $yAxis = new y_axis();
     $yAxis->set_range($yMin, $yMax, $ySteps);
     // create chart title obj.
     $title = new title($chartTitle);
     // create chart.
     $chart = new open_flash_chart();
     // add x axis w/ labels to chart.
     $chart->set_x_axis($xAxis);
     // add y axis values to chart.
     $chart->add_y_axis($yAxis);
     // set title to chart.
     $chart->set_title($title);
     // add bar element to chart.
     $chart->add_element($bar);
     // add x axis legend.
     if ($xName = CRM_Utils_Array::value('xname', $params)) {
         $xLegend = new x_legend($xName);
         $xLegend->set_style("{font-size: 13px; color:#000000; font-family: Verdana; text-align: center;}");
         $chart->set_x_legend($xLegend);
     }
     // add y axis legend.
     if ($yName = CRM_Utils_Array::value('yname', $params)) {
         $yLegend = new y_legend($yName);
         $yLegend->set_style("{font-size: 13px; color:#000000; font-family: Verdana; text-align: center;}");
         $chart->set_y_legend($yLegend);
     }
     return $chart;
 }
Пример #17
0
if (isset($_GET['dt'])) {
    $dt = $_GET['dt'];
}
$br = "Unknown";
if (isset($_GET['dt'])) {
    $br = $_GET['br'];
}
$dateRange = "";
if (intval($dt) == 1) {
    $dateRange = "DATE(ts) between CONVERT('2012-5-1',DATE) and CONVERT('" . Date('Y-m-d') . "',DATE)";
} else {
    $dtt = explode("-", $dt);
    $dateRange = "DATE(ts) between CONVERT('" . $dtt[0] . "',DATE) and CONVERT('" . $dtt[1] . "',DATE)";
}
$title = new title("Page Views using " . $br . " browser between date " . $dt);
$bar = new bar_glass(55, '#D54C78', '#C31812');
include_once 'db.php';
$q = mysql_query("select count(c_browser) as tot from tracker where c_id=1234 and c_browser='" . $br . "' and " . $dateRange);
$bar->set_values(array(1245, 1202, 455, 120, 3652, 454, 121, 452, 1023, 1054, 1500, 1245, 1278, 123, 6598, 6547, 6589, 6999, 7854, 7562, 5478, 1200, 1254, 1562, 5415, 2587, 4589));
$chart = new open_flash_chart();
$chart->set_title($title);
$chart->add_element($bar);
$x = new x_axis();
$x->set_range(0, 31, 1);
$chart->set_x_axis($x);
$chart->set_y_axis($x);
$y = new y_axis();
$y->set_stroke(3);
$y->set_colour('#000000');
$y->set_tick_length(7);
$y->set_grid_colour('#000000');
Пример #18
0
    public function GetRenderContent(WebPage $oPage, $aExtraParams = array(), $sId)
    {
        $sHtml = '';
        // Add the extra params into the filter if they make sense for such a filter
        $bDoSearch = utils::ReadParam('dosearch', false);
        if ($this->m_oSet == null) {
            $aQueryParams = array();
            if (isset($aExtraParams['query_params'])) {
                $aQueryParams = $aExtraParams['query_params'];
            }
            if ($this->m_sStyle != 'links') {
                $oAppContext = new ApplicationContext();
                $sClass = $this->m_oFilter->GetClass();
                $aFilterCodes = array_keys(MetaModel::GetClassFilterDefs($sClass));
                $aCallSpec = array($sClass, 'MapContextParam');
                if (is_callable($aCallSpec)) {
                    foreach ($oAppContext->GetNames() as $sContextParam) {
                        $sParamCode = call_user_func($aCallSpec, $sContextParam);
                        //Map context parameter to the value/filter code depending on the class
                        if (!is_null($sParamCode)) {
                            $sParamValue = $oAppContext->GetCurrentValue($sContextParam, null);
                            if (!is_null($sParamValue)) {
                                $aExtraParams[$sParamCode] = $sParamValue;
                            }
                        }
                    }
                }
                foreach ($aFilterCodes as $sFilterCode) {
                    $externalFilterValue = utils::ReadParam($sFilterCode, '', false, 'raw_data');
                    $condition = null;
                    if (isset($aExtraParams[$sFilterCode])) {
                        $condition = $aExtraParams[$sFilterCode];
                    }
                    if ($bDoSearch && $externalFilterValue != "") {
                        // Search takes precedence over context params...
                        unset($aExtraParams[$sFilterCode]);
                        if (!is_array($externalFilterValue)) {
                            $condition = trim($externalFilterValue);
                        } else {
                            if (count($externalFilterValue) == 1) {
                                $condition = trim($externalFilterValue[0]);
                            } else {
                                $condition = $externalFilterValue;
                            }
                        }
                    }
                    if (!is_null($condition)) {
                        $sOpCode = null;
                        // default operator
                        if (is_array($condition)) {
                            // Multiple values, add them as AND X IN (v1, v2, v3...)
                            $sOpCode = 'IN';
                        }
                        $this->AddCondition($sFilterCode, $condition, $sOpCode);
                    }
                }
                if ($bDoSearch) {
                    // Keep the table_id identifying this table if we're performing a search
                    $sTableId = utils::ReadParam('_table_id_', null, false, 'raw_data');
                    if ($sTableId != null) {
                        $aExtraParams['table_id'] = $sTableId;
                    }
                }
            }
            $aOrderBy = array();
            if (isset($aExtraParams['order_by'])) {
                // Convert the string describing the order_by parameter into an array
                // The syntax is +attCode1,-attCode2
                // attCode1 => ascending, attCode2 => descending
                $aTemp = explode(',', $aExtraParams['order_by']);
                foreach ($aTemp as $sTemp) {
                    $aMatches = array();
                    if (preg_match('/^([+-])?(.+)$/', $sTemp, $aMatches)) {
                        $bAscending = true;
                        if ($aMatches[1] == '-') {
                            $bAscending = false;
                        }
                        $aOrderBy[$aMatches[2]] = $bAscending;
                    }
                }
            }
            $this->m_oSet = new CMDBObjectSet($this->m_oFilter, $aOrderBy, $aQueryParams);
        }
        switch ($this->m_sStyle) {
            case 'count':
                if (isset($aExtraParams['group_by'])) {
                    if (isset($aExtraParams['group_by_label'])) {
                        $oGroupByExp = Expression::FromOQL($aExtraParams['group_by']);
                        $sGroupByLabel = $aExtraParams['group_by_label'];
                    } else {
                        // Backward compatibility: group_by is simply a field id
                        $sAlias = $this->m_oFilter->GetClassAlias();
                        $oGroupByExp = new FieldExpression($aExtraParams['group_by'], $sAlias);
                        $sGroupByLabel = MetaModel::GetLabel($this->m_oFilter->GetClass(), $aExtraParams['group_by']);
                    }
                    $aGroupBy = array();
                    $aGroupBy['grouped_by_1'] = $oGroupByExp;
                    $sSql = $this->m_oFilter->MakeGroupByQuery($aQueryParams, $aGroupBy, true);
                    $aRes = CMDBSource::QueryToArray($sSql);
                    $aGroupBy = array();
                    $aLabels = array();
                    $aValues = array();
                    $iTotalCount = 0;
                    foreach ($aRes as $iRow => $aRow) {
                        $sValue = $aRow['grouped_by_1'];
                        $aValues[$iRow] = $sValue;
                        $sHtmlValue = $oGroupByExp->MakeValueLabel($this->m_oFilter, $sValue, $sValue);
                        $aLabels[$iRow] = $sHtmlValue;
                        $aGroupBy[$iRow] = (int) $aRow['_itop_count_'];
                        $iTotalCount += $aRow['_itop_count_'];
                    }
                    $aData = array();
                    $oAppContext = new ApplicationContext();
                    $sParams = $oAppContext->GetForLink();
                    foreach ($aGroupBy as $iRow => $iCount) {
                        // Build the search for this subset
                        $oSubsetSearch = $this->m_oFilter->DeepClone();
                        $oCondition = new BinaryExpression($oGroupByExp, '=', new ScalarExpression($aValues[$iRow]));
                        $oSubsetSearch->AddConditionExpression($oCondition);
                        $sFilter = urlencode($oSubsetSearch->serialize());
                        $aData[] = array('group' => $aLabels[$iRow], 'value' => "<a href=\"" . utils::GetAbsoluteUrlAppRoot() . "pages/UI.php?operation=search&dosearch=1&{$sParams}&filter={$sFilter}\">{$iCount}</a>");
                        // TO DO: add the context information
                    }
                    $aAttribs = array('group' => array('label' => $sGroupByLabel, 'description' => ''), 'value' => array('label' => Dict::S('UI:GroupBy:Count'), 'description' => Dict::S('UI:GroupBy:Count+')));
                    $sFormat = isset($aExtraParams['format']) ? $aExtraParams['format'] : 'UI:Pagination:HeaderNoSelection';
                    $sHtml .= $oPage->GetP(Dict::Format($sFormat, $iTotalCount));
                    $sHtml .= $oPage->GetTable($aAttribs, $aData);
                } else {
                    // Simply count the number of elements in the set
                    $iCount = $this->m_oSet->Count();
                    $sFormat = 'UI:CountOfObjects';
                    if (isset($aExtraParams['format'])) {
                        $sFormat = $aExtraParams['format'];
                    }
                    $sHtml .= $oPage->GetP(Dict::Format($sFormat, $iCount));
                }
                break;
            case 'join':
                $aDisplayAliases = isset($aExtraParams['display_aliases']) ? explode(',', $aExtraParams['display_aliases']) : array();
                if (!isset($aExtraParams['group_by'])) {
                    $sHtml .= $oPage->GetP(Dict::S('UI:Error:MandatoryTemplateParameter_group_by'));
                } else {
                    $aGroupByFields = array();
                    $aGroupBy = explode(',', $aExtraParams['group_by']);
                    foreach ($aGroupBy as $sGroupBy) {
                        $aMatches = array();
                        if (preg_match('/^(.+)\\.(.+)$/', $sGroupBy, $aMatches) > 0) {
                            $aGroupByFields[] = array('alias' => $aMatches[1], 'att_code' => $aMatches[2]);
                        }
                    }
                    if (count($aGroupByFields) == 0) {
                        $sHtml .= $oPage->GetP(Dict::Format('UI:Error:InvalidGroupByFields', $aExtraParams['group_by']));
                    } else {
                        $aResults = array();
                        $aCriteria = array();
                        while ($aObjects = $this->m_oSet->FetchAssoc()) {
                            $aKeys = array();
                            foreach ($aGroupByFields as $aField) {
                                $sAlias = $aField['alias'];
                                if (is_null($aObjects[$sAlias])) {
                                    $aKeys[$sAlias . '.' . $aField['att_code']] = '';
                                } else {
                                    $aKeys[$sAlias . '.' . $aField['att_code']] = $aObjects[$sAlias]->Get($aField['att_code']);
                                }
                            }
                            $sCategory = implode($aKeys, ' ');
                            $aResults[$sCategory][] = $aObjects;
                            $aCriteria[$sCategory] = $aKeys;
                        }
                        $sHtml .= "<table>\n";
                        // Construct a new (parametric) query that will return the content of this block
                        $oBlockFilter = $this->m_oFilter->DeepClone();
                        $aExpressions = array();
                        $index = 0;
                        foreach ($aGroupByFields as $aField) {
                            $aExpressions[] = '`' . $aField['alias'] . '`.`' . $aField['att_code'] . '` = :param' . $index++;
                        }
                        $sExpression = implode(' AND ', $aExpressions);
                        $oExpression = Expression::FromOQL($sExpression);
                        $oBlockFilter->AddConditionExpression($oExpression);
                        $aExtraParams['menu'] = false;
                        foreach ($aResults as $sCategory => $aObjects) {
                            $sHtml .= "<tr><td><h1>{$sCategory}</h1></td></tr>\n";
                            if (count($aDisplayAliases) == 1) {
                                $aSimpleArray = array();
                                foreach ($aObjects as $aRow) {
                                    $oObj = $aRow[$aDisplayAliases[0]];
                                    if (!is_null($oObj)) {
                                        $aSimpleArray[] = $oObj;
                                    }
                                }
                                $oSet = CMDBObjectSet::FromArray($this->m_oFilter->GetClass(), $aSimpleArray);
                                $sHtml .= "<tr><td>" . cmdbAbstractObject::GetDisplaySet($oPage, $oSet, $aExtraParams) . "</td></tr>\n";
                            } else {
                                $index = 0;
                                $aArgs = array();
                                foreach ($aGroupByFields as $aField) {
                                    $aArgs['param' . $index] = $aCriteria[$sCategory][$aField['alias'] . '.' . $aField['att_code']];
                                    $index++;
                                }
                                $oSet = new CMDBObjectSet($oBlockFilter, array(), $aArgs);
                                $sHtml .= "<tr><td>" . cmdbAbstractObject::GetDisplayExtendedSet($oPage, $oSet, $aExtraParams) . "</td></tr>\n";
                            }
                        }
                        $sHtml .= "</table>\n";
                    }
                }
                break;
            case 'list':
                $aClasses = $this->m_oSet->GetSelectedClasses();
                $aAuthorizedClasses = array();
                if (count($aClasses) > 1) {
                    // Check the classes that can be read (i.e authorized) by this user...
                    foreach ($aClasses as $sAlias => $sClassName) {
                        if (UserRights::IsActionAllowed($sClassName, UR_ACTION_READ, $this->m_oSet) && (UR_ALLOWED_YES || UR_ALLOWED_DEPENDS)) {
                            $aAuthorizedClasses[$sAlias] = $sClassName;
                        }
                    }
                    if (count($aAuthorizedClasses) > 0) {
                        if ($this->m_oSet->Count() > 0) {
                            $sHtml .= cmdbAbstractObject::GetDisplayExtendedSet($oPage, $this->m_oSet, $aExtraParams);
                        } else {
                            // Empty set
                            $sHtml .= $oPage->GetP(Dict::S('UI:NoObjectToDisplay'));
                        }
                    } else {
                        // Not authorized
                        $sHtml .= $oPage->GetP(Dict::S('UI:NoObjectToDisplay'));
                    }
                } else {
                    // The list is made of only 1 class of objects, actions on the list are possible
                    if ($this->m_oSet->Count() > 0 && UserRights::IsActionAllowed($this->m_oSet->GetClass(), UR_ACTION_READ, $this->m_oSet) == UR_ALLOWED_YES) {
                        $sHtml .= cmdbAbstractObject::GetDisplaySet($oPage, $this->m_oSet, $aExtraParams);
                    } else {
                        $sHtml .= $oPage->GetP(Dict::S('UI:NoObjectToDisplay'));
                        $sClass = $this->m_oFilter->GetClass();
                        $bDisplayMenu = isset($aExtraParams['menu']) ? $aExtraParams['menu'] == true : true;
                        if ($bDisplayMenu) {
                            if (UserRights::IsActionAllowed($sClass, UR_ACTION_MODIFY) == UR_ALLOWED_YES) {
                                $sLinkTarget = '';
                                $oAppContext = new ApplicationContext();
                                $sParams = $oAppContext->GetForLink();
                                // 1:n links, populate the target object as a default value when creating a new linked object
                                if (isset($aExtraParams['target_attr'])) {
                                    $sLinkTarget = ' target="_blank" ';
                                    $aExtraParams['default'][$aExtraParams['target_attr']] = $aExtraParams['object_id'];
                                }
                                $sDefault = '';
                                if (!empty($aExtraParams['default'])) {
                                    foreach ($aExtraParams['default'] as $sKey => $sValue) {
                                        $sDefault .= "&default[{$sKey}]={$sValue}";
                                    }
                                }
                                $sHtml .= $oPage->GetP("<a{$sLinkTarget} href=\"" . utils::GetAbsoluteUrlAppRoot() . "pages/UI.php?operation=new&class={$sClass}&{$sParams}{$sDefault}\">" . Dict::Format('UI:ClickToCreateNew', Metamodel::GetName($sClass)) . "</a>\n");
                            }
                        }
                    }
                }
                break;
            case 'links':
                //$bDashboardMode = isset($aExtraParams['dashboard']) ? ($aExtraParams['dashboard'] == 'true') : false;
                //$bSelectMode = isset($aExtraParams['select']) ? ($aExtraParams['select'] == 'true') : false;
                if ($this->m_oSet->Count() > 0 && UserRights::IsActionAllowed($this->m_oSet->GetClass(), UR_ACTION_READ, $this->m_oSet) == UR_ALLOWED_YES) {
                    //$sLinkage = isset($aExtraParams['linkage']) ? $aExtraParams['linkage'] : '';
                    $sHtml .= cmdbAbstractObject::GetDisplaySet($oPage, $this->m_oSet, $aExtraParams);
                } else {
                    $sClass = $this->m_oFilter->GetClass();
                    $oAttDef = MetaModel::GetAttributeDef($sClass, $this->m_aParams['target_attr']);
                    $sTargetClass = $oAttDef->GetTargetClass();
                    $sHtml .= $oPage->GetP(Dict::Format('UI:NoObject_Class_ToDisplay', MetaModel::GetName($sTargetClass)));
                    $bDisplayMenu = isset($this->m_aParams['menu']) ? $this->m_aParams['menu'] == true : true;
                    if ($bDisplayMenu) {
                        if (UserRights::IsActionAllowed($sClass, UR_ACTION_MODIFY) == UR_ALLOWED_YES) {
                            $oAppContext = new ApplicationContext();
                            $sParams = $oAppContext->GetForLink();
                            $sDefaults = '';
                            if (isset($this->m_aParams['default'])) {
                                foreach ($this->m_aParams['default'] as $sName => $sValue) {
                                    $sDefaults .= '&' . urlencode($sName) . '=' . urlencode($sValue);
                                }
                            }
                            $sHtml .= $oPage->GetP("<a href=\"" . utils::GetAbsoluteUrlAppRoot() . "pages/UI.php?operation=modify_links&class={$sClass}&sParams&link_attr=" . $aExtraParams['link_attr'] . "&id=" . $aExtraParams['object_id'] . "&target_class={$sTargetClass}&addObjects=true{$sDefaults}\">" . Dict::Format('UI:ClickToCreateNew', Metamodel::GetName($sClass)) . "</a>\n");
                        }
                    }
                }
                break;
            case 'details':
                while ($oObj = $this->m_oSet->Fetch()) {
                    $sHtml .= $oObj->GetDetails($oPage);
                    // Still used ???
                }
                break;
            case 'actions':
                $sClass = $this->m_oFilter->GetClass();
                $oAppContext = new ApplicationContext();
                $bContextFilter = isset($aExtraParams['context_filter']) ? isset($aExtraParams['context_filter']) != 0 : false;
                if ($bContextFilter) {
                    $aFilterCodes = array_keys(MetaModel::GetClassFilterDefs($this->m_oFilter->GetClass()));
                    foreach ($oAppContext->GetNames() as $sFilterCode) {
                        $sContextParamValue = $oAppContext->GetCurrentValue($sFilterCode, null);
                        if (!is_null($sContextParamValue) && !empty($sContextParamValue) && MetaModel::IsValidFilterCode($sClass, $sFilterCode)) {
                            $this->AddCondition($sFilterCode, $sContextParamValue);
                        }
                    }
                    $aQueryParams = array();
                    if (isset($aExtraParams['query_params'])) {
                        $aQueryParams = $aExtraParams['query_params'];
                    }
                    $this->m_oSet = new CMDBObjectSet($this->m_oFilter, array(), $aQueryParams);
                }
                $iCount = $this->m_oSet->Count();
                $sHyperlink = utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php?operation=search&' . $oAppContext->GetForLink() . '&filter=' . urlencode($this->m_oFilter->serialize());
                $sHtml .= '<p><a class="actions" href="' . $sHyperlink . '">';
                // Note: border set to 0 due to various browser interpretations (IE9 adding a 2px border)
                $sHtml .= MetaModel::GetClassIcon($sClass, true, 'float;left;margin-right:10px;border:0;');
                $sHtml .= MetaModel::GetName($sClass) . ': ' . $iCount . '</a></p>';
                $sParams = $oAppContext->GetForLink();
                $sHtml .= '<p>';
                if (UserRights::IsActionAllowed($sClass, UR_ACTION_MODIFY)) {
                    $sHtml .= "<a href=\"" . utils::GetAbsoluteUrlAppRoot() . "pages/UI.php?operation=new&class={$sClass}&{$sParams}\">" . Dict::Format('UI:ClickToCreateNew', MetaModel::GetName($sClass)) . "</a><br/>\n";
                }
                $sHtml .= "<a href=\"" . utils::GetAbsoluteUrlAppRoot() . "pages/UI.php?operation=search_form&do_search=0&class={$sClass}&{$sParams}\">" . Dict::Format('UI:SearchFor_Class', MetaModel::GetName($sClass)) . "</a>\n";
                $sHtml .= '</p>';
                break;
            case 'summary':
                $sClass = $this->m_oFilter->GetClass();
                $oAppContext = new ApplicationContext();
                $sTitle = isset($aExtraParams['title[block]']) ? $aExtraParams['title[block]'] : '';
                $sLabel = isset($aExtraParams['label[block]']) ? $aExtraParams['label[block]'] : '';
                $sStateAttrCode = isset($aExtraParams['status[block]']) ? $aExtraParams['status[block]'] : 'status';
                $sStatesList = isset($aExtraParams['status_codes[block]']) ? $aExtraParams['status_codes[block]'] : '';
                $bContextFilter = isset($aExtraParams['context_filter']) ? isset($aExtraParams['context_filter']) != 0 : false;
                if ($bContextFilter) {
                    $aFilterCodes = array_keys(MetaModel::GetClassFilterDefs($this->m_oFilter->GetClass()));
                    foreach ($oAppContext->GetNames() as $sFilterCode) {
                        $sContextParamValue = $oAppContext->GetCurrentValue($sFilterCode, null);
                        if (!is_null($sContextParamValue) && !empty($sContextParamValue) && MetaModel::IsValidFilterCode($sClass, $sFilterCode)) {
                            $this->AddCondition($sFilterCode, $sContextParamValue);
                        }
                    }
                    $aQueryParams = array();
                    if (isset($aExtraParams['query_params'])) {
                        $aQueryParams = $aExtraParams['query_params'];
                    }
                    $this->m_oSet = new CMDBObjectSet($this->m_oFilter, array(), $aQueryParams);
                }
                // Summary details
                $aCounts = array();
                $aStateLabels = array();
                if (!empty($sStateAttrCode) && !empty($sStatesList)) {
                    $aStates = explode(',', $sStatesList);
                    $oAttDef = MetaModel::GetAttributeDef($sClass, $sStateAttrCode);
                    foreach ($aStates as $sStateValue) {
                        $oFilter = $this->m_oFilter->DeepClone();
                        $oFilter->AddCondition($sStateAttrCode, $sStateValue, '=');
                        $oSet = new DBObjectSet($oFilter);
                        $aCounts[$sStateValue] = $oSet->Count();
                        $aStateLabels[$sStateValue] = htmlentities($oAttDef->GetValueLabel($sStateValue), ENT_QUOTES, 'UTF-8');
                        if ($aCounts[$sStateValue] == 0) {
                            $aCounts[$sStateValue] = '-';
                        } else {
                            $sHyperlink = utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php?operation=search&' . $oAppContext->GetForLink() . '&filter=' . urlencode($oFilter->serialize());
                            $aCounts[$sStateValue] = "<a href=\"{$sHyperlink}\">{$aCounts[$sStateValue]}</a>";
                        }
                    }
                }
                $sHtml .= '<div class="summary-details"><table><tr><th>' . implode('</th><th>', $aStateLabels) . '</th></tr>';
                $sHtml .= '<tr><td>' . implode('</td><td>', $aCounts) . '</td></tr></table></div>';
                // Title & summary
                $iCount = $this->m_oSet->Count();
                $sHyperlink = utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php?operation=search&' . $oAppContext->GetForLink() . '&filter=' . urlencode($this->m_oFilter->serialize());
                $sHtml .= '<h1>' . Dict::S(str_replace('_', ':', $sTitle)) . '</h1>';
                $sHtml .= '<a class="summary" href="' . $sHyperlink . '">' . Dict::Format(str_replace('_', ':', $sLabel), $iCount) . '</a>';
                $sHtml .= '<div style="clear:both;"></div>';
                break;
            case 'csv':
                $bAdvancedMode = utils::ReadParam('advanced', false);
                $sCsvFile = strtolower($this->m_oFilter->GetClass()) . '.csv';
                $sDownloadLink = utils::GetAbsoluteUrlAppRoot() . 'webservices/export.php?expression=' . urlencode($this->m_oFilter->ToOQL(true)) . '&format=csv&filename=' . urlencode($sCsvFile);
                $sLinkToToggle = utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php?operation=search&' . $oAppContext->GetForLink() . '&filter=' . urlencode($this->m_oFilter->serialize()) . '&format=csv';
                if ($bAdvancedMode) {
                    $sDownloadLink .= '&fields_advanced=1';
                    $sChecked = 'CHECKED';
                } else {
                    $sLinkToToggle = $sLinkToToggle . '&advanced=1';
                    $sChecked = '';
                }
                $sAjaxLink = $sDownloadLink . '&charset=UTF-8';
                // Includes &fields_advanced=1 if in advanced mode
                /*
                			$sCSVData = cmdbAbstractObject::GetSetAsCSV($this->m_oSet, array('fields_advanced' => $bAdvancedMode));
                			$sCharset = MetaModel::GetConfig()->Get('csv_file_default_charset');
                			if ($sCharset == 'UTF-8')
                			{
                				$bLostChars = false;
                			}
                			else
                			{
                				$sConverted = @iconv('UTF-8', $sCharset, $sCSVData);
                				$sRestored = @iconv($sCharset, 'UTF-8', $sConverted);
                				$bLostChars = ($sRestored != $sCSVData);
                			}
                			if ($bLostChars)
                			{
                				$sCharsetNotice = "&nbsp;&nbsp;<span id=\"csv_charset_issue\">";
                				$sCharsetNotice .= '<img src="../images/error.png"  style="vertical-align:middle"/>';
                				$sCharsetNotice .= "</span>";
                				$sTip = "<p>".htmlentities(Dict::S('UI:CSVExport:LostChars'), ENT_QUOTES, 'UTF-8')."</p>";
                				$sTip .= "<p>".htmlentities(Dict::Format('UI:CSVExport:LostChars+', $sCharset), ENT_QUOTES, 'UTF-8')."</p>";
                				$oPage->add_ready_script("$('#csv_charset_issue').qtip( { content: '$sTip', show: 'mouseover', hide: 'mouseout', style: { name: 'dark', tip: 'leftTop' }, position: { corner: { target: 'rightMiddle', tooltip: 'leftTop' }} } );");
                			}
                			else
                			{
                				$sCharsetNotice = '';
                			}
                */
                $sCharsetNotice = false;
                $sHtml .= "<div>";
                $sHtml .= '<table style="width:100%" class="transparent">';
                $sHtml .= '<tr>';
                $sHtml .= '<td><a href="' . $sDownloadLink . '">' . Dict::Format('UI:Download-CSV', $sCsvFile) . '</a>' . $sCharsetNotice . '</td>';
                $sHtml .= '<td style="text-align:right"><input type="checkbox" ' . $sChecked . ' onClick="window.location.href=\'' . $sLinkToToggle . '\'">&nbsp;' . Dict::S('UI:CSVExport:AdvancedMode') . '</td>';
                $sHtml .= '</tr>';
                $sHtml .= '</table>';
                if ($bAdvancedMode) {
                    $sHtml .= "<p>";
                    $sHtml .= htmlentities(Dict::S('UI:CSVExport:AdvancedMode+'), ENT_QUOTES, 'UTF-8');
                    $sHtml .= "</p>";
                }
                $sHtml .= "</div>";
                $sHtml .= "<div id=\"csv_content_loading\"><div style=\"width: 250px; height: 20px; background: url(../setup/orange-progress.gif); border: 1px #999 solid; margin-left:auto; margin-right: auto; text-align: center;\">" . Dict::S('UI:Loading') . "</div></div><textarea id=\"csv_content\" style=\"display:none;\">\n";
                //$sHtml .= htmlentities($sCSVData, ENT_QUOTES, 'UTF-8');
                $sHtml .= "</textarea>\n";
                $oPage->add_ready_script("\$.post('{$sAjaxLink}', {}, function(data) { \$('#csv_content').html(data); \$('#csv_content_loading').hide(); \$('#csv_content').show();} );");
                break;
            case 'modify':
                if (UserRights::IsActionAllowed($this->m_oSet->GetClass(), UR_ACTION_MODIFY, $this->m_oSet) == UR_ALLOWED_YES) {
                    while ($oObj = $this->m_oSet->Fetch()) {
                        $sHtml .= $oObj->GetModifyForm($oPage);
                    }
                }
                break;
            case 'search':
                $sStyle = isset($aExtraParams['open']) && $aExtraParams['open'] == 'true' ? 'SearchDrawer' : 'SearchDrawer DrawerClosed';
                $sHtml .= "<div id=\"ds_{$sId}\" class=\"{$sStyle}\">\n";
                $oPage->add_ready_script(<<<EOF
\t\$("#dh_{$sId}").click( function() {
\t\t\$("#ds_{$sId}").slideToggle('normal', function() { \$("#ds_{$sId}").parent().resize(); FixSearchFormsDisposition(); } );
\t\t\$("#dh_{$sId}").toggleClass('open');
\t});
EOF
);
                $aExtraParams['currentId'] = $sId;
                $sHtml .= cmdbAbstractObject::GetSearchForm($oPage, $this->m_oSet, $aExtraParams);
                $sHtml .= "</div>\n";
                $sHtml .= "<div class=\"HRDrawer\"></div>\n";
                $sHtml .= "<div id=\"dh_{$sId}\" class=\"DrawerHandle\">" . Dict::S('UI:SearchToggle') . "</div>\n";
                break;
            case 'open_flash_chart':
                static $iChartCounter = 0;
                $oAppContext = new ApplicationContext();
                $sContext = $oAppContext->GetForLink();
                if (!empty($sContext)) {
                    $sContext = '&' . $sContext;
                }
                $sChartType = isset($aExtraParams['chart_type']) ? $aExtraParams['chart_type'] : 'pie';
                $sTitle = isset($aExtraParams['chart_title']) ? $aExtraParams['chart_title'] : '';
                $sGroupBy = isset($aExtraParams['group_by']) ? $aExtraParams['group_by'] : '';
                $sGroupByExpr = isset($aExtraParams['group_by_expr']) ? '&params[group_by_expr]=' . $aExtraParams['group_by_expr'] : '';
                $sFilter = $this->m_oFilter->serialize();
                $sHtml .= "<div id=\"my_chart_{$sId}{$iChartCounter}\">If the chart does not display, <a href=\"http://get.adobe.com/flash/\" target=\"_blank\">install Flash</a></div>\n";
                $oPage->add_script("function ofc_resize(left, width, top, height) { /* do nothing special */ }");
                if (isset($aExtraParams['group_by_label'])) {
                    $sUrl = urlencode(utils::GetAbsoluteUrlAppRoot() . "pages/ajax.render.php?operation=open_flash_chart&params[group_by]={$sGroupBy}{$sGroupByExpr}&params[group_by_label]={$aExtraParams['group_by_label']}&params[chart_type]={$sChartType}&params[chart_title]={$sTitle}&params[currentId]={$sId}&id={$sId}&filter=" . urlencode($sFilter));
                } else {
                    $sUrl = urlencode(utils::GetAbsoluteUrlAppRoot() . "pages/ajax.render.php?operation=open_flash_chart&params[group_by]={$sGroupBy}{$sGroupByExpr}&params[chart_type]={$sChartType}&params[chart_title]={$sTitle}&params[currentId]={$sId}&id={$sId}&filter=" . urlencode($sFilter));
                }
                $oPage->add_ready_script("swfobject.embedSWF(\"../images/open-flash-chart.swf\", \"my_chart_{$sId}{$iChartCounter}\", \"100%\", \"300\",\"9.0.0\", \"expressInstall.swf\",\n\t\t\t\t{\"data-file\":\"" . $sUrl . "\"}, {wmode: 'transparent'} );\n");
                $iChartCounter++;
                if (isset($aExtraParams['group_by'])) {
                    if (isset($aExtraParams['group_by_label'])) {
                        $oGroupByExp = Expression::FromOQL($aExtraParams['group_by']);
                        $sGroupByLabel = $aExtraParams['group_by_label'];
                    } else {
                        // Backward compatibility: group_by is simply a field id
                        $sAlias = $this->m_oFilter->GetClassAlias();
                        $oGroupByExp = new FieldExpression($aExtraParams['group_by'], $sAlias);
                        $sGroupByLabel = MetaModel::GetLabel($this->m_oFilter->GetClass(), $aExtraParams['group_by']);
                    }
                    $aGroupBy = array();
                    $aGroupBy['grouped_by_1'] = $oGroupByExp;
                    $sSql = $this->m_oFilter->MakeGroupByQuery($aQueryParams, $aGroupBy, true);
                    $aRes = CMDBSource::QueryToArray($sSql);
                    $aGroupBy = array();
                    $aLabels = array();
                    $aValues = array();
                    $iTotalCount = 0;
                    foreach ($aRes as $iRow => $aRow) {
                        $sValue = $aRow['grouped_by_1'];
                        $aValues[$iRow] = $sValue;
                        $sHtmlValue = $oGroupByExp->MakeValueLabel($this->m_oFilter, $sValue, $sValue);
                        $aLabels[$iRow] = $sHtmlValue;
                        $aGroupBy[$iRow] = (int) $aRow['_itop_count_'];
                        $iTotalCount += $aRow['_itop_count_'];
                    }
                    $aData = array();
                    $idx = 0;
                    $aURLs = array();
                    foreach ($aGroupBy as $iRow => $iCount) {
                        // Build the search for this subset
                        $oSubsetSearch = $this->m_oFilter->DeepClone();
                        $oCondition = new BinaryExpression($oGroupByExp, '=', new ScalarExpression($aValues[$iRow]));
                        $oSubsetSearch->AddConditionExpression($oCondition);
                        $aURLs[$idx] = $oSubsetSearch->serialize();
                        $idx++;
                    }
                    $sURLList = '';
                    foreach ($aURLs as $index => $sURL) {
                        $sURLList .= "\taURLs[{$index}] = '" . utils::GetAbsoluteUrlAppRoot() . "pages/UI.php?operation=search&format=html{$sContext}&filter=" . urlencode($sURL) . "';\n";
                    }
                    $oPage->add_script(<<<EOF
function ofc_drill_down_{$sId}(index)
{
\tvar aURLs = new Array();
{$sURLList}
\twindow.location.href=aURLs[index];
}
EOF
);
                }
                break;
            case 'open_flash_chart_ajax':
                require_once APPROOT . '/pages/php-ofc-library/open-flash-chart.php';
                $sChartType = isset($aExtraParams['chart_type']) ? $aExtraParams['chart_type'] : 'pie';
                $sId = utils::ReadParam('id', '');
                $oChart = new open_flash_chart();
                switch ($sChartType) {
                    case 'bars':
                        $oChartElement = new bar_glass();
                        if (isset($aExtraParams['group_by'])) {
                            if (isset($aExtraParams['group_by_label'])) {
                                $oGroupByExp = Expression::FromOQL($aExtraParams['group_by']);
                                $sGroupByLabel = $aExtraParams['group_by_label'];
                            } else {
                                // Backward compatibility: group_by is simply a field id
                                $sAlias = $this->m_oFilter->GetClassAlias();
                                $oGroupByExp = new FieldExpression($aExtraParams['group_by'], $sAlias);
                                $sGroupByLabel = MetaModel::GetLabel($this->m_oFilter->GetClass(), $aExtraParams['group_by']);
                            }
                            $aGroupBy = array();
                            $aGroupBy['grouped_by_1'] = $oGroupByExp;
                            $sSql = $this->m_oFilter->MakeGroupByQuery($aQueryParams, $aGroupBy, true);
                            $aRes = CMDBSource::QueryToArray($sSql);
                            $aGroupBy = array();
                            $aLabels = array();
                            $iTotalCount = 0;
                            foreach ($aRes as $iRow => $aRow) {
                                $sValue = $aRow['grouped_by_1'];
                                $sHtmlValue = $oGroupByExp->MakeValueLabel($this->m_oFilter, $sValue, $sValue);
                                $aLabels[$iRow] = strip_tags($sHtmlValue);
                                $aGroupBy[$iRow] = (int) $aRow['_itop_count_'];
                                $iTotalCount += $aRow['_itop_count_'];
                            }
                            $aData = array();
                            $aChartLabels = array();
                            $maxValue = 0;
                            foreach ($aGroupBy as $iRow => $iCount) {
                                $oBarValue = new bar_value($iCount);
                                $oBarValue->on_click("ofc_drill_down_{$sId}");
                                $aData[] = $oBarValue;
                                if ($iCount > $maxValue) {
                                    $maxValue = $iCount;
                                }
                                $aChartLabels[] = html_entity_decode($aLabels[$iRow], ENT_QUOTES, 'UTF-8');
                            }
                            $oYAxis = new y_axis();
                            $aMagicValues = array(1, 2, 5, 10);
                            $iMultiplier = 1;
                            $index = 0;
                            $iTop = $aMagicValues[$index % count($aMagicValues)] * $iMultiplier;
                            while ($maxValue > $iTop) {
                                $index++;
                                $iTop = $aMagicValues[$index % count($aMagicValues)] * $iMultiplier;
                                if ($index % count($aMagicValues) == 0) {
                                    $iMultiplier = $iMultiplier * 10;
                                }
                            }
                            //echo "oYAxis->set_range(0, $iTop, $iMultiplier);\n";
                            $oYAxis->set_range(0, $iTop, $iMultiplier);
                            $oChart->set_y_axis($oYAxis);
                            $oChartElement->set_values($aData);
                            $oXAxis = new x_axis();
                            $oXLabels = new x_axis_labels();
                            // set them vertical
                            $oXLabels->set_vertical();
                            // set the label text
                            $oXLabels->set_labels($aChartLabels);
                            // Add the X Axis Labels to the X Axis
                            $oXAxis->set_labels($oXLabels);
                            $oChart->set_x_axis($oXAxis);
                        }
                        break;
                    case 'pie':
                    default:
                        $oChartElement = new pie();
                        $oChartElement->set_start_angle(35);
                        $oChartElement->set_animate(true);
                        $oChartElement->set_tooltip('#label# - #val# (#percent#)');
                        $oChartElement->set_colours(array('#FF8A00', '#909980', '#2C2B33', '#CCC08D', '#596664'));
                        if (isset($aExtraParams['group_by'])) {
                            if (isset($aExtraParams['group_by_label'])) {
                                $oGroupByExp = Expression::FromOQL($aExtraParams['group_by']);
                                $sGroupByLabel = $aExtraParams['group_by_label'];
                            } else {
                                // Backward compatibility: group_by is simply a field id
                                $sAlias = $this->m_oFilter->GetClassAlias();
                                $oGroupByExp = new FieldExpression($aExtraParams['group_by'], $sAlias);
                                $sGroupByLabel = MetaModel::GetLabel($this->m_oFilter->GetClass(), $aExtraParams['group_by']);
                            }
                            $aGroupBy = array();
                            $aGroupBy['grouped_by_1'] = $oGroupByExp;
                            $sSql = $this->m_oFilter->MakeGroupByQuery($aQueryParams, $aGroupBy, true);
                            $aRes = CMDBSource::QueryToArray($sSql);
                            $aGroupBy = array();
                            $aLabels = array();
                            $iTotalCount = 0;
                            foreach ($aRes as $iRow => $aRow) {
                                $sValue = $aRow['grouped_by_1'];
                                $sHtmlValue = $oGroupByExp->MakeValueLabel($this->m_oFilter, $sValue, $sValue);
                                $aLabels[$iRow] = strip_tags($sHtmlValue);
                                $aGroupBy[$iRow] = (int) $aRow['_itop_count_'];
                                $iTotalCount += $aRow['_itop_count_'];
                            }
                            $aData = array();
                            foreach ($aGroupBy as $iRow => $iCount) {
                                $sFlashLabel = html_entity_decode($aLabels[$iRow], ENT_QUOTES, 'UTF-8');
                                $PieValue = new pie_value($iCount, $sFlashLabel);
                                //@@ BUG: not passed via ajax !!!
                                $PieValue->on_click("ofc_drill_down_{$sId}");
                                $aData[] = $PieValue;
                            }
                            $oChartElement->set_values($aData);
                            $oChart->x_axis = null;
                        }
                }
                if (isset($aExtraParams['chart_title'])) {
                    // The title has been given in an url, and urlencoded...
                    // and urlencode transforms utf-8 into something similar to ISO-8859-1
                    // Example: é (C3A9 becomes %E9)
                    // As a consequence, json_encode (called within open-flash-chart.php)
                    // was returning 'null' and the graph was not displayed at all
                    // To make sure that the graph is displayed AND to get a correct title
                    // (at least for european characters) let's transform back into utf-8 !
                    $sTitle = iconv("ISO-8859-1", "UTF-8//IGNORE", $aExtraParams['chart_title']);
                    // If the title is a dictionnary entry, fetch it
                    $sTitle = Dict::S($sTitle);
                    $oTitle = new title($sTitle);
                    $oChart->set_title($oTitle);
                    $oTitle->set_style("{font-size: 16px; font-family: Tahoma; font-weight: bold; text-align: center;}");
                }
                $oChart->set_bg_colour('#FFFFFF');
                $oChart->add_element($oChartElement);
                $sHtml = $oChart->toPrettyString();
                break;
            default:
                // Unsupported style, do nothing.
                $sHtml .= Dict::format('UI:Error:UnsupportedStyleOfBlock', $this->m_sStyle);
        }
        return $sHtml;
    }
Пример #19
0
 //$x_labels->set_vertical();
 // Nouveau grAphique
 $chart2 = new open_flash_chart();
 //$posy=0;
 if (sizeof($listeJeux) > 3) {
     for ($i = sizeof($listeJeux) - 3; $i < sizeof($listeJeux); $i++) {
         // $tab_libelles2[]  = $listeJeux[$i]['titre'];;
         // $type2 = new dot();
         // if      ($posy==0)    $type = new dot();
         // else if ($posy==1)    $type = new solid_dot();
         // else if ($posy==2)    $type = new hollow_dot();
         // else if ($posy==3)    $type = new star();
         // else if ($posy==4)    $type = new anchor();
         // else if ($posy==5)    $type = new bow();
         // $type2->tooltip($listeJoueurs[$j]['nom']."<br>Jeu:#x_label#<br>Moy. #val#");
         $bar_glass = new bar_glass();
         // $bar->set_default_dot_style($type2);
         //$bar->set_width( 1 );
         $bar_glass->set_colour($G_MesCouleurs[$i]);
         $bar_glass->set_values($data_val2[$i]);
         $bar_glass->set_key($listeJeux[$i]["titre"], 10);
         $chart2->add_element($bar_glass);
         //$posy=$posy+1;
         //if ($posy==6) $posy=0;
     }
 }
 $labels2 = new x_axis_labels();
 $labels2->set_labels($tab_libelles2);
 $labels2->rotate(270);
 // Absisses
 $x2 = new x_axis();
Пример #20
0
 function consultaBl($id_atencion)
 {
     //----------------------------------------------------------
     $d = array();
     $d['id_atencion'] = $id_atencion;
     $d['atencion'] = $this->urgencias_model->obtenerAtencion($id_atencion);
     $d['paciente'] = $this->paciente_model->obtenerPacienteConsulta($d['atencion']['id_paciente']);
     $d['tercero'] = $this->paciente_model->obtenerTercero($d['paciente']['id_tercero']);
     $d['ultima_nota'] = $this->enfermeria_model->obtenerUltimaNota($id_atencion);
     //Codificación de la sala de espera según el servicio
     $d['notas'] = $this->enfermeria_model->obtenerBlNotas($id_atencion, $d['atencion']['id_servicio']);
     //print_r($d['notas']);
     $id_serv = $d['atencion']['id_servicio'];
     $d['urlRegresar'] = site_url('/hce/main/consultarAtencion/' . $id_atencion);
     ////////////////////capturamos los valores de los liquidos eliminados/////////////////////
     $bar_1 = array();
     $bar_2 = array();
     $bar_3 = array();
     $tamano = array();
     $tamanoadmi = 0;
     $tamanoelimi = 0;
     $eliminadodia = array();
     $administradodia = array();
     $balance = array();
     $fechas = array();
     $d['valorelimi'] = $this->enfermeria_model->obtenerBlEliminados($id_atencion, $d['atencion']['id_servicio']);
     if ($d['valorelimi'] != 0) {
         foreach ($d['valorelimi'] as $item) {
             $eliminadodia[] = -$item['drend'] - $item['drene'] - $item['storaxe'] - $item['storaxd'] - $item['vomito'] - $item['orina'] - $item['otros'] - $item['deposicion'] - $item['sng'];
             $fechas[] = $item['fecha_nota'];
         }
         $tamanoelimi = sizeof($eliminadodia);
     }
     /////////////////////////////////////////////////////////////////////////////////////////////
     ////////////////////capturamos los valores de los liquidos eliminados/////////////////////
     $d['valoradmi'] = $this->enfermeria_model->obtenerBlAdministrados($id_atencion, $d['atencion']['id_servicio']);
     if ($d['valoradmi'] != 0) {
         foreach ($d['valoradmi'] as $item) {
             $administradodia[] = $item['liv'] + $item['sng'] + $item['via_oral'];
         }
         $tamanoadmi = sizeof($administradodia);
     }
     if ($tamanoadmi == $tamanoelimi) {
         $tamano = $tamanoelimi;
     } else {
         if ($tamanoadmi > $tamanoelimi) {
             $tamano = $tamanoelimi;
         } else {
             if ($tamanoadmi < $tamanoelimi) {
                 $tamano = $tamanoadmi;
             }
         }
     }
     /////////////////////////////////////////////////////////////////////////////////////////////
     for ($i = 0; $i < $tamano; $i++) {
         $balance[] = $administradodia[$i] + $eliminadodia[$i];
     }
     //print_r($balance);
     // generate some random data
     srand((double) microtime() * 1000000);
     $bar_1 = new bar_glass(55, '#5E83BF', '#424581');
     $bar_1->key('Administrados', 10);
     // add 10 bars with random heights
     $maxadmi = 0;
     if ($administradodia != 0) {
         foreach ($administradodia as $item) {
             $bar_1->data[] = $item;
             if ($maxadmi < $item) {
                 $maxadmi = $item;
             }
         }
     }
     //
     // create a 2nd set of bars:
     //
     $bar_2 = new bar_glass(55, '#D54C78', '#C31812');
     $bar_2->key('Eliminados', 10);
     $maxelimi = 0;
     // make 10 bars of random heights
     if ($eliminadodia != 0) {
         foreach ($eliminadodia as $item) {
             $bar_2->data[] = $item;
             if ($maxelimi > $item) {
                 $maxelimi = $item;
             }
         }
     }
     $bar_3 = new bar_glass(55, '#83bf5d', '#448141');
     $bar_3->key('Balance', 10);
     // add 10 bars with random heights\
     if ($balance != 0) {
         foreach ($balance as $item) {
             $bar_3->data[] = $item;
         }
     }
     $this->graph->title('Balance de líquidos', '{font-size:20px; color: #5e6b7f; margin:10px; padding: 5px 15px 5px 15px;}');
     // add both sets of bars:
     $this->graph->data_sets[] = $bar_1;
     $this->graph->data_sets[] = $bar_2;
     $this->graph->data_sets[] = $bar_3;
     // label the X axis (10 labels for 10 bars):
     $this->graph->set_x_labels($fechas);
     // colour the chart to make it pretty:
     $this->graph->x_axis_colour('#909090', '#D2D2FB');
     $this->graph->y_axis_colour('#909090', '#D2D2FB');
     //$this->graph->set_y_min( $maxelimi);
     //$this->graph->set_y_max( $maxadmi);
     $this->graph->set_y_min(-2000);
     $this->graph->set_y_max(2000);
     $this->graph->y_label_steps(10);
     $this->graph->set_y_legend('mililitros (mL)', 12, '#736AFF');
     $this->graph->set_output_type('js');
     //-----------------------------------------------------------
     $this->load->view('core/core_inicio');
     $this->load->view('urg/urg_blListadoM', $d);
     $this->load->view('core/core_fin');
     //----------------------------------------------------------
 }
Пример #21
0
function get_columns_graph($dates, $vals, $keys = array())
{
    include 'php-ofc-library/open-flash-chart.php';
    $max_y = 0;
    for ($i = 0; $i < count($dates); $i++) {
        $year[] = $dates[$i];
        for ($m = 0; $m < count($vals); $m++) {
            $price[$m][] = (int) $vals[$m][$i];
            if ($max_y < (int) $vals[$m][$i]) {
                $max_y = (int) $vals[$m][$i];
            }
            if (@$arr_filled[$m] != $vals[$m][$i] and @$arr_filled[$m] == 0) {
                @($arr_filled[$m] = (int) $vals[$m][$i]);
            }
        }
    }
    while ($max_y % 10 != 0) {
        $max_y++;
    }
    $chart = new open_flash_chart();
    for ($i = 0; $i < count($price); $i++) {
        if ($arr_filled[$i] == 0) {
            continue;
        }
        if ($i == 0) {
            $color = '#5E0722';
        } elseif ($i == 1) {
            $color = '#00FF00';
        } else {
            $color = '#FF0000';
        }
        $area = new bar_glass();
        $area->set_colour($color);
        $area->set_values($price[$i]);
        if (isset($keys[$i])) {
            $area->set_key($keys[$i], 12);
        }
        $chart->add_element($area);
    }
    $x_labels = new x_axis_labels();
    if (count($dates) > 40) {
        $x_labels->set_steps(7);
    } else {
        $x_labels->set_steps(1);
    }
    $x_labels->set_vertical();
    $x_labels->set_colour('#000000');
    $x_labels->set_labels($year);
    $x_labels->rotate(-55);
    $x_labels->set_size(12);
    $x = new x_axis();
    $x->set_colour('#000000');
    $x->set_grid_colour('#DDDDDD');
    $x->set_steps(1);
    // Add the X Axis Labels to the X Axis
    $x->set_labels($x_labels);
    $chart->set_x_axis($x);
    $y = new y_axis();
    $y->set_range(0, $max_y);
    $y->set_colour('#000000');
    $y->set_grid_colour('#DDDDDD');
    $chart->add_y_axis($y);
    $chart->set_bg_colour("#FFFFFF");
    ?>


<script type="text/javascript" src="script/json/json2.js"></script>
<script type="text/javascript" src="script/swfobject.js"></script>
<script type="text/javascript">
swfobject.embedSWF("open-flash-chart.swf", "my_chart", "600", "350", "9.0.0");
</script>

<script type="text/javascript">

function ofc_ready()
{

}

function open_flash_chart_data()
{
	return JSON.stringify(data);
}

function findSWF(movieName) {
	if (navigator.appName.indexOf("Microsoft")!= -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
}

var data = <?php 
    echo $chart->toPrettyString();
    ?>
;

</script>
<?php 
}