From 008b908ebdba1de8d7eb8cd15b3b446a75b81196 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Thu, 22 Apr 2010 19:01:47 +0000 Subject: [PATCH] 2010-04-22 Miguel de Dios * include/ajax/reporting.ajax.php: added ajax respond to delete_sla_item and add_sla actions. * include/functions.php: added in the function "get_report_types" new types of items/contents for reporting. * pandoradb.sql: added columns custom_logo, header, first_page, footer, custom_font into the table treport. And in the table treport_content have new columns text, external_source, treport_custom_sql_id, header_definition, row_separator, line_separator. Added new table treport_custom_sql. * extras/pandoradb_migrate_v3.0_to_v3.1.sql: added changes for DB that it same to pandoradb.sql. * images/sort_none.png, images/sort_down.png, images/sort_up.png: added the images for order list items for reports. * godmode/reporting/reporting_builder.list_items.php, godmode/reporting/reporting_builder.main.php, godmode/reporting/reporting_builder.php, godmode/reporting/reporting_builder.item_editor.php: made new forms to manage the reporting, now Pandora have tabs and list of items. In the list of items, you can order manually or automatically the items. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2595 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 26 + .../extras/pandoradb_migrate_v3.0_to_v3.1.sql | 25 + .../reporting_builder.item_editor.php | 651 ++++++++++++ .../reporting_builder.list_items.php | 255 +++++ .../reporting/reporting_builder.main.php | 68 ++ .../godmode/reporting/reporting_builder.php | 991 ++++++------------ pandora_console/images/sort_down.png | Bin 0 -> 247 bytes pandora_console/images/sort_none.png | Bin 0 -> 250 bytes pandora_console/images/sort_up.png | Bin 0 -> 242 bytes .../include/ajax/reporting.ajax.php | 69 ++ pandora_console/include/functions.php | 29 +- pandora_console/pandoradb.sql | 19 + 12 files changed, 1437 insertions(+), 696 deletions(-) create mode 100644 pandora_console/godmode/reporting/reporting_builder.item_editor.php create mode 100644 pandora_console/godmode/reporting/reporting_builder.list_items.php create mode 100644 pandora_console/godmode/reporting/reporting_builder.main.php create mode 100644 pandora_console/images/sort_down.png create mode 100644 pandora_console/images/sort_none.png create mode 100644 pandora_console/images/sort_up.png create mode 100644 pandora_console/include/ajax/reporting.ajax.php diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index d642b33909..23c7f3aab2 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,29 @@ +2010-04-22 Miguel de Dios + + * include/ajax/reporting.ajax.php: added ajax respond to delete_sla_item and + add_sla actions. + + * include/functions.php: added in the function "get_report_types" new types + of items/contents for reporting. + + * pandoradb.sql: added columns custom_logo, header, first_page, footer, + custom_font into the table treport. And in the table treport_content have + new columns text, external_source, treport_custom_sql_id, header_definition, + row_separator, line_separator. Added new table treport_custom_sql. + + * extras/pandoradb_migrate_v3.0_to_v3.1.sql: added changes for DB that it + same to pandoradb.sql. + + * images/sort_none.png, images/sort_down.png, images/sort_up.png: added the + images for order list items for reports. + + * godmode/reporting/reporting_builder.list_items.php, + godmode/reporting/reporting_builder.main.php, + godmode/reporting/reporting_builder.php, + godmode/reporting/reporting_builder.item_editor.php: made new forms to + manage the reporting, now Pandora have tabs and list of items. In the list + of items, you can order manually or automatically the items. + 2010-04-22 Miguel de Dios * include/javascript/pandora.js: added function diff --git a/pandora_console/extras/pandoradb_migrate_v3.0_to_v3.1.sql b/pandora_console/extras/pandoradb_migrate_v3.0_to_v3.1.sql index dc9c980907..ffc4ef719d 100644 --- a/pandora_console/extras/pandoradb_migrate_v3.0_to_v3.1.sql +++ b/pandora_console/extras/pandoradb_migrate_v3.0_to_v3.1.sql @@ -46,6 +46,21 @@ CREATE INDEX idx_utimestamp USING BTREE ON tagent_access(utimestamp); ALTER TABLE tusuario ADD `timezone` varchar(50) default ''; +-- New report data +ALTER TABLE `treport` ADD `custom_logo` varchar(200) default NULL; +ALTER TABLE `treport` ADD `header` MEDIUMTEXT default NULL; +ALTER TABLE `treport` ADD `first_page` MEDIUMTEXT default NULL; +ALTER TABLE `treport` ADD `footer` MEDIUMTEXT default NULL; +ALTER TABLE `treport` ADD `custom_font` varchar(200) default NULL; + +-- New report content data +ALTER TABLE `treport_content` ADD `text` TEXT default NULL; +ALTER TABLE `treport_content` ADD `external_source` TinyText default NULL; +ALTER TABLE `treport_content` ADD `treport_custom_sql_id` INTEGER UNSIGNED default 0; +ALTER TABLE `treport_content` ADD `header_definition` TinyText default NULL; +ALTER TABLE `treport_content` ADD `row_separator` TinyText default NULL; +ALTER TABLE `treport_content` ADD `line_separator` TinyText default NULL; + -- Realtime statistics on/off and interval INSERT INTO tconfig (`token`, `value`) VALUES ('realtimestats', '1'); INSERT INTO tconfig (`token`, `value`) VALUES ('stats_interval', '300'); @@ -60,6 +75,16 @@ INSERT INTO ttipo_modulo (`id_tipo`, `nombre`, `categoria`, `descripcion`, `icon -- GIS is disabled by default INSERT INTO tconfig (`token`, `value`) VALUES ('activate_gis', '1'); +-- ----------------------------------------------------- +-- Table `treport_custom_sql` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `treport_custom_sql` ( + `id` INTEGER UNSIGNED NOT NULL auto_increment, + `name` varchar(150) NOT NULL default '', + `sql` TEXT default NULL, + PRIMARY KEY(`id`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8; + -- ----------------------------------------------------- -- Table `tgis_data_history` -- ----------------------------------------------------- diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php new file mode 100644 index 0000000000..fcf5c8db75 --- /dev/null +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -0,0 +1,651 @@ + $idItem)); + print_input_hidden('id_item', $idItem); + //debugPrint($item); + $type = $item['type']; + switch ($type) { + case 'avg_value': + $period = $item['period']; + $description = $item['description']; + $idAgentModule = $item['id_agent_module']; + $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); + break; + case 'simple_graph': + $description = $item['description']; + $idAgentModule = $item['id_agent_module']; + $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); + $period = $item['period']; + break; + case 'custom_graph': + $description = $item['description']; + $period = $item['period']; + $idCustomGraph = $item['id_gs']; + break; + case 'SLA': + $description = $item['description']; + $period = $item['period']; + break; + case 'monitor_report': + $description = $item['description']; + $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); + $idAgentModule = $item['id_agent_module']; + $period = $item['period']; + break; + case 'avg_value': + $description = $item['description']; + $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); + $idAgentModule = $item['id_agent_module']; + $period = $item['period']; + break; + case 'max_value': + $description = $item['description']; + $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); + $idAgentModule = $item['id_agent_module']; + $period = $item['period']; + break; + case 'min_value': + $description = $item['description']; + $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); + $idAgentModule = $item['id_agent_module']; + $period = $item['period']; + break; + case 'sumatory': + $description = $item['description']; + $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); + $idAgentModule = $item['id_agent_module']; + $period = $item['period']; + break; + case 'agent_detailed': + $description = $item['description']; + $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); + $period = $item['period']; + break; +// case 'agent_detailed_event': +// $description = $item['description']; +// $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); +// $idAgentModule = $item['id_agent_module']; +// $period = $item['period']; +// break; + case 'text': + $description = $item['description']; + $text = $item['text']; + break; + case 'sql': + $description = $item['description']; + $sql = $item['external_source']; + $idCustom = $item['treport_custom_sql_id']; + $header = $item['header_definition']; + break; + case 'url': + $description = $item['description']; + $url = $item['row_separator']; + break; + case 'database_serialized': + $description = $item['description']; + $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); + $idAgentModule = $item['id_agent_module']; + $header = $item['header_definition']; + $field = $item['row_separator']; + $line = $item['line_separator']; + break; + case 'TTRT': + $description = $item['description']; + $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); + $idAgentModule = $item['id_agent_module']; + $period = $item['period']; + break; + case 'TTO': + $description = $item['description']; + $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); + $idAgentModule = $item['id_agent_module']; + $period = $item['period']; + break; + case 'MTBF': + $description = $item['description']; + $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); + $idAgentModule = $item['id_agent_module']; + $period = $item['period']; + break; + case 'MTTR': + $description = $item['description']; + $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); + $idAgentModule = $item['id_agent_module']; + $period = $item['period']; + break; + case 'alert_report_module': + $description = $item['description']; + $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); + $idAgentModule = $item['id_agent_module']; + $period = $item['period']; + break; + case 'alert_report_agent': + $description = $item['description']; + $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); + $period = $item['period']; + break; + case 'event_report_agent': + $description = $item['description']; + $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); + $period = $item['period']; + break; + case 'event_report_module': + $description = $item['description']; + $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); + $idAgentModule = $item['id_agent_module']; + $period = $item['period']; + break; +// case 'list_events_module': +// $description = $item['description']; +// $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); +// $idAgentModule = $item['id_agent_module']; +// break; +// case 'list_events_agent': +// $description = $item['description']; +// $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); +// break; +// case 'list_alerts_agent': +// $description = $item['description']; +// $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); +// break; +// case 'list_alerts_module': +// $description = $item['description']; +// $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); +// $idAgentModule = $item['id_agent_module']; +// break; + } + + break; +} + +$intervals = array (); +$intervals[30] = human_time_description_raw (30); +$intervals[60] = human_time_description_raw (60); +$intervals[300] = human_time_description_raw (300); +$intervals[600] = human_time_description_raw (600); +$intervals[1200] = human_time_description_raw (1200); +$intervals[1800] = human_time_description_raw (1800); +$intervals[3600] = human_time_description_raw (3600); +$intervals[7200] = human_time_description_raw (7200); + +$urlForm = 'index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&tab=item_editor&action=' . $actionParameter . '&id_report=' . $idReport; + +echo '
'; +?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ '; + } + ?> +
+ 'background: url(images/lightning.png) no-repeat right;')) + . ' ' . __("Type at least two characters to search") . ''; + ?> +
+ + + +
+ +
+'; +if ($action == 'new') { + print_submit_button(__('Create item'), 'create_item', false, 'class="sub next"'); +} +else { + print_submit_button(__('Edit item'), 'edit_item', false, 'class="sub upd"'); +} +echo ''; +echo '
'; + +require_javascript_file('pandora'); +if ($enterpriseEnable) { + enterpriseTextBox(); +} + +function print_SLA_list($width, $action, $idItem = null) { + ?> + + + + + + + + + + + + + + + + '; + $itemsSLA = get_db_all_rows_filter('treport_content_sla_combined', array('id_report_content' => $idItem)); + if ($itemsSLA === false) { + $itemsSLA = array(); + } + foreach ($itemsSLA as $item) { + $idAgent = get_db_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module'])); + $nameAgent = get_agent_name ($idAgent); + $nameModule = get_db_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module'])); + + echo ' + + + + + + + '; + } + echo ''; + ?> + + + + + + + + + + + + + + + + + + + + + +
' . $nameAgent . '' . $nameModule . '' . $item['sla_min'] . '' . $item['sla_max'] . '' . $item['sla_limit'] . ' + +
 Type at least two characters to search
+ + + \ No newline at end of file diff --git a/pandora_console/godmode/reporting/reporting_builder.list_items.php b/pandora_console/godmode/reporting/reporting_builder.list_items.php new file mode 100644 index 0000000000..84bee54d18 --- /dev/null +++ b/pandora_console/godmode/reporting/reporting_builder.list_items.php @@ -0,0 +1,255 @@ +'.__('Items filter').' '; + +$table = null; +$table->width = '80%'; +$table->data[0][0] = __('Agents'); +$table->data[0][1] = print_select($agents, 'agent_filter', $agentFilter, '', 0, '', true); +$table->data[0][2] = __('Modules'); +$table->data[0][3] = print_select($modules, 'module_filter', $moduleFilter, '', '', 0, true); +$table->data[1][0] = __('Type'); +$table->data[1][1] = print_select($types, 'type_filter', $typeFilter, '', '', 0, true); + +echo ''; + +$where = '1=1'; +if ($typeFilter != '') { + $where .= ' AND type LIKE "' . $typeFilter . '"'; +} + +$items = get_db_all_rows_sql('SELECT * FROM treport_content WHERE ' . $where . ' AND id_report = ' . $idReport . ' ORDER BY `order` LIMIT ' . $offset . ', ' . $config["block_size"]); +$countItems = get_db_sql('SELECT COUNT(id_rc) FROM treport_content WHERE ' . $where . ' AND id_report = ' . $idReport); + +if ($items === false) { + $items = array(); +} + +$table = null; +$table->width = '100%'; +$table->head[0] = '' . __('S.') . ''; +$table->head[1] = __('Type'); +if (!$filterEnable) { + $table->head[1] .= ' ' . + ''; +} +$table->head[2] = __('Agent'); +if (!$filterEnable) { + $table->head[2] .= ' ' . + ''; +} +$table->head[3] = __('Module'); +if (!$filterEnable) { + $table->head[3] .= ' ' . + ''; +} +$table->head[4] = __('Period'); +$table->head[5] = __('Description'); +$table->head[6] = '' . __('O.') . ''; + +$table->align[6] = 'center'; + +$lastPage = true; +if (((($offset == 0) && ($config["block_size"] > $countItems)) || + ($countItems >= ($config["block_size"] + $offset))) && + ($countItems > $config["block_size"])) { + $lastPage = false; +} + +$count = 0; +$rowPair = true; +//debugPrint($items); +foreach ($items as $item) { + if ($rowPair) + $table->rowclass[$count] = 'rowPair'; + else + $table->rowclass[$count] = 'rowOdd'; + $rowPair = !$rowPair; + + $row = array(); + + if ((reset($items) == $item) && ($offset == 0)) { + $row[0] = ' '; + } + else { + $row[0] = ''; + } + + if ((end($items) == $item) && $lastPage) { + $row[0] .= ' '; + } + else { + $row[0] .= ''; + } + + if ($filterEnable) { + $row[0] = ''; + } + + $row[1] = get_report_name($item['type']); + + if ($item['id_agent'] == 0) { + if ($item['id_agent_module'] == '') { + $row[2] = '-'; + $row[3] = '-'; + } + else { + $row[2] = get_agent_name(get_agent_module_id($item['id_agent_module'])); + $row[3] = get_db_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module'])); + } + } + else { + $row[2] = get_agent_name($item['id_agent']); + + if ($item['id_agent_module'] == '') { + $row [3] = '-'; + } + else { + $row[3] = get_db_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module'])); + } + } + + $row[4] = human_time_description_raw($item['period']); + + //. ' ' . __("Type at least two


characters to search") . '
'; + + if ($item['description'] == '') { + $row[5] = '-'; + } + else { + if (strlen($item['description']) > 25) { + $row[5] = substr($item['description'], 0, 25) . '…' . ' ' . $item['description'] . ''; + } + else { + $row[5] = substr($item['description'], 0, 25); + } + } + +// if ($item['id_gs'] == null) { +// $row[5] = '-'; +// } +// else { +// $row[5] = get_db_value_filter('name', 'tgraph', array('id_graph' => $item['id_gs'])); +// } + + $row[6] = ''; + $row[6] .= ' '; + $row[6] .= ''; + + $table->data[] = $row; + $count++; +} +pagination ($countItems, 'index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=edit&id_report=' . $idReport . $urlFilter); +print_table($table); +pagination ($countItems, 'index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=edit&id_report=' . $idReport . $urlFilter); +?> + \ No newline at end of file diff --git a/pandora_console/godmode/reporting/reporting_builder.main.php b/pandora_console/godmode/reporting/reporting_builder.main.php new file mode 100644 index 0000000000..443630d4af --- /dev/null +++ b/pandora_console/godmode/reporting/reporting_builder.main.php @@ -0,0 +1,68 @@ +width = '80%'; +$table->id = 'add_alert_table'; +$table->class = 'databox'; +$table->head = array (); +$table->data = array (); +$table->size = array (); +$table->size = array (); +$table->size[0] = '10%'; +$table->size[1] = '90%'; +$table->style[0] = 'font-weight: bold; vertical-align: top;'; + +$table->data['name'][0] = __('Name'); +$table->data['name'][1] = print_input_text('name', $reportName, __('Name'), 20, 40, true); + +$table->data['group'][0] = __('Group'); +$table->data['group'][1] = print_select ($groups, 'id_group', $idGroupReport, false, '', '', true); + +$table->data['description'][0] = __('Description'); +$table->data['description'][1] = print_textarea('description', 5, 15, $description, '', true); + +echo '
'; +print_table ($table); + +echo '
'; +echo $actionButtonHtml; +print_input_hidden('action', $hiddenFieldAction); +print_input_hidden('id_report', $idReport); +echo '
'; +?> \ No newline at end of file diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 13a451c772..52fbc1690c 100644 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -1,8 +1,7 @@ '.__('Reporting successfully created').''; - $id_agent = 0; - $id_agent_module = 0; - $report_id_group = 1; - $period = 0; - $type = 0; - $id_custom_graph = 0; - $sla_max = 0; - $sla_min = 0; - $sla_limit = 0; - $module_description = ""; - } else { - echo '

'.__('There was a problem creating reporting')."

"; - /* Do not unset so the values are kept in the form */ - } -} - -// Create report -if ($create_report) { - $values = array (); - $values['description'] = $report_description; - $values['private'] = $report_private; - - if (strlen($report_name) == 0) - $result = false; - else { - $result = $id_report = create_report ($report_name, $report_id_group, $values); - } - print_result_message ($result, __('Successfully created'), - __('Could not be created')); -} - -// Update report -if ($update_report) { - $values = array (); - $values['name'] = $report_name; - $values['description'] = $report_description; - $values['private'] = $report_private; - $values['id_group'] = $report_id_group; - - if (strlen($report_name) == 0) - $result = false; - else { - $result = update_report ($id_report, $values); - } - print_result_message ($result, __('Successfully updated'), - __('Could not be updated')); -} - -if ($id_report) { - $report = get_report ($id_report); - if ($report === false) - require ("general/noaccess.php"); - $report_name = $report["name"]; - $report_description = $report["description"]; - $report_private = $report["private"]; - $report_id_user = $report["id_user"]; - $report_id_group = $report['id_group']; -} - -$agents = get_group_agents ($report_id_group); - -if ($edit_sla_report_content) { - /* Edit SLA report form */ - $add_sla = (bool) get_parameter ('add_sla'); - $delete_sla = (bool) get_parameter ('delete_sla'); - $id_report_content = (int) get_parameter ('id_report_content'); - $id_module = (int) get_parameter ('id_module'); - - $sla_max = ''; - $sla_min = ''; - $sla_limit = ''; - if ($add_sla) { - $sla_max = (float) get_parameter ('sla_max'); - $sla_min = (float) get_parameter ('sla_min'); - $sla_limit = (float) get_parameter ('sla_limit'); - - if ($id_module) { - $result = process_sql_insert ('treport_content_sla_combined', - array ('id_report_content' => $id_report_content, - 'id_agent_module' => $id_module, - 'sla_max' => $sla_max, - 'sla_min' => $sla_min, - 'sla_limit' => $sla_limit)); - - if ($result !== false) { - echo "

".__('SLA was successfully created')."

"; - } else { - echo "

".__('There was a problem creating SLA')."

"; - } - } else { - echo "

".__('Module is not set')."

"; - } - } - if ($delete_sla) { - $id_sla = (int) get_parameter ('id_sla'); - $sql = sprintf ('DELETE FROM treport_content_sla_combined WHERE id = %d', $id_sla); - $result = process_sql ($sql); - if ($result !== false) { - echo "

".__('SLA was successfully delete')."

"; - } else { - echo "

".__('There was a problem deleting SLA')."

"; - } - } - $report_content = get_db_row ('treport_content', 'id_rc', $id_report_content); - - /* Show all SLAs defined in the report content */ - echo '

'.__('Reporting')." » "; - echo __('Custom reporting builder')." » "; - echo ''.$report['name'].'

'; - echo '

'.__('SLAs defined')."

"; - - $table->id = 'table-sla-list'; - $table->width = '500px'; - $table->align = array (); - $table->align[5] = 'center'; - $table->data = array (); - $table->head = array (); - $table->head[0] = __('Agent'); - $table->head[1] = __('Module'); - $table->head[2] = __('SLA Min. (value)'); - $table->head[3] = __('SLA Max. (value)'); - $table->head[4] = __('SLA Limit (%)'); - $table->head[5] = __('Delete'); - - $slas = get_db_all_rows_field_filter ('treport_content_sla_combined', 'id_report_content', $id_report_content); - if ($slas) { - foreach ($slas as $sla) { - $data = array (); - - $data[0] = get_agentmodule_agent_name ($sla['id_agent_module']); - $data[1] = get_agentmodule_name ($sla['id_agent_module']); - $data[2] = $sla['sla_min']; - $data[3] = $sla['sla_max']; - $data[4] = $sla['sla_limit'].'%'; - $data[5] = ''; - - array_push ($table->data, $data); - } - } - - if (sizeof ($slas)) { - print_table ($table); - } - - echo "

".__('SLA report construction')."

"; - $table->id = 'table-add-sla'; - $table->width = '500px'; - $table->data = array (); - $table->style = array (); - $table->size = array (); - $table->size[0] = '150px'; - $table->head = array (); - $table->style[0] = 'font-weight: bold'; - $table->data[0][0] = __('Agent'); - $table->data[0][1] = print_input_text_extended ('id_agent', __('Select'), 'text_id_agent', '', 30, 100, false, '', - array('style' => 'background: url(images/lightning.png) no-repeat right;'), true) - . ' ' . __("Type at least two characters to search") . ''; - $table->data[1][0] = __('Module'); - $table->data[1][1] = print_select (array (), 'id_module', 0, '', '--', 0, true); - $table->data[2][0] = __('SLA Min. (value)'); - $table->data[2][1] = print_input_text ('sla_min', $sla_min, '', 5, 10, true); - $table->data[3][0] = __('SLA Max. (value)'); - $table->data[3][1] = print_input_text ('sla_max', $sla_max, '', 5, 10, true); - $table->data[4][0] = __('SLA Limit (%)'); - $table->data[4][1] = print_input_text ('sla_limit', $sla_limit, '', 5, 10, true); - - echo '
'; - print_table ($table); - - print_input_hidden ('add_sla', 1); - print_input_hidden ('edit_sla_report_content', 1); - print_input_hidden ('id_report_content', $id_report_content); - - echo '
'; - print_submit_button (__('Create'), 'add', false, 'class="sub wand"'); - echo '
'; - - echo '
'; - -} elseif ($edit_report || $id_report) { - /* Edit and creation report form */ - $id_agent = (int) get_parameter ("id_agent"); - echo "

".__('Reporting')." » "; - echo __('Custom reporting builder'); - - echo " "; - echo "

"; - - $table->id = 'table-edit-report'; - $table->width = '500px'; - $table->data = array (); - $table->style = array (); - $table->style[0] = 'font-weight: bold'; - $table->data[0][0] = __('Report name'); - $table->data[0][1] = print_input_text ('report_name', $report_name, '', 35, 150, true); - - $table->data[0][1] .= "  "; - - $table->data[1][0] = __('Group'); - - $group_select = get_user_groups ($config['id_user']); - $table->data[1][1] = print_select ($group_select, 'report_id_group', $report_id_group, '', '', '', true); - $table->data[1][1] .= ' '; - $table->data[1][1] .= print_group_icon ($report_id_group, true); - $table->data[1][1] .= ''; - - $table->data[2][0] = __('Private'); - $table->data[2][1] = print_checkbox ('report_private', 1, $report_private, true); - $table->data[3][0] = __('Description'); - $table->data[3][1] = print_textarea ('report_description', 3, 40, $report_description, '', true); - - echo "
"; - print_table ($table); - // Button - echo '
'; - print_input_hidden ('edit_report', 1); - if ($id_report) { - print_input_hidden ('id_report', $id_report); - print_input_hidden ('update_report', 1); - print_submit_button (__('Update'), 'submit', false, 'class="sub upd"'); - } else { - print_input_hidden ('create_report', 1); - print_submit_button (__('Create'), 'submit', false, 'class="sub wand"'); - } - echo "
"; - echo "
"; - - if ($id_report) { - // Part 2 - Add new items to report - echo "

".__('Add item to report')."

"; - - /* We're reusing some $table attributes */ - $table->id = 'table-add-item'; - $table->rowstyle = array (); - $table->rowstyle[2] = 'display: none'; - $table->rowstyle[3] = 'display: none'; - $table->rowstyle[4] = 'display: none'; - $table->size = array (); - $table->size[0] = '200px'; - $table->data = array (); - - $table->data[0][0] = __('Reporting type'); - $types = get_report_types (); - asort ($types); - $table->data[0][1] = print_select ($types, 'type', -1, '', '--', -1, true); - $table->data[1][0] = __('Period'); - $periods = array (); - $periods[1] = __('1 hour'); - $periods[2] = '2 '.__('hours'); - $periods[3] = '3 '.__('hours'); - $periods[6] = '6 '.__('hours'); - $periods[12] = '12 '.__('hours'); - $periods[24] = __('1 day'); - $periods[48] = __('2 days'); - $periods[168] = __('1 week'); - $periods[360] = __('2 weeks'); - $periods[720] = __('1 month'); - $periods[2160] = __('3 months'); - $periods[4320] = __('6 months'); - $table->data[1][1] = print_select ($periods, 'period', 0, '', '--', 0, true, false, false, false); - - $table->data[2][0] = __('Source agent'); -// $table->data[2][1] = print_select ($agents, 'id_agent', $id_agent, '', '--', 0, true); - - $table->data[2][1] = print_input_text_extended ('id_agent', __('Select'), 'text_id_agent', '', 30, 100, false, '', - array('style' => 'background: url(images/lightning.png) no-repeat right;'), true) - . ' ' . __("Type at least two characters to search") . ''; - - $table->data[3][0] = __('Module'); - $modules = array (); - if ($id_agent) { - $modules = get_db_all_rows_filter ('tagente_modulo', - array ('id_agente' => $id_agent, 'order' => 'nombre'), - array ('id_agente_modulo', 'nombre')); - } - $table->data[3][1] = print_select ($modules, 'id_module', 0, '', '--', 0, true); - - $table->data[4][0] = __('Custom graph name'); - $table->data[4][1] = print_select_from_sql ('SELECT id_graph, name FROM tgraph WHERE private = 0 OR (private = 1 AND id_user = "'.$config["id_user"].'")', - 'id_custom_graph', 0, '', '--', 0, true); - - $module_description = ""; - $table->data[5][0] = __('Description'); - $table->data[5][1] = print_textarea ("module_description", 3, 35, $module_description, 'height: 50px;', true) ; - - echo "
"; - print_table ($table); - echo '
'; - print_input_hidden ('add_content', 1); - print_input_hidden ('id_report', $id_report); - print_submit_button (__('Add'), 'add', false, 'class="sub wand"'); - echo "
"; - echo "
"; - - // Part 3 - List of already assigned report items - $table->id = 'table-assigned-reports'; - $table->width = '90%'; - $table->data = array (); - $table->head = array (); - $table->size = array (); - $table->rowstyle = array (); - $table->head[0] = __('Order'); - $table->head[1] = __('Type'); - $table->head[2] = __('Agent'); - $table->head[3] = __('Module'); - $table->head[4] = __('Period'); - $table->head[5] = __('Options'); - $table->align = array (); - $table->align[0] = 'center'; - $table->align[5] = 'center'; - if ($report_id_user == $config['id_user']) { - $table->align[6] = 'center'; - $table->head[6] = __('Delete'); - } - - $report_contents = get_report_contents ($id_report); - - if (sizeof ($report_contents)) { - $first_id = $report_contents[0]['id_rc']; - $last_id = $report_contents[sizeof ($report_contents) - 1]['id_rc']; - } - if ($report_contents !== false) { - foreach ($report_contents as $report_content) { - $data = array (); - $data[0] = ''; - if ($first_id != $report_content['id_rc']) { - $data[0] .= '
'; - $data[0] .= print_input_hidden ('edit_report', 1, true); - $data[0] .= print_input_hidden ('id_report', $id_report, true); - $data[0] .= print_input_hidden ('content_up', 1, true); - $data[0] .= print_input_hidden ('id_report_content', $report_content['id_rc'], true); - $data[0] .= print_input_image ('up', 'images/up.png', 1, '', - true, array ('title' => __('Move up'))); - $data[0] .= '
'; - } - if ($last_id != $report_content['id_rc']) { - $data[0] .= '
'; - $data[0] .= print_input_hidden ('edit_report', 1, true); - $data[0] .= print_input_hidden ('id_report', $id_report, true); - $data[0] .= print_input_hidden ('content_down', 1, true); - $data[0] .= print_input_hidden ('id_report_content', $report_content['id_rc'], true); - $data[0] .= print_input_image ('down', 'images/down.png', 1, '', - true, array ('title' => __('Move down'))); - $data[0] .= '
'; - } - - $data[1] = get_report_name ($report_content['type']); - $data[2] = get_agent_name ($report_content['id_agent']); +switch ($action) { + case 'new': + switch ($activeTab) { + case 'main': + $reportName = ''; + $idGroupReport = 1; //All groups + $description = ''; + break; + case 'item_editor': + $resultOperationDB = null; + $report = get_db_row_filter('treport', array('id_report' => $idReport)); - switch (get_report_type_data_source ($report_content['type'])) { - case 'module': - if ($report_content['id_agent_module'] > 0) - $data[2] = strtolower (get_agentmodule_agent_name ($report_content['id_agent_module'])); - $data[3] = '' . strtolower (get_db_value ('nombre', 'tagente_modulo', 'id_agente_modulo', $report_content['id_agent_module'])) . ""; - break; - case 'custom-graph': - $data[3] = $report_content['description']; - break; - default: - $data[3] = '--'; - break; - } - - $data[4] = human_time_description ($report_content['period']); - $data[5] = ''; - if ($report_content['type'] == 'SLA') { - $data[5] = ''; - } - if ($report_id_user == $config['id_user'] || is_user_admin ($config['id_user'])) { - $data[6] = '
'; - $data[6] .= print_input_hidden ('edit_report', 1, true); - $data[6] .= print_input_hidden ('id_report', $id_report, true); - $data[6] .= print_input_hidden ('delete_report_content', 1, true); - $data[6] .= print_input_hidden ('id_report_content', $report_content['id_rc'], true); - $data[6] .= print_input_image ('delete', 'images/cross.png', 1, '', - true, array ('title' => __('Delete'))); - $data[6] .= '
'; - } - - array_push ($table->data, $data); - } + $reportName = $report['name']; + $idGroupReport = $report['id_group']; + $description = $report['description']; + break; } - if ($data) { - echo "

".__('Report items')."

"; - print_table ($table); - } else { - echo "
".__('No items defined')."
"; - } - } -} else { - // Report LIST - echo "

".__('Reporting')." » "; - echo __('Custom reporting')."

"; - - $reports = get_reports (array ('order' => 'name'), - array ('name', 'id_report', 'description', 'private', 'id_user', 'id_group')); - $table->width = '0px'; - if (sizeof ($reports)) { - $table->id = 'report_list'; - $table->width = '720px'; - $table->head = array (); - $table->align = array (); - $table->align[2] = 'center'; - $table->align[4] = 'center'; - $table->data = array (); - $table->head[0] = __('Report name'); - $table->head[1] = __('Description'); - $table->head[2] = __('Private'); - $table->head[3] = __('Group'); - $table->head[4] = ''; - $table->size = array (); - $table->size[4] = '40px'; - - foreach ($reports as $report) { - - if (!is_user_admin ($config["id_user"])){ - if ($report["private"] && $report["id_user"] != $config['id_user']) - if (!give_acl ($config["id_user"], $report["id_group"], "AW")) - continue; - if (!give_acl ($config["id_user"], $report["id_group"], "AW")) - continue; - } - - $data = array (); - $data[0] = ''.$report['name'].''; - $data[1] = $report['description']; - if ($report["private"] == 1) - $data[2] = __('Yes'); - else - $data[2] = __('No'); + break; + case 'update': + case 'save': + switch ($activeTab) { + case 'main': + $reportName = get_parameter('name'); + $idGroupReport = get_parameter('id_group'); + $description = get_parameter('description'); - $data[3] = get_group_name($report['id_group']); - $data[4] = '
'; - $data[4] .= print_input_hidden ('id_report', $report['id_report'], true); - $data[4] .= print_input_hidden ('delete_report', 1, true); - $data[4] .= print_input_image ('delete', 'images/cross.png', 1, '', - true, array ('title' => __('Delete'))); - $data[4] .= '
'; - - array_push ($table->data, $data); + if ($action == 'update') { + $resultOperationDB = (bool)process_sql_update('treport', array('name' => $reportName, 'id_group' => $idGroupReport, 'description' => $description), array('id_report' => $idReport)); + } + else if ($action == 'save') { + $idOrResult = process_sql_insert('treport', array('name' => $reportName, 'id_group' => $idGroupReport, 'description' => $description)); + if ($idOrResult === false) { + $resultOperationDB = false; + } + else { + $resultOperationDB = true; + $idReport = $idOrResult; + } + } + break; + case 'item_editor': + $resultOperationDB = null; + $report = get_db_row_filter('treport', array('id_report' => $idReport)); + + $reportName = $report['name']; + $idGroupReport = $report['id_group']; + $description = $report['description']; + switch ($action) { + case 'update': + $values = array(); + $values['id_report'] = $idReport; + $values['description'] = get_parameter('description'); + $values['period'] = get_parameter('period'); + $values['id_agent'] = get_parameter('id_agent'); + $values['id_gs'] = get_parameter('id_custom_graph'); + $values['text'] = get_parameter('text'); - } - print_table ($table); - } else { - echo "
".__('There are no defined reportings')."
"; - } - - echo '
'; - echo '
'; - print_input_hidden ('edit_report', 1); - print_submit_button (__('Create report'), 'create', false, 'class="sub next"'); - echo "
"; - echo "
"; -} - -require_jquery_file ('pandora.controls'); -require_jquery_file ('bgiframe'); -require_jquery_file ('autocomplete'); -?> - +if ($enterpriseEnable) { + $buttons = enterprise_addTabs($buttons, $idReport); +} + +$buttons[$activeTab]['active'] = true; + +if ($idReport != 0) { + $textReportName = " » " . $reportName; +} +else { + $temp = $buttons['main']; + $buttons = null; + $buttons['main'] = $temp; + $buttons['main']['active'] = true; + $textReportName = ''; +} + +print_page_header(__('Reporting') . $textReportName, "images/reporting_edit.png", false, "reporting_" . $activeTab . "_tab", true, $buttons); + +if ($resultOperationDB !== null) { + print_result_message ($resultOperationDB, __('Successfully action'), __('Unsuccessfully action')); +} + +switch ($activeTab) { + case 'main': + require_once('godmode/reporting/reporting_builder.main.php'); + break; + case 'list_items': + require_once('godmode/reporting/reporting_builder.list_items.php'); + break; + case 'item_editor': + require_once('godmode/reporting/reporting_builder.item_editor.php'); + break; + default: + enterprise_selectTab($activeTab); + break; +} + +?> \ No newline at end of file diff --git a/pandora_console/images/sort_down.png b/pandora_console/images/sort_down.png new file mode 100644 index 0000000000000000000000000000000000000000..c54de445be525b36e7318dd122d91f25d232025a GIT binary patch literal 247 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a&k#^NA%Cx&(BWL^R}Y)RhkEyuBA0mot`i gfB5aSsqs~|&-)1Ja{8iQN zre7;xsMeHwD$h1`gj{uKW@LC*r#f4b#rK|wN7IwoL~(!BlTUKgr`DW0CZ+V~@l>rF bwY{9`JY45kC$C=uG?c;9)z4*}Q$iB}%Opm* literal 0 HcmV?d00001 diff --git a/pandora_console/include/ajax/reporting.ajax.php b/pandora_console/include/ajax/reporting.ajax.php new file mode 100644 index 0000000000..f1940bcd66 --- /dev/null +++ b/pandora_console/include/ajax/reporting.ajax.php @@ -0,0 +1,69 @@ + (int)$id)); + + $data['correct'] = 1; + if ($result === false) { + $data['correct'] = 0; + } + + echo json_encode($data); + return; +} + +if ($add_sla) { + $id_module = get_parameter('id_module', 0); + $sla_limit = get_parameter('sla_limit', 0); + $sla_max = get_parameter('sla_max', 0); + $sla_min = get_parameter('sla_min', 0); + + $result = process_sql_insert('treport_content_sla_combined', array( + 'id_report_content' => $id, + 'id_agent_module' => $id_module, + 'sla_max' => $sla_max, + 'sla_min' => $sla_min, + 'sla_limit' => $sla_limit)); + + if ($result === false) { + $data['correct'] = 0; + } + else { + $data['correct'] = 1; + $data['id'] = $result; + } + + echo json_encode($data); + return; +} +?> \ No newline at end of file diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 38c68ce0bf..923b70cb4e 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -613,17 +613,34 @@ function get_report_types () { $types['simple_graph'] = __('Simple graph'); $types['custom_graph'] = __('Custom graph'); $types['SLA'] = __('S.L.A.'); - $types['event_report'] = __('Event report'); - $types['alert_report'] = __('Alert report'); $types['monitor_report'] = __('Monitor report'); $types['avg_value'] = __('Avg. Value'); $types['max_value'] = __('Max. Value'); $types['min_value'] = __('Min. Value'); $types['sumatory'] = __('Sumatory'); - $types['general_group_report'] = __('General group report'); - $types['monitor_health'] = __('Monitor health'); - $types['agents_detailed'] = __('Agents detailed view'); - $types['agent_detailed_event'] = __('Agent detailed event'); + $types['agent_detailed'] = __('Agent detailed view'); +// $types['agent_detailed_event'] = __('Agent detailed event'); +// $types['list_events_module'] = __('List events of module'); +// $types['list_events_agent'] = __('List events of agent'); +// $types['list_alerts_agent'] = __('List alerts of agent'); +// $types['list_alerts_module'] = __('List alerts of module'); + $types['text'] = __('Text'); + $types['sql'] = __('SQL query'); + $types['url'] = __('Import text from URL'); + $types['database_serialized'] = __('Serialize data'); + $types['TTRT'] = __('TTRT'); + $types['TTO'] = __('TTO'); + $types['MTBF'] = __('MTBF'); + $types['MTTR'] = __('MTTR'); +// $types['agent_detailed_event_pie_char'] = __('Agent detailed pie chart events'); +// $types['agent_detailed_event_last_hours'] = __('Agent detailed event in last hours'); +// $types['agent_detailed_alert_last_hours'] = __('Agent detailed alerts in last hours'); +// $types['agent_detailed_num_modules'] = __('Agent detailed num modules'); +// $types['agent_detailed_num_alerts'] = __('Agent detailed num alerts'); + $types['alert_report_module'] = __('Alert report module'); + $types['alert_report_agent'] = __('Alert report agent'); + $types['event_report_agent'] = __('Event report agent'); + $types['event_report_module'] = __('Event report module'); return $types; } diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 91cac05cfb..29fbfe7122 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -751,6 +751,12 @@ CREATE TABLE IF NOT EXISTS `treport` ( `description` TEXT NOT NULL, `private` tinyint(1) UNSIGNED NOT NULL default 0, `id_group` mediumint(8) unsigned NULL default NULL, + `custom_logo` varchar(200) default NULL, + `header` MEDIUMTEXT default NULL, + `first_page` MEDIUMTEXT default NULL, + `footer` MEDIUMTEXT default NULL, + `custom_font` varchar(200) default NULL, + PRIMARY KEY(`id_report`), FOREIGN KEY (`id_group`) REFERENCES tgrupo(`id_grupo`) ON UPDATE CASCADE ON DELETE CASCADE @@ -766,6 +772,12 @@ CREATE TABLE IF NOT EXISTS `treport_content` ( `order` int (11) NOT NULL default 0, `description` mediumtext, `id_agent` int(10) unsigned NOT NULL default 0, + `text` TEXT default NULL, + `external_source` TinyText default NULL, + `treport_custom_sql_id` INTEGER UNSIGNED default 0, + `header_definition` TinyText default NULL, + `row_separator` TinyText default NULL, + `line_separator` TinyText default NULL, PRIMARY KEY(`id_rc`), FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`) ON UPDATE CASCADE ON DELETE CASCADE @@ -785,6 +797,13 @@ CREATE TABLE IF NOT EXISTS `treport_content_sla_combined` ( ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE = InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE IF NOT EXISTS `treport_custom_sql` ( + `id` INTEGER UNSIGNED NOT NULL auto_increment, + `name` varchar(150) NOT NULL default '', + `sql` TEXT default NULL, + PRIMARY KEY(`id`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8; + CREATE TABLE IF NOT EXISTS `tlayout` ( `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL,