Skip to content

Commit 7789380

Browse files
feat: gestione soft delete sedi
1 parent 4e96893 commit 7789380

4 files changed

Lines changed: 12 additions & 6 deletions

File tree

modules/anagrafiche/ajax/select.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@
381381
SELECT
382382
*
383383
FROM
384-
(SELECT '0' AS id, (SELECT `lat` FROM `an_anagrafiche` |where|) AS lat, (SELECT `lng` FROM `an_anagrafiche` |where|) AS lng, (SELECT `idzona` FROM `an_anagrafiche` |where|) AS idzona, CONCAT_WS(' - ', \"".tr('Sede legale')."\" , (SELECT CONCAT (`citta`, IF(`indirizzo`!='',CONCAT(' (', `indirizzo`, ')'), ''), ' (',`ragione_sociale`,')') FROM `an_anagrafiche` |where|)) AS descrizione
384+
(SELECT '0' AS id, (SELECT `lat` FROM `an_anagrafiche` |where|) AS lat, (SELECT `lng` FROM `an_anagrafiche` |where|) AS lng, NULL AS deleted_at, (SELECT `idzona` FROM `an_anagrafiche` |where|) AS idzona, CONCAT_WS(' - ', \"".tr('Sede legale')."\" , (SELECT CONCAT (`citta`, IF(`indirizzo`!='',CONCAT(' (', `indirizzo`, ')'), ''), ' (',`ragione_sociale`,')') FROM `an_anagrafiche` |where|)) AS descrizione
385385
386386
UNION
387387
@@ -390,6 +390,7 @@
390390
`lat`,
391391
`lng`,
392392
`idzona`,
393+
`deleted_at`,
393394
CONCAT_WS(' - ', `nomesede`, CONCAT(`citta`, IF(indirizzo!='',CONCAT(' (', `indirizzo`, ')'), '')) ) FROM `an_sedi` |where|) AS tab
394395
HAVING
395396
`descrizione` LIKE ".prepare('%'.$search.'%').'
@@ -400,6 +401,10 @@
400401
$filter[] = '`id`='.prepare($element);
401402
}
402403

404+
if (empty($filter)) {
405+
$where[] = 'an_sedi.deleted_at IS NULL';
406+
}
407+
403408
$where[] = '`idanagrafica`='.prepare($superselect['idanagrafica']);
404409

405410
/*

plugins/sedi/actions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132

133133
case 'deletesede':
134134
$id = filter('id');
135-
$dbo->query('DELETE FROM `an_sedi` WHERE `id` = '.prepare($id).'');
135+
$dbo->query('UPDATE `an_sedi` SET deleted_at = NOW() WHERE `id` = '.prepare($id));
136136

137137
flash()->info(tr('Sede eliminata!'));
138138

plugins/sedi/edit.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,6 @@
226226
</ul>
227227
</div>
228228
</div>';
229-
230-
$disabled = 'disabled';
231229
}
232230

233231
$espandi_dettagli = setting('Espandi automaticamente la sezione "Dettagli aggiuntivi"');
@@ -265,7 +263,7 @@
265263
<!-- PULSANTI -->
266264
<div class="modal-footer">
267265
<div class="col-md-12">
268-
<button type="button" class="btn btn-danger '.$disabled.'" onclick="rimuoviSede(this)">
266+
<button type="button" class="btn btn-danger" onclick="rimuoviSede(this)">
269267
<i class="fa fa-trash"></i> '.tr('Elimina').'
270268
</button>
271269

update/2_10.sql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,4 +399,7 @@ INSERT INTO `zz_views_lang` (`id_lang`, `id_record`, `title`) VALUES
399399
('2', (SELECT MAX(id)-1 FROM `zz_views`), 'id'),
400400
('2', (SELECT MAX(id) FROM `zz_views`), 'Description');
401401

402-
DROP TABLE IF EXISTS `an_sedi_tecnici`;
402+
DROP TABLE IF EXISTS `an_sedi_tecnici`;
403+
404+
-- Aggiunta campo deleted_at per gestire eliminazione sedi
405+
ALTER TABLE `an_sedi` ADD `deleted_at` TIMESTAMP NULL AFTER `enable_newsletter`;

0 commit comments

Comments
 (0)