2012-09-04 Miguel de Dios <miguel.dedios@artica.es>

* godmode/reporting/graph_builder.php,
	include/functions_modules.php, operation/agentes/ver_agente.php:
	cleaned source code style.
	
	* include/functions_html.php: fixed the function "html_print_select"
	when pass the selected as array
	(for example in multiple select box).
	
	* godmode/reporting/reporting_builder.item_editor.php,
	include/functions_reports.php: into the function "get_report_name"
	added parameter $template to get type for content template. And the
	function "get_report_types" renamed for "reports_get_report_types"
	and added the same parameter $template.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6931 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-09-04 14:04:46 +00:00
parent ecc3ffdbea
commit 0049260671
7 changed files with 95 additions and 44 deletions

View File

@ -1,3 +1,19 @@
2012-09-04 Miguel de Dios <miguel.dedios@artica.es>
* godmode/reporting/graph_builder.php,
include/functions_modules.php, operation/agentes/ver_agente.php:
cleaned source code style.
* include/functions_html.php: fixed the function "html_print_select"
when pass the selected as array
(for example in multiple select box).
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_reports.php: into the function "get_report_name"
added parameter $template to get type for content template. And the
function "get_report_types" renamed for "reports_get_report_types"
and added the same parameter $template.
2012-08-31 Sergio Martin <sergio.martin@artica.es> 2012-08-31 Sergio Martin <sergio.martin@artica.es>
* include/functions_graph.php * include/functions_graph.php

View File

@ -72,13 +72,20 @@ if ($add_graph) {
$events = get_parameter_post ("events"); $events = get_parameter_post ("events");
$stacked = get_parameter ("stacked", 0); $stacked = get_parameter ("stacked", 0);
$period = get_parameter_post ("period"); $period = get_parameter_post ("period");
// Create graph // Create graph
$values = array( 'id_user' => $config['id_user'], 'name' => $name, 'description' => $description, $values = array(
'period' => $period, 'width' => $width, 'height' => $height, 'id_user' => $config['id_user'],
'private' => 0, 'id_group' => $idGroup, 'events' => $events, 'name' => $name,
'stacked' => $stacked); 'description' => $description,
'period' => $period,
'width' => $width,
'height' => $height,
'private' => 0,
'id_group' => $idGroup,
'events' => $events,
'stacked' => $stacked);
if (trim($name) != "") { if (trim($name) != "") {
$id_graph = db_process_sql_insert('tgraph', $values); $id_graph = db_process_sql_insert('tgraph', $values);
if ($id_graph !== false) if ($id_graph !== false)

View File

@ -361,10 +361,10 @@ html_print_input_hidden('id_item', $idItem);
<td style=""> <td style="">
<?php <?php
if ($action == 'new') { if ($action == 'new') {
html_print_select(get_report_types(), 'type', $type, 'chooseType();', '', ''); html_print_select(reports_get_report_types(), 'type', $type, 'chooseType();', '', '');
} }
else { else {
echo get_report_name($type); echo reports_get_report_types($type);
echo '<input type="hidden" id="type" name="type" value="' . $type . '" />'; echo '<input type="hidden" id="type" name="type" value="' . $type . '" />';
} }
?> ?>
@ -480,7 +480,7 @@ html_print_input_hidden('id_item', $idItem);
if ($config['metaconsole'] == 1) { if ($config['metaconsole'] == 1) {
$connection = metaconsole_get_connection($server_name); $connection = metaconsole_get_connection($server_name);
$agent_name = ''; $agent_name = '';
if (metaconsole_load_external_db($connection) == NOERR) if (metaconsole_load_external_db($connection) == NOERR)
$agent_name = db_get_value_filter('nombre', 'tagente', array('id_agente' => $idAgent)); $agent_name = db_get_value_filter('nombre', 'tagente', array('id_agente' => $idAgent));
// Append server name // Append server name
@ -510,7 +510,7 @@ html_print_input_hidden('id_item', $idItem);
if ($config['metaconsole'] == 1) { if ($config['metaconsole'] == 1) {
$connection = metaconsole_get_connection($server_name); $connection = metaconsole_get_connection($server_name);
if (metaconsole_load_external_db($connection) == NOERR) { if (metaconsole_load_external_db($connection) == NOERR) {
$agent_name_temp = db_get_all_rows_sql($sql); $agent_name_temp = db_get_all_rows_sql($sql);

View File

@ -293,9 +293,15 @@ function html_print_select ($fields, $name, $selected = '', $script = '',
$nothing = __('None'); $nothing = __('None');
} }
$output .= '<option value="'.$nothing_value.'"'; $output .= '<option value="'.$nothing_value.'"';
if ($nothing_value == $selected) { if ($nothing_value == $selected) {
$output .= ' selected="selected"'; $output .= ' selected="selected"';
} }
else if (is_array ($selected)) {
if (in_array ($nothing_value, $selected)) {
$output .= ' selected="selected"';
}
}
$output .= '>'.$nothing.'</option>'; $output .= '>'.$nothing.'</option>';
} }

View File

@ -538,7 +538,17 @@ function modules_get_agentmodule ($id_agentmodule) {
$fields_[] = $field['column_name']; $fields_[] = $field['column_name'];
} }
$fields = implode(',', $fields_); $fields = implode(',', $fields_);
$result = db_process_sql("SELECT TO_NUMBER(MAX_CRITICAL) as max_critical, TO_NUMBER(MIN_CRITICAL) as min_critical, TO_NUMBER(MAX_WARNING) as max_warning, TO_NUMBER(MIN_WARNING) as min_warning, TO_NUMBER(POST_PROCESS) as post_process, " . $fields . " FROM tagente_modulo WHERE id_agente_modulo = " . $id_agentmodule);
$result = db_process_sql("
SELECT TO_NUMBER(MAX_CRITICAL) as max_critical,
TO_NUMBER(MIN_CRITICAL) as min_critical,
TO_NUMBER(MAX_WARNING) as max_warning,
TO_NUMBER(MIN_WARNING) as min_warning,
TO_NUMBER(POST_PROCESS) as post_process,
" . $fields . "
FROM tagente_modulo
WHERE id_agente_modulo = " . $id_agentmodule);
return $result[0]; return $result[0];
break; break;
} }
@ -565,7 +575,10 @@ function modules_get_agentmodule_id ($agentmodule_name, $agent_id) {
* @return bool true if is init and false if is not init * @return bool true if is init and false if is not init
*/ */
function modules_get_agentmodule_is_init ($id_agentmodule) { function modules_get_agentmodule_is_init ($id_agentmodule) {
$result = db_get_row_filter ('tagente_estado', array('id_agente_modulo' => $id_agentmodule), 'utimestamp'); $result = db_get_row_filter ('tagente_estado',
array('id_agente_modulo' => $id_agentmodule),
'utimestamp');
return (bool)$result['utimestamp']; return (bool)$result['utimestamp'];
} }
@ -589,7 +602,8 @@ function modules_get_agent_modules_count ($id_agent = 0) {
$filter = sprintf (" WHERE id_agente IN (%s)", implode (",", (array) $id_agent)); $filter = sprintf (" WHERE id_agente IN (%s)", implode (",", (array) $id_agent));
} }
return (int) db_get_sql ("SELECT COUNT(*) FROM tagente_modulo" . $filter); return (int) db_get_sql ("SELECT COUNT(*)
FROM tagente_modulo" . $filter);
} }
/** /**

View File

@ -411,11 +411,12 @@ function reports_delete_content ($id_report_content) {
* Get report type name from type id. * Get report type name from type id.
* *
* @param int $type Type id of the report. * @param int $type Type id of the report.
* @param boolean $template Set true for to get types for templates. By default false.
* *
* @return string Report type name. * @return string Report type name.
*/ */
function get_report_name ($type) { function get_report_name ($type, $template = false) {
$types = get_report_types (); $types = reports_get_report_types ($template);
if (! isset ($types[$type])) if (! isset ($types[$type]))
return __('Unknown'); return __('Unknown');
@ -475,9 +476,11 @@ function get_report_type_data_source ($type) {
/** /**
* Get report types in an array. * Get report types in an array.
* *
* @param boolean $template Set true for to get types for templates. By default false.
*
* @return array An array with all the possible reports in Pandora where the array index is the report id. * @return array An array with all the possible reports in Pandora where the array index is the report id.
*/ */
function get_report_types () { function reports_get_report_types ($template = false) {
global $config; global $config;
$types = array (); $types = array ();
@ -487,7 +490,7 @@ function get_report_types () {
$types['simple_baseline_graph'] = array('optgroup' => __('Graphs'), $types['simple_baseline_graph'] = array('optgroup' => __('Graphs'),
'name' => __('Simple baseline graph')); 'name' => __('Simple baseline graph'));
$types['custom_graph'] = array('optgroup' => __('Graphs'), $types['custom_graph'] = array('optgroup' => __('Graphs'),
'name' => __('Custom graph')); 'name' => __('Custom graph'));
# Only pandora managers have access to the whole database # Only pandora managers have access to the whole database
if (check_acl ($config['id_user'], 0, "PM")) { if (check_acl ($config['id_user'], 0, "PM")) {
$types['sql_graph_vbar'] = array('optgroup' => __('Graphs'), $types['sql_graph_vbar'] = array('optgroup' => __('Graphs'),
@ -497,53 +500,57 @@ function get_report_types () {
$types['sql_graph_hbar'] = array('optgroup' => __('Graphs'), $types['sql_graph_hbar'] = array('optgroup' => __('Graphs'),
'name' => __('SQL horizonal bar graph')); 'name' => __('SQL horizonal bar graph'));
} }
if ($template) {
$types['automatic_graph'] = array('optgroup' => __('Graphs'),
'name' => __('Automatic combined Graph'));
}
$types['TTRT'] = array('optgroup' => __('ITIL'), $types['TTRT'] = array('optgroup' => __('ITIL'),
'name' => __('TTRT')); 'name' => __('TTRT'));
$types['TTO'] = array('optgroup' => __('ITIL'), $types['TTO'] = array('optgroup' => __('ITIL'),
'name' => __('TTO')); 'name' => __('TTO'));
$types['MTBF'] = array('optgroup' => __('ITIL'), $types['MTBF'] = array('optgroup' => __('ITIL'),
'name' => __('MTBF')); 'name' => __('MTBF'));
$types['MTTR'] = array('optgroup' => __('ITIL'), $types['MTTR'] = array('optgroup' => __('ITIL'),
'name' => __('MTTR')); 'name' => __('MTTR'));
$types['SLA'] = array('optgroup' => __('SLA'), $types['SLA'] = array('optgroup' => __('SLA'),
'name' => __('S.L.A.')); 'name' => __('S.L.A.'));
$types['prediction_date'] = array('optgroup' => __('Forecasting'), $types['prediction_date'] = array('optgroup' => __('Forecasting'),
'name' => __('Prediction date')); 'name' => __('Prediction date'));
$types['projection_graph'] = array('optgroup' => __('Forecasting'), $types['projection_graph'] = array('optgroup' => __('Forecasting'),
'name' => __('Projection graph')); 'name' => __('Projection graph'));
$types['avg_value'] = array('optgroup' => __('Modules'), $types['avg_value'] = array('optgroup' => __('Modules'),
'name' => __('Avg. Value')); 'name' => __('Avg. Value'));
$types['max_value'] = array('optgroup' => __('Modules'), $types['max_value'] = array('optgroup' => __('Modules'),
'name' => __('Max. Value')); 'name' => __('Max. Value'));
$types['min_value'] = array('optgroup' => __('Modules'), $types['min_value'] = array('optgroup' => __('Modules'),
'name' => __('Min. Value')); 'name' => __('Min. Value'));
$types['monitor_report'] = array('optgroup' => __('Modules'), $types['monitor_report'] = array('optgroup' => __('Modules'),
'name' => __('Monitor report')); 'name' => __('Monitor report'));
$types['database_serialized'] = array('optgroup' => __('Modules'), $types['database_serialized'] = array('optgroup' => __('Modules'),
'name' => __('Serialize data')); 'name' => __('Serialize data'));
$types['sumatory'] = array('optgroup' => __('Modules'), $types['sumatory'] = array('optgroup' => __('Modules'),
'name' => __('Summatory')); 'name' => __('Summatory'));
$types['general'] = array('optgroup' => __('Grouped'), $types['general'] = array('optgroup' => __('Grouped'),
'name' => __('General')); 'name' => __('General'));
$types['group_report'] = array('optgroup' => __('Grouped'), $types['group_report'] = array('optgroup' => __('Grouped'),
'name' => __('Group report')); 'name' => __('Group report'));
$types['exception'] = array('optgroup' => __('Grouped'), $types['exception'] = array('optgroup' => __('Grouped'),
'name' => __('Exception')); 'name' => __('Exception'));
if ($config['metaconsole'] != 1) if ($config['metaconsole'] != 1)
$types['agent_module'] = array('optgroup' => __('Grouped'), $types['agent_module'] = array('optgroup' => __('Grouped'),
'name' => __('Agents/Modules')); 'name' => __('Agents/Modules'));
@ -553,38 +560,38 @@ function get_report_types () {
'name' => __('SQL query')); 'name' => __('SQL query'));
} }
$types['top_n'] = array('optgroup' => __('Grouped'), $types['top_n'] = array('optgroup' => __('Grouped'),
'name' => __('Top n')); 'name' => __('Top n'));
$types['text'] = array('optgroup' => __('Text/HTML '), $types['text'] = array('optgroup' => __('Text/HTML '),
'name' => __ ('Text')); 'name' => __ ('Text'));
$types['url'] = array('optgroup' => __('Text/HTML '), $types['url'] = array('optgroup' => __('Text/HTML '),
'name' => __('Import text from URL')); 'name' => __('Import text from URL'));
$types['alert_report_module'] = array('optgroup' => __('Alerts'), $types['alert_report_module'] = array('optgroup' => __('Alerts'),
'name' => __('Alert report module')); 'name' => __('Alert report module'));
$types['alert_report_agent'] = array('optgroup' => __('Alerts'), $types['alert_report_agent'] = array('optgroup' => __('Alerts'),
'name' => __('Alert report agent')); 'name' => __('Alert report agent'));
$types['event_report_agent'] = array('optgroup' => __('Events'), $types['event_report_agent'] = array('optgroup' => __('Events'),
'name' => __('Event report agent')); 'name' => __('Event report agent'));
$types['event_report_module'] = array('optgroup' => __('Events'), $types['event_report_module'] = array('optgroup' => __('Events'),
'name' => __('Event report module')); 'name' => __('Event report module'));
$types['event_report_group'] = array('optgroup' => __('Events'), $types['event_report_group'] = array('optgroup' => __('Events'),
'name' => __('Event report group')); 'name' => __('Event report group'));
if($config['enterprise_installed']) { if($config['enterprise_installed']) {
$types['inventory'] = array('optgroup' => __('Inventory'), $types['inventory'] = array('optgroup' => __('Inventory'),
'name' => __('Inventory')); 'name' => __('Inventory'));
$types['inventory_changes'] = array('optgroup' => __('Inventory'), $types['inventory_changes'] = array('optgroup' => __('Inventory'),
'name' => __('Inventory changes')); 'name' => __('Inventory changes'));
} }
return $types; return $types;
} }
?> ?>

View File

@ -306,6 +306,7 @@ if (is_ajax ()) {
//$agent_modules['any_text'] = __('Any'); //$agent_modules['any_text'] = __('Any');
echo json_encode ($agent_modules); echo json_encode ($agent_modules);
return; return;
} }