diff --git a/pandora_console/extras/mr/10.sql b/pandora_console/extras/mr/10.sql index 3333da3157..53c7c7bcc6 100644 --- a/pandora_console/extras/mr/10.sql +++ b/pandora_console/extras/mr/10.sql @@ -2,7 +2,8 @@ START TRANSACTION; ALTER TABLE tsnmp_filter ADD unified_filters_id int(10) NOT NULL DEFAULT 0; ALTER TABLE treport_content_template ADD COLUMN hide_no_data tinyint(1) DEFAULT 0; -ALTER TABLE tgraph_source ADD COLUMN `order` int(10) NOT NULL default 0; +ALTER TABLE tgraph_source ADD COLUMN `field_order` int(10) NOT NULL default 0; +UPDATE tgraph_source c, (SELECT @n := 0) m SET c.field_order = @n := @n + 1; ALTER TABLE tgraph ADD COLUMN `summatory_series` tinyint(1) UNSIGNED NOT NULL default '0'; ALTER TABLE tgraph ADD COLUMN `average_series` tinyint(1) UNSIGNED NOT NULL default '0'; 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 70fd0a6868..78ff5bf563 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 @@ -1435,7 +1435,7 @@ ALTER TABLE tserver_export MODIFY `name` varchar(600) BINARY NOT NULL default '' -- --------------------------------------------------------------------- ALTER TABLE tgraph_source ADD COLUMN id_server int(11) UNSIGNED NOT NULL default 0; -ALTER TABLE tgraph_source ADD COLUMN `order` int(10) NOT NULL default 0; +ALTER TABLE tgraph_source ADD COLUMN `field_order` int(10) NOT NULL default 0; -- --------------------------------------------------------------------- -- Table `tserver_export_data` diff --git a/pandora_console/godmode/reporting/graph_builder.graph_editor.php b/pandora_console/godmode/reporting/graph_builder.graph_editor.php index 4daaf0c18d..da612b6e33 100644 --- a/pandora_console/godmode/reporting/graph_builder.graph_editor.php +++ b/pandora_console/godmode/reporting/graph_builder.graph_editor.php @@ -61,10 +61,10 @@ switch ($action) { switch ($config["dbtype"]) { case "mysql": $items = db_get_all_rows_sql(' - SELECT id_gs, `order` + SELECT id_gs, `field_order` FROM tgraph_source WHERE id_graph = ' . $id_graph . ' - ORDER BY `order`'); + ORDER BY `field_order`'); break; } @@ -77,7 +77,7 @@ switch ($action) { switch ($config["dbtype"]) { case "mysql": db_process_sql_update('tgraph_source', - array('`order`' => $order_temp), + array('`field_order`' => $order_temp), array('id_gs' => $item['id_rc'])); break; } @@ -89,10 +89,10 @@ switch ($action) { switch ($config["dbtype"]) { case "mysql": $items = db_get_all_rows_sql(' - SELECT id_gs, `order` + SELECT id_gs, `field_order` FROM tgraph_source WHERE id_graph = ' . $id_graph . ' - ORDER BY `order`'); + ORDER BY `field_order`'); break; } @@ -106,7 +106,7 @@ switch ($action) { foreach ($items as $item) { //Remove the contents from the block to sort if (array_search($item['id_gs'], $ids) === false) { - $temp[$item['order']] = $item['id_gs']; + $temp[$item['field_order']] = $item['id_gs']; } } $items = $temp; @@ -142,7 +142,7 @@ switch ($action) { case "mysql": db_process_sql_update('tgraph_source', - array('`order`' => ($order + 1)), + array('`field_order`' => ($order + 1)), array('id_gs' => $id)); break; } @@ -166,7 +166,7 @@ if ($editGraph) { WHERE t2.id_agente_modulo = t1.id_agent_module)) AS agent_name FROM tgraph_source t1 - WHERE t1.id_graph = " . $id_graph . " order by `order`"); + WHERE t1.id_graph = " . $id_graph . " order by `field_order`"); $position_array = array(); $module_array = array(); $weight_array = array(); @@ -183,7 +183,7 @@ if ($editGraph) { $weight_array[] = $graphRow['weight']; $label_array[] = $graphRow['label']; $agent_array[] = $graphRow['agent_name']; - $position_array[] = $graphRow['order']; + $position_array[] = $graphRow['field_order']; } $graphInTgraph = db_get_row_sql("SELECT * FROM tgraph WHERE id_graph = " . $id_graph); @@ -280,9 +280,9 @@ if (defined("METACONSOLE")) { else { $table->data[0][0] = "". __("Sort items") . ""; } -$table->data[1][0] = __('Sort selected items from position: '); +$table->data[1][0] = __('Sort selected items'); $table->data[1][1] = html_print_select_style( - array('before' => __('Move before to'), 'after' => __('Move after to')), 'move_to', + array('before' => __('before to'), 'after' => __('after to')), 'move_to', '', '', '', '', 0, true); $table->data[1][2] = html_print_input_text_extended('position_to_sort', 1, 'text-position_to_sort', '', 3, 10, false, "only_numbers('position_to_sort');", '', true); diff --git a/pandora_console/godmode/reporting/graph_builder.php b/pandora_console/godmode/reporting/graph_builder.php index 9a171e6cba..79cb82302a 100644 --- a/pandora_console/godmode/reporting/graph_builder.php +++ b/pandora_console/godmode/reporting/graph_builder.php @@ -191,10 +191,14 @@ if ($add_module) { implode("','", $id_modules). "')"); - if (count($id_agent_modules) > 0 && $id_agent_modules != '') { - foreach($id_agent_modules as $id_agent_module) - $result = db_process_sql_insert('tgraph_source', array('id_graph' => $id_graph, 'id_agent_module' => $id_agent_module['id_agente_modulo'], 'weight' => $weight)); - } + if (count($id_agent_modules) > 0 && $id_agent_modules != '') { + $order = db_get_row_sql("SELECT `field_order` from tgraph_source ORDER BY `field_order` DESC"); + $order = $order['field_order']; + foreach($id_agent_modules as $id_agent_module){ + $order++; + $result = db_process_sql_insert('tgraph_source', array('id_graph' => $id_graph, 'id_agent_module' => $id_agent_module['id_agente_modulo'], 'weight' => $weight, 'field_order' => $order)); + } + } else $result = false; } diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index efd3183810..be28107f04 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1206,7 +1206,7 @@ CREATE TABLE IF NOT EXISTS `tgraph_source` ( `id_agent_module` int(11) NOT NULL default 0, `weight` float(8,3) NOT NULL DEFAULT 0, `label` varchar(150) DEFAULT '', - `order` int(10) DEFAULT 0, + `field_order` int(10) DEFAULT 0, PRIMARY KEY(`id_gs`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8;