diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 063d99a935..0789fe2af4 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,11 @@ +2009-11-18 Miguel de Dios + + * operation/agentes/exportdata.php: change "search_agents" in the ajax, now + you can add paramater "add" as array json with the names of agents or other + things that you want show in the box of result. + * operation/events/events.php: change the select box for a ajax autocomplete + box for agent form filter. + 2009-11-16 Miguel de Dios * godmode/reporting/reporting_builder.php, diff --git a/pandora_console/operation/agentes/exportdata.php b/pandora_console/operation/agentes/exportdata.php index 9a516dc2b3..c5d889da08 100644 --- a/pandora_console/operation/agentes/exportdata.php +++ b/pandora_console/operation/agentes/exportdata.php @@ -23,6 +23,14 @@ if (is_ajax ()) { $id_agent = (int) get_parameter ('id_agent'); $string = (string) get_parameter ('q'); /* q is what autocomplete plugin gives */ $id_group = (int) get_parameter('id_group'); + $addedItems = html_entity_decode((string) get_parameter('add')); + $addedItems = json_decode($addedItems); + + if ($addedItems != null) { + foreach ($addedItems as $item) { + echo $item . "|\n"; + } + } $filter = array (); $filter[] = '(nombre COLLATE utf8_general_ci LIKE "%'.$string.'%" OR direccion LIKE "%'.$string.'%" OR comentarios LIKE "%'.$string.'%")'; @@ -31,7 +39,7 @@ if (is_ajax ()) { $agents = get_agents ($filter, array ('nombre', 'direccion')); if ($agents === false) return; - + foreach ($agents as $agent) { echo $agent['nombre']."|".$agent['direccion']."\n"; } diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 332fcd3055..a23b3ba65f 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -99,7 +99,20 @@ $search = preg_replace ("/&([A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "%", rawurlde $event_type = get_parameter ("event_type", ''); // 0 all $severity = (int) get_parameter ("severity", -1); // -1 all $status = (int) get_parameter ("status", 0); // -1 all, 0 only red, 1 only green -$id_agent = (int) get_parameter ("id_agent", -1); //-1 all, 0 system +//$id_agent = (int) get_parameter ("id_agent", -1); //-1 all, 0 system +$text_agent = (string) get_parameter("id_agent", "All"); +switch ($text_agent) +{ + case 'All': + $id_agent = -1; + break; + case 'Server': + $id_agent = 0; + default: + $id_agent = get_agent_id($text_agent); + break; +} + $id_event = (int) get_parameter ("id_event", -1); $pagination = (int) get_parameter ("pagination", $config["block_size"]); $groups = get_user_groups ($config["id_user"], "IR"); @@ -241,18 +254,30 @@ echo ''; //Agent search echo "".__('Agent search').""; -$sql = "SELECT DISTINCT(id_agente) AS id_agent FROM tevento WHERE 1=1 ".$sql_post; -$result = get_db_all_rows_sql ($sql); +//$sql = "SELECT DISTINCT(id_agente) AS id_agent FROM tevento WHERE 1=1 ".$sql_post; +//$result = get_db_all_rows_sql ($sql); +// +//if ($result === false) +// $result = array(); +// +//$agents = array (); +//$agents[-1] = __('All'); +// +//if (is_user_admin ($config["id_user"])) { +// $agents[0] = __('System'); +//} -if ($result === false) - $result = array(); -$agents = array (); -$agents[-1] = __('All'); +//foreach ($result as $id_row) { +// $name_for_combo = ""; +// if ($id_row["id_agent"] > 0) +// $name_for_combo = mb_substr (get_agent_name ($id_row["id_agent"], "lower"),0,20); +// +// if ($name_for_combo != "") +// $agents[$id_row["id_agent"]] = $name_for_combo; +//} + -if (is_user_admin ($config["id_user"])) { - $agents[0] = __('System'); -} foreach ($result as $id_row) { $name_for_combo = ""; @@ -263,7 +288,11 @@ foreach ($result as $id_row) { $agents[$id_row["id_agent"]] = $name_for_combo; } -print_select ($agents, 'id_agent', $id_agent, '', '', ''); +print_input_text_extended ('id_agent', $text_agent, 'text_id_agent', '', 30, 100, false, '', +array('style' => 'background: url(images/lightning.png) no-repeat right;')) +. ' ' . __("Type two chars at least for search") . ''; + + echo ""; // User selectable block size @@ -333,8 +362,8 @@ echo ''; if ($group_rep == 0) { $sql = "SELECT * FROM tevento WHERE 1=1 ".$sql_post." ORDER BY utimestamp DESC LIMIT ".$offset.",".$pagination; } else { - $sql = "SELECT *, COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep FROM tevento WHERE 1=1 ".$sql_post." GROUP BY evento, id_agentmodule ORDER BY timestamp_rep DESC LIMIT ".$offset.",".$pagination; -} + $sql = "SELECT *, COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep FROM tevento WHERE 1=1 ".$sql_post." GROUP BY evento, id_agentmodule ORDER BY timestamp_rep DESC LIMIT ".$offset.",".$pagination; +} //Extract the events by filter (or not) from db $result = get_db_all_rows_sql ($sql); @@ -422,7 +451,7 @@ foreach ($result as $event) { switch ($event["criticity"]) { default: - case 0: + case 0: $img = "images/status_sets/default/severity_maintenance.png"; break; case 1: @@ -486,15 +515,15 @@ foreach ($result as $event) { $data[6] = print_group_icon ($event["id_grupo"], true); if ($group_rep == 1) { - $data[7] = $event["event_rep"]; - } + $data[7] = $event["event_rep"]; + } else { if (!empty ($event["estado"])) { if ($event["id_usuario"] != '0' && $event["id_usuario"] != ''){ - $data[7] = ''.mb_substr ($event["id_usuario"],0,8).''; + $data[7] = ''.mb_substr ($event["id_usuario"],0,8).''; } else { - $data[7] = __('System'); + $data[7] = __('System'); } } else { @@ -556,16 +585,48 @@ if (!empty ($table->data)) { } echo ''; -} else { +} +else { echo '
'.__('No events').'
'; } echo ''; unset ($table); + +require_jquery_file ('bgiframe'); +require_jquery_file ('autocomplete'); ?>