diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 5335fe11fb..91aa0e5c7b 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,11 @@ +2012-01-13 Vanessa Gil + + * godmode/netflow/nf_item_list.php + godmode/netflow/nf_report.php + godmode/netflow/nf_report_item.php + operation/netflow/nf_reporting.php + pandoradb.sql: Sort items of netflow reports. + 2012-01-12 Juan Manuel Ramon * include/functions_users.php diff --git a/pandora_console/godmode/netflow/nf_item_list.php b/pandora_console/godmode/netflow/nf_item_list.php index 19e696516c..bdbe3ae990 100644 --- a/pandora_console/godmode/netflow/nf_item_list.php +++ b/pandora_console/godmode/netflow/nf_item_list.php @@ -40,11 +40,30 @@ ui_print_page_header (__('Item list'), "images/god6.png", false, "", true, $butt $delete = (bool) get_parameter ('delete'); $multiple_delete = (bool)get_parameter('multiple_delete', 0); +$order = get_parameter('order'); //id report $id = (int) get_parameter ('id'); //id item $id_rc = (int) get_parameter ('id_rc'); +if ($order) { + $dir = get_parameter ('dir'); + $old_order = db_get_value_sql('SELECT `order` FROM tnetflow_report_content WHERE id_rc = ' . $id_rc); + switch ($dir) { + case 'up': + $new_order = $old_order-1; + break; + case 'down': + $new_order = $old_order + 1; + break; + } + $sql = "select id_rc from tnetflow_report_content where id_report=$id and `order`=$new_order"; + $item_cont = db_get_row_sql($sql); + $id_item_mod = $item_cont['id_rc']; + $result = db_process_sql_update('tnetflow_report_content', array('`order`' => $new_order), array('id_rc' => $id_rc)); + $result2 = db_process_sql_update('tnetflow_report_content', array('`order`' => $old_order), array('id_rc' => $id_item_mod)); +} + if ($delete) { $result = db_process_sql_delete ('tnetflow_report_content', array ('id_rc' => $id_rc)); @@ -92,35 +111,37 @@ $filter['limit'] = (int) $config['block_size']; $reports_item = db_get_all_rows_filter ('tnetflow_report_content', $filter); -$reports_item = db_get_all_rows_sql(' +$reports_item = db_get_all_rows_sql(" SELECT * FROM tnetflow_report_content - WHERE id_report = ' . $id); + WHERE id_report=$id ORDER BY `order`"); if ($reports_item === false) $reports_item = array (); -$table->width = '90%'; +$table->width = '98%'; $table->head = array (); -$table->head[0] = __('Id item'); -$table->head[1] = __('Filter'); -$table->head[2] = __('Max values'); -$table->head[3] = __('Graph'); -$table->head[4] = __('Action') . +$table->head[0] = __('Sort'); +$table->head[1] = __('Id item'); +$table->head[2] = __('Filter'); +$table->head[3] = __('Max values'); +$table->head[4] = __('Graph'); +$table->head[5] = __('Action') . html_print_checkbox('all_delete', 0, false, true, false, 'check_all_checkboxes();'); $table->style = array (); -$table->style[0] = 'font-weight: bold'; +$table->style[1] = 'font-weight: bold'; $table->align = array (); -$table->align[0] = 'center'; -$table->align[2] = 'center'; -$table->align[4] = 'right'; +$table->align[1] = 'center'; +$table->align[3] = 'center'; +$table->align[5] = 'right'; $table->size = array (); -$table->size[0] = '10%'; -$table->size[1] = '50%'; -$table->size[2] = '10%'; -$table->size[3] = '30%'; -$table->size[4] = '20px'; +$table->size[0] = '20px'; +$table->size[1] = '10%'; +$table->size[2] = '50%'; +$table->size[3] = '10%'; +$table->size[4] = '20%'; +$table->size[5] = '20px'; $table->data = array (); @@ -129,33 +150,54 @@ $total_reports_item = $total_reports_item[0]['total']; //ui_pagination ($total_reports_item, $url); +$sql = "SELECT id_rc FROM tnetflow_report_content where `order`= (select min(`order`) + from tnetflow_report_content + where id_report=$id) and id_report=$id"; +$item_min = db_get_row_sql($sql); +$first_item = $item_min['id_rc']; + +$sql = "SELECT id_rc FROM tnetflow_report_content where `order`= (select max(`order`) + from tnetflow_report_content + where id_report=$id) and id_report=$id"; +$item_max = db_get_row_sql($sql); +$last_item = $item_max['id_rc']; + foreach ($reports_item as $item) { $data = array (); - - $data[0] = ''.$item['id_rc'].''; - $name_filter = db_get_value('id_name', 'tnetflow_filter', 'id_sg', $item['id_filter']); - //$data[1] = $item['id_filter']; - $data[1] = $name_filter; + if ($item['id_rc'] == $first_item){ + $data[0] = ' '; + $data[0] .= '' . html_print_image("images/down.png", true, array("title" => __('Move to down'))) . ''; + } else if ($item['id_rc'] == $last_item){ + $data[0] = '' . html_print_image("images/up.png", true, array("title" => __('Move to up'))) . ''; + } else { + $data[0] = '' . html_print_image("images/up.png", true, array("title" => __('Move to up'))) . ''; + $data[0] .= '' . html_print_image("images/down.png", true, array("title" => __('Move to down'))) . ''; + } - $data[2] = $item['max']; + $data[1] = ''.$item['id_rc'].''; + $name_filter = db_get_value('id_name', 'tnetflow_filter', 'id_sg', $item['id_filter']); + + $data[2] = $name_filter; + + $data[3] = $item['max']; switch ($item['show_graph']) { case 0: - $data[3] = 'Area graph'; + $data[4] = 'Area graph'; break; case 1: - $data[3] = 'Pie graph'; + $data[4] = 'Pie graph'; break; case 2: - $data[3] = 'Table values'; + $data[4] = 'Table values'; break; case 3: - $data[3] = 'Table total period'; + $data[4] = 'Table total period'; break; } - $data[4] = "" . html_print_image('images/cross.png', true, array('title' => __('Delete'))) . "" . html_print_checkbox_extended ('delete_multiple[]', $item['id_rc'], false, false, '', 'class="check_delete"', true); @@ -197,5 +239,4 @@ function check_all_checkboxes() { $(".check_delete").attr('checked', false); } } - diff --git a/pandora_console/godmode/netflow/nf_report.php b/pandora_console/godmode/netflow/nf_report.php index ef8bd24b83..1de2c56251 100644 --- a/pandora_console/godmode/netflow/nf_report.php +++ b/pandora_console/godmode/netflow/nf_report.php @@ -93,7 +93,7 @@ $reports = db_get_all_rows_sql($sql); if ($reports === false) $reports = array(); -$table->width = '90%'; +$table->width = '98%'; $table->head = array (); $table->head[0] = __('Report name'); $table->head[1] = __('Description'); @@ -121,7 +121,6 @@ $total_reports = $total_reports[0]['total']; foreach ($reports as $report) { $data = array (); - $data[0] = ''.$report['id_name'].''; $data[1] = $report['description']; diff --git a/pandora_console/godmode/netflow/nf_report_item.php b/pandora_console/godmode/netflow/nf_report_item.php index 67adb61bc4..b9490bf167 100644 --- a/pandora_console/godmode/netflow/nf_report_item.php +++ b/pandora_console/godmode/netflow/nf_report_item.php @@ -53,6 +53,7 @@ if ($id_rc) { $name_filter = db_get_value('id_name', 'tnetflow_filter', 'id_sg', $id_filter); $max_val = $item['max']; $show_graph = $item['show_graph']; + } else { $name_filter = ''; $max_val = ''; @@ -84,12 +85,24 @@ if ($create){ $name_filter = db_get_value('id_name', 'tnetflow_filter', 'id_sg', $id_filter); $max_val = get_parameter('max','2'); $show_graph = get_parameter('show_graph',''); - + + //insertion order + $sql = "SELECT max(`order`) as max_order FROM tnetflow_report_content where id_report=$id"; + $result = db_get_row_sql($sql); + $order = $result['max_order']; + if ($order == '') { + $order = 0; + } else { + $order++; + } + // + $values = array ( 'id_report' => $id, 'id_filter' => $id_filter, 'max' => $max_val, - 'show_graph' => $show_graph + 'show_graph' => $show_graph, + '`order`' => $order ); $result = db_process_sql_insert('tnetflow_report_content', $values); diff --git a/pandora_console/operation/netflow/nf_reporting.php b/pandora_console/operation/netflow/nf_reporting.php index b8927e8cae..30561341b1 100644 --- a/pandora_console/operation/netflow/nf_reporting.php +++ b/pandora_console/operation/netflow/nf_reporting.php @@ -58,15 +58,17 @@ if ($reports == false){ $table->width = '98%'; $table->head = array (); $table->head[0] = __('Report name'); -$table->head[1] = __('Description'); +$table->head[1]= __('Description'); +$table->head[2] = __('Group'); $table->style = array (); $table->style[0] = 'font-weight: bold'; $table->align = array (); $table->align[2] = 'center'; $table->size = array (); -$table->size[0] = '50%'; +$table->size[0] = '40%'; $table->size[1] = '40%'; +$table->size[2] = '20%'; $table->data = array (); $total_reports = db_get_all_rows_filter ('tnetflow_report', false, 'COUNT(*) AS total'); @@ -80,6 +82,11 @@ foreach ($reports as $report) { $data[0] = ''.$report['id_name'].''; $data[1] = $report['description']; + $group = db_get_value('nombre','tgrupo', 'id_grupo', $report['id_group']); + if ($group == '') + $group = 'All'; + $data[2] = $group; + array_push ($table->data, $data); } diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index b4a96d65b5..ada247611b 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1321,6 +1321,7 @@ CREATE TABLE IF NOT EXISTS `tnetflow_report_content` ( `period` int(11) NOT NULL default 0, `max` int (11) NOT NULL default 0, `show_graph` varchar(60), + `order` int (11) NOT NULL default 0, PRIMARY KEY(`id_rc`), FOREIGN KEY (`id_report`) REFERENCES tnetflow_report(`id_report`) ON DELETE CASCADE,