2017-08-04 16:28:16 +02:00
|
|
|
<?php
|
2020-09-07 15:04:06 +02:00
|
|
|
/*
|
|
|
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
2021-01-20 15:08:51 +01:00
|
|
|
* Copyright (C) DevCode s.r.l.
|
2020-09-07 15:04:06 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
include_once __DIR__.'/../../core.php';
|
|
|
|
|
|
|
|
switch (post('op')) {
|
|
|
|
case 'update':
|
2018-09-20 11:39:03 +02:00
|
|
|
$dbo->update('in_statiintervento', [
|
2020-01-14 17:20:19 +01:00
|
|
|
'codice' => post('codice'),
|
2018-09-20 11:39:03 +02:00
|
|
|
'descrizione' => post('descrizione'),
|
|
|
|
'colore' => post('colore'),
|
2020-03-12 22:07:28 +01:00
|
|
|
'is_completato' => post('is_completato'),
|
|
|
|
'is_fatturabile' => post('is_fatturabile'),
|
2018-09-20 11:39:03 +02:00
|
|
|
'notifica' => post('notifica'),
|
2021-02-02 13:01:27 +01:00
|
|
|
'notifica_cliente' => post('notifica_cliente'),
|
|
|
|
'notifica_tecnici' => post('notifica_tecnici'),
|
2018-10-26 19:33:45 +02:00
|
|
|
'id_email' => post('email') ?: null,
|
2018-09-20 11:39:03 +02:00
|
|
|
'destinatari' => post('destinatari'),
|
|
|
|
], ['idstatointervento' => $id_record]);
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2018-07-19 17:29:21 +02:00
|
|
|
flash()->info(tr('Informazioni salvate correttamente.'));
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'add':
|
2020-01-14 17:20:19 +01:00
|
|
|
$codice = post('codice');
|
2017-08-04 16:28:16 +02:00
|
|
|
$descrizione = post('descrizione');
|
|
|
|
$colore = post('colore');
|
2018-02-18 19:53:23 +01:00
|
|
|
|
2020-01-14 17:20:19 +01:00
|
|
|
//controllo che il codice non sia duplicato
|
|
|
|
if (count($dbo->fetchArray('SELECT idstatointervento FROM in_statiintervento WHERE codice='.prepare($codice))) > 0) {
|
|
|
|
flash()->warning(tr('Attenzione: lo stato attività _COD_ risulta già esistente.', [
|
|
|
|
'_COD_' => $codice,
|
|
|
|
]));
|
2018-02-18 19:53:23 +01:00
|
|
|
} else {
|
2020-01-14 17:20:19 +01:00
|
|
|
$query = 'INSERT INTO in_statiintervento(codice, descrizione, colore) VALUES ('.prepare($codice).', '.prepare($descrizione).', '.prepare($colore).')';
|
2018-02-18 19:53:23 +01:00
|
|
|
$dbo->query($query);
|
2019-07-08 16:45:00 +02:00
|
|
|
$id_record = $database->lastInsertedID();
|
2020-01-14 17:20:19 +01:00
|
|
|
flash()->info(tr('Nuovo stato attività aggiunto.'));
|
2018-02-18 19:53:23 +01:00
|
|
|
}
|
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'delete':
|
2018-02-18 19:53:23 +01:00
|
|
|
|
|
|
|
//scelgo se settare come eliminato o cancellare direttamente la riga se non è stato utilizzato negli interventi
|
2018-03-24 14:24:17 +01:00
|
|
|
if (count($dbo->fetchArray('SELECT id FROM in_interventi WHERE idstatointervento='.prepare($id_record))) > 0) {
|
2018-07-17 08:05:19 +02:00
|
|
|
$query = 'UPDATE in_statiintervento SET deleted_at = NOW() WHERE idstatointervento='.prepare($id_record).' AND `can_delete`=1';
|
2018-02-18 19:53:23 +01:00
|
|
|
} else {
|
|
|
|
$query = 'DELETE FROM in_statiintervento WHERE idstatointervento='.prepare($id_record).' AND `can_delete`=1';
|
|
|
|
}
|
|
|
|
|
|
|
|
$dbo->query($query);
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2020-01-23 12:48:46 +01:00
|
|
|
flash()->info(tr('Stato attività eliminato.'));
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|