Aggiunta ordinamento righe in interventi

This commit is contained in:
Matteo 2021-10-04 11:27:05 +02:00
parent 107229de44
commit 1dfc49088c
3 changed files with 37 additions and 2 deletions

View File

@ -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;
}

View File

@ -47,7 +47,7 @@ if (!$righe->isEmpty()) {
</tr>
</thead>
<tbody>';
<tbody class="sortable">';
foreach ($righe as $riga) {
$extra = '';
@ -158,6 +158,10 @@ if (!$righe->isEmpty()) {
<a class="btn btn-xs btn-danger" title="'.tr('Rimuovi riga').'" onclick="rimuoviRiga(this)">
<i class="fa fa-trash"></i>
</a>
<a class="btn btn-xs btn-default handle" title="'.tr('Modifica ordine delle righe').'">
<i class="fa fa-sort"></i>
</a>
</div>';
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(","),
});
});
});
</script>';

View File

@ -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';
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`;