From 1dfc49088ca143d0d8f084c184c34e28c2641ed3 Mon Sep 17 00:00:00 2001 From: Matteo Date: Mon, 4 Oct 2021 11:27:05 +0200 Subject: [PATCH] Aggiunta ordinamento righe in interventi --- modules/interventi/actions.php | 9 +++++++++ modules/interventi/row-list.php | 25 ++++++++++++++++++++++++- update/2_4_27.sql | 5 ++++- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/modules/interventi/actions.php b/modules/interventi/actions.php index e71332322..716c431db 100644 --- a/modules/interventi/actions.php +++ b/modules/interventi/actions.php @@ -739,5 +739,14 @@ switch (post('op')) { flash()->info(tr('Attività duplicata correttamente!')); + break; + + case 'update_position': + $order = explode(',', post('order', true)); + + foreach ($order as $i => $id_riga) { + $dbo->query('UPDATE `in_righe_interventi` SET `order` = '.prepare($i + 1).' WHERE id='.prepare($id_riga)); + } + break; } diff --git a/modules/interventi/row-list.php b/modules/interventi/row-list.php index 2156a297d..03d3184d3 100755 --- a/modules/interventi/row-list.php +++ b/modules/interventi/row-list.php @@ -47,7 +47,7 @@ if (!$righe->isEmpty()) { - '; + '; foreach ($righe as $riga) { $extra = ''; @@ -158,6 +158,10 @@ if (!$righe->isEmpty()) { + + + + '; echo ' @@ -234,4 +238,23 @@ function modificaSeriali(button) { openModal("'.tr('Aggiorna SN').'", globals.rootdir + "/modules/fatture/add_serial.php?id_module=" + globals.id_module + "&id_record=" + globals.id_record + "&riga_id=" + id + "&riga_type=" + type); } + +$(document).ready(function() { + sortable(".sortable", { + axis: "y", + handle: ".handle", + cursor: "move", + dropOnEmpty: true, + scroll: true, + })[0].addEventListener("sortupdate", function(e) { + let order = $(".table tr[data-id]").toArray().map(a => $(a).data("id")) + + $.post(globals.rootdir + "/actions.php", { + id_module: globals.id_module, + id_record: globals.id_record, + op: "update_position", + order: order.join(","), + }); + }); +}); '; diff --git a/update/2_4_27.sql b/update/2_4_27.sql index a553a5b2b..94326e26a 100644 --- a/update/2_4_27.sql +++ b/update/2_4_27.sql @@ -9,4 +9,7 @@ INSERT INTO `zz_group_module` (`idgruppo`, `idmodule`, `name`, `clause`, `positi UPDATE `zz_cache` SET `valid_time` = '1 day' WHERE `zz_cache`.`name` = 'Informazioni su Services'; -- Ridotto il valid time per la cache informazioni su spazio FE -UPDATE `zz_cache` SET `valid_time` = '1 day' WHERE `zz_cache`.`name` = 'Informazioni su spazio FE'; \ No newline at end of file +UPDATE `zz_cache` SET `valid_time` = '1 day' WHERE `zz_cache`.`name` = 'Informazioni su spazio FE'; + +-- Ordinamento righe intervento +ALTER TABLE `in_righe_interventi` ADD `order` INT NOT NULL AFTER `idsede_partenza`;