"; $res = mysql_query($sql); if ($res){ $id_graph = mysql_insert_id(); if ($id_graph){ for ($a=0; $a < $module_number; $a++){ $id_agentemodulo = get_parameter_post ("module_".$a); $id_agentemodulo_w = get_parameter_post ("module_weight_".$a); $sql = "INSERT INTO tgraph_source (id_graph, id_agent_module, weight) VALUES ($id_graph, $id_agentemodulo, $id_agentemodulo_w)"; //echo "DEBUG $sql
"; mysql_query($sql); } echo "

".__('Graph stored successfully')."

"; } else echo "

".__('There was a problem storing Graph')."

"; } else echo "

".__('There was a problem storing Graph')."

"; } if (isset($_GET['change_graph'])) { $id = get_parameter('id'); $name = get_parameter('name'); $id_group = get_parameter('graph_id_group'); $description = get_parameter('description'); $success = process_sql_update('tgraph', array('name' => $name, 'id_group' => $id_group, 'description' => $description), array('id_graph' => $id)); print_result_message($success, __("Update the graph"), __("Bad update the graph")); } if (isset ($_GET["get_agent"])) { $id_agent = $_POST["id_agent"]; if (isset($_POST["chunk"])) $chunkdata = $_POST["chunk"]; } if (isset ($_GET["delete_module"] )) { if ($editGraph) { $deleteGraphs = get_parameter('delete'); foreach ($deleteGraphs as $deleteGraph) { process_sql_delete('tgraph_source', array('id_gs' => $deleteGraph)); } } else { $chunkdata = $_POST["chunk"]; if (isset($chunkdata)) { $chunk1 = array(); $chunk1 = split ("\|", $chunkdata); $modules="";$weights=""; for ($a = 0; $a < count ($chunk1); $a++) { if (isset ($_POST["delete_$a"])) { $id_module = $_POST["delete_$a"]; $deleted_id[]=$id_module; } } $chunkdata2 = ""; $module_array = array (); $weight_array = array (); $agent_array = array (); for ($a = 0; $a < count ($chunk1); $a++) { $chunk2[$a] = array(); $chunk2[$a] = split (",", $chunk1[$a]); $skip_module =0; for ($b = 0; $b < count ($deleted_id); $b++) { if ($deleted_id[$b] == $chunk2[$a][1]) { $skip_module = 1; } } if (($skip_module == 0) && (strpos ($modules, $chunk2[$a][1]) == 0)) { // Skip $module_array[] = $chunk2[$a][1]; $agent_array[] = $chunk2[$a][0]; $weight_array[] = $chunk2[$a][2]; if ($chunkdata2 == "") $chunkdata2 .= $chunk2[$a][0].",".$chunk2[$a][1].",".$chunk2[$a][2]; else $chunkdata2 .= "|".$chunk2[$a][0].",".$chunk2[$a][1].",".$chunk2[$a][2]; if ($modules !="") $modules = $modules.",".$chunk2[$a][1]; else $modules = $chunk2[$a][1]; if ($weights !="") $weights = $weights.",".$chunk2[$a][2]; else $weights = $chunk2[$a][2]; } } $chunkdata = $chunkdata2; } } } if ($add_module) { if ($editGraph) { $id = get_parameter('id'); $id_module = get_parameter('id_module'); if ($id_module != -1) { $factor = get_parameter('factor'); process_sql_insert('tgraph_source', array('id_graph' => $id, 'id_agent_module' => $id_module, 'weight' => $factor)); $period = get_parameter('period'); $width = get_parameter('width'); $height = get_parameter('height'); $events = get_parameter('events'); $stacked = get_parameter('stacked'); process_sql_update('tgraph', array('period' => $period, 'width' => $width, 'height' => $height, 'events' => $events, 'stacked' => $stacked), array('id_graph' => $id)); } } else { $id_agent = $_POST["id_agent"]; $id_module = $_POST["id_module"]; if (isset($_POST["factor"])) $factor = $_POST["factor"]; else $factor = 1; $period = $_POST["period"]; $render = $_POST["render"]; $stacked = get_parameter ("stacked",0); // $alerts = $_POST["alerts"]; if (isset($_POST["chunk"])) $chunkdata = $_POST["chunk"]; $events = $_POST["events"]; $factor = $_POST["factor"]; if ($_POST["width"]!= "") $width = $_POST["width"]; if ($_POST["height"]!= "") $height = $_POST["height"]; if ($id_module > 0){ if (!isset($chunkdata) OR ($chunkdata == "")) $chunkdata = "$id_agent,$id_module,$factor"; else $chunkdata = $chunkdata."|$id_agent,$id_module,$factor"; } } } // Parse CHUNK information into showable information // Split id to get all parameters if (! isset($_GET["delete_module"])) { if (isset($_POST["period"])) $period = $_POST["period"]; if ((isset($chunkdata) )&& ($chunkdata != "")) { $module_array = array(); $weight_array = array(); $agent_array = array(); $chunk1 = array(); $chunk1 = split ("\|", $chunkdata); $modules="";$weights=""; for ($a=0; $a < count($chunk1); $a++){ $chunk2[$a] = array(); $chunk2[$a] = split ( ",", $chunk1[$a]); if (strpos($modules, $chunk2[$a][1]) == 0){ // Skip dupes $module_array[] = $chunk2[$a][1]; $agent_array[] = $chunk2[$a][0]; $weight_array[] = $chunk2[$a][2]; if ($modules !="") $modules = $modules.",".$chunk2[$a][1]; else $modules = $chunk2[$a][1]; if ($weights !="") $weights = $weights.",".$chunk2[$a][2]; else $weights = $chunk2[$a][2]; } } } } if ($editGraph) { $id = (integer) get_parameter('id'); $graphRows = get_db_all_rows_sql("SELECT t1.*, (SELECT t3.nombre FROM tagente AS t3 WHERE t3.id_agente = (SELECT t2.id_agente FROM tagente_modulo AS t2 WHERE t2.id_agente_modulo = t1.id_agent_module)) AS agent_name FROM tgraph_source AS t1 WHERE t1.id_graph = " . $id); $chunk1 = true; $module_array = array(); $weight_array = array(); $agent_array = array(); $chunk1 = array(); $tempChunkdata = array(); $chunkdata = ""; foreach ($graphRows as $graphRow) { $idsTable[] = $graphRow['id_gs']; $module_array[] = $graphRow['id_agent_module']; $weight_array[] = $graphRow['weight']; $agent_array[] = $graphRow['agent_name']; $tempChunkdata[] = $graphRow['agent_name'] . "," . $graphRow['id_agent_module'] . "," . $graphRow['weight']; } $graphInTgraph = get_db_row_sql("SELECT * FROM tgraph WHERE id_graph = " . $id); $stacked = $graphInTgraph['stacked']; $events = $graphInTgraph['events']; $modules = implode(',', $module_array); $weights = implode(',', $weight_array); $chunkdata = implode('|', $tempChunkdata); } echo "

".__('Reporting')." » "; if (isset ($chunk1)) { echo __('Graph builder module list')."

"; if ($editGraph) { echo "
"; } else { echo ""; } if (isset($chunkdata)) echo ""; if ($id_agent) echo ""; if ($period) echo ""; echo ""; echo ""; $color = 0; for ($a = 0; $a < count($module_array); $a++){ // Calculate table line color if ($color == 1){ $tdcolor = "datos"; $color = 0; } else { $tdcolor = "datos2"; $color = 1; } echo ""; echo ""; echo ""; echo ""; } else { echo ""; } } echo "
".__('Agent')." ".__('Module')." ".__('Weight')." ".__('Delete')."
" . $agent_array[$a] . ""; echo get_agentmodule_name ($module_array[$a]).""; echo $weight_array[$a].""; if ($editGraph) { echo "
"; echo ""; echo "
"; echo "
"; echo "
"; } // -------------------------------------- // Parse chunkdata and render graph // -------------------------------------- if (($render == 1) && (isset($modules))) { // parse chunk echo "

".__('Combined image render')."

"; echo ""; echo "
"; if ($config['flash_charts']) { echo graphic_combined_module (split (',', $modules), split (',', $weights), $period, $width, $height, 'Combined%20Sample%20Graph', '', $events, 0, 0, $stacked); } else { echo ""; } echo "
"; } // ----------------------- // SOURCE AGENT TABLE/FORM // ----------------------- echo __('Graph builder').""; echo ""; if ($editGraph) { echo ""; } else { echo ""; print_input_hidden ('add_module', 1); } if (isset($period)) echo ""; echo ""; echo ""; echo ""; // Show combo with agents echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; /* echo "
".__('Source agent').""; $user_groups = implode (',', array_keys (get_user_groups ($config["id_user"]))); print_input_text_extended ('id_agent', get_agent_name ($id_parent), 'text-id_agent', '', 30, 100, false, '', array('style' => 'background: url(images/lightning.png) no-repeat right;')); echo ' ' . __("Type at least two characters to search") . ''; //print_select_from_sql ("SELECT id_agente, nombre FROM tagente WHERE disabled = 0 AND id_grupo IN ($user_groups) ORDER BY nombre", 'id_agent', $id_agent, '', '--', 0); // SOURCE MODULE FORM if (isset ($chunkdata)) echo ""; echo "
"; echo "".__('Modules').""; echo ""; echo ""; echo "
"; echo "".__('Factor').""; echo ""; echo "".__('Width').""; echo ""; echo "
"; echo "".__('Render now').""; echo ""; echo "".__('Height').""; echo ""; switch ($period) { case 3600: $period_label = "1 ".__('hour'); break; case 7200: $period_label = "2 ".__('hours'); break; case 10800: $period_label = "3 ".__('hours'); break; case 21600: $period_label = "6 ".__('hours'); break; case 43200: $period_label = "12 ".__('hours'); break; case 86400: $period_label = "1 ".__('day'); break; case 172800: $period_label = "2 ".__('days'); break; case 345600: $period_label = "4 ".__('days'); break; case 604800: $period_label = __('Last week'); break; case 1296000: $period_label = "15 ".__('days'); break; case 2592000: $period_label = __('Last month'); break; case 5184000: $period_label = "2 ".__('months'); break; case 15552000: $period_label = "6 ".__('months'); break; case 31104000: $period_label = __('1 year'); break; default: $period_label = "1 ".__('day'); } echo "
"; echo "".__('Period').""; echo ""; echo ""; echo "".__('View events').""; echo "
"; echo "".__('Stacked').""; $stackeds[0] = __('Area'); $stackeds[1] = __('Stacked area'); $stackeds[2] = __('Line'); $stackeds[3] = __('Stacked line'); print_select ($stackeds, 'stacked', $stacked, '', '', 0); echo ""; echo "Show alert limit"; echo ""; echo ""; */ echo "
"; echo ""; echo "
"; echo ""; echo "
"; // ----------------------- // STORE GRAPH FORM // ----------------------- // If we have something to save.. if (isset($module_array)){ echo "

".__('Custom graph store')."

"; echo ""; if ($editGraph) { echo ""; } else { echo ""; // hidden fields with data begin echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; for ($a=0; $a < count($module_array); $a++){ $id_agentemodulo = $module_array[$a]; $id_agentemodulo_w = $weight_array[$a]; echo ""; echo ""; } } // hidden fields end echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
".__('Name').""; $group_select = get_user_groups ($config['id_user']); echo "".__('Group')."" . print_select ($group_select, 'graph_id_group', $graphInTgraph['id_group'], '', '', '', true) . "
".__('Description').""; echo "
"; echo ""; if ($editGraph) { echo "
"; } else { echo "
"; } echo ""; echo "
"; } require_jquery_file ('pandora.controls'); require_jquery_file ('ajaxqueue'); require_jquery_file ('bgiframe'); require_jquery_file ('autocomplete'); ?>