diff --git a/modules/viste/actions.php b/modules/viste/actions.php index 40d0c34c8..6bf51c65c 100644 --- a/modules/viste/actions.php +++ b/modules/viste/actions.php @@ -163,17 +163,16 @@ switch (filter('op')) { break; case 'update_position': - $start = filter('start') + 1; - $end = filter('end') + 1; - $id = filter('id'); + + $orders = explode(",", $_POST['order']); + $order = 0; - if ($start > $end) { - $dbo->query('UPDATE `zz_views` SET `order`=`order` + 1 WHERE `order`>='.prepare($end).' AND `order`<'.prepare($start).' AND id_module='.prepare($id_record)); - $dbo->query('UPDATE `zz_views` SET `order`='.prepare($end).' WHERE id='.prepare($id)); - } elseif ($end != $start) { - $dbo->query('UPDATE `zz_views` SET `order`=`order` - 1 WHERE `order`>'.prepare($start).' AND `order`<='.prepare($end).' AND id_module='.prepare($id_record)); - $dbo->query('UPDATE `zz_views` SET `order`='.prepare($end).' WHERE id='.prepare($id)); + foreach ($orders as $idriga) { + $dbo->query('UPDATE `zz_views` SET `order`='.prepare($order).' WHERE id='.prepare($idriga)); + $order++; } - + break; + + } diff --git a/modules/viste/edit.php b/modules/viste/edit.php index 92a3b3428..e8164058a 100644 --- a/modules/viste/edit.php +++ b/modules/viste/edit.php @@ -217,15 +217,15 @@ if (!empty($options) && $options != 'custom') {
- +
+ '; if ($field['visible']) { echo ''.$field['name'].''; @@ -499,24 +499,27 @@ $(document).ready(function(){ cursor: "move", dropOnEmpty: true, scroll: true, - start: function(event, ui) { - ui.item.data("start", ui.item.index()); - }, update: function(event, ui) { - $.get("'.$rootdir.'/actions.php", { + + var order = ""; + $("div.panel-body.sortable p[data-id]").each( function(){ + order += ","+$(this).data("id"); + }); + + order = order.replace(/^,/, ""); + + $.post("'.$rootdir.'/actions.php", { id: ui.item.data("id"), id_module: '.$id_module.', id_record: '.$id_record.', op: "update_position", - start: ui.item.data("start"), - end: ui.item.index() + order: order, }); } }); }); }); '; - // Fix apertura non corrisposta di un tag div echo '