Merge branch '2452-Fallo-recalculo-custom-graph' into 'develop'

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

See merge request artica/pandorafms!1782
This commit is contained in:
vgilc 2018-10-25 13:20:30 +02:00
commit 9aed441246

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) {