2023-02-27 11:14:58 +01:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
|
|
|
* Copyright (C) DevCode s.n.c.
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
include_once __DIR__.'/../../core.php';
|
2023-05-19 17:15:30 +02:00
|
|
|
|
2023-02-27 11:14:58 +01:00
|
|
|
use Modules\Checklists\Check;
|
2023-03-13 16:22:50 +01:00
|
|
|
use Modules\Checklists\ChecklistItem;
|
2023-02-27 11:14:58 +01:00
|
|
|
|
2023-08-04 14:54:28 +02:00
|
|
|
switch (post('op')) {
|
|
|
|
case 'delete_check':
|
2023-02-27 11:14:58 +01:00
|
|
|
$id = post('id');
|
2023-03-13 16:22:50 +01:00
|
|
|
$main_check = post('main_check');
|
|
|
|
|
2023-08-04 14:54:28 +02:00
|
|
|
if ($main_check) {
|
2023-03-13 16:22:50 +01:00
|
|
|
$record = ChecklistItem::find($id);
|
2023-08-04 14:54:28 +02:00
|
|
|
} else {
|
2023-03-13 16:22:50 +01:00
|
|
|
$record = Check::find($id);
|
|
|
|
}
|
2023-02-27 11:14:58 +01:00
|
|
|
|
|
|
|
$record->delete();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2023-08-04 14:54:28 +02:00
|
|
|
case 'update_position':
|
2023-03-13 16:22:50 +01:00
|
|
|
$main_check = post('main_check');
|
2023-02-27 11:14:58 +01:00
|
|
|
$order = explode(',', post('order', true));
|
|
|
|
|
2023-08-04 14:54:28 +02:00
|
|
|
if ($main_check) {
|
|
|
|
foreach ($order as $i => $id) {
|
|
|
|
$dbo->query('UPDATE zz_checklist_items SET `order`='.prepare($i).' WHERE id='.prepare($id));
|
2023-03-13 16:22:50 +01:00
|
|
|
}
|
2023-08-04 14:54:28 +02:00
|
|
|
} else {
|
|
|
|
foreach ($order as $i => $id) {
|
|
|
|
$dbo->query('UPDATE zz_checks SET `order`='.prepare($i).' WHERE id='.prepare($id));
|
2023-03-13 16:22:50 +01:00
|
|
|
}
|
2023-02-27 11:14:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2023-08-04 14:54:28 +02:00
|
|
|
case 'save_checkbox':
|
2023-02-27 11:14:58 +01:00
|
|
|
$id = post('id');
|
|
|
|
|
|
|
|
$record = Check::find($id);
|
|
|
|
$record->checked_by = $user->id;
|
|
|
|
$record->checked_at = date('Y-m-d H:i:s');
|
|
|
|
$record->save();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2023-08-04 14:54:28 +02:00
|
|
|
case 'save_note':
|
2023-05-19 17:15:30 +02:00
|
|
|
$note = post('note');
|
|
|
|
$id = post('id');
|
|
|
|
|
|
|
|
$record = Check::find($id);
|
|
|
|
$record->note = $note;
|
|
|
|
$record->save();
|
|
|
|
|
|
|
|
flash()->info(tr('Nota salvata correttamente!'));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2023-08-04 14:54:28 +02:00
|
|
|
case 'remove_checkbox':
|
2023-02-27 11:14:58 +01:00
|
|
|
$id = post('id');
|
|
|
|
|
|
|
|
$record = Check::find($id);
|
2023-08-04 14:54:28 +02:00
|
|
|
$record->checked_by = null;
|
|
|
|
$record->checked_at = null;
|
2023-02-27 11:14:58 +01:00
|
|
|
$record->save();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2023-08-04 14:54:28 +02:00
|
|
|
case 'edit_check':
|
2023-02-27 11:14:58 +01:00
|
|
|
$id_record = post('id_record');
|
2023-03-13 16:22:50 +01:00
|
|
|
$main_check = post('main_check');
|
|
|
|
|
2023-08-04 14:54:28 +02:00
|
|
|
if ($main_check) {
|
2023-03-13 16:22:50 +01:00
|
|
|
$record = ChecklistItem::find($id_record);
|
2023-08-04 14:54:28 +02:00
|
|
|
} else {
|
2023-03-13 16:22:50 +01:00
|
|
|
$record = Check::find($id_record);
|
|
|
|
}
|
2023-02-27 11:14:58 +01:00
|
|
|
|
|
|
|
$record->content = post('content');
|
2023-07-21 17:19:43 +02:00
|
|
|
$record->is_titolo = post('is_titolo');
|
2023-02-27 11:14:58 +01:00
|
|
|
$record->save();
|
|
|
|
|
|
|
|
flash()->info(tr('Informazioni salvate correttamente!'));
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|