2011-11-03 Juan Manuel Ramon <juanmanuel.ramon@artica.es>

* include/functions_reporting.php
	godmode/reporting/reporting_builder.preview.php
	godmode/reporting/reporting_builder.php
	godmode/reporting/reporting_builder.item_editor.php: Added selector
	for report's items in order to choose the report begin date and
	added combo for sort SLA elements. 



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5104 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
juanmanuelr 2011-11-03 10:56:38 +00:00
parent a06e2fa0be
commit 9da5190a47
5 changed files with 122 additions and 6 deletions

View File

@ -1,3 +1,12 @@
2011-11-03 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* include/functions_reporting.php
godmode/reporting/reporting_builder.preview.php
godmode/reporting/reporting_builder.php
godmode/reporting/reporting_builder.item_editor.php: Added selector
for report's items in order to choose the report begin date and
added combo for sort SLA elements.
2011-10-29 Junichi Satoh <junichi@rworks.jp>
* include/help/ja/help_projection_graph.php,

View File

@ -27,6 +27,11 @@ $show_graph_options[0] = __('Only table');
$show_graph_options[1] = __('Table & Graph');
$show_graph_options[2] = __('Only graph');
// SLA sorting options
$show_sort_options = array();
$show_sort_options[1] = __('Ascending');
$show_sort_options[2] = __('Descending');
enterprise_include('/godmode/reporting/reporting_builder.item_editor.php');
require_once ($config['homedir'].'/include/functions_agents.php');
if (enterprise_include_once ('include/functions_metaconsole.php')) {
@ -150,6 +155,8 @@ switch ($action) {
$time_from = $item['time_from'];
$time_to = $item['time_to'];
$show_graph = $item['show_graph'];
// 'top_n' filed will be reused for SLA sort option
$sla_sorted_by = $item['top_n'];
break;
case 'monitor_report':
$description = $item['description'];
@ -581,6 +588,10 @@ html_print_input_hidden('id_item', $idItem);
<td><?php html_print_checkbox('show_in_two_columns', 1, $show_in_two_columns, false,
false, 'if ($(\'input[name=show_in_two_columns]\').is(\':checked\')) $(\'input[name=show_in_landscape]\').attr(\'checked\', false);');?></td>
</tr>
<tr id="row_sort" style="" class="datos">
<td><?php echo __('Order') . ui_print_help_tip(__('SLA items sorted by fulfillment value'), true);?></td>
<td><?php html_print_select ($show_sort_options, 'combo_sla_sort_options', $sla_sorted_by, '', __('None'), 0); ?></td>
</tr>
<tr id="row_show_in_landscape" style="" class="datos">
<td><?php echo __('Show in landscape');?></td>
<td><?php html_print_checkbox('show_in_landscape', 1, $show_in_landscape, false, false,
@ -1097,6 +1108,7 @@ function chooseType() {
$("#row_show_in_landscape").css('display', 'none');
$("#row_module_group").css('display', 'none');
$("#row_servers").css('display', 'none');
$("#row_sort").css('display', 'none');
switch (type) {
case 'event_report_group':
@ -1146,6 +1158,7 @@ function chooseType() {
$("#row_only_display_wrong").css('display', '');
$("#row_show_graph").css('display', '');
$("#row_show_in_two_columns").css('display', '');
$("#row_sort").css('display', '');
break;
case 'monitor_report':
$("#row_description").css('display', '');

View File

@ -144,7 +144,7 @@ switch ($action) {
}
break;
case 'update':
case 'save':
case 'save':
switch ($activeTab) {
case 'main':
$reportName = get_parameter('name');
@ -191,14 +191,14 @@ switch ($action) {
$values['id_report'] = $idReport;
$values['description'] = get_parameter('description');
$values['type'] = get_parameter('type', null);
// Added support for projection graphs and prediction_date reports
// 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'){
}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');
@ -210,6 +210,12 @@ switch ($action) {
}
$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');
@ -288,7 +294,7 @@ switch ($action) {
$values['id_report'] = $idReport;
$values['type'] = get_parameter('type', null);
$values['description'] = get_parameter('description');
// Support for projection graph and prediction_date reports
// 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');
@ -307,6 +313,12 @@ switch ($action) {
}
$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);

View File

@ -78,7 +78,6 @@ $table->data[1][1] .= html_print_submit_button (__('Update'), 'date_submit', fal
echo '<form method="post" action="">';
html_print_table ($table);
html_print_input_hidden ('id_report', $id_report);
echo '</form>';
echo '<div id="loading">';
echo html_print_image("images/wait.gif", true, array("border" => '0')) . '<br />';
@ -99,6 +98,10 @@ $(document).ready (function () {
$("#loading").slideUp ();
$("#text-time").timeEntry ({spinnerImage: 'images/time-entry.png', spinnerSize: [20, 20, 0]});
$("#text-date").datepicker ();
$('[id^=text-date_init_]').datepicker ();
$('[id^=text-time_init_]').timeEntry ({spinnerImage: 'images/time-entry.png', spinnerSize: [20, 20, 0]});
$.datepicker.regional["<?php echo $config['language']; ?>"];
});
</script>
@ -151,4 +154,5 @@ foreach ($contents as $content) {
echo "</div>";
flush ();
}
?>
echo '</form>';
?>

View File

@ -1983,6 +1983,44 @@ function reporting_get_agent_module_info ($id_agent, $filter = false) {
return $return;
}
/**
* This is the callback sorting function for SLA values descending
*
* @param array $a Array element 1 to compare
* @param array $b Array element 2 to compare
*
*/
function sla_value_desc_cmp($a, $b)
{
// This makes 'Unknown' values the lastest
if (preg_match('/^(.)*Unknown(.)*$/', $a[5]))
$a[6] = -1;
if (preg_match('/^(.)*Unknown(.)*$/', $b[5]))
$b[6] = -1;
return ($a[6] < $b[6])? 1 : 0;
}
/**
* This is the callback sorting function for SLA values ascending
*
* @param array $a Array element 1 to compare
* @param array $b Array element 2 to compare
*
*/
function sla_value_asc_cmp($a, $b)
{
// This makes 'Unknown' values the lastest
if (preg_match('/^(.)*Unknown(.)*$/', $a[5]))
$a[6] = -1;
if (preg_match('/^(.)*Unknown(.)*$/', $b[5]))
$b[6] = -1;
return ($a[6] > $b[6])? 1 : 0;
}
/**
* This function is used once, in reporting_viewer.php, the HTML report render
* file. This function proccess each report item and write the render in the
@ -2030,6 +2068,15 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$agent_name = agents_get_name($content['id_agent']);
}
// Calculations in order to modify init date of the report
$date_init = get_parameter('date_init_' . $content['id_rc'], date ('Y-m-j',$report['datetime'] - $content['period']));
$time_init = get_parameter('time_init_' . $content['id_rc'], date ('h:iA',$report['datetime'] - $content['period']));
$datetime_init = strtotime ($date_init.' '.$time_init);
$new_interval = $report['datetime'] - $datetime_init;
if ($new_interval != $content['period']) {
$content['period'] = $new_interval;
}
switch ($content["type"]) {
case 1:
case 'simple_graph':
@ -2344,6 +2391,8 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$data[4] .= format_numeric ($sla_value, 2). "%";
}
$data[4] .= "</span>";
// This column will be used temporary for sort data
$data[6] = format_numeric ($sla_value, 2);
array_push ($table1->data, $data);
}
@ -2351,7 +2400,22 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
//Restore db connection
metaconsole_restore_db();
}
}
//html_debug_print($table1->data);
// SLA items sorted descending ()
if ($content['top_n'] == 2){
usort($table1->data, "sla_value_desc_cmp");
}
// SLA items sorted ascending
else if ($content['top_n'] == 1){
usort($table1->data, "sla_value_asc_cmp");
}
//html_debug_print($table1->data);
// Delete temporary column used to sort SLA data
for ($i=0; $i < count($table1->data); $i++) {
unset($table1->data[$i][6]);
}
$table->colspan[2][0] = 3;
if ($show_graph == 0 || $show_graph == 1) {
$data = array();
@ -3948,6 +4012,20 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
if (($config ['metaconsole'] == 1) && $server_name != '') {
metaconsole_restore_db();
}
// Adds date/time control to update initial interval report
$table->colspan[3][0] = 3;
// $table->data[3][0] = '<form method="post" action="">';
$table->data[3][0] .= '<b>' . __('Date') . '</b>' . ui_print_help_tip(__('This is the report start date'), true) . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
$table->data[3][0] .= html_print_input_text ('date_init_' . $content['id_rc'], $date_init, '', 12, 10, true). ' ';
$table->data[3][0] .= html_print_input_text ('time_init_' . $content['id_rc'], $time_init, '', 7, 7, true). ' ';
$table->data[3][0] .= html_print_submit_button (__('Update'), 'date_submit_init', false, 'class="sub next"', true);
$table->data[3][0] .= html_print_input_hidden ('id_report_content_' . $content['id_rc'], 1, true);
/* if (!isset(get_parameter('id_rc_list')){
$table->data[3][0] .= html_print_input_hidden ('id_rc_list', $id_rc_list . ',' . $content['id_rc'], true);
}*/
// $table->data[3][0] .= '</form>';
}
/**