Aggiunta modulo Gestione task

This commit is contained in:
Pek5892 2023-10-27 10:23:52 +02:00
parent 543e39d6cc
commit 8dba03e2bb
4 changed files with 238 additions and 1 deletions

View File

@ -0,0 +1,37 @@
<?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('zz_tasks', [
'name' => (count($dbo->fetchArray('SELECT `name` FROM `zz_tasks` WHERE `name` = '.prepare(post('name')))) > 0) ? $dbo->fetchOne('SELECT `name` FROM `zz_tasks` WHERE `id` ='.$id_record)['name'] : post('name'),
'class' => post('class'),
'expression' => post('expression'),
], ['id' => $id_record]);
flash()->info(tr('Informazioni salvate correttamente.'));
break;
}

View File

@ -0,0 +1,165 @@
<?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';
echo '
<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="'.$id_record.'">
<div class="row">
<div class="col-md-3">
{[ "type": "text", "label": "'.tr('Nome').'", "name": "name", "required": 1, "value": "$name$" ]}
</div>
<div class="col-md-3">
{[ "type": "text", "label": "'.tr('Classe').'", "name": "class", "required": 1, "value": "$class$" ]}
</div>
<div class="col-md-3">
{[ "type": "date", "label": "'.tr('Data prossima esecuzione').'", "name": "next_execution_at", "value": "$next_execution_at$", "readonly": 1 ]}
</div>
<div class="col-md-3">
{[ "type": "date", "label": "'.tr('Data precedente esecuzione').'", "name": "last_executed_at", "value": "$last_executed_at$", "readonly": 1 ]}
</div>
</div>
<div class="row">
<div class="col-md-offset-3 col-md-6">
{[ "type": "text", "label": "'.tr('Espressione').'", "name": "expression", "required": 1, "class": "text-center", "value": "$expression$", "extra": "", "readonly": 1 ]}
</div>';
$expression = $record['expression'];
preg_match('/(.*?) (.*?) (.*?) (.*?) (.*?)/U', $record['expression'], $exp);
$minuto = $exp[1];
$ora = $exp[2];
$giorno = $exp[3];
$mese = $exp[4];
$giorno_sett = $exp[5];
echo '
</div>
<div class="row">
<div class="col-md-offset-3 col-md-3">
{[ "type": "text", "label": "'.tr('Minuto').'", "name": "minuto", "required": 1, "class": "text-center", "value": "'.$minuto.'", "readonly": 1]}
</div>
<div class="col-md-3">
{[ "type": "select", "label": "'.tr('&nbsp').'", "name": "minuti", "value": "'.$minuto.'", "values":"list=\"*\": \"'.tr('Una volta al minuto (*)').'\",\"*/5\": \"'.tr('Una volta ogni cinque minuti (*/5)').'\",\"0,30\": \"'.tr('Una volta ogni trenta minuti (0,30)').'\",\"5\": \"'.tr('Al minuto 5 dell\'ora (5)').'\",\" \": \"'.tr('Personalizzato').'\""]}
</div>
</div>
<div class="row">
<div class="col-md-offset-3 col-md-3">
{[ "type": "text", "label": "'.tr('Ora').'", "name": "ora", "required": 1, "class": "text-center", "value": "'.$ora.'", "extra": "", "readonly": 1 ]}
</div>
<div class="col-md-3">
{[ "type": "select", "label": "'.tr('&nbsp').'", "name": "ore", "value": "'.$ora.'", "values":"list=\"*\": \"'.tr('Ogni ora (*)').'\",\"*/2\": \"'.tr('Ogni due ore (*/2)').'\",\"*/4\": \"'.tr('Ogni 15 minuti (*/4)').'\",\"0,12\": \"'.tr('Ogni 12 ore (0,12)').'\",\"5\": \"'.tr('5:00 a.m. (5)').'\",\"17\": \"'.tr('5:00 p.m. (17)').'\",\" \": \"'.tr('Personalizzato').'\""]}
</div>
</div>
<div class="row">
<div class="col-md-offset-3 col-md-3">
{[ "type": "text", "label": "'.tr('Giorno').'", "name": "giorno", "required": 1, "class": "text-center", "value": "'.$giorno.'", "extra": "", "readonly": 1]}
</div>
<div class="col-md-3">
{[ "type": "select", "label": "'.tr('&nbsp').'", "name": "giorni", "value": "'.$giorno.'", "values":"list=\"*\": \"'.tr('Ogni giorno (*)').'\",\"*/2\": \"'.tr('Ogni due giorni (*/2)').'\",\"1,15\": \"'.tr('Il primo e il 15 del mese (1,15)').'\",\"8\": \"'.tr('Il giorno 8 del mese (8)').'\",\" \": \"'.tr('Personalizzato').'\""]}
</div>
</div>
<div class="row">
<div class="col-md-offset-3 col-md-3">
{[ "type": "text", "label": "'.tr('Mese').'", "name": "mese", "required": 1, "class": "text-center", "value": "'.$mese.'", "extra": "", "readonly": 1]}
</div>
<div class="col-md-3">
{[ "type": "select", "label": "'.tr('&nbsp').'", "name": "mesi", "value": "'.$mese.'", "values":"list=\"*\": \"'.tr('Ogni mese (*)').'\",\"*/2\": \"'.tr('Ogni due mesi (*/2)').'\",\"1,7\": \"'.tr('Ogni 6 mesi (1,7)').'\",\"8\": \"'.tr('Agosto (8)').'\",\" \": \"'.tr('Personalizzato').'\""]}
</div>
</div>
<div class="row">
<div class="col-md-offset-3 col-md-3">
{[ "type": "text", "label": "'.tr('Giorno della settimana').'", "name": "giorno_sett", "required": 1, "class": "text-center", "value": "'.$giorno_sett.'", "extra": "", "readonly": 1]}
</div>
<div class="col-md-3">
{[ "type": "select", "label": "'.tr('&nbsp').'", "name": "giorni_sett", "value": "'.$giorno_sett.'", "values":"list=\"*\": \"'.tr('Ogni giorno (*)').'\",\"*/1-5\": \"'.tr('Ogni giorno della settimana (1-5)').'\",\"0,6\": \"'.tr('Ogni giorno del weekend (0,6)').'\",\"1,3,5\": \"'.tr('Ogni Lunedì, Mercoledì e Venerdì (1,3,5)').'\",\" \": \"'.tr('Personalizzato').'\""]}
</div>
</div>
</form>';
?>
<script>
// Alla modifica di un campo select aggiorna il corrispondente campo input, se viene selezionato "Personalizzato" abilita il campo input, altrimenti lo disabilita. Aggiorna infine l'espressione.
function updateField() {
var fieldData = [
{ select: 'minuti', input: 'minuto' },
{ select: 'ore', input: 'ora' },
{ select: 'giorni', input: 'giorno' },
{ select: 'mesi', input: 'mese' },
{ select: 'giorni_sett', input: 'giorno_sett' }
];
fieldData.forEach(function(field) {
var $select = $('select[name="' + field.select + '"]');
var $input = $('input[name="' + field.input + '"]');
var value = $select.val();
if (value == ' ') {
$input.removeAttr('readonly');
} else if (value == '') {
$select.selectSet(' ');
} else {
$input.attr('readonly', 'readonly');
$input.val(value);
}
});
}
$('select[name="minuti"], select[name="ore"], select[name="giorni"], select[name="mesi"], select[name="giorni_sett"]').on('change', function() {
updateField();
updateExpression();
});
//Aggiorna l'expression alla modifica dei campi input
function updateExpression() {
var $minuto = $('input[name="minuto"]').val();
var $ora = $('input[name="ora"]').val();
var $giorno = $('input[name="giorno"]').val();
var $mese = $('input[name="mese"]').val();
var $giorno_sett = $('input[name="giorno_sett"]').val();
var $expression = $minuto + ' ' + $ora + ' ' + $giorno + ' ' + $mese + ' ' + $giorno_sett;
$('input[name="expression"]').val($expression);
}
$('input[name="minuto"], input[name="ora"], input[name="giorno"], input[name="mese"], input[name="giorno_sett"]').on('change', updateExpression);
// Se nell'input è inserito un valore personalizzato, seleziona Personalizzato nel select
var fieldData = [
{ select: 'minuti', input: 'minuto' },
{ select: 'ore', input: 'ora' },
{ select: 'giorni', input: 'giorno' },
{ select: 'mesi', input: 'mese' },
{ select: 'giorni_sett', input: 'giorno_sett' }
];
fieldData.forEach(function(field) {
var $select = $('select[name="' + field.select + '"]');
var $input = $('input[name="' + field.input + '"]');
var value = $select.val();
if (value == '') {
$select.selectSet(' ');
}
});
</script>

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 zz_tasks WHERE id='.prepare($id_record));
}

View File

@ -50,4 +50,15 @@ INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`,
INSERT INTO `zz_settings` (`nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES ("Crea contratto rinnovabile di default", '0', 'boolean', 1, 'Contratti', 2, 'Attivando questa impostazione i nuovi contratti creati saranno impostati automaticamente come Rinnovabili.');
-- Aggiunta impostazione Giorni di preavviso di default alla creazione di un contratto
INSERT INTO `zz_settings` (`nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES ("Giorni di preavviso di default", '2', 'decimal', 1, 'Contratti', 3, 'Inserire il numero di giorni di preavviso da impostare automaticamente alla creazione di un contratto.');
INSERT INTO `zz_settings` (`nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES ("Giorni di preavviso di default", '2', 'decimal', 1, 'Contratti', 3, 'Inserire il numero di giorni di preavviso da impostare automaticamente alla creazione di un contratto.');
-- Aggiunto modulo Gestione task
INSERT INTO `zz_modules` (`name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES ('Gestione task', 'Gestione task','gestione-task', 'SELECT |select| FROM `zz_tasks` WHERE 1=1 HAVING 2=2', '', 'fa fa-calendar', '2.4.51', '2.4.51', '5', (SELECT `id` FROM `zz_modules` t WHERE t.`name` = 'Strumenti'), '1', '1');
-- Aggiunta viste Gestione task
INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `default`, `visible`) VALUES
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Gestione task'), 'id', 'id', 1, 0, 0, 1, 0),
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Gestione task'), 'Nome', 'name', 1, 1, 0, 1, 1),
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Gestione task'), 'Expression', 'expression', 2, 1, 0, 0, 1),
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Gestione task'), 'Prossima esecuzione', 'next_execution_at', 3, 1, 0, 0, 1),
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Gestione task'), 'Precedente esecuzione', 'last_executed_at', 4, 1, 0, 0, 1);