From 2d0c53b3bac73b9d07b6076c54b8962c72140ce9 Mon Sep 17 00:00:00 2001 From: maulapi Date: Wed, 30 Jul 2025 09:34:35 +0200 Subject: [PATCH 1/3] Aggiunta Modulo Ubicazioni --- modules/articoli/ajax/select.php | 29 +++++--- modules/ubicazioni/actions.php | 117 +++++++++++++++++++++++++++++++ modules/ubicazioni/add.php | 71 +++++++++++++++++++ modules/ubicazioni/edit.php | 111 +++++++++++++++++++++++++++++ modules/ubicazioni/init.php | 29 ++++++++ update/2_8_3.sql | 52 +++++++++++++- 6 files changed, 397 insertions(+), 12 deletions(-) create mode 100644 modules/ubicazioni/actions.php create mode 100644 modules/ubicazioni/add.php create mode 100644 modules/ubicazioni/edit.php create mode 100644 modules/ubicazioni/init.php diff --git a/modules/articoli/ajax/select.php b/modules/articoli/ajax/select.php index 155f84ea59..22e490d4a4 100755 --- a/modules/articoli/ajax/select.php +++ b/modules/articoli/ajax/select.php @@ -42,7 +42,7 @@ $query = "SELECT DISTINCT `mg_articoli`.`id`, IF(`categoria_lang`.`title` IS NOT NULL, CONCAT(`categoria_lang`.`title`, IF(`sottocategoria_lang`.`title` IS NOT NULL, CONCAT(' (', `sottocategoria_lang`.`title`, ')'), '-')), '".tr('Nessuna categoria')."') AS optgroup, - `mg_articoli_barcode`.`barcode` AS barcode, + `mg_articoli`.`barcode`, `mg_articoli`.".($prezzi_ivati ? '`prezzo_vendita_ivato`' : '`prezzo_vendita`').' AS prezzo_vendita, `mg_articoli`.`prezzo_vendita_ivato` AS prezzo_vendita_ivato, `mg_articoli`.'.($prezzi_ivati ? '`minimo_vendita_ivato`' : '`minimo_vendita`').' AS minimo_vendita,'; @@ -114,8 +114,7 @@ LEFT JOIN `co_iva` AS iva_articolo ON `iva_articolo`.`id` = `mg_articoli`.`idiva_vendita` LEFT JOIN `co_iva_lang` AS iva_articolo_lang on (`iva_articolo`.`id` = `iva_articolo_lang`.`id_record` AND `iva_articolo_lang`.`id_lang` = ".prepare(Models\Locale::getDefault()->id).") LEFT JOIN `co_iva` AS `iva_predefinita` ON `iva_predefinita`.`id` = '.$iva_predefinita.' - LEFT JOIN `co_iva_lang` AS iva_predefinita_lang on (`iva_predefinita`.`id` = `iva_predefinita_lang`.`id_record` AND `iva_predefinita_lang`.`id_lang` = ".prepare(Models\Locale::getDefault()->id).') - LEFT JOIN mg_articoli_barcode ON mg_articoli_barcode.idarticolo = mg_articoli.id'; + LEFT JOIN `co_iva_lang` AS iva_predefinita_lang on (`iva_predefinita`.`id` = `iva_predefinita_lang`.`id_record` AND `iva_predefinita_lang`.`id_lang` = ".prepare(Models\Locale::getDefault()->id).')'; if ($usare_iva_anagrafica) { $query .= ' @@ -180,8 +179,8 @@ if (!empty($search)) { $search_fields[] = '`mg_articoli_lang`.`title` LIKE '.prepare('%'.$search.'%'); $search_fields[] = '`mg_articoli`.`codice` LIKE '.prepare('%'.$search.'%'); + $search_fields[] = '`mg_articoli`.`barcode` LIKE '.prepare('%'.$search.'%'); $search_fields[] = '`categoria_lang`.`title` LIKE '.prepare('%'.$search.'%'); - $search_fields[] = '`mg_articoli_barcode`.`barcode` LIKE '.prepare('%'.$search.'%'); $search_fields[] = '`sottocategoria_lang`.`title` LIKE '.prepare('%'.$search.'%'); if ($usare_dettaglio_fornitore) { @@ -217,7 +216,6 @@ $results = [ 'results' => $rs, 'recordsFiltered' => $data['recordsFiltered'], - 'link' => 'module:Articoli', ]; break; @@ -236,8 +234,6 @@ $search_fields[] = '`title` LIKE '.prepare('%'.$search.'%'); } - $custom['link'] = 'module:Categorie'; - break; /* @@ -258,8 +254,6 @@ if (!empty($search)) { $search_fields[] = '`title` LIKE '.prepare('%'.$search.'%'); } - - $custom['link'] = 'module:Categorie'; } break; @@ -275,6 +269,20 @@ break; + case 'ubicaz': + $query = 'SELECT `mg_ubicazioni`.`u_label` AS id, `mg_ubicazioni_lang`.`title` AS descrizione FROM `mg_ubicazioni` LEFT JOIN `mg_ubicazioni_lang` ON (`mg_ubicazioni_lang`.`id_record` = `mg_ubicazioni`.`id` AND `mg_ubicazioni_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') |where| ORDER BY `title`'; + //$query = 'SELECT `u_label` AS id, `u_label` AS descrizione FROM `mg_ubicazioni` LEFT JOIN `mg_ubicazioni_lang` ON (`mg_ubicazioni_lang`.`id_record` = `mg_ubicazioni`.`id` AND `mg_ubicazioni_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') |where| ORDER BY TRIM(`mg_ubicazioni`.`u_label`)'; + + foreach ($elements as $element) { + $filter[] = '`u_label`='.prepare($element); + } + if (!empty($search)) { + //$search_fields[] = '`u_label` LIKE '.prepare('%'.$search.'%'); + $search_fields[] = '`title` LIKE '.prepare('%'.$search.'%'); + } + + break; + /* * Opzioni utilizzate: * - idanagrafica @@ -298,7 +306,6 @@ `mg_fornitore_articolo`.`id` AS id_dettaglio_fornitore FROM `mg_articoli` LEFT JOIN `mg_fornitore_articolo` ON `mg_fornitore_articolo`.`id_articolo` = `mg_articoli`.`id` AND `mg_fornitore_articolo`.`deleted_at` IS NULL AND `mg_fornitore_articolo`.`id_fornitore` = '.prepare($id_anagrafica).' - LEFT JOIN `mg_articoli_barcode` ON `mg_articoli`.`id` = `mg_articoli_barcode`.`idarticolo` |where|'; $where[] = '`mg_articoli`.`attivo` = 1'; @@ -306,7 +313,7 @@ if (!empty($search)) { $search_fields[] = '`mg_articoli`.`codice` LIKE '.prepare('%'.$search.'%'); - $search_fields[] = '`mg_articoli_barcode`.`barcode` LIKE '.prepare('%'.$search.'%'); + $search_fields[] = '`mg_articoli`.`barcode` LIKE '.prepare('%'.$search.'%'); } break; diff --git a/modules/ubicazioni/actions.php b/modules/ubicazioni/actions.php new file mode 100644 index 0000000000..815f0f5edb --- /dev/null +++ b/modules/ubicazioni/actions.php @@ -0,0 +1,117 @@ +. + */ + +include_once __DIR__.'/../../core.php'; +use Modules\Ubicazioni; +//use Modules\Articoli\Categoria; + +switch (filter('op')) { + case 'update': + $u_label = filter('u_label'); + //$u_label_info = filter('u_label_info'); + $title = filter('title'); + $colore = filter('colore'); + $notes = filter('notes'); + $u_tags = filter('u_tags'); + //$u_id = filter('id'); + + if (isset($u_label)) { + if ($dbo->fetchNum('SELECT * FROM `mg_ubicazioni` WHERE `mg_ubicazioni`.`u_label`='.prepare($u_label).' AND `mg_ubicazioni`.`id`!='.prepare($id_record)) == 0) { + $dbo->query('UPDATE `mg_ubicazioni` LEFT JOIN `mg_ubicazioni_lang` ON (`mg_ubicazioni`.`id` = `mg_ubicazioni_lang`.`id_record` AND `mg_ubicazioni_lang`.`id_lang` = '.prepare(parameter: Models\Locale::getDefault()->id).') + SET `mg_ubicazioni`.`u_label`='.prepare($u_label).', + `mg_ubicazioni`.`u_tags`='.prepare($u_tags).', + `mg_ubicazioni`.`colore`='.prepare($colore).', + `mg_ubicazioni_lang`.`title`='.prepare($title).', + `mg_ubicazioni_lang`.`notes`='.prepare($notes).' + WHERE `mg_ubicazioni`.`id`='.prepare($id_record)); + //$ubicazione->colore = $colore; + //$categoria->parent = $id_original ?: null; + //$ubicazione->setTranslation('title', $title); + //$ubicazione->setTranslation('notes', $notes); + //$ubicazione->save(); + flash()->info(tr('Salvataggio completato.')); + } else { + flash()->error(tr("E' già presente una tipologia di _TYPE_ con lo stesso valore.", [ + '_TYPE_' => 'ubicazione', + ])); + } + } else { + flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio')); + } + + break; + + //aggiornato con l'aggiunta di mg_ubicazioni_lang + case 'add': + $u_label = filter('u_label'); + //$u_label_info = filter('u_label_info'); + $title = filter('title'); + $colore = filter('colore'); + $notes = filter('notes'); + $u_tags = filter('u_tags'); + //$u_id = filter('id'); + + if (isset($u_label)) { + if ($dbo->fetchNum('SELECT * FROM `mg_ubicazioni` WHERE `u_label`='.prepare($u_label)) == 0) { + $dbo->query('INSERT INTO `mg_ubicazioni` (`u_label`,`u_tags`,`colore`) VALUES ('.prepare($u_label).','.prepare($u_tags).','.prepare($colore).')'); + $id_record = $dbo->lastInsertedID(); + $dbo->query('INSERT INTO `mg_ubicazioni_lang` (`id_lang`,`id_record`,`title`,`notes`) VALUES ('.prepare(parameter: Models\Locale::getDefault()->id).','.prepare($id_record).','.prepare($title).','.prepare($notes).')'); + + if (isAjaxRequest()) { + echo json_encode(['id' => $u_label, 'text' => $u_label]); + } + + flash()->info(tr('Aggiunta nuova tipologia di _TYPE_', [ + '_TYPE_' => 'ubicazione', + ])); + } else { + flash()->error(tr("E' già presente una tipologia di _TYPE_ con lo stesso valore.", [ + '_TYPE_' => 'ubicazione', + ])); + } + } else { + flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio')); + } + + break; + + case 'delete': + //$righe = $dbo->fetchNum('SELECT `id` FROM `co_righe_documenti` WHERE `um`='.prepare($record['valore']).' + // UNION SELECT `id` FROM `dt_righe_ddt` WHERE `um`='.prepare($record['valore']).' + // UNION SELECT `id` FROM `or_righe_ordini` WHERE `um`='.prepare($record['valore']).' + // UNION SELECT `id` FROM `co_righe_contratti` WHERE `um`='.prepare($record['valore']).' + // UNION SELECT `id` FROM `mg_articoli` WHERE `um`='.prepare($record['valore']).' + // UNION SELECT `id` FROM `co_righe_preventivi` WHERE `um`='.prepare($record['valore'])); + + //aggiornato con il delete anche dei record mg_ubicazione_lang + if (!empty($id_record)) { + $dbo->query('DELETE FROM `mg_ubicazioni` WHERE `id`='.prepare($id_record)); + flash()->info(tr('Tipologia di _TYPE_ eliminata con successo!', [ + '_TYPE_' => 'ubicazione', + ])); + $dbo->query('DELETE FROM `mg_ubicazioni_lang` WHERE `id_record`='.prepare($id_record)); + flash()->info(tr('Tipologia di _TYPE_ eliminata con successo!', [ + '_TYPE_' => 'ubicazione_lang', + ])); + } else { + flash()->error(tr('Errore cancellazione di questa ubicazione.')); + } + + break; +} diff --git a/modules/ubicazioni/add.php b/modules/ubicazioni/add.php new file mode 100644 index 0000000000..4ea92736f0 --- /dev/null +++ b/modules/ubicazioni/add.php @@ -0,0 +1,71 @@ +. + */ + +include_once __DIR__.'/../../core.php'; + +?>
+ + + +
+
+ {[ "type": "text", "label": "", "name": "u_label", "required": 1, "value": "$u_label$" ]} +
+ +
+ {[ "type": "text", "label": "", "name": "title", "value": "$title$" ]} +
+
+ {[ "type": "text", "label": "", "name": "notes", "value": "$notes$" ]} +
+
+ {[ "type": "text", "label": "", "name": "u_tags", "value": "$u_tags$" ]} +
+
+ {[ "type": "text", "label": "", "name": "colore", "id": "colore_", "class": "colorpicker text-center", "value": "$colore$", "extra": "maxlength=\"7\"", "icon-after": "
" ]} +
+
+ + +
+
+ +
+
+
+ \ No newline at end of file diff --git a/modules/ubicazioni/edit.php b/modules/ubicazioni/edit.php new file mode 100644 index 0000000000..1a26d70d22 --- /dev/null +++ b/modules/ubicazioni/edit.php @@ -0,0 +1,111 @@ +. + */ + +include_once __DIR__.'/../../core.php'; +//use Modules\Barcode; +//use Modules\Articoli\Articolo; +use Models\Module; +use Modules\Ubicazioni; + +?> +
+ + + + +
+
+

+
+ +
+
+
+ {[ "type": "text", "label": "", "name": "u_label", "required": 1, "value": "$u_label$" ]} +
+ +
+ {[ "type": "text", "label": "", "name": "title", "value": "$title$" ]} +
+
+ {[ "type": "text", "label": "", "name": "notes", "value": "$notes$" ]} +
+
+ {[ "type": "text", "label": "", "name": "u_tags", "value": "$u_tags$" ]} +
+
+ {[ "type": "text", "label": "", "name": "colore", "class": "colorpicker text-center", "value": "$colore$", "extra": "maxlength='7'", "icon-after": "
" ]} +
+
+ + Stampa Etichetta + + + Stampa Etichetta BIG + +
+
+ +
+ + + + +fetchNum('SELECT `id` FROM `mg_articoli` WHERE `ubicazione`='.prepare($record['u_label'])); +if (!empty($righe)) { + echo ' +
+ '.tr('Ci sono _NUM_ righe collegate', [ + '_NUM_' => $righe, + ]).' +
'; +} + +$elementi = $dbo->fetchArray('SELECT `id`,`codice`,`barcode`,`ubicazione` FROM `mg_articoli` WHERE `ubicazione`='.prepare($record['u_label'])); +echo '
'; + foreach ($elementi as $elemento) { + $descrizione = tr('Articolo _CODICE_', [ + '_CODICE_' => !empty($elemento['codice']) ? $elemento['codice'] : $elemento['barcode'], + ]); + $modulo = 'Articoli'; + $id = $elemento['id']; + echo '
  • '.Modules::link($modulo, $id, $descrizione).'
  • '; + } +echo '
    '; + +?> + + + + + diff --git a/modules/ubicazioni/init.php b/modules/ubicazioni/init.php new file mode 100644 index 0000000000..4a4a5d7951 --- /dev/null +++ b/modules/ubicazioni/init.php @@ -0,0 +1,29 @@ +. + */ + +include_once __DIR__.'/../../core.php'; +//use Modules\Articoli\Categoria; +use Modules\Ubicazioni; + +if (!empty($id_record)) { + //cambio query dopo l'aggiunta di mg_ubicazioni_lang + //$record = $dbo->fetchOne('SELECT * FROM `mg_ubicazioni` WHERE id='.prepare($id_record)); + $record = $dbo->fetchOne('SELECT `mg_ubicazioni`.*, `mg_ubicazioni_lang`.`title`, `mg_ubicazioni_lang`.`notes` FROM `mg_ubicazioni` LEFT JOIN `mg_ubicazioni_lang` ON (`mg_ubicazioni`.`id`=`mg_ubicazioni_lang`.`id_record` AND `mg_ubicazioni_lang`.`id_lang`='.prepare(parameter: Models\Locale::getDefault()->id).') WHERE `mg_ubicazioni`.`id`='.prepare($id_record)); + +} \ No newline at end of file diff --git a/update/2_8_3.sql b/update/2_8_3.sql index 1e3ae2ffb4..e4d84912c3 100644 --- a/update/2_8_3.sql +++ b/update/2_8_3.sql @@ -188,4 +188,54 @@ HAVING 2=2 ORDER BY `id`, - `nome` ASC' WHERE `zz_modules`.`name` = 'Utenti e permessi'; \ No newline at end of file + `nome` ASC' WHERE `zz_modules`.`name` = 'Utenti e permessi'; + +-- Aggiunta Modulo Ubicazioni +CREATE TABLE `mg_ubicazioni` ( + `id` int(11) NOT NULL, + `u_label` varchar(255) NOT NULL, + `colore` varchar(255) DEFAULT NULL, + `u_tags` varchar(255) DEFAULT NULL, + `created_at` timestamp NULL DEFAULT current_timestamp(), + `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `deleted_at` timestamp NULL DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +ALTER TABLE `mg_ubicazioni` + ADD PRIMARY KEY (`id`); + +ALTER TABLE `mg_ubicazioni` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; +COMMIT; + +CREATE TABLE `mg_ubicazioni_lang` ( + `id` int(11) NOT NULL, + `id_lang` int(11) NOT NULL, + `id_record` int(11) NOT NULL, + `title` varchar(255) DEFAULT NULL, + `notes` varchar(255) DEFAULT NULL, + `created_at` timestamp NOT NULL DEFAULT current_timestamp(), + `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +ALTER TABLE `mg_ubicazioni_lang` + ADD PRIMARY KEY (`id`), + ADD KEY `mg_ubicazioni_lang_ibfk_2` (`id_lang`) USING BTREE, + ADD KEY `mg_ubicazioni_lang_ibfk_1` (`id_record`) USING BTREE; + +ALTER TABLE `mg_ubicazioni_lang` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; + +ALTER TABLE `mg_ubicazioni_lang` + ADD CONSTRAINT `mg_ubicazioni_lang_ibfk_1` FOREIGN KEY (`id_record`) REFERENCES `mg_ubicazioni` (`id`) ON DELETE CASCADE, + ADD CONSTRAINT `mg_ubicazioni_lang_ibfk_2` FOREIGN KEY (`id_lang`) REFERENCES `zz_langs` (`id`) ON DELETE CASCADE; +COMMIT; + +INSERT INTO `zz_modules` (`name`, `directory`, `attachments_directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`, `use_notes`, `use_checklists`) VALUES +('Ubicazioni', 'ubicazioni', 'ubicazioni', 'SELECT |select| FROM `mg_ubicazioni` LEFT JOIN `mg_ubicazioni_lang` ON (`mg_ubicazioni`.`id` = `mg_ubicazioni_lang`.`id_record` AND `mg_ubicazioni_lang`.|lang|) WHERE 1=1 HAVING 2=2 ORDER BY TRIM(`mg_ubicazioni`.`u_label`)', '', 'nav-icon fa fa-circle-o', '2.8.1', '2.8.1', 110, 20, 1, 1, 0, 0); + +INSERT INTO `zz_modules_lang` (`id_lang`, `id_record`, `title`, `meta_title`) VALUES +( 1, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ubicazioni'), 'Ubicazioni', 'Ubicazioni'); +INSERT INTO `zz_modules_lang` (`id_lang`, `id_record`, `title`, `meta_title`) VALUES +( 2, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ubicazioni'), 'Ubicazioni', 'Ubicazioni'); + From 449b2d205ca160ce2c148ecd878979597026adeb Mon Sep 17 00:00:00 2001 From: maulapi Date: Wed, 30 Jul 2025 10:14:45 +0200 Subject: [PATCH 2/3] Aggiunta al Modulo Ubicazioni file modificati --- modules/articoli/add.php | 13 +++---- modules/articoli/edit.php | 73 +++++++++++++++++++++++---------------- 2 files changed, 51 insertions(+), 35 deletions(-) diff --git a/modules/articoli/add.php b/modules/articoli/add.php index 0d09bd726b..9757dd72df 100755 --- a/modules/articoli/add.php +++ b/modules/articoli/add.php @@ -59,7 +59,7 @@
    - {[ "type": "select", "label": "", "name": "id_modello", "id": "id_modello_add", "ajax-source": "modelli", "icon-after": "add|first()->id; ?>|id_original=0|hide" ]} + {[ "type": "select", "label": "", "name": "id_modello", "id": "id_modello_add", "ajax-source": "modelli", "icon-after": "add|first()->id; ?>||hide" ]}
    @@ -137,6 +137,12 @@ + +
    +
    + {[ "type": "select", "label": "", "name": "ubicazione", "value": "$ubicazione$", "ajax-source": "ubicaz", "icon-after": "add|first()->id; ?>" ]} +
    +
    @@ -191,11 +197,6 @@ } }); - // Nascondi il pulsante modello se non c'è una marca selezionata all'inizio - if(!$('#add-form').find('#id_marca').val()) { - modello.parent().find(".input-group-append button").addClass("hide"); - } - input("coefficiente").on('keyup', function(){ if (iva_vendita.val()) { percentuale = parseFloat(iva_vendita.selectData().percentuale); diff --git a/modules/articoli/edit.php b/modules/articoli/edit.php index 112fd73610..6c7078a8e1 100755 --- a/modules/articoli/edit.php +++ b/modules/articoli/edit.php @@ -45,14 +45,19 @@
    -
    +
    {[ "type": "text", "label": "", "name": "codice", "required": 1, "value": "$codice$", "validation": "codice" ]}
    -
    +
    + + {[ "type": "text", "label": "", "name": "barcode", "validation": "barcode", "class": "text-center", "value": "$barcode$" ]} +
    + +
    {[ "type": "checkbox", "label": "", "name": "servizio", "value": "$servizio$", "help": "", "placeholder": "" ]}
    -
    +
    {[ "type": "checkbox", "label": "", "name": "attivo", "help": "", "value": "$attivo$", "placeholder": "" ]}
    @@ -61,20 +66,20 @@
    - {[ "type": "select", "label": "", "name": "categoria_edit", "id": "categoria_edit", "required": 0, "value": "$id_categoria$", "ajax-source": "categorie", "icon-after": "add|first()->id; ?>" ]} + {[ "type": "select", "label": "", "name": "categoria", "required": 0, "value": "$id_categoria$", "ajax-source": "categorie", "icon-after": "add|first()->id; ?>" ]}
    - {[ "type": "select", "label": "", "name": "subcategoria_edit", "id": "subcategoria_edit", "value": "$id_sottocategoria$", "ajax-source": "sottocategorie", "select-options": $record['id_categoria']]); ?>, "icon-after": "add|first()->id; ?>|id_original=" ]} + {[ "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_marca_edit", "id": "id_marca_edit", "value":"$id_marca$", "ajax-source": "marche", "icon-after": "add|first()->id; ?>" ]} + {[ "type": "select", "label": "", "name": "id_marca", "value":"$id_marca$", "ajax-source": "marche", "icon-after": "add|first()->id; ?>" ]}
    - {[ "type": "select", "label": "", "name": "id_modello_edit", "id": "id_modello_edit", "value":"$id_modello$", "ajax-source": "modelli", "select-options": $record['id_marca']]); ?>, "icon-after": "add|first()->id; ?>|id_original=" ]} + {[ "type": "select", "label": "", "name": "id_modello", "value":"$id_modello$", "ajax-source": "modelli", "select-options": $record['id_marca']]); ?>, "icon-after": "add|first()->id; ?>|id_original=" ]}
    @@ -97,8 +102,11 @@
    {[ "type": "checkbox", "label": "", "name": "abilita_serial", "value": "$abilita_serial$", "help": "", "placeholder": "", "extra": " 0) ? 'readonly' : ''; ?>" ]}
    -
    + +
    + {[ "type": "select", "label": "", "name": "ubicazione", "value": "$ubicazione$", "ajax-source": "ubicaz", "icon-after": "add|first()->id; ?>" ]}
    @@ -338,37 +346,22 @@ }); }); -$("#categoria_edit").change(function() { +$("#categoria").change(function() { updateSelectOption("id_categoria", $(this).val()); - $("#subcategoria_edit").val(null).trigger("change"); - - // Gestione del pulsante "aggiungi" per sottocategoria - var sub = $("#subcategoria_edit"); - var button = sub.parent().find(".input-group-append button"); - - if($(this).val()) { - button.removeClass("hide"); - var original = button.attr("onclick"); - if(original && original.indexOf("id_original=") !== -1) { - var newOnclick = original.replace(/id_original=\d+/, "id_original=" + $(this).val()); - button.attr("onclick", newOnclick); - } - } else { - button.addClass("hide"); - } + $("#subcategoria").val(null).trigger("change"); }); // Gestione del cambio marca per aggiornare i modelli -$("#id_marca_edit").change(function() { +$("#id_marca").change(function() { updateSelectOption("id_marca", $(this).val()); // Reset del modello - $("#id_modello_edit").val(null).trigger("change"); + $("#id_modello").val(null).trigger("change"); // Aggiornamento dell'icona "aggiungi" per il modello if($(this).val()) { - var button = $("#id_modello_edit").parent().find(".input-group-append button"); + var button = $("#id_modello").parent().find(".input-group-append button"); var original = button.attr("onclick"); if(original) { var newOnclick = original.replace(/id_original=\d+/, "id_original=" + $(this).val()); @@ -376,7 +369,7 @@ button.removeClass("hide"); } } else { - $("#id_modello_edit").parent().find(".input-group-append button").addClass("hide"); + $("#id_modello").parent().find(".input-group-append button").addClass("hide"); } }); @@ -393,6 +386,28 @@ function scorporaIva() { scorporaIva(); }); +function generaBarcode() { + $.ajax({ + url: globals.rootdir + "/actions.php", + type: "POST", + data: { + id_module: globals.id_module, + id_record: globals.id_record, + op: "generate-barcode" + }, + success: function(response) { + response = JSON.parse(response); + let input = $("#barcode"); + input.val(response.barcode); + }, + error: function(xhr, status, error) { + } + }); +} + +$("#generaBarcode").click( function() { + generaBarcode(); +}); From 5543b80246711897a3600dc232eecc3da6209a8e Mon Sep 17 00:00:00 2001 From: maulapi Date: Wed, 30 Jul 2025 12:03:26 +0200 Subject: [PATCH 3/3] Ulteriori modifiche modulo Ubicazioni --- modules/articoli/actions.php | 109 +++++------------------------ modules/articoli/add.php | 16 ++--- modules/ubicazioni/add.php | 10 +-- modules/ubicazioni/edit.php | 8 +-- templates/ubicazione/body.php | 74 ++++++++++++++++++++ templates/ubicazione/footer.php | 21 ++++++ templates/ubicazione/header.php | 21 ++++++ templates/ubicazione/init.php | 29 ++++++++ templates/ubicazioneBig/body.php | 75 ++++++++++++++++++++ templates/ubicazioneBig/footer.php | 21 ++++++ templates/ubicazioneBig/header.php | 21 ++++++ templates/ubicazioneBig/init.php | 29 ++++++++ update/2_8_3.sql | 47 ------------- update/2_9.sql | 66 ++++++++++++++++- 14 files changed, 380 insertions(+), 167 deletions(-) create mode 100755 templates/ubicazione/body.php create mode 100755 templates/ubicazione/footer.php create mode 100755 templates/ubicazione/header.php create mode 100755 templates/ubicazione/init.php create mode 100755 templates/ubicazioneBig/body.php create mode 100755 templates/ubicazioneBig/footer.php create mode 100755 templates/ubicazioneBig/header.php create mode 100755 templates/ubicazioneBig/init.php diff --git a/modules/articoli/actions.php b/modules/articoli/actions.php index 49f5e8103f..65aa9733ac 100755 --- a/modules/articoli/actions.php +++ b/modules/articoli/actions.php @@ -62,6 +62,11 @@ $articolo->name = post('descrizione'); } + if (post('genera_barcode')) { + $codice = '200'.str_pad((string) $articolo->id, 9, '0', STR_PAD_LEFT); + $barcode = (new Picqer\Barcode\Types\TypeEan13())->getBarcode($codice)->getBarcode(); + } + $articolo->barcode = $barcode ?: post('barcode'); $articolo->coefficiente = post('coefficiente'); $articolo->idiva_vendita = post('idiva_vendita'); $articolo->prezzo_acquisto = post('prezzo_acquisto'); @@ -71,7 +76,7 @@ $articolo->idconto_vendita = post('idconto_vendita'); $articolo->idconto_acquisto = post('idconto_acquisto'); $articolo->abilita_serial = post('abilita_serial_add'); - + $articolo->ubicazione = post('ubicazione'); $articolo->um = post('um'); $articolo->um_secondaria = post('um_secondaria'); $articolo->fattore_um_secondaria = post('fattore_um_secondaria'); @@ -92,53 +97,6 @@ $id_record = $articolo->id; $iva = post('idiva_vendita') ? Aliquota::find(post('idiva_vendita')) : null; - if (post('genera_barcode')) { - // Genera un barcode unico controllando sia la tabella mg_articoli che mg_articoli_barcode - // per evitare conflitti con barcode esistenti sia principali che aggiuntivi - $tentativi = 0; - $max_tentativi = 1000; // Limite massimo di tentativi per evitare loop infiniti - - do { - // Genera il codice EAN-13 basato sull'ID dell'articolo più il numero di tentativi - $codice = '200'.str_pad((string) ($articolo->id + $tentativi), 9, '0', STR_PAD_LEFT); - $barcode = (new Picqer\Barcode\Types\TypeEan13())->getBarcode($codice)->getBarcode(); - - // Controlla se il barcode è già presente nella tabella mg_articoli (barcode principali) - $esistente_articoli = Articolo::where('barcode', $barcode)->count() > 0; - - // Controlla se il barcode è già presente nella tabella mg_articoli_barcode (barcode aggiuntivi) - $esistente_barcode = $dbo->table('mg_articoli_barcode') - ->where('barcode', $barcode) - ->count() > 0; - - // Controlla se il barcode coincide con un codice articolo esistente - // per evitare conflitti tra barcode e codici articolo - $coincide_codice = Articolo::where([ - ['codice', $barcode], - ['barcode', '=', ''] - ])->count() > 0; - - $tentativi++; - - } while (($esistente_articoli || $esistente_barcode || $coincide_codice) && $tentativi < $max_tentativi); - - // Se dopo tutti i tentativi non è stato trovato un barcode unico, non genera il barcode - if ($tentativi >= $max_tentativi) { - $barcode = null; - flash()->warning(tr('Impossibile generare un barcode unico dopo _NUM_ tentativi', [ - '_NUM_' => $max_tentativi - ])); - } - } - - $barcode = ($barcode ? $barcode : post('barcode')); - if (!empty($barcode)) { - $dbo->insert('mg_articoli_barcode', [ - 'idarticolo' => $id_record, - 'barcode' => $barcode, - ]); - } - if (isAjaxRequest()) { echo json_encode([ 'id' => $id_record, @@ -181,9 +139,10 @@ } $articolo->codice = post('codice', true); + $articolo->barcode = post('barcode'); $articolo->um = post('um'); - $articolo->id_categoria = post('categoria_edit') ?: post('categoria'); - $articolo->id_sottocategoria = post('subcategoria_edit') ?: post('subcategoria'); + $articolo->id_categoria = post('categoria'); + $articolo->id_sottocategoria = post('subcategoria'); $articolo->abilita_serial = post('abilita_serial'); $articolo->ubicazione = post('ubicazione'); $articolo->coefficiente = post('coefficiente'); @@ -196,8 +155,8 @@ $articolo->servizio = post('servizio'); $articolo->volume = post('volume'); $articolo->peso_lordo = post('peso_lordo'); - $articolo->id_marca = post('id_marca_edit') ?: post('id_marca'); - $articolo->id_modello = post('id_modello_edit') ?: post('id_modello'); + $articolo->id_marca = post('id_marca'); + $articolo->id_modello = post('id_modello'); $articolo->um_secondaria = post('um_secondaria'); $articolo->fattore_um_secondaria = post('fattore_um_secondaria'); @@ -506,48 +465,12 @@ break; case 'generate-barcode': - // Genera un barcode unico controllando sia la tabella mg_articoli che mg_articoli_barcode - // per garantire l'unicità anche considerando i barcode aggiuntivi degli articoli - $tentativi = 0; - $max_tentativi = 1000; // Limite massimo di tentativi per evitare loop infiniti - - do { - // Genera il codice EAN-13 basato sull'ID dell'articolo più il numero di tentativi - $codice = '200'.str_pad((string) ($id_record + $tentativi), 9, '0', STR_PAD_LEFT); - $barcode = (new Picqer\Barcode\Types\TypeEan13())->getBarcode($codice)->getBarcode(); - - // Controlla se il barcode è già presente nella tabella mg_articoli (barcode principali) - $esistente_articoli = Articolo::where('barcode', $barcode)->count() > 0; - - // Controlla se il barcode è già presente nella tabella mg_articoli_barcode (barcode aggiuntivi) - $esistente_barcode = $dbo->table('mg_articoli_barcode') - ->where('barcode', $barcode) - ->count() > 0; - - // Controlla se il barcode coincide con un codice articolo esistente - // per evitare conflitti tra barcode e codici articolo - $coincide_codice = Articolo::where([ - ['codice', $barcode], - ['barcode', '=', ''] - ])->count() > 0; + $codice = '200'.str_pad((string) $id_record, 9, '0', STR_PAD_LEFT); + $barcode = (new Picqer\Barcode\Types\TypeEan13())->getBarcode($codice)->getBarcode(); - $tentativi++; - - } while (($esistente_articoli || $esistente_barcode || $coincide_codice) && $tentativi < $max_tentativi); - - // Se dopo tutti i tentativi non è stato trovato un barcode unico, restituisce un errore - if ($tentativi >= $max_tentativi) { - echo json_encode([ - 'error' => tr('Impossibile generare un barcode unico dopo _NUM_ tentativi', [ - '_NUM_' => $max_tentativi - ]) - ]); - } else { - // Restituisce il barcode generato con successo - echo json_encode([ - 'barcode' => $barcode, - ]); - } + echo json_encode([ + 'barcode' => $barcode, + ]); break; } diff --git a/modules/articoli/add.php b/modules/articoli/add.php index 9757dd72df..e827b4066b 100755 --- a/modules/articoli/add.php +++ b/modules/articoli/add.php @@ -97,7 +97,7 @@
    - {[ "type": "number", "label": "", "name": "qta", "decimals": "qta", "value": "" ]} + {[ "type": "number", "label": "", "name": "qta", "decimals": "qta" ]}
    @@ -111,7 +111,7 @@
    - {[ "type": "select", "label": "", "name": "um", "value": "", "ajax-source": "misure", "icon-after": "add|first()->id; ?>" ]} + {[ "type": "select", "label": "", "name": "um", "value": "", "ajax-source": "misure", "icon-after": "add|first()->id; ?>" ]}
    {[ "type": "select", "label": "", "name": "um_secondaria", "value": "", "ajax-source": "misure", "help": "" ]} @@ -137,10 +137,11 @@
    - + +
    - {[ "type": "select", "label": "", "name": "ubicazione", "value": "$ubicazione$", "ajax-source": "ubicaz", "icon-after": "add|first()->id; ?>" ]} + {[ "type": "select", "label": "", "name": "ubicazione", "value": "", "ajax-source": "ubicaz" ]}
    @@ -262,11 +263,4 @@ function scorpora_iva_add() { $("#genera_barcode").click(function(){ $(".modal #barcode").attr("disabled", $(this).is(":checked")).val(""); }); - -// Espandi automaticamente la sezione "Informazioni aggiuntive" se sono precompilati dati dall'ImportFE -$(document).ready(function() { - if (input("prezzo_acquisto").get() > 0 || input("qta").get() > 0 || input("um").get()) { - $(".card.collapsed-card .card-tools button[data-card-widget='collapse']").click(); - } -}); diff --git a/modules/ubicazioni/add.php b/modules/ubicazioni/add.php index 4ea92736f0..8460062d6f 100644 --- a/modules/ubicazioni/add.php +++ b/modules/ubicazioni/add.php @@ -27,14 +27,8 @@
    {[ "type": "text", "label": "", "name": "u_label", "required": 1, "value": "$u_label$" ]}
    -
    - {[ "type": "text", "label": "", "name": "title", "value": "$title$" ]} + {[ "type": "text", "label": "", "name": "title", "required": 1, "value": "$title$" ]}
    {[ "type": "text", "label": "", "name": "notes", "value": "$notes$" ]} @@ -68,4 +62,4 @@ $('#modals > div #colore_').parent().find('.square').css('background', $('#modals > div #colore_').val()); }); - \ No newline at end of file + diff --git a/modules/ubicazioni/edit.php b/modules/ubicazioni/edit.php index 1a26d70d22..e67b69dcde 100644 --- a/modules/ubicazioni/edit.php +++ b/modules/ubicazioni/edit.php @@ -39,14 +39,8 @@
    {[ "type": "text", "label": "", "name": "u_label", "required": 1, "value": "$u_label$" ]}
    -
    - {[ "type": "text", "label": "", "name": "title", "value": "$title$" ]} + {[ "type": "text", "label": "", "name": "title", "required": 1, "value": "$title$" ]}
    {[ "type": "text", "label": "", "name": "notes", "value": "$notes$" ]} diff --git a/templates/ubicazione/body.php b/templates/ubicazione/body.php new file mode 100755 index 0000000000..1720bb3f5e --- /dev/null +++ b/templates/ubicazione/body.php @@ -0,0 +1,74 @@ +. + */ + +//use Database; +//use Modules\Ubicazioni; + +include_once __DIR__.'/../../core.php'; + +echo ''; + +if (!empty($_SESSION['superselect']['id_ubicazione_barcode'])) { + //$records = Ubicazioni::whereIn('id', $_SESSION['superselect']['id_ubicazione_barcode'])->get(); + //unset($_SESSION['superselect']['id_ubicazione_barcode']); +} else { + $records = $dbo->fetchOne('SELECT id FROM `mg_ubicazioni` WHERE id='.prepare($id_record)); +} + +$pages = count($records); +$page = 0; +//$prezzi_ivati = setting('Utilizza prezzi di vendita comprensivi di IVA'); + +foreach ($records as $record) { + //$row = $dbo->fetchOne('SELECT * FROM `mg_ubicazioni` WHERE id='.prepare($id_record)); + //adeguamento a mg_ubicazioni_lang + $row = $dbo->fetchOne('SELECT `mg_ubicazioni`.*, `mg_ubicazioni_lang`.`title` AS title, `mg_ubicazioni_lang`.`notes` FROM `mg_ubicazioni` LEFT JOIN `mg_ubicazioni_lang` ON (`mg_ubicazioni`.`id`=`mg_ubicazioni_lang`.`id_record` AND `mg_ubicazioni_lang`.`id_lang`='.prepare(parameter: Models\Locale::getDefault()->id).') WHERE `mg_ubicazioni`.`id`='.prepare($id_record)); + $u_label = $row['u_label']; + $u_title = $row['title']; + if ($u_title == NULL) { + $u_title = "--"; + } + //$barcode = strtolower(trim($row['u_label']).trim($u_label_info)); + + echo ' +
    +

    '.$u_label.'

    +

    '.$u_title.'


    + + + +
    '; + + ++$page; + + if ($page < $pages) { + echo ''; + } +} + diff --git a/templates/ubicazione/footer.php b/templates/ubicazione/footer.php new file mode 100755 index 0000000000..1a80e0a55a --- /dev/null +++ b/templates/ubicazione/footer.php @@ -0,0 +1,21 @@ +. + */ + +echo ' +'; diff --git a/templates/ubicazione/header.php b/templates/ubicazione/header.php new file mode 100755 index 0000000000..1a80e0a55a --- /dev/null +++ b/templates/ubicazione/header.php @@ -0,0 +1,21 @@ +. + */ + +echo ' +'; diff --git a/templates/ubicazione/init.php b/templates/ubicazione/init.php new file mode 100755 index 0000000000..aa1dd220fa --- /dev/null +++ b/templates/ubicazione/init.php @@ -0,0 +1,29 @@ +. + */ + +include_once __DIR__.'/../../core.php'; + +//use Modules\Articoli\Articolo; + +//$record_modulo_ubicazione = Articolo::find($id_record); +/* +if (!empty($id_record)) { + $record = $dbo->fetchOne('SELECT * FROM `mg_ubicazioni` WHERE id='.prepare($id_record)); +} +*/ diff --git a/templates/ubicazioneBig/body.php b/templates/ubicazioneBig/body.php new file mode 100755 index 0000000000..22401f11b1 --- /dev/null +++ b/templates/ubicazioneBig/body.php @@ -0,0 +1,75 @@ +. + */ + +//use Database; +//use Modules\Ubicazioni; + +include_once __DIR__.'/../../core.php'; + +echo ''; + +if (!empty($_SESSION['superselect']['id_ubicazione_barcode'])) { + //$records = Ubicazioni::whereIn('id', $_SESSION['superselect']['id_ubicazione_barcode'])->get(); + //unset($_SESSION['superselect']['id_ubicazione_barcode']); +} else { + $records = $dbo->fetchOne('SELECT id FROM `mg_ubicazioni` WHERE id='.prepare($id_record)); +} + +$pages = count($records); +$page = 0; +//$prezzi_ivati = setting('Utilizza prezzi di vendita comprensivi di IVA'); + +foreach ($records as $record) { + //$row = $dbo->fetchOne('SELECT * FROM `mg_ubicazioni` WHERE id='.prepare($id_record)); + //adeguamento a mg_ubicazioni_lang + $row = $dbo->fetchOne('SELECT `mg_ubicazioni`.*, `mg_ubicazioni_lang`.`title` AS title, `mg_ubicazioni_lang`.`notes` FROM `mg_ubicazioni` LEFT JOIN `mg_ubicazioni_lang` ON (`mg_ubicazioni`.`id`=`mg_ubicazioni_lang`.`id_record` AND `mg_ubicazioni_lang`.`id_lang`='.prepare(parameter: Models\Locale::getDefault()->id).') WHERE `mg_ubicazioni`.`id`='.prepare($id_record)); + $u_label = $row['u_label']; + $u_title = $row['title']; + if ($u_title == NULL) { + $u_title = "--"; + } + //$barcode = strtolower(trim($row['u_label']).trim($u_label_info)); + + echo ' +
    +

    '.$u_label.'

    +

    '.substr($u_label,5,3).'

    + + + + +
    '; + + ++$page; + + if ($page < $pages) { + echo ''; + } +} + diff --git a/templates/ubicazioneBig/footer.php b/templates/ubicazioneBig/footer.php new file mode 100755 index 0000000000..1a80e0a55a --- /dev/null +++ b/templates/ubicazioneBig/footer.php @@ -0,0 +1,21 @@ +. + */ + +echo ' +'; diff --git a/templates/ubicazioneBig/header.php b/templates/ubicazioneBig/header.php new file mode 100755 index 0000000000..1a80e0a55a --- /dev/null +++ b/templates/ubicazioneBig/header.php @@ -0,0 +1,21 @@ +. + */ + +echo ' +'; diff --git a/templates/ubicazioneBig/init.php b/templates/ubicazioneBig/init.php new file mode 100755 index 0000000000..aa1dd220fa --- /dev/null +++ b/templates/ubicazioneBig/init.php @@ -0,0 +1,29 @@ +. + */ + +include_once __DIR__.'/../../core.php'; + +//use Modules\Articoli\Articolo; + +//$record_modulo_ubicazione = Articolo::find($id_record); +/* +if (!empty($id_record)) { + $record = $dbo->fetchOne('SELECT * FROM `mg_ubicazioni` WHERE id='.prepare($id_record)); +} +*/ diff --git a/update/2_8_3.sql b/update/2_8_3.sql index e4d84912c3..36ab75a571 100644 --- a/update/2_8_3.sql +++ b/update/2_8_3.sql @@ -190,52 +190,5 @@ ORDER BY `id`, `nome` ASC' WHERE `zz_modules`.`name` = 'Utenti e permessi'; --- Aggiunta Modulo Ubicazioni -CREATE TABLE `mg_ubicazioni` ( - `id` int(11) NOT NULL, - `u_label` varchar(255) NOT NULL, - `colore` varchar(255) DEFAULT NULL, - `u_tags` varchar(255) DEFAULT NULL, - `created_at` timestamp NULL DEFAULT current_timestamp(), - `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), - `deleted_at` timestamp NULL DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -ALTER TABLE `mg_ubicazioni` - ADD PRIMARY KEY (`id`); - -ALTER TABLE `mg_ubicazioni` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; -COMMIT; - -CREATE TABLE `mg_ubicazioni_lang` ( - `id` int(11) NOT NULL, - `id_lang` int(11) NOT NULL, - `id_record` int(11) NOT NULL, - `title` varchar(255) DEFAULT NULL, - `notes` varchar(255) DEFAULT NULL, - `created_at` timestamp NOT NULL DEFAULT current_timestamp(), - `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - -ALTER TABLE `mg_ubicazioni_lang` - ADD PRIMARY KEY (`id`), - ADD KEY `mg_ubicazioni_lang_ibfk_2` (`id_lang`) USING BTREE, - ADD KEY `mg_ubicazioni_lang_ibfk_1` (`id_record`) USING BTREE; - -ALTER TABLE `mg_ubicazioni_lang` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; - -ALTER TABLE `mg_ubicazioni_lang` - ADD CONSTRAINT `mg_ubicazioni_lang_ibfk_1` FOREIGN KEY (`id_record`) REFERENCES `mg_ubicazioni` (`id`) ON DELETE CASCADE, - ADD CONSTRAINT `mg_ubicazioni_lang_ibfk_2` FOREIGN KEY (`id_lang`) REFERENCES `zz_langs` (`id`) ON DELETE CASCADE; -COMMIT; - -INSERT INTO `zz_modules` (`name`, `directory`, `attachments_directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`, `use_notes`, `use_checklists`) VALUES -('Ubicazioni', 'ubicazioni', 'ubicazioni', 'SELECT |select| FROM `mg_ubicazioni` LEFT JOIN `mg_ubicazioni_lang` ON (`mg_ubicazioni`.`id` = `mg_ubicazioni_lang`.`id_record` AND `mg_ubicazioni_lang`.|lang|) WHERE 1=1 HAVING 2=2 ORDER BY TRIM(`mg_ubicazioni`.`u_label`)', '', 'nav-icon fa fa-circle-o', '2.8.1', '2.8.1', 110, 20, 1, 1, 0, 0); - -INSERT INTO `zz_modules_lang` (`id_lang`, `id_record`, `title`, `meta_title`) VALUES -( 1, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ubicazioni'), 'Ubicazioni', 'Ubicazioni'); -INSERT INTO `zz_modules_lang` (`id_lang`, `id_record`, `title`, `meta_title`) VALUES -( 2, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ubicazioni'), 'Ubicazioni', 'Ubicazioni'); diff --git a/update/2_9.sql b/update/2_9.sql index 296484f2de..9a3e284941 100644 --- a/update/2_9.sql +++ b/update/2_9.sql @@ -276,4 +276,68 @@ CREATE TABLE `em_email_attachment` (`id` INT NOT NULL AUTO_INCREMENT , `id_email -- Tasto per disattivazione dei task ALTER TABLE `zz_tasks` ADD `enabled` TINYINT NOT NULL DEFAULT '0'; -UPDATE `zz_tasks` SET `enabled` = '1'; \ No newline at end of file +UPDATE `zz_tasks` SET `enabled` = '1'; + + +-- Aggiunta Modulo Ubicazioni +CREATE TABLE `mg_ubicazioni` ( + `id` int(11) NOT NULL, + `u_label` varchar(255) NOT NULL, + `colore` varchar(255) DEFAULT NULL, + `u_tags` varchar(255) DEFAULT NULL, + `created_at` timestamp NULL DEFAULT current_timestamp(), + `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `deleted_at` timestamp NULL DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +ALTER TABLE `mg_ubicazioni` + ADD PRIMARY KEY (`id`); + +ALTER TABLE `mg_ubicazioni` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; +COMMIT; + +CREATE TABLE `mg_ubicazioni_lang` ( + `id` int(11) NOT NULL, + `id_lang` int(11) NOT NULL, + `id_record` int(11) NOT NULL, + `title` varchar(255) DEFAULT NULL, + `notes` varchar(255) DEFAULT NULL, + `created_at` timestamp NOT NULL DEFAULT current_timestamp(), + `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +ALTER TABLE `mg_ubicazioni_lang` + ADD PRIMARY KEY (`id`), + ADD KEY `mg_ubicazioni_lang_ibfk_2` (`id_lang`) USING BTREE, + ADD KEY `mg_ubicazioni_lang_ibfk_1` (`id_record`) USING BTREE; + +ALTER TABLE `mg_ubicazioni_lang` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; + +ALTER TABLE `mg_ubicazioni_lang` + ADD CONSTRAINT `mg_ubicazioni_lang_ibfk_1` FOREIGN KEY (`id_record`) REFERENCES `mg_ubicazioni` (`id`) ON DELETE CASCADE, + ADD CONSTRAINT `mg_ubicazioni_lang_ibfk_2` FOREIGN KEY (`id_lang`) REFERENCES `zz_langs` (`id`) ON DELETE CASCADE; +COMMIT; + +INSERT INTO `zz_modules` (`name`, `directory`, `attachments_directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`, `use_notes`, `use_checklists`) VALUES +('Ubicazioni', 'ubicazioni', 'ubicazioni', 'SELECT |select| FROM `mg_ubicazioni` LEFT JOIN `mg_ubicazioni_lang` ON (`mg_ubicazioni`.`id` = `mg_ubicazioni_lang`.`id_record` AND `mg_ubicazioni_lang`.|lang|) WHERE 1=1 HAVING 2=2 ORDER BY TRIM(`mg_ubicazioni`.`u_label`)', '', 'nav-icon fa fa-circle-o', '2.8.1', '2.8.1', 110, 20, 1, 1, 0, 0); + +INSERT INTO `zz_modules_lang` (`id_lang`, `id_record`, `title`, `meta_title`) VALUES +( 1, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ubicazioni'), 'Ubicazioni', 'Ubicazioni'); +INSERT INTO `zz_modules_lang` (`id_lang`, `id_record`, `title`, `meta_title`) VALUES +( 2, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ubicazioni'), 'Ubicazioni', 'Ubicazioni'); + +-- Aggiornamento zz_prints per nuovo template per modulo Ubicazioni +INSERT INTO `zz_prints` (`id_module`, `is_record`, `name`, `directory`, `previous`, `options`, `icon`, `version`, `compatibility`, `order`, `predefined`, `enabled`, `available_options`, `created_at`, `updated_at`, `default`) VALUES +((SELECT `id` FROM `zz_modules` WHERE `name` = 'Ubicazioni'), 1, 'Barcode', 'ubicazione', '', '{\"width\": 56, \"height\": 32, \"format\": [80, 60], \"margins\": {\"top\": 5,\"bottom\": 5,\"left\": 0,\"right\": 0}}', 'fa fa-print', '', '', 0, 0, 1, NULL, '2022-09-20 16:42:15', '2024-11-02 14:00:07', 1), +((SELECT `id` FROM `zz_modules` WHERE `name` = 'Ubicazioni'), 1, 'BarcodeBig', 'ubicazioneBig', '', '{\"width\": 56, \"height\": 32, \"format\": [80, 60], \"margins\": {\"top\": 5,\"bottom\": 5,\"left\": 0,\"right\": 0}}', 'fa fa-print', '', '', 0, 0, 1, NULL, '2022-09-20 16:42:15', '2024-11-20 10:53:02', 1); +COMMIT; + +--Aggiornamento zz_prints_lang per nuovo template per modulo Ubicazioni +INSERT INTO `zz_prints_lang` (`id_lang`, `id_record`, `title`, `filename`) VALUES +(1, (SELECT `id` FROM `zz_prints` WHERE `name` = 'Barcode' AND `directory` = 'ubicazione'), 'Barcode', 'Barcode'), +(2, (SELECT `id` FROM `zz_prints` WHERE `name` = 'Barcode' AND `directory` = 'ubicazione'), 'Barcode', 'Barcode'), +(1, (SELECT `id` FROM `zz_prints` WHERE `name` = 'BarcodeBig' AND `directory` = 'ubicazioneBig'), 'BarcodeBig', 'Barcode'), +(2, (SELECT `id` FROM `zz_prints` WHERE `name` = 'BarcodeBig' AND `directory` = 'ubicazioneBig'), 'BarcodeBig', 'Barcode'); +COMMIT;