openstamanager/modules/checklists/actions.php

84 lines
2.3 KiB
PHP
Raw Permalink Normal View History

2019-07-29 13:16:55 +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/>.
*/
2019-07-29 13:16:55 +02:00
include_once __DIR__.'/../../core.php';
use Modules\Checklists\Checklist;
use Modules\Checklists\ChecklistItem;
switch (post('op')) {
case 'add':
$record = Checklist::build(post('name'));
$record->id_module = post('module') ?: null;
$record->id_plugin = post('plugin') ?: null;
$record->save();
$id_record = $record->id;
flash()->info(tr('Nuova checklist creata!'));
break;
case 'update':
2024-03-26 18:05:18 +01:00
$record->name = post('name');
2019-07-29 13:16:55 +02:00
$record->id_module = post('module') ?: null;
$record->id_plugin = post('plugin') ?: null;
$record->save();
flash()->info(tr('Informazioni salvate correttamente!'));
break;
case 'delete':
$record->delete();
flash()->info(tr('Checklist eliminata!'));
break;
case 'add_item':
$content = post('content');
$parent_id = post('parent') ?: null;
$is_titolo = post('is_titolo');
$item = ChecklistItem::build($record, $content, $parent_id, $is_titolo);
2019-07-29 13:16:55 +02:00
flash()->info(tr('Nuova riga della checklist creata!'));
break;
case 'delete_item':
$item = ChecklistItem::find(post('check_id'));
$item->delete();
flash()->info(tr('Riga della checklist eliminata!'));
2019-07-30 16:50:10 +02:00
break;
case 'update_position':
2020-08-06 11:34:32 +02:00
$order = explode(',', post('order', true));
2019-07-30 16:50:10 +02:00
2020-08-06 11:34:32 +02:00
foreach ($order as $i => $id_riga) {
$dbo->query('UPDATE `zz_checklist_items` SET `order` = '.prepare($i).' WHERE id='.prepare($id_riga));
2019-07-30 16:50:10 +02:00
}
2019-07-29 13:16:55 +02:00
break;
}