From 40864eee6ba5fbe2c3e8a2de3f5377ed16df955f Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 7 Oct 2020 09:34:43 +0200 Subject: [PATCH] add new token to report --- pandora_console/extras/mr/42.sql | 6 ++ .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 7 +- .../reporting/reporting_builder.main.php | 102 +++++++++++++----- .../godmode/reporting/reporting_builder.php | 61 +++++++---- pandora_console/pandoradb.sql | 4 + 5 files changed, 128 insertions(+), 52 deletions(-) diff --git a/pandora_console/extras/mr/42.sql b/pandora_console/extras/mr/42.sql index 914ae0fae7..26f20e0f0a 100644 --- a/pandora_console/extras/mr/42.sql +++ b/pandora_console/extras/mr/42.sql @@ -25,4 +25,10 @@ ALTER TABLE talert_actions ADD COLUMN `field20_recovery` TEXT NOT NULL DEFAULT " ALTER TABLE `treport_content` add column `graph_render` tinyint(1) UNSIGNED NOT NULL default 0; ALTER TABLE `treport_content_template` add column `graph_render` tinyint(1) UNSIGNED NOT NULL default 0; +ALTER TABLE `treport` ADD COLUMN `cover_page_render` tinyint(1) NOT NULL DEFAULT 1; +ALTER TABLE `treport` ADD COLUMN `index_render` tinyint(1) NOT NULL DEFAULT 1; + +ALTER TABLE `treport_template` ADD COLUMN `cover_page_render` tinyint(1) NOT NULL DEFAULT 1; +ALTER TABLE `treport_template` ADD COLUMN `index_render` tinyint(1) NOT NULL DEFAULT 1; + COMMIT; \ No newline at end of file diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index e6208f034a..664a7749e1 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -770,7 +770,8 @@ CREATE TABLE IF NOT EXISTS `treport_template` ( `custom_font` varchar(200) default NULL, `metaconsole` tinyint(1) DEFAULT 0, `agent_regex` varchar(600) NOT NULL default '', - + `cover_page_render` tinyint(1) NOT NULL DEFAULT 1, + `index_render` tinyint(1) NOT NULL DEFAULT 1, PRIMARY KEY(`id_report`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; @@ -2227,13 +2228,15 @@ INSERT INTO tlog_graph_models VALUES (6, 'Pages with warnings', INSERT INTO tlog_graph_models VALUES (7, 'Users login', 'Starting Session \d+\ of user (.*)', 'user', 0); + -- ----------------------------------------------------- -- Add column in table `treport` -- ----------------------------------------------------- - ALTER TABLE `treport` ADD COLUMN `hidden` tinyint(1) NOT NULL DEFAULT 0; ALTER TABLE `treport` ADD COLUMN `orientation` varchar(25) NOT NULL default 'vertical'; ALTER TABLE `treport` MODIFY COLUMN `hidden` tinyint(1) NULL DEFAULT '0' AFTER `non_interactive`; +ALTER TABLE `treport` ADD COLUMN `cover_page_render` tinyint(1) NOT NULL DEFAULT 1; +ALTER TABLE `treport` ADD COLUMN `index_render` tinyint(1) NOT NULL DEFAULT 1; ALTER TABLE `trecon_task` ADD COLUMN `snmp_version` varchar(5) NOT NULL default '1'; ALTER TABLE `trecon_task` ADD COLUMN `snmp_auth_user` varchar(255) NOT NULL default ''; diff --git a/pandora_console/godmode/reporting/reporting_builder.main.php b/pandora_console/godmode/reporting/reporting_builder.main.php index b8b375bed1..224b2ce517 100755 --- a/pandora_console/godmode/reporting/reporting_builder.main.php +++ b/pandora_console/godmode/reporting/reporting_builder.main.php @@ -1,18 +1,28 @@ id = 'add_alert_table'; $table->class = 'databox filters'; $table->head = []; -if (is_metaconsole()) { +if (is_metaconsole() === true) { $table->head[0] = __('Main data'); $table->head_colspan[0] = 4; $table->headstyle[0] = 'text-align: center'; @@ -70,7 +80,7 @@ $table->size = []; $table->size = []; $table->size[0] = '15%'; $table->size[1] = '90%'; -if (!is_metaconsole()) { +if (is_metaconsole() === false) { $table->style[0] = 'font-weight: bold; vertical-align: top;'; } else { $table->style[0] = 'font-weight: bold;'; @@ -89,14 +99,18 @@ $table->data['name'][1] = html_print_input_text( ); $table->data['group'][0] = __('Group'); -$write_groups = users_get_groups_for_select(false, 'AR', true, true, false, 'id_grupo'); +$write_groups = users_get_groups_for_select( + false, + 'AR', + true, + true, + false, + 'id_grupo' +); - - - - -// If the report group is not among the RW groups (special permission) we add it -if (!isset($write_groups[$idGroupReport]) && $idGroupReport) { +// If the report group is not among the +// RW groups (special permission) we add it. +if (isset($write_groups[$idGroupReport]) === false && $idGroupReport) { $write_groups[$idGroupReport] = groups_get_name($idGroupReport); } @@ -123,7 +137,11 @@ if ($report_id_user == $config['id_user'] 'group_edit' => __('The next group can edit the report'), 'user_edit' => __('Only the user and admin user can edit the report'), ]; - $table->data['access'][0] = __('Write Access').ui_print_help_tip(__('For example, you want a report that the people of "All" groups can see but you want to edit only for you or your group.'), true); + $table->data['access'][0] = __('Write Access'); + $table->data['access'][0] .= ui_print_help_tip( + __('For example, you want a report that the people of "All" groups can see but you want to edit only for you or your group.'), + true + ); $table->data['access'][1] = html_print_select( $type_access, 'type_access', @@ -163,14 +181,19 @@ if ($enterpriseEnable) { } $table->data['interactive_report'][0] = __('Non interactive report'); - $table->data['interactive_report'][1] = __('Yes').'   '.html_print_radio_button( + $table->data['interactive_report'][1] = __('Yes'); + $table->data['interactive_report'][1] .= '   '; + $table->data['interactive_report'][1] .= html_print_radio_button( 'non_interactive', 1, '', $non_interactive_check, true - ).'  '; - $table->data['interactive_report'][1] .= __('No').'   '.html_print_radio_button( + ); + $table->data['interactive_report'][1] .= '  '; + $table->data['interactive_report'][1] .= __('No'); + $table->data['interactive_report'][1] .= '   '; + $table->data['interactive_report'][1] .= html_print_radio_button( 'non_interactive', 0, '', @@ -180,7 +203,32 @@ if ($enterpriseEnable) { } $table->data['description'][0] = __('Description'); -$table->data['description'][1] = html_print_textarea('description', 5, 15, $description, '', true); +$table->data['description'][1] = html_print_textarea( + 'description', + 5, + 15, + $description, + '', + true +); + +if (enterprise_installed() === true) { + $table->data['cover'][0] = __('Generate cover page in PDF render'); + $table->data['cover'][1] = html_print_checkbox_switch( + 'cover_page_render', + 1, + $cover_page_render, + true + ); + + $table->data['index'][0] = __('Generate index in PDF render'); + $table->data['index'][1] = html_print_checkbox_switch( + 'index_render', + 1, + $index_render, + true + ); +} echo '
'; html_print_table($table); diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 4df826d2b3..8ac3a11e37 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -1180,6 +1180,8 @@ switch ($action) { $report_id_user = 0; $type_access_selected = reports_get_type_access(false); $id_group_edit = 0; + $cover_page_render = true; + $index_render = true; break; case 'item_editor': @@ -1215,6 +1217,12 @@ switch ($action) { $report_id_user = get_parameter('report_id_user'); $non_interactive = get_parameter('non_interactive', 0); + $cover_page_render = get_parameter_switch( + 'cover_page_render', + 0 + ); + $index_render = get_parameter_switch('index_render', 0); + $custom_font = $config['custom_report_front_font']; switch ($type_access_selected) { @@ -1241,12 +1249,14 @@ switch ($action) { if ($action == 'update') { if ($reportName != '' && $idGroupReport != '') { $new_values = [ - 'name' => $reportName, - 'id_group' => $idGroupReport, - 'description' => $description, - 'private' => $private, - 'id_group_edit' => $id_group_edit, - 'non_interactive' => $non_interactive, + 'name' => $reportName, + 'id_group' => $idGroupReport, + 'description' => $description, + 'private' => $private, + 'id_group_edit' => $id_group_edit, + 'non_interactive' => $non_interactive, + 'cover_page_render' => $cover_page_render, + 'index_render' => $index_render, ]; @@ -1311,19 +1321,21 @@ switch ($action) { $idOrResult = db_process_sql_insert( 'treport', [ - 'name' => $reportName, - 'id_group' => $idGroupReport, - 'description' => $description, - 'first_page' => $first_page, - 'private' => $private, - 'id_group_edit' => $id_group_edit, - 'id_user' => $config['id_user'], - 'metaconsole' => $metaconsole_report, - 'non_interactive' => $non_interactive, - 'custom_font' => $custom_font, - 'custom_logo' => $logo, - 'header' => $header, - 'footer' => $footer, + 'name' => $reportName, + 'id_group' => $idGroupReport, + 'description' => $description, + 'first_page' => $first_page, + 'private' => $private, + 'id_group_edit' => $id_group_edit, + 'id_user' => $config['id_user'], + 'metaconsole' => $metaconsole_report, + 'non_interactive' => $non_interactive, + 'custom_font' => $custom_font, + 'custom_logo' => $logo, + 'header' => $header, + 'footer' => $footer, + 'cover_page_render' => $cover_page_render, + 'index_render' => $index_render, ] ); @@ -2736,6 +2748,8 @@ switch ($action) { $id_group_edit = $report['id_group_edit']; $report_id_user = $report['id_user']; $non_interactive = $report['non_interactive']; + $cover_page_render = $report['cover_page_render']; + $index_render = $report['index_render']; break; case 'delete': @@ -3106,22 +3120,23 @@ if ($enterpriseEnable) { } } +$urlB = 'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder'; $buttons = [ 'list_reports' => [ 'active' => false, - 'text' => ''.html_print_image('images/report_list.png', true, ['title' => __('Reports list')]).'', + 'text' => ''.html_print_image('images/report_list.png', true, ['title' => __('Reports list')]).'', ], 'main' => [ 'active' => false, - 'text' => ''.html_print_image('images/op_reporting.png', true, ['title' => __('Main data')]).'', + 'text' => ''.html_print_image('images/op_reporting.png', true, ['title' => __('Main data')]).'', ], 'list_items' => [ 'active' => false, - 'text' => ''.html_print_image('images/list.png', true, ['title' => __('List items')]).'', + 'text' => ''.html_print_image('images/list.png', true, ['title' => __('List items')]).'', ], 'item_editor' => [ 'active' => false, - 'text' => ''.html_print_image('images/pen.png', true, ['title' => __('Item editor')]).'', + 'text' => ''.html_print_image('images/pen.png', true, ['title' => __('Item editor')]).'', ], ]; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index f17bdf0c9e..51b0eb8150 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1473,6 +1473,8 @@ CREATE TABLE IF NOT EXISTS `treport` ( `non_interactive` tinyint(1) UNSIGNED NOT NULL default 0, `hidden` tinyint(1) DEFAULT 0, `orientation` varchar(25) NOT NULL default 'vertical', + `cover_page_render` tinyint(1) NOT NULL DEFAULT 1, + `index_render` tinyint(1) NOT NULL DEFAULT 1, PRIMARY KEY(`id_report`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; @@ -3052,6 +3054,8 @@ CREATE TABLE IF NOT EXISTS `treport_template` ( `custom_font` varchar(200) default NULL, `metaconsole` tinyint(1) DEFAULT 0, `agent_regex` varchar(600) BINARY NOT NULL default '', + `cover_page_render` tinyint(1) NOT NULL DEFAULT 1, + `index_render` tinyint(1) NOT NULL DEFAULT 1, PRIMARY KEY(`id_report`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8;