1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-26 07:44:02 +01:00

Aggiunta colonne Contratto, Preventivo, Ordine in Attività

This commit is contained in:
MatteoPistorello 2022-04-08 11:19:27 +02:00
parent 3ded6ce37f
commit 7a9d001f06

View File

@ -91,11 +91,16 @@ INSERT INTO `zz_prints` (`id`, `id_module`, `is_record`, `name`, `title`, `filen
(NULL, (SELECT id FROM zz_modules WHERE `name`='Interventi'), 1, 'Intervento & checklist', 'Intervento & checklist', 'Intervento num {numero} del {data}', 'interventi', 'idintervento', '{\"pricing\":true, \"checklist\": true}', 'fa fa-print', '', '', 0, 1, 1, 1),
(NULL, (SELECT id FROM zz_modules WHERE `name`='Interventi'), 1, 'Intervento & checklist (senza costi)', 'Intervento & checklist (senza prezzi)', 'Intervento num {numero} del {data}', 'interventi', 'idintervento', '{\"pricing\":false, \"checklist\": true}', 'fa fa-print', '', '', 0, 1, 1, 1);
--
-- Modificata query rif. fattura effettuando la ricerca su original_document e original_id e aggiunta colonne Preventivo, Ordine, Contratto in Attività
UPDATE `zz_modules` SET `options` = 'SELECT |select|\nFROM `or_ordini`\n LEFT JOIN `an_anagrafiche` ON `or_ordini`.`idanagrafica` = `an_anagrafiche`.`idanagrafica`\n LEFT JOIN `or_tipiordine` ON `or_ordini`.`idtipoordine` = `or_tipiordine`.`id`\n LEFT JOIN (\n SELECT `idordine`,\n SUM(`qta` - `qta_evasa`) AS `qta_da_evadere`,\n SUM(`subtotale` - `sconto`) AS `totale_imponibile`,\n SUM(`subtotale` - `sconto` + `iva`) AS `totale`\n FROM `or_righe_ordini`\n GROUP BY `idordine`\n ) AS righe ON `or_ordini`.`id` = `righe`.`idordine`\n LEFT JOIN (\n SELECT `idordine`,\n MIN(`data_evasione`) AS `data_evasione`\n FROM `or_righe_ordini`\n WHERE (`qta` - `qta_evasa`)>0\n GROUP BY `idordine`\n ) AS `righe_da_evadere` ON `righe`.`idordine`=`righe_da_evadere`.`idordine`\n LEFT JOIN (\n SELECT GROUP_CONCAT(DISTINCT co_documenti.numero_esterno SEPARATOR \", \") AS info, co_righe_documenti.original_document_id AS idordine FROM co_documenti INNER JOIN co_righe_documenti ON co_documenti.id = co_righe_documenti.iddocumento WHERE original_document_type=\'Modules\\\\Ordini\\\\Ordine\' GROUP BY idordine\n) AS fattura ON fattura.idordine = or_ordini.id\nLEFT JOIN (\n SELECT `zz_operations`.`id_email`, `zz_operations`.`id_record`\n FROM `zz_operations`\n INNER JOIN `em_emails` ON `zz_operations`.`id_email` = `em_emails`.`id`\n INNER JOIN `em_templates` ON `em_emails`.`id_template` = `em_templates`.`id`\n INNER JOIN `zz_modules` ON `zz_operations`.`id_module` = `zz_modules`.`id`\n WHERE `zz_modules`.`name` = \'Ordini fornitore\' AND `zz_operations`.`op` = \'send-email\'\n GROUP BY `zz_operations`.`id_record`\n ) AS `email` ON `email`.`id_record` = `or_ordini`.`id`\nWHERE 1=1 AND `dir` = \'uscita\' |date_period(`data`)|\nHAVING 2=2\nORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC' WHERE `zz_modules`.`name` = 'Ordini fornitore';
UPDATE `zz_modules` SET `options` = 'SELECT |select|\nFROM `or_ordini`\n LEFT JOIN `an_anagrafiche` ON `or_ordini`.`idanagrafica` = `an_anagrafiche`.`idanagrafica`\n LEFT JOIN `or_tipiordine` ON `or_ordini`.`idtipoordine` = `or_tipiordine`.`id`\n LEFT JOIN (\n SELECT `idordine`,\n SUM(`qta` - `qta_evasa`) AS `qta_da_evadere`,\n SUM(`subtotale` - `sconto`) AS `totale_imponibile`,\n SUM(`subtotale` - `sconto` + `iva`) AS `totale`\n FROM `or_righe_ordini`\n GROUP BY `idordine`\n ) AS righe ON `or_ordini`.`id` = `righe`.`idordine`\n LEFT JOIN (\n SELECT `idordine`,\n MIN(`data_evasione`) AS `data_evasione`\n FROM `or_righe_ordini`\n WHERE (`qta` - `qta_evasa`)>0\n GROUP BY `idordine`\n ) AS `righe_da_evadere` ON `righe`.`idordine`=`righe_da_evadere`.`idordine`\n LEFT JOIN (\n SELECT GROUP_CONCAT(DISTINCT co_documenti.numero_esterno SEPARATOR \", \") AS info, co_righe_documenti.original_document_id AS idordine FROM co_documenti INNER JOIN co_righe_documenti ON co_documenti.id = co_righe_documenti.iddocumento WHERE original_document_type=\'Modules\\\\Ordini\\\\Ordine\' GROUP BY idordine\n) AS fattura ON fattura.idordine = or_ordini.id\nLEFT JOIN (\n SELECT `zz_operations`.`id_email`, `zz_operations`.`id_record`\n FROM `zz_operations`\n INNER JOIN `em_emails` ON `zz_operations`.`id_email` = `em_emails`.`id`\n INNER JOIN `em_templates` ON `em_emails`.`id_template` = `em_templates`.`id`\n INNER JOIN `zz_modules` ON `zz_operations`.`id_module` = `zz_modules`.`id`\n WHERE `zz_modules`.`name` = \'Ordini cliente\' AND `zz_operations`.`op` = \'send-email\'\n GROUP BY `zz_operations`.`id_record`\n ) AS `email` ON `email`.`id_record` = `or_ordini`.`id`\nWHERE 1=1 AND `dir` = \'entrata\' |date_period(`data`)|\nHAVING 2=2\nORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC' WHERE `zz_modules`.`name` = 'Ordini cliente';
UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `in_interventi`\nINNER JOIN `an_anagrafiche` ON `in_interventi`.`idanagrafica` = `an_anagrafiche`.`idanagrafica`\nLEFT JOIN `in_interventi_tecnici` ON `in_interventi_tecnici`.`idintervento` = `in_interventi`.`id`\nLEFT JOIN `in_interventi_tecnici_assegnati` ON `in_interventi_tecnici_assegnati`.`id_intervento` = `in_interventi`.`id`\nLEFT JOIN `in_statiintervento` ON `in_interventi`.`idstatointervento`=`in_statiintervento`.`idstatointervento`\nLEFT JOIN (\n SELECT an_sedi.id, CONCAT(an_sedi.nomesede, \'<br />\',IF(an_sedi.telefono!=\'\',CONCAT(an_sedi.telefono,\'<br />\'),\'\'),IF(an_sedi.cellulare!=\'\',CONCAT(an_sedi.cellulare,\'<br />\'),\'\'),an_sedi.citta,IF(an_sedi.indirizzo!=\'\',CONCAT(\' - \',an_sedi.indirizzo),\'\')) AS info FROM an_sedi\n) AS sede_destinazione ON sede_destinazione.id = in_interventi.idsede_destinazione\nLEFT JOIN (\n SELECT GROUP_CONCAT(DISTINCT co_documenti.numero_esterno SEPARATOR \", \") AS info, co_righe_documenti.original_document_id AS idintervento FROM co_documenti INNER JOIN co_righe_documenti ON co_documenti.id = co_righe_documenti.iddocumento WHERE original_document_type=\'Modules\\\\Interventi\\\\Intervento\' GROUP BY idintervento\n) AS fattura ON fattura.idintervento = in_interventi.id\nLEFT JOIN (SELECT `zz_operations`.`id_email`, `zz_operations`.`id_record`\n FROM `zz_operations`\n INNER JOIN `em_emails` ON `zz_operations`.`id_email` = `em_emails`.`id`\n INNER JOIN `em_templates` ON `em_emails`.`id_template` = `em_templates`.`id`\n INNER JOIN `zz_modules` ON `zz_operations`.`id_module` = `zz_modules`.`id` \n WHERE `zz_modules`.`name` = \'Interventi\' AND `zz_operations`.`op` = \'send-email\' \n GROUP BY `zz_operations`.`id_record`) AS email ON email.id_record=in_interventi.id\nLEFT JOIN (\n SELECT GROUP_CONCAT(CONCAT(matricola, IF(nome != \'\', CONCAT(\' - \', nome), \'\')) SEPARATOR \'<br>\') AS descrizione, my_impianti_interventi.idintervento\n FROM my_impianti\n INNER JOIN my_impianti_interventi ON my_impianti.id = my_impianti_interventi.idimpianto\n GROUP BY my_impianti_interventi.idintervento\n) AS impianti ON impianti.idintervento = in_interventi.id\nWHERE 1=1 |date_period(`orario_inizio`,`data_richiesta`)|\nGROUP BY `in_interventi`.`id`\nHAVING 2=2\nORDER BY IFNULL(`orario_fine`, `data_richiesta`) DESC' WHERE `zz_modules`.`name` = 'Interventi';
UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `in_interventi`\nINNER JOIN `an_anagrafiche` ON `in_interventi`.`idanagrafica` = `an_anagrafiche`.`idanagrafica`\nLEFT JOIN `in_interventi_tecnici` ON `in_interventi_tecnici`.`idintervento` = `in_interventi`.`id`\nLEFT JOIN `in_interventi_tecnici_assegnati` ON `in_interventi_tecnici_assegnati`.`id_intervento` = `in_interventi`.`id`\nLEFT JOIN `in_statiintervento` ON `in_interventi`.`idstatointervento`=`in_statiintervento`.`idstatointervento`\nLEFT JOIN (\n SELECT an_sedi.id, CONCAT(an_sedi.nomesede, \'<br />\',IF(an_sedi.telefono!=\'\',CONCAT(an_sedi.telefono,\'<br />\'),\'\'),IF(an_sedi.cellulare!=\'\',CONCAT(an_sedi.cellulare,\'<br />\'),\'\'),an_sedi.citta,IF(an_sedi.indirizzo!=\'\',CONCAT(\' - \',an_sedi.indirizzo),\'\')) AS info FROM an_sedi\n) AS sede_destinazione ON sede_destinazione.id = in_interventi.idsede_destinazione\nLEFT JOIN (\n SELECT GROUP_CONCAT(DISTINCT co_documenti.numero_esterno SEPARATOR \", \") AS info, co_righe_documenti.original_document_id AS idintervento FROM co_documenti INNER JOIN co_righe_documenti ON co_documenti.id = co_righe_documenti.iddocumento WHERE original_document_type=\'Modules\\\\Interventi\\\\Intervento\' GROUP BY idintervento\n) AS fattura ON fattura.idintervento = in_interventi.id\nLEFT JOIN (SELECT `zz_operations`.`id_email`, `zz_operations`.`id_record`\n FROM `zz_operations`\n INNER JOIN `em_emails` ON `zz_operations`.`id_email` = `em_emails`.`id`\n INNER JOIN `em_templates` ON `em_emails`.`id_template` = `em_templates`.`id`\n INNER JOIN `zz_modules` ON `zz_operations`.`id_module` = `zz_modules`.`id` \n WHERE `zz_modules`.`name` = \'Interventi\' AND `zz_operations`.`op` = \'send-email\' \n GROUP BY `zz_operations`.`id_record`) AS email ON email.id_record=in_interventi.id\nLEFT JOIN (\n SELECT GROUP_CONCAT(CONCAT(matricola, IF(nome != \'\', CONCAT(\' - \', nome), \'\')) SEPARATOR \'<br />\') AS descrizione, my_impianti_interventi.idintervento\n FROM my_impianti\n INNER JOIN my_impianti_interventi ON my_impianti.id = my_impianti_interventi.idimpianto\n GROUP BY my_impianti_interventi.idintervento\n) AS impianti ON impianti.idintervento = in_interventi.id\nLEFT JOIN (\n SELECT co_contratti.id, CONCAT(co_contratti.numero, \' del \', DATE_FORMAT(data_bozza, \'%d/%m/%Y\')) AS info FROM co_contratti\n) AS contratto ON contratto.id = in_interventi.id_contratto\nLEFT JOIN (\n SELECT co_preventivi.id, CONCAT(co_preventivi.numero, \' del \', DATE_FORMAT(data_bozza, \'%d/%m/%Y\')) AS info FROM co_preventivi\n) AS preventivo ON preventivo.id = in_interventi.id_preventivo\nLEFT JOIN (\n SELECT or_ordini.id, CONCAT(or_ordini.numero, \' del \', DATE_FORMAT(data, \'%d/%m/%Y\')) AS info FROM or_ordini\n) AS ordine ON ordine.id = in_interventi.id_ordine\nWHERE 1=1 |date_period(`orario_inizio`,`data_richiesta`)|\nGROUP BY `in_interventi`.`id`\nHAVING 2=2\nORDER BY IFNULL(`orario_fine`, `data_richiesta`) DESC' WHERE `zz_modules`.`name` = 'Interventi';
UPDATE `zz_modules` SET `options` = 'SELECT |select|\nFROM `co_preventivi`\n LEFT JOIN `an_anagrafiche` ON `co_preventivi`.`idanagrafica` = `an_anagrafiche`.`idanagrafica`\n LEFT JOIN `co_statipreventivi` ON `co_preventivi`.`idstato` = `co_statipreventivi`.`id`\n LEFT JOIN (\n SELECT `idpreventivo`,\n SUM(`subtotale` - `sconto`) AS `totale_imponibile`,\n SUM(`subtotale` - `sconto` + `iva`) AS `totale`\n FROM `co_righe_preventivi`\n GROUP BY `idpreventivo`\n ) AS righe ON `co_preventivi`.`id` = `righe`.`idpreventivo`\n\nLEFT JOIN (SELECT GROUP_CONCAT(DISTINCT co_documenti.numero_esterno SEPARATOR \", \") AS info, co_righe_documenti.original_document_id AS idpreventivo FROM co_documenti INNER JOIN co_righe_documenti ON co_documenti.id = co_righe_documenti.iddocumento WHERE original_document_type=\'Modules\\\\Preventivi\\\\Preventivo\' GROUP BY idpreventivo) AS fattura ON fattura.idpreventivo = co_preventivi.id\nWHERE 1=1 |date_period(custom,\'|period_start|\' >= `data_bozza` AND \'|period_start|\' <= `data_conclusione`,\'|period_end|\' >= `data_bozza` AND \'|period_end|\' <= `data_conclusione`,`data_bozza` >= \'|period_start|\' AND `data_bozza` <= \'|period_end|\',`data_conclusione` >= \'|period_start|\' AND `data_conclusione` <= \'|period_end|\',`data_bozza` >= \'|period_start|\' AND `data_conclusione` = \'0000-00-00\')| AND default_revision = 1\nGROUP BY `co_preventivi`.`id`\nHAVING 2=2\nORDER BY `co_preventivi`.`id` DESC ' WHERE `zz_modules`.`name` = 'Preventivi';
UPDATE `zz_modules` SET `options` = 'SELECT |select|\nFROM `co_preventivi`\n LEFT JOIN `an_anagrafiche` ON `co_preventivi`.`idanagrafica` = `an_anagrafiche`.`idanagrafica`\n LEFT JOIN `co_statipreventivi` ON `co_preventivi`.`idstato` = `co_statipreventivi`.`id`\n LEFT JOIN (\n SELECT `idpreventivo`,\n SUM(`subtotale` - `sconto`) AS `totale_imponibile`,\n SUM(`subtotale` - `sconto` + `iva`) AS `totale`\n FROM `co_righe_preventivi`\n GROUP BY `idpreventivo`\n ) AS righe ON `co_preventivi`.`id` = `righe`.`idpreventivo`\n\nLEFT JOIN (SELECT GROUP_CONCAT(DISTINCT co_documenti.numero_esterno SEPARATOR \", \") AS info, co_righe_documenti.original_document_id AS idpreventivo FROM co_documenti INNER JOIN co_righe_documenti ON co_documenti.id = co_righe_documenti.iddocumento WHERE original_document_type=\'Modules\\\\Preventivi\\\\Preventivo\' GROUP BY idpreventivo) AS fattura ON fattura.idpreventivo = co_preventivi.id\nWHERE 1=1 |date_period(custom,\'|period_start|\' >= `data_bozza` AND \'|period_start|\' <= `data_conclusione`,\'|period_end|\' >= `data_bozza` AND \'|period_end|\' <= `data_conclusione`,`data_bozza` >= \'|period_start|\' AND `data_bozza` <= \'|period_end|\',`data_conclusione` >= \'|period_start|\' AND `data_conclusione` <= \'|period_end|\',`data_bozza` >= \'|period_start|\' AND `data_conclusione` = \'0000-00-00\')| AND default_revision = 1\nGROUP BY `co_preventivi`.`id`\nHAVING 2=2\nORDER BY `co_preventivi`.`id` DESC ' WHERE `zz_modules`.`name` = 'Preventivi';
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`='Interventi'), 'Contratto', 'contratto.info', 21, 1, 0, 0, 0, '', '', 0, 0, 1),
((SELECT `id` FROM `zz_modules` WHERE `name`='Interventi'), 'Preventivo', 'preventivo.info', 22, 1, 0, 0, 0, '', '', 0, 0, 1),
((SELECT `id` FROM `zz_modules` WHERE `name`='Interventi'), 'Ordine', 'ordine.info', 23, 1, 0, 0, 0, '', '', 0, 0, 1);