diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index 17f0ea5bfe..19aee51f0f 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -274,18 +274,11 @@ function treeview_printTable($id_agente, $server_data = array()) { $url_hash = metaconsole_get_servers_url_hash($server_data); } - require_once ("include/functions_agents.php"); + require_once ($config["homedir"] . "/include/functions_agents.php"); require_once ($config["homedir"] . '/include/functions_graph.php'); - include_graphs_dependencies(); require_once ($config['homedir'] . '/include/functions_groups.php'); require_once ($config['homedir'] . '/include/functions_gis.php'); - - $agent = db_get_row ("tagente", "id_agente", $id_agente); - - if ($agent === false) { - ui_print_error_message(__('There was a problem loading agent')); - return; - } + include_graphs_dependencies(); $is_extra = enterprise_hook('policies_is_agent_extra_policy', array($id_agente)); @@ -300,11 +293,21 @@ function treeview_printTable($id_agente, $server_data = array()) { return; } - echo '
'; - echo ''; - //Agent name - echo ''; + $agent = db_get_row ("tagente", "id_agente", $id_agente); + if ($agent === false) { + ui_print_error_message(__('There was a problem loading agent')); + return; + } + + $table = new StdClass(); + $table->width = "100%"; + $table->style = array(); + $table->style['title'] = 'font-weight: bold;'; + $table->head = array(); + $table->data = array(); + + // Agent name if ($agent['disabled']) { $cellName = ""; } @@ -317,12 +320,13 @@ function treeview_printTable($id_agente, $server_data = array()) { if ($agent['disabled']) { $cellName .= ui_print_help_tip(__('Disabled'), true) . ""; } - - echo ''; - + + $row = array(); + $row['title'] = __('Agent name'); + $row['data'] = $cellName; + $table->data['name'] = $row; + //Addresses - echo ''; - echo ''; + $row = array(); + $row['title'] = __('IP Address'); + $row['data'] = $address; + $table->data['address'] = $row; // Agent Interval - echo ''; - echo ''; + $row = array(); + $row['title'] = __('Interval'); + $row['data'] = human_time_description_raw ($agent["intervalo"]); + $table->data['interval'] = $row; // Comments - echo ''; - echo ''; - + $row = array(); + $row['title'] = __('Description'); + $row['data'] = $agent["comentarios"]; + $table->data['description'] = $row; // Last contact - echo ''; + + $row = array(); + $row['title'] = __('Last contact') . " / " . __('Remote'); + $row['data'] = "$last_contact / $last_remote_contact"; + $table->data['contact'] = $row; // Next contact (agent) $progress = agents_get_next_contact($id_agente); - echo ''; - echo ''; + $row = array(); + $row['title'] = __('Next agent contact'); + $row['data'] = progress_bar($progress, 150, 20); + $table->data['next_contact'] = $row; //End of table - echo '
'.__('Agent name').''.$cellName.'
'.__('IP Address').''; $ips = array(); $addresses = agents_get_addresses ($id_agente); $address = agents_get_address($id_agente); @@ -333,95 +337,115 @@ function treeview_printTable($id_agente, $server_data = array()) { } } - echo $address; - if (!empty($addresses)) { - ui_print_help_tip(__('Other IP addresses').':
'.implode('
',$addresses)); + $address .= ui_print_help_tip(__('Other IP addresses').':
'.implode('
',$addresses), true); } - echo '
'.__('Interval').''.human_time_description_raw ($agent["intervalo"]).'
' . __('Description') . '' . $agent["comentarios"] . '
' . __('Last contact') . " / " . __('Remote') . ''; - - ui_print_timestamp ($agent["ultimo_contacto"]); - - echo " / "; - + $last_contact = ui_print_timestamp($agent["ultimo_contacto"], true); + if ($agent["ultimo_contacto_remoto"] == "01-01-1970 00:00:00") { - echo __('Never'); + $last_remote_contact = __('Never'); } else { - ui_print_timestamp ($agent["ultimo_contacto_remoto"]); + $last_remote_contact = ui_print_timestamp ($agent["ultimo_contacto_remoto"], true); } - echo '
'.__('Next agent contact').'' . progress_bar($progress, 150, 20) . '
'; - + $agent_table = html_print_table($table, true); + if (can_user_access_node () && check_acl ($config["id_user"], $agent["id_grupo"], "AW")) { - echo '
'; - echo '
'; - html_print_submit_button (__('Go to agent edition'), 'upd_button', false, 'class="sub config"'); - echo '
'; - echo '
'; + $go_to_agent = '
'; + $go_to_agent .= '
'; + $go_to_agent .= html_print_submit_button (__('Go to agent edition'), 'upd_button', false, 'class="sub config"', true); + $go_to_agent .= '
'; + $go_to_agent .= '
'; + + $agent_table .= $go_to_agent; } + $agent_table .= "
"; + + // print agent data toggle + ui_toggle($agent_table, __('Agent data'), '', false); + // Advanced data - $advanced = '
'; - $advanced .= ''; - + $table = new StdClass(); + $table->width = "100%"; + $table->style = array(); + $table->style['title'] = 'font-weight: bold;'; + $table->head = array(); + $table->data = array(); + // Agent version - $advanced .= ''; - $advanced .= ''; + $row = array(); + $row['title'] = __('Agent Version'); + $row['data'] = $agent["agent_version"]; + $table->data['agent_version'] = $row; // Position Information if ($config['activate_gis']) { $dataPositionAgent = gis_get_data_last_position_agent($agent['id_agente']); - $advanced .= ''; - $advanced .= ''; } // If the url description is setted if ($agent['url_address'] != '') { - $advanced .= ''; - $advanced .= ''; + $row = array(); + $row['title'] = __('Url address'); + $row['data'] = ''.$agent["url_address"].''; + $table->data['agent_address'] = $row; } // Timezone Offset if ($agent['timezone_offset'] != 0) { - $advanced .= ''; - $advanced .= ''; + $row = array(); + $row['title'] = __('Timezone Offset'); + $row['data'] = $agent["timezone_offset"]; + $table->data['agent_timezone_offset'] = $row; } // Custom fields @@ -431,39 +455,39 @@ function treeview_printTable($id_agente, $server_data = array()) { } if ($fields) { foreach ($fields as $field) { - $advanced .= ''; $custom_value = db_get_value_filter('description', 'tagent_custom_data', array('id_field' => $field['id_field'], 'id_agent' => $id_agente)); - if ($custom_value === false || $custom_value == '') { - $custom_value = '-'.__('empty').'-'; + if (!empty($custom_value)) { + $row = array(); + $row['title'] = $field['name'] . ui_print_help_tip (__('Custom field'), true); + $row['data'] = $custom_value; + $table->data['custom_field_'.$field['id_field']] = $row; } - $advanced .= ''; } } //End of table advanced - $advanced .= '
'.__('Agent Version'). ''.$agent["agent_version"].'
'.__('Position (Long, Lat)'). ''; - - if ($dataPositionAgent === false) { - $advanced .= __('There is no GIS data.'); - } - else { - $advanced .= ''; + if ($dataPositionAgent !== false) { + $position = ''; if ($dataPositionAgent['description'] != "") - $advanced .= $dataPositionAgent['description']; + $position .= $dataPositionAgent['description']; else - $advanced .= $dataPositionAgent['stored_longitude'].', '.$dataPositionAgent['stored_latitude']; - $advanced .= ""; + $position .= $dataPositionAgent['stored_longitude'].', '.$dataPositionAgent['stored_latitude']; + $position .= ""; + + $row = array(); + $row['title'] = __('Position (Long, Lat)'); + $row['data'] = $position; + $table->data['agent_position'] = $row; } - - $advanced .= '
'.__('Url address').'' . $agent["url_address"] . '
'.__('Timezone Offset'). ''.$agent["timezone_offset"].'
'.$field['name'] . ui_print_help_tip (__('Custom field'), true).''.$custom_value.'

'; + $table_advanced = html_print_table($table, true); + $table_advanced .= "
"; - ui_toggle($advanced, __('Advanced information')); + ui_toggle($table_advanced, __('Advanced information')); // Blank space below title, DONT remove this, this // Breaks the layout when Flash charts are enabled :-o //echo '
 
'; if ($config["agentaccess"]) { - $access_graph = '
'; + $access_graph = '
'; $access_graph .= graphic_agentaccess($id_agente, 290, 110, 86400, true); $access_graph .= '

'; ui_toggle($access_graph, __('Agent access rate (24h)')); } - $events_graph = '
'; + $events_graph = '
'; $events_graph .= graph_graphic_agentevents ($id_agente, 290, 15, 86400, '', true); - $events_graph .= '


'; + $events_graph .= '

'; ui_toggle($events_graph, __('Events (24h)')); - - echo '
'; return; }