INSERTINTO`zz_views`(`id`,`id_module`,`name`,`query`,`order`,`search`,`slow`,`format`,`search_inside`,`order_by`,`visible`,`summable`,`default`)VALUES(NULL,(SELECT`id`FROM`zz_modules`WHERE`name`='Interventi'),'Tecnici','GROUP_CONCAT((SELECT DISTINCT(ragione_sociale) FROM an_anagrafiche WHERE idanagrafica = in_interventi_tecnici.idtecnico))','14','1','0','0','','','1','0','0');
-- Aggiornamento query per la lettura dei contratti in scadenza
UPDATE`zz_widgets`SET`query`='SELECT COUNT(id) AS dato, co_contratti.id, DATEDIFF( data_conclusione, NOW() ) AS giorni_rimanenti FROM co_contratti WHERE idstato IN(SELECT id FROM co_staticontratti WHERE fatturabile = 1) AND rinnovabile=1 AND NOW() > DATE_ADD( data_conclusione, INTERVAL - ABS(giorni_preavviso_rinnovo) DAY) AND YEAR(data_conclusione) > 1970 AND ISNULL((SELECT id FROM co_contratti contratti WHERE contratti.idcontratto_prev=co_contratti.id )) ORDER BY giorni_rimanenti ASC'WHERE`zz_widgets`.`name`='Contratti in scadenza';
-- Fix Percentuale rivalsa INPS in Percentuale rivalsa in impostazioni
UPDATE`zz_settings`SET`nome`='Percentuale rivalsa',`tipo`='query=SELECT id, descrizione FROM `co_rivalse` ORDER BY descrizione ASC'WHERE`zz_settings`.`nome`='Percentuale rivalsa INPS';
UPDATE`zz_settings`SET`tipo`='query=SELECT ''IMP'' AS id, ''Imponibile'' AS descrizione UNION SELECT ''IMP+RIV'' AS id, ''Imponibile + rivalsa'' AS descrizione'WHERE`zz_settings`.`nome`='Metodologia calcolo ritenuta d\'accontopredefinito';
INSERTINTO`zz_modules`(`id`,`name`,`title`,`directory`,`options`,`options2`,`icon`,`version`,`compatibility`,`order`,`parent`,`default`,`enabled`)VALUES(NULL,'Rivalse','Rivalse','rivalse','SELECT |select| FROM `co_rivalse` WHERE 1=1 HAVING 2=2','','fa fa-percent','2.4.6','2.4.6','1',(SELECTidFROMzz_modulestWHEREt.name='Tabelle'),'1','1');
UPDATE`zz_settings`SET`tipo`='query=SELECT codice AS id, CONCAT_WS(\'-\', codice, descrizione) AS descrizione FROM fe_causali_pagamento_ritenuta'WHERE`zz_settings`.`nome`='Causale ritenuta d\'acconto';
UPDATE`zz_settings`SET`tipo`='query=SELECT id, descrizione FROM `co_iva` WHERE deleted_at IS NULL ORDER BY descrizione ASC'WHERE`nome`='Iva predefinita';
UPDATE`zz_settings`SET`tipo`='query=SELECT codice AS id, CONCAT_WS(\'-\', codice, descrizione) AS descrizione FROM fe_tipo_cassa'WHERE`zz_settings`.`nome`='Tipo Cassa';
UPDATE`zz_views`SET`query`='(SELECT GROUP_CONCAT(DISTINCT `name` SEPARATOR \'\r\n\') FROM zz_operations INNER JOIN zz_emails ON zz_operations.id_email = zz_emails.id WHERE zz_operations.id_module = (SELECT id FROM zz_modules WHERE `name` = \'Fatturedivendita\') AND op = \'send-email\' AND id_record = co_documenti.id ORDER BY zz_operations.created_at DESC LIMIT 1)'WHERE`zz_views`.`name`='icon_title_Inviata'ANDid_module=(SELECTidFROMzz_modulesWHEREname='Fatture di vendita');
UPDATE`zz_views`SET`query`='IF((SELECT GROUP_CONCAT(DISTINCT `name` SEPARATOR \'\r\n\') FROM zz_operations INNER JOIN zz_emails ON zz_operations.id_email = zz_emails.id WHERE zz_operations.id_module = (SELECT id FROM zz_modules WHERE `name` = \'Fatturedivendita\') AND op = \'send-email\' AND id_record = co_documenti.id ORDER BY zz_operations.created_at DESC LIMIT 1) IS NOT NULL, \'fafa-envelopetext-success\', \'\') 'WHERE`zz_views`.`name`='icon_Inviata'ANDid_module=(SELECTidFROMzz_modulesWHEREname='Fatture di vendita');
UPDATE`zz_views`SET`query`='IF((SELECT COUNT(t.numero_esterno) FROM co_documenti AS t WHERE t.numero_esterno = co_documenti.numero_esterno AND t.numero_esterno != '''' AND t.id_segment = co_documenti.id_segment AND idtipodocumento IN (SELECT id FROM co_tipidocumento WHERE dir = ''entrata'') AND t.data >= ''|period_start|'' AND t.data <= ''|period_end|'' AND YEAR(t.data) = YEAR(co_documenti.data) ) > 1, ''red'', '''') 'WHERE`zz_views`.`name`='_bg_'ANDid_module=(SELECTidFROMzz_modulesWHEREname='Fatture di vendita');
-- Aggiunto modulo per gestire la seconda ritenuta (ENASARCO, ECC..)
INSERTINTO`zz_modules`(`id`,`name`,`title`,`directory`,`options`,`options2`,`icon`,`version`,`compatibility`,`order`,`parent`,`default`,`enabled`)VALUES(NULL,'Ritenute contributi','Ritenute contributi','ritenute_contributi','SELECT |select| FROM `co_ritenuta_contributi` WHERE 1=1 HAVING 2=2','','fa fa-percent','2.4.6','2.4.6','1',(SELECT`id`FROM`zz_modules`tWHEREt.`name`='Tabelle'),'1','1');