Skip to content

Commit 9e95031

Browse files
feat: gestione descrizioni predefinite righe
1 parent f35314b commit 9e95031

7 files changed

Lines changed: 302 additions & 1 deletion

File tree

include/common/descrizione.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
// Inerentemente al tracciato XML prodotto per la FE
2222
// la descrizione del bene o servizio valorizzata all'interno del nodo con ID 2.2.1.4 può avere una lunghezza che varia tra 1 - 1000 caratteri
2323
echo '
24+
<div class="row">
25+
<div class="col-md-12">
26+
{[ "type": "select", "label": "'.tr('Descrizione predefinita').'", "name": "descrizione_predefinita", "ajax-source": "descrizioni_predefinite", "select-options": '.json_encode(['id_module' => $id_module]).' ]}
27+
</div>
28+
</div>
29+
2430
<div class="row">
2531
<div class="col-md-12">
2632
{[ "type": "textarea", "label": "'.tr('Descrizione').'", "name": "descrizione", "id": "descrizione_riga", "value": '.json_encode($result['descrizione']).', "required": 1, "extra": "rows=\"4\"", "charcounter": 1 ]}
@@ -41,3 +47,14 @@
4147
</div>
4248
</div>';
4349
}
50+
51+
echo '
52+
<script>
53+
// Aggiungo al testo la descrizione predefinita
54+
input("descrizione_predefinita").on("change", function() {
55+
if (input(this).get()) {
56+
let value = input("descrizione").get() + input(this).getData().descrizione_predefinita;
57+
input("descrizione").set(value);
58+
}
59+
});
60+
</script>';
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
3+
/*
4+
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
5+
* Copyright (C) DevCode s.r.l.
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
*/
20+
21+
include_once __DIR__.'/../../core.php';
22+
use Modules\DDT\Causale;
23+
24+
switch (filter('op')) {
25+
case 'update':
26+
$dbo->update('zz_default_description', [
27+
'name' => filter('name'),
28+
'descrizione' => filter('descrizione'),
29+
'note' => filter('note')
30+
], [
31+
'id' => $id_record
32+
]);
33+
34+
$dbo->delete('zz_default_description_module', [
35+
'id_description' => $id_record
36+
]);
37+
$id_moduli = (array) post('id_moduli');
38+
foreach ($id_moduli as $id_modulo) {
39+
$dbo->insert('zz_default_description_module', [
40+
'id_description' => $id_record,
41+
'id_module' => $id_modulo
42+
]);
43+
}
44+
45+
flash()->info(tr('Salvataggio completato!'));
46+
47+
break;
48+
49+
case 'add':
50+
$dbo->insert('zz_default_description', [
51+
'name' => filter('name'),
52+
'descrizione' => filter('descrizione'),
53+
'note' => filter('note')
54+
]);
55+
56+
$id_record = $dbo->lastInsertedId();
57+
$id_moduli = (array) post('id_moduli');
58+
foreach ($id_moduli as $id_modulo) {
59+
$dbo->insert('zz_default_description_module', [
60+
'id_description' => $id_record,
61+
'id_module' => $id_modulo
62+
]);
63+
}
64+
65+
flash()->info(tr('Aggiunta nuova risposta predefinita!'));
66+
67+
break;
68+
69+
case 'delete':
70+
$dbo->delete('zz_default_description', [
71+
'id' => $id_record
72+
]);
73+
74+
flash()->info(tr('Risposta predefinita eliminata!'));
75+
76+
break;
77+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
/*
3+
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
4+
* Copyright (C) DevCode s.r.l.
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
20+
include_once __DIR__.'/../../core.php';
21+
22+
?><form action="" method="post" id="add-form">
23+
<input type="hidden" name="op" value="add">
24+
<input type="hidden" name="backto" value="record-edit">
25+
26+
<div class="row">
27+
<div class="col-md-6">
28+
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "name", "required": "1" ]}
29+
</div>
30+
31+
<div class="col-md-6">
32+
{[ "type": "select", "label": "<?php echo tr('Moduli'); ?>", "multiple": "1", "name": "id_moduli[]", "required": 1 , "values": "query=SELECT `zz_modules`.`id`, `title` AS descrizione FROM `zz_modules` LEFT JOIN `zz_modules_lang` ON (`zz_modules`.`id` = `zz_modules_lang`.`id_record` AND `zz_modules_lang`.`id_lang` = <?php echo prepare(Models\Locale::getDefault()->id); ?>) WHERE name IN('Fatture di vendita', 'Fatture di acquisto', 'Ddt in uscita', 'Ddt in entrata', 'Interventi', 'Ordini fornitore', 'Ordini cliente', 'Preventivi', 'Contratti') AND `enabled` = 1 ORDER BY `title` ASC" ]}
33+
</div>
34+
</div>
35+
36+
<div class="row">
37+
<div class="col-md-12">
38+
{[ "type": "textarea", "label": "<?php echo tr('Descrizione'); ?>", "name": "descrizione", "required": "1" ]}
39+
</div>
40+
</div>
41+
42+
<div class="row">
43+
<div class="col-md-12">
44+
{[ "type": "textarea", "label": "<?php echo tr('Note'); ?>", "name": "note" ]}
45+
</div>
46+
</div>
47+
48+
<!-- PULSANTI -->
49+
<div class="modal-footer">
50+
<div class="col-md-12 text-right">
51+
<button type="submit" class="btn btn-primary"><i class="fa fa-plus"></i> <?php echo tr('Aggiungi'); ?></button>
52+
</div>
53+
</div>
54+
</form>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
/*
4+
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
5+
* Copyright (C) DevCode s.r.l.
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
*/
20+
21+
include_once __DIR__.'/../../../core.php';
22+
23+
switch ($resource) {
24+
case 'descrizioni_predefinite':
25+
$query = 'SELECT `zz_default_description`.`id`, `zz_default_description`.`name` as descrizione, `zz_default_description`.`descrizione` AS `descrizione_predefinita` FROM `zz_default_description` LEFT JOIN `zz_default_description_module` ON `zz_default_description`.`id` = `zz_default_description_module`.`id_description` |where| ORDER BY `name` ASC';
26+
27+
foreach ($elements as $element) {
28+
$filter[] = '`zz_default_description`.`id`='.prepare($element);
29+
}
30+
if (empty($filter)) {
31+
$where[] = '`zz_default_description_module`.`id_module`='.prepare($superselect['id_module']);
32+
}
33+
if (!empty($search)) {
34+
$search_fields[] = '`name` LIKE '.prepare('%'.$search.'%');
35+
}
36+
37+
break;
38+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/*
3+
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
4+
* Copyright (C) DevCode s.r.l.
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
20+
include_once __DIR__.'/../../core.php';
21+
22+
?><form action="" method="post" id="edit-form">
23+
<input type="hidden" name="backto" value="record-edit">
24+
<input type="hidden" name="op" value="update">
25+
26+
<div class="card card-primary">
27+
<div class="card-header">
28+
<h3 class="card-title"><?php echo tr('Dati'); ?></h3>
29+
</div>
30+
31+
<div class="card-body">
32+
<div class="row">
33+
<div class="col-md-6">
34+
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "name", "value": "$name$", "required": "1" ]}
35+
</div>
36+
37+
<div class="col-md-6">
38+
{[ "type": "select", "label": "<?php echo tr('Moduli'); ?>", "multiple": "1", "name": "id_moduli[]", "value": "<?php echo $id_moduli; ?>", "required": 1 , "values": "query=SELECT `zz_modules`.`id`, `title` AS descrizione FROM `zz_modules` LEFT JOIN `zz_modules_lang` ON (`zz_modules`.`id` = `zz_modules_lang`.`id_record` AND `zz_modules_lang`.`id_lang` = <?php echo prepare(Models\Locale::getDefault()->id); ?>) WHERE name IN('Fatture di vendita', 'Fatture di acquisto', 'Ddt in uscita', 'Ddt in entrata', 'Interventi', 'Ordini fornitore', 'Ordini cliente', 'Preventivi', 'Contratti') AND `enabled` = 1 ORDER BY `title` ASC" ]}
39+
</div>
40+
</div>
41+
42+
<div class="row">
43+
<div class="col-md-12">
44+
{[ "type": "textarea", "label": "<?php echo tr('Descrizione'); ?>", "name": "descrizione", "value": "$descrizione$", "required": "1" ]}
45+
</div>
46+
</div>
47+
48+
<div class="row">
49+
<div class="col-md-12">
50+
{[ "type": "textarea", "label": "<?php echo tr('Note'); ?>", "name": "note", "value": "$note$" ]}
51+
</div>
52+
</div>
53+
</div>
54+
</div>
55+
</form>
56+
57+
<a class="btn btn-danger ask" data-backto="record-list">
58+
<i class="fa fa-trash"></i> <?php echo tr('Elimina'); ?>
59+
</a>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
/*
4+
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
5+
* Copyright (C) DevCode s.r.l.
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
*/
20+
21+
use Modules\DDT\Causale;
22+
23+
include_once __DIR__.'/../../core.php';
24+
25+
if (!empty($id_record)) {
26+
$record = $dbo->fetchOne('SELECT * FROM `zz_default_description` WHERE `zz_default_description`.`id`='.prepare($id_record));
27+
$id_moduli = $dbo->select('zz_default_description_module', '*', [], ['id_description' => $id_record]);
28+
$id_moduli = implode(',' ,array_column($id_moduli, 'id_module'));
29+
}

update/2_8.sql

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,31 @@ INSERT INTO `zz_settings_lang` (`id_lang`, `id_record`, `title`, `help`) VALUES
5050
INSERT INTO `zz_settings_lang` (`id_lang`, `id_record`, `title`, `help`) VALUES
5151
(2, (SELECT `id` FROM `zz_settings` WHERE `nome` = 'Prompt di sistema per Modello AI'),
5252
'System Prompt for AI Model',
53-
'The system message sent to the AI to define its role and behavior. Modify it to customize responses.');
53+
'The system message sent to the AI to define its role and behavior. Modify it to customize responses.');
54+
55+
56+
-- Nuovo modulo "Descrizioni predefinite"
57+
INSERT INTO `zz_modules` (`name`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`, `use_notes`, `use_checklists`) VALUES ('Descrizioni predefinite', 'descrizioni_predefinite', 'SELECT |select| FROM `zz_default_description` WHERE 1=1 HAVING 2=2', '', 'fa fa-circle-o', '2.8', '2.8', '8', (SELECT `id` FROM `zz_modules` AS `t` WHERE `name` = 'Tabelle'), '1', '1', '1', '1');
58+
59+
SELECT @id_module := `id` FROM `zz_modules` WHERE `name` = 'Descrizioni predefinite';
60+
INSERT INTO `zz_modules_lang` (`id_lang`, `id_record`, `title`, `meta_title`) VALUES
61+
('1', @id_module, 'Descrizioni predefinite', 'Descrizioni predefinite'),
62+
('2', @id_module, 'Descrizioni predefinite', 'Descrizioni predefinite');
63+
64+
SELECT @id_module := `id` FROM `zz_modules` WHERE `name` = 'Descrizioni predefinite';
65+
INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `html_format`, `search_inside`, `order_by`, `visible`, `summable`, `avg`, `default`) VALUES
66+
(@id_module, 'Descrizione', '`zz_default_description`.`descrizione`', '3', '1', '0', '0', '0', NULL, NULL, '1', '0', '0', '1'),
67+
(@id_module, 'Nome', 'zz_default_description.name', '2', '1', '0', '0', '0', NULL, NULL, '1', '0', '0', '1'),
68+
(@id_module, 'id', '`zz_default_description`.`id`', '1', '0', '0', '0', '0', NULL, NULL, '0', '0', '0', '1');
69+
70+
SELECT @id_module := `id` FROM `zz_modules` WHERE `name` = 'Descrizioni predefinite';
71+
INSERT INTO `zz_views_lang` (`id_lang`, `id_record`, `title`) VALUES
72+
('1', (SELECT `id` FROM `zz_views` WHERE `name` = 'Descrizione' AND `id_module` = @id_module), 'Descrizione'),
73+
('2', (SELECT `id` FROM `zz_views` WHERE `name` = 'Descrizione' AND `id_module` = @id_module), 'Description'),
74+
('1', (SELECT `id` FROM `zz_views` WHERE `name` = 'Nome' AND `id_module` = @id_module), 'Nome'),
75+
('2', (SELECT `id` FROM `zz_views` WHERE `name` = 'Nome' AND `id_module` = @id_module), 'Name'),
76+
('1', (SELECT `id` FROM `zz_views` WHERE `name` = 'id' AND `id_module` = @id_module), 'id'),
77+
('2', (SELECT `id` FROM `zz_views` WHERE `name` = 'id' AND `id_module` = @id_module), 'id');
78+
79+
CREATE TABLE `zz_default_description` (`id` INT NOT NULL AUTO_INCREMENT , `name` VARCHAR(255) NOT NULL , `descrizione` TEXT NOT NULL , `note` TEXT NOT NULL , PRIMARY KEY (`id`));
80+
CREATE TABLE `zz_default_description_module` (`id` INT NOT NULL AUTO_INCREMENT , `id_description` INT NOT NULL , `id_module` INT NOT NULL , PRIMARY KEY (`id`));

0 commit comments

Comments
 (0)