From a6c62373816a03ac6ee6a6e94a313346649e9152 Mon Sep 17 00:00:00 2001 From: vgilc <noreply@pandorafms.org> Date: Fri, 24 Feb 2012 13:29:22 +0000 Subject: [PATCH] 2012-02-24 Vanessa Gil <vanessa.gil@artica.es> * include/functions_reporting.php godmode/reporting/graphs.php: Added template graph tabs to graph builder view. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5644 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 6 + .../reporting/graph_template_editor.php | 225 --------- .../reporting/graph_template_item_editor.php | 236 ---------- .../godmode/reporting/graph_template_list.php | 166 ------- .../reporting/graph_template_wizard.php | 431 ------------------ pandora_console/godmode/reporting/graphs.php | 34 +- .../include/functions_reporting.php | 80 +--- 7 files changed, 34 insertions(+), 1144 deletions(-) delete mode 100644 pandora_console/godmode/reporting/graph_template_editor.php delete mode 100644 pandora_console/godmode/reporting/graph_template_item_editor.php delete mode 100644 pandora_console/godmode/reporting/graph_template_list.php delete mode 100644 pandora_console/godmode/reporting/graph_template_wizard.php diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index bdd64dda64..d350084f2c 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2012-02-24 Vanessa Gil <vanessa.gil@artica.es> + + * include/functions_reporting.php + godmode/reporting/graphs.php: Added template graph tabs to graph + builder view. + 2012-02-24 Junichi Satoh <junichi@rworks.jp> include/help/ja/help_ff_threshold.php: Small warning about do not diff --git a/pandora_console/godmode/reporting/graph_template_editor.php b/pandora_console/godmode/reporting/graph_template_editor.php deleted file mode 100644 index c1380de357..0000000000 --- a/pandora_console/godmode/reporting/graph_template_editor.php +++ /dev/null @@ -1,225 +0,0 @@ -<?php - -// Pandora FMS - http://pandorafms.com -// ================================================== -// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas -// Please see http://pandorafms.org for full contribution list - -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation for version 2. -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -global $config; - -check_login (); - -if (! check_acl ($config['id_user'], 0, "IW")) { - db_pandora_audit("ACL Violation", - "Trying to access graph builder"); - include ("general/noaccess.php"); - exit; -} - -$update = get_parameter('edit_template', 0); -$create = get_parameter('create_template', 0); -$id_template = get_parameter('id', 0); - - -if ($create){ - $stacked = get_parameter('stacked'); - $events = get_parameter('events'); - $period = get_parameter('period'); - $name = get_parameter('name'); - $description = get_parameter('description'); - $id_group = get_parameter('id_group'); - $width = get_parameter('width'); - $height = get_parameter('height'); - - $values = array ( - 'name' => $name, - 'id_user' => $config['id_user'], - 'period' => $period, - 'width' => $width, - 'height' => $height, - 'id_group' => $id_group, - 'stacked' => $stacked, - 'private' => 0, - 'events' => $events, - 'description' => $description - ); - $id_template = db_process_sql_insert('tgraph_template', $values); -} - -$buttons['graph_list'] = array('active' => false, - 'text' => '<a href="index.php?sec=greporting&sec2=godmode/reporting/graphs">' . - html_print_image("images/god6.png", true, array ("title" => __('Graph list'))) .'</a>'); - -$buttons['wizard'] = array('active' => false, - 'text' => '<a href="index.php?sec=greporting&sec2=godmode/reporting/graph_template_wizard">' . - html_print_image("images/wand.png", true, array ("title" => __('Wizard'))) .'</a>'); - -$buttons['template'] = array('active' => false, - 'text' => '<a href="index.php?sec=greporting&sec2=godmode/reporting/graph_template_list">' . - html_print_image("images/paste_plain.png", true, array ("title" => __('Templates'))) .'</a>'); - -$buttons['template_editor'] = array('active' => true, - 'text' => '<a href="index.php?sec=greporting&sec2=godmode/reporting/graph_template_item_editor&id='.$id_template.'">' . - html_print_image("images/config.png", true, array ("title" => __('Item editor'))) .'</a>'); - -// Header -ui_print_page_header (__('Graph template editor'), "", false, "", true, $buttons); - -if ($create) { - if ($id_template === false) { - ui_print_error_message ('Error creating template'); - } else { - ui_print_success_message ('Template created successfully'); - } -} - -if ($id_template) { - $template_data = db_get_row_sql("SELECT * FROM tgraph_template WHERE id_graph_template = " . $id_template); - $stacked = $template_data['stacked']; - $events = $template_data['events']; - $period = $template_data['period']; - $name = $template_data['name']; - $description = $template_data['description']; - $id_group = $template_data['id_group']; - $width = $template_data['width']; - $height = $template_data['height']; -} else { - $id_agent = 0; - $id_module = 0; - $id_group = 0; - $name = ""; - $description = ""; - $width = 550; - $height = 210; - $period = 86400; - $events = 0; - $factor = 1; - $stacked = 0; -} - -if ($update) { - $stacked = get_parameter('stacked'); - $events = get_parameter('events'); - $period = get_parameter('period'); - $name = get_parameter('name'); - $description = get_parameter('description'); - $id_group = get_parameter('id_group'); - $width = get_parameter('width'); - $height = get_parameter('height'); - - if ($name == '') { - ui_print_error_message (__('Not updated. Blank name')); - } else { - $result = db_process_sql_update ('tgraph_template', - array ( - 'name' => $name, - 'period' => $period, - 'width' => $width, - 'height' => $height, - 'id_group' => $id_group, - 'stacked' => $stacked, - 'events' => $events, - 'description' => $description - ), - array ('id_graph_template' => $id_template)); - ui_print_result_message ($result, __('Template updated successfully'), __('Error updating template')); - } -} - -// ----------------------- -// CREATE/EDIT GRAPH TEMPLATE FORM -// ----------------------- - -echo "<table width='98%' cellpadding=4 cellspacing=4 class='databox_color'>"; - -if ($id_template) - echo "<form method='post' action='index.php?sec=greporting&sec2=godmode/reporting/graph_template_editor&edit_template=1&id=" . $id_template . "'>"; -else - echo "<form method='post' action='index.php?sec=greporting&sec2=godmode/reporting/graph_template_editor&create_template=1&id=" . $id_template . "'>"; - -echo "<tr>"; -echo "<td class='datos'><b>".__('Name')."</b></td>"; -echo "<td class='datos'><input type='text' name='name' size='25' "; - -echo "value='" . $name . "'>"; - -$own_info = get_user_info ($config['id_user']); -if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")) - $return_all_groups = true; -else - $return_all_groups = false; - -echo "<td><b>".__('Group')."</b></td><td>" . - html_print_select_groups($config['id_user'], "AR", $return_all_groups, 'graph_id_group', $id_group, '', '', '', true) . - "</td></tr>"; -echo "<tr>"; - -echo "<td class='datos2'><b>".__('Description')."</b></td>"; -echo "<td class='datos2' colspan=3><textarea name='description' style='height:45px;' cols=55 rows=2>"; - -echo $description; - -echo "</textarea>"; -echo "</td></tr>"; -echo "<tr>"; -echo "<td class='datos'>"; -echo "<b>".__('Width')."</b></td>"; -echo "<td class='datos'>"; -echo "<input type='text' name='width' value='$width' size=6></td>"; -echo "<td class='datos2'>"; -echo "<b>".__('Height')."</b></td>"; -echo "<td class='datos2'>"; -echo "<input type='text' name='height' value='$height' size=6></td></tr>"; - -$periods = array(3600 => "1 ".__('hour'), 7200 => "2 ".__('hours'), 10800 => "3 ".__('hours'), - 21600 => "6 ".__('hours'), 43200 => "12 ".__('hours'), 86400 => "1 ".__('day'), - 172800 => "2 ".__('days'), 345600 => "4 ".__('days'), 604800 => __('Last week'), - 1296000 => "15 ".__('days'), 2592000 => __('Last month'), 5184000 => "2 ".__('months'), - 15552000 => "6 ".__('months'), 31104000 => __('1 year'), 31104000 => __('1 year')); - -echo "<tr>"; -echo "<td class='datos'>"; -echo "<b>".__('Period')."</b></td>"; -echo "<td class='datos'>"; -html_print_select ($periods, 'period', $period); -echo "</td><td class='datos2'>"; -echo "<b>".__('Stacked')."</b></td>"; -echo "<td class='datos2'>"; - -include_once($config["homedir"] . "/include/functions_graph.php"); - -$stackeds = array( - GRAPH_AREA => __('Area'), - GRAPH_STACKED_AREA => __('Stacked area'), - GRAPH_LINE => __('Line'), - GRAPH_STACKED_LINE => __('Stacked line')); -html_print_select ($stackeds, 'stacked', $stacked); -echo "</td>"; - -echo "<tr>"; -echo "<td class='datos'>"; -echo "<b>".__('View events')."</b></td>"; -echo "<td class='datos'>"; -html_print_checkbox('events', 1, $events); -echo "</td>"; - -echo "<td></td><td></td>"; - -echo "</tr>"; -echo "<tr><td colspan='4' align='right'>"; -if ($id_template) { - echo "<input type=submit class='sub upd' value='".__('Update')."'>"; -} -else { - echo "<input type=submit class='sub next' value='".__('Create')."'>"; -} -echo "</td></tr></table>"; -echo "</form>"; diff --git a/pandora_console/godmode/reporting/graph_template_item_editor.php b/pandora_console/godmode/reporting/graph_template_item_editor.php deleted file mode 100644 index e0434d9077..0000000000 --- a/pandora_console/godmode/reporting/graph_template_item_editor.php +++ /dev/null @@ -1,236 +0,0 @@ -<?php - -// Pandora FMS - http://pandorafms.com -// ================================================== -// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas -// Please see http://pandorafms.org for full contribution list - -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation for version 2. -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -global $config; - -check_login (); - -if (! check_acl ($config['id_user'], 0, "IW")) { - db_pandora_audit("ACL Violation", - "Trying to access graph builder"); - include ("general/noaccess.php"); - exit; -} - -$id_template = get_parameter('id',0); -$delete = get_parameter('delete',0); -$multiple_delete = (bool)get_parameter('multiple_delete', 0); -$change_weight = (bool)get_parameter('change_weight', 0); -$create = get_parameter('add',0); - -$buttons['graph_list'] = array('active' => false, - 'text' => '<a href="index.php?sec=greporting&sec2=godmode/reporting/graphs">' . - html_print_image("images/god6.png", true, array ("title" => __('Graph list'))) .'</a>'); - -$buttons['wizard'] = array('active' => false, - 'text' => '<a href="index.php?sec=greporting&sec2=godmode/reporting/graph_template_wizard">' . - html_print_image("images/wand.png", true, array ("title" => __('Wizard'))) .'</a>'); - -$buttons['template'] = array('active' => false, - 'text' => '<a href="index.php?sec=greporting&sec2=godmode/reporting/graph_template_list">' . - html_print_image("images/paste_plain.png", true, array ("title" => __('Templates'))) .'</a>'); - -$buttons['template_editor'] = array('active' => true, - 'text' => '<a href="index.php?sec=greporting&sec2=godmode/reporting/graph_template_editor&id='.$id_template.'">' . - html_print_image("images/config.png", true, array ("title" => __('Template editor'))) .'</a>'); - -// Header -ui_print_page_header (__('Graph template editor'), "", false, "", true, $buttons); - -if ($create) { - if (!$id_template) { - ui_print_error_message ('Not created. Blank template.'); - } else { - $agent = get_parameter('agent', ''); - $module = get_parameter('module', ''); - $match = get_parameter('match', 0); - $weight = get_parameter('weight', 1); - - if ($module != '') { - $values = array ( - 'id_template' => $id_template, - 'agent' => $agent, - 'module' => $module, - 'exact_match' => $match, - 'weight' => $weight - ); - $id_gs_template = db_process_sql_insert('tgraph_source_template', $values); - if ($id_gs_template === false) { - ui_print_error_message ('Error creating template'); - } else { - ui_print_success_message ('Template created successfully'); - } - } else { - ui_print_error_message ('Not created. Blank module'); - } - } -} - -if ($delete) { - $id_gs_template = get_parameter('id_gs_template'); - $id_template = get_parameter('id_template'); - - $result = db_process_sql_delete ('tgraph_source_template', - array ('id_gs_template' => $id_gs_template)); - - if ($result !== false) { - $result = true; - } else { - $result = false; - } - - ui_print_result_message ($result, - __('Successfully deleted'), - __('Not deleted. Error deleting data')); -} - -if ($multiple_delete) { - $ids = (array)get_parameter('delete_multiple', array()); - - db_process_sql_begin(); - - foreach ($ids as $id) { - $result = db_process_sql_delete ('tgraph_source_template', - array ('id_gs_template' => $id)); - - if ($result === false) { - db_process_sql_rollback(); - break; - } - } - - if ($result !== false) { - db_process_sql_commit(); - } - - if ($result !== false) $result = true; - else $result = false; - - ui_print_result_message ($result, - __('Successfully deleted'), - __('Not deleted. Error deleting data')); -} - -if ($change_weight) { - $new_weight = get_parameter('new_weight'); - $id_gs_template = get_parameter ('id_gs_template'); - $value = array ( - 'weight' => $new_weight - ); - $result = db_process_sql_update('tgraph_source_template', $value, array('id_gs_template'=>$id_gs_template)); -} - -if ($id_template) { - $sql = "SELECT * FROM tgraph_source_template where id_template=$id_template"; - $templates = db_get_all_rows_sql($sql); - if ($templates != false) { - $table_aux->width = '98%'; - - $table_aux->size = array(); - //$table_aux->size[0] = '40%'; - $table_aux->size[1] = '40%'; - $table_aux->size[2] = '30%'; - $table_aux->size[3] = '20%'; - $table_aux->size[4] = '60px'; - - //$table_aux->head[0] = __('Agent'); - //$table_aux->align[0] = 'center'; - $table_aux->head[1] = __('Module'); - $table_aux->align[1] = 'center'; - $table_aux->head[2] = __('Weight'); - $table_aux->align[2] = 'center'; - $table_aux->head[3] = __('Exact match'); - $table_aux->align[3] = 'center'; - $table_aux->head[4] = __('Action') . html_print_checkbox('all_delete', 0, false, true, false, 'check_all_checkboxes();'); - $table_aux->align[4] = 'center'; - - $table_aux->data = array(); - - foreach ($templates as $template) { - $data = array(); - - //$data[0] = $template['agent']; - $data[1] = $template['module']; - - $dec_weight = $template['weight']-0.125; - $inc_weight = $template['weight']+0.125; - $data[2] = "<a href='index.php?sec=greporting&sec2=godmode/reporting/graph_template_item_editor&id=".$template['id_template']."&change_weight=1&new_weight=".$dec_weight."&id_gs_template=". $template['id_gs_template']. "'>". - html_print_image('images/down.png', true, array ('title' => __('Decrease Weight')))."</a>". - $template['weight']. - "<a href='index.php?sec=greporting&sec2=godmode/reporting/graph_template_item_editor&id=".$template['id_template']."&change_weight=1&new_weight=".$inc_weight."&id_gs_template=". $template['id_gs_template']. "'>". - html_print_image('images/up.png', true, array ('title' => __('Increase Weight')))."</a>"; - - if ($template['exact_match']) - $data[3] = __('Yes'); - else - $data[3] = __('No'); - - $data[4] = "<a onclick='if(confirm(\"" . __('Are you sure?') . "\")) return true; else return false;' - href='index.php?sec=greporting&sec2=godmode/reporting/graph_template_item_editor&delete=1&id_gs_template=".$template['id_gs_template']."&id_template=".$template['id_template']."&offset=0'>" . - html_print_image('images/cross.png', true, array('title' => __('Delete'))) . "</a>" . - html_print_checkbox_extended ('delete_multiple[]', $template['id_gs_template'], false, false, '', 'class="check_delete"', true); - - array_push ($table_aux->data, $data); - } - - if(isset($data)) { - echo "<form method='post' action='index.php?sec=greporting&sec2=godmode/reporting/graph_template_item_editor'>"; - html_print_input_hidden('multiple_delete', 1); - html_print_table ($table_aux); - echo "<div style='padding-bottom: 20px; text-align: right; width:" . $table_aux->width . "'>"; - html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"'); - echo "</div>"; - echo "</form>"; - } - - } -} - -//Configuration form -$table->width = '98%'; - -$table->data = array(); - -//$table->data[0][0] = '<b>'.__('Agent').'</b>'; -//$table->data[1][0] = html_print_input_text('agent', '', '', 30, 255, true); -$table->data[0][0] = '<b>'.__('Module').'</b>'." "; -$table->data[0][0] .= " ".html_print_input_text('module', '', '', 30, 255, true); -$table->data[1][0] = '<b>'.__('Weight').'</b>'." "; -$table->data[1][0] .= ' '.html_print_input_text('weight', 2, '', 3, 5, true); -$table->data[2][0] = __('Exact match')." "; -$table->data[2][0] .= html_print_checkbox('match', 1, 0, true); - -echo '<form method="post" action="index.php?sec=greporting&sec2=godmode/reporting/graph_template_item_editor&add=1&id='.$id_template.'">'; -html_print_table($table); -echo '<div class="action-buttons" style="width: '.$table->width.'">'; - -html_print_submit_button (__('Add'), 'crt', false, 'class="sub add"'); - -echo '</div>'; -echo '</form>'; -?> - -<script type="text/javascript"> - -function check_all_checkboxes() { - if ($("input[name=all_delete]").attr('checked')) { - $(".check_delete").attr('checked', true); - } - else { - $(".check_delete").attr('checked', false); - } -} - -</script> diff --git a/pandora_console/godmode/reporting/graph_template_list.php b/pandora_console/godmode/reporting/graph_template_list.php deleted file mode 100644 index 0c178597e0..0000000000 --- a/pandora_console/godmode/reporting/graph_template_list.php +++ /dev/null @@ -1,166 +0,0 @@ -<?php -// Pandora FMS - http://pandorafms.com -// ================================================== -// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas -// Please see http://pandorafms.org for full contribution list - -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation for version 2. -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// Load global variables -global $config; - -require_once ('include/functions_reporting.php'); - -// Check user credentials -check_login (); - -if (! check_acl ($config['id_user'], 0, "IW")) { - db_pandora_audit("ACL Violation", - "Trying to access Inventory Module Management"); - require ("general/noaccess.php"); - return; -} - -$buttons['graph_list'] = array('active' => false, - 'text' => '<a href="index.php?sec=greporting&sec2=godmode/reporting/graphs">' . - html_print_image("images/god6.png", true, array ("title" => __('Graph list'))) .'</a>'); - -$buttons['wizard'] = array('active' => false, - 'text' => '<a href="index.php?sec=greporting&sec2=godmode/reporting/graph_template_wizard">' . - html_print_image("images/wand.png", true, array ("title" => __('Wizard'))) .'</a>'); - -$buttons['template'] = array('active' => true, - 'text' => '<a href="index.php?sec=greporting&sec2=godmode/reporting/graph_template_list">' . - html_print_image("images/paste_plain.png", true, array ("title" => __('Templates'))) .'</a>'); - -// Header -ui_print_page_header (__('Graph template management'), "", false, "", true, $buttons); - -$delete = get_parameter ('delete_template', 0); -$id_template = get_parameter('id', 0); -$multiple_delete = (bool)get_parameter('multiple_delete', 0); - -if ($delete) { - $result = db_process_sql_delete ('tgraph_template', - array ('id_graph_template' => $id_template)); - - if ($result !== false) - $result = true; - else - $result = false; - - ui_print_result_message ($result, - __('Successfully deleted'), - __('Not deleted. Error deleting data')); -} - -if ($multiple_delete) { - $ids = (array)get_parameter('delete_multiple', array()); - - db_process_sql_begin(); - - foreach ($ids as $id) { - $result = db_process_sql_delete ('tgraph_template', - array ('id_graph_template' => $id)); - - if ($result === false) { - db_process_sql_rollback(); - break; - } - } - - if ($result !== false) { - db_process_sql_commit(); - } - - if ($result !== false) $result = true; - else $result = false; - - ui_print_result_message ($result, - __('Successfully deleted'), - __('Not deleted. Error deleting data')); -} - - -$own_info = get_user_info ($config['id_user']); -if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")) - $return_all_group = true; -else - $return_all_group = false; - -$templates = reporting_template_graphs_get_user ($config['id_user'], false, $return_all_group, "IW"); - -if (! empty ($templates)) { - $table->width = '98%'; - $tale->class = 'databox_frame'; - $table->align = array (); - $table->align[3] = 'center'; - $table->head = array (); - $table->head[0] = __('Template name'); - $table->head[1] = __('Description'); - $table->head[3] = __('Group'); - $table->size[3] = '50px'; - if (check_acl ($config['id_user'], 0, "AW")) { - $table->align[4] = 'center'; - $table->head[4] = __('Action'). html_print_checkbox('all_delete', 0, false, true, false, 'check_all_checkboxes();'); - $table->size[4] = '60px'; - } - $table->data = array (); - - foreach ($templates as $template) { - $data = array (); - - $data[0] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/graph_template_editor&id='. - $template['id_graph_template'].'">'.$template['name'].'</a>'; - $data[1] = $template["description"]; - - $data[3] = ui_print_group_icon($template['id_group'],true); - - if (check_acl ($config['id_user'], 0, "AW")) { - $data[4] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/graph_template_list&delete_template=1&id=' - .$template['id_graph_template'].'" onClick="if (!confirm(\''.__('Are you sure?').'\')) - return false;">' . html_print_image("images/cross.png", true) . '</a>'. - html_print_checkbox_extended ('delete_multiple[]', $template['id_graph_template'], false, false, '', 'class="check_delete"', true); - } - - array_push ($table->data, $data); - } - - echo "<form method='post' action='index.php?sec=greporting&sec2=godmode/reporting/graph_template_list'>"; - html_print_input_hidden('multiple_delete', 1); - html_print_table ($table); - echo "<div style='padding-bottom: 20px; text-align: right; width:" . $table->width . "'>"; - html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"'); - echo "</div>"; - echo "</form>"; -} -else { - echo "<div class='nf'>".__('There are no defined graph templates')."</div>"; -} - -echo '<form method="post" action="index.php?sec=greporting&sec2=godmode/reporting/graph_template_editor">'; -echo '<div class="action-buttons" style="width: 98%;">'; -html_print_submit_button (__('Create template'), 'create', false, 'class="sub next"'); -echo "</div>"; -echo "</form>"; - -?> - -<script type="text/javascript"> - -function check_all_checkboxes() { - if ($("input[name=all_delete]").attr('checked')) { - $(".check_delete").attr('checked', true); - } - else { - $(".check_delete").attr('checked', false); - } -} - -</script> diff --git a/pandora_console/godmode/reporting/graph_template_wizard.php b/pandora_console/godmode/reporting/graph_template_wizard.php deleted file mode 100644 index ff6f92710d..0000000000 --- a/pandora_console/godmode/reporting/graph_template_wizard.php +++ /dev/null @@ -1,431 +0,0 @@ -<?php -// Pandora FMS - http://pandorafms.com -// ================================================== -// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas -// Please see http://pandorafms.org for full contribution list - -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation for version 2. -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -global $config; - -// Login check -check_login (); - -if (! check_acl ($config['id_user'], 0, "IW")) { - db_pandora_audit("ACL Violation", - "Trying to access template wizard"); - require ("general/noaccess.php"); - exit; -} - -$id_template = get_parameter('id_template'); -$agent_filter = (string) get_parameter ('agent_filter', ''); -$agent_filter2 = (string) get_parameter ('agent_filter2', ''); -$template_selected = get_parameter ('template_selected'); -$cleanup_template = get_parameter('cleanup_template', 0); -$action_wizard = get_parameter ('action_wizard'); -$template = get_parameter('templates'); - -if (is_ajax()) { - $cleanup_template = get_parameter('cleanup_template', 0); - $id_template_cleanup = get_parameter('id_template_cleanup'); - - // Cleanup applied template from database - if ($cleanup_template){ - $sql = "SELECT id_graph FROM tgraph WHERE id_graph_template=$id_template_cleanup"; - $id_graphs = db_get_all_rows_sql($sql); - - $result = db_process_sql_delete('tgraph', array('id_graph_template' => $id_template_cleanup)); - - if($result) { - foreach ($id_graphs as $id_graph) { - $result_aux = db_process_sql_delete('tgraph_source', array('id_graph' => $id_graph)); - } - echo 1; - } else { - echo 0; - } - } - - return; -} - -// Result for cleanup functionality -echo '<div id="sucess_cleanup" style="display:none">'; - ui_print_success_message(__('Cleanup sucessfully')); -echo '</div>'; -echo '<div id="wrong_cleanup" style="display:none">'; - ui_print_error_message(__('Cleanup error')); -echo '</div>'; - -$buttons['graph_list'] = array('active' => false, - 'text' => '<a href="index.php?sec=greporting&sec2=godmode/reporting/graphs">' . - html_print_image("images/god6.png", true, array ("title" => __('Graph list'))) .'</a>'); - -$buttons['wizard'] = array('active' => true, - 'text' => '<a href="index.php?sec=greporting&sec2=godmode/reporting/graph_template_wizard">' . - html_print_image("images/wand.png", true, array ("title" => __('Wizard'))) .'</a>'); - -$buttons['template'] = array('active' => false, - 'text' => '<a href="index.php?sec=greporting&sec2=godmode/reporting/graph_template_list">' . - html_print_image("images/paste_plain.png", true, array ("title" => __('Templates'))) .'</a>'); - -// Header -ui_print_page_header (__('Wizard template'), "", false, "", true, $buttons); - -// Apply templates action -if ($action_wizard == 'apply') { - $agents_selected = (array) get_parameter ('id_agents2'); - $template_selected = get_parameter('templates'); - - if (empty($agents_selected) || empty($template_selected)) - $result = false; - else { - $result = reporting_apply_report_template_graph($agents_selected, $template_selected); - } -} - -?> -<table style="" class="databox" id="" border="0" cellpadding="4" cellspacing="4" width="98%"> -<tbody> - <tr style="" class="datos"> - <td> - <?php - echo '<form method="post" action="index.php?sec=greporting&sec2=godmode/reporting/graph_template_wizard&action=wizard&id_template=' . $id_template . '">'; - - // List all available templates - $own_info = get_user_info ($config['id_user']); - if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")) - $return_all_group = true; - else - $return_all_group = false; - - $templates = reporting_template_graphs_get_user ($config['id_user'], false, true, 'IW'); - - if ($templates === false) - $template_select = array(); - else{ - foreach ($templates as $template){ - $template_select[$template['id_graph_template']] = $template['name']; - } - } - - echo __('Templates') . " "; - html_print_select($template_select, 'templates', $template_selected, '', __('None'), '0', false, false, true, '', false, 'width:180px;'); - echo " "; - echo '<a id="cleanup_template" href="index.php?sec=greporting&sec2=godmode/reporting/graph_template_wizard&cleanup_template=1&id_template=' . $id_template .'">'; - - html_print_image ('images/clean.png', false, array ('title' => __('Clean up template'))); - echo '</a>'; - ?> - </td> - <td></td> - </tr> - - <tr style="" class="datos"> - <td> - <?php - echo __('Filter group') . " "; - html_print_select(groups_get_all(), 'group', '', "", __('All'), '0', false, false, true, '', false, 'width:180px;'); - echo "<div id='loading_group' class='loading_div' style='display:none; float:left;'><img src='images/spinner.gif'></div>"; - ?> - </td> - - </tr> - <tr style="" class="datos"> - <td> - <?php - echo __('Filter agent') . " "; - html_print_input_text ('agent_filter', $agent_filter, '', 22, 150); - echo "<div id='loading_filter' class='loading_div' style='display:none; float:left;'><img src='images/spinner.gif'></div>"; - ?> - </td> - - </tr> - - <tr style="" class="datos"> - <td> - <?php - echo "<b>" . __('Agents available')."</b> " . html_print_submit_button (__('Select all'), 'select_all', false, 'class="sub upd"', true); - ?> - </td> - <td></td> - <td> - <?php - echo "<b>" . __('Agents to apply')."</b> " . html_print_submit_button (__('Select all'), 'select_all2', false, 'class="sub upd"', true); - ?> - </td> - </tr> - - <tr style="" class="datos"> - <td> - <?php - $option_style = array(); - /* This will keep agents that will be added to the template */ - $template_agents_in = array(); - - $template_agents_all = agents_get_group_agents(0, false, ''); - $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); - - html_print_select ($template_agents_out, 'id_agents[]', 0, false, '', '', false, true, true, '', false, 'width: 100%;', $option_style); - ?> - </td> - <td> - <br> - <?php - html_print_image ('images/darrowright.png', false, array ('id' => 'right', 'title' => __('Add agents to template'))); - ?> - <br><br><br><br> - <?php - html_print_image ('images/darrowleft.png', false, array ('id' => 'left', 'title' => __('Undo agents to template'))); - ?> - <br><br><br> - </td> - <td> - <?php - $option_style = array(); - /* Agents applied to the template */ - html_print_select ($template_agents_in, 'id_agents2[]', 0, false, '', '', false, true, true, '', false, 'width: 100%;', $option_style); - ?> - </td> - </tr> - -</tbody> -</table> - -<?php - -echo '<div class="action-buttons" style="width: 98%;">'; -html_print_input_hidden('action_wizard', 'apply'); -html_print_submit_button (__('Apply template'), 'apply', false, 'class="sub next"'); -echo '</div>'; -echo '</form>'; - -// Choose a weird separator -$separator = ';;..;;..;;'; - -html_print_input_hidden('separator', $separator); -html_print_input_hidden('agents_in', implode($separator, $template_agents_in)); -html_print_input_hidden('agents_in_keys', implode($separator, $template_agents_in_keys)); -html_print_input_hidden('agents_out', implode($separator, $template_agents_out)); -html_print_input_hidden('agents_out_keys', implode($separator, $template_agents_out_keys)); -?> - -<script language="javascript" type="text/javascript"> -var agents_out; -var agents_out_keys; -var agents_in; -var pending_delete_ids; -var agents_in_keys; -var separator; - -$(document).ready (function () { - // Get the agents in both sides from the hidden fields - separator = $("#hidden-separator").attr('value'); - var aux; - aux = $("#hidden-agents_in").attr('value'); - agents_in = aux.split(separator); - aux = $("#hidden-agents_in_keys").attr('value'); - agents_in_keys = aux.split(separator); - aux = $("#hidden-agents_out").attr('value'); - agents_out = aux.split(separator); - aux = $("#hidden-agents_out_keys").attr('value'); - agents_out_keys = aux.split(separator); - - $("select[name='group']").change(function(){ - filterByGroup($(this).val(), ''); - }); - - $("select[name='group2']").change(function(){ - filterByGroup($(this).val(), '2'); - }); - - function filterByGroup(idGroup, idSelect) { - $('#loading_group'+idSelect).show(); - - $('#id_agents'+idSelect).empty (); - search = $("#text-agent_filter"+idSelect).val(); - - jQuery.post ("ajax.php", - {"page" : "godmode/groups/group_list", - "get_group_agents" : 1, - "search" : search, - "id_group" : idGroup - }, - function (data, status) { - var group_agents = new Array(); - var group_agents_keys = new Array(); - - jQuery.each (data, function (id, value) { - group_agents.push(value); - group_agents_keys.push(id); - }); - - if(idSelect == '') { - agents_out_keys = group_agents_keys; - agents_out = group_agents; - } - else { - agents_in_keys = group_agents_keys; - agents_in = group_agents; - } - - refresh_agents($("#text-agent_filter"+idSelect).attr('value'), agents_out_keys, agents_out, $("#id_agents"+idSelect)); - }, - "json" - ); - } - - $("#group").click (function () { - $(this).css ("width", "auto"); - }); - - $("#group").blur (function () { - $(this).css ("width", "180px"); - }); - - $("#group2").click (function () { - $(this).css ("width", "auto"); - }); - - $("#group2").blur (function () { - $(this).css ("width", "180px"); - }); - - function refresh_agents(start_search, keys, values, select) { - var n = 0; - var i = 0; - select.empty(); - - values.forEach(function(item) { - var re = new RegExp(start_search,"gi"); - match = item.match(re); - - if(match != null) { - select.append ($("<option></option>").attr("value", keys[n]).html(values[n])); - i++; - } - n++; - }); - if(i == 0) { - $(select).empty (); - $(select).append ($("<option></option>").attr ("value", 0).html ('<?php echo __('None');?>')); - } - - $('.loading_div').hide(); - } - - $("#text-agent_filter").keyup (function () { - $('#loading_filter').show(); - refresh_agents($(this).val(), agents_out_keys, agents_out, $("#id_agents")); - }); - - $("#text-agent_filter2").keyup (function () { - $('#loading_filter2').show(); - refresh_agents($(this).val(), agents_in_keys, agents_in, $("#id_agents2")); - }); - - $("#right").click (function () { - jQuery.each($("select[name='id_agents[]'] option:selected"), function (key, value) { - agent_name = $(value).html(); - if (agent_name != <?php echo "'".__('None')."'"; ?>){ - id_agent = $(value).attr('value'); - $("select[name='id_agents2[]']").append($("<option>").val(id_agent).html('<i>' + agent_name + '</i>')); - $("#id_agents").find("option[value='" + id_agent + "']").remove(); - } - }); - }); - - $("#left").click(function(){ - jQuery.each($("select[name='id_agents2[]'] option:selected"), function (key, value) { - agent_name = $(value).html(); - if (agent_name != <?php echo "'".__('None')."'"; ?>){ - id_agent = $(value).attr('value'); - $("select[name='id_agents[]']").append($("<option>").val(id_agent).html('<i>' + agent_name + '</i>')); - $("#id_agents2").find("option[value='" + id_agent + "']").remove(); - } - }); - }); - - $("#submit-apply").click(function () { - $('#id_agents2 option').map(function(){ - $(this).attr('selected','selected'); - }); - - //Prevent from applying template 'None' over agent - if ($("#templates").val() == 0){ - alert( <?php echo "'" . __('Please set template distinct than ') . '"' . __('None') . '"' . "'"; ?> ); - return false; - } - - if (!confirm ( <?php echo "'" . __('Are you sure?') . "'"; ?> )) - return false; - - }); - - $("#submit-select_all").click(function () { - $('#id_agents option').map(function(){ - $(this).attr('selected','selected'); - }); - - return false; - }); - - $("#submit-select_all2").click(function () { - $('#id_agents2 option').map(function(){ - $(this).attr('selected','selected'); - }); - - return false; - }); - - $("#cleanup_template").click(function () { - // Prevent user of current action - if (! confirm ( <?php echo "'" . __('This will be delete all reports created in previous template applications. Do you want to continue?') . "'"; ?> )) - return false; - - // Prevent from applying template 'None' over agent - if ($("#templates").val() == 0){ - alert( <?php echo "'" . __('Please set template distinct than ') . '"' . __('None') . '"' . "'"; ?> ); - return false; - } - - // Cleanup applied template - var params = []; - var result; - params.push("cleanup_template=1"); - params.push("id_template_cleanup=" + $("#templates").val()); - params.push("page=godmode/reporting/graph_template_wizard"); - jQuery.ajax ({ - data: params.join ("&"), - type: 'POST', - url: action="ajax.php", - async: false, - timeout: 10000, - success: function (data) { - result = data; - - if (result == 1) - $("#sucess_cleanup").css("display", ""); - else - $("#wrong_cleanup").css("display", ""); - } - }); - - return false; - - }); - -}); - -</script> diff --git a/pandora_console/godmode/reporting/graphs.php b/pandora_console/godmode/reporting/graphs.php index 09a9fee508..325393748b 100644 --- a/pandora_console/godmode/reporting/graphs.php +++ b/pandora_console/godmode/reporting/graphs.php @@ -27,17 +27,37 @@ if (! check_acl ($config['id_user'], 0, "IW")) { return; } +$activeTab = get_parameter('tab', 'main'); + +$enterpriseEnable = false; +if (enterprise_include_once('include/functions_reporting.php') !== ENTERPRISE_NOT_HOOK) { + $enterpriseEnable = true; +} + $buttons['graph_list'] = array('active' => true, 'text' => '<a href="index.php?sec=greporting&sec2=godmode/reporting/graphs">' . html_print_image("images/god6.png", true, array ("title" => __('Graph list'))) .'</a>'); + +if ($enterpriseEnable){ + $buttons = reporting_enterprise_add_template_graph_tabs($buttons); +} -$buttons['wizard'] = array('active' => false, - 'text' => '<a href="index.php?sec=greporting&sec2=godmode/reporting/graph_template_wizard">' . - html_print_image("images/wand.png", true, array ("title" => __('Wizard'))) .'</a>'); +$subsection = ''; +switch ($activeTab){ -$buttons['template'] = array('active' => false, - 'text' => '<a href="index.php?sec=greporting&sec2=godmode/reporting/graph_template_list">' . - html_print_image("images/paste_plain.png", true, array ("title" => __('Templates'))) .'</a>'); + case 'main': $buttons['graph_list']['active'] = true; + $subsection = ' » '.__('Graph list'); + break; + default: $subsection = reporting_enterprise_add_graph_template_subsection($activeTab, &$buttons); + break; + } + +switch ($activeTab) { + case 'main': require_once('godmode/reporting/graphs.php'); + break; + default: reporting_enterprise_select_graph_template_tab($activeTab); + break; +} $delete_graph = (bool) get_parameter ('delete_graph'); $view_graph = (bool) get_parameter ('view_graph'); @@ -126,7 +146,7 @@ if (! empty ($graphs)) { if (check_acl ($config['id_user'], 0, "AW")) { $table->align[5] = 'center'; $table->head[5] = __('Delete'). html_print_checkbox('all_delete', 0, false, true, false, 'check_all_checkboxes();'); - $table->size[5] = '50px'; + $table->size[5] = '60px'; } $table->data = array (); diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 2aff500b62..edc7a4eede 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -4640,7 +4640,7 @@ function reporting_get_agentmodule_ttr ($id_agent_module, $period, $date = 0) { return $critical_period; } -/** +/* * Get all the template graphs a user can see. * * @param $id_user User id to check. @@ -4689,82 +4689,4 @@ function reporting_template_graphs_get_user ($id_user = 0, $only_names = false, return $templates; } - -/** - * Apply a template graph - * - * @param array $agents_selected to apply the template. - * @param $template_selected - * - * @return - */ -function reporting_apply_report_template_graph ($agents_selected, $template_selected) { - - if ($agents_selected[0] == '') { - unset($agents_selected[0]); - } - - if ($agents_selected != null) { - - $template_data = db_get_row('tgraph_template','id_graph_template', $template_selected); - - foreach ($agents_selected as $id_agent) { - $values = array( - 'id_user' => $template_data['id_user'], - 'name' => $template_data['name'], - 'description' => $template_data['description'], - 'period' => $template_data['period'], - 'width' => $template_data['width'], - 'height' => $template_data['height'], - 'private' => $template_data['private'], - 'events' => $template_data['events'], - 'stacked' => $template_data['stacked'], - 'id_group' => $template_data['id_group'], - 'id_graph_template' => $template_selected - ); - - $id_graph = db_process_sql_insert('tgraph', $values); - - $sql = "SELECT * FROM tgraph_source_template WHERE id_template=$template_selected"; - $source_templates = db_get_all_rows_sql($sql); - - foreach ($source_templates as $source) { - $modules = agents_get_modules($id_agent, false, array('disabled' => 0)); - $exact_match = $source['exact_match']; - - foreach ($modules as $key => $module) { - $insert_module = false; - if ($exact_match) { - if ($module == $source['module']) { - $insert_module = true; - } - } else { - $exp = '/'.$source['module'].'/i'; - $result = preg_match($exp, $module); - if ($result) { - $insert_module = true; - } - } - if ($insert_module) { - $values_aux = array( - 'id_graph' => $id_graph, - 'id_agent_module' => $key, - 'weight' => $source['weight'] - ); - $id_gs = db_process_sql_insert('tgraph_source', $values_aux); - } - } - } - } - if ($id_graph) { - ui_print_success_message ('Template applied successfully'); - //return true; - } else { - ui_print_error_message ('An error has ocurred apllying template'); - } - } else { - ui_print_error_message ('Agent must be selected'); - } - return false; -} ?>