Aggiunto modulo Stati degli ordini

This commit is contained in:
MatteoPistorello 2023-07-24 17:27:27 +02:00
parent e455835d2d
commit a25a666de8
9 changed files with 296 additions and 1 deletions

View File

@ -102,6 +102,7 @@
"Modules\\StatiIntervento\\": ["modules/stati_intervento/custom/src/", "modules/stati_intervento/src/"],
"Modules\\StatiPreventivo\\": ["modules/stati_preventivo/custom/src/", "modules/stati_preventivo/src/"],
"Modules\\StatiContratto\\": ["modules/stati_contratto/custom/src/", "modules/stati_contratto/src/"],
"Modules\\StatiOrdine\\": ["modules/stati_ordine/custom/src/", "modules/stati_ordine/src/"],
"Modules\\TipiIntervento\\": ["modules/tipi_intervento/custom/src/", "modules/tipi_intervento/src/"],
"Modules\\CategorieDocumentali\\": ["modules/categorie_documenti/custom/src/", "modules/categorie_documenti/src/"],
"Modules\\PianiSconto\\": ["modules/piano_sconto/custom/src/", "modules/piano_sconto/src/"],

View File

@ -59,6 +59,7 @@ if ($record['can_delete']) {
<?php
$contratti = $dbo->fetchNum('SELECT id FROM co_contratti WHERE idstato='.prepare($id_record));
if (!empty($contratti)) {
echo '

View File

@ -0,0 +1,68 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* 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';
switch (post('op')) {
case 'update':
$dbo->update('or_statiordine', [
'descrizione' => (count($dbo->fetchArray('SELECT descrizione FROM or_statiordine WHERE descrizione = '.prepare(post('descrizione')))) > 0) ? $dbo->fetchOne('SELECT descrizione FROM or_statiordine WHERE id ='.$id_record)['descrizione'] : post('descrizione'),
'icona' => post('icona'),
'completato' => post('completato') ?: null,
'is_fatturabile' => post('is_fatturabile') ?: null,
'impegnato' => post('impegnato') ?: null,
], ['id' => $id_record]);
flash()->info(tr('Informazioni salvate correttamente.'));
break;
case 'add':
$descrizione = post('descrizione');
$icona = post('icona');
$completato = post('completato') ?: null;
$is_fatturabile = post('is_fatturabile') ?: null;
$impegnato = post('impegnato') ?: null;
//controlla descrizione che non sia duplicata
if (count($dbo->fetchArray('SELECT descrizione FROM or_statiordine WHERE descrizione='.prepare($descrizione))) > 0) {
flash()->error(tr('Stato ordine già esistente.'));
} else {
$query = 'INSERT INTO or_statiordine(descrizione, icona, completato, is_fatturabile, impegnato) VALUES ('.prepare($descrizione).', '.prepare($icona).', '.prepare($completato).', '.prepare($is_fatturabile).', '.prepare($impegnato).' )';
$dbo->query($query);
$id_record = $dbo->lastInsertedID();
flash()->info(tr('Nuovo stato ordine aggiunto.'));
}
break;
case 'delete':
//scelgo se settare come eliminato o cancellare direttamente la riga se non è stato utilizzato negli ordini
if (count($dbo->fetchArray('SELECT id FROM or_statiordine WHERE idstato='.prepare($id_record))) > 0) {
$query = 'UPDATE or_statiordine SET deleted_at = NOW() WHERE can_delete = 1 AND id='.prepare($id_record);
} else {
$query = 'DELETE FROM or_statiordine WHERE can_delete = 1 AND id='.prepare($id_record);
}
$dbo->query($query);
flash()->info(tr('Stato ordine eliminato.'));
break;
}

View File

@ -0,0 +1,55 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* 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';
?><form action="" method="post" id="add-form">
<input type="hidden" name="op" value="add">
<input type="hidden" name="backto" value="record-edit">
<div class="row">
<div class="col-md-12">
{[ "type": "text", "label": "<?php echo tr('Descrizione'); ?>", "name": "descrizione", "required": 1 ]}
</div>
</div>
<div class="row">
<div class="col-md-2">
{[ "type": "checkbox", "label": "<?php echo tr('Completato'); ?>", "name": "completato", "value": "$completato$", "help": "<?php echo tr('Gli ordini che si trovano in questo stato verranno considerati come completati'); ?>", "placeholder": "<?php echo tr('Completato'); ?>", "extra": "" ]}
</div>
<div class="col-md-2">
{[ "type": "checkbox", "label": "<?php echo tr('Impegnato'); ?>", "name": "impegnato", "value": "$impegnato$", "help": "<?php echo tr('Gli ordini che si trovano in questo stato verranno considerati come pianificabili'); ?>", "placeholder": "<?php echo tr('Impegnato'); ?>", "extra": "" ]}
</div>
<div class="col-md-2">
{[ "type": "checkbox", "label": "<?php echo tr('Fatturabile'); ?>", "name": "is_fatturabile", "value": "$is_fatturabile$", "help": "<?php echo tr('Gli ordini che si trovano in questo stato verranno considerati come fatturabili'); ?>", "placeholder": "<?php echo tr('Fatturabile'); ?>", "extra": "" ]}
</div>
<div class="col-md-6">
{[ "type": "text", "label": "<?php echo tr('Icona'); ?>", "name": "icona", "required": 1, "class": "text-center", "value": "fa ", "extra": "" ]}
</div>
</div>
<!-- PULSANTI -->
<div class="row">
<div class="col-md-12 text-right">
<button type="submit" class="btn btn-primary"><i class="fa fa-plus"></i> <?php echo tr('Aggiungi'); ?></button>
</div>
</div>
</form>

View File

@ -0,0 +1,80 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* 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';
if ($record['can_delete']) {
$attr = '';
} else {
$attr = 'readonly';
echo '<div class="alert alert-warning">'.tr('Alcune impostazioni non possono essere modificate per questo stato.').'</div>';
}
?>
<form action="" method="post" id="edit-form">
<input type="hidden" name="op" value="update">
<input type="hidden" name="backto" value="record-edit">
<input type="hidden" name="id_record" value="<?php echo $id_record; ?>">
<div class="row">
<div class="col-md-5">
{[ "type": "text", "label": "<?php echo tr('Descrizione'); ?>", "name": "descrizione", "required": 1, "value": "$descrizione$", "extra": "<?php echo $attr; ?>" ]}
</div>
<div class="col-md-4">
{[ "type": "text", "label": "<?php echo tr('Icona'); ?>", "name": "icona", "required": 1, "class": "text-center", "value": "$icona$", "extra": "", "icon-after": "<?php echo (!empty($record['icona'])) ? '<i class=\"'.$record['icona'].'\"></i>' : ''; ?>" ]}
</div>
<div class="col-md-3">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title"><?php echo tr('Flags'); ?></h3>
</div>
<div class="panel-body">
{[ "type": "checkbox", "label": "<?php echo tr('Completato?'); ?>", "name": "completato", "value": "$completato$", "help": "<?php echo tr('Gli ordini che si trovano in questo stato verranno considerati come completati'); ?>", "placeholder": "<?php echo tr('Completato'); ?>", "extra": "" ]}
{[ "type": "checkbox", "label": "<?php echo tr('Impegnato?'); ?>", "name": "impegnato", "value": "$impegnato$", "help": "<?php echo tr('Gli ordini che si trovano in questo stato verranno considerati come impegnati'); ?>", "placeholder": "<?php echo tr('Impegnato'); ?>", "extra": "" ]}
{[ "type": "checkbox", "label": "<?php echo tr('Fatturabile?'); ?>", "name": "is_fatturabile", "value": "$is_fatturabile$", "help": "<?php echo tr('Gli ordini che si trovano in questo stato verranno considerati come fatturabili'); ?>", "placeholder": "<?php echo tr('Fatturabile'); ?>", "extra": "" ]}
</div>
</div>
</div>
</div>
</form>
<?php
$ordini = $dbo->fetchNum('SELECT id FROM or_ordini WHERE idstatoordine='.prepare($id_record));
if (!empty($ordini)) {
echo '
<div class="alert alert-danger">
'.tr('Ci sono _NUM_ ordini collegati', [
'_NUM_' => $ordini,
]).'.
</div>';
}
if (!empty($record['can_delete'])) {
echo '
<a class="btn btn-danger ask" data-backto="record-list">
<i class="fa fa-trash"></i> '.tr('Elimina').'
</a>';
}
?>

View File

@ -0,0 +1,24 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* 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';
if (isset($id_record)) {
$record = $dbo->fetchOne('SELECT * FROM or_statiordine WHERE id='.prepare($id_record));
}

View File

@ -0,0 +1,45 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* 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/>.
*/
namespace Modules\StatiOrdine\API\v1;
use API\Interfaces\RetrieveInterface;
use API\Resource;
class StatiOrdini extends Resource implements RetrieveInterface
{
public function retrieve($request)
{
$table = 'or_statiordine';
$select = [
'*',
];
$where = $request['where'];
if (empty($where['deleted_at'])) {
$where['deleted_at'] = null;
}
return [
'select' => $select,
'table' => $table,
];
}
}

View File

@ -65,6 +65,7 @@ if ($record['can_delete']) {
<?php
$preventivi = $dbo->fetchNum('SELECT id FROM co_preventivi WHERE idstato='.prepare($id_record));
if (!empty($preventivi)) {
echo '

View File

@ -16,4 +16,24 @@ INSERT INTO `zz_settings` (`nome`, `valore`, `tipo`, `editable`, `sezione`, `ord
-- Aggiunta impostazione titolo checklist
ALTER TABLE `zz_checks` ADD `is_titolo` BOOLEAN NOT NULL AFTER `id_parent`;
ALTER TABLE `zz_checklist_items` ADD `is_titolo` BOOLEAN NOT NULL AFTER `id_parent`;
ALTER TABLE `zz_checklist_items` ADD `is_titolo` BOOLEAN NOT NULL AFTER `id_parent`;
-- Aggiunto modulo Stati ordini
INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Stati degli ordini', 'Stati degli ordini','stati_ordine', 'SELECT |select| FROM `or_statiordine` WHERE 1=1 AND deleted_at IS NULL HAVING 2=2', '', 'fa fa-angle-right', '2.4.48', '2.4.48', '1', (SELECT `id` FROM `zz_modules` t WHERE t.`name` = 'Tabelle'), '1', '1');
INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `default`, `visible`) VALUES
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stati degli ordini'), 'Fatturabile', 'IF(is_fatturabile, ''S&igrave;'', ''No'')', 6, 1, 0, 0 ,1),
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stati degli ordini'), 'Completato', 'IF(completato, ''S&igrave;'', ''No'')', 5, 1, 0, 0, 1),
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stati degli ordini'), 'Impegnato', 'IF(impegnato, ''S&igrave;'', ''No'')', 4, 1, 0, 0, 1),
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stati degli ordini'), 'Icona', 'icona', 3, 1, 0, 0, 1),
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stati degli ordini'), 'Descrizione', 'descrizione', 2, 1, 0, 0, 1),
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stati degli ordini'), 'id', 'id', 1, 0, 0, 1, 0);
-- Aggiunto flag can_delete in stati ordini
ALTER TABLE `or_statiordine` ADD `deleted_at` DATETIME NULL;
ALTER TABLE `or_statiordine` ADD `can_delete` BOOLEAN NOT NULL DEFAULT TRUE;
UPDATE `or_statiordine` SET `can_delete` = '0';
-- Aggiunta risorsa api stati ordine
INSERT INTO `zz_api_resources` (`id`, `version`, `type`, `resource`, `class`, `enabled`) VALUES
(NULL, 'v1', 'retrieve', 'stati_ordine', 'Modules\\StatiOrdine\\API\\v1\\StatiOrdini', '1');