diff --git a/modules/categorie/actions.php b/modules/categorie_articoli/actions.php similarity index 100% rename from modules/categorie/actions.php rename to modules/categorie_articoli/actions.php diff --git a/modules/categorie/add.php b/modules/categorie_articoli/add.php similarity index 100% rename from modules/categorie/add.php rename to modules/categorie_articoli/add.php diff --git a/modules/categorie/edit.php b/modules/categorie_articoli/edit.php similarity index 95% rename from modules/categorie/edit.php rename to modules/categorie_articoli/edit.php index 988c8a8c8..5671f94a3 100644 --- a/modules/categorie/edit.php +++ b/modules/categorie_articoli/edit.php @@ -79,7 +79,7 @@ $res = $dbo->fetchNum('SELECT * FROM `mg_articoli` WHERE `id_categoria`='.prepar if ($res) { echo '
-

'.tr('Ci sono '.count($res).' articoli collegati questa categoria. Non è possibile eliminarla.').'

+

'.tr('Ci sono '.count($res).' articoli collegati a questa categoria. Non è possibile eliminarla.').'

'; } else { echo ' diff --git a/modules/categorie/init.php b/modules/categorie_articoli/init.php similarity index 100% rename from modules/categorie/init.php rename to modules/categorie_articoli/init.php diff --git a/modules/categorie/row-list.php b/modules/categorie_articoli/row-list.php similarity index 100% rename from modules/categorie/row-list.php rename to modules/categorie_articoli/row-list.php diff --git a/modules/categorie_impianti/actions.php b/modules/categorie_impianti/actions.php new file mode 100644 index 000000000..d7e12b65d --- /dev/null +++ b/modules/categorie_impianti/actions.php @@ -0,0 +1,61 @@ +query('UPDATE `my_impianti_categorie` SET `nome`='.prepare($nome).', `nota`='.prepare($nota).', `colore`='.prepare($colore).' WHERE `id`='.prepare($id_record)); + flash()->info(tr('Salvataggio completato!')); + } else { + flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio!')); + } + + break; + + case 'add': + $nome = filter('nome'); + $nota = filter('nota'); + $colore = filter('colore'); + + if (isset($nome)) { + $dbo->query('INSERT INTO `my_impianti_categorie` (`nome`, `colore`, `nota`) VALUES ('.prepare($nome).', '.prepare($colore).', '.prepare($nota).')'); + + $id_record = $dbo->lastInsertedID(); + + if (isAjaxRequest()) { + echo json_encode(['id' => $id_record, 'text' => $nome]); + } + + flash()->info(tr('Aggiunta nuova tipologia di _TYPE_', [ + '_TYPE_' => 'categoria', + ])); + } else { + flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio!')); + } + + break; + + case 'delete': + $id = filter('id'); + if (empty($id)) { + $id = $id_record; + } + + if ($dbo->fetchNum('SELECT * FROM `my_impianti` WHERE `id_categoria`='.prepare($id)) == 0) { + $dbo->query('DELETE FROM `my_impianti_categorie` WHERE `id`='.prepare($id)); + + flash()->info(tr('Tipologia di _TYPE_ eliminata con successo!', [ + '_TYPE_' => 'categoria', + ])); + } else { + flash()->error(tr('Esistono ancora alcuni articoli sotto questa categoria!')); + } + + break; + +} diff --git a/modules/categorie_impianti/add.php b/modules/categorie_impianti/add.php new file mode 100644 index 000000000..cab25fd95 --- /dev/null +++ b/modules/categorie_impianti/add.php @@ -0,0 +1,73 @@ +
+ + + + + + + + + +
+
+ {[ "type": "text", "label": "", "name": "nome", "required": 1, "value": "$nome$" ]} +
+ +
+ {[ "type": "text", "label": "", "name": "colore", "id": "colore_", "class": "colorpicker text-center", "value": "$colore$", "extra": "maxlength=\"7\"", "icon-after": "
" ]} +
+
+ +
+
+ {[ "type": "textarea", "label": "", "name": "nota", "value": "$nota$" ]} +
+
+ + +
+
+ + + + + +
+
+
+ + diff --git a/modules/categorie_impianti/edit.php b/modules/categorie_impianti/edit.php new file mode 100644 index 000000000..5cd096fd7 --- /dev/null +++ b/modules/categorie_impianti/edit.php @@ -0,0 +1,60 @@ +
+ + + + +
+
+

+
+ +
+
+
+ {[ "type": "text", "label": "", "name": "nome", "required": 1, "value": "$nome$" ]} +
+ +
+ {[ "type": "text", "label": "", "name": "colore", "class": "colorpicker text-center", "value": "$colore$", "extra": "maxlength='7'", "icon-after": "
" ]} +
+
+ +
+
+ {[ "type": "textarea", "label": "", "name": "nota", "value": "$nota$" ]} +
+
+
+
+ +
+ + + +fetchNum('SELECT * FROM `my_impianti` WHERE `id_categoria`='.prepare($id_record)); + +if ($res) { + echo ' +
+

'.tr('Ci sono '.count($res).' impianti collegati a questa categoria. Non è possibile eliminarla.').'

+
'; +} else { + echo ' + + '.tr('Elimina').' + '; +} diff --git a/modules/categorie_impianti/init.php b/modules/categorie_impianti/init.php new file mode 100644 index 000000000..c9881f030 --- /dev/null +++ b/modules/categorie_impianti/init.php @@ -0,0 +1,7 @@ +fetchOne('SELECT * FROM `my_impianti_categorie` WHERE id='.prepare($id_record)); +} diff --git a/modules/my_impianti/actions.php b/modules/my_impianti/actions.php index 1c50ec052..6ac734aa5 100644 --- a/modules/my_impianti/actions.php +++ b/modules/my_impianti/actions.php @@ -16,6 +16,7 @@ switch ($op) { 'idanagrafica' => post('idanagrafica'), 'nome' => post('nome'), 'matricola' => $matricola, + 'id_categoria' => post('id_categoria'), 'descrizione' => post('descrizione'), 'idsede' => post('idsede'), 'data' => post('data'), diff --git a/modules/my_impianti/edit.php b/modules/my_impianti/edit.php index 5489ecc65..bc11c8ca6 100644 --- a/modules/my_impianti/edit.php +++ b/modules/my_impianti/edit.php @@ -42,12 +42,15 @@ if (!empty($record['immagine'])) {
-
+
{[ "type": "select", "label": "", "name": "idanagrafica", "required": 1, "values": "query=SELECT an_anagrafiche.idanagrafica AS id, ragione_sociale AS descrizione FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE descrizione='Cliente' AND deleted_at IS NULL ORDER BY ragione_sociale", "value": "$idanagrafica$", "extra": "", "ajax-source": "clienti" ]}
+
+ {[ "type": "select", "label": "", "name": "id_categoria", "required": 0, "class": "", "value": "$id_categoria$", "values": "query=SELECT id, nome AS descrizione FROM my_impianti_categorie" ]} +
diff --git a/update/2_4_2.sql b/update/2_4_2.sql index 96e11cdf0..132a88ef2 100644 --- a/update/2_4_2.sql +++ b/update/2_4_2.sql @@ -554,4 +554,26 @@ INSERT INTO `zz_plugins` (`id`, `name`, `title`, `idmodule_from`, `idmodule_to`, UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_preventivi` WHERE 1=1 AND default_revision=1 HAVING 2=2 AND ((\'|period_start|\' >= `data_bozza` AND \'|period_start|\' <= `data_conclusione`) OR (\'|period_end|\' >= `data_bozza` AND \'|period_end|\' <= `data_conclusione`) OR (`data_bozza` >= \'|period_start|\' AND `data_bozza` <= \'|period_end|\') OR (`data_conclusione` >= \'|period_start|\' AND `data_conclusione` <= \'|period_end|\') OR (`data_bozza` >= \'|period_start|\' AND `data_conclusione` = \'0000-00-00\')) ORDER BY `id` DESC' WHERE `zz_modules`.`name` = 'Preventivi'; -- Chiave secondaria per le righe del preventivo -ALTER TABLE `co_righe_preventivi` ADD FOREIGN KEY (`idpreventivo`) REFERENCES `co_preventivi`(`id`) ON DELETE CASCADE; \ No newline at end of file +ALTER TABLE `co_righe_preventivi` ADD FOREIGN KEY (`idpreventivo`) REFERENCES `co_preventivi`(`id`) ON DELETE CASCADE; + +-- Categoria impianto +ALTER TABLE `my_impianti` ADD `id_categoria` INT NOT NULL AFTER `idanagrafica`; + +-- Tabella categorie +CREATE TABLE IF NOT EXISTS `my_impianti_categorie` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `nome` varchar(255) NOT NULL, + `colore` varchar(255) NOT NULL, + `nota` varchar(1000) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB; + +-- Rinominato Categorie in Categorie articoli +UPDATE `zz_modules` SET `name` = 'Categorie articoli', `title` = 'Categorie articoli', `directory` = 'categorie_articoli' WHERE `zz_modules`.`id` = 47; + +-- Modulo Categorie impianti +INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Categorie impianti', 'Categorie impianti', 'categorie_impianti', 'SELECT |select| FROM `my_impianti_categorie` WHERE 1=1 HAVING 2=2', '', 'fa fa-angle-right', '2.4.2', '2.4.2', '1', '40', '1', '1'); + +INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `visible`, `default`) VALUES +((SELECT `id` FROM `zz_modules` WHERE `name` = 'Categorie impianti'), 'id', 'id', 1, 1, 0, 0, 1), +((SELECT `id` FROM `zz_modules` WHERE `name` = 'Categorie impianti'), 'Nome', 'nome', 2, 1, 0, 1, 1);