gest366/update/update_2.4.0.sql

260 lines
30 KiB
MySQL
Raw Normal View History

2021-02-24 20:40:04 +00:00
alter Table an_referenti add `cellulare` varchar(50) NOT NULL;
alter Table an_referenti add `stato` varchar(25) CHARACTER SET latin1 NOT NULL DEFAULT '';
alter Table an_referenti add `note` varchar(255) CHARACTER SET latin1 NOT NULL;
alter Table an_referenti add `fax` varchar(50) NOT NULl;
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
('Rubrica', '', 'rubrica', 'SELECT |fields| FROM `an_referenti` INNER JOIN `an_anagrafiche` ON `an_referenti`.`idanagrafica`=`an_anagrafiche`.`idanagrafica` HAVING 1=1 ORDER BY `an_anagrafiche`.`ragione_sociale` ASC', '', 'fa fa-user-plus', '2.3.0', '2.3.0', 0, 0, 1, 0, 1, 'menu', 0, 0, 1);
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 = 'Rubrica') , 'id', 'an_referenti.id', 1, 1, 0, '', '', 0, 0, 0),
((SELECT id FROM zz_modules WHERE name = 'Rubrica') , 'Nominativo', 'an_referenti.nome', 3, 1, 0, '', '', 1, 0, 0),
((SELECT id FROM zz_modules WHERE name = 'Rubrica') , 'Ragione sociale', 'an_anagrafiche.ragione_sociale', 2, 1, 0, '', '', 1, 0, 0),
((SELECT id FROM zz_modules WHERE name = 'Rubrica') , 'Mansione', 'an_referenti.mansione', 4, 1, 0, '', '', 1, 0, 0),
((SELECT id FROM zz_modules WHERE name = 'Rubrica') , 'Telefono', 'an_referenti.telefono', 6, 1, 0, '', '', 1, 0, 0),
((SELECT id FROM zz_modules WHERE name = 'Rubrica') , 'Cellulare', 'an_referenti.cellulare', 7, 1, 0, '', '', 1, 0, 0),
((SELECT id FROM zz_modules WHERE name = 'Rubrica') , 'E-Mail', 'an_referenti.email', 8, 1, 0, '', '', 1, 0, 0),
((SELECT id FROM zz_modules WHERE name = 'Rubrica') , 'Status', 'an_referenti.stato', 5, 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 = 'Rubrica') 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 = 'Rubrica') 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 = 'Rubrica') 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 = 'Rubrica') 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 = 'Rubrica') AND `name`='Nominativo')),
((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 = 'Rubrica') AND `name`='Nominativo')),
((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 = 'Rubrica') AND `name`='Nominativo')),
((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 = 'Rubrica') AND `name`='Nominativo')),
((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 = 'Rubrica') AND `name`='Ragione sociale')),
((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 = 'Rubrica') AND `name`='Ragione sociale')),
((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 = 'Rubrica') AND `name`='Ragione sociale')),
((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 = 'Rubrica') AND `name`='Ragione sociale')),
((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 = 'Rubrica') AND `name`='Mansione')),
((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 = 'Rubrica') AND `name`='Mansione')),
((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 = 'Rubrica') AND `name`='Mansione')),
((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 = 'Rubrica') AND `name`='Mansione')),
((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 = 'Rubrica') AND `name`='Telefono')),
((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 = 'Rubrica') AND `name`='Telefono')),
((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 = 'Rubrica') AND `name`='Telefono')),
((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 = 'Rubrica') AND `name`='Telefono')),
((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 = 'Rubrica') AND `name`='Cellulare')),
((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 = 'Rubrica') AND `name`='Cellulare')),
((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 = 'Rubrica') AND `name`='Cellulare')),
((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 = 'Rubrica') AND `name`='Cellulare')),
((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 = 'Rubrica') AND `name`='E-Mail')),
((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 = 'Rubrica') AND `name`='E-Mail')),
((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 = 'Rubrica') AND `name`='E-Mail')),
((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 = 'Rubrica') AND `name`='E-Mail')),
((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 = 'Rubrica') AND `name`='Status')),
((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 = 'Rubrica') AND `name`='Status')),
((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 = 'Rubrica') AND `name`='Status')),
((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 = 'Rubrica') AND `name`='Status'));
CREATE TABLE IF NOT EXISTS `ms_cespiti` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`numero` int(11) NOT NULL,
`data` datetime NOT NULL,
`idtipocespite` tinyint(4) NOT NULL,
`idgruppocespite` tinyint(4) NOT NULL,
`descrizione` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `ms_cespitigruppo` (
`id` tinyint(11) NOT NULL AUTO_INCREMENT,
`descrizione` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;
CREATE TABLE IF NOT EXISTS `ms_cespitistati` (
`id` tinyint(4) NOT NULL AUTO_INCREMENT,
`descrizione` varchar(100) NOT NULL,
`annullato` tinyint(1) NOT NULL,
`icona` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
INSERT INTO `ms_cespitistati` (`id`, `descrizione`, `annullato`, `icona`) VALUES
(1, 'Attivo', 0, ''),
(2, 'Non Attivo', 0, '');
INSERT INTO `zz_modules` (`name`, `name2`, `module_dir`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `default_menu`, `enabled`, `type`, `new`) VALUES
('Cespiti', '', 'ms_cespiti', 'SELECT |fields| FROM `ms_cespiti` HAVING 1=1 order by `id`', '', 'fa fa-book', '', '', 9, 0, 1, 0, 1, 'Menu', 0),
('Cespiti Gruppo', '', 'ms_cespiti_gruppo', 'SELECT |fields| FROM `ms_cespitigruppo` HAVING 1=1 order by `id`', '', '', '', '', 9, 90, 1, 0, 1, 'Menu', 0),
('Cespiti Stato', '', 'ms_cespiti_stato', 'SELECT |fields| FROM `ms_cespitistati` HAVING 1=1 order by `id`', '', '', '', '', 2, 90, 1, 0, 1, 'Menu', 0);
UPDATE `zz_modules` SET `parent`=( SELECT `id` FROM (SELECT `id` FROM `zz_modules` `m2` WHERE `name`='Cespiti') AS `m2`) WHERE `name` IN('Cespiti Gruppo','Cespiti Stato');
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 = 'Cespiti'), 'id', 'id', 1, 0, 0, '', '', 0, 0, 0),
((SELECT id FROM zz_modules WHERE name = 'Cespiti'), 'Numero', 'numero', 2, 1, 0, '', '', 1, 0, 0),
((SELECT id FROM zz_modules WHERE name = 'Cespiti'), 'Descrizione', 'descrizione', 3, 1, 0, '', '', 0, 0, 0),
((SELECT id FROM zz_modules WHERE name = 'Cespiti'), 'Data', 'DATE_FORMAT(data, \'%d/%m/%Y\')', 5, 1, 0, '', '', 1, 0, 0),
((SELECT id FROM zz_modules WHERE name = 'Cespiti'), 'Gruppo', '(SELECT descrizione FROM ms_cespitigruppo WHERE idgruppocespite=ms_cespitigruppo.id)', 10, 1, 0, '', '', 1, 0, 0),
((SELECT id FROM zz_modules WHERE name = 'Cespiti'), 'Stato', '(SELECT descrizione FROM ms_cespitistati WHERE idtipocespite=ms_cespitistati.id)',11, 1, 0, '', '', 1, 0, 0),
((SELECT id FROM zz_modules WHERE name = 'Cespiti Gruppo'), 'id', 'id', 1, 0, 0, '', '', 0, 0, 0),
((SELECT id FROM zz_modules WHERE name = 'Cespiti Gruppo'), 'Descrizione', 'descrizione', 2, 0, 0, '', '', 1, 0, 0),
((SELECT id FROM zz_modules WHERE name = 'Cespiti Stato'), 'id', 'id', 1, 0, 0, '', '', 0, 0, 0),
((SELECT id FROM zz_modules WHERE name = 'Cespiti Stato'), 'Descrizione', 'descrizione', 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 = 'Cespiti') 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 = 'Cespiti') 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 = 'Cespiti') 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 = 'Cespiti') 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 = 'Cespiti') AND `name`='Numero')),
((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 = 'Cespiti') AND `name`='Numero')),
((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 = 'Cespiti') AND `name`='Numero')),
((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 = 'Cespiti') AND `name`='Numero')),
((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 = 'Cespiti') 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 = 'Cespiti') 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 = 'Cespiti') 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 = 'Cespiti') 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 = 'Cespiti') AND `name`='Data')),
((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 = 'Cespiti') AND `name`='Data')),
((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 = 'Cespiti') AND `name`='Data')),
((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 = 'Cespiti') AND `name`='Data')),
((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 = 'Cespiti') AND `name`='Gruppo')),
((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 = 'Cespiti') AND `name`='Gruppo')),
((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 = 'Cespiti') AND `name`='Gruppo')),
((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 = 'Cespiti') AND `name`='Gruppo')),
((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 = 'Cespiti') AND `name`='Stato')),
((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 = 'Cespiti') AND `name`='Stato')),
((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 = 'Cespiti') AND `name`='Stato')),
((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 = 'Cespiti') AND `name`='Stato')),
((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 = 'Cespiti Gruppo') 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 = 'Cespiti Gruppo') 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 = 'Cespiti Gruppo') 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 = 'Cespiti Gruppo') 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 = 'Cespiti Gruppo') 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 = 'Cespiti Gruppo') 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 = 'Cespiti Gruppo') 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 = 'Cespiti Gruppo') 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 = 'Cespiti Stato') 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 = 'Cespiti Stato') 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 = 'Cespiti Stato') 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 = 'Cespiti Stato') 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 = 'Cespiti Stato') 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 = 'Cespiti Stato') 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 = 'Cespiti Stato') 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 = 'Cespiti Stato') AND `name`='Descrizione'));
INSERT INTO `zz_widget_modules` (`name`, `type`, `id_module`, `location`, `class`, `query`, `bgcolor`, `icon`, `print_link`, `more_link`, `more_link_type`, `php_include`, `text`, `enabled`, `order`) VALUES
('Stampa cespiti', 'print', (SELECT `id` FROM `zz_modules` `m2` WHERE `name`='Cespiti'), 'controller_top', 'col-md-2', '', '#45a9f1', 'fa fa-print', '', 'if( confirm(\'Stampare elenco cespiti?\') ){ window.open(\'templates/pdfgen.php?ptype=cespiti&search_codice=\'+$(\'#th_Numero input\').val()\r\n+\'&search_descrizione=\'+$(\'#th_Descrizione input\').val()\r\n+\'&search_gruppo=\'+$(\'#th_Gruppo input\').val()\r\n+\'&search_stato=\'+$(\'#th_Stato input\').val()\r\n+\'&search_tipo=solo prodotti attivi\'); }', 'javascript', '', 'Stampa cespiti', 1, 1);
CREATE TABLE IF NOT EXISTS `ms_spese` (
`idscheda` int(11) NOT NULL AUTO_INCREMENT,
`nome` varchar(255) NOT NULL,
`descrizione` varchar(5000) NOT NULL,
`idanagrafica` int(11) NOT NULL,
`idtecnico` int(11) NOT NULL,
`data_archiviazione` date NOT NULL,
`idstato` tinyint(4) NOT NULL,
`importo` decimal(12,4) NOT NULL,
`note` varchar(255) NOT NULL,
`idconti` int(11) NOT NULL,
PRIMARY KEY (`idscheda`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `ms_spese_gruppo` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`descrizione` varchar(255) NOT NULL,
`colore` varchar(7) NOT NULL DEFAULT '#FFFFFF',
`idprimanota` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
INSERT INTO `zz_modules` (`name`, `name2`, `module_dir`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `default_menu`, `enabled`, `type`, `new`) VALUES
('Nota Spese', '', 'ms_notaspese', 'SELECT |fields| FROM `ms_spese` HAVING 1=1 order by `id`', '', 'fa fa-book', '', '', 9, 0, 1, 0, 1, 'Menu', 0),
('Spese Tipologia', '', 'ms_notaspese_gruppo', 'SELECT |fields| FROM `ms_spese_gruppo` HAVING 1=1 order by `id`', '', '', '', '', 9, 90, 1, 0, 1, 'Menu', 0);
UPDATE `zz_modules` SET `parent`=( SELECT `id` FROM (SELECT `id` FROM `zz_modules` `m2` WHERE `name`='Nota Spese') AS `m2`) WHERE `name` IN('Spese Tipologia');
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 = 'Nota Spese'), 'id', 'idscheda', 1, 0, 0, '', '', 0, 0, 0),
((SELECT id FROM zz_modules WHERE name = 'Nota Spese'), 'Data', 'DATE_FORMAT(data_archiviazione, \'%d/%m/%Y\')', 2, 1, 0, '', '', 1, 0, 0),
((SELECT id FROM zz_modules WHERE name = 'Nota Spese'), 'Tecnico', '(SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=ms_spese.idtecnico)', 3, 1, 0, '', '', 1, 0, 0),
((SELECT id FROM zz_modules WHERE name = 'Nota Spese'), 'Anagrafica', '(SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=ms_spese.idanagrafica)', 4, 1, 0, '', '', 1, 0, 0),
((SELECT id FROM zz_modules WHERE name = 'Nota Spese'), 'Nome', 'nome', 5, 1, 0, '', '', 1, 0, 0),
((SELECT id FROM zz_modules WHERE name = 'Nota Spese'), 'Tipologia', '(SELECT descrizione FROM ms_spese_gruppo WHERE id=ms_spese.idstato)', 6, 1, 0, '', '', 1, 0, 0),
((SELECT id FROM zz_modules WHERE name = 'Nota Spese'), 'Importo', 'FORMAT(importo, 2, ''de_DE'' )',7, 1, 0, '', '', 1, 0, 0),
((SELECT id FROM zz_modules WHERE name = 'Spese Tipologia'), 'id', 'id', 1, 0, 0, '', '', 0, 0, 0),
((SELECT id FROM zz_modules WHERE name = 'Spese Tipologia'), 'Descrizione', 'descrizione', 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 = 'Nota Spese') 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 = 'Nota Spese') 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 = 'Nota Spese') 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 = 'Nota Spese') 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 = 'Nota Spese') AND `name`='Tecnico')),
((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 = 'Nota Spese') AND `name`='Tecnico')),
((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 = 'Nota Spese') AND `name`='Tecnico')),
((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 = 'Nota Spese') AND `name`='Tecnico')),
((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 = 'Nota Spese') AND `name`='Anagrafica')),
((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 = 'Nota Spese') AND `name`='Anagrafica')),
((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 = 'Nota Spese') AND `name`='Anagrafica')),
((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 = 'Nota Spese') AND `name`='Anagrafica')),
((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 = 'Nota Spese') AND `name`='Data')),
((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 = 'Nota Spese') AND `name`='Data')),
((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 = 'Nota Spese') AND `name`='Data')),
((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 = 'Nota Spese') AND `name`='Data')),
((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 = 'Nota Spese') AND `name`='Nome')),
((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 = 'Nota Spese') AND `name`='Nome')),
((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 = 'Nota Spese') AND `name`='Nome')),
((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 = 'Nota Spese') AND `name`='Nome')),
((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 = 'Nota Spese') AND `name`='Stato')),
((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 = 'Nota Spese') AND `name`='Stato')),
((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 = 'Nota Spese') AND `name`='Stato')),
((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 = 'Nota Spese') AND `name`='Stato')),
((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 = 'Nota Spese') AND `name`='Importo')),
((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 = 'Nota Spese') AND `name`='Importo')),
((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 = 'Nota Spese') AND `name`='Importo')),
((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 = 'Nota Spese') AND `name`='Importo')),
((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 = 'Spese Tipologia') 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 = 'Spese Tipologia') 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 = 'Spese Tipologia') 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 = 'Spese Tipologia') 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 = 'Spese Tipologia') 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 = 'Spese Tipologia') 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 = 'Spese Tipologia') 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 = 'Spese Tipologia') AND `name`='Descrizione'));