diff --git a/modules/articoli/actions.php b/modules/articoli/actions.php index f15942783..d8c3ed26f 100755 --- a/modules/articoli/actions.php +++ b/modules/articoli/actions.php @@ -148,6 +148,7 @@ switch (post('op')) { $articolo->servizio = post('servizio'); $articolo->volume = post('volume'); $articolo->peso_lordo = post('peso_lordo'); + $articolo->id_marchio = post('id_marchio'); $articolo->um_secondaria = post('um_secondaria'); $articolo->fattore_um_secondaria = post('fattore_um_secondaria'); diff --git a/modules/articoli/edit.php b/modules/articoli/edit.php index bb206ab53..d36c7c50c 100755 --- a/modules/articoli/edit.php +++ b/modules/articoli/edit.php @@ -50,15 +50,20 @@ use Modules\Iva\Aliquota;
-
+
{[ "type": "select", "label": "", "name": "categoria", "required": 0, "value": "$id_categoria$", "ajax-source": "categorie", "icon-after": "add|first()->id; ?>" ]}
-
+
{[ "type": "select", "label": "", "name": "subcategoria", "value": "$id_sottocategoria$", "ajax-source": "sottocategorie", "select-options": $record['id_categoria']]); ?>, "icon-after": "add|first()->id; ?>|id_original=" ]}
+ +
+ + {[ "type": "select", "label": "", "name": "id_marchio", "value":"$id_marchio$", "values": "query=SELECT id, nome AS descrizione FROM mg_marchi ORDER BY descrizione ASC" ]} +
diff --git a/modules/marchi/actions.php b/modules/marchi/actions.php new file mode 100644 index 000000000..f724118df --- /dev/null +++ b/modules/marchi/actions.php @@ -0,0 +1,53 @@ +. + */ + +include_once __DIR__.'/../../core.php'; + +switch (post('op')) { + // Aggiorno informazioni di base impianto + case 'update': + + $dbo->update('mg_marchi',[ + 'nome' => post('nome'), + ],['id' => $id_record]); + + flash()->info(tr('Informazioni salvate correttamente!')); + + break; + + // Aggiungo impianto + case 'add': + + $dbo->insert('mg_marchi',[ + 'nome' => post('nome'), + ]); + $id_record = $dbo->lastInsertedID(); + + flash()->info(tr('Aggiunto nuovo marchio!')); + + break; + + + // Rimuovo impianto e scollego tutti i suoi componenti + case 'delete': + $dbo->query('DELETE FROM mg_marchi WHERE id='.prepare($id_record)); + + flash()->info(tr('Marchio eliminato!')); + break; +} diff --git a/modules/marchi/add.php b/modules/marchi/add.php new file mode 100644 index 000000000..c92d850d9 --- /dev/null +++ b/modules/marchi/add.php @@ -0,0 +1,40 @@ +. + */ + +include_once __DIR__.'/../../core.php'; + +$id_anagrafica = filter('id_anagrafica'); + +?>
+ + + +
+
+ {[ "type": "text", "label": "", "name": "nome", "required": 1, "validation": "nome" ]} +
+
+ + +
+
+ +
+
+
\ No newline at end of file diff --git a/modules/marchi/edit.php b/modules/marchi/edit.php new file mode 100644 index 000000000..5a814a5bd --- /dev/null +++ b/modules/marchi/edit.php @@ -0,0 +1,78 @@ +. + */ + +include_once __DIR__.'/../../core.php'; + + +?>
+ + + + + +
+
+

+
+ +
+
+
+ {[ "type": "text", "label": "", "name": "nome", "value":"$nome$", "required": 1, "validation": "nome" ]} +
+
+ +
+
+
+ +fetchArray('SELECT `mg_articoli`.`id`, CONCAT(`mg_articoli`.`codice`, " - ", `mg_articoli_lang`.`title`) AS `descrizione` FROM `mg_articoli` INNER JOIN mg_articoli_lang ON (`mg_articoli_lang`.`id_record` = `mg_articoli`.`id` AND `mg_articoli_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') WHERE `mg_articoli`.`id_marchio` = '.prepare($id_record)); +$class = ''; + +if (!empty($elementi)) { + echo ' +
+
+

'.tr('Articoli collegati: _NUM_', [ + '_NUM_' => count($elementi), + ]).'

+
+ +
+
+
+ +
+
'; +} + +echo ' + + '.tr('Elimina').' +'; \ No newline at end of file diff --git a/modules/marchi/init.php b/modules/marchi/init.php new file mode 100644 index 000000000..caa7277c1 --- /dev/null +++ b/modules/marchi/init.php @@ -0,0 +1,24 @@ +. + */ + +include_once __DIR__.'/../../core.php'; + +if (isset($id_record)) { + $record = $dbo->fetchOne('SELECT * FROM mg_marchi WHERE id='.prepare($id_record)); +} diff --git a/modules/marchi/validation.php b/modules/marchi/validation.php new file mode 100644 index 000000000..1a079f859 --- /dev/null +++ b/modules/marchi/validation.php @@ -0,0 +1,40 @@ +. + */ + +include_once __DIR__.'/../../core.php'; + +$name = filter('name'); +$value = filter('value'); + +switch ($name) { + case 'nome': + $disponibile = $dbo->table('mg_marchi')->where([ + ['nome', $value], + ['id', '<>', $id_record], + ])->count() == 0; + + $message = $disponibile ? tr('Il nome è disponbile') : tr('Il nome è già utilizzato in un altro marchio'); + + $response = [ + 'result' => $disponibile, + 'message' => $message, + ]; + + break; +} diff --git a/update/2_5_6.sql b/update/2_5_6.sql new file mode 100644 index 000000000..d2f2cdffa --- /dev/null +++ b/update/2_5_6.sql @@ -0,0 +1,22 @@ +-- Aggiunta Marchio articolo +ALTER TABLE `mg_articoli` ADD `id_marchio` INT NULL DEFAULT NULL; + +CREATE TABLE `mg_marchi` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `nome` varchar(255) NOT NULL, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `deleted_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, +PRIMARY KEY (`id`)) ENGINE = InnoDB; + +INSERT INTO `zz_modules` (`id`, `name`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`, `use_notes`, `use_checklists`) VALUES (NULL, 'Marchi', 'marchi', 'SELECT |select| FROM `mg_marchi` WHERE 1=1 HAVING 2=2 ORDER BY `mg_marchi`.`nome`', '', 'fa fa-angle-right', '2.5.6', '2.5.6', '7', (SELECT `id` FROM `zz_modules` AS `t` WHERE `name` = 'Articoli'), '1', '1', '1', '1'); + +INSERT INTO `zz_modules_lang` (`id`, `id_lang`, `id_record`, `title`) VALUES (NULL, '1', (SELECT `id` FROM `zz_modules` WHERE `name` = 'Marchi'), 'Marchi'); + +INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `html_format`, `search_inside`, `order_by`, `visible`, `summable`, `default`) VALUES +((SELECT `id` FROM `zz_modules` WHERE `name` = 'Marchi'), 'id', 'mg_marchi.id', '0', '0', '0', '0', '0', '', '', '0', '0', '0'), +((SELECT `id` FROM `zz_modules` WHERE `name` = 'Marchi'), 'Nome', 'mg_marchi.nome', '1', '0', '0', '0', '0', '', '', '1', '0', '0'); + +INSERT INTO `zz_views_lang` (`id_lang`, `id_record`, `title`) VALUES +(1, (SELECT `id` FROM `zz_views` WHERE `name` = 'id' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Marchi')), 'id'), +(1, (SELECT `id` FROM `zz_views` WHERE `name` = 'Nome' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Marchi')), 'Nome'); \ No newline at end of file