Changed custom graph item insertion and deletion to fix bug when sorting elements in list

This commit is contained in:
alejandro-campos 2018-09-19 10:06:57 +02:00
parent c2b5133ff2
commit 3f046441f0

View File

@ -195,7 +195,8 @@ if ($add_module) {
"')");
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 = db_get_row_sql("SELECT `field_order` from tgraph_source WHERE id_graph=$id_graph ORDER BY `field_order` DESC");
$order = $order['field_order'];
foreach($id_agent_modules as $id_agent_module){
$order++;
@ -207,8 +208,13 @@ if ($add_module) {
}
if ($delete_module) {
$id_graph = get_parameter('id');
$deleteGraph = get_parameter('delete');
$order_val = db_get_value('field_order', 'tgraph_source', 'id_gs', $deleteGraph);
$result = db_process_sql_delete('tgraph_source', array('id_gs' => $deleteGraph));
db_process_sql ('UPDATE tgraph_source SET field_order=field_order-1 WHERE id_graph='.$id_graph.' AND field_order>'.$order_val);
}
if ($change_weight) {