2012-03-27 Sergio Martin <sergio.martin@artica.es>

* include/styles/images/ui-bg_highlight-soft_100_eeeeee_1x100.png
	include/functions_reporting.php
	include/functions.php
	include/constants.php
	include/functions_reports.php
	godmode/reporting/reporting_builder.list_items.php
	godmode/reporting/reporting_builder.php
	godmode/reporting/reporting_builder.item_editor.php: Clean code, 
	fix a baseline graph report, and add a new tipe of report item:
	inventory



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5836 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2012-03-27 07:44:54 +00:00
parent c46b9da534
commit 97edcb10f2
9 changed files with 613 additions and 450 deletions

@ -1,3 +1,16 @@
2012-03-27 Sergio Martin <sergio.martin@artica.es>
* include/styles/images/ui-bg_highlight-soft_100_eeeeee_1x100.png
include/functions_reporting.php
include/functions.php
include/constants.php
include/functions_reports.php
godmode/reporting/reporting_builder.list_items.php
godmode/reporting/reporting_builder.php
godmode/reporting/reporting_builder.item_editor.php: Clean code,
fix a baseline graph report, and add a new tipe of report item:
inventory
2012-03-26 Hirofumi Kosaka <kosaka@rworks.jp>
* include/functions_api.php: Fixed set_create_plugin_module

@ -317,6 +317,13 @@ switch ($action) {
$group = $item['id_group'];
$modulegroup = $item ['id_module_group'];
break;
case 'inventory':
$description = $item['description'];
$es = json_decode($item['external_source'], true);
$date = $es['date'];
$inventory_modules = $es['inventory_modules'];
$id_agents = $es['id_agents'];
break;
}
//Restore db connection
@ -441,7 +448,7 @@ html_print_input_hidden('id_item', $idItem);
<tr id="row_group" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('Group');?></td>
<td style="">
<?php html_print_select_groups($config['id_user'], "AR", true, 'combo_group', $group, 'extract_group_agents()');?>
<?php html_print_select_groups($config['id_user'], "AR", true, 'combo_group', $group, '');?>
</td>
</tr>
<tr id="row_module_group" style="" class="datos">
@ -482,6 +489,42 @@ html_print_input_hidden('id_item', $idItem);
?>
</td>
</tr>
<tr id="row_agent_multi" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('Agents'); ?></td>
<td>
<?php
$agents = inventory_get_agents();
$agents_select = array();
foreach($agents as $a) {
$agents_select[$a['id_agente']] = $a['nombre'];
}
html_print_select($agents_select, 'id_agents[]', $id_agents, $script = '', __('All'), -1, false, true, true, '', false, "min-width: 180px");
?>
</td>
</tr>
<tr id="row_module_multi" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('Modules'); ?></td>
<td>
<?php
html_print_select(array(), 'inventory_modules[]', '', $script = '', __('None'), 0, false, true, true, '', false, "min-width: 180px");
html_print_input_hidden('inventory_modules_selected',implode(',',$inventory_modules));
?>
</td>
</tr>
<tr id="row_date" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('Date'); ?></td>
<td style="max-width: 180px">
<?php
$dates = enterprise_hook('inventory_get_dates',array($idAgentModule, $idAgent, $id_group));
if($dates === ENTERPRISE_NOT_HOOK) {
$dates = array();
}
html_print_select($dates, 'date', '', '', __('Now'), 0, false, false, false, '', false, "min-width: 180px");
html_print_input_hidden('date_selected',$date);
?>
</td>
</tr>
<tr id="row_custom_graph" style="" class="datos">
<td style="vertical-align: top;"><?php echo __('Custom graph'); ?></td>
<td style="">
@ -841,6 +884,8 @@ function print_General_list($width, $action, $idItem = null) {
<span style="display: none" id="module_general_text"><?php echo __('Select an Agent first'); ?></span>
<?php
}
ui_require_javascript_file ('pandora_inventory', ENTERPRISE_DIR.'/include/javascript/');
?>
<script type="text/javascript">
@ -1025,7 +1070,7 @@ function addSLARow() {
if (data['correct']) {
row = $("#sla_template").clone();
$("#row", row).css('display', '');
$("#row", row).show();
$("#row", row).attr('id', 'sla_' + data['id']);
$(".agent_name", row).html(nameAgent);
$(".module_name", row).html(nameModule);
@ -1125,7 +1170,7 @@ function addGeneralRow() {
if (data['correct']) {
row = $("#general_template").clone();
$("#row", row).css('display', '');
$("#row", row).show();
$("#row", row).attr('id', 'general_' + data['id']);
$(".agent_name", row).html(nameAgent);
$(".module_name", row).html(nameModule);
@ -1160,283 +1205,316 @@ function addGeneralRow() {
function chooseType() {
type = $("#type").val();
$("#row_description").css('display', 'none');
$("#row_period").css('display', 'none');
$("#row_agent").css('display', 'none');
$("#row_module").css('display', 'none');
$("#row_period").css('display', 'none');
$("#row_period1").css('display', 'none');
$("#row_estimate").css('display', 'none');
$("#row_interval").css('display', 'none');
$("#row_custom_graph").css('display', 'none');
$("#row_text").css('display', 'none');
$("#row_query").css('display', 'none');
$("#row_header").css('display', 'none');
$("#row_custom").css('display', 'none');
$("#row_url").css('display', 'none');
$("#row_field_separator").css('display', 'none');
$("#row_line_separator").css('display', 'none');
$("#sla_list").css('display', 'none');
$("#row_custom_example").css('display', 'none');
$("#row_group").css('display', 'none');
$("#row_working_time").css('display', 'none');
$("#row_only_display_wrong").css('display', 'none');
$("#row_combo_module").css('display', 'none');
$("#row_only_display_wrong").css('display', 'none');
$("#row_group_by_agent").css('display', 'none');
$("#general_list").css('display', 'none');
$("#row_order_uptodown").css('display', 'none');
$("#row_show_resume").css('display', 'none');
$("#row_show_graph").css('display', 'none');
$("#row_max_min_avg").css('display', 'none');
$("#row_quantity").css('display', 'none');
$("#row_exception_condition_value").css('display', 'none');
$("#row_exception_condition").css('display', 'none');
$("#row_show_in_two_columns").css('display', 'none');
$("#row_show_in_landscape").css('display', 'none');
$("#row_module_group").css('display', 'none');
$("#row_servers").css('display', 'none');
$("#row_sort").css('display', 'none');
$("#row_description").hide();
$("#row_period").hide();
$("#row_agent").hide();
$("#row_module").hide();
$("#row_period").hide();
$("#row_period1").hide();
$("#row_estimate").hide();
$("#row_interval").hide();
$("#row_custom_graph").hide();
$("#row_text").hide();
$("#row_query").hide();
$("#row_header").hide();
$("#row_custom").hide();
$("#row_url").hide();
$("#row_field_separator").hide();
$("#row_line_separator").hide();
$("#sla_list").hide();
$("#row_custom_example").hide();
$("#row_group").hide();
$("#row_working_time").hide();
$("#row_only_display_wrong").hide();
$("#row_combo_module").hide();
$("#row_only_display_wrong").hide();
$("#row_group_by_agent").hide();
$("#general_list").hide();
$("#row_order_uptodown").hide();
$("#row_show_resume").hide();
$("#row_show_graph").hide();
$("#row_max_min_avg").hide();
$("#row_quantity").hide();
$("#row_exception_condition_value").hide();
$("#row_exception_condition").hide();
$("#row_show_in_two_columns").hide();
$("#row_show_in_landscape").hide();
$("#row_module_group").hide();
$("#row_servers").hide();
$("#row_sort").hide();
$("#row_date").hide();
$("#row_agent_multi").hide();
$("#row_module_multi").hide();
switch (type) {
case 'event_report_group':
$("#row_description").css('display', '');
$("#row_period").css('display', '');
$("#row_group").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_description").show();
$("#row_period").show();
$("#row_group").show();
$("#row_show_in_two_columns").show();
break;
case 'simple_graph':
case 'simple_baseline_graph':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_module").css('display', '');
$("#row_period").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_show_in_landscape").css('display', '');
$("#row_description").show();
$("#row_agent").show();
$("#row_module").show();
$("#row_period").show();
$("#row_show_in_two_columns").show();
$("#row_show_in_landscape").show();
break;
case 'projection_graph':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_module").css('display', '');
$("#row_period1").css('display', '');
$("#row_estimate").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_show_in_landscape").css('display', '');
$("#row_description").show();
$("#row_agent").show();
$("#row_module").show();
$("#row_period1").show();
$("#row_estimate").show();
$("#row_show_in_two_columns").show();
$("#row_show_in_landscape").show();
break;
case 'prediction_date':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_period1").css('display', '');
$("#row_module").css('display', '');
$("#row_interval").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_description").show();
$("#row_agent").show();
$("#row_period1").show();
$("#row_module").show();
$("#row_interval").show();
$("#row_show_in_two_columns").show();
break;
case 'custom_graph':
$("#row_description").css('display', '');
$("#row_period").css('display', '');
$("#row_custom_graph").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_show_in_landscape").css('display', '');
$("#row_description").show();
$("#row_period").show();
$("#row_custom_graph").show();
$("#row_show_in_two_columns").show();
$("#row_show_in_landscape").show();
break;
case 'SLA':
$("#row_description").css('display', '');
$("#row_period").css('display', '');
$("#sla_list").css('display', '');
$("#row_working_time").css('display', '');
$("#row_only_display_wrong").css('display', '');
$("#row_show_graph").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_sort").css('display', '');
$("#row_description").show();
$("#row_period").show();
$("#sla_list").show();
$("#row_working_time").show();
$("#row_only_display_wrong").show();
$("#row_show_graph").show();
$("#row_show_in_two_columns").show();
$("#row_sort").show();
break;
case 'monitor_report':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_module").css('display', '');
$("#row_period").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_description").show();
$("#row_agent").show();
$("#row_module").show();
$("#row_period").show();
$("#row_show_in_two_columns").show();
break;
case 'avg_value':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_module").css('display', '');
$("#row_period").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_description").show();
$("#row_agent").show();
$("#row_module").show();
$("#row_period").show();
$("#row_show_in_two_columns").show();
break;
case 'max_value':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_module").css('display', '');
$("#row_period").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_description").show();
$("#row_agent").show();
$("#row_module").show();
$("#row_period").show();
$("#row_show_in_two_columns").show();
break;
case 'min_value':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_module").css('display', '');
$("#row_period").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_description").show();
$("#row_agent").show();
$("#row_module").show();
$("#row_period").show();
$("#row_show_in_two_columns").show();
break;
case 'sumatory':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_module").css('display', '');
$("#row_period").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_description").show();
$("#row_agent").show();
$("#row_module").show();
$("#row_period").show();
$("#row_show_in_two_columns").show();
break;
case 'agent_detailed':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_period").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_description").show();
$("#row_agent").show();
$("#row_period").show();
$("#row_show_in_two_columns").show();
break;
case 'text':
$("#row_description").css('display', '');
$("#row_text").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_description").show();
$("#row_text").show();
$("#row_show_in_two_columns").show();
break;
case 'sql':
$("#row_description").css('display', '');
$("#row_query").css('display', '');
$("#row_header").css('display', '');
$("#row_custom").css('display', '');
$("#row_custom_example").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_servers").css('display', '');
$("#row_description").show();
$("#row_query").show();
$("#row_header").show();
$("#row_custom").show();
$("#row_custom_example").show();
$("#row_show_in_two_columns").show();
$("#row_servers").show();
break;
case 'sql_graph_pie':
$("#row_description").css('display', '');
$("#row_query").css('display', '');
$("#row_custom").css('display', '');
$("#row_custom_example").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_show_in_landscape").css('display', '');
$("#row_servers").css('display', '');
$("#row_description").show();
$("#row_query").show();
$("#row_custom").show();
$("#row_custom_example").show();
$("#row_show_in_two_columns").show();
$("#row_show_in_landscape").show();
$("#row_servers").show();
break;
case 'sql_graph_hbar':
$("#row_description").css('display', '');
$("#row_query").css('display', '');
$("#row_custom").css('display', '');
$("#row_custom_example").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_show_in_landscape").css('display', '');
$("#row_servers").css('display', '');
$("#row_description").show();
$("#row_query").show();
$("#row_custom").show();
$("#row_custom_example").show();
$("#row_show_in_two_columns").show();
$("#row_show_in_landscape").show();
$("#row_servers").show();
break;
case 'sql_graph_vbar':
$("#row_description").css('display', '');
$("#row_query").css('display', '');
$("#row_custom").css('display', '');
$("#row_custom_example").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_show_in_landscape").css('display', '');
$("#row_servers").css('display', '');
$("#row_description").show();
$("#row_query").show();
$("#row_custom").show();
$("#row_custom_example").show();
$("#row_show_in_two_columns").show();
$("#row_show_in_landscape").show();
$("#row_servers").show();
break;
case 'url':
$("#row_description").css('display', '');
$("#row_url").css('display', '');
$("#row_description").show();
$("#row_url").show();
break;
case 'database_serialized':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_module").css('display', '');
$("#row_header").css('display', '');
$("#row_field_separator").css('display', '');
$("#row_line_separator").css('display', '');
$("#row_period").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_description").show();
$("#row_agent").show();
$("#row_module").show();
$("#row_header").show();
$("#row_field_separator").show();
$("#row_line_separator").show();
$("#row_period").show();
$("#row_show_in_two_columns").show();
break;
case 'TTRT':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_module").css('display', '');
$("#row_period").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_description").show();
$("#row_agent").show();
$("#row_module").show();
$("#row_period").show();
$("#row_show_in_two_columns").show();
break;
case 'TTO':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_module").css('display', '');
$("#row_period").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_description").show();
$("#row_agent").show();
$("#row_module").show();
$("#row_period").show();
$("#row_show_in_two_columns").show();
break;
case 'MTBF':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_module").css('display', '');
$("#row_period").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_description").show();
$("#row_agent").show();
$("#row_module").show();
$("#row_period").show();
$("#row_show_in_two_columns").show();
break;
case 'MTTR':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_module").css('display', '');
$("#row_period").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_description").show();
$("#row_agent").show();
$("#row_module").show();
$("#row_period").show();
$("#row_show_in_two_columns").show();
break;
case 'alert_report_module':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_module").css('display', '');
$("#row_period").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_description").show();
$("#row_agent").show();
$("#row_module").show();
$("#row_period").show();
$("#row_show_in_two_columns").show();
break;
case 'alert_report_agent':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_period").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_description").show();
$("#row_agent").show();
$("#row_period").show();
$("#row_show_in_two_columns").show();
break;
case 'event_report_agent':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_period").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_description").show();
$("#row_agent").show();
$("#row_period").show();
$("#row_show_in_two_columns").show();
break;
case 'event_report_module':
$("#row_description").css('display', '');
$("#row_agent").css('display', '');
$("#row_module").css('display', '');
$("#row_period").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_description").show();
$("#row_agent").show();
$("#row_module").show();
$("#row_period").show();
$("#row_show_in_two_columns").show();
break;
case 'general':
$("#row_description").css('display', '');
$("#row_group_by_agent").css('display', '');
$("#row_period").css('display', '');
$("#general_list").css('display', '');
$("#row_order_uptodown").css('display', '');
$("#row_show_resume").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_description").show();
$("#row_group_by_agent").show();
$("#row_period").show();
$("#general_list").show();
$("#row_order_uptodown").show();
$("#row_show_resume").show();
$("#row_show_in_two_columns").show();
break;
case 'group_report':
$("#row_group").css('display', '');
$("#row_group").show();
break;
case 'top_n':
$("#row_description").css('display', '');
$("#row_period").css('display', '');
$("#row_max_min_avg").css('display', '');
$("#row_quantity").css('display', '');
$("#general_list").css('display', '');
$("#row_order_uptodown").css('display', '');
$("#row_show_resume").css('display', '');
$("#row_show_graph").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_description").show();
$("#row_period").show();
$("#row_max_min_avg").show();
$("#row_quantity").show();
$("#general_list").show();
$("#row_order_uptodown").show();
$("#row_show_resume").show();
$("#row_show_graph").show();
$("#row_show_in_two_columns").show();
break;
case 'exception':
$("#row_description").css('display', '');
$("#row_period").css('display', '');
$("#general_list").css('display', '');
$("#row_exception_condition_value").css('display', '');
$("#row_exception_condition").css('display', '');
$("#row_order_uptodown").css('display', '');
$("#row_show_resume").css('display', '');
$("#row_show_graph").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_description").show();
$("#row_period").show();
$("#general_list").show();
$("#row_exception_condition_value").show();
$("#row_exception_condition").show();
$("#row_order_uptodown").show();
$("#row_show_resume").show();
$("#row_show_graph").show();
$("#row_show_in_two_columns").show();
break;
case 'agent_module':
$("#row_description").css('display', '');
$("#row_group").css('display', '');
$("#row_module_group").css('display', '');
$("#row_description").show();
$("#row_group").show();
$("#row_module_group").show();
break;
case 'inventory':
$("#row_description").show();
$("#row_group").show();
$("#row_agent_multi").show();
$("#row_module_multi").show();
$("#row_date").show();
$("#row_show_in_two_columns").show();
$("#id_agents").change(agent_changed_by_multiple_agents_inventory);
$("#id_agents").trigger('change');
$("#combo_group").change(function() {
$('#hidden-date_selected').val('');
updateInventoryDates();
updateAgents($(this).val());
});
$("#id_agents").change(function() {
$('#hidden-date_selected').val('');
updateInventoryDates();
});
$("#inventory_modules").change(function() {
$('#hidden-date_selected').val('');
updateInventoryDates();
});
updateInventoryDates();
break;
case 'inventory_changes':
break;
}
}
</script>

@ -295,7 +295,12 @@ foreach ($items as $item) {
}
}
$row[4] = human_time_description_raw($item['period']);
if($item['period'] > 0) {
$row[4] = human_time_description_raw($item['period']);
}
else {
$row[4] = '-';
}
if ($item['description'] == '') {
$row[5] = '-';

@ -318,37 +318,50 @@ switch ($action) {
$values['type'] = get_parameter('type', null);
// Added support for projection graphs, prediction date and SLA reports
// 'top_n_value','top_n' and 'text' fields will be reused for these types of report
if ($values['type'] == 'projection_graph'){
$values['period'] = get_parameter('period1');
$values['top_n_value'] = get_parameter('period2');
$values['text'] = get_parameter('text');
$good_format = true;
}else if ($values['type'] == 'prediction_date'){
$values['period'] = get_parameter('period1');
$values['top_n'] = get_parameter('radiobutton_max_min_avg');
$values['top_n_value'] = get_parameter('quantity');
$interval_max = get_parameter('max_interval');
$interval_min = get_parameter('min_interval');
// Checks intervals fields
if (preg_match('/^(\-)*[0-9]*\.?[0-9]+$/', $interval_max) and preg_match('/^(\-)*[0-9]*\.?[0-9]+$/', $interval_min)){
switch ($values['type']) {
case 'projection_graph':
$values['period'] = get_parameter('period1');
$values['top_n_value'] = get_parameter('period2');
$values['text'] = get_parameter('text');
$good_format = true;
break;
case 'prediction_date':
$values['period'] = get_parameter('period1');
$values['top_n'] = get_parameter('radiobutton_max_min_avg');
$values['top_n_value'] = get_parameter('quantity');
$interval_max = get_parameter('max_interval');
$interval_min = get_parameter('min_interval');
// Checks intervals fields
if (preg_match('/^(\-)*[0-9]*\.?[0-9]+$/', $interval_max) and preg_match('/^(\-)*[0-9]*\.?[0-9]+$/', $interval_min)){
$good_format = true;
}
$intervals = get_parameter('max_interval') . ';' . get_parameter('min_interval');
$values['text'] = $intervals;
break;
case 'SLA':
$values['period'] = get_parameter('period');
$values['top_n'] = get_parameter('combo_sla_sort_options',0);
$values['top_n_value'] = get_parameter('quantity');
$values['text'] = get_parameter('text');
$good_format = true;
break;
case 'inventory':
$values['period'] = 0;
$es['id_agents'] = get_parameter('id_agents');
$es['inventory_modules'] = get_parameter('inventory_modules');
$es['date'] = get_parameter('date');
$description = get_parameter('description');
$values['external_source'] = json_encode($es);
$good_format = true;
break;
default:
$values['period'] = get_parameter('period');
$values['top_n'] = get_parameter('radiobutton_max_min_avg',0);
$values['top_n_value'] = get_parameter('quantity');
$values['text'] = get_parameter('text');
$good_format = true;
}
$intervals = get_parameter('max_interval') . ';' . get_parameter('min_interval');
$values['text'] = $intervals;
}else if ($values['type'] == 'SLA'){
$values['period'] = get_parameter('period');
$values['top_n'] = get_parameter('combo_sla_sort_options', 0);
$values['top_n_value'] = get_parameter('quantity');
$values['text'] = get_parameter('text');
$good_format = true;
}
else {
$values['period'] = get_parameter('period');
$values['top_n'] = get_parameter('radiobutton_max_min_avg');
$values['top_n_value'] = get_parameter('quantity');
$values['text'] = get_parameter('text');
$good_format = true;
}
$values['id_agent'] = get_parameter('id_agent');
$values['id_gs'] = get_parameter('id_custom_graph');
$values['id_agent_module'] = get_parameter('id_agent_module');
@ -422,39 +435,49 @@ switch ($action) {
$values['description'] = get_parameter('description');
// Support for projection graph, prediction date and SLA reports
// 'top_n_value', 'top_n' and 'text' fields will be reused for these types of report
if ($values['type'] == 'projection_graph') {
$values['period'] = get_parameter('period1');
$values['top_n_value'] = get_parameter('period2');
$values['text'] = get_parameter('text');
$good_format = true;
}
else if ($values['type'] == 'prediction_date') {
$values['period'] = get_parameter('period1');
$values['top_n'] = get_parameter('radiobutton_max_min_avg');
$values['top_n_value'] = get_parameter('quantity');
$interval_max = get_parameter('max_interval');
$interval_min = get_parameter('min_interval');
// Checks intervals fields
if (preg_match('/^(\-)*[0-9]*\.?[0-9]+$/', $interval_max) and preg_match('/^(\-)*[0-9]*\.?[0-9]+$/', $interval_min)){
switch ($values['type']) {
case 'projection_graph':
$values['period'] = get_parameter('period1');
$values['top_n_value'] = get_parameter('period2');
$values['text'] = get_parameter('text');
$good_format = true;
break;
case 'prediction_date':
$values['period'] = get_parameter('period1');
$values['top_n'] = get_parameter('radiobutton_max_min_avg');
$values['top_n_value'] = get_parameter('quantity');
$interval_max = get_parameter('max_interval');
$interval_min = get_parameter('min_interval');
// Checks intervals fields
if (preg_match('/^(\-)*[0-9]*\.?[0-9]+$/', $interval_max) and preg_match('/^(\-)*[0-9]*\.?[0-9]+$/', $interval_min)){
$good_format = true;
}
$intervals = get_parameter('max_interval') . ';' . get_parameter('min_interval');
$values['text'] = $intervals;
break;
case 'SLA':
$values['period'] = get_parameter('period');
$values['top_n'] = get_parameter('combo_sla_sort_options',0);
$values['top_n_value'] = get_parameter('quantity');
$values['text'] = get_parameter('text');
$good_format = true;
break;
case 'inventory':
$values['period'] = 0;
$es['id_agents'] = get_parameter('id_agents');
$es['inventory_modules'] = get_parameter('inventory_modules');
$es['date'] = get_parameter('date');
$values['external_source'] = json_encode($es);
$good_format = true;
break;
default:
$values['period'] = get_parameter('period');
$values['top_n'] = get_parameter('radiobutton_max_min_avg',0);
$values['top_n_value'] = get_parameter('quantity');
$values['text'] = get_parameter('text');
$good_format = true;
}
$intervals = get_parameter('max_interval') . ';' . get_parameter('min_interval');
$values['text'] = $intervals;
}
else if ($values['type'] == 'SLA') {
$values['period'] = get_parameter('period');
$values['top_n'] = get_parameter('combo_sla_sort_options',0);
$values['top_n_value'] = get_parameter('quantity');
$values['text'] = get_parameter('text');
$good_format = true;
}
else {
$values['period'] = get_parameter('period');
$values['top_n'] = get_parameter('radiobutton_max_min_avg',0);
$values['top_n_value'] = get_parameter('quantity');
$values['text'] = get_parameter('text');
$good_format = true;
}
$values['id_agent'] = get_parameter('id_agent');
$values['id_gs'] = get_parameter('id_custom_graph');
$values['id_agent_module'] = get_parameter('id_agent_module');

@ -37,6 +37,7 @@ define ('ERR_INCOMPLETE', -30000);
define ('ERR_DB', -40000);
define ('ERR_FILE', -50000);
define ('ERR_NOCHANGES', -60000);
define ('ERR_NODATA', -70000);
/* Visual console constants */
define('MIN_WIDTH',300);
@ -60,4 +61,10 @@ define('SECONDS_1YEAR',31104000);
define('SECONDS_2YEARS',62208000);
define('SECONDS_3YEARS',93312000);
/* Separator constats */
define('SEPARATOR_COLUMN', ';');
define('SEPARATOR_ROW', chr(10)); //chr(10) = '\n'
define('SEPARATOR_COLUMN_CSV', "#");
define('SEPARATOR_ROW_CSV', "@\n");
?>

@ -730,181 +730,6 @@ function get_alert_times ($row2) {
return substr ($time_from_table, 0, 5)." - ".substr ($time_to_table, 0, 5);
}
/**
* Get report types in an array.
*
* @return array An array with all the possible reports in Pandora where the array index is the report id.
*/
function get_report_types () {
global $config;
$types = array ();
$types['simple_graph'] = array('optgroup' => __('Graphs'),
'name' => __('Simple graph'));
if($config['enterprise_installed']) {
$types['simple_baseline_graph'] = array('optgroup' => __('Graphs'),
'name' => __('Simple baseline graph'));
}
$types['custom_graph'] = array('optgroup' => __('Graphs'),
'name' => __('Custom graph'));
# Only pandora managers have access to the whole database
if (check_acl ($config['id_user'], 0, "PM")) {
$types['sql_graph_vbar'] = array('optgroup' => __('Graphs'),
'name' => __('SQL vertical bar graph'));
$types['sql_graph_pie'] = array('optgroup' => __('Graphs'),
'name' => __('SQL pie graph'));
$types['sql_graph_hbar'] = array('optgroup' => __('Graphs'),
'name' => __('SQL horizonal bar graph'));
}
$types['TTRT'] = array('optgroup' => __('ITIL'),
'name' => __('TTRT'));
$types['TTO'] = array('optgroup' => __('ITIL'),
'name' => __('TTO'));
$types['MTBF'] = array('optgroup' => __('ITIL'),
'name' => __('MTBF'));
$types['MTTR'] = array('optgroup' => __('ITIL'),
'name' => __('MTTR'));
$types['SLA'] = array('optgroup' => __('SLA'),
'name' => __('S.L.A.'));
$types['prediction_date'] = array('optgroup' => __('Forecating'),
'name' => __('Prediction date'));
$types['projection_graph'] = array('optgroup' => __('Forecating'),
'name' => __('Projection graph'));
$types['avg_value'] = array('optgroup' => __('Modules'),
'name' => __('Avg. Value'));
$types['max_value'] = array('optgroup' => __('Modules'),
'name' => __('Max. Value'));
$types['min_value'] = array('optgroup' => __('Modules'),
'name' => __('Min. Value'));
$types['monitor_report'] = array('optgroup' => __('Modules'),
'name' => __('Monitor report'));
$types['database_serialized'] = array('optgroup' => __('Modules'),
'name' => __('Serialize data'));
$types['sumatory'] = array('optgroup' => __('Modules'),
'name' => __('Summatory'));
$types['general'] = array('optgroup' => __('Grouped'),
'name' => __('General'));
$types['group_report'] = array('optgroup' => __('Grouped'),
'name' => __('Group report'));
$types['exception'] = array('optgroup' => __('Grouped'),
'name' => __('Exception'));
if ($config['metaconsole'] != 1)
$types['agent_module'] = array('optgroup' => __('Grouped'),
'name' => __('Agents/Modules'));
# Only pandora managers have access to the whole database
if (check_acl ($config['id_user'], 0, "PM")) {
$types['sql'] = array('optgroup' => __('Grouped'),
'name' => __('SQL query'));
}
$types['top_n'] = array('optgroup' => __('Grouped'),
'name' => __('Top n'));
$types['text'] = array('optgroup' => __('Text/HTML '),
'name' => __ ('Text'));
$types['url'] = array('optgroup' => __('Text/HTML '),
'name' => __('Import text from URL'));
$types['alert_report_module'] = array('optgroup' => __('Alerts'),
'name' => __('Alert report module'));
$types['alert_report_agent'] = array('optgroup' => __('Alerts'),
'name' => __('Alert report agent'));
$types['event_report_agent'] = array('optgroup' => __('Events'),
'name' => __('Event report agent'));
$types['event_report_module'] = array('optgroup' => __('Events'),
'name' => __('Event report module'));
$types['event_report_group'] = array('optgroup' => __('Events'),
'name' => __('Event report group'));
return $types;
}
/**
* Get report type name from type id.
*
* @param int $type Type id of the report.
*
* @return string Report type name.
*/
function get_report_name ($type) {
$types = get_report_types ();
if (! isset ($types[$type]))
return __('Unknown');
return $types[$type]['name'];
}
/**
* Get report type data source from type id.
*
* TODO: Better documentation as to what this function does
*
* @param mixed $type Type id or type name of the report.
*
* @return string Report type name.
*/
function get_report_type_data_source ($type) {
switch ($type) {
case 1:
case 'simple_graph':
case 6:
case 'monitor_report':
case 7:
case 'avg_value':
case 8:
case 'max_value':
case 9:
case 'min_value':
case 10:
case 'sumatory':
case 'agent_detailed_event':
return 'module';
break;
case 2:
case 'custom_graph':
return 'custom-graph';
break;
case 3:
case 'SLA':
case 4:
case 'event_report':
case 5:
case 'alert_report':
case 11:
case 'general_group_report':
case 12:
case 'monitor_health':
case 13:
case 'agents_detailed':
return 'agent-group';
break;
}
return 'unknown';
}
/**
* Checks if a module is of type "data"
*

@ -32,6 +32,7 @@ include_once($config['homedir'] . "/include/functions_events.php");
include_once($config['homedir'] . "/include/functions_alerts.php");
include_once($config['homedir'] . '/include/functions_users.php');
enterprise_include_once ('include/functions_metaconsole.php');
enterprise_include_once ('include/functions_inventory.php');
include_once($config['homedir'] . "/include/functions_forecast.php");
include_once($config['homedir'] . "/include/functions_ui.php");
@ -3760,11 +3761,13 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$data_top_values['agent_name'] = $agent_name;
$data_top_values['module_name'] = $module_name;
$data_top_values['id_agent_module'] = $id_agent_module;
$data_top_values['units'] = $units;
array_splice ($data_top, $top_n_value);
array_splice ($agent_name, $top_n_value);
array_splice ($module_name, $top_n_value);
array_splice ($id_agent_module, $top_n_value);
array_splice ($units, $top_n_value);
switch ($order_uptodown) {
//Descending
@ -4387,6 +4390,34 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$data[0] = $table_data;
array_push ($table->data, $data);
break;
case 'inventory':
reporting_header_content($mini, $content, $report, $table, __('Inventory'));
$es = json_decode($content['external_source'], true);
$id_agent = $es['id_agents'];
$module_name = $es['inventory_modules'];
$date = $es['date'];
$description = $content['description'];
$data = array ();
$table->colspan[1][0] = 2;
$table->colspan[2][0] = 2;
if($description != '') {
$data[0] = $description;
array_push ($table->data, $data);
}
$inventory_data = inventory_get_data((array)$id_agent,0,$date,'',false,(array)$module_name);
if ($inventory_data == ERR_NODATA) {
$inventory_data = "<div class='nf'>".__('No data found.')."</div>";
$inventory_data .= "&nbsp;</td></tr><tr><td>";
}
$data[0] = $inventory_data;
array_push ($table->data, $data);
break;
}
//Restore dbconnection
if (($config ['metaconsole'] == 1) && $server_name != '') {

@ -379,4 +379,185 @@ function reports_delete_content ($id_report_content) {
return (@db_process_sql_delete ('treport_content',
array ('id_rc' => $id_report_content))) !== false;
}
/**
* Get report type name from type id.
*
* @param int $type Type id of the report.
*
* @return string Report type name.
*/
function get_report_name ($type) {
$types = get_report_types ();
if (! isset ($types[$type]))
return __('Unknown');
return $types[$type]['name'];
}
/**
* Get report type data source from type id.
*
* TODO: Better documentation as to what this function does
*
* @param mixed $type Type id or type name of the report.
*
* @return string Report type name.
*/
function get_report_type_data_source ($type) {
switch ($type) {
case 1:
case 'simple_graph':
case 6:
case 'monitor_report':
case 7:
case 'avg_value':
case 8:
case 'max_value':
case 9:
case 'min_value':
case 10:
case 'sumatory':
case 'agent_detailed_event':
return 'module';
break;
case 2:
case 'custom_graph':
return 'custom-graph';
break;
case 3:
case 'SLA':
case 4:
case 'event_report':
case 5:
case 'alert_report':
case 11:
case 'general_group_report':
case 12:
case 'monitor_health':
case 13:
case 'agents_detailed':
return 'agent-group';
break;
}
return 'unknown';
}
/**
* Get report types in an array.
*
* @return array An array with all the possible reports in Pandora where the array index is the report id.
*/
function get_report_types () {
global $config;
$types = array ();
$types['simple_graph'] = array('optgroup' => __('Graphs'),
'name' => __('Simple graph'));
$types['simple_baseline_graph'] = array('optgroup' => __('Graphs'),
'name' => __('Simple baseline graph'));
$types['custom_graph'] = array('optgroup' => __('Graphs'),
'name' => __('Custom graph'));
# Only pandora managers have access to the whole database
if (check_acl ($config['id_user'], 0, "PM")) {
$types['sql_graph_vbar'] = array('optgroup' => __('Graphs'),
'name' => __('SQL vertical bar graph'));
$types['sql_graph_pie'] = array('optgroup' => __('Graphs'),
'name' => __('SQL pie graph'));
$types['sql_graph_hbar'] = array('optgroup' => __('Graphs'),
'name' => __('SQL horizonal bar graph'));
}
$types['TTRT'] = array('optgroup' => __('ITIL'),
'name' => __('TTRT'));
$types['TTO'] = array('optgroup' => __('ITIL'),
'name' => __('TTO'));
$types['MTBF'] = array('optgroup' => __('ITIL'),
'name' => __('MTBF'));
$types['MTTR'] = array('optgroup' => __('ITIL'),
'name' => __('MTTR'));
$types['SLA'] = array('optgroup' => __('SLA'),
'name' => __('S.L.A.'));
$types['prediction_date'] = array('optgroup' => __('Forecating'),
'name' => __('Prediction date'));
$types['projection_graph'] = array('optgroup' => __('Forecating'),
'name' => __('Projection graph'));
$types['avg_value'] = array('optgroup' => __('Modules'),
'name' => __('Avg. Value'));
$types['max_value'] = array('optgroup' => __('Modules'),
'name' => __('Max. Value'));
$types['min_value'] = array('optgroup' => __('Modules'),
'name' => __('Min. Value'));
$types['monitor_report'] = array('optgroup' => __('Modules'),
'name' => __('Monitor report'));
$types['database_serialized'] = array('optgroup' => __('Modules'),
'name' => __('Serialize data'));
$types['sumatory'] = array('optgroup' => __('Modules'),
'name' => __('Summatory'));
$types['general'] = array('optgroup' => __('Grouped'),
'name' => __('General'));
$types['group_report'] = array('optgroup' => __('Grouped'),
'name' => __('Group report'));
$types['exception'] = array('optgroup' => __('Grouped'),
'name' => __('Exception'));
if ($config['metaconsole'] != 1)
$types['agent_module'] = array('optgroup' => __('Grouped'),
'name' => __('Agents/Modules'));
# Only pandora managers have access to the whole database
if (check_acl ($config['id_user'], 0, "PM")) {
$types['sql'] = array('optgroup' => __('Grouped'),
'name' => __('SQL query'));
}
$types['top_n'] = array('optgroup' => __('Grouped'),
'name' => __('Top n'));
$types['text'] = array('optgroup' => __('Text/HTML '),
'name' => __ ('Text'));
$types['url'] = array('optgroup' => __('Text/HTML '),
'name' => __('Import text from URL'));
$types['alert_report_module'] = array('optgroup' => __('Alerts'),
'name' => __('Alert report module'));
$types['alert_report_agent'] = array('optgroup' => __('Alerts'),
'name' => __('Alert report agent'));
$types['event_report_agent'] = array('optgroup' => __('Events'),
'name' => __('Event report agent'));
$types['event_report_module'] = array('optgroup' => __('Events'),
'name' => __('Event report module'));
$types['event_report_group'] = array('optgroup' => __('Events'),
'name' => __('Event report group'));
if($config['enterprise_installed']) {
$types['inventory'] = array('optgroup' => __('Inventory'),
'name' => __('Inventory'));
$types['inventory_changes'] = array('optgroup' => __('Inventory'),
'name' => __('Inventory changes'));
}
return $types;
}
?>

Binary file not shown.

After

(image error) Size: 90 B