alter Table an_anagrafiche add default_ritenuta_acconto int(11) DEFAULT '0' ;
alter Table an_anagrafiche add default_rivalsa_inps int(11) DEFAULT '0' ;
alter Table mg_articoli add `qta_colli` decimal(12,0) NOT NULL  DEFAULT '0' ;
alter Table co_tipidocumento add `colli_automatico` tinyint(1) NOT NULL DEFAULT '0';
alter Table co_tipidocumento add `pan_stampe` tinyint(1) NOT NULL DEFAULT '0';


alter Table co_documenti add `stp_prezzi` tinyint(1) NOT NULL DEFAULT '0';
alter Table co_documenti add `stp_sconti` tinyint(1) NOT NULL DEFAULT '0';
alter Table co_documenti add `stp_immagini` tinyint(1) NOT NULL DEFAULT '0';
alter Table co_documenti add `stp_descestesa` tinyint(1) NOT NULL DEFAULT '0';

alter Table co_documenti add `idmezzo` varchar(255) NOT NULL;
alter Table co_documenti add `datatrasporto` date NOT NULL;
alter Table co_documenti add `oratrasporto` time NOT NULL;



alter Table co_scadenziario add idbanca int(11) DEFAULT '0' ;
alter Table co_scadenziario add banca varchar(255) NOT NULL;

INSERT INTO `zz_viste` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `search_inside`, `order_by`, `enabled`, `summable`, `default`) VALUES
((SELECT id FROM zz_modules WHERE name = 'Scadenzario'), 'Banca', 'banca', 12, 1, 0, '', '', 1, 0, 0);


INSERT INTO `zz_gruppi_viste` (`id_gruppo`, `id_vista`) VALUES
((SELECT `id` FROM `zz_gruppi` WHERE `nome`='Amministratori'), (SELECT `id` FROM `zz_viste` WHERE id_module =  (SELECT zz_modules.id FROM zz_modules WHERE zz_modules.name = 'Scadenzario') AND `name`='Banca')),
((SELECT `id` FROM `zz_gruppi` WHERE `nome`='Tecnici'), (SELECT `id` FROM `zz_viste` WHERE id_module =  (SELECT zz_modules.id FROM zz_modules WHERE zz_modules.name = 'Scadenzario') AND `name`='Banca')),
((SELECT `id` FROM `zz_gruppi` WHERE `nome`='Agenti'), (SELECT `id` FROM `zz_viste` WHERE id_module =  (SELECT zz_modules.id FROM zz_modules WHERE zz_modules.name = 'Scadenzario') AND `name`='Banca')),
((SELECT `id` FROM `zz_gruppi` WHERE `nome`='Clienti'), (SELECT `id` FROM `zz_viste` WHERE id_module =  (SELECT zz_modules.id FROM zz_modules WHERE zz_modules.name = 'Scadenzario') AND `name`='Banca'));



CREATE TABLE `lb_formati` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
  `nome` varchar(255) NOT NULL,
  `codice` varchar(255) NOT NULL,
   PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


INSERT INTO `lb_formati` (`nome`, `codice`) VALUES
('ETICHETTE 70 x 36', '101700'),
('ETICHETTE 70 x 37', '101720'),
('ETICHETTE 105 x 35', '101800');



INSERT INTO `zz_modules` (`name`, `name2`, `module_dir`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `default_menu`, `enabled`, `type`, `new`,  `moduli_add`, `mod_personale`) VALUES
('Label', '', 'label', 'custom', '', 'fa fa-columns', '2.0.0', '2.0.0', 15, 0, 1, 0, 1, 'menu', 0,  0, 0),
('Formati', '', 'label_formati', 'SELECT |fields| FROM `lb_formati` HAVING 1=1 order by `id`', '', 'fa fa-list-ol', '2.0.0', '2.0.0', 9, 90, 1, 0, 1, 'Menu', 0,0,0);

UPDATE `zz_modules` SET `parent`=( SELECT `id` FROM (SELECT `id` FROM `zz_modules` `m2` WHERE `name`='Label') AS `m2`) WHERE `name` IN('Formati');


INSERT INTO `zz_viste` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `search_inside`, `order_by`, `enabled`, `summable`, `default`) VALUES
((SELECT id FROM zz_modules WHERE name = 'Formati'), 'id', 'id', 1, 0, 0, '', '', 0, 0, 0),
((SELECT id FROM zz_modules WHERE name = 'Formati'), 'Descrizione', 'nome', 2, 0, 0, '', '', 1, 0, 0),
((SELECT id FROM zz_modules WHERE name = 'Formati'), 'Formato', 'codice', 2, 0, 0, '', '', 1, 0, 0);

INSERT INTO `zz_gruppi_viste` (`id_gruppo`, `id_vista`) VALUES
((SELECT `id` FROM `zz_gruppi` WHERE `nome`='Amministratori'), (SELECT `id` FROM `zz_viste` WHERE id_module =  (SELECT zz_modules.id FROM zz_modules WHERE zz_modules.name = 'Formati') AND `name`='id')),
((SELECT `id` FROM `zz_gruppi` WHERE `nome`='Tecnici'), (SELECT `id` FROM `zz_viste` WHERE id_module =  (SELECT zz_modules.id FROM zz_modules WHERE zz_modules.name = 'Formati') AND `name`='id')),
((SELECT `id` FROM `zz_gruppi` WHERE `nome`='Agenti'), (SELECT `id` FROM `zz_viste` WHERE id_module =  (SELECT zz_modules.id FROM zz_modules WHERE zz_modules.name = 'Formati') AND `name`='id')),
((SELECT `id` FROM `zz_gruppi` WHERE `nome`='Clienti'), (SELECT `id` FROM `zz_viste` WHERE id_module =  (SELECT zz_modules.id FROM zz_modules WHERE zz_modules.name = 'Formati') AND `name`='id')),
((SELECT `id` FROM `zz_gruppi` WHERE `nome`='Amministratori'), (SELECT `id` FROM `zz_viste` WHERE id_module =  (SELECT zz_modules.id FROM zz_modules WHERE zz_modules.name = 'Formati') AND `name`='Descrizione')),
((SELECT `id` FROM `zz_gruppi` WHERE `nome`='Tecnici'), (SELECT `id` FROM `zz_viste` WHERE id_module =  (SELECT zz_modules.id FROM zz_modules WHERE zz_modules.name = 'Formati') AND `name`='Descrizione')),
((SELECT `id` FROM `zz_gruppi` WHERE `nome`='Agenti'), (SELECT `id` FROM `zz_viste` WHERE id_module =  (SELECT zz_modules.id FROM zz_modules WHERE zz_modules.name = 'Formati') AND `name`='Descrizione')),
((SELECT `id` FROM `zz_gruppi` WHERE `nome`='Clienti'), (SELECT `id` FROM `zz_viste` WHERE id_module =  (SELECT zz_modules.id FROM zz_modules WHERE zz_modules.name = 'Formati') AND `name`='Descrizione')),
((SELECT `id` FROM `zz_gruppi` WHERE `nome`='Amministratori'), (SELECT `id` FROM `zz_viste` WHERE id_module =  (SELECT zz_modules.id FROM zz_modules WHERE zz_modules.name = 'Formati') AND `name`='Formato')),
((SELECT `id` FROM `zz_gruppi` WHERE `nome`='Tecnici'), (SELECT `id` FROM `zz_viste` WHERE id_module =  (SELECT zz_modules.id FROM zz_modules WHERE zz_modules.name = 'Formati') AND `name`='Formato')),
((SELECT `id` FROM `zz_gruppi` WHERE `nome`='Agenti'), (SELECT `id` FROM `zz_viste` WHERE id_module =  (SELECT zz_modules.id FROM zz_modules WHERE zz_modules.name = 'Formati') AND `name`='Formato')),
((SELECT `id` FROM `zz_gruppi` WHERE `nome`='Clienti'), (SELECT `id` FROM `zz_viste` WHERE id_module =  (SELECT zz_modules.id FROM zz_modules WHERE zz_modules.name = 'Formati') AND `name`='Formato'));