From 333e5c874c4411ce80cbc1fb709715796f670efa Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 1 Aug 2018 11:52:20 +0200 Subject: [PATCH] create template visual console --- .../reporting/visual_console_template.php | 64 ++++++++- .../visual_console_template_wizard.php | 134 ++++++++++++++++++ 2 files changed, 196 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/reporting/visual_console_template.php b/pandora_console/godmode/reporting/visual_console_template.php index 2a0c5952c7..074a8648b7 100644 --- a/pandora_console/godmode/reporting/visual_console_template.php +++ b/pandora_console/godmode/reporting/visual_console_template.php @@ -18,8 +18,8 @@ global $config; require_once ($config['homedir'] . '/include/functions_visual_map.php'); // ACL for the general permission -$vconsoles_read = check_acl ($config['id_user'], 0, "VR"); -$vconsoles_write = check_acl ($config['id_user'], 0, "VW"); +$vconsoles_read = check_acl ($config['id_user'], 0, "VR"); +$vconsoles_write = check_acl ($config['id_user'], 0, "VW"); $vconsoles_manage = check_acl ($config['id_user'], 0, "VM"); if (!$vconsoles_read && !$vconsoles_write && !$vconsoles_manage) { @@ -69,5 +69,65 @@ if (!defined('METACONSOLE')) { ); } +$id_layout = (int) get_parameter ('id_layout', 0); +$name_template = (string) get_parameter ('name_template', ''); +$group = (int) get_parameter ('group'); +$action = (string) get_parameter ('action', ''); + +if($action == "create_template"){ + +} + +if($action == "delete_template"){ + +} + +$visual_console_array = visual_map_get_user_layouts($config['id_user'], true); + +if (!check_acl ($config['id_user'], 0, "VR")){ + $return_all_group = false; +} +else{ + $return_all_group = true; +} + +$table = '
'; +$table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; +$table .= "
"; + $table .= "" . __("Create From") . ":"; + $table .= ""; + $table .= html_print_select($visual_console_array, 'id_layout', $id_layout, '', __('none'), 0, true); + $table .= "
"; + $table .= "" . __("Name") . ":"; + $table .= ""; + $table .= html_print_input_text ('name_template', $name_template, '', 50, 255, true); + $table .= "
"; + $table .= '' . __("Group") . ':'; + $table .= ""; + $table .= html_print_select_groups(false, "AR", $return_all_group, "group", $group, 'this.form.submit();', '', 0, true, false, true, '', false); + $table .= "
"; + +if (check_acl ($config['id_user'], 0, "RW")) { + $table .= '
'; + $table .= html_print_input_hidden('action', 'create_template'); + $table .= html_print_submit_button (__('Create template'), 'apply', false, 'class="sub next"', true); + $table .= '
'; +} +$table .= '
'; + +echo ui_toggle($table, __('Create New Template'), '', false, true); + ?> \ No newline at end of file diff --git a/pandora_console/godmode/reporting/visual_console_template_wizard.php b/pandora_console/godmode/reporting/visual_console_template_wizard.php index bcedbabd0b..76ac71b03d 100644 --- a/pandora_console/godmode/reporting/visual_console_template_wizard.php +++ b/pandora_console/godmode/reporting/visual_console_template_wizard.php @@ -68,4 +68,138 @@ if (!defined('METACONSOLE')) { $buttons ); } + + +$templates = reporting_enterprise_get_template_reports(array ('order' => 'id_group, name'), array('id_report', 'name'), true); + +$template_select = array(); +if ($templates === false) + $template_select = array(); +else { + $groups = array(__('All') => 0); + foreach ($templates as $template) { + $id_group = $template['id_group']; + $group_name = ''; + + if (!isset($groups[$id_group])) + $groups[$id_group] = groups_get_name($id_group, true); + + if (!empty($groups[$id_group])) + $group_name = $groups[$id_group]; + + $template_select[$template['id_report']] = array('optgroup' => $group_name, 'name' => $template['name']); + } +} + +if (is_metaconsole()) { + $keys_field = 'nombre'; +} +else { + $keys_field = 'id_grupo'; +} + +$attr_available = array('id' => 'image-select_all_available', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); +$attr_apply = array('id' => 'image-select_all_apply', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); + +$table = '
'; +$table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; +$table .= "
"; + $table .= "" . __('Templates') . ":"; + $table .= ""; + $table .= html_print_select($template_select, 'templates', $template_selected, '', __('None'), '0', true, false, true, '', false, 'width:180px;'); + $table .= ""; + $table .= "" . __('Report name') . " " . + ui_print_help_tip(__('Left in blank if you want to use default name: Template name - agents (num agents) - Date'), true) . ":"; + $table .= ""; + $table .= html_print_input_text ('template_report_name', '', '', 80, 150, true); + $table .= "
"; + $table .= '' . __('Filter group') . ':'; + $table .= ""; + $table .= html_print_select_groups( + false, "RR", users_can_manage_group_all("RR"), + 'group', '', '', '', 0, true, false, false, + '', false, false, false, false, $keys_field + ); + $table .= ""; + $table .= "" . __('Target group') . ":"; + $table .= ""; + $table .= html_print_select_groups( + false, "RR", users_can_manage_group_all("RR"), + 'template_report_group', '', '', '', 0, true, + false, false, '', false, false, false, false, + $keys_field + ); + $table .= "
"; + $table .= '' . __('Filter agent') . ':'; + $table .= ""; + $table .= html_print_input_text ('agent_filter', $agent_filter, '', 20, 150, true); + $table .= ""; + $table .= ''; + $table .= ""; + $table .= ''; + $table .= "
"; + $table .= "" . __('Agents available')."  " . + html_print_image ('images/tick.png', true, $attr_available, false, true); + $table .= ""; + $table .= "" . __('Agents to apply')."  " . + html_print_image ('images/tick.png', true, $attr_apply, false, true); + $table .= "
"; + $option_style = array(); + $template_agents_in = array(); + $template_agents_all = array(); + $template_agents_out = array(); + $template_agents_out = array_diff_key($template_agents_all, $template_agents_in); + $template_agents_in_keys = array_keys($template_agents_in); + $template_agents_out_keys = array_keys($template_agents_out); + + $table .= html_print_select ($template_agents_out, 'id_agents[]', 0, false, '', '', true, true, true, '', false, 'width: 100%;', $option_style); + $table .= ""; + $table .= html_print_image ('images/darrowright.png', true, array ('id' => 'right', 'title' => __('Add agents to template'))); + $table .= html_print_image ('images/darrowleft.png', true, array ('id' => 'left', 'title' => __('Undo agents to template'))); + $table .= ""; + $table .= $option_style = array(); + //Agents applied to the template + $table .= html_print_select ($template_agents_in, 'id_agents2[]', 0, false, '', '', true, true, true, '', false, 'width: 100%;', $option_style); + $table .= "
"; + +if (check_acl ($config['id_user'], 0, "RW")) { + $table .= '
'; + $table .= html_print_input_hidden('action', 'create_template'); + $table .= html_print_submit_button (__('Apply template'), 'apply', false, 'class="sub next"', true); + $table .= '
'; +} +$table .= '
'; + +echo $table; + ?> \ No newline at end of file