From e95a36991d8b6679bb995ab2d57fa54748eaa8a5 Mon Sep 17 00:00:00 2001 From: Maicol Battistini Date: Fri, 30 Jul 2021 18:38:43 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8F=97=EF=B8=8F=20Introduzione=20?= =?UTF-8?q?Laravel=208?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 17 +- .env.example | 51 + .gitattributes | 191 - .github/CONTRIBUTING.md | 96 - .github/ISSUE_TEMPLATE.md | 38 - .github/PULL_REQUEST_TEMPLATE.md | 22 - .github/STANDARD.md | 28 - .github/workflows/main.yml | 129 - .gitignore | 249 +- .styleci.yml | 13 + actions.php | 429 - add.php | 105 - ajax.php | 171 - ajax_complete.php | 33 - ajax_dataload.php | 204 - ajax_search.php | 39 - ajax_select.php | 46 - api/index.php | 69 - artisan | 53 + assets/src/css/datatables.css | 239 - assets/src/css/print/print.css | 105 - assets/src/css/style.css | 1098 -- assets/src/css/themes/default.css | 224 - assets/src/img/ajax-loader.gif | Bin 8238 -> 0 bytes assets/src/img/favicon.png | Bin 1499 -> 0 bytes assets/src/img/help.png | Bin 11709 -> 0 bytes assets/src/img/logo.png | Bin 10500 -> 0 bytes assets/src/img/progress.gif | Bin 7970 -> 0 bytes assets/src/js/base/custom.js | 99 - assets/src/js/base/datatables-buttons.js | 144 - assets/src/js/base/navigation.js | 68 - assets/src/js/base/sidebar.js | 108 - assets/src/js/base/slider.js | 65 - assets/src/js/base/supersearch.js | 91 - assets/src/js/base/widgets.js | 52 - assets/src/js/functions/allegati.js | 308 - assets/src/js/functions/datatables.js | 521 - assets/src/js/functions/dates.js | 151 - assets/src/js/functions/form.js | 249 - assets/src/js/functions/functions.js | 608 - assets/src/js/functions/hooks.js | 230 - assets/src/js/functions/init.js | 71 - assets/src/js/functions/input.js | 411 - assets/src/js/functions/inputmask.js | 71 - assets/src/js/functions/loaders.js | 70 - assets/src/js/functions/moment.js | 93 - assets/src/js/functions/numbers.js | 67 - assets/src/js/functions/prototypes.js | 25 - assets/src/js/functions/select.js | 344 - assets/src/js/functions/textarea.js | 120 - backup/.htaccess | 1 - bootstrap/app.php | 55 + bootstrap/cache/.gitignore | 2 + bug.php | 203 - composer.json | 130 - config.example.php | 63 - config/app.php | 234 + config/auth.php | 117 + config/broadcasting.php | 64 + config/cache.php | 110 + config/cors.php | 34 + config/csrf_config.php | 38 - config/database.php | 147 + config/filesystems.php | 73 + config/hashing.php | 52 + config/logging.php | 105 + config/mail.php | 110 + config/namespaces.php | 64 - config/queue.php | 93 + config/services.php | 33 + config/session.php | 201 + config/view.php | 36 + controller.php | 115 - core.php | 302 - cron.php | 190 - editor.php | 540 - files/.htaccess | 7 - files/impianti/componente.ini | 20 - include/.htaccess | 1 - include/bottom.php | 97 - include/colonne.php | 95 - include/common/articolo.php | 359 - include/common/barcode.php | 364 - include/common/conti.php | 118 - include/common/descrizione.php | 25 - include/common/form.php | 50 - include/common/importa.php | 601 - include/common/riga.php | 176 - include/common/sconto.php | 90 - include/init/configuration.php | 612 - include/init/init.php | 265 - include/init/requirements.php | 211 - include/init/update.php | 260 - include/manager.php | 253 - include/modifica_allegato.php | 89 - include/riferimenti/riferimenti.php | 250 - include/riferimenti/righe_documento.php | 66 - include/riferimenti/righe_riferimenti.php | 74 - include/top.php | 637 - index.php | 191 - info.php | 167 - lib/common.php | 210 - lib/deprecated.php | 402 - lib/functions.php | 495 - lib/helpers.php | 293 - lib/util.php | 569 - locale/.htaccess | 1 - locale/catalog.pot | 11089 ------------- locale/de_DE/de_DE.mo | Bin 1173 -> 0 bytes locale/de_DE/de_DE.po | 10728 ------------- locale/en_GB/en_GB.mo | Bin 193963 -> 0 bytes locale/en_GB/en_GB.po | 12859 ---------------- locale/it_IT/.gitignore | 4 - log.php | 97 - logs/.htaccess | 1 - mail.php | 218 - modules/aggiornamenti/actions.php | 104 - modules/aggiornamenti/checksum.php | 112 - modules/aggiornamenti/controlli.php | 270 - modules/aggiornamenti/database.php | 190 - modules/aggiornamenti/edit.php | 266 - modules/aggiornamenti/modutil.php | 136 - .../aggiornamenti/src/Controlli/Controllo.php | 65 - .../src/Controlli/DatiFattureElettroniche.php | 177 - .../src/Controlli/PianoConti.php | 108 - modules/aggiornamenti/src/UpdateHook.php | 117 - modules/aggiornamenti/upload_modules.php | 113 - modules/anagrafiche/actions.php | 385 - modules/anagrafiche/add.php | 176 - modules/anagrafiche/ajax/complete.php | 127 - modules/anagrafiche/ajax/search.php | 137 - modules/anagrafiche/ajax/select.php | 365 - modules/anagrafiche/bulk.php | 116 - modules/anagrafiche/buttons.php | 77 - modules/anagrafiche/edit.php | 855 - modules/anagrafiche/init.php | 46 - modules/anagrafiche/modals/posizione.php | 88 - modules/anagrafiche/plugins/allegati.php | 154 - .../anagrafiche/src/API/v1/Anagrafiche.php | 170 - modules/anagrafiche/src/API/v1/Sedi.php | 33 - modules/anagrafiche/src/Anagrafica.php | 414 - modules/anagrafiche/src/Export/CSV.php | 143 - modules/anagrafiche/src/Import/CSV.php | 299 - modules/anagrafiche/src/Nazione.php | 35 - modules/anagrafiche/src/Referente.php | 47 - modules/anagrafiche/src/Sede.php | 65 - modules/anagrafiche/src/Tipo.php | 54 - modules/anagrafiche/validation.php | 161 - modules/anagrafiche/variables.php | 28 - modules/articoli/actions.php | 345 - modules/articoli/add.php | 141 - modules/articoli/ajax/complete.php | 168 - modules/articoli/ajax/search.php | 72 - modules/articoli/ajax/select.php | 270 - modules/articoli/bulk.php | 230 - modules/articoli/buttons.php | 31 - modules/articoli/edit.php | 433 - modules/articoli/init.php | 28 - modules/articoli/modals/duplicazione.php | 48 - modules/articoli/modutil.php | 48 - .../articoli/plugins/articoli.giacenze.php | 264 - modules/articoli/plugins/articoli.lotti.php | 321 - .../articoli/plugins/articoli.movimenti.php | 153 - modules/articoli/src/API/v1/Articoli.php | 109 - modules/articoli/src/API/v1/Movimenti.php | 35 - modules/articoli/src/Articolo.php | 250 - modules/articoli/src/Categoria.php | 48 - modules/articoli/src/Import/CSV.php | 359 - modules/articoli/src/Movimento.php | 175 - modules/articoli/validation.php | 57 - .../articoli/widgets/articoli.dashboard.php | 49 - .../articoli/widgets/stampa_inventario.php | 46 - modules/backups/actions.php | 100 - modules/backups/edit.php | 300 - modules/backups/init.php | 25 - modules/backups/src/BackupTask.php | 41 - modules/banche/actions.php | 115 - modules/banche/add.php | 57 - modules/banche/ajax/select.php | 47 - modules/banche/edit.php | 243 - modules/banche/init.php | 32 - modules/banche/src/Banca.php | 105 - modules/banche/src/IBAN.php | 529 - modules/beni/actions.php | 74 - modules/beni/add.php | 38 - modules/beni/ajax/select.php | 35 - modules/beni/edit.php | 62 - modules/beni/init.php | 24 - modules/categorie_articoli/actions.php | 111 - modules/categorie_articoli/add.php | 89 - modules/categorie_articoli/edit.php | 131 - modules/categorie_articoli/init.php | 24 - modules/categorie_articoli/row-list.php | 38 - modules/categorie_documenti/actions.php | 73 - modules/categorie_documenti/add.php | 41 - modules/categorie_documenti/ajax/select.php | 39 - modules/categorie_documenti/edit.php | 53 - modules/categorie_documenti/init.php | 34 - modules/categorie_documenti/src/Categoria.php | 55 - modules/categorie_impianti/actions.php | 77 - modules/categorie_impianti/add.php | 64 - modules/categorie_impianti/edit.php | 77 - modules/categorie_impianti/init.php | 24 - modules/causali/actions.php | 95 - modules/causali/add.php | 38 - modules/causali/ajax/select.php | 34 - modules/causali/edit.php | 76 - modules/causali/init.php | 24 - modules/causali_movimenti/actions.php | 58 - modules/causali_movimenti/add.php | 48 - modules/causali_movimenti/edit.php | 54 - modules/causali_movimenti/init.php | 24 - modules/checklists/actions.php | 82 - modules/checklists/add.php | 69 - modules/checklists/components/add-check.php | 139 - .../checklists/components/add-checklist.php | 120 - modules/checklists/edit.php | 170 - modules/checklists/init.php | 26 - modules/checklists/js/checklist.js | 101 - modules/checklists/modutil.php | 65 - modules/checklists/src/Check.php | 155 - modules/checklists/src/Checklist.php | 92 - modules/checklists/src/ChecklistItem.php | 68 - .../checklists/src/Traits/ChecklistTrait.php | 46 - modules/contratti/actions.php | 519 - modules/contratti/add.php | 47 - modules/contratti/add_preventivo.php | 85 - modules/contratti/ajax.php | 27 - modules/contratti/ajax/select.php | 47 - modules/contratti/bulk.php | 133 - modules/contratti/buttons.php | 61 - modules/contratti/crea_documento.php | 38 - modules/contratti/edit.php | 517 - modules/contratti/init.php | 35 - .../plugins/contratti.consuntivo.php | 332 - modules/contratti/row-add.php | 87 - modules/contratti/row-edit.php | 68 - modules/contratti/row-list.php | 319 - modules/contratti/src/Components/Articolo.php | 29 - .../contratti/src/Components/Descrizione.php | 29 - .../src/Components/RelationTrait.php | 47 - modules/contratti/src/Components/Riga.php | 29 - modules/contratti/src/Components/Sconto.php | 29 - modules/contratti/src/Contratto.php | 304 - modules/contratti/src/Stato.php | 35 - modules/contratti/variables.php | 33 - .../widgets/contratti_scadenza.dashboard.php | 84 - modules/custom_fields/actions.php | 65 - modules/custom_fields/add.php | 60 - modules/custom_fields/content-info.php | 54 - modules/custom_fields/edit.php | 75 - modules/custom_fields/init.php | 26 - modules/dashboard/ajax.php | 422 - modules/dashboard/edit.php | 686 - modules/dashboard/widgets/notifiche.php | 93 - .../widgets/stampa_calendario.dashboard.php | 87 - modules/ddt/actions.php | 487 - modules/ddt/add.php | 83 - modules/ddt/add_ddt.php | 85 - modules/ddt/add_ordine.php | 86 - modules/ddt/ajax/search.php | 78 - modules/ddt/bulk.php | 203 - modules/ddt/buttons.php | 79 - modules/ddt/crea_documento.php | 56 - modules/ddt/edit.php | 531 - modules/ddt/init.php | 59 - modules/ddt/modutil.php | 215 - modules/ddt/row-add.php | 90 - modules/ddt/row-edit.php | 70 - modules/ddt/row-list.php | 393 - modules/ddt/src/Components/Articolo.php | 30 - modules/ddt/src/Components/Descrizione.php | 29 - modules/ddt/src/Components/RelationTrait.php | 47 - modules/ddt/src/Components/Riga.php | 29 - modules/ddt/src/Components/Sconto.php | 29 - modules/ddt/src/DDT.php | 323 - modules/ddt/src/Stato.php | 35 - modules/ddt/src/Tipo.php | 35 - modules/ddt/variables.php | 31 - modules/emails/actions.php | 75 - modules/emails/add.php | 55 - modules/emails/buttons.php | 30 - modules/emails/edit.php | 175 - modules/emails/init.php | 29 - modules/emails/src/Account.php | 82 - modules/emails/src/EmailHook.php | 130 - modules/emails/src/Mail.php | 248 - modules/emails/src/OAuth2.php | 198 - modules/emails/src/Receiver.php | 49 - modules/emails/src/Template.php | 63 - modules/fatture/actions.php | 871 -- modules/fatture/add.php | 203 - modules/fatture/add_contratto.php | 86 - modules/fatture/add_ddt.php | 87 - modules/fatture/add_intervento.php | 145 - modules/fatture/add_ordine.php | 87 - modules/fatture/add_preventivo.php | 86 - modules/fatture/add_serial.php | 159 - modules/fatture/ajax/search.php | 80 - modules/fatture/ajax/select.php | 144 - modules/fatture/bulk.php | 486 - modules/fatture/buttons.php | 111 - modules/fatture/crea_documento.php | 39 - modules/fatture/edit.php | 991 -- modules/fatture/fe/components/altri_dati.php | 75 - .../fatture/fe/components/dati_documento.php | 145 - modules/fatture/fe/document-fe.php | 241 - modules/fatture/fe/row-fe.php | 175 - modules/fatture/fe/style.css | 41 - modules/fatture/init.php | 66 - modules/fatture/modutil.php | 436 - modules/fatture/row-add.php | 115 - modules/fatture/row-edit.php | 74 - modules/fatture/row-list.php | 494 - modules/fatture/src/Components/Articolo.php | 75 - .../fatture/src/Components/Descrizione.php | 32 - .../fatture/src/Components/RelationTrait.php | 252 - modules/fatture/src/Components/Riga.php | 32 - modules/fatture/src/Components/Sconto.php | 32 - modules/fatture/src/Export/CSV.php | 71 - modules/fatture/src/Fattura.php | 839 - modules/fatture/src/Gestori/Bollo.php | 104 - modules/fatture/src/Gestori/Movimenti.php | 237 - modules/fatture/src/Gestori/Scadenze.php | 170 - modules/fatture/src/Stato.php | 35 - modules/fatture/src/StatoFE.php | 37 - modules/fatture/src/Tipo.php | 35 - modules/fatture/variables.php | 70 - modules/gestione_componenti/actions.php | 76 - modules/gestione_componenti/add.php | 57 - modules/gestione_componenti/ajax/select.php | 62 - modules/gestione_componenti/edit.php | 79 - modules/gestione_componenti/init.php | 27 - modules/gestione_documentale/actions.php | 56 - modules/gestione_documentale/add.php | 47 - modules/gestione_documentale/edit.php | 61 - modules/gestione_documentale/init.php | 24 - modules/giacenze_sedi/controller_before.php | 41 - modules/giacenze_sedi/init.php | 25 - modules/impianti/actions.php | 171 - modules/impianti/add.php | 70 - modules/impianti/ajax/search.php | 72 - modules/impianti/ajax/select.php | 80 - modules/impianti/bulk.php | 53 - modules/impianti/buttons.php | 30 - modules/impianti/edit.php | 153 - modules/impianti/init.php | 24 - modules/impianti/modutil.php | 38 - .../plugins/my_impianti.componenti.php | 340 - .../plugins/my_impianti.interventi.php | 177 - modules/impianti/src/API/v1/Impianti.php | 35 - modules/impianti/src/Export/CSV.php | 55 - modules/impianti/src/Impianto.php | 37 - modules/import/actions.php | 106 - modules/import/add.php | 77 - modules/import/edit.php | 224 - modules/import/init.php | 28 - modules/import/src/Import.php | 44 - modules/impostazioni/actions.php | 103 - modules/impostazioni/edit.php | 154 - modules/impostazioni/init.php | 20 - modules/impostazioni/sezione.php | 53 - modules/interventi/actions.php | 640 - modules/interventi/add.php | 600 - modules/interventi/add_contratto.php | 86 - modules/interventi/add_ddt.php | 87 - modules/interventi/add_preventivo.php | 86 - modules/interventi/ajax/complete.php | 112 - modules/interventi/ajax/search.php | 76 - modules/interventi/ajax/select.php | 34 - modules/interventi/ajax_costi.php | 149 - modules/interventi/ajax_tecnici.php | 372 - modules/interventi/bulk.php | 300 - modules/interventi/buttons.php | 74 - modules/interventi/crea_documento.php | 60 - modules/interventi/edit.php | 784 - modules/interventi/init.php | 36 - modules/interventi/modals/anteprima_firma.php | 130 - modules/interventi/modals/copy_sessione.php | 73 - modules/interventi/modals/duplicazione.php | 62 - modules/interventi/modals/manage_sessione.php | 137 - modules/interventi/modutil.php | 338 - modules/interventi/occupazione_tecnici.php | 139 - .../plugins/my_impianti.interventi.php | 76 - modules/interventi/row-add.php | 96 - modules/interventi/row-edit.php | 74 - modules/interventi/row-list.php | 237 - modules/interventi/src/API/v1/Articoli.php | 70 - modules/interventi/src/API/v1/Firma.php | 40 - modules/interventi/src/API/v1/Impianti.php | 60 - modules/interventi/src/API/v1/Interventi.php | 125 - modules/interventi/src/API/v1/Rapportino.php | 83 - modules/interventi/src/API/v1/Sessioni.php | 71 - modules/interventi/src/API/v1/Sync.php | 190 - .../interventi/src/Components/Articolo.php | 30 - .../src/Components/RelationTrait.php | 50 - modules/interventi/src/Components/Riga.php | 29 - modules/interventi/src/Components/Sconto.php | 29 - .../interventi/src/Components/Sessione.php | 450 - modules/interventi/src/Intervento.php | 250 - modules/interventi/src/Stato.php | 36 - modules/interventi/variables.php | 37 - .../widgets/interventi_confermati.php | 49 - .../widgets/interventi_da_pianificare.php | 118 - .../widgets/interventi_da_programmare.php | 49 - modules/iva/actions.php | 98 - modules/iva/add.php | 81 - modules/iva/ajax/select.php | 50 - modules/iva/bulk.php | 56 - modules/iva/edit.php | 137 - modules/iva/init.php | 24 - modules/iva/src/Aliquota.php | 30 - modules/liste_newsletter/actions.php | 72 - modules/liste_newsletter/add.php | 39 - modules/liste_newsletter/edit.php | 139 - modules/liste_newsletter/init.php | 28 - modules/misure/actions.php | 86 - modules/misure/add.php | 38 - modules/misure/edit.php | 63 - modules/misure/init.php | 24 - modules/modelli_primanota/actions.php | 87 - modules/modelli_primanota/add.php | 150 - modules/modelli_primanota/edit.php | 187 - modules/modelli_primanota/init.php | 22 - modules/movimenti/actions.php | 63 - modules/movimenti/add.php | 329 - modules/newsletter/actions.php | 189 - modules/newsletter/add.php | 43 - modules/newsletter/ajax/select.php | 93 - modules/newsletter/buttons.php | 42 - modules/newsletter/edit.php | 242 - modules/newsletter/init.php | 31 - modules/newsletter/src/Lista.php | 77 - modules/newsletter/src/Newsletter.php | 111 - modules/newsletter/validation.php | 55 - modules/ordini/actions.php | 575 - modules/ordini/add.php | 62 - modules/ordini/add_preventivo.php | 86 - modules/ordini/ajax/select.php | 51 - modules/ordini/bulk.php | 168 - modules/ordini/buttons.php | 71 - modules/ordini/crea_documento.php | 60 - modules/ordini/edit.php | 394 - modules/ordini/init.php | 39 - modules/ordini/modutil.php | 242 - modules/ordini/plugins/ordini.consuntivo.php | 288 - modules/ordini/quantita_impegnate.php | 78 - modules/ordini/row-add.php | 88 - modules/ordini/row-edit.php | 68 - modules/ordini/row-list.php | 422 - modules/ordini/src/Components/Articolo.php | 30 - modules/ordini/src/Components/Descrizione.php | 29 - .../ordini/src/Components/RelationTrait.php | 47 - modules/ordini/src/Components/Riga.php | 29 - modules/ordini/src/Components/Sconto.php | 29 - modules/ordini/src/Ordine.php | 259 - modules/ordini/src/Stato.php | 35 - modules/ordini/src/Tipo.php | 35 - modules/ordini/variables.php | 31 - modules/pagamenti/actions.php | 115 - modules/pagamenti/add.php | 42 - modules/pagamenti/ajax/select.php | 52 - modules/pagamenti/edit.php | 263 - modules/pagamenti/init.php | 24 - modules/pagamenti/src/Pagamento.php | 122 - modules/partitario/actions.php | 227 - modules/partitario/add_conto.php | 49 - modules/partitario/aggiorna_reddito.php | 56 - modules/partitario/ajax/select.php | 155 - modules/partitario/dettagli_conto.php | 115 - modules/partitario/edit.php | 467 - modules/partitario/edit_conto.php | 71 - modules/piano_sconto/actions.php | 53 - modules/piano_sconto/add.php | 69 - modules/piano_sconto/edit.php | 67 - modules/piano_sconto/init.php | 28 - modules/piano_sconto/src/PianoSconto.php | 76 - modules/porti/actions.php | 81 - modules/porti/add.php | 38 - modules/porti/edit.php | 65 - modules/porti/init.php | 24 - modules/preventivi/actions.php | 401 - modules/preventivi/add.php | 67 - modules/preventivi/ajax.php | 27 - modules/preventivi/ajax/search.php | 74 - modules/preventivi/ajax/select.php | 50 - modules/preventivi/bulk.php | 133 - modules/preventivi/buttons.php | 92 - modules/preventivi/crea_documento.php | 62 - modules/preventivi/crea_revisione.php | 44 - modules/preventivi/edit.php | 420 - modules/preventivi/init.php | 33 - modules/preventivi/modutil.php | 49 - .../plugins/preventivi.consuntivo.php | 312 - modules/preventivi/row-add.php | 87 - modules/preventivi/row-edit.php | 67 - modules/preventivi/row-list.php | 386 - .../preventivi/src/Components/Articolo.php | 29 - .../preventivi/src/Components/Descrizione.php | 29 - .../src/Components/RelationTrait.php | 47 - modules/preventivi/src/Components/Riga.php | 29 - modules/preventivi/src/Components/Sconto.php | 29 - modules/preventivi/src/Preventivo.php | 338 - modules/preventivi/src/Stato.php | 35 - modules/preventivi/variables.php | 36 - .../widgets/preventivi.dashboard.php | 55 - modules/primanota/actions.php | 108 - modules/primanota/add.php | 442 - modules/primanota/ajax/complete.php | 35 - modules/primanota/edit.php | 101 - modules/primanota/init.php | 28 - modules/primanota/movimenti.php | 330 - modules/primanota/src/Mastrino.php | 258 - modules/primanota/src/Movimento.php | 120 - modules/relazioni_anagrafiche/actions.php | 83 - modules/relazioni_anagrafiche/add.php | 51 - modules/relazioni_anagrafiche/edit.php | 77 - modules/relazioni_anagrafiche/init.php | 24 - modules/ritenute/actions.php | 77 - modules/ritenute/add.php | 48 - modules/ritenute/edit.php | 71 - modules/ritenute/init.php | 24 - modules/ritenute/src/RitenutaAcconto.php | 30 - modules/ritenute_contributi/actions.php | 77 - modules/ritenute_contributi/add.php | 48 - modules/ritenute_contributi/edit.php | 71 - modules/ritenute_contributi/init.php | 24 - .../src/RitenutaContributi.php | 36 - modules/rivalse/actions.php | 77 - modules/rivalse/add.php | 48 - modules/rivalse/edit.php | 55 - modules/rivalse/init.php | 24 - modules/rivalse/src/RivalsaINPS.php | 30 - modules/scadenzario/actions.php | 121 - modules/scadenzario/add.php | 54 - modules/scadenzario/bulk.php | 32 - modules/scadenzario/controller_after.php | 40 - modules/scadenzario/edit.php | 295 - modules/scadenzario/init.php | 36 - modules/scadenzario/src/Scadenza.php | 58 - modules/scadenzario/variables.php | 46 - modules/segmenti/actions.php | 100 - modules/segmenti/add.php | 62 - modules/segmenti/edit.php | 189 - modules/segmenti/init.php | 30 - modules/smtp/actions.php | 122 - modules/smtp/add.php | 48 - modules/smtp/ajax/select.php | 37 - modules/smtp/buttons.php | 57 - modules/smtp/edit.php | 213 - modules/smtp/init.php | 28 - modules/spedizioni/actions.php | 82 - modules/spedizioni/add.php | 38 - modules/spedizioni/edit.php | 68 - modules/spedizioni/init.php | 24 - modules/stampe/actions.php | 41 - modules/stampe/edit.php | 123 - modules/stampe/init.php | 27 - modules/stampe_contabili/edit.php | 77 - modules/stampe_contabili/stampe_contabili.php | 90 - modules/stati_contratto/actions.php | 68 - modules/stati_contratto/add.php | 55 - modules/stati_contratto/edit.php | 79 - modules/stati_contratto/init.php | 24 - .../src/API/v1/StatiContratti.php | 45 - modules/stati_intervento/actions.php | 73 - modules/stati_intervento/add.php | 56 - modules/stati_intervento/edit.php | 132 - modules/stati_intervento/init.php | 24 - .../src/API/v1/StatiInterventi.php | 49 - modules/stati_preventivo/actions.php | 69 - modules/stati_preventivo/add.php | 55 - modules/stati_preventivo/edit.php | 81 - modules/stati_preventivo/init.php | 24 - .../src/API/v1/StatiPreventivi.php | 45 - modules/statistiche/actions.php | 55 - modules/statistiche/edit.php | 444 - modules/statistiche/js/calendar.js | 43 - modules/statistiche/js/functions.js | 80 - modules/statistiche/js/init.js | 29 - modules/statistiche/js/manager.js | 56 - modules/statistiche/js/stat.js | 54 - modules/statistiche/js/stats/line_chart.js | 113 - modules/statistiche/js/stats/table.js | 51 - modules/statistiche/js/stats/widget.js | 21 - modules/statistiche/src/Stats.php | 62 - modules/stato_email/actions.php | 52 - modules/stato_email/bulk.php | 55 - modules/stato_email/buttons.php | 40 - modules/stato_email/edit.php | 174 - modules/stato_email/init.php | 28 - modules/stato_servizi/actions.php | 197 - modules/stato_servizi/edit.php | 238 - modules/stato_servizi/modutil.php | 98 - .../stato_servizi/src/API/v1/FolderSize.php | 72 - modules/stato_servizi/src/ServicesHook.php | 75 - modules/stato_servizi/src/SpaceHook.php | 61 - .../widgets/spazio_utilizzato.php | 167 - modules/tecnici_tariffe/actions.php | 74 - modules/tecnici_tariffe/edit.php | 113 - modules/tecnici_tariffe/init.php | 26 - modules/tipi_anagrafiche/actions.php | 65 - modules/tipi_anagrafiche/add.php | 41 - modules/tipi_anagrafiche/edit.php | 68 - modules/tipi_anagrafiche/init.php | 24 - modules/tipi_documento/actions.php | 111 - modules/tipi_documento/add.php | 46 - modules/tipi_documento/ajax/select.php | 37 - modules/tipi_documento/edit.php | 75 - modules/tipi_documento/init.php | 24 - modules/tipi_intervento/actions.php | 115 - modules/tipi_intervento/add.php | 90 - modules/tipi_intervento/buttons.php | 23 - modules/tipi_intervento/edit.php | 154 - modules/tipi_intervento/init.php | 27 - .../src/API/v1/TipiInterventi.php | 44 - modules/tipi_intervento/src/Tipo.php | 95 - modules/tipi_scadenze/actions.php | 114 - modules/tipi_scadenze/add.php | 41 - modules/tipi_scadenze/ajax/select.php | 36 - modules/tipi_scadenze/edit.php | 77 - modules/tipi_scadenze/init.php | 24 - modules/utenti/actions.php | 247 - modules/utenti/add.php | 38 - modules/utenti/ajax/select.php | 114 - modules/utenti/components/base.php | 64 - modules/utenti/components/password.php | 27 - modules/utenti/components/photo.php | 33 - modules/utenti/edit.php | 240 - modules/utenti/info.php | 147 - modules/utenti/init.php | 24 - modules/utenti/modutil.php | 56 - modules/utenti/self.php | 49 - modules/utenti/src/API/v1/Login.php | 63 - modules/utenti/src/API/v1/Logout.php | 43 - modules/utenti/user.php | 119 - modules/utenti/validation.php | 50 - modules/utenti/variables.php | 28 - modules/viste/actions.php | 185 - modules/viste/edit.php | 154 - modules/viste/fields.php | 262 - modules/viste/filters.php | 161 - modules/viste/init.php | 24 - modules/voci_servizio/actions.php | 47 - modules/voci_servizio/add.php | 42 - modules/voci_servizio/edit.php | 40 - modules/voci_servizio/init.php | 24 - modules/zone/actions.php | 76 - modules/zone/add.php | 42 - modules/zone/ajax/select.php | 35 - modules/zone/edit.php | 41 - modules/zone/init.php | 24 - oauth2.php | 53 - package.json | 85 +- pdfgen.php | 50 - plugins/checks.php | 134 - plugins/componenti/actions.php | 124 - plugins/componenti/add.php | 40 - plugins/componenti/allegati.php | 22 - plugins/componenti/edit.php | 194 - plugins/dichiarazioni_intento/actions.php | 68 - plugins/dichiarazioni_intento/add.php | 75 - plugins/dichiarazioni_intento/edit.php | 101 - plugins/dichiarazioni_intento/init.php | 28 - .../src/Dichiarazione.php | 102 - plugins/exportFE/actions.php | 89 - plugins/exportFE/download.php | 23 - plugins/exportFE/edit.php | 304 - plugins/exportFE/init.php | 29 - plugins/exportFE/notifiche.php | 150 - plugins/exportFE/src/FatturaElettronica.php | 1757 --- plugins/exportFE/src/Interaction.php | 95 - plugins/exportFE/src/InvoiceHook.php | 89 - plugins/exportFE/src/Validator.php | 683 - plugins/importFE/actions.php | 403 - plugins/importFE/buttons.php | 119 - plugins/importFE/edit.php | 238 - plugins/importFE/generate.php | 680 - plugins/importFE/init.php | 48 - plugins/importFE/list.php | 234 - plugins/importFE/riferimento.php | 125 - plugins/importFE/src/FatturaElettronica.php | 395 - plugins/importFE/src/FatturaOrdinaria.php | 414 - plugins/importFE/src/FatturaSemplificata.php | 140 - plugins/importFE/src/Interaction.php | 122 - plugins/importFE/src/InvoiceHook.php | 71 - plugins/importFE/src/Parcella.php | 65 - plugins/importFE/view.php | 39 - plugins/listino_clienti/actions.php | 90 - plugins/listino_clienti/dettaglio_prezzi.php | 270 - plugins/listino_clienti/edit.php | 156 - .../listino_clienti/src/DettaglioPrezzo.php | 117 - plugins/listino_fornitori/actions.php | 67 - .../listino_fornitori/dettaglio_fornitore.php | 90 - plugins/listino_fornitori/edit.php | 225 - .../src/DettaglioFornitore.php | 68 - plugins/listino_fornitori/src/METEL.php | 104 - plugins/notes.php | 125 - plugins/piani_sconto_maggiorazione/edit.php | 66 - .../pianificazione_fatturazione/actions.php | 189 - .../add_pianificazione.php | 244 - .../ajax_cadenza.php | 103 - .../crea_fattura.php | 154 - plugins/pianificazione_fatturazione/edit.php | 138 - .../pianificazione_fatturazione/modutil.php | 37 - .../src/Pianificazione.php | 158 - .../widgets/rate_contrattuali.php | 128 - plugins/pianificazione_interventi/actions.php | 285 - plugins/pianificazione_interventi/edit.php | 206 - plugins/pianificazione_interventi/init.php | 26 - .../pianificazione.php | 314 - plugins/pianificazione_interventi/row-add.php | 96 - .../pianificazione_interventi/row-edit.php | 79 - .../pianificazione_interventi/row-list.php | 185 - .../src/Components/Articolo.php | 29 - .../src/Components/Descrizione.php | 29 - .../src/Components/RelationTrait.php | 63 - .../src/Components/Riga.php | 29 - .../src/Components/Sconto.php | 29 - .../src/Promemoria.php | 184 - .../widgets/promemoria_da_pianificare.php | 131 - plugins/receiptFE/actions.php | 95 - plugins/receiptFE/edit.php | 293 - plugins/receiptFE/list.php | 168 - plugins/receiptFE/src/Interaction.php | 127 - plugins/receiptFE/src/MissingReceiptTask.php | 62 - .../receiptFE/src/NotificheRicevuteHook.php | 89 - plugins/receiptFE/src/ReceiptHook.php | 119 - plugins/receiptFE/src/ReceiptTask.php | 46 - plugins/receiptFE/src/Ricevuta.php | 262 - plugins/referenti/actions.php | 69 - plugins/referenti/add.php | 71 - plugins/referenti/edit.php | 74 - plugins/referenti/init.php | 24 - plugins/revisioni/actions.php | 41 - plugins/revisioni/edit.php | 109 - plugins/rinnovi_contratti/edit.php | 92 - plugins/sedi/actions.php | 89 - plugins/sedi/add.php | 95 - plugins/sedi/edit.php | 211 - plugins/sedi/init.php | 33 - plugins/statistiche_anagrafiche/edit.php | 74 - plugins/statistiche_anagrafiche/info.php | 207 - plugins/statistiche_articoli/edit.php | 132 - plugins/statistiche_articoli/js/prezzo.js | 25 - .../statistiche_articoli/manage_prezzi.php | 57 - plugins/statistiche_articoli/src/Stats.php | 42 - plugins/xml/AT.xsl | 155 - plugins/xml/DT.xsl | 163 - plugins/xml/EC.xsl | 150 - plugins/xml/MC.xsl | 278 - plugins/xml/MT.xsl | 228 - plugins/xml/NE.xsl | 193 - plugins/xml/NS.xsl | 308 - plugins/xml/RC.xsl | 294 - plugins/xml/SE.xsl | 162 - plugins/xml/asso-invoice.xsl | 3117 ---- public/.htaccess | 21 + files/temp/.gitkeep => public/favicon.ico | 0 public/index.php | 55 + public/web.config | 28 + reset.php | 159 - tests/_data/.gitkeep => resources/css/app.css | 0 update/2_4_17_1.sql => resources/js/app.js | 0 resources/lang/en/auth.php | 20 + resources/lang/en/pagination.php | 19 + resources/lang/en/passwords.php | 22 + resources/lang/en/validation.php | 156 + routes/api.php | 19 + routes/channels.php | 18 + routes/console.php | 19 + routes/web.php | 15 + server.php | 21 + src/AJAX.php | 325 - src/API/App/AppResource.php | 326 - src/API/App/v1/AliquoteIva.php | 58 - src/API/App/v1/AllegatiInterventi.php | 124 - src/API/App/v1/Articoli.php | 66 - src/API/App/v1/Clienti.php | 165 - src/API/App/v1/Contratti.php | 85 - src/API/App/v1/ControlloClienti.php | 62 - src/API/App/v1/Flash/Intervento.php | 98 - src/API/App/v1/Impianti.php | 76 - src/API/App/v1/Impostazioni.php | 80 - src/API/App/v1/Interventi.php | 265 - src/API/App/v1/Login.php | 77 - src/API/App/v1/MovimentiManuali.php | 56 - src/API/App/v1/Preventivi.php | 82 - src/API/App/v1/RapportinoIntervento.php | 99 - src/API/App/v1/Referenti.php | 67 - src/API/App/v1/Revisione.php | 35 - src/API/App/v1/RigheInterventi.php | 243 - src/API/App/v1/Sedi.php | 78 - src/API/App/v1/SediAzienda.php | 78 - src/API/App/v1/SegnalazioneBug.php | 76 - src/API/App/v1/SessioniInterventi.php | 214 - src/API/App/v1/StatiIntervento.php | 60 - src/API/App/v1/TariffeContratti.php | 86 - src/API/App/v1/TariffeTecnici.php | 62 - src/API/App/v1/Tecnici.php | 62 - src/API/App/v1/TipiIntervento.php | 60 - src/API/Common/Allegato.php | 62 - src/API/Common/Stampa.php | 53 - src/API/Common/Task.php | 107 - src/API/Exceptions/InternalError.php | 26 - src/API/Exceptions/ResourceNotFound.php | 26 - src/API/Exceptions/ServiceError.php | 26 - src/API/Exceptions/Unauthorized.php | 26 - src/API/Interfaces/CreateInterface.php | 25 - src/API/Interfaces/DeleteInterface.php | 25 - src/API/Interfaces/RetrieveInterface.php | 25 - src/API/Interfaces/UpdateInterface.php | 25 - src/API/Manager.php | 231 - src/API/Resource.php | 48 - src/API/Response.php | 272 - src/API/Services.php | 81 - src/App.php | 350 - src/Auth.php | 481 - src/Backup.php | 312 - src/Common/Components/Accounting.php | 436 - src/Common/Components/Article.php | 408 - src/Common/Components/Component.php | 438 - src/Common/Components/Description.php | 82 - src/Common/Components/Discount.php | 128 - src/Common/Components/Row.php | 90 - src/Common/Document.php | 320 - src/Common/DocumentInterface.php | 69 - src/Common/Model.php | 30 - src/Common/ReferenceInterface.php | 33 - src/Common/RowReference.php | 37 - src/Common/SimpleModelTrait.php | 44 - src/Database.php | 705 - src/Exporter/CSVExporter.php | 100 - src/Exporter/ExporterInterface.php | 74 - src/Extensions/EloquentCollector.php | 82 - src/Extensions/MessageHandler.php | 63 - src/Filter.php | 210 - src/HTMLBuilder/HTMLBuilder.php | 502 - src/HTMLBuilder/Handler/CKEditorHandler.php | 39 - src/HTMLBuilder/Handler/ChoicesHandler.php | 91 - src/HTMLBuilder/Handler/DateHandler.php | 148 - src/HTMLBuilder/Handler/DefaultHandler.php | 281 - src/HTMLBuilder/Handler/HandlerInterface.php | 38 - src/HTMLBuilder/Handler/MediaHandler.php | 76 - src/HTMLBuilder/Handler/SelectHandler.php | 260 - src/HTMLBuilder/Manager/ButtonManager.php | 195 - src/HTMLBuilder/Manager/EmailManager.php | 118 - src/HTMLBuilder/Manager/FieldManager.php | 118 - src/HTMLBuilder/Manager/FileManager.php | 265 - src/HTMLBuilder/Manager/ManagerInterface.php | 28 - src/HTMLBuilder/Manager/WidgetManager.php | 278 - src/HTMLBuilder/Wrapper/HTMLWrapper.php | 286 - src/HTMLBuilder/Wrapper/WrapperInterface.php | 32 - src/Hooks/CachedManager.php | 65 - src/Hooks/Manager.php | 89 - src/Importer/CSVImporter.php | 157 - src/Importer/ImporterInterface.php | 123 - src/Intl/FileLoader.php | 70 - src/Intl/Formatter.php | 607 - src/Models/ApiResource.php | 32 - src/Models/Cache.php | 108 - src/Models/Clause.php | 48 - src/Models/Group.php | 47 - src/Models/Hook.php | 165 - src/Models/Log.php | 37 - src/Models/Module.php | 213 - src/Models/Note.php | 79 - src/Models/OperationLog.php | 85 - src/Models/Plugin.php | 138 - src/Models/PrintTemplate.php | 52 - src/Models/Setting.php | 52 - src/Models/Upload.php | 362 - src/Models/User.php | 245 - src/Models/View.php | 48 - src/Modules.php | 383 - src/Notifications/EmailNotification.php | 313 - src/Notifications/Notification.php | 89 - src/Notifications/NotificationInterface.php | 25 - src/Permissions.php | 108 - src/Plugins.php | 143 - src/Prints.php | 650 - src/Settings.php | 224 - src/Tasks/Log.php | 46 - src/Tasks/Manager.php | 32 - src/Tasks/Task.php | 105 - src/Tasks/TaskInterface.php | 28 - src/Traits/Components/NoteTrait.php | 35 - src/Traits/Components/UploadTrait.php | 47 - src/Traits/HierarchyTrait.php | 50 - src/Traits/LocalPoolTrait.php | 113 - src/Traits/ManagerTrait.php | 77 - src/Traits/PathTrait.php | 64 - src/Traits/RecordTrait.php | 69 - src/Traits/ReferenceTrait.php | 65 - src/Translator.php | 382 - src/Update.php | 627 - src/Uploads.php | 155 - src/Util/Autofill.php | 116 - src/Util/FileSystem.php | 185 - src/Util/Generator.php | 243 - src/Util/Ini.php | 183 - src/Util/Messages.php | 43 - src/Util/Query.php | 482 - src/Util/Singleton.php | 68 - src/Util/XML.php | 161 - src/Util/Zip.php | 159 - src/Validate.php | 179 - storage/app/.gitignore | 3 + storage/app/public/.gitignore | 2 + storage/framework/.gitignore | 9 + storage/framework/cache/.gitignore | 3 + storage/framework/cache/data/.gitignore | 2 + storage/framework/sessions/.gitignore | 2 + storage/framework/testing/.gitignore | 2 + storage/framework/views/.gitignore | 2 + storage/logs/.gitignore | 2 + templates/anagrafiche/body.php | 174 - templates/anagrafiche/init.php | 25 - templates/azienda/body.php | 65 - templates/azienda/init.php | 24 - templates/barcode/body.php | 61 - templates/barcode/footer.php | 21 - templates/barcode/header.php | 21 - templates/barcode/init.php | 24 - templates/base/bootstrap.css | 1111 -- templates/base/footer.php | 43 - templates/base/header.php | 46 - templates/base/logo_azienda.jpg | Bin 4348 -> 0 bytes templates/base/settings.php | 33 - templates/base/style.css | 158 - templates/bilancio/body.php | 312 - templates/bilancio/header.php | 25 - templates/bilancio/init.php | 82 - templates/bilancio/settings.php | 7 - templates/contratti/body.php | 385 - templates/contratti/footer.php | 37 - templates/contratti/init.php | 57 - templates/contratti/settings.php | 22 - templates/contratti_cons/bottom.php | 86 - templates/contratti_cons/init.php | 30 - templates/contratti_cons/piece.php | 20 - templates/contratti_cons/top.php | 83 - templates/dashboard/body.php | 184 - templates/dashboard/header.php | 34 - templates/dashboard/settings.php | 26 - templates/ddt/body.php | 192 - templates/ddt/footer.php | 242 - templates/ddt/header.php | 97 - templates/ddt/init.php | 103 - templates/fatturato/body.php | 88 - templates/fatturato/init.php | 41 - templates/fatture/body.php | 245 - templates/fatture/footer.php | 465 - templates/fatture/header.php | 132 - templates/fatture/init.php | 128 - templates/fatture_elettroniche/body.php | 99 - templates/info.php | 157 - templates/interventi/body.php | 495 - templates/interventi/init.php | 44 - templates/liquidazione_iva/body.php | 312 - templates/liquidazione_iva/footer.php | 34 - templates/liquidazione_iva/header.php | 40 - templates/liquidazione_iva/init.php | 57 - templates/liquidazione_iva/settings.php | 27 - templates/magazzino_inventario/body.php | 110 - templates/magazzino_inventario/settings.php | 23 - templates/ordini/body.php | 336 - templates/ordini/header.php | 88 - templates/ordini/init.php | 68 - templates/ordini/settings.php | 24 - templates/ordini_cons/bottom.php | 66 - templates/ordini_cons/init.php | 30 - templates/ordini_cons/piece.php | 20 - templates/ordini_cons/top.php | 83 - templates/partitario_mastrino/bottom.php | 88 - templates/partitario_mastrino/footer.php | 34 - templates/partitario_mastrino/header.php | 41 - templates/partitario_mastrino/init.php | 41 - templates/partitario_mastrino/piece.php | 49 - templates/partitario_mastrino/settings.php | 22 - templates/partitario_mastrino/top.php | 35 - templates/pdfgen_variables.php | 57 - templates/preventivi/body.php | 443 - templates/preventivi/footer.php | 37 - templates/preventivi/init.php | 57 - templates/preventivi/settings.php | 22 - templates/preventivi_cons/bottom.php | 66 - templates/preventivi_cons/init.php | 30 - templates/preventivi_cons/piece.php | 20 - templates/preventivi_cons/top.php | 83 - templates/registro_iva/bottom.php | 75 - templates/registro_iva/footer.php | 34 - templates/registro_iva/init.php | 57 - templates/registro_iva/piece.php | 42 - templates/registro_iva/settings.php | 27 - templates/registro_iva/top.php | 65 - templates/replace.php | 35 - templates/riepilogo_interventi/bottom.php | 37 - templates/riepilogo_interventi/footer.php | 34 - templates/riepilogo_interventi/init.php | 54 - templates/riepilogo_interventi/piece.php | 113 - templates/riepilogo_interventi/top.php | 38 - templates/scadenzario/bottom.php | 34 - templates/scadenzario/footer.php | 34 - templates/scadenzario/init.php | 56 - templates/scadenzario/piece.php | 33 - templates/scadenzario/settings.php | 23 - templates/scadenzario/top.php | 44 - templates/spesometro/body.php | 196 - templates/spesometro/header.php | 34 - templates/spesometro/settings.php | 22 - tests/_output/.gitignore | 2 - tests/_support/AcceptanceTester.php | 110 - tests/_support/FunctionalTester.php | 26 - tests/_support/Helper/Acceptance.php | 73 - tests/_support/Helper/Common/RowHelper.php | 225 - tests/_support/Helper/Functional.php | 10 - tests/_support/Helper/Select2.php | 232 - tests/_support/Helper/Select2Ajax.php | 88 - tests/_support/Helper/Unit.php | 10 - tests/_support/UnitTester.php | 26 - tests/_support/_generated/.gitignore | 2 - tests/acceptance.suite.yml | 22 - tests/acceptance/AnagraficheCest.php | 92 - tests/acceptance/BackupCest.php | 46 - tests/acceptance/ContrattiCest.php | 74 - tests/acceptance/DDTCest.php | 84 - tests/acceptance/FattureCest.php | 86 - tests/acceptance/OrdiniCest.php | 87 - tests/acceptance/PreventiviCest.php | 75 - tests/acceptance/_bootstrap.php | 1 - tests/functional.suite.yml | 12 - tests/functional/_bootstrap.php | 1 - tests/unit.suite.yml | 9 - tests/unit/GeneratorTest.php | 70 - tests/unit/_bootstrap.php | 10 - update/.htaccess | 1 - update/2_0.sql | 2416 --- update/2_1.php | 25 - update/2_1.sql | 61 - update/2_2.php | 117 - update/2_2.sql | 177 - update/2_3.php | 42 - update/2_3.sql | 1085 -- update/2_3_1.php | 128 - update/2_3_1.sql | 71 - update/2_4.php | 36 - update/2_4.sql | 343 - update/2_4_1.sql | 498 - update/2_4_10.php | 159 - update/2_4_10.sql | 274 - update/2_4_11.php | 92 - update/2_4_11.sql | 922 -- update/2_4_12.sql | 50 - update/2_4_13.php | 59 - update/2_4_13.sql | 260 - update/2_4_14.php | 32 - update/2_4_14.sql | 625 - update/2_4_15.sql | 33 - update/2_4_16.sql | 164 - update/2_4_17.sql | 240 - update/2_4_17_1.php | 6 - update/2_4_18.php | 41 - update/2_4_18.sql | 330 - update/2_4_19.sql | 60 - update/2_4_2.php | 45 - update/2_4_2.sql | 656 - update/2_4_20.php | 119 - update/2_4_20.sql | 234 - update/2_4_21.sql | 93 - update/2_4_22.php | 15 - update/2_4_22.sql | 319 - update/2_4_23.php | 26 - update/2_4_23.sql | 207 - update/2_4_24.sql | 180 - update/2_4_25.sql | 2 - update/2_4_3.php | 631 - update/2_4_3.sql | 63 - update/2_4_4.php | 12 - update/2_4_4.sql | 29 - update/2_4_5.sql | 80 - update/2_4_6.php | 12 - update/2_4_6.sql | 97 - update/2_4_7.php | 22 - update/2_4_7.sql | 35 - update/2_4_8.sql | 15 - update/2_4_9.php | 227 - update/2_4_9.sql | 379 - update/api.php | 28 - update/create_updates.sql | 9 - update/structure.php | 11 - update/tables.php | 134 - update/v2_4_17/recupero_date_movimenti.php | 118 - view.php | 104 - webpack.mix.js | 17 + 1095 files changed, 2217 insertions(+), 175431 deletions(-) create mode 100644 .env.example delete mode 100755 .gitattributes delete mode 100755 .github/CONTRIBUTING.md delete mode 100755 .github/ISSUE_TEMPLATE.md delete mode 100755 .github/PULL_REQUEST_TEMPLATE.md delete mode 100755 .github/STANDARD.md delete mode 100644 .github/workflows/main.yml create mode 100644 .styleci.yml delete mode 100755 actions.php delete mode 100755 add.php delete mode 100755 ajax.php delete mode 100755 ajax_complete.php delete mode 100755 ajax_dataload.php delete mode 100755 ajax_search.php delete mode 100755 ajax_select.php delete mode 100755 api/index.php create mode 100644 artisan delete mode 100755 assets/src/css/datatables.css delete mode 100755 assets/src/css/print/print.css delete mode 100755 assets/src/css/style.css delete mode 100755 assets/src/css/themes/default.css delete mode 100755 assets/src/img/ajax-loader.gif delete mode 100755 assets/src/img/favicon.png delete mode 100755 assets/src/img/help.png delete mode 100755 assets/src/img/logo.png delete mode 100755 assets/src/img/progress.gif delete mode 100644 assets/src/js/base/custom.js delete mode 100644 assets/src/js/base/datatables-buttons.js delete mode 100644 assets/src/js/base/navigation.js delete mode 100644 assets/src/js/base/sidebar.js delete mode 100644 assets/src/js/base/slider.js delete mode 100644 assets/src/js/base/supersearch.js delete mode 100644 assets/src/js/base/widgets.js delete mode 100644 assets/src/js/functions/allegati.js delete mode 100755 assets/src/js/functions/datatables.js delete mode 100755 assets/src/js/functions/dates.js delete mode 100644 assets/src/js/functions/form.js delete mode 100755 assets/src/js/functions/functions.js delete mode 100755 assets/src/js/functions/hooks.js delete mode 100755 assets/src/js/functions/init.js delete mode 100644 assets/src/js/functions/input.js delete mode 100644 assets/src/js/functions/inputmask.js delete mode 100644 assets/src/js/functions/loaders.js delete mode 100755 assets/src/js/functions/moment.js delete mode 100644 assets/src/js/functions/numbers.js delete mode 100755 assets/src/js/functions/prototypes.js delete mode 100755 assets/src/js/functions/select.js delete mode 100644 assets/src/js/functions/textarea.js delete mode 100755 backup/.htaccess create mode 100644 bootstrap/app.php create mode 100644 bootstrap/cache/.gitignore delete mode 100755 bug.php delete mode 100755 composer.json delete mode 100755 config.example.php create mode 100644 config/app.php create mode 100644 config/auth.php create mode 100644 config/broadcasting.php create mode 100644 config/cache.php create mode 100644 config/cors.php delete mode 100755 config/csrf_config.php create mode 100644 config/database.php create mode 100644 config/filesystems.php create mode 100644 config/hashing.php create mode 100644 config/logging.php create mode 100644 config/mail.php delete mode 100755 config/namespaces.php create mode 100644 config/queue.php create mode 100644 config/services.php create mode 100644 config/session.php create mode 100644 config/view.php delete mode 100755 controller.php delete mode 100755 core.php delete mode 100644 cron.php delete mode 100755 editor.php delete mode 100755 files/.htaccess delete mode 100755 files/impianti/componente.ini delete mode 100755 include/.htaccess delete mode 100755 include/bottom.php delete mode 100644 include/colonne.php delete mode 100755 include/common/articolo.php delete mode 100644 include/common/barcode.php delete mode 100755 include/common/conti.php delete mode 100755 include/common/descrizione.php delete mode 100755 include/common/form.php delete mode 100755 include/common/importa.php delete mode 100755 include/common/riga.php delete mode 100755 include/common/sconto.php delete mode 100755 include/init/configuration.php delete mode 100755 include/init/init.php delete mode 100755 include/init/requirements.php delete mode 100755 include/init/update.php delete mode 100755 include/manager.php delete mode 100644 include/modifica_allegato.php delete mode 100644 include/riferimenti/riferimenti.php delete mode 100644 include/riferimenti/righe_documento.php delete mode 100644 include/riferimenti/righe_riferimenti.php delete mode 100755 include/top.php delete mode 100755 index.php delete mode 100755 info.php delete mode 100755 lib/common.php delete mode 100755 lib/deprecated.php delete mode 100755 lib/functions.php delete mode 100755 lib/helpers.php delete mode 100755 lib/util.php delete mode 100755 locale/.htaccess delete mode 100755 locale/catalog.pot delete mode 100644 locale/de_DE/de_DE.mo delete mode 100644 locale/de_DE/de_DE.po delete mode 100755 locale/en_GB/en_GB.mo delete mode 100755 locale/en_GB/en_GB.po delete mode 100755 locale/it_IT/.gitignore delete mode 100755 log.php delete mode 100755 logs/.htaccess delete mode 100755 mail.php delete mode 100755 modules/aggiornamenti/actions.php delete mode 100644 modules/aggiornamenti/checksum.php delete mode 100644 modules/aggiornamenti/controlli.php delete mode 100644 modules/aggiornamenti/database.php delete mode 100755 modules/aggiornamenti/edit.php delete mode 100755 modules/aggiornamenti/modutil.php delete mode 100644 modules/aggiornamenti/src/Controlli/Controllo.php delete mode 100644 modules/aggiornamenti/src/Controlli/DatiFattureElettroniche.php delete mode 100644 modules/aggiornamenti/src/Controlli/PianoConti.php delete mode 100755 modules/aggiornamenti/src/UpdateHook.php delete mode 100755 modules/aggiornamenti/upload_modules.php delete mode 100755 modules/anagrafiche/actions.php delete mode 100755 modules/anagrafiche/add.php delete mode 100755 modules/anagrafiche/ajax/complete.php delete mode 100755 modules/anagrafiche/ajax/search.php delete mode 100755 modules/anagrafiche/ajax/select.php delete mode 100755 modules/anagrafiche/bulk.php delete mode 100755 modules/anagrafiche/buttons.php delete mode 100755 modules/anagrafiche/edit.php delete mode 100755 modules/anagrafiche/init.php delete mode 100644 modules/anagrafiche/modals/posizione.php delete mode 100755 modules/anagrafiche/plugins/allegati.php delete mode 100755 modules/anagrafiche/src/API/v1/Anagrafiche.php delete mode 100755 modules/anagrafiche/src/API/v1/Sedi.php delete mode 100755 modules/anagrafiche/src/Anagrafica.php delete mode 100644 modules/anagrafiche/src/Export/CSV.php delete mode 100644 modules/anagrafiche/src/Import/CSV.php delete mode 100755 modules/anagrafiche/src/Nazione.php delete mode 100644 modules/anagrafiche/src/Referente.php delete mode 100644 modules/anagrafiche/src/Sede.php delete mode 100755 modules/anagrafiche/src/Tipo.php delete mode 100755 modules/anagrafiche/validation.php delete mode 100755 modules/anagrafiche/variables.php delete mode 100755 modules/articoli/actions.php delete mode 100755 modules/articoli/add.php delete mode 100755 modules/articoli/ajax/complete.php delete mode 100755 modules/articoli/ajax/search.php delete mode 100755 modules/articoli/ajax/select.php delete mode 100644 modules/articoli/bulk.php delete mode 100755 modules/articoli/buttons.php delete mode 100755 modules/articoli/edit.php delete mode 100755 modules/articoli/init.php delete mode 100644 modules/articoli/modals/duplicazione.php delete mode 100755 modules/articoli/modutil.php delete mode 100755 modules/articoli/plugins/articoli.giacenze.php delete mode 100755 modules/articoli/plugins/articoli.lotti.php delete mode 100755 modules/articoli/plugins/articoli.movimenti.php delete mode 100755 modules/articoli/src/API/v1/Articoli.php delete mode 100755 modules/articoli/src/API/v1/Movimenti.php delete mode 100755 modules/articoli/src/Articolo.php delete mode 100755 modules/articoli/src/Categoria.php delete mode 100644 modules/articoli/src/Import/CSV.php delete mode 100755 modules/articoli/src/Movimento.php delete mode 100755 modules/articoli/validation.php delete mode 100755 modules/articoli/widgets/articoli.dashboard.php delete mode 100755 modules/articoli/widgets/stampa_inventario.php delete mode 100755 modules/backups/actions.php delete mode 100755 modules/backups/edit.php delete mode 100755 modules/backups/init.php delete mode 100644 modules/backups/src/BackupTask.php delete mode 100755 modules/banche/actions.php delete mode 100755 modules/banche/add.php delete mode 100644 modules/banche/ajax/select.php delete mode 100644 modules/banche/edit.php delete mode 100755 modules/banche/init.php delete mode 100644 modules/banche/src/Banca.php delete mode 100644 modules/banche/src/IBAN.php delete mode 100755 modules/beni/actions.php delete mode 100755 modules/beni/add.php delete mode 100755 modules/beni/ajax/select.php delete mode 100755 modules/beni/edit.php delete mode 100755 modules/beni/init.php delete mode 100755 modules/categorie_articoli/actions.php delete mode 100755 modules/categorie_articoli/add.php delete mode 100755 modules/categorie_articoli/edit.php delete mode 100755 modules/categorie_articoli/init.php delete mode 100755 modules/categorie_articoli/row-list.php delete mode 100755 modules/categorie_documenti/actions.php delete mode 100755 modules/categorie_documenti/add.php delete mode 100755 modules/categorie_documenti/ajax/select.php delete mode 100755 modules/categorie_documenti/edit.php delete mode 100755 modules/categorie_documenti/init.php delete mode 100755 modules/categorie_documenti/src/Categoria.php delete mode 100755 modules/categorie_impianti/actions.php delete mode 100755 modules/categorie_impianti/add.php delete mode 100755 modules/categorie_impianti/edit.php delete mode 100755 modules/categorie_impianti/init.php delete mode 100755 modules/causali/actions.php delete mode 100755 modules/causali/add.php delete mode 100755 modules/causali/ajax/select.php delete mode 100755 modules/causali/edit.php delete mode 100755 modules/causali/init.php delete mode 100755 modules/causali_movimenti/actions.php delete mode 100755 modules/causali_movimenti/add.php delete mode 100755 modules/causali_movimenti/edit.php delete mode 100755 modules/causali_movimenti/init.php delete mode 100755 modules/checklists/actions.php delete mode 100755 modules/checklists/add.php delete mode 100755 modules/checklists/components/add-check.php delete mode 100755 modules/checklists/components/add-checklist.php delete mode 100755 modules/checklists/edit.php delete mode 100755 modules/checklists/init.php delete mode 100755 modules/checklists/js/checklist.js delete mode 100755 modules/checklists/modutil.php delete mode 100755 modules/checklists/src/Check.php delete mode 100755 modules/checklists/src/Checklist.php delete mode 100755 modules/checklists/src/ChecklistItem.php delete mode 100755 modules/checklists/src/Traits/ChecklistTrait.php delete mode 100644 modules/contratti/actions.php delete mode 100755 modules/contratti/add.php delete mode 100644 modules/contratti/add_preventivo.php delete mode 100755 modules/contratti/ajax.php delete mode 100755 modules/contratti/ajax/select.php delete mode 100755 modules/contratti/bulk.php delete mode 100755 modules/contratti/buttons.php delete mode 100644 modules/contratti/crea_documento.php delete mode 100755 modules/contratti/edit.php delete mode 100755 modules/contratti/init.php delete mode 100755 modules/contratti/plugins/contratti.consuntivo.php delete mode 100755 modules/contratti/row-add.php delete mode 100755 modules/contratti/row-edit.php delete mode 100755 modules/contratti/row-list.php delete mode 100755 modules/contratti/src/Components/Articolo.php delete mode 100755 modules/contratti/src/Components/Descrizione.php delete mode 100755 modules/contratti/src/Components/RelationTrait.php delete mode 100755 modules/contratti/src/Components/Riga.php delete mode 100755 modules/contratti/src/Components/Sconto.php delete mode 100755 modules/contratti/src/Contratto.php delete mode 100755 modules/contratti/src/Stato.php delete mode 100755 modules/contratti/variables.php delete mode 100755 modules/contratti/widgets/contratti_scadenza.dashboard.php delete mode 100755 modules/custom_fields/actions.php delete mode 100755 modules/custom_fields/add.php delete mode 100755 modules/custom_fields/content-info.php delete mode 100755 modules/custom_fields/edit.php delete mode 100755 modules/custom_fields/init.php delete mode 100644 modules/dashboard/ajax.php delete mode 100755 modules/dashboard/edit.php delete mode 100755 modules/dashboard/widgets/notifiche.php delete mode 100755 modules/dashboard/widgets/stampa_calendario.dashboard.php delete mode 100755 modules/ddt/actions.php delete mode 100755 modules/ddt/add.php delete mode 100644 modules/ddt/add_ddt.php delete mode 100755 modules/ddt/add_ordine.php delete mode 100755 modules/ddt/ajax/search.php delete mode 100755 modules/ddt/bulk.php delete mode 100755 modules/ddt/buttons.php delete mode 100755 modules/ddt/crea_documento.php delete mode 100755 modules/ddt/edit.php delete mode 100755 modules/ddt/init.php delete mode 100644 modules/ddt/modutil.php delete mode 100755 modules/ddt/row-add.php delete mode 100755 modules/ddt/row-edit.php delete mode 100755 modules/ddt/row-list.php delete mode 100755 modules/ddt/src/Components/Articolo.php delete mode 100755 modules/ddt/src/Components/Descrizione.php delete mode 100755 modules/ddt/src/Components/RelationTrait.php delete mode 100755 modules/ddt/src/Components/Riga.php delete mode 100755 modules/ddt/src/Components/Sconto.php delete mode 100755 modules/ddt/src/DDT.php delete mode 100755 modules/ddt/src/Stato.php delete mode 100755 modules/ddt/src/Tipo.php delete mode 100755 modules/ddt/variables.php delete mode 100755 modules/emails/actions.php delete mode 100755 modules/emails/add.php delete mode 100644 modules/emails/buttons.php delete mode 100755 modules/emails/edit.php delete mode 100755 modules/emails/init.php delete mode 100755 modules/emails/src/Account.php delete mode 100755 modules/emails/src/EmailHook.php delete mode 100755 modules/emails/src/Mail.php delete mode 100644 modules/emails/src/OAuth2.php delete mode 100755 modules/emails/src/Receiver.php delete mode 100755 modules/emails/src/Template.php delete mode 100755 modules/fatture/actions.php delete mode 100755 modules/fatture/add.php delete mode 100755 modules/fatture/add_contratto.php delete mode 100755 modules/fatture/add_ddt.php delete mode 100755 modules/fatture/add_intervento.php delete mode 100755 modules/fatture/add_ordine.php delete mode 100755 modules/fatture/add_preventivo.php delete mode 100755 modules/fatture/add_serial.php delete mode 100755 modules/fatture/ajax/search.php delete mode 100644 modules/fatture/ajax/select.php delete mode 100755 modules/fatture/bulk.php delete mode 100755 modules/fatture/buttons.php delete mode 100755 modules/fatture/crea_documento.php delete mode 100755 modules/fatture/edit.php delete mode 100755 modules/fatture/fe/components/altri_dati.php delete mode 100755 modules/fatture/fe/components/dati_documento.php delete mode 100755 modules/fatture/fe/document-fe.php delete mode 100755 modules/fatture/fe/row-fe.php delete mode 100755 modules/fatture/fe/style.css delete mode 100755 modules/fatture/init.php delete mode 100755 modules/fatture/modutil.php delete mode 100755 modules/fatture/row-add.php delete mode 100755 modules/fatture/row-edit.php delete mode 100755 modules/fatture/row-list.php delete mode 100755 modules/fatture/src/Components/Articolo.php delete mode 100755 modules/fatture/src/Components/Descrizione.php delete mode 100755 modules/fatture/src/Components/RelationTrait.php delete mode 100755 modules/fatture/src/Components/Riga.php delete mode 100755 modules/fatture/src/Components/Sconto.php delete mode 100644 modules/fatture/src/Export/CSV.php delete mode 100755 modules/fatture/src/Fattura.php delete mode 100644 modules/fatture/src/Gestori/Bollo.php delete mode 100644 modules/fatture/src/Gestori/Movimenti.php delete mode 100644 modules/fatture/src/Gestori/Scadenze.php delete mode 100755 modules/fatture/src/Stato.php delete mode 100755 modules/fatture/src/StatoFE.php delete mode 100755 modules/fatture/src/Tipo.php delete mode 100755 modules/fatture/variables.php delete mode 100755 modules/gestione_componenti/actions.php delete mode 100755 modules/gestione_componenti/add.php delete mode 100755 modules/gestione_componenti/ajax/select.php delete mode 100755 modules/gestione_componenti/edit.php delete mode 100755 modules/gestione_componenti/init.php delete mode 100755 modules/gestione_documentale/actions.php delete mode 100755 modules/gestione_documentale/add.php delete mode 100755 modules/gestione_documentale/edit.php delete mode 100755 modules/gestione_documentale/init.php delete mode 100644 modules/giacenze_sedi/controller_before.php delete mode 100644 modules/giacenze_sedi/init.php delete mode 100644 modules/impianti/actions.php delete mode 100644 modules/impianti/add.php delete mode 100644 modules/impianti/ajax/search.php delete mode 100755 modules/impianti/ajax/select.php delete mode 100644 modules/impianti/bulk.php delete mode 100755 modules/impianti/buttons.php delete mode 100644 modules/impianti/edit.php delete mode 100755 modules/impianti/init.php delete mode 100755 modules/impianti/modutil.php delete mode 100755 modules/impianti/plugins/my_impianti.componenti.php delete mode 100644 modules/impianti/plugins/my_impianti.interventi.php delete mode 100755 modules/impianti/src/API/v1/Impianti.php delete mode 100644 modules/impianti/src/Export/CSV.php delete mode 100644 modules/impianti/src/Impianto.php delete mode 100755 modules/import/actions.php delete mode 100755 modules/import/add.php delete mode 100755 modules/import/edit.php delete mode 100755 modules/import/init.php delete mode 100644 modules/import/src/Import.php delete mode 100755 modules/impostazioni/actions.php delete mode 100755 modules/impostazioni/edit.php delete mode 100755 modules/impostazioni/init.php delete mode 100644 modules/impostazioni/sezione.php delete mode 100644 modules/interventi/actions.php delete mode 100755 modules/interventi/add.php delete mode 100644 modules/interventi/add_contratto.php delete mode 100644 modules/interventi/add_ddt.php delete mode 100644 modules/interventi/add_preventivo.php delete mode 100644 modules/interventi/ajax/complete.php delete mode 100755 modules/interventi/ajax/search.php delete mode 100755 modules/interventi/ajax/select.php delete mode 100755 modules/interventi/ajax_costi.php delete mode 100755 modules/interventi/ajax_tecnici.php delete mode 100755 modules/interventi/bulk.php delete mode 100755 modules/interventi/buttons.php delete mode 100644 modules/interventi/crea_documento.php delete mode 100755 modules/interventi/edit.php delete mode 100755 modules/interventi/init.php delete mode 100644 modules/interventi/modals/anteprima_firma.php delete mode 100644 modules/interventi/modals/copy_sessione.php delete mode 100644 modules/interventi/modals/duplicazione.php delete mode 100644 modules/interventi/modals/manage_sessione.php delete mode 100755 modules/interventi/modutil.php delete mode 100644 modules/interventi/occupazione_tecnici.php delete mode 100755 modules/interventi/plugins/my_impianti.interventi.php delete mode 100755 modules/interventi/row-add.php delete mode 100755 modules/interventi/row-edit.php delete mode 100755 modules/interventi/row-list.php delete mode 100755 modules/interventi/src/API/v1/Articoli.php delete mode 100755 modules/interventi/src/API/v1/Firma.php delete mode 100755 modules/interventi/src/API/v1/Impianti.php delete mode 100755 modules/interventi/src/API/v1/Interventi.php delete mode 100755 modules/interventi/src/API/v1/Rapportino.php delete mode 100755 modules/interventi/src/API/v1/Sessioni.php delete mode 100755 modules/interventi/src/API/v1/Sync.php delete mode 100755 modules/interventi/src/Components/Articolo.php delete mode 100755 modules/interventi/src/Components/RelationTrait.php delete mode 100755 modules/interventi/src/Components/Riga.php delete mode 100755 modules/interventi/src/Components/Sconto.php delete mode 100755 modules/interventi/src/Components/Sessione.php delete mode 100755 modules/interventi/src/Intervento.php delete mode 100755 modules/interventi/src/Stato.php delete mode 100755 modules/interventi/variables.php delete mode 100755 modules/interventi/widgets/interventi_confermati.php delete mode 100755 modules/interventi/widgets/interventi_da_pianificare.php delete mode 100755 modules/interventi/widgets/interventi_da_programmare.php delete mode 100755 modules/iva/actions.php delete mode 100755 modules/iva/add.php delete mode 100755 modules/iva/ajax/select.php delete mode 100755 modules/iva/bulk.php delete mode 100755 modules/iva/edit.php delete mode 100755 modules/iva/init.php delete mode 100755 modules/iva/src/Aliquota.php delete mode 100755 modules/liste_newsletter/actions.php delete mode 100755 modules/liste_newsletter/add.php delete mode 100755 modules/liste_newsletter/edit.php delete mode 100755 modules/liste_newsletter/init.php delete mode 100755 modules/misure/actions.php delete mode 100755 modules/misure/add.php delete mode 100755 modules/misure/edit.php delete mode 100755 modules/misure/init.php delete mode 100755 modules/modelli_primanota/actions.php delete mode 100755 modules/modelli_primanota/add.php delete mode 100755 modules/modelli_primanota/edit.php delete mode 100755 modules/modelli_primanota/init.php delete mode 100755 modules/movimenti/actions.php delete mode 100755 modules/movimenti/add.php delete mode 100755 modules/newsletter/actions.php delete mode 100755 modules/newsletter/add.php delete mode 100755 modules/newsletter/ajax/select.php delete mode 100755 modules/newsletter/buttons.php delete mode 100755 modules/newsletter/edit.php delete mode 100755 modules/newsletter/init.php delete mode 100755 modules/newsletter/src/Lista.php delete mode 100755 modules/newsletter/src/Newsletter.php delete mode 100644 modules/newsletter/validation.php delete mode 100755 modules/ordini/actions.php delete mode 100755 modules/ordini/add.php delete mode 100644 modules/ordini/add_preventivo.php delete mode 100644 modules/ordini/ajax/select.php delete mode 100644 modules/ordini/bulk.php delete mode 100755 modules/ordini/buttons.php delete mode 100755 modules/ordini/crea_documento.php delete mode 100755 modules/ordini/edit.php delete mode 100755 modules/ordini/init.php delete mode 100755 modules/ordini/modutil.php delete mode 100644 modules/ordini/plugins/ordini.consuntivo.php delete mode 100644 modules/ordini/quantita_impegnate.php delete mode 100755 modules/ordini/row-add.php delete mode 100755 modules/ordini/row-edit.php delete mode 100755 modules/ordini/row-list.php delete mode 100755 modules/ordini/src/Components/Articolo.php delete mode 100755 modules/ordini/src/Components/Descrizione.php delete mode 100755 modules/ordini/src/Components/RelationTrait.php delete mode 100755 modules/ordini/src/Components/Riga.php delete mode 100755 modules/ordini/src/Components/Sconto.php delete mode 100755 modules/ordini/src/Ordine.php delete mode 100755 modules/ordini/src/Stato.php delete mode 100755 modules/ordini/src/Tipo.php delete mode 100755 modules/ordini/variables.php delete mode 100755 modules/pagamenti/actions.php delete mode 100755 modules/pagamenti/add.php delete mode 100755 modules/pagamenti/ajax/select.php delete mode 100755 modules/pagamenti/edit.php delete mode 100755 modules/pagamenti/init.php delete mode 100755 modules/pagamenti/src/Pagamento.php delete mode 100755 modules/partitario/actions.php delete mode 100755 modules/partitario/add_conto.php delete mode 100644 modules/partitario/aggiorna_reddito.php delete mode 100755 modules/partitario/ajax/select.php delete mode 100755 modules/partitario/dettagli_conto.php delete mode 100755 modules/partitario/edit.php delete mode 100755 modules/partitario/edit_conto.php delete mode 100644 modules/piano_sconto/actions.php delete mode 100755 modules/piano_sconto/add.php delete mode 100755 modules/piano_sconto/edit.php delete mode 100644 modules/piano_sconto/init.php delete mode 100644 modules/piano_sconto/src/PianoSconto.php delete mode 100755 modules/porti/actions.php delete mode 100755 modules/porti/add.php delete mode 100755 modules/porti/edit.php delete mode 100755 modules/porti/init.php delete mode 100755 modules/preventivi/actions.php delete mode 100755 modules/preventivi/add.php delete mode 100755 modules/preventivi/ajax.php delete mode 100755 modules/preventivi/ajax/search.php delete mode 100755 modules/preventivi/ajax/select.php delete mode 100755 modules/preventivi/bulk.php delete mode 100644 modules/preventivi/buttons.php delete mode 100644 modules/preventivi/crea_documento.php delete mode 100644 modules/preventivi/crea_revisione.php delete mode 100755 modules/preventivi/edit.php delete mode 100755 modules/preventivi/init.php delete mode 100755 modules/preventivi/modutil.php delete mode 100755 modules/preventivi/plugins/preventivi.consuntivo.php delete mode 100755 modules/preventivi/row-add.php delete mode 100755 modules/preventivi/row-edit.php delete mode 100755 modules/preventivi/row-list.php delete mode 100755 modules/preventivi/src/Components/Articolo.php delete mode 100755 modules/preventivi/src/Components/Descrizione.php delete mode 100755 modules/preventivi/src/Components/RelationTrait.php delete mode 100755 modules/preventivi/src/Components/Riga.php delete mode 100755 modules/preventivi/src/Components/Sconto.php delete mode 100755 modules/preventivi/src/Preventivo.php delete mode 100755 modules/preventivi/src/Stato.php delete mode 100755 modules/preventivi/variables.php delete mode 100755 modules/preventivi/widgets/preventivi.dashboard.php delete mode 100755 modules/primanota/actions.php delete mode 100755 modules/primanota/add.php delete mode 100755 modules/primanota/ajax/complete.php delete mode 100755 modules/primanota/edit.php delete mode 100755 modules/primanota/init.php delete mode 100755 modules/primanota/movimenti.php delete mode 100755 modules/primanota/src/Mastrino.php delete mode 100755 modules/primanota/src/Movimento.php delete mode 100755 modules/relazioni_anagrafiche/actions.php delete mode 100755 modules/relazioni_anagrafiche/add.php delete mode 100755 modules/relazioni_anagrafiche/edit.php delete mode 100755 modules/relazioni_anagrafiche/init.php delete mode 100755 modules/ritenute/actions.php delete mode 100755 modules/ritenute/add.php delete mode 100755 modules/ritenute/edit.php delete mode 100755 modules/ritenute/init.php delete mode 100755 modules/ritenute/src/RitenutaAcconto.php delete mode 100755 modules/ritenute_contributi/actions.php delete mode 100755 modules/ritenute_contributi/add.php delete mode 100755 modules/ritenute_contributi/edit.php delete mode 100755 modules/ritenute_contributi/init.php delete mode 100755 modules/ritenute_contributi/src/RitenutaContributi.php delete mode 100755 modules/rivalse/actions.php delete mode 100755 modules/rivalse/add.php delete mode 100755 modules/rivalse/edit.php delete mode 100755 modules/rivalse/init.php delete mode 100755 modules/rivalse/src/RivalsaINPS.php delete mode 100755 modules/scadenzario/actions.php delete mode 100755 modules/scadenzario/add.php delete mode 100755 modules/scadenzario/bulk.php delete mode 100755 modules/scadenzario/controller_after.php delete mode 100755 modules/scadenzario/edit.php delete mode 100755 modules/scadenzario/init.php delete mode 100755 modules/scadenzario/src/Scadenza.php delete mode 100755 modules/scadenzario/variables.php delete mode 100755 modules/segmenti/actions.php delete mode 100755 modules/segmenti/add.php delete mode 100755 modules/segmenti/edit.php delete mode 100755 modules/segmenti/init.php delete mode 100755 modules/smtp/actions.php delete mode 100755 modules/smtp/add.php delete mode 100755 modules/smtp/ajax/select.php delete mode 100755 modules/smtp/buttons.php delete mode 100755 modules/smtp/edit.php delete mode 100755 modules/smtp/init.php delete mode 100755 modules/spedizioni/actions.php delete mode 100755 modules/spedizioni/add.php delete mode 100755 modules/spedizioni/edit.php delete mode 100755 modules/spedizioni/init.php delete mode 100755 modules/stampe/actions.php delete mode 100755 modules/stampe/edit.php delete mode 100755 modules/stampe/init.php delete mode 100755 modules/stampe_contabili/edit.php delete mode 100644 modules/stampe_contabili/stampe_contabili.php delete mode 100755 modules/stati_contratto/actions.php delete mode 100755 modules/stati_contratto/add.php delete mode 100755 modules/stati_contratto/edit.php delete mode 100755 modules/stati_contratto/init.php delete mode 100755 modules/stati_contratto/src/API/v1/StatiContratti.php delete mode 100755 modules/stati_intervento/actions.php delete mode 100755 modules/stati_intervento/add.php delete mode 100755 modules/stati_intervento/edit.php delete mode 100755 modules/stati_intervento/init.php delete mode 100755 modules/stati_intervento/src/API/v1/StatiInterventi.php delete mode 100755 modules/stati_preventivo/actions.php delete mode 100755 modules/stati_preventivo/add.php delete mode 100755 modules/stati_preventivo/edit.php delete mode 100755 modules/stati_preventivo/init.php delete mode 100755 modules/stati_preventivo/src/API/v1/StatiPreventivi.php delete mode 100755 modules/statistiche/actions.php delete mode 100755 modules/statistiche/edit.php delete mode 100755 modules/statistiche/js/calendar.js delete mode 100755 modules/statistiche/js/functions.js delete mode 100755 modules/statistiche/js/init.js delete mode 100755 modules/statistiche/js/manager.js delete mode 100755 modules/statistiche/js/stat.js delete mode 100755 modules/statistiche/js/stats/line_chart.js delete mode 100755 modules/statistiche/js/stats/table.js delete mode 100755 modules/statistiche/js/stats/widget.js delete mode 100755 modules/statistiche/src/Stats.php delete mode 100755 modules/stato_email/actions.php delete mode 100644 modules/stato_email/bulk.php delete mode 100644 modules/stato_email/buttons.php delete mode 100755 modules/stato_email/edit.php delete mode 100755 modules/stato_email/init.php delete mode 100755 modules/stato_servizi/actions.php delete mode 100755 modules/stato_servizi/edit.php delete mode 100755 modules/stato_servizi/modutil.php delete mode 100755 modules/stato_servizi/src/API/v1/FolderSize.php delete mode 100644 modules/stato_servizi/src/ServicesHook.php delete mode 100644 modules/stato_servizi/src/SpaceHook.php delete mode 100755 modules/stato_servizi/widgets/spazio_utilizzato.php delete mode 100755 modules/tecnici_tariffe/actions.php delete mode 100755 modules/tecnici_tariffe/edit.php delete mode 100755 modules/tecnici_tariffe/init.php delete mode 100755 modules/tipi_anagrafiche/actions.php delete mode 100755 modules/tipi_anagrafiche/add.php delete mode 100755 modules/tipi_anagrafiche/edit.php delete mode 100755 modules/tipi_anagrafiche/init.php delete mode 100644 modules/tipi_documento/actions.php delete mode 100644 modules/tipi_documento/add.php delete mode 100644 modules/tipi_documento/ajax/select.php delete mode 100644 modules/tipi_documento/edit.php delete mode 100644 modules/tipi_documento/init.php delete mode 100755 modules/tipi_intervento/actions.php delete mode 100755 modules/tipi_intervento/add.php delete mode 100755 modules/tipi_intervento/buttons.php delete mode 100755 modules/tipi_intervento/edit.php delete mode 100755 modules/tipi_intervento/init.php delete mode 100755 modules/tipi_intervento/src/API/v1/TipiInterventi.php delete mode 100755 modules/tipi_intervento/src/Tipo.php delete mode 100755 modules/tipi_scadenze/actions.php delete mode 100755 modules/tipi_scadenze/add.php delete mode 100755 modules/tipi_scadenze/ajax/select.php delete mode 100755 modules/tipi_scadenze/edit.php delete mode 100755 modules/tipi_scadenze/init.php delete mode 100755 modules/utenti/actions.php delete mode 100755 modules/utenti/add.php delete mode 100755 modules/utenti/ajax/select.php delete mode 100755 modules/utenti/components/base.php delete mode 100755 modules/utenti/components/password.php delete mode 100755 modules/utenti/components/photo.php delete mode 100755 modules/utenti/edit.php delete mode 100755 modules/utenti/info.php delete mode 100755 modules/utenti/init.php delete mode 100755 modules/utenti/modutil.php delete mode 100755 modules/utenti/self.php delete mode 100755 modules/utenti/src/API/v1/Login.php delete mode 100755 modules/utenti/src/API/v1/Logout.php delete mode 100755 modules/utenti/user.php delete mode 100755 modules/utenti/validation.php delete mode 100755 modules/utenti/variables.php delete mode 100755 modules/viste/actions.php delete mode 100755 modules/viste/edit.php delete mode 100755 modules/viste/fields.php delete mode 100755 modules/viste/filters.php delete mode 100755 modules/viste/init.php delete mode 100755 modules/voci_servizio/actions.php delete mode 100755 modules/voci_servizio/add.php delete mode 100755 modules/voci_servizio/edit.php delete mode 100755 modules/voci_servizio/init.php delete mode 100755 modules/zone/actions.php delete mode 100755 modules/zone/add.php delete mode 100755 modules/zone/ajax/select.php delete mode 100755 modules/zone/edit.php delete mode 100755 modules/zone/init.php delete mode 100644 oauth2.php mode change 100755 => 100644 package.json delete mode 100755 pdfgen.php delete mode 100755 plugins/checks.php delete mode 100644 plugins/componenti/actions.php delete mode 100644 plugins/componenti/add.php delete mode 100644 plugins/componenti/allegati.php delete mode 100644 plugins/componenti/edit.php delete mode 100755 plugins/dichiarazioni_intento/actions.php delete mode 100755 plugins/dichiarazioni_intento/add.php delete mode 100755 plugins/dichiarazioni_intento/edit.php delete mode 100755 plugins/dichiarazioni_intento/init.php delete mode 100755 plugins/dichiarazioni_intento/src/Dichiarazione.php delete mode 100755 plugins/exportFE/actions.php delete mode 100755 plugins/exportFE/download.php delete mode 100755 plugins/exportFE/edit.php delete mode 100755 plugins/exportFE/init.php delete mode 100644 plugins/exportFE/notifiche.php delete mode 100755 plugins/exportFE/src/FatturaElettronica.php delete mode 100755 plugins/exportFE/src/Interaction.php delete mode 100755 plugins/exportFE/src/InvoiceHook.php delete mode 100755 plugins/exportFE/src/Validator.php delete mode 100755 plugins/importFE/actions.php delete mode 100755 plugins/importFE/buttons.php delete mode 100755 plugins/importFE/edit.php delete mode 100755 plugins/importFE/generate.php delete mode 100755 plugins/importFE/init.php delete mode 100755 plugins/importFE/list.php delete mode 100755 plugins/importFE/riferimento.php delete mode 100755 plugins/importFE/src/FatturaElettronica.php delete mode 100755 plugins/importFE/src/FatturaOrdinaria.php delete mode 100755 plugins/importFE/src/FatturaSemplificata.php delete mode 100755 plugins/importFE/src/Interaction.php delete mode 100755 plugins/importFE/src/InvoiceHook.php delete mode 100755 plugins/importFE/src/Parcella.php delete mode 100755 plugins/importFE/view.php delete mode 100644 plugins/listino_clienti/actions.php delete mode 100644 plugins/listino_clienti/dettaglio_prezzi.php delete mode 100644 plugins/listino_clienti/edit.php delete mode 100644 plugins/listino_clienti/src/DettaglioPrezzo.php delete mode 100644 plugins/listino_fornitori/actions.php delete mode 100644 plugins/listino_fornitori/dettaglio_fornitore.php delete mode 100644 plugins/listino_fornitori/edit.php delete mode 100644 plugins/listino_fornitori/src/DettaglioFornitore.php delete mode 100644 plugins/listino_fornitori/src/METEL.php delete mode 100755 plugins/notes.php delete mode 100644 plugins/piani_sconto_maggiorazione/edit.php delete mode 100755 plugins/pianificazione_fatturazione/actions.php delete mode 100755 plugins/pianificazione_fatturazione/add_pianificazione.php delete mode 100644 plugins/pianificazione_fatturazione/ajax_cadenza.php delete mode 100755 plugins/pianificazione_fatturazione/crea_fattura.php delete mode 100755 plugins/pianificazione_fatturazione/edit.php delete mode 100644 plugins/pianificazione_fatturazione/modutil.php delete mode 100755 plugins/pianificazione_fatturazione/src/Pianificazione.php delete mode 100644 plugins/pianificazione_fatturazione/widgets/rate_contrattuali.php delete mode 100755 plugins/pianificazione_interventi/actions.php delete mode 100755 plugins/pianificazione_interventi/edit.php delete mode 100755 plugins/pianificazione_interventi/init.php delete mode 100755 plugins/pianificazione_interventi/pianificazione.php delete mode 100755 plugins/pianificazione_interventi/row-add.php delete mode 100755 plugins/pianificazione_interventi/row-edit.php delete mode 100755 plugins/pianificazione_interventi/row-list.php delete mode 100755 plugins/pianificazione_interventi/src/Components/Articolo.php delete mode 100755 plugins/pianificazione_interventi/src/Components/Descrizione.php delete mode 100755 plugins/pianificazione_interventi/src/Components/RelationTrait.php delete mode 100755 plugins/pianificazione_interventi/src/Components/Riga.php delete mode 100755 plugins/pianificazione_interventi/src/Components/Sconto.php delete mode 100755 plugins/pianificazione_interventi/src/Promemoria.php delete mode 100644 plugins/pianificazione_interventi/widgets/promemoria_da_pianificare.php delete mode 100755 plugins/receiptFE/actions.php delete mode 100755 plugins/receiptFE/edit.php delete mode 100755 plugins/receiptFE/list.php delete mode 100755 plugins/receiptFE/src/Interaction.php delete mode 100644 plugins/receiptFE/src/MissingReceiptTask.php delete mode 100644 plugins/receiptFE/src/NotificheRicevuteHook.php delete mode 100755 plugins/receiptFE/src/ReceiptHook.php delete mode 100644 plugins/receiptFE/src/ReceiptTask.php delete mode 100755 plugins/receiptFE/src/Ricevuta.php delete mode 100755 plugins/referenti/actions.php delete mode 100755 plugins/referenti/add.php delete mode 100755 plugins/referenti/edit.php delete mode 100755 plugins/referenti/init.php delete mode 100755 plugins/revisioni/actions.php delete mode 100755 plugins/revisioni/edit.php delete mode 100755 plugins/rinnovi_contratti/edit.php delete mode 100755 plugins/sedi/actions.php delete mode 100755 plugins/sedi/add.php delete mode 100755 plugins/sedi/edit.php delete mode 100755 plugins/sedi/init.php delete mode 100755 plugins/statistiche_anagrafiche/edit.php delete mode 100755 plugins/statistiche_anagrafiche/info.php delete mode 100755 plugins/statistiche_articoli/edit.php delete mode 100755 plugins/statistiche_articoli/js/prezzo.js delete mode 100755 plugins/statistiche_articoli/manage_prezzi.php delete mode 100755 plugins/statistiche_articoli/src/Stats.php delete mode 100755 plugins/xml/AT.xsl delete mode 100755 plugins/xml/DT.xsl delete mode 100755 plugins/xml/EC.xsl delete mode 100755 plugins/xml/MC.xsl delete mode 100755 plugins/xml/MT.xsl delete mode 100755 plugins/xml/NE.xsl delete mode 100755 plugins/xml/NS.xsl delete mode 100755 plugins/xml/RC.xsl delete mode 100755 plugins/xml/SE.xsl delete mode 100755 plugins/xml/asso-invoice.xsl create mode 100644 public/.htaccess rename files/temp/.gitkeep => public/favicon.ico (100%) create mode 100644 public/index.php create mode 100644 public/web.config delete mode 100755 reset.php rename tests/_data/.gitkeep => resources/css/app.css (100%) mode change 100755 => 100644 rename update/2_4_17_1.sql => resources/js/app.js (100%) create mode 100644 resources/lang/en/auth.php create mode 100644 resources/lang/en/pagination.php create mode 100644 resources/lang/en/passwords.php create mode 100644 resources/lang/en/validation.php create mode 100644 routes/api.php create mode 100644 routes/channels.php create mode 100644 routes/console.php create mode 100644 routes/web.php create mode 100644 server.php delete mode 100755 src/AJAX.php delete mode 100644 src/API/App/AppResource.php delete mode 100644 src/API/App/v1/AliquoteIva.php delete mode 100644 src/API/App/v1/AllegatiInterventi.php delete mode 100644 src/API/App/v1/Articoli.php delete mode 100644 src/API/App/v1/Clienti.php delete mode 100644 src/API/App/v1/Contratti.php delete mode 100644 src/API/App/v1/ControlloClienti.php delete mode 100644 src/API/App/v1/Flash/Intervento.php delete mode 100644 src/API/App/v1/Impianti.php delete mode 100644 src/API/App/v1/Impostazioni.php delete mode 100644 src/API/App/v1/Interventi.php delete mode 100644 src/API/App/v1/Login.php delete mode 100644 src/API/App/v1/MovimentiManuali.php delete mode 100644 src/API/App/v1/Preventivi.php delete mode 100644 src/API/App/v1/RapportinoIntervento.php delete mode 100644 src/API/App/v1/Referenti.php delete mode 100644 src/API/App/v1/Revisione.php delete mode 100644 src/API/App/v1/RigheInterventi.php delete mode 100644 src/API/App/v1/Sedi.php delete mode 100644 src/API/App/v1/SediAzienda.php delete mode 100644 src/API/App/v1/SegnalazioneBug.php delete mode 100644 src/API/App/v1/SessioniInterventi.php delete mode 100644 src/API/App/v1/StatiIntervento.php delete mode 100644 src/API/App/v1/TariffeContratti.php delete mode 100644 src/API/App/v1/TariffeTecnici.php delete mode 100644 src/API/App/v1/Tecnici.php delete mode 100644 src/API/App/v1/TipiIntervento.php delete mode 100755 src/API/Common/Allegato.php delete mode 100755 src/API/Common/Stampa.php delete mode 100644 src/API/Common/Task.php delete mode 100755 src/API/Exceptions/InternalError.php delete mode 100755 src/API/Exceptions/ResourceNotFound.php delete mode 100755 src/API/Exceptions/ServiceError.php delete mode 100755 src/API/Exceptions/Unauthorized.php delete mode 100755 src/API/Interfaces/CreateInterface.php delete mode 100755 src/API/Interfaces/DeleteInterface.php delete mode 100755 src/API/Interfaces/RetrieveInterface.php delete mode 100755 src/API/Interfaces/UpdateInterface.php delete mode 100755 src/API/Manager.php delete mode 100755 src/API/Resource.php delete mode 100755 src/API/Response.php delete mode 100755 src/API/Services.php delete mode 100755 src/App.php delete mode 100755 src/Auth.php delete mode 100755 src/Backup.php delete mode 100644 src/Common/Components/Accounting.php delete mode 100755 src/Common/Components/Article.php delete mode 100644 src/Common/Components/Component.php delete mode 100755 src/Common/Components/Description.php delete mode 100755 src/Common/Components/Discount.php delete mode 100755 src/Common/Components/Row.php delete mode 100755 src/Common/Document.php delete mode 100644 src/Common/DocumentInterface.php delete mode 100755 src/Common/Model.php delete mode 100755 src/Common/ReferenceInterface.php delete mode 100644 src/Common/RowReference.php delete mode 100644 src/Common/SimpleModelTrait.php delete mode 100755 src/Database.php delete mode 100644 src/Exporter/CSVExporter.php delete mode 100644 src/Exporter/ExporterInterface.php delete mode 100755 src/Extensions/EloquentCollector.php delete mode 100755 src/Extensions/MessageHandler.php delete mode 100755 src/Filter.php delete mode 100755 src/HTMLBuilder/HTMLBuilder.php delete mode 100755 src/HTMLBuilder/Handler/CKEditorHandler.php delete mode 100755 src/HTMLBuilder/Handler/ChoicesHandler.php delete mode 100755 src/HTMLBuilder/Handler/DateHandler.php delete mode 100755 src/HTMLBuilder/Handler/DefaultHandler.php delete mode 100755 src/HTMLBuilder/Handler/HandlerInterface.php delete mode 100755 src/HTMLBuilder/Handler/MediaHandler.php delete mode 100755 src/HTMLBuilder/Handler/SelectHandler.php delete mode 100755 src/HTMLBuilder/Manager/ButtonManager.php delete mode 100755 src/HTMLBuilder/Manager/EmailManager.php delete mode 100755 src/HTMLBuilder/Manager/FieldManager.php delete mode 100755 src/HTMLBuilder/Manager/FileManager.php delete mode 100755 src/HTMLBuilder/Manager/ManagerInterface.php delete mode 100755 src/HTMLBuilder/Manager/WidgetManager.php delete mode 100755 src/HTMLBuilder/Wrapper/HTMLWrapper.php delete mode 100755 src/HTMLBuilder/Wrapper/WrapperInterface.php delete mode 100755 src/Hooks/CachedManager.php delete mode 100755 src/Hooks/Manager.php delete mode 100644 src/Importer/CSVImporter.php delete mode 100644 src/Importer/ImporterInterface.php delete mode 100755 src/Intl/FileLoader.php delete mode 100755 src/Intl/Formatter.php delete mode 100755 src/Models/ApiResource.php delete mode 100755 src/Models/Cache.php delete mode 100755 src/Models/Clause.php delete mode 100755 src/Models/Group.php delete mode 100755 src/Models/Hook.php delete mode 100755 src/Models/Log.php delete mode 100755 src/Models/Module.php delete mode 100755 src/Models/Note.php delete mode 100755 src/Models/OperationLog.php delete mode 100755 src/Models/Plugin.php delete mode 100755 src/Models/PrintTemplate.php delete mode 100755 src/Models/Setting.php delete mode 100755 src/Models/Upload.php delete mode 100755 src/Models/User.php delete mode 100755 src/Models/View.php delete mode 100755 src/Modules.php delete mode 100755 src/Notifications/EmailNotification.php delete mode 100755 src/Notifications/Notification.php delete mode 100755 src/Notifications/NotificationInterface.php delete mode 100755 src/Permissions.php delete mode 100755 src/Plugins.php delete mode 100755 src/Prints.php delete mode 100755 src/Settings.php delete mode 100644 src/Tasks/Log.php delete mode 100644 src/Tasks/Manager.php delete mode 100644 src/Tasks/Task.php delete mode 100644 src/Tasks/TaskInterface.php delete mode 100755 src/Traits/Components/NoteTrait.php delete mode 100755 src/Traits/Components/UploadTrait.php delete mode 100755 src/Traits/HierarchyTrait.php delete mode 100644 src/Traits/LocalPoolTrait.php delete mode 100755 src/Traits/ManagerTrait.php delete mode 100755 src/Traits/PathTrait.php delete mode 100755 src/Traits/RecordTrait.php delete mode 100755 src/Traits/ReferenceTrait.php delete mode 100755 src/Translator.php delete mode 100755 src/Update.php delete mode 100755 src/Uploads.php delete mode 100755 src/Util/Autofill.php delete mode 100755 src/Util/FileSystem.php delete mode 100755 src/Util/Generator.php delete mode 100755 src/Util/Ini.php delete mode 100755 src/Util/Messages.php delete mode 100755 src/Util/Query.php delete mode 100755 src/Util/Singleton.php delete mode 100755 src/Util/XML.php delete mode 100755 src/Util/Zip.php delete mode 100755 src/Validate.php create mode 100644 storage/app/.gitignore create mode 100644 storage/app/public/.gitignore create mode 100644 storage/framework/.gitignore create mode 100644 storage/framework/cache/.gitignore create mode 100644 storage/framework/cache/data/.gitignore create mode 100644 storage/framework/sessions/.gitignore create mode 100644 storage/framework/testing/.gitignore create mode 100644 storage/framework/views/.gitignore create mode 100644 storage/logs/.gitignore delete mode 100755 templates/anagrafiche/body.php delete mode 100755 templates/anagrafiche/init.php delete mode 100755 templates/azienda/body.php delete mode 100755 templates/azienda/init.php delete mode 100755 templates/barcode/body.php delete mode 100755 templates/barcode/footer.php delete mode 100755 templates/barcode/header.php delete mode 100755 templates/barcode/init.php delete mode 100755 templates/base/bootstrap.css delete mode 100755 templates/base/footer.php delete mode 100755 templates/base/header.php delete mode 100755 templates/base/logo_azienda.jpg delete mode 100755 templates/base/settings.php delete mode 100755 templates/base/style.css delete mode 100644 templates/bilancio/body.php delete mode 100644 templates/bilancio/header.php delete mode 100644 templates/bilancio/init.php delete mode 100644 templates/bilancio/settings.php delete mode 100755 templates/contratti/body.php delete mode 100755 templates/contratti/footer.php delete mode 100755 templates/contratti/init.php delete mode 100755 templates/contratti/settings.php delete mode 100755 templates/contratti_cons/bottom.php delete mode 100755 templates/contratti_cons/init.php delete mode 100755 templates/contratti_cons/piece.php delete mode 100755 templates/contratti_cons/top.php delete mode 100755 templates/dashboard/body.php delete mode 100755 templates/dashboard/header.php delete mode 100755 templates/dashboard/settings.php delete mode 100755 templates/ddt/body.php delete mode 100755 templates/ddt/footer.php delete mode 100755 templates/ddt/header.php delete mode 100755 templates/ddt/init.php delete mode 100755 templates/fatturato/body.php delete mode 100755 templates/fatturato/init.php delete mode 100755 templates/fatture/body.php delete mode 100755 templates/fatture/footer.php delete mode 100755 templates/fatture/header.php delete mode 100755 templates/fatture/init.php delete mode 100644 templates/fatture_elettroniche/body.php delete mode 100755 templates/info.php delete mode 100755 templates/interventi/body.php delete mode 100755 templates/interventi/init.php delete mode 100644 templates/liquidazione_iva/body.php delete mode 100644 templates/liquidazione_iva/footer.php delete mode 100644 templates/liquidazione_iva/header.php delete mode 100644 templates/liquidazione_iva/init.php delete mode 100644 templates/liquidazione_iva/settings.php delete mode 100755 templates/magazzino_inventario/body.php delete mode 100755 templates/magazzino_inventario/settings.php delete mode 100755 templates/ordini/body.php delete mode 100755 templates/ordini/header.php delete mode 100755 templates/ordini/init.php delete mode 100644 templates/ordini/settings.php delete mode 100644 templates/ordini_cons/bottom.php delete mode 100644 templates/ordini_cons/init.php delete mode 100644 templates/ordini_cons/piece.php delete mode 100644 templates/ordini_cons/top.php delete mode 100644 templates/partitario_mastrino/bottom.php delete mode 100644 templates/partitario_mastrino/footer.php delete mode 100644 templates/partitario_mastrino/header.php delete mode 100644 templates/partitario_mastrino/init.php delete mode 100644 templates/partitario_mastrino/piece.php delete mode 100644 templates/partitario_mastrino/settings.php delete mode 100644 templates/partitario_mastrino/top.php delete mode 100755 templates/pdfgen_variables.php delete mode 100755 templates/preventivi/body.php delete mode 100755 templates/preventivi/footer.php delete mode 100755 templates/preventivi/init.php delete mode 100755 templates/preventivi/settings.php delete mode 100755 templates/preventivi_cons/bottom.php delete mode 100755 templates/preventivi_cons/init.php delete mode 100755 templates/preventivi_cons/piece.php delete mode 100755 templates/preventivi_cons/top.php delete mode 100755 templates/registro_iva/bottom.php delete mode 100755 templates/registro_iva/footer.php delete mode 100755 templates/registro_iva/init.php delete mode 100755 templates/registro_iva/piece.php delete mode 100755 templates/registro_iva/settings.php delete mode 100755 templates/registro_iva/top.php delete mode 100755 templates/replace.php delete mode 100755 templates/riepilogo_interventi/bottom.php delete mode 100755 templates/riepilogo_interventi/footer.php delete mode 100755 templates/riepilogo_interventi/init.php delete mode 100755 templates/riepilogo_interventi/piece.php delete mode 100755 templates/riepilogo_interventi/top.php delete mode 100755 templates/scadenzario/bottom.php delete mode 100755 templates/scadenzario/footer.php delete mode 100755 templates/scadenzario/init.php delete mode 100755 templates/scadenzario/piece.php delete mode 100755 templates/scadenzario/settings.php delete mode 100755 templates/scadenzario/top.php delete mode 100755 templates/spesometro/body.php delete mode 100755 templates/spesometro/header.php delete mode 100755 templates/spesometro/settings.php delete mode 100755 tests/_output/.gitignore delete mode 100755 tests/_support/AcceptanceTester.php delete mode 100755 tests/_support/FunctionalTester.php delete mode 100755 tests/_support/Helper/Acceptance.php delete mode 100755 tests/_support/Helper/Common/RowHelper.php delete mode 100755 tests/_support/Helper/Functional.php delete mode 100755 tests/_support/Helper/Select2.php delete mode 100755 tests/_support/Helper/Select2Ajax.php delete mode 100755 tests/_support/Helper/Unit.php delete mode 100755 tests/_support/UnitTester.php delete mode 100755 tests/_support/_generated/.gitignore delete mode 100755 tests/acceptance.suite.yml delete mode 100755 tests/acceptance/AnagraficheCest.php delete mode 100755 tests/acceptance/BackupCest.php delete mode 100755 tests/acceptance/ContrattiCest.php delete mode 100755 tests/acceptance/DDTCest.php delete mode 100755 tests/acceptance/FattureCest.php delete mode 100755 tests/acceptance/OrdiniCest.php delete mode 100755 tests/acceptance/PreventiviCest.php delete mode 100755 tests/acceptance/_bootstrap.php delete mode 100755 tests/functional.suite.yml delete mode 100755 tests/functional/_bootstrap.php delete mode 100755 tests/unit.suite.yml delete mode 100755 tests/unit/GeneratorTest.php delete mode 100755 tests/unit/_bootstrap.php delete mode 100755 update/.htaccess delete mode 100755 update/2_0.sql delete mode 100755 update/2_1.php delete mode 100755 update/2_1.sql delete mode 100755 update/2_2.php delete mode 100755 update/2_2.sql delete mode 100755 update/2_3.php delete mode 100755 update/2_3.sql delete mode 100755 update/2_3_1.php delete mode 100755 update/2_3_1.sql delete mode 100755 update/2_4.php delete mode 100755 update/2_4.sql delete mode 100755 update/2_4_1.sql delete mode 100755 update/2_4_10.php delete mode 100755 update/2_4_10.sql delete mode 100755 update/2_4_11.php delete mode 100755 update/2_4_11.sql delete mode 100755 update/2_4_12.sql delete mode 100755 update/2_4_13.php delete mode 100755 update/2_4_13.sql delete mode 100755 update/2_4_14.php delete mode 100755 update/2_4_14.sql delete mode 100644 update/2_4_15.sql delete mode 100644 update/2_4_16.sql delete mode 100644 update/2_4_17.sql delete mode 100644 update/2_4_17_1.php delete mode 100644 update/2_4_18.php delete mode 100644 update/2_4_18.sql delete mode 100644 update/2_4_19.sql delete mode 100755 update/2_4_2.php delete mode 100755 update/2_4_2.sql delete mode 100644 update/2_4_20.php delete mode 100644 update/2_4_20.sql delete mode 100644 update/2_4_21.sql delete mode 100644 update/2_4_22.php delete mode 100644 update/2_4_22.sql delete mode 100644 update/2_4_23.php delete mode 100644 update/2_4_23.sql delete mode 100644 update/2_4_24.sql delete mode 100644 update/2_4_25.sql delete mode 100755 update/2_4_3.php delete mode 100755 update/2_4_3.sql delete mode 100755 update/2_4_4.php delete mode 100755 update/2_4_4.sql delete mode 100755 update/2_4_5.sql delete mode 100755 update/2_4_6.php delete mode 100755 update/2_4_6.sql delete mode 100755 update/2_4_7.php delete mode 100755 update/2_4_7.sql delete mode 100755 update/2_4_8.sql delete mode 100755 update/2_4_9.php delete mode 100755 update/2_4_9.sql delete mode 100755 update/api.php delete mode 100755 update/create_updates.sql delete mode 100644 update/structure.php delete mode 100755 update/tables.php delete mode 100644 update/v2_4_17/recupero_date_movimenti.php delete mode 100755 view.php create mode 100644 webpack.mix.js diff --git a/.editorconfig b/.editorconfig index 6bb235b83..1671c9b9d 100755 --- a/.editorconfig +++ b/.editorconfig @@ -1,11 +1,18 @@ -# editorconfig.org - root = true [*] charset = utf-8 end_of_line = lf -indent_size = 4 -indent_style = space insert_final_newline = true -trim_trailing_whitespace = true \ No newline at end of file +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*.{yml,yaml}] +indent_size = 2 + +[docker-compose.yml] +indent_size = 4 diff --git a/.env.example b/.env.example new file mode 100644 index 000000000..44853cd59 --- /dev/null +++ b/.env.example @@ -0,0 +1,51 @@ +APP_NAME=Laravel +APP_ENV=local +APP_KEY= +APP_DEBUG=true +APP_URL=http://localhost + +LOG_CHANNEL=stack +LOG_LEVEL=debug + +DB_CONNECTION=mysql +DB_HOST=127.0.0.1 +DB_PORT=3306 +DB_DATABASE=laravel +DB_USERNAME=root +DB_PASSWORD= + +BROADCAST_DRIVER=log +CACHE_DRIVER=file +FILESYSTEM_DRIVER=local +QUEUE_CONNECTION=sync +SESSION_DRIVER=file +SESSION_LIFETIME=120 + +MEMCACHED_HOST=127.0.0.1 + +REDIS_HOST=127.0.0.1 +REDIS_PASSWORD=null +REDIS_PORT=6379 + +MAIL_MAILER=smtp +MAIL_HOST=mailhog +MAIL_PORT=1025 +MAIL_USERNAME=null +MAIL_PASSWORD=null +MAIL_ENCRYPTION=null +MAIL_FROM_ADDRESS=null +MAIL_FROM_NAME="${APP_NAME}" + +AWS_ACCESS_KEY_ID= +AWS_SECRET_ACCESS_KEY= +AWS_DEFAULT_REGION=us-east-1 +AWS_BUCKET= +AWS_USE_PATH_STYLE_ENDPOINT=false + +PUSHER_APP_ID= +PUSHER_APP_KEY= +PUSHER_APP_SECRET= +PUSHER_APP_CLUSTER=mt1 + +MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" +MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" diff --git a/.gitattributes b/.gitattributes deleted file mode 100755 index 67483f479..000000000 --- a/.gitattributes +++ /dev/null @@ -1,191 +0,0 @@ -## GITATTRIBUTES FOR WEB PROJECTS -# -# These settings are for any web project. -# -# Details per file setting: -# text These files should be normalized (i.e. convert CRLF to LF). -# binary These files are binary and should be left untouched. -# -# Note that binary is a macro for -text -diff. -###################################################################### - -## AUTO-DETECT -## Handle line endings automatically for files detected as -## text and leave all files detected as binary untouched. -## This will handle all files NOT defined below. -* text=auto - -## SOURCE CODE -*.bat text eol=crlf -*.coffee text -*.css text -*.htm text -*.html text -*.inc text -*.ini text -*.js text -*.json text -*.jsx text -*.less text -*.od text -*.onlydata text -*.php text -*.pl text -*.py text -*.rb text -*.sass text -*.scm text -*.scss text -*.sh text eol=lf -*.sql text -*.styl text -*.tag text -*.ts text -*.tsx text -*.xml text -*.xhtml text - -## DOCKER -*.dockerignore text -Dockerfile text - -## DOCUMENTATION -*.markdown text -*.md text -*.mdwn text -*.mdown text -*.mkd text -*.mkdn text -*.mdtxt text -*.mdtext text -*.txt text -AUTHORS text -CHANGELOG text -CHANGES text -CONTRIBUTING text -COPYING text -copyright text -*COPYRIGHT* text -INSTALL text -license text -LICENSE text -NEWS text -readme text -*README* text -TODO text - -## TEMPLATES -*.dot text -*.ejs text -*.haml text -*.handlebars text -*.hbs text -*.hbt text -*.jade text -*.latte text -*.mustache text -*.njk text -*.phtml text -*.tmpl text -*.tpl text -*.twig text - -## LINTERS -.csslintrc text -.eslintrc text -.htmlhintrc text -.jscsrc text -.jshintrc text -.jshintignore text -.stylelintrc text - -## CONFIGS -*.bowerrc text -*.cnf text -*.conf text -*.config text -.browserslistrc text -.editorconfig text -.gitattributes text -.gitconfig text -.htaccess text -*.npmignore text -*.yaml text -*.yml text -browserslist text -Makefile text -makefile text - -## HEROKU -Procfile text -.slugignore text - -## GRAPHICS -*.ai binary -*.bmp binary -*.eps binary -*.gif binary -*.ico binary -*.jng binary -*.jp2 binary -*.jpg binary -*.jpeg binary -*.jpx binary -*.jxr binary -*.pdf binary -*.png binary -*.psb binary -*.psd binary -*.svg text -*.svgz binary -*.tif binary -*.tiff binary -*.wbmp binary -*.webp binary - -## AUDIO -*.kar binary -*.m4a binary -*.mid binary -*.midi binary -*.mp3 binary -*.ogg binary -*.ra binary - -## VIDEO -*.3gpp binary -*.3gp binary -*.as binary -*.asf binary -*.asx binary -*.fla binary -*.flv binary -*.m4v binary -*.mng binary -*.mov binary -*.mp4 binary -*.mpeg binary -*.mpg binary -*.ogv binary -*.swc binary -*.swf binary -*.webm binary - -## ARCHIVES -*.7z binary -*.gz binary -*.jar binary -*.rar binary -*.tar binary -*.zip binary - -## FONTS -*.ttf binary -*.eot binary -*.otf binary -*.woff binary -*.woff2 binary - -## EXECUTABLES -*.exe binary -*.pyc binary diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md deleted file mode 100755 index 46178f820..000000000 --- a/.github/CONTRIBUTING.md +++ /dev/null @@ -1,96 +0,0 @@ ---- -currentMenu: contribuire ---- - -# Contribuire - -Sei interessato a contribuire allo sviluppo di OpenSTAManger? Ottimo, sei il benvenuto! - -Siamo entusiasti di ogni nuova contribuzione che otteniamo dalla nostra community. -Ci sono molti modi per contribuire: segnalare bug, richiedere miglioramenti, scrivere tutorial, migliorare la documentazione, ... - -Non serve essere degli esperti programmatori per aiutarci! :smile_cat: - -Leggi le seguenti sezioni per scoprire come ti consigliamo di procedere. -Se ti serve un aiuto, crea una issue su GitHub. - -## Linee guida - -Per migliorare il sistema con cui sviluppiamo il codice, abbiamo deciso di adottare alcune linee guida per facilitare la collaborazione tra più persone. - - -### Standard del codice - -Per lo standard ufficiale riguardante i nomi e le strutture da utilizzare, visita la sezione [Standard](STANDARD.md). - -### Codice di condotta - -Per il momento non abbiamo adottato un vero e proprio codice di condotta, ma ti chiediamo di essere il più civile possibile nel comunicare con gli altri per questo progetto. - -### Stile del codice - -Utilizziamo principalmente due strumenti per mantenere consistente nel tempo lo stile del codice: -- [PHP CS Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer) -- [EditorConfig](https://editorconfig.org) - -PHP CS Fixer viene utilizzato per formattare automaticamente il codice PHP e aumentare la sua comprensibilità. -La configurazione può essere trovata nel file [.php_cs](https://github.com/devcode-it/openstamanager/blob/master/.php_cs). - -EditorConfig viene sfruttato per mantenere la consistenza nella formattazione di base dei diversi altri file utilizzati nel progetto. -La configurazione può essere trovata nel file [.editorconfig](https://github.com/devcode-it/openstamanager/blob/master/.editorconfig). - -Maggiori informazioni sui plugin che permettono di integrare questi strumenti sono disponibili nei relativi siti. - -## Prima contribuzione - -Sei insicuro su cosa potresti lavorare per contribuire al progetto? - -Prova a dare un'occhiata alle issue sotto la label [nuovi contributori](https://github.com/devcode-it/openstamanager/labels/nuovi%20contributori), dove sono indicate le migliorie più semplici da applicare. - -## Problemi di sicurezza - -Se trovi un problema di sicurezza, NON aprire una issue. Inviaci un'email all'indirizzo `info at openstamanager dot com`. - -Per capire se hai individuato un problema di sicurezza, prova a farti queste domande: - -* Posso accedere a qualcosa a cui non dovrei avere accesso? -* Posso disabilitare qualcosa per altre persone? - -Se la risposta a una di queste domande è positiva, allora probabilmente hai individuato un problema di sicurezza. -Considera però che anche in caso negativo potrebbe trattarsi di un problema di questo tipo, quindi se sei insicuro contattaci comunque via email. - -## Segnalare un bug - -Se hai individuato un bug e desideri segnalarlo, apri una nuova issue provando a mantenerti sulla base del [file di template su GitHub](https://github.com/devcode-it/openstamanager/blob/master/.github/ISSUE_TEMPLATE.md). - -Se vuoi suggerire una miglioramento di qualche tipo oppure una nuova funzionalità, sentiti libero di aprire una issue apposita dove spieghi dettagliatamente la modifica che vorresti, la sua utilità e il suo funzionamento generale - -## Pull Request - -Se sei in grado di risolvere uno dei bug segnalati oppure vuoi completare una nuova funzionalità, apri una nuova Pull Request provando a mantenerti sulla base del [file di template su GitHub](https://github.com/devcode-it/openstamanager/blob/master/.github/PULL_REQUEST_TEMPLATE.md). - -## Community - -Siamo presenti su [Facebook](https://www.facebook.com/openstamanager), e il nostro forum ufficiale è disponibile all'indirizzo . - -Cerchiamo di essere disponibili quanto possibile, ma non sempre riusciamo a rispondere tempestivamente. - -## Testing - -Il progetto presenta, a partire dalla versione 2.4.2, un insieme di test per facilitare il controllo sul corretto funzionamento del gestionale. - -E' innanzitutto necessario configurare correttamente l'ambiente locale per l'esecuzione dei test: -- Impostare l'URL del web server locale nel file `codeception.yml` per Codeception -```yml -modules: - config: - WebDriver: - url: http://localhost/openstamanager -``` -- Scaricare (ChromeDriver)[https://sites.google.com/a/chromium.org/chromedriver/getting-started], rendendolo eseguibile da riga di comando (su Windows, aggiungerlo al PATH) - -E' quindi possibile eseguire i tests avviando dapprima il server ChromeDriver e poi Codeception in shell differenti: -```bash -chromedriver --url-base=/wd/hub -php codecept.phar run --steps -``` diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100755 index 1a968ebf7..000000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,38 +0,0 @@ -## Comportamento richiesto - -Descrivi il comportamento che ti aspetti dal progetto. - -## Comportamento attuale - -Qual è il comportamento attuale, e come ti aspetti che venga migliorato? - -## Possibile soluzione - -[Non obbligatorio] Hai suggerimenti su come risolvere il bug o individuarne le cause? - -## Passi per riprodurre il comportamento - -[Per i bug] Descrivi dettagliatamente i singoli passi per riprodurre il malfunzionamento. - -1. -2. -3. - -Eventuale codice rilevante: -```php -Se serve, aggiungi qui il codice che vuoi farci testare -``` - -Eventuali log relativi (cartella **logs/**): -``` -Se presenti, aggiungi qui i log relativi al malfunzionamento -``` - -## Contesto - -Inserisci le informazioni riguardanti il tuo ambiente di esecuzione. Può essere utile per individuare problemi riproducibili solo con condizioni specifiche. - -* Modulo: -* Versione del progetto: -* Versione PHP: -* Tipo di server: diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100755 index 874e8c2f1..000000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,22 +0,0 @@ -## Descrizione - -Includi un sommario dei cambiamenti introdotti, con il relativo contesto. -Elenca anche le eventuali dipendenze aggiuntive richieste per questa modifica. - -Risolve: #(issue) - -## Tipologia - -Rimuovi le opzioni non rilevanti. - -- [ ] Bug fix (cambiamenti minori che risolvono una issue) -- [ ] Nuova funzionalità (cambiamenti minori che aggiungono una nuova funzionalità) -- [ ] Cambiamento maggiore (fix o funzionalità che richiede una revisione prima di essere pubblicata) -- [ ] Questo cambiamenti richiede un aggiornamento della documentazione - -# Checklist - -- [ ] Il codice segue le linee guida del progetto -- [ ] Ho commentato il codice, in particolare nelle parti più complesse -- [ ] Ho aggiornato di conseguenza la documentazione (se presente) -- [ ] Il codice non genera warnings diff --git a/.github/STANDARD.md b/.github/STANDARD.md deleted file mode 100755 index b3d475ee9..000000000 --- a/.github/STANDARD.md +++ /dev/null @@ -1,28 +0,0 @@ -# Standard del codice - -Lo standard prevede l'utilizzo di nomi in italiano per la maggior parte dei contenuti, esclusi i sistemi di gestione interna del gestionale (tabelle `zz_*` e codici particolarmente rilevanti). - -I nomi delle variabili devono seguire uno standard comune, che prevede la sostituzione degli spazi con `_` (*underscore*) e la rimozione delle lettere accentate a favore di quelle semplici. - -Le variabili devono possedere nomi completi e chiari. -Esempio: - - Partita IVA -> `partita_iva` nel database, `$partita_iva` in PHP - -## Database - -Gli identificatori devono iniziare per `id_*` e i flag per `is_*`. -E' fondamentale ricordarsi di impostare correttamente le **FOREIGN KEYS** delle relative tabelle. - -Ci sono inoltre alcuni campi utilizzati in modo riccorrente all'interno del gestionale: - - `default boolean NOT NULL DEFAULT 0` per i valori di default, non cancellabili e con modificabilità limitata - - `predefined boolean NOT NULL DEFAULT 0` per i valori predefiniti in selezioni o gruppi - - `visible boolean NOT NULL DEFAULT 1` per nascondere gli elementi - - `deleted_at timestamp NULL DEFAULT NULL,` per segnare un elemento come eliminato - -Per tabelle non presenti all'interno della lista ufficiale di OpenSTAManager (file **update/tables.php**), è necessario inoltre provvedere all'aggiunta dei seguenti campi: - - `updated_at timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP` - - `created_at timestamp NULL DEFAULT CURRENT_TIMESTAMP` - -## Note - -Malgrado una buona parte del codice ufficiale non segua completamente queste buone pratiche, è consigliato l'implementazione di queste linee guida per nuove funzioni e strutture mentre il sistema di base viene lentamente standardizzato. diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 1d889ccb0..000000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,129 +0,0 @@ -name: OpenSTAManager CI - -on: - workflow_dispatch - -jobs: - tests: - runs-on: ubuntu-18.04 - - strategy: - matrix: - python-version: [3.9] - php-version: ['7.4'] - - steps: - - uses: actions/checkout@v2 - -# - name: Set up PHP ${{ matrix.php-version }} -# uses: shivammathur/setup-php@v2 -# with: -# php-version: ${{ matrix.php-version }} -# extensions: zip, mbstring, pdo_mysql, mysql, dom, xsl, openssl, intl, curl, soap, gd - - - name: Setup PHP - run: | - sudo apt install libapache2-mod-php7.4 - sudo sed -i 's,^post_max_size =.*$,post_max_size = 32M,' /etc/php/7.4/apache2/php.ini - sudo sed -i 's,^upload_max_filesize =.*$,upload_max_filesize = 32M,' /etc/php/7.4/apache2/php.ini - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - - name: Install SeleniumBase - uses: actions/checkout@v2 - with: - repository: seleniumbase/SeleniumBase - path: selenium-base - - - name: Configure SeleniumBase - run: | - cd selenium-base - python setup.py install - - - name: Install Chrome and Firefox - run: | - sudo apt install google-chrome-stable - sudo apt-get install firefox - - - name: Check the console scripts interface - run: | - seleniumbase - sbase - - - name: Install chromedriver and geckodriver (Firefox Webdriver) - run: | - seleniumbase install chromedriver - seleniumbase install geckodriver - - - name: Make sure pytest is working - run: | - echo "def test_1(): pass" > nothing.py - pytest nothing.py - - - name: Make sure nosetests is working - run: | - echo "def test_2(): pass" > nothing2.py - nosetests nothing2.py - - - name: Cache Composer packages - id: composer-cache - uses: actions/cache@v2 - with: - path: vendor - key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-php- - - - name: Install Composer dependencies - run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist - - - name: Use NPM and Node.js - uses: actions/setup-node@v2 - with: - node-version: '14' - - name: Install NPM and compile assets - run: | - yarn install - npm run build-OSM - - - - name: Copy OSM to www root - run: | - sudo cp -R /home/runner/work/openstamanager/openstamanager /var/www/html/ - sudo chmod -R 0777 /var/www/html/openstamanager - sudo rm /var/www/html/openstamanager/.htaccess - - - name: Check out test repository - uses: actions/checkout@v2 - with: - repository: devcode-it/openstamanager-tests - path: python-tests - - - name: Install Python dependencies - run: | - cd python-tests/ - python -m pip install --upgrade pip - python -m pip install pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - - name: Restart apache - run: sudo service apache2 restart - - - name: Restart MySQL - run: sudo service mysql restart - - - name: Init test configuration - run: | - curl http://localhost/openstamanager/ - sudo cat /var/log/apache2/access.log - cd python-tests/ - echo -ne "{\n \"login\": {\n \"password\": \"adminadmin\",\n \"username\": \"admin\"\n },\n \"database\": {\n \"host\": \"localhost\",\n \"user\": \"root\",\n \"pass\": \"root\",\n \"name\": \"osm\"\n },\n \"server\": \"http://localhost/openstamanager/\",\n \"browser\": \"firefox\",\n \"headless\": true\n}" > config.json - pytest Init.py - - - name: Execute tests - run: | - cd python-tests/ - pytest tests diff --git a/.gitignore b/.gitignore index a805acbe6..0d51056de 100755 --- a/.gitignore +++ b/.gitignore @@ -1,100 +1,163 @@ -# Compiled source # -################### -*.com -*.class -*.dll -*.exe -*.o -*.so -*.pyo -*.pyc +/.vscode -# Packages # -############ -*.7z -*.dmg -*.gz -*.iso -*.jar -*.rar -*.tar -*.zip +# Created by https://www.toptal.com/developers/gitignore/api/phpstorm,laravel,composer,yarn +# Edit at https://www.toptal.com/developers/gitignore?templates=phpstorm,laravel,composer,yarn -# Logs and databases # -###################### -*.log -*.sqlite +### Composer ### +composer.phar +/vendor/ -# Mixed # -###################### -*~ -._* -.cache -.DS_Store -.DS_Store? -.idea -.project -.settings -.tmproj -*.esproj -*.sublime-project -*.sublime-workspace -nbproject -Thumbs.db -ehthumbs.db -ehthumbs_vista.db -$RECYCLE.BIN -desktop.ini -Desktop.ini -.Spotlight-V100 -.Trashes -.fuse_hidden* -.directory -.Trash-* -.nfs* -*.cab -*.msi -*.msm -*.msp -*.lnk -.vscode/* +# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control +# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file +# composer.lock -# Npm, Bower, Composer # -###################### -bower_components/ +### Laravel ### node_modules/ -vendor/ -*.phar -*.lock -package-lock.json +npm-debug.log +yarn-error.log -# Project # -###################### -*.new -*.old -*.txt -assets/dist/ -backup/* -!backup/.htaccess -custom/ -files/* -!files/.htaccess -!files/impianti/ -files/impianti/* -!files/impianti/componente.ini -!files/temp/ -files/temp/* -tmp/ -config.inc.php -database.sql -VERSION -REVISION -.php_cs.cache -manifest.json -checksum.json -database.json +# Laravel 4 specific +bootstrap/compiled.php +app/storage/ + +# Laravel 5 & Lumen specific +public/storage +public/hot + +# Laravel 5 & Lumen specific with changed public path +public_html/storage +public_html/hot + +storage/*.key +.env +.env.backup +Homestead.yaml +Homestead.json +/.vagrant +.phpunit.result.cache +docker-compose.override.yml + +### PhpStorm ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### PhpStorm Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +### yarn ### +# https://yarnpkg.com/advanced/qa#which-files-should-be-gitignored + +.yarn/* +!.yarn/releases +!.yarn/plugins +!.yarn/sdks +!.yarn/versions + +# if you are NOT using Zero-installs, then: +# comment the following lines +!.yarn/cache + +# and uncomment the following lines +# .pnp.* + +# End of https://www.toptal.com/developers/gitignore/api/phpstorm,laravel,composer,yarn -/tests/_log/* -/tests/_temp/* -codeception.yml -!.gitkeep diff --git a/.styleci.yml b/.styleci.yml new file mode 100644 index 000000000..9231873a1 --- /dev/null +++ b/.styleci.yml @@ -0,0 +1,13 @@ +php: + preset: laravel + disabled: + - no_unused_imports + finder: + not-name: + - index.php + - server.php +js: + finder: + not-name: + - webpack.mix.js +css: true diff --git a/actions.php b/actions.php deleted file mode 100755 index cca727e2a..000000000 --- a/actions.php +++ /dev/null @@ -1,429 +0,0 @@ -. - */ - -include_once __DIR__.'/core.php'; - -use Models\Note; -use Models\OperationLog; -use Models\Upload; -use Modules\Checklists\Check; -use Modules\Checklists\Checklist; -use Modules\Emails\Template; -use Notifications\EmailNotification; - -if (empty($structure) || empty($structure['enabled'])) { - exit(tr('Accesso negato')); -} - -$upload_dir = base_dir().'/'.Uploads::getDirectory($id_module, $id_plugin); - -$database->beginTransaction(); - -// Upload allegati e rimozione -if (filter('op') == 'aggiungi-allegato' || filter('op') == 'rimuovi-allegato') { - // Controllo sui permessi di scrittura per il modulo - if (Modules::getPermission($id_module) != 'rw') { - flash()->error(tr('Non hai permessi di scrittura per il modulo _MODULE_', [ - '_MODULE_' => '"'.Modules::get($id_module)['name'].'"', - ])); - } - - // Controllo sui permessi di scrittura per il file system - elseif (!directory($upload_dir)) { - flash()->error(tr('Non hai i permessi di scrittura nella cartella _DIR_!', [ - '_DIR_' => '"files"', - ])); - } - - // Gestione delle operazioni - else { - // UPLOAD - if (filter('op') == 'aggiungi-allegato' && !empty($_FILES) && !empty($_FILES['file']['name'])) { - $upload = Uploads::upload($_FILES['file'], [ - 'name' => filter('nome_allegato'), - 'category' => filter('categoria'), - 'id_module' => $id_module, - 'id_plugin' => $id_plugin, - 'id_record' => $id_record, - ]); - - // Creazione file fisico - if (!empty($upload)) { - flash()->info(tr('File caricato correttamente!')); - } else { - flash()->error(tr('Errore durante il caricamento del file!')); - } - } - - // DELETE - elseif (filter('op') == 'rimuovi-allegato' && filter('filename') !== null) { - $name = Uploads::delete(filter('filename'), [ - 'id_module' => $id_module, - 'id_plugin' => $id_plugin, - 'id_record' => $id_record, - ]); - - if (!empty($name)) { - flash()->info(tr('File _FILE_ eliminato!', [ - '_FILE_' => '"'.$name.'"', - ])); - } else { - flash()->error(tr("Errore durante l'eliminazione del file!")); - } - } - - redirect(base_path().'/editor.php?id_module='.$id_module.'&id_record='.$id_record.((!empty($options['id_plugin'])) ? '#tab_'.$options['id_plugin'] : '')); - } -} - -// Download allegati -elseif (filter('op') == 'download-allegato') { - $rs = $dbo->fetchArray('SELECT * FROM zz_files WHERE id_module='.prepare($id_module).' AND id='.prepare(filter('id')).' AND filename='.prepare(filter('filename'))); - - download($upload_dir.'/'.$rs[0]['filename'], $rs[0]['original']); -} elseif (filter('op') == 'visualizza-modifica-allegato') { - include_once base_dir().'/include/modifica_allegato.php'; -} - -// Modifica dati di un allegato -elseif (filter('op') == 'modifica-allegato') { - $id_allegato = filter('id_allegato'); - $allegato = Upload::find($id_allegato); - - $allegato->name = post('nome_allegato'); - $allegato->category = post('categoria_allegato'); - - $allegato->save(); -} - -// Modifica nome della categoria degli allegati -elseif (filter('op') == 'modifica-categoria-allegato') { - $category = post('category'); - $name = post('name'); - - $uploads = $structure->uploads($id_record)->where('category', $category); - foreach ($uploads as $upload) { - $upload->category = $name; - $upload->save(); - } -} - -// Validazione dati -elseif (filter('op') == 'validate') { - // Lettura informazioni di base - $init = $structure->filepath('init.php'); - if (!empty($init)) { - include_once $init; - } - - // Validazione del campo - $validation = $structure->filepath('validation.php'); - if (!empty($validation)) { - include_once $validation; - } - - echo json_encode($response); - - return; -} - -// Aggiunta nota interna -elseif (filter('op') == 'aggiungi-nota') { - $contenuto = post('contenuto'); - $data_notifica = post('data_notifica') ?: null; - - $nota = Note::build($user, $structure, $id_record, $contenuto, $data_notifica); - - flash()->info(tr('Nota interna aggiunta correttamente!')); -} - -// Rimozione data di notifica dalla nota interna -elseif (filter('op') == 'rimuovi-notifica-nota') { - $id_nota = post('id_nota'); - $nota = Note::find($id_nota); - - $nota->notification_date = null; - $nota->save(); - - flash()->info(tr('Data di notifica rimossa dalla nota interna!')); -} - -// Rimozione nota interna -elseif (filter('op') == 'rimuovi-nota') { - $id_nota = post('id_nota'); - $nota = Note::find($id_nota); - - $nota->delete(); - - flash()->info(tr('Nota interna aggiunta correttamente!')); -} - -// Clonazione di una checklist -elseif (filter('op') == 'copia-checklist') { - $content = post('content'); - $checklist_id = post('checklist'); - - $users = post('assigned_users'); - $users = array_clean($users); - - $group_id = post('group_id'); - - $checklist = Checklist::find($checklist_id); - $checklist->copia($user, $id_record, $users, $group_id); -} - -// Aggiunta check alla checklist -elseif (filter('op') == 'aggiungi-check') { - $content = post('content'); - $parent_id = post('parent') ?: null; - - $users = post('assigned_users'); - $users = array_clean($users); - - $group_id = post('group_id'); - - $check = Check::build($user, $structure, $id_record, $content, $parent_id); - $check->setAccess($users, $group_id); -} - -// Rimozione di un check della checklist -elseif (filter('op') == 'rimuovi-check') { - $check_id = post('check_id'); - $check = Check::find($check_id); - - if (!empty($check) && $check->user->id == $user->id) { - $check->delete(); - } else { - flash()->error(tr('Impossibile eliminare il check!')); - } -} - -// Gestione check per le checklist -elseif (filter('op') == 'toggle-check') { - $check_id = post('check_id'); - $check = Check::find($check_id); - - if (!empty($check) && $check->assignedUsers->pluck('id')->search($user->id) !== false) { - $check->toggleCheck($user); - } else { - flash()->error(tr('Impossibile cambiare lo stato del check!')); - } -} - -// Gestione ordine per le checklist -elseif (filter('op') == 'ordina-checks') { - $ids = explode(',', $_POST['order']); - $order = 0; - - foreach ($ids as $id) { - $dbo->query('UPDATE `zz_checks` SET `order` = '.prepare($order).' WHERE id = '.prepare($id)); - ++$order; - } -} - -// Inizializzazione email -elseif (post('op') == 'send-email') { - $template = Template::find(post('template')); - - $mail = \Modules\Emails\Mail::build($user, $template, $id_record); - - // Rimozione allegati predefiniti - $mail->resetPrints(); - - // Destinatari - $receivers = array_clean(post('destinatari')); - $types = post('tipo_destinatari'); - foreach ($receivers as $key => $receiver) { - $mail->addReceiver($receiver, $types[$key]); - } - - // Contenuti - $mail->subject = post('subject'); - $mail->content = post('body'); - - // Conferma di lettura - $mail->read_notify = post('read_notify'); - - // Stampe da allegare - $prints = post('prints'); - foreach ($prints as $print) { - $mail->addPrint($print); - } - - // Allegati originali - $files = post('uploads'); - foreach ($files as $file) { - $mail->addUpload($file); - } - - // Salvataggio email nella coda di invio - $mail->save(); - - // Invio mail istantaneo - $email = EmailNotification::build($mail); - $email_success = $email->send(); - - if ($email_success) { - OperationLog::setInfo('id_email', $mail->id); - flash()->info(tr('Email inviata correttamente!')); - } else { - $mail->delete(); - flash()->error(tr('Errore durante l\'invio email! Verifica i parametri dell\'account SMTP utilizzato.')); - } -} elseif (filter('op') == 'aggiorna_colonne') { - include_once base_dir().'/include/colonne.php'; -} elseif (filter('op') == 'toggle_colonna') { - $visible = filter('visible'); - $id_riga = filter('id_vista'); - - $dbo->query('UPDATE `zz_views` SET `visible` = '.prepare($visible).' WHERE id = '.prepare($id_riga)); -} elseif (filter('op') == 'ordina_colonne') { - $order = explode(',', post('order', true)); - - foreach ($order as $i => $id_riga) { - $dbo->query('UPDATE `zz_views` SET `order` = '.prepare($i).' WHERE id='.prepare($id_riga)); - } -} elseif (filter('op') == 'visualizza_righe_riferimenti') { - include_once base_dir().'/include/riferimenti/riferimenti.php'; -} elseif (filter('op') == 'visualizza_righe_documento') { - include_once base_dir().'/include/riferimenti/righe_documento.php'; -} elseif (filter('op') == 'salva_riferimento_riga') { - $database->insert('co_riferimenti_righe', [ - 'source_type' => filter('source_type'), - 'source_id' => filter('source_id'), - 'target_type' => filter('target_type'), - 'target_id' => filter('target_id'), - ]); -} elseif (filter('op') == 'rimuovi_riferimento_riga') { - $database->delete('co_riferimenti_righe', [ - 'id' => filter('idriferimento'), - ]); -} - -// Inclusione di eventuale plugin personalizzato -if (!empty($structure['script'])) { - $path = $structure->getEditFile(); - if (!empty($path)) { - include $path; - } - - $database->commitTransaction(); - - return; -} - -// Lettura risultato query del modulo -$init = $structure->filepath('init.php'); -if (!empty($init)) { - include_once $init; -} - -// Retrocompatibilità -if (!isset($record) && isset($records[0])) { - $record = $records[0]; -} elseif (!isset($records[0]) && isset($record)) { - $records = [$record]; -} elseif (!isset($record)) { - $record = []; - $records = [$record]; -} - -// Registrazione del record -HTMLBuilder\HTMLBuilder::setRecord($record); - -if ($structure->permission == 'rw') { - // Esecuzione delle operazioni di gruppo - $id_records = post('id_records'); - $id_records = is_array($id_records) ? $id_records : explode(';', $id_records); - $id_records = array_clean($id_records); - $id_records = array_unique($id_records); - - $bulk = $structure->filepath('bulk.php'); - $bulk = empty($bulk) ? [] : include $bulk; - $bulk = empty($bulk) ? [] : $bulk; - - if (in_array(post('op'), array_keys($bulk))) { - redirect(base_path().'/controller.php?id_module='.$id_module, 'js'); - } else { - // Esecuzione delle operazioni del modulo - ($include_file = $structure->filepath('actions.php')) ? include $include_file : null; - - // Operazioni generiche per i campi personalizzati - if (post('op') != null) { - $custom_where = !empty($id_plugin) ? '`id_plugin` = '.prepare($id_plugin) : '`id_module` = '.prepare($id_module); - - $query = 'SELECT `id`, `html_name` AS `name` FROM `zz_fields` WHERE '.$custom_where; - $customs = $dbo->fetchArray($query); - - if (!string_starts_with(post('op'), 'delete')) { - $values = []; - foreach ($customs as $custom) { - if (post($custom['name']) !== null) { - $values[$custom['id']] = post($custom['name']); - } - } - - // Inserimento iniziale - if (string_starts_with(post('op'), 'add')) { - // Informazioni di log - Filter::set('get', 'id_record', $id_record); - - foreach ($values as $key => $value) { - $dbo->insert('zz_field_record', [ - 'id_record' => $id_record, - 'id_field' => $key, - 'value' => $value, - ]); - } - } - - // Aggiornamento - elseif (string_starts_with(post('op'), 'update')) { - $query = 'SELECT `zz_field_record`.`id_field` FROM `zz_field_record` JOIN `zz_fields` ON `zz_fields`.`id` = `zz_field_record`.`id_field` WHERE id_record = '.prepare($id_record).' AND '.$custom_where; - $customs_present = $dbo->fetchArray($query); - $customs_present = array_column($customs_present, 'id_field'); - - foreach ($values as $key => $value) { - if (in_array($key, $customs_present)) { - $dbo->update('zz_field_record', [ - 'value' => $value, - ], [ - 'id_record' => $id_record, - 'id_field' => $key, - ]); - } else { - $dbo->insert('zz_field_record', [ - 'id_record' => $id_record, - 'id_field' => $key, - 'value' => $value, - ]); - } - } - } - } - - // Eliminazione - elseif (!empty($customs)) { - $dbo->query('DELETE FROM `zz_field_record` WHERE `id_record` = '.prepare($id_record).' AND `id_field` IN ('.implode(',', array_column($customs, 'id')).')'); - } - } - } -} - -$database->commitTransaction(); diff --git a/add.php b/add.php deleted file mode 100755 index e946ce2ba..000000000 --- a/add.php +++ /dev/null @@ -1,105 +0,0 @@ -. - */ - -include_once __DIR__.'/core.php'; - -// Inclusione elementi fondamentali del modulo -include base_dir().'/actions.php'; - -// Controllo dei permessi -if (empty($id_plugin)) { - Permissions::check('rw'); -} - -// Caricamento template -echo ' -
-'; - -include !empty(get('edit')) ? $structure->getEditFile() : $structure->getAddFile(); - -echo ' -
'; - -// Campi personalizzati -echo ' - -
- - - - {( "name": "custom_fields", "id_module": "'.$id_module.'", "id_plugin": "'.$id_plugin.'", "position": "top", "place": "add" )} -
- -
- {( "name": "custom_fields", "id_module": "'.$id_module.'", "id_plugin": "'.$id_plugin.'", "position": "bottom", "place": "add" )} -
- -'; - -if (isAjaxRequest()) { - echo ' -'; -} - -echo ' -'; diff --git a/ajax.php b/ajax.php deleted file mode 100755 index 8b82006f8..000000000 --- a/ajax.php +++ /dev/null @@ -1,171 +0,0 @@ -. - */ - -include_once __DIR__.'/core.php'; - -use Models\Hook; - -switch (filter('op')) { - // Imposta un valore ad un array di $_SESSION - // esempio: push di un valore in $_SESSION['dashboard']['idtecnici'] - // iversed: specifica se rimuovere dall'array il valore trovato e applicare quindi una deselezione (valori 0 o 1, default 1) - case 'session_set_array': - $array = explode(',', get('session')); - $value = "'".get('value')."'"; - $inversed = get('inversed'); - - $found = false; - - // Ricerca valore nell'array - foreach ($_SESSION[$array[0]][$array[1]] as $idx => $val) { - // Se il valore esiste lo tolgo - if ($val == $value) { - $found = true; - - if ((int) $inversed == 1) { - unset($_SESSION[$array[0]][$array[1]][$idx]); - } - } - } - - if (!$found) { - array_push($_SESSION[$array[0]][$array[1]], $value); - } - - // print_r($_SESSION[$array[0]][$array[1]]); - - break; - - // Imposta un valore ad una sessione - case 'session_set': - $array = explode(',', get('session')); - $value = get('value'); - $clear = get('clear'); - - if ($clear == 1 || $value == '') { - unset($_SESSION[$array[0]][$array[1]]); - } else { - $_SESSION[$array[0]][$array[1]] = $value; - } - - break; - - case 'list_attachments': - echo '{( "name": "filelist_and_upload", "id_module": "'.$id_module.'", "id_record": "'.$id_record.'", "id_plugin": "'.$id_plugin.'" )}'; - - break; - - case 'checklists': - include base_dir().'/plugins/checks.php'; - - break; - - case 'active_users': - $posizione = get('id_module'); - if (isset($id_record)) { - $posizione .= ', '.get('id_record'); - } - - $user = Auth::user(); - $interval = setting('Timeout notifica di presenza (minuti)') * 60 * 2; - - $dbo->query('UPDATE zz_semaphores SET updated = NOW() WHERE id_utente = :user_id AND posizione = :position', [ - ':user_id' => $user['id'], - ':position' => $posizione, - ]); - - // Rimozione record scaduti - $dbo->query('DELETE FROM zz_semaphores WHERE DATE_ADD(updated, INTERVAL :interval SECOND) <= NOW()', [ - ':interval' => $interval, - ]); - - $datas = $dbo->fetchArray('SELECT DISTINCT username FROM zz_semaphores INNER JOIN zz_users ON zz_semaphores.id_utente=zz_users.id WHERE zz_semaphores.id_utente != :user_id AND posizione = :position', [ - ':user_id' => $user['id'], - ':position' => $posizione, - ]); - - echo json_encode($datas); - - break; - - case 'hooks': - $hooks = Hook::all(); - - $results = []; - foreach ($hooks as $hook) { - if ($hook->permission != '-') { - $results[] = [ - 'id' => $hook->id, - 'name' => $hook->name, - ]; - } - } - - echo json_encode($results); - - break; - - case 'hook-lock': - $hook_id = filter('id'); - $hook = Hook::find($hook_id); - - $token = $hook->lock(); - - echo json_encode($token); - - break; - - case 'hook-execute': - $hook_id = filter('id'); - $token = filter('token'); - $hook = Hook::find($hook_id); - - $response = $hook->execute($token); - - echo json_encode($response); - - break; - - case 'hook-response': - $hook_id = filter('id'); - $hook = Hook::find($hook_id); - - $response = $hook->response(); - - echo json_encode($response); - - break; - - case 'flash': - $response = flash()->getMessages(); - - echo json_encode($response); - - break; - - case 'summable-results': - $ids = post('ids') ?: []; - $results = Util\Query::getSums($structure, [ - 'id' => $ids, - ]); - - echo json_encode($results); - - break; -} diff --git a/ajax_complete.php b/ajax_complete.php deleted file mode 100755 index f7eaad063..000000000 --- a/ajax_complete.php +++ /dev/null @@ -1,33 +0,0 @@ -. - */ - -include_once __DIR__.'/core.php'; - -if (!isset($resource)) { - $module = get('module'); - $op = get('op'); - - $result = AJAX::complete($op); - - echo $result; -} - -// Casi particolari -else { -} diff --git a/ajax_dataload.php b/ajax_dataload.php deleted file mode 100755 index bda5e6f45..000000000 --- a/ajax_dataload.php +++ /dev/null @@ -1,204 +0,0 @@ -. - */ - -include_once __DIR__.'/core.php'; - -use Util\Query; - -// Informazioni fondamentali -$columns = (array) filter('columns'); -$order = filter('order') ? filter('order')[0] : []; -$draw_numer = intval(filter('draw')); - -if (!empty(filter('order'))) { - $order['column'] = $order['column'] - 1; -} -array_shift($columns); - -$total = Util\Query::readQuery($structure); - -// Ricerca -$search = []; -for ($i = 0; $i < count($columns); ++$i) { - if (!empty($columns[$i]['search']['value']) || $columns[$i]['search']['value'] == '0') { - $search[$total['fields'][$i]] = $columns[$i]['search']['value']; - } -} - -$limit = [ - 'start' => filter('start'), - 'length' => filter('length'), -]; - -// Predisposizione della risposta -$results = [ - 'data' => [], - 'recordsTotal' => 0, - 'recordsFiltered' => 0, - 'summable' => [], - 'draw' => $draw_numer, -]; - -$query = Query::getQuery($structure); -if (!empty($query)) { - // CONTEGGIO TOTALE - $results['recordsTotal'] = $dbo->fetchNum($query); - - // RISULTATI VISIBILI - $query = Query::getQuery($structure, $search, $order, $limit); - - // Filtri derivanti dai permessi (eventuali) - if (empty($id_plugin)) { - $query = Modules::replaceAdditionals($id_module, $query); - } - - // Conteggio dei record filtrati - $data = Query::executeAndCount($query); - $rows = $data['results']; - $results['recordsFiltered'] = $data['count']; - - // SOMME - $results['summable'] = Util\Query::getSums($structure, $search); - - // Allineamento delle righe - $align = []; - $row = isset($rows[0]) ? $rows[0] : []; - foreach ($row as $field => $value) { - $value = trim($value); - - // Allineamento a destra se il valore della prima riga risulta numerica - if (is_numeric($value) && formatter()->isStandardNumber($value)) { - $align[$field] = 'text-right'; - } - - // Allineamento al centro se il valore della prima riga risulta relativo a date o icone - elseif (formatter()->isStandardDate($value) || preg_match('/^icon_(.+?)$/', $field)) { - $align[$field] = 'text-center'; - } - } - - // Creazione della tabella - foreach ($rows as $i => $r) { - // Evitare risultati con ID a null - // Codice non applicabile in ogni caso: sulla base dei permessi, ID può non essere impostato - /* - if (empty($r['id'])) { - continue; - }*/ - - $result = [ - 'id' => $r['id'], - '', // Colonna ID - ]; - - foreach ($total['fields'] as $pos => $field) { - $column = []; - - if (!empty($r['_bg_'])) { - $column['data-background'] = $r['_bg_']; - } - - // Allineamento - if (!empty($align[$field])) { - $column['class'] = $align[$field]; - } - - $value = trim($r[$field]); - - // Formattazione automatica - if (!empty($total['format'][$pos]) && !empty($value)) { - if (formatter()->isStandardTimestamp($value)) { - $value = Translator::timestampToLocale($value); - } elseif (formatter()->isStandardDate($value)) { - $value = Translator::dateToLocale($value); - } elseif (formatter()->isStandardTime($value)) { - $value = Translator::timeToLocale($value); - } elseif (formatter()->isStandardNumber($value)) { - $value = Translator::numberToLocale($value); - } - } - - // Icona - if (preg_match('/^color_(.+?)$/', $field, $m)) { - $value = isset($r['color_title_'.$m[1]]) ? $r['color_title_'.$m[1]] : ''; - - $column['class'] = 'text-center small'; - $column['data-background'] = $r[$field]; - } - - // Icona di stampa - elseif ($field == '_print_') { - $print = $r['_print_']; - - $print_url = Prints::getHref($print, $r['id']); - - $value = ''; - } - - // Icona - elseif (preg_match('/^icon_(.+?)$/', trim($field), $m)) { - $value = ' '.$r['icon_title_'.$m[1]].''; - } - - // Colore del testo - if (!empty($column['data-background'])) { - $column['data-color'] = isset($column['data-color']) ? $column['data-color'] : color_inverse(trim($column['data-background'])); - } - - // Link della colonna - if ($field != '_print_') { - $id_record = $r['id']; - $hash = ''; - - $id_module = !empty($r['_link_module_']) ? $r['_link_module_'] : $id_module; - if (!empty($r['_link_record_'])) { - $id_record = $r['_link_record_']; - $hash = !empty($r['_link_hash_']) ? '#'.$r['_link_hash_'] : ''; - unset($id_plugin); - } - - // Link per i moduli - if (empty($id_plugin)) { - $column['data-link'] = base_path().'/editor.php?id_module='.$id_module.'&id_record='.$id_record.$hash; - } - // Link per i plugin - else { - $column['data-link'] = base_path().'/add.php?id_module='.$id_module.'&id_record='.$id_record.'&id_plugin='.$id_plugin.'&id_parent='.$id_parent.'&edit=1'.$hash; - - $column['data-type'] = 'dialog'; - } - } - - $attributes = []; - foreach ($column as $key => $val) { - $val = is_array($val) ? implode(' ', $val) : $val; - $attributes[] = $key.'="'.$val.'"'; - } - - // Replace base_link() per le query - $value = str_replace('base_link()', base_path(), $value); - $result[] = str_replace('|attr|', implode(' ', $attributes), '
'.$value.'
'); - } - - $results['data'][] = $result; - } -} - -$json = json_encode($results); -echo $json; diff --git a/ajax_search.php b/ajax_search.php deleted file mode 100755 index 2858b8221..000000000 --- a/ajax_search.php +++ /dev/null @@ -1,39 +0,0 @@ -. - */ - -include_once __DIR__.'/core.php'; - -if (!isset($term)) { - /* - == Super search == - Ricerca di un termine su tutti i moduli. - Il risultato è in json - */ - - $term = get('term'); - $term = str_replace('/', '\\/', $term); - - $results = AJAX::search($term); - - echo json_encode($results); -} - -// Casi particolari -else { -} diff --git a/ajax_select.php b/ajax_select.php deleted file mode 100755 index 03932f48c..000000000 --- a/ajax_select.php +++ /dev/null @@ -1,46 +0,0 @@ -. - */ - -include_once __DIR__.'/core.php'; - -if (!isset($resource)) { - $op = empty($op) ? filter('op') : $op; - $search = filter('search'); - $page = filter('page') ?: 0; - $length = filter('length') ?: 100; - - // Opzioni di selezione sugli elementi - $options = filter('options') ?: []; - $options_compatibility = session_get('superselect', []); - $options = array_merge($options_compatibility, $options); - - // Preselezione su $elements dichiarato da file precedente - if (!isset($elements)) { - $elements = []; - } - $elements = (!is_array($elements)) ? explode(',', $elements) : $elements; - - $results = AJAX::select($op, $elements, $search, $page, $length, $options); - - echo json_encode($results); -} - -// Casi particolari -else { -} diff --git a/api/index.php b/api/index.php deleted file mode 100755 index fd5ef0b00..000000000 --- a/api/index.php +++ /dev/null @@ -1,69 +0,0 @@ -. - */ - -use API\Response; - -function serverError() -{ - $error = error_get_last(); - if ($error['type'] == E_ERROR) { - ob_end_clean(); - echo Response::error('serverError'); - } -} - -// Gestione degli errori -set_error_handler('serverError'); -register_shutdown_function('serverError'); - -include_once __DIR__.'/../core.php'; - -// Disabilita la sessione per l'API -session_write_close(); - -// Permesso di accesso all'API da ogni dispositivo -header('Access-Control-Allow-Origin: *'); -header('Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS'); - -try { - $response = Response::manage(); -} catch (Exception $e) { - // Log dell'errore - $logger = logger(); - $logger->addRecord(\Monolog\Logger::ERROR, $e); - - $response = Response::error('serverError'); -} - -// Richiesta OPTIONS (controllo da parte del dispositivo) -if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') { - $response = Response::error('ok'); -} - -json_decode($response); - -// Impostazioni di Content-Type e Charset Header -if (json_last_error() == JSON_ERROR_NONE) { - header('Content-Type: application/json; charset=UTF-8'); -} else { - header('Content-Type: text/plain; charset=UTF-8'); -} - -// Stampa dei risultati -echo $response; diff --git a/artisan b/artisan new file mode 100644 index 000000000..67a3329b1 --- /dev/null +++ b/artisan @@ -0,0 +1,53 @@ +#!/usr/bin/env php +make(Illuminate\Contracts\Console\Kernel::class); + +$status = $kernel->handle( + $input = new Symfony\Component\Console\Input\ArgvInput, + new Symfony\Component\Console\Output\ConsoleOutput +); + +/* +|-------------------------------------------------------------------------- +| Shutdown The Application +|-------------------------------------------------------------------------- +| +| Once Artisan has finished running, we will fire off the shutdown events +| so that any final work may be done by the application before we shut +| down the process. This is the last thing to happen to the request. +| +*/ + +$kernel->terminate($input, $status); + +exit($status); diff --git a/assets/src/css/datatables.css b/assets/src/css/datatables.css deleted file mode 100755 index 277a89911..000000000 --- a/assets/src/css/datatables.css +++ /dev/null @@ -1,239 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/*! - * DataTables + Font Awesome integration - * License: MIT - http://datatables.net/license - */ - - -/* - * Sort styling - */ - -table.dataTable thead th { - position: relative; - background-image: none !important; - /* Remove the DataTables bootstrap integration styling */ -} - -table.dataTable thead th.sorting:after, -table.dataTable thead th.sorting_asc:after, -table.dataTable thead th.sorting_desc:after { - position: absolute; - top: 12px; - right: 8px; - display: block; - font-family: FontAwesome; -} - -table.dataTable thead th.sorting:after { - content: "\f0dc"; - color: #ddd; - font-size: 0.8em; - padding-top: 0.12em; -} - -table.dataTable thead th.sorting_asc:after { - content: "\f0de"; -} - -table.dataTable thead th.sorting_desc:after { - content: "\f0dd"; -} - -div.dataTables_scrollBody table.dataTable thead th.sorting:after, -div.dataTables_scrollBody table.dataTable thead th.sorting_asc:after, -div.dataTables_scrollBody table.dataTable thead th.sorting_desc:after { - content: ""; -} - - -/* In Bootstrap and Foundation the padding top is a little different from the DataTables stylesheet */ - -table.table thead th.sorting:after, -table.table thead th.sorting_asc:after, -table.table thead th.sorting_desc:after { - top: 8px; -} - - -/* - * DataTables style pagination controls - */ - -div.dataTables_paginate a.paginate_button.first, -div.dataTables_paginate a.paginate_button.previous { - position: relative; - padding-left: 24px; -} - -div.dataTables_paginate a.paginate_button.next, -div.dataTables_paginate a.paginate_button.last { - position: relative; - padding-right: 24px; -} - -div.dataTables_paginate a.first:before, -div.dataTables_paginate a.previous:before { - position: absolute; - top: 8px; - left: 10px; - display: block; - font-family: FontAwesome; -} - -div.dataTables_paginate a.next:after, -div.dataTables_paginate a.last:after { - position: absolute; - top: 8px; - right: 10px; - display: block; - font-family: FontAwesome; -} - -div.dataTables_paginate a.first:before { - content: "\f100"; -} - -div.dataTables_paginate a.previous:before { - content: "\f104"; -} - -div.dataTables_paginate a.next:after { - content: "\f105"; -} - -div.dataTables_paginate a.last:after { - content: "\f101"; -} - - -/* - * Bootstrap and foundation style pagination controls - */ - -div.dataTables_paginate li.first > a, -div.dataTables_paginate li.previous > a { - position: relative; - padding-left: 24px; -} - -div.dataTables_paginate li.next > a, -div.dataTables_paginate li.last > a { - position: relative; - padding-right: 24px; -} - -div.dataTables_paginate li.first a:before, -div.dataTables_paginate li.previous a:before { - position: absolute; - top: 6px; - left: 10px; - display: block; - font-family: FontAwesome; -} - -div.dataTables_paginate li.next a:after, -div.dataTables_paginate li.last a:after { - position: absolute; - top: 6px; - right: 10px; - display: block; - font-family: FontAwesome; -} - -div.dataTables_paginate li.first a:before { - content: "\f100"; -} - -div.dataTables_paginate li.previous a:before { - content: "\f104"; -} - -div.dataTables_paginate li.next a:after { - content: "\f105"; -} - -div.dataTables_paginate li.last a:after { - content: "\f101"; -} - - -/* In Foundation we don't want the padding like in bootstrap */ - -div.columns div.dataTables_paginate li.first a:before, -div.columns div.dataTables_paginate li.previous a:before, -div.columns div.dataTables_paginate li.next a:after, -div.columns div.dataTables_paginate li.last a:after { - top: 0; -} - - -/* Fix for Scroller plugin */ - -div.DTS { - display: block !important; -} - -div.DTS tbody td { - white-space: normal; -} - -div.DTS div.DTS_Loading { - z-index: 1; -} - -div.DTS div.dataTables_scrollBody { - background: none; -} - -div.DTS div.dataTables_scrollBody table { - z-index: 2; -} - -div.DTS div.dataTables_paginate, -div.DTS div.dataTables_length { - display: none; -} - - -/* Custom */ - -div.dataTables_wrapper { - min-height: 150px; -} - -.dataTables_filter input { - display: inline-block; - border-radius: 0px !important; - box-shadow: none; - height: 34px; - padding: 6px 12px; - font-size: 14px; - line-height: 1.42857; - vertical-align: middle; - background-color: #FFF; - background-image: none; - border: 1px solid #CCC; - transition: border-color 0.15s ease-in-out 0s, box-shadow 0.15s ease-in-out 0s; -} - -.dataTables_info .select-info { - display: none; -} diff --git a/assets/src/css/print/print.css b/assets/src/css/print/print.css deleted file mode 100755 index aa0b4e68c..000000000 --- a/assets/src/css/print/print.css +++ /dev/null @@ -1,105 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -input, -button, -.btn, -header, -.main-sidebar, -.main-footer, -#widget-controller_top, -#widget-controller_right, -.daterangepicker, -.datepicker, -#main-records_filter, -.extra-info, -.deleteicon, -.fa.deleteicon::after, -.fa.deleteicon::before, -.hide, -#back-to-top { - display: none; -} - -td { - border: 1px solid #ccc; -} - -th { - background: #333; - color: #fff; - text-align: left; - padding: 4px; -} - -nav { - float: left; -} - -ul { - margin: 0; - padding: 0; -} - -li.header i { - display: none; -} - -li.header { - list-style: none; - margin: 10px 0; - padding: 0; -} - -li.header > a { - font-size: 30px; - text-decoration: none; - font-weight: bold; - color: #333; - text-align: left; - float: left; -} - -.table { - width: 100%; -} - -.text-right { - text-align: right; -} - -.pull-left { - float: left; - text-align: left; -} - -#totali_colonne td { - background: #eee; -} - -#totali_colonne td big { - font-size: 22px; -} - -.li-widget, .nav-tabs, .dataTables_info, tfoot, #th_selector, td.select-checkbox, th.search.sorting { - display: none !important; -} - -a[href]:after { - content: none !important; -} diff --git a/assets/src/css/style.css b/assets/src/css/style.css deleted file mode 100755 index 09ed1aead..000000000 --- a/assets/src/css/style.css +++ /dev/null @@ -1,1098 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -*:focus { - outline: none; -} - -@font-face { - font-family: 'OpenSansRegular'; - src: url('../fonts/opensans-regular-webfont.eot'); - src: url('../fonts/opensans-regular-webfont.eot?#iefix') format('embedded-opentype'), url('../fonts/opensans-regular-webfont.woff') format('woff'), url('../fonts/opensans-regular-webfont.ttf') format('truetype'), url('../fonts/opensans-regular-webfont.svg#OpenSansRegular') format('svg'); - font-weight: normal; - font-style: normal; -} - -html, -body { - font-family: 'Open Sans', sans-serif; -} - -html { - height: 100%; -} - -textarea { - resize: vertical; -} - -a.disabled { - pointer-events: none; - cursor: default; - opacity: 0.6; -} - -#progress { - margin: auto; - position: relative; - display: none; -} - -#progress .progress-bar { - background-image: url(../img/progress.gif); -} - -#progress .progress-bar span { - position: absolute; - top: 2px; - left: 47%; - color: #a20; - font-weight: bold; -} - -input[type=file] { - height: initial; - margin-bottom: 5px; -} - -#datetime { - font-size: 11px; - font-weight: normal; - color: #aaa; - margin: 8px 0 0 0; -} - -.ui-menu { - position: fixed; -} - -.autocomplete, .ui-autocomplete { - background: white; - z-index: 10000; - min-width: 160px; - padding: 10px; - margin: 2px; - list-style: none; - border-style: solid; - border-width: 1px; - -webkit-border-radius: 5px; - -moz-border-radius: 5px; - border-radius: 5px; -} - -.autocomplete .group, .ui-autocomplete-category { - font-size: 1.5em; - background: inherit; -} - -.autocomplete > div { - padding: 5px; -} - -.highlight { - background: #FFFF66; -} - -.autocomplete > div:hover:not(.group), -.autocomplete > div.selected { - background: #F5F5F5; - cursor: pointer; -} - -.ui-autocomplete-scrollable { - max-height: 80vh; - width: 600px; - overflow-y: auto; - overflow-x: hidden; -} - -.ui-autocomplete a { - color: inherit; -} - -.square { - width: 24px; - height: 24px; - margin: auto; -} - -.content { - padding: 20px 15px; -} - -.navbar a:hover, -.logo:hover { - text-decoration: none -} - -.no-padding { - padding: 0 0px; -} - -.box-center { - width: 600px; - margin: 7% auto -} - -.box-center-large { - width: 850px; - margin: 7% auto -} - -.box-center .box-body, -.box-center-large .box-body { - padding: 20px; - border-top: 0 -} - -.li-widget a:hover { - text-decoration: none; -} - -.clickable { - cursor: pointer; -} - -#main_loading { - position: fixed; - top: 0; - left: 0; - width: 100%; - height: 100%; - background: #555; - z-index: 9999; - text-align: center; - opacity: 0.9; - -moz-opacity: 0.9; - filter: alpha(opacity=90); -} - -#main_loading > div { - position: relative; - top: 50%; - color: #333; -} - -#main_loading > div > i { - font-size: 300px; - margin-top: -150px; - color: #e24e1e; -} - -#mini-loader { - position: fixed; - top: 0; - left: 0; - z-index: 9000; - width: 100%; - height: 100%; - background: rgba(0, 0, 0, 0.15); -} - -#mini-loader > div { - position: absolute; - bottom: 50%; - left: 50%; - width: 100px; - height: 100px; - margin-top: -50px; - margin-left: -50px; - background: transparent url(../img/ajax-loader.gif) top left no-repeat; -} - -#tiny-loader { - position: fixed; - z-index: 9000; - width: 100%; - height: 100%; - top: 50%; - left: 50%; - background: transparent url(../img/ajax-loader.gif) top left no-repeat; -} - -body .header .logo { - font-family: inherit; -} - -.btn-github { - color: #ffffff !important; - background-color: #444444 !important; - border-color: rgba(0, 0, 0, 0.2) !important; -} - -.navbar-custom-menu > ul > li > a:hover, -.navbar-custom-menu > ul > li > a:focus, -.navbar-custom-menu > ul > li > a:active { - filter: brightness(75%); -} - -.btn-github:active, -.btn-github.active, -.open .dropdown-toggle.btn-github { - background-image: none; -} - -.btn-github.disabled, -.btn-github[disabled], -fieldset[disabled] .btn-github, -.btn-github.disabled:hover, -.btn-github[disabled]:hover, -fieldset[disabled] .btn-github:hover, -.btn-github.disabled:focus, -.btn-github[disabled]:focus, -fieldset[disabled] .btn-github:focus, -.btn-github.disabled:active, -.btn-github[disabled]:active, -fieldset[disabled] .btn-github:active, -.btn-github.disabled.active, -.btn-github[disabled].active, -fieldset[disabled] .btn-github.active { - background-color: #444444; - border-color: rgba(0, 0, 0, 0.2); -} - -.btn-github .badge { - color: #444444; - background-color: #ffffff; -} - -span.form-control { - background: transparent; - border: none; -} - -.panel-heading.mini { - padding: 5px 8px; -} - -.dropdown.col-md-3 > .dropdown-menu { - width: 91.5%; - left: 15px; - padding: 5px; -} - -.input-group-addon { - padding: 0px 12px; -} - -.colorpicker { - margin-top: 0; -} - -#pulsanti.affix { - top: 0; - padding: 10px 0; - width: 100%; - z-index: 800; - background: #fff; - border-bottom: 3px solid #ddd; -} - - -/* Aggiustamenti per i widget */ - -.widget li { - margin-left: 0; - list-style-type: none; -} - -.widget { - padding: 0; - margin-bottom: 0; -} - -.widget.bordered { - border: 6px dashed #aaa; - margin: 10px; - min-height: 200px; - padding: 4px; -} - -.close { - padding-right: 5px; - position: relative; - z-index: 1; - opacity: 0.4; -} - -.close:focus, -.close:hover { - opacity: 0.8; -} - -.li-widget button.close:hover, -.li-widget button.close:focus { - opacity: 0.3; -} - -.li-widget button.close { - padding-right: 5px; - opacity: 0.1; -} - - -/* Tooltip dark */ - -.ui-tooltip { - background: #222; - color: white; - border: 0; - font-size: 11px; -} - -.nav-tabs-custom > .nav-tabs.pull-right > li > a.back-btn { - font-size: 12px; - color: #FFFFFF; -} - -.navbar-nav > .notifications-menu > .dropdown-menu > li .menu > li > a, -.navbar-nav > .messages-menu > .dropdown-menu > li .menu > li > a, -.navbar-nav > .tasks-menu > .dropdown-menu > li .menu > li > a { - white-space: normal; -} - -.nav-tabs-custom > .nav-tabs.pull-right > li > a.back-btn:hover { - cursor: pointer; - color: #72AFD2; -} - -.input-searching { - background: #FFBF91; -} - -.deleteicon:hover { - color: black; -} - -.deleteicon { - color: gray; - width: 30px; - height: 30px; - position: absolute; - margin-left: -30px; - bottom: 7px; - right: 17px; - float: right; - display: block; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} - -.input-group-addon { - min-width: 40px; -} - -.info-box-icon i { - color: #fff; -} - -.progress-description, -.info-box-text { - white-space: normal; - overflow: auto; - font-size: 12px; -} - -.colorpicker, -.colorpicker * { - z-index: 9999 -} - -.signature-pad { - width: 100%; - height: 100%; - font-size: 10px; - border: 1px solid #e8e8e8; - background-color: #fff; - box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27), 0 0 40px rgba(0, 0, 0, 0.08) inset; - border-radius: 4px; -} - -.signature-pad:before, -.signature-pad:after { - content: ""; - width: 40%; - height: 10px; - left: 20px; - bottom: 10px; - background: transparent; - -webkit-transform: skew(-3deg) rotate(-3deg); - -moz-transform: skew(-3deg) rotate(-3deg); - -ms-transform: skew(-3deg) rotate(-3deg); - -o-transform: skew(-3deg) rotate(-3deg); - transform: skew(-3deg) rotate(-3deg); - box-shadow: 0 8px 12px rgba(0, 0, 0, 0.4); -} - -.signature-pad:after { - left: auto; - right: 20px; - -webkit-transform: skew(3deg) rotate(3deg); - -moz-transform: skew(3deg) rotate(3deg); - -ms-transform: skew(3deg) rotate(3deg); - -o-transform: skew(3deg) rotate(3deg); - transform: skew(3deg) rotate(3deg); -} - -#canvas { - width: 100%; - height: 100%; - min-height: 202px; - border-radius: 4px; - box-shadow: 0 0 5px rgba(0, 0, 0, 0.02) inset; -} - -.sidebar-menu li > a > .pull-right-container { - position: absolute; - padding: 12px; - right: 10px; - top: 50%; - margin-top: -19px; -} - -.sidebar-form { - border-radius: 3px; - margin: 10px 10px; -} - -.sidebar-form input[type="text"], -.sidebar-form .btn { - border: 1px; - height: 35px; - -webkit-transition: all 0.3s ease-in-out; - -o-transition: all 0.3s ease-in-out; - transition: all 0.3s ease-in-out; -} - -.sidebar-form input[type="text"] { - border-top-left-radius: 2px; - border-top-right-radius: 0; - border-bottom-right-radius: 0; - border-bottom-left-radius: 2px; -} - -.sidebar-form .btn { - border-top-left-radius: 0; - border-top-right-radius: 2px; - border-bottom-right-radius: 2px; - border-bottom-left-radius: 0; -} - -.swal2-buttonswrapper .btn { - margin: 5px; -} - - -/* Personalizzazione del plugin Select2 */ - -.select2-search, -.select2-search__field { - width: 100% !important -} - -.select2-results__option[aria-selected=true] { - display: none -} - -.select2-container--bootstrap .select2-selection--multiple .select2-selection__choice { - margin: 2px 0 0 2px; -} - -.select2-container--bootstrap .select2-selection--single .select2-selection__rendered { - padding: 4px; -} - -.input-group-addon.no-padding { - border: 0px; -} - -.input-group-addon.no-padding > * { - border-radius: 0px; -} - -div.DTS tbody td, -div.DTS tbody th { - max-width: 500px; -} - -input.min-width { - min-width: 200px; -} - -input.small-width { - min-width: 100px; -} - -.pac-container { - z-index: 1100; -} - -.form-control#blob { - height: auto; -} - -@media (max-width: 480px) { - #main_loading > div > i { - font-size: 160px; - margin-top: -80px; - } -} - -@media screen and (max-width: 767px) { - .navbar-left { - display: none; - } - - .box-center, - .box-center-large { - width: 90%; - margin-top: 20px - } - - .main-header .logo { - display: none; - } - - /* - .content-wrapper, - .right-side, - .left-side, - .main-sidebar { - padding-top: 50px; - }*/ -} - -@media screen and (min-width: 768px) and (max-width: 1024px) { - .signature-pad { - margin: 10%; - } -} - -@media screen and (max-width: 992px) { - .table-bordered > thead > tr > th, - .table-bordered > tbody > tr > th, - .table-bordered > tfoot > tr > th, - .table-bordered > thead > tr > td, - .table-bordered > tbody > tr > td, - .table-bordered > tfoot > tr > td { - word-break: break-all; - } -} - -@media screen and (max-width: 1024px) { - .push { - position: static; - } - - .signature-pad { - top: 0; - left: 0; - right: 0; - bottom: 0; - width: auto; - height: auto; - min-width: 250px; - min-height: 140px; - margin: 5%; - } -} - -.callout a { - text-decoration: none; -} - -.dropdown-menu { - min-width: 130px; -} - -.img-circle.square { - box-shadow: 0px 0px 1px 1px lightgray; -} - -.select2-dropdown { - z-index: 2000; -} - -.after.input-group-addon .select2-selection, -.after.input-group-addon { - border-radius: 0px 4px 4px 0px; - border-left: none; -} - -.before.input-group-addon .select2-selection, -.before.input-group-addon { - border-radius: 4px 0px 0px 4px; - border-right: none; -} - -.hide-it-off-screen { - position: absolute; - left: -10000px; - top: -10000px; -} - -.box-info ul > li > :last-child { - margin-bottom: 5px; -} - -.row { - overflow-wrap: break-word; - word-wrap: break-word; - -ms-word-break: break-all; - word-break: break-all; - word-break: break-word; - -ms-hyphens: auto; - -moz-hyphens: auto; - -webkit-hyphens: auto; - hyphens: auto; -} - -.request .morelink { - color: #fff; - font-weight: bold; -} - -.component-loader { - position: absolute; - z-index: 20; - opacity: 0.5; - width: 100%; - height: 100%; - background: #fff; -} - -.component-loader > div { - position: relative; - top: 50%; - color: #333; -} - -.btn-group-flex { - display: flex; -} - -.btn-group-flex .btn { - flex: 1 -} - -@media (min-width: 1140px) { - .modal-lg { - width: 60vw; - } -} - - -/* Interventi da pianificare in Dashboard */ - -#external-events .fc-event { - margin-top: 10px; - padding: 10px; - cursor: pointer; -} - -.fc-event-primary { - background-color: #3a87ad; - border: 1px solid #3a87ad; -} - -.fc-event-danger { - background-color: #dd4b46; - border: 1px solid #dd4b46; -} - - -/* Fix per tabs editor */ - -.nav-tabs-custom > .nav-tabs > li { - border-top: 3px solid #ddd; -} - -.nav-tabs-custom > .nav-tabs.pull-right > li:first-of-type.active > a { - border-right-color: #f4f4f4; - border-right-width: 1px; - border-left-width: 0px; -} - -.nav-tabs-custom > .nav-tabs > li.header { - padding: 0px; -} - -.nav-tabs-custom > .nav-tabs > li { - margin-bottom: -1px; - margin-right: 0px; -} - -.ui-autocomplete { - background: #f6f6f6; - border-color: #ccc; - border-color: rgba(0, 0, 0, 0.2); - -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); - -moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); - box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); - -webkit-background-clip: padding-box; - -moz-background-clip: padding; - background-clip: padding-box; -} - -.parsley-errors-list { - color: red; -} - - -/** TIMELINE */ - -.timeline { - list-style: none; - padding: 20px 0 20px; - position: relative; -} - -.timeline:before { - top: 0; - bottom: 0; - position: absolute; - content: " "; - width: 3px; - background-color: #eeeeee; - left: 50%; - margin-left: -4.5px; -} - -.timeline > li { - margin-bottom: 20px; - position: relative; -} - -.timeline > li:before, -.timeline > li:after { - content: " "; - display: table; -} - -.timeline > li:after { - clear: both; -} - -.timeline > li:before, -.timeline > li:after { - content: " "; - display: table; -} - -.timeline > li:after { - clear: both; -} - -.timeline > li > .timeline-panel { - width: 50%; - float: left; - border: 1px solid #d4d4d4; - border-radius: 2px; - padding: 20px; - position: relative; - -webkit-box-shadow: 0 1px 6px rgba(0, 0, 0, 0.175); - box-shadow: 0 1px 6px rgba(0, 0, 0, 0.175); -} - -.timeline > li.timeline-inverted + li:not(.timeline-inverted), -.timeline > li:not(.timeline-inverted) + li.timeline-inverted { - margin-top: -60px; -} - -.timeline > li:not(.timeline-inverted) { - padding-right: 90px; -} - -.timeline > li.timeline-inverted { - padding-left: 90px; -} - -.timeline > li > .timeline-panel:before { - position: absolute; - top: 26px; - right: -15px; - display: inline-block; - border-top: 15px solid transparent; - border-left: 15px solid #ccc; - border-right: 0 solid #ccc; - border-bottom: 15px solid transparent; - content: " "; -} - -.timeline > li > .timeline-panel:after { - position: absolute; - top: 27px; - right: -14px; - display: inline-block; - border-top: 14px solid transparent; - border-left: 14px solid #fff; - border-right: 0 solid #fff; - border-bottom: 14px solid transparent; - content: " "; -} - -.timeline > li > .timeline-badge { - color: #fff; - width: 50px; - height: 50px; - line-height: 50px; - font-size: 1.4em; - text-align: center; - position: absolute; - top: 16px; - left: 50%; - margin-left: -25px; - background-color: #999999; - z-index: 100; - border-top-right-radius: 50%; - border-top-left-radius: 50%; - border-bottom-right-radius: 50%; - border-bottom-left-radius: 50%; -} - -.timeline > li.timeline-inverted > .timeline-panel { - float: right; -} - -.timeline > li.timeline-inverted > .timeline-panel:before { - border-left-width: 0; - border-right-width: 15px; - left: -15px; - right: auto; -} - -.timeline > li.timeline-inverted > .timeline-panel:after { - border-left-width: 0; - border-right-width: 14px; - left: -14px; - right: auto; -} - -.timeline-badge.primary { - background-color: #2e6da4 !important; -} - -.timeline-badge.success { - background-color: #3f903f !important; -} - -.timeline-badge.warning { - background-color: #f0ad4e !important; -} - -.timeline-badge.danger { - background-color: #d9534f !important; -} - -.timeline-badge.info { - background-color: #5bc0de !important; -} - -.timeline-title { - margin-top: 0; - color: inherit; -} - -.timeline-body > p, -.timeline-body > ul { - margin-bottom: 0; -} - -.timeline-body > p + p { - margin-top: 5px; -} - - -/* Checklist */ - -.todo-list ul { - list-style: none; - margin-left: 11px; -} - -.progress .progress-bar span { - color: #000; -} - -.attachment-img { - max-width: 20px; - max-height: 20px; -} - -.logo-image { - max-width: 320px; - max-height: 60px; -} - -.has-feedback .form-control { - padding-right: 6px; -} - -.direct-chat-text img { - max-width: 100%; -} - - -/* Dropzone */ - -.dropzone { - border: 2px dashed #337ab7; - border-radius: 5px; - background: white; - margin-top: 10px; -} - -.dropzone .dz-message { - font-weight: 400; -} - -.dropzone .dz-message .note { - font-size: 0.8em; - font-weight: 200; - display: block; - margin-top: 1.4rem; -} - - -/** Fix tooltip per elementi disabilitati. */ - -div.tip { - display: inline-block !important; -} - -.disabled { - pointer-events: none -} - - -/* Fancy checkbox: https://bootsnipp.com/snippets/M2bda */ - -.checkbox-group input[type="checkbox"] { - display: none; -} - -.checkbox-group input[type="checkbox"] + .btn-group > label span { - width: 20px; -} - -.checkbox-group input[type="checkbox"] + .btn-group { - width: 100%; - display: flex; - overflow: auto; -} - -.checkbox-group input[type="checkbox"] + .btn-group label:last-child { - flex-grow: 100; -} - -.checkbox-group input[type="checkbox"] + .btn-group > label span:first-child { - display: none; -} - -.checkbox-group input[type="checkbox"] + .btn-group > label span:last-child { - display: inline-block; -} - -.checkbox-group input[type="checkbox"]:checked + .btn-group > label span:first-child { - display: inline-block; -} - -.checkbox-group input[type="checkbox"]:checked + .btn-group > label span:last-child { - display: none; -} - - -/* Sidebar destra per i plugin */ - -.control-sidebar { - top: 50px; -} - -.control-sidebar { - padding-top: 10px; -} - -@media screen and (min-width: 1140px) { - .with-control-sidebar { - margin-right: 230px; - } - - .control-sidebar-open { - right: 0; - display: block !important; - } - - .control-sidebar.control-sidebar-open, - .control-sidebar.control-sidebar-open + .control-sidebar-bg { - right: 0; - } - - .control-sidebar-toggle { - /*display: none !important;*/ - } -} - -/* Fix stile */ -.skin-default .nav.navbar-nav li a { - color: #FFFFFF; -} - -.skin-default .nav.navbar-nav li a:hover { - background: #222222; -} - -.number-input { - text-align: right; -} - -/* Loading specificato per un div */ -.local-loader { - position: relative; - width: 100%; - height: 0 -} - -.local-loader > div { - position: absolute; - top: 100px; - z-index: 2; - opacity: 0.5; - width: 100% -} - -.div-loading { - opacity: 0.5; -} - -/* Stile Fullcalendar per weekend */ -.fc-sat, .fc-sun { - background-color: rgba(255, 99, 71, 0.6) !important; -} - -.login-box .img-responsive { - padding: 18px 0px 4px; -} - -.no-selection { - -webkit-touch-callout: none; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} diff --git a/assets/src/css/themes/default.css b/assets/src/css/themes/default.css deleted file mode 100755 index 8f074dc2c..000000000 --- a/assets/src/css/themes/default.css +++ /dev/null @@ -1,224 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -.skin-default .wrapper, -.skin-default .main-sidebar, -.skin-default .left-side { - background: #333; -} - -.skin-default.login-page .wrapper { - background: #d2d6de; -} - -.skin-default .content-wrapper, -.skin-default .content { - background: #f6f6f6; -} - -.skin-default #supersearch { - color: #eee; -} - -.skin-default #supersearch:focus { - color: #222; -} - -.skin-default .inner { - color: #eee; -} - -.skin-default .nav-tabs-custom .nav-tabs li a { - color: #3c8dbc; -} - -.skin-default .nav-tabs-custom .nav-tabs li.active a { - color: inherit; -} - -.skin-default .nav-tabs-custom .nav-tabs.pull-right li a.back-btn { - color: #3C8DBC; -} - -.skin-default .nav-tabs-custom .nav-tabs.pull-right li a.back-btn:hover { - color: #72AFD2; -} - -.skin-default .main-header .navbar > span { - color: #eee; - background: #222; - border: none; -} - -.skin-default .main-header .navbar .nav > li > a -.skin-default .main-header .navbar .nav > li > a:hover, -.skin-default .main-header .navbar .nav > li > a:active, -.skin-default .main-header .navbar .nav > li > a:focus, -.skin-default .main-header .navbar .nav .open > a, -.skin-default .main-header .navbar .nav .open > a:hover, -.skin-default .main-header .navbar .nav .open > a:focus, -.skin-default .main-header .navbar .nav .active a, -.skin-default .main-header .navbar .nav .actual a, -.skin-default .main-header .navbar .nav .menu-open a { - background: rgba(0, 0, 0, 0.2); - color: #f6f6f6; -} - -.skin-default .main-header .navbar .sidebar-toggle, -.skin-default .main-header .navbar .sidebar-toggle .icon-bar { - color: #f6f6f6; -} - -.skin-default .main-header .navbar .sidebar-toggle:hover { - color: #f6f6f6; - background: rgba(0, 0, 0, 0.2); -} - -.skin-default .main-header .navbar .sidebar-toggle { - color: #f6f6f6; -} - -.skin-default .main-header .navbar .sidebar-toggle:hover { - background: #222; -} - -@media (max-width: 767px) { - .skin-default .main-header .navbar .dropdown-menu li.divider { - background: rgba(255, 255, 255, 0.1); - } - - .skin-default .main-header .navbar .dropdown-menu li a { - color: #f6f6f6; - } - - .skin-default .main-header .navbar .dropdown-menu li a:hover { - background: #222; - } -} - -.skin-default .main-header .navbar .sidebar-toggle .icon-bar { - background: #f6f6f6; -} - -.skin-default .main-header .logo { - background: #222; - color: #f6f6f6; - border-bottom: 0 solid transparent; -} - -.skin-default .main-header .logo:hover { - background: #222; -} - -.skin-default .main-header li.user-header { - background: #222; -} - -.skin-default .main-header a { - text-decoration: none; -} - -.skin-default .content-header { - background: transparent; -} - -.skin-default .user-panel .info, -.skin-default .user-panel .info a { - color: #f6f6f6; -} - -.skin-default .sidebar-menu li.header { - color: #4b646f; - background: #222; -} - -.skin-default .sidebar-menu li a { - border-left: 3px solid transparent; -} - -.skin-default .sidebar-menu li:hover a, -.skin-default .sidebar-menu li.active a, -.skin-default .sidebar-menu li.actual a, -.skin-default .sidebar-menu li.menu-open a { - background: #222; - border-left-color: #222; -} - -.skin-default .sidebar-menu li:hover > a, -.skin-default .sidebar-menu li.actual > a { - color: #f6f6f6; -} - -.skin-default .sidebar-menu li .treeview-menu { - margin: 0 1px; - background: #222; -} - -.skin-default .sidebar a { - color: #f6f6f6; -} - -.skin-default .sidebar a:hover { - text-decoration: none; -} - -.skin-default .treeview-menu li a { - color: #f6f6f6; -} - -.skin-default .sidebar-form { - border-color: #222; -} - -.skin-default .sidebar-form input[type="text"], -.skin-default .sidebar-form .btn { - box-shadow: none; - background: #222; - border-color: transparent; -} - -.skin-default .sidebar-form input[type="text"] { - color: #666; -} - -.skin-default .sidebar-form input[type="text"]:focus, -.skin-default .sidebar-form input[type="text"]:focus + .input-group-btn .btn { - background: #f6f6f6; - color: #666; -} - -.skin-default .sidebar-form input[type="text"]:focus + .input-group-btn .btn { - border-left-color: #f6f6f6; -} - -.skin-default .sidebar-form .btn { - color: #999; -} - -.skin-default .main-sidebar li, -.skin-default .main-sidebar li a { - color: #ccc; -} - -.skin-default .panel-primary .panel-heading { - border-bottom: 2px solid #57a; -} - -.skin-default .nav-button { - background-color: #333; -} diff --git a/assets/src/img/ajax-loader.gif b/assets/src/img/ajax-loader.gif deleted file mode 100755 index cc70a7a8b3d426c30e76686fac70c0dcd4c70125..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8238 zcmbW6c|278!}n*-IkPWjhBOHchNdh{wkBC-?1V<*vZSmfT96{Cj1RMDH|I4McL~yX!;bg|+TWD*sLFDo~O26dHLjAqN{QVf=`@#Yk-hti``ww~h zY3)0>=MX~aJA}h5Kc(^e>%V^zfm&iP(*5=o1YEA#Ki?Lt@gVHLL`2oQs0nR6*lDE! zK(PrQcocf!jjqshu=~E$S78wg&9YBlbZp%f-FZ6X31%HrS@;O?lU{ioOxm?OK%oN@ zZb&&EcT}B3cEUJlktk_`wWzq`kQPYbu>m~qOa>E|9qDXIK^N>SVp2)DX@WR+By?t+vw27R1Tu1djF8 zmfShbFiV!VxmMbn$x>ayvH7qV*uBo4v6=f326Gja40mpX)dYEgeAedLE^|kklPz&Y zZP=^C(shtVq9_R!ou{Wz9{l4I5>aK=9=YP#k;=zanhbs#rG31#(D=YXqm+mHpO@Gz z6yGQ4z5Ani?Zc|u5giDZJYEv;WoyGmuS?zvSA+)Hl4QvBQ2&b`;UP0E1+Vl;H|Z#- z(b28BYgJwS{Nozmdj<9_4GYhj4p;N+pTRK`Id^ap&CaifBr+qi@ZssvL+A5W$-1`v ztNY_LIngADoo^7dvcL9JxEcfaj9o~7M%-op9q7sqPlebv+%p@Ml>7mk z;!ljsH@#}kSsT8ueVOZ*v#$)Rv<&J$K#_v|3q>&2TtLUB4va}^E6K&Ka%OIx%JENX z2tx~|U2`jLv>IMIVI5be>b0Rzy&ZVZ(HK`><|P*6rB2v?>KIunJsktHfSA}gk_IWs znGms_db%hjgK3kKgVwU9(-?gk?0NkUXS(GU3yT+jlnC}UN0XkvCeFk7K2HfUK5#5vQ~JF3XahVpJ^=CXUiES@cL|@`(s_*V^z438&pk!;I!%c%*X+x_ttod-2McHOLGgv5U4bQZH=k>B5snG{M3jXMO%ddlL2)A^n;*e^&{As(OgwSY6R3Lz1l*rdx>JY}FnZAWar zElN7^^SzGfi2TvH$pl6`OIa_37i+O~RevZAiKB?N$xzJsTW|D+9ZP-@ z6Mdaks$;Cn7pGeN!uF(@(zxzt4ExJxRxjaJwZ|*7h01th&z!G;9f>W@QPrJM4t3Lm zRgKUxlH$zaRj-QAqwFfOj1JL)UxaOH#?6MkXQJElRAd9^iV_8M;2%KyZb`hV1m?=n z+e_0!Sh7;q7qcvb4RFKz`vONIJ$BA+VtMKAN($~kt)t+D?`2$**57(nmv*>w|dqG3Q4hU-2o;O*!&%9|GFf%2h6;PQBVw5&bI9SYh?& z(Q6H>rmgYOpC3+$V+d;;TASWa_xy%d{sN375WguJYayedh)^;cu{z#h{*hB#OqCZe zeC1%(?hW7j#e%QN`?&l=&lk5~->np9@vMF-U!V|c){vfkel!-1RV$Z-3W)l1A}o;@ zTo8<=cqtv{VntkN$p2&3YFUTG&Uk8YuKjA+X6l3#RbxO|Yt+!cDDJ>#FLBBjx03YL zn}0E2B)&4jewALC#VFiGa^yl*ti9q4l+1ui$R^8uKA~Y6Zo{D@$aN;hD}LR}TwMG= z(azr(cJdiSsJ+yI%i%~trJ=SuhK1ISvK}d*OM@mdeK9`0dMUgQ=+<~xiO?3WMP^3yc zQ=Px_oHjj5 zW~1%+okQ)$GLuWlCRQk!gkCFU9D9d9W2Z!T{XFWcREg#4H9tulSH$VN%i6i#^X~PE z;Y<7y+kD&l%g$DWZ-dkUvD`y6Suyd1P*j{~3%x#eB+~1RE1(`)rYh8q8+J4l$uJb}y@6u7_dPyY zF!uf9c+b^Mht!BI+DWLA+j3i|MIoLt4IaK_#HV#{o_6}4XAA#C&hT%JREZQ;U0q8#whiK-h6W4;Dx?sAc1Brw56Driw|c}T)TX2Y^0UoNMeoTpp~8&k)+8OMWpC%P`zT;KjngI;Cu{dRaUt>##%Uz3V3-S;{KBe`K)-sfutrztheVZkn`IJM@YF^t zwN=sCTew31iXt$ z(?yADm*~v8dZX&dU{|C^eCNZWZ+T8J3!#gF zTxhS08P(0zlkhfll13rJ)Zmb{BwPX+7p@5ssQa}}!O^j635f|&Tw-Q^OtuOYmsEn| zdFR6v5%X9sig%#`V_B(8%*9>d;VPg8CJ}{0weaFIp+fN<3Oc3lul)IM{WJ#9c<`Ps z&@UWAfEesNWZG5QB6!kVpI$sqJ>I= zXl-Tl3yoK!Z-d{xumOIInR+Dh*;4*|8JBk^o9%n|f=yl7{r}d_4Kt}f{c5>_!IV^G znZ<;o)Wb{@>wR`8G}rFfy|@`@mrW&MmrQI1w(t32&>Bksz!<53^*Js#d)DqZS! zzaO{Xs;~LD&F6aoEY7*gmnO`(TvVsmjNelE@IfKPWrIW-#G4rH6aUA9!-@ zd0Xb!Vv5L3@N5N`74N%qWvJgsW6+-qms>*A?~4-BgI^moEm8q`u<_qazxnh03A|r6 zgJlI~K63rzD54DoU8LrC4Db5R>j<|cgiSm$o}XVu!uLGhz18Dq^G0*ZMATDj{sdBA zSLk{)a<=A=C&#D7OffQBiIa~&7{Q3x(Ifvh{i(#~bV@YvVqpLQ{$^ zwp&5l*aI2J*Umn0nqBYQ_T&&Jv>V$&&FznSfbNZJ#Q=d-1811n+q}qr#N+y( ze&B60^*ev6CH|xQ`EH5p9@D;zVymUkIks}49(wo;11lP(``OrY=ud)!wrZMn&1H$^ z?RR>TdbV7pafu&RJ~@66M?3%?4pRjP&N!-<761x1pvf5-VC-5CC^4J6os7xAxa6p! z&y^8)#LO!vN|eDeXLLnjL8e0$f(Vrr^YB;5bvIOqXaYXQgoLi|?TV#PQU*r;$I49r zGvKby6s1W5pfC&67aMC@(Th(=(8Bk3dH{rKh02fk4v=|m;47c8>CcBUH=!^jMM^n^ zQSI`aA>VhF9UpxPl6~0uNbF<`p)8kvc(WN&9E9q}?~%P`2oOaw82Z2Rr*dtKLO~t%ez-wJz#G(Xxa!s|r%z3Ne4Ym;>Y4Z;%E`_c-5-RC@Nf3lm zpXpCaaf$V4PasGac*xdHNs|_*4!8rrXf^DN)gNlsV=_#GfKUAA?UfrJZ$$KO^r3{qFF$PVE7sLKOp1)?T9M<0utG z6!d9{~%yB)nyyVx7@56NHqTrN0z7t`z2k) zam60RHy(LME?um6nWz5`O8DKznGh~J2a%SZ zY>dvoR4B4Sq2f#dej-#QQX!H`xd5JkzELm!JCJ*C-6bxkOrahLy!oJe8Fbvlhz^=M zjDOk*peDv~czx2)5Owm-*qd?cCiI7weXpL+%Z_=mt9I*P=i3G&!~5yb5rVA#yi&;j z0&;m&^4o|6iA!{^f#6s;M;fIO94w9ocWb2kdAygjClwfPMXWH$GJim|LNYDfKXoC_ z^A!fvm86pd6_zo3oG)iz`J-&Ng@!`2?*3#fKWKbsEdi%j;CcIp1|jS1Se5Vm)Xn4i zm+isLD_P=-;>w+MRtw6H@?2}ZY1{TaHH5R*_cfbO>-Pt8-g)=0_p?;puZ_CfuCev+ zK(;g-P>yx!(0IaVkDh>zo{Hw*aD6w?L%^CSS+$SE+@dn9_!m&%EPlPB4#Vijp@j`c zH&<(=B0qebc`}|i3Uj|sc=%m1Q#{qMTJ_$czkpnle`P(88EW>%RD4*BmB8nA(Pl86 z2&_5FbA6PC=rPRIWfa9?I9Lc+XVnq`kQ)Yp1&FvBK zaVuZe0fsbaUAu>gBHt%LEH7G_p{~Iw6#}&)r36WB5uBmbz!Yb0>j-mKkmrdn3I(ld zFLP;GujD{%Y7#eFjl?cXzf$zD48p>jSA!HTV)hh_Ue6-^L*HMfl@-KAlZuDb5@qly zGog4LP9b=?!9T))^ei~pu}QltK-#Q`(0!GiIQ7VgC6_0@cfubR0rK+fS-c zqtnd5gm_8{(}haKn^EGACuajL_(Cq>I4UOF$Liqas_L5BYjxM_8ycH#G`BbbAo>J{ z2xhea$8iufLXSvzaQjANZ||Tk`oYl_!b1qxuG{}W(ug0QozbC)Tkp)GT8)YbVBh<% z-@gC&^It!IEg?X>ymgJJJ?18ZTaz#VK^UAoGjLEuu8@{e^y&*xF0rI3nxsou0%q?S zMW-b!+>?P=sh{U^!5rtMW_4aJq_}V0wLRNpKpIxz>3RzVeT_XiGdOKOr^0P#4K7w> zne%g~8}hLJB3AO{O~>O;Ts~Z}t=7&Fo5bv@yYJF+;Og|0Ax17hT)Xj{!{9`!)hT?SJRdg)0>H(Py%PN4pSFN=! z0`v(6FYR%S_eN`@)nRF1wW=iJ{<1v{U7VaWHQJ&;lqe~L<@m$ZAL)dhDz5CGwSW1( zRmA7>8As0klo5&xZiX^QG9|3DbJ1;N-%SFCd8cWmS0C#hb}x z97q2UaRrF7m6ni{tt5jG(mH^EKmEKTk^OEIV2_tl;!Y&3`-bs?s)$?>%(4|trD+r} zxJbnIFL;Q`r0~+$GJ~hnsMiL#UO(lJ&3HSEN6?Xu2VLm`D@FDck0c}VL3*VBoc7+hnTBFO}`E0aOuL zS{7bATp2tofUtu_dBx`?=W4HMl`-h>vnw%=k+pcLy)XZ~zI3^PH@vs=0t+TTZ_c_n zRAO^X|3zdm@8S7*Q+L&Urs~5N{Tc;v^UhVnwDbKw_92d?-GxUI#!sx4Dc_nKQ=cRB z8_rCQqbr!pTUINdkHP5#jrZNCn|&ZMOHs5pcn;^`grD==eKTVpR});*QAIC-N7@YW zc-o?DEQFJX?vP5v2S;(iFIH$pRi{FCc5e~iW^jTf)Ijq@Ev4^QTOTQWD=pd*dB|fV z4lHc-5r;f!2J*chbl3_s>bCw{H3#h}lsFn7LEb}P7$Qa~F#CM~2FT{4eQN<`lSuGs z5K#nT%zI=N&^wzX5yot>cPv#+s6@plmNSx!aucVLy3#hnDcGoTz-UA63h#uDtK~^? z1Vv#X*2VmrBLUqv$BhZo<<21W@)(E&jNdEq83e^QKky2c4Fg`+YPdN8ijpzBW$>}B z$N*)bDzcC&+>?Wf+QSuuyv}tyvTr+>mpe#j%$)iwe*HAiSK)P*~gkK0F2RkZVIcL1LP^%rp+8Z+pGEiSPJ4W$pSYnB`wY5rO@F1=sH(7A{|HI|@DQvNNV(|3d_ zTMO)NT=QQ=8e?(33EPp7h)OIwvKKMC0x(WM|8&em064EhSBir5=BkTi#N$SC@xU_? zF43LR67gPdj3PGRNez>_F7iP+nhE18Hpj!;sH z#`Se4APDPOg)v5ym6Ne&&4VYA9XHrqh!7DDfS|24_k^?j^cv(#WDN{*i{}6^f;A-v zanjjbAqKHd#S{;%nh8x`h49Pd?)gRsx9i*Z_@cdD!8vFAEiuOf%9it|_Wvi4(d`3V z1Ap7N4zDP8H=yEr1iAG=l0CnnqXZ0WgTsq@_9`a5b7!iPJ&4I6%dW=g>m z2q#Z51>vUXL;^ZRH9Aeo6g)%8VjfLHMS>tDI4dZeR+ewIJYMccU8(#pM{m8^ruKW= zym-q5r1kb*>sF~_Q|=Cd_id@*VcqJXUR<{uflAHP!;STlyGfJO$tT*>S=#t5w}ol_ z!P$qe@zWRdc82)6EO?5M5RFM+tUTA5KvA*%TOoRnjrCFRWHVp{4}g`Nm)IQswNfZ+ z1xl9>r&&bjXe!YCVtdV37w)&^Ol?+XAxbPxm3i?Qrbq#cA?doIvu>co$O5uRuD{}Z z)uS%bvq-Yf>7?VOhN$ipZ(J*FpNCpJO$>NO`;|xY2s!-vyi9oK(-rF9f*v;|+|Kj* zp=;_)Be_n+;;w5>bs1{z)w}HWJ_)^5ELrvZc%d5sfH3q^6 z=EIsW9`9rTEVR2ovQZ03z*?`hT3)DLTsp!N?&3Co)V@d6_`{1>6b7JVdTUPpgd=yU zv}`pwY08D(w^J$KPTmtAi`O4*l;821JAgRRvk=0#aBz8)m&8ykv8Y3h{*&T3{NmXz zr4yq*;y8>~xfK$}G)D-`bP;258f|xCkgDCeo^q5LY%!?ymg1QT@vV{&xUo4du=zC` zaeD2DHk?NO)+9ib4D2mTqKY_B7Eg^EN6_1|c^XGd1u``8Z49x{488A#h3B4gGy5q` on`h3JtIn#Osjn#KA8uTpT|qfp)|@C-w%HVm*z)`I{jcl)0R6+R(f|Me diff --git a/assets/src/img/favicon.png b/assets/src/img/favicon.png deleted file mode 100755 index 63def4f30166e85d0253d4e9d0b3170cf4f67bba..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1499 zcmV<11tj{3P)NyZ`_I8FWQhbW?9;ba!ELWdL_~cP?peYja~^ zaAhuUa%Y?FJQ@H11z1T$K~zYI&6jIzRaF+pe`}x9mNsfB+)8g-1;k1SI6jbQ%xD}j zV#Y@z4oY-jG8&nf_zXyl??h)D1v9=MOjH#4019Ko$c*^Nh%@5|AJo$LqC9GEFNF#e zwDk7uy_X+OZ@IU<_qNJ>n16DTz4uys?X~}F@3r<3MhIO^AXnl5I+i4^Cz542P%Gd- zoGhq+sPnG?I)^}Bi*<)XIGjT2g~VhN>C(m_0t3 zC(Sm#d7Fx(4^_9|WS4q>n{o1;?=$b?7@re@T*?^~g2R0aIU#6s8vcsjsK)rd8TfGpN1UgB)`B*&%fYC?J0LL5WHe*aRK4!e4GP4l)(*Ofq>na5;wg!ckRjc`X9;5kHQi3=tgF%!jbkqFQC%SM8# zNW#0JKLllE;o_*z9{_F!%8SpF&jV*>k6XOEb&y~O@Q-irs9h>HSPPWO7k$7Jwjz8G zK<3P-t;1_*fX|`M3Er~(@1M)X|NheKE48(=j}2=sY}B`nmkC(ux5I#) z-MxPP)4S}3fh}EqT4Kn}4GfH_%pX3G5i&Mzml+tHBX=t7?TOo!A@n-XK~~EH@Cw%F zj}J*iqbp(l8A@|na6Yyo0w>ifAGX55KH>6do|aC*_Zy3x@}HgYjh@-0l!vgk`EZgI zfm_a1-f9uP*gcE`^~XT#cksbh$j#Kd4?IX1H!7dBL3?+s^UDd! z*s9o(!5Fq04#uY`;nJzfZ+@WzSyuof@McTA!nzh=&MENtMyM)RrZ>XBwimYdlO4!d zc>S}XTRG_Dm;W;Vh3CxXp81MtsQ7+VEX z>+(-nU|`BP<&9=TqAF(QqwT`2=Xk#D7TWd+)9QvEOel5>1Zt`@uU79rBt(Ab4FJ%7 zx%Dur3?c{4Lq!<3y~3yvA|H?EF%X3^Ku+mApgT8w%C9$m9qjGN6gW*L{?1AUW6rN* zecbo>PD@3$F4_+$OLjyA}7k{t}Y z9|c+!{m6@+DMqIQZU2MC+k6mAS21S-8-do$p^8Tj`;vn_YpRm9SM;Q_{awpzR;cB- zM-~Ekwef}2ysXU~v&SbVtlgO|=s+$yUa3AqocS*fbA)F=adLL3@0oM%>5uBF3OJY)m;eCaC@IQmB1YJM2N(_U-!JiQ1Tmm^$S7%p z5x)SiRW#z9+*4lPQ_IE1)90PLHQ?jp!)fpA=wbQJ)tb}A-8Sn;i~<0lfRdcFwr}=f z;D>bWfwm_jue%Eo@n7QN_uPE!VPW+ypipcuJ(Rh8O3_tmJ=2k&$F%EBtnv(Py03s+ z%v641C`eM?UYM&SA+w>ENRCd~F9sxTBv+n6Ln3+mRO`03l9CeVkyH)^-D>?cP(H{!+haD% zepe}xX3rc#8xBB@yYG);c`OG`HlU4I1Ml=mFoWGyz-A9Z^t4c6sjVzZ<_^$Z_jf?eVo}jIKFOVk96hC9(~9A1O%1rr*WEy zxDvTu!h)agD~l^DkxJ`%Erfz7L+4&}HuF`S{oCplcu(f|b4*-6E4BG(WOI}B$hh+c z1;}_#Vy*`l_E2`Unc|m1=r|5`WZdQ>@l!?0!B=qP=g0(X$(zc; z2?7{ICipySrI<7?_{rrwfwE1|V*_2; zd;g2EEf54*&y;-AP^oI*ZOMeBS$)9mSvyU=&W;BPG(1t*+2zZU ze2;CJ)<^Hj-Y`NxXT6fdJQ38b4BPw~L)77~-31=s!M0oQ5H+(-@58Vmq3iFya(S|O zP=HqM`D}!1f?8AS{Lkuk9v5%$waLEH8)>d~a9{8v>2SVu7gI6X!-YNbge0EVSSEzd z*Tdadfl0N~ammP~>qORG{DKt;Onb3gmY2)@lEX=9Ez5<(w%P=XATdgFQrH8!gmY_J-F4WNl1@1O!NsjQHW6|oPYmF z_=-cn&YXDLcvt?^qEHX)`uD?j#!>rzjpVj~;9tLSt{^0Wlt@I~7=m9d0h2VQTuu8O z$LbRAKmp6du$M~Jm6dx_8GN=9eZpye2A$D6ZlEQ%A*y)>28NMC?|YRuEbcUcL>2q9 zNGvQ6QZ6(q$!>+Mj}db2kuR_lBk`iDE6Xb?LMkhv;Ziy}GqbZbA8xnOT!KyqNcR_l zH75#(z*1n^1o5js!%6fC-S3(VW6FENvEIHVbANv1e!823;wsGC`>*K4;n;5~a#s-p zaAAeOKyk4rUF>bjxVSh`iN}jy5k4z{*K6G~#s~Nyh)lTkNa`3HGqdjxi*J7fhTgR- zCNYd~+lxO-g!{THkaGi{1~qWBkvKRw?3|si#G^cfa>ljL@u-a(UDx_J0tbW-yb(|F zWYep8a8gwrCkX4!|3w+K?5yD6zzU}2KK_H0Q#!{%a;I{N1b;8+%cKH4yuo9Z1ky$# zN=r*ugjoJ8OVw#Kja@TBMqh=~1GDIK)7?%c1^P4a-Fof`+ zB@7|UfU(iSxXs}(Yp(8_^=rWUs(kX@jv&^_q%2;Jfc4LmF(oCX`QEf!f`rl0QNfZ3 z2&kMjS@I6tSW+T;ycr6lW*=bbvgy0?YF802Ib6npc+t4g3K2jP%8jL;l6kc9ZSTF1f|eE`kvxWBYscR1I89W3^@nIv-bT#{jRp`hTh!!Oj z3jJl%VSUXN)Qdsea_KpeKf;bkx6ZSlY%yrKl&!`@^6Qdl00aezoSa-kS-yBvRX+a1x;RK&&r_Y%CE~SMYGDZR&8$A6E|3K zYS$A@8bT+*g;I~bFbU));j_`Ki_A?=gLHIg1FpzNuUGI4bt8-Bj6L>m^h`h0Fd3nl z*dPTx?wi?eZ*4tt7~cYk$;qJc4|Uq%ww}co?GqA2qVk zQI(af+Ye-x@5>6Ak10jH4;l;_Y;-{8A#maCrwX<9s#oZ7#X4;`#fk?Z|7zUzGe zTPsS)rxqol3x9$m^*#cqyj^I-M89O`o8Y4AZx^tCD%*_1c z8VnWt`?}n_#xhn~=eK1cbGNl%mYyhOd=Aj=*?5?0-ArM zEfP*+Ut4$gGY-El3Gq&cXf~5%lvBha?=ODMVsHg9-(Sl<{>w_Vta;auyLCM8p{gbn zp2G;|n-Jr(|NFuvAh+Jjk((){kzZTl1n^{FnB0|d%!sCvNikd!UU$sb9OVUg;UwLf|dc_MkE?kWL>XVsl7!OVU z5)tWG6Ox?u;%;4Ntebu05=a%IjNjVb-TgvE(i|fN#&3QZi zZH)o4?|K%rI`xb6a#zRLX(X-e6Tk2ClfNj3C${IG|KmS*WyN9^i*>Z?aBMdrpq8|K zV<^ec5c6DtCgfgO1m^t}*rs%D>7ayvMc}*IHR={Jux*@!z^Zy=bX?<2?+(X)>wnqE z#KcmT^bp;>B23(^bm4MWgcx8c&7zKN8Qk6QrKDh9YtZlwPef*?&ZV~ zdBr&sQk7RR^odeTdSvzSG|xCnR&s38p3#7?uyEv(OSb`3_jU8n?^d52jud5)*%DsgoYX`*ru<}+hvW@SA$yR3BEVqsz37oQ=oW;g8qDw7P}o2lqweb+y{*Xouy z6p!O|V}WA9-~0`rgxOEzx;-Mv`jiyNqO?9g-7}SZHF1o2$sN_h-=cNgyNlAN9PjdX z>Au6~IOqhy#qOm8ECz)2NH`2V)nsM+d(sDokbv9LEI4!A2!`lIer3hAA197VRfB8w&o|3l zDpBvHwNqarDXpB666x-L6nUW=;Dt8q1<;qJX?G(Z9b~F+Kw(j5fb+~W7kIUPsRntI zN|eOG+nc*VTSp!-qmeYTpxd4f?m+R#{o0-&H7~ErD#L9OU}l8#{4MERagG93=;UA? z2yQ_KaG>AYA=VsHA#c*m=)jfj=6qHx=9_E6W&y5LxJa{%+&z$54-& z|HvR-$MR7sWGGd$E;(7xu|%a~ zP$evW2=G;izgXVqdTeTHQj@rtlY)2*UrEhPL<+SKEEJ_e)$Dzfcq|Y>S`^y@U(h zNaMo#?`UU2kQbXk>huYZu0SX|DZWg50Ev$bO6&bm$1lxzsu#rePPtH8Z2<==bS01; zk#CtA9t-W**ci=M{cnW|_tza*2-)eSTIQkLIx+ZfB4G~?^;}Vh{!Ryws;W$8A|=k4 z98in~=wHVQEq2=CePpx}ON{vxARZxgvhgD_GVkzGQ=@_7}8Jl04LYzWsA4p^$nQnGk6lCP|TN!wI zykGfZoq?PgQq#zvxYl3vmr(6*iQ@E3O{#!1g84>kl(9`8&lBpveW7vGRJ?cF-W@GZ zw-doNZ>9c8Bp@WtW%$s>tzf|S&%`9&tjE}#bLog%@v)#U{l#pxYy(!f|EPv;erNb){8TVMn=cg$867&e4 zo(39KQ&L{;%As2yH>_rR$ZPyu2#DhLb?y658d1|Mh}?ad*n$0#pAGz_xLA&|`@~V_ zxfpUt8I&;O!5X6QWDXrUt2iN_=&a*Dx~JdbW8qQ*O_rGSVc<)t>nNL-$>Mky@f6E( z4^B=`p9LoarnT3eH$IT!e88BfcWaWOmR3nhD;XB~5@eu|Xj)4*|HIr7KlT2A2Ae1Q%O3M(r?DpLz1T=h+* z_K%#Ov@?gGP!aupCGrN0Bot*pOV(9|flAB^Mi(jx5QyP@|3~`!Au=|Vh<1Mc`&ds- z=REiyzm6Wf{GfqP#DNaYYI4;SDwEQ>7Z(w$!R?{*F|Z1ayOD9Cd)`mr3InztPxXrP>eq9YK}_2u?~k zooN!nueZMnTv$0)L) zwHgjCHzQb=|8?be!oW;NV_oPd`sA)>1r`Z=w4IJ0VaYk=)%1t>VUNc3@8Z`>pH*3i zLv*+FsBT|LklV`5Mk@`|@DQhHa?4|480)BWuRjP*Y@poKM^B^MF4peH8m}pS2f41h ze-NI07m-wVq#*;gnaIsS&MzpMIKWI9_fRR)Zq3E)lha8$U(E|`+Fa-7BKBm;s02(8YpLI0c&j)jT0jG|ZPU z?ppo)$kep;v6PR1fDSnS8cyY9A>)6QO)2_s@s2M-6SL}fCbGF1$lVj;&9*QzEDKe- zb;7F2b~{&qf^{2(a#clM*@VGCm72HwlUTH-NVJFXb=fU>Sw`j4yVJV`>qGGsE8Z=X zZs@woKqP}CYJtcmULL5ldF9x;u~_aU07%zOa?$ujUj(m)j8EhsFyQaQ!)shC?+fdT zovFzL29}5ciyt4|lw0yWbBpqz;QeI2a|J70GF2_!vjyYN!mdK~XmRlFua3P$;CYuO|&WWS@$a0{?aUmgvu(qfHI`I-Ty4LJ!En}xE z0JY<_^dU4USL)x-vB%t@wn&$kG%#)5P`gy+q7<3hIiDj^8jM2ETuW-OaHfFoXnBaG zje3kY@~4A1GHfN5;hkXB8+tHIDP>v~5&vKGU11OzIgQbh6qzp!2OomTr_W-{->61Z z{&YiSao@$mltK|ZJL8|We`di4l{>FOM#c_Z^|+<&1f*ExH8nNed{jK6!x33TAhRoq z+Rqqce=D#4Qmv!cT-EuUvb0i;=#nKo@mhIXcs%BWb;_pUEkpR~`POw94{AkQ7@SDB z2HKIMUhK^%@4=aBq-D1MKKJ`uU|d*F=Q4k~CwK`jK`!>h0dDb4rR%VH@gOO0(u+A~ zJ6#dwo$Pbcz|7uoBHz`Ma^b zpkJ*P5*C_U+nzDff+&St&GS<7Rto-R0W9Iyf6qCl%MGM{+BA&O zhI`u6w2-7sTay^I&nIURr_JMq4_5N}8d?Mwu3q})6Alo)*(HRz^v2H2%*-3>xZaF3 zaWj@k@n;sWx*JPhwXQl;e-w2JPy7*_nI_TP|KaoSK!U`bT^tj~q593KTs6|yijb4v zdcA?`Mk3y`n?F8}eT-R=K-3B68noe17+I;)#_UU{dZ+VDcC^d9;g9{2*l&)AsC{zj zI27y{u*mSX+ovc`Ce>9?T`JA1z}!83s`r)`@L76g)gS+PPnvHfz8E!_CWvh5vNkuvYk*kqp_#2r z3?tMvYTkh`olf?Pm|H~Yo;$xz-uJf8gKKA1|LB>Rkh6cRszj;+<9UJ@de82((|n7Z z`yd$Q&5gD4Z8sMHH@jwYL;Z0W-XL+|=!gqN+(DjE!M$VoO!*m*H1bn&2rB$AlXTUh z{VM1oviQ}CG0|bDFIZZy8rE)(q_{fA6AD9o*cWL&Y$lNcl*ce*T14@XAv#ZGbVMxO zwWB$4zgIt@rx^>PhoRvCaJtmtM*bHy#zHiXbMK{Ye@rH1IK&@Hdwi+g%K!CZy#dHB z>R!K3^eI{R%oF&}ck|y(^gnmMlU{VQ!fN(C85TOrRxG%a+e?AyaOD@<**T-*K|0ie z)mnVUySd`|ReI>x7_{6JakJ+WlFzgyL>%9Au7g zyQ)(QX<49Y6ziXS79QpTo7@ju3HI(^#5rMzh^H4ezQ}Y`lRa(5JufX;Jo%Mp3R_|q zg%iP8xU)RerM>ECAWx`clxFFoIWISZA{(7R4JiX^UJLe7D zoZVe?I%i8J9gmzneVL;Q?-brJ=ZVo+QNS3gPUhhzqkEx5ylMM!Qzr@x7uI`mara!N z68Bi}MobshdC!Re2-@ZT*F_p;+S(U;SX`Zx1*JGJH()0=gAnR(k|?G+oQ(cyGlK2| zt^YD&Lhtz1jh{Yeknt39zZ+1{#J0t(uh;C=Ceh1Unb*fT1SOGXm%Xer+YC= z^o&7upmRkz(b4181kJq$#sPFwHLKAwVmJB68yb=iIkLM&uj34xJa?zV#f<=YZ=+SpM+O^{`?!;Q1o|c4Gs6@(| zAu(-EBq9^?=Y8|L2Ai>kv%CFTGq20vdM?VV=ck?x^HRcEiFs*}51st3<5M%6q4V!y z%xKAnY)vLOpOx^^Mv#B(he8|2EDX-VnS<>#a9`t&De0$HY~%D*{PJ>b=Z|3OCDATh zSW4qEyl5_KZLKasmR&Ljo|li|D}khPMFIId>`6Jw9V3Cmg&yCD=DfGF-rAkc%*mvcl_+7GZjsDAX5N^kD(v7ZftLgqBKf}4Qm(N+na(WWd!_zf9TeuhF=vxZSpI2nqFS)pmyAc|9 zRM_ugM^?|+Z9w6Ki;g^zL0um5M$;3tOL9()C&wexhFR5x?T6%1N-9$;Tej&byqph0 z)glAV-V|Q@c$TPxR#0d#rIu%Vo`Wj}26#lj3Dd6Xnc;LkOK{u9Um4(UB#mQ)0v*c| z-ru9~kAogB=l0ElA1}}IY2Dy-<*Zc~zMad?h{j18oA(5L0Sc)qhg7}%&P7M1V~#m1 zGC+*RvgSq7UcB!kK!Y7m`FgeYK)BJuthJ=suCN)6G4Y&ES_@bkO- z&x3q_yH{1K+lf$_X%m?OBe;^}Lfcw20rH%(0sN zz1P+1+h_N*;WUMp;sZaUhT@lfe#gBswRzY#Gm-=v^3hId;Rt8G`q0c?oywo5lAn*4Kp(i*py!KJp* zHX0b6R(~$(UQ`Yk4+~zwwD^(Cz{FHzc-he)@o+-k9xQoNZ2&(G#v?d<^$mah+xS4c zDv^A2VY-!I7MGh4Wm+QJa~75FHP5t>1WduAH$m(x2^A%apH(S2kCi#*1>GU<)+8}7(h{i{9yoQZuLyt-tW^VWank3dVk?wer4HSl``?-1?@_ZXt;b#J{t=L zXC>JaHo`(M5&9Igycs@p7&0|UPZ%F&=Wx}xaTZ=VLq@^2p_dr>51vUj8fy5 zRX~bZ+X>uvw5VQwL1iLvMO}`YvTqi6S-MalD;a%}Ha?ybU_F3YZqzK*erwZOrWREn z@L_nRxp9usmIQ96G`Rb-l-dVS(-EX)5Jzv@RtX;^!=*ZuAjhS43LPbbi`qPej9(*% zU!R|Zq2smdeKous85|r$UT_pG3aDXLPvde4{BgRGc+^94^pTMEaaV1XnAquPgiH*r ztkTdg8z`$X8K&mNe;gVGkfa-oUN})W>XsPKq zA$s1dWxout>~x1ug0Ts9wy;*_f>bJWnEjsvPufMKYOfzZ$`SR-Uug;&4gS!;d~7Z1|TG-KYl1f6FE{^z7^)xGPVC5sze{bMbrntQbp zV4Paeea9Nz<~3c{GsmQzc;;TdwWU7yH4FvXpA>p1Ya(PaAA4|-dkgA1NWn_h8-RUd zfZ#CdzbAM7tyfU3`P!+Aw1UNi@4TxryB^NF{MqTN3Y(|i@*eFfziVb(=p zkp`Xo^*>(LQdd7|H9g*^wvLsCps2sW?~YXUr36x}M_^~}>MqIN z`yWE!x;cEd;~raETM2$$rZsJXc4x>|U=*iIn7Ds_wJDB;;C<-8G{vhd>He$!2~t7B zlfVdcj`5>f%)J-lLOM+Eq)-*k3Du-d+t<7V?|xy;2)Z8#?;Uy$P2?7tB2Ku26-2g& zowXbYq|zQGByQld&K5TV2MyI3xk63 zjZptG<%QqP+tLnMW<1#4b7&9V#}lRt&W49p*Q7fxkSP3Q2sm}Yv&s1xsjU8us|}yH zR53L}wv0YqJhK1YTlN*lER4U;sZtssf%jk{+|HN052r_QO;eIKu`o_10P-0{zth*P z7h#2(B5YPdkggPw{9%`R_YG*;W8xO~dxa_YudXKMWhvk2is<5U_&Q&?CG-5xtGj4 zA^`zTijY49Kst}*>z}fC;umuWQ&e6g2RB8N3>(cX!OVoJ6HfwMV~|iu&tQf%NG?&} zFIDY4DxwEd-Ju{D#vB@~CFXB*twZTaDoUZ3BqYn&mj5Koi%(%f)S*hDVM;HRJmc-T za^>w>9|5_dM)Kdty~M#UbMktD1S@|De*d4`+8Gaeyc4(Mr$Bwfg6${1X`72A>i+UV z8iQFZQw{1yPBS8E{>IJnpB-#^JW0x$lICEw++NP&=Nz=d47ZY%H8BHJOeS8J5s2D6 z^;NcL2=)oh{ARddcx+-IvSsBsw)K*zaWnVww`iZ5r{g_ybpkYiEiEPG;ltL?FQSpy zM$w~oj*d(wr6(ZWg zdMw|c0$EoClzL>{5=MQ(L-LzKgd=Zcz>(Nge!fq{X~fjRzF>jhIzl>I_j^nNY*eZ{D!PG%T)snywsR8reI&e}53TtFeNeVZKTJ*}>EHF#(%r0! zB5OwF#WlWQGWQ?B4XArG($;C$@YIab7`jwUqHC#P%OXAy=jh)XcI~=yU1-b>?;sPhNh~mM#kzTcMrU1HX+lr>TN`9*HGVADc-4v-3t&*H<1|PyYx`^N*;s5iqeiK?vwS-ZW-un1vj?K9RJCk^T;;9P%0C;kS=H$g0C*sP|F(FfBq z_?6S5ZeIdTSt6Y@AGujOdICpLeAZ1X!i-zs6Snin#w zW;N>p3S#+Z6<@_7XUa&uE!MKeWmS7medEGntMvHyptU=d997+_!`RPnn$?dei<9c5c zOAGnUwNVIw54Mc88%`wcI%ap@-&T6(}>?RK@>9 z@xvR3cFufr9E{LUbCgA~JpBCp2X1Y~e622V+tEAo7#=*3hjRM9rBHC%=VG4qN-Xqk zlC75v8ahat*z+ep2|A;LIr4L1Uu=qIjnFWW(%$Z<={@a5_czH^L}E9eR@K+X43$Je zpal5MM-`{OR*ZFbesav0lgxQ&0m#o!V893Y#*+W`4jTy+EfcQJKJX!fnHt`Oh#R#xIn zi?O4G!;gJ1EMw8wkqoQGrCM_!_3<9ve1-4D)A2B9W5H4|Y`jqY*!JzRt!<%ng4Wc& zlB>7>S;8ozlI(mh$KttO>rj-mq&F1)&2oG2EJ{ve+_TU@Ho6k{_Rl7x@T)sUfQN_$ zRSW0_i?%rYym@5g+5m)-|M)T+B4aM|!#qoTPEM{IQ%Y)8LsWpJRAKd=IHZ;-z_mT@ z!PYA7WAI4Veow{2Q)==>-{fCO>e#%RG}l7iW_q^)M_C@&3g~9VwXOYvD`gpHT)2ho zI~$szRF++bF% zuAr@J6NZC_8n=&V!y9jLRP$N@Lxj7vh2i$5ay%Bk=lJwdql;PR0jy{r4o;S12G%5p zmVX#u%6)y7{IgYwYA);e?sw_|JgC@XVFMdJt(YSlmw{$^BwxMDA12Bhx>6yF<{?g~0SnL%~3{>&i*=KdWZ^q=mmP`3HG0SE+y&OX?Gp} z%?kzJUD?r%1*cUC4AxF?UVTZ94i!rsc+t)cl_El6VLO{GFcQeT1x=;U1aVF`eT$dZ zQZ0VGTK^Vr-|}tU@C5Akb-n2xJ4vY^4!!yl0ZCuNkHA6n$p9zH+*ZI&^q%soSKbx5 zTti8w5Jn90N0yeNpYdqamRZr(>iwYv3^ne-#~PvT-duG0p(i37e=QGxC#?PT5L>hx zTA#;L@EufW0EIa5J3_z?;ZBYDD548@6iAJeLg7?8&c(jPkNULCsws%k7e5XqiHOE@ zZU__q2c&|jPK^*s`EHgLe~Yp5?@Ee7+sOY+85%kKa-cm)yR6oVrCmIrca*p~0q>mq+OvG=cm0I!xkI$t$ge_X#Fa z0W5J}_CITPl$NngH`*2!65Km>P=N6WYhS-9Rjl<#BzVikom2t_OTfeXC3!5bP{o*X zB_$0yR0G@RA|gWON21qh^ykYSN17-gjinYkeWY~}4mfm)&TD<7#9ssJkv>p~#>8aj zmH666qTks}VcA`(7p_3q%N4@RHYAzkW3|ObL#x==%rkL(uuW2e<>9da{#!MC`dBgL zac9-=)Wwr)94bqxr~0S9a5XQt0}1Bl?JrA;D^ogxcea-^rszi_8vh9-ia}rkd66X^ zU%KeP8{6oqC1~&PD+4SW+&>0^TM;F=Q0l+APHZK!$m;i_eLQc2O@zzt;>-KB zf}ii6qyDMm(F>s7&;h0Eg4v3Dlw^W={83b4$ZM4FK`!y{2#HmvY)Bs64v(wyFXfb8 zw7@N#fja%+4t}gzj;-^PM3a0%9Xp=wisA@xX9+Uc+cKp<>n;xv?P$B zFiX1UdIQt&Evm^kXqlJc#tqv@ehUrF3Zk7%gH0%B>C+evy=)KmD^RZDZ|r~i{C;Y* z&YtRC_S61hzo$1^!&G6iY7Zpwxy1>X6k`=8H?%aDw!j0|8b#<)u{V>)yU_ydg-?8_ zn2q{F58>w_cJBkHar~y;b9hI(jZUJvWm3#!YWw$?C;2yB~s9K!m9IDL@UeuI=;c-}vqN zlKo>Q81AvsAG#oo?z^Kn(bfs}Pt!<%YY+KY`&bF*vmg}XH-gqJB4UTxrw=c$Cccf$ z-B-sPP#!I;db<1<^%h!!dc*fLdZ+uHPkv=#LUwA~Otn1gz`3uqRQ2lZJJ^K#v*@zz z$F&uL*%)OxiK)9WneC5VzPNqsv_8OEtULPt@9jpOdb@n2QL585=U8`SOyr4xt}%VL z7MG#f^jc$n`;4YzN22xg?i-Fb2m#a`=t6%V+%F~P{^-7_>hLhdGwU;EN=M{K6`R|D8OeI zQ&WC$Zc=%C;gz1N&#~^!!P*f8s>uB@bhT%0{3!7fzInQ{;H3(q*-h5lzBj0)9#ABw z0}yowG5&f@CP)}^zqbe{t97#u7!;{q9Z@8-R#~c}X9T~jBTguD_9bqY6+B3CeCoV3 zs1l=bC7869IA0Uyis)Cyi=+Q@gutH=cky$5ApGEu1|}(bvc54HcUjx|JJ{Hm){-$! zOM5hO9CoJq$d1^MSk|NcW9kVpK1RLCNoG8lMu+&z~@*VPFc{CBdVS zs$+>tb9uuZMcH*if!C6D0b@$k?7khiT)Mv9oE#->po5@OYSkW(3!3If3K&>n4y(J+ zT>dw2vk@rw$_@MrkxyQQEE6)^37p>rEoJeQ=>62obnE(sJ_v6|3Y3myquWRgjUEj6 zCBJ>72>G8p7lPHk_Af`x0`n%Uh&@A;&r#Aj*_8gZ>4`_fH9T($=0dZDK@E=>KmMOgV4R`Hh2i>EM> zDUJuDk0a0J=H@_7y!+P9lPQk)&1#$lA}t6?-0v$Us4KCy@T^Jg zTBh`Fb!8x=K>v!&`@M8SWdn51*ATq*wD2w)^Q$car_6abO~$I&;{fKd3NXfE#<|uI zhSw$O|9rsFp-$EAG6@q3?1BLW~{lmUnZbTKej1U6p?Cv$Te+kpv|?efg$D-7?1 zgLEJuUlr#S0o;O?yXb?u&yKcDn=*$*GHV`0lt@&S(c$A%4U0W1pt~g80vsL3hF@B)79E0~dvR%9XVW zh-wm-<$k`bE|hb=+|aNH+417Bq@zMeE<>wVcB|afFiK@07Q~LlS2Y-X0O8q~eOo5h z*0TCmAd*+CY#ybmjD0_BvWDud#$wIsEk*W zZ=eYh5_?tEe|WSq@(vG^*{ks7aUBQIY?}7Kj~)}ys()3HvlV;V!zZl|9|(L0D_M$` zo#$EOzj8-1KMtr_yM+_0!?pf!U&-_I3?V_75R-gB{)_Yk%#*b zpda05S^eg%@dOFNUC-4;ba~w)>YhELrDS^ues>6dJJ`MT@8KB9f(xEY%~h(861+SW zIy%{gu!?H33rPEq&Il&NNMjr&g%l8tT;zX~R_TQ`S|hxseTQR@pTtC~ra)3MnY08p#n{|Ml=CqnxHSg!iGTN$V z0M;+R9RfMSrwt8NK?mVvWa8D$}8K}CD8>_ZgFJn2k)HP#F!ce z-;7ApRKDqiOfT9Y&v3RTU)NSfPaVl6=w&9t>L48n<0jX8T)HUBHq3|CkAX^0+vK2B zgJ_KpD&H=BD(Po4Hn_G_OebprAMb@(Fh=%=h|-D_wLf*dk0|ZW?zaNL6Gu9 z>4J)a0E!{a5>K-ZX5$ry zgCAx+XHw_UtUJdz&oayk?EPNDOM5k%xlOZN^Xsk!-vb-uxXMeJDwl_#vX!w%iLlhb zZYnf9N0!^A4xWV{_lve~OL}_D^s0>Pu$_Us*m^c|cr#A>xs~v>q6+X;NSW4(>0LdZ z#v?_RA<^oXN14Zc`ic5Bs!jc*DvQBGJ#=+`**H!Y9b)wGCHwf9SK4;u9@|1`H55}Z zMsS)1xnRfv&X?$MfQQ|jP6_%Z!!(^5?1evYI$r}cYoeUKJ94;Q=-{)PW3A_~vmx&R z01m^?l9rpuew)Lz1B%px2mp4u{NzTQ;J}wF*$?#-W>4gqm926Y%B@Qjb;g;-W|Bp| z=7l~<*2=^bHeB{|thSsdKO*6!>RHYgx$4Pq&@-H7SyyoF0`+wXZu8>Y#=7vrO&c~H zuF7ZXPa+WL>L2C77BuYbr$JbyCghArZj`e4io0J~Ayl-@HR$0XLVdD-)U1C;5T6VG zk@gCk;ik9xw3KeKXFulNA#L<4#;*mwFji({Th&Qi8I79eqD_H0{Q^D#+fGpQ&WP>3&9I~;rWw;ccdXbi!(J7ee#y~#Eqb0)jS;LkDt91XO}ydqof8E}Q#cbJ3<&!F@&4VR1vb|(~iL@7nu?YJMv+=%01BzOO` zv?r&*pe~N}Y%CUVb=R}}+ty?wDUU>#ZVUi{_>u`9OtWbaRIEHWX4c0dT{29QOm#nL z;s2@v#46e=_azWI^f5q)*Ee znfl!!gdEa_r^z4ALe6(?j(Al>FKUYp_W1CGxhkLYXI5k&RSuW`5Bn+h&pQ4NCl=q7 zoL`DnUum=Jj#kg}d&fk(Evh5*nHl&0SNR<;-QTtYs~H@66Y~pf)u3L<>_w~ zz>8tG64Tb4zbMGEZ3`K{pal)|qYcR=%Yzlx*6F_mncN1yEI^#PSeRD#3VetEnDCqm z<_V>WXA(Gq@AD$Ap3A@F>p?~jSuNYc{d;{r_Y`nP@>3z$n37*=`eN!=+o(RfARWj- zH+?l!Q&3}^@TP^rSh??ops7G zKDML^SMJgKwjMR|uGCh7Me|vrzM^Efddd5^!kqTVlD}ZcUC1#kRzieh=lQdMAz4l%XODgTO_df9$uD_7FajA6 zTx`Evn+ossCIj_Gu4FxIPFY<}2hsvVQX!5`9p;iJ>TXy4)jjc_g#D=ZA=mX+JhLe? zF=aLq%Z9#(a^dV&9$!)AvD;Ib(P`U%WAuub5CxEZNycBkDds6JDf^=Ug5N_N)|@k@X>zeP ziLkZsVb}eBMo2h`BMPSpS&k)xTO>WMB)MRfjNEBP^piyY-JIPkL|;F+L~czb7wyK? zj`p}VC%bA+jL(Yt_V0{+uwsAiNMy-J9C3qno0oQKp6*++V!~Zxh380gtG-5mtHs#kPva9J8(Z z^MRtL1J*inMA>Lt7O^E$?u3oG;`qPL92sn$$A-$SkJ+5$}sON=^{RS5aM~t$*Ra1jCte9>|2D(edNwoWSZ|XLt|M z_6_UqG0m*{0r^XMOS9EHXZUnIYk%=k`lABBZ&$Q%)+kKE(yF<&1aGH}!-eFJ9FIO@ zFT(vT@IRR-e1iK6c#p`G=kfBDX?pB#WL_`bYq>=`yPLzq1M-sd8SwRVAt~@-Q2Kvj zbVj`_#W(DUpn?_AiQmiPn@{YZT*fucwn%G(&g|y#qM3*gX|P-QX;XFrX;(yRfQ1jd zP=SEisI)!LCm+O>(tHZKkt*nX7i9c9F5IB~X!gFnZ3Q*Nr@2I>4Q8h9ic;tpAU9Qz$jrXBW&Q2O{PrO6Yfg<^~=w)75`Nfg>;V=i* z;7j~it@n8cZ>%F^=Rj%qm#2IDvRybu`uL_bfP*c;kn)Hu;qgvgw?54bF_IYZU>S?` z_{!0#x7T^TMA2h8T+Y|dv;B5$8YRk}6eo>v50Z8Z*ERO9z(!#3w#;Zi$ZRoS`1p|; zUi6r?ihL%S!^FFJ;746D(n`|CBh7bTMT2+jA0SR#cY=^6K8-DZj=u83PyK-lQa0>~ zU*o&PgY^|D&?fJ2&{DjaZ2cW3GZ}@?vD~^XVSVGh<7UdE=VRm>MWW8Qz zc{1cP`lcerMgznJsXtd(K{xtmhO-}5QHEs4!}&%SPQVI&ed+8dCa)$2omG>??%Wc$ zAj;fR5Ah@az1U<2M50e-<+#skAJK*6oY9+F0n`A_W&sT|2u}|NijWLWS;VGmJGh7nJsFl09R?PMhSyRZfm58- zrtQIYLj%qJOr^7DU1J@ik63QOLk_R~%w4C4RJGJUIg?Dg2DZ4Qz_KASU*v@_Tqgq@ z-=BHfHK5~Iea)ziluHQ|^z>B-4p zn>lL&qvTYnM!Dusdqx|3pErGaTLOpzrz|3mAm#VMVSNRX6Erf;kqpiNUE$<%5R*T4 zpoQXQ6g5=~cyQ-hFT3`Fw3yJ+@si9g%HOD(q&>!}EF@KMgn9U80L`yAs%4&e8Ca>? zO7=w6?T_%yG+(XGUO6DCaJbd75BwlH5#{7Yv*=OjE^@Mo3MC_IMBOoF7)AT*os`Lc?EpPgGb}^P#eTs>g?q=N#Ga_8e6A|$9@3b6Q7~Ut2kJl z<=f6BPEbAg?|bj~h`rMYawIe9(Qj=ExAQji4%w(W-GiD%lPNI!!4z!w>hL|0(Y>PR z0)iv_o7K%h0^&y+dXTe+*|ai2i$APE&I|GI*keA+=mc_d`w3@~x>epu`k}>th19}0HD{BxkGonu%EL@RJPCEa zRU25ekTHej)^cfo<6}A!rye!$q*lxumqXS839a?IVnAt!$p9V6Dy2noB3Nd1CODL8 z*6HeI>NGVImZ?!W%(CvIe#7u)lSFUqT_0nBuFmA#mO7-R38!lgpR*f}8rjkk%2kQu zrLD7aiBlYBGa{OP+Q;T_Q;-YiJ9k8HWQuop&U7kic^w4Xu50?)eh()hWr1+3-iG-d zs36MJMyU!4y^@$IK2x9cq{uG&X{0bdWb-FiHXmCyH`BPT!Xj~kxQ}6lCtX;}IFz>L z&jJ$8!7|m;>&7KL_LDvL&P_%RZ{Fy!su}*ie(e>Uz3fI0J0QgSp|2GrI)^a9*Lpew zi&r6RQQzSMlkDOkSln^n$<0l^Oe``DWz8Fz0 z4MeRp?@sS>{=}bK`?UyV_X$X$PT=C7x=yQESNcUHS|bKCdbkb+my@)j#e>%=VwNK~ zzPd*23+bpagIns>wBvT4RvrnP?jd6b^XDn8oFQ}9EYLap&^E;tpTt<0$I!*Wb zk)03B;EPQ_HR2bp6k9`e4nB7}--e^{+;#>LXk+{)%NIh_I#{nRN_ZIW&bO7rH$}KrYLaG(Z@a2K4;8LR}@w z$tPh*r#tiNp8*5B=y3am#Y&IFA)6#-iW{3Br9=W=*GZ9L74qTrT2>@{=U3F@f5u*q zOzs;@Rm1da=EBzn3*_H#*Q5pTtVQal;2z)@(uuGw%bck}(n6FX65cwrf zwqA@U=QO50UOewpMWsonX5TVZy5x2)J1T;EmzqfuG&WP8@X$z{lhLxT-D5NGnj$a@ z(%#!4@gAY}@DhH(1tcu3Gvc)a{%B1H?&0|UXV@$J&;!Loil@1`S!FfAA+wSGW<_q| zYbV9=UF0EVrPOr3>}sSdqRU0+WrXh)&Gk{J(S)~+ypH*4%Z7}vO1L}w3Qu?tYp_N| zr=~9FjC+-J2j0#BIUc8(r^HUG#ZF(nnvmknsZA=|^9SXl%@gOIAsIoS0G2)ssuU zLd*2p;uiXy-RlY0U!;fLWE}YF0G4BhInHnonC{Hu;*Wcm@5=g?QXmdqN7Ty2XTniG z6JO)bxDOl)Cp(h_K+eU`SJj^u+~i#uJHcbHPd*1A^3G%tD}{JCgdgcyDBg{XN7oab zx=f7{eGs;3g#naVvNLw3KI+-{7Yo!2l-JO%9rfCe2y`E$5O@8?xT(w9_90l1VzdB8 z=~w3|HFf=-za&dDTC}_R!*0Fj2JUpT@SN`VOBZpTc)MPgm#no>KV+Qpf&dX2&!Mbu z$4u{kkNnm?Ka3;7vmYJnR6H?s6UPL9@h^Tx5Pen2Xmhc&Thu3mHySMsOpB>8wXJ+ zIki=TZ4=e(x8goOXhU7OB=j$84!1P7MA~hq`D8z3Lzbz`624l%fzi^DpJVvCOTsj# z-=OW08kN>vqU3IckiGH>#M*k-K2WAxY(X#hZReyIhJG;#);+fx3Ui*L^#UQQbf8tKj9 zE}dekqRcf!ed5yK#A#E`bO#LL)%cY+=2)m)=Lg9=uRp+{9-Y2kNAWnUi=fA2z!-OZ zlB&9?q*jQ!YOp!w!ucebK($#`_>`z%Y)eR=owvd7slau;xbKY|$q=!8%03=yOc{&@ zaEk@jH;0ssA~Y_pGf1fvdI5JqAwsQm&|I27rXfy@lKW>%3-b+?3$B514$(Y#p^-Ly zikw3XjMvFW_nuF4kd%gJXu-BdS!UxWaj zgtkBO%lM3kI}6VACL2~8A0Kx)zEsx|ls2yf>$6Ixxn!C&E!j9%vuH%sV70o~DpTEO zv`nk_@gl|9y?bFMDjqNvhc5g3sBObIx6LfaBL#;i9eP9QY4LjHF%`G7+rd52J0xG{ z`MpA}w37#qkQ>SXwXdRTI%yIO)rt=&lq}o;1g^ZmiiCT5xpj_P6lz?*hmmedmQ`j( z0OKDi-!2;HKQTbxU!z;W8_O?38rk|djfZx+Y}#@MvaPhj<))@`R0#*I+GDXt;FBDt06W*BU?h7CG{u)#JN7;E)cZ6>SUk&9II{Qw_R726WIXQj1X-GDs zNnqKp+o{AJD{EuS(zyJWk@X0!6dLQSWg-oZ)4F&H_CJBqe?zaDv}%tRqTRiZ;9bij z{*|U@+#17wmZoi?V^}ZCUAUfuV?J84RPfSp9(@m^z}5(OAp9_TuxO$+rGtkG7ov-+ zbqu!TSm!?5+cwjkvA$87bDoK8jZGrrGJa=H-U7{qW8hfV=GaOZC|dD*QK73)5xRwl z9r59V&k*zo-k1kjv9~2QcOl)Dp?fH)sZNyO80rF4Y<4RZU!3I_2(hdRw4~*FMbUr8 zIjtIiRJGTL%^Zv^ElO^CLBzrtGESC2Yj4s&THZlC(*|kGSuXwg@H+aY zU^*;HmdyhFca_tSGF^{k$Op(cD~AfAG(z`0J49>k_4(djPtKFc3o9tCSMM=?X`7o4 zfqusL2|m>C{;7kQ|B8b@fEP2BMO<0*Xit_0F2=oGx1(DR4lxeSK_7Q!{3G6 zN`v=8nZpdT0!-0i&rt!b=^7a-{eGSnZ9?ds22 zP>LB3R;gnxz7v36e|+iB9ajxnrZ31!MCpl`zb*3qiQfEb_|UN4hwqTptVAR;hUdi8 zD0@3rO*Jrm6CL<6Oy>A{zXn^Vby!o+Q4)My@Zzd6o%nsSN#^w*KeAJN=}TI|z+yt`KW6>KsutVULX6h>@0gM=3W^6#TKI`7SJ*e!`Vt;gtKbc zn?XKDu7OC4{Kdq1j6tw1J8Vu-Ba<``9H&Z2n(&tTBgIS6gu@OeYt~mU&O=XlZ=;W1 zAXIM3k|rLOy#HGe!4?GGy`v`yfNN!peC>jFLREw1&9&?TSgp^B_be#PkP?LdPvcCM z-4<~p*+KPWgjUy!2b+n&ucSjVMBF!mz)BC!C?&(g4^&skXn4uw9lG*~6Tn;96GGL4 z6ZN0;Pz9#ilwxqC{4C2?^U=+p9L^M^1TH9_^Jav1LQ<{1G_s9WZZ1ccbF42~1RF%Z z$v0c7&s&Idyo41sLB0h_6-KB0@#gkp?{a4NaMsH$F-53iB!zh1-k{@otVMmy0))Q=vh(7(}9V>C)cecfu>S_a0Evt*?PT(DXeKQU|_%9 zb#CF)dA+`7W5v}X97%H`00AbUjm)^^=Mt|pwTs|jbm z>q6iE=YQJek(T)bt9=hP=XCDbj2V7%|LVi({hp(pohKTXMZB3%!L~*Q=H{p~es-GE zJ8V4>ZjDD1Pa%*OY52>&F1k6Q!})mUxvOH$uyvFh1PQd7z=gZD*$xwts#>_rCZNXO zzQB?rYQWoJz({M-mawEubFSyk_sB&KwH6s#=~D{7V|h=A$@zFP zzw`a_=qdcA;6+VpcLIz7w0evxr`+E)_;rhI%_6ri{jZoxfeCp^WC0fDVGbO(J}E<^ W#n?y;+OUd60PrC!x8wbZ*v@K{&uuGO{zD#}sBs{#pf=imr8 zgxrMFkPC7`?u3Ng0l}@cTea)BMX99Ks&u8xz8_TTY=Pa*_K)ri`6n}ZXTJHK-}$`R zjtvQVD{>WTF6!P)l$R0q&|UV>T;?_B4{1&h$xc6%#SIDedIfP_!Qr90u!nV99@d3< z8C!<_!a$)=i-zFc@9qoVx_QsLYgVk9`qaoz`*-c}-4=N!5`3ro{>mR{g6BcO8bgN6g#(N*h=(8Ry_j$qar7JQ1Zb=xU``H3Hwfpd;He+-i zAv0;`3cC5~%5R*}4VOG}#^8ge`UeJ?Cwm_arDvp~Q*sE&_{`kQY$An}SDaQ*ScrzG zRWv$-T2@Z1WY#d*<(S3`7;deA#S=HT@P)N-i&7#JDq6LTQWZm^YlV$+v$n&^Y`2SN zqZa)fpsAC*xk*Ev-k}=e9QHjD!wQI*72l^_MR(uxxz=0^0EV7jkYK&|RN=-&vyW|C zpS2_EUh=+>$ne;^_8vb>ju-$CB_A!k?0mDP+aSje?ndy#J=FuWz68bYVy2YQ@&|IgY4%saFtvX`y-*)C01}XS9*rXq@maaKIV8%t)Vvaq0TLQQ z5qG&qgi^j;)BBPt~|luk1)&z3^@DIudxMThjzu@r8#29 zV0bVEVemY`fJ)8E%gP}Yp3BWI%`Pe$VW^_AAxZ_2%B-hx*dz>JAQUt-S4-F;xkA{| zMuU}FkxHe}wHw+@?ONE8 z+o^>Mu-+kk#LR}}&nFpci;g=Nm3Kx;2J)9xh3~)A=De-kvo#WQg6GETmtPH0b=^M8 z{Xy7(OIM%weD%h2AQ4&F>F87v8I_h(kVDKZPR^&46G}?Z5S_tf(Krx?T1;a#FsgYZ zj6f(7H@0x4Jh4J4lBig4tFBpX)auPfli3V+sM>9<4rhy7KPE&=r|m5>0%3X-5s*7A z(icDk#+D@pdTxGp_0A5jq$)H)dNu-Vq?a^)*)16N^syFj|&9MX_V; z9CxoY<@Kew&k~jN`Jx640^yxHZw3O9lYu@@KA%n~Adp5NhyY?SoiP(CqLOLM+E>_h zObn*6j?EK+Zs0*OxkA}0hb0a^atv{z1I*ZQ3ctCtQ0hcxUwcJ>qVo7jlGk$=4p zVQxrMTubSaJ4vd+6?X59sZ;e{FqQD=8QD1mA}J*!FE5K+NX{=gPbsR%#+8 zXpTHq-AoRn-XFu~F&p{KEfOi812Ec@uuLmc8H^g8S#GqdEf(13Zg*&1ZtFN0@=hD} z!YIaK(B6+Rq-5~4PlG@92iXXn)}LYxKiL|*GM!%&n`>T!sZCVw=}pO- z-jd=fqSAr_Ux zje;Qba7i^|8dG@u7G*O}rPgTGaH~>8_=8Y&RGmFr)chZ-%c+`N2HTSWv?L0NubF_nm?LzPv< zXgZ$BuBzr9W+G!sC~9h~5lf{Ik`Wb1iH@%}nzVYI$=YVNNMW1D;S{+&)~+!zBp@Sw zbABTjI0zQY^?_0;(qrV;kfW~j&{A# zV79Bk)_@&dZbN669Ue0uQozx4HmVoshhZ`0$otP{XYj%HZpv_<`M72o-*orR=Y(uf zRz5iz_L{TtZoo>vg6dlInKmWi^J{lo%bl;h z{2UsE%qv1BIt`RnL0Sf}m`J9S7ZjCLky05Dl~#ggq_Q|PZp{%EvN=Rz{skTcH!Bnn zk`Ha0Txk^O%;w<^QG?9^JDqNixa*>2Y>-t-Y?CHD-=!K_un2fm?&JPIJnCD1&G7bE zsi4o#4)t#i-LXDxNA#@$d`R8m*mW^UNxJKx)jJb%er)w)5yP#n6(+6RFmZoG3^xd) zhQ+Dk*3f?$h;D3<#Qf{PNB+D>HFQ0F-nL;M3GLG+2J_as?8*@wcCB;FcT@ zzEaT{(Onf5QXL-a^;s9Jy)FigzQ5Ip%&bb!@oK}abEX@cyh$7X14!im0HPTO#5$V+ zq+~g3C}N%;Y4hWK9$30GPSVfsz@`ofhD!^lul>?`WNC(@{!A}U$PJIVL^DQLO)nl} zVx5Xiaz1?Nzb~!BzbqrFF+s$M*7@Ut5E}cid#~yLbOQ7UPInzB`ohvM#_9FhA@A*6 zcE7D>?}*{P*m8C0W#@{TZp&HRc|y~<0ne9u)K7*;BI8oC3bJx?i^)JtvXiM$Sp@}6 zO{Os_SnRiHz;Jm@{KmR^2o^{r5VF(TV90wWhKY4J1Gsb;e@LYM}v@6NW(F}Caex-U;u! zToJR->3Qjyq(Tx9-Hf7&9CR>k5k#r1sG`%E?8<6x@aPt#L16AG6jEedfoX-TkI}KK zfE^B(ThwVD69Xgzdn^&?Rr9c3Mfq%d>?J_26r1~x{H;dGv0q>AQ)p!;Vt1}D)-Mr$ z&j-f%;-%Z|(eEEzAstS}sr~V5Yp;3NJ(?k+-;6?~KXGRQdWFx-&&(zlk@5=4vWhDS z!8G7jh15zqxH55yxb)h`%RHDlilLG#_29ZRnheEoGDIHrm=qE~5jRS)ICI`81!7lm zMZs);1>>9h2*sg9>Kp!S+mi4Zg1L3!72OBS(eEAX@7@zY_w=55D=?(wQsO$*$M_C! zA8W%j)T$?h{pWUt#<6BXCG;{jtGb3>mr^}qR{}_ixULj#QL9^ZI+eyG)LZ1nc2kGb zW>>>b3u0IDF*#(&6&$?+sMXxL;0jJ2XXUarj+me zyC*p>q@ibS&w;gI`H7PTzc_{asD&24!F#bU=`$wkvNt~qIQygf=yPBPW+tbR(lT=L zvx(%Q^n%hPH0X*-T2%$TvaAfvVAU`goB~X3Q%x-fadrvs$Nq+;TJ3Ouo5e<}vfW~~ zxgAa|3}m-U(mg)Oa?CIZB8g<*$A2b_NTSctYp*`bNO)!{$cX=*(4P5adzMIA^9~e* z$Mz-5qGihyUW^T(dU~Z-0vEpO=o@Iev%z>XNq%DG6x0*9kAIiMayl7}XU~L68RaYv zj@$4K2E%Jak7)Z(k|-ONM2p;HYc+RR>>j5}2YYN?7o|Pp=j8u@L_h3_GT@09yQQ;H GZ~qHVLrA>< diff --git a/assets/src/js/base/custom.js b/assets/src/js/base/custom.js deleted file mode 100644 index 7c063fe71..000000000 --- a/assets/src/js/base/custom.js +++ /dev/null @@ -1,99 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -// Aggiunta dell'ingranaggio all'unload della pagina -$(window).on("beforeunload", function () { - $("#main_loading").show(); -}); - -// Rimozione dell'ingranaggio al caricamento completo della pagina -$(window).on("load", function () { - $("#main_loading").fadeOut(); -}); - -// Fix multi-modal -$(document).on('hidden.bs.modal', '.modal', function () { - $(this).remove(); - $('.modal:visible').length && $(document.body).addClass('modal-open'); -}); - -$(document).ready(function () { - // Standard per i popup - toastr.options = { - "closeButton": true, - "debug": false, - "newestOnTop": false, - "progressBar": true, - "positionClass": "toast-top-right", - //"preventDuplicates": true, - "onclick": null, - "showDuration": "300", - "hideDuration": "1000", - "timeOut": "12000", - "extendedTimeOut": "8000", - "showEasing": "swing", - "hideEasing": "linear", - "showMethod": "fadeIn", - "hideMethod": "fadeOut" - }; - - // Imposta lo standard per la conversione dei numeri - if (numeral.locales['current_locale'] === undefined) { - numeral.register('locale', 'current_locale', { - delimiters: { - thousands: globals.thousands, - decimal: globals.decimals, - }, - abbreviations: { - thousand: 'k', - million: 'm', - billion: 'b', - trillion: 't' - }, - currency: { - symbol: '€' - } - }); - } - numeral.locale('current_locale'); - numeral.defaultFormat('0,0.' + ('0').repeat(globals.cifre_decimali)); - - // Richiamo alla generazione di Datatables - start_datatables(); - - // Calendario principale - start_complete_calendar("#daterange", function (start, end) { - // Esegue il submit del periodo selezionato e ricarica la pagina - $.get(globals.rootdir + '/core.php?period_start=' + start.format('YYYY-MM-DD') + '&period_end=' + end.format('YYYY-MM-DD'), function (data) { - location.reload(); - }); - }); - - // Messaggi automatici di eliminazione - $(document).on('click', '.ask', function () { - message(this); - }); - - // Forza l'evento "blur" nei campi di testo per formattare i numeri con - // jquery inputmask prima del submit - setTimeout(function () { - $('form').on('submit', function () { - $('input').trigger('blur'); - }); - }, 1000); -}); diff --git a/assets/src/js/base/datatables-buttons.js b/assets/src/js/base/datatables-buttons.js deleted file mode 100644 index 9838dd939..000000000 --- a/assets/src/js/base/datatables-buttons.js +++ /dev/null @@ -1,144 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -$(document).ready(function () { - // Pulsanti di Datatables - $(".btn-csv").off("click").on("click", function (e) { - var table = $(document).find("#" + $(this).closest("[data-target]").data("target")).DataTable(); - - table.buttons(0).trigger(); - }); - - $(".btn-excel").off("click").on("click", function (e) { - var table = $(document).find("#" + $(this).closest("[data-target]").data("target")).DataTable(); - - table.buttons(3).trigger(); - }); - - $(".btn-pdf").off("click").on("click", function (e) { - var table = $(document).find("#" + $(this).closest("[data-target]").data("target")).DataTable(); - - table.buttons(4).trigger(); - }); - - $(".btn-copy").off("click").on("click", function (e) { - var table = $(document).find("#" + $(this).closest("[data-target]").data("target")).DataTable(); - - table.buttons(1).trigger(); - }); - - $(".btn-print").off("click").on("click", function (e) { - var table = $(document).find("#" + $(this).closest("[data-target]").data("target")).DataTable(); - - table.buttons(2).trigger(); - }); - - $(".btn-select-all").click(function () { - var table_selector = "#" + $(this).closest("[data-target]").data("target"); - var wrapper = getTable(table_selector); - var table = wrapper.datatable; - - // Visualizzazione del caricamento - $("#main_loading").show(); - - // Parametri della richiesta - var params = table.ajax.params(); - params.length = -1; - - $.ajax({ - url: table.ajax.url(), - data: params, - type: 'GET', - dataType: "json", - success: function (response) { - var row_ids = response.data.map(function (a) { - return a.id; - }); - - // Chiamata di selezione completa - wrapper.addSelectedRows(row_ids); - table.clear().draw(); - - $("#main_loading").hide(); - } - }) - }); - - $(".btn-select-none").click(function () { - var table_selector = "#" + $(this).closest("[data-target]").data("target"); - var wrapper = getTable(table_selector); - var table = wrapper.datatable; - - // Chiamata di deselezione completa - var row_ids = wrapper.getSelectedRows(); - wrapper.removeSelectedRows(row_ids); - table.clear().draw(); - }); - - $(document).on("click", ".select-checkbox", function () { - var row = $(this).parent(); - var row_id = row.attr("id"); - - var table_selector = $(this).closest(".dataTable"); - var wrapper = getTable(table_selector); - - if (row.hasClass("selected")) { - //table.datatable.rows("#" + row_id).select(); - wrapper.addSelectedRows(row_id); - } else { - //table.datatable.rows("#" + row_id).deselect(); - wrapper.removeSelectedRows(row_id); - } - }); - - $(".bulk-action").click(function () { - var table = $(document).find("#" + $(this).parent().parent().parent().parent().data("target")); - - if (table.data('selected')) { - $(this).attr("data-id_records", table.data('selected')); - $(this).data("id_records", table.data('selected')); - - if ($(this).data("type") === "modal") { - var data = JSON.parse(JSON.stringify($(this).data())); - var href = data.url; - - delete data.url; - delete data.title; - delete data.op; - delete data.backto; - delete data.blank; - - var values = []; - for (var name in data) { - values.push(name + '=' + data[name]); - } - - var link = href + (href.indexOf('?') !== -1 ? '&' : '?') + values.join('&'); - - launch_modal($(this).data("title"), link); - } else { - message(this); - } - - $(this).attr("data-id_records", ""); - $(this).data("id_records", ""); - } else { - swal(globals.translations.waiting, globals.translations.waitingMessage, "error"); - } - }); -}); diff --git a/assets/src/js/base/navigation.js b/assets/src/js/base/navigation.js deleted file mode 100644 index 82405dde1..000000000 --- a/assets/src/js/base/navigation.js +++ /dev/null @@ -1,68 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -$(document).ready(function () { - // Tabs - $('.nav-tabs').tabs(); - - // Entra nel tab indicato al caricamento della pagina - var hash = location.hash ? location.hash : getUrlVars().hash; - if (hash && hash != '#tab_0') { - $('ul.nav-tabs a[href="' + hash + '"]').tab('show').trigger('shown.bs.tab'); - } else { - removeHash(); - } - - $(window).bind('beforeunload', function () { - if (location.hash == '#tab_0') { - removeHash(); - } - }); - - // Nel caso la navigazione sia da mobile, disabilito il ritorno al punto precedente - if (!globals.is_mobile) { - // Salvo lo scroll per riportare qui l'utente al reload - $(window).on('scroll', function () { - if (sessionStorage != undefined) { - sessionStorage.setItem('scrollTop_' + globals.id_module + '_' + globals.id_record, $(document).scrollTop()); - } - }); - - // Riporto l'utente allo scroll precedente - if (sessionStorage['scrollTop_' + globals.id_module + '_' + globals.id_record] != undefined) { - setTimeout(function () { - scrollToOffset(sessionStorage['scrollTop_' + globals.id_module + '_' + globals.id_record]); - }, 1); - } - } - - $('.nav-tabs a').click(function (e) { - $(this).tab('show'); - - let scroll = $('body').scrollTop() || $('html').scrollTop(); - window.location.hash = this.hash; - - $('html,body').scrollTop(scroll); - }); - - // Fix per la visualizzazione di Datatables all'interno dei tab Bootstrap - $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { - $($.fn.dataTable.tables(true)).DataTable().columns.adjust(); - $($.fn.dataTable.tables(true)).DataTable().scroller.measure(); - }); -}); diff --git a/assets/src/js/base/sidebar.js b/assets/src/js/base/sidebar.js deleted file mode 100644 index 90c705a08..000000000 --- a/assets/src/js/base/sidebar.js +++ /dev/null @@ -1,108 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -$(document).ready(function () { - // Fix per il menu principale - $('.sidebar-menu').tree({ - followLink: true, - }); - - $('.sidebar-menu > li.treeview i.fa-angle-left').click(function (e) { - e.preventDefault(); - $(this).find('ul').stop().slideDown(); - }); - - $('.sidebar-menu > li.treeview i.fa-angle-down').click(function (e) { - e.preventDefault(); - $(this).find('ul').stop().slideUp(); - }); - - const elenco_menu = $('.treeview-menu > li.active'); - for (i = 0; i < elenco_menu.length; i++) { - const elemento = $(elenco_menu[i]); - elemento.parent().show().parent().addClass('active'); - elemento.parent().parent().find('i.fa-angle-left').removeClass('fa-angle-left').addClass('fa-angle-down'); - } - - // Menu ordinabile - if (!globals.is_mobile) { - sortable(".sidebar-menu", { - axis: "y", - cursor: "move", - dropOnEmpty: true, - scroll: true, - })[0].addEventListener("sortupdate", function (e) { - let order = $(".sidebar-menu > .treeview[data-id]").toArray().map(a => $(a).data("id")) - - $.post(globals.rootdir + "/actions.php", { - id_module: globals.order_manager_id, - op: "sort_modules", - order: order.join(","), - }); - }); - } - - // Mostra/nasconde sidebar del menu principale - $(".sidebar-toggle").on("click", function () { - if ($("body").hasClass("sidebar-collapse")) { - session_set("settings,sidebar-collapse", 0, 1, 0); - } else { - session_set("settings,sidebar-collapse", 1, 0, 0); - } - - setTimeout(function () { - window.dispatchEvent(new Event('resize')); - }, 350); - }); - - // Barra plugin laterale - const pluginToggle = $(".control-sidebar-toggle"); - const largeScreen = screen.width > 1200; - - // Gestione click sul pulsante per il toggle - pluginToggle.on("click", function () { - $("aside.content-wrapper, .main-footer").toggleClass("with-control-sidebar"); - - toggleControlSidebar(); - }); - - // Gestione click sulla sidebar per evitare chiusura - $(".control-sidebar").on("click", function (e) { - if (largeScreen && e.target.tagName === 'A' && $(".main-footer").hasClass("with-control-sidebar")) { - toggleControlSidebar(); - } - }); - - // Barra plugin laterale disabilitata per schermi piccoli - if (largeScreen && !globals.collapse_plugin_sidebar) { - pluginToggle.click(); - } -}); - -/** - * Funzione dedicata alla gestione del toggle della sidebar. - */ -function toggleControlSidebar() { - const sidebar = $(".control-sidebar"); - - sidebar.toggleClass("control-sidebar-open"); - - if (sidebar.hasClass("control-sidebar-open")) { - sidebar.show(); - } -} diff --git a/assets/src/js/base/slider.js b/assets/src/js/base/slider.js deleted file mode 100644 index 7e9784e71..000000000 --- a/assets/src/js/base/slider.js +++ /dev/null @@ -1,65 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -$(document).ready(function () { - // Pulsante per il ritorno a inizio pagina - var slideToTop = $("
"); - slideToTop.html(''); - slideToTop.css({ - position: 'fixed', - bottom: '20px', - right: '25px', - width: '40px', - height: '40px', - color: '#eee', - 'font-size': '', - 'line-height': '40px', - 'text-align': 'center', - 'background-color': 'rgba(255, 78, 0)', - 'box-shadow': '0 0 10px rgba(0, 0, 0, 0.05)', - cursor: 'pointer', - 'z-index': '99999', - opacity: '.7', - 'display': 'none' - }); - - slideToTop.on('mouseenter', function () { - $(this).css('opacity', '1'); - }); - - slideToTop.on('mouseout', function () { - $(this).css('opacity', '.7'); - }); - - $('.wrapper').append(slideToTop); - $(window).scroll(function () { - if ($(window).scrollTop() >= 150) { - if (!$(slideToTop).is(':visible')) { - $(slideToTop).fadeIn(500); - } - } else { - $(slideToTop).fadeOut(500); - } - }); - - $(slideToTop).click(function () { - $("html, body").animate({ - scrollTop: 0 - }, 500); - }); -}); diff --git a/assets/src/js/base/supersearch.js b/assets/src/js/base/supersearch.js deleted file mode 100644 index 23212355a..000000000 --- a/assets/src/js/base/supersearch.js +++ /dev/null @@ -1,91 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -$(document).ready(function () { - const searchInput = $('#supersearch'); - const searchButton = searchInput.parent().find('i'); - const searches = []; - - autocomplete({ - minLength: 1, - input: searchInput[0], - emptyMsg: globals.translations.noResults, - debounceWaitMs: 500, - fetch: function(text, update) { - text = text.toLowerCase(); - - // Registrazione ricerca - searches.push(text); - searchButton - .removeClass('fa-search') - .addClass('fa-spinner fa-spin'); - - $.ajax({ - url: globals.rootdir + '/ajax_search.php', - dataType: "JSON", - data: { - term: text, - }, - success: function (data) { - // Fix per gestione risultati null - data = data ? data : []; - - // Trasformazione risultati in formato leggibile - const results = data.map(function (result) { - return { - label: result.label ? result.label : '

' + result.title + '

' + result.labels - .join('').split('
,').join('
'), - group: result.category, - link: result.link, - value: result.title - } - }); - - // Rimozione ricerca in corso - searches.pop(); - if (searches.length === 0) { - searchButton - .removeClass('fa-spinner fa-spin') - .addClass('fa-search'); - } - - update(results); - }, - error: function (){ - searchButton - .removeClass('fa-spinner fa-spin') - .addClass('fa-exclamation-triangle'); - } - }); - }, - preventSubmit: true, - disableAutoSelect: true, - onSelect: function(item) { - window.location.href = item.link; - }, - customize: function(input, inputRect, container, maxHeight) { - container.style.width = '600px'; - }, - render: function(item, currentValue){ - const itemElement = document.createElement("div"); - itemElement.innerHTML = item.label; - //
" + item.value + "
" + item.label + "
- return itemElement; - } - }); -}); diff --git a/assets/src/js/base/widgets.js b/assets/src/js/base/widgets.js deleted file mode 100644 index 3aae07b43..000000000 --- a/assets/src/js/base/widgets.js +++ /dev/null @@ -1,52 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -$(document).ready(function () { - const widgets = sortable("#widget-top, #widget-right", { - forcePlaceholderSize: true, - items: 'li', - cursor: 'move', - dropOnEmpty: true, - acceptFrom: '.widget', - scroll: true, - }); - - for (const sorting of widgets) { - sorting.addEventListener("sortupdate", function (e) { - // Rimuovo l'evidenziazione dell'area widget - $('.widget').removeClass('bordered'); - - // Salvo la lista su cui ho eseguito il drop - const location = $(e.detail.destination.container).attr('id').replace('widget-', ''); - - let order = $(".widget li[data-id]").toArray().map(a => $(a).data("id")) - $.post(globals.rootdir + "/actions.php", { - id_module: globals.order_manager_id, - id_module_widget: globals.id_module, - op: 'sort_widgets', - location: location, - order: order.join(','), - }); - }); - - sorting.addEventListener("sortstart", function (e) { - // Evidenzio le aree dei widget - $('.widget').addClass('bordered'); - }); - } -}); diff --git a/assets/src/js/functions/allegati.js b/assets/src/js/functions/allegati.js deleted file mode 100644 index f15708843..000000000 --- a/assets/src/js/functions/allegati.js +++ /dev/null @@ -1,308 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -// Disabling autoDiscover, otherwise Dropzone will try to attach twice. -Dropzone.autoDiscover = false; - -/** - * Restituisce filename ed estensione di un file indicato. - * @param path - * @returns [string, string] - */ -function getFilenameAndExtension(path) { - let filename_extension = path.replace(/^.*[\\\/]/, ''); - let filename = filename_extension.substring(0, filename_extension.lastIndexOf('.')); - let ext = filename_extension.split('.').pop(); - - return [filename, ext]; -} - -/** - * Inizializza la gestione degli allegati. - * @param gestione - */ -function initGestioneAllegati(gestione) { - const dropzone_id = '#' + gestione.attr('id') + ' .dropzone'; - const maxFilesize = gestione.data('max_filesize'); - if ($(dropzone_id).length === 0) { - return; - } - - let params = new URLSearchParams({ - op: "aggiungi-allegato", - id_module: gestione.data('id_module'), - id_plugin: gestione.data('id_plugin'), - id_record: gestione.data('id_record'), - }).toString(); - - let dragdrop = new Dropzone(dropzone_id, { - dictDefaultMessage: globals.translations.allegati.messaggio + ".
(" + globals.translations.allegati.maxFilesize.replace('_SIZE_', maxFilesize) + ")", - paramName: "file", - maxFilesize: maxFilesize, // MB - uploadMultiple: false, - parallelUploads: 2, - addRemoveLinks: false, - autoProcessQueue: true, - autoQueue: true, - url: globals.rootdir + "/actions.php?" + params, - init: function (file, xhr, formData) { - this.on("success", function (file) { - dragdrop.removeFile(file); - }); - - this.on("complete", function (file) { - // Ricarico solo quando ho finito - if (this.getUploadingFiles().length === 0 && this.getQueuedFiles().length === 0) { - ricaricaAllegati(gestione); - } - }); - } - }); -} - -/** - * Funzione per l'apertura della schermata di modifica per una categoria di allegati. - * @param gestione - * @param pulsanteModifica - */ -function modificaCategoriaAllegati(gestione, pulsanteModifica) { - const categoria = $(pulsanteModifica).parent().parent(); - console.log(categoria) - - const nome = categoria.find(".box-title"); - nome.addClass('hidden'); - $(pulsanteModifica).addClass('hidden'); - - const pulsanteSalva = categoria.find(".category-save"); - const pulsanteAnnulla = categoria.find(".category-cancel"); - const inputNome = categoria.find(".category-name"); - pulsanteSalva.removeClass("hidden"); - pulsanteAnnulla.removeClass("hidden"); - inputNome.removeClass("hidden"); -} - -/** - * Funzione per salvare le modifiche effettuate su una categoria di allegati. - * @param gestione - * @param pulsanteSalva - */ -function salvaCategoriaAllegati(gestione, pulsanteSalva) { - const categoria = $(pulsanteSalva).parent().parent(); - - const nome = categoria.find(".box-title"); - const inputNome = categoria.find(".category-name"); - - mostraCaricamentoAllegati(gestione); - - $.ajax({ - url: globals.rootdir + "/actions.php", - cache: false, - type: "POST", - data: { - op: "modifica-categoria-allegato", - id_module: gestione.data('id_module'), - id_plugin: gestione.data('id_plugin'), - id_record: gestione.data('id_record'), - category: nome.text(), - name: inputNome.val(), - }, - success: function (data) { - ricaricaAllegati(gestione); - }, - error: function (gestione) { - ricaricaAllegati(gestione); - } - }); -} - -/** - * Funzione per caricare un nuovo allegato. - * @param gestione - */ -function aggiungiAllegato(gestione) { - const id = "#" + gestione.attr('id'); - const form = $(id + " #upload-form"); - - form.ajaxSubmit({ - url: globals.rootdir + "/actions.php", - data: data, - type: "post", - uploadProgress: function (event, position, total, percentComplete) { - $(id + " #upload").prop("disabled", true).html(percentComplete + "%").removeClass("btn-success").addClass("btn-info"); - }, - success: function (data) { - ricaricaAllegati(gestione); - }, - error: function (data) { - alert(globals.translations.allegati.errore + ": " + data); - } - }); -} - -/** - * Funzione per mostrare il loader di caricamento per gli allegati. - * @param gestione - */ -function mostraCaricamentoAllegati(gestione) { - const id = "#" + gestione.attr('id'); - - localLoading($(id + " .panel-body"), true); -} - -/** - * Funzione dedicata al caricamento dinamico degli allegati. - * @param gestione - */ -function ricaricaAllegati(gestione) { - const id = "#" + gestione.attr('id'); - - let params = new URLSearchParams({ - op: "list_attachments", - id_module: gestione.data('id_module'), - id_plugin: gestione.data('id_plugin'), - id_record: gestione.data('id_record'), - }).toString(); - - $(id).load(globals.rootdir + "/ajax.php?" + params, function () { - localLoading($(id + " .panel-body"), false); - - const nuovoAllegato = $(id + " table tr").eq(-1).attr("id"); - if (nuovoAllegato !== undefined) { - $("#" + nuovoAllegato).effect("highlight", {}, 1500); - } - }); -} - -/** - * Funzione per l'apertura della pagina di gestione dei dati dell'allegato. - * @param button - */ -function modificaAllegato(button) { - const gestione = $(button).closest(".gestione-allegati"); - const allegato = $(button).closest("tr").data(); - - let params = new URLSearchParams({ - op: "visualizza-modifica-allegato", - id_module: gestione.data('id_module'), - id_plugin: gestione.data('id_plugin'), - id_record: gestione.data('id_record'), - id_allegato: allegato.id, - }).toString(); - - openModal(globals.translations.allegati.modifica, globals.rootdir + "/actions.php?" + params); -} - -/** - * Funzione per gestire il download di un allegato. - * @param button - */ -function saggiungiAllegato(button) { - const gestione = $(button).closest(".gestione-allegati"); - const allegato = $(button).closest("tr").data(); - - let params = new URLSearchParams({ - op: "download-allegato", - id_module: gestione.data('id_module'), - id_plugin: gestione.data('id_plugin'), - id_record: gestione.data('id_record'), - id: allegato.id, - filename: allegato.filename, - }).toString(); - - window.open(globals.rootdir + "/actions.php?" + params, "_blank") -} - -/** - * Funzione per l'apertura dell'anteprima di visualizzazione allegato. - * @param button - */ -function visualizzaAllegato(button) { - const allegato = $(button).closest("tr").data(); - - let params = new URLSearchParams({ - file_id: allegato.id, - }).toString(); - - openModal(allegato.nome + ' (' + allegato.filename + ')', globals.rootdir + "/view.php?" + params); -} - -/** - * Funzione per la gestione della rimozione di un allegato specifico. - * - * @param button - */ -function rimuoviAllegato(button) { - const gestione = $(button).closest(".gestione-allegati"); - const allegato = $(button).closest("tr").data(); - - swal({ - title: globals.translations.allegati.elimina, - type: "warning", - showCancelButton: true, - confirmButtonText: globals.translations.allegati.procedi, - }).then(function () { - mostraCaricamentoAllegati(gestione); - - // Parametri della richiesta AJAX - let params = new URLSearchParams({ - op: "rimuovi-allegato", - id_module: gestione.data('id_module'), - id_plugin: gestione.data('id_plugin'), - id_record: gestione.data('id_record'), - id_allegato: allegato.id, - filename: allegato.filename, - }).toString(); - - // Richiesta AJAX - $.ajax(globals.rootdir + "/actions.php?" + params) - .then(function () { - ricaricaAllegati(gestione); - }); - }).catch(swal.noop); -} - -function impostaCategorieAllegatiDisponibili(gestione, categorie) { - // Disabilitazione per rimozione input in aggiunta - return; - - const id = "#" + gestione.attr('id'); - const input = $("#modifica-allegato #categoria_allegato")[0]; - - autocomplete({ - minLength: 0, - input: input, - emptyMsg: globals.translations.noResults, - fetch: function (text, update) { - text = text.toLowerCase(); - const suggestions = categorie.filter(n => n.toLowerCase().startsWith(text)); - - // Trasformazione risultati in formato leggibile - const results = suggestions.map(function (result) { - return { - label: result, - value: result - } - }); - - update(results); - }, - onSelect: function (item) { - input.value = item.label; - }, - }); -} diff --git a/assets/src/js/functions/datatables.js b/assets/src/js/functions/datatables.js deleted file mode 100755 index 9b1e0a1a6..000000000 --- a/assets/src/js/functions/datatables.js +++ /dev/null @@ -1,521 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -function start_local_datatables() { - $('.datatables').each(function () { - if (!$.fn.DataTable.isDataTable($(this))) { - $(this).DataTable({ - language: globals.translations.datatables, - retrieve: true, - ordering: true, - searching: true, - paging: false, - order: [], - lengthChange: false, - scrollY: "70vh", - }); - } - }); -} - -// Datatable -function start_datatables() { - start_local_datatables(); - - $('.main-records').each(function () { - const $this = $(this); - - // Controlla che la tabella non sia già inizializzata - if (!$.fn.DataTable.isDataTable('#' + $this.attr('id'))) { - const id_module = $this.data('idmodule'); - const id_plugin = $this.data('idplugin'); - const id_parent = $this.data('idparent'); - - // Parametri di ricerca da url o sessione - const search = getTableSearch(); - - const column_search = []; - $this.find("th").each(function () { - const id = $(this).attr('id').replace("th_", ""); - const single_value = search["search_" + id] ? search["search_" + id] : ""; - - column_search.push({ - "sSearch": single_value, - }); - }); - - $this.on('preInit.dt', function (ev, settings) { - $('#mini-loader').show(); - }); - - const table = $this.DataTable({ - language: globals.translations.datatables, - autoWidth: true, - dom: "ti", - serverSide: true, - deferRender: true, - ordering: true, - searching: true, - aaSorting: [], - aoSearchCols: column_search, - scrollY: "60vh", - scrollX: '100%', - retrieve: true, - stateSave: true, - rowId: 'id', - stateSaveCallback: function (settings, data) { - sessionStorage.setItem('DataTables_' + id_module + '-' + id_plugin + '-' + id_parent, JSON.stringify(data)); - }, - stateLoadCallback: function (settings) { - return JSON.parse(sessionStorage.getItem('DataTables_' + id_module + '-' + id_plugin + '-' + id_parent)); - }, - columnDefs: [{ - searchable: false, - orderable: false, - width: '1%', - className: 'select-checkbox', - targets: 0 - }], - select: { - style: 'multi', - selector: 'td:first-child' - }, - buttons: getDatatablesButtons($this), - scroller: { - loadingIndicator: true, - displayBuffer: globals.dataload_page_buffer, - }, - ajax: { - url: "ajax_dataload.php?id_module=" + id_module + "&id_plugin=" + id_plugin + "&id_parent=" + id_parent, - type: 'GET', - dataSrc: "data", - }, - initComplete: initComplete, - drawCallback: drawCallback, - footerCallback: footerCallback, - }); - - table.on('processing.dt', function (e, settings, processing) { - if (processing) { - $('#mini-loader').show(); - } else { - $('#mini-loader').hide(); - } - }) - } - }); -} - -/** - * Funzione per evitare il sorting al click della colonna. - * Utilizzata per evitare il sorting nelle ricerche. - * @param {*} e - */ -function stopTableSorting(e) { - if (!e) var e = window.event; - e.cancelBubble = true; - if (e.stopPropagation) e.stopPropagation(); -} - -/** - * Funzione per resettare il campo di ricerca in una specifica colonna. - * @param {string} type - */ -function resetTableSearch(type) { - if (type == null) $('[id^=th_] input').val('').trigger('keyup'); - else $('[id^=th_' + type + '] input').val('').trigger('keyup'); -} - -/** - * Sostituisce i caratteri speciali per la ricerca attraverso le tabelle Datatables. - * - * @param {string} field - * @return string - */ -function searchFieldName(field) { - return field.replace(' ', '-').replace('.', ''); -} - -/** - * Salva nella sessione la ricerca per le tabelle Datatables. - * - * @param {int} module_id - * @param {string} field - * @param {string} value - */ -function setTableSearch(module_id, field, value) { - session_set('module_' + module_id + ',' + 'search_' + searchFieldName(field), value, 0); -} - -/** - * Restituisce i valori di ricerca impostati nell'URL della pagina. - * @returns {{}} - */ -function getTableSearch() { - // Parametri di ricerca da url o sessione - const search = getUrlVars(); - - globals.search.forEach(function (value, index, array) { - if (search[array[index]] === undefined) { - search[array[index]] = array[value]; - } - }); - - return search; -} - -/** - * Restituisce i pulsanti da generare per la tabella Datatables. - * @returns - */ -function getDatatablesButtons(table) { - return [ - // Pulsante di esportazione CSV - { - extend: 'csv', - footer: true, - fieldSeparator: ";", - exportOptions: { - modifier: { - selected: true - }, - format: { - body: function (data, row, column, node) { - data = $('

' + data + '

').text(); - data_edit = data.replace('.', ''); // Rimozione punto delle migliaia - - return data_edit.match(/^[0-9,]+$/) ? data_edit : data; - } - } - } - }, - // Pulsante di esportazione tramite copia - { - extend: 'copy', - footer: true, - exportOptions: { - modifier: { - selected: true - } - } - }, - // Pulsante di esportazione via stampa della tabella - { - extend: 'print', - autoPrint: true, - footer: false, // Non funzionante in Firefox, e saltuarmente in Chrome - customize: function (win, config, datatable) { - const footer = datatable.table().footer().children[0]; - - const body = $(win.document.body); - body.find('table') - .addClass('compact') - .css('font-size', 'inherit') - .append(footer.cloneNode(true)); - - body.find('td:first-child, th:first-child') - .addClass('hide'); - - }, - exportOptions: { - modifier: { - selected: true - } - } - }, - // Pulsante di esportazione in formato Excel - { - extend: 'excel', - footer: true, - exportOptions: { - modifier: { - selected: true - }, - format: { - body: function (data, row, column, node) { - data = $('

' + data + '

').text(); - data_edit = data.replace('.', ''); // Fix specifico per i numeri italiani - data_edit = data_edit.replace(',', '.'); - - return data_edit.match(/^[0-9\.]+$/) ? data_edit : data; - } - } - } - }, - // Pulsante di esportazione in formato PDF - { - extend: 'pdf', - footer: true, - exportOptions: { - modifier: { - selected: true - } - } - }, - ]; -} - -function initComplete(settings) { - const api = this.api(); - const $this = $(this); - const search = getTableSearch(); - - api.columns('.search').every(function () { - const column = this; - - // Valore predefinito della ricerca - let tempo; - const header = $(column.header()); - const name = header.attr('id').replace('th_', ''); - - const value = search['search_' + name] ? search['search_' + name] : ''; - - $('
') - .appendTo(column.header()) - .on('keyup', function (e) { - clearInterval(tempo); - - // Fix del pulsante di pulizia ricerca e del messaggio sulla ricerca lenta - if (e.which != 9) { - if (!$(this).val()) { - if ($(this).parent().data("slow") != undefined) $("#slow").remove(); - $(this).removeClass('input-searching'); - $(this).next('.deleteicon').addClass('hide'); - } else { - if ($(this).parent().data("slow") != undefined && $("#slow").length == 0) { - $("#" + $this.attr('id') + "_info").parent().append(' ' + globals.translations.long + ''); - } - $(this).addClass('input-searching'); - $(this).next('.deleteicon').removeClass('hide'); - } - } - - function start_search(module_id, field, search_value) { - setTableSearch(module_id, field, search_value); - column.search(search_value).draw(); - } - - // Impostazione delle sessioni per le ricerche del modulo e del campo specificati - const module_id = $this.data('idmodule'); //+ "-" + $this.data('idplugin'); - const field = $(this).parent().attr('id').replace('th_', ''); - const value = $(this).val(); - if (e.keyCode == 13 || $(this).val() == '') { - start_search(module_id, field, value); - } else { - const tempo_attesa_ricerche = (globals.tempo_attesa_ricerche * 1000); - - tempo = window.setTimeout(start_search, tempo_attesa_ricerche, module_id, field, value); - } - }); - }); - - // Disabilito l'ordinamento alla pressione del tasto invio sull' - $("thead input, .search").on('keypress', function (e) { - stopTableSorting(e); - }); - - // Disabilito l'ordinamento al click sull' - $("thead input, .deleteicon").click(function (e) { - stopTableSorting(e); - }); - - $('.deleteicon').on("click", function (e) { - resetTableSearch($(this).parent().attr("id").replace("th_", "")); - }); -} - -function drawCallback(settings) { - const table = getTable(settings.nTable); - const datatable = table.datatable; - - $(".dataTables_sizing .deleteicon").addClass('hide'); - - $("[data-background]").each(function () { - $(this).parent().css("background", $(this).data("background")); - }); - - $("[data-color]").each(function () { - $(this).parent().css("color", $(this).data("color")); - }); - - $("[data-link]").each(function () { - const $link = $(this); - $(this).parent().not('.bound').addClass('bound').click(function (event) { - if ($link.data('type') === 'dialog') { - launch_modal(globals.translations.details, $link.data('link')); - } else { - openLink(event, $link.data('link')) - } - }); - $(this).parent().addClass("clickable"); - }); - - // Reimposto il flag sulle righe ricaricate selezionate in precedenza - const selected = table.getSelectedRows(); - datatable.rows().every(function (rowIdx) { - if (selected.includes(this.id())) { - datatable.row(':eq(' + rowIdx + ')', { - page: 'current' - }).select(); - } - }); -} - -function footerCallback(row, data, start, end, display) { - let i = -1; - const json = this.api().ajax.json(); - - this.api().columns().every(function () { - if (json.summable[i] !== undefined) { - $(this.footer()).addClass("text-right") - .attr("id", "summable") - .html(json.summable[i]); - } - - i++; - }); -} - -/** - * Restituisce un oggetto che permette di gestire le tabelle DataTables. - * - * @param selector - */ -function getTable(selector) { - const table = $(selector); - - const selected = new Map(); - const selected_ids = table.data('selected') ? table.data('selected').split(';') : []; - selected_ids.forEach(function (item, index) { - selected.set(item, true); - }); - - return { - table: table, - - id_module: table.data('idmodule'), - id_plugin: table.data('idplugin'), - - initDatatable: function () { - if (table.hasClass('datatables')) { - start_local_datatables(); - } else { - start_datatables(); - } - }, - datatable: table.DataTable(), - - // Funzioni per i contenitori relativi alla tabella - getSelectControllerContainer: function () { - return $('.row[data-target="' + table.attr('id') + '"]').find('.select-controller-container'); - }, - getExportContainer: function () { - return $('.row[data-target="' + table.attr('id') + '"]').find('.export-container'); - }, - getActionsContainer: function () { - return $('.row[data-target="' + table.attr('id') + '"]').find('.actions-container'); - }, - - // Gestione delle righe selezionate - selected: selected, - getSelectedRows: function () { - return Array.from(selected.keys()); - }, - saveSelectedRows: function () { - const selected_rows = this.getSelectedRows(); - table.data('selected', selected_rows.join(';')); - - // Abilitazione dinamica di azioni di gruppo e esportazione - const bulk_container = this.getActionsContainer(); - const export_buttons = this.getExportContainer().find('.table-btn'); - if (selected_rows.length > 0) { - bulk_container.removeClass('disabled').attr('disabled', false); - export_buttons.removeClass('disabled').attr('disabled', false); - } else { - bulk_container.addClass('disabled').attr('disabled', true); - export_buttons.addClass('disabled').attr('disabled', true); - } - - // Aggiornamento contatore delle selezioni - this.getSelectControllerContainer() - .find('.selected-count').html(selected_rows.length); - - // Aggiornamento del footer nel caso sia richiesto - if (globals.restrict_summables_to_selected) { - this.updateFooterForSelectedRows(); - } - }, - addSelectedRows: function (row_ids) { - row_ids = Array.isArray(row_ids) ? row_ids : [row_ids]; - row_ids.forEach(function (item, index) { - selected.set(item.toString(), true); - }); - - this.saveSelectedRows(); - }, - removeSelectedRows: function (row_ids) { - row_ids = Array.isArray(row_ids) ? row_ids : [row_ids]; - row_ids.forEach(function (item, index) { - selected.delete(item.toString()); - }); - - this.saveSelectedRows(); - }, - clearSelectedRows: function () { - selected.clear(); - this.saveSelectedRows(); - }, - - /** - * Nuovi valori dei campi summable - * @returns - */ - getSelectedRowsFooter: function () { - let ids = this.getSelectedRows(); - - return $.ajax({ - url: globals.rootdir + "/ajax.php", - type: "POST", - dataType: "json", - data: { - id_module: this.id_module, - id_plugin: this.id_plugin, - op: "summable-results", - ids: ids, - } - }); - }, - - /** - * Aggiornamento dei campi summable - */ - updateFooterForSelectedRows: function () { - let datatable = this.datatable; - - this.getSelectedRowsFooter().then(function (response) { - for (let [column, value] of Object.entries(response)) { - let index = parseInt(column) + 1; - let sel = datatable.column(index).footer(); - $(sel).addClass("text-right") - .attr("id", "summable") - .html(value); - } - }); - }, - }; -} diff --git a/assets/src/js/functions/dates.js b/assets/src/js/functions/dates.js deleted file mode 100755 index 56bc0214f..000000000 --- a/assets/src/js/functions/dates.js +++ /dev/null @@ -1,151 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -function getCalendarIcons() { - return { - time: 'fa fa-clock-o', - date: 'fa fa-calendar', - up: 'fa fa-chevron-up', - down: 'fa fa-chevron-down', - previous: 'fa fa-chevron-left', - next: 'fa fa-chevron-right', - today: 'fa fa-street-view', - clear: 'fa fa-trash', - close: 'fa fa-times' - }; -} - -function initDateInput(input) { - let date_format = dateFormatMoment(globals.date_format); - let calendar_icons = getCalendarIcons(); - let $input = $(input); - - $(input).datetimepicker({ - format: date_format, - locale: globals.locale, - icons: calendar_icons, - useCurrent: false, - minDate: moment($input.attr('min-date')).isValid() ? $input.attr('min-date') : false, - maxDate: moment($input.attr('max-date')).isValid() ? $input.attr('max-date') : false, - }); - - return true; -} - -function initTimestampInput(input) { - let $input = $(input); - let timestamp_format = dateFormatMoment(globals.timestamp_format); - let calendar_icons = getCalendarIcons(); - - $input.datetimepicker({ - format: timestamp_format, - locale: globals.locale, - icons: calendar_icons, - collapse: false, - sideBySide: true, - useCurrent: false, - stepping: 5, - widgetPositioning: { - horizontal: 'left', - vertical: 'auto' - }, - minDate: moment($input.attr('min-date')).isValid() ? $input.attr('min-date') : false, - maxDate: moment($input.attr('max-date')).isValid() ? $input.attr('max-date') : false, - }); - - // fix per timestamp-picker non visibile con la classe table-responsive - $input.on("dp.show", function (e) { - $('#tecnici > div').removeClass('table-responsive'); - }); - - $input.on("dp.hide", function (e) { - $('#tecnici > div').addClass('table-responsive'); - }); - - return true; -} - -function initTimeInput(input) { - let $input = $(input); - let time_format = dateFormatMoment(globals.time_format); - let calendar_icons = getCalendarIcons(); - - $input.datetimepicker({ - format: time_format, - locale: globals.locale, - icons: calendar_icons, - useCurrent: false, - stepping: 5, - minDate: moment($input.attr('min-date')).isValid() ? $input.attr('min-date') : false, - maxDate: moment($input.attr('max-date')).isValid() ? $input.attr('max-date') : false, - }); - - return true; -} - -/** - * @deprecated - */ -function start_datepickers() { - $('.timestamp-picker').each(function () { - input(this); - }); - - $('.datepicker').each(function () { - input(this); - }); - - $('.timepicker').each(function () { - input(this); - }); -} - -function start_complete_calendar(id, callback) { - var ranges = {}; - ranges[globals.translations.today] = [moment(), moment()]; - ranges[globals.translations.firstThreemester] = [moment("01", "MM"), moment("03", "MM").endOf('month')]; - ranges[globals.translations.secondThreemester] = [moment("04", "MM"), moment("06", "MM").endOf('month')]; - ranges[globals.translations.thirdThreemester] = [moment("07", "MM"), moment("09", "MM").endOf('month')]; - ranges[globals.translations.fourthThreemester] = [moment("10", "MM"), moment("12", "MM").endOf('month')]; - ranges[globals.translations.firstSemester] = [moment("01", "MM"), moment("06", "MM").endOf('month')]; - ranges[globals.translations.secondSemester] = [moment("06", "MM"), moment("12", "MM").endOf('month')]; - ranges[globals.translations.thisMonth] = [moment().startOf('month'), moment().endOf('month')]; - ranges[globals.translations.lastMonth] = [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]; - ranges[globals.translations.thisYear] = [moment().startOf('year'), moment().endOf('year')]; - ranges[globals.translations.lastYear] = [moment().subtract(1, 'year').startOf('year'), moment().subtract(1, 'year').endOf('year')]; - - var format = dateFormatMoment(globals.date_format); - $(id).daterangepicker({ - locale: { - format: format, - customRangeLabel: globals.translations.custom, - applyLabel: globals.translations.apply, - cancelLabel: globals.translations.cancel, - fromLabel: globals.translations.from, - toLabel: globals.translations.to, - }, - ranges: ranges, - startDate: globals.start_date_formatted, - endDate: globals.end_date_formatted, - applyClass: 'btn btn-success btn-sm', - cancelClass: 'btn btn-danger btn-sm', - linkedCalendars: false - }, - callback - ); -} diff --git a/assets/src/js/functions/form.js b/assets/src/js/functions/form.js deleted file mode 100644 index a415454f2..000000000 --- a/assets/src/js/functions/form.js +++ /dev/null @@ -1,249 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * @deprecated - * @param form - * @param data - * @param callback - * @param errorCallback - * @returns {*|jQuery} - */ -function submitAjax(form, data, callback, errorCallback) { - let valid = $(form).parsley().validate(); - if (!valid) { - return valid; - } - - if (!data) data = {}; - - // Lettura dei contenuti degli input - data = {...getInputsData(form), ...data}; - - $("#main_loading").show(); - content_was_modified = false; - - // Fix per gli id di default - data.id_module = data.id_module ? data.id_module : globals.id_module; - data.id_record = data.id_record ? data.id_record : globals.id_record; - data.id_plugin = data.id_plugin ? data.id_plugin : globals.id_plugin; - data.ajax = 1; - - prepareForm(form); - - // Invio dei dati - $(form).ajaxSubmit({ - url: globals.rootdir + "/actions.php", - data: data, - type: "post", - success: function (data) { - let response = data.trim(); - - // Tentativo di conversione da JSON - try { - response = JSON.parse(response); - } catch (e) { - } - - callback(response); - - $("#main_loading").fadeOut(); - - renderMessages(); - }, - error: function (data) { - $("#main_loading").fadeOut(); - - toastr["error"](data); - - if (errorCallback) errorCallback(data); - } - }); - - return valid; -} - -/** - * - * @param form - */ -function prepareForm(form) { - $(form).find('input:disabled, select:disabled').prop('disabled', false); - - let hash = window.location.hash; - if (hash) { - var input = $('', { - type: 'hidden', - name: 'hash', - value: hash, - }); - - $(form).append(input); - } -} - -/** - * Funzione per la gestione delle animazioni di caricamento sui pulsanti cliccati e appositamente predisposti, - * - * @param button - * @returns {[*, *]} - */ -function buttonLoading(button) { - let $this = $(button); - - let result = [ - $this.html(), - $this.attr("class") - ]; - - $this.html(' Attendere...'); - $this.addClass("btn-warning"); - $this.prop("disabled", true); - - return result; -} - -/** - * Funzione per ripristinare un pulsante con animazioni allo stato precedente. - * - * @param button - * @param loadingResult - */ -function buttonRestore(button, loadingResult) { - let $this = $(button); - - $this.html(loadingResult[0]); - - $this.attr("class", ""); - $this.addClass(loadingResult[1]); - $this.prop("disabled", false); -} - -/** - * Funzione per salvare i contenuti di un form via AJAX, utilizzando una struttura più recente fondata sull'utilizzo di Promise. - * - * @param button - * @param form - * @param data - * @returns {Promise} - */ -function salvaForm(form, data = {}, button = null) { - return new Promise(function (resolve, reject) { - // Caricamento visibile nel pulsante - let restore = buttonLoading(button); - - // Messaggio in caso di eventuali errori - let valid = $(form).parsley().validate(); - if (!valid) { - swal({ - type: "error", - title: globals.translations.ajax.missing.title, - text: globals.translations.ajax.missing.text, - }); - buttonRestore(button, restore); - - reject(); - return; - } - - // Gestione grafica di salvataggio - $("#main_loading").show(); - content_was_modified = false; - - // Lettura dei contenuti degli input - data = {...getInputsData(form), ...data}; - data.ajax = 1; - - // Fix per gli id di default - data.id_module = data.id_module ? data.id_module : globals.id_module; - data.id_record = data.id_record ? data.id_record : globals.id_record; - data.id_plugin = data.id_plugin ? data.id_plugin : globals.id_plugin; - - // Invio dei dati - $.ajax({ - url: globals.rootdir + "/actions.php", - data: data, - type: "POST", - success: function (data) { - let response = data.trim(); - - // Tentativo di conversione da JSON - try { - response = JSON.parse(response); - } catch (e) { - } - - // Gestione grafica del successo - $("#main_loading").fadeOut(); - renderMessages(); - buttonRestore(button, restore); - - resolve(response); - }, - error: function (data) { - toastr["error"](data); - - // Gestione grafica dell'errore - $("#main_loading").fadeOut(); - swal({ - type: "error", - title: globals.translations.ajax.error.title, - text: globals.translations.ajax.error.text, - }); - buttonRestore(button, restore); - - reject(data); - } - }); - }); -} - -/** - * Funzione per recuperare come oggetto i contenuti degli input interni a un tag HTML. - * - * @param {HTMLElement|string|jQuery} form - * @returns {{}} - */ -function getInputsData(form) { - let place = $(form); - let data = {}; - - // Gestione input previsti con sistema JS integrato - let inputs = place.find('.openstamanager-input'); - for (const x of inputs) { - const i = input(x); - const name = i.getElement().attr('name'); - const value = i.get(); - - data[name] = value === undefined || value === null ? undefined : value; - } - - // Gestione input HTML standard - let standardInputs = place.find(':input').not('.openstamanager-input').serializeArray(); - for (const x of standardInputs) { - data[x.name] = x.value; - } - - // Gestione hash dell'URL - let hash = window.location.hash; - if (hash) { - data['hash'] = hash; - } - - return data; -} diff --git a/assets/src/js/functions/functions.js b/assets/src/js/functions/functions.js deleted file mode 100755 index e77147816..000000000 --- a/assets/src/js/functions/functions.js +++ /dev/null @@ -1,608 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * Modal gestito da versioni precedenti. - * @param title - * @param href - * @param init_modal - */ -function launch_modal(title, href, init_modal) { - openModal(title, href); -} - -/** - * Modal. - * @param title - * @param href - */ -function openModal(title, href) { - // Fix - Select2 does not function properly when I use it inside a Bootstrap modal. - $.fn.modal.Constructor.prototype.enforceFocus = function () { - }; - - // Generazione dinamica modal - do { - id = '#bs-popup-' + Math.floor(Math.random() * 100); - } while ($(id).length !== 0); - - if ($(id).length === 0) { - $('#modals').append(''); - } - - $(id).on('hidden.bs.modal', function () { - if ($('.modal-backdrop').length < 1) { - $(this).html(''); - $(this).data('modal', null); - } - }); - - // Promise per la gestione degli eventi - const d = $.Deferred(); - $(id).one('shown.bs.modal', d.resolve); - - const content = ''; - - // Lettura contenuto div - if (href.substr(0, 1) === '#') { - const data = $(href).html(); - - $(id).html(content.replace("|data|", data)); - $(id).modal('show'); - } else { - $.get(href, function (data, response) { - if (response === 'success') { - $(id).html(content.replace("|data|", data)); - $(id).modal('show'); - } - }); - } - - return d.promise(); -} - -/** - * - * @param event - * @param link - */ -function openLink(event, link) { - if (event.ctrlKey) { - window.open(link); - } else { - location.href = link; - } -} - -/** - * Funzione per far scrollare la pagina fino a un offset - * @param offset - */ -function scrollToOffset(offset) { - $('html,body').animate({ - scrollTop: offset - }, 'slow'); -} - -/** - * Ritorna un array associativo con i parametri passati via GET - */ -function getUrlVars() { - let params = {}; - - let query = window.location.search.substring(1); - let parameterArray = query.split('&'); - if (parameterArray && parameterArray.length) { - parameterArray.map(param => { - let keyValuePair = param.split('=') - let key = keyValuePair[0]; - params[key] = keyValuePair[1] ? decodeURIComponent(keyValuePair[1]) : null; - }) - } - - return params; -} - -/** - * Data e ora (orologio) - */ -function clock() { - $('#datetime').html(moment().formatPHP(globals.timestamp_format)); - setTimeout('clock()', 1000); -} - -/** - * Funzione per impostare un valore ad un array in $_SESSION - */ -function session_set_array(session_array, value, inversed) { - if (inversed == undefined) { - inversed = 1; - } - - return $.get(globals.rootdir + "/ajax.php?op=session_set_array&session=" + session_array + "&value=" + value + "&inversed=" + inversed); -} - -/** - * Funzione per impostare un valore ad una sessione - */ -function session_set(session_array, value, clear, reload) { - if (clear === undefined) { - clear = 1; - } - - if (reload === undefined) { - reload = 0; - } - - return $.get(globals.rootdir + "/ajax.php?op=session_set&session=" + session_array + "&value=" + value + "&clear=" + clear, function (data, status) { - if (reload === 1) { - location.reload(); - } - }); -} - -function session_keep_alive() { - $.get(globals.rootdir + '/core.php'); -} - -function setContrast(backgroundcolor) { - var rgb = []; - var bg = String(backgroundcolor); - - // ex. backgroundcolor = #ffc400 - rgb[0] = bg.substr(1, 2); - rgb[1] = bg.substr(2, 2); - rgb[2] = bg.substr(5, 2); - - var R1 = parseInt(rgb[0], 16); - var G1 = parseInt(rgb[1], 16); - var B1 = parseInt(rgb[2], 16); - - var R2 = 255; - var G2 = 255; - var B2 = 255; - - var L1 = 0.2126 * Math.pow(R1 / 255, 2.2) + 0.7152 * Math.pow(G1 / 255, 2.2) + 0.0722 * Math.pow(B1 / 255, 2.2); - var L2 = 0.2126 * Math.pow(R2 / 255, 2.2) + 0.7152 * Math.pow(G2 / 255, 2.2) + 0.0722 * Math.pow(B2 / 255, 2.2); - - if (L1 > L2) { - var lum = (L1 + 0.05) / (L2 + 0.05); - } else { - var lum = (L2 + 0.05) / (L1 + 0.05); - } - - if (lum >= 9) { - return "#ffffff"; - } else { - return "#000000"; - } -} - -function message(element) { - data = $.extend({}, $(element).data()); - - var title = globals.translations.deleteTitle; - if (data["title"] != undefined) title = data["title"]; - - var msg = globals.translations.deleteMessage; - if (data["msg"] != undefined) msg = data["msg"]; - - var button = globals.translations.delete; - if (data["button"] != undefined) button = data["button"]; - - var btn_class = "btn btn-lg btn-danger"; - if (data["class"] != undefined) btn_class = data["class"]; - - swal({ - title: title, - html: '
' + msg + '
', - type: "warning", - showCancelButton: true, - confirmButtonText: button, - confirmButtonClass: btn_class, - onOpen: function () { - restart_inputs(); - }, - preConfirm: function () { - $form = $('#swal-form'); - $form.find(':input').each(function () { - data[$(this).attr('name')] = $(this).val(); - }); - - if ($form.parsley().validate()) { - return new Promise(function (resolve) { - resolve(); - }); - } else { - $('.swal2-buttonswrapper button').each(function () { - $(this).prop('disabled', false); - }); - } - } - }).then( - function () { - if (data["op"] == undefined) data["op"] = "delete"; - - var href = window.location.href.split("#")[0]; - if (data["href"] != undefined) { - href = data["href"]; - delete data.href; - } - - var hash = window.location.href.split("#")[1]; - if (hash) { - data["hash"] = hash; - } - - method = "post"; - if (data["method"] != undefined) { - if (data["method"] == "post" || data["method"] == "get") { - method = data["method"]; - } - delete data.method; - } - - blank = data.blank != undefined && data.blank; - delete data.blank; - - if (data.callback) { - $.ajax({ - type: method, - crossDomain: true, - url: href, - data: data, - beforeSend: function (response) { - var before = window[data.before]; - - if (typeof before === 'function') { - before(response); - } - }, - success: function (response) { - var callback = window[data.callback]; - - if (typeof callback === 'function') { - callback(response); - } - }, - error: function (xhr, ajaxOptions, error) { - swal({ - title: globals.translations.errorTitle, - html: globals.translations.errorMessage, - type: "error", - }) - }, - }); - } else { - redirect(href, data, method, blank); - } - }, - function (dismiss) { - } - ); -} - -function redirect(href, data, method, blank) { - method = method ? method : "get"; - blank = blank ? blank : false; - - if (method == "post") { - var text = '
'; - - for (var name in data) { - text += ''; - } - - text += '
'; - - var form = $(text); - $('body').append(form); - - form.submit(); - } else { - var values = []; - - for (var name in data) { - values.push(name + '=' + data[name]); - } - - var link = href + (href.indexOf('?') !== -1 ? '&' : '?') + values.join('&') + window.location.hash; - - if (!blank) { - location.href = link; - } else { - window.open(link); - } - } -} - -function setCookie(cname, cvalue, exdays) { - var d = new Date(); - d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); - var expires = "expires=" + d.toUTCString(); - document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; -} - -function getCookie(cname) { - var name = cname + "="; - var decodedCookie = decodeURIComponent(document.cookie); - var ca = decodedCookie.split(';'); - for (var i = 0; i < ca.length; i++) { - var c = ca[i]; - while (c.charAt(0) == ' ') { - c = c.substring(1); - } - if (c.indexOf(name) == 0) { - return c.substring(name.length, c.length); - } - } - return ""; -} - -/** - * Visualizzazione dei messaggi attivi tramite toastr. - */ -function renderMessages() { - $.ajax({ - url: globals.rootdir + '/ajax.php', - type: 'get', - dataType: 'JSON', - data: { - op: 'flash', - }, - success: function (messages) { - let info = messages.info ? messages.info : []; - info.forEach(function (element) { - if (element) toastr["success"](element); - }); - - let warning = messages.warning ? messages.warning : []; - warning.forEach(function (element) { - if (element) toastr["warning"](element); - }); - - let error = messages.error ? messages.error : []; - error.forEach(function (element) { - if (element) toastr["error"](element); - }); - - } - }); -} - -/** - * Rimuove l'hash dall'URL corrente. - */ -function removeHash() { - history.replaceState(null, null, ' '); -} - -/** - * - * @param str - * @param find - * @param replace - * @returns {*} - */ -function replaceAll(str, find, replace) { - return str.replace(new RegExp(find, "g"), replace); -} - -/** - * @deprecated - */ -function cleanup_inputs() { - $('.bound').removeClass("bound"); - - $('.superselect, .superselectajax').each(function () { - let $this = $(this); - - if ($this.data('select2')) { - input(this).destroy(); - } - }); -} - -/** - * @deprecated - */ -function restart_inputs() { - // Generazione degli input - $('.openstamanager-input').each(function () { - input(this); - }); -} - -/** - * Messaggio di avviso salvataggio a comparsa sulla destra solo nella versione a desktop intero - */ -function alertPush() { - if ($(window).width() > 1023) { - let i = 0; - - $('.alert-success.push').each(function () { - i++; - tops = 60 * i + 95; - - $(this).css({ - 'position': 'fixed', - 'z-index': 3000, - 'right': '10px', - 'top': -100, - }).delay(1000).animate({ - 'top': tops, - }).delay(3000).animate({ - 'top': -100, - }); - }); - } - - // Nascondo la notifica se passo sopra col mouse - $('.alert-success.push').on('mouseover', function () { - $(this).stop().animate({ - 'top': -100, - 'opacity': 0 - }); - }); -} - -/** - * Funzione per l'apertura del messaggi di rimozione elemento standard. - * - * @param button - * @param title - * @param message - * @returns {*} - */ -function confirmDelete(button, title, message) { - return swal({ - title: title ? title : globals.translations.deleteTitle, - html: message ? message : globals.translations.deleteMessage, - type: "warning", - showCancelButton: true, - confirmButtonText: globals.translations.delete, - confirmButtonClass: "btn btn-lg btn-danger", - }) -} - - -/** - * Nasconde una specifica colonna di una tabella indicata. - * - * @param table - * @param column - */ -function hideTableColumn(table, column) { - column = "" + column; // Cast a stringa - - // Verifica sulle colonne nascoste in precedenza - let hiddenColumns = table.getAttribute("hidden-columns"); - hiddenColumns = hiddenColumns ? hiddenColumns.split(",") : []; - if (hiddenColumns.includes(column)) { - return; - } - - // Salvataggio delle colonne nascoste - hiddenColumns.push(column); - table.setAttribute("hidden-columns", hiddenColumns.join(",")); - - let rows = table.rows; - for (let row of rows) { - let currentColumn = 1; - for (let i = 0; i < row.cells.length; i++) { - let cell = row.cells[i]; - - // Individuazione del colspan - let colspan = parseInt(cell.getAttribute("colspan")); - let hiddenColspan = cell.getAttribute("colspan-hidden"); - hiddenColspan = parseInt(hiddenColspan ? hiddenColspan : 0); - let totalColspan = colspan + hiddenColspan; - - // Gestione dell'operazione nel caso di cella multipla - if (totalColspan && totalColspan > 1) { - if (column >= currentColumn && column <= currentColumn + totalColspan - 1) { - cell.setAttribute("colspan", colspan - 1); - cell.setAttribute("colspan-hidden", hiddenColspan + 1); - - // Cella nascosta nel caso colspan sia nullo - if (colspan - 1 === 0) { - cell.classList.add("hidden"); - } - } - - currentColumn += totalColspan; - } - // Gestione di una cella normale - else { - if (column === "" + currentColumn) { - cell.classList.add("hidden"); - } - currentColumn++; - } - } - } -} - -/** - * Funzione per aggiungere in un *endpoint* il contenuto di uno specifico *template*, effettuando delle sostituzioni di base e inizializzando i campi aggiunti. - * - * @param {string|jQuery|HTMLElement} endpoint_selector - * @param {string|jQuery|HTMLElement} template_selector - * @param {object} replaces - * @param {boolean} prepend - * @returns {*|jQuery|HTMLElement} - */ -function aggiungiContenuto(endpoint_selector, template_selector, replaces = {}, prepend = false) { - let template = $(template_selector); - let endpoint = $(endpoint_selector); - - // Distruzione degli input interni - template.find('.openstamanager-input').each(function () { - input(this).destroy(); - }); - - // Contenuto da sostituire - let content = template.html(); - for ([key, value] of Object.entries(replaces)) { - content = replaceAll(content, key, value); - } - - // Aggiunta del contenuto - let element = $(content); - if (prepend) { - endpoint.prepend(element); - } else { - endpoint.append(element); - } - - // Rigenerazione degli input interni - element.find('.openstamanager-input').each(function () { - input(this).trigger("change"); - }); - - return element; -} - -/** - * Funzione per forzare l'apertura di uno specifico tab senza un relativo cambiamento di URL. - * - * @param {HTMLElement} link - */ -function apriTab(link) { - let element = $(link).closest("li"); - let parent = element.closest(".nav-tabs-custom"); - - parent.find("ul > li").removeClass("active"); - element.addClass("active"); - - let tab = $(link).data("tab"); - parent.find(".tab-pane").removeClass("active"); - parent.find(".tab-pane#" + tab).addClass("active"); -} diff --git a/assets/src/js/functions/hooks.js b/assets/src/js/functions/hooks.js deleted file mode 100755 index df3fa0902..000000000 --- a/assets/src/js/functions/hooks.js +++ /dev/null @@ -1,230 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * - */ -function startHooks() { - $.ajax({ - url: globals.rootdir + "/ajax.php", - type: "get", - data: { - op: "hooks", - }, - success: function (data) { - hooks = JSON.parse(data); - - $("#hooks-header").text(globals.translations.hooksExecuting); - $("#hooks-number").text(hooks.length); - - if (hooks.length == 0) { - $("#hooks-loading").hide(); - $("#hooks-number").text(0); - $("#hooks-header").text(globals.translations.hookNone); - } - - hooks.forEach(function (item, index) { - renderHook(item, { - show: true, - message: globals.translations.hookExecuting.replace('_NAME_', item.name) - }); - - startHook(item, true); - }); - }, - }); -} - -/** - * Richiama l'hook per l'esecuzione. - * - * @param hook - */ -function startHook(hook, init) { - $.ajax({ - url: globals.rootdir + "/ajax.php", - type: "get", - data: { - op: "hook-lock", - id: hook.id, - }, - success: function (data) { - var token = JSON.parse(data); - - if (init) { - hookCount("#hooks-counter"); - - updateHook(hook); - } - - if (token) { - executeHook(hook, token); - } else { - var timeout = 10; - - setTimeout(function () { - startHook(hook); - }, timeout * 1000); - } - }, - }); -} - -/** - * Richiama l'hook per l'esecuzione. - * - * @param hook - * @param token - */ -function executeHook(hook, token) { - $.ajax({ - url: globals.rootdir + "/ajax.php", - type: "get", - data: { - op: "hook-execute", - id: hook.id, - token: token, - }, - success: function (data) { - var result = JSON.parse(data); - updateHook(hook); - - var timeout; - if (result.execute) { - startHook(hook); - } else { - timeout = 30; - - setTimeout(function () { - startHook(hook); - }, timeout * 1000); - } - }, - }); -} - -/** - * Aggiorna le informazioni dell'hook. - * - * @param hook - * @param init - */ -function updateHook(hook) { - $.ajax({ - url: globals.rootdir + "/ajax.php", - type: "get", - data: { - op: "hook-response", - id: hook.id, - }, - success: function (data) { - var result = JSON.parse(data); - renderHook(hook, result); - - // Rimozione eventuale della rotella di caricamento - var counter = $("#hooks-counter").text(); - var number = $("#hooks > li").length; - - if (number == 0) { - $("#hooks-notified").html(''); - $("#hooks-label").removeClass(); - $("#hooks-label").addClass('label').addClass('label-success'); - } else { - $("#hooks-notified").text(number); - $("#hooks-label").removeClass(); - $("#hooks-label").addClass('label').addClass('label-danger'); - } - - if (counter == $("#hooks-number").text()) { - $("#hooks-loading").hide(); - - var hookMessage; - if (number > 1) { - hookMessage = globals.translations.hookMultiple.replace('_NUM_', number); - } else if (number == 1) { - hookMessage = globals.translations.hookSingle; - } else { - hookMessage = globals.translations.hookNone; - } - - $("#hooks-header").text(hookMessage); - } - }, - }); -} - -/** - * Aggiunta dell'hook al numero totale. - */ -function hookCount(id, value) { - value = value ? value : 1; - - var element = $(id); - var number = parseInt(element.text()); - number = isNaN(number) ? 0 : number; - - number += value; - element.text(number); - - return number; -} - -/** - * Genera l'HTML per la visualizzazione degli hook. - * - * @param element_id - * @param result - */ -function renderHook(hook, result) { - if (result.length == 0) return; - - var element_id = "hook-" + hook.id; - - // Inizializzazione - var element = $("#" + element_id); - if (element.length == 0) { - $("#hooks").append('
  • '); - - element = $("#" + element_id); - } - - // Rimozione - if (!result.show) { - element.remove(); - - return; - } - - // Contenuto - var content = ' ' + result.message + ''; - - if (result.progress) { - var current = result.progress.current; - var total = result.progress.total; - var percentage = current / total * 100; - percentage = isNaN(percentage) ? 100 : percentage; - - percentage = Math.round(percentage * 100) / 100; - - content += '
    ' + percentage + '% (' + current + '/' + total + ')
    '; - } - - content += '
    '; - - element.html(content); -} diff --git a/assets/src/js/functions/init.js b/assets/src/js/functions/init.js deleted file mode 100755 index 8080438e8..000000000 --- a/assets/src/js/functions/init.js +++ /dev/null @@ -1,71 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -function init() { - // Inizializzazzione dei box AdminLTE - $('.box').boxWidget(); - - // Modal di default - $('[data-href]').not('.ask, .bound').click(function () { - launch_modal($(this).data('title'), $(this).data('href'), 1); - }); - $('[data-href]').not('.ask, .bound').addClass('bound clickable'); - - // Tooltip - $('.tip').not('.tooltipstered').each(function () { - $this = $(this); - $this.tooltipster({ - animation: 'grow', - contentAsHTML: true, - hideOnClick: true, - onlyOne: true, - maxWidth: 350, - touchDevices: true, - trigger: 'hover', - position: $this.data('position') ? $this.data('position') : 'top', - }); - }); - - if ($('form').length) { - $('form').not('.no-check').parsley(); - } - - // Aggiunta nell'URL del nome tab su cui tornare dopo il submit - // Blocco del pulsante di submit dopo il primo submit - $('form').on("submit", function (e) { - if ($(this).parsley().validate() && (e.result == undefined || e.result)) { - $(this).submit(function () { - return false; - }); - - $(this).find('[type=submit]').prop("disabled", true).addClass("disabled"); - - prepareForm(this); - - return true; - } - - return false; - }); - - window.Parsley.on('field:success', function () { - this.$element.removeClass('parsley-success'); - }); - - restart_inputs(); -} diff --git a/assets/src/js/functions/input.js b/assets/src/js/functions/input.js deleted file mode 100644 index a45a555f4..000000000 --- a/assets/src/js/functions/input.js +++ /dev/null @@ -1,411 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * Funzione semplificata per accedere ad uno specifico input. - * Accetta un oggetto jQuery, oppure un elemento JS HTMLElement, oppure il nome dell'input di interesse. - * - * Attenzione: in caso di molteplici input individuati, viene restituito l'ultimo individuato. - * - * @param {string|jQuery|HTMLElement} name - * @returns {Input|*} - */ -function input(name) { - let element; - - // Selezione tramite jQuery - if (name instanceof jQuery) { - element = name.last(); - } - - // Selezione tramite JS diretto - else if (isElement(name)) { - element = $(name); - } - - // Selezione per nome - else { - element = $("[name='" + name + "']").last(); - - // Fix per select multipli - if (element.length === 0) { - element = $("[name='" + name + "[]']").last(); - } - } - - if (!element.data("input-controller")) { - return new Input(element); - } else { - const controller = element.data("input-controller"); - - if (!element.data("input-init")) { - controller.init(); - } - - return controller; - } -} - -/** - * - * @constructor - * @param {jQuery} element - */ -function Input(element) { - this.element = element; - - this.element.data("input-controller", this); - this.element.data("required", this.element.attr("required")); - - this.init(); -} - -/** - * Effettua le operazioni di inizializzazione sull'input in base alla relativa tipologia. - */ -Input.prototype.init = function () { - let initCompleted = false; - let htmlElement = this.element[0]; - - // Operazioni di inizializzazione per input specifici - // Inizializzazione per date - if (this.element.hasClass('timestamp-picker')) { - initCompleted = initTimestampInput(htmlElement); - } else if (this.element.hasClass('datepicker')) { - initCompleted = initDateInput(htmlElement); - } else if (this.element.hasClass('timepicker')) { - initCompleted = initTimeInput(htmlElement); - } - - // Inizializzazione per campi numerici - else if (this.element.hasClass('number-input')) { - initCompleted = initNumberInput(htmlElement); - } - - // Inizializzazione per textarea - else if (this.element.hasClass('editor-input')) { - initCompleted = initEditorInput(htmlElement); - } - - // Inizializzazione per textarea - else if (this.element.hasClass('autosize') || this.element.attr('maxlength')) { - if (this.element.hasClass('autosize')) - initCompleted = initTextareaInput(htmlElement); - - if (htmlElement.hasAttribute('charcounter')) - initCompleted = initCharCounter(htmlElement); - } - - // Inizializzazione per select - else if (this.element.hasClass('select-input')) { - initCompleted = initSelectInput(htmlElement); - } - - // Inizializzazione alternativa per maschere - else { - initCompleted = initMaskInput(htmlElement); - } - - this.element.data("input-init", !!initCompleted); -} - -/** - * Restituisce l'elemento jQuery che rappresenta l'input. - * - * @returns {jQuery} - */ -Input.prototype.getElement = function () { - return this.element; -} - -/** - * Gestisce l'abilitazione e la disibilitazione dell'input sulla base del valore indicato. - * - * @param {boolean} value - * @returns {Input} - */ -Input.prototype.setDisabled = function (value) { - if (value) { - return this.disable(); - } else { - return this.enable(); - } -} - -/** - * Disabilita l'input all'utilizzo grafico. - * - * @returns {Input} - */ -Input.prototype.disable = function () { - this.element.addClass("disabled") - .attr("disabled", true) - .attr("readonly", false) - .attr("required", false); - - let group = this.element.closest(".form-group"); - - // Disabilitazione eventuali pulsanti relativi - group.find("button") - .addClass("disabled"); - - // Disabilitazione per checkbox - group.find(".btn-group label") - .addClass("disabled"); - group.find("input[type=checkbox]") - .attr("disabled", true) - .attr("readonly", false) - .addClass("disabled"); - - // Gestione dell'editor - if (this.element.hasClass("editor-input")) { - const name = this.element.attr("id"); - CKEDITOR.instances[name].setReadOnly(true); - } - - return this; -} - -/** - * Abilita l'input all'utilizzo grafico. - * - * @returns {Input} - */ -Input.prototype.enable = function () { - this.element.removeClass("disabled") - .attr("disabled", false) - .attr("readonly", false) - .attr("required", this.element.data("required")); - - let group = this.element.closest(".form-group"); - - // Abilitazione eventuali pulsanti relativi - group.find("button") - .removeClass("disabled"); - - // Abilitazione per checkbox - group.find(".btn-group label") - .removeClass("disabled"); - group.find("input[type=checkbox]") - .attr("disabled", false) - .attr("readonly", false) - .removeClass("disabled"); - - // Gestione dell'editor - if (this.element.hasClass("editor-input")) { - const name = this.element.attr("id"); - CKEDITOR.instances[name].setReadOnly(false); - } - - return this; -} - -/** - * Controlla se l'input è disabilitato. - * - * @returns {boolean} - */ -Input.prototype.isDisabled = function () { - return this.element.hasClass("disabled") -} - -/** - * Restituisce un oggetto cotentente le caratteristiche dell'input. - * - * @returns {{value: (string|number)}|jQuery|any} - */ -Input.prototype.getData = function () { - if (this.element.is('select')) { - return this.element.selectData(); - } - - return { - value: this.get() - }; -} - -/** - * Restituisce il valore corrente dell'input. - * - * @returns {string|number} - */ -Input.prototype.get = function () { - let value = this.element.val(); - - // Gestione dei valori per select - if (this.element.hasClass("select-input")) { - value = value ? value : null; - } - - // Gestione dei valori per l'editor - if (this.element.hasClass("editor-input")) { - const name = this.element.attr("id"); - value = typeof CKEDITOR !== 'undefined' ? CKEDITOR.instances[name].getData() : value; - } - - // Conversione del valore per le checkbox - let group = this.element.closest(".form-group"); - if (group.find("input[type=checkbox]").length) { - return parseInt(value) ? 1 : 0; - } - - // Gestione dei valori numerici - if (this.element.hasClass("number-input")) { - const autonumeric = this.element.data("autonumeric"); - - if (autonumeric) { - return parseFloat(autonumeric.rawValue); - } - // In attesa dell'inizializzazione per autonumeric, il valore registrato è interpretabile - else { - return parseFloat(value); - } - } - - return value; -} - -/** - * Imposta il valore per l'input. - * - * @param value - * @returns {Input} - */ -Input.prototype.set = function (value) { - // Gestione dei valori per l'editor - if (this.element.hasClass("editor-input") && typeof CKEDITOR !== 'undefined') { - const name = this.element.attr("id"); - CKEDITOR.instances[name].setData(value); - } else { - this.element.val(value).trigger("change"); - } - - return this; -} - -/** - * Imposta l'input per essere obbligatorio o meno. - * @param {bool} value - * @returns {Input} - */ -Input.prototype.setRequired = function (value) { - this.element.attr("required", value) - .data("required", value); - - return this; -} - -// Eventi permessi -/** - * Gestisce gli eventi di tipologia "change". - * - * @param callable - * @returns {Input} - */ -Input.prototype.change = function (callable) { - this.on("change", callable) - - return this; -} - -/** - * Gestisce l'ascolto a uno specifico evento sulla base dell'oggetto jQuery. - * - * @param {string} event - * @param callable - * - * @returns {Input} - */ -Input.prototype.on = function (event, callable) { - this.element.on(event, callable); - - return this; -} - -/** - * Gestisce la rimozione degli ascoltatori attivi per uno specifico evento sulla base dell'oggetto jQuery. - * - * @param {string} event - * - * @returns {Input} - */ -Input.prototype.off = function (event) { - this.element.off(event); - - return this; -} - -/** - * Effettua il trigger di uno specifico evento sull'input. - * @param {string} event - * @param callable - * @returns {Input} - */ -Input.prototype.trigger = function (event, callable) { - this.element.trigger(event, callable); - - return this; -} - -/** - * Distrugge il gestore attuale per l'input e ne disabilita le funzionalità previste. - */ -Input.prototype.destroy = function () { - if (this.element.data('select2')) { - this.element.select2().select2("destroy") - } - - // Gestione della distruzione per l'editor - if (this.element.hasClass("editor-input")) { - const name = this.element.attr("id"); - CKEDITOR.instances[name].destroy(); - } - - this.element.data("input-controller", null); - this.element.data("input-init", false); -} - -/** - * Returns true if it is a DOM node. - * - * @param o - * @returns boolean - * - * @source https://stackoverflow.com/a/384380 - */ -function isNode(o) { - return ( - typeof Node === "object" ? o instanceof Node : - o && typeof o === "object" && typeof o.nodeType === "number" && typeof o.nodeName === "string" - ); -} - -/** - * Returns true if it is a DOM element. - * - * @param o - * @returns boolean - * - * @source https://stackoverflow.com/a/384380 - */ -function isElement(o) { - return ( - typeof HTMLElement === "object" ? o instanceof HTMLElement : // DOM2 - o && typeof o === "object" && o.nodeType === 1 && typeof o.nodeName === "string" - ); -} diff --git a/assets/src/js/functions/inputmask.js b/assets/src/js/functions/inputmask.js deleted file mode 100644 index 5b7ad9cc1..000000000 --- a/assets/src/js/functions/inputmask.js +++ /dev/null @@ -1,71 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * Funzione per l'inizializzazione delle maschere sui campi impostati. - * @param input - */ -function initMaskInput(input) { - let $input = $(input); - - if ($input.hasClass('email-mask')) { - $input.inputmask('Regex', { - regex: "^[a-zA-Z0-9_!#$%&'*+/=?`{|}~^-]+(?:\\.[a-zA-Z0-9_!#$%&'*+/=?`{|}~^-]+)*@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$", - }); - } else if ($input.hasClass('rea-mask')) { - $input.inputmask({ - mask: "AA-999999{1,15}", - casing: "upper", - }); - } else if ($input.hasClass('provincia-mask')) { - $input.inputmask({ - mask: "AA", - casing: "upper", - }); - } else if ($input.hasClass('alphanumeric-mask')) { - $input.inputmask('Regex', { - regex: "[A-Za-z0-9#_|\/\\-.]*", - }); - } else if ($input.hasClass('math-mask')) { - $input.inputmask('Regex', { - regex: "[0-9,.+\-]*", - }); - } - - return true; -} - -/** - * Inputmask. - * - * @param element - */ -function start_inputmask(element) { - if (element === undefined) { - element = ''; - } else { - element = element + ' '; - } - - let masks = ['math-mask', 'alphanumeric-mask', 'provincia-mask', 'rea-mask', 'email-mask']; - - let selector = element + '.' + masks.join(', ' + element + '.') - $(selector).each(function () { - input(this); - }); -} diff --git a/assets/src/js/functions/loaders.js b/assets/src/js/functions/loaders.js deleted file mode 100644 index 9f985c670..000000000 --- a/assets/src/js/functions/loaders.js +++ /dev/null @@ -1,70 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * Funzione per gestire il loader locale per uno specifico DIV. - * - * @param div Identificatore JS dell'elemento - * @param show - */ -function localLoading(div, show) { - let container = $(div); - - // Ricerca del loader esistente - let loader = container.find(".panel-loading"); - - // Aggiunta del loader in caso di assenza - if (!loader.length) { - let html = ``; - - container.prepend(html); - loader = container.find(".local-loader"); - } - - // Visualizzazione del loader - if (show) { - loader.removeClass("hidden"); - container.addClass("div-loading"); - } - // Rimozione del loader - else { - loader.addClass("hidden"); - container.removeClass("div-loading"); - } -} - -/** - * Funzione per gestire la visualizzazione del loader generale del gestionale. - * @param show - */ -function mainLoader(show) { - let loader = $("#main_loading"); - - if (show) { - loader.show(); - } else { - loader.fadeOut(); - } -} diff --git a/assets/src/js/functions/moment.js b/assets/src/js/functions/moment.js deleted file mode 100755 index 87fe6e0c6..000000000 --- a/assets/src/js/functions/moment.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -function dateFormatMoment(format) { - /* - * PHP => moment.js - * Will take a php date format and convert it into a JS format for moment - * http://www.php.net/manual/en/function.date.php - * http://momentjs.com/docs/#/displaying/format/ - */ - var formatMap = { - d: 'DD', - D: 'ddd', - j: 'D', - l: 'dddd', - N: 'E', - S: function () { - return '[' + moment().format('Do').replace(/\d*/g, '') + ']'; - }, - w: 'd', - z: function () { - return moment().format('DDD') - 1; - }, - W: 'W', - F: 'MMMM', - m: 'MM', - M: 'MMM', - n: 'M', - t: function () { - return moment().daysInMonth(); - }, - L: function () { - return moment().isLeapYear() ? 1 : 0; - }, - o: 'GGGG', - Y: 'YYYY', - y: 'YY', - a: 'a', - A: 'A', - B: function () { - var thisUTC = moment().clone().utc(), - // Shamelessly stolen from http://javascript.about.com/library/blswatch.htm - swatch = ((thisUTC.hours() + 1) % 24) + (thisUTC.minutes() / 60) + (thisUTC.seconds() / 3600); - return Math.floor(swatch * 1000 / 24); - }, - g: 'h', - G: 'H', - h: 'hh', - H: 'HH', - i: 'mm', - s: 'ss', - u: '[u]', // not sure if moment has this - e: '[e]', // moment does not have this - I: function () { - return moment().isDST() ? 1 : 0; - }, - O: 'ZZ', - P: 'Z', - T: '[T]', // deprecated in moment - Z: function () { - return parseInt(moment().format('ZZ'), 10) * 36; - }, - c: 'YYYY-MM-DD[T]HH:mm:ssZ', - r: 'ddd, DD MMM YYYY HH:mm:ss ZZ', - U: 'X' - }; - var formatEx = /[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]/g; - - return format.replace(formatEx, function (phpStr) { - return typeof formatMap[phpStr] === 'function' ? formatMap[phpStr].call(that) : formatMap[phpStr]; - }) -} - -(function (m) { - moment.fn.formatPHP = function (format) { - return this.format(dateFormatMoment(format)); - }; -}(moment)); diff --git a/assets/src/js/functions/numbers.js b/assets/src/js/functions/numbers.js deleted file mode 100644 index 4ad9bce88..000000000 --- a/assets/src/js/functions/numbers.js +++ /dev/null @@ -1,67 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * Funzione per inizializzare i campi di input numerici per la gestione integrata del formato impostato per il gestionale. - * - * @deprecated - */ -function initNumbers() { - $('.number-input').each(function () { - input(this); - }); -} - -/** - * Funzione per l'inizializzazione dei campi numerici. - * @param input - */ -function initNumberInput(input) { - let $input = $(input); - if (AutoNumeric.isManagedByAutoNumeric(input)) { - return true; - } - - let min = $input.attr('min-value') && $input.attr('min-value') !== "undefined" ? $input.attr('min-value') : null; - let max = $input.attr('max-value') && $input.attr('max-value') !== "undefined" ? $input.attr('max-value') : null; - - let decimals = $input.attr('decimals') ? $input.attr('decimals') : globals.cifre_decimali; - - let autonumeric = new AutoNumeric(input, { - caretPositionOnFocus: "decimalLeft", - allowDecimalPadding: true, - currencySymbolPlacement: "s", - negativePositiveSignPlacement: "p", - decimalCharacter: globals.decimals, - decimalCharacterAlternative: ".", - digitGroupSeparator: globals.thousands, - emptyInputBehavior: min ? min : "zero", - overrideMinMaxLimits: "ignore", - modifyValueOnWheel: false, - outputFormat: "string", - unformatOnSubmit: true, - watchExternalChanges: true, - minimumValue: min ? min : "-10000000000000", - maximumValue: max ? max : "10000000000000", - decimalPlaces: decimals, - }); - - $input.data("autonumeric", autonumeric); - - return true; -} diff --git a/assets/src/js/functions/prototypes.js b/assets/src/js/functions/prototypes.js deleted file mode 100755 index 279e53b49..000000000 --- a/assets/src/js/functions/prototypes.js +++ /dev/null @@ -1,25 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -String.prototype.toEnglish = function () { - return numeral(this.toString()).value(); -}; - -Number.prototype.toLocale = function () { - return numeral(this).format(); -}; diff --git a/assets/src/js/functions/select.js b/assets/src/js/functions/select.js deleted file mode 100755 index a8756c410..000000000 --- a/assets/src/js/functions/select.js +++ /dev/null @@ -1,344 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * Select. - * - * @deprecated - */ -function start_superselect() { - $('.superselect, .superselectajax').each(function () { - input(this); - }); -} - -/** - * Gestisce le operazioni di rendering per una singola opzione del select. - * - * @param data - * @param container - * @returns {*} - */ -function optionRendering(data, container) { - // Aggiunta degli attributi impostati staticamente - selectOptionAttributes(data); - - // Impostazione del colore dell'opzione - let bg; - if (data._bgcolor_) { - bg = data._bgcolor_; - } else if ($(data.element).attr("_bgcolor_")) { - bg = $(data.element).attr("_bgcolor_"); - } else if ($(data.element).data("_bgcolor_")) { - bg = $(data.element).data("_bgcolor_"); - } - - if (bg && !$("head").find('#' + data._resultId + '_style').length) { - $(container).css("background-color", bg); - $(container).css("color", setContrast(bg)); - } - - return data.text; -} - -/** - * Gestisce le operazioni di rendering per le opzioni selezionate del select. - * - * @param data - * @returns {*} - */ -function selectionRendering(data) { - // Aggiunta degli attributi impostati staticamente - selectOptionAttributes(data); - - return data.text; -} - -/** - * Gestisce le operazioni per l'impostazione dinamica degli attributi per una singola opzione del select. - * - * @param data - * @returns {void} - */ -function selectOptionAttributes(data) { - // Aggiunta degli attributi impostati staticamente - let attributes = $(data.element).data("select-attributes"); - if (attributes) { - for ([key, value] of Object.entries(attributes)) { - data[key] = value; - } - } -} - -/** - * Reimposta i contenuti di un creato con select2. - */ -jQuery.fn.selectReset = function (placeholder) { - this.selectClear(); - this.empty(); - - if (placeholder !== undefined) { - this.next().find('.select2-selection__placeholder').text(placeholder); - this.next().find('input.select2-search__field').attr('placeholder', placeholder); - } - - return this; -}; - -/** - * Aggiorna un creato con select2 impostando un valore di default. - * Da utilizzare per l'impostazione dei select statici. - */ -jQuery.fn.selectSet = function (value) { - this.val(value).trigger("change"); - - return this; -}; - -/** - * Aggiorna un creato con select2. - */ -jQuery.fn.setSelectOption = function (name, value) { - this.data('select-options')[name] = value; - - return this; -}; - -/** - * Restituisce il valore impostato per un'opzione di un - - - - - - - - - - - - - - - - - - -
    '.tr('Da').':'.$account['from_address'].'
    '.tr('A').':'.$bug_email.'
    '.tr('Versione OSM').':'.$version.' ('.(!empty($revision) ? $revision : tr('In sviluppo')).')
    - -
    -
    - {[ "type": "checkbox", "placeholder": "'.tr('Allega file di log').'", "name": "log", "value": "1" ]} -
    - -
    - {[ "type": "checkbox", "placeholder": "'.tr('Allega copia del database').'", "name": "sql" ]} -
    - -
    - {[ "type": "checkbox", "placeholder": "'.tr('Allega informazioni sul PC').'", "name": "info", "value": "1" ]} -
    -
    - -
    -
    - - {[ "type": "ckeditor", "label": "'.tr('Descrizione del bug').'", "name": "body" ]} - - -
    -
    - -
    -
    - -
    - - - - -'; - -include_once App::filepath('include|custom|', 'bottom.php'); diff --git a/composer.json b/composer.json deleted file mode 100755 index e55c44494..000000000 --- a/composer.json +++ /dev/null @@ -1,130 +0,0 @@ -{ - "name": "devcode-it/openstamanager", - "description": "Gestionale open-source per assistenza tecnica e fatturazione elettronica", - "license": "GPL-3.0", - "keywords": [ - "gestionale", - "assistenza tecnica", - "fatturazione elettronica", - "open-source" - ], - "homepage": "https://www.openstamanager.com/", - "authors": [{ - "name": "DevCode s.r.l.", - "email": "info@openstamanager.com" - }], - "type": "project", - "require": { - "php": ">=5.6.4", - "ext-curl": "*", - "ext-dom": "*", - "ext-fileinfo": "*", - "ext-intl": "*", - "ext-json": "*", - "ext-libxml": "*", - "ext-mbstring": "*", - "ext-openssl": "*", - "ext-pdo": "*", - "ext-simplexml": "*", - "ext-xsl": "*", - "ext-zip": "*", - "aluguest/ical-easy-reader": "^1.5", - "danielstjules/stringy": "^3.1", - "davidepastore/codice-fiscale": "^0.6.0", - "dragonmantank/cron-expression": "^1.0", - "ezyang/htmlpurifier": "^4.8", - "filp/whoops": "^2.1", - "guzzlehttp/guzzle": "^6.3", - "ifsnop/mysqldump-php": "^2.3", - "illuminate/database": "~5.4.0", - "intervention/image": "^2.3", - "league/csv": "^8.2", - "league/oauth2-client": "^2.6", - "league/oauth2-google": "^3.0", - "maximebf/debugbar": "^1.15", - "monolog/monolog": "^1.22", - "mpdf/mpdf": "^v8.0.7", - "mpociot/vat-calculator": "^2.3", - "owasp/csrf-protector-php": "^1.0", - "phpmailer/phpmailer": "^6.0", - "respect/validation": "^1.1", - "servo/fluidxml": "^1.21", - "slim/flash": "^0.4.0", - "spipu/html2pdf": "^5.0", - "symfony/filesystem": "^3.3", - "symfony/finder": "^3.3", - "symfony/polyfill-ctype": "^1.8", - "symfony/polyfill-php70": "^1.8", - "symfony/translation": "^3.3", - "symfony/var-dumper": "^3.3", - "thenetworg/oauth2-azure": "^2.0", - "willdurand/geocoder": "^3.3" - }, - "require-dev": { - "codeception/codeception": "^3.0", - "friendsofphp/php-cs-fixer": "^2.10" - }, - "autoload": { - "psr-4": { - "": "src/", - "Update\\": "update/", - "Modules\\Aggiornamenti\\": ["modules/aggiornamenti/custom/src/", "modules/aggiornamenti/src/"], - "Modules\\Anagrafiche\\": ["modules/anagrafiche/custom/src/", "modules/anagrafiche/src/"], - "Modules\\Backups\\": ["modules/backups/custom/src/", "modules/backups/src/"], - "Modules\\Emails\\": ["modules/emails/custom/src/", "modules/emails/src/"], - "Modules\\Articoli\\": ["modules/articoli/custom/src/", "modules/articoli/src/"], - "Modules\\Checklists\\": ["modules/checklists/custom/src/", "modules/checklists/src/"], - "Modules\\Ritenute\\": ["modules/ritenute/custom/src/", "modules/ritenute/src/"], - "Modules\\RitenuteContributi\\": ["modules/ritenute_contributi/custom/src/", "modules/ritenute_contributi/src/"], - "Modules\\Rivalse\\": ["modules/rivalse/custom/src/", "modules/rivalse/src/"], - "Modules\\Newsletter\\": ["modules/newsletter/custom/src/", "modules/newsletter/src/"], - "Modules\\Iva\\": ["modules/iva/custom/src/", "modules/iva/src/"], - "Modules\\DDT\\": ["modules/ddt/custom/src/", "modules/ddt/src/"], - "Modules\\Fatture\\": ["modules/fatture/custom/src/", "modules/fatture/src/"], - "Modules\\Ordini\\": ["modules/ordini/custom/src/", "modules/ordini/src/"], - "Modules\\Preventivi\\": ["modules/preventivi/custom/src/", "modules/preventivi/src/"], - "Modules\\Contratti\\": ["modules/contratti/custom/src/", "modules/contratti/src/"], - "Modules\\Interventi\\": ["modules/interventi/custom/src/", "modules/interventi/src/"], - "Modules\\Pagamenti\\": ["modules/pagamenti/custom/src/", "modules/pagamenti/src/"], - "Modules\\Statistiche\\": ["modules/statistiche/custom/src/", "modules/statistiche/src/"], - "Modules\\Scadenzario\\": ["modules/scadenzario/custom/src/", "modules/scadenzario/src/"], - "Modules\\PrimaNota\\": ["modules/primanota/custom/src/", "modules/primanota/src/"], - "Modules\\Utenti\\": ["modules/utenti/custom/src/", "modules/utenti/src/"], - "Modules\\StatoServizi\\": ["modules/stato_servizi/custom/src/", "modules/stato_servizi/src/"], - "Modules\\StatiIntervento\\": ["modules/stati_intervento/custom/src/", "modules/stati_intervento/src/"], - "Modules\\StatiPreventivo\\": ["modules/stati_preventivo/custom/src/", "modules/stati_preventivo/src/"], - "Modules\\StatiContratto\\": ["modules/stati_contratto/custom/src/", "modules/stati_contratto/src/"], - "Modules\\TipiIntervento\\": ["modules/tipi_intervento/custom/src/", "modules/tipi_intervento/src/"], - "Modules\\CategorieDocumentali\\": ["modules/categorie_documenti/custom/src/", "modules/categorie_documenti/src/"], - "Modules\\PianiSconto\\": ["modules/piano_sconto/custom/src/", "modules/piano_sconto/src/"], - "Modules\\Impianti\\": ["modules/impianti/custom/src/", "modules/impianti/src/"], - "Modules\\Importazione\\": ["modules/import/custom/src/", "modules/import/src/"], - "Modules\\Impostazioni\\": ["modules/impostazioni/custom/src/", "modules/impostazioni/src/"], - "Plugins\\ExportFE\\": ["plugins/exportFE/custom/src/", "plugins/exportFE/src/"], - "Plugins\\ImportFE\\": ["plugins/importFE/custom/src/", "plugins/importFE/src/"], - "Plugins\\ReceiptFE\\": ["plugins/receiptFE/custom/src/", "plugins/receiptFE/src/"], - "Plugins\\DichiarazioniIntento\\": ["plugins/dichiarazioni_intento/custom/src/", "plugins/dichiarazioni_intento/src/"], - "Plugins\\PianificazioneInterventi\\": ["plugins/pianificazione_interventi/custom/src/", "plugins/pianificazione_interventi/src/"], - "Plugins\\PianificazioneFatturazione\\": ["plugins/pianificazione_fatturazione/custom/src/", "plugins/pianificazione_fatturazione/src/"], - "Plugins\\StatisticheArticoli\\": ["plugins/statistiche_articoli/custom/src/", "plugins/statistiche_articoli/src/"], - "Plugins\\ListinoClienti\\": ["plugins/listino_clienti/custom/src/", "plugins/listino_clienti/src/"], - "Plugins\\ListinoFornitori\\": ["plugins/listino_fornitori/custom/src/", "plugins/listino_fornitori/src/"] - }, - "files": [ - "lib/functions.php", - "lib/common.php", - "lib/helpers.php", - "lib/util.php", - "lib/deprecated.php" - ] - }, - "config": { - "sort-packages": true, - "optimize-autoloader": false, - "apcu-autoloader": true, - "prefer-stable": true, - "platform": { - "php": "5.6.4" - } - } -} diff --git a/config.example.php b/config.example.php deleted file mode 100755 index 3f982f57d..000000000 --- a/config.example.php +++ /dev/null @@ -1,63 +0,0 @@ -. - */ - -// Impostazioni di base per l'accesso al database -$db_host = '|host|'; -$db_username = '|username|'; -$db_password = '|password|'; -$db_name = '|database|'; -//$port = '|port|'; - -// Percorso della cartella di backup -$backup_dir = __DIR__.'/backup/'; - -// Tema selezionato per il front-end -$theme = 'default'; - -// Impostazioni di sicurezza -$redirectHTTPS = false; // Redirect automatico delle richieste da HTTP a HTTPS -$disableCSRF = true; // Protezione contro CSRF - -// Impostazioni di debug -$debug = false; - -// Personalizzazione dei gestori dei tag personalizzati -$HTMLWrapper = null; -$HTMLHandlers = []; -$HTMLManagers = []; - -// Lingua del progetto (per la traduzione e la conversione numerica) -$lang = '|lang|'; -// Personalizzazione della formattazione di timestamp, date e orari -$formatter = [ - 'timestamp' => '|timestamp|', - 'date' => '|date|', - 'time' => '|time|', - 'number' => [ - 'decimals' => '|decimals|', - 'thousands' => '|thousands|', - ], -]; - -// Ulteriori file CSS e JS da includere -$assets = [ - 'css' => [], - 'print' => [], - 'js' => [], -]; diff --git a/config/app.php b/config/app.php new file mode 100644 index 000000000..c9b8f5ae1 --- /dev/null +++ b/config/app.php @@ -0,0 +1,234 @@ + env('APP_NAME', 'Laravel'), + + /* + |-------------------------------------------------------------------------- + | Application Environment + |-------------------------------------------------------------------------- + | + | This value determines the "environment" your application is currently + | running in. This may determine how you prefer to configure various + | services the application utilizes. Set this in your ".env" file. + | + */ + + 'env' => env('APP_ENV', 'production'), + + /* + |-------------------------------------------------------------------------- + | Application Debug Mode + |-------------------------------------------------------------------------- + | + | When your application is in debug mode, detailed error messages with + | stack traces will be shown on every error that occurs within your + | application. If disabled, a simple generic error page is shown. + | + */ + + 'debug' => (bool) env('APP_DEBUG', false), + + /* + |-------------------------------------------------------------------------- + | Application URL + |-------------------------------------------------------------------------- + | + | This URL is used by the console to properly generate URLs when using + | the Artisan command line tool. You should set this to the root of + | your application so that it is used when running Artisan tasks. + | + */ + + 'url' => env('APP_URL', 'http://localhost'), + + 'asset_url' => env('ASSET_URL', null), + + /* + |-------------------------------------------------------------------------- + | Application Timezone + |-------------------------------------------------------------------------- + | + | Here you may specify the default timezone for your application, which + | will be used by the PHP date and date-time functions. We have gone + | ahead and set this to a sensible default for you out of the box. + | + */ + + 'timezone' => 'UTC', + + /* + |-------------------------------------------------------------------------- + | Application Locale Configuration + |-------------------------------------------------------------------------- + | + | The application locale determines the default locale that will be used + | by the translation service provider. You are free to set this value + | to any of the locales which will be supported by the application. + | + */ + + 'locale' => 'en', + + /* + |-------------------------------------------------------------------------- + | Application Fallback Locale + |-------------------------------------------------------------------------- + | + | The fallback locale determines the locale to use when the current one + | is not available. You may change the value to correspond to any of + | the language folders that are provided through your application. + | + */ + + 'fallback_locale' => 'en', + + /* + |-------------------------------------------------------------------------- + | Faker Locale + |-------------------------------------------------------------------------- + | + | This locale will be used by the Faker PHP library when generating fake + | data for your database seeds. For example, this will be used to get + | localized telephone numbers, street address information and more. + | + */ + + 'faker_locale' => 'en_US', + + /* + |-------------------------------------------------------------------------- + | Encryption Key + |-------------------------------------------------------------------------- + | + | This key is used by the Illuminate encrypter service and should be set + | to a random, 32 character string, otherwise these encrypted strings + | will not be safe. Please do this before deploying an application! + | + */ + + 'key' => env('APP_KEY'), + + 'cipher' => 'AES-256-CBC', + + /* + |-------------------------------------------------------------------------- + | Autoloaded Service Providers + |-------------------------------------------------------------------------- + | + | The service providers listed here will be automatically loaded on the + | request to your application. Feel free to add your own services to + | this array to grant expanded functionality to your applications. + | + */ + + 'providers' => [ + + /* + * Laravel Framework Service Providers... + */ + Illuminate\Auth\AuthServiceProvider::class, + Illuminate\Broadcasting\BroadcastServiceProvider::class, + Illuminate\Bus\BusServiceProvider::class, + Illuminate\Cache\CacheServiceProvider::class, + Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, + Illuminate\Cookie\CookieServiceProvider::class, + Illuminate\Database\DatabaseServiceProvider::class, + Illuminate\Encryption\EncryptionServiceProvider::class, + Illuminate\Filesystem\FilesystemServiceProvider::class, + Illuminate\Foundation\Providers\FoundationServiceProvider::class, + Illuminate\Hashing\HashServiceProvider::class, + Illuminate\Mail\MailServiceProvider::class, + Illuminate\Notifications\NotificationServiceProvider::class, + Illuminate\Pagination\PaginationServiceProvider::class, + Illuminate\Pipeline\PipelineServiceProvider::class, + Illuminate\Queue\QueueServiceProvider::class, + Illuminate\Redis\RedisServiceProvider::class, + Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, + Illuminate\Session\SessionServiceProvider::class, + Illuminate\Translation\TranslationServiceProvider::class, + Illuminate\Validation\ValidationServiceProvider::class, + Illuminate\View\ViewServiceProvider::class, + + /* + * Package Service Providers... + */ + + /* + * Application Service Providers... + */ + App\Providers\AppServiceProvider::class, + App\Providers\AuthServiceProvider::class, + // App\Providers\BroadcastServiceProvider::class, + App\Providers\EventServiceProvider::class, + App\Providers\RouteServiceProvider::class, + + ], + + /* + |-------------------------------------------------------------------------- + | Class Aliases + |-------------------------------------------------------------------------- + | + | This array of class aliases will be registered when this application + | is started. However, feel free to register as many as you wish as + | the aliases are "lazy" loaded so they don't hinder performance. + | + */ + + 'aliases' => [ + + 'App' => Illuminate\Support\Facades\App::class, + 'Arr' => Illuminate\Support\Arr::class, + 'Artisan' => Illuminate\Support\Facades\Artisan::class, + 'Auth' => Illuminate\Support\Facades\Auth::class, + 'Blade' => Illuminate\Support\Facades\Blade::class, + 'Broadcast' => Illuminate\Support\Facades\Broadcast::class, + 'Bus' => Illuminate\Support\Facades\Bus::class, + 'Cache' => Illuminate\Support\Facades\Cache::class, + 'Config' => Illuminate\Support\Facades\Config::class, + 'Cookie' => Illuminate\Support\Facades\Cookie::class, + 'Crypt' => Illuminate\Support\Facades\Crypt::class, + 'Date' => Illuminate\Support\Facades\Date::class, + 'DB' => Illuminate\Support\Facades\DB::class, + 'Eloquent' => Illuminate\Database\Eloquent\Model::class, + 'Event' => Illuminate\Support\Facades\Event::class, + 'File' => Illuminate\Support\Facades\File::class, + 'Gate' => Illuminate\Support\Facades\Gate::class, + 'Hash' => Illuminate\Support\Facades\Hash::class, + 'Http' => Illuminate\Support\Facades\Http::class, + 'Lang' => Illuminate\Support\Facades\Lang::class, + 'Log' => Illuminate\Support\Facades\Log::class, + 'Mail' => Illuminate\Support\Facades\Mail::class, + 'Notification' => Illuminate\Support\Facades\Notification::class, + 'Password' => Illuminate\Support\Facades\Password::class, + 'Queue' => Illuminate\Support\Facades\Queue::class, + 'RateLimiter' => Illuminate\Support\Facades\RateLimiter::class, + 'Redirect' => Illuminate\Support\Facades\Redirect::class, + // 'Redis' => Illuminate\Support\Facades\Redis::class, + 'Request' => Illuminate\Support\Facades\Request::class, + 'Response' => Illuminate\Support\Facades\Response::class, + 'Route' => Illuminate\Support\Facades\Route::class, + 'Schema' => Illuminate\Support\Facades\Schema::class, + 'Session' => Illuminate\Support\Facades\Session::class, + 'Storage' => Illuminate\Support\Facades\Storage::class, + 'Str' => Illuminate\Support\Str::class, + 'URL' => Illuminate\Support\Facades\URL::class, + 'Validator' => Illuminate\Support\Facades\Validator::class, + 'View' => Illuminate\Support\Facades\View::class, + + ], + +]; diff --git a/config/auth.php b/config/auth.php new file mode 100644 index 000000000..ba1a4d8cb --- /dev/null +++ b/config/auth.php @@ -0,0 +1,117 @@ + [ + 'guard' => 'web', + 'passwords' => 'users', + ], + + /* + |-------------------------------------------------------------------------- + | Authentication Guards + |-------------------------------------------------------------------------- + | + | Next, you may define every authentication guard for your application. + | Of course, a great default configuration has been defined for you + | here which uses session storage and the Eloquent user provider. + | + | All authentication drivers have a user provider. This defines how the + | users are actually retrieved out of your database or other storage + | mechanisms used by this application to persist your user's data. + | + | Supported: "session", "token" + | + */ + + 'guards' => [ + 'web' => [ + 'driver' => 'session', + 'provider' => 'users', + ], + + 'api' => [ + 'driver' => 'token', + 'provider' => 'users', + 'hash' => false, + ], + ], + + /* + |-------------------------------------------------------------------------- + | User Providers + |-------------------------------------------------------------------------- + | + | All authentication drivers have a user provider. This defines how the + | users are actually retrieved out of your database or other storage + | mechanisms used by this application to persist your user's data. + | + | If you have multiple user tables or models you may configure multiple + | sources which represent each model / table. These sources may then + | be assigned to any extra authentication guards you have defined. + | + | Supported: "database", "eloquent" + | + */ + + 'providers' => [ + 'users' => [ + 'driver' => 'eloquent', + 'model' => App\Models\User::class, + ], + + // 'users' => [ + // 'driver' => 'database', + // 'table' => 'users', + // ], + ], + + /* + |-------------------------------------------------------------------------- + | Resetting Passwords + |-------------------------------------------------------------------------- + | + | You may specify multiple password reset configurations if you have more + | than one user table or model in the application and you want to have + | separate password reset settings based on the specific user types. + | + | The expire time is the number of minutes that the reset token should be + | considered valid. This security feature keeps tokens short-lived so + | they have less time to be guessed. You may change this as needed. + | + */ + + 'passwords' => [ + 'users' => [ + 'provider' => 'users', + 'table' => 'password_resets', + 'expire' => 60, + 'throttle' => 60, + ], + ], + + /* + |-------------------------------------------------------------------------- + | Password Confirmation Timeout + |-------------------------------------------------------------------------- + | + | Here you may define the amount of seconds before a password confirmation + | times out and the user is prompted to re-enter their password via the + | confirmation screen. By default, the timeout lasts for three hours. + | + */ + + 'password_timeout' => 10800, + +]; diff --git a/config/broadcasting.php b/config/broadcasting.php new file mode 100644 index 000000000..2d529820c --- /dev/null +++ b/config/broadcasting.php @@ -0,0 +1,64 @@ + env('BROADCAST_DRIVER', 'null'), + + /* + |-------------------------------------------------------------------------- + | Broadcast Connections + |-------------------------------------------------------------------------- + | + | Here you may define all of the broadcast connections that will be used + | to broadcast events to other systems or over websockets. Samples of + | each available type of connection are provided inside this array. + | + */ + + 'connections' => [ + + 'pusher' => [ + 'driver' => 'pusher', + 'key' => env('PUSHER_APP_KEY'), + 'secret' => env('PUSHER_APP_SECRET'), + 'app_id' => env('PUSHER_APP_ID'), + 'options' => [ + 'cluster' => env('PUSHER_APP_CLUSTER'), + 'useTLS' => true, + ], + ], + + 'ably' => [ + 'driver' => 'ably', + 'key' => env('ABLY_KEY'), + ], + + 'redis' => [ + 'driver' => 'redis', + 'connection' => 'default', + ], + + 'log' => [ + 'driver' => 'log', + ], + + 'null' => [ + 'driver' => 'null', + ], + + ], + +]; diff --git a/config/cache.php b/config/cache.php new file mode 100644 index 000000000..8736c7a7a --- /dev/null +++ b/config/cache.php @@ -0,0 +1,110 @@ + env('CACHE_DRIVER', 'file'), + + /* + |-------------------------------------------------------------------------- + | Cache Stores + |-------------------------------------------------------------------------- + | + | Here you may define all of the cache "stores" for your application as + | well as their drivers. You may even define multiple stores for the + | same cache driver to group types of items stored in your caches. + | + | Supported drivers: "apc", "array", "database", "file", + | "memcached", "redis", "dynamodb", "octane", "null" + | + */ + + 'stores' => [ + + 'apc' => [ + 'driver' => 'apc', + ], + + 'array' => [ + 'driver' => 'array', + 'serialize' => false, + ], + + 'database' => [ + 'driver' => 'database', + 'table' => 'cache', + 'connection' => null, + 'lock_connection' => null, + ], + + 'file' => [ + 'driver' => 'file', + 'path' => storage_path('framework/cache/data'), + ], + + 'memcached' => [ + 'driver' => 'memcached', + 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), + 'sasl' => [ + env('MEMCACHED_USERNAME'), + env('MEMCACHED_PASSWORD'), + ], + 'options' => [ + // Memcached::OPT_CONNECT_TIMEOUT => 2000, + ], + 'servers' => [ + [ + 'host' => env('MEMCACHED_HOST', '127.0.0.1'), + 'port' => env('MEMCACHED_PORT', 11211), + 'weight' => 100, + ], + ], + ], + + 'redis' => [ + 'driver' => 'redis', + 'connection' => 'cache', + 'lock_connection' => 'default', + ], + + 'dynamodb' => [ + 'driver' => 'dynamodb', + 'key' => env('AWS_ACCESS_KEY_ID'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), + 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), + 'endpoint' => env('DYNAMODB_ENDPOINT'), + ], + + 'octane' => [ + 'driver' => 'octane', + ], + + ], + + /* + |-------------------------------------------------------------------------- + | Cache Key Prefix + |-------------------------------------------------------------------------- + | + | When utilizing a RAM based store such as APC or Memcached, there might + | be other applications utilizing the same cache. So, we'll specify a + | value to get prefixed to all our keys so we can avoid collisions. + | + */ + + 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'), + +]; diff --git a/config/cors.php b/config/cors.php new file mode 100644 index 000000000..8a39e6daa --- /dev/null +++ b/config/cors.php @@ -0,0 +1,34 @@ + ['api/*', 'sanctum/csrf-cookie'], + + 'allowed_methods' => ['*'], + + 'allowed_origins' => ['*'], + + 'allowed_origins_patterns' => [], + + 'allowed_headers' => ['*'], + + 'exposed_headers' => [], + + 'max_age' => 0, + + 'supports_credentials' => false, + +]; diff --git a/config/csrf_config.php b/config/csrf_config.php deleted file mode 100755 index 61b740868..000000000 --- a/config/csrf_config.php +++ /dev/null @@ -1,38 +0,0 @@ -. - */ - -/* - * Configuration file for CSRF Protector. - */ -return [ - 'logDirectory' => base_dir().'/logs', - 'failedAuthAction' => [ - 'GET' => 0, - 'POST' => 0, - ], - 'jsUrl' => base_path().'/assets/dist/js/csrf/csrfprotector.js', - 'tokenLength' => 10, - 'cookieConfig' => [ - 'path' => base_path(), - 'secure' => isHTTPS(true), - ], - 'verifyGetFor' => [], - 'CSRFP_TOKEN' => '', - 'disabledJavascriptMessage' => '', -]; diff --git a/config/database.php b/config/database.php new file mode 100644 index 000000000..b42d9b30a --- /dev/null +++ b/config/database.php @@ -0,0 +1,147 @@ + env('DB_CONNECTION', 'mysql'), + + /* + |-------------------------------------------------------------------------- + | Database Connections + |-------------------------------------------------------------------------- + | + | Here are each of the database connections setup for your application. + | Of course, examples of configuring each database platform that is + | supported by Laravel is shown below to make development simple. + | + | + | All database work in Laravel is done through the PHP PDO facilities + | so make sure you have the driver for your particular database of + | choice installed on your machine before you begin development. + | + */ + + 'connections' => [ + + 'sqlite' => [ + 'driver' => 'sqlite', + 'url' => env('DATABASE_URL'), + 'database' => env('DB_DATABASE', database_path('database.sqlite')), + 'prefix' => '', + 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), + ], + + 'mysql' => [ + 'driver' => 'mysql', + 'url' => env('DATABASE_URL'), + 'host' => env('DB_HOST', '127.0.0.1'), + 'port' => env('DB_PORT', '3306'), + 'database' => env('DB_DATABASE', 'forge'), + 'username' => env('DB_USERNAME', 'forge'), + 'password' => env('DB_PASSWORD', ''), + 'unix_socket' => env('DB_SOCKET', ''), + 'charset' => 'utf8mb4', + 'collation' => 'utf8mb4_unicode_ci', + 'prefix' => '', + 'prefix_indexes' => true, + 'strict' => true, + 'engine' => null, + 'options' => extension_loaded('pdo_mysql') ? array_filter([ + PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), + ]) : [], + ], + + 'pgsql' => [ + 'driver' => 'pgsql', + 'url' => env('DATABASE_URL'), + 'host' => env('DB_HOST', '127.0.0.1'), + 'port' => env('DB_PORT', '5432'), + 'database' => env('DB_DATABASE', 'forge'), + 'username' => env('DB_USERNAME', 'forge'), + 'password' => env('DB_PASSWORD', ''), + 'charset' => 'utf8', + 'prefix' => '', + 'prefix_indexes' => true, + 'schema' => 'public', + 'sslmode' => 'prefer', + ], + + 'sqlsrv' => [ + 'driver' => 'sqlsrv', + 'url' => env('DATABASE_URL'), + 'host' => env('DB_HOST', 'localhost'), + 'port' => env('DB_PORT', '1433'), + 'database' => env('DB_DATABASE', 'forge'), + 'username' => env('DB_USERNAME', 'forge'), + 'password' => env('DB_PASSWORD', ''), + 'charset' => 'utf8', + 'prefix' => '', + 'prefix_indexes' => true, + ], + + ], + + /* + |-------------------------------------------------------------------------- + | Migration Repository Table + |-------------------------------------------------------------------------- + | + | This table keeps track of all the migrations that have already run for + | your application. Using this information, we can determine which of + | the migrations on disk haven't actually been run in the database. + | + */ + + 'migrations' => 'migrations', + + /* + |-------------------------------------------------------------------------- + | Redis Databases + |-------------------------------------------------------------------------- + | + | Redis is an open source, fast, and advanced key-value store that also + | provides a richer body of commands than a typical key-value system + | such as APC or Memcached. Laravel makes it easy to dig right in. + | + */ + + 'redis' => [ + + 'client' => env('REDIS_CLIENT', 'phpredis'), + + 'options' => [ + 'cluster' => env('REDIS_CLUSTER', 'redis'), + 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), + ], + + 'default' => [ + 'url' => env('REDIS_URL'), + 'host' => env('REDIS_HOST', '127.0.0.1'), + 'password' => env('REDIS_PASSWORD', null), + 'port' => env('REDIS_PORT', '6379'), + 'database' => env('REDIS_DB', '0'), + ], + + 'cache' => [ + 'url' => env('REDIS_URL'), + 'host' => env('REDIS_HOST', '127.0.0.1'), + 'password' => env('REDIS_PASSWORD', null), + 'port' => env('REDIS_PORT', '6379'), + 'database' => env('REDIS_CACHE_DB', '1'), + ], + + ], + +]; diff --git a/config/filesystems.php b/config/filesystems.php new file mode 100644 index 000000000..760ef9728 --- /dev/null +++ b/config/filesystems.php @@ -0,0 +1,73 @@ + env('FILESYSTEM_DRIVER', 'local'), + + /* + |-------------------------------------------------------------------------- + | Filesystem Disks + |-------------------------------------------------------------------------- + | + | Here you may configure as many filesystem "disks" as you wish, and you + | may even configure multiple disks of the same driver. Defaults have + | been setup for each driver as an example of the required options. + | + | Supported Drivers: "local", "ftp", "sftp", "s3" + | + */ + + 'disks' => [ + + 'local' => [ + 'driver' => 'local', + 'root' => storage_path('app'), + ], + + 'public' => [ + 'driver' => 'local', + 'root' => storage_path('app/public'), + 'url' => env('APP_URL').'/storage', + 'visibility' => 'public', + ], + + 's3' => [ + 'driver' => 's3', + 'key' => env('AWS_ACCESS_KEY_ID'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'region' => env('AWS_DEFAULT_REGION'), + 'bucket' => env('AWS_BUCKET'), + 'url' => env('AWS_URL'), + 'endpoint' => env('AWS_ENDPOINT'), + 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), + ], + + ], + + /* + |-------------------------------------------------------------------------- + | Symbolic Links + |-------------------------------------------------------------------------- + | + | Here you may configure the symbolic links that will be created when the + | `storage:link` Artisan command is executed. The array keys should be + | the locations of the links and the values should be their targets. + | + */ + + 'links' => [ + public_path('storage') => storage_path('app/public'), + ], + +]; diff --git a/config/hashing.php b/config/hashing.php new file mode 100644 index 000000000..842577087 --- /dev/null +++ b/config/hashing.php @@ -0,0 +1,52 @@ + 'bcrypt', + + /* + |-------------------------------------------------------------------------- + | Bcrypt Options + |-------------------------------------------------------------------------- + | + | Here you may specify the configuration options that should be used when + | passwords are hashed using the Bcrypt algorithm. This will allow you + | to control the amount of time it takes to hash the given password. + | + */ + + 'bcrypt' => [ + 'rounds' => env('BCRYPT_ROUNDS', 10), + ], + + /* + |-------------------------------------------------------------------------- + | Argon Options + |-------------------------------------------------------------------------- + | + | Here you may specify the configuration options that should be used when + | passwords are hashed using the Argon algorithm. These will allow you + | to control the amount of time it takes to hash the given password. + | + */ + + 'argon' => [ + 'memory' => 1024, + 'threads' => 2, + 'time' => 2, + ], + +]; diff --git a/config/logging.php b/config/logging.php new file mode 100644 index 000000000..1aa06aa30 --- /dev/null +++ b/config/logging.php @@ -0,0 +1,105 @@ + env('LOG_CHANNEL', 'stack'), + + /* + |-------------------------------------------------------------------------- + | Log Channels + |-------------------------------------------------------------------------- + | + | Here you may configure the log channels for your application. Out of + | the box, Laravel uses the Monolog PHP logging library. This gives + | you a variety of powerful log handlers / formatters to utilize. + | + | Available Drivers: "single", "daily", "slack", "syslog", + | "errorlog", "monolog", + | "custom", "stack" + | + */ + + 'channels' => [ + 'stack' => [ + 'driver' => 'stack', + 'channels' => ['single'], + 'ignore_exceptions' => false, + ], + + 'single' => [ + 'driver' => 'single', + 'path' => storage_path('logs/laravel.log'), + 'level' => env('LOG_LEVEL', 'debug'), + ], + + 'daily' => [ + 'driver' => 'daily', + 'path' => storage_path('logs/laravel.log'), + 'level' => env('LOG_LEVEL', 'debug'), + 'days' => 14, + ], + + 'slack' => [ + 'driver' => 'slack', + 'url' => env('LOG_SLACK_WEBHOOK_URL'), + 'username' => 'Laravel Log', + 'emoji' => ':boom:', + 'level' => env('LOG_LEVEL', 'critical'), + ], + + 'papertrail' => [ + 'driver' => 'monolog', + 'level' => env('LOG_LEVEL', 'debug'), + 'handler' => SyslogUdpHandler::class, + 'handler_with' => [ + 'host' => env('PAPERTRAIL_URL'), + 'port' => env('PAPERTRAIL_PORT'), + ], + ], + + 'stderr' => [ + 'driver' => 'monolog', + 'level' => env('LOG_LEVEL', 'debug'), + 'handler' => StreamHandler::class, + 'formatter' => env('LOG_STDERR_FORMATTER'), + 'with' => [ + 'stream' => 'php://stderr', + ], + ], + + 'syslog' => [ + 'driver' => 'syslog', + 'level' => env('LOG_LEVEL', 'debug'), + ], + + 'errorlog' => [ + 'driver' => 'errorlog', + 'level' => env('LOG_LEVEL', 'debug'), + ], + + 'null' => [ + 'driver' => 'monolog', + 'handler' => NullHandler::class, + ], + + 'emergency' => [ + 'path' => storage_path('logs/laravel.log'), + ], + ], + +]; diff --git a/config/mail.php b/config/mail.php new file mode 100644 index 000000000..54299aabf --- /dev/null +++ b/config/mail.php @@ -0,0 +1,110 @@ + env('MAIL_MAILER', 'smtp'), + + /* + |-------------------------------------------------------------------------- + | Mailer Configurations + |-------------------------------------------------------------------------- + | + | Here you may configure all of the mailers used by your application plus + | their respective settings. Several examples have been configured for + | you and you are free to add your own as your application requires. + | + | Laravel supports a variety of mail "transport" drivers to be used while + | sending an e-mail. You will specify which one you are using for your + | mailers below. You are free to add additional mailers as required. + | + | Supported: "smtp", "sendmail", "mailgun", "ses", + | "postmark", "log", "array" + | + */ + + 'mailers' => [ + 'smtp' => [ + 'transport' => 'smtp', + 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), + 'port' => env('MAIL_PORT', 587), + 'encryption' => env('MAIL_ENCRYPTION', 'tls'), + 'username' => env('MAIL_USERNAME'), + 'password' => env('MAIL_PASSWORD'), + 'timeout' => null, + 'auth_mode' => null, + ], + + 'ses' => [ + 'transport' => 'ses', + ], + + 'mailgun' => [ + 'transport' => 'mailgun', + ], + + 'postmark' => [ + 'transport' => 'postmark', + ], + + 'sendmail' => [ + 'transport' => 'sendmail', + 'path' => '/usr/sbin/sendmail -bs', + ], + + 'log' => [ + 'transport' => 'log', + 'channel' => env('MAIL_LOG_CHANNEL'), + ], + + 'array' => [ + 'transport' => 'array', + ], + ], + + /* + |-------------------------------------------------------------------------- + | Global "From" Address + |-------------------------------------------------------------------------- + | + | You may wish for all e-mails sent by your application to be sent from + | the same address. Here, you may specify a name and address that is + | used globally for all e-mails that are sent by your application. + | + */ + + 'from' => [ + 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), + 'name' => env('MAIL_FROM_NAME', 'Example'), + ], + + /* + |-------------------------------------------------------------------------- + | Markdown Mail Settings + |-------------------------------------------------------------------------- + | + | If you are using Markdown based email rendering, you may configure your + | theme and component paths here, allowing you to customize the design + | of the emails. Or, you may simply stick with the Laravel defaults! + | + */ + + 'markdown' => [ + 'theme' => 'default', + + 'paths' => [ + resource_path('views/vendor/mail'), + ], + ], + +]; diff --git a/config/namespaces.php b/config/namespaces.php deleted file mode 100755 index ce6f78f32..000000000 --- a/config/namespaces.php +++ /dev/null @@ -1,64 +0,0 @@ -. - */ - -return [ - 'modules/banche' => 'Modules\Banche', -]; - -/* -'modules/aggiornamenti' => 'Modules\Aggiornamenti', -'modules/anagrafiche' => 'Modules\Anagrafiche', -'modules/backups' => 'Modules\Backups', -'modules/emails' => 'Modules\Emails', -'modules/articoli' => 'Modules\Articoli', -'modules/checklists' => 'Modules\Checklists', -'modules/ritenute' => 'Modules\Ritenute', -'modules/ritenute_contributi' => 'Modules\RitenuteContributi', -'modules/rivalse' => 'Modules\Rivalse', -'modules/newsletter' => 'Modules\Newsletter', -'modules/iva' => 'Modules\Iva', -'modules/ddt' => 'Modules\DDT', -'modules/fatture' => 'Modules\Fatture', -'modules/ordini' => 'Modules\Ordini', -'modules/preventivi' => 'Modules\Preventivi', -'modules/contratti' => 'Modules\Contratti', -'modules/interventi' => 'Modules\Interventi', -'modules/pagamenti' => 'Modules\Pagamenti', -'modules/statistiche' => 'Modules\Statistiche', -'modules/scadenzario' => 'Modules\Scadenzario', -'modules/primanota' => 'Modules\PrimaNota', -'modules/utenti' => 'Modules\Utenti', -'modules/stato_servizi' => 'Modules\StatoServizi', -'modules/stati_intervento' => 'Modules\StatiIntervento', -'modules/stati_preventivo' => 'Modules\StatiPreventivo', -'modules/stati_contratto' => 'Modules\StatiContratto', -'modules/tipi_intervento' => 'Modules\TipiIntervento', -'modules/categorie_documenti' => 'Modules\CategorieDocumentali', -'modules/listini' => 'Modules\Listini', -'modules/impianti' => 'Modules\Impianti', -'modules/impostazioni' => 'Modules\Impostazioni', -'plugins/exportFE' => 'Plugins\ExportFE', -'plugins/importFE' => 'Plugins\ImportFE', -'plugins/receiptFE' => 'Plugins\ReceiptFE', -'plugins/dichiarazioni_intento' => 'Plugins\DichiarazioniIntento', -'plugins/pianificazione_interventi' => 'Plugins\PianificazioneInterventi', -'plugins/pianificazione_fatturazione' => 'Plugins\PianificazioneFatturazione', -'plugins/statistiche_articoli' => 'Plugins\StatisticheArticoli', -'plugins/dettagli_articolo' => 'Plugins\DettagliArticolo', -*/ diff --git a/config/queue.php b/config/queue.php new file mode 100644 index 000000000..25ea5a819 --- /dev/null +++ b/config/queue.php @@ -0,0 +1,93 @@ + env('QUEUE_CONNECTION', 'sync'), + + /* + |-------------------------------------------------------------------------- + | Queue Connections + |-------------------------------------------------------------------------- + | + | Here you may configure the connection information for each server that + | is used by your application. A default configuration has been added + | for each back-end shipped with Laravel. You are free to add more. + | + | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" + | + */ + + 'connections' => [ + + 'sync' => [ + 'driver' => 'sync', + ], + + 'database' => [ + 'driver' => 'database', + 'table' => 'jobs', + 'queue' => 'default', + 'retry_after' => 90, + 'after_commit' => false, + ], + + 'beanstalkd' => [ + 'driver' => 'beanstalkd', + 'host' => 'localhost', + 'queue' => 'default', + 'retry_after' => 90, + 'block_for' => 0, + 'after_commit' => false, + ], + + 'sqs' => [ + 'driver' => 'sqs', + 'key' => env('AWS_ACCESS_KEY_ID'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), + 'queue' => env('SQS_QUEUE', 'default'), + 'suffix' => env('SQS_SUFFIX'), + 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), + 'after_commit' => false, + ], + + 'redis' => [ + 'driver' => 'redis', + 'connection' => 'default', + 'queue' => env('REDIS_QUEUE', 'default'), + 'retry_after' => 90, + 'block_for' => null, + 'after_commit' => false, + ], + + ], + + /* + |-------------------------------------------------------------------------- + | Failed Queue Jobs + |-------------------------------------------------------------------------- + | + | These options configure the behavior of failed queue job logging so you + | can control which database and table are used to store the jobs that + | have failed. You may change them to any database / table you wish. + | + */ + + 'failed' => [ + 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), + 'database' => env('DB_CONNECTION', 'mysql'), + 'table' => 'failed_jobs', + ], + +]; diff --git a/config/services.php b/config/services.php new file mode 100644 index 000000000..2a1d616c7 --- /dev/null +++ b/config/services.php @@ -0,0 +1,33 @@ + [ + 'domain' => env('MAILGUN_DOMAIN'), + 'secret' => env('MAILGUN_SECRET'), + 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), + ], + + 'postmark' => [ + 'token' => env('POSTMARK_TOKEN'), + ], + + 'ses' => [ + 'key' => env('AWS_ACCESS_KEY_ID'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), + ], + +]; diff --git a/config/session.php b/config/session.php new file mode 100644 index 000000000..ac0802b19 --- /dev/null +++ b/config/session.php @@ -0,0 +1,201 @@ + env('SESSION_DRIVER', 'file'), + + /* + |-------------------------------------------------------------------------- + | Session Lifetime + |-------------------------------------------------------------------------- + | + | Here you may specify the number of minutes that you wish the session + | to be allowed to remain idle before it expires. If you want them + | to immediately expire on the browser closing, set that option. + | + */ + + 'lifetime' => env('SESSION_LIFETIME', 120), + + 'expire_on_close' => false, + + /* + |-------------------------------------------------------------------------- + | Session Encryption + |-------------------------------------------------------------------------- + | + | This option allows you to easily specify that all of your session data + | should be encrypted before it is stored. All encryption will be run + | automatically by Laravel and you can use the Session like normal. + | + */ + + 'encrypt' => false, + + /* + |-------------------------------------------------------------------------- + | Session File Location + |-------------------------------------------------------------------------- + | + | When using the native session driver, we need a location where session + | files may be stored. A default has been set for you but a different + | location may be specified. This is only needed for file sessions. + | + */ + + 'files' => storage_path('framework/sessions'), + + /* + |-------------------------------------------------------------------------- + | Session Database Connection + |-------------------------------------------------------------------------- + | + | When using the "database" or "redis" session drivers, you may specify a + | connection that should be used to manage these sessions. This should + | correspond to a connection in your database configuration options. + | + */ + + 'connection' => env('SESSION_CONNECTION', null), + + /* + |-------------------------------------------------------------------------- + | Session Database Table + |-------------------------------------------------------------------------- + | + | When using the "database" session driver, you may specify the table we + | should use to manage the sessions. Of course, a sensible default is + | provided for you; however, you are free to change this as needed. + | + */ + + 'table' => 'sessions', + + /* + |-------------------------------------------------------------------------- + | Session Cache Store + |-------------------------------------------------------------------------- + | + | While using one of the framework's cache driven session backends you may + | list a cache store that should be used for these sessions. This value + | must match with one of the application's configured cache "stores". + | + | Affects: "apc", "dynamodb", "memcached", "redis" + | + */ + + 'store' => env('SESSION_STORE', null), + + /* + |-------------------------------------------------------------------------- + | Session Sweeping Lottery + |-------------------------------------------------------------------------- + | + | Some session drivers must manually sweep their storage location to get + | rid of old sessions from storage. Here are the chances that it will + | happen on a given request. By default, the odds are 2 out of 100. + | + */ + + 'lottery' => [2, 100], + + /* + |-------------------------------------------------------------------------- + | Session Cookie Name + |-------------------------------------------------------------------------- + | + | Here you may change the name of the cookie used to identify a session + | instance by ID. The name specified here will get used every time a + | new session cookie is created by the framework for every driver. + | + */ + + 'cookie' => env( + 'SESSION_COOKIE', + Str::slug(env('APP_NAME', 'laravel'), '_').'_session' + ), + + /* + |-------------------------------------------------------------------------- + | Session Cookie Path + |-------------------------------------------------------------------------- + | + | The session cookie path determines the path for which the cookie will + | be regarded as available. Typically, this will be the root path of + | your application but you are free to change this when necessary. + | + */ + + 'path' => '/', + + /* + |-------------------------------------------------------------------------- + | Session Cookie Domain + |-------------------------------------------------------------------------- + | + | Here you may change the domain of the cookie used to identify a session + | in your application. This will determine which domains the cookie is + | available to in your application. A sensible default has been set. + | + */ + + 'domain' => env('SESSION_DOMAIN', null), + + /* + |-------------------------------------------------------------------------- + | HTTPS Only Cookies + |-------------------------------------------------------------------------- + | + | By setting this option to true, session cookies will only be sent back + | to the server if the browser has a HTTPS connection. This will keep + | the cookie from being sent to you when it can't be done securely. + | + */ + + 'secure' => env('SESSION_SECURE_COOKIE'), + + /* + |-------------------------------------------------------------------------- + | HTTP Access Only + |-------------------------------------------------------------------------- + | + | Setting this value to true will prevent JavaScript from accessing the + | value of the cookie and the cookie will only be accessible through + | the HTTP protocol. You are free to modify this option if needed. + | + */ + + 'http_only' => true, + + /* + |-------------------------------------------------------------------------- + | Same-Site Cookies + |-------------------------------------------------------------------------- + | + | This option determines how your cookies behave when cross-site requests + | take place, and can be used to mitigate CSRF attacks. By default, we + | will set this value to "lax" since this is a secure default value. + | + | Supported: "lax", "strict", "none", null + | + */ + + 'same_site' => 'lax', + +]; diff --git a/config/view.php b/config/view.php new file mode 100644 index 000000000..22b8a18d3 --- /dev/null +++ b/config/view.php @@ -0,0 +1,36 @@ + [ + resource_path('views'), + ], + + /* + |-------------------------------------------------------------------------- + | Compiled View Path + |-------------------------------------------------------------------------- + | + | This option determines where all the compiled Blade templates will be + | stored for your application. Typically, this is within the storage + | directory. However, as usual, you are free to change this value. + | + */ + + 'compiled' => env( + 'VIEW_COMPILED_PATH', + realpath(storage_path('framework/views')) + ), + +]; diff --git a/controller.php b/controller.php deleted file mode 100755 index d5ef0265f..000000000 --- a/controller.php +++ /dev/null @@ -1,115 +0,0 @@ -. - */ - -include_once __DIR__.'/core.php'; - -if (!empty($id_record) && !empty($id_module)) { - redirect(base_path().'/editor.php?id_module='.$id_module.'&id_record='.$id_record); -} elseif (empty($id_module)) { - redirect(base_path().'/index.php'); -} - -include_once App::filepath('include|custom|', 'top.php'); - -// Inclusione gli elementi fondamentali -include_once base_dir().'/actions.php'; - -// Widget in alto -echo '{( "name": "widgets", "id_module": "'.$id_module.'", "position": "top", "place": "controller" )}'; - -// Lettura eventuali plugins modulo da inserire come tab -echo ' - '; - -redirectOperation($id_module, isset($id_parent) ? $id_parent : $id_record); - -// Interfaccia per la modifica dell'ordine e della visibilità delle colonne (Amministratore) -if ($user->is_admin && string_contains($module['option'], '|select|')) { - echo ' - - '.tr('Modifica colonne').' -
     
    - -'; -} - -// Widget in basso -echo '{( "name": "widgets", "id_module": "'.$id_module.'", "position": "right", "place": "controller" )}'; - -include_once App::filepath('include|custom|', 'bottom.php'); diff --git a/core.php b/core.php deleted file mode 100755 index d9306f0ad..000000000 --- a/core.php +++ /dev/null @@ -1,302 +0,0 @@ -. - */ - -// Rimozione header X-Powered-By -header_remove('X-Powered-By'); - -// Impostazioni di configurazione PHP -date_default_timezone_set('Europe/Rome'); - -// Controllo sulla versione PHP -$minimum = '5.6.0'; -if (version_compare(phpversion(), $minimum) < 0) { - echo ' -

    Stai utilizzando la versione PHP '.phpversion().', non compatibile con OpenSTAManager.

    - -

    Aggiorna PHP alla versione >= '.$minimum.'.

    '; - exit(); -} - -// Caricamento delle impostazioni personalizzabili -if (file_exists(__DIR__.'/config.inc.php')) { - include_once __DIR__.'/config.inc.php'; -} - -// Caricamento delle dipendenze e delle librerie del progetto -$loader = require_once __DIR__.'/vendor/autoload.php'; - -$namespaces = require_once __DIR__.'/config/namespaces.php'; -foreach ($namespaces as $path => $namespace) { - $loader->addPsr4($namespace.'\\', __DIR__.'/'.$path.'/custom/src'); - $loader->addPsr4($namespace.'\\', __DIR__.'/'.$path.'/src'); -} - -// Individuazione dei percorsi di base -App::definePaths(__DIR__); - -$docroot = DOCROOT; -$rootdir = ROOTDIR; -$baseurl = BASEURL; - -// Sicurezza della sessioni -//ini_set('session.cookie_samesite', 'strict'); -ini_set('session.use_trans_sid', '0'); -ini_set('session.use_only_cookies', '1'); - -session_set_cookie_params(0, base_path(), null, isHTTPS(true)); -session_start(); - -// Lettura della configurazione -$config = App::getConfig(); - -// Redirect al percorso HTTPS se impostato nella configurazione -if (!empty($config['redirectHTTPS']) && !isHTTPS(true)) { - header('HTTP/1.1 301 Moved Permanently'); - header('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); - exit(); -} - -/* GESTIONE DEGLI ERRORI */ -// Logger per la segnalazione degli errori -$logger = new Monolog\Logger('Logs'); -$logger->pushProcessor(new Monolog\Processor\UidProcessor()); -$logger->pushProcessor(new Monolog\Processor\WebProcessor()); - -// Registrazione globale del logger -Monolog\Registry::addLogger($logger, 'logs'); - -use Monolog\Handler\FilterHandler; -use Monolog\Handler\RotatingFileHandler; -use Monolog\Handler\StreamHandler; - -$handlers = []; -if (!API\Response::isAPIRequest()) { - // File di log di base (logs/error.log, logs/setup.log) - $handlers[] = new StreamHandler(base_dir().'/logs/error.log', Monolog\Logger::ERROR); - $handlers[] = new StreamHandler(base_dir().'/logs/setup.log', Monolog\Logger::EMERGENCY); - - // Messaggi grafici per l'utente - $handlers[] = new Extensions\MessageHandler(Monolog\Logger::ERROR); - - // File di log ordinati in base alla data - if (App::debug()) { - $handlers[] = new RotatingFileHandler(base_dir().'/logs/error.log', 0, Monolog\Logger::ERROR); - $handlers[] = new RotatingFileHandler(base_dir().'/logs/setup.log', 0, Monolog\Logger::EMERGENCY); - } - - // Inizializzazione Whoops - $whoops = new Whoops\Run(); - - if (App::debug()) { - $whoops->pushHandler(new Whoops\Handler\PrettyPageHandler()); - } - - // Abilita la gestione degli errori nel caso la richiesta sia di tipo AJAX - if (Whoops\Util\Misc::isAjaxRequest()) { - $whoops->pushHandler(new Whoops\Handler\JsonResponseHandler()); - } - - $whoops->register(); - - // Aggiunta di Monolog a Whoops - $whoops->pushHandler(function ($exception, $inspector, $run) use ($logger) { - $logger->addError($exception->getMessage(), [ - 'code' => $exception->getCode(), - 'message' => $exception->getMessage(), - 'file' => $exception->getFile(), - 'line' => $exception->getLine(), - 'trace' => $exception->getTraceAsString(), - ]); - }); -} else { - $handlers[] = new StreamHandler(base_dir().'/logs/api.log', Monolog\Logger::ERROR); -} - -// Disabilita i messaggi nativi di PHP -ini_set('display_errors', 0); -// Ignora gli avvertimenti e le informazioni relative alla deprecazione di componenti -error_reporting(E_ALL & ~E_WARNING & ~E_CORE_WARNING & ~E_NOTICE & ~E_USER_DEPRECATED & ~E_STRICT); - -$pattern = '[%datetime%] %channel%.%level_name%: %message% %context%'.PHP_EOL.'%extra% '.PHP_EOL; -$monologFormatter = new Monolog\Formatter\LineFormatter($pattern); -$monologFormatter->includeStacktraces(App::debug()); - -// Filtra gli errori per livello preciso del gestore dedicato -foreach ($handlers as $handler) { - $handler->setFormatter($monologFormatter); - $logger->pushHandler(new FilterHandler($handler, [$handler->getLevel()])); -} - -// Imposta Monolog come gestore degli errori -$handler = new Monolog\ErrorHandler($logger); -if (!API\Response::isAPIRequest()) { - $handler->registerErrorHandler([]); - $handler->registerExceptionHandler(Monolog\Logger::ERROR); -} -$handler->registerFatalHandler(Monolog\Logger::ERROR); - -// Database -$dbo = $database = database(); - -/* INTERNAZIONALIZZAZIONE */ -// Istanziamento del gestore delle traduzioni del progetto -$lang = !empty($config['lang']) ? $config['lang'] : (isset($_GET['lang']) ? $_GET['lang'] : null); -$formatter = !empty($config['formatter']) ? $config['formatter'] : []; -$translator = trans(); -$translator->addLocalePath(base_dir().'/locale'); -$translator->addLocalePath(base_dir().'/modules/*/locale'); -$translator->setLocale($lang, $formatter); - -// Individuazione di versione e revisione del progetto -$version = Update::getVersion(); -$revision = Update::getRevision(); - -/* ACCESSO E INSTALLAZIONE */ -// Controllo sulla presenza dei permessi di accesso basilari -$continue = $dbo->isInstalled() && !Update::isUpdateAvailable() && (Auth::check() || API\Response::isAPIRequest()); - -if (!empty($skip_permissions)) { - Permissions::skip(); -} - -if (!$continue && getURLPath() != slashes(base_path().'/index.php') && !Permissions::getSkip()) { - if (Auth::check()) { - Auth::logout(); - } - - redirect(base_path().'/index.php'); - exit(); -} - -/* INIZIALIZZAZIONE GENERALE */ -// Operazione aggiuntive (richieste non API) -if (!API\Response::isAPIRequest()) { - // Impostazioni di Content-Type e Charset Header - header('Content-Type: text/html; charset=UTF-8'); - - // Controllo CSRF - if (empty($config['disableCSRF'])) { - csrfProtector::init(); - } - - // Aggiunta del wrapper personalizzato per la generazione degli input - if (!empty($config['HTMLWrapper'])) { - HTMLBuilder\HTMLBuilder::setWrapper($config['HTMLWrapper']); - } - - // Aggiunta dei gestori personalizzati per la generazione degli input - foreach ((array) $config['HTMLHandlers'] as $key => $value) { - HTMLBuilder\HTMLBuilder::setHandler($key, $value); - } - - // Aggiunta dei gestori per componenti personalizzate - foreach ((array) $config['HTMLManagers'] as $key => $value) { - HTMLBuilder\HTMLBuilder::setManager($key, $value); - } - - // Registrazione globale del template per gli input HTML - register_shutdown_function('translateTemplate'); - ob_start(); - - // Retrocompatibilità - $_SESSION['infos'] = isset($_SESSION['infos']) ? array_unique($_SESSION['infos']) : []; - $_SESSION['warnings'] = isset($_SESSION['warnings']) ? array_unique($_SESSION['warnings']) : []; - $_SESSION['errors'] = isset($_SESSION['errors']) ? array_unique($_SESSION['errors']) : []; - - // Impostazione del tema grafico di default - $theme = !empty($config['theme']) ? $config['theme'] : 'default'; - - if ($continue) { - // Periodo di visualizzazione dei record - // Personalizzato - if (!empty($_GET['period_start'])) { - $_SESSION['period_start'] = $_GET['period_start']; - $_SESSION['period_end'] = $_GET['period_end']; - } - // Dal 01-01-yyy al 31-12-yyyy - elseif (!isset($_SESSION['period_start'])) { - $_SESSION['period_start'] = date('Y').'-01-01'; - $_SESSION['period_end'] = date('Y').'-12-31'; - } - - $id_record = filter('id_record'); - $id_parent = filter('id_parent'); - - Modules::setCurrent(filter('id_module')); - Plugins::setCurrent(filter('id_plugin')); - - // Variabili fondamentali - $module = Modules::getCurrent(); - $plugin = Plugins::getCurrent(); - $structure = isset($plugin) ? $plugin : $module; - - $id_module = $module ? $module['id'] : null; - $id_plugin = $plugin ? $plugin['id'] : null; - - $user = Auth::user(); - - if (!empty($id_module)) { - // Segmenti - if (!isset($_SESSION['module_'.$id_module]['id_segment'])) { - $segments = Modules::getSegments($id_module); - $_SESSION['module_'.$id_module]['id_segment'] = isset($segments[0]['id']) ? $segments[0]['id'] : null; - } - - Permissions::addModule($id_module); - } - - Permissions::check(); - } - - // Retrocompatibilità - $post = Filter::getPOST(); - $get = Filter::getGET(); -} - -// Inclusione dei file modutil.php -// TODO: sostituire * con lista module dir {aggiornamenti,anagrafiche,articoli} -// TODO: sostituire tutte le funzioni dei moduli con classi Eloquent relative -$files = glob(__DIR__.'/{modules,plugins}/*/modutil.php', GLOB_BRACE); -$custom_files = glob(__DIR__.'/{modules,plugins}/*/custom/modutil.php', GLOB_BRACE); -foreach ($custom_files as $key => $value) { - $index = array_search(str_replace('custom/', '', $value), $files); - if ($index !== false) { - unset($files[$index]); - } -} - -$list = array_merge($files, $custom_files); -foreach ($list as $file) { - include_once $file; -} - -// Inclusione dei file vendor/autoload.php di Composer -$files = glob(__DIR__.'/{modules,plugins}/*/vendor/autoload.php', GLOB_BRACE); -$custom_files = glob(__DIR__.'/{modules,plugins}/*/custom/vendor/autoload.php', GLOB_BRACE); -foreach ($custom_files as $key => $value) { - $index = array_search(str_replace('custom/', '', $value), $files); - if ($index !== false) { - unset($files[$index]); - } -} - -$list = array_merge($files, $custom_files); -foreach ($list as $file) { - include_once $file; -} diff --git a/cron.php b/cron.php deleted file mode 100644 index e841d1e5b..000000000 --- a/cron.php +++ /dev/null @@ -1,190 +0,0 @@ -. - */ - -/* - * Script dedicato alla gestione delle operazioni di cron ricorrenti del gestionale. - * Una volta attivato, questo script rimane attivo in background per gestire l'esecuzione delle diverse operazioni come pianificate nella tabella zz_tasks. - * - * Il file viene richiamato in automatico al login di un utente. - * Per garantire che lo script resti attivo in ogni situazione, si consiglia di introdurre una chiamata nel relativo crontab di sistema secondo il seguente schema: - */ -// Schema crontab: "*/5 * * * * php /cron.php" - -use Carbon\Carbon; -use Models\Cache; -use Monolog\Handler\RotatingFileHandler; -use Monolog\Logger; -use Tasks\Task; - -// Rimozione delle limitazioni sull'esecuzione -set_time_limit(0); -ignore_user_abort(true); - -// Chiusura della richiesta alla pagina -flush(); - -$skip_permissions = true; -include_once __DIR__.'/core.php'; - -// Controllo su possibili aggiornamenti per bloccare il sistema -$database_online = $database->isInstalled() && !Update::isUpdateAvailable(); -if (!$database_online) { - return; -} - -// Disabilita della sessione -session_write_close(); - -// Aggiunta di un logger specifico -$pattern = '[%datetime%] %level_name%: %message% %context%'.PHP_EOL; -$formatter = new Monolog\Formatter\LineFormatter($pattern); - -$logger = new Logger('Tasks'); -$handler = new RotatingFileHandler(base_dir().'/logs/cron.log', 7); -$handler->setFormatter($formatter); -$logger->pushHandler($handler); - -// Lettura della cache -$ultima_esecuzione = Cache::pool('Ultima esecuzione del cron'); -$data = $ultima_esecuzione->content; - -$in_esecuzione = Cache::pool('Cron in esecuzione'); -$cron_id = Cache::pool('ID del cron'); - -$disattiva = Cache::pool('Disabilita cron'); -if (!empty($disattiva->content)) { - return; -} - -// Impostazioni sugli slot di esecuzione -$slot_duration = 5; - -// Controllo sull'ultima esecuzione -$data = $data ? new Carbon($data) : null; -$minimo_esecuzione = (new Carbon())->subMinutes($slot_duration * 5); -if (!empty($data) && $minimo_esecuzione->lessThan($data)) { - return; -} - -// Generazione e registrazione del cron -$current_id = random_string(); -$cron_id->set($current_id); - -// Registrazione dell'esecuzione -$adesso = new Carbon(); -$ultima_esecuzione->set($adesso->__toString()); - -// Prima esecuzione immediata -$slot_minimo = $adesso->copy(); - -// Esecuzione ricorrente -$number = 1; -while (true) { - $disattiva->refresh(); - $cron_id->refresh(); - $in_esecuzione->refresh(); - - // Controllo su possibili aggiornamenti per bloccare il sistema - $database_online = $database->isInstalled() && !Update::isUpdateAvailable(); - if (!$database_online || !empty($disattiva->content) || $cron_id->content != $current_id) { - return; - } - - // Rimozione dei log più vecchi - $database->query('DELETE FROM zz_tasks_logs WHERE DATE_ADD(created_at, INTERVAL :interval DAY) <= NOW()', [ - ':interval' => 7, - ]); - - // Risveglio programmato tramite slot - $timestamp = $slot_minimo->getTimestamp(); - time_sleep_until($timestamp); - $in_esecuzione->set(true); - - // Registrazione dell'iterazione nei log - $logger->info('Cron #'.$number.' iniziato', [ - 'slot' => $slot_minimo->toDateTimeString(), - 'slot-unix' => $timestamp, - ]); - - // Calcolo del primo slot disponibile per l'esecuzione successiva - $inizio_iterazione = $slot_minimo->copy(); - $slot_minimo = $inizio_iterazione->copy()->startOfHour(); - while ($inizio_iterazione->greaterThanOrEqualTo($slot_minimo)) { - $slot_minimo->addMinutes($slot_duration); - } - - // Aggiornamento dei cron disponibili - $tasks = Task::all(); - foreach ($tasks as $task) { - $adesso = new Carbon(); - - // Registrazione della data per l'esecuzione se non indicata - if (empty($task->next_execution_at)) { - $task->registerNextExecution($inizio_iterazione); - $task->save(); - - $logger->info($task->name.': data mancante', [ - 'timestamp' => $task->next_execution_at->toDateTimeString(), - ]); - } - - // Esecuzione diretta solo nel caso in cui sia prevista - if ($task->next_execution_at->copy()->addSeconds(20)->greaterThanOrEqualTo($inizio_iterazione) && $task->next_execution_at->lessThanOrEqualTo($adesso->copy()->addseconds(20))) { - // Registrazione dell'esecuzione nei log - $logger->info($task->name.': '.$task->expression); - try { - $task->execute(); - } catch (Exception $e) { - // Registrazione del completamento nei log - $task->log('error', 'Errore di esecuzione', [ - 'code' => $e->getCode(), - 'message' => $e->getMessage(), - 'trace' => $e->getTraceAsString(), - ]); - - $logger->error($task->name.': errore'); - } - } - // Esecuzione mancata - elseif ($task->next_execution_at->lessThan($inizio_iterazione)) { - $logger->warning($task->name.': mancata', [ - 'timestamp' => $task->next_execution_at->toDateTimeString(), - ]); - - $task->registerMissedExecution($inizio_iterazione); - } - - // Calcolo dello successivo slot - if ($task->next_execution_at->lessThan($slot_minimo)) { - $slot_minimo = $task->next_execution_at; - } - } - - // Registrazione dello slot successivo nei log - $logger->info('Cron #'.$number.' concluso', [ - 'next-slot' => $slot_minimo->toDateTimeString(), - 'next-slot-unix' => $timestamp, - ]); - $in_esecuzione->set(false); - - // Registrazione dell'esecuzione - $adesso = new Carbon(); - $ultima_esecuzione->set($adesso->__toString()); - ++$number; -} diff --git a/editor.php b/editor.php deleted file mode 100755 index f5da27b4f..000000000 --- a/editor.php +++ /dev/null @@ -1,540 +0,0 @@ -. - */ - -include_once __DIR__.'/core.php'; - -use Carbon\Carbon; - -// Disabilitazione dei campi -$read_only = $structure->permission == 'r'; - -if (empty($id_record) && !empty($id_module) && empty($id_plugin)) { - redirect(base_path().'/controller.php?id_module='.$id_module); -} elseif (empty($id_record) && empty($id_module) && empty($id_plugin)) { - redirect(base_path().'/index.php'); -} - -include_once App::filepath('include|custom|', 'top.php'); - -if (!empty($id_record)) { - Util\Query::setSegments(false); - $query = Util\Query::getQuery($structure, [ - 'id' => $id_record, - ]); - Util\Query::setSegments(true); -} -// Rimozione della condizione deleted_at IS NULL per visualizzare anche i record eliminati -if (preg_match('/[`]*([a-z0-9_]*)[`]*[\.]*([`]*deleted_at[`]* IS NULL)/i', $query, $m)) { - $conditions_to_remove = []; - - $condition = trim($m[0]); - - if (!empty($table_name)) { - $condition = $table_name.'.'.$condition; - } - - $conditions_to_remove[] = ' AND '.$condition; - $conditions_to_remove[] = $condition.' AND '; - - $query = str_replace($conditions_to_remove, '', $query); - $query = str_replace($condition, '', $query); -} - -$has_access = !empty($query) ? $dbo->fetchNum($query) !== 0 : true; - -if ($has_access) { - // Inclusione gli elementi fondamentali - include_once base_dir().'/actions.php'; -} - -if (empty($record) || !$has_access) { - echo ' -
    -

    '. - ' '.tr('Record non trovato').' -

    - '.tr('Stai cercando di accedere ad un record eliminato o non presente').'. -

    -
    - - - '.tr('Indietro').' - -
    '; -} else { - // Widget in alto - echo '{( "name": "widgets", "id_module": "'.$id_module.'", "id_record": "'.$id_record.'", "position": "top", "place": "editor" )}'; - - $advanced_sessions = setting('Attiva notifica di presenza utenti sul record'); - if (!empty($advanced_sessions)) { - $dbo->query('DELETE FROM zz_semaphores WHERE id_utente='.prepare(Auth::user()['id']).' AND posizione='.prepare($id_module.', '.$id_record)); - - $dbo->query('INSERT INTO zz_semaphores (id_utente, posizione, updated) VALUES ('.prepare(Auth::user()['id']).', '.prepare($id_module.', '.$id_record).', NOW())'); - - echo ' -
    -
    -

    '.tr('Attenzione!').'

    -
    -
    -

    '.tr('I seguenti utenti stanno visualizzando questa pagina').':

    -
      -
    -

    '.tr('Prestare attenzione prima di effettuare modifiche, poichè queste potrebbero essere perse a causa di multipli salvataggi contemporanei').'.

    -
    -
    '; - } - - echo ' - - '; -} - -redirectOperation($id_module, isset($id_parent) ? $id_parent : $id_record); - -// Widget in basso -echo '{( "name": "widgets", "id_module": "'.$id_module.'", "id_record": "'.$id_record.'", "position": "right", "place": "editor" )}'; - -if (!empty($record)) { - echo ' -
    - - '.tr('Indietro').' - '; -} - -echo ' - - - php_flag engine off - - - php_flag engine off - diff --git a/files/impianti/componente.ini b/files/impianti/componente.ini deleted file mode 100755 index 666004e58..000000000 --- a/files/impianti/componente.ini +++ /dev/null @@ -1,20 +0,0 @@ -[Nome] -tipo = span -valore = "Componente di esempio" - -[Marca] -tipo = input -valore = - -[Tipo] -tipo = select -valore = -opzioni = "Tipo 1", "Tipo 2" - -[Data di installazione] -tipo = date -valore = - -[Note] -tipo = textarea -valore = diff --git a/include/.htaccess b/include/.htaccess deleted file mode 100755 index 3a4288278..000000000 --- a/include/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/include/bottom.php b/include/bottom.php deleted file mode 100755 index 918715b39..000000000 --- a/include/bottom.php +++ /dev/null @@ -1,97 +0,0 @@ -. - */ - -include_once __DIR__.'/../core.php'; - -if (Auth::check()) { - echo ' - - - - - -
    - - -
    - -
    -
    '; -} -echo ' - '; - -if (Auth::check()) { - if (!empty($_SESSION['keep_alive'])) { - echo ' - '; - } - - if (App::debug()) { - echo ' - - - - - '; - } - - $custom_css = html_entity_decode(setting('CSS Personalizzato')); - if (!empty($custom_css)) { - echo ' - '; - } - - // Hooks - echo ' - '; -} - -echo ' - - -'; - -// Retrocompatibilità -if (!empty($id_record) || basename($_SERVER['PHP_SELF']) == 'controller.php' || basename($_SERVER['PHP_SELF']) == 'index.php') { - unset($_SESSION['infos']); - unset($_SESSION['errors']); - unset($_SESSION['warnings']); -} diff --git a/include/colonne.php b/include/colonne.php deleted file mode 100644 index 6746474fb..000000000 --- a/include/colonne.php +++ /dev/null @@ -1,95 +0,0 @@ -. - */ - -include_once __DIR__.'/../core.php'; - -// Compatibilità per controller ed editor -$structure = Modules::get($id_module); - -echo ' -

    '.tr('Trascina le colonne per ordinare la struttura della tabella principale, seleziona e deseleziona le colonne per renderle visibili o meno').'.

    -
    '; - -$fields = $dbo->fetchArray('SELECT *, (SELECT GROUP_CONCAT(zz_groups.nome) FROM zz_group_view INNER JOIN zz_groups ON zz_group_view.id_gruppo = zz_groups.id WHERE zz_group_view.id_vista = zz_views.id) AS gruppi_con_accesso FROM zz_views WHERE id_module='.prepare($id_module).' ORDER BY `order` ASC'); -foreach ($fields as $field) { - echo ' -
    -
    - - - '.$field['name'].'
    ( '.$field['gruppi_con_accesso'].')
    - - -
    -
    '; -} - -echo ' -
    -
    - -'; diff --git a/include/common/articolo.php b/include/common/articolo.php deleted file mode 100755 index cd81098b8..000000000 --- a/include/common/articolo.php +++ /dev/null @@ -1,359 +0,0 @@ -. - */ - -$result['idarticolo'] = isset($result['idarticolo']) ? $result['idarticolo'] : null; -$qta_minima = 0; - -// Articolo -if (empty($result['idarticolo'])) { - // Sede partenza - if ($module['name'] == 'Interventi') { - echo ' -
    -
    - {[ "type": "select", "label": "'.tr('Partenza merce').'", "required": "1", "id":"idsede", "name": "idsede_partenza", "ajax-source": "sedi_azienda", "value": "'.($result['idsede_partenza'] ?: $options['idsede_partenza']).'" ]} -
    -
    '; - } - echo ' -
    -
    - {[ "type": "select", "label": "'.tr('Articolo').'", "name": "idarticolo", "required": 1, "value": "'.$result['idarticolo'].'", "ajax-source": "articoli", "select-options": '.json_encode($options['select-options']['articoli']).', "icon-after": "add|'.Modules::get('Articoli')['id'].'" ]} -
    -
    - - '; -} else { - $database = database(); - $articolo = $database->fetchOne('SELECT mg_articoli.id, - mg_fornitore_articolo.id AS id_dettaglio_fornitore, - IFNULL(mg_fornitore_articolo.codice_fornitore, mg_articoli.codice) AS codice, - IFNULL(mg_fornitore_articolo.descrizione, mg_articoli.descrizione) AS descrizione, - IFNULL(mg_fornitore_articolo.qta_minima, 0) AS qta_minima - FROM mg_articoli - LEFT JOIN mg_fornitore_articolo ON mg_fornitore_articolo.id_articolo = mg_articoli.id AND mg_fornitore_articolo.id = '.prepare($result['id_dettaglio_fornitore']).' - WHERE mg_articoli.id = '.prepare($result['idarticolo'])); - - $qta_minima = $articolo['qta_minima']; - - echo ' -

    '.tr('Articolo').': '.$articolo['codice'].' - '.$articolo['descrizione'].'.

    - - - '; -} - -echo ' - '; - -// Selezione impianto per gli Interventi -if ($module['name'] == 'Interventi') { - echo ' -
    -
    - {[ "type": "select", "label": "'.tr('Impianto su cui installare').'", "name": "idimpianto", "value": "'.$idimpianto.'", "ajax-source": "impianti-intervento", "select-options": '.json_encode($options['select-options']['impianti']).' ]} -
    -
    '; -} - -echo App::internalLoad('riga.php', $result, $options); - -// Informazioni aggiuntive -$disabled = empty($result['idarticolo']); - -echo ' -
    -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    -
    -
    - -'; diff --git a/include/common/barcode.php b/include/common/barcode.php deleted file mode 100644 index 54ded6559..000000000 --- a/include/common/barcode.php +++ /dev/null @@ -1,364 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$incorpora_iva = setting('Utilizza prezzi di vendita comprensivi di IVA'); -$intestazione_prezzo = ($options['dir'] == 'uscita' ? tr('Prezzo di acquisto') : ($incorpora_iva ? tr('Prezzo vendita ivato') : tr('Prezzo vendita imponibile'))); - -// Articolo -echo ' -
    -
    - {[ "type": "text", "label": "", "name": "barcode", "value": "", "icon-before": "" ]} -
    -
    - - - - - -
    -
    - - - - - - - - -
    '.tr('Articolo').''.$intestazione_prezzo.''.tr('Sconto').''.tr('Q.tà').'#
    -
    -
    '; - -echo ' - - - - - - - - - - - - - - - -'; diff --git a/include/common/conti.php b/include/common/conti.php deleted file mode 100755 index 1692cdc6c..000000000 --- a/include/common/conti.php +++ /dev/null @@ -1,118 +0,0 @@ -. - */ - -// Informazioni aggiuntive per Fatture -if ($module['name'] != 'Fatture di acquisto' && $module['name'] != 'Fatture di vendita') { - return; -} - -// Percentuale rivalsa e Percentuale ritenuta d'acconto -if ($options['action'] == 'edit') { - $id_rivalsa_inps = $result['idrivalsainps']; - $id_ritenuta_acconto = $result['idritenutaacconto']; - $calcolo_ritenuta_acconto = $result['calcolo_ritenuta_acconto']; -} elseif ($options['action'] == 'add') { - // Fattura di acquisto - if ($options['dir'] == 'uscita') { - // TODO: Luca S. questi campi non dovrebbero essere definiti all'interno della scheda fornitore? - $id_rivalsa_inps = ''; - $id_ritenuta_acconto = ''; - } - // Fattura di vendita - elseif ($options['dir'] == 'entrata') { - // Caso particolare per aggiunta articolo - $id_rivalsa_inps = ($options['op'] == 'addarticolo') ? '' : setting('Percentuale rivalsa'); - - $id_ritenuta_acconto = $options['id_ritenuta_acconto_predefined'] ?: setting("Percentuale ritenuta d'acconto"); - } -} - -$calcolo_ritenuta_acconto = $calcolo_ritenuta_acconto ?: setting("Metodologia calcolo ritenuta d'acconto predefinito"); - -echo ' -
    '; - - // Rivalsa INPS - echo ' -
    - {[ "type": "select", "label": "'.tr('Rivalsa').'", "name": "id_rivalsa_inps", "value": "'.$id_rivalsa_inps.'", "values": "query=SELECT * FROM co_rivalse", "help": "'.(($options['dir'] == 'entrata') ? setting('Tipo Cassa Previdenziale') : null).'" ]} -
    '; - - // Ritenuta d'acconto - echo ' -
    - {[ "type": "select", "label": "'.tr("Ritenuta d'acconto").'", "name": "id_ritenuta_acconto", "value": "'.$id_ritenuta_acconto.'", "values": "query=SELECT * FROM co_ritenutaacconto" ]} -
    '; - - // Calcola ritenuta d'acconto su - echo ' -
    - {[ "type": "select", "label": "'.tr("Calcola ritenuta d'acconto su").'", "name": "calcolo_ritenuta_acconto", "value": "'.$calcolo_ritenuta_acconto.'", "values": "list=\"IMP\":\"Imponibile\", \"IMP+RIV\":\"Imponibile + rivalsa\""]} -
    '; - - echo ' -
    '; - -if (!empty($options['show-ritenuta-contributi']) || empty($options['hide_conto'])) { - $width = !empty($options['show-ritenuta-contributi']) && empty($options['hide_conto']) ? 6 : 12; - - echo ' -
    '; - - // Ritenuta contributi - if (!empty($options['show-ritenuta-contributi'])) { - echo ' -
    - {[ "type": "checkbox", "label": "'.tr('Ritenuta contributi').'", "name": "ritenuta_contributi", "value": "'.$result['ritenuta_contributi'].'" ]} -
    '; - } - - // Conto - if (empty($options['hide_conto'])) { - echo ' -
    - {[ "type": "select", "label": "'.tr('Conto').'", "name": "idconto", "required": 1, "value": "'.$result['idconto'].'", "ajax-source": "'.$options['conti'].'" ]} -
    '; - } - - echo ' -
    '; -} - -echo ' -'; diff --git a/include/common/descrizione.php b/include/common/descrizione.php deleted file mode 100755 index 1b0e44ec0..000000000 --- a/include/common/descrizione.php +++ /dev/null @@ -1,25 +0,0 @@ -. - */ - -echo ' -
    -
    - {[ "type": "textarea", "label": "'.tr('Descrizione').'", "name": "descrizione", "id": "descrizione_riga", "value": '.json_encode($result['descrizione']).', "required": 1, "extra": "rows=\"4\"" ]} -
    -
    '; diff --git a/include/common/form.php b/include/common/form.php deleted file mode 100755 index 116547030..000000000 --- a/include/common/form.php +++ /dev/null @@ -1,50 +0,0 @@ -. - */ - -$result['id'] = isset($result['id']) ? $result['id'] : null; - -// Form di inserimento riga documento -echo ' -
    - - - - - - - '; - -echo ' - |response|'; - -$button = $options['action'] == 'add' ? tr('Aggiungi') : tr('Modifica'); -$icon = $options['action'] == 'add' ? 'fa-plus' : 'fa-pencil'; - -echo ' - - -
    -
    - -
    -
    -
    '; - -echo ' -'; diff --git a/include/common/importa.php b/include/common/importa.php deleted file mode 100755 index 8efbfd68a..000000000 --- a/include/common/importa.php +++ /dev/null @@ -1,601 +0,0 @@ -. - */ - -// Inizializzazione -$documento = $options['documento']; -$documento_finale = $options['documento_finale']; -if (empty($documento)) { - return; -} - -// Informazioni utili -$dir = $documento->direzione; -$original_module = Modules::get($documento->module); - -$name = !empty($documento_finale) ? $documento_finale->module : $options['module']; -$final_module = Modules::get($name); - -// IVA predefinita -$id_iva = $id_iva ?: setting('Iva predefinita'); - -$righe_totali = $documento->getRighe(); -if ($final_module['name'] == 'Interventi') { - $righe = $righe_totali->where('is_descrizione', '=', 0) - ->where('qta_rimanente', '>', 0); - $righe_evase = $righe_totali->where('is_descrizione', '=', 0) - ->where('qta_rimanente', '=', 0); -} elseif ($final_module['name'] == 'Ordini fornitore') { - $righe = $righe_totali; - $righe_evase = collect(); -} else { - $righe = $righe_totali->where('qta_rimanente', '>', 0); - $righe_evase = $righe_totali->where('qta_rimanente', '=', 0); -} - -if ($righe->isEmpty()) { - echo ' -

    '.tr('Non ci sono elementi da evadere').'...

    '; - - return; -} - -$link = !empty($documento_finale) ? base_path().'/editor.php?id_module='.$final_module['id'].'&id_record='.$documento_finale->id : base_path().'/controller.php?id_module='.$final_module['id']; - -echo ' -
    - - - - - - - '; - -// Creazione fattura dal documento -if (!empty($options['create_document'])) { - echo ' -
    -
    -

    '.tr('Nuovo documento').'

    -
    -
    - -
    - - -
    - {[ "type": "date", "label": "'.tr('Data del documento').'", "name": "data", "required": 1, "value": "-now-" ]} -
    '; - - // Opzioni aggiuntive per le Fatture - if (in_array($final_module['name'], ['Fatture di vendita', 'Fatture di acquisto'])) { - $id_segment = $_SESSION['module_'.$final_module['id']]['id_segment']; - - $stato_predefinito = $database->fetchOne("SELECT id FROM co_statidocumento WHERE descrizione = 'Bozza'"); - - echo ' - -
    - {[ "type": "select", "label": "'.tr('Stato').'", "name": "id_stato", "required": 1, "values": "query=SELECT * FROM co_statidocumento WHERE descrizione IN (\'Emessa\', \'Bozza\')", "value": "'.$stato_predefinito['id'].'"]} -
    - -
    - {[ "type": "select", "label": "'.tr('Ritenuta contributi').'", "name": "id_ritenuta_contributi", "value": "$id_ritenuta_contributi$", "values": "query=SELECT * FROM co_ritenuta_contributi" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Sezionale').'", "name": "id_segment", "required": 1, "values": "query=SELECT id, name AS descrizione FROM zz_segments WHERE id_module='.prepare($final_module['id']).' ORDER BY name", "value": "'.$id_segment.'" ]} -
    '; - } - - // Opzioni aggiuntive per gli Interventi - elseif ($final_module['name'] == 'Interventi') { - echo ' -
    - {[ "type": "select", "label": "'.tr('Stato').'", "name": "id_stato_intervento", "required": 1, "values": "query=SELECT idstatointervento AS id, descrizione, colore AS _bgcolor_ FROM in_statiintervento WHERE deleted_at IS NULL" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Tipo').'", "name": "id_tipo_intervento", "required": 1, "values": "query=SELECT idtipointervento AS id, descrizione FROM in_tipiintervento" ]} -
    '; - } - - // Opzioni aggiuntive per i Contratti - elseif ($final_module['name'] == 'Contratti') { - $stato_predefinito = $database->fetchOne("SELECT * FROM co_staticontratti WHERE descrizione = 'Bozza'"); - - echo ' -
    - {[ "type": "select", "label": "'.tr('Stato').'", "name": "id_stato", "required": 1, "values": "query=SELECT id, descrizione FROM co_staticontratti", "value": "'.$stato_predefinito['id'].'" ]} -
    '; - } - - // Opzioni aggiuntive per i DDT - elseif (in_array($final_module['name'], ['Ddt di vendita', 'Ddt di acquisto'])) { - $stato_predefinito = $database->fetchOne("SELECT * FROM dt_statiddt WHERE descrizione = 'Bozza'"); - - echo ' -
    - {[ "type": "select", "label": "'.tr('Stato').'", "name": "id_stato", "required": 1, "values": "query=SELECT * FROM dt_statiddt", "value": "'.$stato_predefinito['id'].'" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Causale trasporto').'", "name": "id_causale_trasporto", "required": 1, "ajax-source": "causali", "icon-after": "add|'.Modules::get('Causali')['id'].'", "help": "'.tr('Definisce la causale del trasporto').'" ]} -
    '; - } - - // Opzioni aggiuntive per gli Ordini - elseif (in_array($final_module['name'], ['Ordini cliente', 'Ordini fornitore'])) { - $stato_predefinito = $database->fetchOne("SELECT * FROM or_statiordine WHERE descrizione = 'Bozza'"); - - echo ' -
    - {[ "type": "select", "label": "'.tr('Stato').'", "name": "id_stato", "required": 1, "values": "query=SELECT * FROM or_statiordine WHERE descrizione IN(\'Bozza\', \'Accettato\', \'In attesa di conferma\', \'Annullato\')", "value": "'.$stato_predefinito['id'].'" ]} -
    '; - } - - // Selezione fornitore per Ordine fornitore - if ($options['op'] == 'add_ordine_cliente' || $options['op'] == 'add_intervento' || $options['op'] == 'add_ordine_fornitore') { - $tipo_anagrafica = $options['op'] == 'add_intervento' ? tr('Cliente') : tr('Fornitore'); - $ajax = $options['op'] == 'add_intervento' ? 'clienti' : 'fornitori'; - - echo ' -
    - {[ "type": "select", "label": "'.$tipo_anagrafica.'", "name": "idanagrafica", "required": 1, "ajax-source": "'.$ajax.'", "icon-after": "add|'.Modules::get('Anagrafiche')['id'].'|tipoanagrafica='.$tipo_anagrafica.'" ]} -
    '; - } - - echo ' -
    -
    -
    '; -} - -// Conto, rivalsa INPS, ritenuta d'acconto e ritenuta contributi -if (in_array($final_module['name'], ['Fatture di vendita', 'Fatture di acquisto']) && !in_array($original_module['name'], ['Fatture di vendita', 'Fatture di acquisto'])) { - $id_rivalsa_inps = setting('Percentuale rivalsa'); - if ($dir == 'uscita') { - $id_ritenuta_acconto = $documento->anagrafica->id_ritenuta_acconto_acquisti; - } else { - $id_ritenuta_acconto = $documento->anagrafica->id_ritenuta_acconto_vendite ?: setting("Percentuale ritenuta d'acconto"); - } - $calcolo_ritenuta_acconto = setting("Metodologia calcolo ritenuta d'acconto predefinito"); - - $show_ritenuta_contributi = !empty($documento_finale['id_ritenuta_contributi']); - - $id_conto = $documento_finale['idconto']; - if (empty($id_conto)) { - $id_conto = $dir == 'entrata' ? setting('Conto predefinito fatture di vendita') : setting('Conto predefinito fatture di acquisto'); - } - - echo ' -
    -
    -

    '.tr('Opzioni generali delle righe').'

    -
    -
    '; - - echo ' -
    '; - - // Rivalsa INPS - echo ' -
    - {[ "type": "select", "label": "'.tr('Rivalsa').'", "name": "id_rivalsa_inps", "value": "'.$id_rivalsa_inps.'", "values": "query=SELECT * FROM co_rivalse", "help": "'.($options['dir'] == 'entrata' ? setting('Tipo Cassa Previdenziale') : null).'" ]} -
    '; - - // Ritenuta d'acconto - echo ' -
    - {[ "type": "select", "label": "'.tr("Ritenuta d'acconto").'", "name": "id_ritenuta_acconto", "value": "'.$id_ritenuta_acconto.'", "values": "query=SELECT * FROM co_ritenutaacconto" ]} -
    '; - - // Calcola ritenuta d'acconto su - echo ' -
    - {[ "type": "select", "label": "'.tr("Calcola ritenuta d'acconto su").'", "name": "calcolo_ritenuta_acconto", "value": "'.$calcolo_ritenuta_acconto.'", "values": "list=\"IMP\":\"Imponibile\", \"IMP+RIV\":\"Imponibile + rivalsa\"", "required": "1" ]} -
    '; - - echo ' -
    '; - - $width = $show_ritenuta_contributi ? 6 : 12; - - echo ' -
    '; - - // Ritenuta contributi - if ($show_ritenuta_contributi) { - echo ' -
    - {[ "type": "checkbox", "label": "'.tr('Ritenuta contributi').'", "name": "ritenuta_contributi", "value": "1" ]} -
    '; - } - - // Conto - echo ' -
    - {[ "type": "select", "label": "'.tr('Conto').'", "name": "id_conto", "required": 1, "value": "'.$id_conto.'", "ajax-source": "'.($dir == 'entrata' ? 'conti-vendite' : 'conti-acquisti').'" ]} -
    -
    -
    -
    '; -} - -// Righe del documento -echo ' -
    -
    -

    '.tr('Righe da importare').'

    -
    - - - - - - - - '; - -if (!empty($options['serials'])) { - echo ' - '; -} - -echo ' - - - '; - -foreach ($righe as $i => $riga) { - if ($final_module['name'] == 'Ordini fornitore') { - $qta_rimanente = $riga['qta']; - } else { - $qta_rimanente = $riga['qta_rimanente']; - } - - $attr = 'checked="checked"'; - if ($original_module['name'] == 'Preventivi') { - if (empty($riga['confermato']) && $riga['is_descrizione'] == 0) { - $attr = ''; - } - } - - // Descrizione - echo ' - - '; - - // Q.tà rimanente - echo ' - '; - - // Q.tà da evadere - echo ' - '; - - echo ' - '; - - // Seriali - if (!empty($options['serials'])) { - echo ' - '; - } - - echo ' - '; -} - -// Totale -echo ' - - - - - - -
    '.tr('Descrizione').''.tr('Q.tà').''.tr('Q.tà da evadere').''.tr('Subtot.').''.tr('Seriali').'
    - - - - - - '; - - // Checkbox - da evadere? - echo ' - '; - - $descrizione = ($riga->isArticolo() ? $riga->articolo->codice.' - ' : '').$riga['descrizione']; - - echo ' '.nl2br($descrizione); - - echo ' - - '.numberFormat($qta_rimanente).' - - {[ "type": "number", "name": "qta_da_evadere['.$riga['id'].']", "id": "qta_'.$i.'", "required": 1, "value": "'.$qta_rimanente.'", "decimals": "qta", "min-value": "0", "extra": "'.(($riga['is_descrizione']) ? 'readonly' : '').' onkeyup=\"ricalcolaTotaleRiga('.$i.');\"" ]} - - - '; - - if (!empty($riga['abilita_serial'])) { - $serials = $riga->serials; - - $list = []; - foreach ($serials as $serial) { - $list[] = [ - 'id' => $serial, - 'text' => $serial, - ]; - } - - if (!empty($serials)) { - echo ' - {[ "type": "select", "name": "serial['.$riga['id'].'][]", "id": "serial_'.$i.'", "multiple": 1, "values": '.json_encode($list).', "value": "'.implode(',', $serials).'", "extra": "data-maximum=\"'.intval($riga['qta_rimanente']).'\"" ]}'; - } - } - - echo ' -
    - '.tr('Totale').': - - -
    -
    '; - -// Elenco righe evase completametne -if (!$righe_evase->isEmpty()) { - echo ' -
    -
    -

    '.tr('Righe evase completamente').'

    -
    - -
    -
    - - - - - - - - - '; - - foreach ($righe_evase as $riga) { - echo ' - - - - '; - } - - echo ' - -
    '.tr('Descrizione').''.tr('Q.tà').'
    '.$riga->descrizione.''.numberFormat($riga->qta, 'qta').' '.$riga->um.'
    -
    '; -} - -// Gestione articolo sottoscorta -echo ' - '; - -echo ' - - -
    -
    - -
    -
    -
    '; - -echo ' -'; - -// Individuazione scorte -$articoli = $documento->articoli->groupBy('idarticolo'); -$scorte = []; -foreach ($articoli as $elenco) { - $qta = $elenco->sum('qta'); - $articolo = $elenco->first()->articolo; - - $descrizione_riga = $articolo->codice.' - '.$articolo->descrizione; - $text = $articolo ? Modules::link('Articoli', $articolo->id, $descrizione_riga) : $descrizione_riga; - - $scorte[$articolo->id] = [ - 'qta' => $articolo->qta, - 'descrizione' => $text, - 'servizio' => $articolo->servizio, - ]; -} - -echo ' -'; diff --git a/include/common/riga.php b/include/common/riga.php deleted file mode 100755 index b9d3fc6ac..000000000 --- a/include/common/riga.php +++ /dev/null @@ -1,176 +0,0 @@ -. - */ - -// Descrizione -echo App::internalLoad('descrizione.php', $result, $options); - -// Conti, rivalsa INPS e ritenuta d'acconto -echo App::internalLoad('conti.php', $result, $options); - -// Iva -echo ' -
    -
    - {[ "type": "select", "label": "'.tr('Iva').'", "name": "idiva", "required": 1, "value": "'.$result['idiva'].'", "ajax-source": "iva", "select-options": '.json_encode($options['select-options']['iva']).' ]} -
    '; - -// Quantità -echo ' -
    - {[ "type": "number", "label": "'.tr('Q.tà').'", "name": "qta", "required": 1, "value": "'.abs($result['qta']).'", "decimals": "qta"'.(isset($result['max_qta']) ? ', "icon-after": "/ '.numberFormat(abs($result['max_qta']), 'qta').' "' : '').', "min-value": "'.abs($result['qta_evasa']).'" ]} -
    '; - -// Unità di misura -echo ' -
    - {[ "type": "select", "label": "'.tr('Unità di misura').'", "icon-after": "add|'.Modules::get('Unità di misura')['id'].'", "name": "um", "value": "'.$result['um'].'", "ajax-source": "misure" ]} -
    -
    '; - -echo ' -
    '; - -$width = $options['dir'] == 'entrata' ? 4 : 6; -$label = $options['dir'] == 'entrata' ? tr('Prezzo unitario di vendita') : tr('Prezzo unitario'); - -if ($options['dir'] == 'entrata') { - // Prezzo di acquisto unitario - echo ' -
    - {[ "type": "number", "label": "'.tr('Prezzo unitario di acquisto').'", "name": "costo_unitario", "value": "'.$result['costo_unitario'].'", "icon-after": "'.currency().'" ]} -
    '; - - // Funzione per l'aggiornamento in tempo reale del guadagno - echo ' - '; -} - -// Prezzo di vendita unitario -echo ' -
    - {[ "type": "number", "label": "'.$label.'", "name": "prezzo_unitario", "value": "'.$result['prezzo_unitario_corrente'].'", "required": 1, "icon-after": "'.currency().'", "help": "'.($options['dir'] == 'entrata' && setting('Utilizza prezzi di vendita comprensivi di IVA') ? tr('Importo IVA inclusa') : '').'" ]} -
    '; - -// Sconto unitario -echo ' -
    - {[ "type": "number", "label": "'.tr('Sconto unitario').'", "name": "sconto", "value": "'.($result['sconto_percentuale'] ?: $result['sconto_unitario_corrente']).'", "icon-after": "choice|untprc|'.$result['tipo_sconto'].'", "help": "'.tr('Il valore positivo indica uno sconto. Per applicare una maggiorazione inserire un valore negativo.').'" ]} -
    -
    '; - -// Data prevista evasione (per ordini) - -if (in_array($module['name'], ['Ordini cliente', 'Ordini fornitore', 'Preventivi'])) { - if ($options['action'] == 'add') { - if ($module['name'] == 'Ordini cliente') { - $confermato = setting('Conferma automaticamente le quantità negli ordini cliente'); - } elseif ($module['name'] == 'Ordini fornitore') { - $confermato = setting('Conferma automaticamente le quantità negli ordini fornitore'); - } else { - $confermato = setting('Conferma automaticamente le quantità nei preventivi'); - } - } else { - $confermato = $result['confermato']; - } - echo ' -
    -
    -

    '.tr('Informazioni aggiuntive').'

    -
    - -
    -
    - -
    -
    -
    - {[ "type": "date", "label": "'.tr('Data prevista evasione').'", "name": "data_evasione", "value": "'.$result['data_evasione'].'" ]} -
    -
    - {[ "type": "time", "label": "'.tr('Ora prevista evasione').'", "name": "ora_evasione", "value": "'.$result['ora_evasione'].'", "disabled": 1 ]} -
    -
    - {[ "type": "checkbox", "label": "'.tr('Cambia data a tutte le righe').'", "name": "data_evasione_all", "value": "" ]} -
    -
    -
    -
    - -
    -
    - {[ "type": "checkbox", "label": "'.tr('Articolo confermato').'", "name": "confermato", "value": "'.$confermato.'" ]} -
    -
    - {[ "type": "checkbox", "label": "'.tr('Cambia stato a tutte le righe').'", "name": "confermato_all", "value": "" ]} -
    -
    -
    -
    - - '; -} diff --git a/include/common/sconto.php b/include/common/sconto.php deleted file mode 100755 index d193afbea..000000000 --- a/include/common/sconto.php +++ /dev/null @@ -1,90 +0,0 @@ -. - */ - -// Descrizione -echo App::internalLoad('descrizione.php', $result, $options); - -// Conti, rivalsa INPS e ritenuta d'acconto -echo App::internalLoad('conti.php', $result, $options); - -$incorpora_iva = $options['dir'] == 'entrata' && setting('Utilizza prezzi di vendita comprensivi di IVA'); - -// Sconto percentuale -echo ' -
    '; - -if ($options['action'] == 'add') { - echo ' -
    - {[ "type": "number", "label": "'.tr('Sconto/maggiorazione percentuale').'", "name": "sconto_percentuale", "icon-after": "%", "help": "'.tr('Il valore positivo indica uno sconto: per applicare una maggiorazione inserire un valore negativo').'" ]} -
    '; -} - -// Sconto unitario -echo ' -
    - {[ "type": "number", "label": "'.tr('Sconto/maggiorazione unitario').'", "name": "sconto_unitario", "value": "'.$result['sconto_unitario_corrente'].'", "icon-after": "'.currency().'", "help": "'.tr('Il valore positivo indica uno sconto: per applicare una maggiorazione inserire un valore negativo').'" ]} -
    '; - -// Iva -echo ' -
    - {[ "type": "select", "label": "'.tr('Iva').'", "name": "idiva", "required": 1, "value": "'.$result['idiva'].'", "ajax-source": "iva" ]} -
    -
    '; - -// Funzione per l'aggiornamento in tempo reale dello sconto -$totale_documento = $incorpora_iva ? $options['totale_documento'] : $options['totale_imponibile_documento']; -echo ' -'; diff --git a/include/init/configuration.php b/include/init/configuration.php deleted file mode 100755 index ac92daeaa..000000000 --- a/include/init/configuration.php +++ /dev/null @@ -1,612 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$valid_config = isset($db_host) && isset($db_name) && isset($db_username) && isset($db_password); - -// Gestione del file di configurazione -if (file_exists('config.inc.php') && $valid_config && $dbo->isConnected()) { - return; -} - -$pageTitle = tr('Configurazione'); - -include_once App::filepath('include|custom|', 'top.php'); - -// Controllo sull'esistenza di nuovi parametri di configurazione -if (post('db_host') !== null) { - $db_host = $_POST['db_host']; // Fix per evitare la conversione in numero - $db_name = post('db_name'); - $db_username = post('db_username'); - $db_password = post('db_password'); - - $valid_config = isset($db_host) && isset($db_name) && isset($db_username) && isset($db_password); - - // Generazione di una nuova connessione al database - try { - $dbo = Database::getConnection(true, [ - 'db_host' => $db_host, - 'db_name' => $db_name, - 'db_username' => $db_username, - 'db_password' => $db_password, - ]); - } catch (Exception $e) { - } - - // Test della configurazione - if (post('test') !== null) { - ob_end_clean(); - - if ($dbo->isConnected()) { - $requirements = [ - 'SELECT', - 'INSERT', - 'UPDATE', - 'CREATE', - 'ALTER', - 'DROP', - ]; - - $db_host = str_replace('_', '\_', $db_name); - $db_name = str_replace('_', '\_', $db_name); - $db_username = str_replace('_', '\_', $db_name); - - $results = $dbo->fetchArray('SHOW GRANTS FOR CURRENT_USER'); - foreach ($results as $result) { - $privileges = current($result); - - if ( - string_contains($privileges, ' ON `'.$db_name.'`.*') || - string_contains($privileges, ' ON *.*') - ) { - $pieces = explode(', ', explode(' ON ', str_replace('GRANT ', '', $privileges))[0]); - - // Permessi generici sul database - if (in_array('ALL', $pieces) || in_array('ALL PRIVILEGES', $pieces)) { - $requirements = []; - break; - } - - // Permessi specifici sul database - foreach ($requirements as $key => $value) { - if (in_array($value, $pieces)) { - unset($requirements[$key]); - } - } - } - } - - // Permessi insufficienti - if (!empty($requirements)) { - $state = 1; - } - - // Permessi completi - else { - $state = 2; - } - } - - // Connessione fallita - else { - $state = 0; - } - - echo $state; - exit(); - } - - // Creazione della configurazione - if ($dbo->isConnected()) { - $new_config = file_get_contents(base_dir().'/config.example.php'); - - $decimals = post('decimal_separator'); - $thousands = post('thousand_separator'); - $decimals = $decimals == 'dot' ? '.' : ','; - $thousands = $thousands == 'dot' ? '.' : $thousands; - $thousands = $thousands == 'comma' ? ',' : $thousands; - - $values = [ - '|host|' => $db_host, - '|username|' => $db_username, - '|password|' => $db_password, - '|database|' => $db_name, - '|lang|' => post('lang'), - '|timestamp|' => post('timestamp_format'), - '|date|' => post('date_format'), - '|time|' => post('time_format'), - '|decimals|' => $decimals, - '|thousands|' => $thousands, - ]; - $new_config = str_replace(array_keys($values), $values, $new_config); - - // Controlla che la scrittura del file di configurazione sia andata a buon fine - $creation = file_put_contents('config.inc.php', $new_config); - if (!$creation) { - echo ' -
    -
    -

    '.tr('Permessi di scrittura mancanti').'

    -
    -
    -

    '.tr('Sembra che non ci siano i permessi di scrittura sul file _FILE_', [ - '_FILE_' => 'config.inc.php', - ]).'

    -
    -
    - - - ; - -
    - '.tr('Torna indietro').' - -
    -
    -
    - -
    -

    '.tr('Inserire il seguente testo nel file _FILE_', [ - '_FILE_' => 'config.inc.php', - ]).'

    -
    '.htmlentities($new_config).'
    -
    -
    -
    -
    '; - } - // Continua con l'esecuzione delle operazioni previste - else { - // Creazione manifest.json - $manifest = '{ - "dir" : "ltr", - "lang" : "it-IT", - "name" : "OpenSTAManager", - "scope" : "'.base_path().'", - "display" : "fullscreen", - "start_url" : "'.base_path().'", - "short_name" : "OSM", - "theme_color" : "transparent", - "description" : "OpenSTAManager", - "orientation" : "any", - "background_color" : "transparent", - "generated" : "true", - "icons" : [ - { - "src": "assets/dist/img/logo.png", - "type": "image/png", - "sizes": "489x91" - } - ] -}'; - file_put_contents('manifest.json', $manifest); - - redirect(base_path().'/index.php'); - exit(); - } - } -} - -// Controlla che i parametri di configurazione permettano l'accesso al database -if ((file_exists('config.inc.php') || $valid_config) && !$dbo->isConnected()) { - echo ' -
    -
    -

    '.tr('Impossibile connettersi al database').'

    -
    -
    -

    '.tr("Si è verificato un'errore durante la connessione al database").'.

    -

    '.tr('Controllare di aver inserito correttamente i dati di accesso, e che il database atto ad ospitare i dati del gestionale sia esistente').'.

    - '.tr('Riprova').' -
    -
    '; -} - -$img = App::getPaths()['img']; - -// Visualizzazione dell'interfaccia di impostazione iniziale, nel caso il file di configurazione sia mancante oppure i paramentri non siano sufficienti -if (empty($creation) && (!file_exists('config.inc.php') || !$valid_config)) { - if (file_exists('config.inc.php')) { - echo ' -
    -
    -

    '.tr('Parametri non sufficienti!').'

    -
    -
    -

    '.tr("L'avvio del software è fallito a causa dell'assenza di alcuni paramentri nella configurazione di base").'.

    -

    '.tr("Si prega di controllare che il file _FILE_ contenga tutti i dati inseriti durante la configurazione iniziale (con l'eccezione di password e indirizzo email amministrativi)", [ - '_FILE_' => 'config.inc.php', - ]).'.

    -

    '.tr("Nel caso il problema persista, rivolgersi all'assistenza ufficiale").'.

    - '.tr('Riprova').' -
    -
    '; - } - - // Controlli per essere sicuro che l'utente abbia letto la licenza - echo ' - '; - - echo ' -
    -
    - '.tr('OSM Logo').' -
    - -
    - - - - - - - - -
    - -
    '; - - // Introduzione - echo ' -

    '.tr('Benvenuto in _NAME_!', [ - '_NAME_' => 'OpenSTAManager', - ]).'

    -

    '.tr("Prima di procedere alla configurazione e all'installazione del software, sono necessari alcuni accorgimenti per garantire il corretto funzionamento del gestionale").'.

    -
    - -

    '.tr('Le estensioni e impostazioni PHP possono essere personalizzate nel file di configurazione _FILE_', [ - '_FILE_' => 'php.ini', - ]).'.

    -
    '; - - // REQUISITI PER IL CORRETTO FUNZIONAMENTO - include __DIR__.'/requirements.php'; - - echo ' -
    '; - - // LICENZA - echo ' -
    -

    '.tr('OpenSTAManager è tutelato dalla licenza _LICENSE_!', [ - '_LICENSE_' => 'GPL 3.0', - ]).'

    - -
    -
    - '.tr('Accetti la licenza GPLv3 di OpenSTAManager?').'* -
    - -
    - - -
    -
    -
    - -
    - [ '.tr('Versioni tradotte').' ]

    -
    '; - - $host = !empty($db_host) ? $db_host : ''; - $username = !empty($db_username) ? $db_username : ''; - $password = !empty($db_password) ? $db_password : ''; - $name = !empty($db_name) ? $db_name : ''; - - // PARAMETRI - echo ' -
    - '.tr('Aiuto').' - -

    '.tr('Non hai ancora configurato OpenSTAManager').'.

    -

    '.tr('Configura correttamente il software con i seguenti parametri (modificabili successivamente dal file _FILE_)', [ - '_FILE_' => 'config.inc.php', - ]).'

    - -
    '; - - // Form dei parametri - echo ' -
    - - -

    '.tr('Formato date').'

    -
    -
    - {[ "type": "text", "label": "'.tr('Formato data lunga').'", "name": "timestamp_format", "value": "d/m/Y H:i", "required": 1 ]} -
    - -
    - {[ "type": "text", "label": "'.tr('Formato data corta').'", "name": "date_format", "value": "d/m/Y", "required": 1 ]} -
    - -
    - {[ "type": "text", "label": "'.tr('Formato orario').'", "name": "time_format", "value": "H:i", "required": 1 ]} -
    -
    - - '.tr('I formati sono impostabili attraverso lo standard previsto da PHP: _LINK_', [ - '_LINK_' => 'https://www.php.net/manual/en/function.date.php#refsect1-function.date-parameters', - ]).'. - -
    '; - - if (!extension_loaded('intl')) { - $list = [ - [ - 'id' => 'comma', - 'text' => tr('Virgola'), - ], - [ - 'id' => 'dot', - 'text' => tr('Punto'), - ], - ]; - - echo ' -

    '.tr('Formato numeri').'

    - -
    -
    - {[ "type": "select", "label": "'.tr('Separatore dei decimali').'", "name": "decimal_separator", "value": "comma", "values": '.json_encode($list).', "required": 1 ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Separatore delle migliaia').'", "name": "thousand_separator", "value": "dot", "values": '.json_encode($list).' ]} -
    -
    - - '.tr("Si consiglia l'abilitazione dell'estensione _EXT_ di PHP", [ - '_EXT_' => 'intl', - ]).'. - -
    '; - } - - echo ' - -

    '.tr('Database').'

    -
    '; - - // db_host - echo ' -
    - {[ "type": "text", "label": "'.tr('Host del database').'", "name": "db_host", "placeholder": "'.tr('Host').'", "value": "'.$host.'", "help": "'.tr('Esempio').': localhost", "show-help": 0, "required": 1 ]} -
    -
    - -
    '; - - // db_username - echo ' -
    - {[ "type": "text", "label": "'.tr("Username dell'utente MySQL").'", "name": "db_username", "placeholder": "'.tr('Username').'", "value": "'.$username.'", "help": "'.tr('Esempio').': root", "show-help": 0, "required": 1 ]} -
    '; - - // db_password - echo ' -
    - {[ "type": "password", "label": "'.tr("Password dell'utente MySQL").'", "name": "db_password", "placeholder": "'.tr('Password').'", "value": "'.$password.'", "help": "'.tr('Esempio').': mysql", "show-help": 0 ]} -
    '; - - // db_name - echo ' -
    - {[ "type": "text", "label": "'.tr('Nome del database').'", "name": "db_name", "placeholder": "'.tr('Database').'", "value": "'.$name.'", "help": "'.tr('Esempio').': openstamanager", "show-help": 0, "required": 1 ]} -
    -
    '; - - echo ' - -
    -
    - *'.tr('Campi obbligatori').' -
    -
    - -
    -
    - -
    -
    - -
    -
    - -
    -
    -
    '; -} - -include_once App::filepath('include|custom|', 'bottom.php'); - -exit(); diff --git a/include/init/init.php b/include/init/init.php deleted file mode 100755 index cd08cf394..000000000 --- a/include/init/init.php +++ /dev/null @@ -1,265 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (Update::isUpdateAvailable() || !$dbo->isInstalled()) { - return; -} - -$has_azienda = $dbo->fetchNum("SELECT `an_anagrafiche`.`idanagrafica` FROM `an_anagrafiche` - LEFT JOIN `an_tipianagrafiche_anagrafiche` ON `an_anagrafiche`.`idanagrafica`=`an_tipianagrafiche_anagrafiche`.`idanagrafica` - LEFT JOIN `an_tipianagrafiche` ON `an_tipianagrafiche`.`idtipoanagrafica`=`an_tipianagrafiche_anagrafiche`.`idtipoanagrafica` -WHERE `an_tipianagrafiche`.`descrizione` = 'Azienda' AND `an_anagrafiche`.`deleted_at` IS NULL") != 0; -$has_user = $dbo->fetchNum('SELECT `id` FROM `zz_users`') != 0; - -$settings = [ - 'Regime Fiscale' => true, - 'Tipo Cassa Previdenziale' => false, - 'Conto predefinito fatture di vendita' => true, - 'Conto predefinito fatture di acquisto' => true, - "Percentuale ritenuta d'acconto" => false, - "Causale ritenuta d'acconto" => false, - 'Valuta' => true, - 'Utilizza prezzi di vendita comprensivi di IVA' => false, -]; - -if (!empty(setting("Percentuale ritenuta d'acconto"))) { - $settings["Causale ritenuta d'acconto"] = true; -} - -$has_settings = true; -foreach ($settings as $setting => $required) { - if (empty(setting($setting)) && $required) { - $has_settings = false; - break; - } -} - -if ($has_azienda && $has_user && $has_settings) { - return; -} - -$pageTitle = tr('Inizializzazione'); - -include_once App::filepath('include|custom|', 'top.php'); - -// Controllo sull'esistenza di nuovi parametri di configurazione -if (post('action') == 'init') { - // Azienda predefinita - if (!$has_azienda) { - Filter::set('post', 'op', 'add'); - $id_module = Modules::get('Anagrafiche')['id']; - include base_dir().'/modules/anagrafiche/actions.php'; - - // Logo stampe - if (!empty($_FILES) && !empty($_FILES['blob']['name'])) { - $upload = Uploads::upload($_FILES['blob'], [ - 'name' => 'Logo stampe', - 'id_module' => $id_module, - 'id_record' => $id_record, - ]); - - Settings::setValue('Logo stampe', $upload->filename); - } - } - - // Utente amministratore - if (!$has_user) { - $admin = $dbo->selectOne('zz_groups', ['id'], [ - 'nome' => 'Amministratori', - ]); - - // Creazione utente Amministratore - $dbo->insert('zz_users', [ - 'username' => post('admin_username'), - 'password' => Auth::hashPassword(post('admin_password')), - 'email' => post('admin_email'), - 'idgruppo' => $admin['id'], - 'idanagrafica' => isset($id_record) ? $id_record : 0, - 'enabled' => 1, - ]); - - // Creazione token API per l'amministratore - $dbo->insert('zz_tokens', [ - 'id_utente' => $dbo->lastInsertedID(), - 'token' => secure_random_string(), - ]); - } - - if (!$has_settings) { - foreach ($settings as $setting => $required) { - $setting = Settings::get($setting); - - $value = post('setting')[$setting['id']]; - if (!empty($value)) { - Settings::setValue($setting['nome'], $value); - } - } - } - - redirect(base_path(), 'js'); - exit(); -} - -$img = App::getPaths()['img']; - -// Visualizzazione dell'interfaccia di impostazione iniziale, nel caso il file di configurazione sia mancante oppure i paramentri non siano sufficienti -echo ' -
    -
    - '.tr('OSM Logo').' -
    - -
    -
    - '; - -if (!$has_user) { - echo ' - -
    -
    -

    '.tr('Amministrazione').'

    -
    - -
    -
    -
    - {[ "type": "text", "label": "'.tr('Username').'", "name": "admin_username", "value": "", "placeholder": "'.tr("Digita l'username dell'amministratore").'", "required": 1 ]} -
    - -
    - {[ "type": "password", "label": "'.tr('Password').'", "id": "password", "name": "admin_password", "value": "", "placeholder": "'.tr("Digita la password dell'amministratore").'", "required": 1, "strength": "#config" ]} -
    - -
    - {[ "type": "email", "label": "'.tr('Email').'", "name": "admin_email", "value": "", "placeholder": "'.tr("Digita l'indirizzo email dell'amministratore").'", "required": 1 ]} -
    -
    -
    -
    '; -} - -if (!$has_azienda) { - echo ' - -
    -
    -

    '.tr('Azienda predefinita').'

    -
    - -
    '; - - $idtipoanagrafica = $dbo->fetchArray("SELECT idtipoanagrafica FROM an_tipianagrafiche WHERE descrizione='Azienda'")[0]['idtipoanagrafica']; - $readonly_tipo = true; - - ob_start(); - include base_dir().'/modules/anagrafiche/add.php'; - $anagrafica = ob_get_clean(); - - echo str_replace('', '', $anagrafica); - - echo ' -
    -
    -

    '.tr('Logo stampe').'

    -
    - -
    -
    -
    - -
    - {[ "type": "file", "placeholder": "'.tr('File').'", "name": "blob" ]} -
    - - -

     

    '.tr('Per impostare il logo delle stampe, caricare un file ".jpg". Risoluzione consigliata 302x111 pixel').'.
    - -
    -
    '; - - echo ' -
    -
    '; -} - -if (!$has_settings) { - echo ' - -
    -
    -

    '.tr('Impostazioni di base').'

    -
    - -
    '; - $i = 0; - foreach ($settings as $setting => $required) { - if (empty(setting($setting))) { - if ($i % 2 == 0 or $i == 0) { - echo '
    '; - } - - echo ' -
    - '.Settings::input($setting, $required).' -
    '; - ++$i; - if ($i % 2 == 0 or $i == sizeof($settings)) { - echo '
    '; - } - } - } - - echo '
    -
    '; -} - -echo ' - -
    -
    - *'.tr('Campi obbligatori').' -
    -
    - -
    -
    - - -
    -
    '; - -echo ' - - -'; - -include_once App::filepath('include|custom|', 'bottom.php'); - -exit(); diff --git a/include/init/requirements.php b/include/init/requirements.php deleted file mode 100755 index 43a22cf30..000000000 --- a/include/init/requirements.php +++ /dev/null @@ -1,211 +0,0 @@ -. - */ - -// Apache -$modules = [ - 'mod_rewrite' => [ - 'server' => 'HTTP_MOD_REWRITE', - 'description' => tr('Fornisce un sistema di riscrittura URL basato su regole predefinite'), - ], -]; - -if (function_exists('apache_get_modules')) { - $available_modules = apache_get_modules(); -} - -$apache = []; -foreach ($modules as $name => $values) { - $description = $values['description']; - - $status = isset($available_modules) ? in_array($name, $available_modules) : $_SERVER[$values['server']] == 'On'; - - $apache[] = [ - 'name' => $name, - 'description' => $description, - 'status' => $status, - 'type' => tr('Modulo'), - ]; -} - -// PHP -$settings = [ - 'zip' => [ - 'type' => 'ext', - 'description' => tr('Permette di leggere e scrivere gli archivi compressi ZIP e i file al loro interno'), - ], - 'mbstring' => [ - 'type' => 'ext', - 'description' => tr('Permette di gestire i caratteri dello standard UTF-8'), - ], - 'pdo_mysql' => [ - 'type' => 'ext', - 'description' => tr('Permette di effettuare la connessione al database MySQL'), - ], - 'dom' => [ - 'type' => 'ext', - 'description' => tr('Permette la gestione dei file standard per la Fatturazione Elettronica'), - ], - 'xsl' => [ - 'type' => 'ext', - 'description' => tr('Permette di visualizzazione grafica della Fattura Elettronica'), - ], - 'openssl' => [ - 'type' => 'ext', - 'description' => tr("Permette l'utilizzo di funzioni crittografiche simmetriche e asimmetriche"), - ], - 'intl' => [ - 'type' => 'ext', - 'description' => tr("Permette l'automazione della conversione dei numeri"), - ], - 'curl' => [ - 'type' => 'ext', - 'description' => tr('Permette la comunicazione con servizi esterni'), - ], - 'soap' => [ - 'type' => 'ext', - 'description' => tr('Permette la comunicazione con servizi esterni, quali il database europeo delle Partite IVA (facoltativo)'), - ], - 'gd' => [ - 'type' => 'ext', - 'description' => tr('Permette la creazione dell\'immagine della firma per il rapportino d\'intervento (facoltativo)'), - ], - - //'display_errors' => [ - // 'type' => 'value', - // 'description' => true, - //], - 'upload_max_filesize' => [ - 'type' => 'value', - 'description' => '>32M', - ], - 'post_max_size' => [ - 'type' => 'value', - 'description' => '>32M', - ], -]; - -$php = []; -foreach ($settings as $name => $values) { - $description = $values['description']; - - if ($values['type'] == 'ext') { - $status = extension_loaded($name); - } else { - $ini = str_replace(['k', 'M'], ['000', '000000'], ini_get($name)); - $real = str_replace(['k', 'M'], ['000', '000000'], $description); - - if (string_starts_with($real, '>')) { - $status = $ini >= substr($real, 1); - } elseif (string_starts_with($real, '<')) { - $status = $ini <= substr($real, 1); - } else { - $status = ($real == $ini); - } - - if (is_bool($description)) { - $description = !empty($description) ? 'On' : 'Off'; - } else { - $description = str_replace(['>', '<'], '', $description); - } - - $description = tr('Valore consigliato: _VALUE_ (Valore attuale: _INI_)', [ - '_VALUE_' => $description, - '_INI_' => ini_get($name), - ]); - } - - $type = ($values['type'] == 'ext') ? tr('Estensione') : tr('Impostazione'); - - $php[] = [ - 'name' => $name, - 'description' => $description, - 'status' => $status, - 'type' => $type, - ]; -} - -// Percorsi di servizio -$dirs = [ - 'backup' => tr('Necessario per il salvataggio dei backup'), - 'files' => tr('Necessario per il salvataggio di file inseriti dagli utenti'), - 'logs' => tr('Necessario per la gestione dei file di log'), -]; - -$directories = []; -foreach ($dirs as $name => $description) { - $status = is_writable(base_dir().DIRECTORY_SEPARATOR.$name); - - $directories[] = [ - 'name' => $name, - 'description' => $description, - 'status' => $status, - 'type' => tr('Cartella'), - ]; -} - -$requirements = [ - tr('Apache') => $apache, - tr('PHP (_VERSION_)', [ - '_VERSION_' => phpversion(), - ]) => $php, - tr('Percorsi di servizio') => $directories, -]; - -// Tabelle di riepilogo -foreach ($requirements as $key => $values) { - $statuses = array_column($values, 'status'); - $general_status = true; - foreach ($statuses as $status) { - $general_status &= $status; - } - - echo ' -
    -
    -

    '.$key.'

    '; - - if ($general_status) { - echo ' -
    - -
    '; - } - - echo ' -
    -
    - '; - - foreach ($values as $value) { - echo ' - - - - - - '; - } - - echo ' -
    '.$value['type'].''.$value['name'].''.$value['description'].'
    -
    -
    '; -} diff --git a/include/init/update.php b/include/init/update.php deleted file mode 100755 index f0debc345..000000000 --- a/include/init/update.php +++ /dev/null @@ -1,260 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$updateRate = 20; -$scriptValue = $updateRate * 5; - -/* -* Aggiornamento tramite AJAX -*/ -if (filter('action') == 'do_update') { - // Aggiornamento in progresso - if (Update::isUpdateAvailable()) { - $update = Update::getCurrentUpdate(); - - $result = Update::doUpdate($updateRate); - - if (!empty($result)) { - // Aggiunta del messaggio generico riguardante l'aggiornamento - echo ' - '; - - if (is_array($result)) { - // Aggiunta del messaggio riguardante la conclusione dell'aggiornamento del database - if (!empty($update['sql']) && $result[1] == $result[2]) { - echo ' - '; - } - - $rate = $result[1] - $result[0]; - } elseif (!empty($update['script'])) { - // Aggiunta del messaggio riguardante la conclusione dello script - echo ' - '; - - $rate = $scriptValue; - } - - // Aumento della percentuale di completamento totale - if (!empty($rate)) { - echo ' - '; - } - - echo ' - '; - } else { - // Fallimento - echo ' -
    - '.tr("Errore durante l'esecuzione dell'aggiornamento alla versione _VERSION_", [ - '_VERSION_' => $update['version'], - ]).' -
    '; - } - } - // Aggiornamento completato - elseif (Update::isUpdateCompleted()) { - Update::updateCleanup(); - - echo ' -

    '.tr('Aggiornamento completato').'

    - '; - - // Istruzioni per la prima installazione - if ($_GET['firstuse'] == 'true') { - echo ' -

    '.tr("E' fortemente consigliato rimuovere i permessi di scrittura dal file _FILE_", [ - '_FILE_' => 'config.inc.php', - ]).'.

    '; - } - - echo ' - - '.tr('Continua').' - '; - } - - exit(); -} elseif (Update::isUpdateAvailable()) { - // Controllo se l'aggiornamento è in esecuzione - if (Update::isUpdateLocked() && filter('force') === null) { - $pageTitle = tr('Aggiornamento in corso!'); - - include_once App::filepath('include|custom|', 'top.php'); - - echo ' -
    -
    -

    '.tr('Aggiornamento in corso!').'

    -
    -
    -

    '.tr("E' attualmente in corso la procedura di aggiornamento del software, e pertanto siete pregati di attendere fino alla sua conclusione").'.

    -

    '.tr("Nel caso il problema persista, rivolgersi all'amministratore o all'assistenza ufficiale").'.

    - '.tr('Riprova').' -
    -
    '; - - include_once App::filepath('include|custom|', 'bottom.php'); - - exit(); - } - - $firstuse = !$dbo->isInstalled() ? 'true' : 'false'; - - $button = !$dbo->isInstalled() ? tr('Installa!') : tr('Aggiorna!'); - $pageTitle = !$dbo->isInstalled() ? tr('Installazione') : tr('Aggiornamento'); - - include_once App::filepath('include|custom|', 'top.php'); - - echo ' -
    -
    -

    '.(!$dbo->isInstalled() ? tr('Installazione') : tr('Aggiornamento')).'

    -
    -
    '; - if (!$dbo->isInstalled()) { - echo ' -

    '.tr("E' la prima volta che avvii OpenSTAManager e non hai ancora installato il database").'.

    '; - } else { - echo ' -

    '.tr("E' necessario aggiornare il database a una nuova versione").'.

    '; - } - echo ' -

    '.tr("Premi il tasto _BUTTON_ per procedere con l'".(!$dbo->isInstalled() ? tr('installazione') : tr('aggiornamento')).'!', [ - '_BUTTON_' => '"'.$button.'"', - ]).'

    - - - - -
    -
    -
    - 0% -
    -
    -
    -
    -
    -

    '.tr('Log').'

    -
    - -
    -
    -
    -
    -
    -
    '; - - $total = 0; - $updates = Update::getTodoUpdates(); - - foreach ($updates as $update) { - if ($update['sql'] && (!empty($update['done']) || is_null($update['done']))) { - $queries = readSQLFile(base_dir().$update['directory'].$update['filename'].'.sql', ';'); - $total += count($queries); - - if (intval($update['done']) > 1) { - $total -= intval($update['done']) - 2; - } - } - - if ($update['script']) { - $total += $scriptValue; - } - } - - echo ' - -
    -
    '; -} diff --git a/include/manager.php b/include/manager.php deleted file mode 100755 index a4b93821a..000000000 --- a/include/manager.php +++ /dev/null @@ -1,253 +0,0 @@ -. - */ - -use HTMLBuilder\HTMLBuilder; - -include_once __DIR__.'/../core.php'; - -// Compatibilità per controller ed editor -if (!empty($id_plugin)) { - $structure = Plugins::get($id_plugin); -} else { - $structure = Modules::get($id_module); -} - -if (!empty($id_plugin)) { - // Inclusione di eventuale plugin personalizzato - if (!empty($structure['script'])) { - $path = $structure->getEditFile(); - if (!empty($path)) { - include $path; - } - - return; - } - - echo ' -

    - - '.$structure['title'].(!empty($structure['help']) ? ' ' : '').''; - - if ($structure->hasAddFile()) { - echo ' - '; - } - - echo ' -

    '; -} - -$type = $structure['option']; - -// Lettura risultato query del modulo -// include $structure->filepath('init.php'); - -// Caricamento file aggiuntivo su elenco record -$controller_before = $structure->filepath('controller_before.php'); -if (!empty($controller_before)) { - include $controller_before; -} - -/* - * Datatables con record - */ -if (!empty($type) && $type != 'menu' && $type != 'custom') { - $total = Util\Query::readQuery($structure); - - if (empty($id_plugin) && count(Modules::getSegments($id_module)) > 1) { - echo ' -
    -
    - {[ "type": "select", "name": "id_segment_", "required": 0, "values": "query=SELECT id, name AS descrizione FROM zz_segments WHERE id_module = '.prepare($id_module).'", "value": "'.$_SESSION['module_'.$id_module]['id_segment'].'" ]} -
    -
    -
    '; - - echo ' - '; - } - - // Reset della selezione precedente - $_SESSION['module_'.$id_module]['selected'] = []; - $selezione = array_keys($_SESSION['module_'.$id_module]['selected']); - - $table_id = 'main_'.rand(0, 99); - echo ' - - - - '; - - foreach ($total['fields'] as $key => $field) { - $attr_td = ''; - $name = trim($field); - - // Check per tipologie di campi particolari - if (preg_match('/^color_/', $field)) { - $attr_td .= " width='140'"; - $field = str_replace('color_', '', $field); - } - - // Data (larghezza fissa) - elseif (preg_match('/^Data/', $field)) { - $attr_td .= " width='100'"; - } - - // Icona di stampa - elseif (trim($field) == '_print_') { - $attr_td .= " width='30'"; - $field = str_replace('_print_', '', $field); - } elseif (preg_match('/^icon_/', $field)) { - $attr_td .= " width='30'"; - $name = str_replace('icon_', 'icon_title_', $name); - $field = str_replace('icon_', '', $field); - } - - echo ' - '.$field.''; - } - - echo ' - - - - - - - - '; - echo ' - '; - foreach ($total['fields'] as $key => $field) { - echo ' - '; - } - echo ' - - -
    '; - - echo ' -
    -
    -
    - - -
    -
    - - - -
    - -
    '; - - if (setting('Abilita esportazione Excel e PDF')) { - echo ' -
    - - - - - -
    '; - } else { - echo ' - '; - } - - echo ' - - - - -
    -
    -
    '; -} - -/* - * Inclusione modulo personalizzato - */ -elseif ($type == 'custom') { - $path = $structure->getEditFile(); - if (!empty($path)) { - include $path; - } -} - -// Caricamento file aggiuntivo su elenco record -$controller_after = $structure->filepath('controller_after.php'); -if (!empty($controller_after)) { - include $controller_after; -} diff --git a/include/modifica_allegato.php b/include/modifica_allegato.php deleted file mode 100644 index a6a41db5d..000000000 --- a/include/modifica_allegato.php +++ /dev/null @@ -1,89 +0,0 @@ -. - */ - -use Models\Upload; - -$id_allegato = filter('id_allegato'); -$allegato = Upload::find($id_allegato); - -// Form di inserimento riga documento -echo ' -
    - - - - -
    -
    - {[ "type": "text", "label": "'.tr('Nome').'", "name": "nome_allegato", "value": "'.$allegato->name.'" ]} -
    - -
    - {[ "type": "text", "label": "'.tr('Categoria').'", "name": "categoria_allegato", "value": "'.$allegato->category.'", "disabled": "'.intval(in_array($allegato->category, ['Fattura Elettronica'])).'" ]} -
    -
    - - -
    -
    - -
    -
    -
    '; - -// Elenco categoria disponibili per l'autocompletamento -$where = '`id_module` '.(!empty($allegato['id_module']) && empty($allegato['id_plugin']) ? '= '.prepare($allegato['id_module']) : 'IS NULL').' AND `id_plugin` '.(!empty($allegato['id_plugin']) ? '= '.prepare($allegato['id_plugin']) : 'IS NULL').''; -$categories = $dbo->fetchArray('SELECT DISTINCT(BINARY `category`) AS `category` FROM `zz_files` WHERE '.$where.' ORDER BY `category`'); -$source = array_clean(array_column($categories, 'category')); - -echo ' - -'; diff --git a/include/riferimenti/riferimenti.php b/include/riferimenti/riferimenti.php deleted file mode 100644 index aaa40a4e4..000000000 --- a/include/riferimenti/riferimenti.php +++ /dev/null @@ -1,250 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\DDT\DDT; -use Modules\Ordini\Ordine; - -// Informazioni generali sulla riga -$source_type = filter('riga_type'); -$source_id = filter('riga_id'); -if (empty($source_type) || empty($source_id)) { - return; -} - -$source = $source_type::find($source_id); - -echo ' -

    '.tr('Informazioni per i riferimenti di: _DESC_', [ - '_DESC_' => $source->descrizione, -]).'

    - -
    '; - -include_once __DIR__.'/righe_riferimenti.php'; - -echo ' -
    - -
    - '.tr('Caricamento in corso').'... -
    '; - -$documenti_disponibili = collect(); -$direzione_richiesta = $source->getDocument()->direzione == 'entrata' ? 'uscita' : 'entrata'; - -// Individuazione DDT disponibili -$ddt = DDT::whereHas('stato', function ($query) { - $query->where('descrizione', '!=', 'Bozza'); -})->whereHas('tipo', function ($query) use ($direzione_richiesta) { - $query->where('dir', '=', $direzione_richiesta); -})->get(); -foreach ($ddt as $elemento) { - $documenti_disponibili->push([ - 'id' => get_class($elemento).'|'.$elemento->id, - 'text' => $elemento->getReference(1), - 'optgroup' => tr('Ddt in ').$source->getDocument()->direzione, - ]); -} - -// Individuazione ordini disponibili -$tipo_ordini = $direzione_richiesta == 'entrata' ? 'cliente' : 'fornitore'; -$ordini = Ordine::whereHas('stato', function ($query) { - $query->where('descrizione', '!=', 'Bozza'); -})->get(); -foreach ($ordini as $elemento) { - $documenti_disponibili->push([ - 'id' => get_class($elemento).'|'.$elemento->id, - 'text' => $elemento->getReference(1), - 'optgroup' => tr('Ordini ').$tipo_ordini, - ]); -} - -echo ' -
    -
    -

    '.tr('Nuovo riferimento').'

    -
    - -
    -
    -
    - {[ "type": "select", "label": "'.tr('Documento').'", "name": "documento_riferimento", "required": 1, "values": '.$documenti_disponibili->toJson().' ]} -
    -
    - -
    - -
    - '.tr('Caricamento in corso').'... -
    -
    -
    '; - -$file = basename(__FILE__); -echo ' - - -'; diff --git a/include/riferimenti/righe_documento.php b/include/riferimenti/righe_documento.php deleted file mode 100644 index f263c0bd1..000000000 --- a/include/riferimenti/righe_documento.php +++ /dev/null @@ -1,66 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -// Generazione della tabella per l'aggiunta dei riferimenti -$id_documento = filter('id_documento'); -$tipo_documento = filter('tipo_documento'); -if (empty($tipo_documento) || empty($id_documento)) { - return; -} -$documento = $tipo_documento::find($id_documento); - -// Informazioni sulla riga -$source_type = filter('source_type'); -$source_id = filter('source_id'); -$riferimenti = (array) filter('riferimenti'); - -echo ' - - - - - - - - '; - - $righe = $documento->getRighe(); - foreach ($righe as $riga) { - $riga_class = get_class($riga); - - $riferimento_locale = $riga_class.'|'.$riga->id; - $presente = in_array($riferimento_locale, $riferimenti); - - echo ' - - - - - '; - } - - echo ' - -
    '.tr('Descrizione').''.tr('Q.tà').' #
    '.$riga->descrizione.''.numberFormat($riga->qta_rimanente, 'qta').' / '.numberFormat($riga->qta, 'qta').' - -
    '; diff --git a/include/riferimenti/righe_riferimenti.php b/include/riferimenti/righe_riferimenti.php deleted file mode 100644 index a53cd7f0e..000000000 --- a/include/riferimenti/righe_riferimenti.php +++ /dev/null @@ -1,74 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -// Informazioni generali sulla riga -$source_type = $source_type ?: filter('source_type'); -$source_id = $source_id ?: filter('source_id'); -if (empty($source_type) || empty($source_id)) { - return; -} - -$source = $source_type::find($source_id); - -$riferimenti = $source->referenceTargets; -$elenco_riferimenti = []; -if (!$riferimenti->isEmpty()) { - echo ' - - - - - - - - '; - - foreach ($riferimenti as $riferimento) { - $riga = $riferimento->target; - $riga_class = get_class($source); - - echo ' - - - '; - - // Aggiunta all'elenco dei riferimenti - $elenco_riferimenti[] = addslashes($riga_class).'|'.$riga->id; - } - - echo ' - -
    '.tr('Riferimento').'
    - - - '.$riferimento->target->descrizione.' - -
    - '.reference($riferimento->target->getDocument()).' -
    '; -} else { - echo ' -
    - '.tr('Nessun riferimento presente').'. -
    '; -} diff --git a/include/top.php b/include/top.php deleted file mode 100755 index ad30a586c..000000000 --- a/include/top.php +++ /dev/null @@ -1,637 +0,0 @@ -. - */ - -use Util\FileSystem; - -include_once __DIR__.'/../core.php'; - -$paths = App::getPaths(); -$user = Auth::user(); - -$pageTitle = !empty($pageTitle) ? $pageTitle : $structure->title; - -$messages = flash()->getMessages(); - -echo ' - - - - '.$pageTitle.' - '.tr('OpenSTAManager').' - - - - - - '; - -if (file_exists(base_dir().'/manifest.json')) { - echo ' - '; -} - -// CSS -foreach (App::getAssets()['css'] as $style) { - echo ' - '; -} - -// Print CSS -foreach (App::getAssets()['print'] as $style) { - echo ' - '; -} - -if (Auth::check()) { - echo ' - '; -} else { - echo ' - '; -} - -// JS -foreach (App::getAssets()['js'] as $js) { - echo ' - '; -} - -// Impostazioni di default per gli alert -echo ' - '; - -if (Auth::check()) { - if (setting('Abilita esportazione Excel e PDF')) { - echo ' - - - '; - } - - if (setting('Attiva scorciatoie da tastiera')) { - echo ''; - echo ' - '; - } -} - -$settings_collapse = session_get('settings.sidebar-collapse') ? 1 : 0; -$hide_sidebar = Auth::check() && (setting('Nascondere la barra sinistra di default') || $settings_collapse); -echo ' - - - - -
    '; - -if (Auth::check()) { - $calendar_color_label = ($_SESSION['period_start'] != date('Y').'-01-01' || $_SESSION['period_end'] != date('Y').'-12-31') ? 'danger' : 'default'; - - echo ' - -
    -
    - -
    -
    - - - - - - - -
    - - - -
    - - '; - - if (string_contains($_SERVER['SCRIPT_FILENAME'], 'editor.php')) { - // Menu laterale per la visualizzazione dei plugin - echo ' - - -
    '; - } - - echo ' - -
    - - - - -
    -
    -
    -

    - - -
    - -
    -

    -
    -
    -
    -
    -
    - {[ "type": "text", "label": "", "name": "id_documento_fe", "required": 0, "help": "Obbligatorio per valorizzare CIG/CUP. È possible inserire:
    • N. determina
    • RDO
    • Ordine MEPA
    '); ?>", "value": "$id_documento_fe$", "maxlength": 20 ]} -
    - -
    - {[ "type": "text", "label": "", "name": "num_item", "required": 0, "value": "$num_item$", "maxlength": 15 ]} -
    -
    -
    -
    - {[ "type": "text", "label": "", "name": "codice_cig", "required": 0, "value": "$codice_cig$", "maxlength": 15 ]} -
    - -
    - {[ "type": "text", "label": "", "name": "codice_cup", "required": 0, "value": "$codice_cup$", "maxlength": 15 ]} -
    -
    -
    -
    -
    -
    - - -
    -
    -

    -
    - -
    -
    -
    -fetchArray('SELECT co_contratti_tipiintervento.*, in_tipiintervento.descrizione FROM co_contratti_tipiintervento INNER JOIN in_tipiintervento ON in_tipiintervento.idtipointervento = co_contratti_tipiintervento.idtipointervento WHERE idcontratto='.prepare($id_record).' AND (co_contratti_tipiintervento.costo_ore != in_tipiintervento.costo_orario OR co_contratti_tipiintervento.costo_km != in_tipiintervento.costo_km OR co_contratti_tipiintervento.costo_dirittochiamata != in_tipiintervento.costo_diritto_chiamata) ORDER BY in_tipiintervento.descrizione'); - -if (!empty($rs)) { - echo ' - - - - - - - - - - '; - - for ($i = 0; $i < sizeof($rs); ++$i) { - echo ' - - - - - - - - - - - - '; - - $idtipiintervento[] = prepare($rs[$i]['idtipointervento']); - } - echo ' -
    '.tr('Tipo attività').''.tr('Addebito orario').' '.tr('Addebito km').' '.tr('Addebito diritto ch.').'
    '.$rs[$i]['descrizione'].' - {[ "type": "number", "name": "costo_ore['.$rs[$i]['idtipointervento'].']", "value": "'.$rs[$i]['costo_ore'].'" ]} - - {[ "type": "number", "name": "costo_km['.$rs[$i]['idtipointervento'].']", "value": "'.$rs[$i]['costo_km'].'" ]} - - {[ "type": "number", "name": "costo_dirittochiamata['.$rs[$i]['idtipointervento'].']", "value": "'.$rs[$i]['costo_dirittochiamata'].'" ]} - - -
    '; -} - -echo ' - -
    '; - -//Loop fra i tipi di attività e i relativi costi del tipo intervento (quelli a 0) -$rs = $dbo->fetchArray('SELECT * FROM co_contratti_tipiintervento INNER JOIN in_tipiintervento ON in_tipiintervento.idtipointervento = co_contratti_tipiintervento.idtipointervento WHERE co_contratti_tipiintervento.idtipointervento NOT IN('.implode(',', $idtipiintervento).') AND idcontratto='.prepare($id_record).' ORDER BY descrizione'); - -if (!empty($rs)) { - echo ' -
     
    - - - - - - - - - - '; - - for ($i = 0; $i < sizeof($rs); ++$i) { - echo ' - - - - - - - - - - - - '; - } - echo ' -
    '.tr('Tipo attività').''.tr('Addebito orario').' '.tr('Addebito km').' '.tr('Addebito diritto ch.').'
    '.$rs[$i]['descrizione'].' - {[ "type": "number", "name": "costo_ore['.$rs[$i]['idtipointervento'].']", "value": "'.$rs[$i]['costo_orario'].'" ]} - - {[ "type": "number", "name": "costo_km['.$rs[$i]['idtipointervento'].']", "value": "'.$rs[$i]['costo_km'].'" ]} - - {[ "type": "number", "name": "costo_dirittochiamata['.$rs[$i]['idtipointervento'].']", "value": "'.$rs[$i]['costo_diritto_chiamata'].'" ]} - - -
    '; -} - echo ' - -
    -
    -
    -
    -
    - - - -
    -
    -

    '.tr('Righe').'

    -
    - -
    '; - -if (!$block_edit) { - echo ' - '; - - echo ' - '; - - echo ' - '; - - echo ' - '; - - echo ' - '; -} - -echo ' -
    -
    - -
    -
    -
    -
    -
    - -{( "name": "filelist_and_upload", "id_module": "$id_module$", "id_record": "$id_record$" )} - -{( "name": "log_email", "id_module": "$id_module$", "id_record": "$id_record$" )} - -'; - -// Collegamenti diretti -// Fatture o interventi collegati a questo contratto -$elementi = $dbo->fetchArray('SELECT `co_documenti`.`id`, `co_documenti`.`data`, `co_documenti`.`numero`, `co_documenti`.`numero_esterno`, `co_tipidocumento`.`descrizione` AS tipo_documento, IF(`co_tipidocumento`.`dir` = \'entrata\', \'Fatture di vendita\', \'Fatture di acquisto\') AS modulo FROM `co_documenti` JOIN `co_tipidocumento` ON `co_tipidocumento`.`id` = `co_documenti`.`idtipodocumento` WHERE `co_documenti`.`id` IN (SELECT `iddocumento` FROM `co_righe_documenti` WHERE `idcontratto` = '.prepare($id_record).') - -UNION -SELECT `in_interventi`.`id`, `in_interventi`.`data_richiesta`, `in_interventi`.`codice`, NULL, \'Attività\', \'Interventi\' FROM `in_interventi` JOIN `in_righe_interventi` ON `in_righe_interventi`.`idintervento` = `in_interventi`.`id` WHERE (`in_righe_interventi`.`original_document_id` = '.prepare($contratto->id).' AND `in_righe_interventi`.`original_document_type` = '.prepare(get_class($contratto)).') OR `in_interventi`.`id_contratto` = '.prepare($id_record).' - -ORDER BY `data` '); - -if (!empty($elementi)) { - echo ' -
    -
    -

    '.tr('Documenti collegati: _NUM_', [ - '_NUM_' => count($elementi), - ]).'

    -
    - -
    -
    -
    -
      '; - - // Elenco attività o contratti collegati - foreach ($elementi as $elemento) { - $descrizione = tr('_DOC_ num. _NUM_ del _DATE_', [ - '_DOC_' => $elemento['tipo_documento'], - '_NUM_' => !empty($elemento['numero_esterno']) ? $elemento['numero_esterno'] : $elemento['numero'], - '_DATE_' => Translator::dateToLocale($elemento['data']), - ]); - - echo ' -
    • '.Modules::link($elemento['modulo'], $elemento['id'], $descrizione).'
    • '; - } - - echo ' -
    -
    -
    '; -} - -if (!empty($elementi)) { - echo ' -
    - '.tr('Eliminando questo documento si potrebbero verificare problemi nelle altre sezioni del gestionale').'. -
    '; -} else { - ?> - - - - - - -$(document).ready(function() { - $("#rinnovabile").click(function() { - if ($(this).is(":checked")){ - input("giorni_preavviso_rinnovo").enable(); - input("rinnovo_automatico").enable(); - - }else{ - input("giorni_preavviso_rinnovo").disable(); - input("rinnovo_automatico").disable(); - } - }); - - $("#data_conclusione").on("dp.change", function (e) { - let data_accettazione = $("#data_accettazione"); - data_accettazione.data("DateTimePicker").maxDate(e.date); - - if(data_accettazione.data("DateTimePicker").date() > e.date){ - data_accettazione.data("DateTimePicker").date(e.date); - } - }); -}); -'; -?> diff --git a/modules/contratti/init.php b/modules/contratti/init.php deleted file mode 100755 index c524fe8b3..000000000 --- a/modules/contratti/init.php +++ /dev/null @@ -1,35 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Contratti\Contratto; - -if (isset($id_record)) { - $contratto = Contratto::find($id_record); - - $record = $dbo->fetchOne('SELECT *, - (SELECT tipo FROM an_anagrafiche WHERE idanagrafica = co_contratti.idanagrafica) AS tipo_anagrafica, - (SELECT is_fatturabile FROM co_staticontratti WHERE id=idstato) AS is_fatturabile, - (SELECT is_pianificabile FROM co_staticontratti WHERE id=idstato) AS is_pianificabile, - (SELECT is_completato FROM co_staticontratti WHERE id=idstato) AS is_completato, - (SELECT descrizione FROM co_staticontratti WHERE id=idstato) AS stato, - (SELECT GROUP_CONCAT(my_impianti_contratti.idimpianto) FROM my_impianti_contratti WHERE idcontratto = co_contratti.id) AS idimpianti - FROM co_contratti WHERE id='.prepare($id_record)); -} diff --git a/modules/contratti/plugins/contratti.consuntivo.php b/modules/contratti/plugins/contratti.consuntivo.php deleted file mode 100755 index c6288b841..000000000 --- a/modules/contratti/plugins/contratti.consuntivo.php +++ /dev/null @@ -1,332 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -use Modules\Interventi\Intervento; - -// Tabella con riepilogo interventi -$interventi = Intervento::where('id_contratto', $id_record)->get(); -$totale_ore_completate = 0; -if (!empty($interventi)) { - echo ' - - - - - - - - - '; - - // Tabella con i dati - foreach ($interventi as $intervento) { - $totale_ore_completate += !empty($intervento->stato->is_completato) ? $intervento->ore_totali : 0; - - // Riga per il singolo intervento - echo ' - - - - - - - - - - - - - '; - - // Riga con dettagli - echo ' - - - '; - } - - $array_interventi = $interventi->toArray(); - $totale_km = sum(array_column($array_interventi, 'km_totali')); - $totale_costo = sum(array_column($array_interventi, 'spesa')); - $totale_addebito = sum(array_column($array_interventi, 'imponibile')); - $totale = sum(array_column($array_interventi, 'totale_imponibile')); - $totale_ore = sum(array_column($array_interventi, 'ore_totali')); - - // Totali - echo ' - - '; - - echo ' - '; - - echo ' - '; - - echo ' - '; - - echo ' - '; - - echo ' - - '; - - $stati = $interventi->groupBy('idstatointervento'); - if (count($stati) > 0) { - // Totali per stato - echo ' - - - '; - - foreach ($stati as $interventi_collegati) { - $stato = $interventi_collegati->first()->stato; - $totale_stato = sum(array_column($interventi_collegati->toArray(), 'totale_imponibile')); - - echo ' - - - - - - - '; - } - } - - echo ' -
    '.tr('Attività').''.tr('Ore').''.tr('Km').''.tr('Costo').''.tr('Addebito').''.tr('Tot. scontato').'
    - - '.Modules::link('Interventi', $intervento->id, tr('Intervento num. _NUM_ del _DATE_', [ - '_NUM_' => $intervento->codice, - '_DATE_' => Translator::dateToLocale($intervento->inizio), - ])).' - - '.numberFormat($intervento->ore_totali).' - - '.numberFormat($intervento->km_totali).' - - '.moneyFormat($intervento->spesa).' - - '.moneyFormat($intervento->imponibile).' - - '.moneyFormat($intervento->totale_imponibile).' -
    '; - - // Lettura sessioni di lavoro - $sessioni = $intervento->sessioni; - if (!empty($sessioni)) { - echo ' - - - - - - - - - - - - - '; - - foreach ($sessioni as $sessione) { - // Visualizzo lo sconto su ore o km se c'è - $sconto_ore = !empty($sessione->sconto_totale_manodopera) ? '
    '.moneyFormat(-$sessione->sconto_totale_manodopera).'' : ''; - $sconto_km = !empty($sessione->sconto_totale_viaggio) ? '
    '.moneyFormat(-$sessione->sconto_totale_viaggio).'' : ''; - - echo ' - - - - - - - - - - - - '; - } - - echo ' -
    '.tr('Tecnico').''.tr('Tipo attività').''.tr('Ore').''.tr('Km').''.tr('Costo ore').''.tr('Costo km').''.tr('Diritto ch.').''.tr('Prezzo ore').''.tr('Prezzo km').''.tr('Diritto ch.').'
    '.$sessione->anagrafica->ragione_sociale.''.$sessione->tipo->descrizione.''.numberFormat($sessione->ore).''.numberFormat($sessione->km).''.moneyFormat($sessione->costo_manodopera).''.moneyFormat($sessione->costo_viaggio).''.moneyFormat($sessione->costo_diritto_chiamata).''.moneyFormat($sessione->prezzo_manodopera).$sconto_ore.''.moneyFormat($sessione->prezzo_viaggio).$sconto_km.''.moneyFormat($sessione->prezzo_diritto_chiamata).'
    '; - } - - // Lettura articoli utilizzati - $articoli = $intervento->articoli; - if (!$articoli->isEmpty()) { - echo ' - - - - - - - '; - - foreach ($articoli as $articolo) { - $sconto = !empty($articolo->sconto) ? '
    '.moneyFormat(-$articolo->sconto).'' : ''; - - echo ' - - - - - - '; - } - - echo ' -
    '.tr('Materiale').''.tr('Q.tà').''.tr('Prezzo di acquisto').''.tr('Prezzo di vendita').'
    - '.Modules::link('Articoli', $articolo->idarticolo, $articolo->descrizione).' - '.numberFormat($articolo->qta, 'qta').''.moneyFormat($articolo->spesa).''.moneyFormat($articolo->imponibile).$sconto.'
    '; - } - - // Lettura spese aggiuntive - $righe = $intervento->righe; - if (!$righe->isEmpty()) { - echo ' - - - - - - - '; - - foreach ($righe as $riga) { - $sconto = !empty($riga->sconto) ? '
    '.moneyFormat(-$riga->sconto).'' : ''; - - echo ' - - - - - - '; - } - - echo ' -
    '.tr('Altre spese').''.tr('Q.tà').''.tr('Prezzo di acquisto').''.tr('Prezzo di vendita').'
    - '.$riga->descrizione.' - '.numberFormat($riga->qta, 'qta').''.moneyFormat($riga->spesa).''.moneyFormat($riga->imponibile).$sconto.'
    '; - } - - echo ' -
    - '.tr('Totale').' - - '.numberFormat($totale_ore).' - - '.numberFormat($totale_km).' - - '.moneyFormat($totale_costo).' - - '.moneyFormat($totale_addebito).' - - '.moneyFormat($totale).' -
    -
    '.tr('Totale interventi per stato', [], ['upper' => true]).' -
    - '.$stato->descrizione.': - - '.moneyFormat($totale_stato).' -
    '; -} - -/* - Bilancio del contratto -*/ -$rs = $dbo->fetchArray('SELECT SUM(subtotale - sconto) AS budget FROM co_righe_contratti WHERE idcontratto='.prepare($id_record)); -$budget = $rs[0]['budget']; - -$rs = $dbo->fetchArray("SELECT SUM(qta) AS totale_ore FROM `co_righe_contratti` WHERE um='ore' AND idcontratto=".prepare($id_record)); -$totale_ore_contratto = $rs[0]['totale_ore']; - -$diff = sum($budget, -$totale); - -if ($diff > 0) { - $bilancio = ''.moneyFormat($diff).''; -} elseif ($diff < 0) { - $bilancio = ''.moneyFormat($diff).''; -} else { - $bilancio = ''.moneyFormat($diff).''; -} - -echo ' -
    - - '.tr('Rapporto budget/spesa').':
    - '.$bilancio.' -
    -

    '; - -if (!empty($totale_ore_contratto)) { - echo ' -
    - - - - - - - - - - - - - - - - - - - - - - - -
    '.tr('Ore a contratto').':'.Translator::numberToLocale($totale_ore_contratto).'
    '.tr('Ore erogate totali').':'.Translator::numberToLocale($totale_ore).'
    '.tr('Ore residue totali').':'.Translator::numberToLocale(floatval($totale_ore_contratto) - floatval($totale_ore)).'
    '.tr('Ore erogate concluse').':'.Translator::numberToLocale($totale_ore_completate).'
    '.tr('Ore residue concluse').':'.Translator::numberToLocale(floatval($totale_ore_contratto) - floatval($totale_ore_completate)).'
    -
    -
    '; -} else { - echo ' -
    -

    '.tr('Per monitorare il consumo ore, inserisci almeno una riga con unità di misura "ore"').'.

    -
    '; -} - - echo ' -
    '; - -/* - Stampa consuntivo -*/ -echo ' -
    - '.Prints::getLink('Consuntivo contratto', $id_record, 'btn-primary', tr('Stampa consuntivo')).' -
    '; diff --git a/modules/contratti/row-add.php b/modules/contratti/row-add.php deleted file mode 100755 index 229d7a369..000000000 --- a/modules/contratti/row-add.php +++ /dev/null @@ -1,87 +0,0 @@ -. - */ - -use Modules\Contratti\Contratto; - -include_once __DIR__.'/../../core.php'; - -// Info contratto -$documento = Contratto::find($id_record); - -// Impostazioni per la gestione -$options = [ - 'op' => 'manage_riga', - 'action' => 'add', - 'dir' => $documento->direzione, - 'idanagrafica' => $documento['idanagrafica'], - 'totale_imponibile_documento' => $documento->totale_imponibile, - 'totale_documento' => $documento->totale, - 'select-options' => [ - 'articoli' => [ - 'idanagrafica' => $documento->idanagrafica, - 'dir' => $documento->direzione, - 'permetti_movimento_a_zero' => 1, - ], - ], -]; - -// Dati di default -$result = [ - 'descrizione' => '', - 'qta' => 1, - 'um' => '', - 'prezzo' => 0, - 'sconto_unitario' => 0, - 'tipo_sconto' => '', - 'idiva' => '', -]; - -// Leggo l'iva predefinita per l'anagrafica e se non c'è leggo quella predefinita generica -$iva = $dbo->fetchArray('SELECT idiva_vendite AS idiva FROM an_anagrafiche WHERE idanagrafica='.prepare($documento['idanagrafica'])); -$result['idiva'] = $iva[0]['idiva'] ?: setting('Iva predefinita'); - -// Importazione della gestione dedicata -$file = 'riga'; -if (get('is_descrizione') !== null) { - $file = 'descrizione'; - - $options['op'] = 'manage_descrizione'; -} elseif (get('is_articolo') !== null) { - $file = 'articolo'; - - // Aggiunta sconto di default da listino per le vendite - $listino = $dbo->fetchOne('SELECT prc_guadagno FROM an_anagrafiche INNER JOIN mg_listini ON an_anagrafiche.idlistino_vendite=mg_listini.id WHERE idanagrafica='.prepare($documento['idanagrafica'])); - - if (!empty($listino['prc_guadagno'])) { - $result['sconto_percentuale'] = $listino['prc_guadagno']; - $result['tipo_sconto'] = 'PRC'; - } - - $options['op'] = 'manage_articolo'; -} elseif (get('is_sconto') !== null) { - $file = 'sconto'; - - $options['op'] = 'manage_sconto'; -} elseif (get('is_barcode') !== null) { - $file = 'barcode'; - - $options['op'] = 'manage_barcode'; -} - -echo App::load($file.'.php', $result, $options); diff --git a/modules/contratti/row-edit.php b/modules/contratti/row-edit.php deleted file mode 100755 index fa35e896e..000000000 --- a/modules/contratti/row-edit.php +++ /dev/null @@ -1,68 +0,0 @@ -. - */ - -use Modules\Contratti\Contratto; - -include_once __DIR__.'/../../core.php'; - -// Info contratto -$documento = Contratto::find($id_record); - -// Impostazioni per la gestione -$options = [ - 'op' => 'manage_riga', - 'action' => 'edit', - 'dir' => $documento->direzione, - 'idanagrafica' => $documento['idanagrafica'], - 'totale_imponibile_documento' => $documento->totale_imponibile, - 'totale_documento' => $documento->totale, - 'select-options' => [ - 'articoli' => [ - 'idanagrafica' => $documento->idanagrafica, - 'dir' => $documento->direzione, - 'permetti_movimento_a_zero' => 1, - ], - ], -]; - -// Dati della riga -$id_riga = get('riga_id'); -$type = get('riga_type'); -$riga = $documento->getRiga($type, $id_riga); - -$result = $riga->toArray(); -$result['prezzo'] = $riga->prezzo_unitario; - -// Importazione della gestione dedicata -$file = 'riga'; -if ($riga->isDescrizione()) { - $file = 'descrizione'; - - $options['op'] = 'manage_descrizione'; -} elseif ($riga->isArticolo()) { - $file = 'articolo'; - - $options['op'] = 'manage_articolo'; -} elseif ($riga->isSconto()) { - $file = 'sconto'; - - $options['op'] = 'manage_sconto'; -} - -echo App::load($file.'.php', $result, $options); diff --git a/modules/contratti/row-list.php b/modules/contratti/row-list.php deleted file mode 100755 index 6b9cac5d9..000000000 --- a/modules/contratti/row-list.php +++ /dev/null @@ -1,319 +0,0 @@ -. - */ - -include_once __DIR__.'/init.php'; - -echo ' -
    - - - - - - - - - - - - - - '; - -// Righe documento -$righe = $contratto->getRighe(); -$num = 0; -foreach ($righe as $riga) { - ++$num; - - echo ' - - - - '; - - if ($riga->isDescrizione()) { - echo ' - - - - '; - } else { - // Quantità e unità di misura - echo ' - '; - - // Prezzi unitari - echo ' - '; - - // Iva - echo ' - '; - - // Importo - echo ' - '; - } - - // Possibilità di rimuovere una riga solo se il preventivo non è stato pagato - echo ' - - '; -} - -echo ' - '; - -// Calcoli -$imponibile = abs($contratto->imponibile); -$sconto = $contratto->sconto; -$totale_imponibile = abs($contratto->totale_imponibile); -$iva = abs($contratto->iva); -$totale = abs($contratto->totale); -$sconto_finale = $contratto->getScontoFinale(); -$netto_a_pagare = $contratto->netto; - -// Totale totale imponibile -echo ' - - - - - '; - -// SCONTO -if (!empty($sconto)) { - echo ' - - - - - '; - - // Totale totale imponibile - echo ' - - - - - '; -} - -// Totale iva -echo ' - - - - - '; - -// Totale contratto -echo ' - - - - - '; - -// SCONTO FINALE -if (!empty($sconto_finale)) { - echo ' - - - - - '; -} - -// NETTO A PAGARE -if ($totale != $netto_a_pagare) { - echo ' - - - - - '; -} - -echo ' -
    '.tr('#').''.tr('Descrizione').''.tr('Q.tà').' '.tr('Prezzo unitario').''.tr('Iva unitaria').''.tr('Importo').'
    - '.$num.' - '; - - // Aggiunta dei riferimenti ai documenti - if ($riga->hasOriginalComponent()) { - echo ' - '.reference($riga->getOriginalComponent()->getDocument(), tr('Origine')).''; - } - - // Descrizione - $descrizione = nl2br($riga->descrizione); - if ($riga->isArticolo()) { - $descrizione = Modules::link('Articoli', $riga->idarticolo, $riga->codice.' - '.$descrizione); - } - - echo ' - '.$descrizione.' - - '.numberFormat($riga->qta_rimanente, 'qta').' / '.numberFormat($riga->qta, 'qta').' '.$riga->um.' - - '.moneyFormat($riga->prezzo_unitario_corrente); - - if ($dir == 'entrata' && $riga->costo_unitario != 0) { - echo ' -
    - '.tr('Acquisto').': '.moneyFormat($riga->costo_unitario).' - '; - } - - if (abs($riga->sconto_unitario) > 0) { - $text = discountInfo($riga); - - echo ' -
    '.$text.''; - } - - echo ' -
    - '.moneyFormat($riga->iva_unitaria_scontata).' -
    '.$riga->aliquota->descrizione.(($riga->aliquota->esente) ? ' ('.$riga->aliquota->codice_natura_fe.')' : null).' -
    - '.moneyFormat($riga->importo).' - '; - - if (empty($record['is_completato'])) { - echo ' -
    - - - - - - - - - - - -
    '; - } - - echo ' -
    - '.tr('Imponibile', [], ['upper' => true]).': - - '.moneyFormat($contratto->imponibile, 2).' -
    - '.tr('Sconto/maggiorazione', [], ['upper' => true]).': - - '.moneyFormat($contratto->sconto, 2).' -
    - '.tr('Totale imponibile', [], ['upper' => true]).': - - '.moneyFormat($totale_imponibile, 2).' -
    - '.tr('Iva', [], ['upper' => true]).': - - '.moneyFormat($contratto->iva, 2).' -
    - '.tr('Totale', [], ['upper' => true]).': - - '.moneyFormat($contratto->totale, 2).' -
    - '.tr('Sconto finale', [], ['upper' => true]).': - - '.moneyFormat($sconto_finale, 2).' -
    - '.tr('Netto a pagare', [], ['upper' => true]).': - - '.moneyFormat($netto_a_pagare, 2).' -
    -
    '; - -echo ' -'; diff --git a/modules/contratti/src/Components/Articolo.php b/modules/contratti/src/Components/Articolo.php deleted file mode 100755 index ad2826c73..000000000 --- a/modules/contratti/src/Components/Articolo.php +++ /dev/null @@ -1,29 +0,0 @@ -. - */ - -namespace Modules\Contratti\Components; - -use Common\Components\Article; - -class Articolo extends Article -{ - use RelationTrait; - - protected $table = 'co_righe_contratti'; -} diff --git a/modules/contratti/src/Components/Descrizione.php b/modules/contratti/src/Components/Descrizione.php deleted file mode 100755 index d8b604006..000000000 --- a/modules/contratti/src/Components/Descrizione.php +++ /dev/null @@ -1,29 +0,0 @@ -. - */ - -namespace Modules\Contratti\Components; - -use Common\Components\Description; - -class Descrizione extends Description -{ - use RelationTrait; - - protected $table = 'co_righe_contratti'; -} diff --git a/modules/contratti/src/Components/RelationTrait.php b/modules/contratti/src/Components/RelationTrait.php deleted file mode 100755 index e656a5cd6..000000000 --- a/modules/contratti/src/Components/RelationTrait.php +++ /dev/null @@ -1,47 +0,0 @@ -. - */ - -namespace Modules\Contratti\Components; - -use Modules\Contratti\Contratto; - -trait RelationTrait -{ - public function getDocumentID() - { - return 'idcontratto'; - } - - public function document() - { - return $this->belongsTo(Contratto::class, $this->getDocumentID()); - } - - public function contratto() - { - return $this->document(); - } - - public function getNettoAttribute() - { - $result = $this->totale; - - return $result; - } -} diff --git a/modules/contratti/src/Components/Riga.php b/modules/contratti/src/Components/Riga.php deleted file mode 100755 index b09ea7ae9..000000000 --- a/modules/contratti/src/Components/Riga.php +++ /dev/null @@ -1,29 +0,0 @@ -. - */ - -namespace Modules\Contratti\Components; - -use Common\Components\Row; - -class Riga extends Row -{ - use RelationTrait; - - protected $table = 'co_righe_contratti'; -} diff --git a/modules/contratti/src/Components/Sconto.php b/modules/contratti/src/Components/Sconto.php deleted file mode 100755 index bcd8f1091..000000000 --- a/modules/contratti/src/Components/Sconto.php +++ /dev/null @@ -1,29 +0,0 @@ -. - */ - -namespace Modules\Contratti\Components; - -use Common\Components\Discount; - -class Sconto extends Discount -{ - use RelationTrait; - - protected $table = 'co_righe_contratti'; -} diff --git a/modules/contratti/src/Contratto.php b/modules/contratti/src/Contratto.php deleted file mode 100755 index a2b974ca3..000000000 --- a/modules/contratti/src/Contratto.php +++ /dev/null @@ -1,304 +0,0 @@ -. - */ - -namespace Modules\Contratti; - -use Carbon\Carbon; -use Carbon\CarbonInterval; -use Common\Components\Component; -use Common\Document; -use Modules\Anagrafiche\Anagrafica; -use Modules\Interventi\Intervento; -use Modules\TipiIntervento\Tipo as TipoSessione; -use Plugins\PianificazioneFatturazione\Pianificazione; -use Plugins\PianificazioneInterventi\Promemoria; -use Traits\RecordTrait; -use Traits\ReferenceTrait; -use Util\Generator; - -class Contratto extends Document -{ - use ReferenceTrait; - use RecordTrait; - - /** - * @var bool Disabilita movimentazione automatica - */ - public static $movimenta_magazzino = false; - - protected $table = 'co_contratti'; - - /** - * The attributes that should be mutated to dates. - * - * @var array - */ - protected $dates = [ - 'data_conclusione', - 'data_accettazione', - ]; - - /** - * Crea un nuovo contratto. - * - * @param string $nome - * - * @return self - */ - public static function build(Anagrafica $anagrafica, $nome) - { - $model = new static(); - - $stato_documento = Stato::where('descrizione', 'Bozza')->first(); - - $id_anagrafica = $anagrafica->id; - $id_agente = $anagrafica->idagente; - - $id_pagamento = $anagrafica->idpagamento_vendite; - if (empty($id_pagamento)) { - $id_pagamento = setting('Tipo di pagamento predefinito'); - } - - $model->anagrafica()->associate($anagrafica); - $model->stato()->associate($stato_documento); - - $model->numero = static::getNextNumero(); - - $model->nome = $nome; - $model->data_bozza = Carbon::now(); - - if (!empty($id_agente)) { - $model->idagente = $id_agente; - } - - if (!empty($id_pagamento)) { - $model->idpagamento = $id_pagamento; - } - - // Salvataggio delle informazioni - $model->save(); - - return $model; - } - - public function fixTipiSessioni() - { - $database = database(); - - $presenti = $database->fetchArray('SELECT idtipointervento AS id FROM co_contratti_tipiintervento WHERE idcontratto = '.prepare($this->id)); - - // Aggiunta associazioni costi unitari al contratto - $tipi = TipoSessione::whereNotIn('idtipointervento', array_column($presenti, 'id'))->get(); - - foreach ($tipi as $tipo) { - $database->insert('co_contratti_tipiintervento', [ - 'idcontratto' => $this->id, - 'idtipointervento' => $tipo->id, - 'costo_ore' => $tipo->costo_orario, - 'costo_km' => $tipo->costo_km, - 'costo_dirittochiamata' => $tipo->costo_diritto_chiamata, - 'costo_ore_tecnico' => $tipo->costo_orario_tecnico, - 'costo_km_tecnico' => $tipo->costo_km_tecnico, - 'costo_dirittochiamata_tecnico' => $tipo->costo_diritto_chiamata_tecnico, - ]); - } - } - - public function setTipoValiditaAttribute($value) - { - $this->attributes['tipo_validita'] = $value == 'manual' ? null : $value; - } - - /** - * Controlla se la data di conclusione del documento deve essere calcolata in modo automatico. - * - * @return bool - */ - public function isDataConclusioneAutomatica() - { - return !empty($this->validita) && !empty($this->tipo_validita) && !empty($this->data_accettazione); - } - - /** - * Restituisce il nome del modulo a cui l'oggetto è collegato. - * - * @return string - */ - public function getModuleAttribute() - { - return 'Contratti'; - } - - public function getDirezioneAttribute() - { - return 'entrata'; - } - - public function anagrafica() - { - return $this->belongsTo(Anagrafica::class, 'idanagrafica'); - } - - public function stato() - { - return $this->belongsTo(Stato::class, 'idstato'); - } - - public function articoli() - { - return $this->hasMany(Components\Articolo::class, 'idcontratto'); - } - - public function righe() - { - return $this->hasMany(Components\Riga::class, 'idcontratto'); - } - - public function sconti() - { - return $this->hasMany(Components\Sconto::class, 'idcontratto'); - } - - public function descrizioni() - { - return $this->hasMany(Components\Descrizione::class, 'idcontratto'); - } - - public function interventi() - { - return $this->hasMany(Intervento::class, 'id_contratto'); - } - - public function promemoria() - { - return $this->hasMany(Promemoria::class, 'idcontratto'); - } - - public function pianificazioni() - { - return $this->hasMany(Pianificazione::class, 'idcontratto'); - } - - public function fixBudget() - { - $this->budget = $this->totale_imponibile ?: 0; - } - - public function fixDataConclusione() - { - // Calcolo della data di conclusione in base alla validità - if ($this->isDataConclusioneAutomatica()) { - $intervallo = CarbonInterval::make($this->validita.' '.$this->tipo_validita); - $data = Carbon::make($this->data_accettazione)->add($intervallo); - $this->data_conclusione = $data->subDays(1); - } - } - - public function save(array $options = []) - { - $this->fixBudget(); - $this->fixDataConclusione(); - - $result = parent::save($options); - - $this->fixTipiSessioni(); - - return $result; - } - - /** - * Effettua un controllo sui campi del documento. - * Viene richiamato dalle modifiche alle righe del documento. - */ - public function triggerEvasione(Component $trigger) - { - parent::triggerEvasione($trigger); - - $righe = $this->getRighe(); - - $qta_evasa = $righe->sum('qta_evasa'); - $qta = $righe->sum('qta'); - $parziale = $qta != $qta_evasa; - - // Impostazione del nuovo stato - if ($qta_evasa == 0) { - $descrizione = 'In lavorazione'; - $codice_intervento = 'OK'; - } else { - $descrizione = $parziale ? 'Parzialmente fatturato' : 'Fatturato'; - $codice_intervento = 'FAT'; - } - - $stato = Stato::where('descrizione', $descrizione)->first(); - $this->stato()->associate($stato); - $this->save(); - - // Trasferimento degli interventi collegati - $interventi = $this->interventi; - $stato_intervento = \Modules\Interventi\Stato::where('codice', $codice_intervento)->first(); - foreach ($interventi as $intervento) { - $intervento->stato()->associate($stato_intervento); - $intervento->save(); - } - } - - // Metodi statici - - /** - * Calcola il nuovo numero di contratto. - * - * @return string - */ - public static function getNextNumero() - { - $maschera = setting('Formato codice contratti'); - - $ultimo = Generator::getPreviousFrom($maschera, 'co_contratti', 'numero'); - $numero = Generator::generate($maschera, $ultimo); - - return $numero; - } - - // Opzioni di riferimento - - public function getReferenceName() - { - return 'Contratto'; - } - - public function getReferenceNumber() - { - return $this->numero; - } - - public function getReferenceDate() - { - return $this->data_bozza; - } - - public function getReferenceRagioneSociale() - { - return $this->anagrafica->ragione_sociale; - } - - public function setStatoAttribute($stato) - { - $this->idstato = Stato::where('descrizione', $stato)->first()['id']; - } -} diff --git a/modules/contratti/src/Stato.php b/modules/contratti/src/Stato.php deleted file mode 100755 index cefd5ebdd..000000000 --- a/modules/contratti/src/Stato.php +++ /dev/null @@ -1,35 +0,0 @@ -. - */ - -namespace Modules\Contratti; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; - -class Stato extends Model -{ - use SimpleModelTrait; - - protected $table = 'co_staticontratti'; - - public function preventivi() - { - return $this->hasMany(Contratto::class, 'idstato'); - } -} diff --git a/modules/contratti/variables.php b/modules/contratti/variables.php deleted file mode 100755 index fb7706dcf..000000000 --- a/modules/contratti/variables.php +++ /dev/null @@ -1,33 +0,0 @@ -. - */ - -$r = $dbo->fetchOne('SELECT *, co_contratti.idanagrafica, - IF( (an_referenti.email IS NOT NULL AND an_referenti.email!=""), an_referenti.email, an_anagrafiche.email) AS email, - an_anagrafiche.ragione_sociale -FROM co_contratti INNER JOIN an_anagrafiche ON co_contratti.idanagrafica=an_anagrafiche.idanagrafica LEFT OUTER JOIN an_referenti ON an_referenti.id=co_contratti.idreferente WHERE co_contratti.id='.prepare($id_record)); - -// Variabili da sostituire -return [ - 'email' => $r['email'], - 'ragione_sociale' => $r['ragione_sociale'], - 'numero' => $r['numero'], - 'descrizione' => $r['descrizione'], - 'data' => Translator::dateToLocale($r['data_bozza']), - 'id_anagrafica' => $r['idanagrafica'], -]; diff --git a/modules/contratti/widgets/contratti_scadenza.dashboard.php b/modules/contratti/widgets/contratti_scadenza.dashboard.php deleted file mode 100755 index 931a8885c..000000000 --- a/modules/contratti/widgets/contratti_scadenza.dashboard.php +++ /dev/null @@ -1,84 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -$rs = $dbo->fetchArray('SELECT *, - ((SELECT SUM(co_righe_contratti.qta) FROM co_righe_contratti WHERE co_righe_contratti.um=\'ore\' AND co_righe_contratti.idcontratto=co_contratti.id) - IFNULL( (SELECT SUM(in_interventi_tecnici.ore) FROM in_interventi_tecnici INNER JOIN in_interventi ON in_interventi_tecnici.idintervento=in_interventi.id WHERE in_interventi.id_contratto=co_contratti.id AND in_interventi.idstatointervento IN (SELECT in_statiintervento.idstatointervento FROM in_statiintervento WHERE in_statiintervento.is_completato = 1)), 0) ) AS ore_rimanenti, - DATEDIFF(data_conclusione, NOW()) AS giorni_rimanenti, - data_conclusione, - ore_preavviso_rinnovo, - giorni_preavviso_rinnovo, - (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=co_contratti.idanagrafica) AS ragione_sociale -FROM co_contratti WHERE - idstato IN (SELECT id FROM co_staticontratti WHERE is_pianificabile = 1) AND - rinnovabile = 1 AND - YEAR(data_conclusione) > 1970 AND - (SELECT id FROM co_contratti contratti WHERE contratti.idcontratto_prev = co_contratti.id) IS NULL -HAVING (ore_rimanenti < ore_preavviso_rinnovo OR DATEDIFF(data_conclusione, NOW()) < ABS(giorni_preavviso_rinnovo)) -ORDER BY giorni_rimanenti ASC, ore_rimanenti ASC'); - -if (!empty($rs)) { - echo ' - - - - - - - '; - - foreach ($rs as $r) { - $data_accettazione = !empty($r['data_accettazione']) ? Translator::dateToLocale($r['data_accettazione']) : ''; - - $data_conclusione = !empty($r['data_conclusione']) ? Translator::dateToLocale($r['data_conclusione']) : ''; - - // Se scaduto, segna la riga in rosso - $class = (strtotime($r['data_conclusione']) < strtotime(date('Y-m-d')) && !empty($data_conclusione)) ? 'danger' : ''; - - if (isset($r['ore_rimanenti'])) { - // Se ore finite, segna la riga in rosso - if ($class != 'danger') { - $class = ($r['ore_rimanenti'] < 0) ? 'warning' : ''; - } - - $ore_rimanenti = ($r['ore_rimanenti'] >= 0) ? tr('ore rimanenti: _NUM_') : tr('ore in aggiunta: _NUM_'); - $ore_rimanenti = str_replace('_NUM_', abs($r['ore_rimanenti']), $ore_rimanenti); - } - - $scadenza = ($r['giorni_rimanenti'] > 0) ? tr('scade tra _DAYS_ giorni') : tr('scaduto da _DAYS_ giorni'); - $scadenza = str_replace('_DAYS_', abs($r['giorni_rimanenti']), $scadenza); - - echo ' - - - - - - '; - } - echo ' -
    '.tr('Contratto').''.tr('Data inizio').''.tr('Data conclusione').''.tr('Rinnovo').'
    - '.Modules::link('Contratti', $r['id'], $r['nome']).'
    - '.$r['ragione_sociale'].' -
    '.$data_accettazione.''.$data_conclusione.''.$scadenza.(isset($r['ore_rimanenti']) ? ' ('.$ore_rimanenti.')' : '').'
    '; -} else { - echo ' -

    '.tr('Non ci sono contratti in scadenza').'.

    '; -} diff --git a/modules/custom_fields/actions.php b/modules/custom_fields/actions.php deleted file mode 100755 index 9e29fd8a1..000000000 --- a/modules/custom_fields/actions.php +++ /dev/null @@ -1,65 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -switch (post('op')) { - case 'update': - $plugin = post('plugin_id') ?: null; - $module = $plugin ? null : post('module_id'); - - $dbo->update('zz_fields', [ - 'id_module' => $module, - 'id_plugin' => $plugin, - 'name' => post('name'), - 'html_name' => post('html_name'), - 'content' => post('content'), - 'on_add' => post('on_add'), - 'top' => post('top'), - ], ['id' => $id_record]); - - flash()->info(tr('Salvataggio completato')); - - break; - - case 'add': - $plugin = post('plugin_id') ?: null; - $module = $plugin ? null : post('module_id'); - - $dbo->insert('zz_fields', [ - 'id_module' => $module, - 'id_plugin' => $plugin, - 'name' => post('name'), - 'content' => post('content'), - 'html_name' => secure_random_string(8), - ]); - $id_record = $dbo->lastInsertedID(); - - flash()->info(tr('Nuovo campo personalizzato creato')); - - break; - - case 'delete': - $dbo->delete('zz_fields', ['id' => $id_record]); - $dbo->delete('zz_field_record', ['id_field' => $id_record]); - - flash()->info(tr('Campo personalizzato eliminato')); - - break; -} diff --git a/modules/custom_fields/add.php b/modules/custom_fields/add.php deleted file mode 100755 index 27cd8146c..000000000 --- a/modules/custom_fields/add.php +++ /dev/null @@ -1,60 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - -
    -
    - {[ "type": "select", "label": "", "name": "module_id", "values": "query=SELECT id, name as text FROM zz_modules WHERE enabled = 1" ]} -
    - -
    - {[ "type": "select", "label": "", "name": "plugin_id", "values": "query=SELECT id, name as text FROM zz_plugins WHERE enabled = 1" ]} -
    -
    - -
    -
    - {[ "type": "text", "label": "", "name": "name", "required": 1 ]} -
    -
    - -
    -
    - {[ "type": "textarea", "label": "", "name": "content", "required": 1, "value": "$content$" ]} -
    -
    - -filepath('content-info.php'); - -?> - - -
    -
    - -
    -
    -
    diff --git a/modules/custom_fields/content-info.php b/modules/custom_fields/content-info.php deleted file mode 100755 index 1f68ed21e..000000000 --- a/modules/custom_fields/content-info.php +++ /dev/null @@ -1,54 +0,0 @@ -. - */ - -echo ' - -
    -
    -

    '.tr('Istruzioni per il campo _FIELD_', [ - '_FIELD_' => tr('Contenuto'), - ]).'

    -
    - -
    -

    '.tr('Le seguenti sequenze di testo vengono sostituite nel seguente modo').':

    -
      '; - -$list = [ - 'label' => tr('Nome'), - 'name' => tr('Nome HTML'), -]; - -foreach ($list as $key => $value) { - echo ' -
    • '.tr('_TEXT_ con il valore del campo "_FIELD_"', [ - '_TEXT_' => '|'.$key.'|', - '_FIELD_' => $value, - ]).'
    • '; -} - -echo ' -
    • '.tr('_TEXT_ con il valore impostato per il record', [ - '_TEXT_' => '|value|', - ]).'
    • '; - -echo ' -
    -
    -
    '; diff --git a/modules/custom_fields/edit.php b/modules/custom_fields/edit.php deleted file mode 100755 index b71648bb7..000000000 --- a/modules/custom_fields/edit.php +++ /dev/null @@ -1,75 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?> -
    - - - - -
    -
    - {[ "type": "select", "label": "", "name": "module_id", "values": "query=SELECT id, name as text FROM zz_modules WHERE enabled = 1", "value": "" ]} -
    - -
    - {[ "type": "select", "label": "", "name": "plugin_id", "values": "query=SELECT id, name as text FROM zz_plugins WHERE enabled = 1", "value": "" ]} -
    -
    - -
    -
    - {[ "type": "text", "label": "", "name": "name", "required": 1, "value": "$name$" ]} -
    - -
    - {[ "type": "text", "label": "", "name": "html_name", "required": 1, "value": "$html_name$" ]} -
    -
    - -
    -
    - {[ "type": "checkbox", "label": "", "name": "on_add","value": "$on_add$" ]} -
    - -
    - {[ "type": "checkbox", "label": "", "name": "top", "value": "$top$" ]} -
    -
    - -
    -
    - {[ "type": "textarea", "label": "", "name": "content", "required": 1, "value": "$content$" ]} -
    -
    -
    - -filepath('content-info.php'); - -?> - -
    - - - - diff --git a/modules/custom_fields/init.php b/modules/custom_fields/init.php deleted file mode 100755 index fea41e80f..000000000 --- a/modules/custom_fields/init.php +++ /dev/null @@ -1,26 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $records = $dbo->fetchArray('SELECT * FROM zz_fields WHERE id='.prepare($id_record)); -} - -// TODO: prevedere un utilizzo pratico del campo options diff --git a/modules/dashboard/ajax.php b/modules/dashboard/ajax.php deleted file mode 100644 index 9211e32ad..000000000 --- a/modules/dashboard/ajax.php +++ /dev/null @@ -1,422 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$modulo_interventi = Modules::get('Interventi'); -$modulo_preventivi = Modules::get('Preventivi'); - -if (!isset($user['idanagrafica'])) { - $user['idanagrafica'] = ''; -} - -switch (filter('op')) { - // Lettura calendario tecnici - case 'interventi_periodo': - $start = filter('start'); - $end = filter('end'); - - $stati = (array) $_SESSION['dashboard']['idstatiintervento']; - $stati[] = prepare(''); - - $tipi = (array) $_SESSION['dashboard']['idtipiintervento']; - $zone = (array) $_SESSION['dashboard']['idzone']; - $tecnici = (array) $_SESSION['dashboard']['idtecnici']; - - $query = 'SELECT - in_interventi_tecnici.id, - in_interventi_tecnici.idintervento, - in_interventi.codice, - colore, - in_interventi_tecnici.idtecnico, - in_interventi_tecnici.orario_inizio, - in_interventi_tecnici.orario_fine, - (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica = idtecnico) AS nome_tecnico, - (SELECT id FROM zz_files WHERE id_record = in_interventi.id AND id_module = '.prepare($modulo_interventi->id).' LIMIT 1) AS have_attachments, - (SELECT colore FROM an_anagrafiche WHERE idanagrafica = idtecnico) AS colore_tecnico, (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=in_interventi.idanagrafica) AS cliente, - (SELECT idzona FROM an_anagrafiche WHERE idanagrafica = in_interventi.idanagrafica) AS idzona, - in_statiintervento.is_completato AS is_completato - FROM in_interventi_tecnici - INNER JOIN in_interventi ON in_interventi_tecnici.idintervento = in_interventi.id - LEFT OUTER JOIN in_statiintervento ON in_interventi.idstatointervento = in_statiintervento.idstatointervento - WHERE - ( - ( - in_interventi_tecnici.orario_inizio >= '.prepare($start).' - AND - in_interventi_tecnici.orario_fine <= '.prepare($end).' - ) - OR - ( - in_interventi_tecnici.orario_inizio >= '.prepare($start).' - AND - in_interventi_tecnici.orario_inizio <= '.prepare($end).' - ) - OR - ( - in_interventi_tecnici.orario_inizio <= '.prepare($start).' - AND - in_interventi_tecnici.orario_fine >= '.prepare($end).' - ) - OR - ( - in_interventi_tecnici.orario_fine >= '.prepare($start).' - AND - in_interventi_tecnici.orario_fine <= '.prepare($end).' - ) - ) - AND - idtecnico IN('.implode(',', $tecnici).') - AND - in_interventi.idstatointervento IN('.implode(',', $stati).') - AND - in_interventi_tecnici.idtipointervento IN('.implode(',', $tipi).') - '.Modules::getAdditionalsQuery('Interventi').' - HAVING - idzona IN ('.implode(',', $zone).')'; - $sessioni = $dbo->fetchArray($query); - - $results = []; - foreach ($sessioni as $sessione) { - $results[] = [ - 'id' => $sessione['id'], - 'idintervento' => $sessione['idintervento'], - 'idtecnico' => $sessione['idtecnico'], - 'title' => '
    '.(($sessione['is_completato']) ? '' : '').' '.(($sessione['have_attachments']) ? '' : '').'
    '.'Int. '.$sessione['codice'].' '.$sessione['cliente'].'
    '.tr('Tecnici').': '.$sessione['nome_tecnico'], - 'start' => $sessione['orario_inizio'], - 'end' => $sessione['orario_fine'], - 'url' => base_path().'/editor.php?id_module='.$modulo_interventi->id.'&id_record='.$sessione['idintervento'], - 'backgroundColor' => $sessione['colore'], - 'textColor' => color_inverse($sessione['colore']), - 'borderColor' => ($sessione['colore_tecnico'] == '#FFFFFF') ? color_darken($sessione['colore_tecnico'], 100) : $sessione['colore_tecnico'], - 'allDay' => false, - ]; - } - - if (setting('Visualizza informazioni aggiuntive sul calendario')) { - //# Box allDay - $query = 'SELECT - co_preventivi.id, - co_preventivi.nome, - co_preventivi.numero, - co_preventivi.data_accettazione, - co_preventivi.data_conclusione, - (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica = co_preventivi.idanagrafica) AS cliente, - (SELECT id FROM zz_files WHERE id_record = co_preventivi.id AND id_module = '.prepare($modulo_preventivi->id).' LIMIT 1) AS have_attachments, - \'1\' AS is_completato - FROM co_preventivi - LEFT JOIN co_statipreventivi ON co_preventivi.idstato = co_statipreventivi.id - WHERE - ( - (co_preventivi.data_accettazione >= '.prepare($start).' AND co_preventivi.data_accettazione <= '.prepare($end).') - OR (co_preventivi.data_conclusione >= '.prepare($start).' AND co_preventivi.data_conclusione <= '.prepare($end).') - ) - AND - co_statipreventivi.is_pianificabile=1'; - - $alldays = $dbo->fetchArray($query); - - foreach ($alldays as $preventivo) { - if (!empty($preventivo['data_accettazione']) && $preventivo['data_accettazione'] != '0000-00-00') { - $results[] = [ - 'id' => 'A_'.$modulo_preventivi->id.'_'.$preventivo['id'], - 'idintervento' => $preventivo['id'], - 'idtecnico' => '', - 'title' => '
    '.(($preventivo['is_completato']) ? '' : '').' '.(($preventivo['have_attachments']) ? '' : '').'
    '.'Accettazione prev. '.$preventivo['numero'].' '.$preventivo['nome'].'
    '.tr('Cliente').': '.$preventivo['cliente'], - 'start' => $preventivo['data_accettazione'], - 'end' => $preventivo['data_accettazione'], - 'url' => base_path().'/editor.php?id_module='.$modulo_preventivi->id.'&id_record='.$preventivo['id'], - 'backgroundColor' => '#ff7f50', - 'textColor' => color_inverse('#ff7f50'), - 'borderColor' => '#ff7f50', - 'allDay' => true, - 'eventStartEditable' => false, - ]; - } - - if ($preventivo['data_accettazione'] != $preventivo['data_conclusione'] && $preventivo['data_conclusione'] != '0000-00-00' && !empty($preventivo['data_conclusione'])) { - $results[] = [ - 'id' => 'B_'.$modulo_preventivi->id.'_'.$preventivo['id'], - 'idintervento' => $preventivo['id'], - 'idtecnico' => '', - 'title' => '
    '.(($preventivo['is_completato']) ? '' : '').' '.(($preventivo['have_attachments']) ? '' : '').'
    '.'Conclusione prev. '.$preventivo['numero'].' '.$preventivo['nome'].'
    '.tr('Cliente').': '.$preventivo['cliente'], - 'start' => $preventivo['data_conclusione'], - 'end' => $preventivo['data_conclusione'], - 'url' => base_path().'/editor.php?id_module='.$modulo_preventivi->id.'&id_record='.$preventivo['id'], - 'backgroundColor' => '#ff7f50', - 'textColor' => color_inverse('#ff7f50'), - 'borderColor' => '#ff7f50', - 'allDay' => true, - 'eventStartEditable' => false, - ]; - } - } - } - - echo json_encode($results); - - break; - - case 'modifica_intervento': - $sessione = filter('id'); - $idintervento = filter('idintervento'); - $orario_inizio = filter('timeStart'); - $orario_fine = filter('timeEnd'); - - // Aggiornamento prezzo totale - $q = 'SELECT in_interventi_tecnici.prezzo_ore_unitario, idtecnico, in_statiintervento.is_completato FROM in_interventi_tecnici INNER JOIN in_interventi ON in_interventi_tecnici.idintervento=in_interventi.id LEFT OUTER JOIN in_statiintervento ON in_interventi.idstatointervento = in_statiintervento.idstatointervento WHERE in_interventi.id='.prepare($idintervento).' AND in_statiintervento.is_completato = 0 '.Modules::getAdditionalsQuery('Interventi'); - $rs = $dbo->fetchArray($q); - $prezzo_ore = 0.00; - - for ($i = 0; $i < count($rs); ++$i) { - $prezzo_ore_unitario = $rs[$i]['prezzo_ore_unitario']; - $ore = calcola_ore_intervento($orario_inizio, $orario_fine); - - $prezzo_ore += $ore * $prezzo_ore_unitario; - } - - if (count($rs) > 0) { - // Aggiornamento orario tecnico - $dbo->query('UPDATE in_interventi_tecnici SET orario_inizio = '.prepare($orario_inizio).', orario_fine = '.prepare($orario_fine).', ore='.prepare($ore).', prezzo_ore_consuntivo='.prepare($t * $prezzo_ore_unitario).' WHERE id='.prepare($sessione)); - echo 'ok'; - } else { - echo tr('Attività completata, non è possibile modificarla!'); - } - - break; - - case 'tooltip_info': - $id = filter('id_record'); - $allDay = filter('allDay'); - $timeStart = filter('timeStart'); - $timeEnd = filter('timeEnd'); - - if (empty($allday)) { - // Lettura dati intervento di riferimento - $query = 'SELECT in_interventi_tecnici.idintervento, in_interventi.id, idtecnico, orario_inizio, orario_fine, (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=idtecnico) AS nome_tecnico, (SELECT colore FROM an_anagrafiche WHERE idanagrafica=idtecnico) AS colore FROM in_interventi_tecnici INNER JOIN in_interventi ON in_interventi_tecnici.idintervento=in_interventi.id WHERE in_interventi.id='.prepare($id).' '.Modules::getAdditionalsQuery('Interventi'); - $rs = $dbo->fetchArray($query); - - if (!empty($rs)) { - $tecnici = []; - foreach ($rs as $sessione) { - $tecnici[] = $sessione['nome_tecnico'].' ('.Translator::timestampToLocale($sessione['orario_inizio']).' - '.Translator::timeToLocale($sessione['orario_fine']).')'; - } - - // Lettura dati intervento - $query = 'SELECT *, in_interventi.codice, an_anagrafiche.note AS note_anagrafica, idstatointervento AS parent_idstato, in_interventi.idtipointervento AS parent_idtipo, (SELECT GROUP_CONCAT(CONCAT(matricola, " - ", nome) SEPARATOR ", ") FROM my_impianti INNER JOIN my_impianti_interventi ON my_impianti.id=my_impianti_interventi.idimpianto WHERE my_impianti_interventi.idintervento='.prepare($id).' GROUP BY my_impianti_interventi.idintervento) AS impianti, (SELECT descrizione FROM in_statiintervento WHERE idstatointervento=parent_idstato) AS stato, (SELECT descrizione FROM in_tipiintervento WHERE idtipointervento=parent_idtipo) AS tipo, (SELECT idzona FROM an_anagrafiche WHERE idanagrafica=in_interventi.idanagrafica) AS idzona FROM in_interventi LEFT JOIN in_interventi_tecnici ON in_interventi.id =in_interventi_tecnici.idintervento LEFT JOIN an_anagrafiche ON in_interventi.idanagrafica=an_anagrafiche.idanagrafica WHERE in_interventi.id='.prepare($id).' '.Modules::getAdditionalsQuery('Interventi'); - $rs = $dbo->fetchArray($query); - - //correggo info indirizzo citta cap provincia con quelle della sede di destinazione - if (!empty($rs[0]['idsede_destinazione'])) { - $sede = $database->fetchOne('SELECT * FROM an_sedi WHERE id = '.prepare($rs[0]['idsede_destinazione'])); - $rs[0]['indirizzo'] = $sede['nomesede'].'
    '.$sede['indirizzo']; - $rs[0]['cap'] = $sede['cap']; - $rs[0]['citta'] = $sede['citta']; - $rs[0]['provincia'] = $sede['provincia']; - } - - $desc_tipointervento = $rs[0]['tipo']; - - $tooltip = ''.tr('Numero intervento').': '.$rs[0]['codice'].'
    '; - - $tooltip .= ''.tr('Data richiesta').': '.Translator::timestampToLocale($rs[0]['data_richiesta']).'
    '; - - if (!empty($rs[0]['data_scadenza'])) { - $tooltip .= ''.tr('Data scadenza').': '.Translator::timestampToLocale($rs[0]['data_scadenza']).'
    '; - } - - $tooltip .= ''.tr('Tipo intervento').': '.nl2br($desc_tipointervento).'
    '; - - $tooltip .= ''.tr('Tecnici').': '.implode(', ', $tecnici).'
    '; - - if ($rs[0]['impianti'] != '') { - $tooltip .= ''.tr('Impianti').': '.$rs[0]['impianti'].'
    '; - } - - if ($rs[0]['richiesta'] != '') { - $tooltip .= ''.tr('Richiesta').':
    '.nl2br($rs[0]['richiesta']).'
    '; - } - - if ($rs[0]['descrizione'] != '') { - $tooltip .= ''.tr('Descrizione').':
    '.nl2br($rs[0]['descrizione']).'
    '; - } - - if ($rs[0]['informazioniaggiuntive'] != '') { - $tooltip .= ''.tr('Informazioni aggiuntive').': '.nl2br($rs[0]['informazioniaggiuntive']).'
    '; - } - - $tooltip .= ''.tr('Ragione sociale').': '.nl2br($rs[0]['ragione_sociale']).'
    '; - - if (!empty($rs[0]['telefono'])) { - $tooltip .= ''.tr('Telefono').': '.nl2br($rs[0]['telefono']).'
    '; - } - - if (!empty($rs[0]['cellulare'])) { - $tooltip .= ''.tr('Cellulare').': '.nl2br($rs[0]['cellulare']).'
    '; - } - - if (!empty($rs[0]['indirizzo']) || !empty($rs[0]['citta']) || !empty($rs[0]['provincia']) || !empty($rs[0]['cap'])) { - $tooltip .= ''.tr('Indirizzo').': '.nl2br($rs[0]['indirizzo'].' - '.$rs[0]['cap'].' '.$rs[0]['citta'].' ('.$rs[0]['provincia'].')').'
    '; - } - - if (!empty($rs[0]['note_anagrafica'])) { - $tooltip .= ''.tr('Note anagrafica').': '.nl2br($rs[0]['note_anagrafica']).'
    '; - } - } else { - $query = 'SELECT - co_preventivi.nome, - co_preventivi.numero, - co_preventivi.data_accettazione, - co_preventivi.data_conclusione, - (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica = co_preventivi.idanagrafica) AS cliente, - (SELECT id FROM zz_files WHERE id_record = '.prepare($id).' AND id_module = '.prepare($modulo_preventivi->id).' LIMIT 1) AS have_attachments - FROM co_preventivi - LEFT JOIN co_statipreventivi ON co_preventivi.idstato = co_statipreventivi.id - WHERE co_preventivi.id='.prepare($id); - - $rs = $dbo->fetchArray($query); - - $tooltip = 'Prev. '.$rs[0]['numero'].' '.$rs[0]['nome'].''.(($rs[0]['have_attachments']) ? ' ' : '').'
    '.tr('Cliente').': '.$rs[0]['cliente']; - } - - $tooltip .= ' - '; - - echo $tooltip; - } - break; - - case 'carica_interventi': - $mese = filter('mese'); - - $solo_promemoria_assegnati = setting('Mostra promemoria attività ai soli Tecnici assegnati'); - $id_tecnico = null; - if ($user['gruppo'] == 'Tecnici' && !empty($user['idanagrafica'])) { - $id_tecnico = $user['idanagrafica']; - } - - // Promemoria da contratti con stato pianificabile - $query_promemoria_contratti = "SELECT - co_promemoria.id, - idcontratto, - richiesta, - co_contratti.nome AS nome_contratto, - co_contratti.numero AS numero_contratto, - co_contratti.data_bozza AS data_contratto, - DATE_FORMAT( data_richiesta, '%m%Y') AS mese, - data_richiesta, - an_anagrafiche.ragione_sociale, - 'promemoria' AS ref, - (SELECT descrizione FROM in_tipiintervento WHERE idtipointervento = co_promemoria.idtipointervento) AS tipo_intervento - FROM co_promemoria - INNER JOIN co_contratti ON co_promemoria.idcontratto = co_contratti.id - INNER JOIN an_anagrafiche ON co_contratti.idanagrafica = an_anagrafiche.idanagrafica - WHERE idintervento IS NULL AND - idcontratto IN (SELECT id FROM co_contratti WHERE idstato IN(SELECT id FROM co_staticontratti WHERE is_pianificabile = 1)) - ORDER BY data_richiesta ASC"; - $promemoria_contratti = $dbo->fetchArray($query_promemoria_contratti); - - // Promemoria da interventi con stato NON completato - $query_interventi = "SELECT in_interventi.id, - in_interventi.richiesta, - in_interventi.id_contratto AS idcontratto, - in_interventi_tecnici_assegnati.id_tecnico AS id_tecnico, - tecnico.ragione_sociale AS ragione_sociale_tecnico, - DATE_FORMAT(IF(in_interventi.data_scadenza IS NULL, in_interventi.data_richiesta, in_interventi.data_scadenza), '%m%Y') AS mese, - IF(in_interventi.data_scadenza IS NULL, in_interventi.data_richiesta, in_interventi.data_scadenza) AS data_richiesta, - in_interventi.data_scadenza, - an_anagrafiche.ragione_sociale, - tecnico.colore, - 'intervento' AS ref, - (SELECT descrizione FROM in_tipiintervento WHERE in_tipiintervento.idtipointervento=in_interventi.idtipointervento) AS tipo_intervento - FROM in_interventi - INNER JOIN an_anagrafiche ON in_interventi.idanagrafica=an_anagrafiche.idanagrafica"; - - // Visualizzo solo promemoria del tecnico loggato - if (!empty($id_tecnico) && !empty($solo_promemoria_assegnati)) { - $query_interventi .= ' - INNER JOIN in_interventi_tecnici_assegnati ON in_interventi.id = in_interventi_tecnici_assegnati.id_intervento AND id_tecnico = '.prepare($id_tecnico); - } else { - $query_interventi .= ' - LEFT JOIN in_interventi_tecnici_assegnati ON in_interventi.id = in_interventi_tecnici_assegnati.id_intervento'; - } - - $query_interventi .= ' - LEFT JOIN in_interventi_tecnici ON in_interventi_tecnici.idintervento = in_interventi.id - INNER JOIN in_statiintervento ON in_interventi.idstatointervento = in_statiintervento.idstatointervento - LEFT JOIN an_anagrafiche AS tecnico ON in_interventi_tecnici_assegnati.id_tecnico = tecnico.idanagrafica - WHERE in_statiintervento.is_completato = 0 - GROUP BY in_interventi.id, in_interventi_tecnici_assegnati.id_tecnico - HAVING COUNT(in_interventi_tecnici.id) = 0 - ORDER BY data_richiesta ASC'; - $promemoria_interventi = $dbo->fetchArray($query_interventi); - - $promemoria = array_merge($promemoria_contratti, $promemoria_interventi); - - if (!empty($promemoria)) { - $prev_mese = ''; - - // Elenco interventi da pianificare - foreach ($promemoria as $sessione) { - if ($sessione['mese'] == $mese) { - if (date('Ymd', strtotime($sessione['data_scadenza'])) < date('Ymd') and !empty($sessione['data_scadenza'])) { - $class = 'danger'; - } else { - $class = 'primary'; - } - - $link = null; - if ($sessione['ref'] == 'intervento') { - $modulo_riferimento = 'Interventi'; - $id_riferimento = $sessione['id']; - } else { - $modulo_riferimento = 'Contratti'; - $id_riferimento = $sessione['idcontratto']; - } - - echo ' -
    '.($sessione['ref'] == 'intervento' ? Modules::link($modulo_riferimento, $id_riferimento, '', null, 'title="'.tr('Visualizza scheda').'" class="btn btn-'.$class.' btn-xs pull-right"') : Modules::link($modulo_riferimento, $id_riferimento, '', null, 'title="'.tr('Visualizza scheda').'" class="btn btn-'.$class.' btn-xs pull-right"')).' - '.$sessione['ragione_sociale'].' -
    '.dateFormat($sessione['data_richiesta']).' ('.$sessione['tipo_intervento'].') -
    '.(!empty($sessione['richiesta']) ? ' - '.$sessione['richiesta'] : '').'
    - '.(!empty($sessione['numero_contratto']) ? ''.tr('Contratto numero: ').$sessione['numero_contratto'].tr(' del ').dateFormat($sessione['data_contratto']).'' : '').' '.(!empty($sessione['data_scadenza'] && $sessione['data_scadenza'] != '0000-00-00 00:00:00') ? ''.tr('Entro il: ').dateFormat($sessione['data_scadenza']).'' : '').' '.(!empty($sessione['id_tecnico']) ? ''.tr('Tecnico').': '.$sessione['ragione_sociale_tecnico'].'' : '').' -
    '; - } - } - - echo ' - '; - } else { - echo '
    '.tr('Non ci sono interventi da pianificare per questo mese').''; - } - - break; -} diff --git a/modules/dashboard/edit.php b/modules/dashboard/edit.php deleted file mode 100755 index 66b8ea072..000000000 --- a/modules/dashboard/edit.php +++ /dev/null @@ -1,686 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -// Individuazione dati selezionabili -// Stati interventi -$stati_intervento = $dbo->fetchArray('SELECT idstatointervento AS id, descrizione, colore FROM in_statiintervento WHERE deleted_at IS NULL ORDER BY descrizione ASC'); - -// Tipi intervento -$tipi_intervento = $dbo->fetchArray('SELECT idtipointervento AS id, descrizione FROM in_tipiintervento ORDER BY descrizione ASC'); - -// Tecnici disponibili -$tecnici_disponibili = $dbo->fetchArray("SELECT an_anagrafiche.idanagrafica AS id, ragione_sociale, colore FROM an_anagrafiche - INNER JOIN - an_tipianagrafiche_anagrafiche ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica - INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica - LEFT OUTER JOIN in_interventi_tecnici ON in_interventi_tecnici.idtecnico = an_anagrafiche.idanagrafica - INNER JOIN in_interventi ON in_interventi_tecnici.idintervento=in_interventi.id -WHERE an_anagrafiche.deleted_at IS NULL AND an_tipianagrafiche.descrizione='Tecnico' ".Modules::getAdditionalsQuery('Interventi').' -GROUP BY an_anagrafiche.idanagrafica -ORDER BY ragione_sociale ASC'); - -// Zone -$zone = $dbo->fetchArray('(SELECT 0 AS ordine, \'0\' AS id, \'Nessuna zona\' AS descrizione) UNION (SELECT 1 AS ordine, id, descrizione FROM an_zone) ORDER BY ordine, descrizione ASC'); - -// Prima selezione globale per tutti i filtri -if (!isset($_SESSION['dashboard']['idtecnici'])) { - $_SESSION['dashboard']['idtecnici'] = ["'-1'"]; - - foreach ($tecnici_disponibili as $tecnico) { - $_SESSION['dashboard']['idtecnici'][] = "'".$tecnico['id']."'"; - } -} - -if (!isset($_SESSION['dashboard']['idstatiintervento'])) { - $_SESSION['dashboard']['idstatiintervento'] = ["'-1'"]; - - foreach ($stati_intervento as $stato) { - $_SESSION['dashboard']['idstatiintervento'][] = "'".$stato['id']."'"; - } -} - -if (!isset($_SESSION['dashboard']['idtipiintervento'])) { - $_SESSION['dashboard']['idtipiintervento'] = ["'-1'"]; - - foreach ($tipi_intervento as $tipo) { - $_SESSION['dashboard']['idtipiintervento'][] = "'".$tipo['id']."'"; - } -} - -if (!isset($_SESSION['dashboard']['idzone'])) { - $_SESSION['dashboard']['idzone'] = ["'-1'"]; - - foreach ($zone as $zona) { - $_SESSION['dashboard']['idzone'][] = "'".$zona['id']."'"; - } -} - -echo ' - -
    - - - - - - - - - - - -
    -
    '; - -$solo_promemoria_assegnati = setting('Mostra promemoria attività ai soli Tecnici assegnati'); -$id_tecnico = null; -if ($user['gruppo'] == 'Tecnici' && !empty($user['idanagrafica'])) { - $id_tecnico = $user['idanagrafica']; -} - -$query_da_programmare = 'SELECT data_richiesta AS data FROM co_promemoria - INNER JOIN co_contratti ON co_promemoria.idcontratto = co_contratti.id - INNER JOIN an_anagrafiche ON co_contratti.idanagrafica = an_anagrafiche.idanagrafica -WHERE - idcontratto IN (SELECT id FROM co_contratti WHERE idstato IN (SELECT id FROM co_staticontratti WHERE is_pianificabile = 1)) - AND idintervento IS NULL - -UNION SELECT IF(data_scadenza IS NULL, data_richiesta, data_scadenza) AS data FROM in_interventi - INNER JOIN an_anagrafiche ON in_interventi.idanagrafica = an_anagrafiche.idanagrafica'; - -// Visualizzo solo promemoria del tecnico loggato -if (!empty($id_tecnico) && !empty($solo_promemoria_assegnati)) { - $query_da_programmare .= ' - INNER JOIN in_interventi_tecnici_assegnati ON in_interventi.id = in_interventi_tecnici_assegnati.id_intervento AND id_tecnico = '.prepare($id_tecnico); -} - -$query_da_programmare .= ' -WHERE (SELECT COUNT(*) FROM in_interventi_tecnici WHERE in_interventi_tecnici.idintervento = in_interventi.id) = 0 AND in_interventi.idstatointervento IN(SELECT idstatointervento FROM in_statiintervento WHERE is_completato = 0)'; -$risultati_da_programmare = $dbo->fetchArray($query_da_programmare); - -if (!empty($risultati_da_programmare)) { - echo ' -
    -
    '; -} - -echo ' -
    '; - -if (!empty($risultati_da_programmare)) { - echo ' -
    - - -
    '; -} - -$vista = setting('Vista dashboard'); -if ($vista == 'mese') { - $def = 'month'; -} elseif ($vista == 'giorno') { - $def = 'agendaDay'; -} else { - $def = 'agendaWeek'; -} - -$modulo_interventi = Modules::get('Interventi'); - -echo ' -'; diff --git a/modules/dashboard/widgets/notifiche.php b/modules/dashboard/widgets/notifiche.php deleted file mode 100755 index 77958c1ec..000000000 --- a/modules/dashboard/widgets/notifiche.php +++ /dev/null @@ -1,93 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -use Carbon\Carbon; -use Models\Module; - -if (!empty($is_title_request)) { - echo tr('Notifiche interne'); - - return; -} - -$notes = collect(); - -$moduli = Module::getAll()->where('permission', '<>', '-'); -foreach ($moduli as $modulo) { - $note = $modulo->notes()->whereNotNull('notification_date')->orderBy('notification_date', 'asc')->get(); - $notes = $notes->merge($note); -} - -if (!empty($is_number_request)) { - echo $notes->count(); - - return; -} - -if ($notes->count() < 1) { - echo ' -

    '.tr('Non ci sono note da notificare').'.

    '; - - return; -} - -$moduli = $notes->groupBy('id_module')->sortBy('notification_date'); -foreach ($moduli as $module_id => $note) { - $modulo = Module::pool($module_id); - - echo ' -

    '.$modulo->title.'

    - - - - - - - '; - - foreach ($note as $nota) { - $class = (strtotime($nota->notification_date) < strtotime(date('Y-m-d')) && !empty($nota->notification_date)) ? 'danger' : ''; - - echo ' - - - - - - - - - '; - } - - echo ' -
    '.tr('Record').''.tr('Contenuto').''.tr('Data di notifica').'#
    '.$nota->id_record.' - - - '.$nota->content.' - - '.$nota->user->nome_completo.' - - '.dateFormat($nota->notification_date).' ('.Carbon::parse($nota->notification_date)->diffForHumans().') - - '.Modules::link($module_id, $nota->id_record, '', null, 'class="btn btn-primary btn-xs"', true, 'tab_note').' -
    '; -} diff --git a/modules/dashboard/widgets/stampa_calendario.dashboard.php b/modules/dashboard/widgets/stampa_calendario.dashboard.php deleted file mode 100755 index dc9321d02..000000000 --- a/modules/dashboard/widgets/stampa_calendario.dashboard.php +++ /dev/null @@ -1,87 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -use Carbon\Carbon; - -// Trovo id_print della stampa -$id_print = Prints::getModulePredefinedPrint('Dashboard')['id']; -$date = new Carbon($_SESSION['dashboard']['date']); - -echo ' -
    - -
    -
    - {[ "type": "text", "label": "'.tr('Mese e anno').'", "name": "date", "required": "1" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Formato').'", "name": "format", "required": "1", "values": "list=\"A4\": \"'.tr('A4').'\", \"A3\": \"'.tr('A3').'\"", "value": "'.$_SESSION['dashboard']['format'].'" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Orientamento').'", "name": "orientation", "required": "1", "values": "list=\"L\": \"'.tr('Orizzontale').'\", \"P\": \"'.tr('Verticale').'\"", "value": "'.$_SESSION['dashboard']['orientation'].'" ]} -
    - - -
    -

     

    - - -
    - -
    - -
    - -'; - -echo ' -'; diff --git a/modules/ddt/actions.php b/modules/ddt/actions.php deleted file mode 100755 index c5e614237..000000000 --- a/modules/ddt/actions.php +++ /dev/null @@ -1,487 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Models\Module; -use Modules\Anagrafiche\Anagrafica; -use Modules\Articoli\Articolo as ArticoloOriginale; -use Modules\DDT\Components\Articolo; -use Modules\DDT\Components\Descrizione; -use Modules\DDT\Components\Riga; -use Modules\DDT\Components\Sconto; -use Modules\DDT\DDT; -use Modules\DDT\Stato; -use Modules\DDT\Tipo; - -$module = Modules::get($id_module); - -if ($module['name'] == 'Ddt di vendita') { - $dir = 'entrata'; -} else { - $dir = 'uscita'; -} - -switch (filter('op')) { - case 'add': - $idanagrafica = post('idanagrafica'); - $data = post('data'); - $id_tipo = post('idtipoddt'); - - $anagrafica = Anagrafica::find($idanagrafica); - $tipo = Tipo::find($id_tipo); - - $ddt = DDT::build($anagrafica, $tipo, $data); - $id_record = $ddt->id; - - $ddt->idcausalet = post('idcausalet'); - $ddt->save(); - - flash()->info(tr('Aggiunto ddt in _TYPE_ numero _NUM_!', [ - '_TYPE_' => $dir, - '_NUM_' => $ddt->numero, - ])); - - break; - - case 'update': - if (isset($id_record)) { - $idstatoddt = post('idstatoddt'); - $idpagamento = post('idpagamento'); - $numero_esterno = post('numero_esterno'); - $id_anagrafica = post('idanagrafica'); - - if ($dir == 'uscita') { - $idrivalsainps = post('id_rivalsa_inps'); - $idritenutaacconto = post('id_ritenuta_acconto'); - $bollo = post('bollo'); - } else { - $idrivalsainps = 0; - $idritenutaacconto = 0; - $bollo = 0; - } - - $tipo_sconto = post('tipo_sconto_generico'); - $sconto = post('sconto_generico'); - - // Leggo la descrizione del pagamento - $query = 'SELECT descrizione FROM co_pagamenti WHERE id='.prepare($idpagamento); - $rs = $dbo->fetchArray($query); - $pagamento = $rs[0]['descrizione']; - - $ddt->data = post('data'); - $ddt->numero_esterno = $numero_esterno; - $ddt->note = post('note'); - $ddt->note_aggiuntive = post('note_aggiuntive'); - - $ddt->idstatoddt = $idstatoddt; - $ddt->idpagamento = $idpagamento; - $ddt->idconto = post('idconto'); - $ddt->idanagrafica = $id_anagrafica; - $ddt->idreferente = post('idreferente'); - $ddt->idspedizione = post('idspedizione'); - $ddt->idcausalet = post('idcausalet'); - $ddt->idsede_partenza = post('idsede_partenza'); - $ddt->idsede_destinazione = post('idsede_destinazione'); - $ddt->idvettore = post('idvettore'); - $ddt->data_ora_trasporto = post('data_ora_trasporto') ?: null; - $ddt->idporto = post('idporto'); - $ddt->idaspettobeni = post('idaspettobeni'); - $ddt->idrivalsainps = $idrivalsainps; - $ddt->idritenutaacconto = $idritenutaacconto; - - $ddt->n_colli = post('n_colli'); - $ddt->peso = post('peso'); - $ddt->volume = post('volume'); - $ddt->peso_manuale = post('peso_manuale'); - $ddt->volume_manuale = post('volume_manuale'); - $ddt->bollo = 0; - $ddt->rivalsainps = 0; - $ddt->ritenutaacconto = 0; - - $ddt->id_documento_fe = post('id_documento_fe'); - $ddt->codice_cup = post('codice_cup'); - $ddt->codice_cig = post('codice_cig'); - $ddt->num_item = post('num_item'); - - $ddt->setScontoFinale(post('sconto_finale'), post('tipo_sconto_finale')); - - $ddt->save(); - - $query = 'SELECT descrizione FROM dt_statiddt WHERE id='.prepare($idstatoddt); - $rs = $dbo->fetchArray($query); - - // Ricalcolo inps, ritenuta e bollo (se l'ddt non è stato evaso) - if ($dir == 'entrata') { - if ($rs[0]['descrizione'] != 'Pagato') { - ricalcola_costiagg_ddt($id_record); - } - } else { - if ($rs[0]['descrizione'] != 'Pagato') { - ricalcola_costiagg_ddt($id_record, $idrivalsainps, $idritenutaacconto, $bollo); - } - } - - aggiorna_sedi_movimenti('ddt', $id_record); - - // Controllo sulla presenza di DDT con lo stesso numero secondario - $direzione = $ddt->direzione; - if ($direzione == 'uscita' and !empty($numero_esterno)) { - $count = DDT::where('numero_esterno', $numero_esterno) - ->where('id', '!=', $id_record) - ->where('idanagrafica', '=', $id_anagrafica) - ->whereHas('tipo', function ($query) use ($direzione) { - $query->where('dir', '=', $direzione); - })->count(); - if (!empty($count)) { - flash()->warning(tr('Esiste già un DDT con lo stesso numero secondario e la stessa anagrafica collegata!')); - } - } - - flash()->info(tr('Ddt modificato correttamente!')); - } - - break; - - case 'manage_barcode': - foreach (post('qta') as $id_articolo => $qta) { - if ($id_articolo == '-id-') { - continue; - } - - // Dati di input - $sconto = post('sconto')[$id_articolo]; - $tipo_sconto = post('tipo_sconto')[$id_articolo]; - $prezzo_unitario = post('prezzo_unitario')[$id_articolo]; - $id_dettaglio_fornitore = post('id_dettaglio_fornitore')[$id_articolo]; - $id_iva = $originale->idiva_vendita ? $originale->idiva_vendita : setting('Iva predefinita'); - - // Creazione articolo - $originale = ArticoloOriginale::find($id_articolo); - $articolo = Articolo::build($ddt, $originale); - $articolo->id_dettaglio_fornitore = $id_dettaglio_fornitore ?: null; - - $articolo->setPrezzoUnitario($prezzo_unitario, $id_iva); - if ($dir == 'entrata') { - $articolo->costo_unitario = $originale->prezzo_acquisto; - } - $articolo->setSconto($sconto, $tipo_sconto); - $articolo->qta = $qta; - - $articolo->save(); - } - - flash()->info(tr('Articoli aggiunti!')); - - break; - - case 'manage_articolo': - if (post('idriga') != null) { - $articolo = Articolo::find(post('idriga')); - } else { - $originale = ArticoloOriginale::find(post('idarticolo')); - $articolo = Articolo::build($ddt, $originale); - $articolo->id_dettaglio_fornitore = post('id_dettaglio_fornitore') ?: null; - } - - $articolo->descrizione = post('descrizione'); - $articolo->um = post('um') ?: null; - - $articolo->costo_unitario = post('costo_unitario') ?: 0; - $articolo->setPrezzoUnitario(post('prezzo_unitario'), post('idiva')); - $articolo->setSconto(post('sconto'), post('tipo_sconto')); - - try { - $articolo->qta = post('qta'); - } catch (UnexpectedValueException $e) { - flash()->error(tr('Alcuni serial number sono già stati utilizzati!')); - } - - $articolo->save(); - - if (post('idriga') != null) { - flash()->info(tr('Articolo modificato!')); - } else { - flash()->info(tr('Articolo aggiunto!')); - } - - // Ricalcolo inps, ritenuta e bollo - ricalcola_costiagg_ddt($id_record); - - break; - - case 'manage_sconto': - if (post('idriga') != null) { - $sconto = Sconto::find(post('idriga')); - } else { - $sconto = Sconto::build($ddt); - } - - $sconto->descrizione = post('descrizione'); - $sconto->setScontoUnitario(post('sconto_unitario'), post('idiva')); - - $sconto->save(); - - if (post('idriga') != null) { - flash()->info(tr('Sconto/maggiorazione modificato!')); - } else { - flash()->info(tr('Sconto/maggiorazione aggiunto!')); - } - - // Ricalcolo inps, ritenuta e bollo - ricalcola_costiagg_ddt($id_record); - - break; - - case 'manage_riga': - if (post('idriga') != null) { - $riga = Riga::find(post('idriga')); - } else { - $riga = Riga::build($ddt); - } - - $riga->descrizione = post('descrizione'); - $riga->um = post('um') ?: null; - - $riga->costo_unitario = post('costo_unitario') ?: 0; - $riga->setPrezzoUnitario(post('prezzo_unitario'), post('idiva')); - $riga->setSconto(post('sconto'), post('tipo_sconto')); - - $riga->qta = post('qta'); - - $riga->save(); - - if (post('idriga') != null) { - flash()->info(tr('Riga modificata!')); - } else { - flash()->info(tr('Riga aggiunta!')); - } - - // Ricalcolo inps, ritenuta e bollo - ricalcola_costiagg_ddt($id_record); - - break; - - case 'manage_descrizione': - if (post('idriga') != null) { - $riga = Descrizione::find(post('idriga')); - } else { - $riga = Descrizione::build($ddt); - } - - $riga->descrizione = post('descrizione'); - - $riga->save(); - - if (post('idriga') != null) { - flash()->info(tr('Riga descrittiva modificata!')); - } else { - flash()->info(tr('Riga descrittiva aggiunta!')); - } - - break; - - // Aggiunta di un documento in ddt - case 'add_ordine': - case 'add_documento': - $class = post('class'); - $id_documento = post('id_documento'); - - // Individuazione del documento originale - if (!is_subclass_of($class, \Common\Document::class)) { - return; - } - $documento = $class::find($id_documento); - - // Individuazione sede - $id_sede = ($documento->direzione == 'entrata') ? $documento->idsede_destinazione : $documento->idsede_partenza; - $id_sede = $id_sede ?: $documento->idsede; - $id_sede = $id_sede ?: 0; - - // Creazione del ddt al volo - if (post('create_document') == 'on') { - $tipo = Tipo::where('dir', $documento->direzione)->first(); - - $ddt = DDT::build($documento->anagrafica, $tipo, post('data')); - $ddt->idpagamento = $documento->idpagamento; - - $ddt->id_documento_fe = $documento->id_documento_fe; - $ddt->codice_cup = $documento->codice_cup; - $ddt->codice_cig = $documento->codice_cig; - $ddt->num_item = $documento->num_item; - $ddt->idsede_destinazione = $id_sede; - - $ddt->idcausalet = post('id_causale_trasporto'); - $ddt->idreferente = $documento->idreferente; - - $ddt->save(); - - $id_record = $ddt->id; - } - - if (!empty($documento->sconto_finale)) { - $ddt->sconto_finale = $documento->sconto_finale; - } elseif (!empty($documento->sconto_finale_percentuale)) { - $ddt->sconto_finale_percentuale = $documento->sconto_finale_percentuale; - } - - $ddt->save(); - - $righe = $documento->getRighe(); - foreach ($righe as $riga) { - if (post('evadere')[$riga->id] == 'on' and !empty(post('qta_da_evadere')[$riga->id])) { - $qta = post('qta_da_evadere')[$riga->id]; - - $copia = $riga->copiaIn($ddt, $qta); - - // Aggiornamento seriali dalla riga dell'ordine - if ($copia->isArticolo()) { - if ($documento->tipo->dir == 'uscita') { - $originale = ArticoloOriginale::find($riga->idarticolo); - $id_iva = $originale->idiva_vendita ? $originale->idiva_vendita : setting('Iva predefinita'); - $copia->setPrezzoUnitario($originale->prezzo_vendita, $id_iva); - } - $serials = is_array(post('serial')[$riga->id]) ? post('serial')[$riga->id] : []; - - $copia->serials = $serials; - } - - $copia->save(); - } - } - - // Modifica finale dello stato - if (post('create_document') == 'on') { - $ddt->idstatoddt = post('id_stato'); - $ddt->save(); - } - - ricalcola_costiagg_ddt($id_record); - - // Messaggio informativo - $message = tr('_DOC_ aggiunto!', [ - '_DOC_' => $documento->getReference(), - ]); - flash()->info($message); - - break; - - // Scollegamento riga generica da ddt - case 'delete_riga': - $id_riga = post('riga_id'); - $type = post('riga_type'); - - $riga = $ddt->getRiga($type, $id_riga); - - if (!empty($riga)) { - try { - $riga->delete(); - - flash()->info(tr('Riga rimossa!')); - } catch (InvalidArgumentException $e) { - flash()->error(tr('Alcuni serial number sono già stati utilizzati!')); - } - } - - ricalcola_costiagg_ddt($id_record); - - break; - - // eliminazione ddt - case 'delete': - try { - $ddt->delete(); - - flash()->info(tr('Ddt eliminato!')); - } catch (InvalidArgumentException $e) { - flash()->error(tr('Sono stati utilizzati alcuni serial number nel documento: impossibile procedere!')); - } - - break; - - case 'add_serial': - $articolo = Articolo::find(post('idriga')); - - $serials = (array) post('serial'); - $articolo->serials = $serials; - - break; - - case 'update_position': - $order = explode(',', post('order', true)); - - foreach ($order as $i => $id_riga) { - $dbo->query('UPDATE `dt_righe_ddt` SET `order` = '.prepare($i + 1).' WHERE id='.prepare($id_riga)); - } - - break; - - /* - * Gestione della generazione di DDT in direzione opposta a quella corrente, per completare il riferimento di trasporto interno tra sedi distinte dell'anagrafica Azienda. - */ - case 'completa_trasporto': - $tipo = Tipo::where('dir', '!=', $ddt->direzione)->first(); - $stato = Stato::where('descrizione', '=', 'Evaso')->first(); - - // Duplicazione DDT - $copia = $ddt->replicate(); - $copia->tipo()->associate($tipo); - $copia->stato()->associate($stato); - $copia->id_ddt_trasporto_interno = $ddt->id; - - // Inversione sedi - $copia->idsede_partenza = $ddt->idsede_destinazione; - $copia->idsede_destinazione = $ddt->idsede_partenza; - - $copia->save(); - - // Copia righe - $righe = $ddt->getRighe(); - foreach ($righe as $riga) { - $copia_riga = $riga->replicate(); - - // Aggiornamento riferimenti - $copia_riga->idddt = $copia->id; - $copia_riga->original_id = null; - $copia_riga->original_type = null; - - $copia_riga->save(); - - // Movimentazione forzata in direzione del documento - $copia_riga->movimenta($riga->qta); - } - - // Salvataggio riferimento - $ddt->id_ddt_trasporto_interno = $copia->id; - $ddt->save(); - - $id_record = $copia->id; - $id_module = $ddt->direzione == 'entrata' ? Module::pool('Ddt di acquisto')->id : Module::pool('Ddt di vendita')->id; - - break; -} - -// Aggiornamento stato degli ordini presenti in questa fattura in base alle quantità totali evase -if (!empty($id_record) && setting('Cambia automaticamente stato ordini fatturati')) { - $rs = $dbo->fetchArray('SELECT idordine FROM dt_righe_ddt WHERE idddt='.prepare($id_record)); - - for ($i = 0; $i < sizeof($rs); ++$i) { - $dbo->query('UPDATE or_ordini SET idstatoordine=(SELECT id FROM or_statiordine WHERE descrizione="'.get_stato_ordine($rs[$i]['idordine']).'") WHERE id = '.prepare($rs[$i]['idordine'])); - } -} diff --git a/modules/ddt/add.php b/modules/ddt/add.php deleted file mode 100755 index fa01a1dbe..000000000 --- a/modules/ddt/add.php +++ /dev/null @@ -1,83 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$module = Modules::get($id_module); - -if ($module['name'] == 'Ddt di vendita') { - $dir = 'entrata'; - - $id_tipoddt = $dbo->fetchOne("SELECT id FROM dt_tipiddt WHERE descrizione='Ddt in uscita'")['id']; - - $tipo_anagrafica = tr('Cliente'); - $label = tr('Destinatario'); -} else { - $dir = 'uscita'; - - $id_tipoddt = $dbo->fetchOne("SELECT id FROM dt_tipiddt WHERE descrizione='Ddt in entrata'")['id']; - - $tipo_anagrafica = tr('Fornitore'); - $label = tr('Mittente'); -} -$id_causalet = $dbo->fetchOne('SELECT id FROM dt_causalet WHERE predefined=1')['id']; -$id_anagrafica = !empty(get('idanagrafica')) ? get('idanagrafica') : ''; - -?>
    - - - - - - - -
    -
    - {[ "type": "date", "label": "", "name": "data", "required": 1, "value": "-now-" ]} -
    - -
    - {[ "type": "select", "label": "", "name": "idanagrafica", "id": "idanagrafica_add", "required": 1, "value": "", "ajax-source": "clienti_fornitori", "icon-after": "add||tipoanagrafica=" ]} -
    - - -
    - {[ "type": "select", "label": "", "name": "idtipoddt", "required": 1, "values": "query=SELECT id, descrizione FROM dt_tipiddt WHERE dir=''", "value": "" ]} -
    - -
    - {[ "type": "select", "label": "", "name": "idcausalet", "required": 1, "value": "", "ajax-source": "causali", "icon-after": "add||||" ]} -
    -
    - - -
    -
    - -
    -
    -
    - diff --git a/modules/ddt/add_ddt.php b/modules/ddt/add_ddt.php deleted file mode 100644 index ccd0888b6..000000000 --- a/modules/ddt/add_ddt.php +++ /dev/null @@ -1,85 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\DDT\DDT; - -$documento_finale = DDT::find($id_record); -$dir = $documento_finale->direzione; - -$id_documento = get('id_documento'); -if (!empty($id_documento)) { - $documento = DDT::find($id_documento); - - $options = [ - 'op' => 'add_documento', - 'button' => tr('Aggiungi'), - 'serials' => true, - 'documento' => $documento, - 'documento_finale' => $documento_finale, - 'tipo_documento_finale' => DDT::class, - 'superamento_soglia_qta' => setting('Permetti il superamento della soglia quantità dei documenti di origine'), - ]; - - echo App::load('importa.php', [], $options, true); - - return; -} - -$id_anagrafica = $documento_finale->idanagrafica; - -echo ' -
    -
    - {[ "type": "select", "label": "'.tr('Ddt').'", "name": "id_documento", "values": "query=SELECT dt_ddt.id, CONCAT(IF(numero_esterno != \'\', numero_esterno, numero), \' del \', DATE_FORMAT(data, \'%d-%m-%Y\')) AS descrizione FROM dt_ddt WHERE idstatoddt IN (SELECT id FROM dt_statiddt WHERE descrizione IN(\'Evaso\', \'Parzialmente evaso\', \'Parzialmente fatturato\')) AND idtipoddt=(SELECT id FROM dt_tipiddt WHERE dir=\''.($dir == 'entrata' ? 'uscita' : 'entrata').'\' LIMIT 0,1) AND dt_ddt.id IN (SELECT idddt FROM dt_righe_ddt WHERE dt_righe_ddt.idddt = dt_ddt.id AND (qta - qta_evasa) > 0) ORDER BY data DESC, numero DESC" ]} -
    -
    - -
    - -
    - -
    - '.tr('Caricamento in corso').'... -
    '; - -$file = basename(__FILE__); -echo ' - - -'; diff --git a/modules/ddt/add_ordine.php b/modules/ddt/add_ordine.php deleted file mode 100755 index 929189cca..000000000 --- a/modules/ddt/add_ordine.php +++ /dev/null @@ -1,86 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\DDT\DDT; -use Modules\Ordini\Ordine; - -$documento_finale = DDT::find($id_record); -$dir = $documento_finale->direzione; - -$id_documento = get('id_documento'); -if (!empty($id_documento)) { - $documento = Ordine::find($id_documento); - - $options = [ - 'op' => 'add_ordine', - 'button' => tr('Aggiungi'), - 'serials' => true, - 'documento' => $documento, - 'documento_finale' => $documento_finale, - 'tipo_documento_finale' => DDT::class, - 'superamento_soglia_qta' => setting('Permetti il superamento della soglia quantità dei documenti di origine'), - ]; - - echo App::load('importa.php', [], $options, true); - - return; -} - -$id_anagrafica = $documento_finale->idanagrafica; - -echo ' -
    -
    - {[ "type": "select", "label": "'.tr('Ordine').'", "name": "id_documento", "values": "query=SELECT or_ordini.id, CONCAT(IF(numero_esterno != \'\', numero_esterno, numero), \' del \', DATE_FORMAT(data, \'%d-%m-%Y\')) AS descrizione FROM or_ordini WHERE idanagrafica='.prepare($id_anagrafica).' AND idstatoordine IN (SELECT id FROM or_statiordine WHERE descrizione IN(\'Accettato\', \'Evaso\', \'Parzialmente evaso\', \'Parzialmente fatturato\')) AND idtipoordine=(SELECT id FROM or_tipiordine WHERE dir='.prepare($dir).' LIMIT 0,1) AND or_ordini.id IN (SELECT idordine FROM or_righe_ordini WHERE or_righe_ordini.idordine = or_ordini.id AND (qta - qta_evasa) > 0) ORDER BY data DESC, numero DESC" ]} -
    -
    - -
    - -
    - -
    - '.tr('Caricamento in corso').'... -
    '; - -$file = basename(__FILE__); -echo ' - - -'; diff --git a/modules/ddt/ajax/search.php b/modules/ddt/ajax/search.php deleted file mode 100755 index 182c8690f..000000000 --- a/modules/ddt/ajax/search.php +++ /dev/null @@ -1,78 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -$fields = [ - 'Numero' => 'numero', - 'Numero secondario' => 'numero_esterno', - 'Data' => 'data', - 'Note' => 'note', - 'Righe' => '(SELECT GROUP_CONCAT(descrizione SEPARATOR \' -- \') FROM dt_righe_ddt WHERE dt_righe_ddt.idddt = dt_ddt.id)', -]; - -$query = 'SELECT *, dt_ddt.id, dt_tipiddt.descrizione AS tipologia'; - -foreach ($fields as $name => $value) { - $query .= ', '.$value." AS '".str_replace("'", "\'", $name)."'"; -} - -$query .= ' FROM dt_ddt INNER JOIN dt_tipiddt ON dt_ddt.idtipoddt=dt_tipiddt.id WHERE idanagrafica IN('.implode(',', $idanagrafiche).') '; - -foreach ($fields as $name => $value) { - $query .= ' OR '.$value.' LIKE "%'.$term.'%"'; -} - -//$query .= Modules::getAdditionalsQuery('Interventi'); - -$rs = $dbo->fetchArray($query); - -foreach ($rs as $r) { - $result = []; - - $module = ($r['dir'] == 'uscita') ? 'Ddt di acquisto' : 'Ddt di vendita'; - $link_id = Modules::get($module)['id']; - - $numero = empty($r['numero_esterno']) ? $r['numero'] : $r['numero_esterno']; - - $result['link'] = base_path().'/editor.php?id_module='.$link_id.'&id_record='.$r['id']; - $result['title'] = $r['tipologia'].' num. '.$numero.' del '.Translator::dateToLocale($r['data']); - $result['category'] = $r['tipologia']; - - // Campi da evidenziare - $result['labels'] = []; - foreach ($fields as $name => $value) { - if (string_contains($r[$name], $term)) { - if ($name == 'Righe') { - $result['labels'][] = tr('Termine presente nelle righe del documento').'
    '; - } else { - $text = str_replace($term, "".$term.'', $r[$name]); - - $result['labels'][] = $name.': '.$text.'
    '; - } - } - } - - // Aggiunta nome anagrafica come ultimo campo - if (sizeof($ragioni_sociali) > 1) { - $result['labels'][] = 'Anagrafica: '.$ragioni_sociali[$r['idanagrafica']].'
    '; - } - - $results[] = $result; -} diff --git a/modules/ddt/bulk.php b/modules/ddt/bulk.php deleted file mode 100755 index a26988e8a..000000000 --- a/modules/ddt/bulk.php +++ /dev/null @@ -1,203 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Articoli\Articolo as ArticoloOriginale; -use Modules\DDT\DDT; -use Modules\Fatture\Fattura; -use Modules\Fatture\Stato; -use Modules\Fatture\Tipo; - -if ($module['name'] == 'Ddt di vendita') { - $dir = 'entrata'; - $module_fatture = 'Fatture di vendita'; -} else { - $dir = 'uscita'; - $module_fatture = 'Fatture di acquisto'; -} - -// Segmenti -$id_fatture = Modules::get($module_fatture)['id']; -if (!isset($_SESSION['module_'.$id_fatture]['id_segment'])) { - $segments = Modules::getSegments($id_fatture); - $_SESSION['module_'.$id_fatture]['id_segment'] = isset($segments[0]['id']) ? $segments[0]['id'] : null; -} -$id_segment = $_SESSION['module_'.$id_fatture]['id_segment']; -$idconto = setting('Conto predefinito fatture di vendita'); - -switch (post('op')) { - case 'crea_fattura': - $documenti = collect(); - $numero_totale = 0; - - // Informazioni della fattura - if ($dir == 'entrata') { - $descrizione_tipo = 'Fattura immediata di vendita'; - } else { - $descrizione_tipo = 'Fattura immediata di acquisto'; - } - - $tipo_documento = Tipo::where('descrizione', $descrizione_tipo)->first(); - - $stato_documenti_accodabili = Stato::where('descrizione', 'Bozza')->first(); - $accodare = post('accodare'); - - $data = date('Y-m-d'); - $id_segment = post('id_segment'); - - // Lettura righe selezionate - foreach ($id_records as $id) { - $documento_import = DDT::find($id); - $anagrafica = $documento_import->anagrafica; - $id_anagrafica = $anagrafica->id; - - // Proseguo solo se i documenti scelti sono fatturabili - if ($documento_import->isImportabile()) { - $righe = $documento_import->getRighe(); - if (!empty($righe)) { - ++$numero_totale; - - // Ricerca fattura per anagrafica tra le registrate - $fattura = $documenti->first(function ($item, $key) use ($id_anagrafica) { - return $item->anagrafica->id == $id_anagrafica; - }); - - // Ricerca fattura per anagrafica se l'impostazione di accodamento è selezionata - if (!empty($accodare) && empty($fattura)) { - $fattura = Fattura::where('idanagrafica', $id_anagrafica) - ->where('idstatodocumento', $stato_documenti_accodabili->id) - ->where('idtipodocumento', $tipo_documento->id) - ->first(); - - if (!empty($fattura)) { - $documenti->push($fattura); - } - } - - // Creazione fattura per anagrafica - if (empty($fattura)) { - $fattura = Fattura::build($anagrafica, $tipo_documento, $data, $id_segment); - $documenti->push($fattura); - } - - // Inserimento righe - foreach ($righe as $riga) { - $qta = $riga->qta_rimanente; - - if ($qta > 0) { - $copia = $riga->copiaIn($fattura, $qta); - - //Fix per idconto righe fattura - $articolo = ArticoloOriginale::find($copia->idarticolo); - $copia->id_conto = ($articolo->idconto_vendita ? $articolo->idconto_vendita : $idconto); - - // Aggiornamento seriali dalla riga dell'ordine - if ($copia->isArticolo()) { - $copia->serials = $riga->serials; - } - - $copia->save(); - } - } - } - } - } - - if ($numero_totale > 0) { - flash()->info(tr('_NUM_ ddt fatturati!', [ - '_NUM_' => $numero_totale, - ])); - } else { - flash()->warning(tr('Nessun ddt fatturato!')); - } - break; - - case 'delete-bulk': - foreach ($id_records as $id) { - $documento = DDT::find($id); - try { - $documento->delete(); - } catch (InvalidArgumentException $e) { - } - } - - flash()->info(tr('Ddt eliminati!')); - break; - - case 'cambia_stato': - $id_stato = post('id_stato'); - - $n_ddt = 0; - - foreach ($id_records as $id) { - $ddt = DDT::find($id); - $ddt->idstatoddt = $id_stato; - $ddt->save(); - - ++$n_ddt; - } - - if ($n_ddt > 0) { - flash()->info(tr('Stato cambiato a _NUM_ DDT!', [ - '_NUM_' => $n_ordini, - ])); - } else { - flash()->warning(tr('Nessun DDT modificato!')); - } - - break; -} - -if (App::debug()) { - $operations['delete-bulk'] = [ - 'text' => ' '.tr('Elimina selezionati').'', - 'data' => [ - 'msg' => tr('Vuoi davvero eliminare i ddt selezionati?'), - 'button' => tr('Procedi'), - 'class' => 'btn btn-lg btn-danger', - ], - ]; -} - -$operations['crea_fattura'] = [ - 'text' => ' '.tr('Fattura _TYPE_', ['_TYPE_' => strtolower($module['name'])]), - 'data' => [ - 'title' => tr('Fatturare i _TYPE_ selezionati?', ['_TYPE_' => strtolower($module['name'])]), - 'msg' => '{[ "type": "checkbox", "label": "'.tr('Aggiungere alle _TYPE_ non ancora emesse?', ['_TYPE_' => strtolower($module_fatture)]).'", "placeholder": "'.tr('Aggiungere alle _TYPE_ nello stato bozza?', ['_TYPE_' => strtolower($module_fatture)]).'", "name": "accodare" ]} -
    {[ "type": "select", "label": "'.tr('Sezionale').'", "name": "id_segment", "required": 1, "values": "query=SELECT id, name AS descrizione FROM zz_segments WHERE id_module=\''.$id_fatture.'\' AND is_fiscale = 1 ORDER BY name", "value": "'.$id_segment.'" ]}', - 'button' => tr('Procedi'), - 'class' => 'btn btn-lg btn-warning', - 'blank' => false, - ], - ]; - - $operations['cambia_stato'] = [ - 'text' => ' '.tr('Cambia stato'), - 'data' => [ - 'title' => tr('Vuoi davvero cambiare lo stato per questi DDT?'), - 'msg' => tr('Seleziona lo stato in cui spostare tutti i DDT').'.
    -
    {[ "type": "select", "label": "'.tr('Stato').'", "name": "id_stato", "required": 1, "values": "query=SELECT id, descrizione FROM dt_statiddt" ]}', - 'button' => tr('Procedi'), - 'class' => 'btn btn-lg btn-warning', - 'blank' => false, - ], - ]; - -return $operations; diff --git a/modules/ddt/buttons.php b/modules/ddt/buttons.php deleted file mode 100755 index 4f4920465..000000000 --- a/modules/ddt/buttons.php +++ /dev/null @@ -1,79 +0,0 @@ -. - */ - -use Models\Module; - -include_once __DIR__.'/../../core.php'; - -// Informazioni sui movimenti interni -if (!empty($ddt->id_ddt_trasporto_interno)) { - $id_module_collegamento = $ddt->direzione == 'entrata' ? Module::pool('Ddt di acquisto')->id : Module::pool('Ddt di vendita')->id; - - echo ' -'; -} elseif ($azienda->id == $ddt->anagrafica->id) { - echo ' -
    - -
    - -'; -} - -// Informazioni sull'importabilità del DDT -$stati = $database->fetchArray('SELECT descrizione FROM `dt_statiddt` WHERE `is_fatturabile` = 1'); -foreach ($stati as $stato) { - $stati_importabili[] = $stato['descrizione']; -} - -$causali = $database->fetchArray('SELECT descrizione FROM `dt_causalet` WHERE `is_importabile` = 1'); -foreach ($causali as $causale) { - $causali_importabili[] = $causale['descrizione']; -} - -echo ' -
    - -
    '; diff --git a/modules/ddt/crea_documento.php b/modules/ddt/crea_documento.php deleted file mode 100755 index 18b78f13b..000000000 --- a/modules/ddt/crea_documento.php +++ /dev/null @@ -1,56 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\DDT\DDT; - -$documento = DDT::find($id_record); - -$module = Modules::get($id_module); -if ($documento->reversed) { - if ($module['name'] == 'Ddt di vendita') { - $final_module = 'Fatture di acquisto'; - $dir = 'uscita'; - } else { - $final_module = 'Fatture di vendita'; - $dir = 'entrata'; - } -} elseif ($module['name'] == 'Ddt di vendita') { - $final_module = 'Fatture di vendita'; - $dir = 'entrata'; -} else { - $final_module = 'Fatture di acquisto'; - $dir = 'uscita'; -} - -$options = [ - 'op' => 'add_documento', - 'type' => 'ddt', - 'module' => $final_module, - 'serials' => true, - 'button' => tr('Aggiungi'), - 'dir' => $dir, - 'create_document' => true, - 'documento' => $documento, - 'tipo_documento_finale' => $tipo_documento_finale, - 'reversed' => $documento->reversed, -]; - -echo App::load('importa.php', [], $options, true); diff --git a/modules/ddt/edit.php b/modules/ddt/edit.php deleted file mode 100755 index 6c4f93c9f..000000000 --- a/modules/ddt/edit.php +++ /dev/null @@ -1,531 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$block_edit = $record['flag_completato']; - -$module = Modules::get($id_module); - -if ($module['name'] == 'Ddt di vendita') { - $dir = 'entrata'; -} else { - $dir = 'uscita'; -} - -?> -
    - - - - - -
    -
    -

    -
    - -
    - fetchArray('SELECT piva, codice_fiscale, citta, indirizzo, cap, provincia FROM an_anagrafiche WHERE idanagrafica='.prepare($record['idanagrafica'])); - $campi_mancanti = []; - - if ($rs2[0]['piva'] == '') { - if ($rs2[0]['codice_fiscale'] == '') { - array_push($campi_mancanti, 'codice fiscale'); - } - } - if ($rs2[0]['citta'] == '') { - array_push($campi_mancanti, 'citta'); - } - if ($rs2[0]['indirizzo'] == '') { - array_push($campi_mancanti, 'indirizzo'); - } - if ($rs2[0]['cap'] == '') { - array_push($campi_mancanti, 'C.A.P.'); - } - - if (sizeof($campi_mancanti) > 0) { - echo "
    Prima di procedere alla stampa completa i seguenti campi dell'anagrafica:
    ".implode(', ', $campi_mancanti).'
    - '.Modules::link('Anagrafiche', $record['idanagrafica'], tr('Vai alla scheda anagrafica'), null).'
    '; - } - } - ?> - - -
    - - {[ "type": "span", "label": "'.tr('Numero ddt').'", "class": "text-center", "value": "$numero$" ]} -
    '; - } - ?> - -
    - {[ "type": "text", "label": "", "name": "numero_esterno", "class": "text-center", "value": "$numero_esterno$" ]} -
    - -
    - {[ "type": "date", "label": "", "name": "data", "required": 1, "value": "$data$" ]} -
    - -
    - - {[ "type": "select", "label": "", "name": "idstatoddt", "required": 1, "values": "query=SELECT * FROM dt_statiddt", "value": "$idstatoddt$", "extra": "readonly", "class": "unblockable" ]} - - {[ "type": "select", "label": "", "name": "idstatoddt", "required": 1, "values": "query=SELECT * FROM dt_statiddt WHERE descrizione IN('Bozza', 'Evaso', 'Parzialmente evaso')", "value": "$idstatoddt$", "class": "unblockable" ]} - - {[ "type": "select", "label": "", "name": "idstatoddt", "required": 1, "values": "query=SELECT * FROM dt_statiddt", "value": "$idstatoddt$", "class": "unblockable" ]} - -
    -
    - -
    -
    - - {[ "type": "select", "label": "", "name": "idanagrafica", "required": 1, "value": "$idanagrafica$", "ajax-source": "clienti_fornitori" ]} -
    -'; - if (!empty($record['idreferente'])) { - echo Plugins::link('Referenti', $record['idanagrafica'], null, null, 'class="pull-right"'); - } - echo ' - {[ "type": "select", "label": "'.tr('Referente').'", "name": "idreferente", "value": "$idreferente$", "ajax-source": "referenti", "select-options": {"idanagrafica": '.$record['idanagrafica'].'} ]} -
    '; - - // Conteggio numero articoli ddt in uscita - $articolo = $dbo->fetchArray('SELECT mg_articoli.id FROM ((mg_articoli INNER JOIN dt_righe_ddt ON mg_articoli.id=dt_righe_ddt.idarticolo) INNER JOIN dt_ddt ON dt_ddt.id=dt_righe_ddt.idddt) WHERE dt_ddt.id='.prepare($id_record)); - $id_modulo_anagrafiche = Modules::get('Anagrafiche')['id']; - $id_plugin_sedi = Plugins::get('Sedi')['id']; - if ($dir == 'entrata') { - echo ' -
    - {[ "type": "select", "label": "'.tr('Partenza merce').'", "name": "idsede_partenza", "ajax-source": "sedi_azienda", "value": "$idsede_partenza$", "readonly": "'.(sizeof($articolo) ? 1 : 0).'", "help": "'.tr("Sedi di partenza dell'azienda").'" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Destinazione merce').'", "name": "idsede_destinazione", "ajax-source": "sedi", "select-options": {"idanagrafica": '.$record['idanagrafica'].'}, "value": "$idsede_destinazione$", "help": "'.tr('Sedi del destinatario').'", "icon-after": "add|'.$id_modulo_anagrafiche.'|id_plugin='.$id_plugin_sedi.'&id_parent='.$record['idanagrafica'].'||'.(intval($block_edit) ? 'disabled' : '').'" ]} -
    '; - } else { - echo ' -
    - {[ "type": "select", "label": "'.tr('Partenza merce').'", "name": "idsede_partenza", "ajax-source": "sedi", "select-options": {"idanagrafica": '.$record['idanagrafica'].'}, "value": "$idsede_partenza$", "help": "'.tr('Sedi del mittente').'", "icon-after": "add|'.$id_modulo_anagrafiche.'|id_plugin='.$id_plugin_sedi.'&id_parent='.$record['idanagrafica'].'||'.(intval($block_edit) ? 'disabled' : '').'" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Destinazione merce').'", "name": "idsede_destinazione", "ajax-source": "sedi_azienda", "value": "$idsede_destinazione$", "help": "'.tr("Sedi di arrivo dell'azienda").'" ]} -
    '; - } - ?> -
    -
    - -
    -
    - {[ "type": "select", "label": "", "name": "idaspettobeni", "value": "$idaspettobeni$", "ajax-source": "aspetto-beni", "icon-after": "add||||" ]} -
    - -
    - - {[ "type": "select", "label": "", "name": "idcausalet", "required": 1, "value": "$idcausalet$", "ajax-source": "causali", "icon-after": "add||||", "help": "" ]} -
    - -
    - {[ "type": "select", "label": "", "name": "idspedizione", "placeholder": "-", "values": "query=SELECT id, descrizione, esterno FROM dt_spedizione ORDER BY descrizione ASC", "value": "$idspedizione$" ]} -
    - -
    - {[ "type": "text", "label": "", "name": "n_colli", "value": "$n_colli$" ]} -
    -
    - -
    -
    - {[ "type": "select", "label": "", "name": "idpagamento", "ajax-source": "pagamenti", "value": "$idpagamento$" ]} -
    - -
    - {[ "type": "select", "label": "", "name": "idporto", "placeholder": "-", "help": "
  • Franco: pagamento del trasporto a carico del mittente
  • Assegnato: pagamento del trasporto a carico del destinatario
  • '); ?>", "values": "query=SELECT id, descrizione FROM dt_porto ORDER BY descrizione ASC", "value": "$idporto$" ]} -
    - -
    - selectOne('dt_spedizione', 'esterno', [ - 'id' => $record['idspedizione'], - ])['esterno']; - ?> - {[ "type": "select", "label": "", "name": "idvettore", "ajax-source": "vettori", "value": "$idvettore$", "disabled": , "required": , "icon-after": "add||tipoanagrafica=Vettore&readonly_tipo=1|btn_idvettore|" ]} -
    - -
    - {[ "type": "timestamp", "label": "", "name": "data_ora_trasporto", "value": "$data_ora_trasporto$", "help": "" ]} -
    - - -
    - -
    - {[ "type": "number", "label": "'.tr('Peso').'", "name": "peso", "value": "$peso$", "readonly": "'.intval(empty($record['peso_manuale'])).'", "help": "'.tr('Il valore del campo Peso viene calcolato in automatico sulla base degli articoli inseriti nel documento, a meno dell\'impostazione di un valore manuale in questo punto').'" ]} - -
    - -
    - {[ "type": "checkbox", "label": "'.tr('Modifica peso').'", "name": "peso_manuale", "value":"$peso_manuale$", "help": "'.tr('Seleziona per modificare manualmente il campo Peso').'", "placeholder": "'.tr('Modifica peso').'" ]} -
    - -
    - {[ "type": "number", "label": "'.tr('Volume').'", "name": "volume", "value": "$volume$", "readonly": "'.intval(empty($record['volume_manuale'])).'", "help": "'.tr('Il valore del campo volume viene calcolato in automatico sulla base degli articoli inseriti nel documento, a meno dell\'impostazione di un valore manuale in questo punto').'" ]} - -
    - -
    - {[ "type": "checkbox", "label": "'.tr('Modifica volume').'", "name": "volume_manuale", "value":"$volume_manuale$", "help": "'.tr('Seleziona per modificare manualmente il campo volume').'", "placeholder": "'.tr('Modifica volume').'" ]} -
    - - -
    -
    - {[ "type": "number", "label": "'.('Sconto finale').'", "name": "sconto_finale", "value": "'.($ddt->sconto_finale_percentuale ?: $ddt->sconto_finale).'", "icon-after": "choice|untprc|'.(empty($ddt->sconto_finale) ? 'PRC' : 'UNT').'", "help": "'.tr('Sconto finale, utilizzabile per applicare sconti sul Netto a pagare del documento').'." ]} -
    -
    '; -} - -?> -
    -
    - {[ "type": "textarea", "label": "", "name": "note", "value": "$note$" ]} -
    -
    - -
    -
    - {[ "type": "textarea", "label": "", "name": "note_aggiuntive", "help": "", "value": "$note_aggiuntive$" ]} -
    -
    - - - - - - -
    -
    -
    -

    - - -
    - -
    -

    -
    -
    -
    -
    -
    - {[ "type": "text", "label": "", "name": "id_documento_fe", "required": 0, "help": "Obbligatorio per valorizzare CIG/CUP. È possible inserire:
    • N. determina
    • RDO
    • Ordine MEPA
    '); ?>", "value": "$id_documento_fe$", "maxlength": 20 ]} -
    - -
    - {[ "type": "text", "label": "", "name": "num_item", "required": 0, "value": "$num_item$", "maxlength": 15 ]} -
    -
    -
    -
    - {[ "type": "text", "label": "", "name": "codice_cig", "required": 0, "value": "$codice_cig$", "maxlength": 15 ]} -
    - -
    - {[ "type": "text", "label": "", "name": "codice_cup", "required": 0, "value": "$codice_cup$", "maxlength": 15 ]} -
    -
    -
    -
    -
    -
    -
    - - -
    -
    -

    -
    - -
    -
    - 0)'; - $ordini = $dbo->fetchArray($ordini_query)[0]['tot']; - - $ddt_query = 'SELECT COUNT(*) AS tot FROM dt_ddt WHERE idstatoddt IN (SELECT id FROM dt_statiddt WHERE descrizione IN(\'Evaso\', \'Parzialmente evaso\', \'Parzialmente fatturato\')) AND idtipoddt=(SELECT id FROM or_tipiordine WHERE dir="'.($dir == 'entrata' ? 'uscita' : 'entrata').'") AND dt_ddt.id IN (SELECT idddt FROM dt_righe_ddt WHERE dt_righe_ddt.idddt = dt_ddt.id AND (qta - qta_evasa) > 0)'; - $ddt = $dbo->fetchArray($ddt_query)[0]['tot']; - echo ' - - '.tr('Ddt').' - '; - - echo ' - - '.tr('Ordine').' - '; - - echo ' - '; - - echo ' - '; - - echo ' - '; - - echo ' - '; - - echo ' - '; -} - -echo ' -
    -
    -
    - -
    -
    -
    -
    -
    - -{( "name": "filelist_and_upload", "id_module": "$id_module$", "id_record": "$id_record$" )} - -{( "name": "log_email", "id_module": "$id_module$", "id_record": "$id_record$" )} - -'; - -// Collegamenti diretti -// Fatture collegate a questo ddt -$elementi = $dbo->fetchArray('SELECT `co_documenti`.*, `co_tipidocumento`.`descrizione` AS tipo_documento, `co_tipidocumento`.`dir` FROM `co_documenti` JOIN `co_tipidocumento` ON `co_tipidocumento`.`id` = `co_documenti`.`idtipodocumento` WHERE `co_documenti`.`id` IN (SELECT `iddocumento` FROM `co_righe_documenti` WHERE `idddt` = '.prepare($id_record).') ORDER BY `data`'); - -if (!empty($elementi)) { - echo ' -
    -
    -

    '.tr('Documenti collegati: _NUM_', [ - '_NUM_' => count($elementi), - ]).'

    -
    - -
    -
    -
    -
      '; - - foreach ($elementi as $fattura) { - $descrizione = tr('_DOC_ num. _NUM_ del _DATE_', [ - '_DOC_' => $fattura['tipo_documento'], - '_NUM_' => !empty($fattura['numero_esterno']) ? $fattura['numero_esterno'] : $fattura['numero'], - '_DATE_' => Translator::dateToLocale($fattura['data']), - ]); - - $modulo = ($fattura['dir'] == 'entrata') ? 'Fatture di vendita' : 'Fatture di acquisto'; - $id = $fattura['id']; - - echo ' -
    • '.Modules::link($modulo, $id, $descrizione).'
    • '; - } - - echo ' -
    -
    -
    '; -} - -if (!empty($elementi)) { - echo ' -
    - '.tr('Eliminando questo documento si potrebbero verificare problemi nelle altre sezioni del gestionale').'. -
    '; -} - -?> - -sedi)) { - ?> - - - -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Anagrafiche\Anagrafica; -use Modules\DDT\DDT; - -$azienda = Anagrafica::find(setting('Azienda predefinita')); - -if ($module['name'] == 'Ddt di vendita') { - $dir = 'entrata'; -} else { - $dir = 'uscita'; -} - -if (isset($id_record)) { - $ddt = DDT::with('tipo', 'stato')->find($id_record); - - $record = $dbo->fetchOne('SELECT dt_ddt.*, - dt_ddt.id AS idddt, - dt_statiddt.descrizione AS `stato`, - dt_statiddt.completato AS `flag_completato`, - dt_tipiddt.descrizione AS `descrizione_tipodoc`, - an_anagrafiche.tipo AS tipo_anagrafica - FROM dt_ddt - LEFT OUTER JOIN dt_statiddt ON dt_ddt.idstatoddt=dt_statiddt.id - INNER JOIN an_anagrafiche ON dt_ddt.idanagrafica=an_anagrafiche.idanagrafica - INNER JOIN dt_tipiddt ON dt_ddt.idtipoddt=dt_tipiddt.id - WHERE dt_ddt.id='.prepare($id_record)); - - if (!empty($record)) { - $record['idporto'] = $record['idporto'] ?: $dbo->fetchOne('SELECT id FROM dt_porto WHERE predefined = 1')['id']; - $record['idcausalet'] = $record['idcausalet'] ?: $dbo->fetchOne('SELECT id FROM dt_causalet WHERE predefined = 1')['id']; - $record['idspedizione'] = $record['idspedizione'] ?: $dbo->fetchOne('SELECT id FROM dt_spedizione WHERE predefined = 1')['id']; - } - - // Se la sede del ddt non è di mia competenza, blocco il ddt in modifica - $field_name = ($dir == 'entrata') ? 'idsede_partenza' : 'idsede_destinazione'; - if (!Auth::admin() && !in_array($record[$field_name], $user->sedi)) { - $record['flag_completato'] = 1; - } -} diff --git a/modules/ddt/modutil.php b/modules/ddt/modutil.php deleted file mode 100644 index e28e1624c..000000000 --- a/modules/ddt/modutil.php +++ /dev/null @@ -1,215 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\DDT\DDT; - -/** - * Funzione per generare un nuovo numero per il ddt. - * - * @deprecated 2.4.5 - */ -function get_new_numeroddt($data) -{ - global $dir; - - return DDT::getNextNumero($data, $dir); -} - -/** - * Funzione per calcolare il numero secondario successivo utilizzando la maschera dalle impostazioni. - * - * @deprecated 2.4.5 - */ -function get_new_numerosecondarioddt($data) -{ - global $dir; - - return DDT::getNextNumeroSecondario($data, $dir); -} - -/** - * Calcolo imponibile ddt (totale_righe - sconto). - * - * @deprecated 2.4.5 - */ -function get_imponibile_ddt($id_ddt) -{ - $ddt = DDT::find($id_ddt); - - return $ddt->imponibile; -} - -/** - * Calcolo totale ddt (imponibile + iva). - * - * @deprecated 2.4.5 - */ -function get_totale_ddt($id_ddt) -{ - $ddt = DDT::find($id_ddt); - - return $ddt->totale; -} - -/** - * Calcolo netto a pagare ddt (totale - ritenute - bolli). - * - * @deprecated 2.4.5 - */ -function get_netto_ddt($id_ddt) -{ - $ddt = DDT::find($id_ddt); - - return $ddt->netto; -} - -/** - * Calcolo iva detraibile ddt. - * - * @deprecated 2.4.5 - */ -function get_ivadetraibile_ddt($id_ddt) -{ - $ddt = DDT::find($id_ddt); - - return $ddt->iva_detraibile; -} - -/** - * Calcolo iva indetraibile ddt. - * - * @deprecated 2.4.5 - */ -function get_ivaindetraibile_ddt($id_ddt) -{ - $ddt = DDT::find($id_ddt); - - return $ddt->iva_indetraibile; -} - -/** - * Ricalcola i costi aggiuntivi in ddt (rivalsa inps, ritenuta d'acconto, marca da bollo) - * Deve essere eseguito ogni volta che si aggiunge o toglie una riga - * $idddt int ID del ddt - * $idrivalsainps int ID della rivalsa inps da applicare. Se omesso viene utilizzata quella impostata di default - * $idritenutaacconto int ID della ritenuta d'acconto da applicare. Se omesso viene utilizzata quella impostata di default - * $bolli float Costi aggiuntivi delle marche da bollo. Se omesso verrà usata la cifra predefinita. - */ -function ricalcola_costiagg_ddt($idddt, $idrivalsainps = '', $idritenutaacconto = '', $bolli = '') -{ - global $dir; - - $dbo = database(); - - // Se ci sono righe nel ddt faccio i conteggi, altrimenti azzero gli sconti e le spese aggiuntive (inps, ritenuta, marche da bollo) - $query = "SELECT COUNT(id) AS righe FROM dt_righe_ddt WHERE idddt='$idddt'"; - $rs = $dbo->fetchArray($query); - if ($rs[0]['righe'] > 0) { - $totale_imponibile = get_imponibile_ddt($idddt); - $totale_ddt = get_totale_ddt($idddt); - - // Leggo gli id dei costi aggiuntivi - if ($dir == 'uscita') { - $query2 = "SELECT idrivalsainps, idritenutaacconto, bollo FROM dt_ddt WHERE id='$idddt'"; - $rs2 = $dbo->fetchArray($query2); - $idrivalsainps = $rs2[0]['idrivalsainps']; - $idritenutaacconto = $rs2[0]['idritenutaacconto']; - $bollo = $rs2[0]['bollo']; - } - - // Leggo la rivalsa inps se c'è (per i ddt di vendita lo leggo dalle impostazioni) - if ($dir == 'entrata') { - if (!empty($idrivalsainps)) { - $idrivalsainps = setting('Percentuale rivalsa'); - } - } - - $query = "SELECT percentuale FROM co_rivalse WHERE id='".$idrivalsainps."'"; - $rs = $dbo->fetchArray($query); - $rivalsainps = $totale_imponibile / 100 * $rs[0]['percentuale']; - - // Leggo l'iva predefinita per calcolare l'iva aggiuntiva sulla rivalsa inps - $qi = "SELECT percentuale FROM co_iva WHERE id='".setting('Iva predefinita')."'"; - $rsi = $dbo->fetchArray($qi); - $iva_rivalsainps = $rivalsainps / 100 * $rsi[0]['percentuale']; - - // Aggiorno la rivalsa inps - $dbo->query("UPDATE dt_ddt SET rivalsainps='$rivalsainps', iva_rivalsainps='$iva_rivalsainps' WHERE id='$idddt'"); - - $totale_ddt = get_totale_ddt($idddt); - - // Leggo la ritenuta d'acconto se c'è (per i ddt di vendita lo leggo dalle impostazioni) - if (!empty($idritenutaacconto)) { - if ($dir == 'entrata') { - $idritenutaacconto = setting("Percentuale ritenuta d'acconto"); - } - } - - $query = "SELECT percentuale FROM co_ritenutaacconto WHERE id='".$idritenutaacconto."'"; - $rs = $dbo->fetchArray($query); - $ritenutaacconto = $totale_ddt / 100 * $rs[0]['percentuale']; - $netto_a_pagare = $totale_ddt - $ritenutaacconto; - - // Leggo la marca da bollo se c'è e se il netto a pagare supera la soglia - $bolli = str_replace(',', '.', $bolli); - $bolli = floatval($bolli); - if ($dir == 'uscita') { - if ($bolli != 0.00) { - $bolli = str_replace(',', '.', $bolli); - if (abs($bolli) > 0 && abs($netto_a_pagare > setting("Soglia minima per l'applicazione della marca da bollo"))) { - $marca_da_bollo = str_replace(',', '.', $bolli); - } else { - $marca_da_bollo = 0.00; - } - } - } else { - $marca_da_bollo = 0.00; - } - - $dbo->query("UPDATE dt_ddt SET ritenutaacconto='$ritenutaacconto', bollo='$marca_da_bollo' WHERE id='$idddt'"); - } else { - $dbo->query("UPDATE dt_ddt SET ritenutaacconto='0', bollo='0', rivalsainps='0', iva_rivalsainps='0' WHERE id='$idddt'"); - } -} - -/** - * Restituisce lo stato del ddt in base alle righe. - */ -function get_stato_ddt($idddt) -{ - $dbo = database(); - - $rs = $dbo->fetchArray('SELECT SUM(qta) AS qta, SUM(qta_evasa) AS qta_evasa FROM dt_righe_ddt GROUP BY idddt HAVING idddt='.prepare($idddt)); - - if ($rs[0]['qta'] == 0) { - return 'Bozza'; - } else { - if ($rs[0]['qta_evasa'] > 0) { - if ($rs[0]['qta'] > $rs[0]['qta_evasa']) { - return 'Parzialmente fatturato'; - } elseif ($rs[0]['qta'] == $rs[0]['qta_evasa']) { - return 'Fatturato'; - } - } else { - return 'Evaso'; - } - } -} diff --git a/modules/ddt/row-add.php b/modules/ddt/row-add.php deleted file mode 100755 index fe1d1b7bc..000000000 --- a/modules/ddt/row-add.php +++ /dev/null @@ -1,90 +0,0 @@ -. - */ - -use Modules\DDT\DDT; - -include_once __DIR__.'/../../core.php'; - -// Info contratto -$documento = DDT::find($id_record); -$dir = $documento->direzione; - -// Impostazioni per la gestione -$options = [ - 'op' => 'manage_riga', - 'action' => 'add', - 'dir' => $documento->direzione, - 'idanagrafica' => $documento['idanagrafica'], - 'totale_imponibile_documento' => $documento->totale_imponibile, - 'totale_documento' => $documento->totale, - 'select-options' => [ - 'articoli' => [ - 'idanagrafica' => $documento->idanagrafica, - 'dir' => $documento->direzione, - 'idsede_partenza' => $documento->idsede_partenza, - 'idsede_destinazione' => $documento->idsede_destinazione, - 'permetti_movimento_a_zero' => intval($documento->direzione == 'uscita'), - ], - ], -]; - -// Dati di default -$result = [ - 'descrizione' => '', - 'qta' => 1, - 'um' => '', - 'prezzo' => 0, - 'sconto_unitario' => 0, - 'tipo_sconto' => '', - 'idiva' => '', -]; - -// Leggo l'iva predefinita per l'anagrafica e se non c'è leggo quella predefinita generica -$iva = $dbo->fetchArray('SELECT idiva_'.($dir == 'uscita' ? 'acquisti' : 'vendite').' AS idiva FROM an_anagrafiche WHERE idanagrafica='.prepare($documento['idanagrafica'])); -$result['idiva'] = $iva[0]['idiva'] ?: setting('Iva predefinita'); - -// Importazione della gestione dedicata -$file = 'riga'; -if (get('is_descrizione') !== null) { - $file = 'descrizione'; - - $options['op'] = 'manage_descrizione'; -} elseif (get('is_articolo') !== null) { - $file = 'articolo'; - - // Aggiunta sconto di default da listino per le vendite - $listino = $dbo->fetchOne('SELECT prc_guadagno FROM an_anagrafiche INNER JOIN mg_listini ON an_anagrafiche.idlistino_vendite=mg_listini.id WHERE idanagrafica='.prepare($documento['idanagrafica'])); - - if (!empty($listino['prc_guadagno'])) { - $result['sconto_percentuale'] = $listino['prc_guadagno']; - $result['tipo_sconto'] = 'PRC'; - } - - $options['op'] = 'manage_articolo'; -} elseif (get('is_sconto') !== null) { - $file = 'sconto'; - - $options['op'] = 'manage_sconto'; -} elseif (get('is_barcode') !== null) { - $file = 'barcode'; - - $options['op'] = 'manage_barcode'; -} - -echo App::load($file.'.php', $result, $options); diff --git a/modules/ddt/row-edit.php b/modules/ddt/row-edit.php deleted file mode 100755 index 5dc305125..000000000 --- a/modules/ddt/row-edit.php +++ /dev/null @@ -1,70 +0,0 @@ -. - */ - -use Modules\DDT\DDT; - -include_once __DIR__.'/../../core.php'; - -// Info contratto -$documento = DDT::find($id_record); - -// Impostazioni per la gestione -$options = [ - 'op' => 'manage_riga', - 'action' => 'edit', - 'dir' => $documento->direzione, - 'idanagrafica' => $documento['idanagrafica'], - 'totale_imponibile_documento' => $documento->totale_imponibile, - 'totale_documento' => $documento->totale, - 'select-options' => [ - 'articoli' => [ - 'idanagrafica' => $documento->idanagrafica, - 'dir' => $documento->direzione, - 'idsede_partenza' => $documento->idsede_partenza, - 'idsede_destinazione' => $documento->idsede_destinazione, - 'permetti_movimento_a_zero' => intval($documento->direzione == 'uscita'), -], - ], -]; - -// Dati della riga -$id_riga = get('riga_id'); -$type = get('riga_type'); -$riga = $documento->getRiga($type, $id_riga); - -$result = $riga->toArray(); -$result['prezzo'] = $riga->prezzo_unitario; - -// Importazione della gestione dedicata -$file = 'riga'; -if ($riga->isDescrizione()) { - $file = 'descrizione'; - - $options['op'] = 'manage_descrizione'; -} elseif ($riga->isArticolo()) { - $file = 'articolo'; - - $options['op'] = 'manage_articolo'; -} elseif ($riga->isSconto()) { - $file = 'sconto'; - - $options['op'] = 'manage_sconto'; -} - -echo App::load($file.'.php', $result, $options); diff --git a/modules/ddt/row-list.php b/modules/ddt/row-list.php deleted file mode 100755 index 4d09ca89f..000000000 --- a/modules/ddt/row-list.php +++ /dev/null @@ -1,393 +0,0 @@ -. - */ - -include_once __DIR__.'/init.php'; - -echo ' -
    - - - - - - - - - - - - - - '; - -// Righe documento -$righe = $ddt->getRighe(); -$num = 0; -foreach ($righe as $riga) { - ++$num; - - $extra = ''; - $mancanti = 0; - - // Individuazione dei seriali - if ($riga->isArticolo() && !empty($riga->abilita_serial)) { - $serials = $riga->serials; - $mancanti = abs($riga->qta) - count($serials); - - if ($mancanti > 0) { - $extra = 'class="warning"'; - } else { - $mancanti = 0; - } - } - - echo ' - - - - '; - - if ($riga->isDescrizione()) { - echo ' - - - - '; - } else { - // Quantità e unità di misura - echo ' - '; - - // Prezzi unitari - echo ' - '; - - // Iva - echo ' - '; - - // Importo - echo ' - '; - } - - // Possibilità di rimuovere una riga solo se il ddt non è evaso - echo ' - - '; -} - -echo ' - '; - -// Calcoli -$imponibile = abs($ddt->imponibile); -$sconto = $ddt->sconto; -$totale_imponibile = abs($ddt->totale_imponibile); -$iva = abs($ddt->iva); -$totale = abs($ddt->totale); -$sconto_finale = $ddt->getScontoFinale(); -$netto_a_pagare = $ddt->netto; - -// IMPONIBILE -echo ' - - - - - - - '; - -// SCONTO -if (!empty($sconto)) { - echo ' - - - - - - - '; - - // TOTALE IMPONIBILE - echo ' - - - - - - - '; -} - -// IVA -echo ' - - - - - - - '; - -// TOTALE -echo ' - - - - - - - '; - -// SCONTO FINALE -if (!empty($sconto_finale)) { - echo ' - - - - - '; -} - -// NETTO A PAGARE -if ($totale != $netto_a_pagare) { - echo ' - - - - - '; -} - -echo ' -
    '.tr('#').''.tr('Descrizione').''.tr('Q.tà').' '.tr('Prezzo unitario').''.tr('Iva unitaria').''.tr('Importo').'
    - '.$num.' - - '; - - $numero_riferimenti_riga = $riga->referenceTargets()->count(); - $numero_riferimenti_collegati = $riga->referenceSources()->count(); - $riferimenti_presenti = $numero_riferimenti_riga; - $testo_aggiuntivo = $riferimenti_presenti ? $numero_riferimenti_riga : ''; - echo ' - '; - - // Aggiunta dei riferimenti ai documenti - if ($riga->hasOriginalComponent()) { - echo ' -
    '.reference($riga->getOriginalComponent()->getDocument(), tr('Origine')); - } - echo ' -
    '; - - if ($riga->isArticolo()) { - echo Modules::link('Articoli', $riga->idarticolo, $riga->codice.' - '.$riga->descrizione); - } else { - echo nl2br($riga->descrizione); - } - - if ($riga->isArticolo() && !empty($riga->abilita_serial)) { - if (!empty($mancanti)) { - echo ' -
    '.tr('_NUM_ serial mancanti', [ - '_NUM_' => $mancanti, - ]).''; - } - if (!empty($serials)) { - echo ' -
    '.tr('SN').': '.implode(', ', $serials); - } - } - - echo ' -
    - '.numberFormat($riga->qta_rimanente, 'qta').' / '.numberFormat($riga->qta, 'qta').' '.$riga->um.' - - '.moneyFormat($riga->prezzo_unitario_corrente); - - if ($dir == 'entrata' && $riga->costo_unitario != 0) { - echo ' -
    - '.tr('Acquisto').': '.moneyFormat($riga->costo_unitario).' - '; - } - - if (abs($riga->sconto_unitario) > 0) { - $text = discountInfo($riga); - - echo ' -
    '.$text.''; - } - - echo ' -
    - '.moneyFormat($riga->iva_unitaria_scontata).' -
    '.$riga->aliquota->descrizione.(($riga->aliquota->esente) ? ' ('.$riga->aliquota->codice_natura_fe.')' : null).' -
    - '.moneyFormat($riga->importo).' - '; - - if ($record['flag_completato'] == 0) { - echo ' -
    '; - - if ($riga->isArticolo() && !empty($riga->abilita_serial)) { - echo ' - - - '; - } - - echo ' - - - - - - - - - - - -
    '; - } - - echo ' -
    - '.tr('Imponibile', [], ['upper' => true]).': - - '.moneyFormat($imponibile, 2).' -
    - '.tr('Sconto/maggiorazione', [], ['upper' => true]).': - - '.moneyFormat($sconto, 2).' -
    - '.tr('Totale imponibile', [], ['upper' => true]).': - - '.moneyFormat($totale_imponibile, 2).' -
    - '.tr('IVA', [], ['upper' => true]).': - - '.moneyFormat($iva, 2).' -
    - '.tr('Totale', [], ['upper' => true]).': - - '.moneyFormat($totale, 2).' -
    - '.tr('Sconto finale', [], ['upper' => true]).': - - '.moneyFormat($sconto_finale, 2).' -
    - '.tr('Netto a pagare', [], ['upper' => true]).': - - '.moneyFormat($netto_a_pagare, 2).' -
    -
    '; - -echo ' -'; diff --git a/modules/ddt/src/Components/Articolo.php b/modules/ddt/src/Components/Articolo.php deleted file mode 100755 index a3543d9cb..000000000 --- a/modules/ddt/src/Components/Articolo.php +++ /dev/null @@ -1,30 +0,0 @@ -. - */ - -namespace Modules\DDT\Components; - -use Common\Components\Article; - -class Articolo extends Article -{ - use RelationTrait; - - protected $table = 'dt_righe_ddt'; - protected $serialRowID = 'ddt'; -} diff --git a/modules/ddt/src/Components/Descrizione.php b/modules/ddt/src/Components/Descrizione.php deleted file mode 100755 index d8bcde48e..000000000 --- a/modules/ddt/src/Components/Descrizione.php +++ /dev/null @@ -1,29 +0,0 @@ -. - */ - -namespace Modules\DDT\Components; - -use Common\Components\Description; - -class Descrizione extends Description -{ - use RelationTrait; - - protected $table = 'dt_righe_ddt'; -} diff --git a/modules/ddt/src/Components/RelationTrait.php b/modules/ddt/src/Components/RelationTrait.php deleted file mode 100755 index 466f49ca4..000000000 --- a/modules/ddt/src/Components/RelationTrait.php +++ /dev/null @@ -1,47 +0,0 @@ -. - */ - -namespace Modules\DDT\Components; - -use Modules\DDT\DDT; - -trait RelationTrait -{ - public function getDocumentID() - { - return 'idddt'; - } - - public function document() - { - return $this->belongsTo(DDT::class, $this->getDocumentID()); - } - - public function ddt() - { - return $this->document(); - } - - public function getNettoAttribute() - { - $result = $this->totale; - - return $result; - } -} diff --git a/modules/ddt/src/Components/Riga.php b/modules/ddt/src/Components/Riga.php deleted file mode 100755 index bba6af4b6..000000000 --- a/modules/ddt/src/Components/Riga.php +++ /dev/null @@ -1,29 +0,0 @@ -. - */ - -namespace Modules\DDT\Components; - -use Common\Components\Row; - -class Riga extends Row -{ - use RelationTrait; - - protected $table = 'dt_righe_ddt'; -} diff --git a/modules/ddt/src/Components/Sconto.php b/modules/ddt/src/Components/Sconto.php deleted file mode 100755 index b24be6e49..000000000 --- a/modules/ddt/src/Components/Sconto.php +++ /dev/null @@ -1,29 +0,0 @@ -. - */ - -namespace Modules\DDT\Components; - -use Common\Components\Discount; - -class Sconto extends Discount -{ - use RelationTrait; - - protected $table = 'dt_righe_ddt'; -} diff --git a/modules/ddt/src/DDT.php b/modules/ddt/src/DDT.php deleted file mode 100755 index ea76f5584..000000000 --- a/modules/ddt/src/DDT.php +++ /dev/null @@ -1,323 +0,0 @@ -. - */ - -namespace Modules\DDT; - -use Auth; -use Common\Components\Component; -use Common\Document; -use Modules\Anagrafiche\Anagrafica; -use Modules\Fatture\Fattura; -use Traits\RecordTrait; -use Traits\ReferenceTrait; -use Util\Generator; - -class DDT extends Document -{ - use ReferenceTrait; - use RecordTrait; - - protected $table = 'dt_ddt'; - - protected $casts = [ - 'bollo' => 'float', - 'peso' => 'float', - 'volume' => 'float', - - 'sconto_finale' => 'float', - 'sconto_finale_percentuale' => 'float', - ]; - - protected $with = [ - 'tipo', - ]; - - /** - * Crea un nuovo ddt. - * - * @param string $data - * - * @return self - */ - public static function build(Anagrafica $anagrafica, Tipo $tipo_documento, $data) - { - $model = new static(); - - $user = Auth::user(); - - $stato_documento = Stato::where('descrizione', 'Bozza')->first(); - - $id_anagrafica = $anagrafica->id; - $direzione = $tipo_documento->dir; - - $database = database(); - - if ($direzione == 'entrata') { - $conto = 'vendite'; - } else { - $conto = 'acquisti'; - } - - // Tipo di pagamento e banca predefinite dall'anagrafica - $id_pagamento = $database->fetchOne('SELECT id FROM co_pagamenti WHERE id = :id_pagamento', [ - ':id_pagamento' => $anagrafica['idpagamento_'.$conto], - ])['id']; - - // Se il ddt è un ddt cliente e non è stato associato un pagamento predefinito al cliente leggo il pagamento dalle impostazioni - if ($direzione == 'entrata' && empty($id_pagamento)) { - $id_pagamento = setting('Tipo di pagamento predefinito'); - } - - $model->anagrafica()->associate($anagrafica); - $model->tipo()->associate($tipo_documento); - $model->stato()->associate($stato_documento); - - $model->save(); - - // Salvataggio delle informazioni - $model->data = $data; - - if (!empty($id_pagamento)) { - $model->idpagamento = $id_pagamento; - } - - $model->numero = static::getNextNumero($data, $direzione); - $model->numero_esterno = static::getNextNumeroSecondario($data, $direzione); - - // Imposto, come sede aziendale, la prima sede disponibile come utente - if ($direzione == 'entrata') { - $model->idsede_partenza = $user->sedi[0]; - } else { - $model->idsede_destinazione = $user->sedi[0]; - } - - $model->save(); - - return $model; - } - - /** - * Restituisce il nome del modulo a cui l'oggetto è collegato. - * - * @return string - */ - public function getModuleAttribute() - { - return $this->direzione == 'entrata' ? 'Ddt di vendita' : 'DDT di acquisto'; - } - - public function getDirezioneAttribute() - { - return $this->tipo->dir; - } - - public function isImportabile() - { - $database = database(); - $stati = $database->fetchArray('SELECT descrizione FROM `dt_statiddt` WHERE `is_fatturabile` = 1'); - foreach ($stati as $stato) { - $stati_importabili[] = $stato['descrizione']; - } - - $causale = $database->fetchOne('SELECT * FROM `dt_causalet` WHERE `id` = '.prepare($this->idcausalet)); - - return $causale['is_importabile'] && in_array($this->stato->descrizione, $stati_importabili); - } - - public function getReversedAttribute() - { - $database = database(); - $causale = $database->fetchOne('SELECT * FROM `dt_causalet` WHERE `id` = '.prepare($this->idcausalet)); - - return $causale['reversed']; - } - - /** - * Restituisce il peso calcolato sulla base degli articoli del documento. - * - * @return float - */ - public function getPesoCalcolatoAttribute() - { - $righe = $this->getRighe(); - - $peso_lordo = $righe->sum(function ($item) { - return $item->isArticolo() ? $item->articolo->peso_lordo * $item->qta : 0; - }); - - return $peso_lordo; - } - - /** - * Restituisce il volume calcolato sulla base degli articoli del documento. - * - * @return float - */ - public function getVolumeCalcolatoAttribute() - { - $righe = $this->getRighe(); - - $volume = $righe->sum(function ($item) { - return $item->isArticolo() ? $item->articolo->volume * $item->qta : 0; - }); - - return $volume; - } - - public function anagrafica() - { - return $this->belongsTo(Anagrafica::class, 'idanagrafica'); - } - - public function tipo() - { - return $this->belongsTo(Tipo::class, 'idtipoddt'); - } - - public function stato() - { - return $this->belongsTo(Stato::class, 'idstatoddt'); - } - - public function articoli() - { - return $this->hasMany(Components\Articolo::class, 'idddt'); - } - - public function righe() - { - return $this->hasMany(Components\Riga::class, 'idddt'); - } - - public function sconti() - { - return $this->hasMany(Components\Sconto::class, 'idddt'); - } - - public function descrizioni() - { - return $this->hasMany(Components\Descrizione::class, 'idddt'); - } - - /** - * Effettua un controllo sui campi del documento. - * Viene richiamato dalle modifiche alle righe del documento. - */ - public function triggerEvasione(Component $trigger) - { - parent::triggerEvasione($trigger); - - if (setting('Cambia automaticamente stato ddt fatturati')) { - $righe = $this->getRighe(); - $qta = $righe->sum('qta'); - $qta_evasa = $righe->sum('qta_evasa'); - $parziale = $qta != $qta_evasa; - - $fattura = Fattura::find($trigger->iddocumento); - if (!empty($fattura)) { - $righe_fatturate = $fattura->getRighe()->where('idddt', '=', $this->id); - $qta_fatturate = $righe_fatturate->sum('qta'); - $parziale_fatturato = $qta != $qta_fatturate; - } - - // Impostazione del nuovo stato - if ($qta_evasa == 0) { - $descrizione = 'Bozza'; - } elseif (empty($qta_fatturate)) { - $descrizione = $parziale ? 'Parzialmente evaso' : 'Evaso'; - } else { - $descrizione = $parziale_fatturato ? 'Parzialmente fatturato' : 'Fatturato'; - } - - $stato = Stato::where('descrizione', $descrizione)->first(); - $this->stato()->associate($stato); - $this->save(); - } - } - - // Metodi statici - - /** - * Calcola il nuovo numero di ddt. - * - * @param string $data - * @param string $direzione - * - * @return string - */ - public static function getNextNumero($data, $direzione) - { - $maschera = '#'; - - $ultimo = Generator::getPreviousFrom($maschera, 'dt_ddt', 'numero', [ - 'YEAR(data) = '.prepare(date('Y', strtotime($data))), - 'idtipoddt IN (SELECT id FROM dt_tipiddt WHERE dir = '.prepare($direzione).')', - ]); - $numero = Generator::generate($maschera, $ultimo); - - return $numero; - } - - /** - * Calcola il nuovo numero secondario di ddt. - * - * @param string $data - * @param string $direzione - * - * @return string - */ - public static function getNextNumeroSecondario($data, $direzione) - { - if ($direzione == 'uscita') { - return ''; - } - - $maschera = setting('Formato numero secondario ddt'); - - $ultimo = Generator::getPreviousFrom($maschera, 'dt_ddt', 'numero_esterno', [ - 'YEAR(data) = '.prepare(date('Y', strtotime($data))), - 'idtipoddt IN (SELECT id FROM dt_tipiddt WHERE dir = '.prepare($direzione).')', - ]); - $numero = Generator::generate($maschera, $ultimo, 1, Generator::dateToPattern($data)); - - return $numero; - } - - // Opzioni di riferimento - - public function getReferenceName() - { - return $this->tipo->descrizione; - } - - public function getReferenceNumber() - { - return $this->numero_esterno ?: $this->numero; - } - - public function getReferenceDate() - { - return $this->data; - } - - public function getReferenceRagioneSociale() - { - return $this->anagrafica->ragione_sociale; - } -} diff --git a/modules/ddt/src/Stato.php b/modules/ddt/src/Stato.php deleted file mode 100755 index 67a735329..000000000 --- a/modules/ddt/src/Stato.php +++ /dev/null @@ -1,35 +0,0 @@ -. - */ - -namespace Modules\DDT; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; - -class Stato extends Model -{ - use SimpleModelTrait; - - protected $table = 'dt_statiddt'; - - public function ddt() - { - return $this->hasMany(DDT::class, 'idstatoddt'); - } -} diff --git a/modules/ddt/src/Tipo.php b/modules/ddt/src/Tipo.php deleted file mode 100755 index 869bc3e7c..000000000 --- a/modules/ddt/src/Tipo.php +++ /dev/null @@ -1,35 +0,0 @@ -. - */ - -namespace Modules\DDT; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; - -class Tipo extends Model -{ - use SimpleModelTrait; - - protected $table = 'dt_tipiddt'; - - public function ddt() - { - return $this->hasMany(DDT::class, 'idtipoddt'); - } -} diff --git a/modules/ddt/variables.php b/modules/ddt/variables.php deleted file mode 100755 index 3dd2d7424..000000000 --- a/modules/ddt/variables.php +++ /dev/null @@ -1,31 +0,0 @@ -. - */ - -$r = $dbo->fetchOne('SELECT *, dt_ddt.idanagrafica, - IF( (an_referenti.email IS NOT NULL AND an_referenti.email!=""), an_referenti.email, an_anagrafiche.email) AS email -FROM dt_ddt INNER JOIN an_anagrafiche ON an_anagrafiche.idanagrafica=dt_ddt.idanagrafica LEFT OUTER JOIN an_referenti ON an_referenti.id=dt_ddt.idreferente WHERE dt_ddt.id='.prepare($id_record)); - -// Variabili da sostituire -return [ - 'email' => $r['email'], - 'numero' => empty($r['numero_esterno']) ? $r['numero'] : $r['numero_esterno'], - 'note' => $r['note'], - 'data' => Translator::dateToLocale($r['data']), - 'id_anagrafica' => $r['idanagrafica'], -]; diff --git a/modules/emails/actions.php b/modules/emails/actions.php deleted file mode 100755 index cf4d434b2..000000000 --- a/modules/emails/actions.php +++ /dev/null @@ -1,75 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -switch (post('op')) { - case 'add': - $dbo->insert('em_templates', [ - 'name' => post('name'), - 'id_module' => post('module'), - 'id_account' => post('smtp'), - 'subject' => post('subject'), - ]); - - $id_record = $dbo->lastInsertedID(); - - flash()->info(tr('Aggiunto nuovo template per le email!')); - - break; - - case 'update': - $dbo->update('em_templates', [ - 'name' => post('name'), - 'id_account' => post('smtp'), - 'icon' => post('icon'), - 'subject' => post('subject'), - 'reply_to' => post('reply_to'), - 'cc' => post('cc'), - 'bcc' => post('bcc'), - 'body' => $_POST['body'], // post('body'), - 'read_notify' => post('read_notify'), - ], ['id' => $id_record]); - - $dbo->sync('em_print_template', ['id_template' => $id_record], ['id_print' => (array) post('prints')]); - - flash()->info(tr('Informazioni salvate correttamente!')); - - break; - - case 'delete': - $dbo->query('UPDATE em_templates SET deleted_at = NOW() WHERE id='.prepare($id_record)); - - flash()->info(tr('Template delle email eliminato!')); - - break; - - case 'copy': - $dbo->query('CREATE TEMPORARY TABLE tmp SELECT * FROM em_templates WHERE id= '.prepare($id_record)); - $dbo->query('ALTER TABLE tmp DROP id'); - $dbo->query('INSERT INTO em_templates SELECT NULL,tmp. * FROM tmp'); - $id_record = $dbo->lastInsertedID(); - $dbo->query('DROP TEMPORARY TABLE tmp'); - - $dbo->query('UPDATE em_templates SET name = CONCAT (name, " (copia)") WHERE id = '.prepare($id_record)); - - flash()->info(tr('Template duplicato correttamente!')); - - break; -} diff --git a/modules/emails/add.php b/modules/emails/add.php deleted file mode 100755 index f2a9b0f5c..000000000 --- a/modules/emails/add.php +++ /dev/null @@ -1,55 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?> -
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "name", "required": 1 ]} -
    -
    - -
    -
    - {[ "type": "select", "label": "", "name": "module", "required": 1 , "values": "query=SELECT id, title AS descrizione FROM zz_modules WHERE enabled = 1" ]} -
    - -
    - {[ "type": "text", "label": "", "name": "subject" ]} -
    -
    - -
    -
    - {[ "type": "select", "label": "", "name": "smtp", "value": "$id_account$", "required": 1, "ajax-source": "smtp" ]} -
    -
    - - -
    -
    - -
    -
    -
    diff --git a/modules/emails/buttons.php b/modules/emails/buttons.php deleted file mode 100644 index e8acb1891..000000000 --- a/modules/emails/buttons.php +++ /dev/null @@ -1,30 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo ' -'; - -// Duplica template -echo ' -
    - - -
    '; diff --git a/modules/emails/edit.php b/modules/emails/edit.php deleted file mode 100755 index 73572e43e..000000000 --- a/modules/emails/edit.php +++ /dev/null @@ -1,175 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (!$record['predefined']) { - $attr = ''; -} else { - $attr = 'readonly'; - echo '
    '.tr('Alcune impostazioni non possono essere modificate per questo template.').'
    '; -} - -?> -
    - - - - -
    -
    -

    -
    - -
    -
    -
    - {[ "type": "text", "label": "", "name": "name", "value": "$name$", "required": 1, "extra": "" ]} -
    - -
    - {[ "type": "span", "label": "", "name": "module", "values": "query=SELECT id, title AS descrizione FROM zz_modules WHERE enabled = 1", "value": "" ]} -
    -
    - -
    -
    - {[ "type": "select", "label": "", "name": "smtp", "value": "$id_account$", "ajax-source": "smtp" ]} -
    - -
    - {[ "type": "checkbox", "label": "", "name": "read_notify", "value": "$read_notify$", "placeholder": "" ]} -
    -
    - -
    -
    - {[ "type": "text", "label": "", "name": "subject", "value": "$subject$" ]} -
    - -
    - - {[ "type": "text", "label": "", "name": "icon", "value": "" ,"help":"" ]} -
    -
    - -
    -
    - {[ "type": "text", "label": "", "name": "cc", "value": "$cc$", "help": "" ]} -
    - -
    - {[ "type": "text", "label": "", "name": "bcc", "value": "$bcc$", "help": "" ]} -
    - -
    - {[ "type": "email", "label": "", "name": "reply_to", "value": "$reply_to$", "help": "" ]} -
    -
    - -fetchArray('SELECT id_print FROM em_print_template WHERE id_template = '.prepare($id_record)); -$selected = array_column($selected_prints, 'id_print'); - -echo ' - -
    -
    - {[ "type": "select", "multiple": "1", "label": "'.tr('Stampe').'", "name": "prints[]", "value": "'.implode(',', $selected).'", "values": "query=SELECT id, title AS text FROM zz_prints WHERE id_module = '.prepare($record['id_module']).' AND enabled=1" ]} -
    -
    '; - -?> - -
    -
    - {[ "type": "ckeditor", "label": "", "name": "body", "value": "$body$" ]} -
    -
    - -getPlaceholders($id_record); - -echo ' - -
    -
    -

    '.tr('Variabili').'

    -
    - -
    '; - -if (!empty($variables)) { - echo ' -

    '.tr("Puoi utilizzare le seguenti variabili nell'oggetto e nel corpo della mail").':

    -
      '; - - foreach ($variables as $variable => $value) { - echo ' -
    • {'.$variable.'}
    • '; - } - - echo ' -
    '; -} else { - echo ' -

    '.tr('Non sono state definite variabili da utilizzare nel template').'.

    '; -} - -echo ' -
    -
    - -
    '; - -?> - -
    -
    - -
    - - '.tr('Questo template non può essere rimosso dal sistema perchè collegato alle seguenti newsletter:').' -
      '; - - foreach ($newsletters as $newsletter) { - echo ' -
    • '.Modules::link('Newsletter', $newsletter->id, $newsletter->name, null, '').'
    • '; - } - - echo ' -
    - '; -} elseif (!$record['predefined']) { - ?> - - - - - diff --git a/modules/emails/init.php b/modules/emails/init.php deleted file mode 100755 index f0fec6fed..000000000 --- a/modules/emails/init.php +++ /dev/null @@ -1,29 +0,0 @@ -. - */ - -use Modules\Newsletter\Newsletter; - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT * FROM em_templates WHERE id='.prepare($id_record).' AND deleted_at IS NULL'); - - //Controllo se ci sono newletter collegate a questo template - $newsletters = Newsletter::where('id_template', $id_record)->get(); -} diff --git a/modules/emails/src/Account.php b/modules/emails/src/Account.php deleted file mode 100755 index 7b003c83b..000000000 --- a/modules/emails/src/Account.php +++ /dev/null @@ -1,82 +0,0 @@ -. - */ - -namespace Modules\Emails; - -use Carbon\Carbon; -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Eloquent\SoftDeletes; -use Notifications\EmailNotification; -use Traits\LocalPoolTrait; - -class Account extends Model -{ - use SimpleModelTrait; - use LocalPoolTrait; - use SoftDeletes; - - protected $table = 'em_accounts'; - - /** @var OAuth2 */ - protected $gestoreOAuth2; - - public function testConnection() - { - // Impostazione di connected_at a NULL - $this->connected_at = null; - $this->save(); - - // Creazione email di test - $mail = new EmailNotification($this->id); - // Tentativo di connessione - $result = $mail->testSMTP(); - - // Salvataggio della data di connessione per test riuscito - if ($result) { - $this->connected_at = Carbon::now(); - $this->save(); - } - - return $result; - } - - public function getGestoreOAuth2() - { - if (isset($this->gestoreOAuth2)) { - return $this->gestoreOAuth2; - } - - $this->gestoreOAuth2 = new OAuth2($this); - - return $this->gestoreOAuth2; - } - - /* Relazioni Eloquent */ - - public function templates() - { - return $this->hasMany(Template::class, 'id_account'); - } - - public function emails() - { - return $this->hasMany(Mail::class, 'id_account'); - } -} diff --git a/modules/emails/src/EmailHook.php b/modules/emails/src/EmailHook.php deleted file mode 100755 index e0c0cc03f..000000000 --- a/modules/emails/src/EmailHook.php +++ /dev/null @@ -1,130 +0,0 @@ -. - */ - -namespace Modules\Emails; - -use Carbon\Carbon; -use Hooks\Manager; -use Notifications\EmailNotification; -use PHPMailer\PHPMailer\Exception; - -class EmailHook extends Manager -{ - public function isSingleton() - { - return true; - } - - public function needsExecution() - { - $diff = date('Y-m-d H:i:s', strtotime('-4 hours')); - $failed = function ($query) use ($diff) { - $query->where('failed_at', '<', $diff) - ->orWhereNull('failed_at'); - }; - - $accounts = Account::all(); - $remaining = Mail::whereNull('sent_at') - ->where($failed) - ->where('attempt', '<', setting('Numero massimo di tentativi')) - ->whereIn('id_account', $accounts->pluck('id')) - ->count(); - - return !empty($remaining); - } - - public function execute() - { - $diff = date('Y-m-d H:i:s', strtotime('-4 hours')); - $failed = function ($query) use ($diff) { - $query->where('failed_at', '<', $diff) - ->orWhereNull('failed_at'); - }; - - $accounts = Account::all(); - $list = []; - foreach ($accounts as $account) { - $last_mail = $account->emails() - ->whereNotNull('sent_at') - ->orderBy('sent_at') - ->first(); - - // Controllo sul timeout dell'account - $date = new Carbon($last_mail->sent_at); - $now = new Carbon(); - $diff_milliseconds = $date->diffInMilliseconds($now); - - if (empty($last_mail) || $diff_milliseconds > $account->timeout) { - $mail = Mail::whereNull('sent_at') - ->where('id_account', $account->id) - ->where($failed) - ->where('attempt', '<', setting('Numero massimo di tentativi')) - ->orderBy('created_at') - ->first(); - - if (!empty($mail)) { - $list[] = $mail; - } - } - } - - foreach ($list as $mail) { - $email = EmailNotification::build($mail); - - try { - // Invio mail - $email->send(); - } catch (Exception $e) { - } - } - - return $list; - } - - public function response() - { - $yesterday = date('Y-m-d', strtotime('-1 days')); - $user = auth()->getUser(); - - $current = Mail::whereDate('sent_at', '>', $yesterday) - ->where('attempt', '<', setting('Numero massimo di tentativi')) - ->where('created_by', $user->id) - ->count(); - $total = Mail::where(function ($query) use ($yesterday) { - $query->whereDate('sent_at', '>', $yesterday) - ->orWhereNull('sent_at'); - }) - ->where('attempt', '<', setting('Numero massimo di tentativi')) - ->where('created_by', $user->id) - ->count(); - - $message = $total != $current ? tr('Invio email in corso...') : tr('Invio email completato!'); - $message = empty($total) ? tr('Nessuna email presente...') : $message; - - return [ - 'icon' => 'fa fa-envelope text-info', - 'message' => $message, - 'show' => ($total != $current), - 'progress' => [ - 'current' => $current, - 'total' => $total, - ], - ]; - } -} diff --git a/modules/emails/src/Mail.php b/modules/emails/src/Mail.php deleted file mode 100755 index f522ef636..000000000 --- a/modules/emails/src/Mail.php +++ /dev/null @@ -1,248 +0,0 @@ -. - */ - -namespace Modules\Emails; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; -use Models\PrintTemplate; -use Models\Upload; -use Models\User; -use Modules\Newsletter\Newsletter; - -class Mail extends Model -{ - use SimpleModelTrait; - - protected $table = 'em_emails'; - - protected $options = null; - - public static function build(User $user, $template = null, $id_record = null, $account = null) - { - $model = new static(); - - $model->created_by = $user->id; - - if (!empty($template)) { - $model->id_template = $template->id; - $model->id_account = $template->account->id; - } - - $model->id_record = $id_record; - - $model->save(); - - if (!empty($template)) { - $model->resetFromTemplate(); - } - - if (!empty($account)) { - $model->id_account = $account->id; - } - - $model->save(); - - return $model; - } - - /** - * Aggiunge un allegato del gestionale alla notifica. - * - * @param string $file_id - */ - public function addUpload($file_id, $name = null) - { - $this->uploads()->attach($file_id, ['id_email' => $this->id, 'name' => $name]); - } - - /** - * Aggiunge una stampa alla notifica. - * - * @param string|int $print - * @param string $name - */ - public function addPrint($print_id, $name = null) - { - $this->prints()->attach($print_id, ['id_email' => $this->id, 'name' => $name]); - } - - public function resetPrints() - { - $this->prints()->detach(); - } - - /** - * Aggiunge un destinatario alla notifica. - * - * @param string $value - * @param string $type - */ - public function addReceiver($value, $type = null) - { - if (empty($value)) { - return; - } - - $list = explode(';', $value); - foreach ($list as $address) { - if (!empty($address)) { - $receiver = Receiver::build($this, $address, $type); - } - } - } - - public function save(array $options = []) - { - if (isset($this->options)) { - $this->setOptionsAttribute($this->options); - } - - $newsletter = $this->newsletter; - if (!empty($newsletter)) { - $newsletter->fixStato(); - } - - return parent::save($options); - } - - // Attributi Eloquent - - public function setOptionsAttribute($value) - { - $this->attributes['options'] = json_encode($value); - } - - public function getOptionsAttribute() - { - return json_decode($this->attributes['options'], true); - } - - /** - * Restituisce il titolo della notifica. - * - * @return bool - */ - public function getReadNotifyAttribute() - { - return $this->options['read-notify']; - } - - /** - * Imposta il titolo della notifica. - * - * @param bool $value - */ - public function setReadNotifyAttribute($value) - { - $this->options['read-notify'] = boolval($value); - } - - public function setSubjectAttribute($value) - { - if (isset($this->template)) { - $module = $this->template->module; - - $value = $module->replacePlaceholders($this->id_record, $value); - } - - $this->attributes['subject'] = $value; - } - - public function setContentAttribute($value) - { - if (isset($this->template)) { - $module = $this->template->module; - - $value = $module->replacePlaceholders($this->id_record, $value); - } - - $this->attributes['content'] = $value; - } - - /* Relazioni Eloquent */ - - public function account() - { - return $this->belongsTo(Account::class, 'id_account')->withTrashed(); - } - - public function template() - { - return $this->belongsTo(Template::class, 'id_template')->withTrashed(); - } - - public function user() - { - return $this->belongsTo(User::class, 'created_by'); - } - - public function newsletter() - { - return $this->belongsTo(Newsletter::class, 'id_newsletter'); - } - - public function receivers() - { - return $this->hasMany(Receiver::class, 'id_email'); - } - - public function uploads() - { - return $this->belongsToMany(Upload::class, 'em_email_upload', 'id_email', 'id_file')->withPivot('name'); - } - - public function prints() - { - return $this->belongsToMany(PrintTemplate::class, 'em_email_print', 'id_email', 'id_print')->withPivot('name'); - } - - protected function resetFromTemplate() - { - $template = $this->template; - - $this->id_account = $template->account->id; - $this->read_notify = $template->read_notify; - - // Contentuto e oggetto - $this->content = $template->body; - $this->subject = $template->subject; - - // Reply To - if (!empty($template['reply_to'])) { - $this->options['reply_to'] = $template['reply_to']; - } - - // CC - if (!empty($template['cc'])) { - $this->addReceiver($template['cc'], 'cc'); - } - - // BCC - if (!empty($template['bcc'])) { - $this->addReceiver($template['bcc'], 'bcc'); - } - - // Incluesione stampe predefinite - $prints = $template->prints; - foreach ($prints as $print) { - $this->addPrint($print['id']); - } - } -} diff --git a/modules/emails/src/OAuth2.php b/modules/emails/src/OAuth2.php deleted file mode 100644 index bc4c515f3..000000000 --- a/modules/emails/src/OAuth2.php +++ /dev/null @@ -1,198 +0,0 @@ - [ - 'name' => 'Microsoft', - 'class' => Azure::class, - 'options' => [ - 'scope' => [ - 'offline_access', - 'https://graph.microsoft.com/SMTP.Send', - //'https://outlook.office.com/IMAP.AccessAsUser.All' - ], - ], - 'help' => 'https://docs.openstamanager.com/faq/configurazione-oauth2#microsoft', - ], - 'google' => [ - 'name' => 'Google', - 'class' => Google::class, - 'options' => [ - 'scope' => ['https://mail.google.com/'], - 'accessType' => 'offline', - ], - 'help' => 'https://docs.openstamanager.com/faq/configurazione-oauth2#google', - ], - ]; - - protected $provider; - protected $account; - - public function __construct(Account $account) - { - $this->account = $account; - - $this->init(); - } - - /** - * Inizializza il provider per l'autenticazione OAuth2. - */ - public function init() - { - $redirect_uri = base_url().'/oauth2.php'; - - $class = $this->getProviderConfiguration()['class']; - - // Authorization - $this->provider = new $class([ - 'clientId' => $this->account->client_id, - 'clientSecret' => $this->account->client_secret, - 'redirectUri' => $redirect_uri, - 'accessType' => 'offline', - ]); - - // Configurazioni specifiche per il provider di Microsoft Azure - if ($this->provider instanceof Azure) { - $this->provider->defaultEndPointVersion = Azure::ENDPOINT_VERSION_2_0; - $this->provider->tenant = 'consumers'; - } - } - - public function getProvider() - { - return $this->provider; - } - - public function getProviderConfiguration() - { - return self::$providers[$this->account->provider]; - } - - public function needsConfiguration() - { - $access_token = $this->getAccessToken(); - - return empty($access_token); - } - - /** - * Gestisce le operazioni di configurazione per l'autenticazione OAuth2. - * Restituisce l'URL di redirect per le operazioni di aggiornamento dei dati, lancia un eccezione in caso di errori e restituisce null in caso di completamento della configurazione. - * - * Nota: l'autenticazione OAuth2 richiede una serie di richieste su una singola pagina - * - Richiesta di autenticazione al server remoto (code, state vuoti) - * - Conferma di autenticazione alla pagina di redirect (code, state impostati) - * - Richiesta del token di accesso dalla pagina di redirect al server remoto - * - * @param string|null $code - * @param string|null $state - * - * @throws IdentityProviderException - * @throws InvalidArgumentException - * - * @return string|null - */ - public function configure($code, $state) - { - if (!$this->needsConfiguration()) { - return null; - } - - $provider = $this->getProvider(); - $options = $this->getProviderConfiguration()['options']; - if (empty($code)) { - // Fetch the authorization URL from the provider; this returns the - // urlAuthorize option and generates and applies any necessary parameters - // (e.g. state). - $authorization_url = $provider->getAuthorizationUrl($options); - - // Get the state generated for you and store it to the session. - $this->account->oauth2_state = $provider->getState(); - $this->account->save(); - - // Redirect the user to the authorization URL. - return $authorization_url; - } elseif (!empty($this->account->oauth2_state) && $this->account->oauth2_state !== $state) { - $this->account->oauth2_state = null; - $this->account->save(); - - throw new InvalidArgumentException(); - } else { - $this->account->oauth2_state = null; - $this->account->save(); - - // Try to get an access token using the authorization code grant - $access_token = $provider->getAccessToken('authorization_code', [ - 'code' => $code, - ]); - $refresh_token = $access_token->getRefreshToken(); - - $this->updateTokens($access_token, $refresh_token); - } - - return null; - } - - public function getRefreshToken() - { - $this->checkTokens(); - - return $this->account->refresh_token; - } - - /** - * Restituisce l'access token per l'autenticazione OAuth2. - * - * @return AccessToken|null - */ - public function getAccessToken() - { - $this->checkTokens(); - - return unserialize($this->account->access_token); - } - - /** - * Imposta l'access token per l'autenticazione OAuth2. - * - * @param AccessToken|null - */ - public function updateTokens($access_token, $refresh_token) - { - $this->account->access_token = serialize($access_token); - $this->account->refresh_token = $refresh_token; - $this->account->save(); - } - - protected function checkTokens() - { - $access_token = unserialize($this->account->access_token); - - if (!empty($access_token) && $access_token->hasExpired()) { - // Tentativo di refresh del token di accesso - $refresh_token = $this->account->refresh_token; - if (!empty($refresh_token)) { - $access_token = $this->getProvider()->getAccessToken('refresh_token', [ - 'refresh_token' => $this->account->refresh_token, - ]); - - $refresh_token = $access_token->getRefreshToken(); - } else { - $access_token = null; - $refresh_token = null; - } - - $this->updateTokens($access_token, $refresh_token); - } - } -} diff --git a/modules/emails/src/Receiver.php b/modules/emails/src/Receiver.php deleted file mode 100755 index 60c284b7e..000000000 --- a/modules/emails/src/Receiver.php +++ /dev/null @@ -1,49 +0,0 @@ -. - */ - -namespace Modules\Emails; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; - -class Receiver extends Model -{ - use SimpleModelTrait; - - protected $table = 'em_email_receiver'; - - /* Relazioni Eloquent */ - - public static function build(Mail $mail, $address, $type = null) - { - $model = new static(); - - $model->email()->associate($mail); - - $model->address = $address; - $model->type = $type ?: 'a'; - - $model->save(); - } - - public function email() - { - return $this->belongsTo(Mail::class, 'id_email'); - } -} diff --git a/modules/emails/src/Template.php b/modules/emails/src/Template.php deleted file mode 100755 index a7a491c87..000000000 --- a/modules/emails/src/Template.php +++ /dev/null @@ -1,63 +0,0 @@ -. - */ - -namespace Modules\Emails; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Eloquent\SoftDeletes; -use Models\Module; -use Models\PrintTemplate; -use Traits\LocalPoolTrait; - -class Template extends Model -{ - use SimpleModelTrait; - use LocalPoolTrait; - use SoftDeletes; - - protected $table = 'em_templates'; - - public function getVariablesAttribute() - { - $dbo = $database = database(); - - // Lettura delle variabili del modulo collegato - $variables = include $this->module->filepath('variables.php'); - - return (array) $variables; - } - - /* Relazioni Eloquent */ - - public function module() - { - return $this->belongsTo(Module::class, 'id_module'); - } - - public function account() - { - return $this->belongsTo(Account::class, 'id_account')->withTrashed(); - } - - public function prints() - { - return $this->belongsToMany(PrintTemplate::class, 'em_print_template', 'id_template', 'id_print'); - } -} diff --git a/modules/fatture/actions.php b/modules/fatture/actions.php deleted file mode 100755 index e06036c89..000000000 --- a/modules/fatture/actions.php +++ /dev/null @@ -1,871 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Anagrafiche\Anagrafica; -use Modules\Articoli\Articolo as ArticoloOriginale; -use Modules\DDT\DDT; -use Modules\Fatture\Components\Articolo; -use Modules\Fatture\Components\Descrizione; -use Modules\Fatture\Components\Riga; -use Modules\Fatture\Components\Sconto; -use Modules\Fatture\Fattura; -use Modules\Fatture\Stato; -use Modules\Fatture\Tipo; -use Plugins\ExportFE\FatturaElettronica; -use Util\XML; - -$module = Modules::get($id_module); - -if ($module['name'] == 'Fatture di vendita') { - $dir = 'entrata'; -} else { - $dir = 'uscita'; -} - -switch (post('op')) { - case 'add': - $idanagrafica = post('idanagrafica'); - $data = post('data'); - $idtipodocumento = post('idtipodocumento'); - $id_segment = post('id_segment'); - - if ($dir == 'uscita') { - $numero_esterno = post('numero_esterno'); - } - - $anagrafica = Anagrafica::find($idanagrafica); - $tipo = Tipo::find($idtipodocumento); - - $fattura = Fattura::build($anagrafica, $tipo, $data, $id_segment, $numero_esterno); - - $id_record = $fattura->id; - - flash()->info(tr('Aggiunta fattura numero _NUM_!', [ - '_NUM_' => $fattura->numero, - ])); - - break; - - case 'update': - $stato_precedente = $fattura->stato; - - $stato = Stato::find(post('idstatodocumento')); - $fattura->stato()->associate($stato); - - $tipo = Tipo::find(post('idtipodocumento')); - $fattura->tipo()->associate($tipo); - - $fattura->data = post('data'); - - if ($dir == 'entrata') { - $fattura->data_registrazione = post('data'); - } else { - $fattura->data_registrazione = post('data_registrazione'); - } - - $fattura->data_competenza = post('data_competenza'); - - $fattura->numero_esterno = post('numero_esterno'); - $fattura->note = post('note'); - $fattura->note_aggiuntive = post('note_aggiuntive'); - - $fattura->idanagrafica = post('idanagrafica'); - $fattura->idagente = post('idagente'); - $fattura->idreferente = post('idreferente'); - $fattura->idpagamento = post('idpagamento'); - $fattura->id_banca_azienda = post('id_banca_azienda'); - $fattura->id_banca_controparte = post('id_banca_controparte'); - $fattura->idcausalet = post('idcausalet'); - $fattura->idspedizione = post('idspedizione'); - $fattura->idporto = post('idporto'); - $fattura->idaspettobeni = post('idaspettobeni'); - $fattura->idvettore = post('idvettore'); - $fattura->idsede_partenza = post('idsede_partenza'); - $fattura->idsede_destinazione = post('idsede_destinazione'); - $fattura->idconto = post('idconto'); - $fattura->split_payment = post('split_payment') ?: 0; - $fattura->is_fattura_conto_terzi = post('is_fattura_conto_terzi') ?: 0; - $fattura->n_colli = post('n_colli'); - $fattura->tipo_resa = post('tipo_resa'); - - $fattura->peso = post('peso'); - $fattura->volume = post('volume'); - $fattura->peso_manuale = post('peso_manuale'); - $fattura->volume_manuale = post('volume_manuale'); - - $fattura->rivalsainps = 0; - $fattura->ritenutaacconto = 0; - $fattura->iva_rivalsainps = 0; - $fattura->id_ritenuta_contributi = post('id_ritenuta_contributi') ?: null; - - $fattura->codice_stato_fe = post('codice_stato_fe') ?: null; - - // Informazioni per le fatture di acquisto - if ($dir == 'uscita') { - $fattura->numero = post('numero'); - $fattura->numero_esterno = post('numero_esterno'); - $fattura->idrivalsainps = post('id_rivalsa_inps'); - $fattura->idritenutaacconto = post('id_ritenuta_acconto'); - } - - // Operazioni sul bollo - if ($dir == 'entrata') { - $fattura->addebita_bollo = post('addebita_bollo'); - $bollo_automatico = post('bollo_automatico'); - if (empty($bollo_automatico)) { - $fattura->bollo = post('bollo'); - } else { - $fattura->bollo = null; - } - } - - // Operazioni sulla dichiarazione d'intento - $dichiarazione_precedente = $fattura->dichiarazione; - $fattura->id_dichiarazione_intento = post('id_dichiarazione_intento') ?: null; - - // Flag pagamento ritenuta - $fattura->is_ritenuta_pagata = post('is_ritenuta_pagata') ?: 0; - - $fattura->setScontoFinale(post('sconto_finale'), post('tipo_sconto_finale')); - - $fattura->save(); - - // Operazioni automatiche per le Fatture Elettroniche - if ($fattura->direzione == 'entrata' && $stato_precedente->descrizione == 'Bozza' && $stato['descrizione'] == 'Emessa') { - $stato_fe = $database->fetchOne('SELECT * FROM fe_stati_documento WHERE codice = '.prepare($fattura->codice_stato_fe)); - $abilita_genera = empty($fattura->codice_stato_fe) || intval($stato_fe['is_generabile']); - - // Generazione automatica della Fattura Elettronica - $checks = FatturaElettronica::controllaFattura($fattura); - $fattura_elettronica = new FatturaElettronica($id_record); - if ($abilita_genera && empty($checks)) { - $file = $fattura_elettronica->save(base_dir().'/'.FatturaElettronica::getDirectory()); - - flash()->info(tr('Fattura elettronica generata correttamente!')); - - if (!$fattura_elettronica->isValid()) { - $errors = $fattura_elettronica->getErrors(); - - flash()->warning(tr('La fattura elettronica potrebbe avere delle irregolarità!').' '.tr('Controllare i seguenti campi: _LIST_', [ - '_LIST_' => implode(', ', $errors), - ]).'.'); - } - } - // Visualizzazione degli errori - elseif (!empty($checks)) { - // Rimozione eventuale fattura generata erronamente - // Fix per la modifica di dati interni su fattura già generata - if ($abilita_genera) { - $fattura_elettronica->delete(); - } - - // Messaggi informativi sulle problematiche - $message = tr('La fattura elettronica non è stata generata a causa di alcune informazioni mancanti').':'; - - foreach ($checks as $check) { - $message .= ' -

    '.$check['name'].' '.$check['link'].'

    -
      '; - - foreach ($check['errors'] as $error) { - if (!empty($error)) { - $message .= ' -
    • '.$error.'
    • '; - } - } - - $message .= ' -
    '; - } - - flash()->warning($message); - } - } - - aggiorna_sedi_movimenti('documenti', $id_record); - - // Controllo sulla presenza di fattura di acquisto con lo stesso numero secondario nello stesso periodo - $direzione = $fattura->direzione; - if ($direzione == 'uscita') { - $count = Fattura::where('numero_esterno', $fattura->numero_esterno) - ->where('id', '!=', $id_record) - ->where('idanagrafica', '=', $fattura->anagrafica->id) - ->where('data', '>=', $_SESSION['period_start']) - ->where('data', '<=', $_SESSION['period_end']) - ->whereHas('tipo', function ($query) use ($direzione) { - $query->where('dir', '=', $direzione); - })->count(); - if (!empty($count)) { - flash()->warning(tr('Esiste già una fattura con lo stesso numero secondario e la stessa anagrafica collegata!')); - } - } - - flash()->info(tr('Fattura modificata correttamente!')); - - break; - - // Ricalcolo scadenze - case 'ricalcola_scadenze': - $fattura->registraScadenze(false, true); - - break; - - // Ricalcolo scadenze - case 'controlla_totali': - $totale_documento = null; - - try { - $xml = XML::read($fattura->getXML()); - - // Totale basato sul campo ImportoTotaleDocumento - $dati_generali = $xml['FatturaElettronicaBody']['DatiGenerali']['DatiGeneraliDocumento']; - if (isset($dati_generali['ImportoTotaleDocumento'])) { - $totale_documento_indicato = abs(floatval($dati_generali['ImportoTotaleDocumento'])); - - // Calcolo del totale basato sui DatiRiepilogo - if (empty($totale_documento) && empty($dati_generali['ScontoMaggiorazione'])) { - $totale_documento = 0; - - $riepiloghi = $xml['FatturaElettronicaBody']['DatiBeniServizi']['DatiRiepilogo']; - if (!empty($riepiloghi) && !isset($riepiloghi[0])) { - $riepiloghi = [$riepiloghi]; - } - - foreach ($riepiloghi as $riepilogo) { - $totale_documento = sum([$totale_documento, $riepilogo['ImponibileImporto'], $riepilogo['Imposta'], -$riepilogo['Arrotondamento']]); - } - - $totale_documento = abs($totale_documento); - } else { - $totale_documento = $totale_documento_indicato; - } - } - } catch (Exception $e) { - } - - echo json_encode([ - 'stored' => $totale_documento, - 'calculated' => $fattura->totale, - ]); - - break; - - // Elenco fatture in stato Bozza per il cliente - case 'fatture_bozza': - $id_anagrafica = post('id_anagrafica'); - $stato = Stato::where('descrizione', 'Bozza')->first(); - - $fatture = Fattura::vendita() - ->where('idanagrafica', $id_anagrafica) - ->where('idstatodocumento', $stato->id) - ->get(); - - $results = []; - foreach ($fatture as $result) { - $results[] = Modules::link('Fatture di vendita', $result->id, reference($result)); - } - - echo json_encode($results); - - break; - - // Elenco fatture Scadute per il cliente - case 'fatture_scadute': - $id_anagrafica = post('id_anagrafica'); - $stato1 = Stato::where('descrizione', 'Emessa')->first(); - $stato2 = Stato::where('descrizione', 'Prazialmente pagato')->first(); - - $fatture = Fattura::vendita() - ->select('*', 'co_documenti.id AS id', 'co_documenti.data AS data') - ->where('idanagrafica', $id_anagrafica) - ->whereIn('idstatodocumento', [$stato1->id, $stato2->id]) - ->join('co_scadenziario', 'co_documenti.id', '=', 'co_scadenziario.iddocumento') - ->where('co_scadenziario.da_pagare', '>', 'co_scadenziario.pagato') - ->whereRaw('co_scadenziario.scadenza < NOW()') - ->groupBy('co_scadenziario.iddocumento') - ->get(); - - $results = []; - foreach ($fatture as $result) { - $results[] = Modules::link('Fatture di vendita', $result->id, reference($result)); - } - - echo json_encode($results); - - break; - - // eliminazione documento - case 'delete': - try { - $fattura->delete(); - - $dbo->query('DELETE FROM co_scadenziario WHERE iddocumento='.prepare($id_record)); - $dbo->query('DELETE FROM co_movimenti WHERE iddocumento='.prepare($id_record)); - - // Azzeramento collegamento della rata contrattuale alla pianificazione - $dbo->query('UPDATE co_fatturazione_contratti SET iddocumento=0 WHERE iddocumento='.prepare($id_record)); - - // Eliminazione allegati collegati - Uploads::deleteLinked([ - 'id_module' => $id_module, - 'id_record' => $id_record, - ]); - - flash()->info(tr('Fattura eliminata!')); - } catch (InvalidArgumentException $e) { - flash()->error(tr('Sono stati utilizzati alcuni serial number nel documento: impossibile procedere!')); - } - - break; - - // Duplicazione fattura - case 'copy': - $new = $fattura->replicate(); - $new->save(); - - $id_record = $new->id; - - $righe = $fattura->getRighe()->where('id', '!=', $fattura->id_riga_bollo); - foreach ($righe as $riga) { - $new_riga = $riga->replicate(); - $new_riga->setDocument($new); - - // Rimozione riferimenti (deprecati) - $new_riga->idpreventivo = 0; - $new_riga->idcontratto = 0; - $new_riga->idintervento = 0; - $new_riga->idddt = 0; - $new_riga->idordine = 0; - $new_riga->save(); - - if ($new_riga->isArticolo()) { - $new_riga->movimenta($new_riga->qta); - } - } - - flash()->info(tr('Fattura duplicata correttamente!')); - - break; - - case 'reopen': - if (!empty($id_record)) { - $dbo->query("UPDATE co_documenti SET idstatodocumento=(SELECT id FROM co_statidocumento WHERE descrizione='Bozza') WHERE id=".prepare($id_record)); - elimina_movimenti($id_record, 1); - elimina_scadenze($id_record); - ricalcola_costiagg_fattura($id_record); - flash()->info(tr('Fattura riaperta!')); - } - - break; - - case 'add_intervento': - $id_intervento = post('idintervento'); - - if (!empty($id_record) && $id_intervento !== null) { - $copia_descrizione = post('copia_descrizione'); - $intervento = $dbo->fetchOne('SELECT descrizione FROM in_interventi WHERE id = '.prepare($id_intervento)); - if (!empty($copia_descrizione) && !empty($intervento['descrizione'])) { - $riga = Descrizione::build($fattura); - $riga->descrizione = $intervento['descrizione']; - $riga->idintervento = $id_intervento; - $riga->save(); - } - - aggiungi_intervento_in_fattura($id_intervento, $id_record, post('descrizione'), post('idiva'), post('idconto'), post('id_rivalsa_inps'), post('id_ritenuta_acconto'), post('calcolo_ritenuta_acconto')); - - flash()->info(tr('Intervento _NUM_ aggiunto!', [ - '_NUM_' => $idintervento, - ])); - } - break; - - case 'manage_documento_fe': - $data = Filter::getPOST(); - - $ignore = [ - 'id_plugin', - 'id_module', - 'id_record', - 'backto', - 'hash', - 'op', - 'idriga', - 'dir', - ]; - foreach ($ignore as $name) { - unset($data[$name]); - } - - $fattura->dati_aggiuntivi_fe = $data; - $fattura->save(); - - flash()->info(tr('Dati FE aggiornati correttamente!')); - - break; - - case 'manage_riga_fe': - $id_riga = post('id_riga'); - if ($id_riga != null) { - $riga = Articolo::find($id_riga) ?: Riga::find($id_riga); - $riga = $riga ?: Descrizione::find($id_riga); - $riga = $riga ?: Sconto::find($id_riga); - - $data = Filter::getPOST(); - - $ignore = [ - 'id_plugin', - 'id_module', - 'id_record', - 'backto', - 'hash', - 'op', - 'idriga', - 'dir', - ]; - foreach ($ignore as $name) { - unset($data[$name]); - } - - $riga->dati_aggiuntivi_fe = $data; - $riga->save(); - - flash()->info(tr('Dati FE aggiornati correttamente!')); - } - - break; - - case 'manage_barcode': - foreach (post('qta') as $id_articolo => $qta) { - if ($id_articolo == '-id-') { - continue; - } - - // Dati di input - $sconto = post('sconto')[$id_articolo]; - $tipo_sconto = post('tipo_sconto')[$id_articolo]; - $prezzo_unitario = post('prezzo_unitario')[$id_articolo]; - $id_dettaglio_fornitore = post('id_dettaglio_fornitore')[$id_articolo]; - $id_iva = $originale->idiva_vendita ? $originale->idiva_vendita : setting('Iva predefinita'); - - $id_conto = ($fattura->direzione == 'entrata') ? setting('Conto predefinito fatture di vendita') : setting('Conto predefinito fatture di acquisto'); - if ($fattura->direzione == 'entrata' && !empty($originale->idconto_vendita)) { - $id_conto = $originale->idconto_vendita; - } elseif ($fattura->direzione == 'uscita' && !empty($originale->idconto_acquisto)) { - $id_conto = $originale->idconto_acquisto; - } - - // Creazione articolo - $originale = ArticoloOriginale::find($id_articolo); - $articolo = Articolo::build($fattura, $originale); - $articolo->id_dettaglio_fornitore = $id_dettaglio_fornitore ?: null; - - $articolo->setPrezzoUnitario($prezzo_unitario, $id_iva); - if ($dir == 'entrata') { - $articolo->costo_unitario = $originale->prezzo_acquisto; - } - $articolo->setSconto($sconto, $tipo_sconto); - $articolo->qta = $qta; - $articolo->idconto = $id_conto; - - $articolo->save(); - } - - flash()->info(tr('Articoli aggiunti!')); - - break; - - case 'manage_articolo': - if (post('idriga') != null) { - $articolo = Articolo::find(post('idriga')); - } else { - $originale = ArticoloOriginale::find(post('idarticolo')); - $articolo = Articolo::build($fattura, $originale); - $articolo->id_dettaglio_fornitore = post('id_dettaglio_fornitore') ?: null; - } - - $qta = post('qta'); - - $articolo->descrizione = post('descrizione'); - $articolo->um = post('um') ?: null; - - $articolo->id_iva = post('idiva'); - $articolo->idconto = post('idconto'); - - $articolo->calcolo_ritenuta_acconto = post('calcolo_ritenuta_acconto') ?: null; - $articolo->id_ritenuta_acconto = post('id_ritenuta_acconto') ?: null; - $articolo->ritenuta_contributi = boolval(post('ritenuta_contributi')); - $articolo->id_rivalsa_inps = post('id_rivalsa_inps') ?: null; - - $articolo->costo_unitario = post('costo_unitario') ?: 0; - $articolo->setPrezzoUnitario(post('prezzo_unitario'), post('idiva')); - $articolo->setSconto(post('sconto'), post('tipo_sconto')); - - try { - $articolo->qta = $qta; - } catch (UnexpectedValueException $e) { - flash()->error(tr('Alcuni serial number sono già stati utilizzati!')); - } - - $articolo->save(); - - if (post('idriga') != null) { - flash()->info(tr('Articolo modificato!')); - } else { - flash()->info(tr('Articolo aggiunto!')); - } - - // Ricalcolo inps, ritenuta e bollo - ricalcola_costiagg_fattura($id_record); - - break; - - case 'manage_sconto': - if (post('idriga') != null) { - $sconto = Sconto::find(post('idriga')); - } else { - $sconto = Sconto::build($fattura); - } - - $sconto->idconto = post('idconto'); - - $sconto->calcolo_ritenuta_acconto = post('calcolo_ritenuta_acconto') ?: null; - $sconto->id_ritenuta_acconto = post('id_ritenuta_acconto') ?: null; - $sconto->ritenuta_contributi = boolval(post('ritenuta_contributi')); - $sconto->id_rivalsa_inps = post('id_rivalsa_inps') ?: null; - - $sconto->descrizione = post('descrizione'); - $sconto->setScontoUnitario(post('sconto_unitario'), post('idiva')); - - $sconto->save(); - - if (post('idriga') != null) { - flash()->info(tr('Sconto/maggiorazione modificato!')); - } else { - flash()->info(tr('Sconto/maggiorazione aggiunto!')); - } - - // Ricalcolo inps, ritenuta e bollo - ricalcola_costiagg_fattura($id_record); - - break; - - case 'manage_riga': - if (post('idriga') != null) { - $riga = Riga::find(post('idriga')); - } else { - $riga = Riga::build($fattura); - } - - $qta = post('qta'); - - $riga->descrizione = post('descrizione'); - $riga->um = post('um') ?: null; - - $riga->id_iva = post('idiva'); - $riga->idconto = post('idconto'); - - $riga->calcolo_ritenuta_acconto = post('calcolo_ritenuta_acconto') ?: null; - $riga->id_ritenuta_acconto = post('id_ritenuta_acconto') ?: null; - $riga->ritenuta_contributi = boolval(post('ritenuta_contributi')); - $riga->id_rivalsa_inps = post('id_rivalsa_inps') ?: null; - - $riga->costo_unitario = post('costo_unitario') ?: 0; - $riga->setPrezzoUnitario(post('prezzo_unitario'), post('idiva')); - $riga->setSconto(post('sconto'), post('tipo_sconto')); - - $riga->qta = $qta; - - $riga->save(); - - if (post('idriga') != null) { - flash()->info(tr('Riga modificata!')); - } else { - flash()->info(tr('Riga aggiunta!')); - } - - // Ricalcolo inps, ritenuta e bollo - ricalcola_costiagg_fattura($id_record); - - break; - - case 'manage_descrizione': - if (post('idriga') != null) { - $riga = Descrizione::find(post('idriga')); - } else { - $riga = Descrizione::build($fattura); - } - - $riga->descrizione = post('descrizione'); - - $riga->save(); - - if (post('idriga') != null) { - flash()->info(tr('Riga descrittiva modificata!')); - } else { - flash()->info(tr('Riga descrittiva aggiunta!')); - } - - break; - - // Scollegamento intervento da documento - case 'unlink_intervento': - if (!empty($id_record) && post('idriga') !== null) { - $id_riga = post('idriga'); - $type = post('type'); - $riga = $fattura->getRiga($type, $id_riga); - - if (!empty($riga)) { - try { - $riga->delete(); - - flash()->info(tr('Intervento _NUM_ rimosso!', [ - '_NUM_' => $idintervento, - ])); - } catch (InvalidArgumentException $e) { - flash()->error(tr('Errore durante l\'eliminazione della riga!')); - } - } - } - break; - - // Scollegamento riga generica da documento - case 'delete_riga': - $id_riga = post('riga_id'); - $type = post('riga_type'); - $riga = $fattura->getRiga($type, $id_riga); - - if (!empty($riga)) { - try { - $riga->delete(); - - // Ricalcolo inps, ritenuta e bollo - ricalcola_costiagg_fattura($id_record); - - flash()->info(tr('Riga rimossa!')); - } catch (InvalidArgumentException $e) { - flash()->error(tr('Alcuni serial number sono già stati utilizzati!')); - } - } - break; - - case 'add_serial': - $articolo = Articolo::find(post('idriga')); - - $serials = (array) post('serial'); - $articolo->serials = $serials; - - break; - - case 'update_position': - $order = explode(',', post('order', true)); - - foreach ($order as $i => $id_riga) { - $dbo->query('UPDATE `co_righe_documenti` SET `order` = '.prepare($i + 1).' WHERE id='.prepare($id_riga)); - } - - break; - - // Aggiunta di un documento esterno - case 'add_documento': - $class = post('class'); - $id_documento = post('id_documento'); - $reversed = post('reversed'); - - // Individuazione del documento originale - if (!is_subclass_of($class, \Common\Document::class)) { - return; - } - $documento = $class::find($id_documento); - - // Individuazione sede - $id_sede = ($documento->direzione == 'entrata') ? $documento->idsede_destinazione : $documento->idsede_partenza; - $id_sede = $id_sede ?: $documento->idsede; - $id_sede = $id_sede ?: 0; - - // Creazione della fattura al volo - if (post('create_document') == 'on') { - $descrizione = ($documento->direzione == 'entrata') ? 'Fattura immediata di vendita' : 'Fattura immediata di acquisto'; - - // Fattura differita in caso di importazione da DDT - if ($documento instanceof DDT) { - $descrizione = ($documento->direzione == 'entrata') ? 'Fattura differita di vendita' : 'Fattura differita di acquisto'; - } - - if ($reversed) { - $tipo = Tipo::where('descrizione', 'Nota di credito')->where('dir', '!=', $documento->direzione)->first(); - } else { - $tipo = Tipo::where('descrizione', $descrizione)->first(); - } - - $fattura = Fattura::build($documento->anagrafica, $tipo, post('data'), post('id_segment')); - - if (!empty($documento->idpagamento)) { - $fattura->idpagamento = $documento->idpagamento; - } else { - $fattura->idpagamento = setting('Tipo di pagamento predefinito'); - } - - $fattura->idsede_destinazione = $documento->idsede; - $fattura->id_ritenuta_contributi = post('id_ritenuta_contributi') ?: null; - $fattura->idreferente = $documento->idreferente; - - $fattura->save(); - - $id_record = $fattura->id; - } - - if (!empty($documento->sconto_finale)) { - $fattura->sconto_finale = $documento->sconto_finale; - } elseif (!empty($documento->sconto_finale_percentuale)) { - $fattura->sconto_finale_percentuale = $documento->sconto_finale_percentuale; - } - - $fattura->save(); - - $calcolo_ritenuta_acconto = post('calcolo_ritenuta_acconto') ?: null; - $id_ritenuta_acconto = post('id_ritenuta_acconto') ?: null; - $ritenuta_contributi = boolval(post('ritenuta_contributi')); - $id_rivalsa_inps = post('id_rivalsa_inps') ?: null; - $id_conto = post('id_conto'); - - $righe = $documento->getRighe(); - foreach ($righe as $riga) { - if (post('evadere')[$riga->id] == 'on') { - $qta = post('qta_da_evadere')[$riga->id]; - $articolo = ArticoloOriginale::find($riga->idarticolo); - - $copia = $riga->copiaIn($fattura, $qta); - - $copia->id_conto = ($documento->direzione == 'entrata' ? ($articolo->idconto_vendita ?: $id_conto) : ($articolo->idconto_acquisto ?: $id_conto)); - $copia->calcolo_ritenuta_acconto = $calcolo_ritenuta_acconto; - $copia->id_ritenuta_acconto = $id_ritenuta_acconto; - $copia->id_rivalsa_inps = $id_rivalsa_inps; - $copia->ritenuta_contributi = $ritenuta_contributi; - - // Aggiornamento seriali dalla riga dell'ordine - if ($copia->isArticolo()) { - $serials = is_array(post('serial')[$riga->id]) ? post('serial')[$riga->id] : []; - - $copia->serials = $serials; - } - - $copia->save(); - } - } - - // Modifica finale dello stato - if (post('create_document') == 'on') { - $fattura->idstatodocumento = post('id_stato'); - $fattura->save(); - } - - ricalcola_costiagg_fattura($id_record); - - // Messaggio informativo - $message = tr('_DOC_ aggiunto!', [ - '_DOC_' => $documento->getReference(), - ]); - flash()->info($message); - - break; - - // Nota di credito - case 'nota_credito': - $id_documento = post('id_documento'); - $fattura = Fattura::find($id_documento); - - $id_segment = post('id_segment'); - $data = post('data'); - - $anagrafica = $fattura->anagrafica; - $tipo = Tipo::where('descrizione', 'Nota di credito')->where('dir', 'entrata')->first(); - - $nota = Fattura::build($anagrafica, $tipo, $data, $id_segment); - $nota->ref_documento = $fattura->id; - $nota->idconto = $fattura->idconto; - $nota->idpagamento = $fattura->idpagamento; - $nota->id_banca_azienda = $fattura->id_banca_azienda; - $nota->id_banca_controparte = $fattura->id_banca_controparte; - $nota->idsede_partenza = $fattura->idsede_partenza; - $nota->idsede_destinazione = $fattura->idsede_destinazione; - $nota->split_payment = $fattura->split_payment; - $nota->save(); - - $righe = $fattura->getRighe(); - foreach ($righe as $riga) { - if (post('evadere')[$riga->id] == 'on' and !empty(post('qta_da_evadere')[$riga->id])) { - $qta = post('qta_da_evadere')[$riga->id]; - - $copia = $riga->copiaIn($nota, $qta); - $copia->ref_riga_documento = $riga->id; - - // Aggiornamento seriali dalla riga dell'ordine - if ($copia->isArticolo()) { - $serials = is_array(post('serial')[$riga->id]) ? post('serial')[$riga->id] : []; - - $copia->serials = $serials; - } - - $copia->save(); - } - } - - $id_record = $nota->id; - aggiorna_sedi_movimenti('documenti', $id_record); - - break; - - case 'transform': - $fattura->id_segment = post('id_segment'); - $fattura->data = post('data'); - $fattura->data_registrazione = post('data'); - $fattura->data_competenza = post('data'); - $fattura->save(); - - break; -} - -// Nota di debito -if (get('op') == 'nota_addebito') { - $rs_segment = $dbo->fetchArray("SELECT * FROM zz_segments WHERE predefined_addebito='1'"); - if (!empty($rs_segment)) { - $id_segment = $rs_segment[0]['id']; - } else { - $id_segment = $record['id_segment']; - } - - $anagrafica = $fattura->anagrafica; - $tipo = Tipo::where('descrizione', 'Nota di debito')->where('dir', 'entrata')->first(); - $data = $fattura->data; - - $nota = Fattura::build($anagrafica, $tipo, $data, $id_segment); - $nota->ref_documento = $fattura->id; - $nota->idconto = $fattura->idconto; - $nota->idpagamento = $fattura->idpagamento; - $nota->id_banca_azienda = $fattura->id_banca_azienda; - $nota->id_banca_controparte = $fattura->id_banca_controparte; - $nota->idsede_partenza = $fattura->idsede_partenza; - $nota->idsede_destinazione = $fattura->idsede_destinazione; - $nota->save(); - - $id_record = $nota->id; - aggiorna_sedi_movimenti('documenti', $id_record); -} diff --git a/modules/fatture/add.php b/modules/fatture/add.php deleted file mode 100755 index 73d3374ed..000000000 --- a/modules/fatture/add.php +++ /dev/null @@ -1,203 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$module = Modules::get($id_module); - -if ($module['name'] == 'Fatture di vendita') { - $dir = 'entrata'; - $tipo_anagrafica = tr('Cliente'); -} else { - $dir = 'uscita'; - $tipo_anagrafica = tr('Fornitore'); -} - -$id_anagrafica = !empty(get('idanagrafica')) ? get('idanagrafica') : $user['idanagrafica']; - -$idtipodocumento = $dbo->selectOne('co_tipidocumento', ['id'], [ - 'predefined' => 1, - 'dir' => $dir, -])['id']; - -?> -
    - - - - - - - -
    - - - {[ "type": "text", "label": "'.tr('N. fattura del fornitore').'", "required": 1, "name": "numero_esterno","class": "text-center", "value": "" ]} -
    '; - $size = 3; - } else { - $size = 6; - } - ?> - -
    - {[ "type": "date", "label": "", "name": "data", "required": 1, "value": "-now-" ]} -
    - -
    - {[ "type": "select", "label": "", "name": "idanagrafica", "id": "idanagrafica_add", "required": 1, "ajax-source": "", "value": "", "icon-after": "add||tipoanagrafica=" ]} -
    - - -
    -
    - {[ "type": "select", "label": "", "name": "idtipodocumento", "required": 1, "values": "query=SELECT id, CONCAT(codice_tipo_documento_fe, ' - ', descrizione) AS descrizione FROM co_tipidocumento WHERE enabled = 1 AND dir = '' ORDER BY codice_tipo_documento_fe", "value": "" ]} -
    - -
    - {[ "type": "select", "label": "", "name": "id_segment", "required": 1, "values": "query=SELECT id, name AS descrizione FROM zz_segments WHERE id_module='' ORDER BY name", "value": "" ]} -
    -
    - - - - -
    -
    - -
    -
    -
    - - -$(document).ready(function () { - $("#idanagrafica_add").change(function () { - let data = $(this).selectData(); - - if (data !== undefined) { - - $("#info").removeClass("hidden"); - - $.ajax({ - url: globals.rootdir + "/actions.php", - type: "POST", - dataType: "json", - data: { - id_module: globals.id_module, - id_anagrafica: data.id, - op: "fatture_bozza", - }, - success: function (results) { - - $("#info").removeClass("box-info"); - $("#info").removeClass("box-warning"); - if (results.length === 0){ - $("#info-title-bozza").addClass("box-info"); - $("#info-title-bozza").removeClass("box-warning"); - $("#info-content-bozza").html("

    '.tr('Per il cliente selezionato non è presente alcuna fattura in stato Bozza').'

    ") - } else { - let content = ""; - - results.forEach(function(item) { - content += "
  • " + item + "
  • "; - }); - $("#info-title-bozza").addClass("box-warning"); - $("#info-title-bozza").removeClass("box-info"); - $("#info-content-bozza").html("

    '.tr('Attenzione: per il cliente selezionato sono presenti le seguenti fatture in stato Bozza').':

      " + content + "
    ") - } - } - }); - - - $.ajax({ - url: globals.rootdir + "/actions.php", - type: "POST", - dataType: "json", - data: { - id_module: globals.id_module, - id_anagrafica: data.id, - op: "fatture_scadute", - }, - success: function (results) { - $("#info").removeClass("box-info"); - $("#info").removeClass("box-warning"); - if (results.length === 0){ - $("#info-title-scadute").addClass("box-info"); - $("#info-title-scadute").removeClass("box-warning"); - $("#info-content-scadute").html("

    '.tr('Per il cliente selezionato non è presente alcuna fattura Scaduta').'

    ") - } else { - let content = ""; - - results.forEach(function(item) { - content += "
  • " + item + "
  • "; - }); - $("#info-title-scadute").addClass("box-warning"); - $("#info-title-scadute").removeClass("box-info"); - $("#info-content-scadute").html("

    '.tr('Attenzione: per il cliente selezionato le seguenti fatture presentamento una o più rate scadute').':

      " + content + "
    ") - } - } - }); - - - }else{ - - $("#info").addClass("hidden"); - return; - } - }) -}) -'; -} diff --git a/modules/fatture/add_contratto.php b/modules/fatture/add_contratto.php deleted file mode 100755 index d07632115..000000000 --- a/modules/fatture/add_contratto.php +++ /dev/null @@ -1,86 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Contratti\Contratto; -use Modules\Fatture\Fattura; - -$documento_finale = Fattura::find($id_record); -$dir = $documento_finale->direzione; - -$id_documento = get('id_documento'); -if (!empty($id_documento)) { - $documento = Contratto::find($id_documento); - - $options = [ - 'op' => 'add_documento', - 'type' => 'contratto', - 'button' => tr('Aggiungi'), - 'documento' => $documento, - 'documento_finale' => $documento_finale, - 'tipo_documento_finale' => Fattura::class, - 'superamento_soglia_qta' => setting('Permetti il superamento della soglia quantità dei documenti di origine'), - ]; - - echo App::load('importa.php', [], $options, true); - - return; -} - -$id_anagrafica = $documento_finale->idanagrafica; - -echo ' -
    -
    - {[ "type": "select", "label": "'.tr('Contratto').'", "name": "id_documento", "ajax-source": "contratti", "select-options": {"idanagrafica": '.$id_anagrafica.', "stato": "is_fatturabile"} ]} -
    -
    - -
    - -
    - -
    - '.tr('Caricamento in corso').'... -
    '; - -$file = basename(__FILE__); -echo ' - - -'; diff --git a/modules/fatture/add_ddt.php b/modules/fatture/add_ddt.php deleted file mode 100755 index 31c907ae0..000000000 --- a/modules/fatture/add_ddt.php +++ /dev/null @@ -1,87 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\DDT\DDT; -use Modules\Fatture\Fattura; - -$documento_finale = Fattura::find($id_record); -$dir = $documento_finale->direzione; - -$id_documento = get('id_documento'); -if (!empty($id_documento)) { - $documento = DDT::find($id_documento); - - $options = [ - 'op' => 'add_documento', - 'type' => 'ddt', - 'serials' => true, - 'button' => tr('Aggiungi'), - 'documento' => $documento, - 'documento_finale' => $documento_finale, - 'tipo_documento_finale' => Fattura::class, - 'superamento_soglia_qta' => setting('Permetti il superamento della soglia quantità dei documenti di origine'), - ]; - - echo App::load('importa.php', [], $options, true); - - return; -} - -$id_anagrafica = $documento_finale->idanagrafica; - -echo ' -
    -
    - {[ "type": "select", "label": "'.tr('Ddt').'", "name": "id_documento", "values": "query=SELECT dt_ddt.id, CONCAT(\'DDT num. \', IF(numero_esterno != \'\', numero_esterno, numero), \' del \', DATE_FORMAT(data, \'%d-%m-%Y\'), \' [\', (SELECT descrizione FROM dt_statiddt WHERE id = idstatoddt) , \']\') AS descrizione FROM dt_ddt LEFT JOIN `dt_causalet` ON `dt_causalet`.`id` = `dt_ddt`.`idcausalet` WHERE idanagrafica='.prepare($id_anagrafica).' AND idstatoddt IN (SELECT id FROM dt_statiddt WHERE descrizione IN(\'Evaso\', \'Parzialmente evaso\', \'Parzialmente fatturato\')) AND idtipoddt=(SELECT id FROM dt_tipiddt WHERE dir='.prepare($dir).') AND `dt_causalet`.`is_importabile` = 1 AND dt_ddt.id IN (SELECT idddt FROM dt_righe_ddt WHERE dt_righe_ddt.idddt = dt_ddt.id AND (qta - qta_evasa) > 0) ORDER BY data DESC, numero DESC" ]} -
    -
    - -
    - -
    - -
    - '.tr('Caricamento in corso').'... -
    '; - -$file = basename(__FILE__); -echo ' - - -'; diff --git a/modules/fatture/add_intervento.php b/modules/fatture/add_intervento.php deleted file mode 100755 index bd9ffc1b3..000000000 --- a/modules/fatture/add_intervento.php +++ /dev/null @@ -1,145 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$module = Modules::get($id_module); - -if ($module['name'] == 'Fatture di vendita') { - $dir = 'entrata'; - $conti = 'conti-vendite'; -} else { - $dir = 'uscita'; - $conti = 'conti-acquisti'; -} - -$info = $dbo->fetchOne('SELECT * FROM co_documenti WHERE id='.prepare($id_record)); -$numero = ($info['numero_esterno'] != '') ? $info['numero_esterno'] : $info['numero']; -$idanagrafica = $info['idanagrafica']; - -$idconto = ($dir == 'entrata') ? setting('Conto predefinito fatture di vendita') : setting('Conto predefinito fatture di acquisto'); - -/* - Form di inserimento riga documento -*/ - -echo ' -

    '.tr('Documento numero _NUM_', [ - '_NUM_' => $numero, -]).'

    - -
    - - - '; - -$rs = $dbo->fetchArray('SELECT - in_interventi.id, - CONCAT(\'Attività numero \', in_interventi.codice, \' del \', DATE_FORMAT(IFNULL((SELECT MIN(orario_inizio) FROM in_interventi_tecnici WHERE in_interventi_tecnici.idintervento=in_interventi.id), in_interventi.data_richiesta), \'%d/%m/%Y\'), " [", `in_statiintervento`.`descrizione` , "]") AS descrizione, - CONCAT(\'Attività numero \', in_interventi.codice, \' del \', DATE_FORMAT(IFNULL((SELECT MIN(orario_inizio) FROM in_interventi_tecnici WHERE in_interventi_tecnici.idintervento=in_interventi.id), in_interventi.data_richiesta), \'%d/%m/%Y\')) AS info, - CONCAT(\'\n\', in_interventi.descrizione) AS descrizione_intervento, - IF(idclientefinale='.prepare($idanagrafica).', \'Interventi conto terzi\', \'Interventi diretti\') AS `optgroup` - FROM - in_interventi INNER JOIN in_statiintervento ON in_interventi.idstatointervento=in_statiintervento.idstatointervento - WHERE - (in_interventi.idanagrafica='.prepare($idanagrafica).' OR in_interventi.idclientefinale='.prepare($idanagrafica).') - AND in_statiintervento.is_completato=1 AND in_statiintervento.is_fatturabile=1 - AND in_interventi.id NOT IN (SELECT idintervento FROM co_righe_documenti WHERE idintervento IS NOT NULL) - AND in_interventi.id_preventivo IS NULL - AND in_interventi.id_contratto IS NULL - AND in_interventi.id_ordine IS NULL - AND NOT in_interventi.id IN (SELECT idintervento FROM co_promemoria WHERE idintervento IS NOT NULL)'); -foreach ($rs as $key => $value) { - $intervento = \Modules\Interventi\Intervento::find($value['id']); - $prezzo = $intervento->totale; - - $rs[$key]['prezzo'] = Translator::numberToLocale($prezzo); - $rs[$key]['descrizione_intervento'] = strip_tags($rs[$key]['descrizione_intervento']); -} - -// Intervento -echo ' -
    -
    - {[ "type": "select", "label": "'.tr('Intervento').'", "name": "idintervento", "required": 1, "values": '.json_encode($rs).', "extra": "onchange=\"$data = $(this).selectData(); $(\'#descrizione\').val($data.info); if($(\'#copia_descrizione\').is(\':checked\')){ $(\'#descrizione\').val($data.info + $data.descrizione_intervento); }; $(\'#prezzo\').val($data.prezzo);\"" ]} -
    - -
    - {[ "type": "checkbox", "label": "'.tr('Copia descrizione').'", "name": "copia_descrizione", "placeholder": "'.tr('Copia anche la descrizione dell\'intervento').'." ]} -
    - -
    '; - -// Descrizione -echo ' -
    -
    - {[ "type": "textarea", "label": "'.tr('Descrizione').'", "name": "descrizione", "required": 1 ]} -
    -
    '; - -$options = [ - 'action' => 'add', - 'hide_conto' => true, - 'dir' => $dir, - 'superamento_soglia_qta' => setting('Permetti il superamento della soglia quantità dei documenti di origine'), -]; - -// Leggo la ritenuta d'acconto predefinita per l'anagrafica e se non c'è leggo quella predefinita generica -$ritenuta_acconto = $dbo->fetchOne('SELECT id_ritenuta_acconto_'.($dir == 'uscita' ? 'acquisti' : 'vendite').' AS id_ritenuta_acconto FROM an_anagrafiche WHERE idanagrafica='.prepare($idanagrafica)); -$options['id_ritenuta_acconto_predefined'] = $ritenuta_acconto['id_ritenuta_acconto']; - -echo App::internalLoad('conti.php', [], $options); - -// Leggo l'iva predefinita dall'articolo e se non c'è leggo quella predefinita generica -$idiva = $idiva ?: setting('Iva predefinita'); - -// Iva -echo ' -
    -
    - {[ "type": "select", "label": "'.tr('Iva').'", "name": "idiva", "required": 1, "value": "'.$idiva.'", "ajax-source": "iva", "help": "'.tr("L'aliquota IVA selezionata sovrascrive il valore predditivo presentato in Attività, modificando di conseguenza le sessioni di lavoro dei tecnici").'. '.tr('Righe generiche, articoli e sconti non verranno influenzati').'."]} -
    '; - -echo ' -
    - {[ "type": "select", "label": "'.tr('Conto').'", "name": "idconto", "required": 1, "value": "'.$idconto.'", "ajax-source": "'.$conti.'" ]} -
    -
    '; - -// Costo unitario -echo ' -
    -
    - {[ "type": "number", "label": "'.tr('Costo unitario').'", "name": "prezzo", "required": 1, "icon-after": "'.currency().'", "disabled": 1 ]} -
    -
    '; - -echo ' - - -
    -
    - -
    -
    -
    '; - -echo ' -'; diff --git a/modules/fatture/add_ordine.php b/modules/fatture/add_ordine.php deleted file mode 100755 index 90b047e69..000000000 --- a/modules/fatture/add_ordine.php +++ /dev/null @@ -1,87 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Fatture\Fattura; -use Modules\Ordini\Ordine; - -$documento_finale = Fattura::find($id_record); -$dir = $documento_finale->direzione; - -$id_documento = get('id_documento'); -if (!empty($id_documento)) { - $documento = Ordine::find($id_documento); - - $options = [ - 'op' => 'add_documento', - 'type' => 'ordine', - 'serials' => true, - 'button' => tr('Aggiungi'), - 'documento' => $documento, - 'documento_finale' => $documento_finale, - 'tipo_documento_finale' => Fattura::class, - 'superamento_soglia_qta' => setting('Permetti il superamento della soglia quantità dei documenti di origine'), - ]; - - echo App::load('importa.php', [], $options, true); - - return; -} - -$id_anagrafica = $documento_finale->idanagrafica; - -echo ' -
    -
    - {[ "type": "select", "label": "'.tr('Ordine').'", "name": "id_documento", "values": "query=SELECT or_ordini.id, CONCAT(IF(numero_esterno != \'\', numero_esterno, numero), \' del \', DATE_FORMAT(data, \'%d-%m-%Y\'), \' [\', (SELECT descrizione FROM or_statiordine WHERE id = idstatoordine) , \']\') AS descrizione FROM or_ordini WHERE idanagrafica='.prepare($id_anagrafica).' AND idstatoordine IN (SELECT id FROM or_statiordine WHERE descrizione IN(\'Accettato\', \'Evaso\', \'Parzialmente evaso\', \'Parzialmente fatturato\')) AND idtipoordine=(SELECT id FROM or_tipiordine WHERE dir='.prepare($dir).' LIMIT 0,1) AND or_ordini.id IN (SELECT idordine FROM or_righe_ordini WHERE or_righe_ordini.idordine = or_ordini.id AND (qta - qta_evasa) > 0) ORDER BY data DESC, numero DESC" ]} -
    -
    - -
    - -
    - -
    - '.tr('Caricamento in corso').'... -
    '; - -$file = basename(__FILE__); -echo ' - - -'; diff --git a/modules/fatture/add_preventivo.php b/modules/fatture/add_preventivo.php deleted file mode 100755 index 43e372c31..000000000 --- a/modules/fatture/add_preventivo.php +++ /dev/null @@ -1,86 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Fatture\Fattura; -use Modules\Preventivi\Preventivo; - -$documento_finale = Fattura::find($id_record); -$dir = $documento_finale->direzione; - -$id_documento = get('id_documento'); -if (!empty($id_documento)) { - $documento = Preventivo::find($id_documento); - - $options = [ - 'op' => 'add_documento', - 'type' => 'preventivo', - 'button' => tr('Aggiungi'), - 'documento' => $documento, - 'documento_finale' => $documento_finale, - 'tipo_documento_finale' => Fattura::class, - 'superamento_soglia_qta' => setting('Permetti il superamento della soglia quantità dei documenti di origine'), - ]; - - echo App::load('importa.php', [], $options, true); - - return; -} - -$id_anagrafica = $documento_finale->idanagrafica; - -echo ' -
    -
    - {[ "type": "select", "label": "'.tr('Preventivo').'", "name": "id_documento", "ajax-source": "preventivi", "select-options": {"idanagrafica": '.$id_anagrafica.', "stato": "is_fatturabile"} ]} -
    -
    - -
    - -
    - -
    - '.tr('Caricamento in corso').'... -
    '; - -$file = basename(__FILE__); -echo ' - - -'; diff --git a/modules/fatture/add_serial.php b/modules/fatture/add_serial.php deleted file mode 100755 index 6f7a1a11d..000000000 --- a/modules/fatture/add_serial.php +++ /dev/null @@ -1,159 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$module = Modules::get($id_module); - -// Controllo sulla direzione monetaria -$uscite = [ - 'Fatture di acquisto', - 'Ddt di acquisto', - 'Ordini fornitore', -]; - -if (in_array($module['name'], $uscite)) { - $dir = 'uscita'; -} else { - $dir = 'entrata'; -} - -$data = [ - 'fat' => [ - 'table' => 'co_righe_documenti', - 'id' => 'iddocumento', - ], - 'ddt' => [ - 'table' => 'dt_righe_ddt', - 'id' => 'idddt', - ], - 'ord' => [ - 'table' => 'or_righe_ordini', - 'id' => 'idordine', - ], - 'int' => [ - 'table' => 'in_righe_interventi', - 'id' => 'idintervento', - ], -]; - -// Individuazione delle tabelle interessate -if (in_array($module['name'], ['Fatture di vendita', 'Fatture di acquisto'])) { - $modulo = 'fat'; -} elseif (in_array($module['name'], ['Ddt di vendita', 'Ddt di acquisto'])) { - $modulo = 'ddt'; -} elseif (in_array($module['name'], ['Ordini cliente', 'Ordini fornitore'])) { - $modulo = 'ord'; -} else { - $modulo = 'int'; -} - -$table = $data[$modulo]['table']; -$id = $data[$modulo]['id']; -$riga = str_replace('id', 'id_riga_', $id); - -$idriga = get('idriga') ?: get('riga_id'); - -$rs = $dbo->fetchArray('SELECT mg_articoli.id AS idarticolo, mg_articoli.codice, mg_articoli.descrizione, '.$table.'.qta FROM '.$table.' INNER JOIN mg_articoli ON '.$table.'.idarticolo=mg_articoli.id WHERE '.$table.'.'.$id.'='.prepare($id_record).' AND '.$table.'.id='.prepare($idriga)); - -echo ' -

    '.tr('Articolo').': '.$rs[0]['codice'].' - '.$rs[0]['descrizione'].'

    - -
    - - - - - '; - -$info = $dbo->fetchArray('SELECT * FROM mg_prodotti WHERE serial IS NOT NULL AND '.$riga.'='.prepare($idriga)); -$serials = array_column($info, 'serial'); - -if ($dir == 'entrata') { - echo ' -
    -
    - {[ "type": "select", "label": "'.tr('Serial').'", "name": "serial[]", "multiple": 1, "value": "'.implode(',', $serials).'", "values": "query=SELECT serial AS id, serial AS descrizione FROM mg_prodotti WHERE id_articolo = '.prepare($rs[0]['idarticolo']).' AND mg_prodotti.dir=\'uscita\' AND id=(SELECT MAX(id) FROM mg_prodotti AS prodotti WHERE prodotti.id_articolo=mg_prodotti.id_articolo AND prodotti.serial=mg_prodotti.serial AND prodotti.dir=\'uscita\')" ]} -
    -
    '; -} else { - echo ' -

    '.tr('Inserisci i numeri seriali degli articoli aggiunti:').'

    '; - for ($i = 0; $i < $rs[0]['qta']; ++$i) { - if ($i % 3 == 0) { - echo ' -
    '; - } - - $res = []; - if (!empty($serials[$i])) { - $res = $dbo->fetchArray("SELECT * FROM mg_prodotti WHERE dir='entrata' AND serial = ".prepare($serials[$i])); - } - - echo ' -
    - {[ "type": "text", "name": "serial[]", "value": "'.$serials[$i].'"'.(!empty($res) ? ', "readonly": 1' : '').' ]}'; - - if (!empty($res)) { - if (!empty($res[0]['id_riga_intervento'])) { - $modulo = 'Interventi'; - $pos = 'int'; - } elseif (!empty($res[0]['id_riga_ddt'])) { - $modulo = 'Ddt di vendita'; - $pos = 'ddt'; - } elseif (!empty($res[0]['id_riga_documento'])) { - $modulo = 'Fatture di vendita'; - $pos = 'fat'; - } elseif (!empty($res[0]['id_riga_ordine'])) { - $modulo = 'Ordini cliente'; - $pos = 'ord'; - } - - $r = $dbo->select($data[$pos]['table'], $data[$pos]['id'], ['id' => $res[0][str_replace('id', 'id_riga_', $data[$pos]['id'])]]); - - echo ' - '.Modules::link($modulo, $r[0][$data[$pos]['id']], tr('Visualizza vendita'), null); - } - echo ' -
    '; - - if (($i + 1) % 3 == 0) { - echo ' -
    -
    '; - } - } - if ($i % 3 != 0) { - echo ' - '; - } -} - -echo ' - - -
    -
    - -
    -
    -
    '; - -echo ' -'; diff --git a/modules/fatture/ajax/search.php b/modules/fatture/ajax/search.php deleted file mode 100755 index e4da2f691..000000000 --- a/modules/fatture/ajax/search.php +++ /dev/null @@ -1,80 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -$fields = [ - 'Numero' => 'numero', - 'Numero secondario' => 'numero_esterno', - 'Data' => 'data', - 'Note' => 'note', - 'Note aggiuntive' => 'note_aggiuntive', - 'Buono d\'ordine' => 'buono_ordine', - 'Righe' => 'righe.descrizione', -]; - -$query = 'SELECT *, co_documenti.id, co_tipidocumento.descrizione AS tipologia'; - -foreach ($fields as $name => $value) { - $query .= ', '.$value." AS '".str_replace("'", "\'", $name)."'"; -} - -$query .= ' FROM co_documenti INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id LEFT JOIN (SELECT GROUP_CONCAT(descrizione SEPARATOR " -- ") AS "descrizione", iddocumento FROM co_righe_documenti GROUP BY iddocumento) righe ON righe.iddocumento=co_documenti.id WHERE idanagrafica IN('.implode(',', $idanagrafiche).') '; - -foreach ($fields as $name => $value) { - $query .= ' OR '.$value.' LIKE "%'.$term.'%"'; -} - -//$query .= Modules::getAdditionalsQuery('Interventi'); - -$rs = $dbo->fetchArray($query); - -foreach ($rs as $r) { - $result = []; - - $module = ($r['dir'] == 'uscita') ? 'Fatture di acquisto' : 'Fatture di vendita'; - $link_id = Modules::get($module)['id']; - - $numero = empty($r['numero_esterno']) ? $r['numero'] : $r['numero_esterno']; - - $result['link'] = base_path().'/editor.php?id_module='.$link_id.'&id_record='.$r['id']; - $result['title'] = $r['tipologia'].' num. '.$numero.' del '.Translator::dateToLocale($r['data']); - $result['category'] = $r['tipologia']; - - // Campi da evidenziare - $result['labels'] = []; - foreach ($fields as $name => $value) { - if (string_contains($r[$name], $term)) { - if ($name == 'Righe') { - $result['labels'][] = tr('Termine presente nelle righe del documento').'
    '; - } else { - $text = str_replace($term, "".$term.'', $r[$name]); - - $result['labels'][] = $name.': '.$text.'
    '; - } - } - } - - // Aggiunta nome anagrafica come ultimo campo - if (sizeof($ragioni_sociali) > 1) { - $result['labels'][] = 'Anagrafica: '.$ragioni_sociali[$r['idanagrafica']].'
    '; - } - - $results[] = $result; -} diff --git a/modules/fatture/ajax/select.php b/modules/fatture/ajax/select.php deleted file mode 100644 index aa4cbbef8..000000000 --- a/modules/fatture/ajax/select.php +++ /dev/null @@ -1,144 +0,0 @@ - 0 - ORDER BY data DESC, numero DESC'; - - $query_ddt = "SELECT dt_ddt.id, - CONCAT('DDT num. ', IF(numero_esterno != '', numero_esterno, numero), ' del ', DATE_FORMAT(data, '%d/%m/%Y'), ' [', (SELECT descrizione FROM dt_statiddt WHERE id = idstatoddt) , ']') AS text, - 'DDT' AS optgroup, - 'ddt' AS tipo, - 'uscita' AS dir - FROM dt_ddt - INNER JOIN dt_righe_ddt ON dt_righe_ddt.idddt = dt_ddt.id - WHERE idanagrafica = ".prepare($id_anagrafica)." AND - idstatoddt IN ( - SELECT id FROM dt_statiddt WHERE descrizione != 'Fatturato' - ) AND - idtipoddt IN ( - SELECT id FROM dt_tipiddt WHERE dir=".prepare($direzione).' - ) AND |where| - GROUP BY dt_ddt.id - HAVING SUM(dt_righe_ddt.qta - dt_righe_ddt.qta_evasa) > 0 - ORDER BY data DESC, numero DESC'; - - // Sostituzione per la ricerca - $query_ordini = replace($query_ordini, [ - '|where|' => $where, - ]); - - $query_ddt = replace($query_ddt, [ - '|where|' => $where, - ]); - - $ordini = $database->fetchArray($query_ordini); - $ddt = $database->fetchArray($query_ddt); - $results = array_merge($ordini, $ddt); - - break; - - case 'riferimenti-vendita-fe': - $direzione = 'entrata'; - $id_articolo = $superselect['id_articolo']; - if (empty($id_articolo)) { - return []; - } - - // Campi di ricerca - $search_fields = []; - if (!empty($search)) { - $search_fields[] = "IF(numero_esterno != '', numero_esterno, numero) LIKE ".prepare('%'.$search.'%'); - $search_fields[] = "DATE_FORMAT(data, '%d/%m/%Y') LIKE ".prepare('%'.$search.'%'); - } - - $where = implode(' OR ', $search_fields); - $where = $where ? '('.$where.')' : '1=1'; - - $query_ordini = "SELECT or_ordini.id, - CONCAT('Ordine num. ', IF(numero_esterno != '', numero_esterno, numero), ' del ', DATE_FORMAT(data, '%d/%m/%Y'), ' [', (SELECT descrizione FROM or_statiordine WHERE id = idstatoordine) , ']') AS text, - 'Ordini' AS optgroup, - 'ordine' AS tipo, - 'entrata' AS dir - FROM or_ordini - INNER JOIN or_righe_ordini ON or_righe_ordini.idordine = or_ordini.id - WHERE idarticolo = ".prepare($id_articolo)." AND - idstatoordine IN ( - SELECT id FROM or_statiordine WHERE descrizione != 'Fatturato' - ) AND - idtipoordine IN ( - SELECT id FROM or_tipiordine WHERE dir = ".prepare($direzione).' - ) AND |where| - GROUP BY or_ordini.id - ORDER BY data DESC, numero DESC'; - - $query_ddt = "SELECT dt_ddt.id, - CONCAT('DDT num. ', IF(numero_esterno != '', numero_esterno, numero), ' del ', DATE_FORMAT(data, '%d/%m/%Y'), ' [', (SELECT descrizione FROM dt_statiddt WHERE id = idstatoddt) , ']') AS text, - 'DDT' AS optgroup, - 'ddt' AS tipo, - 'entrata' AS dir - FROM dt_ddt - INNER JOIN dt_righe_ddt ON dt_righe_ddt.idddt = dt_ddt.id - WHERE idarticolo = ".prepare($id_articolo)." AND - idstatoddt IN ( - SELECT id FROM dt_statiddt WHERE descrizione != 'Fatturato' - ) AND - idtipoddt IN ( - SELECT id FROM dt_tipiddt WHERE dir=".prepare($direzione).' - ) AND |where| - GROUP BY dt_ddt.id - HAVING SUM(dt_righe_ddt.qta - dt_righe_ddt.qta_evasa) > 0 - ORDER BY data DESC, numero DESC'; - - // Sostituzione per la ricerca - $query_ordini = replace($query_ordini, [ - '|where|' => $where, - ]); - - $query_ddt = replace($query_ddt, [ - '|where|' => $where, - ]); - - $ordini = $database->fetchArray($query_ordini); - $ddt = $database->fetchArray($query_ddt); - $results = array_merge($ordini, $ddt); - - break; -} diff --git a/modules/fatture/bulk.php b/modules/fatture/bulk.php deleted file mode 100755 index d5cf59f05..000000000 --- a/modules/fatture/bulk.php +++ /dev/null @@ -1,486 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Aggiornamenti\Controlli\DatiFattureElettroniche; -use Modules\Fatture\Export\CSV; -use Modules\Fatture\Fattura; -use Plugins\ExportFE\FatturaElettronica; -use Plugins\ExportFE\Interaction; -use Util\XML; -use Util\Zip; - -switch (post('op')) { - case 'export-bulk': - $dir = base_dir().'/files/export_fatture/'; - directory($dir.'tmp/'); - - $dir = slashes($dir); - $zip = slashes($dir.'fatture_'.time().'.zip'); - - // Rimozione dei contenuti precedenti - $files = glob($dir.'/*.zip'); - foreach ($files as $file) { - delete($file); - } - - // Selezione delle fatture da stampare - $fatture = $dbo->fetchArray('SELECT co_documenti.id, numero_esterno, data, ragione_sociale, co_tipidocumento.descrizione FROM co_documenti INNER JOIN an_anagrafiche ON co_documenti.idanagrafica=an_anagrafiche.idanagrafica INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE co_documenti.id IN('.implode(',', $id_records).')'); - - if (!empty($fatture)) { - foreach ($fatture as $r) { - $print = Prints::getModulePredefinedPrint($id_module); - - Prints::render($print['id'], $r['id'], $dir.'tmp/'); - } - - // Creazione zip - if (extension_loaded('zip')) { - Zip::create($dir.'tmp/', $zip); - - // Invio al browser dello zip - download($zip); - - // Rimozione dei contenuti - delete($dir.'tmp/'); - } - } - - break; - - case 'exportFE-bulk': - $dir = base_dir().'/files/export_fatture/'; - directory($dir.'tmp/'); - - $dir = slashes($dir); - $zip = slashes($dir.'fattureFE_'.time().'.zip'); - - // Rimozione dei contenuti precedenti - $files = glob($dir.'/*.zip'); - foreach ($files as $file) { - delete($file); - } - - $module = Modules::get($id_module); - - if ($module['name'] == 'Fatture di vendita') { - $print_name = 'Fattura elettronica di vendita'; - } else { - $print_name = 'Fattura elettronica di acquisto'; - } - $print = $dbo->SelectOne('zz_prints', 'id', ['name' => $print_name]); - - if (!empty($id_records)) { - foreach ($id_records as $id_record) { - Prints::render($print['id'], $id_record, $dir.'tmp/'); - } - - // Creazione zip - if (extension_loaded('zip')) { - Zip::create($dir.'tmp/', $zip); - - // Invio al browser dello zip - download($zip); - - // Rimozione dei contenuti - delete($dir.'tmp/'); - } - } - - break; - - case 'genera-xml': - $failed = []; - $added = []; - - foreach ($id_records as $id) { - $fattura = Fattura::find($id); - - try { - $fattura_elettronica = new FatturaElettronica($id); - - if (!empty($fattura_elettronica) && !$fattura_elettronica->isGenerated()) { - $file = $fattura_elettronica->save($upload_dir); - $added[] = $fattura->numero_esterno; - } - } catch (UnexpectedValueException $e) { - $failed[] = $fattura->numero_esterno; - } - } - - if (!empty($failed)) { - flash()->warning(tr('Le fatture elettroniche _LIST_ non sono state generate.', [ - '_LIST_' => implode(', ', $failed), - ])); - } - - if (!empty($added)) { - flash()->info(tr('Le fatture elettroniche _LIST_ sono state generate.', [ - '_LIST_' => implode(', ', $added), - ])); - } - - break; - - case 'hook-send': - foreach ($id_records as $id) { - $fattura = Fattura::find($id); - - try { - $fattura_elettronica = new FatturaElettronica($fattura->id); - - if (!empty($fattura_elettronica) && $fattura_elettronica->isGenerated() && $fattura->codice_stato_fe == 'GEN') { - $fattura->codice_stato_fe = 'QUEUE'; - $fattura->data_stato_fe = date('Y-m-d H:i:s'); - $fattura->hook_send = true; - $fattura->save(); - - $added[] = $fattura->numero_esterno; - } - } catch (UnexpectedValueException $e) { - $failed[] = $fattura->numero_esterno; - } - } - - flash()->info(tr('Le fatture elettroniche sono state aggiunte alla coda di invio')); - - break; - - case 'export-xml-bulk': - $dir = base_dir().'/files/export_fatture/'; - directory($dir.'tmp/'); - - $dir = slashes($dir); - $zip = slashes($dir.'fatture_'.time().'.zip'); - - // Rimozione dei contenuti precedenti - $files = glob($dir.'/*.zip'); - foreach ($files as $file) { - delete($file); - } - - // Selezione delle fatture da esportare - $fatture = $dbo->fetchArray('SELECT co_documenti.id, numero_esterno, data, ragione_sociale, co_tipidocumento.descrizione, co_tipidocumento.dir FROM co_documenti INNER JOIN an_anagrafiche ON co_documenti.idanagrafica=an_anagrafiche.idanagrafica INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id INNER JOIN co_statidocumento ON co_documenti.idstatodocumento=co_statidocumento.id WHERE co_documenti.id IN('.implode(',', $id_records).')'); - - $failed = []; - $added = 0; - if (!empty($fatture)) { - foreach ($fatture as $r) { - $fattura = Fattura::find($r['id']); - $include = true; - - try { - if ($r['dir'] == 'entrata') { - $fe = new FatturaElettronica($fattura->id); - $include = $fe->isGenerated(); - } else { - $include = $fattura->isFE(); - } - } catch (UnexpectedValueException $e) { - $include = false; - } - - if (!$include) { - $failed[] = $fattura->numero_esterno; - } else { - if ($r['dir'] == 'entrata') { - $src = $fe->getFilename(); - $dst = $src; - } else { - $src = basename($fattura->uploads()->where('name', 'Fattura Elettronica')->first()->filepath); - $dst = basename($fattura->uploads()->where('name', 'Fattura Elettronica')->first()->original_name); - } - - $file = slashes($module->upload_directory.'/'.$src); - $dest = slashes($dir.'/tmp/'.$dst); - - $result = copy($file, $dest); - - if ($result) { - ++$added; - //operationLog('export-xml-bulk', ['id_record' => $r['id']]); - } else { - $failed[] = $fattura->numero_esterno; - } - } - } - - // Creazione zip - if (extension_loaded('zip') and !empty($added)) { - Zip::create($dir.'tmp/', $zip); - - // Invio al browser il file zip - download($zip); - - // Rimozione dei contenuti - delete($dir.'tmp/'); - } - - if (!empty($failed)) { - flash()->warning(tr('Le fatture elettroniche _LIST_ non sono state incluse poichè non ancora generate o non presenti sul server', [ - '_LIST_' => implode(', ', $failed), - ])); - } - } - break; - - case 'copy-bulk': - $list = []; - foreach ($id_records as $id) { - $fattura = Fattura::find($id); - array_push($list, $fattura->numero_esterno); - - $id_segment = (post('id_segment') ? post('id_segment') : $fattura->id_segment); - $dir = $dbo->fetchOne('SELECT dir FROM co_tipidocumento WHERE id='.prepare($fattura->idtipodocumento))['dir']; - - //+ 1 giorno - if (post('skip_time') == 'Giorno') { - $data = date('Y-m-d', strtotime('+1 day', strtotime($fattura->data))); - } - - //+ 1 settimana - if (post('skip_time') == 'Settimana') { - $data = date('Y-m-d', strtotime('+1 week', strtotime($fattura->data))); - } - - //+ 1 mese - if (post('skip_time') == 'Mese') { - $data = date('Y-m-d', strtotime('+1 month', strtotime($fattura->data))); - } - - //+ 1 anno - if (post('skip_time') == 'Anno') { - $data = date('Y-m-d', strtotime('+1 year', strtotime($fattura->data))); - } - - $new = $fattura->replicate(); - - $new->data = $data; - $new->id_segment = $id_segment; - $new->numero = Fattura::getNextNumero($data, $dir, $id_segment); - - $new->save(); - - $righe = $fattura->getRighe(); - foreach ($righe as $riga) { - $new_riga = $riga->replicate(); - $new_riga->setDocument($new); - - if (!post('riferimenti')) { - $new_riga->idpreventivo = 0; - $new_riga->idcontratto = 0; - $new_riga->idintervento = 0; - $new_riga->idddt = 0; - $new_riga->idordine = 0; - } - - $new_riga->save(); - - if ($new_riga->isArticolo()) { - $new_riga->movimenta($new_riga->qta); - } - } - } - - flash()->info(tr('Fatture _LIST_ duplicate correttamente!', [ - '_LIST_' => implode(',', $list), - ])); - - break; - - case 'check-bulk': - $controllo = new DatiFattureElettroniche(); - $fatture = []; - foreach ($id_records as $id) { - $fattura_vendita = Fattura::vendita() - ->whereNotIn('codice_stato_fe', ['ERR', 'NS', 'EC02', 'ERVAL']) - ->where('data', '>=', $_SESSION['period_start']) - ->where('data', '<=', $_SESSION['period_end']) - ->where('id', '=', $id) - ->orderBy('data') - ->first(); - - if (!empty($fattura_vendita)) { - $fatture[$id] = $fattura_vendita; - - $controllo->checkFattura($fattura_vendita); - } - } - - $results = $controllo->getResults(); - $num = count($results); - - // Messaggi di risposta - if (empty($fatture)) { - flash()->warning(tr('Nessuna fattura utile per il controllo!')); - } elseif (empty($results)) { - flash()->info(tr('Nessuna anomalia!')); - } else { - flash()->info(tr('Fatture _LIST_ controllate.', [ - '_LIST_' => implode(',', array_column($results, 'numero')), - ])); - - $riepilogo_anomalie = tr('Attenzione: Trovate _NUM_ anomalie! Le seguenti fatture non trovano corrispondenza tra XML e dati nel documento', ['_NUM_' => $num]).':

    '; - - foreach ($results as $anomalia) { - $fattura = $fatture[$anomalia['id']]; - - $riepilogo_anomalie .= '
      -
    • '.reference($fattura, $fattura->getReference()).'
    • -
    • '.$anomalia['descrizione'].'
    • -

    '; - } - - flash()->warning($riepilogo_anomalie); - } - break; - - case 'export-csv': - $file = temp_file(); - $exporter = new CSV($file); - - // Esportazione dei record selezionati - $fatture = Fattura::whereIn('id', $id_records)->get(); - $exporter->setRecords($fatture); - - $count = $exporter->exportRecords(); - - download($file, 'fatture.csv'); - - break; - - case 'delete-bulk': - foreach ($id_records as $id) { - $documento = Fattura::find($id); - try { - $documento->delete(); - } catch (InvalidArgumentException $e) { - } - } - - flash()->info(tr('Fatture eliminate!')); - break; -} - -if (App::debug()) { - $operations['delete-bulk'] = [ - 'text' => ' '.tr('Elimina selezionati').' beta', - ]; - - $operations['export-csv'] = [ - 'text' => ' '.tr('Esporta selezionati').' beta', - 'data' => [ - 'msg' => tr('Vuoi davvero esportare un CSV con tutte le fatture?'), - 'button' => tr('Procedi'), - 'class' => 'btn btn-lg btn-danger', - 'blank' => true, - ], - ]; -} - -$operations['copy-bulk'] = [ - 'text' => ' '.tr('Duplica selezionati').'', - 'data' => [ - 'msg' => tr('Vuoi davvero duplicare le righe selezionate?').'

    {[ "type": "select", "label": "'.tr('Fattura in avanti di').'", "name": "skip_time", "required": 1, "values": "list=\"Giorno\":\"'.tr('Un giorno').'\", \"Settimana\":\"'.tr('Una settimana').'\", \"Mese\":\"'.tr('Un mese').'\", \"Anno\":\"'.tr('Un anno').'\" ", "value": "Giorno" ]}
    {[ "type": "select", "label": "'.tr('Sezionale').'", "name": "id_segment", "required": 1, "values": "query=SELECT id, name AS descrizione FROM zz_segments WHERE id_module='.$id_module.' ORDER BY name", "value": "'.$_SESSION['module_'.$id_module]['id_segment'].'" ]}
    {[ "type": "checkbox", "label": "'.tr('Aggiungere i riferimenti ai documenti esterni?').'", "placeholder": "'.tr('Aggiungere i riferimenti ai documenti esterni?').'", "name": "riferimenti" ]}', - 'button' => tr('Procedi'), - 'class' => 'btn btn-lg btn-warning', - ], -]; - -$operations['registrazione-contabile'] = [ - 'text' => ' '.tr('Registrazione contabile').'', - 'data' => [ - 'title' => tr('Registrazione contabile'), - 'type' => 'modal', - 'origine' => 'fatture', - 'url' => base_path().'/add.php?id_module='.Modules::get('Prima nota')['id'], - ], -]; - -$operations['exportFE-bulk'] = [ - 'text' => ' '.tr('Esporta stampe FE').'', - 'data' => [ - 'title' => '', - 'msg' => tr('Vuoi davvero esportare i PDF delle fatture elettroniche selezionate in un archivio ZIP?'), - 'button' => tr('Procedi'), - 'class' => 'btn btn-lg btn-warning', - 'blank' => true, - ], -]; - -if ($module->name == 'Fatture di vendita') { - $operations['genera-xml'] = [ - 'text' => ' '.tr('Genera fatture elettroniche').'', - 'data' => [ - 'title' => '', - 'msg' => tr('Generare le fatture elettroniche per i documenti selezionati?
    (le fatture dovranno trovarsi nello stato Emessa e non essere mai state generate)'), - 'button' => tr('Procedi'), - 'class' => 'btn btn-lg btn-warning', - 'blank' => true, - ], - ]; - - $operations['export-bulk'] = [ - 'text' => ' '.tr('Esporta stampe').'', - 'data' => [ - 'title' => '', - 'msg' => tr('Vuoi davvero esportare i PDF delle fatture selezionate in un archivio ZIP?'), - 'button' => tr('Procedi'), - 'class' => 'btn btn-lg btn-warning', - 'blank' => true, - ], - ]; - - $operations['check-bulk'] = [ - 'text' => ' '.tr('Controlla fatture elettroniche').'', - 'data' => [ - 'title' => '', - 'msg' => tr('Controllare corrispondenza tra XML e fattura di vendita?
    (le fatture dovranno essere state generate)'), - 'button' => tr('Procedi'), - 'class' => 'btn btn-lg btn-warning', - 'blank' => true, - ], - ]; -} - -$operations['export-xml-bulk'] = [ - 'text' => ' '.tr('Esporta XML').'', - 'data' => [ - 'title' => '', - 'msg' => tr('Vuoi davvero esportare le fatture elettroniche selezionate in un archivio ZIP?'), - 'button' => tr('Procedi'), - 'class' => 'btn btn-lg btn-warning', - 'blank' => true, - ], -]; - -if (Interaction::isEnabled()) { - $operations['hook-send'] = [ - 'text' => ' '.tr('Coda di invio FE').'', - 'data' => [ - 'title' => '', - 'msg' => tr('Vuoi davvero aggiungere queste fatture alla coda di invio per le fatture elettroniche?'), - 'button' => tr('Procedi'), - 'class' => 'btn btn-lg btn-warning', - ], - ]; -} - -return $operations; diff --git a/modules/fatture/buttons.php b/modules/fatture/buttons.php deleted file mode 100755 index 27c96d01c..000000000 --- a/modules/fatture/buttons.php +++ /dev/null @@ -1,111 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo ' -'; - -if ($module->name == 'Fatture di vendita') { - $attributi_visibili = $record['dati_aggiuntivi_fe'] != null || $record['stato'] == 'Bozza'; - - echo ' - - '.tr('Attributi avanzati').' -'; -} - -if ($dir == 'entrata') { - echo ' -'; -} - -if (empty($record['is_fiscale'])) { - $msg = '
    {[ "type": "select", "label": "'.tr('Sezionale').'", "name": "id_segment", "required": 1, "values": "query=SELECT id, name AS descrizione FROM zz_segments WHERE id_module=\''.$id_module.'\' AND is_fiscale = 1 ORDER BY name" ]} - {[ "type": "date", "label": "'.tr('Data').'", "name": "data", "required": 1, "value": "-now-" ]}'; - - echo ' - '; -} - -$modulo_prima_nota = Modules::get('Prima nota'); -$totale_scadenze = $dbo->fetchOne('SELECT SUM(da_pagare - pagato) AS differenza, SUM(da_pagare) AS da_pagare FROM co_scadenziario WHERE iddocumento = '.prepare($id_record)); -if (!empty($record['is_fiscale'])) { - // Aggiunta insoluto - $registrazione_insoluto = 0; - $pagamento = $fattura->pagamento; - if (!empty($pagamento)) { - if ($pagamento->isRiBa() && $dir == 'entrata' && in_array($record['stato'], ['Emessa', 'Parzialmente pagato', 'Pagato'])) { - $registrazione_insoluto = 1; - } - } - - if (floatval($totale_scadenze['da_pagare']) == 0) { - $registrazione_insoluto = 0; - } - - echo ' - - '.tr('Registra insoluto').' - '; - - // Aggiunta prima nota solo se non c'è già, se non si è in bozza o se il pagamento non è completo - $prima_nota_presente = $dbo->fetchNum('SELECT id FROM co_movimenti WHERE iddocumento = '.prepare($id_record).' AND primanota = 1'); - - $differenza = isset($totale_scadenze) ? $totale_scadenze['differenza'] : 0; - $registrazione_contabile = 0; - if ($differenza != 0 || (!$prima_nota_presente && $record['stato'] == 'Emessa')) { - $registrazione_contabile = 1; - } - - if (floatval($totale_scadenze['da_pagare']) == 0) { - $registrazione_contabile = 0; - } - - echo ' - - '.tr('Registra contabile').' - '; - - if ($record['stato'] == 'Pagato') { - echo ' - '; - } -} diff --git a/modules/fatture/crea_documento.php b/modules/fatture/crea_documento.php deleted file mode 100755 index e1d0cb10b..000000000 --- a/modules/fatture/crea_documento.php +++ /dev/null @@ -1,39 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Fatture\Fattura; - -$documento = Fattura::find($id_record); -$tipo_documento_finale = Fattura::class; - -$options = [ - 'type' => 'nota_credito', - 'op' => 'nota_credito', - 'serials' => true, - 'module' => 'Fatture di vendita', - 'documento' => $documento, - 'tipo_documento_finale' => $tipo_documento_finale, - 'button' => tr('Aggiungi'), - 'create_document' => true, - 'allow-empty' => true, -]; - -echo App::load('importa.php', [], $options, true); diff --git a/modules/fatture/edit.php b/modules/fatture/edit.php deleted file mode 100755 index e782b20fb..000000000 --- a/modules/fatture/edit.php +++ /dev/null @@ -1,991 +0,0 @@ -. - */ - -use Carbon\Carbon; -use Modules\Anagrafiche\Anagrafica; -use Modules\Anagrafiche\Nazione; -use Modules\Fatture\Gestori\Bollo; -use Modules\Interventi\Intervento; -use Modules\Iva\Aliquota; - -include_once __DIR__.'/../../core.php'; - -$anagrafica_azienda = Anagrafica::find(setting('Azienda predefinita')); - -$block_edit = !empty($note_accredito) || in_array($record['stato'], ['Emessa', 'Pagato', 'Parzialmente pagato']) || !$abilita_genera; - -if ($dir == 'entrata') { - $conto = 'vendite'; -} else { - $conto = 'acquisti'; -} - -// Informazioni sulla dichiarazione d'intento, visibili solo finchè la fattura è in bozza -if ($dir == 'entrata' && !empty($fattura->dichiarazione) && $fattura->stato->descrizione == 'Bozza') { - $diff = $fattura->dichiarazione->massimale - $fattura->dichiarazione->totale; - - $id_iva = setting("Iva per lettere d'intento"); - $iva = Aliquota::find($id_iva); - - if (!empty($iva)) { - if ($diff > 0) { - echo ' -
    - '.tr("La fattura è collegata a una dichiarazione d'intento con diponibilità di _MONEY_: per collegare una riga alla dichiarazione è sufficiente inserire come IVA _IVA_", [ - '_MONEY_' => moneyFormat(abs($diff)), - '_IVA_' => '"'.$iva->descrizione.'"', - ]).'. -
    '; - } elseif ($diff == 0) { - echo ' -
    - '.tr("La dichiarazione d'intento ha raggiunto il massimale previsto di _MONEY_: le nuove righe della fattura devono presentare IVA diversa da _IVA_", [ - '_MONEY_' => moneyFormat(abs($fattura->dichiarazione->massimale)), - '_IVA_' => '"'.$iva->descrizione.'"', - ]).'. -
    '; - } else { - echo ' -
    - '.tr("La dichiarazione d'intento ha superato il massimale previsto di _MONEY_: per rimuovere righe della fattura dalla dichiarazione è sufficiente modificare l'IVA in qualcosa di diverso da _IVA_", [ - '_MONEY_' => moneyFormat(abs($diff)), - '_IVA_' => '"'.$iva->descrizione.'"', - ]).'. -
    '; - } - } else { - //TODO link ad impostazioni con nuova ricerca rapida - echo ' -
    - '.tr("Attenzione nessuna aliq. IVA definita per la dichiarazione d'intento. _SETTING_", [ - '_SETTING_' => Modules::link('Impostazioni', null, tr('Selezionala dalle impostazioni'), true, null, true, null, "&search=Iva per lettere d'intento"), - ]).' -
    '; - } -} - -// Verifica aggiuntive sulla sequenzialità dei numeri -if ($dir == 'entrata') { - $numero_previsto = verifica_numero_fattura($fattura); - if (!empty($numero_previsto)) { - echo ' -
    - '.tr("E' assente una fattura di vendita di numero _NUM_ in data precedente o corrispondente a _DATE_: si potrebbero verificare dei problemi con la numerazione corrente delle fatture", [ - '_DATE_' => dateFormat($fattura->data), - '_NUM_' => '"'.$numero_previsto.'"', - ]).'. -
    '; - } - - // Verifica la data dell'intervento rispetto alla data della fattura - $righe_interventi = $fattura->getRighe()->where('idintervento', '!=', null); - if (!empty($righe_interventi)) { - foreach ($righe_interventi as $riga_intervento) { - $intervento = Intervento::find($riga_intervento->idintervento); - - if ((new Carbon($intervento->fine))->diffInDays(new Carbon($fattura->data), false) < 0) { - $fatturazione_futura = true; - break; - } - } - - if ($fatturazione_futura) { - echo ' -
    - '.tr("Stai fatturando un'attività futura rispetto alla data di fatturazione.").' -
    '; - } - } -} -?> -
    - - - - - -
    -
    -

    -
    - -
    - - fetchArray('SELECT piva, codice_fiscale, citta, indirizzo, cap, provincia, id_nazione, tipo FROM an_anagrafiche WHERE idanagrafica='.prepare($record['idanagrafica'])); - $campi_mancanti = []; - - //di default è un azienda e chiedo la partita iva - if (empty($rs2[0]['piva']) and empty($rs2[0]['codice_fiscale']) and (empty($rs2[0]['tipo']) or $rs2[0]['tipo'] == 'Azienda')) { - array_push($campi_mancanti, 'Partita IVA'); - array_push($campi_mancanti, 'Codice fiscale'); - } - - $nazione = Nazione::find($rs2[0]['id_nazione']); - //se è un privato o un ente pubblico controllo il codice fiscale - if ((($rs2[0]['tipo'] == 'Privato' && $nazione->iso2 == 'IT') or $rs2[0]['tipo'] == 'Ente pubblico') and empty($rs2[0]['codice_fiscale'])) { - array_push($campi_mancanti, 'Codice fiscale'); - } - - if ($rs2[0]['citta'] == '') { - array_push($campi_mancanti, 'Città'); - } - if ($rs2[0]['indirizzo'] == '') { - array_push($campi_mancanti, 'Indirizzo'); - } - if ($rs2[0]['cap'] == '') { - array_push($campi_mancanti, 'C.A.P.'); - } - if (empty($rs2[0]['id_nazione'])) { - array_push($campi_mancanti, 'Nazione'); - } - - if (sizeof($campi_mancanti) > 0) { - echo "
    Prima di procedere alla stampa completa i seguenti campi dell'anagrafica Cliente: ".implode(', ', $campi_mancanti).'
    - '.Modules::link('Anagrafiche', $record['idanagrafica'], tr('Vai alla scheda anagrafica'), null).'
    '; - } - } - ?> - -
    - - {[ "type": "text", "label": "'.tr('Numero fattura/protocollo').'", "required": 1, "name": "numero","class": "text-center alphanumeric-mask", "value": "$numero$" ]} -
    '; - $label = tr('N. fattura del fornitore'); - $size = 2; - } else { - $label = tr('Numero fattura'); - $size = 4; - } - ?> - - - {[ "type": "hidden", "label": "Segmento", "name": "id_segment", "class": "text-center", "value": "$id_segment$" ]} - -
    - {[ "type": "text", "label": "", "required": "", "name": "numero_esterno", "class": "text-center", "value": "$numero_esterno$", "help": "" ]} -
    - -
    - {[ "type": "date", "label": "", "name": "data", "required": 1, "value": "$data$" ]} -
    - -fetchArray("SELECT id FROM zz_plugins WHERE name='Fatturazione Elettronica' AND idmodule_to = ".prepare($id_module)); - echo ''; -} -// Forzo il passaggio della fattura da Bozza ad Emessa per il corretto calcolo del numero. -elseif ($record['stato'] == 'Bozza') { - $query .= " WHERE descrizione IN ('Emessa', 'Bozza')"; -} - -?> - - -
    > - {[ "type": "date", "label": "", "name": "data_registrazione", "value": "$data_registrazione$", "help": "" ]} -
    - - -
    > - {[ "type": "date", "class":"data_competenza) <= dateFormat($fattura->data)) ? 'unblockable' : ''; ?>", "label": "", "name": "data_competenza", "required": 1, "value": "$data_competenza$", "min-date": "$data$", "help": "" ]} -
    - - - -
    > - {[ "type": "select", "label": "", "name": "codice_stato_fe", "values": "query=SELECT codice as id, CONCAT_WS(' - ',codice,descrizione) as text FROM fe_stati_documento", "value": "$codice_stato_fe$", "disabled": , "class": "unblockable", "help": "" ]} -
    - - - - {[ "type": "select", "label": "'.tr('Stato').'", "name": "idstatodocumento", "required": 1, "values": "query='.$query.'", "value": "$idstatodocumento$", "class": "'.(($record['stato'] != 'Bozza' && !$abilita_genera) ? '' : 'unblockable').'", "extra": "onchange=\"return cambiaStato()\"" ]} -
    -
    - -
    -
    - '.Modules::link('Anagrafiche', $record['idanagrafica'], null, null, 'class="pull-right"'); - - if ($dir == 'entrata') { - ?> - {[ "type": "select", "label": "", "name": "idanagrafica", "required": 1, "ajax-source": "clienti", "help": "fetchOne('SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica = '.prepare(setting('Azienda predefinita')))['ragione_sociale']); ?>", "value": "$idanagrafica$" ]} - - {[ "type": "select", "label": "", "name": "idanagrafica", "required": 1, "ajax-source": "fornitori", "value": "$idanagrafica$" ]} - '; - - if ($dir == 'entrata') { - echo ' -
    - {[ "type": "select", "label": "'.tr('Agente di riferimento').'", "name": "idagente", "ajax-source": "agenti", "select-options": {"idanagrafica": '.$record['idanagrafica'].'}, "value": "$idagente_fattura$" ]} -
    '; - } - - echo ' -
    '; - if (!empty($record['idreferente'])) { - echo Plugins::link('Referenti', $record['idanagrafica'], null, null, 'class="pull-right"'); - } - echo ' - {[ "type": "select", "label": "'.tr('Referente').'", "name": "idreferente", "value": "$idreferente$", "ajax-source": "referenti", "select-options": {"idanagrafica": '.$record['idanagrafica'].'} ]} -
    '; - - // Conteggio numero articoli fatture - $articolo = $dbo->fetchArray('SELECT mg_articoli.id FROM ((mg_articoli INNER JOIN co_righe_documenti ON mg_articoli.id=co_righe_documenti.idarticolo) INNER JOIN co_documenti ON co_documenti.id=co_righe_documenti.iddocumento) WHERE co_documenti.id='.prepare($id_record)); - $id_modulo_anagrafiche = Modules::get('Anagrafiche')['id']; - $id_plugin_sedi = Plugins::get('Sedi')['id']; - if ($dir == 'entrata') { - echo ' -
    - {[ "type": "select", "label": "'.tr('Partenza merce').'", "name": "idsede_partenza", "ajax-source": "sedi_azienda", "value": "$idsede_partenza$", "readonly": "'.(sizeof($articolo) ? 1 : 0).'", "help": "'.tr("Sedi di partenza dell'azienda").'" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Destinazione merce').'", "name": "idsede_destinazione", "ajax-source": "sedi", "select-options": {"idanagrafica": '.$record['idanagrafica'].'}, "value": "$idsede_destinazione$", "help": "'.tr('Sedi del destinatario').'", "icon-after": "add|'.$id_modulo_anagrafiche.'|id_plugin='.$id_plugin_sedi.'&id_parent='.$record['idanagrafica'].'||'.(intval($block_edit) ? 'disabled' : '').'" ]} -
    '; - } else { - echo ' -
    - {[ "type": "select", "label": "'.tr('Partenza merce').'", "name": "idsede_partenza", "ajax-source": "sedi", "select-options": {"idanagrafica": '.$record['idanagrafica'].'}, "value": "$idsede_partenza$", "help": "'.tr('Sedi del mittente').'", "icon-after": "add|'.$id_modulo_anagrafiche.'|id_plugin='.$id_plugin_sedi.'&id_parent='.$record['idanagrafica'].'||'.(intval($block_edit) ? 'disabled' : '').'" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Destinazione merce').'", "name": "idsede_destinazione", "ajax-source": "sedi_azienda", "value": "$idsede_destinazione$", "help": "'.tr("Sedi di arrivo dell'azienda").'" ]} -
    '; - } - ?> -
    -
    - - -
    -
    - - - {[ "type": "select", "label": "", "name": "idtipodocumento", "required": 1, "values": "query=SELECT id, CONCAT_WS(\" - \",codice_tipo_documento_fe, descrizione) AS descrizione FROM co_tipidocumento WHERE dir='' AND (reversed = 0 OR id = ) ORDER BY codice_tipo_documento_fe", "value": "$idtipodocumento$", "readonly": , "help": "fetchOne('SELECT tipo FROM an_anagrafiche WHERE idanagrafica = '.prepare($record['idanagrafica']))['tipo'] == 'Ente pubblico') ? 'FPA12 - fattura verso PA (Ente pubblico)' : 'FPR12 - fattura verso soggetti privati (Azienda o Privato)'; ?>" ]} -
    - -
    - - - {[ "type": "select", "label": "", "name": "idpagamento", "required": 1, "ajax-source": "pagamenti", "value": "$idpagamento$", "extra": "onchange=\"$('#id_banca_azienda').selectSetNew( $(this).selectData().id_banca_, $(this).selectData().descrizione_banca_ ).change(); \" " ]} -
    - -
    - {[ "type": "select", "label": "", "name": "id_banca_azienda", "ajax-source": "banche", "select-options": $anagrafica_azienda->id]); ?>, "value": "$id_banca_azienda$", "icon-after": "add||id_anagrafica=id; ?>", "extra": " " ]} -
    - - scadenze; - - $ricalcola = true; - foreach ($scadenze as $scadenza) { - $ricalcola = empty(floatval($scadenza->pagato)) && $ricalcola; - } - - echo ' -
    -

    '.tr('Scadenze').'

    - -
    - '.Modules::link('Scadenzario', $scadenze[0]['id'], tr(''), '', 'class="btn btn-xs btn-primary"'); - - // Ricalcola scadenze disponibile solo per fatture di acquisto - if ($fattura->isFE() && $ricalcola && $module['name'] == 'Fatture di acquisto') { - echo ' - '; - } - echo ' -
    -
    '; - - foreach ($scadenze as $scadenza) { - $pagamento_iniziato = !empty(floatval($scadenza->pagato)) || $scadenza->da_pagare == 0; - - echo ' -

    '.dateFormat($scadenza['scadenza']).': '; - - if ($pagamento_iniziato) { - echo ' - '; - } - - echo(empty($scadenza->da_pagare) ? '' : '').moneyFormat($scadenza->da_pagare); - - if ($pagamento_iniziato) { - echo ' - '; - } - - if ($pagamento_iniziato && $scadenza->pagato != $scadenza->da_pagare) { - echo ' ('.moneyFormat($scadenza->da_pagare - $scadenza->pagato).')'; - } - - echo ' -

    '; - } - - echo ' -
    '; - } - ?> -
    - -
    -
    - {[ "type": "checkbox", "label": "", "name": "split_payment", "value": "$split_payment$", "help": "", "placeholder": "" ]} -
    - - -
    - {[ "type": "checkbox", "label": "", "name": "is_fattura_conto_terzi", "value": "$is_fattura_conto_terzi$", "help": "fetchOne('SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica = '.prepare(setting('Azienda predefinita')))['ragione_sociale']).') come cessionario e il cliente come cedente/prestatore.'); ?>", "placeholder": "" ]} -
    - - - -
    - - {[ "type": "select", "label": "", "name": "id_ritenuta_contributi", "value": "$id_ritenuta_contributi$", "values": "query=SELECT *, CONCAT(descrizione,(IF(percentuale>0, CONCAT(\" - \", percentuale, \"% sul \", percentuale_imponibile, \"% imponibile\"), \"\"))) AS descrizione FROM co_ritenuta_contributi", "help": "" ]} -
    - - - {[ "type": "checkbox", "label": "'.tr('Ritenuta pagata dal fornitore').'", "name": "is_ritenuta_pagata", "value": "$is_ritenuta_pagata$" ]} -
    '; - } - if ($dir == 'entrata') { - echo ' -
    '; - - if (!empty($record['id_dichiarazione_intento'])) { - echo Plugins::link("Dichiarazioni d'Intento", $record['idanagrafica'], null, null, 'class="pull-right"'); - } - - echo ' - {[ "type": "select", "label": "'.tr("Dichiarazione d'intento").'", "name": "id_dichiarazione_intento", "ajax-source": "dichiarazioni_intento", "select-options": {"idanagrafica": '.$record['idanagrafica'].', "data": "'.$record['data'].'"},"value": "$id_dichiarazione_intento$" ]} -
    '; - } - echo ' -
    '; - - if ($dir == 'entrata') { - echo ' -
    -
    - {[ "type": "checkbox", "label": "'.tr('Marca da bollo automatica').'", "name": "bollo_automatico", "value": "'.intval(!isset($record['bollo'])).'", "help": "'.tr("Seleziona per impostare automaticamente l'importo della marca da bollo").'. '.tr('Applicata solo se il totale della fattura è maggiore di _MONEY_', [ - '_MONEY_' => moneyFormat(setting("Soglia minima per l'applicazione della marca da bollo")), - ]).'.", "placeholder": "'.tr('Bollo automatico').'" ]} -
    - -
    - {[ "type": "checkbox", "label": "'.tr('Addebita marca da bollo').'", "name": "addebita_bollo", "value": "$addebita_bollo$" ]} -
    - -
    - {[ "type": "number", "label": "'.tr('Importo marca da bollo').'", "name": "bollo", "value": "$bollo$"]} -
    - -
    - {[ "type": "number", "label": "'.tr('Sconto finale').'", "name": "sconto_finale", "value": "'.($fattura->sconto_finale_percentuale ?: $fattura->sconto_finale).'", "icon-after": "choice|untprc|'.(empty($fattura->sconto_finale) ? 'PRC' : 'UNT').'", "help": "'.tr('Sconto finale in fattura, utilizzabile per applicare sconti sul Netto a pagare del documento e le relative scadenze').'. '.tr('Per utilizzarlo in relazione a una riga della Fattura Elettronica, inserire il testo di descrizione in \'\'Attributi avanzati\'\' -> \'\'Altri Dati Gestionali\'\' -> \'\'Riferimento Testo\'\' della specifica riga').'. '.tr('Nota: lo sconto finale in fattura non influenza i movimenti contabili').'." ]} -
    -
    '; - - $bollo = new Bollo($fattura); - } -?> -
    -
    - {[ "type": "textarea", "label": "", "name": "note", "help": "", "value": "$note$" ]} -
    -
    - -
    -
    - {[ "type": "textarea", "label": "", "name": "note_aggiuntive", "help": "", "value": "$note_aggiuntive$", "class": "unblockable" ]} -
    -
    - - - - -
    -

    '.tr('Dati Fattura accompagnatoria').'

    -
    - -
    -
    -
    - {[ "type": "select", "label": "'.tr('Aspetto beni').'", "name": "idaspettobeni", "placeholder": "", "ajax-source": "aspetto-beni", "value": "$idaspettobeni$", "icon-after": "add|'.Modules::get('Aspetto beni')['id'].'||'.(($record['stato'] != 'Bozza') ? 'disabled' : '').'" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Causale trasporto').'", "name": "idcausalet", "placeholder": "", "ajax-source": "causali", "value": "$idcausalet$", "icon-after": "add|'.Modules::get('Causali')['id'].'||'.(($record['stato'] != 'Bozza') ? 'disabled' : '').'" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Porto').'", "name": "idporto", "placeholder": "", "values": "query=SELECT id, descrizione FROM dt_porto ORDER BY descrizione ASC", "value": "$idporto$" ]} -
    - -
    - {[ "type": "text", "label": "'.tr('Num. colli').'", "name": "n_colli", "value": "$n_colli$" ]} -
    -
    - -
    -
    - {[ "type": "select", "label": "'.tr('Tipo di spedizione').'", "name": "idspedizione", "values": "query=SELECT id, descrizione FROM dt_spedizione ORDER BY descrizione ASC", "value": "$idspedizione$" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Vettore').'", "name": "idvettore", "ajax-source": "vettori", "value": "$idvettore$", "icon-after": "add|'.Modules::get('Anagrafiche')['id'].'|tipoanagrafica=Vettore|'.((($record['idspedizione'] != 3) and ($record['stato'] == 'Bozza')) ? '' : 'disabled').'", "disabled": '.intval($record['idspedizione'] == 3).', "required": '.intval($record['idspedizione'] != 3).' ]} -
    - - '; - - $tipo_resa = [ - [ - 'id' => 'EXW', - 'text' => 'EXW', - ], - [ - 'id' => 'FCA', - 'text' => 'FCA', - ], - [ - 'id' => 'FAS', - 'text' => 'FAS', - ], - [ - 'id' => 'FOB', - 'text' => 'FOB', - ], - [ - 'id' => 'CFR', - 'text' => 'CFR', - ], - [ - 'id' => 'CIF', - 'text' => 'CIF', - ], - [ - 'id' => 'CPT', - 'text' => 'CPT', - ], - [ - 'id' => 'CIP', - 'text' => 'CIP', - ], - [ - 'id' => 'DAF', - 'text' => 'DAF', - ], - [ - 'id' => 'DES', - 'text' => 'DES', - ], - [ - 'id' => 'DEQ', - 'text' => 'DEQ', - ], - [ - 'id' => 'DDU', - 'text' => 'DDU', - ], - [ - 'id' => 'DDP', - 'text' => 'DDP', - ], - ]; - - echo ' -
    - {[ "type": "select", "label": "'.tr('Tipo Resa').'", "name": "tipo_resa", "value": "$tipo_resa$", "values": '.json_encode($tipo_resa).', "readonly": '.intval($record['causale_desc'] != 'Reso').' ]} -
    -
    -
    '; - - echo ' -
    -
    - {[ "type": "number", "label": "'.tr('Peso').'", "name": "peso", "value": "$peso$", "readonly": "'.intval(empty($record['peso_manuale'])).'", "help": "'.tr('Il valore del campo Peso viene calcolato in automatico sulla base degli articoli inseriti nel documento, a meno dell\'impostazione di un valore manuale in questo punto').'" ]} - -
    - -
    - {[ "type": "checkbox", "label": "'.tr('Modifica peso').'", "name": "peso_manuale", "value":"$peso_manuale$", "help": "'.tr('Seleziona per modificare manualmente il campo Peso').'", "placeholder": "'.tr('Modifica peso').'" ]} -
    - -
    - {[ "type": "number", "label": "'.tr('Volume').'", "name": "volume", "value": "$volume$", "readonly": "'.intval(empty($record['volume_manuale'])).'", "help": "'.tr('Il valore del campo Volume viene calcolato in automatico sulla base degli articoli inseriti nel documento, a meno dell\'impostazione di un valore manuale in questo punto').'" ]} - -
    - -
    - {[ "type": "checkbox", "label": "'.tr('Modifica volume').'", "name": "volume_manuale", "value":"$volume_manuale$", "help": "'.tr('Seleziona per modificare manualmente il campo Volume').'", "placeholder": "'.tr('Modifica volume').'" ]} -
    -
    - '; -} - -echo ' -
    - - -
    -
    -

    '.tr('Righe').'

    -
    - -
    -
    -
    -
    '; - -if (!$block_edit) { - if (empty($record['ref_documento'])) { - if ($dir == 'entrata') { - // Lettura interventi non rifiutati, non fatturati e non collegati a preventivi o contratti - $int_query = 'SELECT COUNT(*) AS tot FROM in_interventi INNER JOIN in_statiintervento ON in_interventi.idstatointervento=in_statiintervento.idstatointervento WHERE idanagrafica='.prepare($record['idanagrafica']).' AND in_statiintervento.is_completato=1 AND in_statiintervento.is_fatturabile=1 AND in_interventi.id NOT IN (SELECT idintervento FROM co_righe_documenti WHERE idintervento IS NOT NULL) AND in_interventi.id_preventivo IS NULL AND in_interventi.id NOT IN (SELECT idintervento FROM co_promemoria WHERE idintervento IS NOT NULL)'; - $interventi = $dbo->fetchArray($int_query)[0]['tot']; - - // Se non trovo niente provo a vedere se ce ne sono per clienti terzi - if (empty($interventi)) { - // Lettura interventi non rifiutati, non fatturati e non collegati a preventivi o contratti (clienti terzi) - $int_query = 'SELECT COUNT(*) AS tot FROM in_interventi INNER JOIN in_statiintervento ON in_interventi.idstatointervento=in_statiintervento.idstatointervento WHERE idclientefinale='.prepare($record['idanagrafica']).' AND in_statiintervento.is_completato=1 AND in_statiintervento.is_fatturabile=1 AND in_interventi.id NOT IN (SELECT idintervento FROM co_righe_documenti WHERE idintervento IS NOT NULL) AND in_interventi.id_preventivo IS NULL AND in_interventi.id NOT IN (SELECT idintervento FROM co_promemoria WHERE idintervento IS NOT NULL)'; - $interventi = $dbo->fetchArray($int_query)[0]['tot']; - } - - echo ' - '; - - // Lettura preventivi accettati, in attesa di conferma o in lavorazione - $prev_query = 'SELECT COUNT(*) AS tot FROM co_preventivi WHERE idanagrafica='.prepare($record['idanagrafica']).' AND idstato IN(SELECT id FROM co_statipreventivi WHERE is_fatturabile = 1) AND default_revision=1 AND co_preventivi.id IN (SELECT idpreventivo FROM co_righe_preventivi WHERE co_righe_preventivi.idpreventivo = co_preventivi.id AND (qta - qta_evasa) > 0)'; - $preventivi = $dbo->fetchArray($prev_query)[0]['tot']; - echo ' - '; - - // Lettura contratti accettati, in attesa di conferma o in lavorazione - $contr_query = 'SELECT COUNT(*) AS tot FROM co_contratti WHERE idanagrafica='.prepare($record['idanagrafica']).' AND idstato IN( SELECT id FROM co_staticontratti WHERE is_fatturabile = 1) AND co_contratti.id IN (SELECT idcontratto FROM co_righe_contratti WHERE co_righe_contratti.idcontratto = co_contratti.id AND (qta - qta_evasa) > 0)'; - $contratti = $dbo->fetchArray($contr_query)[0]['tot']; - echo ' - '; - } - - // Lettura ddt (entrata o uscita) - $ddt_query = 'SELECT COUNT(*) AS tot FROM dt_ddt - LEFT JOIN `dt_causalet` ON `dt_causalet`.`id` = `dt_ddt`.`idcausalet` - LEFT JOIN `dt_statiddt` ON `dt_statiddt`.`id` = `dt_ddt`.`idstatoddt` - LEFT JOIN `dt_tipiddt` ON `dt_tipiddt`.`id` = `dt_ddt`.`idtipoddt` - WHERE idanagrafica='.prepare($record['idanagrafica']).' - AND `dt_statiddt`.`descrizione` IN (\'Evaso\', \'Parzialmente evaso\', \'Parzialmente fatturato\') - AND `dt_tipiddt`.`dir` = '.prepare($dir).' - AND `dt_causalet`.`is_importabile` = 1 - AND dt_ddt.id IN (SELECT idddt FROM dt_righe_ddt WHERE dt_righe_ddt.idddt = dt_ddt.id AND (qta - qta_evasa) > 0)'; - $ddt = $dbo->fetchArray($ddt_query)[0]['tot']; - echo ' - '; - - // Lettura ordini (cliente o fornitore) - $ordini_query = 'SELECT COUNT(*) AS tot FROM or_ordini WHERE idanagrafica='.prepare($record['idanagrafica']).' AND idstatoordine IN (SELECT id FROM or_statiordine WHERE descrizione IN(\'Accettato\', \'Evaso\', \'Parzialmente evaso\', \'Parzialmente fatturato\')) AND idtipoordine=(SELECT id FROM or_tipiordine WHERE dir='.prepare($dir).') AND or_ordini.id IN (SELECT idordine FROM or_righe_ordini WHERE or_righe_ordini.idordine = or_ordini.id AND (qta - qta_evasa) > 0)'; - $ordini = $dbo->fetchArray($ordini_query)[0]['tot']; - echo ' - '; - } - - // Lettura articoli - $art_query = 'SELECT id FROM mg_articoli WHERE attivo = 1 AND deleted_at IS NULL'; - if ($dir == 'entrata') { - $art_query .= ' AND (qta > 0 OR servizio = 1)'; - } else { - //Gli articoli possono essere creati al volo direttamente dal modale di aggiunta articolo - $art_query .= ' OR 1=1'; - } - - $articoli = $dbo->fetchNum($art_query); - echo ' - '; - - echo ' - '; - - echo ' - '; - - echo ' - '; - - echo ' - '; -} -?> -
    - -
    - - 0) { - //echo '{( "name": "button", "type": "print", "id_module": "'.$id_module.'", "id_record": "'.$id_record.'", "class": "btn-info disabled" )}'; - } else { - //echo '{( "name": "button", "type": "print", "id_module": "'.$id_module.'", "id_record": "'.$id_record.'" )}'; - } -} -?> -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    - -isFE()) { - echo ' -
    '.tr('Controllo sui totali del documento e della fattura elettronica in corso').'...
    - -'; -} -?> - -{( "name": "filelist_and_upload", "id_module": "$id_module$", "id_record": "$id_record$" )} - -'.tr('Per allegare un documento alla fattura elettronica caricare il file PDF specificando come categoria "Allegati Fattura Elettronica"').'.'; -} - -echo ' -'; - -if (!empty($note_accredito)) { - echo ' -
    '.tr('Note di credito collegate').':'; - foreach ($note_accredito as $nota) { - $text = tr('Rif. fattura _NUM_ del _DATE_', [ - '_NUM_' => $nota['numero'], - '_DATE_' => Translator::dateToLocale($nota['data']), - ]); - - echo ' -
    '.Modules::link('Fatture di vendita', $nota['id'], $text, $text); - } - echo ' -
    '; -} - -?> - -{( "name": "log_email", "id_module": "$id_module$", "id_record": "$id_record$" )} - -sedi)) { - ?> - - - - -function gestioneArticolo(button) { - gestioneRiga(button, "is_articolo"); -} - -function gestioneBarcode(button) { - gestioneRiga(button, "is_barcode"); -} - -function gestioneSconto(button) { - gestioneRiga(button, "is_sconto"); -} - -function gestioneDescrizione(button) { - gestioneRiga(button, "is_descrizione"); -} - -async function gestioneRiga(button, options) { - // Salvataggio via AJAX - await salvaForm("#edit-form", {}, button); - - // Lettura titolo e chiusura tooltip - let title = $(button).tooltipster("content"); - $(button).tooltipster("close") - - // Apertura modal - options = options ? options : "is_riga"; - openModal(title, "'.$structure->fileurl('row-add.php').'?id_module='.$id_module.'&id_record='.$id_record.'&" + options); -} - -/** - * Funzione dedicata al caricamento dinamico via AJAX delle righe del documento. - */ -function caricaRighe() { - let container = $("#righe"); - - localLoading(container, true); - return $.get("'.$structure->fileurl('row-list.php').'?id_module='.$id_module.'&id_record='.$id_record.'", function(data) { - container.html(data); - localLoading(container, false); - }); -} - -$(document).ready(function () { - caricaRighe(); - - $("#data_registrazione").on("dp.change", function (e) { - let data_competenza = $("#data_competenza"); - data_competenza.data("DateTimePicker").minDate(e.date); - - if(data_competenza.data("DateTimePicker").date() < e.date){ - data_competenza.data("DateTimePicker").date(e.date); - } - }); - - $("#data").on("dp.change", function (e) { - let data_competenza = $("#data_competenza"); - data_competenza.data("DateTimePicker").minDate(e.date); - - if(data_competenza.data("DateTimePicker").date() < e.date){ - data_competenza.data("DateTimePicker").date(e.date); - } - }); -}); - -function cambiaStato() { - let testo = $("#idstatodocumento option:selected").text(); - - if (testo === "Pagato" || testo === "Parzialmente pagato") { - if(confirm("'.tr('Sicuro di voler impostare manualmente la fattura come pagata senza aggiungere il movimento in prima nota?').'")) { - return true; - } else { - $("#idstatodocumento").selectSet('.$record['idstatodocumento'].'); - } - } -}'; -if ($dir == 'entrata') { - echo ' - function bolloAutomatico() { - let bollo_automatico = input("bollo_automatico"); - let addebita_bollo = input("addebita_bollo"); - let has_bollo ='.($bollo->getBollo() > 0 ? 'true' : 'false').'; - if(bollo_automatico.get()==0){ - $(".bollo").show(); - input("bollo").enable(); - } else if(!has_bollo) { - $(".bollo").hide(); - } else { - $(".bollo").show(); - input("bollo").disable(); - $("#bollo").val('.setting('Importo marca da bollo').'); - } - } - $(document).ready(function() { - if(!$("#volume_manuale").is(":checked")){ - input("volume").set($("#volume_calcolato").val()); - } - $("#volume_manuale").click(function() { - $("#volume").prop("readonly", !$("#volume_manuale").is(":checked")); - if(!$("#volume_manuale").is(":checked")){ - input("volume").set($("#volume_calcolato").val()); - } - }); - - if(!$("#peso_manuale").is(":checked")){ - input("peso").set($("#peso_calcolato").val()); - } - $("#peso_manuale").click(function() { - $("#peso").prop("readonly", !$("#peso_manuale").is(":checked")); - if(!$("#peso_manuale").is(":checked")){ - input("peso").set($("#peso_calcolato").val()); - } - }); - - bolloAutomatico(); - }); - input("bollo_automatico").change(function () { - bolloAutomatico(); - });'; -} -echo ' -'; diff --git a/modules/fatture/fe/components/altri_dati.php b/modules/fatture/fe/components/altri_dati.php deleted file mode 100755 index 1b3257832..000000000 --- a/modules/fatture/fe/components/altri_dati.php +++ /dev/null @@ -1,75 +0,0 @@ -. - */ - -// Altri dati gestionali -echo ' - - - - '.str_repeat($space, 3).'2.2.1.16 AltriDatiGestionali - '.tr('Riga _NUM_', [ - '_NUM_' => $key, - ]); - -if ($key == 1) { - echo ' - '; -} - -echo ' - - '; - -// Tipo Dato -echo ' - - '.str_repeat($space, 4).'2.2.1.16.1 TipoDato - - {[ "type": "text", "name": "altri_dati['.$key.'][tipo_dato]", "value": "'.$dato['tipo_dato'].'", "maxlength": 10 ]} - - '; - -// Riferimento Testo -echo ' - - '.str_repeat($space, 4).'2.2.1.16.2 RiferimentoTesto - - {[ "type": "text", "name": "altri_dati['.$key.'][riferimento_testo]", "value": "'.$dato['riferimento_testo'].'", "maxlength": 60 ]} - - '; - -// Riferimento Numero -echo ' - - '.str_repeat($space, 4).'2.2.1.16.3 RiferimentoNumero - - {[ "type": "number", "name": "altri_dati['.$key.'][riferimento_numero]", "value": "'.$dato['riferimento_numero'].'" ]} - - '; - -// Riferimento Data -echo ' - - '.str_repeat($space, 4).'2.2.1.16.4 RiferimentoData - - {[ "type": "date", "name": "altri_dati['.$key.'][riferimento_data]", "value": "'.$dato['riferimento_data'].'"]} - - - '; diff --git a/modules/fatture/fe/components/dati_documento.php b/modules/fatture/fe/components/dati_documento.php deleted file mode 100755 index f560f7202..000000000 --- a/modules/fatture/fe/components/dati_documento.php +++ /dev/null @@ -1,145 +0,0 @@ -. - */ - -// Altri dati gestionali -echo ' - - - - '.str_repeat($space, 3).$info['code'].' '.$info['name'].' - '.tr('Riga _NUM_', [ - '_NUM_' => $key, - ]); - -if ($key == 1) { - echo ' - '; -} - -echo ' - - '; - -// RiferimentoNumeroLinea -if (empty($dato['riferimento_linea'])) { - $dato['riferimento_linea'][] = 0; -} - -$index = 1; -foreach ($dato['riferimento_linea'] as $linea) { - echo ' - - - '.str_repeat($space, 4).$info['code'].'.1 RiferimentoNumeroLinea - '.tr('Riga _NUM_', [ - '_NUM_' => $index, - ]); - - if ($index == 1) { - echo ' - '; - } - - echo ' - - - {[ "type": "number", "name": "'.$nome.'['.$key.'][riferimento_linea][]", "value": "'.$linea.'", "maxlength": 4, "decimals": 0, "extra": " title=\"\" " ]} - - '; - - ++$index; -} - -// IdDocumento -echo ' - - '.str_repeat($space, 4).$info['code'].'.2 IdDocumento - - {[ "type": "text", "name": "'.$nome.'['.$key.'][id_documento]", "value": "'.$dato['id_documento'].'", "maxlength": 20 ]} - - '; - -// Data -echo ' - - '.str_repeat($space, 4).$info['code'].'.3 Data - - {[ "type": "date", "name": "'.$nome.'['.$key.'][data]", "value": "'.$dato['data'].'", "readonly": '.(empty($dato['id_documento']) ? 1 : 0).' ]} - - '; - -// NumItem -echo ' - - '.str_repeat($space, 4).$info['code'].'.4 NumItem - - {[ "type": "text", "name": "'.$nome.'['.$key.'][num_item]", "value": "'.$dato['num_item'].'", "maxlength": 20, "readonly": '.(empty($dato['id_documento']) ? 1 : 0).' ]} - - '; - -// CodiceCommessaConvenzione -echo ' - - '.str_repeat($space, 4).$info['code'].'.5 CodiceCommessaConvenzione - - {[ "type": "text", "name": "'.$nome.'['.$key.'][codice_commessa]", "value": "'.$dato['codice_commessa'].'", "maxlength": 100, "readonly": '.(empty($dato['id_documento']) ? 1 : 0).' ]} - - '; - -// CodiceCUP -echo ' - - '.str_repeat($space, 4).$info['code'].'.6 CodiceCUP - - {[ "type": "text", "name": "'.$nome.'['.$key.'][codice_cup]", "value": "'.$dato['codice_cup'].'", "maxlength": 15, "readonly": '.(empty($dato['id_documento']) ? 1 : 0).' ]} - - '; - -// CodiceCIG -echo ' - - '.str_repeat($space, 4).$info['code'].'.7 CodiceCIG - - {[ "type": "text", "name": "'.$nome.'['.$key.'][codice_cig]", "value": "'.$dato['codice_cig'].'", "maxlength": 15, "readonly": '.(empty($dato['id_documento']) ? 1 : 0).' ]} - - - '; - -echo ' -'; diff --git a/modules/fatture/fe/document-fe.php b/modules/fatture/fe/document-fe.php deleted file mode 100755 index 5d82b1115..000000000 --- a/modules/fatture/fe/document-fe.php +++ /dev/null @@ -1,241 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -use Modules\Fatture\Fattura; - -$space = str_repeat(' ', 6); - -$documento = Fattura::find($id_record); - -$result = $documento->toArray(); -$result = array_merge($result, $documento->dati_aggiuntivi_fe); - -echo ' - '; - -echo ' -
    - - - - '; - -echo ' - - - - - - - - - - - '; - -// ScontoMaggiorazione -echo ' - - - -'; - -// ScontoMaggiorazione - Tipo -echo ' - - - - -'; - -// ScontoMaggiorazione - Percentuale -echo ' - - - - -'; - -// ScontoMaggiorazione - Importo -echo ' - - - - -'; - -// Art73 -echo ' - - - - - '; - -echo ' -'; - -$documenti = [ - 'dati_ordine' => [ - 'code' => '2.1.2', - 'name' => 'DatiOrdineAcquisto', - ], - 'dati_contratto' => [ - 'code' => '2.1.3', - 'name' => 'DatiContratto', - ], - 'dati_convenzione' => [ - 'code' => '2.1.4', - 'name' => 'DatiConvenzione', - ], - 'dati_ricezione' => [ - 'code' => '2.1.5', - 'name' => 'DatiRicezione', - ], - 'dati_fatture' => [ - 'code' => '2.1.6', - 'name' => 'DatiFattureCollegate', - ], -]; -foreach ($documenti as $nome => $info) { - if (empty($result[$nome])) { - $result[$nome][] = []; - } - - $key = 1; - foreach ($result[$nome] as $dato) { - include __DIR__.'/components/dati_documento.php'; - - echo ' - '; - - ++$key; - } - - echo ' - '; -} - -echo ' -
    - 2 FatturaElettronicaBody - -
    '.str_repeat($space, 1).'2.1 DatiGenerali
    '.str_repeat($space, 2).'2.1.1 DatiGeneraliDocumento
    '.str_repeat($space, 3).'2.1.1.8 ScontoMaggiorazione
    '.str_repeat($space, 4).'2.1.1.8.1 Tipo - {[ "type": "select", "name": "sconto_maggiorazione_tipo", "values": "list=\"SC\":\"Sconto\",\"MG\":\"Maggiorazione\"", "value": "'.$result['sconto_maggiorazione_tipo'].'" ]} -
    '.str_repeat($space, 4).'2.1.1.8.2 Percentuale - {[ "type": "number", "name": "sconto_maggiorazione_percentuale", "value": "'.$result['sconto_maggiorazione_percentuale'].'" ]} -
    '.str_repeat($space, 4).'2.1.1.8.3 Importo - {[ "type": "number", "name": "sconto_maggiorazione_importo", "value": "'.$result['sconto_maggiorazione_importo'].'" ]} -
    '.str_repeat($space, 3).'2.1.1.12 Art73 - {[ "type": "checkbox", "name": "art73", "value": "'.$result['art73'].'", "placeholder": "'.tr("Emesso ai sensi dell'articolo 73 del DPR 633/72").'" ]} -
    '; - -foreach ($documenti as $nome => $info) { - echo ' -'; - $dato = []; - $key = '-id-'; - - include __DIR__.'/components/dati_documento.php'; - - echo ' -
    - - - - - - - - -
    - '.str_repeat($space, 4).$info['code'].'.1 RiferimentoNumeroLinea - '.tr('Riga _NUM_', [ - '_NUM_' => '-num-', - ]).' - - {[ "type": "number", "name": "'.$nome.'[-id-][riferimento_linea][]", "value": "", "maxlength": 4, "decimals": 0 ]} -
    '; -} - -echo ' - -
    -
    - -
    -
    '; - -echo ' -
    '; - -echo ' - - -'; - -$attributi_editabili = $documento['stato'] != 'Emessa' && $documento['stato'] != 'Parzialmente pagato' && $documento['stato'] != 'Pagato'; -if (!$attributi_editabili) { - echo ''; -} diff --git a/modules/fatture/fe/row-fe.php b/modules/fatture/fe/row-fe.php deleted file mode 100755 index c661f8bc5..000000000 --- a/modules/fatture/fe/row-fe.php +++ /dev/null @@ -1,175 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -use Modules\Fatture\Fattura; - -$tipi_cessione_prestazione = [ - [ - 'id' => 'SC', - 'text' => 'SC - '.tr('Sconto'), - ], - [ - 'id' => 'PR', - 'text' => 'PR - '.tr('Premio'), - ], - [ - 'id' => 'AB', - 'text' => 'AB - '.tr('Abbuono'), - ], - [ - 'id' => 'AC', - 'text' => 'AC - '.tr('Spesa accessoria'), - ], -]; - -$space = str_repeat(' ', 6); - -$documento = Fattura::find($id_record); - -// Dati della riga -$id_riga = get('riga_id'); -$type = get('riga_type'); -$riga = $documento->getRiga($type, $id_riga); - -$result = $riga->toArray(); -$result = array_merge($result, $riga->dati_aggiuntivi_fe); - -echo ' - '; - -echo ' -
    - - - - - '; - -echo ' - - - - - - - - - - - '; - -// Tipo Cessione Prestazione - echo ' - - - - '; - -// Data inizio periodo -echo ' - - - - '; - -// Data fine periodo -echo ' - - - - '; - -// Riferimento amministrazione -echo ' - - - - - '; - -if (empty($result['altri_dati'])) { - $result['altri_dati'][] = []; -} - -$key = 1; -foreach ($result['altri_dati'] as $dato) { - include __DIR__.'/components/altri_dati.php'; - - ++$key; -} - - echo ' - -
    - 2 FatturaElettronicaBody - -
    '.str_repeat($space, 1).'2.2 DatiBeniServizi
    '.str_repeat($space, 2).'2.2.1 DettaglioLinee
    '.str_repeat($space, 3).'2.2.1.2 TipoCessionePrestazione - {[ "type": "select", "name": "tipo_cessione_prestazione", "value": "'.$result['tipo_cessione_prestazione'].'", "values": '.json_encode($tipi_cessione_prestazione).' ]} -
    '.str_repeat($space, 3).'2.2.1.7 DataInizioPeriodo - {[ "type": "date", "name": "data_inizio_periodo", "value": "'.$result['data_inizio_periodo'].'" ]} -
    '.str_repeat($space, 3).'2.2.1.8 DataFinePeriodo - {[ "type": "date", "name": "data_fine_periodo", "value": "'.$result['data_fine_periodo'].'" ]} -
    '.str_repeat($space, 3).'2.2.1.15 RiferimentoAmministrazione - {[ "type": "text", "name": "riferimento_amministrazione", "value": "'.$result['riferimento_amministrazione'].'", "maxlength": 20 ]} -
    '; - -echo ' - - -'; -$dato = []; -$key = '-id-'; - -include __DIR__.'/components/altri_dati.php'; - -echo ' -
    '; - -echo ' - -
    -
    - -
    -
    '; - -echo ' -
    '; - -echo ' -'; diff --git a/modules/fatture/fe/style.css b/modules/fatture/fe/style.css deleted file mode 100755 index b708711aa..000000000 --- a/modules/fatture/fe/style.css +++ /dev/null @@ -1,41 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -.first-level{ - background-color: #ffffff; -} -.second-level{ - background-color: rgba(192,192,192, 0.1); -} -.third-level{ - background-color: rgba(192,192,192, 0.15); -} -.fourth-level{ - background-color: rgba(192,192,192, 0.25); -} -.fifth-level{ - background-color: rgba(192,192,192, 0.4); -} - -.first-level td, -.second-level td, -.third-level td, -.fourth-level td, -.fifth-level td{ - vertical-align: middle; -} diff --git a/modules/fatture/init.php b/modules/fatture/init.php deleted file mode 100755 index 67b497cb4..000000000 --- a/modules/fatture/init.php +++ /dev/null @@ -1,66 +0,0 @@ -. - */ - -use Modules\Fatture\Fattura; - -include_once __DIR__.'/../../core.php'; - -if ($module['name'] == 'Fatture di vendita') { - $dir = 'entrata'; -} else { - $dir = 'uscita'; -} - -if (isset($id_record)) { - $fattura = Fattura::with('tipo', 'stato')->find($id_record); - $dir = $fattura->direzione; - - $is_fiscale = false; - if (!empty($fattura)) { - $is_fiscale = $fattura->isFiscale(); - } - - $record = $dbo->fetchOne('SELECT co_documenti.*, - co_tipidocumento.reversed AS is_reversed, - co_documenti.idagente AS idagente_fattura, - co_documenti.note, - co_documenti.note_aggiuntive, - co_documenti.idpagamento, - co_documenti.id AS iddocumento, - co_documenti.split_payment AS split_payment, - co_statidocumento.descrizione AS `stato`, - co_tipidocumento.descrizione AS `descrizione_tipo`, - (SELECT is_fiscale FROM zz_segments WHERE id = id_segment) AS is_fiscale, - (SELECT descrizione FROM co_ritenutaacconto WHERE id=idritenutaacconto) AS ritenutaacconto_desc, - (SELECT descrizione FROM co_rivalse WHERE id=idrivalsainps) AS rivalsainps_desc, - (SELECT descrizione FROM dt_causalet WHERE id=idcausalet) AS causale_desc - FROM co_documenti - LEFT OUTER JOIN co_statidocumento ON co_documenti.idstatodocumento=co_statidocumento.id - INNER JOIN an_anagrafiche ON co_documenti.idanagrafica=an_anagrafiche.idanagrafica - INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id - LEFT JOIN co_pagamenti ON co_documenti.idpagamento=co_pagamenti.id - WHERE co_tipidocumento.dir = '.prepare($dir).' AND co_documenti.id='.prepare($id_record)); - - // Note di credito collegate - $note_accredito = $dbo->fetchArray("SELECT co_documenti.id, IF(numero_esterno != '', numero_esterno, numero) AS numero, data FROM co_documenti JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE reversed = 1 AND ref_documento=".prepare($id_record)); - - // Blocco gestito dallo stato della Fattura Elettronica - $stato_fe = $database->fetchOne('SELECT * FROM fe_stati_documento WHERE codice = '.prepare($fattura->codice_stato_fe)); - $abilita_genera = empty($fattura->codice_stato_fe) || intval($stato_fe['is_generabile']); -} diff --git a/modules/fatture/modutil.php b/modules/fatture/modutil.php deleted file mode 100755 index 67567189a..000000000 --- a/modules/fatture/modutil.php +++ /dev/null @@ -1,436 +0,0 @@ -. - */ - -use Modules\Fatture\Fattura; -use Util\Generator; - -/** - * Funzione per generare un nuovo numero per la fattura. - * - * @deprecated 2.4.5 - */ -function get_new_numerofattura($data) -{ - global $dir; - global $id_segment; - - return Fattura::getNextNumero($data, $dir, $id_segment); -} - -/** - * Funzione per calcolare il numero secondario successivo utilizzando la maschera dalle impostazioni. - * - * @deprecated 2.4.5 - */ -function get_new_numerosecondariofattura($data) -{ - global $dir; - global $id_segment; - - return Fattura::getNextNumeroSecondario($data, $dir, $id_segment); -} - -/** - * Calcolo imponibile fattura (totale_righe - sconto). - * - * @deprecated 2.4.5 - */ -function get_imponibile_fattura($iddocumento) -{ - $fattura = Fattura::find($iddocumento); - - return $fattura->imponibile; -} - -/** - * Calcolo totale fattura (imponibile + iva). - * - * @deprecated 2.4.5 - */ -function get_totale_fattura($iddocumento) -{ - $fattura = Fattura::find($iddocumento); - - return $fattura->totale; -} - -/** - * Calcolo netto a pagare fattura (totale - ritenute - bolli). - * - * @deprecated 2.4.5 - */ -function get_netto_fattura($iddocumento) -{ - $fattura = Fattura::find($iddocumento); - - return $fattura->netto; -} - -/** - * Calcolo iva detraibile fattura. - * - * @deprecated 2.4.5 - */ -function get_ivadetraibile_fattura($iddocumento) -{ - $fattura = Fattura::find($iddocumento); - - return $fattura->iva_detraibile; -} - -/** - * Calcolo iva indetraibile fattura. - * - * @deprecated 2.4.5 - */ -function get_ivaindetraibile_fattura($iddocumento) -{ - $fattura = Fattura::find($iddocumento); - - return $fattura->iva_indetraibile; -} - -/** - * Elimina una scadenza in base al codice documento. - * - * @deprecated 2.4.17 - */ -function elimina_scadenze($iddocumento) -{ - $fattura = Fattura::find($iddocumento); - - $fattura->rimuoviScadenze(); -} - -/** - * Funzione per ricalcolare lo scadenzario di una determinata fattura - * $iddocumento string E' l'id del documento di cui ricalcolare lo scadenzario - * $pagamento string Nome del tipo di pagamento. Se è vuoto lo leggo da co_pagamenti_documenti, perché significa che devo solo aggiornare gli importi. - * $pagato boolean Indica se devo segnare l'importo come pagato. - * - * @deprecated 2.4.17 - */ -function aggiungi_scadenza($iddocumento, $pagamento = '', $pagato = false) -{ - $fattura = Fattura::find($iddocumento); - - $fattura->registraScadenze($pagato); -} - -/** - * Elimina i movimenti collegati ad una fattura. - * Se il flag $prima_nota è impostato a 1 elimina solo i movimenti di Prima Nota, altrimenti rimuove quelli automatici. - * - * @param $iddocumento - * @param int $prima_nota - * - * @deprecated 2.4.17 - */ -function elimina_movimenti($id_documento, $prima_nota = 0) -{ - $dbo = database(); - - $idmastrino = $dbo->fetchOne('SELECT idmastrino FROM co_movimenti WHERE iddocumento='.prepare($id_documento).' AND primanota='.prepare($prima_nota))['idmastrino']; - - $query2 = 'DELETE FROM co_movimenti WHERE idmastrino='.prepare($idmastrino).' AND primanota='.prepare($prima_nota); - $dbo->query($query2); -} - -/** - * Funzione per aggiungere la fattura in prima nota - * $iddocumento string E' l'id del documento da collegare alla prima nota - * $dir string Direzione dell'importo (entrata, uscita) - * $primanota boolean Indica se il movimento è un movimento di prima nota o un movimento normale (di default movimento normale). - * - * @deprecated 2.4.17 - */ -function aggiungi_movimento($iddocumento, $dir, $primanota = 0) -{ - $dbo = database(); - - $fattura = Modules\Fatture\Fattura::find($iddocumento); - $is_nota = $fattura->isNota(); - - // Totale marca da bollo, inps, ritenuta, idagente - $query = 'SELECT data, bollo, ritenutaacconto, rivalsainps, split_payment FROM co_documenti WHERE id='.prepare($iddocumento); - $rs = $dbo->fetchArray($query); - $totale_bolli = $is_nota ? -$rs[0]['bollo'] : $rs[0]['bollo']; - $totale_ritenutaacconto = $is_nota ? -$rs[0]['ritenutaacconto'] : $rs[0]['ritenutaacconto']; - $totale_ritenutacontributi = $is_nota ? -$fattura->totale_ritenuta_contributi : $fattura->totale_ritenuta_contributi; - $totale_rivalsainps = $is_nota ? -$rs[0]['rivalsainps'] : $rs[0]['rivalsainps']; - $data_documento = $rs[0]['data']; - $split_payment = $rs[0]['split_payment']; - - $netto_fattura = get_netto_fattura($iddocumento); - $totale_fattura = get_totale_fattura($iddocumento); - $totale_fattura = $is_nota ? -$totale_fattura : $totale_fattura; - - $imponibile_fattura = get_imponibile_fattura($iddocumento); - - // Calcolo l'iva della rivalsa inps - $iva_rivalsainps = 0; - - $rsr = $dbo->fetchArray('SELECT idiva, rivalsainps FROM co_righe_documenti WHERE iddocumento='.prepare($iddocumento)); - - for ($r = 0; $r < sizeof($rsr); ++$r) { - $qi = 'SELECT percentuale FROM co_iva WHERE id='.prepare($rsr[$r]['idiva']); - $rsi = $dbo->fetchArray($qi); - $iva_rivalsainps += $rsr[$r]['rivalsainps'] / 100 * $rsi[0]['percentuale']; - } - - // Lettura iva indetraibile fattura - $query = 'SELECT SUM(iva_indetraibile) AS iva_indetraibile FROM co_righe_documenti GROUP BY iddocumento HAVING iddocumento='.prepare($iddocumento); - $rs = $dbo->fetchArray($query); - $iva_indetraibile_fattura = $is_nota ? -$rs[0]['iva_indetraibile'] : $rs[0]['iva_indetraibile']; - - // Lettura iva delle righe in fattura - $query = 'SELECT iva FROM co_righe_documenti WHERE iddocumento='.prepare($iddocumento); - $rs = $dbo->fetchArray($query); - $iva_fattura = sum(array_column($rs, 'iva'), null) + $iva_rivalsainps - $iva_indetraibile_fattura; - $iva_fattura = $is_nota ? -$iva_fattura : $iva_fattura; - - // Imposto i segni + e - in base se la fattura è di acquisto o vendita - if ($dir == 'uscita') { - $segno_mov1_cliente = -1; - $segno_mov2_ricavivendite = 1; - $segno_mov3_iva = 1; - - $segno_mov4_inps = 1; - $segno_mov5_ritenutaacconto = -1; - - // Lettura conto fornitore - $query = 'SELECT idconto_fornitore FROM an_anagrafiche INNER JOIN co_documenti ON an_anagrafiche.idanagrafica=co_documenti.idanagrafica WHERE co_documenti.id='.prepare($iddocumento); - $rs = $dbo->fetchArray($query); - $idconto_controparte = $rs[0]['idconto_fornitore']; - - if ($idconto_controparte == '') { - $idconto_controparte = setting('Conto per Riepilogativo fornitori'); - } - } else { - $segno_mov1_cliente = 1; - $segno_mov2_ricavivendite = -1; - $segno_mov3_iva = -1; - - $segno_mov4_inps = -1; - $segno_mov5_ritenutaacconto = 1; - - // Lettura conto cliente - $query = 'SELECT idconto_cliente FROM an_anagrafiche INNER JOIN co_documenti ON an_anagrafiche.idanagrafica=co_documenti.idanagrafica WHERE co_documenti.id='.prepare($iddocumento); - $rs = $dbo->fetchArray($query); - $idconto_controparte = $rs[0]['idconto_cliente']; - - if ($idconto_controparte == '') { - $idconto_controparte = setting('Conto per Riepilogativo clienti'); - } - } - - // Lettura info fattura - $query = 'SELECT *, co_documenti.data_competenza, co_documenti.note, co_documenti.idpagamento, co_documenti.id AS iddocumento, co_statidocumento.descrizione AS `stato`, co_tipidocumento.descrizione AS `descrizione_tipo` FROM ((co_documenti LEFT OUTER JOIN co_statidocumento ON co_documenti.idstatodocumento=co_statidocumento.id) INNER JOIN an_anagrafiche ON co_documenti.idanagrafica=an_anagrafiche.idanagrafica) INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE co_documenti.id='.prepare($iddocumento); - $rs = $dbo->fetchArray($query); - $n = sizeof($rs); - $data = $rs[0]['data_competenza']; - $idanagrafica = $rs[0]['idanagrafica']; - $ragione_sociale = $rs[0]['ragione_sociale']; - $stato = $rs[0]['stato']; - - $idmastrino = get_new_idmastrino(); - - // Prendo il numero doc. esterno se c'è, altrimenti quello normale - if (!empty($rs[0]['numero_esterno'])) { - $numero = $rs[0]['numero_esterno']; - } else { - $numero = $rs[0]['numero']; - } - - // Abbreviazioni contabili dei movimenti - $tipodoc = ''; - if ($rs[0]['descrizione_tipo'] == 'Nota di credito') { - $tipodoc = 'Nota di credito'; - } elseif ($rs[0]['descrizione_tipo'] == 'Nota di debito') { - $tipodoc = 'Nota di debito'; - } else { - $tipodoc = 'Fattura'; - } - - $descrizione = $tipodoc.' num. '.$numero; - - /* - Il mastrino si apre con almeno 3 righe di solito (esempio fattura di vendita): - 1) dare imponibile+iva al conto cliente - 2) avere imponibile sul conto dei ricavi - 3) avere iva sul conto dell'iva a credito (ed eventuale iva indetraibile sul rispettivo conto) - - aggiuntivo: - 4) eventuale rivalsa inps - 5) eventuale ritenuta d'acconto - */ - // 1) Aggiungo la riga del conto cliente - $importo_cliente = $totale_fattura; - - if ($split_payment) { - $importo_cliente = sum($importo_cliente, -$iva_fattura, 2); - } - - $query2 = 'INSERT INTO co_movimenti(idmastrino, data, iddocumento, id_anagrafica, descrizione, idconto, totale, primanota) VALUES('.prepare($idmastrino).', '.prepare($data).', '.prepare($iddocumento).", '', ".prepare($descrizione.' del '.date('d/m/Y', strtotime($data)).' ('.$ragione_sociale.')').', '.prepare($idconto_controparte).', '.prepare(($importo_cliente + $totale_bolli) * $segno_mov1_cliente).', '.prepare($primanota).' )'; - $dbo->query($query2); - - // 2) Aggiungo il totale sul conto dei ricavi/spese scelto - // Lettura descrizione conto ricavi/spese per ogni riga del documento - $righe = $dbo->fetchArray('SELECT idconto, SUM(subtotale - sconto) AS imponibile FROM co_righe_documenti WHERE iddocumento='.prepare($iddocumento).' GROUP BY idconto'); - - foreach ($righe as $riga) { - // Retrocompatibilità - $idconto_riga = !empty($riga['idconto']) ? $riga['idconto'] : $idconto; - $riga['imponibile'] = $is_nota ? -$riga['imponibile'] : $riga['imponibile']; - - $query2 = 'INSERT INTO co_movimenti(idmastrino, data, iddocumento, id_anagrafica, descrizione, idconto, totale, primanota) VALUES('.prepare($idmastrino).', '.prepare($data).', '.prepare($iddocumento).", '', ".prepare($descrizione.' del '.date('d/m/Y', strtotime($data)).' ('.$ragione_sociale.')').', '.prepare($idconto_riga).', '.prepare($riga['imponibile'] * $segno_mov2_ricavivendite).', '.prepare($primanota).')'; - $dbo->query($query2); - } - - // 3) Aggiungo il totale sul conto dell'iva - // Lettura id conto iva - if ($iva_fattura != 0 && !$split_payment) { - $descrizione_conto_iva = ($dir == 'entrata') ? 'Iva su vendite' : 'Iva su acquisti'; - $idconto_iva = setting('Conto per '.$descrizione_conto_iva); - - $query2 = 'INSERT INTO co_movimenti(idmastrino, data, iddocumento, id_anagrafica, descrizione, idconto, totale, primanota) VALUES('.prepare($idmastrino).', '.prepare($data).', '.prepare($iddocumento).", '', ".prepare($descrizione.' del '.date('d/m/Y', strtotime($data)).' ('.$ragione_sociale.')').', '.prepare($idconto_iva).', '.prepare($iva_fattura * $segno_mov3_iva).', '.prepare($primanota).')'; - $dbo->query($query2); - } - - // Lettura id conto iva indetraibile - if ($iva_indetraibile_fattura != 0 && !$split_payment) { - $idconto_iva2 = setting('Conto per Iva indetraibile'); - - $query2 = 'INSERT INTO co_movimenti(idmastrino, data, iddocumento, id_anagrafica, descrizione, idconto, totale, primanota) VALUES('.prepare($idmastrino).', '.prepare($data).', '.prepare($iddocumento).", '', ".prepare($descrizione.' del '.date('d/m/Y', strtotime($data)).' ('.$ragione_sociale.')').', '.prepare($idconto_iva2).', '.prepare($iva_indetraibile_fattura * $segno_mov3_iva).', '.prepare($primanota).')'; - $dbo->query($query2); - } - - // 4) Aggiungo la rivalsa INPS se c'è - // Lettura id conto inps - if ($totale_rivalsainps != 0) { - $idconto_inps = setting('Conto per Erario c/INPS'); - - $query2 = 'INSERT INTO co_movimenti(idmastrino, data, iddocumento, id_anagrafica, descrizione, idconto, totale, primanota) VALUES('.prepare($idmastrino).', '.prepare($data).', '.prepare($iddocumento).", '', ".prepare($descrizione.' del '.date('d/m/Y', strtotime($data)).' ('.$ragione_sociale.')').', '.prepare($idconto_inps).', '.prepare($totale_rivalsainps * $segno_mov4_inps).', '.prepare($primanota).')'; - $dbo->query($query2); - } - - // 5) Aggiungo la ritenuta d'acconto se c'è - // Lettura id conto ritenuta e la storno subito - if ($totale_ritenutaacconto != 0) { - $idconto_ritenutaacconto = setting("Conto per Erario c/ritenute d'acconto"); - - // DARE nel conto ritenuta - $query2 = 'INSERT INTO co_movimenti(idmastrino, data, iddocumento, id_anagrafica, descrizione, idconto, totale, primanota) VALUES('.prepare($idmastrino).', '.prepare($data).', '.prepare($iddocumento).", '', ".prepare($descrizione.' del '.date('d/m/Y', strtotime($data)).' ('.$ragione_sociale.')').', '.prepare($idconto_ritenutaacconto).', '.prepare($totale_ritenutaacconto * $segno_mov5_ritenutaacconto).', '.prepare($primanota).')'; - $dbo->query($query2); - - // AVERE nel riepilogativo clienti - $query2 = 'INSERT INTO co_movimenti(idmastrino, data, iddocumento, id_anagrafica, descrizione, idconto, totale, primanota) VALUES('.prepare($idmastrino).', '.prepare($data).', '.prepare($iddocumento).", '', ".prepare($descrizione.' del '.date('d/m/Y', strtotime($data)).' ('.$ragione_sociale.')').', '.prepare($idconto_controparte).', '.prepare(($totale_ritenutaacconto * $segno_mov5_ritenutaacconto) * -1).', '.prepare($primanota).')'; - $dbo->query($query2); - } - - // 6) Aggiungo la ritenuta enasarco se c'è - // Lettura id conto ritenuta e la storno subito - if ($totale_ritenutacontributi != 0) { - $idconto_ritenutaenasarco = setting('Conto per Erario c/enasarco'); - - // DARE nel conto ritenuta - $query2 = 'INSERT INTO co_movimenti(idmastrino, data, iddocumento, id_anagrafica, descrizione, idconto, totale, primanota) VALUES('.prepare($idmastrino).', '.prepare($data).', '.prepare($iddocumento).", '', ".prepare($descrizione.' del '.date('d/m/Y', strtotime($data)).' ('.$ragione_sociale.')').', '.prepare($idconto_ritenutaenasarco).', '.prepare($totale_ritenutacontributi * $segno_mov5_ritenutaacconto).', '.prepare($primanota).')'; - $dbo->query($query2); - - // AVERE nel riepilogativo clienti - $query2 = 'INSERT INTO co_movimenti(idmastrino, data, iddocumento, id_anagrafica, descrizione, idconto, totale, primanota) VALUES('.prepare($idmastrino).', '.prepare($data).', '.prepare($iddocumento).", '', ".prepare($descrizione.' del '.date('d/m/Y', strtotime($data)).' ('.$ragione_sociale.')').', '.prepare($idconto_controparte).', '.prepare(($totale_ritenutacontributi * $segno_mov5_ritenutaacconto) * -1).', '.prepare($primanota).')'; - $dbo->query($query2); - } -} - -/** - * Funzione per generare un nuovo codice per il mastrino. - * - * @deprecated 2.4.17 - */ -function get_new_idmastrino($table = 'co_movimenti') -{ - $dbo = database(); - - $query = 'SELECT MAX(idmastrino) AS maxidmastrino FROM '.$table; - $rs = $dbo->fetchArray($query); - - return intval($rs[0]['maxidmastrino']) + 1; -} - -/** - * Ricalcola i costi aggiuntivi in fattura (rivalsa inps, ritenuta d'acconto, marca da bollo) - * Deve essere eseguito ogni volta che si aggiunge o toglie una riga - * $iddocumento int ID della fattura. - * - * @deprecated 2.4.17 - */ -function ricalcola_costiagg_fattura($iddocumento) -{ - global $dir; - - $fattura = Fattura::find($iddocumento); - $fattura->save(); -} - -/** - * Verifica che il numero_esterno della fattura indicata sia correttamente impostato, a partire dai valori delle fatture ai giorni precedenti. - * Restituisce il numero_esterno mancante in caso di numero errato. - * - * @return bool|string - */ -function verifica_numero_fattura(Fattura $fattura) -{ - if (empty($fattura->numero_esterno)) { - return null; - } - - $id_segment = $fattura->id_segment; - $data = $fattura->data; - - $documenti = Fattura::where('id_segment', '=', $id_segment) - ->where('data', '=', $data) - ->get(); - - // Recupero maschera per questo segmento - $maschera = Generator::getMaschera($id_segment); - - $ultimo = Generator::getPreviousFrom($maschera, 'co_documenti', 'numero_esterno', [ - 'data < '.prepare(date('Y-m-d', strtotime($data))), - 'YEAR(data) = '.prepare(date('Y', strtotime($data))), - 'id_segment = '.prepare($id_segment), - ], $data); - - do { - $numero = Generator::generate($maschera, $ultimo, 1, Generator::dateToPattern($data)); - - $filtered = $documenti->reject(function ($item, $key) use ($numero) { - return $item->numero_esterno == $numero; - }); - - if ($documenti->count() == $filtered->count()) { - return $numero; - } - - $documenti = $filtered; - $ultimo = $numero; - } while ($numero != $fattura->numero_esterno); - - return null; -} diff --git a/modules/fatture/row-add.php b/modules/fatture/row-add.php deleted file mode 100755 index 7510a4e45..000000000 --- a/modules/fatture/row-add.php +++ /dev/null @@ -1,115 +0,0 @@ -. - */ - -use Modules\Fatture\Fattura; - -include_once __DIR__.'/../../core.php'; - -$documento = Fattura::find($id_record); -$dir = $documento->direzione; - -// Impostazioni per la gestione -$options = [ - 'op' => 'manage_riga', - 'action' => 'add', - 'dir' => $documento->direzione, - 'conti' => $documento->direzione == 'entrata' ? 'conti-vendite' : 'conti-acquisti', - 'idanagrafica' => $documento['idanagrafica'], - 'show-ritenuta-contributi' => !empty($documento['id_ritenuta_contributi']), - 'totale_imponibile_documento' => $documento->totale_imponibile, - 'totale_documento' => $documento->totale, - 'select-options' => [ - 'articoli' => [ - 'idanagrafica' => $documento->idanagrafica, - 'dir' => $documento->direzione, - 'idsede_partenza' => $documento->idsede_partenza, - 'idsede_destinazione' => $documento->idsede_destinazione, - 'permetti_movimento_a_zero' => intval($documento->direzione == 'uscita'), - ], - 'iva' => [ - 'split_payment' => $documento['split_payment'], - ], - ], -]; - -// Conto dalle impostazioni -if (empty($idconto)) { - $idconto = ($dir == 'entrata') ? setting('Conto predefinito fatture di vendita') : setting('Conto predefinito fatture di acquisto'); -} - -// Dati di default -$result = [ - 'descrizione' => '', - 'qta' => 1, - 'um' => '', - 'prezzo' => 0, - 'prezzo_acquisto' => 0, - 'sconto_unitario' => 0, - 'tipo_sconto' => '', - 'idiva' => '', - 'idconto' => $idconto, - 'ritenuta_contributi' => true, -]; - -// Leggo l'iva predefinita per l'anagrafica e se non c'è leggo quella predefinita generica -$iva = $dbo->fetchArray('SELECT idiva_'.($dir == 'uscita' ? 'acquisti' : 'vendite').' AS idiva FROM an_anagrafiche WHERE idanagrafica='.prepare($documento['idanagrafica'])); -$result['idiva'] = $iva[0]['idiva'] ?: setting('Iva predefinita'); - -if (!empty($documento->dichiarazione)) { - $result['idiva'] = setting("Iva per lettere d'intento"); -} - -// Leggo la ritenuta d'acconto predefinita per l'anagrafica e se non c'è leggo quella predefinita generica -// id_ritenuta_acconto_vendite oppure id_ritenuta_acconto_acquisti -$ritenuta_acconto = $dbo->fetchOne('SELECT id_ritenuta_acconto_'.($dir == 'uscita' ? 'acquisti' : 'vendite').' AS id_ritenuta_acconto FROM an_anagrafiche WHERE idanagrafica='.prepare($documento['idanagrafica'])); -$id_ritenuta_acconto = $ritenuta_acconto['id_ritenuta_acconto']; -if ($dir == 'entrata' && empty($id_ritenuta_acconto)) { - $id_ritenuta_acconto = setting("Percentuale ritenuta d'acconto"); -} -$options['id_ritenuta_acconto_predefined'] = $id_ritenuta_acconto; - -// Importazione della gestione dedicata -$file = 'riga'; -if (get('is_descrizione') !== null) { - $file = 'descrizione'; - - $options['op'] = 'manage_descrizione'; -} elseif (get('is_articolo') !== null) { - $file = 'articolo'; - - // Aggiunta sconto di default da listino per le vendite - $listino = $dbo->fetchOne('SELECT prc_guadagno FROM an_anagrafiche INNER JOIN mg_listini ON an_anagrafiche.idlistino_vendite=mg_listini.id WHERE idanagrafica='.prepare($documento['idanagrafica'])); - - if (!empty($listino['prc_guadagno'])) { - $result['sconto_percentuale'] = $listino['prc_guadagno']; - $result['tipo_sconto'] = 'PRC'; - } - - $options['op'] = 'manage_articolo'; -} elseif (get('is_sconto') !== null) { - $file = 'sconto'; - - $options['op'] = 'manage_sconto'; -} elseif (get('is_barcode') !== null) { - $file = 'barcode'; - - $options['op'] = 'manage_barcode'; -} - -echo App::load($file.'.php', $result, $options); diff --git a/modules/fatture/row-edit.php b/modules/fatture/row-edit.php deleted file mode 100755 index 0acf42497..000000000 --- a/modules/fatture/row-edit.php +++ /dev/null @@ -1,74 +0,0 @@ -. - */ - -use Modules\Fatture\Fattura; - -include_once __DIR__.'/../../core.php'; - -$documento = Fattura::find($id_record); - -// Impostazioni per la gestione -$options = [ - 'op' => 'manage_riga', - 'action' => 'edit', - 'dir' => $documento->direzione, - 'conti' => $documento->direzione == 'entrata' ? 'conti-vendite' : 'conti-acquisti', - 'idanagrafica' => $documento['idanagrafica'], - 'show-ritenuta-contributi' => !empty($documento['id_ritenuta_contributi']), - 'totale_imponibile_documento' => $documento->totale_imponibile, - 'totale_documento' => $documento->totale, - 'select-options' => [ - 'articoli' => [ - 'idanagrafica' => $documento->idanagrafica, - 'dir' => $documento->direzione, - 'idsede_partenza' => $documento->idsede_partenza, - 'idsede_destinazione' => $documento->idsede_destinazione, - 'permetti_movimento_a_zero' => intval($documento->direzione == 'uscita'), - ], - 'iva' => [ - 'split_payment' => $documento['split_payment'], - ], - ], -]; - -// Dati della riga -$id_riga = get('riga_id'); -$type = get('riga_type'); -$riga = $documento->getRiga($type, $id_riga); - -$result = $riga->toArray(); -$result['prezzo'] = $riga->prezzo_unitario; - -// Importazione della gestione dedicata -$file = 'riga'; -if ($riga->isDescrizione()) { - $file = 'descrizione'; - - $options['op'] = 'manage_descrizione'; -} elseif ($riga->isArticolo()) { - $file = 'articolo'; - - $options['op'] = 'manage_articolo'; -} elseif ($riga->isSconto()) { - $file = 'sconto'; - - $options['op'] = 'manage_sconto'; -} - -echo App::load($file.'.php', $result, $options); diff --git a/modules/fatture/row-list.php b/modules/fatture/row-list.php deleted file mode 100755 index 8cc19a4dc..000000000 --- a/modules/fatture/row-list.php +++ /dev/null @@ -1,494 +0,0 @@ -. - */ - -use Modules\Interventi\Intervento; - -include_once __DIR__.'/init.php'; - -echo ' -
    - - - - - - - - - - - - - '; - -// Righe documento -$righe = $fattura->getRighe(); -$num = 0; -foreach ($righe as $riga) { - ++$num; - - $extra = ''; - $mancanti = 0; - $delete = 'delete_riga'; - - // Individuazione dei seriali - if ($riga->isArticolo() && !empty($riga->abilita_serial)) { - $serials = $riga->serials; - $mancanti = abs($riga->qta) - count($serials); - - if ($mancanti > 0) { - $extra = 'class="warning"'; - } else { - $mancanti = 0; - } - } - - $extra_riga = ''; - if (!$riga->isDescrizione()) { - // Informazioni su CIG, CUP, ... - if ($riga->hasOriginalComponent()) { - $documento_originale = $riga->getOriginalComponent()->getDocument(); - - $num_item = $documento_originale['num_item']; - $codice_cig = $documento_originale['codice_cig']; - $codice_commessa = $documento_originale['codice_commessa']; - $codice_cup = $documento_originale['codice_cup']; - $id_documento_fe = $documento_originale['id_documento_fe']; - } - - $descrizione_conto = $dbo->fetchOne('SELECT descrizione FROM co_pianodeiconti3 WHERE id = '.prepare($riga->id_conto))['descrizione']; - - $extra_riga = replace('_DESCRIZIONE_CONTO__ID_DOCUMENTO__NUMERO_RIGA__CODICE_COMMESSA__CODICE_CIG__CODICE_CUP__RITENUTA_ACCONTO__RITENUTA_CONTRIBUTI__RIVALSA_', [ - '_RIVALSA_' => $riga->rivalsa_inps ? '
    Rivalsa: '.moneyFormat(abs($riga->rivalsa_inps)) : null, - '_RITENUTA_ACCONTO_' => $riga->ritenuta_acconto ? '
    Ritenuta acconto: '.moneyFormat(abs($riga->ritenuta_acconto)) : null, - '_RITENUTA_CONTRIBUTI_' => $riga->ritenuta_contributi ? '
    Ritenuta contributi: '.moneyFormat(abs($riga->ritenuta_contributi)) : null, - '_DESCRIZIONE_CONTO_' => $descrizione_conto ?: ' - '.tr('Conto mancante').'', - '_ID_DOCUMENTO_' => $id_documento_fe ? ' - DOC: '.$id_documento_fe : null, - '_NUMERO_RIGA_' => $num_item ? ', NRI: '.$num_item : null, - '_CODICE_COMMESSA_' => $codice_commessa ? ', COM: '.$codice_commessa : null, - '_CODICE_CIG_' => $codice_cig ? ', CIG: '.$codice_cig : null, - '_CODICE_CUP_' => $codice_cup ? ', CUP: '.$codice_cup : null, - ]); - } - - echo ' - - - - '; - - if ($riga->isDescrizione()) { - echo ' - - - - '; - } else { - // Quantità e unità di misura - echo ' - '; - - // Prezzi unitari - echo ' - '; - - // Iva - echo ' - '; - - // Importo - echo ' - '; - } - - // Possibilità di rimuovere una riga solo se la fattura non è pagata - echo ' - - '; -} - -echo ' - '; - -// Individuazione dei totali -$imponibile = $fattura->imponibile; -$sconto = $fattura->sconto; -$totale_imponibile = $fattura->totale_imponibile; -$iva = $fattura->iva; -$totale = $fattura->totale; -$sconto_finale = $fattura->getScontoFinale(); -$netto_a_pagare = $fattura->netto; -$rivalsa_inps = $fattura->rivalsa_inps; -$ritenuta_acconto = $fattura->ritenuta_acconto; -$ritenuta_contributi = $fattura->totale_ritenuta_contributi; - -// IMPONIBILE -echo ' - - - - - '; - -// SCONTO -if (!empty($sconto)) { - echo ' - - - - - '; - - // TOTALE IMPONIBILE - echo ' - - - - - '; -} - -// RIVALSA INPS -if (!empty($rivalsa_inps)) { - echo ' - - - - - '; -} - -// IVA -if (!empty($iva)) { - echo ' - - - - - '; -} - -// TOTALE -echo ' - - - - - '; - -// RITENUTA D'ACCONTO -if (!empty($ritenuta_acconto)) { - echo ' - - - - - '; -} - -// RITENUTA CONTRIBUTI -if (!empty($ritenuta_contributi)) { - echo ' - - - - - '; -} - -// SCONTO FINALE -if (!empty($sconto_finale)) { - echo ' - - - - - '; -} - -// NETTO A PAGARE -if ($totale != $netto_a_pagare) { - echo ' - - - - - '; -} - -echo ' -
    '.tr('#').''.tr('Descrizione').''.tr('Q.tà').''.tr('Prezzo unitario').''.tr('Iva unitaria').''.tr('Importo').'
    - '.$num.' - '; - - // Informazioni aggiuntive sulla destra - echo ' - - '.$extra_riga; - - // Aggiunta dei riferimenti ai documenti - if ($riga->hasOriginalComponent()) { - echo ' -
    '.reference($riga->getOriginalComponent()->getDocument(), tr('Origine')); - } - // Fix per righe da altre componenti degli Interventi - elseif (!empty($riga->idintervento)) { - echo ' -
    '.reference(Intervento::find($riga->idintervento), tr('Origine')); - } - - echo ' -
    '; - - if ($riga->isArticolo()) { - echo Modules::link('Articoli', $riga->idarticolo, $riga->codice.' - '.$riga->descrizione); - } else { - echo nl2br($riga->descrizione); - } - - if ($riga->isArticolo() && !empty($riga->articolo->deleted_at)) { - echo ' -
    '.tr('Articolo eliminato', []).''; - } - - if ($riga->isArticolo() && empty($riga->articolo->codice)) { - echo ' -
    '.tr('_DATO_ articolo mancante', [ - '_DATO_' => 'Codice', - ]).''; - } - - if ($riga->isArticolo() && !empty($riga->abilita_serial)) { - if (!empty($mancanti)) { - echo ' -
    '.tr('_NUM_ serial mancanti', [ - '_NUM_' => $mancanti, - ]).''; - } - if (!empty($serials)) { - echo ' -
    '.tr('SN').': '.implode(', ', $serials); - } - } - - echo ' -
    - '.numberFormat($riga->qta, 'qta').' '.$riga->um.' - - '.moneyFormat($riga->prezzo_unitario_corrente); - - if ($dir == 'entrata' && $riga->costo_unitario != 0) { - echo ' -
    - '.tr('Acquisto').': '.moneyFormat($riga->costo_unitario).' - '; - } - - if (abs($riga->sconto_unitario) > 0) { - $text = discountInfo($riga); - - echo ' -
    '.$text.''; - } - - echo ' -
    - '.moneyFormat($riga->iva_unitaria_scontata).' -
    '.$riga->aliquota->descrizione.' ('.$riga->aliquota->esigibilita.') '.(($riga->aliquota->esente) ? ' ('.$riga->aliquota->codice_natura_fe.')' : null).' -
    - '.moneyFormat($riga->importo).' - '; - - if ($record['stato'] != 'Pagato' && $record['stato'] != 'Emessa' && $riga->id != $fattura->rigaBollo->id) { - echo ' -
    '; - - if ($riga->isArticolo() && !empty($riga->abilita_serial)) { - echo ' - - - '; - } - - echo ' - - - - - - - - - - - - - - - -
    '; - } - - echo ' -
    - '.tr('Imponibile', [], ['upper' => true]).': - - '.moneyFormat($imponibile, 2).' -
    - '.tr('Sconto/maggiorazione', [], ['upper' => true]).': - - '.moneyFormat($sconto, 2).' -
    - '.tr('Totale imponibile', [], ['upper' => true]).': - - '.moneyFormat($totale_imponibile, 2).' -
    '; - - if ($dir == 'entrata') { - $descrizione_rivalsa = $database->fetchOne('SELECT CONCAT_WS(\' - \', codice, descrizione) AS descrizione FROM fe_tipo_cassa WHERE codice = '.prepare(setting('Tipo Cassa Previdenziale'))); - echo ' - - - '; - } - - echo ' - '.tr('Rivalsa', [], ['upper' => true]).' : - - '.moneyFormat($rivalsa_inps, 2).' -
    '; - - if ($records[0]['split_payment']) { - echo ''.tr('Iva a carico del destinatario', [], ['upper' => true]).':'; - } else { - echo ''.tr('Iva', [], ['upper' => true]).':'; - } - echo ' - - '.moneyFormat($iva, 2).' -
    - '.tr('Totale', [], ['upper' => true]).': - - '.moneyFormat($totale, 2).' -
    - '.tr("Ritenuta d'acconto", [], ['upper' => true]).': - - '.moneyFormat($ritenuta_acconto, 2).' -
    - '.tr('Ritenuta contributi', [], ['upper' => true]).': - - '.moneyFormat($ritenuta_contributi, 2).' -
    - '.tr('Sconto finale', [], ['upper' => true]).': - - '.moneyFormat($sconto_finale, 2).' -
    - '.tr('Netto a pagare', [], ['upper' => true]).': - - '.moneyFormat($netto_a_pagare, 2).' -
    -
    '; - -echo ' -'; diff --git a/modules/fatture/src/Components/Articolo.php b/modules/fatture/src/Components/Articolo.php deleted file mode 100755 index 32dcdedf1..000000000 --- a/modules/fatture/src/Components/Articolo.php +++ /dev/null @@ -1,75 +0,0 @@ -. - */ - -namespace Modules\Fatture\Components; - -use Common\Components\Article; - -/** - * @extends Article<\Modules\Fatture\Fattura> - */ -class Articolo extends Article -{ - use RelationTrait; - - protected $table = 'co_righe_documenti'; - protected $serialRowID = 'documento'; - - public function movimenta($qta) - { - $documento = $this->getDocument(); - if (!$documento->movimenta_magazzino) { - return; - } - - $movimenta = true; - - // Controllo sul documento di origine dell'articolo: effettua il movimento di magazzino solo se non è già stato effettuato - // Se il documento corrente è una Nota (di credito/debito) si veda il controllo successivo - if (!$documento->isNota() && $this->hasOriginalComponent()) { - $original = $this->getOriginalComponent(); - $movimenta = !$original->getDocument()->movimenta_magazzino; - } - - // Gestione casistica per Note (di credito/debito) - if ($documento->isNota()) { - // Correzione delle quantità per gestione dei movimenti invertiti - $qta = -$qta; - - if ($this->hasOriginalComponent()) { - $original = $this->getOriginalComponent(); - $original_document = $original->getDocument(); - $direzione_inversa = $original_document->direzione != $this->getDocument()->direzione; - - // Inversione aggiuntiva in caso di origine da documenti della tipologia inversa - $qta = $direzione_inversa ? -$qta : $qta; - - // Controllo sul documento di origine dell'articolo: se i movimenti sono già stati effettuati e la direzione è invertita rispetto alla Nota, non si effettuano altri movimenti - // Esempio: DDT in entrata (documento di uscita) -> Nota di credito (documento di entrata) - if ($original_document->movimenta_magazzino && $direzione_inversa) { - $movimenta = false; - } - } - } - - if ($movimenta) { - $this->movimentaMagazzino($qta); - } - } -} diff --git a/modules/fatture/src/Components/Descrizione.php b/modules/fatture/src/Components/Descrizione.php deleted file mode 100755 index da8a16559..000000000 --- a/modules/fatture/src/Components/Descrizione.php +++ /dev/null @@ -1,32 +0,0 @@ -. - */ - -namespace Modules\Fatture\Components; - -use Common\Components\Description; - -/** - * @extends Description<\Modules\Fatture\Fattura> - */ -class Descrizione extends Description -{ - use RelationTrait; - - protected $table = 'co_righe_documenti'; -} diff --git a/modules/fatture/src/Components/RelationTrait.php b/modules/fatture/src/Components/RelationTrait.php deleted file mode 100755 index c4545aa5c..000000000 --- a/modules/fatture/src/Components/RelationTrait.php +++ /dev/null @@ -1,252 +0,0 @@ -. - */ - -namespace Modules\Fatture\Components; - -use Illuminate\Database\Eloquent\Builder; -use Modules\Fatture\Fattura; -use Modules\Ritenute\RitenutaAcconto; -use Modules\Rivalse\RivalsaINPS; - -trait RelationTrait -{ - public function getDocumentID() - { - return 'iddocumento'; - } - - public function document() - { - return $this->belongsTo(Fattura::class, $this->getDocumentID()); - } - - public function fattura() - { - return $this->document(); - } - - public function getNettoAttribute() - { - $result = $this->totale - $this->ritenuta_acconto - $this->ritenuta_contributi; - - if ($this->getDocument()->split_payment) { - $result = $result - $this->iva; - } - - return $result; - } - - /** - * Restituisce i dati aggiuntivi per la fattura elettronica dell'elemento. - * - * @return array - */ - public function getDatiAggiuntiviFEAttribute() - { - $result = json_decode($this->attributes['dati_aggiuntivi_fe'], true); - - return (array) $result; - } - - /** - * Imposta i dati aggiuntivi per la fattura elettronica dell'elemento. - */ - public function setDatiAggiuntiviFEAttribute($values) - { - $values = (array) $values; - $dati = array_deep_clean($values); - - $this->attributes['dati_aggiuntivi_fe'] = json_encode($dati); - } - - /** - * Restituisce il totale (imponibile + iva + rivalsa_inps + iva_rivalsainps) dell'elemento. - * - * @return float - */ - public function getTotaleAttribute() - { - return $this->totale_imponibile + $this->iva + $this->rivalsa_inps + $this->iva_rivalsa_inps; - } - - public function getRivalsaINPSAttribute() - { - return $this->totale_imponibile / 100 * $this->rivalsa->percentuale; - } - - public function getIvaRivalsaINPSAttribute() - { - return $this->rivalsa_inps / 100 * $this->aliquota->percentuale; - } - - public function getRitenutaAccontoAttribute() - { - $result = $this->totale_imponibile; - - if ($this->calcolo_ritenuta_acconto == 'IMP+RIV') { - $result += $this->rivalsainps; - } - - $ritenuta = $this->ritenuta; - $result = $result * $ritenuta->percentuale_imponibile / 100; - - return $result / 100 * $ritenuta->percentuale; - } - - public function getRitenutaContributiAttribute() - { - if ($this->attributes['ritenuta_contributi']) { - $result = $this->totale_imponibile; - $ritenuta = $this->getDocument()->ritenutaContributi; - - $result = $result * $ritenuta->percentuale_imponibile / 100; - - return $result / 100 * $ritenuta->percentuale; - } - - return 0; - } - - /** - * Imposta l'identificatore della Rivalsa INPS. - * - * @param int $value - */ - public function setIdRivalsaINPSAttribute($value) - { - $this->attributes['idrivalsainps'] = $value; - $this->load('rivalsa'); - } - - /** - * Imposta l'identificatore della Ritenuta d'Acconto. - * - * @param int $value - */ - public function setIdRitenutaAccontoAttribute($value) - { - $this->attributes['idritenutaacconto'] = $value; - $this->load('ritenuta'); - } - - public function getIdContoAttribute() - { - return $this->attributes['idconto']; - } - - public function setIdContoAttribute($value) - { - $this->attributes['idconto'] = $value; - } - - public function rivalsa() - { - return $this->belongsTo(RivalsaINPS::class, 'idrivalsainps'); - } - - public function ritenuta() - { - return $this->belongsTo(RitenutaAcconto::class, 'idritenutaacconto'); - } - - /** - * Salva la riga, impostando i campi dipendenti dai parametri singoli. - * - * @return bool - */ - public function save(array $options = []) - { - $this->fixRitenutaAcconto(); - $this->fixRivalsaINPS(); - - return parent::save($options); - } - - public function delete() - { - $result = parent::delete(); - - if (!empty($this->idintervento)) { - database()->query("UPDATE in_interventi SET idstatointervento = (SELECT idstatointervento FROM in_statiintervento WHERE codice = 'OK') WHERE id=".prepare($this->idintervento)); - } - - return $result; - } - - /** - * Modifica la quantità del componente. - * Se la fattura è una Nota di credito/debito, risale al secondo livello di origine del componente e corregge di conseguenza le quantità evase. - * - * @param float $value - * - * @return float - */ - public function setQtaAttribute($value) - { - list($qta, $diff) = $this->parseQta($value); - parent::setQtaAttribute($value); - - // Individuazione fattura corrente (fix in caso di creazione diretta) - $fattura = $this->fattura; - if (isset($fattura) && $fattura->isNota() && $this->hasOriginalComponent()) { - $source = $this->getOriginalComponent(); - - // Aggiornamento della quantità evasa di origine - if ($source->hasOriginalComponent()) { - $target = $source->getOriginalComponent(); - - $target->qta_evasa -= $diff; - $target->save(); - } - } - - return $diff; - } - - /** - * Effettua i conti per la Rivalsa INPS. - */ - protected function fixRivalsaINPS() - { - $this->attributes['rivalsainps'] = $this->rivalsa_inps; - } - - /** - * Effettua i conti per la Ritenuta d'Acconto, basandosi sul valore del campo calcolo_ritenuta_acconto. - */ - protected function fixRitenutaAcconto() - { - $this->attributes['ritenutaacconto'] = $this->ritenuta_acconto; - } - - protected static function boot($bypass = false) - { - parent::boot($bypass); - - // Precaricamento Rivalsa INPS - static::addGlobalScope('rivalsa', function (Builder $builder) { - $builder->with('rivalsa'); - }); - - // Precaricamento Ritenuta d'Acconto - static::addGlobalScope('ritenuta', function (Builder $builder) { - $builder->with('ritenuta'); - }); - } -} diff --git a/modules/fatture/src/Components/Riga.php b/modules/fatture/src/Components/Riga.php deleted file mode 100755 index b068730cc..000000000 --- a/modules/fatture/src/Components/Riga.php +++ /dev/null @@ -1,32 +0,0 @@ -. - */ - -namespace Modules\Fatture\Components; - -use Common\Components\Row; - -/** - * @extends Row<\Modules\Fatture\Fattura> - */ -class Riga extends Row -{ - use RelationTrait; - - protected $table = 'co_righe_documenti'; -} diff --git a/modules/fatture/src/Components/Sconto.php b/modules/fatture/src/Components/Sconto.php deleted file mode 100755 index e1e7078cb..000000000 --- a/modules/fatture/src/Components/Sconto.php +++ /dev/null @@ -1,32 +0,0 @@ -. - */ - -namespace Modules\Fatture\Components; - -use Common\Components\Discount; - -/** - * @extends Discount<\Modules\Fatture\Fattura> - */ -class Sconto extends Discount -{ - use RelationTrait; - - protected $table = 'co_righe_documenti'; -} diff --git a/modules/fatture/src/Export/CSV.php b/modules/fatture/src/Export/CSV.php deleted file mode 100644 index 9a187e96c..000000000 --- a/modules/fatture/src/Export/CSV.php +++ /dev/null @@ -1,71 +0,0 @@ -. - */ - -namespace Modules\Fatture\Export; - -use Exporter\CSVExporter; -use Modules\Fatture\Fattura; - -/** - * Struttura per la gestione delle operazioni di esportazione (in CSV) delle Fatture. - * - * @since 2.4.18 - */ -class CSV extends CSVExporter -{ - public function getAvailableFields() - { - return [ - [ - 'field' => 'id', - 'label' => 'ID', - 'primary_key' => true, - ], - [ - 'field' => 'numero_esterno', - 'label' => 'Numero', - ], - [ - 'field' => 'data', - 'label' => 'Data', - ], - [ - 'field' => 'anagrafica.ragione_sociale', - 'label' => 'Ragione sociale', - ], - [ - 'field' => 'totale', - 'label' => 'Totale', - ], - [ - 'field' => 'stato.descrizione', - 'label' => 'Stato', - ], - [ - 'field' => 'codice_stato_fe', - 'label' => 'Stato FE', - ], - ]; - } - - public function getRecords() - { - return Fattura::all(); - } -} diff --git a/modules/fatture/src/Fattura.php b/modules/fatture/src/Fattura.php deleted file mode 100755 index 4a932ad12..000000000 --- a/modules/fatture/src/Fattura.php +++ /dev/null @@ -1,839 +0,0 @@ -. - */ - -namespace Modules\Fatture; - -use Auth; -use Carbon\Carbon; -use Common\Components\Component; -use Common\Document; -use Illuminate\Database\Eloquent\Builder; -use Models\Upload; -use Modules\Anagrafiche\Anagrafica; -use Modules\Banche\Banca; -use Modules\Fatture\Gestori\Bollo as GestoreBollo; -use Modules\Fatture\Gestori\Movimenti as GestoreMovimenti; -use Modules\Fatture\Gestori\Scadenze as GestoreScadenze; -use Modules\Pagamenti\Pagamento; -use Modules\PrimaNota\Movimento; -use Modules\RitenuteContributi\RitenutaContributi; -use Modules\Scadenzario\Scadenza; -use Plugins\DichiarazioniIntento\Dichiarazione; -use Plugins\ExportFE\FatturaElettronica; -use Traits\RecordTrait; -use Traits\ReferenceTrait; -use Translator; -use Util\Generator; - -class Fattura extends Document -{ - use RecordTrait; - use ReferenceTrait; - - protected $table = 'co_documenti'; - - protected $casts = [ - 'bollo' => 'float', - 'peso' => 'float', - 'volume' => 'float', - - 'sconto_finale' => 'float', - 'sconto_finale_percentuale' => 'float', - ]; - - protected $with = [ - 'tipo', - ]; - - protected $dates = [ - 'data', - ]; - - /** @var GestoreScadenze */ - protected $gestoreScadenze; - /** @var GestoreMovimenti */ - protected $gestoreMovimenti; - /** @var GestoreBollo */ - protected $gestoreBollo; - - public function __construct(array $attributes = []) - { - parent::__construct($attributes); - - // Inizializzazione gestori relativi - $this->gestoreScadenze = new GestoreScadenze($this); - $this->gestoreMovimenti = new GestoreMovimenti($this); - $this->gestoreBollo = new GestoreBollo($this); - } - - /** - * Crea una nuova fattura. - * - * @param string $data - * @param int $id_segment - * - * @return self - */ - public static function build(Anagrafica $anagrafica, Tipo $tipo_documento, $data, $id_segment, $numero_esterno = null) - { - $model = new static(); - - $user = Auth::user(); - $database = database(); - - // Individuazione dello stato predefinito per il documento - $stato_documento = Stato::where('descrizione', 'Bozza')->first(); - $direzione = $tipo_documento->dir; - - // Conto predefinito sulla base del flusso di denaro - if ($direzione == 'entrata') { - $id_conto = setting('Conto predefinito fatture di vendita'); - $conto = 'vendite'; - } else { - $id_conto = setting('Conto predefinito fatture di acquisto'); - $conto = 'acquisti'; - } - - // Informazioni di base - $model->anagrafica()->associate($anagrafica); - $model->tipo()->associate($tipo_documento); - $model->stato()->associate($stato_documento); - - $model->save(); - - // Salvataggio delle informazioni - $model->data = $data; - $model->data_registrazione = $data; - $model->data_competenza = $data; - $model->id_segment = $id_segment; - $model->idconto = $id_conto; - if ($numero_esterno) { - $model->numero_esterno = $numero_esterno; - } - - // Sede aziendale scelta tra le sedi disponibili per l'utente - $id_sede = $user->sedi[0]; - if ($direzione == 'entrata') { - $model->idsede_destinazione = $id_sede; - } else { - $model->idsede_partenza = $id_sede; - } - - // Gestione della marca da bollo predefinita - $model->addebita_bollo = setting('Addebita marca da bollo al cliente'); - - // Ritenuta contributi predefinita - $id_ritenuta_contributi = ($tipo_documento->dir == 'entrata') ? setting('Ritenuta contributi') : null; - $model->id_ritenuta_contributi = $id_ritenuta_contributi ?: null; - - // Banca predefinita per l'anagrafica controparte - //$model->id_banca_controparte = ; - - // Tipo di pagamento dall'anagrafica controparte - $id_pagamento = $database->fetchOne('SELECT id FROM co_pagamenti WHERE id = :id_pagamento', [ - ':id_pagamento' => $anagrafica->{'idpagamento_'.$conto}, - ])['id']; - - // Per Fatture di Vendita senza pagamento predefinito per il Cliente, si utilizza il pagamento predefinito dalle Impostazioni - if ($direzione == 'entrata' && empty($id_pagamento)) { - $id_pagamento = setting('Tipo di pagamento predefinito'); - } - - // Salvataggio del pagamento - if (!empty($id_pagamento)) { - $model->idpagamento = $id_pagamento; - } - - // Banca predefinita per l'azienda, con ricerca della banca impostata per il pagamento - $id_banca_azienda = $anagrafica->{'idbanca_'.$conto}; - if (empty($id_banca_azienda)) { - $azienda = Anagrafica::find(setting('Azienda predefinita')); - $id_banca_azienda = $database->fetchOne('SELECT id FROM co_banche WHERE id_pianodeiconti3 = (SELECT idconto_'.$conto.' FROM co_pagamenti WHERE id = :id_pagamento) AND id_anagrafica = :id_anagrafica', [ - ':id_pagamento' => $id_pagamento, - ':id_anagrafica' => $azienda->id, - ])['id']; - if (empty($id_banca_azienda)) { - $id_banca_azienda = $azienda->{'idbanca_'.$conto}; - } - } - - $model->id_banca_azienda = $id_banca_azienda; - - // Gestione dello Split Payment sulla base dell'anagrafica Controparte - $split_payment = $anagrafica->split_payment; - if (!empty($split_payment)) { - $model->split_payment = $split_payment; - } - - // Gestione della Dichiarazione d'Intento associata all'anargafica Controparte - $now = new Carbon(); - $dichiarazione = $anagrafica->dichiarazioni() - ->where('massimale', '>', 'totale') - ->where('data_inizio', '<', $now) - ->where('data_fine', '>', $now) - ->first(); - if (!empty($dichiarazione)) { - $model->dichiarazione()->associate($dichiarazione); - - // Registrazione dell'operazione nelle note - $model->note = tr("Operazione non imponibile come da vostra dichiarazione d'intento nr _PROT_ del _PROT_DATE_ emessa in data _RELEASE_DATE_, da noi registrata al nr _ID_ del _DATE_", [ - '_PROT_' => $dichiarazione->numero_protocollo, - '_PROT_DATE_' => Translator::dateToLocale($dichiarazione->data_protocollo), - '_RELEASE_DATE_' => Translator::dateToLocale($dichiarazione->data_emissione), - '_ID_' => $dichiarazione->id, - '_DATE_' => Translator::dateToLocale($dichiarazione->data), - ]).'.'; - } - - $model->save(); - - return $model; - } - - // Attributi Eloquent - - /** - * Imposta il sezionale relativo alla fattura e calcola il relativo numero. - * **Attenzione**: la data deve inserita prima! - * - * @param int $value - */ - public function setIdSegmentAttribute($value) - { - $previous = $this->id_segment; - - $this->attributes['id_segment'] = $value; - - // Calcolo dei numeri fattura - if ($value != $previous) { - $direzione = $this->tipo->dir; - $data = $this->data; - - $this->numero = static::getNextNumero($data, $direzione, $value); - - if ($this->stato->descrizione == 'Bozza') { - $this->numero_esterno = null; - } elseif (!empty($previous)) { - $this->numero_esterno = static::getNextNumeroSecondario($data, $direzione, $value); - } - } - } - - /** - * Restituisce il nome del modulo a cui l'oggetto è collegato. - * - * @return string - */ - public function getModuleAttribute() - { - return $this->direzione == 'entrata' ? 'Fatture di vendita' : 'Fatture di acquisto'; - } - - public function getDirezioneAttribute() - { - return $this->tipo->dir; - } - - /** - * Restituisce il peso calcolato sulla base degli articoli del documento. - * - * @return float - */ - public function getPesoCalcolatoAttribute() - { - $righe = $this->getRighe(); - - $peso_lordo = $righe->sum(function ($item) { - return $item->isArticolo() ? $item->articolo->peso_lordo * $item->qta : 0; - }); - - return $peso_lordo; - } - - /** - * Restituisce il volume calcolato sulla base degli articoli del documento. - * - * @return float - */ - public function getVolumeCalcolatoAttribute() - { - $righe = $this->getRighe(); - - $volume = $righe->sum(function ($item) { - return $item->isArticolo() ? $item->articolo->volume * $item->qta : 0; - }); - - return $volume; - } - - // Calcoli - - /** - * Calcola la rivalsa INPS totale della fattura. - * - * @return float - */ - public function getRivalsaINPSAttribute() - { - return $this->calcola('rivalsa_inps'); - } - - /** - * Calcola l'IVA totale della fattura. - * - * @return float - */ - public function getIvaAttribute() - { - return $this->calcola('iva', 'iva_rivalsa_inps'); - } - - /** - * Calcola l'IVA INDETRAIBILE totale della fattura. - * - * @return float - */ - public function getIvaIndetraibileAttribute() - { - return $this->calcola('iva_indetraibile'); - } - - /** - * Calcola l'iva della rivalsa INPS totale della fattura. - * - * @return float - */ - public function getIvaRivalsaINPSAttribute() - { - return $this->calcola('iva_rivalsa_inps'); - } - - /** - * Calcola la ritenuta d'acconto totale della fattura. - * - * @return float - */ - public function getRitenutaAccontoAttribute() - { - return $this->calcola('ritenuta_acconto'); - } - - public function getTotaleRitenutaContributiAttribute() - { - return $this->calcola('ritenuta_contributi'); - } - - /** - * Restituisce i dati aggiuntivi per la fattura elettronica dell'elemento. - * - * @return array - */ - public function getDatiAggiuntiviFEAttribute() - { - $result = json_decode($this->attributes['dati_aggiuntivi_fe'], true); - - return (array) $result; - } - - /** - * Imposta i dati aggiuntivi per la fattura elettronica dell'elemento. - */ - public function setDatiAggiuntiviFEAttribute($values) - { - $values = (array) $values; - $dati = array_deep_clean($values); - - $this->attributes['dati_aggiuntivi_fe'] = json_encode($dati); - } - - // Relazioni Eloquent - - public function anagrafica() - { - return $this->belongsTo(Anagrafica::class, 'idanagrafica'); - } - - public function tipo() - { - return $this->belongsTo(Tipo::class, 'idtipodocumento'); - } - - public function stato() - { - return $this->belongsTo(Stato::class, 'idstatodocumento'); - } - - public function pagamento() - { - return $this->belongsTo(Pagamento::class, 'idpagamento'); - } - - public function dichiarazione() - { - return $this->belongsTo(Dichiarazione::class, 'id_dichiarazione_intento'); - } - - public function statoFE() - { - return $this->belongsTo(StatoFE::class, 'codice_stato_fe'); - } - - public function articoli() - { - return $this->hasMany(Components\Articolo::class, 'iddocumento'); - } - - public function righe() - { - return $this->hasMany(Components\Riga::class, 'iddocumento'); - } - - public function sconti() - { - return $this->hasMany(Components\Sconto::class, 'iddocumento'); - } - - public function descrizioni() - { - return $this->hasMany(Components\Descrizione::class, 'iddocumento'); - } - - public function ritenutaContributi() - { - return $this->belongsTo(RitenutaContributi::class, 'id_ritenuta_contributi'); - } - - public function rigaBollo() - { - return $this->hasOne(Components\Riga::class, 'iddocumento')->where('id', $this->id_riga_bollo); - } - - public function scadenze() - { - return $this->hasMany(Scadenza::class, 'iddocumento')->orderBy('scadenza'); - } - - public function movimentiContabili() - { - return $this->hasMany(Movimento::class, 'iddocumento')->where('primanota', 1); - } - - // Metodi generali - - public function triggerComponent(Component $trigger) - { - parent::triggerComponent($trigger); - - // Correzione del totale della dichiarazione d'intento - $dichiarazione = $this->dichiarazione; - if (!empty($dichiarazione)) { - $dichiarazione->fixTotale(); - $dichiarazione->save(); - } - } - - /** - * Restituisce i contenuti della fattura elettronica relativa al documento. - * - * @return false|string - */ - public function getXML() - { - if (empty($this->progressivo_invio) && $this->module == 'Fatture di acquisto') { - $fe = new FatturaElettronica($this->id); - - return $fe->toXML(); - } - - $file = $this->uploads()->where('name', '=', 'Fattura Elettronica')->first(); - - return $file->getContent(); - } - - /** - * Restituisce le ricevute della fattura elettronica relativa al documento. - * - * @return iterable - */ - public function getRicevute() - { - $nome = 'Ricevuta'; - - return $this->uploads()->filter(function ($item) use ($nome) { - return false !== strstr($item->name, $nome); - })->sortBy('created_at'); - } - - /** - * Restituisce la ricevuta principale, impostata attraverso il campo aggiuntivo id_ricevuta_principale. - * - * @return Upload|null - */ - public function getRicevutaPrincipale() - { - if (empty($this->id_ricevuta_principale)) { - return null; - } - - return $this->getModule() - ->uploads($this->id) - ->where('id', $this->id_ricevuta_principale) - ->first(); - } - - /** - * Restituisce la fattura elettronica registrata come allegato. - * - * @return Upload|null - */ - public function getFatturaElettronica() - { - return $this->uploads() - ->where('name', '=', 'Fattura Elettronica') - ->first(); - } - - /** - * Controlla se la fattura di acquisto è elettronica. - * - * @return bool - */ - public function isFE() - { - $file = $this->getFatturaElettronica(); - - return !empty($this->progressivo_invio) and file_exists($file->filepath); - } - - /** - * Registra le scadenze della fattura. - * - * @param bool $is_pagato - * @param bool $ignora_fe - */ - public function registraScadenze($is_pagato = false, $ignora_fe = false) - { - $this->gestoreScadenze->registra($is_pagato, $ignora_fe); - } - - /** - * Elimina le scadenze della fattura. - */ - public function rimuoviScadenze() - { - $this->gestoreScadenze->rimuovi(); - } - - /** - * Salva la fattura, impostando i campi dipendenti dai singoli parametri. - * - * @return bool - */ - public function save(array $options = []) - { - // Informazioni sul cambio dei valori - $stato_precedente = Stato::find($this->original['idstatodocumento']); - $dichiarazione_precedente = Dichiarazione::find($this->original['id_dichiarazione_intento']); - $is_fiscale = $this->isFiscale(); - - // Salvataggio effettivo - $result = parent::save($options); - - // Fix dei campi statici - $this->id_riga_bollo = $this->gestoreBollo->manageRigaMarcaDaBollo(); - - $this->attributes['ritenutaacconto'] = $this->ritenuta_acconto; - $this->attributes['iva_rivalsainps'] = $this->iva_rivalsa_inps; - $this->attributes['rivalsainps'] = $this->rivalsa_inps; - $this->attributes['ritenutaacconto'] = $this->ritenuta_acconto; - - // Generazione numero fattura se non presente (Bozza -> Emessa) - if ((($stato_precedente->descrizione == 'Bozza' && $this->stato['descrizione'] == 'Emessa') or (!$is_fiscale)) && empty($this->numero_esterno)) { - $this->numero_esterno = self::getNextNumeroSecondario($this->data, $this->direzione, $this->id_segment); - } - - // Salvataggio effettivo - $result = parent::save($options); - - // Operazioni al cambiamento di stato - // Bozza o Annullato -> Stato diverso da Bozza o Annullato - if ( - in_array($stato_precedente->descrizione, ['Bozza', 'Annullata']) - && !in_array($this->stato['descrizione'], ['Bozza', 'Annullata']) - ) { - // Registrazione scadenze - $this->registraScadenze($this->stato['descrizione'] == 'Pagato'); - - // Registrazione movimenti - $this->gestoreMovimenti->registra(); - } // Stato qualunque -> Bozza o Annullato - elseif (in_array($this->stato['descrizione'], ['Bozza', 'Annullata'])) { - // Rimozione delle scadenza - $this->rimuoviScadenze(); - - // Rimozione dei movimenti - $this->gestoreMovimenti->rimuovi(); - - // Rimozione dei movimenti contabili (Prima nota) - $this->movimentiContabili()->delete(); - } - - // Operazioni sulla dichiarazione d'intento - if (!empty($dichiarazione_precedente) && $dichiarazione_precedente->id != $this->id_dichiarazione_intento) { - // Correzione dichiarazione precedente - $dichiarazione_precedente->fixTotale(); - $dichiarazione_precedente->save(); - - // Correzione nuova dichiarazione - $dichiarazione = Dichiarazione::find($this->id_dichiarazione_intento); - if (!empty($dichiarazione)) { - $dichiarazione->fixTotale(); - $dichiarazione->save(); - } - } - - return $result; - } - - public function delete() - { - $result = parent::delete(); - - // Rimozione delle scadenza - $this->rimuoviScadenze(); - - // Rimozione dei movimenti - $this->gestoreMovimenti->rimuovi(); - - // Rimozione dei movimenti contabili (Prima nota) - $this->movimentiContabili()->delete(); - - return $result; - } - - public function replicate(array $except = null) - { - $new = parent::replicate($except); - $now = Carbon::now(); - - // In fase di duplicazione di una fattura non deve essere calcolato il numero progressivo ma questo deve - // essere generato in fase di emissione della stessa. - $new->numero_esterno = ''; - $new->numero = Fattura::getNextNumero($now, $new->direzione, $new->id_segment); - - // Rimozione informazioni di Fattura Elettronica - $new->hook_send = false; - $new->codice_stato_fe = null; - $new->progressivo_invio = null; - $new->data_stato_fe = null; - $new->data = $now; - $new->data_registrazione = $now; - $new->data_competenza = $now; - $new->descrizione_ricevuta_fe = null; - $new->id_ricevuta_principale = null; - - // Spostamento dello stato - $stato = Stato::where('descrizione', 'Bozza')->first(); - $new->stato()->associate($stato); - - return $new; - } - - /** - * Restituisce l'elenco delle note di credito collegate. - * - * @return iterable - */ - public function getNoteDiAccredito() - { - return self::where('ref_documento', $this->id)->get(); - } - - /** - * Restituisce l'elenco delle note di credito collegate. - * - * @return self - */ - public function getFatturaOriginale() - { - return self::find($this->ref_documento); - } - - /** - * Controlla se la fattura è una nota di credito. - * - * @return bool - */ - public function isNota() - { - return $this->tipo->reversed == 1; - } - - /** - * Controlla se la fattura è fiscale. - * - * @return bool - */ - public function isFiscale() - { - $result = database()->fetchOne('SELECT is_fiscale FROM zz_segments WHERE id ='.prepare($this->id_segment))['is_fiscale']; - - return $result; - } - - /** - * Scope per l'inclusione delle sole fatture con valore contabile. - * - * @param \Illuminate\Database\Eloquent\Builder $query - * - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeContabile($query) - { - return $query->whereHas('stato', function (Builder $query) { - $query->whereIn('descrizione', ['Emessa', 'Parzialmente pagato', 'Pagato']); - }); - } - - /** - * Restituisce i dati bancari in base al pagamento. - * - * @return array - */ - public function getBanca() - { - $pagamento = $this->pagamento; - - if ($pagamento->isRiBa()) { - $banca = Banca::where('id_anagrafica', $this->idanagrafica) - ->where('predefined', 1) - ->first(); - } else { - $banca = Banca::find($this->id_banca_azienda); - } - - return $banca; - } - - // Metodi statici - - /** - * Calcola il nuovo numero di fattura. - * - * @param string $data - * @param string $direzione - * @param int $id_segment - * - * @return string - */ - public static function getNextNumero($data, $direzione, $id_segment) - { - if ($direzione == 'entrata') { - return ''; - } - - // Recupero maschera per questo segmento - $maschera = Generator::getMaschera($id_segment); - - $ultimo = Generator::getPreviousFrom($maschera, 'co_documenti', 'numero', [ - 'YEAR(data) = '.prepare(date('Y', strtotime($data))), - 'id_segment = '.prepare($id_segment), - ]); - $numero = Generator::generate($maschera, $ultimo, 1, Generator::dateToPattern($data)); - - return $numero; - } - - /** - * Scope per l'inclusione delle fatture di vendita. - * - * @param \Illuminate\Database\Eloquent\Builder $query - * - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeVendita($query) - { - return $query->whereHas('tipo', function (Builder $query) { - $query->where('dir', 'entrata'); - }); - } - - /** - * Scope per l'inclusione delle fatture di acquisto. - * - * @param \Illuminate\Database\Eloquent\Builder $query - * - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeAcquisto($query) - { - return $query->whereHas('tipo', function (Builder $query) { - $query->where('dir', 'uscita'); - }); - } - - /** - * Calcola il nuovo numero secondario di fattura. - * - * @param string $data - * @param string $direzione - * @param int $id_segment - * - * @return string - */ - public static function getNextNumeroSecondario($data, $direzione, $id_segment) - { - if ($direzione == 'uscita') { - return ''; - } - - // Recupero maschera per questo segmento - $maschera = Generator::getMaschera($id_segment); - - $ultimo = Generator::getPreviousFrom($maschera, 'co_documenti', 'numero_esterno', [ - 'YEAR(data) = '.prepare(date('Y', strtotime($data))), - 'id_segment = '.prepare($id_segment), - ], $data); - $numero = Generator::generate($maschera, $ultimo, 1, Generator::dateToPattern($data)); - - return $numero; - } - - // Opzioni di riferimento - - public function getReferenceName() - { - return $this->tipo->descrizione; - } - - public function getReferenceNumber() - { - return $this->numero_esterno ?: $this->numero; - } - - public function getReferenceDate() - { - return $this->data; - } - - public function getReferenceRagioneSociale() - { - return $this->anagrafica->ragione_sociale; - } -} diff --git a/modules/fatture/src/Gestori/Bollo.php b/modules/fatture/src/Gestori/Bollo.php deleted file mode 100644 index eda5480f5..000000000 --- a/modules/fatture/src/Gestori/Bollo.php +++ /dev/null @@ -1,104 +0,0 @@ -. - */ - -namespace Modules\Fatture\Gestori; - -use Modules\Fatture\Components; -use Modules\Fatture\Fattura; - -/** - * Classe dedicata alla gestione del Bollo per la Fattura, compreso il calcolo del relativo valore e la generazione dinamica della riga associata. - * - * @since 2.4.17 - */ -class Bollo -{ - private $fattura; - - public function __construct(Fattura $fattura) - { - $this->fattura = $fattura; - } - - /** - * Metodo per calcolare automaticamente il bollo da applicare al documento. - * - * @return float - */ - public function getBollo() - { - if (isset($this->fattura->bollo)) { - return $this->fattura->bollo; - } - - $righe_bollo = $this->fattura->getRighe()->filter(function ($item, $key) { - return $item->aliquota != null && in_array($item->aliquota->codice_natura_fe, ['N1', 'N2.1', 'N2.2', 'N3.1', 'N3.2', 'N3.3', 'N3.4', 'N3.5', 'N3.6', 'N4']); - }); - $importo_righe_bollo = $righe_bollo->sum('netto'); - - // Leggo la marca da bollo se c'è e se il netto a pagare supera la soglia - $bollo = ($this->fattura->direzione == 'uscita') ? $this->fattura->bollo : setting('Importo marca da bollo'); - - $marca_da_bollo = 0; - if (abs($bollo) > 0 && abs($importo_righe_bollo) > setting("Soglia minima per l'applicazione della marca da bollo")) { - $marca_da_bollo = $bollo; - } - - // Se l'importo è negativo può essere una nota di credito, quindi cambio segno alla marca da bollo - $marca_da_bollo = abs($marca_da_bollo); - - return $marca_da_bollo; - } - - /** - * Metodo per aggiornare ed eventualmente aggiungere la marca da bollo al documento. - */ - public function manageRigaMarcaDaBollo() - { - $riga = $this->fattura->rigaBollo; - - $addebita_bollo = $this->fattura->addebita_bollo; - $marca_da_bollo = $this->getBollo(); - - // Rimozione riga bollo se nullo - if (empty($addebita_bollo) || empty($marca_da_bollo)) { - if (!empty($riga)) { - $riga->delete(); - } - - return null; - } - - // Creazione riga bollo se non presente - if (empty($riga)) { - $riga = Components\Riga::build($this->fattura); - $riga->save(); - } - - $riga->prezzo_unitario = $marca_da_bollo; - $riga->qta = 1; - $riga->descrizione = setting('Descrizione addebito bollo'); - $riga->id_iva = setting('Iva da applicare su marca da bollo'); - $riga->idconto = setting('Conto predefinito per la marca da bollo'); - - $riga->save(); - - return $riga->id; - } -} diff --git a/modules/fatture/src/Gestori/Movimenti.php b/modules/fatture/src/Gestori/Movimenti.php deleted file mode 100644 index ebe11c184..000000000 --- a/modules/fatture/src/Gestori/Movimenti.php +++ /dev/null @@ -1,237 +0,0 @@ -. - */ - -namespace Modules\Fatture\Gestori; - -use Modules\Fatture\Fattura; -use Modules\PrimaNota\Mastrino; -use Modules\PrimaNota\Movimento; - -/** - * Classe indirizzata alla gestione dei Movimenti automatici (non contabili, ovvero non di Prima Nota) associati a una Fattura. - * - * @since 2.4.17 - */ -class Movimenti -{ - protected $fattura; - protected $mastrino = null; - - public function __construct(Fattura $fattura) - { - $this->fattura = $fattura; - } - - public function getMastrino() - { - if (!isset($this->mastrino)) { - $this->mastrino = Mastrino::where('iddocumento', $this->fattura->id) - ->where('primanota', false) - ->first(); - } - - return $this->mastrino; - } - - public function generateMastrino() - { - $descrizione = $this->fattura->getReference(); - $data = $this->fattura->data_competenza; - - $mastrino = Mastrino::build($descrizione, $data, false, false); - $this->mastrino = $mastrino; - - return $this->mastrino; - } - - /** - * Registra i movimenti relativi alla fattura. - */ - public function registra() - { - // Rimozione degli elementi pre-esistenti - $this->rimuovi(); - - $movimenti = []; - - // Informazioni generali sul documento - $direzione = $this->fattura->direzione; - $is_acquisto = $direzione == 'uscita'; - $split_payment = $this->fattura->split_payment; - $is_nota = $this->fattura->isNota(); - - // Totali utili per i movimenti - $totale = $this->fattura->totale; - $iva_indetraibile = $this->fattura->iva_indetraibile; - $iva_detraibile = $this->fattura->iva - $iva_indetraibile; - - // Inversione di segno per le note - $totale = $is_nota ? -$totale : $totale; - $iva_indetraibile = $is_nota ? -$iva_indetraibile : $iva_indetraibile; - $iva_detraibile = $is_nota ? -$iva_detraibile : $iva_detraibile; - - /* - * 1) Movimento relativo al conto dell'anagrafica del documento - * - * Totale (Split Payment disabilitato), oppure Totale - IVA detraibile (Split Payment abilitato) -> DARE per Vendita, AVERE per Acquisto - */ - $anagrafica = $this->fattura->anagrafica; - - $id_conto = $is_acquisto ? $anagrafica->idconto_fornitore : $anagrafica->idconto_cliente; - if (empty($id_conto)) { - $id_conto = $is_acquisto ? setting('Conto per Riepilogativo fornitori') : setting('Conto per Riepilogativo clienti'); - } - $id_conto_controparte = $id_conto; // Salvataggio del conto dell'anagrafica per usi successivi - - $importo_anagrafica = $totale; - if ($split_payment) { - $importo_anagrafica = sum($importo_anagrafica, -$iva_detraibile, 2); - } - - $movimenti[] = [ - 'id_conto' => $id_conto, - 'dare' => $importo_anagrafica, - ]; - - /* - * 2) Movimento per ogni riga del documento - * Imponibile -> AVERE per Vendita, DARE per Acquisto - */ - $righe = $this->fattura->getRighe(); - foreach ($righe as $riga) { - // Retro-compatibilità per versioni <= 2.4 - $id_conto = $riga->id_conto ?: $this->fattura->idconto; - - $imponibile = $riga->totale_imponibile; - $imponibile = $is_nota ? -$imponibile : $imponibile; // Inversione di segno per le note - if (!empty($imponibile)) { - $movimenti[] = [ - 'id_conto' => $id_conto, - 'avere' => $imponibile, - ]; - } - } - - /* - * 3) IVA detraibile sul relativo conto (Split Payment disabilitato) - * IVA detraibile -> AVERE per Vendita, DARE per Acquisto - */ - if (!empty($iva_detraibile) && empty($split_payment)) { - $id_conto = $is_acquisto ? setting('Conto per Iva su acquisti') : setting('Conto per Iva su vendite'); - $movimenti[] = [ - 'id_conto' => $id_conto, - 'avere' => $iva_detraibile, - ]; - } - - /* - * 4) IVA indetraibile sul relativo conto (Split Payment disabilitato) - * IVA indetraibile -> AVERE per Vendita, DARE per Acquisto - */ - if (!empty($iva_indetraibile) && empty($split_payment)) { - $id_conto = setting('Conto per Iva indetraibile'); - $movimenti[] = [ - 'id_conto' => $id_conto, - 'avere' => $iva_indetraibile, - ]; - } - - /* - * 5) Rivalsa INPS sul relativo conto - * Rivalsa INPS (senza IVA) -> AVERE per Vendita, DARE per Acquisto - */ - $rivalsa_inps = $this->fattura->rivalsa_inps; - $rivalsa_inps = $is_nota ? -$rivalsa_inps : $rivalsa_inps; // Inversione di segno per le note - if (!empty($rivalsa_inps)) { - $id_conto = setting('Conto per Erario c/INPS'); - $movimenti[] = [ - 'id_conto' => $id_conto, - 'avere' => $rivalsa_inps, - ]; - } - - /* - * 6) Ritenuta d'acconto - * Conto "Conto per Erario c/ritenute d'acconto": DARE per Vendita, AVERE per Acquisto - * Conto della controparte: AVERE per Vendita, DARE per Acquisto - */ - $ritenuta_acconto = $this->fattura->ritenuta_acconto; - $ritenuta_acconto = $is_nota ? -$ritenuta_acconto : $ritenuta_acconto; // Inversione di segno per le note - if (!empty($ritenuta_acconto)) { - $id_conto = setting("Conto per Erario c/ritenute d'acconto"); - $movimenti[] = [ - 'id_conto' => $id_conto, - 'dare' => $ritenuta_acconto, - ]; - - $movimenti[] = [ - 'id_conto' => $id_conto_controparte, - 'avere' => $ritenuta_acconto, - ]; - } - - /* - * 7) Ritenuta contributi - * Conto "Conto per Erario c/enasarco": DARE per Vendita, AVERE per Acquisto - * Conto della controparte: AVERE per Vendita, DARE per Acquisto - */ - $ritenuta_contributi = $this->fattura->totale_ritenuta_contributi; - $ritenuta_contributi = $is_nota ? -$ritenuta_contributi : $ritenuta_contributi; // Inversione di segno per le note - if (!empty($ritenuta_contributi)) { - $id_conto = setting('Conto per Erario c/enasarco'); - $movimenti[] = [ - 'id_conto' => $id_conto, - 'dare' => $ritenuta_contributi, - ]; - - $movimenti[] = [ - 'id_conto' => $id_conto_controparte, - 'avere' => $ritenuta_contributi, - ]; - } - - // Inversione contabile per i documenti di acquisto - if ($is_acquisto) { - foreach ($movimenti as $key => $movimento) { - $movimenti[$key]['avere'] = $movimento['dare']; - $movimenti[$key]['dare'] = $movimento['avere']; - } - } - - // Registrazione dei singoli Movimenti nel relativo Mastrino - $mastrino = $this->generateMastrino(); - foreach ($movimenti as $element) { - $movimento = Movimento::build($mastrino, $element['id_conto'], $this->fattura); - $movimento->setTotale($element['avere'] ?: 0, $element['dare'] ?: 0); - $movimento->save(); - } - } - - /** - * Elimina i movimenti del mastrino relativo alla fattura. - */ - public function rimuovi() - { - $mastrino = $this->getMastrino(); - - if (!empty($mastrino)) { - $mastrino->delete(); - } - } -} diff --git a/modules/fatture/src/Gestori/Scadenze.php b/modules/fatture/src/Gestori/Scadenze.php deleted file mode 100644 index 2846263cd..000000000 --- a/modules/fatture/src/Gestori/Scadenze.php +++ /dev/null @@ -1,170 +0,0 @@ -. - */ - -namespace Modules\Fatture\Gestori; - -use Modules\Fatture\Fattura; -use Modules\Scadenzario\Scadenza; -use Plugins\ImportFE\FatturaElettronica as FatturaElettronicaImport; -use Util\XML; - -/** - * Classe dedicata alla gestione delle procedure di registrazione delle Scadenze di pagamento per una Fattura, con relativo supporto alla Fatturazione Elettronica per permettere l'importazione delle scadenze eventualmente registrate. - * - * @since 2.4.17 - */ -class Scadenze -{ - private $fattura; - - public function __construct(Fattura $fattura) - { - $this->fattura = $fattura; - } - - /** - * Registra le scadenze della fattura. - * - * @param bool $is_pagato - * @param bool $ignora_fe - */ - public function registra($is_pagato = false, $ignora_fe = false) - { - // Rimozione degli elementi pre-esistenti - $this->rimuovi(); - - if (!$ignora_fe && $this->fattura->module == 'Fatture di acquisto' && $this->fattura->isFE()) { - $scadenze_fe = $this->registraScadenzeFE($is_pagato); - } - - if (empty($scadenze_fe)) { - $this->registraScadenzeTradizionali($is_pagato); - } - - // Registrazione scadenza per Ritenuta d'Acconto - // Inversione di segno per le note - $ritenuta_acconto = $this->fattura->ritenuta_acconto; - $ritenuta_acconto = $this->fattura->isNota() ? -$ritenuta_acconto : $ritenuta_acconto; - - if (!empty($this->fattura->sconto_finale_percentuale)) { - $ritenuta_acconto = $ritenuta_acconto * (1 - $this->fattura->sconto_finale_percentuale / 100); - } - - $direzione = $this->fattura->tipo->dir; - $is_ritenuta_pagata = $this->fattura->is_ritenuta_pagata; - - // Se c'è una ritenuta d'acconto, la aggiungo allo scadenzario al 15 del mese dopo l'ultima scadenza di pagamento - if ($direzione == 'uscita' && $ritenuta_acconto > 0 && empty($is_ritenuta_pagata)) { - $ultima_scadenza = $this->fattura->scadenze->last(); - $scadenza = $ultima_scadenza->scadenza->copy()->startOfMonth()->addMonth(); - $scadenza->setDate($scadenza->year, $scadenza->month, 15); - - $importo = -$ritenuta_acconto; - - self::registraScadenza($this->fattura, $importo, $scadenza, $is_pagato, 'ritenutaacconto'); - } - } - - /** - * Elimina le scadenze della fattura. - */ - public function rimuovi() - { - database()->delete('co_scadenziario', ['iddocumento' => $this->fattura->id]); - } - - /** - * Registra una specifica scadenza nel database. - * - * @param float $importo - * @param string $data_scadenza - * @param bool $is_pagato - * @param string $type - */ - protected function registraScadenza(Fattura $fattura, $importo, $data_scadenza, $is_pagato, $type = 'fattura') - { - $numero = $fattura->numero_esterno ?: $fattura->numero; - $descrizione = $fattura->tipo->descrizione.' numero '.$numero; - - $scadenza = Scadenza::build($descrizione, $importo, $data_scadenza, $type, $is_pagato); - - $scadenza->documento()->associate($fattura); - $scadenza->data_emissione = $fattura->data; - - $scadenza->save(); - } - - /** - * Registra le scadenze della fattura elettronica collegata al documento. - * - * @param bool $is_pagato - * - * @return bool - */ - protected function registraScadenzeFE($is_pagato = false) - { - $xml = XML::read($this->fattura->getXML()); - - $fattura_body = $xml['FatturaElettronicaBody']; - - // Gestione per fattura elettroniche senza pagamento definito - $pagamenti = []; - if (isset($fattura_body['DatiPagamento'])) { - $pagamenti = $fattura_body['DatiPagamento']; - $pagamenti = isset($pagamenti[0]) ? $pagamenti : [$pagamenti]; - } - - foreach ($pagamenti as $pagamento) { - $rate = $pagamento['DettaglioPagamento']; - $rate = isset($rate[0]) ? $rate : [$rate]; - - foreach ($rate as $rata) { - $scadenza = !empty($rata['DataScadenzaPagamento']) ? FatturaElettronicaImport::parseDate($rata['DataScadenzaPagamento']) : $this->fattura->data; - $importo = $this->fattura->isNota() ? $rata['ImportoPagamento'] : -$rata['ImportoPagamento']; - - self::registraScadenza($this->fattura, $importo, $scadenza, $is_pagato); - } - } - - return !empty($pagamenti); - } - - /** - * Registra le scadenze tradizionali del gestionale. - * - * @param bool $is_pagato - */ - protected function registraScadenzeTradizionali($is_pagato = false) - { - // Inversione di segno per le note - $netto = $this->fattura->netto; - $netto = $this->fattura->isNota() ? -$netto : $netto; - - // Calcolo delle rate - $rate = $this->fattura->pagamento->calcola($netto, $this->fattura->data); - $direzione = $this->fattura->tipo->dir; - - foreach ($rate as $rata) { - $scadenza = $rata['scadenza']; - $importo = $direzione == 'uscita' ? -$rata['importo'] : $rata['importo']; - - self::registraScadenza($this->fattura, $importo, $scadenza, $is_pagato); - } - } -} diff --git a/modules/fatture/src/Stato.php b/modules/fatture/src/Stato.php deleted file mode 100755 index 632f069c5..000000000 --- a/modules/fatture/src/Stato.php +++ /dev/null @@ -1,35 +0,0 @@ -. - */ - -namespace Modules\Fatture; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; - -class Stato extends Model -{ - use SimpleModelTrait; - - protected $table = 'co_statidocumento'; - - public function fatture() - { - return $this->hasMany(Fattura::class, 'idstatodocumento'); - } -} diff --git a/modules/fatture/src/StatoFE.php b/modules/fatture/src/StatoFE.php deleted file mode 100755 index 422aa10d5..000000000 --- a/modules/fatture/src/StatoFE.php +++ /dev/null @@ -1,37 +0,0 @@ -. - */ - -namespace Modules\Fatture; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; - -class StatoFE extends Model -{ - use SimpleModelTrait; - - public $incrementing = false; - protected $table = 'fe_stati_documento'; - protected $primaryKey = 'codice'; - - public function fatture() - { - return $this->hasMany(Fattura::class, 'codice_stato_fe'); - } -} diff --git a/modules/fatture/src/Tipo.php b/modules/fatture/src/Tipo.php deleted file mode 100755 index 959823319..000000000 --- a/modules/fatture/src/Tipo.php +++ /dev/null @@ -1,35 +0,0 @@ -. - */ - -namespace Modules\Fatture; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; - -class Tipo extends Model -{ - use SimpleModelTrait; - - protected $table = 'co_tipidocumento'; - - public function fatture() - { - return $this->hasMany(Fattura::class, 'idtipodocumento'); - } -} diff --git a/modules/fatture/variables.php b/modules/fatture/variables.php deleted file mode 100755 index 61f93e1e5..000000000 --- a/modules/fatture/variables.php +++ /dev/null @@ -1,70 +0,0 @@ -. - */ - -$r = $dbo->fetchOne('SELECT co_documenti.*, - IF( (an_referenti.email IS NOT NULL AND an_referenti.email!=""), an_referenti.email, an_anagrafiche.email) AS email, - an_anagrafiche.idconto_cliente, - an_anagrafiche.idconto_fornitore, - an_anagrafiche.pec, - an_anagrafiche.ragione_sociale, - co_tipidocumento.descrizione AS tipo_documento, - (SELECT pec FROM em_accounts WHERE em_accounts.id='.prepare($template['id_account']).') AS is_pec -FROM co_documenti - INNER JOIN an_anagrafiche ON co_documenti.idanagrafica=an_anagrafiche.idanagrafica - INNER JOIN co_tipidocumento ON co_tipidocumento.id=co_documenti.idtipodocumento - LEFT OUTER JOIN an_referenti ON an_referenti.id=co_documenti.idreferente -WHERE co_documenti.id='.prepare($id_record)); - -if (!empty(setting('Logo stampe'))) { - $logo_azienda = base_url().'/'.Models\Upload::where('filename', setting('Logo stampe'))->first()->fileurl; -} else { - $logo_azienda = str_replace(base_dir(), base_url(), App::filepath('templates/base|custom|/logo_azienda.jpg')); - $logo_azienda = str_replace('\\', '/', $logo_azienda); -} - -//cliente -if ($r['idconto_cliente'] != '') { - $conto = $r['idconto_cliente']; - $conto_descrizione = $dbo->fetchOne('SELECT CONCAT ((SELECT numero FROM co_pianodeiconti2 WHERE id=co_pianodeiconti3.idpianodeiconti2), ".", numero, " ", descrizione) AS descrizione FROM co_pianodeiconti3 WHERE id='.prepare($conto))['descrizione']; -} -//Fornitore -elseif ($r['idconto_fornitore'] != '') { - $conto = $r['idconto_fornitore']; - $conto_descrizione = $dbo->fetchOne('SELECT CONCAT ((SELECT numero FROM co_pianodeiconti2 WHERE id=co_pianodeiconti3.idpianodeiconti2), ".", numero, " ", descrizione) AS descrizione FROM co_pianodeiconti3 WHERE id='.prepare($conto))['descrizione']; -} - -$r_user = $dbo->fetchOne('SELECT * FROM an_anagrafiche WHERE idanagrafica='.prepare(Auth::user()['idanagrafica'])); -$r_company = $dbo->fetchOne('SELECT * FROM an_anagrafiche WHERE idanagrafica='.prepare(setting('Azienda predefinita'))); - -// Variabili da sostituire -return [ - 'email' => $r['is_pec'] ? $r['pec'] : $r['email'], - 'id_anagrafica' => $r['idanagrafica'], - 'ragione_sociale' => $r['ragione_sociale'], - 'numero' => empty($r['numero_esterno']) ? $r['numero'] : $r['numero_esterno'], - 'tipo_documento' => $r['tipo_documento'], - 'note' => $r['note'], - 'data' => Translator::dateToLocale($r['data']), - 'logo_azienda' => !empty($logo_azienda) ? '' : '', - 'conto' => $conto, - 'conto_descrizione' => $conto_descrizione, - 'nome_utente' => $r_user['ragione_sociale'], - 'telefono_utente' => $r_user['cellulare'], - 'sito_web' => $r_company['sitoweb'], -]; diff --git a/modules/gestione_componenti/actions.php b/modules/gestione_componenti/actions.php deleted file mode 100755 index d0094d392..000000000 --- a/modules/gestione_componenti/actions.php +++ /dev/null @@ -1,76 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$path = base_dir().'/files/impianti/'; - -switch (post('op')) { - case 'update': - $nomefile = post('nomefile'); - $contenuto = post('contenuto'); - - if (!file_put_contents($path.$nomefile, $contenuto)) { - flash()->error(tr('Impossibile modificare il file!')); - } else { - flash()->info(tr('Informazioni salvate correttamente!')); - } - - break; - - case 'add': - $nomefile = str_replace('.ini', '', post('nomefile')).'.ini'; - $contenuto = post('contenuto'); - - $cmp = \Util\Ini::getList($path); - - $duplicato = false; - for ($c = 0; $c < count($cmp); ++$c) { - if ($nomefile == $cmp[$c][0]) { - $duplicato = true; - } - } - - if ($duplicato) { - flash()->error(tr('Il file componente _FILE_ esiste già, nessun nuovo componente è stato creato!', [ - '_FILE_' => "'".$nomefile."'", - ])); - } elseif (!file_put_contents($path.$nomefile, $contenuto)) { - flash()->error(tr('Impossibile creare il file!')); - } else { - flash()->info(tr('Componente _FILE_ aggiunto correttamente!', [ - '_FILE_' => "'".$nomefile."'", - ])); - } - - break; - - case 'delete': - $nomefile = post('nomefile'); - - if (!empty($nomefile)) { - delete($path.$nomefile); - - flash()->info(tr('File _FILE_ rimosso correttamente!', [ - '_FILE_' => "'".$nomefile."'", - ])); - } - - break; -} diff --git a/modules/gestione_componenti/add.php b/modules/gestione_componenti/add.php deleted file mode 100755 index 310ef4429..000000000 --- a/modules/gestione_componenti/add.php +++ /dev/null @@ -1,57 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "nomefile", "required": 1 ]} -
    - - -
    - [Default] - {[ "type": "textarea", "label": "", "name": "contenuto", "id": "contenuto_add", "required": 1, "class": "autosize", "extra": "rows='10'" ]} -
    -
    - - -
    -
    - -
    -
    -
    - - diff --git a/modules/gestione_componenti/ajax/select.php b/modules/gestione_componenti/ajax/select.php deleted file mode 100755 index 28a3f15fe..000000000 --- a/modules/gestione_componenti/ajax/select.php +++ /dev/null @@ -1,62 +0,0 @@ -. - */ - -use Util\Ini; - -include_once __DIR__.'/../../../core.php'; - -switch ($resource) { - /* - * Opzioni utilizzate: - * - matricola - */ - case 'componenti': - if (isset($superselect['matricola'])) { - $query = 'SELECT id, nome AS descrizione, contenuto FROM my_impianto_componenti |where| ORDER BY id'; - - foreach ($elements as $element) { - $filter[] = 'id='.prepare($element); - } - - $temp = []; - $impianti = explode(',', $superselect['matricola']); - foreach ($impianti as $key => $idimpianto) { - $temp[] = 'idimpianto='.prepare($idimpianto); - } - $where[] = '('.implode(' OR ', $temp).')'; - - if (!empty($search)) { - $search_fields[] = 'nome LIKE '.prepare('%'.$search.'%'); - } - - $results = AJAX::selectResults($query, $where, $filter, $search, $limit, $custom); - $data = $results['results']; - foreach ($data as $key => $value) { - $matricola = Ini::getValue($value['contenuto'], 'Matricola'); - - $data[$key]['text'] = (empty($matricola) ? '' : $matricola.' - ').$data[$key]['text']; - - unset($data[$key]['contenuto']); - } - - $results['results'] = $data; - } - - break; -} diff --git a/modules/gestione_componenti/edit.php b/modules/gestione_componenti/edit.php deleted file mode 100755 index c78ace8b2..000000000 --- a/modules/gestione_componenti/edit.php +++ /dev/null @@ -1,79 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (empty($id_record)) { - echo ' - - - - - - - - '; - - for ($c = 1; $c <= count($cmp); ++$c) { - echo ' - - - - '; - } - echo ' - -
    '.tr('Numero').''.tr('Nome del file').'
    '.$c.''.$cmp[$c - 1][0].'
    '; -} else { - ?> -
    - - - - -
    -
    -

    -
    - -
    - -
    -
    - {[ "type": "text", "label": "", "name": "nomefile", "required": 1, "value": "$nomefile$", "readonly": 1 ]} -
    -
    - - -
    -
    - {[ "type": "textarea", "label": "", "name": "contenuto", "required": 1, "class": "autosize", "value": "$contenuto$" ]} -
    -
    - -
    -
    -
    - - - - - -. - */ - -include_once __DIR__.'/../../core.php'; - -$cmp = \Util\Ini::getList(base_dir().'/files/impianti/'); - -if (!empty($id_record) && isset($cmp[$id_record - 1])) { - $record['nomefile'] = $cmp[$id_record - 1][0]; - $record['contenuto'] = file_get_contents(base_dir().'/files/impianti/'.$record['nomefile']); -} diff --git a/modules/gestione_documentale/actions.php b/modules/gestione_documentale/actions.php deleted file mode 100755 index 77979cfca..000000000 --- a/modules/gestione_documentale/actions.php +++ /dev/null @@ -1,56 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -switch (post('op')) { - case 'add': - $dbo->insert('do_documenti', [ - 'idcategoria' => post('idcategoria'), - 'nome' => post('nome'), - 'data' => post('data') ?: null, - ]); - $id_record = $dbo->lastInsertedID(); - - flash()->info(tr('Nuova documento aggiunto!')); - - break; - - case 'update': - $dbo->update('do_documenti', [ - 'idcategoria' => post('idcategoria'), - 'nome' => post('nome'), - 'data' => post('data') ?: null, - ], ['id' => $id_record]); - - flash()->info(tr('Informazioni salvate correttamente!')); - break; - - case 'delete': - $dbo->query('DELETE FROM do_documenti WHERE id = '.prepare($id_record)); - - Uploads::deleteLinked([ - 'id_module' => $id_module, - 'id_record' => $id_record, - ]); - - flash()->info(tr('Scheda e relativi files eliminati!')); - - break; -} diff --git a/modules/gestione_documentale/add.php b/modules/gestione_documentale/add.php deleted file mode 100755 index 30804fd59..000000000 --- a/modules/gestione_documentale/add.php +++ /dev/null @@ -1,47 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - -
    -
    - {[ "type": "text", "label": "Nome", "name": "nome", "required": 1, "value": "", "extra": "" ]} -
    -
    -
    -
    - {[ "type": "select", "label": "Categoria", "name": "idcategoria", "required": 1, "ajax-source": "categorie_documenti" , "value": "", "extra": "", "icon-after": "add|" ]} -
    - -
    - {[ "type": "text", "label": "Data", "name": "data", "class": "datepicker text-center", "value": "", "extra": "" ]} -
    -
    - - -
    -
    - -
    -
    -
    diff --git a/modules/gestione_documentale/edit.php b/modules/gestione_documentale/edit.php deleted file mode 100755 index dc6162850..000000000 --- a/modules/gestione_documentale/edit.php +++ /dev/null @@ -1,61 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - - -
    -
    -

    Scheda file

    -
    - -
    - -
    - -
    - {[ "type": "text", "label": "Nome", "name": "nome", "required": 1, "value": "$nome$", "extra": "" ]} -
    - - - -
    - {[ "type": "select", "label": "Categoria", "name": "idcategoria", "required": 1, "ajax-source": "categorie_documenti", "value": "$idcategoria$", "extra": "" ]} -
    - - -
    - {[ "type": "date", "label": "Data", "name": "data", "class": "datepicker text-center", "value": "$data$", "extra": "" ]} -
    - -
    -
    -
    - -
    - -{( "name": "filelist_and_upload", "id_module": "$id_module$", "id_record": "$id_record$" )} - - - - diff --git a/modules/gestione_documentale/init.php b/modules/gestione_documentale/init.php deleted file mode 100755 index 5ab2797b1..000000000 --- a/modules/gestione_documentale/init.php +++ /dev/null @@ -1,24 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT *, do_documenti.`id`as id, do_documenti.nome AS nome, do_documenti.`data` AS `data` FROM do_documenti WHERE do_documenti.id = '.prepare($id_record)); -} diff --git a/modules/giacenze_sedi/controller_before.php b/modules/giacenze_sedi/controller_before.php deleted file mode 100644 index a4fdeb7a9..000000000 --- a/modules/giacenze_sedi/controller_before.php +++ /dev/null @@ -1,41 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (empty($_SESSION['giacenze_sedi']['idsede'])) { - $_SESSION['giacenze_sedi']['idsede'] = 0; -} -$id_sede = $_SESSION['giacenze_sedi']['idsede']; - -echo ' -
    -
    - {["type":"select", "label":"'.tr('Sede').'", "name": "id_sede", "ajax-source": "sedi_azienda", "value":"'.$id_sede.'" ]} -
    -
    - -'; diff --git a/modules/giacenze_sedi/init.php b/modules/giacenze_sedi/init.php deleted file mode 100644 index 8594016ad..000000000 --- a/modules/giacenze_sedi/init.php +++ /dev/null @@ -1,25 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $id_module = Modules::get('Articoli')['id']; - redirect(base_path().'/editor.php?id_module='.$id_module.'&id_record='.$id_record); -} diff --git a/modules/impianti/actions.php b/modules/impianti/actions.php deleted file mode 100644 index 7e7c3582a..000000000 --- a/modules/impianti/actions.php +++ /dev/null @@ -1,171 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$op = post('op'); - -$upload_dir = base_dir().'/files/'.Modules::get('Impianti')['directory']; - -switch ($op) { - // Aggiorno informazioni di base impianto - case 'update': - $matricola = post('matricola'); - - if (!empty($matricola)) { - $dbo->update('my_impianti', [ - 'idanagrafica' => post('idanagrafica'), - 'nome' => post('nome'), - 'matricola' => $matricola, - 'id_categoria' => post('id_categoria') ?: null, - 'descrizione' => post('descrizione'), - 'idsede' => post('idsede'), - 'data' => post('data'), - 'proprietario' => post('proprietario'), - 'palazzo' => post('palazzo'), - 'ubicazione' => post('ubicazione'), - 'idtecnico' => post('idtecnico'), - 'scala' => post('scala'), - 'piano' => post('piano'), - 'interno' => post('interno'), - 'occupante' => post('occupante'), - ], ['id' => $id_record]); - - flash()->info(tr('Informazioni salvate correttamente!')); - - // Upload file - if (!empty($_FILES) && !empty($_FILES['immagine']['name'])) { - $upload = Uploads::upload($_FILES['immagine'], [ - 'name' => 'Immagine', - 'id_module' => $id_module, - 'id_record' => $id_record, - ], [ - 'thumbnails' => true, - ]); - $filename = $upload->filename; - - if (!empty($filename)) { - $dbo->update('my_impianti', [ - 'immagine' => $filename, - ], [ - 'id' => $id_record, - ]); - } else { - flash()->warning(tr('Errore durante il caricamento del file in _DIR_!', [ - '_DIR_' => $upload_dir, - ])); - } - } - - // Eliminazione file - if (post('delete_immagine') !== null) { - Uploads::delete($record['immagine'], [ - 'id_module' => $id_module, - 'id_record' => $id_record, - ]); - - $dbo->update('my_impianti', [ - 'immagine' => null, - ], [ - 'id' => $id_record, - ]); - } - } - break; - - // Aggiungo impianto - case 'add': - $matricola = post('matricola'); - $idanagrafica = post('idanagrafica'); - $nome = post('nome'); - $idtecnico = post('idtecnico'); - $idsede = post('idsede'); - - if (!empty($matricola)) { - $dbo->query('INSERT INTO my_impianti(matricola, idanagrafica, nome, data, idtecnico, idsede) VALUES ('.prepare($matricola).', '.prepare($idanagrafica).', '.prepare($nome).', NOW(), '.prepare($idtecnico).', '.prepare($idsede).')'); - - $id_record = $dbo->lastInsertedID(); - - if (isAjaxRequest()) { - echo json_encode(['id' => $id_record, 'text' => $matricola.' - '.$nome]); - } - - flash()->info(tr('Aggiunto nuovo impianto!')); - } - - break; - - // Carica i campi da compilare del componente - case 'load_componente': - $filename = post('filename'); - $idarticolo = post('idarticolo'); - - // Se è stato specificato un idarticolo, carico il file .ini dal campo `contenuto` di quell'idarticolo - $rs = $dbo->fetchArray('SELECT contenuto, componente_filename FROM mg_articoli WHERE id='.prepare($idarticolo)); - - // Se i campi da caricare sono del componente già salvato leggo dal campo `contenuto`... - if ($rs[0]['componente_filename'] == $filename) { - $contenuto = $rs[0]['contenuto']; - } - - // ...altrimenti carico dal file .ini - elseif (file_exists(base_dir().'/files/impianti/'.$filename)) { - $contenuto = file_get_contents(base_dir().'/files/impianti/'.$filename); - } - - crea_form_componente($contenuto); - - break; - - // Duplica impianto - case 'copy': - $dbo->query('CREATE TEMPORARY TABLE tmp SELECT * FROM my_impianti WHERE id= '.prepare($id_record)); - $dbo->query('ALTER TABLE tmp DROP id'); - $dbo->query('INSERT INTO my_impianti SELECT NULL,tmp. * FROM tmp'); - $id_record = $dbo->lastInsertedID(); - $dbo->query('DROP TEMPORARY TABLE tmp'); - - $dbo->query('UPDATE my_impianti SET matricola = CONCAT (matricola, " (copia)") WHERE id = '.prepare($id_record)); - - flash()->info(tr('Impianto duplicato correttamente!')); - - break; - - // Rimuovo impianto e scollego tutti i suoi componenti - case 'delete': - $dbo->query('DELETE FROM my_impianti WHERE id='.prepare($id_record)); - - flash()->info(tr('Impianto e relativi componenti eliminati!')); - break; -} - -// Operazioni aggiuntive per l'immagine -if (filter('op') == 'rimuovi-allegato' && filter('filename') == $record['immagine']) { - $dbo->update('my_impianti', [ - 'immagine' => null, - ], [ - 'id' => $id_record, - ]); -} elseif (filter('op') == 'aggiungi-allegato' && filter('nome_allegato') == 'Immagine') { - $dbo->update('my_impianti', [ - 'immagine' => $upload->filename, - ], [ - 'id' => $id_record, - ]); -} diff --git a/modules/impianti/add.php b/modules/impianti/add.php deleted file mode 100644 index d01c873ee..000000000 --- a/modules/impianti/add.php +++ /dev/null @@ -1,70 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$id_anagrafica = filter('id_anagrafica'); - -?>
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "matricola", "required": 1, "class": "text-center alphanumeric-mask", "maxlength": 25 ]} -
    - -
    - {[ "type": "text", "label": "", "name": "nome", "required": 1 ]} -
    - -
    - {[ "type": "select", "label": "", "name": "idanagrafica", "id": "idanagrafica_impianto", "required": 1, "value": "", "ajax-source": "clienti", "icon-after": "add||tipoanagrafica=Cliente&readonly_tipo=1" ]} -
    - -
    - {[ "type": "select", "label": "", "name": "idsede", "value": "$idsede$", "ajax-source": "sedi", "select-options": $id_anagrafica]); ?>, "placeholder": "Sede legale" ]} -
    - -
    - {[ "type": "select", "label": "", "name": "idtecnico", "ajax-source": "tecnici" ]} -
    -
    - - -
    -
    - -
    -
    -
    - - diff --git a/modules/impianti/ajax/search.php b/modules/impianti/ajax/search.php deleted file mode 100644 index 5daba4b23..000000000 --- a/modules/impianti/ajax/search.php +++ /dev/null @@ -1,72 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -$link_id = Modules::get('Impianti')['id']; - -$fields = [ - 'Matricola' => 'matricola', - 'Nome' => 'nome', - 'Descrizione' => 'descrizione', - 'Ubicazione' => 'ubicazione', - 'Occupante' => 'occupante', - 'Proprietario' => 'proprietario', -]; - -$query = 'SELECT *'; - -foreach ($fields as $name => $value) { - $query .= ', '.$value." AS '".str_replace("'", "\'", $name)."'"; -} - -$query .= ' FROM my_impianti WHERE idanagrafica IN('.implode(',', $idanagrafiche).') '; - -foreach ($fields as $name => $value) { - $query .= ' OR '.$value.' LIKE "%'.$term.'%"'; -} - -$query .= Modules::getAdditionalsQuery('Impianti'); - -$rs = $dbo->fetchArray($query); - -foreach ($rs as $r) { - $result = []; - - $result['link'] = base_path().'/editor.php?id_module='.$link_id.'&id_record='.$r['id']; - $result['title'] = $r['matricola'].' - '.$r['nome']; - $result['category'] = 'Impianti'; - - // Campi da evidenziare - $result['labels'] = []; - foreach ($fields as $name => $value) { - if (string_contains($r[$name], $term)) { - $text = str_replace($term, "".$term.'', $r[$name]); - - $result['labels'][] = $name.': '.$text.'
    '; - } - } - - // Aggiunta nome anagrafica come ultimo campo - if (sizeof($ragioni_sociali) > 1) { - $result['labels'][] = 'Anagrafica: '.$ragioni_sociali[$r['idanagrafica']].'
    '; - } - - $results[] = $result; -} diff --git a/modules/impianti/ajax/select.php b/modules/impianti/ajax/select.php deleted file mode 100755 index d3092fdf2..000000000 --- a/modules/impianti/ajax/select.php +++ /dev/null @@ -1,80 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -switch ($resource) { - case 'impianti': - $query = 'SELECT id, CONCAT(matricola, " - ", nome) AS descrizione FROM my_impianti |where| ORDER BY id, idanagrafica'; - - foreach ($elements as $element) { - $filter[] = 'id='.prepare($element); - } - - if (!empty($search)) { - $search_fields[] = 'nome LIKE '.prepare('%'.$search.'%'); - $search_fields[] = 'matricola LIKE '.prepare('%'.$search.'%'); - } - break; - - /* - * Opzioni utilizzate: - * - idanagrafica - */ - case 'impianti-cliente': - if (isset($superselect['idanagrafica'])) { - $query = 'SELECT id, CONCAT(matricola, " - ", nome) AS descrizione FROM my_impianti |where| ORDER BY idsede'; - - foreach ($elements as $element) { - $filter[] = 'id='.prepare($element); - } - - $where[] = 'idanagrafica='.prepare($superselect['idanagrafica']); - if (!empty($superselect['idsede_destinazione'])) { - $where[] = 'idsede='.prepare($superselect['idsede_destinazione']); - } - - if (!empty($search)) { - $search_fields[] = 'nome LIKE '.prepare('%'.$search.'%'); - $search_fields[] = 'matricola LIKE '.prepare('%'.$search.'%'); - } - } - break; - - /* - * Opzioni utilizzate: - * - idintervento - */ - case 'impianti-intervento': - if (isset($superselect['idintervento'])) { - $query = 'SELECT id, CONCAT(matricola, " - ", nome) AS descrizione FROM my_impianti INNER JOIN my_impianti_interventi ON my_impianti.id=my_impianti_interventi.idimpianto |where| ORDER BY idsede'; - - foreach ($elements as $element) { - $filter[] = 'id='.prepare($element); - } - - $where[] = 'my_impianti_interventi.idintervento='.prepare($superselect['idintervento']); - - if (!empty($search)) { - $search_fields[] = 'nome LIKE '.prepare('%'.$search.'%'); - $search_fields[] = 'matricola LIKE '.prepare('%'.$search.'%'); - } - } - break; -} diff --git a/modules/impianti/bulk.php b/modules/impianti/bulk.php deleted file mode 100644 index 19727cca5..000000000 --- a/modules/impianti/bulk.php +++ /dev/null @@ -1,53 +0,0 @@ -. - */ - -use Modules\Impianti\Export\CSV; -use Modules\Impianti\Impianto; - -include_once __DIR__.'/../../core.php'; - -switch (post('op')) { - case 'export-csv': - $file = temp_file(); - $exporter = new CSV($file); - - // Esportazione dei record selezionati - $fatture = Impianto::whereIn('id', $id_records)->get(); - $exporter->setRecords($fatture); - - $count = $exporter->exportRecords(); - - download($file, 'impianti.csv'); - - break; -} - -if (App::debug()) { - $operations['export-csv'] = [ - 'text' => ' '.tr('Esporta selezionati').' beta', - 'data' => [ - 'msg' => tr('Vuoi davvero esportare un CSV con tutti gli impianti?'), - 'button' => tr('Procedi'), - 'class' => 'btn btn-lg btn-danger', - 'blank' => true, - ], - ]; -} - -return $operations; diff --git a/modules/impianti/buttons.php b/modules/impianti/buttons.php deleted file mode 100755 index 4f613b3cd..000000000 --- a/modules/impianti/buttons.php +++ /dev/null @@ -1,30 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo ' -'; - -// Duplica impianto -echo ' -
    - - -
    '; diff --git a/modules/impianti/edit.php b/modules/impianti/edit.php deleted file mode 100644 index 049b49b9c..000000000 --- a/modules/impianti/edit.php +++ /dev/null @@ -1,153 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$img = null; -if (!empty($record['immagine'])) { - $fileinfo = Uploads::fileInfo($record['immagine']); - - $default_img = '/'.Uploads::getDirectory($id_module).'/'.$fileinfo['filename'].'_thumb600.'.$fileinfo['extension']; - - $img = file_exists(base_dir().$default_img) ? base_path().$default_img : base_path().'/'.Uploads::getDirectory($id_module).'/'.$record['immagine']; -} - -?>
    - - - - - -
    -
    -

    -
    - -
    -
    -
    - {[ "type": "image", "label": "", "name": "immagine", "class": "img-thumbnail", "value": "" ]} -
    - -
    -
    -
    - {[ "type": "text", "label": "", "name": "matricola", "required": 1, "class": "text-center", "maxlength": 25, "value": "$matricola$" ]} -
    - -
    - {[ "type": "text", "label": "", "name": "nome", "required": 1, "value": "$nome$" ]} -
    -
    - -
    - - {[ "type": "select", "label": "", "name": "idanagrafica", "required": 1, "value": "$idanagrafica$", "extra": "", "ajax-source": "clienti" ]} -
    -
    - {[ "type": "select", "label": "", "name": "id_categoria", "required": 0, "value": "$id_categoria$", "values": "query=SELECT id, nome AS descrizione FROM my_impianti_categorie" ]} -
    -
    -
    -
    - -
    -
    - {[ "type": "select", "label": "", "name": "idtecnico", "ajax-source": "tecnici", "value": "$idtecnico$" ]} -
    - -
    - {[ "type": "date", "label": "", "name": "data", "value": "$data$" ]} -
    - - - {[ "type": "select", "label": "'.tr('Sede').'", "name": "idsede", "value": "$idsede$", "required": "1", "ajax-source": "sedi", "select-options": '.json_encode(['idanagrafica' => $record['idanagrafica']]).', "placeholder": "'.tr('Sede legale').'" ]} -
    '; - ?> -
    - -
    -
    - {[ "type": "textarea", "label": "", "name": "descrizione", "value": "$descrizione$" ]} -
    -
    - -
    -
    - {[ "type": "text", "label": "", "name": "proprietario", "value": "$proprietario$" ]} -
    - -
    - -
    -
    - {[ "type": "text", "label": "", "name": "ubicazione", "value": "$ubicazione$" ]} -
    - -
    - {[ "type": "text", "label": "", "name": "palazzo", "value": "$palazzo$" ]} -
    - -
    - {[ "type": "text", "label": "", "name": "scala", "value": "$scala$" ]} -
    -
    - -
    -
    - {[ "type": "text", "label": "", "name": "piano", "value": "$piano$" ]} -
    - -
    - {[ "type": "text", "label": "", "name": "interno", "value": "$interno$" ]} -
    - -
    - {[ "type": "text", "label": "", "name": "occupante", "value": "$occupante$" ]} -
    -
    - -
    - -
    - -{( "name": "filelist_and_upload", "id_module": "$id_module$", "id_record": "$id_record$" )} - - - - - - - diff --git a/modules/impianti/init.php b/modules/impianti/init.php deleted file mode 100755 index 42d94cdf1..000000000 --- a/modules/impianti/init.php +++ /dev/null @@ -1,24 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT *, (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=my_impianti.idanagrafica) AS cliente FROM my_impianti WHERE id='.prepare($id_record)); -} diff --git a/modules/impianti/modutil.php b/modules/impianti/modutil.php deleted file mode 100755 index c0fcb3b7b..000000000 --- a/modules/impianti/modutil.php +++ /dev/null @@ -1,38 +0,0 @@ -. - */ - -use Util\Ini; - -include_once __DIR__.'/../../core.php'; - -function crea_form_componente($contenuto) -{ - $fields = Ini::getFields($contenuto); - $title = array_shift($fields); - - foreach ($fields as $key => $value) { - $fields[$key] = '
    '.$value.'
    '; - } - - echo $title.' -
    - '.implode(PHP_EOL, $fields).' - -
    '; -} diff --git a/modules/impianti/plugins/my_impianti.componenti.php b/modules/impianti/plugins/my_impianti.componenti.php deleted file mode 100755 index 2516c7fb8..000000000 --- a/modules/impianti/plugins/my_impianti.componenti.php +++ /dev/null @@ -1,340 +0,0 @@ -. - */ - -use Modules\Interventi\Intervento; -use Util\Ini; - -include_once __DIR__.'/../../../core.php'; - -switch (filter('op')) { - case 'modifica_componente': - $idcomponente = get('id'); - $data = post('data_componente'); - - // Ricavo il valore di contenuto leggendolo dal db - $query = 'SELECT * FROM my_impianto_componenti WHERE idimpianto='.prepare($id_record).' AND id='.prepare($idcomponente); - $rs = $dbo->fetchArray($query); - $contenuto = $rs[0]['contenuto']; - - $contenuto = Ini::write($contenuto, $post); - - $query = 'UPDATE my_impianto_componenti SET data='.prepare($data).', contenuto='.prepare($contenuto).' WHERE idimpianto='.prepare($id_record).' AND id='.prepare($idcomponente); - $dbo->query($query); - - flash()->info(tr('Informazioni componente aggiornate correttamente!')); - - $_SESSION['idcomponente'] = $idcomponente; - break; - - case 'aggiunta_componente': - $filename = get('filename'); - - if (!empty($filename)) { - $contenuto = file_get_contents(base_dir().'/files/impianti/'.$filename); - $nome = Ini::getValue(Ini::readFile(base_dir().'/files/impianti/'.$filename), 'Nome'); - - $query = 'INSERT INTO my_impianto_componenti(filename, idimpianto, contenuto, nome, data) VALUES('.prepare($filename).', '.prepare($id_record).', '.prepare($contenuto).', '.prepare($nome).', NOW())'; - $dbo->query($query); - - $idcomponente = $dbo->lastInsertedID(); - $_SESSION['idcomponente'] = $idcomponente; - - flash()->info(tr("Aggiunto un nuovo componente all'impianto!")); - } - break; - - case 'sostituzione_componente': - $filename = get('filename'); - $id = get('id'); - - $nome = Ini::getValue(Ini::readFile(base_dir().'/files/impianti/'.$filename), 'Nome'); - $contenuto = file_get_contents(base_dir().'/files/impianti/'.$filename); - - // Verifico che questo componente non sia già stato sostituito - $query = 'SELECT * FROM my_impianto_componenti WHERE idsostituto = '.prepare($id); - $rs = $dbo->fetchArray($query); - - if (empty($rs)) { - // Inserisco il nuovo componente in sostituzione - $query = 'INSERT INTO my_impianto_componenti(idsostituto, filename, idimpianto, contenuto, nome, data) VALUES('.prepare($id).', '.prepare($filename).', '.prepare($id_record).', '.prepare($contenuto).', '.prepare($nome).', NOW())'; - $dbo->query($query); - - $idcomponente = $dbo->lastInsertedID(); - $_SESSION['idcomponente'] = $idcomponente; - - // Aggiorno la data di sostituzione del componente precedente - $query = 'UPDATE my_impianto_componenti SET data_sostituzione = NOW() WHERE idimpianto = '.prepare($id_record).' AND id = '.prepare($id); - $dbo->query($query); - - flash()->info(tr('Aggiunto un nuovo componente in sostituzione al precedente!')); - } else { - flash()->error(tr('Questo componente è già stato sostituito!').' '.('Nessuna modifica applicata')); - } - break; - - case 'unaggiunta_componente': - $idcomponente = filter('id'); - - $query = 'DELETE FROM my_impianto_componenti WHERE id='.prepare($idcomponente).' AND idimpianto='.prepare($id_record); - $dbo->query($query); - - flash()->info(tr("Rimosso componente dall'impianto!")); - break; -} - -// Componenti non ancora collegati -if (empty($id_list)) { - $id_list = '0'; -} - -echo ' -
    -
    -

    '.tr('Componenti installati').'

    -
    -
    '; - -// Elenca i componenti disponibili -$componenti_disponibili = Ini::getList(base_dir().'/files/impianti/', $id_list); -echo ' -
    -
    - -
    - -
    - -
    -
    - -
    -
    '; - -// Mostro tutti i componenti utilizzati elencando quelli attualmente installati per primi. -$q2 = 'SELECT * FROM my_impianto_componenti WHERE idimpianto = '.prepare($id_record).' ORDER by nome ASC, idsostituto DESC'; -$componenti_installati = $dbo->fetchArray($q2); - -if (!empty($componenti_installati)) { - $prev_componente = ''; - - echo ' -
    '; - - // Ciclo tra tutti i componenti - foreach ($componenti_installati as $componente) { - $contenuto = $componente['contenuto']; - - $nome_componente = $componente['nome']; - $filename = $componente['filename']; - - if (empty($componente['data_sostituzione'])) { - $stato_componente = tr('INSTALLATO in data _DATE_', [ - '_DATE_' => dateFormat($componente['data']), - ]); - } else { - $stato_componente = tr('SOSTITUITO in data _DATE_', [ - '_DATE_' => dateFormat($componente['data_sostituzione']), - ]); - } - - // Per più "versioni" dello stesso componente mostro un riga meno evidente - // per non confonderlo come componente in uso in questo momento - $same = ($prev_componente == $nome_componente); - - if (get('id') == $componente['id']) { - $collapsed = ''; - $icon = 'minus'; - } elseif ($_SESSION['idcomponente'] == $componente['id']) { - unset($_SESSION['idcomponente']); - $collapsed = ''; - $icon = 'minus'; - } else { - $collapsed = 'collapsed-box'; - $icon = 'plus'; - } - - echo ' -
    -
    -

    '. - ($same ? '' : '').$nome_componente.' ('.$stato_componente.')'.($same ? '' : '').' -

    - -
    - -
    -
    '; - - echo ' -
    -
    -
    - '; - - // Nome - echo ' -
    - {[ "type": "span", "label": "'.tr('Nome').':", "name": "nome", "value": "'.$componente['nome'].'" ]} -
    '; - - // Data - echo ' -
    - {[ "type": "date", "label": "'.tr('Data').':", "name": "data_componente", "id": "data_componente'.$j.'", "value": "'.$componente['data'].'" ]} -
    '; - - // Campi previsti dal componente - $fields = Ini::getFields($contenuto); - array_shift($fields); - foreach ($fields as $field) { - echo ' -
    - '.$field.' -
    '; - } - - // Interventi collegati al componente - $interventi_collegati = Intervento::join('my_componenti_interventi', 'my_componenti_interventi.id_intervento', '=', 'in_interventi.id') - ->where('id_componente', $componente['id']) - ->get(); - if (!$interventi_collegati->isEmpty()) { - echo ' -
    - '.tr('Interventi collegati').': - - - - - - - - '; - - foreach ($interventi_collegati as $intervento) { - echo ' - - - - - - - '; - } - - echo ' -
    '.tr('Codice').''.tr('Tipo').''.tr('Stato').''.tr('Data richiesta').''.tr('Dettagli').'
    '.$intervento->codice.''.$intervento->tipo->descrizione.''.$intervento->stato->descrizione.''.dateFormat($intervento->data_richiesta).''.Modules::link('Interventi', $intervento->id, null, '-').'
    -
    '; - } else { - echo ' -
    -
    -
    - '.tr('Nessuna attività collegato a questo componente!').' -
    -
    '; - } - - // Intervento di installazione del componente - if (!empty($componente['idintervento'])) { - $intervento_origine = Intervento::find($componente['idintervento']); - - echo ' - '.Modules::link('Interventi', $componente['idintervento'], $intervento_origine->getReference()).'
    '; - } - - echo ' -
    -
    '; - - // Pulsante Salva/Elimina - echo ' -
    - '.tr('Elimina').''; - - // Sostituisci componente con un altro dello stesso tipo, posso sostituire solo i componenti installati - if (empty($componente['data_sostituzione'])) { - echo ' - '; - } else { - echo ' - '; - } - - echo ' - '; - - echo ' -
    -
    -
    -
    -
    '; - $prev_componente = $nome_componente; - } - echo ' -
    '; -} else { - echo ' -
    '.tr('Nessun componente inserito').'.
    '; -} - -echo ' -
    -
    - -'; diff --git a/modules/impianti/plugins/my_impianti.interventi.php b/modules/impianti/plugins/my_impianti.interventi.php deleted file mode 100644 index 93aedaae5..000000000 --- a/modules/impianti/plugins/my_impianti.interventi.php +++ /dev/null @@ -1,177 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -$matricole = (array) post('matricole'); - -// Salvo gli impianti selezionati -if (filter('op') == 'link_impianti') { - $matricole_old = $dbo->fetchArray('SELECT * FROM my_impianti_interventi WHERE idintervento='.prepare($id_record)); - $matricole_old = array_column($matricole_old, 'idimpianto'); - - // Individuazione delle matricole mancanti - foreach ($matricole_old as $matricola) { - if (!in_array($matricola, $matricole)) { - $dbo->query('DELETE FROM my_impianti_interventi WHERE idintervento='.prepare($id_record).' AND idimpianto = '.prepare($matricola)); - - $components = $dbo->fetchArray('SELECT * FROM my_impianto_componenti WHERE idimpianto = '.prepare($matricola)); - if (!empty($components)) { - foreach ($components as $component) { - $dbo->query('DELETE FROM my_componenti_interventi WHERE id_componente = '.prepare($component['id']).' AND id_intervento = '.prepare($id_record)); - } - } - } - } - - foreach ($matricole as $matricola) { - if (!in_array($matricola, $matricole_old)) { - $dbo->query('INSERT INTO my_impianti_interventi(idimpianto, idintervento) VALUES('.prepare($matricola).', '.prepare($id_record).')'); - } - } - - flash()->info(tr('Informazioni impianti salvate!')); -} elseif (filter('op') == 'link_componenti') { - $components = (array) post('componenti'); - $id_impianto = post('id_impianto'); - - $dbo->query('DELETE FROM my_componenti_interventi WHERE id_componente IN (SELECT id FROM my_impianto_componenti WHERE idimpianto = '.prepare($id_impianto).') AND id_intervento = '.prepare($id_record)); - - foreach ($components as $component) { - $dbo->query('INSERT INTO my_componenti_interventi(id_componente, id_intervento) VALUES ('.prepare($component).', '.prepare($id_record).')'); - } - - flash()->info(tr('Informazioni componenti salvate!')); -} - -// Blocco della modifica impianti se l'intervento è completato -$dati_intervento = $dbo->fetchArray('SELECT in_statiintervento.is_completato FROM in_statiintervento INNER JOIN in_interventi ON in_statiintervento.idstatointervento = in_interventi.idstatointervento WHERE in_interventi.id='.prepare($id_record)); -$is_completato = $dati_intervento[0]['is_completato']; - -if ($is_completato) { - $readonly = 'readonly'; - $disabled = 'disabled'; -} else { - $readonly = ''; - $disabled = ''; -} - -// IMPIANTI -echo ' -
    -
    -

    '.tr("Impianti dell'intervento").'

    -
    -
    -

    '.tr("Impianti su cui è stato effettuato l'intervento").'

    '; - -$impianti_collegati = $dbo->fetchArray('SELECT * FROM my_impianti_interventi INNER JOIN my_impianti ON my_impianti_interventi.idimpianto = my_impianti.id WHERE idintervento = '.prepare($id_record)); - -echo ' -
    '; -foreach ($impianti_collegati as $impianto) { - echo ' -
    - '; - - // MATRICOLA - echo ' - - - - '; - - // NOME - echo ' - - - - '; - - // DATA - echo ' - - - - '; - - // DESCRIZIONE - echo ' - - - - '; - - echo ' - - - - -
    '.tr('Matricola').':'.$impianto['matricola'].'
    '.tr('Nome').': - '.Modules::link('Impianti', $impianto['id'], $impianto['nome']).' -
    '.tr('Data').':'.dateFormat($impianto['data']).'
    '.tr('Descrizione').':'.$impianto['descrizione'].'
    '.tr("Componenti soggetti all'intervento").' -
    - - '; - - $inseriti = $dbo->fetchArray('SELECT * FROM my_componenti_interventi WHERE id_intervento = '.prepare($id_record)); - $ids = array_column($inseriti, 'id_componente'); - - echo ' - - {[ "type": "select", "label": "'.tr('Componenti').'", "multiple": 1, "name": "componenti[]", "id": "componenti_'.$impianto['id'].'", "ajax-source": "componenti", "select-options": {"matricola": '.$impianto['id'].'}, "value": "'.implode(',', $ids).'", "readonly": "'.!empty($readonly).'", "disabled": "'.!empty($disabled).'" ]} - - -
    -
    -
    '; -} - -echo ' -
    '; - -/* - Aggiunta impianti all'intervento -*/ -// Elenco impianti collegati all'intervento -$impianti = $dbo->fetchArray('SELECT idimpianto FROM my_impianti_interventi WHERE idintervento='.prepare($id_record)); -$impianti = !empty($impianti) ? array_column($impianti, 'idimpianto') : []; - -// Elenco sedi -$sedi = $dbo->fetchArray('SELECT id, nomesede, citta FROM an_sedi WHERE idanagrafica='.prepare($record['idanagrafica'])." UNION SELECT 0, 'Sede legale', '' ORDER BY id"); - -echo ' -

    '.tr('Impianti disponibili').'

    -
    - -
    -
    - {[ "type": "select", "name": "matricole[]", "multiple": 1, "value": "'.implode(',', $impianti).'", "ajax-source": "impianti-cliente", "select-options": {"idanagrafica": '.$record['idanagrafica'].'}, "extra": "'.$readonly.'" ]} -
    -
    -

    - - - - -
    '; - -echo ' -
    -
    '; diff --git a/modules/impianti/src/API/v1/Impianti.php b/modules/impianti/src/API/v1/Impianti.php deleted file mode 100755 index 23800ca10..000000000 --- a/modules/impianti/src/API/v1/Impianti.php +++ /dev/null @@ -1,35 +0,0 @@ -. - */ - -namespace Modules\Impianti\API\v1; - -use API\Interfaces\RetrieveInterface; -use API\Resource; - -class Impianti extends Resource implements RetrieveInterface -{ - public function retrieve($request) - { - $query = 'SELECT id, idanagrafica, matricola, nome, descrizione FROM my_impianti'; - - return [ - 'query' => $query, - ]; - } -} diff --git a/modules/impianti/src/Export/CSV.php b/modules/impianti/src/Export/CSV.php deleted file mode 100644 index 92b06c3dc..000000000 --- a/modules/impianti/src/Export/CSV.php +++ /dev/null @@ -1,55 +0,0 @@ -. - */ - -namespace Modules\Impianti\Export; - -use Exporter\CSVExporter; -use Modules\Impianti\Impianto; - -/** - * Struttura per la gestione delle operazioni di esportazione (in CSV) degli impianti. - * - * @since 2.4.18 - */ -class CSV extends CSVExporter -{ - public function getAvailableFields() - { - return [ - [ - 'field' => 'id', - 'label' => 'ID', - 'primary_key' => true, - ], - [ - 'field' => 'matricola', - 'label' => 'Matricola', - ], - [ - 'field' => 'nome', - 'label' => 'Nome', - ], - ]; - } - - public function getRecords() - { - return Impianto::all(); - } -} diff --git a/modules/impianti/src/Impianto.php b/modules/impianti/src/Impianto.php deleted file mode 100644 index ceaa625b3..000000000 --- a/modules/impianti/src/Impianto.php +++ /dev/null @@ -1,37 +0,0 @@ -. - */ - -namespace Modules\Impianti; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; -use Modules\Anagrafiche\Anagrafica; - -class Impianto extends Model -{ - use SimpleModelTrait; - - protected $table = 'my_impianti'; - - // Relazioni Eloquent - public function anagrafica() - { - return $this->belongsTo(Anagrafica::class, 'idanagrafica'); - } -} diff --git a/modules/import/actions.php b/modules/import/actions.php deleted file mode 100755 index 7a318e382..000000000 --- a/modules/import/actions.php +++ /dev/null @@ -1,106 +0,0 @@ -. - */ - -use Modules\Importazione\Import; - -include_once __DIR__.'/../../core.php'; - -switch (filter('op')) { - case 'add': - $id_import = filter('id_import'); - $import = Import::find($id_import); - - $id_record = $import->id; - - Uploads::upload($_FILES['file'], [ - 'id_module' => $import->getModule()->id, - 'id_record' => $id_record, - ]); - break; - - case 'example': - $id_import = filter('id_import'); - - $import = Import::find($id_import); - $import_manager = $import->class; - - $modulo_collegato = $import->moduloCollegato; - if (!empty($import_manager)) { - // Generazione percorso - $file = $modulo_collegato->upload_directory.'/example-'.strtolower($modulo_collegato->title).'.csv'; - $filepath = base_dir().'/'.$file; - - // Generazione del file - $import_manager::createExample($filepath); - - echo base_path().'/'.$file; - } - - break; - - case 'import': - // Individuazione del modulo - $import = Import::find($id_record); - $import_manager = $import->class; - - // Dati indicati - $include_first_row = post('include_first_row'); - $fields = (array) post('fields'); - $page = post('page'); - - $limit = 500; - - // Inizializzazione del lettore CSV - $csv = new $import_manager($record->filepath); - foreach ($fields as $key => $value) { - $csv->setColumnAssociation($key, $value - 1); - } - - // Generazione offset sulla base della pagina - $offset = isset($page) ? $page * $limit : 0; - - // Ignora la prima riga se composta da header - if ($offset == 0 && empty($include_first_row)) { - ++$offset; - } - - // Gestione automatica dei valori convertiti - $primary_key = post('primary_key'); - $csv->setPrimaryKey($primary_key - 1); - - // Operazioni di inizializzazione per l'importazione - if (!isset($page) || empty($page)) { - $csv->init(); - } - - $count = $csv->importRows($offset, $limit); - $more = $count == $limit; - - // Operazioni di finalizzazione per l'importazione - if (!$more) { - $csv->complete(); - } - - echo json_encode([ - 'more' => $more, - 'count' => $count, - ]); - - break; -} diff --git a/modules/import/add.php b/modules/import/add.php deleted file mode 100755 index 1a50892b3..000000000 --- a/modules/import/add.php +++ /dev/null @@ -1,77 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - -
    -
    - {[ "type": "file", "label": "", "name": "file", "required": 1, "accept": ".csv" ]} -
    - -
    - {[ "type": "select", "label": "", "name": "id_import", "required": 1, "values": "query=SELECT id, name AS text FROM zz_imports" ]} -
    -
    - - -
    -
    - - - -
    -
    -
    - - diff --git a/modules/import/edit.php b/modules/import/edit.php deleted file mode 100755 index 2732d5de5..000000000 --- a/modules/import/edit.php +++ /dev/null @@ -1,224 +0,0 @@ -. - */ - -use Modules\Importazione\Import; - -include_once __DIR__.'/../../core.php'; - -// Gestione del redirect in caso di caricamento del file -if (filter('op')) { - return; -} - -if (empty($id_record)) { - require base_dir().'/add.php'; -} else { - $import = Import::find($id_record); - $import_selezionato = $import->class; - - // Inizializzazione del lettore CSV - $csv = new $import_selezionato($record->filepath); - $fields = $csv->getAvailableFields(); - - // Generazione della base per i campi da selezionare - $campi_disponibili = []; - foreach ($fields as $key => $value) { - $campi_disponibili[] = [ - 'id' => $key + 1, - 'text' => $value['label'], - ]; - - if ($value['primary_key']) { - $primary_key = $key + 1; - } - } - - echo ' -
    - - - -
    -
    - {[ "type": "checkbox", "label": "'.tr('Importa prima riga').'", "name": "include_first_row", "extra":"", "value": "1" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Chiave primaria').'", "name": "primary_key", "values": '.json_encode($campi_disponibili).', "value": "'.$primary_key.'" ]} -
    -
    '; - - // Lettura delle prime righe disponibili - $righe = $csv->getRows(0, 10); - $prima_riga = $csv->getHeader(); - $numero_colonne = count($prima_riga); - - // Trasformazione dei nomi indicati per i campi in lowercase - $nomi_disponibili = []; - foreach ($fields as $key => $value) { - $nomi_disponibili[$key] = []; - $names = isset($value['names']) ? $value['names'] : [$value['label']]; - foreach ($names as $name) { - $nomi_disponibili[$key][] = trim(string_lowercase($name)); - } - } - - echo ' -
    '; - - for ($column = 0; $column < $numero_colonne; ++$column) { - echo ' -
    -
    -
    -

    '.tr('Colonna _NUM_', [ - '_NUM_' => $column + 1, - ]).'

    -
    - -
    '; - - // Individuazione delle corrispondenze - $selezionato = null; - foreach ($fields as $key => $value) { - // Confronto per l'individuazione della relativa colonna - $nome = trim(string_lowercase($prima_riga[$column])); - if (in_array($nome, $nomi_disponibili[$key])) { - $escludi_prima_riga = 1; - $selezionato = $key + 1; - break; - } - } - - echo ' - {[ "type": "select", "label": "'.tr('Campo').'", "name": "fields['.$column.']", "values": '.json_encode($campi_disponibili).', "value": "'.$selezionato.'" ]} - - - - - - - - - '; - - foreach ($righe as $key => $row) { - echo ' - - - - '; - } - - echo ' - - -
    '.tr('#').''.tr('Valore').'
    '.($key + 1).''.$row[$column].'
    - -
    -
    -
    '; - } - - echo ' -
    -
    '; - - echo ' -'; -} diff --git a/modules/import/init.php b/modules/import/init.php deleted file mode 100755 index 401caaf22..000000000 --- a/modules/import/init.php +++ /dev/null @@ -1,28 +0,0 @@ -. - */ - -use Modules\Importazione\Import; - -include_once __DIR__.'/../../core.php'; - -if (!empty($id_record)) { - $import = Import::find($id_record); - - $record = $import->uploads()->last(); -} diff --git a/modules/import/src/Import.php b/modules/import/src/Import.php deleted file mode 100644 index be4c19851..000000000 --- a/modules/import/src/Import.php +++ /dev/null @@ -1,44 +0,0 @@ -. - */ - -namespace Modules\Importazione; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; -use Models\Module; -use Traits\RecordTrait; - -class Import extends Model -{ - use SimpleModelTrait; - use RecordTrait; - - protected $table = 'zz_imports'; - - // Relazioni Eloquent - public function moduloCollegato() - { - return $this->belongsTo(Module::class, 'id_module'); - } - - public function getModuleAttribute() - { - return 'Import'; - } -} diff --git a/modules/impostazioni/actions.php b/modules/impostazioni/actions.php deleted file mode 100755 index f705634c8..000000000 --- a/modules/impostazioni/actions.php +++ /dev/null @@ -1,103 +0,0 @@ -. - */ - -use Models\Setting; - -include_once __DIR__.'/../../core.php'; - -switch (filter('op')) { - case 'salva': - $id = filter('id'); - $valore = filter('valore'); - - $impostazione = Setting::find($id); - if (!$impostazione->editable) { - echo json_encode([ - 'result' => true, - ]); - - return; - } - - $result = Settings::setValue($impostazione->id, $valore); - echo json_encode([ - 'result' => $result, - ]); - - if ($result) { - flash()->info('Impostazione modificata con successo!'); - } else { - flash()->error('Errore durante il salvataggio!'); - } - - break; - - case 'ricerca': - $search = filter('search'); - $sezioni = Setting::select('sezione') - ->where('sezione', 'like', '%'.$search.'%') - ->orWhere('nome', 'like', '%'.$search.'%') - ->groupBy(['sezione']) - ->get()->pluck('sezione'); - - echo json_encode($sezioni); - - break; - - case 'update': - $is_all_valid = true; - - foreach (post('setting') as $id => $value) { - $result = Settings::get($id); - - if (preg_match("/multiple\[(.+?)\]/", $result['tipo'], $m)) { - $value = implode(',', $value); - } - - //Se è un'impostazione editabile - if ($result->editable) { - $is_valid = Settings::setValue($id, $value); - - if (!$is_valid) { - // integer - if ($result['tipo'] == 'integer') { - flash()->error(tr('Il valore inserito del parametro _NAME_ deve essere un numero intero!', [ - '_NAME_' => '"'.$result['nome'].'"', - ])); - } - - // list - // verifico che il valore scelto sia nella lista enumerata nel db - elseif (preg_match("/list\[(.+?)\]/", $result['tipo'], $m)) { - flash()->error(tr('Il valore inserito del parametro _NAME_ deve essere un compreso tra i valori previsti!', [ - '_NAME_' => '"'.$result['nome'].'"', - ])); - } - } - } - - $is_all_valid &= $is_valid; - } - - if ($is_all_valid) { - flash()->info(tr('Impostazioni aggiornate correttamente!')); - } - - break; -} diff --git a/modules/impostazioni/edit.php b/modules/impostazioni/edit.php deleted file mode 100755 index 013a8fff4..000000000 --- a/modules/impostazioni/edit.php +++ /dev/null @@ -1,154 +0,0 @@ -. - */ - -use Models\Setting; - -include_once __DIR__.'/../../core.php'; - -$ricerca = get('search'); -$gruppi = Setting::selectRaw('sezione AS nome, COUNT(id) AS numero') - ->groupBy(['sezione']) - ->orderBy('sezione') - ->get(); - -echo ' -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    - -

    '; - -foreach ($gruppi as $key => $gruppo) { - echo ' - -
    -
    -
    '.tr('_SEZIONE_', [ - '_SEZIONE_' => $gruppo['nome'], - ]).'
    -
    -
    '.$gruppo['numero'].'
    -
    -
    - -
    -
    '; -} - -echo ' -'; - -if (!empty($ricerca)) { - echo ' -'; -} diff --git a/modules/impostazioni/init.php b/modules/impostazioni/init.php deleted file mode 100755 index 62ae38e24..000000000 --- a/modules/impostazioni/init.php +++ /dev/null @@ -1,20 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; diff --git a/modules/impostazioni/sezione.php b/modules/impostazioni/sezione.php deleted file mode 100644 index a0e5df107..000000000 --- a/modules/impostazioni/sezione.php +++ /dev/null @@ -1,53 +0,0 @@ -. - */ - -use Models\Setting; - -include_once __DIR__.'/../../core.php'; - -$sezione = filter('sezione'); -$impostazioni = Setting::where('sezione', $sezione) - ->get(); - -foreach ($impostazioni as $impostazione) { - echo ' -
    - '.Settings::input($impostazione['id']).' -
    - - '; -} diff --git a/modules/interventi/actions.php b/modules/interventi/actions.php deleted file mode 100644 index aca18cec5..000000000 --- a/modules/interventi/actions.php +++ /dev/null @@ -1,640 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Anagrafiche\Anagrafica; -use Modules\Articoli\Articolo as ArticoloOriginale; -use Modules\Emails\Mail; -use Modules\Emails\Template; -use Modules\Interventi\Components\Articolo; -use Modules\Interventi\Components\Riga; -use Modules\Interventi\Components\Sconto; -use Modules\Interventi\Components\Sessione; -use Modules\Interventi\Intervento; -use Modules\Interventi\Stato; -use Modules\TipiIntervento\Tipo as TipoSessione; -use Plugins\PianificazioneInterventi\Promemoria; - -switch (post('op')) { - case 'update': - $idcontratto = post('idcontratto'); - $id_promemoria = post('idcontratto_riga'); - - // Rimozione del collegamento al promemoria - if (!empty($id_promemoria) && $intervento->id_contratto != $idcontratto) { - $dbo->update('co_promemoria', ['idintervento' => null], ['idintervento' => $id_record]); - } - - // Salvataggio modifiche intervento - $intervento->codice = post('codice'); - $intervento->data_richiesta = post('data_richiesta'); - $intervento->data_scadenza = post('data_scadenza') ?: null; - $intervento->richiesta = post('richiesta'); - $intervento->descrizione = post('descrizione'); - $intervento->informazioniaggiuntive = post('informazioniaggiuntive'); - - $intervento->idanagrafica = post('idanagrafica'); - $intervento->idclientefinale = post('idclientefinale'); - $intervento->idreferente = post('idreferente'); - $intervento->idtipointervento = post('idtipointervento'); - - $intervento->idstatointervento = post('idstatointervento'); - $intervento->idsede_partenza = post('idsede_partenza'); - $intervento->idsede_destinazione = post('idsede_destinazione'); - $intervento->id_preventivo = post('idpreventivo'); - $intervento->id_contratto = $idcontratto; - $intervento->id_ordine = post('idordine'); - - $intervento->id_documento_fe = post('id_documento_fe'); - $intervento->num_item = post('num_item'); - $intervento->codice_cup = post('codice_cup'); - $intervento->codice_cig = post('codice_cig'); - $intervento->save(); - - // Assegnazione dei tecnici all'intervento - $tecnici_assegnati = (array) post('tecnici_assegnati'); - $dbo->sync('in_interventi_tecnici_assegnati', [ - 'id_intervento' => $id_record, - ], [ - 'id_tecnico' => $tecnici_assegnati, - ]); - - // Notifica chiusura intervento - $stato = $dbo->selectOne('in_statiintervento', '*', ['idstatointervento' => post('idstatointervento')]); - if (!empty($stato['notifica']) && $stato['idstatointervento'] != $record['idstatointervento']) { - $template = Template::find($stato['id_email']); - - if (!empty($stato['destinatari'])) { - $mail = Mail::build(auth()->getUser(), $template, $id_record); - $mail->addReceiver($stato['destinatari']); - $mail->save(); - } - - if (!empty($stato['notifica_cliente'])) { - $mail_cliente = $dbo->selectOne('an_anagrafiche', '*', ['idanagrafica' => post('idanagrafica')]); - if (!empty($mail_cliente['email'])) { - $mail = Mail::build(auth()->getUser(), $template, $id_record); - $mail->addReceiver($mail_cliente['email']); - $mail->save(); - } - } - - if (!empty($stato['notifica_tecnici'])) { - $tecnici_intervento = $dbo->select('in_interventi_tecnici', 'idtecnico', ['idintervento' => $id_record]); - $tecnici_assegnati = $dbo->select('in_interventi_tecnici_assegnati', 'id_tecnico AS idtecnico', ['id_intervento' => $id_record]); - $tecnici = array_unique(array_merge($tecnici_intervento, $tecnici_assegnati), SORT_REGULAR); - - foreach ($tecnici as $tecnico) { - $mail_tecnico = $dbo->selectOne('an_anagrafiche', '*', ['idanagrafica' => $tecnico]); - if (!empty($mail_tecnico['email'])) { - $mail = Mail::build(auth()->getUser(), $template, $id_record); - $mail->addReceiver($mail_tecnico['email']); - $mail->save(); - } - } - } - } - - flash()->info(tr('Attività modificata correttamente!')); - - break; - - case 'add': - if (post('id_intervento') == null) { - $idanagrafica = post('idanagrafica'); - $idtipointervento = post('idtipointervento'); - $idstatointervento = post('idstatointervento'); - $data_richiesta = post('data_richiesta'); - $data_scadenza = post('data_scadenza') ?: null; - - $anagrafica = Anagrafica::find($idanagrafica); - $tipo = TipoSessione::find($idtipointervento); - $stato = Stato::find($idstatointervento); - - $intervento = Intervento::build($anagrafica, $tipo, $stato, $data_richiesta); - $id_record = $intervento->id; - - flash()->info(tr('Aggiunto nuovo intervento!')); - - // Informazioni di base - $idpreventivo = post('idpreventivo'); - $idcontratto = post('idcontratto'); - $id_promemoria = post('idcontratto_riga'); - $idtipointervento = post('idtipointervento'); - $idsede_partenza = post('idsede_partenza'); - $idsede_destinazione = post('idsede_destinazione'); - - if (post('idclientefinale')) { - $intervento->idclientefinale = post('idclientefinale'); - } - - if (post('idsede_destinazione')) { - $intervento->idsede_destinazione = post('idsede_destinazione'); - } - - $intervento->id_preventivo = post('idpreventivo'); - $intervento->id_contratto = post('idcontratto'); - $intervento->id_ordine = post('idordine'); - $intervento->richiesta = post('richiesta'); - $intervento->idsede_destinazione = $idsede_destinazione; - $intervento->data_scadenza = $data_scadenza; - - $intervento->save(); - - // Sincronizzazione con il promemoria indicato - if (!empty($id_promemoria)) { - $promemoria = Promemoria::find($id_promemoria); - $promemoria->pianifica($intervento, false); - } - - // Collegamenti intervento/impianti - $impianti = (array) post('idimpianti'); - if (!empty($impianti)) { - $impianti = array_unique($impianti); - foreach ($impianti as $impianto) { - $dbo->insert('my_impianti_interventi', [ - 'idintervento' => $id_record, - 'idimpianto' => $impianto, - ]); - } - - // Collegamenti intervento/componenti - $componenti = (array) post('componenti'); - foreach ($componenti as $componente) { - $dbo->insert('my_componenti_interventi', [ - 'id_intervento' => $id_record, - 'id_componente' => $componente, - ]); - } - } - } else { - $id_record = post('id_intervento'); - - $intervento = Intervento::find($id_record); - $intervento->richiesta = post('richiesta'); - $intervento->save(); - - $idcontratto = $dbo->fetchOne('SELECT idcontratto FROM co_promemoria WHERE idintervento = :id', [ - ':id' => $id_record, - ])['idcontratto']; - } - - // Collegamenti tecnici/interventi - if (!empty(post('orario_inizio')) && !empty(post('orario_fine'))) { - $idtecnici = post('idtecnico'); - foreach ($idtecnici as $idtecnico) { - add_tecnico($id_record, $idtecnico, post('orario_inizio'), post('orario_fine'), $idcontratto); - } - } - - // Assegnazione dei tecnici all'intervento - $tecnici_assegnati = (array) post('tecnici_assegnati'); - $dbo->sync('in_interventi_tecnici_assegnati', [ - 'id_intervento' => $id_record, - ], [ - 'id_tecnico' => $tecnici_assegnati, - ]); - - if (post('ref') == 'dashboard') { - flash()->clearMessage('info'); - flash()->clearMessage('warning'); - } - - break; - - // Eliminazione intervento - case 'delete': - try { - // Eliminazione associazioni tra interventi e contratti - $dbo->query('UPDATE co_promemoria SET idintervento = NULL WHERE idintervento='.prepare($id_record)); - - $intervento->delete(); - - // Elimino il collegamento al componente - $dbo->query('DELETE FROM my_impianto_componenti WHERE idintervento='.prepare($id_record)); - - // Eliminazione associazione tecnici collegati all'intervento - $dbo->query('DELETE FROM in_interventi_tecnici WHERE idintervento='.prepare($id_record)); - - // Eliminazione associazione interventi e my_impianti - $dbo->query('DELETE FROM my_impianti_interventi WHERE idintervento='.prepare($id_record)); - - // Elimino anche eventuali file caricati - Uploads::deleteLinked([ - 'id_module' => $id_module, - 'id_record' => $id_record, - ]); - - flash()->info(tr('Intervento eliminato!')); - } catch (InvalidArgumentException $e) { - flash()->error(tr('Sono stati utilizzati alcuni serial number nel documento: impossibile procedere!')); - } - - break; - - case 'delete_riga': - $id_riga = post('riga_id'); - $type = post('riga_type'); - $riga = $intervento->getRiga($type, $id_riga); - - if (!empty($riga)) { - try { - $riga->delete(); - - flash()->info(tr('Riga rimossa!')); - } catch (InvalidArgumentException $e) { - flash()->error(tr('Alcuni serial number sono già stati utilizzati!')); - } - } - - break; - - case 'manage_barcode': - foreach (post('qta') as $id_articolo => $qta) { - if ($id_articolo == '-id-') { - continue; - } - - // Dati di input - $sconto = post('sconto')[$id_articolo]; - $tipo_sconto = post('tipo_sconto')[$id_articolo]; - $prezzo_unitario = post('prezzo_unitario')[$id_articolo]; - $id_dettaglio_fornitore = post('id_dettaglio_fornitore')[$id_articolo]; - $id_iva = $originale->idiva_vendita ? $originale->idiva_vendita : setting('Iva predefinita'); - - // Creazione articolo - $originale = ArticoloOriginale::find($id_articolo); - $articolo = Articolo::build($intervento, $originale); - $articolo->id_dettaglio_fornitore = $id_dettaglio_fornitore ?: null; - - $articolo->setPrezzoUnitario($prezzo_unitario, $id_iva); - if ($dir == 'entrata') { - $articolo->costo_unitario = $originale->prezzo_acquisto; - } - $articolo->setSconto($sconto, $tipo_sconto); - $articolo->qta = $qta; - - $articolo->save(); - } - - flash()->info(tr('Articoli aggiunti!')); - - break; - - case 'manage_articolo': - if (post('idriga') != null) { - $articolo = Articolo::find(post('idriga')); - } else { - $originale = ArticoloOriginale::find(post('idarticolo')); - $articolo = Articolo::build($intervento, $originale); - $articolo->id_dettaglio_fornitore = post('id_dettaglio_fornitore') ?: null; - } - - $qta = post('qta'); - - $articolo->idsede_partenza = post('idsede_partenza'); - $articolo->descrizione = post('descrizione'); - $articolo->um = post('um') ?: null; - - $articolo->costo_unitario = post('costo_unitario') ?: 0; - $articolo->setPrezzoUnitario(post('prezzo_unitario'), post('idiva')); - $articolo->setSconto(post('sconto'), post('tipo_sconto')); - - try { - $articolo->qta = $qta; - } catch (UnexpectedValueException $e) { - flash()->error(tr('Alcuni serial number sono già stati utilizzati!')); - } - - $articolo->save(); - - if (post('idriga') != null) { - flash()->info(tr('Articolo modificato!')); - } else { - flash()->info(tr('Articolo aggiunto!')); - } - - // Collegamento all'impianto - link_componente_to_articolo($id_record, post('idimpianto'), $articolo->idarticolo, $qta); - - break; - - case 'manage_sconto': - if (post('idriga') != null) { - $sconto = Sconto::find(post('idriga')); - } else { - $sconto = Sconto::build($intervento); - } - - $sconto->descrizione = post('descrizione'); - $sconto->setScontoUnitario(post('sconto_unitario'), post('idiva')); - - $sconto->save(); - - if (post('idriga') != null) { - flash()->info(tr('Sconto/maggiorazione modificato!')); - } else { - flash()->info(tr('Sconto/maggiorazione aggiunto!')); - } - - break; - - case 'manage_riga': - if (post('idriga') != null) { - $riga = Riga::find(post('idriga')); - } else { - $riga = Riga::build($intervento); - } - - $qta = post('qta'); - - $riga->descrizione = post('descrizione'); - $riga->um = post('um') ?: null; - - $riga->costo_unitario = post('costo_unitario') ?: 0; - $riga->setPrezzoUnitario(post('prezzo_unitario'), post('idiva')); - $riga->setSconto(post('sconto'), post('tipo_sconto')); - - $riga->qta = $qta; - - $riga->save(); - - if (post('idriga') != null) { - flash()->info(tr('Riga modificata!')); - } else { - flash()->info(tr('Riga aggiunta!')); - } - - break; - - case 'add_serial': - $articolo = Articolo::find(post('idriga')); - - $serials = (array) post('serial'); - $articolo->serials = $serials; - - break; - - // Aggiunta di un documento in ordine - case 'add_intervento': - case 'add_documento': - $class = post('class'); - $id_documento = post('id_documento'); - - // Individuazione del documento originale - if (!is_subclass_of($class, \Common\Document::class)) { - return; - } - $documento = $class::find($id_documento); - - // Individuazione sede - $id_sede = ($documento->direzione == 'entrata') ? $documento->idsede_destinazione : $documento->idsede_partenza; - $id_sede = $id_sede ?: $documento->idsede; - $id_sede = $id_sede ?: 0; - - // Creazione dell' ordine al volo - if (post('create_document') == 'on') { - $stato = Stato::find(post('id_stato_intervento')); - $tipo = TipoSessione::find(post('id_tipo_intervento')); - - $anagrafica = post('idanagrafica') ? Anagrafica::find(post('idanagrafica')) : $documento->anagrafica; - - $intervento = Intervento::build($anagrafica, $tipo, $stato, post('data')); - $intervento->idsede_destinazione = $id_sede; - - $intervento->id_documento_fe = $documento->id_documento_fe; - $intervento->codice_cup = $documento->codice_cup; - $intervento->codice_cig = $documento->codice_cig; - $intervento->num_item = $documento->num_item; - $intervento->idreferente = $documento->idreferente; - - $intervento->save(); - - $id_record = $intervento->id; - } - - $righe = $documento->getRighe(); - foreach ($righe as $riga) { - if (post('evadere')[$riga->id] == 'on' and !empty(post('qta_da_evadere')[$riga->id])) { - $qta = post('qta_da_evadere')[$riga->id]; - - $copia = $riga->copiaIn($intervento, $qta); - - // Aggiornamento seriali - if ($copia->isArticolo()) { - $serials = is_array(post('serial')[$riga->id]) ? post('serial')[$riga->id] : []; - - $copia->serials = $serials; - } - - $copia->save(); - } - } - - // Modifica finale dello stato - /* - if (post('create_document') == 'on') { - $intervento->idstatointervento = post('id_stato_intervento'); - $intervento->save(); - }*/ - - // Messaggio informativo - $message = tr('_DOC_ aggiunto!', [ - '_DOC_' => $documento->getReference(), - ]); - flash()->info($message); - - break; - - case 'firma': - if (directory(base_dir().'/files/interventi')) { - if (post('firma_base64') != '') { - // Salvataggio firma - $firma_file = 'firma_'.time().'.jpg'; - $firma_nome = post('firma_nome'); - - $data = explode(',', post('firma_base64')); - - $img = Intervention\Image\ImageManagerStatic::make(base64_decode($data[1])); - $img->resize(680, 202, function ($constraint) { - $constraint->aspectRatio(); - }); - - if (!$img->save(base_dir().'/files/interventi/'.$firma_file)) { - flash()->error(tr('Impossibile creare il file!')); - } elseif ($dbo->query('UPDATE in_interventi SET firma_file='.prepare($firma_file).', firma_data=NOW(), firma_nome = '.prepare($firma_nome).' WHERE id='.prepare($id_record))) { - flash()->info(tr('Firma salvata correttamente!')); - flash()->info(tr('Attività completata!')); - - $id_stato = setting("Stato dell'attività dopo la firma"); - $stato = $dbo->selectOne('in_statiintervento', '*', ['idstatointervento' => $id_stato]); - $intervento = Intervento::find($id_record); - $intervento->idstatointervento = $stato['idstatointervento']; - $intervento->save(); - // Notifica chiusura intervento - if (!empty($stato['notifica']) && !empty($stato['destinatari'])) { - $template = Template::find($stato['id_email']); - - $mail = Mail::build(auth()->getUser(), $template, $id_record); - $mail->addReceiver($stato['destinatari']); - $mail->save(); - } - } else { - flash()->error(tr('Errore durante il salvataggio della firma nel database!')); - } - } else { - flash()->error(tr('Errore durante il salvataggio della firma!').tr('La firma risulta vuota').'...'); - } - } else { - flash()->error(tr("Non è stato possibile creare la cartella _DIRECTORY_ per salvare l'immagine della firma!", [ - '_DIRECTORY_' => '/files/interventi', - ])); - } - - break; - - // OPERAZIONI PER AGGIUNTA NUOVA SESSIONE DI LAVORO - case 'add_sessione': - $id_tecnico = post('id_tecnico'); - - $idcontratto = $intervento['id_contratto']; - - $ore = 1; - - $inizio = post('orario_inizio') ?: date('Y-m-d H:\0\0'); - $fine = post('orario_fine') ?: date_modify(date_create(date('Y-m-d H:\0\0')), '+'.$ore.' hours')->format('Y-m-d H:\0\0'); - - add_tecnico($id_record, $id_tecnico, $inizio, $fine, $idcontratto); - break; - - // RIMOZIONE SESSIONE DI LAVORO - case 'delete_sessione': - $id_sessione = post('id_sessione'); - - $tecnico = $dbo->fetchOne('SELECT an_anagrafiche.email FROM an_anagrafiche INNER JOIN in_interventi_tecnici ON in_interventi_tecnici.idtecnico = an_anagrafiche.idanagrafica WHERE in_interventi_tecnici.id = '.prepare($id_sessione)); - - $dbo->query('DELETE FROM in_interventi_tecnici WHERE id='.prepare($id_sessione)); - - // Notifica rimozione dell' intervento al tecnico - if (setting('Notifica al tecnico la rimozione dall\'attività')) { - if (!empty($tecnico['email'])) { - $template = Template::pool('Notifica rimozione intervento'); - - if (!empty($template)) { - $mail = Mail::build(auth()->getUser(), $template, $id_record); - $mail->addReceiver($tecnico['email']); - $mail->save(); - } - } - } - - break; - - case 'edit_sessione': - $id_sessione = post('id_sessione'); - $sessione = Sessione::find($id_sessione); - - $sessione->orario_inizio = post('orario_inizio'); - $sessione->orario_fine = post('orario_fine'); - $sessione->km = post('km'); - - $id_tipo = post('idtipointerventot'); - $sessione->setTipo($id_tipo); - - // Prezzi - $sessione->prezzo_ore_unitario = post('prezzo_ore_unitario'); - $sessione->prezzo_km_unitario = post('prezzo_km_unitario'); - $sessione->prezzo_dirittochiamata = post('prezzo_dirittochiamata'); - - // Sconto orario - $sessione->sconto_unitario = post('sconto'); - $sessione->tipo_sconto = post('tipo_sconto'); - - // Sconto chilometrico - $sessione->scontokm_unitario = post('sconto_km'); - $sessione->tipo_scontokm = post('tipo_sconto_km'); - - $sessione->save(); - - break; - - // Duplica intervento - case 'copy': - $id_stato = post('id_stato'); - $data_richiesta = post('data_richiesta'); - $copia_sessioni = post('copia_sessioni'); - $copia_righe = post('copia_righe'); - - $new = $intervento->replicate(); - $new->idstatointervento = $id_stato; - - // Calcolo del nuovo codice sulla base della data di richiesta - $new->codice = Intervento::getNextCodice($data_richiesta); - $new->data_richiesta = $data_richiesta; - $new->data_scadenza = post('data_scadenza'); - - $new->save(); - - $id_record = $new->id; - - // Copio le righe - if (!empty($copia_righe)) { - $righe = $intervento->getRighe(); - foreach ($righe as $riga) { - $new_riga = $riga->replicate(); - $new_riga->setDocument($new); - - $new_riga->qta_evasa = 0; - $new_riga->save(); - } - } - - // Copia delle sessioni - $numero_sessione = 0; - if (!empty($copia_sessioni)) { - $sessioni = $intervento->sessioni; - foreach ($sessioni as $sessione) { - // Se è la prima sessione che copio importo la data con quella della richiesta - if ($numero_sessione == 0) { - $orario_inizio = date('Y-m-d', strtotime($data_richiesta)).' '.date('H:i:s', strtotime($sessione->orario_inizio)); - } else { - $diff = strtotime($sessione->orario_inizio) - strtotime($inizio_old); - $orario_inizio = date('Y-m-d H:i:s', (strtotime($sessione->orario_inizio) + $diff)); - } - - $diff_fine = strtotime($sessione->orario_fine) - strtotime($sessione->orario_inizio); - $orario_fine = date('Y-m-d H:i:s', (strtotime($orario_inizio) + $diff_fine)); - - $new_sessione = $sessione->replicate(); - $new_sessione->idintervento = $new->id; - - $new_sessione->orario_inizio = $orario_inizio; - $new_sessione->orario_fine = $orario_fine; - $new_sessione->save(); - - ++$numero_sessione; - $inizio_old = $sessione->orario_inizio; - } - } - - flash()->info(tr('Attività duplicata correttamente!')); - - break; -} diff --git a/modules/interventi/add.php b/modules/interventi/add.php deleted file mode 100755 index c5ee52d7b..000000000 --- a/modules/interventi/add.php +++ /dev/null @@ -1,600 +0,0 @@ -. - */ - -use Modules\Interventi\Intervento; - -include_once __DIR__.'/../../core.php'; - -// Lettura dei parametri di interesse -$id_anagrafica = filter('idanagrafica'); -$id_sede = filter('idsede'); -$richiesta = filter('richiesta'); -$id_tipo = filter('id_tipo'); - -$origine_dashboard = get('ref') !== null; -$module_anagrafiche = Modules::get('Anagrafiche'); - -// Calcolo dell'orario di inizio e di fine sulla base delle informazioni fornite -$orario_inizio = filter('orario_inizio'); -$orario_fine = filter('orario_fine'); -if (null == $orario_inizio || '00:00:00' == $orario_inizio) { - $orario_inizio = date('H').':00:00'; - $orario_fine = date('H', time() + 60 * 60).':00:00'; -} - -// Un utente del gruppo Tecnici può aprire attività solo a proprio nome -$id_tecnico = filter('id_tecnico'); -if ($user['gruppo'] == 'Tecnici' && !empty($user['idanagrafica'])) { - $id_tecnico = $user['idanagrafica']; -} elseif ($user['gruppo'] == 'Clienti' && !empty($user['idanagrafica'])) { - $id_cliente = $user['idanagrafica']; -} - -// Stato di default associato all'attivitò -$stato = $dbo->fetchArray("SELECT * FROM in_statiintervento WHERE descrizione = 'In programmazione'"); -$id_stato = $stato['idstatointervento']; - -// Se è indicata un'anagrafica relativa, si carica il tipo di intervento di default impostato -if (!empty($id_anagrafica)) { - $anagrafica = $dbo->fetchOne('SELECT idtipointervento_default, idzona FROM an_anagrafiche WHERE idanagrafica='.prepare($id_anagrafica)); - $id_tipo = $id_tipo ?: $anagrafica['idtipointervento_default']; - $id_zona = $anagrafica['idzona']; -} - -// Gestione dell'impostazione dei Contratti -$id_intervento = filter('id_intervento'); -$id_contratto = filter('idcontratto'); -$id_promemoria_contratto = filter('idcontratto_riga'); -$id_ordine = null; - -// Trasformazione di un Promemoria dei Contratti in Intervento -if (!empty($id_contratto) && !empty($id_promemoria_contratto)) { - $contratto = $dbo->fetchOne('SELECT *, (SELECT idzona FROM an_anagrafiche WHERE idanagrafica = co_contratti.idanagrafica) AS idzona FROM co_contratti WHERE id = '.prepare($id_contratto)); - $id_anagrafica = $contratto['idanagrafica']; - $id_zona = $contratto['idzona']; - - // Informazioni del Promemoria - $promemoria = $dbo->fetchOne('SELECT *, (SELECT tempo_standard FROM in_tipiintervento WHERE idtipointervento = co_promemoria.idtipointervento) AS tempo_standard FROM co_promemoria WHERE idcontratto='.prepare($id_contratto).' AND id = '.prepare($id_promemoria_contratto)); - $id_tipo = $promemoria['idtipointervento']; - $data = (null !== filter('data')) ? filter('data') : $promemoria['data_richiesta']; - $richiesta = $promemoria['richiesta']; - $id_sede = $promemoria['idsede']; - $impianti_collegati = $promemoria['idimpianti']; - - // Generazione dell'orario di fine sulla base del tempo standard definito dal Promemoria - if (!empty($promemoria['tempo_standard'])) { - $orario_fine = date('H:i:s', strtotime($orario_inizio) + ((60 * 60) * $promemoria['tempo_standard'])); - } - - // Caricamento degli impianti a Contratto se non definiti in Promemoria - if (empty($impianti_collegati)) { - $rs = $dbo->fetchArray('SELECT idimpianto FROM my_impianti_contratti WHERE idcontratto = '.prepare($id_contratto)); - $impianti_collegati = implode(',', array_column($rs, 'idimpianto')); - } -} - -// Gestione dell'aggiunta di una sessione a un Intervento senza sessioni (Promemoria intervento) da Dashboard -elseif (!empty($id_intervento)) { - $intervento = $dbo->fetchOne('SELECT *, (SELECT idcontratto FROM co_promemoria WHERE idintervento = in_interventi.id LIMIT 0,1) AS idcontratto, in_interventi.id_preventivo as idpreventivo, (SELECT tempo_standard FROM in_tipiintervento WHERE idtipointervento = in_interventi.idtipointervento) AS tempo_standard FROM in_interventi WHERE id = '.prepare($id_intervento)); - - $id_tipo = $intervento['idtipointervento']; - $data = (null !== filter('data')) ? filter('data') : $intervento['data_richiesta']; - $data_richiesta = $intervento['data_richiesta']; - $data_scadenza = $intervento['data_scadenza']; - $richiesta = $intervento['richiesta']; - $id_sede = $intervento['idsede']; - $id_anagrafica = $intervento['idanagrafica']; - $id_cliente_finale = $intervento['idclientefinale']; - $id_stato = $intervento['idstatointervento']; - $id_contratto = $intervento['idcontratto']; - $id_preventivo = $intervento['idpreventivo']; - $id_zona = $intervento['idzona']; - - // Generazione dell'orario di fine sulla base del tempo standard definito dall'Intervento - if (!empty($intervento['tempo_standard'])) { - $orario_fine = date('H:i:s', strtotime($orario_inizio) + ((60 * 60) * $intervento['tempo_standard'])); - } - - $rs = $dbo->fetchArray('SELECT idimpianto FROM my_impianti_interventi WHERE idintervento = '.prepare($id_intervento)); - $impianti_collegati = implode(',', array_column($rs, 'idimpianto')); -} - -// Selezione dei tecnici assegnati agli impianti selezionati -if (!empty($impianti_collegati)) { - $tecnici_impianti = $dbo->fetchArray('SELECT idtecnico FROM my_impianti WHERE id IN ('.prepare($impianti_collegati).')'); - $id_tecnico = array_unique(array_column($tecnici_impianti, 'idtecnico')); -} - -// Impostazione della data se mancante -if (empty($data)) { - $data = filter('data'); - if (null == $data) { - $data = date('Y-m-d'); - } -} - -// Impostazione della data di fine da Dashboard -if (empty($data_fine)) { - $data_fine = filter('data_fine'); - if (null == $data_fine) { - $data_fine = $data; - } -} -$data_fine = $data_fine ?: $data; - -$inizio_sessione = $data.' '.$orario_inizio; -$fine_sessione = $data_fine.' '.$orario_fine; - -// Calcolo del nuovo codice -$new_codice = Intervento::getNextCodice($data); - -echo ' -
    - - - - - - '; - -if (!empty($id_promemoria_contratto)) { - echo ''; -} - -if (!empty($id_intervento)) { - echo ''; -} - -echo ' -
    -
    - {[ "type": "select", "label": "'.tr('Cliente').'", "name": "idanagrafica", "required": 1, "value": "'.(!$id_cliente ? $id_anagrafica : $id_cliente).'", "ajax-source": "clienti", "icon-after": "add|'.$module_anagrafiche['id'].'|tipoanagrafica=Cliente&readonly_tipo=1", "readonly": "'.((empty($id_anagrafica) && empty($id_cliente)) ? 0 : 1).'" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Sede destinazione').'", "name": "idsede_destinazione", "value": "'.$id_sede.'", "ajax-source": "sedi" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Per conto di').'", "name": "idclientefinale", "value": "'.$id_cliente_finale.'", "ajax-source": "clienti" ]} -
    -
    - -
    -
    - {[ "type": "select", "label": "'.tr('Preventivo').'", "name": "idpreventivo", "value": "'.$id_preventivo.'", "ajax-source": "preventivi", "readonly": "'.(empty($id_preventivo) ? 0 : 1).'", "select-options": '.json_encode(['idanagrafica' => $id_anagrafica]).' ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Contratto').'", "name": "idcontratto", "value": "'.$id_contratto.'", "ajax-source": "contratti", "readonly": "'.(empty($id_contratto) ? 0 : 1).'", "select-options": '.json_encode(['idanagrafica' => $id_anagrafica]).' ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Ordine').'", "name": "idordine", "ajax-source": "ordini-cliente", "value": "'.$id_ordine.'", "select-options": '.json_encode(['idanagrafica' => $id_anagrafica]).' ]} -
    -
    - -
    -
    - {[ "type": "timestamp", "label": "'.tr('Data/ora richiesta').'", "name": "data_richiesta", "required": 1, "value": "'.($data_richiesta ?: '-now-').'" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Tipo').'", "name": "idtipointervento", "required": 1, "values": "query=SELECT idtipointervento AS id, descrizione FROM in_tipiintervento ORDER BY descrizione ASC", "value": "'.$id_tipo.'", "ajax-source": "tipiintervento" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Stato').'", "name": "idstatointervento", "required": 1, "values": "query=SELECT idstatointervento AS id, descrizione, colore AS _bgcolor_ FROM in_statiintervento WHERE deleted_at IS NULL", "value": "'.$id_stato.'" ]} -
    -
    - -
    -
    - {[ "type": "ckeditor", "label": "'.tr('Richiesta').'", "name": "richiesta", "id": "richiesta_add", "required": 1, "value": "'.$richiesta.'", "extra": "style=\'max-height:80px;\'" ]} -
    -
    '; - -$espandi_dettagli = setting('Espandi automaticamente la sezione "Dettagli aggiuntivi"'); -echo ' - -
    -
    -

    '.tr('Dettagli aggiuntivi').'

    -
    - -
    -
    - -
    -
    -
    - {[ "type": "timestamp", "label": "'.tr('Data/ora scadenza').'", "name": "data_scadenza", "required": 0, "value": "'.$data_scadenza.'" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Impianto').'", "multiple": 1, "name": "idimpianti[]", "value": "'.$impianti_collegati.'", "ajax-source": "impianti-cliente", "select-options": {"idanagrafica": '.($id_anagrafica ?: '""').'}, "icon-after": "add|'.Modules::get('Impianti')['id'].'|id_anagrafica='.$id_anagrafica.'" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Componenti').'", "multiple": 1, "name": "componenti[]", "placeholder": "'.tr('Seleziona prima un impianto').'", "ajax-source": "componenti" ]} -
    -
    -
    -
    '; - -if (empty($id_intervento)) { - echo ' - -
    -
    -

    '.tr('Assegnazione tecnici').'

    -
    - -
    -
    - -
    -
    -
    - {[ "type": "select", "label": "'.tr('Tecnici assegnati').'", "multiple": "1", "name": "tecnici_assegnati[]", "ajax-source": "tecnici", "value": "", "icon-after": "add|'.$module_anagrafiche['id'].'|tipoanagrafica=Tecnico" ]} -
    -
    -
    - - - -
    -
    -
    -
    -
    -
    -
    '; -} - -echo ' - -
    -
    -

    '.tr('Ore di lavoro').'

    -
    - -
    -
    - -
    -
    -
    - {[ "type": "timestamp", "label": "'.tr('Inizio attività').'", "name": "orario_inizio", "required": '.($origine_dashboard ? 1 : 0).', "value": "'.$inizio_sessione.'" ]} -
    - -
    - {[ "type": "timestamp", "label": "'.tr('Fine attività').'", "name": "orario_fine", "required": '.($origine_dashboard ? 1 : 0).', "value": "'.$fine_sessione.'" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Zona').'", "name": "idzona", "values": "query=SELECT id, CONCAT_WS(\' - \', nome, descrizione) AS descrizione FROM an_zone ORDER BY nome", "placeholder": "'.tr('Nessuna zona').'", "help": "'.tr('La zona viene definita automaticamente in base al cliente selezionato').'.", "readonly": "1", "value": "'.$id_zona.'" ]} -
    -
    - -
    -
    - {[ "type": "select", "label": "'.tr('Tecnici').'", "multiple": "1", "name": "idtecnico[]", "required": '.($origine_dashboard ? 1 : 0).', "ajax-source": "tecnici", "value": "'.$id_tecnico.'", "icon-after": "add|'.$module_anagrafiche['id'].'|tipoanagrafica=Tecnico||'.(empty($id_tecnico) ? '' : 'disabled').'" ]} -
    -
    - -
    - -
    -
    - - -
    -
    -

    '.tr('Dettagli cliente').'

    -
    - -
    -
    - -
    - '.tr('Prima seleziona un cliente').'... -
    -
    - - -
    -
    - -
    -
    -
    '; - -if (!empty($id_intervento)) { - echo ' -'; -} - -// Disabilito i campi che non devono essere modificati per poter collegare l'Intervento al Promemoria del Contratto -if (!empty($id_contratto) && !empty($id_promemoria_contratto)) { - echo ' -'; -} - -echo ' -'; diff --git a/modules/interventi/add_contratto.php b/modules/interventi/add_contratto.php deleted file mode 100644 index 2c8f4b2d5..000000000 --- a/modules/interventi/add_contratto.php +++ /dev/null @@ -1,86 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Contratti\Contratto; -use Modules\Interventi\Intervento; - -$documento_finale = Intervento::find($id_record); -$dir = $documento_finale->direzione; - -$id_documento = get('id_documento'); -if (!empty($id_documento)) { - $documento = Contratto::find($id_documento); - - $options = [ - 'op' => 'add_documento', - 'type' => 'contratto', - 'button' => tr('Aggiungi'), - 'documento' => $documento, - 'documento_finale' => $documento_finale, - 'tipo_documento_finale' => Intervento::class, - 'superamento_soglia_qta' => setting('Permetti il superamento della soglia quantità dei documenti di origine'), - ]; - - echo App::load('importa.php', [], $options, true); - - return; -} - -$id_anagrafica = $documento_finale->idanagrafica; - -echo ' -
    -
    - {[ "type": "select", "label": "'.tr('Contratto').'", "name": "id_documento", "ajax-source": "contratti", "select-options": {"idanagrafica": '.$id_anagrafica.', "stato": "is_fatturabile"} ]} -
    -
    - -
    - -
    - -
    - '.tr('Caricamento in corso').'... -
    '; - -$file = basename(__FILE__); -echo ' - - -'; diff --git a/modules/interventi/add_ddt.php b/modules/interventi/add_ddt.php deleted file mode 100644 index b7839200e..000000000 --- a/modules/interventi/add_ddt.php +++ /dev/null @@ -1,87 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\DDT\DDT; -use Modules\Interventi\Intervento; - -$documento_finale = Intervento::find($id_record); -$dir = $documento_finale->direzione; - -$id_documento = get('id_documento'); -if (!empty($id_documento)) { - $documento = DDT::find($id_documento); - - $options = [ - 'op' => 'add_documento', - 'type' => 'ddt', - 'serials' => true, - 'button' => tr('Aggiungi'), - 'documento' => $documento, - 'documento_finale' => $documento_finale, - 'tipo_documento_finale' => Intervento::class, - 'superamento_soglia_qta' => setting('Permetti il superamento della soglia quantità dei documenti di origine'), - ]; - - echo App::load('importa.php', [], $options, true); - - return; -} - -$id_anagrafica = $documento_finale->idanagrafica; - -echo ' -
    -
    - {[ "type": "select", "label": "'.tr('Ddt').'", "name": "id_documento", "values": "query=SELECT dt_ddt.id, CONCAT(\'DDT num. \', IF(numero_esterno != \'\', numero_esterno, numero), \' del \', DATE_FORMAT(data, \'%d-%m-%Y\'), \' [\', (SELECT descrizione FROM dt_statiddt WHERE id = idstatoddt) , \']\') AS descrizione FROM dt_ddt LEFT JOIN `dt_causalet` ON `dt_causalet`.`id` = `dt_ddt`.`idcausalet` WHERE idanagrafica='.prepare($id_anagrafica).' AND idstatoddt IN (SELECT id FROM dt_statiddt WHERE descrizione IN(\'Evaso\', \'Parzialmente evaso\', \'Parzialmente fatturato\')) AND idtipoddt=(SELECT id FROM dt_tipiddt WHERE dir='.prepare($dir).') AND `dt_causalet`.`is_importabile` = 1 AND dt_ddt.id IN (SELECT idddt FROM dt_righe_ddt WHERE dt_righe_ddt.idddt = dt_ddt.id AND (qta - qta_evasa) > 0) ORDER BY data DESC, numero DESC" ]} -
    -
    - -
    - -
    - -
    - '.tr('Caricamento in corso').'... -
    '; - -$file = basename(__FILE__); -echo ' - - -'; diff --git a/modules/interventi/add_preventivo.php b/modules/interventi/add_preventivo.php deleted file mode 100644 index 693856828..000000000 --- a/modules/interventi/add_preventivo.php +++ /dev/null @@ -1,86 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Interventi\Intervento; -use Modules\Preventivi\Preventivo; - -$documento_finale = Intervento::find($id_record); -$dir = $documento_finale->direzione; - -$id_documento = get('id_documento'); -if (!empty($id_documento)) { - $documento = Preventivo::find($id_documento); - - $options = [ - 'op' => 'add_documento', - 'type' => 'preventivo', - 'button' => tr('Aggiungi'), - 'documento' => $documento, - 'documento_finale' => $documento_finale, - 'tipo_documento_finale' => Intervento::class, - 'superamento_soglia_qta' => setting('Permetti il superamento della soglia quantità dei documenti di origine'), - ]; - - echo App::load('importa.php', [], $options, true); - - return; -} - -$id_anagrafica = $documento_finale->idanagrafica; - -echo ' -
    -
    - {[ "type": "select", "label": "'.tr('Preventivo').'", "name": "id_documento", "ajax-source": "preventivi", "select-options": {"idanagrafica": '.$id_anagrafica.', "stato": "is_fatturabile"} ]} -
    -
    - -
    - -
    - -
    - '.tr('Caricamento in corso').'... -
    '; - -$file = basename(__FILE__); -echo ' - - -'; diff --git a/modules/interventi/ajax/complete.php b/modules/interventi/ajax/complete.php deleted file mode 100644 index 6d38411ed..000000000 --- a/modules/interventi/ajax/complete.php +++ /dev/null @@ -1,112 +0,0 @@ -permission != '-') { - // Contratti attivi per l'anagrafica - $contratti = Contratto::where('idanagrafica', '=', $id_anagrafica) - ->whereHas('stato', function ($query) { - $query->where('is_pianificabile', '=', 1); - }) - ->latest()->take($numero_documenti)->get(); - - echo ' -
    -
    - '.tr('Contratti').':
      '; - if (!$contratti->isEmpty()) { - foreach ($contratti as $contratto) { - echo ' -
    • '.$contratto->getReference().' ['.$contratto->stato->descrizione.']: '.dateFormat($contratto->data_accettazione).' - '.dateFormat($contratto->data_conclusione).'
    • '; - } - } else { - echo ' -
    • '.tr('Nessun contratto attivo per questo cliente').'
    • '; - } - echo ' -
    -
    '; - } - - // Informazioni sui preventivi - $modulo_preventivi = Module::pool('Preventivi'); - if ($modulo_preventivi->permission != '-') { - // Preventivi attivi - $preventivi = Preventivo::where('idanagrafica', '=', $id_anagrafica) - ->whereHas('stato', function ($query) { - $query->where('is_pianificabile', '=', 1); - }) - ->latest()->take($numero_documenti)->get(); - echo ' -
    - '.tr('Preventivi').':
      '; - if (!$preventivi->isEmpty()) { - foreach ($preventivi as $preventivo) { - echo ' -
    • '.$preventivo->getReference().' ['.$preventivo->stato->descrizione.']
    • '; - } - } else { - echo ' -
    • '.tr('Nessun preventivo attivo per questo cliente').'
    • '; - } - echo ' -
    -
    '; - } - - // Informazioni sui preventivi - $modulo_fatture_vendita = Module::pool('Fatture di vendita'); - if ($modulo_fatture_vendita->permission != '-') { - // Fatture attive - $fatture = Fattura::where('idanagrafica', '=', $id_anagrafica) - ->whereHas('stato', function ($query) { - $query->whereIn('descrizione', ['Emessa', 'Parzialmente pagato']); - }) - ->latest()->take($numero_documenti)->get(); - echo ' -
    - '.tr('Fatture').':
      '; - if (!$fatture->isEmpty()) { - foreach ($fatture as $fattura) { - $scadenze = $fattura->scadenze; - $da_pagare = $scadenze->sum('da_pagare') - $scadenze->sum('pagato'); - echo ' -
    • '.$fattura->getReference().': '.moneyFormat($da_pagare).'
    • '; - } - } else { - echo ' -
    • '.tr('Nessuna fattura attiva per questo cliente').'
    • '; - } - echo ' -
    -
    '; - } - - // Note dell'anagrafica - $anagrafica = Anagrafica::find($id_anagrafica); - $note_anagrafica = $anagrafica->note; - echo ' -
    -

    '.tr('Note interne sul cliente').':

    - '.(!empty($note_anagrafica) ? $note_anagrafica : tr('Nessuna nota interna per questo cliente')).' -
    '; - - echo ' -
    '; - - break; -} diff --git a/modules/interventi/ajax/search.php b/modules/interventi/ajax/search.php deleted file mode 100755 index c744dcb72..000000000 --- a/modules/interventi/ajax/search.php +++ /dev/null @@ -1,76 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -$link_id = Modules::get('Interventi')['id']; - -$fields = [ - 'Codice intervento' => 'codice', - 'Data intervento' => '(SELECT MIN(orario_inizio) FROM in_interventi_tecnici WHERE idintervento=in_interventi.id)', - 'Data richiesta intervento' => 'data_richiesta', - 'Sede intervento' => 'info_sede', - 'Richiesta' => 'richiesta', - 'Descrizione' => 'descrizione', - 'Informazioni aggiuntive' => 'informazioniaggiuntive', -]; - -$query = 'SELECT *, (SELECT MIN(orario_inizio) FROM in_interventi_tecnici WHERE idintervento=in_interventi.id) AS data'; - -foreach ($fields as $name => $value) { - $query .= ', '.$value." AS '".str_replace("'", "\'", $name)."'"; -} - -$query .= ' FROM in_interventi '; - -$where = []; -foreach ($fields as $name => $value) { - $where[] = $value.' LIKE "%'.$term.'%"'; -} - -$query .= ' WHERE ('.implode(' OR ', $where).') '; - -$query .= ' '.Modules::getAdditionalsQuery('Interventi'); - -$rs = $dbo->fetchArray($query); - -foreach ($rs as $r) { - $result = []; - - $result['link'] = base_path().'/editor.php?id_module='.$link_id.'&id_record='.$r['id']; - $result['title'] = 'Intervento '.$r['codice'].' del '.Translator::dateToLocale($r['data']); - $result['category'] = 'Interventi'; - - // Campi da evidenziare - $result['labels'] = []; - foreach ($fields as $name => $value) { - if (string_contains($r[$name], $term)) { - $text = str_replace($term, "".$term.'', $r[$name]); - - $result['labels'][] = $name.': '.$text.'
    '; - } - } - - // Aggiunta nome anagrafica come ultimo campo - if (sizeof($ragioni_sociali) > 1) { - $result['labels'][] = 'Anagrafica: '.$ragioni_sociali[$r['idanagrafica']].'
    '; - } - - $results[] = $result; -} diff --git a/modules/interventi/ajax/select.php b/modules/interventi/ajax/select.php deleted file mode 100755 index fe46a729e..000000000 --- a/modules/interventi/ajax/select.php +++ /dev/null @@ -1,34 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -switch ($resource) { - case 'tipiintervento': - $query = 'SELECT idtipointervento AS id, CASE WHEN ISNULL(tempo_standard) OR tempo_standard <= 0 THEN descrizione WHEN tempo_standard > 0 THEN CONCAT(descrizione, \' (\', REPLACE(FORMAT(tempo_standard, 2), \'.\', \',\'), \' ore)\') END AS descrizione, tempo_standard FROM in_tipiintervento |where| ORDER BY idtipointervento'; - - foreach ($elements as $element) { - $filter[] = 'idtipointervento='.prepare($element); - } - if (!empty($search)) { - $search_fields[] = 'descrizione LIKE '.prepare('%'.$search.'%'); - } - - break; -} diff --git a/modules/interventi/ajax_costi.php b/modules/interventi/ajax_costi.php deleted file mode 100755 index 6a1414ccc..000000000 --- a/modules/interventi/ajax_costi.php +++ /dev/null @@ -1,149 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Interventi\Intervento; - -$intervento = Intervento::find($id_record); -$sessioni = $intervento->sessioni; -$righe = $intervento->getRighe(); - -$show_prezzi = Auth::user()['gruppo'] != 'Tecnici' || (Auth::user()['gruppo'] == 'Tecnici' && setting('Mostra i prezzi al tecnico')); - -if ($show_prezzi) { - $rss = $dbo->fetchArray('SELECT in_statiintervento.is_completato AS flag_completato FROM in_statiintervento INNER JOIN in_interventi ON in_statiintervento.idstatointervento=in_interventi.idstatointervento WHERE in_interventi.id='.prepare($id_record)); - - if ($rss[0]['flag_completato']) { - $readonly = 'readonly'; - } else { - $readonly = ''; - } - - echo ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - '; - - // Calcoli - $imponibile = abs($intervento->imponibile); - $sconto = $intervento->sconto; - $totale_imponibile = abs($intervento->totale_imponibile); - $iva = abs($intervento->iva); - $totale = abs($intervento->totale); - - echo ' - - - - '; - - // SCONTO - if (!empty($sconto)) { - echo ' - - - - '; - - // Totale imponibile - echo ' - - - - '; - } - - // Totale iva - echo ' - - - - '; - - // Totale preventivo - echo ' - - - - '; - - echo ' -
    '.tr('Costo', [], ['upper' => true]).' '.tr('Addebito', [], ['upper' => true]).' '.tr('Tot. Scontato', [], ['upper' => true]).'
    '.tr('Totale manodopera', [], ['upper' => true]).''.moneyFormat($sessioni->sum('costo_manodopera'), 2).''.moneyFormat($sessioni->sum('prezzo_manodopera'), 2).''.moneyFormat($sessioni->sum('prezzo_manodopera_scontato'), 2).'
    '.tr('Totale diritto di chiamata', [], ['upper' => true]).''.moneyFormat($sessioni->sum('costo_diritto_chiamata'), 2).''.moneyFormat($sessioni->sum('prezzo_diritto_chiamata'), 2).''.moneyFormat($sessioni->sum('prezzo_diritto_chiamata'), 2).'
    '.tr('Totale viaggio', [], ['upper' => true]).''.moneyFormat($sessioni->sum('costo_viaggio'), 2).''.moneyFormat($sessioni->sum('prezzo_viaggio'), 2).''.moneyFormat($sessioni->sum('prezzo_viaggio_scontato'), 2).'
    '.tr('Totale righe', [], ['upper' => true]).''.moneyFormat($righe->sum('spesa'), 2).''.moneyFormat($righe->sum('imponibile'), 2).''.moneyFormat($righe->sum('totale_imponibile'), 2).'
    - '.tr('Imponibile', [], ['upper' => true]).': - - '.moneyFormat($imponibile, 2).' -
    - '.tr('Sconto/maggiorazione', [], ['upper' => true]).': - - '.moneyFormat($sconto, 2).' -
    - '.tr('Totale imponibile', [], ['upper' => true]).': - - '.moneyFormat($totale_imponibile, 2).' -
    - '.tr('IVA', [], ['upper' => true]).': - - '.moneyFormat($iva, 2).' -
    - '.tr('Totale', [], ['upper' => true]).': - - '.moneyFormat($totale, 2).' -
    '; -} - -echo ' -'; diff --git a/modules/interventi/ajax_tecnici.php b/modules/interventi/ajax_tecnici.php deleted file mode 100755 index 669c62272..000000000 --- a/modules/interventi/ajax_tecnici.php +++ /dev/null @@ -1,372 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$show_costi = true; -// Limitazione delle azioni dei tecnici -if ($user['gruppo'] == 'Tecnici') { - $show_costi = !empty($user['idanagrafica']) && setting('Mostra i prezzi al tecnico'); -} - -// Stato dell'intervento -$rss = $dbo->fetchArray('SELECT is_completato AS flag_completato FROM in_statiintervento WHERE idstatointervento = (SELECT idstatointervento FROM in_interventi WHERE id='.prepare($id_record).')'); -$is_completato = $rss[0]['flag_completato']; - -// Sessioni dell'intervento -$query = 'SELECT in_interventi_tecnici.*, an_anagrafiche.ragione_sociale, an_anagrafiche.deleted_at AS anagrafica_deleted_at, in_tipiintervento.descrizione AS descrizione_tipo, in_interventi_tecnici.tipo_scontokm AS tipo_sconto_km FROM in_interventi_tecnici -INNER JOIN an_anagrafiche ON in_interventi_tecnici.idtecnico = an_anagrafiche.idanagrafica -INNER JOIN in_tipiintervento ON in_interventi_tecnici.idtipointervento = in_tipiintervento.idtipointervento -WHERE in_interventi_tecnici.idintervento='.prepare($id_record).' ORDER BY ragione_sociale ASC, in_interventi_tecnici.orario_inizio ASC, in_interventi_tecnici.id ASC'; -$sessioni = $dbo->fetchArray($query); - -$prev_tecnico = ''; -if (!empty($sessioni)) { - foreach ($sessioni as $key => $sessione) { - // Intestazione tecnico - if ($prev_tecnico != $sessione['ragione_sociale']) { - $prev_tecnico = $sessione['ragione_sociale']; - - echo ' -
    - - - - - - - '; - - if ($show_costi) { - echo ' - - '; - } - - if (!$is_completato) { - echo ' - '; - } - - echo ' - '; - } - - // Lettura costi unitari salvati al momento dell'intervento - $sconto = $sessione['sconto']; - $scontokm = $sessione['scontokm']; - - $costo_ore_unitario = $sessione['prezzo_ore_unitario']; - $costo_km_unitario = $sessione['prezzo_km_unitario']; - $costo_dirittochiamata = $sessione['prezzo_dirittochiamata']; - - $costo_ore_unitario_tecnico = $sessione['prezzo_ore_unitario_tecnico']; - $costo_km_unitario_tecnico = $sessione['prezzo_km_unitario_tecnico']; - $costo_dirittochiamata_tecnico = $sessione['prezzo_dirittochiamata_tecnico']; - - $costo_km_consuntivo_tecnico = $sessione['prezzo_km_consuntivo_tecnico']; - $costo_ore_consuntivo_tecnico = $sessione['prezzo_ore_consuntivo_tecnico']; - $costo_km_consuntivo = $sessione['prezzo_km_consuntivo']; - $costo_ore_consuntivo = $sessione['prezzo_ore_consuntivo']; - - $ore = $sessione['ore']; - $km = $sessione['km']; - - // Tipologia - echo ' - - '; - - // Orario di inizio - echo ' - '; - - // Orario di fine - echo ' - '; - - // ORE - echo ' - '; - - // KM - echo ' - '; - - // Sconto ore - if ($show_costi) { - echo ' - '; - } - - // Sconto km - if ($show_costi) { - echo ' - '; - } - - // Pulsante per la sessione - if (!$is_completato) { - echo ' - '; - } - - echo ' - '; - - // Intestazione tecnico - if (!isset($sessioni[$key + 1]['ragione_sociale']) || $sessione['ragione_sociale'] != $sessioni[$key + 1]['ragione_sociale']) { - echo ' -
    '.$sessione['ragione_sociale'].' '.(($sessione['anagrafica_deleted_at']) ? '('.tr('Eliminato').')' : '').''.tr('Orario inizio').''.tr('Orario fine').''.tr('Ore').''.tr('Km').''.tr('Sconto ore').''.tr('Sconto km').'#
    - '.$sessione['descrizione_tipo'].' - - '.Translator::timestampToLocale($sessione['orario_inizio']).' - - '.Translator::timestampToLocale($sessione['orario_fine']).' - - '.Translator::numberToLocale($ore).' - -
    - - - - - - - - - - - - - -
    '.tr('Costo').': - '.Translator::numberToLocale($costo_ore_consuntivo_tecnico)." - ".Translator::numberToLocale($costo_ore_unitario_tecnico).'x'.Translator::numberToLocale($ore).'
    +'.Translator::numberToLocale($costo_dirittochiamata_tecnico).'
    -
    '.tr('Addebito').': - '.Translator::numberToLocale($costo_ore_consuntivo).' - '.Translator::numberToLocale($costo_ore_unitario).'x'.Translator::numberToLocale($ore).'
    +'.Translator::numberToLocale($costo_dirittochiamata).'
    -
    '.tr('Scontato').':'.Translator::numberToLocale($costo_ore_consuntivo - $sconto).'
    -
    -
    - '.Translator::numberToLocale($km).' - -
    - - - - - - - - - - - - - -
    '.tr('Costo').': - '.Translator::numberToLocale($costo_km_consuntivo_tecnico).' - - '.Translator::numberToLocale($costo_km_unitario_tecnico).'x'.Translator::numberToLocale($km).' -
    -
    '.tr('Addebito').': - '.Translator::numberToLocale($costo_km_consuntivo).' - - '.Translator::numberToLocale($costo_km_unitario).'x'.Translator::numberToLocale($km).' -
    -
    '.tr('Scontato').':'.Translator::numberToLocale($costo_km_consuntivo - $scontokm).'
    -
    -
    - '.tr('_TOT_ _TYPE_', [ - '_TOT_' => Translator::numberToLocale($sessione['sconto_unitario']), - '_TYPE_' => ($sessione['tipo_sconto'] == 'PRC' ? '%' : currency()), - ]).' - - '.tr('_TOT_ _TYPE_', [ - '_TOT_' => Translator::numberToLocale($sessione['scontokm_unitario']), - '_TYPE_' => ($sessione['tipo_sconto_km'] == 'PRC' ? '%' : currency()), - ]).' - - - - - - -
    -
    '; - } - } -} else { - echo ' -
    - '.tr('Nessun tecnico assegnato').'. -
    '; -} - -echo ' -
    '; - -if (!$is_completato) { - echo ' - -
    -
    - {[ "type": "select", "label": "'.tr('Tecnico').'", "name": "nuovo_tecnico", "placeholder": "'.tr('Seleziona un tecnico').'", "ajax-source": "tecnici", "icon-after": "add|'.Modules::get('Anagrafiche')['id'].'|tipoanagrafica=Tecnico&readonly_tipo=1" ]} -
    - -
    - - -
    -
    '; -} - -echo ' - - - -'; diff --git a/modules/interventi/bulk.php b/modules/interventi/bulk.php deleted file mode 100755 index df503b6e0..000000000 --- a/modules/interventi/bulk.php +++ /dev/null @@ -1,300 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Anagrafiche\Anagrafica; -use Modules\Fatture\Fattura; -use Modules\Fatture\Tipo; -use Modules\Interventi\Intervento; -use Modules\Interventi\Stato; -use Util\Zip; - -// Segmenti -$id_fatture = Modules::get('Fatture di vendita')['id']; -if (!isset($_SESSION['module_'.$id_fatture]['id_segment'])) { - $segments = Modules::getSegments($id_fatture); - $_SESSION['module_'.$id_fatture]['id_segment'] = isset($segments[0]['id']) ? $segments[0]['id'] : null; -} -$id_segment = $_SESSION['module_'.$id_fatture]['id_segment']; - -switch (post('op')) { - case 'export-bulk': - $dir = base_dir().'/files/export_interventi/'; - directory($dir.'tmp/'); - - // Rimozione dei contenuti precedenti - $files = glob($dir.'/*.zip'); - foreach ($files as $file) { - delete($file); - } - - // Selezione degli interventi da stampare - $interventi = $dbo->fetchArray('SELECT in_interventi.id, in_interventi.codice, data_richiesta, ragione_sociale FROM in_interventi INNER JOIN an_anagrafiche ON in_interventi.idanagrafica=an_anagrafiche.idanagrafica WHERE in_interventi.id IN('.implode(',', $id_records).')'); - - if (!empty($interventi)) { - foreach ($interventi as $r) { - $print = Prints::getModulePredefinedPrint($id_module); - - Prints::render($print['id'], $r['id'], $dir.'tmp/'); - } - - $dir = slashes($dir); - $file = slashes($dir.'interventi_'.time().'.zip'); - - // Creazione zip - if (extension_loaded('zip')) { - Zip::create($dir.'tmp/', $file); - - // Invio al browser dello zip - download($file); - - // Rimozione dei contenuti - delete($dir.'tmp/'); - } - } - - break; - - case 'crea_fattura': - $id_documento_cliente = []; - $n_interventi = 0; - - $data = date('Y-m-d'); - $dir = 'entrata'; - $tipo_documento = Tipo::where('descrizione', 'Fattura immediata di vendita')->first(); - - $id_iva = setting('Iva predefinita'); - $id_conto = setting('Conto predefinito fatture di vendita'); - - $accodare = post('accodare'); - $id_segment = post('id_segment'); - - $interventi = $dbo->fetchArray('SELECT *, IFNULL((SELECT MIN(orario_inizio) FROM in_interventi_tecnici WHERE in_interventi_tecnici.idintervento = in_interventi.id), in_interventi.data_richiesta) AS data, in_statiintervento.descrizione AS stato, in_interventi.codice AS codice_intervento FROM in_interventi INNER JOIN in_statiintervento ON in_interventi.idstatointervento=in_statiintervento.idstatointervento WHERE in_statiintervento.is_completato=1 AND in_interventi.id NOT IN (SELECT idintervento FROM co_righe_documenti WHERE idintervento IS NOT NULL) AND in_interventi.id_preventivo IS NULL AND in_interventi.id_contratto IS NULL AND in_interventi.id_ordine IS NULL AND in_interventi.id NOT IN (SELECT idintervento FROM co_promemoria WHERE idintervento IS NOT NULL) AND in_interventi.id IN ('.implode(',', $id_records).')'); - - // Lettura righe selezionate - foreach ($interventi as $intervento) { - $id_anagrafica = $intervento['idanagrafica']; - - $id_documento = $id_documento_cliente[$id_anagrafica]; - - // Se non c'è già una fattura appena creata per questo cliente, creo una fattura nuova - if (empty($id_documento)) { - if (!empty($accodare)) { - $documento = $dbo->fetchOne('SELECT co_documenti.id FROM co_documenti INNER JOIN co_statidocumento ON co_documenti.idstatodocumento = co_statidocumento.id WHERE co_statidocumento.descrizione = \'Bozza\' AND idanagrafica = '.prepare($id_anagrafica)); - - $id_documento = $documento['id']; - $id_documento_cliente[$id_anagrafica] = $id_documento; - } - - if (empty($id_documento)) { - $anagrafica = Anagrafica::find($id_anagrafica); - $fattura = Fattura::build($anagrafica, $tipo_documento, $data, $id_segment); - - $id_documento = $fattura->id; - $id_documento_cliente[$id_anagrafica] = $id_documento; - } - } - - $descrizione = tr('Attività numero _NUM_ del _DATE_ [_STATE_]', [ - '_NUM_' => $intervento['codice_intervento'], - '_DATE_' => Translator::dateToLocale($intervento['data']), - '_STATE_' => $intervento['stato'], - ]); - - aggiungi_intervento_in_fattura($intervento['id'], $id_documento, $descrizione, $id_iva, $id_conto); - $fatturati[] = $intervento['id']; - ++$n_interventi; - } - - if ($n_interventi > 0) { - flash()->info(tr('_NUM_ interventi fatturati.', [ - '_NUM_' => $n_interventi, - ])); - } - - if (!empty(array_diff($id_records, $fatturati))) { - flash()->warning(tr('_NUM_ interventi non sono stati fatturati.', [ - '_NUM_' => sizeof(array_diff($id_records, $fatturati)), - ])); - } - - break; - - case 'cambia_stato': - $id_stato = post('id_stato'); - - $n_interventi = 0; - $stato = Stato::find($id_stato); - - // Lettura righe selezionate - foreach ($id_records as $id) { - $intervento = Intervento::find($id); - - if (!$intervento->stato->is_completato || ($intervento->stato->is_completato == $stato->is_completato)) { - $intervento->stato()->associate($stato); - $intervento->save(); - - ++$n_interventi; - } - } - - if ($n_interventi > 0) { - flash()->info(tr('Stato cambiato a _NUM_ attività!', [ - '_NUM_' => $n_interventi, - ])); - } else { - flash()->warning(tr('Nessuna attività modificata!')); - } - - break; - - case 'copy-bulk': - $id_stato = post('idstatointervento'); - $data_richiesta = post('data_richiesta'); - $copia_sessioni = post('sessioni'); - $copia_righe = post('righe'); - - foreach ($id_records as $idintervento) { - $intervento = Intervento::find($idintervento); - - $new = $intervento->replicate(); - $new->idstatointervento = $id_stato; - - // Calcolo del nuovo codice sulla base della data di richiesta - $new->codice = Intervento::getNextCodice($data_richiesta); - - $new->save(); - - $id_record = $new->id; - - // Copio le righe - if (!empty($copia_righe)) { - $righe = $intervento->getRighe(); - foreach ($righe as $riga) { - $new_riga = $riga->replicate(); - $new_riga->setDocument($new); - - $new_riga->qta_evasa = 0; - $new_riga->save(); - } - } - - // Copia delle sessioni - $numero_sessione = 0; - if (!empty($copia_sessioni)) { - $sessioni = $intervento->sessioni; - foreach ($sessioni as $sessione) { - // Se è la prima sessione che copio importo la data con quella della richiesta - if ($numero_sessione == 0) { - $orario_inizio = date('Y-m-d', strtotime($data_richiesta)).' '.date('H:i:s', strtotime($sessione->orario_inizio)); - } else { - $diff = strtotime($sessione->orario_inizio) - strtotime($inizio_old); - $orario_inizio = date('Y-m-d H:i:s', (strtotime($sessione->orario_inizio) + $diff)); - } - - $diff_fine = strtotime($sessione->orario_fine) - strtotime($sessione->orario_inizio); - $orario_fine = date('Y-m-d H:i:s', (strtotime($orario_inizio) + $diff_fine)); - - $new_sessione = $sessione->replicate(); - $new_sessione->idintervento = $new->id; - - $new_sessione->orario_inizio = $orario_inizio; - $new_sessione->orario_fine = $orario_fine; - $new_sessione->save(); - - ++$numero_sessione; - $inizio_old = $sessione->orario_inizio; - } - } - } - - flash()->info(tr('Attività duplicate correttamente!')); - - break; - - case 'delete-bulk': - foreach ($id_records as $id) { - $intervento = Intervento::find($id); - try { - $intervento->delete(); - } catch (InvalidArgumentException $e) { - } - } - - flash()->info(tr('Interventi eliminati!')); - break; -} - -if (App::debug()) { - $operations['delete-bulk'] = [ - 'text' => ' '.tr('Elimina selezionati').' beta', - ]; -} - - $operations['export-bulk'] = [ - 'text' => ' '.tr('Esporta stampe'), - 'data' => [ - 'title' => tr('Vuoi davvero esportare queste stampe in un archivio ZIP?'), - 'msg' => '', - 'button' => tr('Procedi'), - 'class' => 'btn btn-lg btn-warning', - 'blank' => true, - ], - ]; - - $operations['crea_fattura'] = [ - 'text' => ' '.tr('Fattura _TYPE_', ['_TYPE_' => strtolower($module['name'])]), - 'data' => [ - 'title' => tr('Fatturare gli _TYPE_ selezionati?', ['_TYPE_' => strtolower($module['name'])]).' ', - 'msg' => '{[ "type": "checkbox", "label": "'.tr('Aggiungere alle fatture di vendita non ancora emesse?').'", "placeholder": "'.tr('Aggiungere alle fatture di vendita nello stato bozza?').'", "name": "accodare" ]}
    - {[ "type": "select", "label": "'.tr('Sezionale').'", "name": "id_segment", "required": 1, "values": "query=SELECT id, name AS descrizione FROM zz_segments WHERE id_module=\''.$id_fatture.'\' AND is_fiscale = 1 ORDER BY name", "value": "'.$id_segment.'" ]}', - 'button' => tr('Procedi'), - 'class' => 'btn btn-lg btn-warning', - 'blank' => false, - ], - ]; - - $operations['cambia_stato'] = [ - 'text' => ' '.tr('Cambia stato'), - 'data' => [ - 'title' => tr('Vuoi davvero cambiare lo stato per questi interventi?'), - 'msg' => tr('Seleziona lo stato in cui spostare tutti gli interventi non completati').'.
    -
    {[ "type": "select", "label": "'.tr('Stato').'", "name": "id_stato", "required": 1, "values": "query=SELECT idstatointervento AS id, descrizione, colore AS _bgcolor_ FROM in_statiintervento WHERE deleted_at IS NULL" ]}', - 'button' => tr('Procedi'), - 'class' => 'btn btn-lg btn-warning', - 'blank' => false, - ], - ]; - - $operations['copy-bulk'] = [ - 'text' => ' '.tr('Duplica attività'), - 'data' => [ - 'title' => tr('Vuoi davvero fare una copia degli interventi selezionati?'), - 'msg' => '
    {[ "type": "timestamp", "label": "'.tr('Data/ora richiesta').'", "name": "data_richiesta", "required": 0, "value": "-now-", "required":1 ]} -
    {[ "type": "select", "label": "'.tr('Stato').'", "name": "idstatointervento", "required": 1, "values": "query=SELECT idstatointervento AS id, descrizione, colore AS _bgcolor_ FROM in_statiintervento WHERE deleted_at IS NULL", "value": "" ]} -
    {[ "type":"checkbox", "label":"'.tr('Duplica righe').'", "name":"righe", "value":"" ]} -
    {[ "type":"checkbox", "label":"'.tr('Duplica sessioni').'", "name":"sessioni", "value":"" ]}', - 'button' => tr('Procedi'), - 'class' => 'btn btn-lg btn-warning', - 'blank' => false, - ], - ]; - -return $operations; diff --git a/modules/interventi/buttons.php b/modules/interventi/buttons.php deleted file mode 100755 index f24f4a92b..000000000 --- a/modules/interventi/buttons.php +++ /dev/null @@ -1,74 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (empty($record['firma_file'])) { - $frase = tr('Anteprima e firma'); - $info_firma = ''; -} else { - $frase = tr('Nuova anteprima e firma'); - $info_firma = ' '.tr('Firmato il _DATE_ alle _TIME_ da _PERSON_', [ - '_DATE_' => Translator::dateToLocale($record['firma_data']), - '_TIME_' => Translator::timeToLocale($record['firma_data']), - '_PERSON_' => ''.$record['firma_nome'].'', - ]).''; -} - -// Duplica intervento -echo ' - - - -'.$info_firma.' - - - -'; - -// Creazione altri documenti -// TODO: trasformazione delle sessioni in righe relative -/* -echo ' -
    - - -
    '; -*/ diff --git a/modules/interventi/crea_documento.php b/modules/interventi/crea_documento.php deleted file mode 100644 index 3457c4d17..000000000 --- a/modules/interventi/crea_documento.php +++ /dev/null @@ -1,60 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\DDT\DDT; -use Modules\Fatture\Fattura; -use Modules\Interventi\Intervento; -use Modules\Ordini\Ordine; - -$documento = Intervento::find($id_record); - -$module = Modules::get($documento->module); - -if (get('documento') == 'fattura') { - $final_module = 'Fatture di vendita'; - $op = 'add_documento'; - $tipo_documento_finale = Fattura::class; -} elseif (get('documento') == 'ordine_fornitore') { - $final_module = 'Ordini fornitore'; - $op = 'add_ordine_cliente'; - $tipo_documento_finale = Ordine::class; -} elseif (get('documento') == 'ordine') { - $final_module = 'Ordini cliente'; - $op = 'add_documento'; - $tipo_documento_finale = Ordine::class; -} else { - $final_module = 'Ddt di vendita'; - $op = 'add_documento'; - $tipo_documento_finale = DDT::class; -} - -$options = [ - 'op' => $op, - 'type' => 'ordine', - 'module' => $final_module, - 'button' => tr('Aggiungi'), - 'create_document' => true, - 'serials' => true, - 'documento' => $documento, - 'tipo_documento_finale' => $tipo_documento_finale, -]; - -echo App::load('importa.php', [], $options, true); diff --git a/modules/interventi/edit.php b/modules/interventi/edit.php deleted file mode 100755 index a31adc1e2..000000000 --- a/modules/interventi/edit.php +++ /dev/null @@ -1,784 +0,0 @@ -. - */ - -use Modules\Anagrafiche\Anagrafica; -use Modules\Anagrafiche\Sede; - -include_once __DIR__.'/../../core.php'; - -$block_edit = $record['flag_completato']; -$module_anagrafiche = Modules::get('Anagrafiche'); - -// Verifica aggiuntive sulla sequenzialità dei numeri -$numero_previsto = verifica_numero_intervento($intervento); - -if (!empty($numero_previsto) && intval((setting('Verifica numero intervento')))) { - echo ' -
    - '.tr("E' assente una attività di numero _NUM_ in data precedente o corrispondente a _DATE_: si potrebbero verificare dei problemi con la numerazione corrente delle attività", [ - '_DATE_' => dateFormat($intervento->data_richiesta), - '_NUM_' => '"'.$numero_previsto.'"', - ]).'. -
    '; -} - -echo ' -
    - - - - -
    -
    - -
    -
    -

    '.tr('Dati cliente').'

    -
    - -
    - -
    -
    - '.Modules::link('Anagrafiche', $record['idanagrafica'], null, null, 'class="pull-right"').' - {[ "type": "select", "label": "'.tr('Cliente').'", "name": "idanagrafica", "required": 1, "value": "$idanagrafica$", "ajax-source": "clienti", "readonly": "'.($user['gruppo'] == 'Clienti' ? '1' : $record['flag_completato']).'" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Sede destinazione').'", "name": "idsede_destinazione","value": "$idsede_destinazione$", "ajax-source": "sedi", "select-options": '.json_encode(['idanagrafica' => $record['idanagrafica']]).', "placeholder": "'.tr('Sede legale').'", "readonly": "'.$record['flag_completato'].'" ]} -
    - -
    '; - if (!empty($record['idclientefinale'])) { - echo ' - '.Modules::link('Anagrafiche', $record['idclientefinale'], null, null, 'class="pull-right"'); - } -echo ' - {[ "type": "select", "label": "'.tr('Per conto di').'", "name": "idclientefinale", "value": "$idclientefinale$", "ajax-source": "clienti", "readonly": "'.$record['flag_completato'].'" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Referente').'", "name": "idreferente", "value": "$idreferente$", "ajax-source": "referenti", "select-options": '.json_encode(['idanagrafica' => $record['idanagrafica'], 'idclientefinale' => $record['idclientefinale']]).', "readonly": "'.intval($record['flag_completato']).'" ]} -
    -
    - - -
    -
    '; -if (!empty($record['idpreventivo'])) { - echo ' - '.Modules::link('Preventivi', $record['idpreventivo'], null, null, 'class="pull-right"'); -} -echo ' - {[ "type": "select", "label": "'.tr('Preventivo').'", "name": "idpreventivo", "value": "'.$record['id_preventivo'].'", "ajax-source": "preventivi", "select-options": '.json_encode(['idanagrafica' => $record['idanagrafica']]).', "readonly": "'.$record['flag_completato'].'" ]} -
    - -
    '; - -$idcontratto_riga = $dbo->fetchOne('SELECT id FROM co_promemoria WHERE idintervento='.prepare($id_record))['id']; - -if (!empty($record['idcontratto'])) { - echo ' - '.Modules::link('Contratti', $record['idcontratto'], null, null, 'class="pull-right"'); -} -echo ' - - {[ "type": "select", "label": "'.tr('Contratto').'", "name": "idcontratto", "value": "'.$record['id_contratto'].'", "ajax-source": "contratti", "select-options": '.json_encode(['idanagrafica' => $record['idanagrafica']]).', "readonly": "'.$record['flag_completato'].'" ]} - - -
    -
    - -
    -
    '; - - $idcontratto_riga = $dbo->fetchOne('SELECT id FROM co_promemoria WHERE idintervento='.prepare($id_record))['id']; - - if (!empty($record['idordine'])) { - echo ' - '.Modules::link('Ordini cliente', $record['idordine'], null, null, 'class="pull-right"'); - } - echo ' - - {[ "type": "select", "label": "'.tr('Ordine').'", "name": "idordine", "value": "'.$record['id_ordine'].'", "ajax-source": "ordini-cliente", "select-options": '.json_encode(['idanagrafica' => $record['idanagrafica']]).', "readonly": "'.$record['flag_completato'].'" ]} -
    -
    - -
    -
    -
    '; - -$anagrafica_cliente = $intervento->anagrafica; -$sede_cliente = $anagrafica_cliente->sedeLegale; -if (!empty($intervento->idsede_destinazione)) { - $sede_cliente = Sede::find($intervento->idsede_destinazione); -} - -$anagrafica_azienda = Anagrafica::find(setting('Azienda predefinita')); -$sede_azienda = $anagrafica_azienda->sedeLegale; - -$google = setting('Google Maps API key'); - -echo ' -
    -
    -
    -

    '.tr('Geolocalizzazione').'

    -
    -
    '; - -$map_load_message = tr('Clicca per visualizzare'); -if (empty($google)) { - echo ' -
    - '.Modules::link('Impostazioni', null, tr('Per abilitare la visualizzazione delle anagrafiche nella mappa, inserire la Google Maps API Key nella scheda Impostazioni'), true, null, true, null, '&search=Google Maps API key').'. -
    '; -} elseif (!empty($sede_cliente->gaddress) || (!empty($sede_cliente->lat) && !empty($sede_cliente->lng))) { - echo ' -
    -

    '.$map_load_message.'

    -
    - -
    -
    '; - - // Navigazione diretta verso l'indirizzo - echo ' - - '.tr('Calcola percorso').' - '; -} else { - // Navigazione diretta verso l'indirizzo - echo ' - - '.tr('Calcola percorso').' - '; - - // Ricerca diretta su Google Maps - echo ' - - '.tr('Cerca su Google Maps').' - '; -} - -echo ' -
    -
    -
    -
    - - '; - -?> - -
    -
    -

    -
    - -
    - -
    -
    - {[ "type": "text", "label": "", "name": "codice", "value": "$codice$", "readonly": "" ]} -
    - -
    - {[ "type": "timestamp", "label": "", "name": "data_richiesta", "required": 1, "value": "$data_richiesta$", "readonly": "" ]} -
    - -
    - {[ "type": "timestamp", "label": "", "name": "data_scadenza", "required": 0, "value": "$data_scadenza$", "readonly": "" ]} -
    - -
    - {[ "type": "select", "label": "", "name": "idzona", "values": "query=SELECT id, CONCAT_WS( ' - ', nome, descrizione) AS descrizione FROM an_zone ORDER BY nome", "value": "$idzona$" , "placeholder": "", "extra": "readonly", "help":"." ]} -
    - -
    - - -
    -
    - {[ "type": "select", "label": "", "name": "idtipointervento", "required": 1, "ajax-source": "tipiintervento", "value": "$idtipointervento$", "readonly": "" ]} -
    - -
    - {[ "type": "select", "label": "", "name": "idstatointervento", "required": 1, "values": "query=SELECT idstatointervento AS id, descrizione, colore AS _bgcolor_ FROM in_statiintervento WHERE deleted_at IS NULL", "value": "$idstatointervento$", "class": "unblockable" ]} -
    -fetchArray('SELECT id_tecnico FROM in_interventi_tecnici_assegnati WHERE id_intervento = '.prepare($id_record)); -$tecnici_assegnati = array_column($tecnici_assegnati, 'id_tecnico'); -echo ' -
    - {[ "type": "select", "label": "'.tr('Tecnici assegnati').'", "multiple": "1", "name": "tecnici_assegnati[]", "ajax-source": "tecnici", "value": "'.implode(',', $tecnici_assegnati).'", "icon-after": "add|'.$module_anagrafiche['id'].'|tipoanagrafica=Tecnico&readonly_tipo=1" ]} -
    '; - -?> -
    - - -
    -
    - {[ "type": "ckeditor", "label": "", "name": "richiesta", "required": 1, "class": "autosize", "value": "$richiesta$", "extra": "rows='5'", "readonly": "" ]} -
    - -
    - {[ "type": "ckeditor", "label": "", "name": "descrizione", "class": "autosize", "value": "$descrizione$", "extra": "rows='10'", "readonly": "" ]} -
    -gruppo != 'Clienti') { - echo ' -
    - {[ "type": "textarea", "label": "'.tr('Note interne').'", "name": "informazioniaggiuntive", "class": "autosize", "value": "$informazioniaggiuntive$", "extra": "rows=\'5\'" ]} -
    '; - } -?> -
    -
    -
    - -fetchOne('SELECT num_item,codice_cig,codice_cup,id_documento_fe FROM co_contratti WHERE id = '.prepare($record['idcontratto'])); - $record['id_documento_fe'] = $contratto['id_documento_fe']; - $record['codice_cup'] = $contratto['codice_cup']; - $record['codice_cig'] = $contratto['codice_cig']; - $record['num_item'] = $contratto['num_item']; - } - - ?> - -
    -
    -

    - - -

    - -
    - -
    -
    -
    - {[ "type": "", "label": "", "name": "id_documento_fe", "required": 0, "help": "Obbligatorio per valorizzare CIG/CUP. È possible inserire:
    • N. determina
    • RDO
    • Ordine MEPA
    '); ?>", "value": "", "maxlength": 20, "readonly": "", "extra": "" ]} -
    - -
    - {[ "type": "", "label": "", "name": "num_item", "required": 0, "value": "", "maxlength": 15, "readonly": "", "extra": "" ]} -
    -
    -
    -
    - {[ "type": "", "label": "", "name": "codice_cig", "required": 0, "value": "", "maxlength": 15, "readonly": "", "extra": "" ]} -
    - -
    - {[ "type": "", "label": "", "name": "codice_cup", "required": 0, "value": "", "maxlength": 15, "readonly": "", "extra": "" ]} -
    -
    -
    -
    - - - -
    -
    -

    -
    - -
    - - - -
    -
    -
    "; - } - ?> - -
    -
    -
    -
    - - - -
    -
    -

    -
    - -
    -
    -
    - - 0)'; - $preventivi = $dbo->fetchArray($prev_query)[0]['tot']; - echo ' - '; - - // Lettura contratti accettati, in attesa di conferma o in lavorazione - $contr_query = 'SELECT COUNT(*) AS tot FROM co_contratti WHERE idanagrafica='.prepare($record['idanagrafica']).' AND idstato IN( SELECT id FROM co_staticontratti WHERE is_fatturabile = 1) AND co_contratti.id IN (SELECT idcontratto FROM co_righe_contratti WHERE co_righe_contratti.idcontratto = co_contratti.id AND (qta - qta_evasa) > 0)'; - $contratti = $dbo->fetchArray($contr_query)[0]['tot']; - echo ' - '; - - // Lettura ddt (entrata o uscita) - $ddt_query = 'SELECT COUNT(*) AS tot FROM dt_ddt - LEFT JOIN `dt_causalet` ON `dt_causalet`.`id` = `dt_ddt`.`idcausalet` - LEFT JOIN `dt_statiddt` ON `dt_statiddt`.`id` = `dt_ddt`.`idstatoddt` - LEFT JOIN `dt_tipiddt` ON `dt_tipiddt`.`id` = `dt_ddt`.`idtipoddt` - WHERE idanagrafica='.prepare($record['idanagrafica']).' - AND `dt_statiddt`.`descrizione` IN (\'Evaso\', \'Parzialmente evaso\', \'Parzialmente fatturato\') - AND `dt_tipiddt`.`dir` = '.prepare($intervento->direzione).' - AND `dt_causalet`.`is_importabile` = 1 - AND dt_ddt.id IN (SELECT idddt FROM dt_righe_ddt WHERE dt_righe_ddt.idddt = dt_ddt.id AND (qta - qta_evasa) > 0)'; - $ddt = $dbo->fetchArray($ddt_query)[0]['tot']; - echo ' -
    - -
    '; - - echo ' - '; - - echo ' - '; - - echo ' - '; - - /* - echo ' - ';*/ - - echo ' - '; -} - -// Conteggio numero articoli intervento per eventuale blocco della sede di partenza -$articoli = $intervento->articoli; - -?> -
    - -
    - {[ "type": "select", "label": "", "name": "idsede_partenza", "ajax-source": "sedi_azienda", "value": "$idsede_partenza$", "readonly": "isEmpty()) ? 1 : 0; ?>" ]} -
    -
    - -
    -
    -
    -
    -
    - - -
    -
    -

    -
    - -
    -
    -
    -
    -
    -
    -
    - -{( "name": "filelist_and_upload", "id_module": "$id_module$", "id_record": "$id_record$", )} - - -
    -
    - '.tr('Questo intervento non è ancora stato firmato dal cliente').'.
    '; - } else { - echo ' -
     
    -
    '.tr('Firmato il _DATE_ alle _TIME_ da _PERSON_', [ - '_DATE_' => Translator::dateToLocale($record['firma_data']), - '_TIME_' => Translator::timeToLocale($record['firma_data']), - '_PERSON_' => ''.$record['firma_nome'].'', - ]).'
    '; - } - - echo ' -
    - - -{( "name": "log_email", "id_module": "$id_module$", "id_record": "$id_record$" )} - -'; - -// Collegamenti diretti -// Fatture collegate a questo intervento -$elementi = $dbo->fetchArray('SELECT `co_documenti`.*, `co_tipidocumento`.`descrizione` AS tipo_documento, `co_statidocumento`.`descrizione` AS stato_documento, `co_tipidocumento`.`dir` FROM `co_documenti` JOIN `co_tipidocumento` ON `co_tipidocumento`.`id` = `co_documenti`.`idtipodocumento` JOIN `co_statidocumento` ON `co_statidocumento`.`id` = `co_documenti`.`idstatodocumento` WHERE `co_documenti`.`id` IN (SELECT `iddocumento` FROM `co_righe_documenti` WHERE `idintervento` = '.prepare($id_record).') ORDER BY `data`'); - -if (!empty($elementi)) { - echo ' -
    -
    -

    '.tr('Documenti collegati: _NUM_', [ - '_NUM_' => count($elementi), - ]).'

    -
    - -
    -
    -
    -
      '; - - foreach ($elementi as $fattura) { - $descrizione = tr('_DOC_ num. _NUM_ del _DATE_ [_STATE_]', [ - '_DOC_' => $fattura['tipo_documento'], - '_NUM_' => !empty($fattura['numero_esterno']) ? $fattura['numero_esterno'] : $fattura['numero'], - '_DATE_' => Translator::dateToLocale($fattura['data']), - '_STATE_' => $fattura['stato_documento'], - ]); - - $modulo = ($fattura['dir'] == 'entrata') ? 'Fatture di vendita' : 'Fatture di acquisto'; - $id = $fattura['id']; - - echo ' -
    • '.Modules::link($modulo, $id, $descrizione).'
    • '; - } - - echo ' -
    -
    -
    '; -} - -if (!empty($elementi)) { - echo ' -
    - '.tr('Eliminando questo documento si potrebbero verificare problemi nelle altre sezioni del gestionale').'. -
    '; -} - -?> - - - - diff --git a/modules/interventi/init.php b/modules/interventi/init.php deleted file mode 100755 index 5aebcfe74..000000000 --- a/modules/interventi/init.php +++ /dev/null @@ -1,36 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Interventi\Intervento; - -if (isset($id_record)) { - $intervento = Intervento::find($id_record); - - $record = $dbo->fetchOne('SELECT *, - (SELECT tipo FROM an_anagrafiche WHERE idanagrafica = in_interventi.idanagrafica) AS tipo_anagrafica, - (SELECT is_completato FROM in_statiintervento WHERE idstatointervento=in_interventi.idstatointervento) AS flag_completato, - IF((in_interventi.idsede_destinazione = 0), (SELECT idzona FROM an_anagrafiche WHERE idanagrafica = in_interventi.idanagrafica), (SELECT idzona FROM an_sedi WHERE id = in_interventi.idsede_destinazione)) AS idzona, - (SELECT colore FROM in_statiintervento WHERE idstatointervento=in_interventi.idstatointervento) AS colore, - in_interventi.id_preventivo as idpreventivo, - in_interventi.id_contratto as idcontratto, - in_interventi.id_ordine as idordine - FROM in_interventi WHERE id='.prepare($id_record)); -} diff --git a/modules/interventi/modals/anteprima_firma.php b/modules/interventi/modals/anteprima_firma.php deleted file mode 100644 index 0e3df6251..000000000 --- a/modules/interventi/modals/anteprima_firma.php +++ /dev/null @@ -1,130 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -if (get('anteprima') !== null) { - // Lettura dati intervento - $query = 'SELECT codice FROM in_interventi WHERE id='.prepare($id_record); - $rs = $dbo->fetchArray($query); - - if (empty($rs)) { - echo tr('Intervento inesistente!'); - exit(); - } - - // Gestione della stampa - $directory = base_dir().'/files/interventi/'; - $id_print = setting('Stampa per anteprima e firma'); - - // HTML per la visualizzazione - echo ' -
    - -
    - -
    - - -
    '; -} - -?> -
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "firma_nome", "required": 1 ]} -
    -
    -
    -
    -
    - - -
    -
    -
    -
    -
    -
    - -
    -
    - -
    -
    - -
    -
    - - diff --git a/modules/interventi/modals/copy_sessione.php b/modules/interventi/modals/copy_sessione.php deleted file mode 100644 index fe7502deb..000000000 --- a/modules/interventi/modals/copy_sessione.php +++ /dev/null @@ -1,73 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; -include_once __DIR__.'/../../../../core.php'; - -$sessione = $dbo->fetchOne('SELECT in_interventi_tecnici.*, an_anagrafiche.ragione_sociale, an_anagrafiche.deleted_at, in_interventi_tecnici.tipo_scontokm AS tipo_sconto_km, in_interventi_tecnici.prezzo_ore_unitario, in_interventi_tecnici.prezzo_km_unitario, in_interventi_tecnici.prezzo_dirittochiamata FROM in_interventi_tecnici INNER JOIN an_anagrafiche ON in_interventi_tecnici.idtecnico = an_anagrafiche.idanagrafica WHERE in_interventi_tecnici.id = '.prepare(get('id_sessione'))); - -$op = 'add_sessione'; -$button = ' '.tr('Aggiungi'); - -echo ' -
    - - '; - -// Tecnico -echo ' -
    -
    - {[ "type": "select", "label": "'.tr('Tecnico').'", "name": "id_tecnico", "required": 1, "ajax-source": "tecnici" ]} -
    '; - -// Orari -echo ' -
    - {[ "type": "timestamp", "label": "'.tr('Inizio attività').'", "name": "orario_inizio", "required": 1, "value": "'.$sessione['orario_inizio'].'" ]} -
    - -
    - {[ "type": "timestamp", "label": "'.tr('Fine attività').'", "name": "orario_fine", "required": 1, "value": "'.$sessione['orario_fine'].'" ]} -
    -
    '; - -echo ' - - -
    -
    - -
    -
    -
    '; - -echo ' -'; - -echo ' -'; diff --git a/modules/interventi/modals/duplicazione.php b/modules/interventi/modals/duplicazione.php deleted file mode 100644 index 3d14ad67a..000000000 --- a/modules/interventi/modals/duplicazione.php +++ /dev/null @@ -1,62 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -echo ' -
    - - - -
    -
    - {[ "type": "timestamp", "label": "'.tr('Data/ora richiesta').'", "name": "data_richiesta", "value": "-now-", "required":1 ]} -
    - -
    - {[ "type": "timestamp", "label": "'.tr('Data/ora scadenza').'", "name": "data_scadenza" ]} -
    -
    - -
    -
    - {[ "type": "select", "label": "'.tr('Stato').'", "name": "id_stato", "required": 1, "values": "query=SELECT idstatointervento AS id, descrizione, colore AS _bgcolor_ FROM in_statiintervento WHERE deleted_at IS NULL", "value": "" ]} -
    - -
    - {["type": "checkbox", "label": "'.tr('Duplica righe').'", "name": "copia_righe", "help": "'.tr('Selezione per riportare anche le righe nella nuova attività').'", "value": 1 ]} -
    - -
    - {["type": "checkbox", "label": "'.tr('Duplica sessioni').'", "name": "copia_sessioni", "help": "'.tr('Selezione per riportare anche le sessioni di lavoro nella nuova attività').'", "value": 1 ]} -
    -
    - - -
    -
    - -
    -
    -
    '; - -echo ' -'; diff --git a/modules/interventi/modals/manage_sessione.php b/modules/interventi/modals/manage_sessione.php deleted file mode 100644 index 5849fa711..000000000 --- a/modules/interventi/modals/manage_sessione.php +++ /dev/null @@ -1,137 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; -include_once __DIR__.'/../../../../core.php'; - -$show_costi = true; -// Limitazione delle azioni dei tecnici -if ($user['gruppo'] == 'Tecnici') { - $show_costi = !empty($user['idanagrafica']) && setting('Mostra i prezzi al tecnico'); -} - -$sessione = $dbo->fetchOne('SELECT in_interventi_tecnici.*, an_anagrafiche.ragione_sociale, an_anagrafiche.deleted_at, in_interventi_tecnici.tipo_scontokm AS tipo_sconto_km, in_interventi_tecnici.prezzo_ore_unitario, in_interventi_tecnici.prezzo_km_unitario, in_interventi_tecnici.prezzo_dirittochiamata FROM in_interventi_tecnici INNER JOIN an_anagrafiche ON in_interventi_tecnici.idtecnico = an_anagrafiche.idanagrafica WHERE in_interventi_tecnici.id = '.prepare(get('id_sessione'))); - -$op = 'edit_sessione'; -$button = ' '.tr('Modifica'); - -echo ' -
    - - - - '; - -// Tecnico -echo ' -
    -
    - {[ "type": "span", "label": "'.tr('Tecnico').'", "name": "tecnico", "required": 0, "value": "'.$sessione['ragione_sociale'].' '.(!empty($sessione['deleted_at']) ? '('.tr('Eliminato').')' : '').'" ]} -
    -
    '; - -// Orari -echo ' -
    -
    - {[ "type": "select", "label": "'.tr('Tipo attività').'", "name": "idtipointerventot", "value": "'.$sessione['idtipointervento'].'", "required": 1, "values": "query=SELECT in_tipiintervento.idtipointervento AS id, descrizione, in_tariffe.costo_ore AS prezzo_ore_unitario, in_tariffe.costo_km AS prezzo_km_unitario, in_tariffe.costo_dirittochiamata AS prezzo_dirittochiamata FROM in_tipiintervento JOIN in_tariffe ON in_tipiintervento.idtipointervento = in_tariffe.idtipointervento WHERE in_tariffe.idtecnico = '.prepare($sessione['idtecnico']).' ORDER BY descrizione" ]} -
    - -
    - {[ "type": "timestamp", "label": "'.tr('Inizio attività').'", "name": "orario_inizio", "required": 1, "value": "'.$sessione['orario_inizio'].'" ]} -
    - -
    - {[ "type": "timestamp", "label": "'.tr('Fine attività').'", "name": "orario_fine", "required": 1, "value": "'.$sessione['orario_fine'].'" ]} -
    -
    '; - - echo ' -
    '; - - // Km - echo ' -
    - {[ "type": "number", "label": "'.tr('Km').'", "name": "km", "value": "'.$sessione['km'].'"]} -
    '; - - $class = $show_costi ? '' : 'hide'; - - // Sconto ore - echo ' -
    - {[ "type": "number", "label": "'.tr('Sconto ore').'", "name": "sconto", "value": "'.$sessione['sconto_unitario'].'", "icon-after": "choice|untprc|'.$sessione['tipo_sconto'].'"]} -
    '; - - // Sconto km - echo ' -
    - {[ "type": "number", "label": "'.tr('Sconto km').'", "name": "sconto_km", "value": "'.$sessione['scontokm_unitario'].'", "icon-after": "choice|untprc|'.$sessione['tipo_sconto_km'].'"]} -
    '; - - echo ' -
    - -
    -
    - {[ "type": "number", "label": "'.tr('Addebito orario').'", "name": "prezzo_ore_unitario", "value": "'.$sessione['prezzo_ore_unitario'].'" ]} -
    - -
    - {[ "type": "number", "label": "'.tr('Addebito km').'", "name": "prezzo_km_unitario", "value": "'.$sessione['prezzo_km_unitario'].'" ]} -
    - -
    - {[ "type": "number", "label": "'.tr('Addebito diritto ch.').'", "name": "prezzo_dirittochiamata", "value": "'.$sessione['prezzo_dirittochiamata'].'" ]} -
    '; - - echo ' -
    '; - -echo ' - - -
    -
    - -
    -
    -
    '; - -echo ' -'; - -echo ' -'; diff --git a/modules/interventi/modutil.php b/modules/interventi/modutil.php deleted file mode 100755 index e6afbe9d8..000000000 --- a/modules/interventi/modutil.php +++ /dev/null @@ -1,338 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Anagrafiche\Anagrafica; -use Modules\Articoli\Articolo as ArticoloOriginale; -use Modules\Emails\Mail; -use Modules\Emails\Template; -use Modules\Fatture\Components\Descrizione; -use Modules\Fatture\Components\Riga; -use Modules\Fatture\Fattura; -use Modules\Interventi\Components\Sessione; -use Modules\Interventi\Intervento; -use Util\Generator; -use Util\Ini; - -/** - * Recupera il totale delle ore spese per un intervento. - * - * @param int $id_intervento - * - * @deprecated - */ -function get_ore_intervento($id_intervento) -{ - $intervento = Intervento::find($id_intervento); - - return $intervento->ore_totali; -} - -/** - * Funzione per collegare gli articoli, usati in un intervento, ai rispettivi impianti. - * - * @param int $id_intervento - * @param int $id_impianto - * @param int $id_articolo - * @param int $qta - */ -function link_componente_to_articolo($id_intervento, $id_impianto, $id_articolo, $qta) -{ - if (empty($id_impianto) || empty($id_intervento)) { - return; - } - - $dbo = database(); - $intervento = Intervento::find($id_intervento); - - // Data di inizio dell'intervento (data_richiesta in caso di assenza di sessioni) - $data = $intervento->inizio ?: $intervento->data_richiesta; - - // Se l'articolo aggiunto è collegato a un componente, aggiungo il componente all'impianto selezionato - $componente_articolo = $dbo->fetchOne('SELECT componente_filename, contenuto FROM mg_articoli WHERE id = '.prepare($id_articolo)); - if (!empty($componente_articolo) && !empty($componente_articolo['componente_filename'])) { - $contenuto_ini = Ini::read($componente_articolo['contenuto']); - $nome_componente = Ini::getValue($contenuto_ini, 'Nome'); - - $dati = [ - 'idimpianto' => $id_impianto, - 'idintervento' => $id_intervento, - 'nome' => $nome_componente, - 'data' => $data, - 'filename' => $componente_articolo['componente_filename'], - 'contenuto' => $componente_articolo['contenuto'], - ]; - - // Inserisco il componente tante volte quante la quantità degli articoli inseriti - for ($q = 0; $q < $qta; ++$q) { - $dbo->insert('my_impianto_componenti', $dati); - } - } -} - -function add_tecnico($id_intervento, $idtecnico, $inizio, $fine, $idcontratto = null) -{ - $intervento = Intervento::find($id_intervento); - $anagrafica = Anagrafica::find($idtecnico); - - $sessione = Sessione::build($intervento, $anagrafica, $inizio, $fine); - - // Notifica nuovo intervento al tecnico - if (setting('Notifica al tecnico l\'assegnazione all\'attività')) { - if (!empty($anagrafica['email'])) { - $template = Template::pool('Notifica intervento'); - - if (!empty($template)) { - $mail = Mail::build(auth()->getUser(), $template, $id_intervento); - $mail->addReceiver($anagrafica['email']); - $mail->save(); - } - } - } - - return true; -} - -/** - * Calcola le ore presenti tra due date. - * - * @param string $orario_inizio - * @param string $orario_fine - * - * @return float - * - * @deprecated - */ -function calcola_ore_intervento($orario_inizio, $orario_fine) -{ - $inizio = new DateTime($orario_inizio); - $diff = $inizio->diff(new DateTime($orario_fine)); - - $ore = $diff->i / 60 + $diff->h + ($diff->days * 24); - - return $ore; -} - -function aggiungi_intervento_in_fattura($id_intervento, $id_fattura, $descrizione, $id_iva, $id_conto, $id_rivalsa_inps = false, $id_ritenuta_acconto = false, $calcolo_ritenuta_acconto = false) -{ - $dbo = database(); - - $id_rivalsa_inps = $id_rivalsa_inps !== false ? $id_rivalsa_inps : setting('Percentuale rivalsa'); - $id_ritenuta_acconto = $id_ritenuta_acconto !== false ? $id_ritenuta_acconto : setting("Percentuale ritenuta d'acconto"); - $calcolo_ritenuta_acconto = $calcolo_ritenuta_acconto !== false ? $calcolo_ritenuta_acconto : setting("Metodologia calcolo ritenuta d'acconto predefinito"); - - $fattura = Fattura::find($id_fattura); - $intervento = Intervento::find($id_intervento); - - if (!empty($fattura->anagrafica->idiva_vendite)) { - $id_iva = $fattura->anagrafica->idiva_vendite; - } - - $data = $intervento->fine; - $codice = $intervento->codice; - - // Riga di descrizione - $riga = Descrizione::build($fattura); - $riga->descrizione = $descrizione; - $riga->idintervento = $id_intervento; - $riga->save(); - - // Ore di lavoro raggruppate per costo orario - $sessioni = $intervento->sessioni; - - if (empty($sessioni)) { - flash()->warning(tr("L'attività _NUM_ non ha sessioni di lavoro!", [ - '_NUM_' => $codice, - ])); - } else { - $decimals = setting('Cifre decimali per quantità'); - - $ore_di_lavoro = $sessioni->groupBy(function ($item, $key) { - return $item['prezzo_orario'].'|'.$item['sconto_unitario'].'|'.$item['tipo_sconto']; - }); - foreach ($ore_di_lavoro as $gruppo) { - $sessione = $gruppo->first(); - $riga = Riga::build($fattura); - - $riga->descrizione = tr("Ore di lavoro dell'attività _NUM_ del _DATE_", [ - '_NUM_' => $codice, - '_DATE_' => dateFormat($data), - ]); - $riga->idintervento = $id_intervento; - $riga->um = 'ore'; - - $riga->id_iva = $id_iva; - $riga->idconto = $id_conto; - - $riga->calcolo_ritenuta_acconto = $calcolo_ritenuta_acconto; - $riga->id_ritenuta_acconto = $id_ritenuta_acconto; - $riga->id_rivalsa_inps = $id_rivalsa_inps; - - $riga->prezzo_unitario = $sessione->prezzo_orario; - $riga->setSconto($sessione->sconto_unitario, $sessione->tipo_sconto); - - $qta_gruppo = $gruppo->sum('ore'); - $riga->qta = round($qta_gruppo, $decimals); - - $riga->save(); - } - - // Diritti di chiamata raggruppati per costo - $diritti_chiamata = $sessioni->where('prezzo_diritto_chiamata', '>', 0)->groupBy(function ($item, $key) { - return $item['prezzo_diritto_chiamata']; - }); - foreach ($diritti_chiamata as $gruppo) { - $diritto_chiamata = $gruppo->first(); - $riga = Riga::build($fattura); - - $riga->descrizione = tr("Diritto di chiamata dell'attività _NUM_ del _DATE_", [ - '_NUM_' => $codice, - '_DATE_' => dateFormat($data), - ]); - $riga->idintervento = $id_intervento; - //$riga->um = 'ore'; - - $riga->id_iva = $id_iva; - $riga->idconto = $id_conto; - - $riga->calcolo_ritenuta_acconto = $calcolo_ritenuta_acconto; - $riga->id_ritenuta_acconto = $id_ritenuta_acconto; - $riga->id_rivalsa_inps = $id_rivalsa_inps; - - $riga->prezzo_unitario = $diritto_chiamata->prezzo_diritto_chiamata; - - $riga->qta = $gruppo->count(); - - $riga->save(); - } - - // Viaggi raggruppati per costo - $viaggi = $sessioni->where('prezzo_km_unitario', '>', 0)->groupBy(function ($item, $key) { - return $item['prezzo_km_unitario'].'|'.$item['scontokm_unitario'].'|'.$item['tipo_scontokm']; - }); - foreach ($viaggi as $gruppo) { - $qta_trasferta = $gruppo->sum('km'); - if ($qta_trasferta == 0) { - continue; - } - - $viaggio = $gruppo->first(); - $riga = Riga::build($fattura); - - $riga->descrizione = tr("Trasferta dell'attività _NUM_ del _DATE_", [ - '_NUM_' => $codice, - '_DATE_' => dateFormat($data), - ]); - $riga->idintervento = $id_intervento; - $riga->um = 'km'; - - $riga->id_iva = $id_iva; - $riga->idconto = $id_conto; - - $riga->calcolo_ritenuta_acconto = $calcolo_ritenuta_acconto; - $riga->id_ritenuta_acconto = $id_ritenuta_acconto; - $riga->id_rivalsa_inps = $id_rivalsa_inps; - - $riga->prezzo_unitario = $viaggio->prezzo_km_unitario; - $riga->setSconto($viaggio->scontokm_unitario, $viaggio->tipo_scontokm); - - $riga->qta = $qta_trasferta; - - $riga->save(); - } - } - - // Articoli, righe, sconti e descrizioni collegati all'intervento - $righe = $intervento->getRighe(); - foreach ($righe as $riga) { - $qta = $riga->qta; - - $copia = $riga->copiaIn($fattura, $qta); - - $copia->id_conto = $id_conto; - - $copia->calcolo_ritenuta_acconto = $calcolo_ritenuta_acconto; - $copia->id_ritenuta_acconto = $id_ritenuta_acconto; - $copia->id_rivalsa_inps = $id_rivalsa_inps; - - // Aggiornamento seriali dalla riga dell'ordine - if ($copia->isArticolo()) { - $copia->serials = $riga->serials; - $articolo = ArticoloOriginale::find($copia->idarticolo); - $copia->id_conto = ($articolo->idconto_vendita ? $articolo->idconto_vendita : $id_conto); - } - - $copia->save(); - } - - // Ricalcolo inps, ritenuta e bollo - ricalcola_costiagg_fattura($id_fattura); - - // Metto l'intervento in stato "Fatturato" - $dbo->query("UPDATE in_interventi SET idstatointervento=(SELECT idstatointervento FROM in_statiintervento WHERE codice='FAT') WHERE id=".prepare($id_intervento)); -} - -/** - * Verifica che il numero_esterno della fattura indicata sia correttamente impostato, a partire dai valori delle fatture ai giorni precedenti. - * Restituisce il numero_esterno mancante in caso di numero errato. - * - * @return bool|string - */ -function verifica_numero_intervento(Intervento $intervento) -{ - if (empty($intervento->codice)) { - return null; - } - - $data = $intervento->data_richiesta; - $documenti = Intervento::whereDate('data_richiesta', '=', $data->format('Y-m-d')) - ->get(); - - // Recupero maschera per questo segmento - $maschera = setting('Formato codice attività'); - - if ((strpos($maschera, 'YYYY') !== false) or (strpos($maschera, 'yy') !== false)) { - $ultimo = Generator::getPreviousFrom($maschera, 'in_interventi', 'codice', [ - 'DATE(data_richiesta) < '.prepare($data->format('Y-m-d')), - 'YEAR(data_richiesta) = '.prepare($data->format('Y')), - ], $data); - } else { - $ultimo = Generator::getPreviousFrom($maschera, 'in_interventi', 'codice', [ - 'DATE(data_richiesta) < '.prepare($data->format('Y-m-d')), - ]); - } - - do { - $numero = Generator::generate($maschera, $ultimo, 1, Generator::dateToPattern($data), $data); - - $filtered = $documenti->reject(function ($item, $key) use ($numero) { - return $item->codice == $numero; - }); - - if ($documenti->count() == $filtered->count()) { - return $numero; - } - - $documenti = $filtered; - $ultimo = $numero; - } while ($numero != $intervento->codice); - - return null; -} diff --git a/modules/interventi/occupazione_tecnici.php b/modules/interventi/occupazione_tecnici.php deleted file mode 100644 index 11df74c0d..000000000 --- a/modules/interventi/occupazione_tecnici.php +++ /dev/null @@ -1,139 +0,0 @@ -. - */ - -use Modules\Interventi\Intervento; - -include_once __DIR__.'/../../core.php'; - -$tecnici = []; -if (!empty($id_record)) { - $documento = Intervento::find($id_record); - $sessioni = $documento->sessioni; - - foreach ($sessioni as $sessione) { - $id_tecnico = $sessione->idtecnico; - $inizio = $sessione->orario_inizio; - $fine = $sessione->orario_fine; - if (!isset($tecnici[$id_tecnico])) { - $tecnici[$id_tecnico] = []; - } - - $tecnici[$id_tecnico][] = [ - 'inizio' => $inizio, - 'fine' => $fine, - ]; - } -} - -// Lettura dei dati da URL -$tecnici_selezionati = filter('tecnici'); -if (!empty($tecnici_selezionati)) { - $inizio = filter('inizio'); - $fine = filter('fine'); - - foreach ($tecnici_selezionati as $id_tecnico) { - if (empty($id_tecnico)) { - continue; - } - - if (!isset($tecnici[$id_tecnico])) { - $tecnici[$id_tecnico] = []; - } - - $tecnici[$id_tecnico][] = [ - 'inizio' => $inizio, - 'fine' => $fine, - ]; - } -} - -// Blocco dei controlli se non sono presenti tecnici -if (empty($tecnici) || setting('Alert occupazione tecnici') != 1) { - return; -} - -// Individuazione dei conflitti con altri interventi -$elenco_conflitti = []; -foreach ($tecnici as $id_tecnico => $ore) { - $query = 'SELECT idintervento, orario_inizio, orario_fine FROM in_interventi_tecnici WHERE idtecnico = '.prepare($id_tecnico).($id_record ? ' AND idintervento != '.prepare($id_record) : ''); - - // Conflitti ristretti per orario - foreach ($ore as $orario) { - $query_conflitto = $query.' AND ((orario_inizio > '.prepare($orario['inizio']).' AND orario_inizio < '.prepare($orario['fine']).') OR - (orario_fine > '.prepare($orario['inizio']).' AND orario_fine < '.prepare($orario['fine']).') OR - (orario_inizio < '.prepare($orario['inizio']).' AND orario_fine > '.prepare($orario['inizio']).') OR - (orario_inizio < '.prepare($orario['fine']).' AND orario_fine > '.prepare($orario['fine']).'))'; - - $conflitto = $database->fetchArray($query_conflitto); - if (!empty($conflitto)) { - $elenco_conflitti[$id_tecnico][] = [ - 'inizio' => $orario['inizio'], - 'fine' => $orario['fine'], - 'conflitti' => $conflitto, - ]; - } - } -} - -if (empty($elenco_conflitti)) { - return; -} - -echo ' -
    -

    '.tr('Sono presenti dei conflitti con le sessioni di lavoro di alcuni tecnici').'.

    - - - - - - - - - - - '; - -foreach ($elenco_conflitti as $id_tecnico => $elenco_conflitti_tecnico) { - $anagrafica_tecnico = $database->fetchOne('SELECT ragione_sociale, deleted_at FROM an_anagrafiche WHERE idanagrafica = '.prepare($id_tecnico)); - - foreach ($elenco_conflitti_tecnico as $conflitto) { - echo ' - - - - - '; - - foreach ($conflitto['conflitti'] as $conflitto_intervento) { - $intervento = Intervento::find($conflitto_intervento['idintervento']); - echo ' - - - - - '; - } - } -} - -echo ' - -
    '.tr('Tecnico').''.tr('Attività').''.tr('Orario di conflitto').'
    '.$anagrafica_tecnico['ragione_sociale'].' '.(!empty($anagrafica_tecnico['deleted_at']) ? '('.tr('Eliminato').')' : '').''.timestampFormat($conflitto['inizio']).' - '.timestampFormat($conflitto['fine']).'
    '.$anagrafica_tecnico['ragione_sociale'].' '.(!empty($anagrafica_tecnico['deleted_at']) ? '('.tr('Eliminato').')' : '').''.Modules::link('Interventi', $intervento->id, $intervento->getReference()).''.timestampFormat($conflitto_intervento['orario_inizio']).' - '.timestampFormat($conflitto_intervento['orario_fine']).'
    -
    '; diff --git a/modules/interventi/plugins/my_impianti.interventi.php b/modules/interventi/plugins/my_impianti.interventi.php deleted file mode 100755 index 05160a8df..000000000 --- a/modules/interventi/plugins/my_impianti.interventi.php +++ /dev/null @@ -1,76 +0,0 @@ -. - */ - -use Modules\Interventi\Intervento; - -include_once __DIR__.'/../../../core.php'; - -// INTERVENTI ESEGUITI SU QUESTO IMPIANTO -echo ' -
    -
    -

    '.tr('Interventi eseguiti su questo impianto').'

    -
    -
    '; - -$results = $dbo->fetchArray('SELECT in_interventi.id, in_interventi.codice, descrizione, (SELECT MIN(orario_inizio) FROM in_interventi_tecnici WHERE idintervento=my_impianti_interventi.idintervento) AS data FROM my_impianti_interventi INNER JOIN in_interventi ON my_impianti_interventi.idintervento=in_interventi.id WHERE idimpianto='.prepare($id_record).' ORDER BY data DESC'); -$totale_interventi = 0; - -if (!empty($results)) { - echo ' - - - - - - '; - - foreach ($results as $result) { - $intervento = Intervento::find($result['id']); - $totale_interventi += $intervento->totale; - - echo ' - - - - - '; - } - - echo ' - - - '; - - echo ' -
    '.tr('Intervento').''.tr('Descrizione').''.tr('Costo totale').'
    - '.Modules::link('Interventi', $result['id'], $intervento->getReference()).' - '.nl2br($result['descrizione']).''.moneyFormat($intervento->totale).'
    - '.tr('Totale').': - - '.moneyFormat($totale_interventi).' -
    '; -} else { - echo ' -
    '.tr('Nessun intervento su questo impianto').'.
    '; -} - -echo ' -
    -
    '; diff --git a/modules/interventi/row-add.php b/modules/interventi/row-add.php deleted file mode 100755 index 4bdc0b18b..000000000 --- a/modules/interventi/row-add.php +++ /dev/null @@ -1,96 +0,0 @@ -. - */ - -use Modules\Interventi\Intervento; - -include_once __DIR__.'/../../core.php'; - -$documento = Intervento::find($id_record); -$show_prezzi = Auth::user()['gruppo'] != 'Tecnici' || (Auth::user()['gruppo'] == 'Tecnici' && setting('Mostra i prezzi al tecnico')); - -// Impostazioni per la gestione -$options = [ - 'op' => 'manage_riga', - 'action' => 'add', - 'dir' => $documento->direzione, - 'idanagrafica' => $documento['idanagrafica'], - 'totale_imponibile_documento' => $documento->totale_imponibile, - 'totale_documento' => $documento->totale, - 'nascondi_prezzi' => !$show_prezzi, - 'idsede_partenza' => $documento->idsede_partenza, - 'select-options' => [ - 'articoli' => [ - 'idanagrafica' => $documento->idanagrafica, - 'dir' => $documento->direzione, - 'idsede_partenza' => $documento->idsede_partenza, - 'idsede_destinazione' => $documento->idsede_destinazione, - 'permetti_movimento_a_zero' => 0, - ], - 'impianti' => [ - 'idintervento' => $documento->id, - ], - ], -]; - -// Dati di default -$result = [ - 'descrizione' => '', - 'qta' => 1, - 'um' => '', - 'prezzo' => 0, - 'sconto_unitario' => 0, - 'tipo_sconto' => '', - 'idiva' => '', - 'idconto' => $idconto, - 'ritenuta_contributi' => true, -]; - -// Leggo l'iva predefinita per l'anagrafica e se non c'è leggo quella predefinita generica -$iva = $dbo->fetchArray('SELECT idiva_vendite AS idiva FROM an_anagrafiche WHERE idanagrafica='.prepare($documento['idanagrafica'])); -$result['idiva'] = $iva[0]['idiva'] ?: setting('Iva predefinita'); - -// Importazione della gestione dedicata -$file = 'riga'; -if (get('is_descrizione') !== null) { - $file = 'descrizione'; - - $options['op'] = 'manage_descrizione'; -} elseif (get('is_articolo') !== null) { - $file = 'articolo'; - - // Aggiunta sconto di default da listino per le vendite - $listino = $dbo->fetchOne('SELECT prc_guadagno FROM an_anagrafiche INNER JOIN mg_listini ON an_anagrafiche.idlistino_vendite=mg_listini.id WHERE idanagrafica='.prepare($documento['idanagrafica'])); - - if (!empty($listino['prc_guadagno'])) { - $result['sconto_percentuale'] = $listino['prc_guadagno']; - $result['tipo_sconto'] = 'PRC'; - } - - $options['op'] = 'manage_articolo'; -} elseif (get('is_sconto') !== null) { - $file = 'sconto'; - - $options['op'] = 'manage_sconto'; -} elseif (get('is_barcode') !== null) { - $file = 'barcode'; - - $options['op'] = 'manage_barcode'; -} - -echo App::load($file.'.php', $result, $options); diff --git a/modules/interventi/row-edit.php b/modules/interventi/row-edit.php deleted file mode 100755 index 528578075..000000000 --- a/modules/interventi/row-edit.php +++ /dev/null @@ -1,74 +0,0 @@ -. - */ - -use Modules\Interventi\Intervento; - -include_once __DIR__.'/../../core.php'; - -$documento = Intervento::find($id_record); -$show_prezzi = Auth::user()['gruppo'] != 'Tecnici' || (Auth::user()['gruppo'] == 'Tecnici' && setting('Mostra i prezzi al tecnico')); - -// Impostazioni per la gestione -$options = [ - 'op' => 'manage_riga', - 'action' => 'edit', - 'dir' => $documento->direzione, - 'idanagrafica' => $documento['idanagrafica'], - 'totale_imponibile_documento' => $documento->totale_imponibile, - 'totale_documento' => $documento->totale, - 'nascondi_prezzi' => !$show_prezzi, - 'select-options' => [ - 'articoli' => [ - 'idanagrafica' => $documento->idanagrafica, - 'dir' => $documento->direzione, - 'idsede_partenza' => $documento->idsede_partenza, - 'idsede_destinazione' => $documento->idsede_destinazione, - 'permetti_movimento_a_zero' => 0, - ], - 'impianti' => [ - 'idintervento' => $documento->id, - ], - ], -]; - -// Dati della riga -$id_riga = get('riga_id'); -$type = get('riga_type'); -$riga = $documento->getRiga($type, $id_riga); - -$result = $riga->toArray(); -$result['prezzo'] = $riga->prezzo_unitario; - -// Importazione della gestione dedicata -$file = 'riga'; -if ($riga->isDescrizione()) { - $file = 'descrizione'; - - $options['op'] = 'manage_descrizione'; -} elseif ($riga->isArticolo()) { - $file = 'articolo'; - - $options['op'] = 'manage_articolo'; -} elseif ($riga->isSconto()) { - $file = 'sconto'; - - $options['op'] = 'manage_sconto'; -} - -echo App::load($file.'.php', $result, $options); diff --git a/modules/interventi/row-list.php b/modules/interventi/row-list.php deleted file mode 100755 index 2156a297d..000000000 --- a/modules/interventi/row-list.php +++ /dev/null @@ -1,237 +0,0 @@ -. - */ - -include_once __DIR__.'/init.php'; - -$show_prezzi = Auth::user()['gruppo'] != 'Tecnici' || (Auth::user()['gruppo'] == 'Tecnici' && setting('Mostra i prezzi al tecnico')); - -$righe = $intervento->getRighe(); -if (!$righe->isEmpty()) { - echo ' -
    - - - - - '; - - if ($show_prezzi) { - echo ' - - - - '; - } - - if (!$record['flag_completato']) { - echo ' - '; - } - echo ' - - - - '; - - foreach ($righe as $riga) { - $extra = ''; - $mancanti = $riga->isArticolo() ? $riga->missing_serials_number : 0; - if ($mancanti > 0) { - $extra = 'class="warning"'; - } - $descrizione = (!empty($riga->articolo) ? $riga->codice.' - ' : '').$riga['descrizione']; - - echo ' - - '; - - // Quantità - echo ' - '; - - if ($show_prezzi) { - // Costo unitario - echo ' - '; - - // Prezzo unitario - echo ' - '; - - echo ' - '; - - // Prezzo di vendita - echo ' - '; - } - - // Pulsante per riportare nel magazzino centrale. - // Visibile solo se l'intervento non è stato nè fatturato nè completato. - if (!$record['flag_completato']) { - echo ' - '; - } - echo ' - '; - } - - echo ' - -
    '.tr('Descrizione').''.tr('Q.tà').''.tr('Prezzo di acquisto').''.tr('Prezzo di vendita').''.tr('Iva unitaria').''.tr('Importo').''.tr('#').'
    '; - - // Informazioni aggiuntive sulla destra - echo ' - '; - - // Aggiunta dei riferimenti ai documenti - if ($riga->hasOriginalComponent()) { - echo ' - '.reference($riga->getOriginalComponent()->getDocument(), tr('Origine')); - } - - echo ' - '; - - echo ' - '.Modules::link($riga->isArticolo() ? Modules::get('Articoli')['id'] : null, $riga->isArticolo() ? $riga['idarticolo'] : null, $descrizione); - - if ($riga->isArticolo()) { - if (!empty($mancanti)) { - echo ' -
    '.tr('_NUM_ serial mancanti', [ - '_NUM_' => $mancanti, - ]).''; - } - - $serials = $riga->serials; - if (!empty($serials)) { - echo ' -
    '.tr('SN').': '.implode(', ', $serials); - } - } - - echo ' -
    - '.Translator::numberToLocale($riga->qta, 'qta').' '.$riga->um.' - - '.moneyFormat($riga->costo_unitario).' - - '.moneyFormat($riga->prezzo_unitario); - - if (abs($riga->sconto_unitario) > 0) { - $text = discountInfo($riga); - - echo ' -
    '.$text.''; - } - - echo ' -
    - '.moneyFormat($riga->iva_unitaria_scontata).' -
    '.$riga->aliquota->descrizione.(($riga->aliquota->esente) ? ' ('.$riga->aliquota->codice_natura_fe.')' : null).' -
    - '.moneyFormat($riga->importo).' - -
    '; - - if ($riga->isArticolo() && !empty($riga->abilita_serial)) { - echo ' - - - '; - } - - echo ' - - - - - - - -
    '; - - echo ' -
    -
    '; -} else { - echo ' -

    '.tr('Nessuna riga presente').'.

    '; -} - -echo ' -'; diff --git a/modules/interventi/src/API/v1/Articoli.php b/modules/interventi/src/API/v1/Articoli.php deleted file mode 100755 index d916b69c9..000000000 --- a/modules/interventi/src/API/v1/Articoli.php +++ /dev/null @@ -1,70 +0,0 @@ -. - */ - -namespace Modules\Interventi\API\v1; - -use API\Interfaces\CreateInterface; -use API\Interfaces\RetrieveInterface; -use API\Resource; -use Modules\Articoli\Articolo as ArticoloOriginale; -use Modules\Interventi\Components\Articolo; -use Modules\Interventi\Intervento; - -class Articoli extends Resource implements RetrieveInterface, CreateInterface -{ - public function retrieve($request) - { - $query = 'SELECT id, idarticolo AS id_articolo, idintervento AS id_intervento, qta, created_at as data FROM in_righe_interventi WHERE `idarticolo` IS NOT NULL AND `idintervento` = :id_intervento'; - - $parameters = [ - ':id_intervento' => $request['id_intervento'], - ]; - - return [ - 'query' => $query, - 'parameters' => $parameters, - ]; - } - - public function create($request) - { - $data = $request['data']; - - $originale = ArticoloOriginale::find($data['id_articolo']); - $intervento = Intervento::find($data['id_intervento']); - $articolo = Articolo::build($intervento, $originale); - - $articolo->qta = $data['qta']; - $articolo->um = $data['um']; - - $articolo->prezzo_unitario = $originale->prezzo_vendita; - $articolo->costo_unitario = $originale->prezzo_acquisto; - - $articolo->save(); - } - - public function delete($request) - { - $database = database(); - - $database->query('DELETE FROM `in_righe_interventi` WHERE `idarticolo` IS NOT NULL AND `idintervento` = :id_intervento', [ - ':id_intervento' => $request['id_intervento'], - ]); - } -} diff --git a/modules/interventi/src/API/v1/Firma.php b/modules/interventi/src/API/v1/Firma.php deleted file mode 100755 index d44ab3395..000000000 --- a/modules/interventi/src/API/v1/Firma.php +++ /dev/null @@ -1,40 +0,0 @@ -. - */ - -namespace Modules\Interventi\API\v1; - -use API\Interfaces\UpdateInterface; -use API\Resource; -use Models\Upload; - -class Firma extends Resource implements UpdateInterface -{ - public function update($request) - { - $database = database(); - $data = $request['data']; - - //$file = Upload::find($data['file_id']); - $database->update('in_interventi', [ - 'firma_file' => $data['firma_file'], - 'firma_data' => $data['firma_data'], - 'firma_nome' => $data['firma_nome'], - ], ['id' => $data['id']]); - } -} diff --git a/modules/interventi/src/API/v1/Impianti.php b/modules/interventi/src/API/v1/Impianti.php deleted file mode 100755 index 264d022ae..000000000 --- a/modules/interventi/src/API/v1/Impianti.php +++ /dev/null @@ -1,60 +0,0 @@ -. - */ - -namespace Modules\Interventi\API\v1; - -use API\Interfaces\CreateInterface; -use API\Interfaces\RetrieveInterface; -use API\Resource; - -class Impianti extends Resource implements RetrieveInterface, CreateInterface -{ - public function retrieve($request) - { - $query = 'SELECT idimpianto AS id_impianto, idintervento AS id_intervento FROM my_impianti_interventi WHERE `idintervento` = :id_intervento'; - - $parameters = [ - ':id_intervento' => $request['id_intervento'], - ]; - - return [ - 'query' => $query, - 'parameters' => $parameters, - ]; - } - - public function create($request) - { - $data = $request['data']; - $id_record = $data['id_intervento']; - - $database = database(); - $database->query('DELETE FROM my_impianti_interventi WHERE `idintervento` = :id_intervento', [ - ':id_intervento' => $id_record, - ]); - - $impianti = $data['impianti']; - foreach ($impianti as $impianto) { - $database->insert('my_impianti_interventi', [ - 'idintervento' => $id_record, - 'idimpianto' => $impianto, - ]); - } - } -} diff --git a/modules/interventi/src/API/v1/Interventi.php b/modules/interventi/src/API/v1/Interventi.php deleted file mode 100755 index 92efa3a43..000000000 --- a/modules/interventi/src/API/v1/Interventi.php +++ /dev/null @@ -1,125 +0,0 @@ -. - */ - -namespace Modules\Interventi\API\v1; - -use API\Interfaces\CreateInterface; -use API\Interfaces\RetrieveInterface; -use API\Interfaces\UpdateInterface; -use API\Resource; -use Auth; -use Modules; -use Modules\Anagrafiche\Anagrafica; -use Modules\Interventi\Intervento; -use Modules\Interventi\Stato; -use Modules\TipiIntervento\Tipo as TipoSessione; - -class Interventi extends Resource implements RetrieveInterface, CreateInterface, UpdateInterface -{ - public function retrieve($request) - { - // Periodo per selezionare interventi - $today = date('Y-m-d'); - $period_end = date('Y-m-d', strtotime($today.' +7 days')); - $period_start = date('Y-m-d', strtotime($today.' -2 months')); - $user = Auth::user(); - - // AND `in_statiintervento`.`is_completato`=0 - $query = "SELECT `in_interventi`.`id`, - `in_interventi`.`codice`, - `in_interventi`.`data_richiesta`, - `in_interventi`.`richiesta`, - `in_interventi`.`descrizione`, - `in_interventi`.`idtipointervento`, - `in_interventi`.`idanagrafica`, - `in_interventi`.`idsede_destinazione`, - `in_interventi`.`idstatointervento`, - `in_interventi`.`informazioniaggiuntive`, - `in_interventi`.`idclientefinale`, - `in_interventi`.`firma_file`, - IF(firma_data = '0000-00-00 00:00:00', '', firma_data) AS `firma_data`, - `in_interventi`.firma_nome, - (SELECT GROUP_CONCAT(CONCAT(my_impianti.matricola, ' - ', my_impianti.nome) SEPARATOR ', ') FROM (my_impianti_interventi INNER JOIN my_impianti ON my_impianti_interventi.idimpianto=my_impianti.id) WHERE my_impianti_interventi.idintervento = `in_interventi`.`id`) AS `impianti`, - (SELECT MAX(`orario_fine`) FROM `in_interventi_tecnici` WHERE `in_interventi_tecnici`.`idintervento` = `in_interventi`.`id`) AS `data`, - (SELECT GROUP_CONCAT(DISTINCT ragione_sociale SEPARATOR ', ') FROM `in_interventi_tecnici` INNER JOIN `an_anagrafiche` ON `in_interventi_tecnici`.`idtecnico` = `an_anagrafiche`.`idanagrafica` WHERE `in_interventi_tecnici`.`idintervento` = `in_interventi`.`id`) AS `tecnici`, - `in_statiintervento`.`colore` AS `bgcolor`, - `in_statiintervento`.`descrizione` AS `stato`, - `in_interventi`.`idtipointervento` AS `tipo` - FROM `in_interventi` - INNER JOIN `in_statiintervento` ON `in_interventi`.`idstatointervento` = `in_statiintervento`.`idstatointervento` - INNER JOIN `an_anagrafiche` ON `in_interventi`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - LEFT JOIN `an_sedi` ON `in_interventi`.`idsede_destinazione` = `an_sedi`.`id` - WHERE EXISTS(SELECT `orario_fine` FROM `in_interventi_tecnici` WHERE `in_interventi_tecnici`.`idintervento` = `in_interventi`.`id` AND `orario_fine` BETWEEN :period_start AND :period_end AND idtecnico LIKE :idtecnico)"; - - // Se sono l'admin posso vedere tutte le attività - $id_anagrafica = $user->is_admin ? '%' : $user->idanagrafica; - - $query .= ' - HAVING 2=2 - ORDER BY `in_interventi`.`data_richiesta` DESC'; - - $parameters = [ - ':period_end' => $period_end, - ':period_start' => $period_start, - ':idtecnico' => $id_anagrafica, - ]; - - $module = Modules::get('Interventi'); - - $query = Modules::replaceAdditionals($module->id, $query); - - return [ - 'query' => $query, - 'parameters' => $parameters, - ]; - } - - public function create($request) - { - $data = $request['data']; - - $anagrafica = Anagrafica::find($data['id_anagrafica']); - $tipo = TipoSessione::find($data['id_tipo_intervento']); - $stato = Stato::find($data['id_stato_intervento']); - - $intervento = Intervento::build($anagrafica, $tipo, $stato, $data['data_richiesta']); - - $intervento->richiesta = $data['richiesta']; - $intervento->descrizione = $data['descrizione']; - $intervento->informazioniaggiuntive = $data['informazioni_aggiuntive']; - $intervento->save(); - - return [ - 'id' => $intervento->id, - 'codice' => $intervento->codice, - ]; - } - - public function update($request) - { - $data = $request['data']; - - $intervento = Intervento::find($data['id']); - - $intervento->idstatointervento = $data['id_stato_intervento']; - $intervento->descrizione = $data['descrizione']; - $intervento->informazioniaggiuntive = $data['informazioni_aggiuntive']; - $intervento->save(); - } -} diff --git a/modules/interventi/src/API/v1/Rapportino.php b/modules/interventi/src/API/v1/Rapportino.php deleted file mode 100755 index 899760ad7..000000000 --- a/modules/interventi/src/API/v1/Rapportino.php +++ /dev/null @@ -1,83 +0,0 @@ -. - */ - -namespace Modules\Interventi\API\v1; - -use API\Interfaces\CreateInterface; -use API\Interfaces\RetrieveInterface; -use API\Resource; -use Modules\Emails\Mail; -use Modules\Emails\Template; - -class Rapportino extends Resource implements RetrieveInterface, CreateInterface -{ - public function retrieve($request) - { - $database = database(); - $id_record = $request['id_intervento']; - - $template = Template::where('name', 'Rapportino intervento')->first(); - $module = $template->module; - - $body = $module->replacePlaceholders($id_record, $template['body']); - $subject = $module->replacePlaceholders($id_record, $template['subject']); - $email = $module->replacePlaceholders($id_record, '{email}'); - - $prints = $database->fetchArray('SELECT id, title, EXISTS(SELECT id_print FROM em_print_template WHERE id_template = '.prepare($template['id']).' AND em_print_template.id_print = zz_prints.id) AS selected FROM zz_prints WHERE id_module = '.prepare($module->id).' AND enabled = 1'); - - return [ - 'email' => $email, - 'subject' => $subject, - 'body' => $body, - 'prints' => $prints, - ]; - } - - public function create($request) - { - $id_record = $request['id_intervento']; - - $template = Template::where('name', 'Rapportino intervento')->first(); - $mail = Mail::build($this->getUser(), $template, $id_record); - - // Rimozione allegati predefiniti - $mail->resetPrints(); - - // Destinatari - $receivers = $request['receivers']; - foreach ($receivers as $receiver) { - $mail->addReceiver($receiver['email'], $receiver['tipo']); - } - - // Contenuti - $mail->subject = $request['subject']; - $mail->content = $request['body']; - - // Stampe da allegare - $prints = $request['prints']; - foreach ($prints as $print) { - $mail->addPrint($print['id']); - } - - $mail->save(); - - return [ - ]; - } -} diff --git a/modules/interventi/src/API/v1/Sessioni.php b/modules/interventi/src/API/v1/Sessioni.php deleted file mode 100755 index 8ca5c2c4a..000000000 --- a/modules/interventi/src/API/v1/Sessioni.php +++ /dev/null @@ -1,71 +0,0 @@ -. - */ - -namespace Modules\Interventi\API\v1; - -use API\Interfaces\CreateInterface; -use API\Interfaces\DeleteInterface; -use API\Interfaces\RetrieveInterface; -use API\Resource; - -class Sessioni extends Resource implements RetrieveInterface, CreateInterface, DeleteInterface -{ - public function retrieve($request) - { - $user = $this->getUser(); - - $query = 'SELECT id, idtecnico AS id_tecnico, idintervento AS id_intervento, orario_inizio, orario_fine, ragione_sociale AS tecnico FROM in_interventi_tecnici INNER JOIN an_anagrafiche ON idanagrafica = idtecnico WHERE `idintervento` = :id_intervento'; - - $parameters = [ - ':id_intervento' => $request['id_intervento'], - ]; - - if ($user['gruppo'] == 'Tecnici') { - $query .= ' AND `idtecnico` = :id_tecnico'; - $parameters[':id_tecnico'] = $user['idanagrafica']; - } - - return [ - 'query' => $query, - 'parameters' => $parameters, - ]; - } - - public function create($request) - { - $user = $this->getUser(); - $data = $request['data']; - - try { - add_tecnico($data['id_intervento'], $user['idanagrafica'], $data['orario_inizio'], $data['orario_fine']); - } catch (\InvalidArgumentException $e) { - } - } - - public function delete($request) - { - $database = database(); - $user = $this->getUser(); - - $database->query('DELETE FROM `in_interventi_tecnici` WHERE `idintervento` = :id_intervento AND `idtecnico` = :id_tecnico', [ - ':id_intervento' => $request['id_intervento'], - ':id_tecnico' => $user['idanagrafica'], - ]); - } -} diff --git a/modules/interventi/src/API/v1/Sync.php b/modules/interventi/src/API/v1/Sync.php deleted file mode 100755 index 63771fed1..000000000 --- a/modules/interventi/src/API/v1/Sync.php +++ /dev/null @@ -1,190 +0,0 @@ -. - */ - -namespace Modules\Interventi\API\v1; - -use API\Interfaces\RetrieveInterface; -use API\Interfaces\UpdateInterface; -use API\Resource; -use Carbon\Carbon; -use DateTime; -use iCalEasyReader; - -class Sync extends Resource implements RetrieveInterface, UpdateInterface -{ - public function retrieve($request) - { - $database = database(); - $user = $this->getUser(); - - // Normalizzazione degli interventi a database - $database->query('UPDATE in_interventi_tecnici SET summary = (SELECT ragione_sociale FROM an_anagrafiche INNER JOIN in_interventi ON an_anagrafiche.idanagrafica=in_interventi.idanagrafica WHERE in_interventi.id=in_interventi_tecnici.idintervento) WHERE summary IS NULL'); - $database->query('UPDATE in_interventi_tecnici SET uid = id WHERE uid IS NULL'); - - // Individuazione degli interventi - $query = 'SELECT in_interventi_tecnici.id AS idriga, in_interventi_tecnici.idintervento, (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=in_interventi.idanagrafica) AS cliente, richiesta, orario_inizio, orario_fine, (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=idtecnico) AS nome_tecnico, summary FROM in_interventi_tecnici INNER JOIN in_interventi ON in_interventi_tecnici.idintervento=in_interventi.id WHERE DATE(orario_inizio) BETWEEN CURDATE() - INTERVAL 7 DAY AND CURDATE() + INTERVAL 3 MONTH AND deleted_at IS NULL'; - - if ($user->anagrafica->isTipo('Tecnico')) { - $query .= ' AND in_interventi_tecnici.idtecnico = '.prepare($user['idanagrafica']); - } elseif ($user->anagrafica->isTipo('Cliente')) { - $query .= ' AND in_interventi.idanagrafica = '.prepare($user['idanagrafica']); - } - - $rs = $database->fetchArray($query); - - $result = ''; - - $result .= "BEGIN:VCALENDAR\n"; - $result .= "VERSION:2.0\n"; - $result .= "PRODID:-// OpenSTAManager\n"; - - foreach ($rs as $r) { - $richiesta = str_replace("\r\n", "\n", $r['richiesta']); - $richiesta = str_replace("\r", "\n", $richiesta); - $richiesta = str_replace("\n", '\\n', $richiesta); - - $r['summary'] = str_replace("\r\n", "\n", $r['summary']); - - $now = new Carbon(); - $inizio = new Carbon($r['orario_inizio']); - $fine = new Carbon($r['orario_fine']); - - $result .= "BEGIN:VEVENT\n"; - $result .= 'UID:'.$r['idriga']."\n"; - $result .= 'DTSTAMP:'.$now->format('Ymd\THis')."\n"; - //$result .= 'ORGANIZER;CN='.$azienda.':MAILTO:'.$email."\n"; - $result .= 'DTSTART:'.$inizio->format('Ymd\THis')."\n"; - $result .= 'DTEND:'.$fine->format('Ymd\THis')."\n"; - $result .= 'SUMMARY:'.html_entity_decode($r['summary'])."\n"; - $result .= 'DESCRIPTION:'.html_entity_decode($richiesta, ENT_QUOTES, 'UTF-8')."\n"; - $result .= "END:VEVENT\n"; - } - - $result .= "END:VCALENDAR\n"; - - return [ - 'custom' => $result, - ]; - } - - public function update($request) - { - $database = database(); - $user = $this->getUser(); - - // Normalizzazione degli interventi a database - $database->query('UPDATE in_interventi_tecnici SET summary = (SELECT ragione_sociale FROM an_anagrafiche INNER JOIN in_interventi ON an_anagrafiche.idanagrafica=in_interventi.idanagrafica WHERE in_interventi.id=in_interventi_tecnici.idintervento) WHERE summary IS NULL'); - $database->query('UPDATE in_interventi_tecnici SET uid = id WHERE uid IS NULL'); - - // Interpretazione degli eventi - $idtecnico = $user['idanagrafica']; - - $response = API\Response::getRequest(true); - - $ical = new iCalEasyReader(); - $events = $ical->load($response); - - foreach ($events['VEVENT'] as $event) { - $description = $event['DESCRIPTION']; - - // Individuazione idriga di in_interventi_tecnici - if (string_contains($event['UID'], '-')) { - $idriga = 'NEW'; - } else { - $idriga = $event['UID']; - } - - // Timestamp di inizio - $orario_inizio = DateTime::createFromFormat('Ymd\\THi', $event['DTSTART'])->format(Intl\Formatter::getStandardFormats()['timestamp']); - - // Timestamp di fine - $orario_fine = DateTime::createFromFormat('Ymd\\THi', $event['DTEND'])->format(Intl\Formatter::getStandardFormats()['timestamp']); - - // Descrizione - $richiesta = $event['DESCRIPTION']; - $richiesta = str_replace('\\r\\n', "\n", $richiesta); - $richiesta = str_replace('\\n', "\n", $richiesta); - - $summary = trim($event['SUMMARY']); - $summary = str_replace('\\r\\n', "\n", $summary); - $summary = str_replace('\\n', "\n", $summary); - - // Nuova attività - if ($idriga == 'NEW') { - $rs_copie = $database->fetchArray('SELECT * FROM in_interventi_tecnici WHERE uid = '.prepare($event['UID'])); - - if (!empty($rs_copie)) { - $idintervento = $rs_copie[0]['idintervento']; - - $database->update('in_interventi_tecnici', [ - 'orario_inizio' => $orario_inizio, - 'orario_fine' => $orario_fine, - 'summary' => $summary, - ], [ - 'uid' => $event['UID'], - 'idtecnico' => $idtecnico, - ]); - - $database->query('UPDATE in_interventi SET richiesta='.prepare($richiesta).', oggetto='.prepare($summary).' WHERE idintervento = (SELECT idintervento FROM in_interventi_tecnici WHERE idintervento = '.prepare($idintervento).' AND idtecnico = '.prepare($idtecnico).' LIMIT 0,1)'); - - $idriga = $rs_copie[0]['id']; - } else { - $idintervento = get_new_idintervento(); - $stato = $database->fetchArray("SELECT * FROM in_statiintervento WHERE descrizione = 'Chiamata'"); - - $database->insert('in_interventi', [ - 'idintervento' => $idintervento, - 'idanagrafica' => setting('Azienda predefinita'), - 'data_richiesta' => Carbon::now(), - 'richiesta' => $richiesta, - 'idtipointervento' => 0, - 'idstatointervento' => $stato['idstatointerventoWIP'], - 'oggetto' => $summary, - ]); - - $database->insert('in_interventi', [ - 'idintervento' => $idintervento, - 'idtecnico' => $idtecnico, - 'orario_inizio' => $orario_inizio, - 'orario_fine' => $orario_fine, - 'summary' => $summary, - 'uid' => $event['UID'], - ]); - - $idriga = $database->lastInsertedID(); - } - } - - // Modifica attività esistente - else { - $database->update('in_interventi_tecnici', [ - 'orario_inizio' => $orario_inizio, - 'orario_fine' => $orario_fine, - 'summary' => $summary, - ], [ - 'id' => $idriga, - 'idtecnico' => $idtecnico, - ]); - - $query = 'UPDATE in_interventi SET richiesta='.prepare($richiesta).', oggetto='.prepare($summary).' WHERE idintervento = (SELECT idintervento FROM in_interventi_tecnici WHERE id = '.prepare($idriga).' AND idtecnico = '.prepare($idtecnico).' LIMIT 0,1)'; - $database->query($query); - } - } - } -} diff --git a/modules/interventi/src/Components/Articolo.php b/modules/interventi/src/Components/Articolo.php deleted file mode 100755 index 226036274..000000000 --- a/modules/interventi/src/Components/Articolo.php +++ /dev/null @@ -1,30 +0,0 @@ -. - */ - -namespace Modules\Interventi\Components; - -use Common\Components\Article; - -class Articolo extends Article -{ - use RelationTrait; - - protected $table = 'in_righe_interventi'; - protected $serialRowID = 'intervento'; -} diff --git a/modules/interventi/src/Components/RelationTrait.php b/modules/interventi/src/Components/RelationTrait.php deleted file mode 100755 index 855fcac1c..000000000 --- a/modules/interventi/src/Components/RelationTrait.php +++ /dev/null @@ -1,50 +0,0 @@ -. - */ - -namespace Modules\Interventi\Components; - -use Modules\Interventi\Intervento; - -trait RelationTrait -{ - protected $disableOrder = true; - - public function getDocumentID() - { - return 'idintervento'; - } - - public function document() - { - return $this->belongsTo(Intervento::class, $this->getDocumentID()); - } - - public function intervento() - { - return $this->document(); - } - - public function fixIvaIndetraibile() - { - } - - protected function fixSubtotale() - { - } -} diff --git a/modules/interventi/src/Components/Riga.php b/modules/interventi/src/Components/Riga.php deleted file mode 100755 index 7cee40572..000000000 --- a/modules/interventi/src/Components/Riga.php +++ /dev/null @@ -1,29 +0,0 @@ -. - */ - -namespace Modules\Interventi\Components; - -use Common\Components\Row; - -class Riga extends Row -{ - use RelationTrait; - - protected $table = 'in_righe_interventi'; -} diff --git a/modules/interventi/src/Components/Sconto.php b/modules/interventi/src/Components/Sconto.php deleted file mode 100755 index 05f0f74db..000000000 --- a/modules/interventi/src/Components/Sconto.php +++ /dev/null @@ -1,29 +0,0 @@ -. - */ - -namespace Modules\Interventi\Components; - -use Common\Components\Discount; - -class Sconto extends Discount -{ - use RelationTrait; - - protected $table = 'in_righe_interventi'; -} diff --git a/modules/interventi/src/Components/Sessione.php b/modules/interventi/src/Components/Sessione.php deleted file mode 100755 index a5b8912c2..000000000 --- a/modules/interventi/src/Components/Sessione.php +++ /dev/null @@ -1,450 +0,0 @@ -. - */ - -namespace Modules\Interventi\Components; - -use Common\SimpleModelTrait; -use DateTime; -use Illuminate\Database\Eloquent\Model; -use InvalidArgumentException; -use Modules\Anagrafiche\Anagrafica; -use Modules\Interventi\Intervento; -/* - * Notazione: i costi sono rivolti all'azienda, i prezzi al cliente. - * - * @since 2.4.9 - */ -use Modules\Iva\Aliquota; -use Modules\TipiIntervento\Tipo as TipoSessione; - -class Sessione extends Model -{ - use SimpleModelTrait; - use RelationTrait; - - protected $table = 'in_interventi_tecnici'; - - protected $aliquota_iva = null; - - /** - * Crea un nuova sessione collegata ad un intervento. - * - * @param string $inizio - * @param string $fine - * - * @return self - */ - public static function build(Intervento $intervento, Anagrafica $anagrafica, $inizio, $fine) - { - if (!$anagrafica->isTipo('Tecnico')) { - throw new InvalidArgumentException(); - } - - $model = new static(); - - $model->document()->associate($intervento); - $model->anagrafica()->associate($anagrafica); - - $id_tipo = $intervento['idtipointervento']; - $tipo_sessione = TipoSessione::find($id_tipo); - $model->tipo()->associate($tipo_sessione); - - $model->orario_inizio = $inizio; - $model->orario_fine = $fine; - - // Sede secondaria - if (!empty($intervento['idsede_destinazione'])) { - $sede = database()->fetchOne('SELECT km FROM an_sedi WHERE id = '.prepare($intervento['idsede_destinazione'])); - $km = $sede['km']; - } - - // Sede legale dell'anagrafica - else { - $km = $intervento->anagrafica->sedeLegale->km; - } - - $model->km = empty($km) ? 0 : $km; - - $model->save(); - - $model->setTipo($id_tipo, true); - $model->save(); - - return $model; - } - - public function setTipo($id_tipo, $reset = false) - { - $previous = $this->idtipointervento; - - $tipo_sessione = TipoSessione::find($id_tipo); - $this->tipo()->associate($tipo_sessione); - - if ($previous != $id_tipo || $reset) { - $tariffa = $this->getTariffa($id_tipo); - - // Azzeramento forzato del diritto di chiamata nel caso la sessione non sia la prima dell'intervento nel giorno di inizio o fine - $sessioni = database()->fetchArray('SELECT id FROM in_interventi_tecnici WHERE (DATE(orario_inizio) = DATE('.prepare($this->orario_inizio).') OR DATE(orario_fine) = DATE('.prepare($this->orario_fine).')) AND (prezzo_dirittochiamata != 0 OR prezzo_dirittochiamata_tecnico != 0) AND id != '.prepare($this->id).' AND idintervento = '.prepare($this->intervento->id)); - if (!empty($sessioni)) { - $tariffa['costo_dirittochiamata_tecnico'] = 0; - $tariffa['costo_dirittochiamata'] = 0; - - // Fix se reset non attivo - $this->prezzo_dirittochiamata = $tariffa['costo_dirittochiamata']; - } - - // Modifica dei costi - $this->prezzo_ore_unitario_tecnico = $tariffa['costo_ore_tecnico']; - $this->prezzo_km_unitario_tecnico = $tariffa['costo_km_tecnico']; - $this->prezzo_dirittochiamata_tecnico = $tariffa['costo_dirittochiamata_tecnico']; - - // Modifica dei prezzi - if ($reset) { - $this->prezzo_ore_unitario = $tariffa['costo_ore']; - $this->prezzo_km_unitario = $tariffa['costo_km']; - $this->prezzo_dirittochiamata = $tariffa['costo_dirittochiamata']; - } - } - } - - public function getOreAttribute() - { - $inizio = new DateTime($this->orario_inizio); - $diff = $inizio->diff(new DateTime($this->orario_fine)); - - $ore = $diff->i / 60 + $diff->h + ($diff->days * 24); - - return $ore; - } - - /** - * Salva la sessione, impostando i campi dipendenti dai singoli parametri. - * - * @return bool - */ - public function save(array $options = []) - { - $this->attributes['ore'] = $this->ore; - - $this->attributes['prezzo_ore_consuntivo'] = $this->prezzo_manodopera + $this->prezzo_diritto_chiamata; - $this->attributes['prezzo_km_consuntivo'] = $this->prezzo_viaggio; - - $this->attributes['prezzo_ore_consuntivo_tecnico'] = $this->costo_manodopera + $this->costo_diritto_chiamata; - $this->attributes['prezzo_km_consuntivo_tecnico'] = $this->costo_viaggio; - - $this->attributes['sconto'] = $this->sconto_totale_manodopera; - $this->attributes['scontokm'] = $this->sconto_totale_viaggio; - - return parent::save($options); - } - - public function getDocumentID() - { - return 'idintervento'; - } - - // Relazioni Eloquent - - public function anagrafica() - { - return $this->belongsTo(Anagrafica::class, 'idtecnico'); - } - - public function tipo() - { - return $this->belongsTo(TipoSessione::class, 'idtipointervento'); - } - - public function parent() - { - return $this->belongsTo(Intervento::class, $this->getDocumentID()); - } - - // Costi per l'azienda - - /** - * Restituisce il costo orario (per l'azienda) per la sessione del tecnico. - * - * @return float - */ - public function getCostoOrarioAttribute() - { - return $this->attributes['prezzo_ore_unitario_tecnico']; - } - - /** - * Restituisce il costo del diritto di chiamata (per l'azienda) per la sessione del tecnico. - * - * @return float - */ - public function getCostoDirittoChiamataAttribute() - { - return $this->attributes['prezzo_dirittochiamata_tecnico']; - } - - /** - * Restituisce il costo chilometrico (per l'azienda) del viaggio del tecnico. - * - * @return float - */ - public function getCostoChilometricoAttribute() - { - return $this->attributes['prezzo_km_unitario_tecnico']; - } - - /** - * Restituisce il costo totale della manodopera escluso il diritto di chiamata (per l'azienda) per la sessione del tecnico. - * - * @return float - */ - public function getCostoManodoperaAttribute() - { - return $this->costo_orario * $this->ore; - } - - /** - * Restituisce il costo totale (per l'azienda) del viaggio del tecnico. - * - * @return float - */ - public function getCostoViaggioAttribute() - { - return $this->costo_chilometrico * $this->km; - } - - // Prezzi per il cliente - - /** - * Restituisce il prezzo del diritto di chiamata (per il cliente) per la sessione del tecnico. - * - * @return float - */ - public function getPrezzoDirittoChiamataAttribute() - { - return $this->attributes['prezzo_dirittochiamata']; - } - - /** - * Restituisce il prezzo del diritto di chiamata (per il cliente) per la sessione del tecnico. - * - * @return float - */ - public function getPrezzoChilometricoAttribute() - { - return $this->attributes['prezzo_km_unitario']; - } - - /** - * Restituisce il prezzo del diritto di chiamata (per il cliente) per la sessione del tecnico. - * - * @return float - */ - public function getPrezzoOrarioAttribute() - { - return $this->attributes['prezzo_ore_unitario']; - } - - /** - * Restituisce il prezzo totale della manodopera escluso il diritto di chiamata (per il cliente) per la sessione del tecnico. - * - * @return float - */ - public function getPrezzoManodoperaAttribute() - { - return $this->prezzo_orario * $this->ore; - } - - /** - * Restituisce lo sconto totale km in euro. - * - * @return float - */ - public function getScontoTotaleManodoperaAttribute() - { - return calcola_sconto([ - 'sconto' => $this->sconto_unitario, - 'prezzo' => $this->prezzo_orario, - 'qta' => $this->ore, - 'tipo' => $this->tipo_sconto, - ]); - } - - /** - * Restituisce il prezzo totale scontato (per il cliente) del viaggio del tecnico. - * - * @return float - */ - public function getPrezzoManodoperaScontatoAttribute() - { - return $this->prezzo_manodopera - $this->sconto_totale_manodopera; - } - - /** - * Restituisce il prezzo totale (per il cliente) del viaggio del tecnico. - * - * @return float - */ - public function getPrezzoViaggioAttribute() - { - return $this->prezzo_chilometrico * $this->km; - } - - /** - * Restituisce lo sconto totale km in euro. - * - * @return float - */ - public function getScontoTotaleViaggioAttribute() - { - return calcola_sconto([ - 'sconto' => $this->scontokm_unitario, - 'prezzo' => $this->prezzo_chilometrico, - 'qta' => $this->km, - 'tipo' => $this->tipo_scontokm, - ]); - } - - /** - * Restituisce il prezzo totale scontato (per il cliente) del viaggio del tecnico. - * - * @return float - */ - public function getPrezzoViaggioScontatoAttribute() - { - return $this->prezzo_viaggio - $this->sconto_totale_viaggio; - } - - // Attributi di contabilità - - /** - * Restituisce l'imponibile dell'elemento. - * - * @return float - */ - public function getImponibileAttribute() - { - return $this->prezzo_manodopera + $this->prezzo_viaggio + $this->prezzo_diritto_chiamata; - } - - /** - * Restituisce il totale imponibile dell'elemento. - * - * @return float - */ - public function getTotaleImponibileAttribute() - { - return $this->prezzo_manodopera_scontato + $this->prezzo_viaggio_scontato + $this->prezzo_diritto_chiamata; - } - - /** - * Restituisce il totale (imponibile + iva) dell'elemento. - * - * @return float - */ - public function getTotaleAttribute() - { - return $this->totale_imponibile + $this->iva; - } - - /** - * Restituisce la spesa (costo_unitario * qta) relativa all'elemento. - * - * @return float - */ - public function getSpesaAttribute() - { - return $this->costo_manodopera; - } - - /** - * Restituisce il margine totale (imponibile - spesa) relativo all'elemento. - * - * @return float - */ - public function getMargineAttribute() - { - return $this->imponibile - $this->spesa; - } - - /** - * Restituisce lo sconto della riga corrente in euro. - * - * @return float - */ - public function getScontoAttribute() - { - return $this->sconto_totale_manodopera + $this->sconto_totale_viaggio; - } - - /** - * Restituisce il margine percentuale relativo all'elemento. - * - * @return float - */ - public function getMarginePercentualeAttribute() - { - return $this->imponibile ? (1 - ($this->spesa / $this->imponibile)) * 100 : 100; - } - - public function getIvaIndetraibileAttribute() - { - return $this->iva / 100 * $this->aliquota->indetraibile; - } - - public function getIvaAttribute() - { - return ($this->totale_imponibile) * $this->aliquota->percentuale / 100; - } - - public function getIvaDetraibileAttribute() - { - return $this->iva - $this->iva_indetraibile; - } - - public function getAliquotaAttribute() - { - if (!isset($this->aliquota_iva)) { - $id_iva = setting('Iva predefinita'); - - $this->aliquota_iva = Aliquota::find($id_iva); - } - - return $this->aliquota_iva; - } - - protected function getTariffa($id_tipo) - { - $database = database(); - - // Costi unitari dalla tariffa del tecnico - $result = $database->fetchOne('SELECT * FROM in_tariffe WHERE idtecnico='.prepare($this->anagrafica->id).' AND idtipointervento = '.prepare($id_tipo)); - - // Costi unitari del contratto - $id_contratto = $this->intervento->id_contratto; - if (!empty($id_contratto)) { - $tariffa_contratto = $database->fetchOne('SELECT costo_ore, costo_km, costo_dirittochiamata FROM co_contratti_tipiintervento WHERE idcontratto = '.prepare($id_contratto).' AND idtipointervento = '.prepare($id_tipo)); - - if (!empty($tariffa_contratto)) { - $result = array_merge($result, $tariffa_contratto); - } - } - - return $result; - } -} diff --git a/modules/interventi/src/Intervento.php b/modules/interventi/src/Intervento.php deleted file mode 100755 index 247a96926..000000000 --- a/modules/interventi/src/Intervento.php +++ /dev/null @@ -1,250 +0,0 @@ -. - */ - -namespace Modules\Interventi; - -use Common\Document; -use Illuminate\Database\Eloquent\SoftDeletes; -use Modules\Anagrafiche\Anagrafica; -use Modules\Contratti\Contratto; -use Modules\Preventivi\Preventivo; -use Modules\TipiIntervento\Tipo as TipoSessione; -use Traits\RecordTrait; -use Traits\ReferenceTrait; -use Util\Generator; - -class Intervento extends Document -{ - use ReferenceTrait; - //use SoftDeletes; - - use RecordTrait; - - protected $table = 'in_interventi'; - - protected $info = []; - - protected $dates = [ - 'data_richiesta', - 'data_scadenza', - ]; - - /** - * Crea un nuovo intervento. - * - * @param string $data_richiesta - * - * @return self - */ - public static function build(Anagrafica $anagrafica, TipoSessione $tipo_sessione, Stato $stato, $data_richiesta) - { - $model = new static(); - - $model->anagrafica()->associate($anagrafica); - $model->stato()->associate($stato); - $model->tipo()->associate($tipo_sessione); - - $model->codice = static::getNextCodice($data_richiesta); - $model->data_richiesta = $data_richiesta; - - $model->save(); - - return $model; - } - - public function getOreTotaliAttribute() - { - if (!isset($this->info['ore_totali'])) { - $sessioni = $this->sessioni; - - $this->info['ore_totali'] = $sessioni->sum('ore'); - } - - return $this->info['ore_totali']; - } - - public function getKmTotaliAttribute() - { - if (!isset($this->info['km_totali'])) { - $sessioni = $this->sessioni; - - $this->info['km_totali'] = $sessioni->sum('km'); - } - - return $this->info['km_totali']; - } - - public function getInizioAttribute() - { - if (!isset($this->info['inizio'])) { - $sessioni = $this->sessioni; - - $this->info['inizio'] = $sessioni->min('orario_inizio'); - } - - return $this->info['inizio']; - } - - public function getFineAttribute() - { - if (!isset($this->info['fine'])) { - $sessioni = $this->sessioni; - - $this->info['fine'] = $sessioni->max('orario_fine'); - } - - return $this->info['fine']; - } - - public function getModuleAttribute() - { - return 'Interventi'; - } - - public function getDirezioneAttribute() - { - return 'entrata'; - } - - /** - * Restituisce la collezione di righe e articoli con valori rilevanti per i conti. - * - * @return iterable - */ - public function getRigheContabili() - { - $results = parent::getRigheContabili(); - - return $this->mergeCollections($results, $this->sessioni); - } - - // Relazioni Eloquent - - public function anagrafica() - { - return $this->belongsTo(Anagrafica::class, 'idanagrafica'); - } - - public function preventivo() - { - return $this->belongsTo(Preventivo::class, 'id_preventivo'); - } - - public function contratto() - { - return $this->belongsTo(Contratto::class, 'id_contratto'); - } - - public function stato() - { - return $this->belongsTo(Stato::class, 'idstatointervento'); - } - - public function tipo() - { - return $this->belongsTo(TipoSessione::class, 'idtipointervento'); - } - - public function articoli() - { - return $this->hasMany(Components\Articolo::class, 'idintervento'); - } - - public function righe() - { - return $this->hasMany(Components\Riga::class, 'idintervento'); - } - - public function sconti() - { - return $this->hasMany(Components\Sconto::class, 'idintervento'); - } - - public function descrizioni() - { - return $this->righe()->where('is_descrizione', 1); - } - - public function sessioni() - { - return $this->hasMany(Components\Sessione::class, 'idintervento'); - } - - public function toArray() - { - $array = parent::toArray(); - - $result = array_merge($array, [ - 'ore_totali' => $this->ore_totali, - 'km_totali' => $this->km_totali, - ]); - - return $result; - } - - // Metodi statici - - /** - * Calcola il nuovo codice di intervento. - * - * @param string $data - * - * @return string - */ - public static function getNextCodice($data) - { - $maschera = setting('Formato codice attività'); - - //$ultimo = Generator::getPreviousFrom($maschera, 'in_interventi', 'codice'); - - if ((strpos($maschera, 'YYYY') == false) or (strpos($maschera, 'yy') == false)) { - $ultimo = Generator::getPreviousFrom($maschera, 'in_interventi', 'codice', [ - 'YEAR(data_richiesta) = '.prepare(date('Y', strtotime($data))), - ], $data); - } else { - $ultimo = Generator::getPreviousFrom($maschera, 'in_interventi', 'codice'); - } - - $numero = Generator::generate($maschera, $ultimo, $quantity = 1, $values = [], $data); - - return $numero; - } - - // Opzioni di riferimento - - public function getReferenceName() - { - return 'Attività'; - } - - public function getReferenceNumber() - { - return $this->codice; - } - - public function getReferenceDate() - { - return $this->fine; - } - - public function getReferenceRagioneSociale() - { - return $this->anagrafica->ragione_sociale; - } -} diff --git a/modules/interventi/src/Stato.php b/modules/interventi/src/Stato.php deleted file mode 100755 index 5aeef4c5f..000000000 --- a/modules/interventi/src/Stato.php +++ /dev/null @@ -1,36 +0,0 @@ -. - */ - -namespace Modules\Interventi; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; - -class Stato extends Model -{ - use SimpleModelTrait; - - protected $primaryKey = 'idstatointervento'; - protected $table = 'in_statiintervento'; - - public function interventi() - { - return $this->hasMany(Intervento::class, 'idstatointervento'); - } -} diff --git a/modules/interventi/variables.php b/modules/interventi/variables.php deleted file mode 100755 index 49544d041..000000000 --- a/modules/interventi/variables.php +++ /dev/null @@ -1,37 +0,0 @@ -. - */ - -$r = $dbo->fetchOne('SELECT *, - (SELECT MAX(orario_fine) FROM in_interventi_tecnici WHERE idintervento=in_interventi.id) AS data_fine, - (SELECT email FROM an_anagrafiche WHERE an_anagrafiche.idanagrafica=in_interventi.idanagrafica) AS email, - (SELECT descrizione FROM in_statiintervento WHERE idstatointervento=in_interventi.idstatointervento) AS stato -FROM in_interventi WHERE id='.prepare($id_record)); - -// Variabili da sostituire -return [ - 'email' => $r['email'], - 'numero' => $r['codice'], - 'richiesta' => $r['richiesta'], - 'descrizione' => $r['descrizione'], - 'data' => Translator::dateToLocale($r['data_richiesta']), - 'data richiesta' => Translator::dateToLocale($r['data_richiesta']), - 'data fine intervento' => empty($r['data_fine']) ? Translator::dateToLocale($r['data_richiesta']) : Translator::dateToLocale($r['data_fine']), - 'id_anagrafica' => $r['idanagrafica'], - 'stato' => $r['stato'], -]; diff --git a/modules/interventi/widgets/interventi_confermati.php b/modules/interventi/widgets/interventi_confermati.php deleted file mode 100755 index 9e93c8361..000000000 --- a/modules/interventi/widgets/interventi_confermati.php +++ /dev/null @@ -1,49 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -$rs = $dbo->fetchArray('SELECT * FROM in_interventi WHERE in_interventi.idstatointervento = (SELECT in_statiintervento.idstatointervento FROM in_statiintervento WHERE in_statiintervento.codice=\'WIP\') ORDER BY data_richiesta ASC'); - -if (!empty($rs)) { - echo ' - - - - - '; - - foreach ($rs as $r) { - $data_richiesta = !empty($r['data_richiesta']) ? Translator::dateToLocale($r['data_richiesta']) : ''; - - echo ' - - - - '; - } - echo ' -
    '.tr('Attività').''.tr('Data richiesta').'
    - '.Modules::link('Interventi', $r['id'], 'Intervento n. '.$r['codice'].' del '.$data_richiesta).'
    - '.$r['ragione_sociale'].' -
    '.$data_richiesta.'
    '; -} else { - echo ' -

    '.tr('Non ci sono attività programmate').'.

    '; -} diff --git a/modules/interventi/widgets/interventi_da_pianificare.php b/modules/interventi/widgets/interventi_da_pianificare.php deleted file mode 100755 index bc38a40d6..000000000 --- a/modules/interventi/widgets/interventi_da_pianificare.php +++ /dev/null @@ -1,118 +0,0 @@ -. - */ - -use Modules\Interventi\Intervento; - -include_once __DIR__.'/../../../core.php'; - -// Interventi da pianificare NON completati -$interventi_da_pianificare = Intervento::doesntHave('sessioni') - ->orderByRaw('IF(data_scadenza IS NULL, data_richiesta, data_scadenza)') - ->whereHas('stato', function ($query) { - return $query->where('is_completato', '=', 0); - }) - ->get(); -$raggruppamenti = $interventi_da_pianificare->groupBy(function ($item, $key) { - $data = $item->data_scadenza ?: $item->data_richiesta; - - return ucfirst($data->formatLocalized('%B %Y')); -}); - -$counter = 0; -foreach ($raggruppamenti as $mese => $raggruppamento) { - ++$counter; - - // Se cambia il mese ricreo l'intestazione della tabella - if ($counter == 1) { - $attr = ''; - $class = 'fa-minus-circle'; - } else { - $attr = 'style="display:none;"'; - $class = 'fa-plus-circle'; - } - - echo " -

    - - ".$mese.' - -

    '; - - echo ' -
    - - - - - - - - - - - - - - '; - - // Elenco interventi da pianificare - foreach ($raggruppamento as $r) { - $rs_tecnici = $dbo->fetchArray("SELECT GROUP_CONCAT(ragione_sociale SEPARATOR ',') AS tecnici FROM an_anagrafiche INNER JOIN in_interventi_tecnici_assegnati ON in_interventi_tecnici_assegnati.id_tecnico=an_anagrafiche.idanagrafica WHERE id_intervento=".prepare($r['id']).' GROUP BY id_intervento'); - - echo ' - - - - - - - - - - '; - - echo ' - '; - } - - echo ' - -
    '.tr('Codice').''.tr('Cliente').''.tr('Data richiesta').''.tr('Tecnici assegnati').''.tr('Tipo intervento').''.tr('Stato intervento').''.tr('Descrizione').'
    '.Modules::link(Modules::get('Interventi')['id'], $r['id'], $r['codice']).''.Modules::link(Modules::get('Anagrafiche')['id'], $r['idanagrafica'], $dbo->fetchOne('SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica='.prepare($r['idanagrafica']))['ragione_sociale']).'
    Presso: '; - // Sede promemoria - if ($r['idsede'] == '-1') { - echo '- '.('Nessuna').' -'; - } elseif (empty($r['idsede'])) { - echo tr('Sede legale'); - } else { - $rsp2 = $dbo->fetchArray("SELECT id, CONCAT( CONCAT_WS( ' (', CONCAT_WS(', ', nomesede, citta), indirizzo ), ')') AS descrizione FROM an_sedi WHERE id=".prepare($r['idsede'])); - - echo $rsp2[0]['descrizione']; - } - echo ' - -
    '.Translator::dateToLocale($r['data_richiesta']).' '.((empty($r['data_scadenza'])) ? '' : '
    Entro il '.Translator::dateToLocale($r['data_scadenza']).'').'
    - '.$rs_tecnici[0]['tecnici'].' - '.$dbo->fetchOne("SELECT CONCAT_WS(' - ', codice,descrizione) AS descrizione FROM in_tipiintervento WHERE idtipointervento=".prepare($r['idtipointervento']))['descrizione'].''.$dbo->fetchOne("SELECT CONCAT_WS(' - ', codice,descrizione) AS descrizione FROM in_statiintervento WHERE idstatointervento=".prepare($r['idstatointervento']))['descrizione'].''.nl2br($r['richiesta']).'
    -
    '; -} - -if ($raggruppamenti->isEmpty()) { - echo ' -

    '.tr('Non ci sono interventi da pianificare').'.

    '; -} diff --git a/modules/interventi/widgets/interventi_da_programmare.php b/modules/interventi/widgets/interventi_da_programmare.php deleted file mode 100755 index 345b98116..000000000 --- a/modules/interventi/widgets/interventi_da_programmare.php +++ /dev/null @@ -1,49 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -$rs = $dbo->fetchArray('SELECT * FROM in_interventi WHERE in_interventi.idstatointervento = (SELECT in_statiintervento.idstatointervento FROM in_statiintervento WHERE in_statiintervento.codice=\'TODO\') ORDER BY data_richiesta ASC'); - -if (!empty($rs)) { - echo ' - - - - - '; - - foreach ($rs as $r) { - $data_richiesta = !empty($r['data_richiesta']) ? Translator::dateToLocale($r['data_richiesta']) : ''; - - echo ' - - - - '; - } - echo ' -
    '.tr('Attività').''.tr('Data richiesta').'
    - '.Modules::link('Interventi', $r['id'], 'Intervento n. '.$r['codice'].' del '.$data_richiesta).'
    - '.$r['ragione_sociale'].' -
    '.$data_richiesta.'
    '; -} else { - echo ' -

    '.tr('Non ci sono attività da programmare').'.

    '; -} diff --git a/modules/iva/actions.php b/modules/iva/actions.php deleted file mode 100755 index 6d7ce8f75..000000000 --- a/modules/iva/actions.php +++ /dev/null @@ -1,98 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -switch (filter('op')) { - case 'update': - $descrizione = post('descrizione'); - $codice = post('codice'); - - $esente = post('esente'); - $percentuale = empty($esente) ? post('percentuale') : 0; - - if ($dbo->fetchNum('SELECT * FROM `co_iva` WHERE (`descrizione` = '.prepare($descrizione).' AND `codice` = '.prepare($codice).') AND `id` != '.prepare($id_record)) == 0) { - $codice_natura = post('codice_natura_fe') ?: null; - $esigibilita = post('esigibilita'); - - $dbo->update('co_iva', [ - 'descrizione' => $descrizione, - 'esente' => $esente, - 'percentuale' => $percentuale, - 'indetraibile' => post('indetraibile'), - 'dicitura' => post('dicitura'), - 'codice' => $codice, - 'codice_natura_fe' => $codice_natura, - 'esigibilita' => $esigibilita, - ], ['id' => $id_record]); - - // Messaggio di avvertenza - if ((stripos('N6', (string) $codice_natura) === 0) && $esigibilita == 'S') { - flash()->warning(tr('Combinazione di natura IVA _TYPE_ ed esigibilità non compatibile', [ - '_TYPE_' => $codice_natura, - ])); - } - - flash()->info(tr('Salvataggio completato!')); - } else { - flash()->error(tr("E' già presente una tipologia di _TYPE_ con lo stesso codice e descrizione", [ - '_TYPE_' => 'IVA', - ])); - } - break; - - case 'add': - $descrizione = post('descrizione'); - $codice = post('codice'); - $esente = post('esente'); - $percentuale = empty($esente) ? post('percentuale') : 0; - $codice_natura = post('codice_natura_fe') ?: null; - if ($dbo->fetchNum('SELECT * FROM `co_iva` WHERE `descrizione` = '.prepare($descrizione).' AND `codice` = '.prepare($codice)) == 0) { - $dbo->insert('co_iva', [ - 'descrizione' => $descrizione, - 'esente' => $esente, - 'codice' => $codice, - 'codice_natura_fe' => $codice_natura, - 'percentuale' => $percentuale, - 'indetraibile' => post('indetraibile'), - ]); - $id_record = $dbo->lastInsertedID(); - - flash()->info(tr('Aggiunta nuova tipologia di _TYPE_', [ - '_TYPE_' => 'IVA', - ])); - } else { - flash()->error(tr("E' già presente una tipologia di _TYPE_ con lo stesso codice e descrizione", [ - '_TYPE_' => 'IVA', - ])); - } - - break; - - case 'delete': - if (isset($id_record)) { - $dbo->query('UPDATE `co_iva` SET deleted_at = NOW() WHERE `id`='.prepare($id_record)); - - flash()->info(tr('Tipologia di _TYPE_ eliminata con successo', [ - '_TYPE_' => 'IVA', - ])); - } - - break; -} diff --git a/modules/iva/add.php b/modules/iva/add.php deleted file mode 100755 index ebc4f5d58..000000000 --- a/modules/iva/add.php +++ /dev/null @@ -1,81 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1 ]} -
    - -
    - {[ "type": "number", "label": "", "name": "codice", "required": 1, "decimals":0, "min-value":"0", "max-value":"999", "maxlength": 3 ]} -
    -
    - -
    -
    - {[ "type": "checkbox", "label": "", "name": "esente", "id": "esente-add", "value": "$esente$" ]} -
    - -
    - {[ "type": "number", "label": "", "name": "percentuale", "id": "percentuale-add", "icon-after": "", "max-value": "100" ]} -
    -
    -
    -
    - {[ "type": "number", "label": "", "name": "indetraibile", "icon-after": "", "max-value": "100" ]} -
    - -
    - {[ "type": "select", "label": "", "name": "codice_natura_fe", "values": "query=SELECT codice as id, CONCAT(codice, ' - ', descrizione) AS descrizione FROM fe_natura", "extra": "disabled" ]} -
    - -
    - - -
    -
    - -
    -
    -
    - - diff --git a/modules/iva/ajax/select.php b/modules/iva/ajax/select.php deleted file mode 100755 index 100707daf..000000000 --- a/modules/iva/ajax/select.php +++ /dev/null @@ -1,50 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -switch ($resource) { - /* - * Opzioni utilizzate: - * - split_payment - */ - case 'iva': - $query = 'SELECT id, IF( codice_natura_fe IS NULL, IF(codice IS NULL, descrizione, CONCAT(codice, " - ", descrizione)), CONCAT( IF(codice IS NULL, descrizione, CONCAT(codice, " - ", descrizione)), " (", codice_natura_fe, ")" ) ) AS descrizione, percentuale FROM co_iva |where| ORDER BY descrizione ASC'; - - foreach ($elements as $element) { - $filter[] = 'id='.prepare($element); - } - - if (!empty($search)) { - $search_fields[] = 'descrizione LIKE '.prepare('%'.$search.'%'); - $search_fields[] = 'codice LIKE '.prepare('%'.$search.'%'); - $search_fields[] = 'codice_natura_fe LIKE '.prepare('%'.$search.'%'); - } - - if (empty($filter)) { - $where[] = 'deleted_at IS NULL'; - - //se sto valorizzando un documento con lo split payment impedisco la selezione delle aliquote iva con natura N6.X (reverse charge) - if (isset($superselect['split_payment']) and !empty($superselect['split_payment'])) { - $where[] = '(codice_natura_fe IS NULL OR codice_natura_fe NOT LIKE "N6%")'; - } - } - - break; -} diff --git a/modules/iva/bulk.php b/modules/iva/bulk.php deleted file mode 100755 index 961340885..000000000 --- a/modules/iva/bulk.php +++ /dev/null @@ -1,56 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -switch (post('op')) { - case 'delete-bulk': - $count_iva = $dbo->fetchNum('SELECT id FROM `co_iva` WHERE deleted_at IS NOT NULL'); - foreach ($id_records as $id) { - $res = $dbo->fetchNum('SELECT `co_righe_documenti`.`id` FROM `co_righe_documenti` WHERE `co_righe_documenti`.`idiva`='.prepare($id). - ' UNION SELECT `co_righe_preventivi`.`id` FROM `co_righe_preventivi` WHERE `co_righe_preventivi`.`idiva` = '.prepare($id). - ' UNION SELECT `co_righe_contratti`.`id` FROM `co_righe_contratti` WHERE `co_righe_contratti`.`idiva` = '.prepare($id). - ' UNION SELECT `dt_righe_ddt`.`id` FROM `dt_righe_ddt` WHERE `dt_righe_ddt`.`idiva` = '.prepare($id). - ' UNION SELECT `or_righe_ordini`.`id` FROM `or_righe_ordini` WHERE `or_righe_ordini`.`idiva` = '.prepare($id). - ' UNION SELECT `mg_articoli`.`id` FROM `mg_articoli` WHERE `mg_articoli`.`idiva_vendita` = '.prepare($id). - ' UNION SELECT `an_anagrafiche`.`idanagrafica` AS `id` FROM `an_anagrafiche` WHERE `an_anagrafiche`.`idiva_vendite` = '.prepare($id).' OR `an_anagrafiche`.`idiva_acquisti` = '.prepare($id)); - - if (empty($res)) { - $dbo->query('UPDATE `co_iva` SET deleted_at = NOW() WHERE id = '.prepare($id).Modules::getAdditionalsQuery($id_module)); - } - } - $count_iva = $dbo->fetchNum('SELECT id FROM `co_iva` WHERE deleted_at IS NOT NULL') - $count_iva; - - if ($count_iva > 0) { - $msg = tr('_NUM_ tipologi_A_ iva eliminat_A_.', [ - '_NUM_' => $count_iva, - '_A_' => ($count_iva == 1) ? 'a' : 'e', ]); - - flash()->info($msg); - } else { - flash()->warning(tr('Nessuna tipologia iva eliminata!')); - } - break; -} - -$bulk = [ - 'delete-bulk' => tr('Elimina selezionati'), -]; - -return $bulk; diff --git a/modules/iva/edit.php b/modules/iva/edit.php deleted file mode 100755 index f76c265e0..000000000 --- a/modules/iva/edit.php +++ /dev/null @@ -1,137 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$esigibilita = [ - [ - 'id' => 'I', - 'text' => tr('IVA ad esigibilità immediata'), - ], - [ - 'id' => 'D', - 'text' => tr('IVA ad esigibilità differita'), - ], - [ - 'id' => 'S', - 'text' => tr('Scissione dei pagamenti'), - ], -]; - -$res = $dbo->fetchNum('SELECT `co_righe_documenti`.`id` FROM `co_righe_documenti` WHERE `co_righe_documenti`.`idiva`='.prepare($id_record). -' UNION SELECT `co_righe_preventivi`.`id` FROM `co_righe_preventivi` WHERE `co_righe_preventivi`.`idiva` = '.prepare($id_record). -' UNION SELECT `co_righe_contratti`.`id` FROM `co_righe_contratti` WHERE `co_righe_contratti`.`idiva` = '.prepare($id_record). -' UNION SELECT `dt_righe_ddt`.`id` FROM `dt_righe_ddt` WHERE `dt_righe_ddt`.`idiva` = '.prepare($id_record). -' UNION SELECT `or_righe_ordini`.`id` FROM `or_righe_ordini` WHERE `or_righe_ordini`.`idiva` = '.prepare($id_record). -' UNION SELECT `mg_articoli`.`id` FROM `mg_articoli` WHERE `mg_articoli`.`idiva_vendita` = '.prepare($id_record). -' UNION SELECT `an_anagrafiche`.`idanagrafica` AS `id` FROM `an_anagrafiche` WHERE `an_anagrafiche`.`idiva_vendite` = '.prepare($id_record).' OR `an_anagrafiche`.`idiva_acquisti` = '.prepare($id_record)); -$is_readonly = 0; -if ($res) { - $is_readonly = '1'; -} - -?>
    - - - - -
    -
    -

    -
    - -
    -
    -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1, "value": "$descrizione$" ]} -
    -
    - -
    -
    - {[ "type": "checkbox", "label": "", "name": "esente", "id": "esente-edit", "value": "$esente$", "readonly": "", "extra": ""]} -
    - -
    - {[ "type": "number", "label": "", "name": "percentuale", "id": "percentuale-edit", "value": "$percentuale$", "icon-after": "", "disabled": , "readonly": "", "extra": "", "max-value": "100" ]} -
    - -
    - {[ "type": "number", "label": "", "name": "indetraibile", "value": "$indetraibile$", "icon-after": "", "readonly": "", "extra": "", "max-value": "100" ]} -
    -
    - -
    -
    - {[ "type": "number", "label": "", "name": "codice", "value": "$codice$", "required": 1, "decimals":0, "min-value":"0", "max-value":"999", "maxlength": 3, "extra": "" ]} -
    - -
    - {[ "type": "select", "label": "", "name": "codice_natura_fe", "value": "$codice_natura_fe$", "required": , "disabled": , "values": "query=SELECT codice as id, CONCAT(codice, ' - ', descrizione) AS descrizione FROM fe_natura", "readonly": "", "extra": "" ]} -
    - -
    - {[ "type": "select", "label": "", "name": "esigibilita", "value": "$esigibilita$", "values": , "required": 1, "readonly": "", "extra": "" ]} -
    -
    - -
    -
    - {[ "type": "textarea", "label": "", "name": "dicitura", "value": "$dicitura$" ]} -
    -
    -
    -
    - -
    - - - - - - -

    '.tr('Ci sono '.count($res).' documenti collegati a questa aliquota IVA. Non è possibile eliminarla o modificarne alcuni campi.').'

    - '; -} else { - echo ' - - '.tr('Elimina').' - '; -} diff --git a/modules/iva/init.php b/modules/iva/init.php deleted file mode 100755 index e1b52a7e3..000000000 --- a/modules/iva/init.php +++ /dev/null @@ -1,24 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT * FROM `co_iva` WHERE id='.prepare($id_record)); -} diff --git a/modules/iva/src/Aliquota.php b/modules/iva/src/Aliquota.php deleted file mode 100755 index 67e2afcd8..000000000 --- a/modules/iva/src/Aliquota.php +++ /dev/null @@ -1,30 +0,0 @@ -. - */ - -namespace Modules\Iva; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; - -class Aliquota extends Model -{ - use SimpleModelTrait; - - protected $table = 'co_iva'; -} diff --git a/modules/liste_newsletter/actions.php b/modules/liste_newsletter/actions.php deleted file mode 100755 index da6e6300c..000000000 --- a/modules/liste_newsletter/actions.php +++ /dev/null @@ -1,72 +0,0 @@ -. - */ - -use Modules\Newsletter\Lista; - -include_once __DIR__.'/../../core.php'; - -switch (filter('op')) { - case 'add': - $lista = Lista::build(filter('name')); - $id_record = $lista->id; - - flash()->info(tr('Nuova lista newsletter creata!')); - - break; - - case 'update': - $lista->name = filter('name'); - $lista->description = filter('description'); - - $query = filter('query'); - if (check_query($query)) { - $lista->query = html_entity_decode($query); - } - - $lista->save(); - - flash()->info(tr('Lista newsletter salvata!')); - - break; - - case 'delete': - $lista->delete(); - - flash()->info(tr('Lista newsletter rimossa!')); - - break; - - case 'add_receivers': - $receivers = post('receivers'); - - $lista->anagrafiche()->syncWithoutDetaching($receivers); - - flash()->info(tr('Aggiunti nuovi destinatari alla lista!')); - - break; - - case 'remove_receiver': - $receiver = post('id'); - - $lista->anagrafiche()->detach($receiver); - - flash()->info(tr('Destinatario rimosso dalla lista!')); - - break; -} diff --git a/modules/liste_newsletter/add.php b/modules/liste_newsletter/add.php deleted file mode 100755 index d0b89c6b9..000000000 --- a/modules/liste_newsletter/add.php +++ /dev/null @@ -1,39 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo ' -
    - - - -
    -
    - {[ "type": "text", "label": "'.tr('Nome').'", "name": "name", "required": 1 ]} -
    -
    - - -
    -
    - -
    -
    -
    '; diff --git a/modules/liste_newsletter/edit.php b/modules/liste_newsletter/edit.php deleted file mode 100755 index 5f7eafa2c..000000000 --- a/modules/liste_newsletter/edit.php +++ /dev/null @@ -1,139 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo ' -
    - - - - -
    -
    -

    '.tr('Dati campagna').'

    -
    - -
    -
    -
    - {[ "type": "text", "label": "'.tr('Nome').'", "name": "name", "required": 1, "value": "$name$" ]} -
    -
    - -
    -
    - {[ "type": "textarea", "label": "'.tr('Descrizione').'", "name": "description", "required": 0, "value": "$description$" ]} -
    -
    - -
    -
    - {[ "type": "textarea", "label": "'.tr('Query dinamica').'", "name": "query", "required": 0, "value": "$query$", "help": "'.tr("La query SQL deve restituire gli identificativi delle anagrafiche da inserire nella lista, sotto un campo di nome ''id''").'. '.tr('Per esempio: _SQL_', [ - '_SQL_' => 'SELECT idanagrafica AS id FROM an_anagrafiche', - ]).'" ]} -
    -
    -
    -
    -
    - -
    - - - - -
    -
    -

    '.tr('Aggiunta destinatari').'

    -
    - -
    -
    -
    - {[ "type": "select", "label": "'.tr('Destinatari').'", "name": "receivers[]", "ajax-source": "anagrafiche_newsletter", "multiple": 1, "disabled": '.intval(!empty($lista->query)).' ]} -
    -
    - -
    -
    - -
    -
    -
    -
    -
    '; - -$anagrafiche = $lista->anagrafiche; - -echo ' - -
    -
    -

    - '.tr('Destinatari').' - '.$anagrafiche->count().' -

    -
    - -
    '; - -if (!$anagrafiche->isEmpty()) { - echo ' - - - - - - - - - - '; - - foreach ($anagrafiche as $anagrafica) { - echo ' - email) ? 'class="bg-danger"' : '').'> - - - - '; - } - - echo ' - -
    '.tr('Nome').''.tr('Indirizzo').'#
    '.Modules::link('Anagrafiche', $anagrafica->id, $anagrafica->ragione_sociale).''.$anagrafica->email.' - query) ? 'disabled' : '').'> - - -
    '; -} else { - echo ' -

    '.tr('Nessuna anagrafica collegata alla lista').'.

    '; -} - - echo ' -
    -
    - - - '.tr('Elimina').' -'; diff --git a/modules/liste_newsletter/init.php b/modules/liste_newsletter/init.php deleted file mode 100755 index 5d0acd1b9..000000000 --- a/modules/liste_newsletter/init.php +++ /dev/null @@ -1,28 +0,0 @@ -. - */ - -use Modules\Newsletter\Lista; - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $lista = Lista::find($id_record); - - $record = $lista->toArray(); -} diff --git a/modules/misure/actions.php b/modules/misure/actions.php deleted file mode 100755 index 085ad1652..000000000 --- a/modules/misure/actions.php +++ /dev/null @@ -1,86 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -switch (filter('op')) { - case 'update': - $valore = filter('valore'); - - if (isset($valore)) { - if ($dbo->fetchNum('SELECT * FROM `mg_unitamisura` WHERE `valore`='.prepare($valore).' AND `id`!='.prepare($id_record)) == 0) { - $dbo->query('UPDATE `mg_unitamisura` SET `valore`='.prepare($valore).' WHERE `id`='.prepare($id_record)); - flash()->info(tr('Salvataggio completato.')); - } else { - flash()->error(tr("E' già presente una tipologia di _TYPE_ con lo stesso valore.", [ - '_TYPE_' => 'unità di misura', - ])); - } - } else { - flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio')); - } - - break; - - case 'add': - $valore = filter('valore'); - - if (isset($valore)) { - if ($dbo->fetchNum('SELECT * FROM `mg_unitamisura` WHERE `valore`='.prepare($valore)) == 0) { - $dbo->query('INSERT INTO `mg_unitamisura` (`valore`) VALUES ('.prepare($valore).')'); - - $id_record = $dbo->lastInsertedID(); - - if (isAjaxRequest()) { - echo json_encode(['id' => $valore, 'text' => $valore]); - } - - flash()->info(tr('Aggiunta nuova tipologia di _TYPE_', [ - '_TYPE_' => 'unità di misura', - ])); - } else { - flash()->error(tr("E' già presente una tipologia di _TYPE_ con lo stesso valore.", [ - '_TYPE_' => 'unità di misura', - ])); - } - } 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'])); - - if (isset($id_record) && empty($righe)) { - $dbo->query('DELETE FROM `mg_unitamisura` WHERE `id`='.prepare($id_record)); - flash()->info(tr('Tipologia di _TYPE_ eliminata con successo!', [ - '_TYPE_' => 'unità di misura', - ])); - } else { - flash()->error(tr('Sono presenti righe collegate a questa unità di misura.')); - } - - break; -} diff --git a/modules/misure/add.php b/modules/misure/add.php deleted file mode 100755 index 46448cf8d..000000000 --- a/modules/misure/add.php +++ /dev/null @@ -1,38 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "valore", "required": 1 ]} -
    -
    - - -
    -
    - -
    -
    -
    diff --git a/modules/misure/edit.php b/modules/misure/edit.php deleted file mode 100755 index c191a87a4..000000000 --- a/modules/misure/edit.php +++ /dev/null @@ -1,63 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - - -
    -
    -

    -
    - -
    -
    -
    - {[ "type": "text", "label": "", "name": "valore", "required": 1, "value": "$valore$" ]} -
    -
    -
    -
    - -
    - -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'])); - -if (!empty($righe)) { - echo ' -
    - '.tr('Ci sono _NUM_ righe collegate', [ - '_NUM_' => count($righe), - ]).'. -
    '; -} -?> - - - - diff --git a/modules/misure/init.php b/modules/misure/init.php deleted file mode 100755 index b349dc392..000000000 --- a/modules/misure/init.php +++ /dev/null @@ -1,24 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT * FROM `mg_unitamisura` WHERE id='.prepare($id_record)); -} diff --git a/modules/modelli_primanota/actions.php b/modules/modelli_primanota/actions.php deleted file mode 100755 index 5a50809e2..000000000 --- a/modules/modelli_primanota/actions.php +++ /dev/null @@ -1,87 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -switch (post('op')) { - case 'add': - $idmastrino = get_new_idmastrino('co_movimenti_modelli'); - $descrizione = post('descrizione'); - $nome = post('nome'); - - for ($i = 0; $i < sizeof(post('idconto')); ++$i) { - $idconto = post('idconto')[$i]; - $dare = post('dare')[$i]; - $avere = post('avere')[$i]; - - if (!empty($idconto)) { - if (!empty($dare)) { - $totale = $dare; - } else { - $totale = -$avere; - } - $query = 'INSERT INTO co_movimenti_modelli(idmastrino, nome, descrizione, idconto, totale) VALUES('.prepare($idmastrino).', '.prepare($nome).', '.prepare($descrizione).', '.prepare($idconto).', '.prepare($totale).')'; - if ($dbo->query($query)) { - $id_record = $idmastrino; - } - } - } - - break; - - case 'editriga': - $idmastrino = post('idmastrino'); - $descrizione = post('descrizione'); - $nome = post('nome'); - - // Eliminazione prima nota - $dbo->query('DELETE FROM co_movimenti_modelli WHERE idmastrino='.prepare($idmastrino)); - - for ($i = 0; $i < sizeof(post('idconto')); ++$i) { - $idconto = post('idconto')[$i]; - $dare = post('dare')[$i]; - $avere = post('avere')[$i]; - - if (!empty($idconto)) { - if (!empty($dare)) { - $totale = $dare; - } else { - $totale = -$avere; - } - $query = 'INSERT INTO co_movimenti_modelli(idmastrino, nome, descrizione, idconto, totale) VALUES('.prepare($idmastrino).', '.prepare($nome).', '.prepare($descrizione).', '.prepare($idconto).', '.prepare($totale).')'; - if ($dbo->query($query)) { - $id_record = $idmastrino; - } - } - } - - break; - - case 'delete': - $idmastrino = post('idmastrino'); - - if (!empty($idmastrino)) { - // Eliminazione prima nota - $dbo->query('DELETE FROM co_movimenti_modelli WHERE idmastrino='.prepare($idmastrino)); - - flash()->info(tr('Movimento eliminato!')); - } - - break; -} diff --git a/modules/modelli_primanota/add.php b/modules/modelli_primanota/add.php deleted file mode 100755 index fafa65c4f..000000000 --- a/modules/modelli_primanota/add.php +++ /dev/null @@ -1,150 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "nome", "required": 1 ]} -
    -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1 ]} -
    -
    - - - - '.tr('Conto').' - '.tr('Dare').' - '.tr('Avere').' - '; - - for ($i = 0; $i < 10; ++$i) { - $required = ($i <= 1) ? 1 : 0; - - // Conto - echo ' - - - {[ "type": "select", "name": "idconto['.$i.']", "ajax-source": "conti", "required": "'.$required.'" ]} - - - - {[ "type": "number", "name": "dare['.$i.']", "id": "dare'.$id.'", "value": "'.($rs[$i]['totale'] > 0 ? $rs[$i]['totale'] : '').'"]} - - - - {[ "type": "number", "name": "avere['.$i.']", "id": "avere'.$id.'", "value": "'.($rs[$i]['totale'] < 0 ? abs($rs[$i]['totale']) : '').'"]} - - '; - } - - echo ' - '; - - // Variabili utilizzabili - $variables = include Modules::filepath(Modules::get('Fatture di vendita')['id'], 'variables.php'); - - echo ' - -
    -
    '; - - if (!empty($variables)) { - echo ' -

    '.tr("Puoi utilizzare le seguenti sequenze di testo all'interno del campo causale, verranno sostituite in fase generazione prima nota dalla fattura.").':

    -
      '; - - foreach ($variables as $variable => $value) { - echo ' -
    • {'.$variable.'}
    • '; - } - - echo ' -
    '; - } else { - echo ' -

    '.tr('Non sono state definite variabili da utilizzare nel template').'.

    '; - } - - echo ' -
    -
    '; -?> - - -
    -
    - -
    -
    -
    - - \ No newline at end of file diff --git a/modules/modelli_primanota/edit.php b/modules/modelli_primanota/edit.php deleted file mode 100755 index 364b02f01..000000000 --- a/modules/modelli_primanota/edit.php +++ /dev/null @@ -1,187 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - - - - - -
    -
    - {[ "type": "text", "label": "", "name": "nome", "required": 1, "value": "$nome$" ]} -
    -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1, "value": "$descrizione$" ]} -
    -
    - -fetchArray($query2); -for ($x = 0; $x < sizeof($conti2); ++$x) { - $query3 = 'SELECT * FROM co_pianodeiconti3 WHERE idpianodeiconti2='.prepare($conti2[$x]['id']); - $rs3 = $dbo->fetchArray($query3); - for ($y = 0; $y < sizeof($rs3); ++$y) { - // Creo un array con le descrizioni dei conti di livello 3 che ha come indice l'id del livello2 e del livello3 - $conti3[$rs3[$y]['idpianodeiconti2']][$y]['id'] = $rs3[$y]['id']; - $conti3[$rs3[$y]['idpianodeiconti2']][$y]['descrizione'] = $conti2[$x]['numero'].'.'.$rs3[$y]['numero'].' '.$rs3[$y]['descrizione']; - } -} - -/* - Form di modifica riga movimento -*/ -echo ' - - - - - '; - -// Lettura movimenti del mastrino selezionato -$rs = $dbo->fetchArray('SELECT * FROM co_movimenti_modelli WHERE idmastrino='.prepare($record['idmastrino'])); -for ($i = 0; $i < 10; ++$i) { - $required = ($i <= 1) ? 1 : 0; - - // Conto - echo ' - - - - - - - '; -} - -echo ' -
    '.tr('Conto').''.tr('Dare').''.tr('Avere').'
    - {[ "type": "select", "name": "idconto['.$i.']", "value": "'.$rs[$i]['idconto'].'", "ajax-source": "conti-modelliprimanota", "required": "'.$required.'" ]} - - {[ "type": "number", "name": "dare['.$i.']", "id": "dare'.$id.'", "value": "'.($rs[$i]['totale'] > 0 ? $rs[$i]['totale'] : '').'"]} - - {[ "type": "number", "name": "avere['.$i.']", "id": "avere'.$id.'", "value": "'.($rs[$i]['totale'] < 0 ? abs($rs[$i]['totale']) : '').'"]} -
    '; -?> - - - - -
    - - -
    -
    '; - -if (!empty($variables)) { - echo ' -

    '.tr("Puoi utilizzare le seguenti sequenze di testo all'interno del campo causale, verranno sostituite in fase generazione prima nota dalla fattura.").':

    -
      '; - - foreach ($variables as $variable => $value) { - echo ' -
    • {'.$variable.'}
    • '; - } - - echo ' -
    '; -} else { - echo ' -

    '.tr('Non sono state definite variabili da utilizzare nel template').'.

    '; -} - -echo ' -
    -
    '; -?> - - - - - - - - diff --git a/modules/modelli_primanota/init.php b/modules/modelli_primanota/init.php deleted file mode 100755 index d79598f0b..000000000 --- a/modules/modelli_primanota/init.php +++ /dev/null @@ -1,22 +0,0 @@ -. - */ - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT * FROM co_movimenti_modelli WHERE idmastrino='.prepare($id_record)); -} diff --git a/modules/movimenti/actions.php b/modules/movimenti/actions.php deleted file mode 100755 index b7d082664..000000000 --- a/modules/movimenti/actions.php +++ /dev/null @@ -1,63 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Articoli\Articolo; - -switch (post('op')) { - case 'add': - $articolo = Articolo::find(post('idarticolo')); - $tipo_movimento = post('tipo_movimento'); - $descrizione = post('movimento'); - $data = post('data'); - $qta = post('qta'); - - $idsede_partenza = post('idsede_partenza'); - $idsede_destinazione = post('idsede_destinazione'); - - if ($tipo_movimento == 'carico' || $tipo_movimento == 'scarico') { - if ($tipo_movimento == 'carico') { - $id_sede_azienda = $idsede_destinazione; - $id_sede_controparte = 0; - } elseif ($tipo_movimento == 'scarico') { - $id_sede_azienda = $idsede_partenza; - $id_sede_controparte = 0; - - $qta = -$qta; - } - - // Registrazione del movimento con variazione della quantità - $articolo->movimenta($qta, $descrizione, $data, 1, [ - 'idsede' => $id_sede_azienda, - ]); - } elseif ($tipo_movimento == 'spostamento') { - // Registrazione del movimento verso la sede di destinazione - $articolo->registra($qta, $descrizione, $data, 1, [ - 'idsede' => $idsede_destinazione, - ]); - - // Registrazione del movimento dalla sede di origine - $articolo->registra(-$qta, $descrizione, $data, 1, [ - 'idsede' => $idsede_partenza, - ]); - } - - break; -} diff --git a/modules/movimenti/add.php b/modules/movimenti/add.php deleted file mode 100755 index 748dfec3d..000000000 --- a/modules/movimenti/add.php +++ /dev/null @@ -1,329 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -// Imposto come azienda l'azienda predefinita per selezionare le sedi a cui ho accesso -// select-options - -if (setting('Attiva scorciatoie da tastiera')) { - echo '
    - '.tr('Scorciatoie da tastiera: F7 - Barcode, F8 - Carico, F9 - Sarico, F10 - Spostamento').' -
    '; -} - -?> - - - - -
    - - - -
    -
    - {["type": "text", "label": "", "name": "barcode", "icon-before": "" ]} -
    -
    - -
    -
    - {["type": "select", "label": "", "name": "idarticolo", "ajax-source": "articoli", "value": "", "required": 1, "select-options": {"permetti_movimento_a_zero": 1, "idanagrafica": , "idsede_partenza": 0, "idsede_destinazione": 0} ]} -
    - -
    - {["type": "number", "label": "", "name": "qta", "decimals": "qta", "value": "1", "required": 1 ]} -
    - -
    - {["type": "date", "label": "", "name": "data", "value": "-now-", "required": 1 ]} -
    - -
    - {["type": "select", "label": "", "name": "causale", "values": "query=SELECT id, nome as text, descrizione, tipo_movimento FROM mg_causali_movimenti", "value": 1, "required": 1 ]} - -
    -
    - -
    -
    - {["type": "textarea", "label": "", "name": "movimento", "required": 1, "value": "Carico manuale" ]} -
    -
    - -
    -
    - {[ "type": "select", "label": "", "name": "idsede_partenza", "ajax-source": "sedi_azienda", "value": "0", "required": 1, "disabled": "1" ]} -
    - -
    - {[ "type": "select", "label": "", "name": "idsede_destinazione", "ajax-source": "sedi_azienda", "value": "0", "required": 1 ]} -
    -
    - - -
    -
    - - -
    -
    -
    - - -
    - - - -'; - -echo ' -'; diff --git a/modules/newsletter/actions.php b/modules/newsletter/actions.php deleted file mode 100755 index 27cd53788..000000000 --- a/modules/newsletter/actions.php +++ /dev/null @@ -1,189 +0,0 @@ -. - */ - -use Modules\Emails\Template; -use Modules\Newsletter\Lista; -use Modules\Newsletter\Newsletter; - -include_once __DIR__.'/../../core.php'; - -switch (filter('op')) { - case 'add': - $template = Template::find(filter('id_template')); - $newsletter = Newsletter::build($user, $template, filter('name')); - - $id_record = $newsletter->id; - - flash()->info(tr('Nuova campagna newsletter creata!')); - - break; - - case 'update': - $newsletter->name = filter('name'); - $newsletter->state = filter('state'); - $newsletter->completed_at = filter('completed_at'); - - $newsletter->subject = filter('subject'); - $newsletter->content = $_POST['content']; //filter('content'); - - $newsletter->save(); - - flash()->info(tr('Campagna newsletter salvata!')); - - break; - - case 'delete': - $newsletter->delete(); - - flash()->info(tr('Campagna newsletter rimossa!')); - - break; - - case 'send': - $anagrafiche = $newsletter->anagrafiche; - $template = $newsletter->template; - - $uploads = $newsletter->uploads()->pluck('id'); - - foreach ($anagrafiche as $anagrafica) { - if (empty($anagrafica['email']) || empty($anagrafica['enable_newsletter'])) { - continue; - } - - $mail = \Modules\Emails\Mail::build($user, $template, $anagrafica->id); - - $mail->addReceiver($anagrafica['email']); - $mail->subject = $newsletter->subject; - $mail->content = $newsletter->content; - - $mail->id_newsletter = $newsletter->id; - - foreach ($uploads as $upload) { - $mail->addUpload($upload); - } - - $mail->save(); - - $newsletter->anagrafiche()->updateExistingPivot($anagrafica->id, ['id_email' => $mail->id]); - } - - $newsletter->state = 'WAIT'; - $newsletter->save(); - - flash()->info(tr('Campagna newsletter in invio!')); - - break; - - case 'block': - $mails = $newsletter->emails; - - foreach ($mails as $mail) { - if (empty($mail->sent_at)) { - $newsletter->emails()->updateExistingPivot($mail->id, ['id_email' => null], false); - - $mail->delete(); - } - } - - $newsletter->state = 'DEV'; - $newsletter->save(); - - flash()->info(tr('Coda della campagna newsletter svuotata!')); - - break; - - case 'add_receivers': - $receivers = post('receivers'); - - $id_list = post('id_list'); - if (!empty($id_list)) { - $list = Lista::find($id_list); - $receivers = $list->anagrafiche->pluck('idanagrafica'); - } - - $newsletter->anagrafiche()->syncWithoutDetaching($receivers); - - //Controllo indirizzo e-mail aggiunto - foreach ($newsletter->anagrafiche as $anagrafica) { - if (!empty($anagrafica['email'])) { - $check = Validate::isValidEmail($anagrafica['email']); - - if (empty($check['valid-format'])) { - $errors[] = $anagrafica['email']; - } - } else { - $errors[] = tr('Indirizzo e-mail mancante per "_EMAIL_"', [ - '_EMAIL_' => $anagrafica['ragione_sociale'], - ]); - } - } - - if (!empty($errors)) { - $message = '
      '; - foreach ($errors as $error) { - $message .= '
    • '.$error.'
    • '; - } - $message .= '
    '; - } - - if (!empty($message)) { - flash()->warning(tr('Attenzione questi indirizzi e-mail non sembrano essere validi: _EMAIL_ ', [ - '_EMAIL_' => $message, - ])); - } else { - flash()->info(tr('Nuovi destinatari aggiunti correttamente alla newsletter!')); - } - - break; - - case 'remove_receiver': - $receiver = post('id'); - - $newsletter->anagrafiche()->detach($receiver); - - flash()->info(tr('Destinatario rimosso dalla newsletter!')); - - break; - - case 'remove_all_receiver': - //$receiver = post('id'); - - $anagrafiche = $newsletter->anagrafiche; - - foreach ($anagrafiche as $anagrafica) { - $newsletter->anagrafiche()->detach($anagrafica->id); - } - - flash()->info(tr('Tutti i destinatari sono stati rimossi dalla newsletter!')); - - break; - - // Duplica newsletter - case 'copy': - $new = $newsletter->replicate(); - $new->state = 'DEV'; - $new->completed_at = null; - $new->save(); - - $id_record = $new->id; - - flash()->info(tr('Newsletter duplicata correttamente!')); - - break; -} diff --git a/modules/newsletter/add.php b/modules/newsletter/add.php deleted file mode 100755 index 14360714a..000000000 --- a/modules/newsletter/add.php +++ /dev/null @@ -1,43 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo ' -
    - - - -
    -
    - {[ "type": "select", "label": "'.tr('Template email').'", "name": "id_template", "values": "query=SELECT id, name AS descrizione FROM em_templates WHERE deleted_at IS NULL ORDER BY descrizione", "required": 1 ]} -
    - -
    - {[ "type": "text", "label": "'.tr('Nome').'", "name": "name", "required": 1 ]} -
    -
    - - -
    -
    - -
    -
    -
    '; diff --git a/modules/newsletter/ajax/select.php b/modules/newsletter/ajax/select.php deleted file mode 100755 index 44dab59f9..000000000 --- a/modules/newsletter/ajax/select.php +++ /dev/null @@ -1,93 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -switch ($resource) { - case 'anagrafiche_newsletter': - $query = "SELECT an_anagrafiche.idanagrafica AS id, CONCAT(ragione_sociale, IF(citta != '' OR provincia != '', CONCAT(' (', citta, IF(provincia != '', provincia, ''), ')'), ''), ' [', email, ']') AS descrizione, `an_tipianagrafiche`.`descrizione` AS optgroup FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica |where| ORDER BY `optgroup` ASC, ragione_sociale ASC"; - - foreach ($elements as $element) { - $filter[] = 'an_anagrafiche.idanagrafica='.prepare($element); - } - - if (empty($filter)) { - $where[] = 'deleted_at IS NULL'; - $where[] = 'enable_newsletter = 1'; - } - - if (!empty($search)) { - $search_fields[] = 'ragione_sociale LIKE '.prepare('%'.$search.'%'); - $search_fields[] = 'citta LIKE '.prepare('%'.$search.'%'); - $search_fields[] = 'provincia LIKE '.prepare('%'.$search.'%'); - $search_fields[] = 'email LIKE '.prepare('%'.$search.'%'); - } - - // Aggiunta filtri di ricerca - if (!empty($search_fields)) { - $where[] = '('.implode(' OR ', $search_fields).')'; - } - - if (!empty($filter)) { - $where[] = '('.implode(' OR ', $filter).')'; - } - - $query = str_replace('|where|', !empty($where) ? 'WHERE '.implode(' AND ', $where) : '', $query); - - $rs = $dbo->fetchArray($query); - foreach ($rs as $r) { - if ($prev != $r['optgroup']) { - $results[] = ['text' => $r['optgroup'], 'children' => []]; - $prev = $r['optgroup']; - } - - $results[count($results) - 1]['children'][] = [ - 'id' => $r['id'], - 'text' => $r['descrizione'], - 'descrizione' => $r['descrizione'], - ]; - } - break; - - case 'liste_newsletter': - $query = "SELECT id, CONCAT(name, ' (', (SELECT COUNT(*) FROM em_list_anagrafica WHERE em_lists.id = em_list_anagrafica.id_list), ' destinatari)') AS descrizione FROM em_lists |where| ORDER BY `name` ASC"; - - foreach ($elements as $element) { - $filter[] = 'id='.prepare($element); - } - - if (empty($filter)) { - $where[] = 'deleted_at IS NULL'; - } - - if (!empty($search)) { - $search_fields[] = 'name LIKE '.prepare('%'.$search.'%'); - } - - // Aggiunta filtri di ricerca - if (!empty($search_fields)) { - $where[] = '('.implode(' OR ', $search_fields).')'; - } - - if (!empty($filter)) { - $where[] = '('.implode(' OR ', $filter).')'; - } - - break; -} diff --git a/modules/newsletter/buttons.php b/modules/newsletter/buttons.php deleted file mode 100755 index 155b354ff..000000000 --- a/modules/newsletter/buttons.php +++ /dev/null @@ -1,42 +0,0 @@ -. - */ - -if ($newsletter->state == 'DEV' && !empty($template)) { - echo ' - '; -} elseif ($newsletter->state == 'WAIT') { - echo ' - '; -} - -// Duplica newsletter -echo ' -'; - -echo ' -
    - - -
    '; diff --git a/modules/newsletter/edit.php b/modules/newsletter/edit.php deleted file mode 100755 index fce917d86..000000000 --- a/modules/newsletter/edit.php +++ /dev/null @@ -1,242 +0,0 @@ -. - */ - -use Modules\Emails\Mail; -use Modules\Emails\Template; - -include_once __DIR__.'/../../core.php'; - -//Controllo se il template è ancora attivo -if (empty($template)) { - echo ' -
    '.tr('ATTENZIONE! Questa newsletter risulta collegata ad un template non più presente a sistema').'
    '; -} - -$block_edit = $newsletter->state != 'DEV'; - -$stati = [ - [ - 'id' => 'DEV', - 'text' => 'Bozza', - ], - [ - 'id' => 'WAIT', - 'text' => 'Invio in corso', - ], - [ - 'id' => 'OK', - 'text' => 'Completata', - ], -]; - -echo ' -
    - - - - -
    -
    -

    '.tr('Dati campagna').'

    -
    - -
    -
    -
    - '.Modules::link('Template email', $record['id_template'], null, null, 'class="pull-right"').' - {[ "type": "select", "label": "'.tr('Template email').'", "name": "id_template", "values": "query=SELECT id, name AS descrizione FROM em_templates WHERE deleted_at IS NULL ORDER BY descrizione", "required": 1, "value": "$id_template$", "readonly": 1 ]} -
    - -
    - {[ "type": "text", "label": "'.tr('Nome').'", "name": "name", "required": 1, "value": "$name$" ]} -
    -
    - -
    -
    - {[ "type": "select", "label": "'.tr('Stato').'", "name": "state", "values": '.json_encode($stati).', "required": 1, "value": "$state$", "class": "unblockable" ]} -
    - -
    - {[ "type": "timestamp", "label": "'.tr('Data di completamento').'", "name": "completed_at", "value": "$completed_at$", "readonly": 1 ]} -
    -
    - -
    -
    - {[ "type": "text", "label": "'.tr('Oggetto').'", "name": "subject", "value": "$subject$" ]} -
    -
    - -
    -
    - {[ "type": "ckeditor", "use_full_ckeditor": 1, "label": "'.tr('Contenuto').'", "name": "content", "value": "$content$" ]} -
    -
    - -
    -
    -
    - -
    - - - - -
    -
    -

    '.tr('Aggiunta destinatari').'

    -
    - -
    -
    -
    - {[ "type": "select", "label": "'.tr('Destinatari').'", "name": "receivers[]", "ajax-source": "anagrafiche_newsletter", "multiple": 1 ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Lista').'", "name": "id_list", "ajax-source": "liste_newsletter" ]} -
    -
    - -
    -
    - -
    -
    -
    -
    -
    -'; - -$anagrafiche = $newsletter->anagrafiche; - -echo ' - -
    -
    -

    - '.tr('Destinatari').' - ('.$anagrafiche->count().')
    - '.(($anagrafiche->where('email', '')->count() > 0) ? ' '.$anagrafiche->where('email', '')->count().'' : '') - .(($anagrafiche->where('enable_newsletter', false)->count() > 0) ? ' '.$anagrafiche->where('enable_newsletter', false)->count().'' : '').'
    -

    -
    - -
    '; - -if (!$anagrafiche->isEmpty()) { - echo ' - - - - - - - - - - - - - - '; - - foreach ($anagrafiche as $anagrafica) { - $mail_id = $anagrafica->pivot->id_email; - $mail = Mail::find($mail_id); - if (!empty($mail) && !empty($mail->sent_at)) { - $data = ' '.timestampFormat($mail->sent_at).''; - } else { - $data = ' - '.tr('Non ancora inviata').''; - } - - echo ' - email) ? 'class="bg-danger"' : (empty($anagrafica->enable_newsletter) ? 'class="bg-warning"' : '')).'> - - - - - - - - '; - } - - echo ' - -
    '.tr('Ragione sociale').''.tr('Tipo').''.tr('Tipologia').''.tr('E-mail').''.tr('Data di invio').''.tr('Newsletter').'#
    '.Modules::link('Anagrafiche', $anagrafica->id, $anagrafica->ragione_sociale).''.$database->fetchOne('SELECT GROUP_CONCAT(an_tipianagrafiche.descrizione) AS descrizione FROM an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica = an_tipianagrafiche.idtipoanagrafica WHERE an_tipianagrafiche_anagrafiche.idanagrafica='.prepare($anagrafica->id))['descrizione'].''.$anagrafica->tipo.' - '.((!empty($anagrafica->email) ? ' - {[ "type": "text", "name": "email", "id": "email_'.rand(0, 99999).'", "readonly": "1", "class": "email-mask", "value": "'.$anagrafica->email.'", "validation": "email" ]}' : ' '.tr('Indirizzo e-mail mancante').'')).''.$data.' - '.((!empty($anagrafica->enable_newsletter)) ? ' '.tr('Abilitato').'' : ' '.tr('Disabilitato').'').' - - - - -
    - - - Elimina tutti - - - '; -} else { - echo '
    '.tr('Nessuna anagrafica collegata alla campagna').'.
    '; -} - - echo ' -
    -
    - -{( "name": "filelist_and_upload", "id_module": "$id_module$", "id_record": "$id_record$" )} - - - '.tr('Elimina').' -'; - -if ($block_edit) { - echo ' -'; -} diff --git a/modules/newsletter/init.php b/modules/newsletter/init.php deleted file mode 100755 index be0b97d69..000000000 --- a/modules/newsletter/init.php +++ /dev/null @@ -1,31 +0,0 @@ -. - */ - -use Modules\Emails\Template; -use Modules\Newsletter\Newsletter; - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $newsletter = Newsletter::find($id_record); - - $record = $newsletter->toArray(); - - $template = Template::find($record['id_template']); -} diff --git a/modules/newsletter/src/Lista.php b/modules/newsletter/src/Lista.php deleted file mode 100755 index 7fcd5ff05..000000000 --- a/modules/newsletter/src/Lista.php +++ /dev/null @@ -1,77 +0,0 @@ -. - */ - -namespace Modules\Newsletter; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Eloquent\SoftDeletes; -use Modules\Anagrafiche\Anagrafica; -use Traits\RecordTrait; - -class Lista extends Model -{ - use SimpleModelTrait; - use SoftDeletes; - use RecordTrait; - - protected $table = 'em_lists'; - - public static function build($name) - { - $model = new static(); - $model->name = $name; - - $model->save(); - - return $model; - } - - public function save(array $options = []) - { - $result = parent::save($options); - - $query = $this->query; - if (!empty($query)) { - $results = database()->fetchArray($query); - - $anagrafiche = array_column($results, 'id'); - $this->anagrafiche()->sync($anagrafiche); - } - - return $result; - } - - // Relazione Eloquent - - public function anagrafiche() - { - return $this->belongsToMany(Anagrafica::class, 'em_list_anagrafica', 'id_list', 'id_anagrafica')->withTrashed(); - } - - /** - * Restituisce il nome del modulo a cui l'oggetto è collegato. - * - * @return string - */ - public function getModuleAttribute() - { - return 'Liste'; - } -} diff --git a/modules/newsletter/src/Newsletter.php b/modules/newsletter/src/Newsletter.php deleted file mode 100755 index a23de7966..000000000 --- a/modules/newsletter/src/Newsletter.php +++ /dev/null @@ -1,111 +0,0 @@ -. - */ - -namespace Modules\Newsletter; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Eloquent\SoftDeletes; -use Models\User; -use Modules\Anagrafiche\Anagrafica; -use Modules\Emails\Account; -use Modules\Emails\Mail; -use Modules\Emails\Template; -use Traits\RecordTrait; - -class Newsletter extends Model -{ - use SimpleModelTrait; - use SoftDeletes; - use RecordTrait; - - protected $table = 'em_newsletters'; - - public static function build(User $user, Template $template, $name) - { - $model = new static(); - - $model->user()->associate($user); - $model->template()->associate($template); - $model->name = $name; - - $model->subject = $template->subject; - $model->content = $template->body; - - $model->state = 'DEV'; - - $model->save(); - - return $model; - } - - /** - * Restituisce il nome del modulo a cui l'oggetto è collegato. - * - * @return string - */ - public function getModuleAttribute() - { - return 'Newsletter'; - } - - public function fixStato() - { - $mails = $this->emails; - - $completed = true; - foreach ($mails as $mail) { - if (empty($mail->sent_at)) { - $completed = false; - break; - } - } - - $this->state = $completed ? 'OK' : $this->state; - $this->completed_at = $completed ? date('Y-m-d H:i:s') : $this->completed_at; - $this->save(); - } - - // Relazione Eloquent - - public function anagrafiche() - { - return $this->belongsToMany(Anagrafica::class, 'em_newsletter_anagrafica', 'id_newsletter', 'id_anagrafica')->orderByRaw('IF(email=\'\',email,enable_newsletter) ASC')->orderBy('ragione_sociale', 'ASC')->withPivot('id_email')->withTrashed(); - } - - public function emails() - { - return $this->belongsToMany(Mail::class, 'em_newsletter_anagrafica', 'id_newsletter', 'id_email')->withPivot('id_anagrafica'); - } - - public function account() - { - return $this->belongsTo(Account::class, 'id_account'); - } - - public function template() - { - return $this->belongsTo(Template::class, 'id_template'); - } - - public function user() - { - return $this->belongsTo(User::class, 'created_by'); - } -} diff --git a/modules/newsletter/validation.php b/modules/newsletter/validation.php deleted file mode 100644 index 3c5e8ee48..000000000 --- a/modules/newsletter/validation.php +++ /dev/null @@ -1,55 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$name = filter('name'); -$value = filter('value'); - -switch ($name) { - case 'email': - $check = Validate::isValidEmail($value); - - if (empty($check['valid-format'])) { - $result = false; - $errors[] = tr("L'email inserita non possiede un formato valido"); - } else { - $result = true; - } - - if (isset($check['smtp-check']) && empty($check['smtp-check'])) { - $result = false; - $errors[] = tr("Impossibile verificare l'origine dell'email"); - } - - if (!empty($errors)) { - $message = tr('Attenzione').':
      '; - foreach ($errors as $error) { - $message .= '
    • '.$error.'
    • '; - } - $message .= '
    '; - } - - $response = [ - 'result' => $result, - 'message' => $message, - ]; - - break; -} diff --git a/modules/ordini/actions.php b/modules/ordini/actions.php deleted file mode 100755 index c36c2bc34..000000000 --- a/modules/ordini/actions.php +++ /dev/null @@ -1,575 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Anagrafiche\Anagrafica; -use Modules\Articoli\Articolo as ArticoloOriginale; -use Modules\Ordini\Components\Articolo; -use Modules\Ordini\Components\Descrizione; -use Modules\Ordini\Components\Riga; -use Modules\Ordini\Components\Sconto; -use Modules\Ordini\Ordine; -use Modules\Ordini\Tipo; -use Modules\Preventivi\Preventivo; -use Plugins\ListinoClienti\DettaglioPrezzo; - -$module = Modules::get($id_module); - -if ($module['name'] == 'Ordini cliente') { - $dir = 'entrata'; -} else { - $dir = 'uscita'; -} - -switch (post('op')) { - case 'add': - $idanagrafica = post('idanagrafica'); - $data = post('data'); - - $anagrafica = Anagrafica::find($idanagrafica); - $tipo = Tipo::where('dir', $dir)->first(); - - $ordine = Ordine::build($anagrafica, $tipo, $data); - $id_record = $ordine->id; - - flash()->info(tr('Aggiunto ordine numero _NUM_!', [ - '_NUM_' => $ordine->numero, - ])); - - break; - - case 'update': - if (isset($id_record)) { - $idstatoordine = post('idstatoordine'); - $idpagamento = post('idpagamento'); - $idsede = post('idsede'); - - $totale_imponibile = get_imponibile_ordine($id_record); - $totale_ordine = get_totale_ordine($id_record); - - $tipo_sconto = post('tipo_sconto_generico'); - $sconto = post('sconto_generico'); - - if ($dir == 'uscita') { - $idrivalsainps = post('id_rivalsa_inps'); - $idritenutaacconto = post('id_ritenuta_acconto'); - $bollo = post('bollo'); - } else { - $idrivalsainps = 0; - $idritenutaacconto = 0; - $bollo = 0; - } - - // Leggo la descrizione del pagamento - $query = 'SELECT descrizione FROM co_pagamenti WHERE id='.prepare($idpagamento); - $rs = $dbo->fetchArray($query); - $pagamento = $rs[0]['descrizione']; - - $ordine->idanagrafica = post('idanagrafica'); - $ordine->idreferente = post('idreferente'); - $ordine->data = post('data'); - $ordine->numero = post('numero'); - $ordine->numero_esterno = post('numero_esterno'); - $ordine->note = post('note'); - $ordine->note_aggiuntive = post('note_aggiuntive'); - - $ordine->idagente = post('idagente'); - $ordine->idstatoordine = $idstatoordine; - $ordine->idpagamento = $idpagamento; - $ordine->idsede = $idsede; - $ordine->idconto = post('idconto'); - $ordine->idrivalsainps = $idrivalsainps; - $ordine->idritenutaacconto = $idritenutaacconto; - - $ordine->bollo = 0; - $ordine->rivalsainps = 0; - $ordine->ritenutaacconto = 0; - - $ordine->numero_cliente = post('numero_cliente'); - $ordine->data_cliente = post('data_cliente'); - - $ordine->id_documento_fe = post('numero_cliente'); - $ordine->codice_commessa = post('codice_commessa'); - $ordine->codice_cup = post('codice_cup'); - $ordine->codice_cig = post('codice_cig'); - $ordine->num_item = post('num_item'); - - $ordine->setScontoFinale(post('sconto_finale'), post('tipo_sconto_finale')); - - $ordine->save(); - - if ($dbo->query($query)) { - $query = 'SELECT descrizione FROM or_statiordine WHERE id='.prepare($idstatoordine); - $rs = $dbo->fetchArray($query); - - // Ricalcolo inps, ritenuta e bollo (se l'ordine non è stato evaso) - if ($dir == 'entrata') { - if ($rs[0]['descrizione'] != 'Evaso') { - ricalcola_costiagg_ordine($id_record); - } - } else { - if ($rs[0]['descrizione'] != 'Evaso') { - ricalcola_costiagg_ordine($id_record, $idrivalsainps, $idritenutaacconto, $bollo); - } - } - - flash()->info(tr('Ordine modificato correttamente!')); - } - } - - break; - - case 'manage_barcode': - foreach (post('qta') as $id_articolo => $qta) { - if ($id_articolo == '-id-') { - continue; - } - - // Dati di input - $sconto = post('sconto')[$id_articolo]; - $tipo_sconto = post('tipo_sconto')[$id_articolo]; - $prezzo_unitario = post('prezzo_unitario')[$id_articolo]; - $id_dettaglio_fornitore = post('id_dettaglio_fornitore')[$id_articolo]; - $id_iva = $originale->idiva_vendita ? $originale->idiva_vendita : setting('Iva predefinita'); - - // Creazione articolo - $originale = ArticoloOriginale::find($id_articolo); - $articolo = Articolo::build($ordine, $originale); - $articolo->id_dettaglio_fornitore = $id_dettaglio_fornitore ?: null; - - $articolo->setPrezzoUnitario($prezzo_unitario, $id_iva); - if ($dir == 'entrata') { - $articolo->costo_unitario = $originale->prezzo_acquisto; - } - $articolo->setSconto($sconto, $tipo_sconto); - $articolo->qta = $qta; - - $articolo->save(); - } - - flash()->info(tr('Articoli aggiunti!')); - - break; - - case 'manage_articolo': - if (post('idriga') != null) { - $articolo = Articolo::find(post('idriga')); - } else { - $originale = ArticoloOriginale::find(post('idarticolo')); - $articolo = Articolo::build($ordine, $originale); - $articolo->id_dettaglio_fornitore = post('id_dettaglio_fornitore') ?: null; - } - - $articolo->descrizione = post('descrizione'); - $articolo->um = post('um') ?: null; - - $articolo->costo_unitario = post('costo_unitario') ?: 0; - $articolo->data_evasione = post('data_evasione') ?: null; - $articolo->ora_evasione = post('ora_evasione') ?: null; - $articolo->confermato = post('confermato') ?: 0; - $articolo->setPrezzoUnitario(post('prezzo_unitario'), post('idiva')); - $articolo->setSconto(post('sconto'), post('tipo_sconto')); - - try { - $articolo->qta = post('qta'); - } catch (UnexpectedValueException $e) { - flash()->error(tr('Alcuni serial number sono già stati utilizzati!')); - } - - $articolo->save(); - - // Impostare data evasione su tutte le righe - if (post('data_evasione_all') == 1) { - $righe = $ordine->getRighe()->where('is_descrizione', '=', '0'); - - foreach ($righe as $riga) { - $riga->data_evasione = post('data_evasione') ?: null; - $riga->ora_evasione = post('ora_evasione') ?: null; - $riga->save(); - } - } - // Impostare confermato su tutte le righe - if (post('confermato_all') == 1) { - $righe = $ordine->getRighe()->where('is_descrizione', '=', '0'); - - foreach ($righe as $riga) { - $riga->confermato = post('confermato') ?: 0; - $riga->save(); - } - } - - if (post('idriga') != null) { - flash()->info(tr('Articolo modificato!')); - } else { - flash()->info(tr('Articolo aggiunto!')); - } - - // Ricalcolo inps, ritenuta e bollo - ricalcola_costiagg_ordine($id_record); - - break; - - case 'manage_sconto': - if (post('idriga') != null) { - $sconto = Sconto::find(post('idriga')); - } else { - $sconto = Sconto::build($ordine); - } - - $sconto->descrizione = post('descrizione'); - $sconto->setScontoUnitario(post('sconto_unitario'), post('idiva')); - - $sconto->save(); - - if (post('idriga') != null) { - flash()->info(tr('Sconto/maggiorazione modificato!')); - } else { - flash()->info(tr('Sconto/maggiorazione aggiunto!')); - } - - // Ricalcolo inps, ritenuta e bollo - ricalcola_costiagg_ordine($id_record); - - break; - - case 'manage_riga': - if (post('idriga') != null) { - $riga = Riga::find(post('idriga')); - } else { - $riga = Riga::build($ordine); - } - - $riga->descrizione = post('descrizione'); - $riga->um = post('um') ?: null; - - $riga->costo_unitario = post('costo_unitario') ?: 0; - $riga->data_evasione = post('data_evasione') ?: null; - $riga->ora_evasione = post('ora_evasione') ?: null; - $riga->confermato = post('confermato') ?: 0; - $riga->setPrezzoUnitario(post('prezzo_unitario'), post('idiva')); - $riga->setSconto(post('sconto'), post('tipo_sconto')); - - $riga->qta = post('qta'); - - $riga->save(); - - // Impostare data evasione su tutte le righe - if (post('data_evasione_all') == 1) { - $righe = $ordine->getRighe()->where('is_descrizione', '=', '0'); - - foreach ($righe as $riga) { - $riga->data_evasione = post('data_evasione') ?: null; - $riga->ora_evasione = post('ora_evasione') ?: null; - $riga->save(); - } - } - // Impostare confermato su tutte le righe - if (post('confermato_all') == 1) { - $righe = $ordine->getRighe()->where('is_descrizione', '=', '0'); - - foreach ($righe as $riga) { - $riga->confermato = post('confermato') ?: 0; - $riga->save(); - } - } - - if (post('idriga') != null) { - flash()->info(tr('Riga modificata!')); - } else { - flash()->info(tr('Riga aggiunta!')); - } - - // Ricalcolo inps, ritenuta e bollo - ricalcola_costiagg_ordine($id_record); - - break; - - case 'manage_descrizione': - if (post('idriga') != null) { - $riga = Descrizione::find(post('idriga')); - } else { - $riga = Descrizione::build($ordine); - } - - $riga->descrizione = post('descrizione'); - - $riga->save(); - - if (post('idriga') != null) { - flash()->info(tr('Riga descrittiva modificata!')); - } else { - flash()->info(tr('Riga descrittiva aggiunta!')); - } - - break; - - // Scollegamento riga generica da ordine - case 'delete_riga': - $id_riga = post('riga_id'); - $type = post('riga_type'); - $riga = $ordine->getRiga($type, $id_riga); - - if (!empty($riga)) { - try { - $riga->delete(); - - flash()->info(tr('Riga rimossa!')); - } catch (InvalidArgumentException $e) { - flash()->error(tr('Alcuni serial number sono già stati utilizzati!')); - } - } - - ricalcola_costiagg_ordine($id_record); - - break; - - // Eliminazione ordine - case 'delete': - try { - $ordine->delete(); - - flash()->info(tr('Ordine eliminato!')); - } catch (InvalidArgumentException $e) { - flash()->error(tr('Sono stati utilizzati alcuni serial number nel documento: impossibile procedere!')); - } - - break; - - case 'add_serial': - $articolo = Articolo::find(post('idriga')); - - $serials = (array) post('serial'); - $articolo->serials = $serials; - - break; - - case 'update_position': - $order = explode(',', post('order', true)); - - foreach ($order as $i => $id_riga) { - $dbo->query('UPDATE `or_righe_ordini` SET `order` = '.prepare($i + 1).' WHERE id='.prepare($id_riga)); - } - - break; - - // Aggiunta di un documento in ordine - case 'add_preventivo': - case 'add_documento': - $class = post('class'); - $id_documento = post('id_documento'); - - // Individuazione del documento originale - if (!is_subclass_of($class, \Common\Document::class)) { - return; - } - $documento = $class::find($id_documento); - - // Individuazione sede - $id_sede = ($documento->direzione == 'entrata') ? $documento->idsede_destinazione : $documento->idsede_partenza; - $id_sede = $id_sede ?: $documento->idsede; - $id_sede = $id_sede ?: 0; - - // Creazione dell' ordine al volo - if (post('create_document') == 'on') { - $tipo = Tipo::where('dir', $documento->direzione)->first(); - - $ordine = Ordine::build($documento->anagrafica, $tipo, post('data')); - $ordine->idpagamento = $documento->idpagamento; - $ordine->idsede = $id_sede; - - $ordine->id_documento_fe = $documento->id_documento_fe; - $ordine->numero_cliente = $documento->id_documento_fe; - $ordine->codice_cup = $documento->codice_cup; - $ordine->codice_cig = $documento->codice_cig; - $ordine->num_item = $documento->num_item; - $ordine->idreferente = $documento->idreferente; - - $ordine->save(); - - $id_record = $ordine->id; - } - - if (!empty($documento->sconto_finale)) { - $ordine->sconto_finale = $documento->sconto_finale; - } elseif (!empty($documento->sconto_finale_percentuale)) { - $ordine->sconto_finale_percentuale = $documento->sconto_finale_percentuale; - } - - $ordine->save(); - - $righe = $documento->getRighe(); - foreach ($righe as $riga) { - if (post('evadere')[$riga->id] == 'on' and !empty(post('qta_da_evadere')[$riga->id])) { - $qta = post('qta_da_evadere')[$riga->id]; - - $copia = $riga->copiaIn($ordine, $qta); - $copia->save(); - } - } - - // Modifica finale dello stato - if (post('create_document') == 'on') { - $ordine->idstatoordine = post('id_stato'); - $ordine->save(); - } - - ricalcola_costiagg_ordine($id_record); - - // Messaggio informativo - $message = tr('_DOC_ aggiunto!', [ - '_DOC_' => $documento->getReference(), - ]); - flash()->info($message); - - break; - - // Aggiunta di un ordine fornitore da un ordine cliente - case 'add_ordine_cliente': - $ordine_cliente = Ordine::find(post('id_documento')); - - // Creazione dell' ordine al volo - if (post('create_document') == 'on') { - $anagrafica = Anagrafica::find(post('idanagrafica')); - $tipo = Tipo::where('dir', $dir)->first(); - - $ordine = Ordine::build($anagrafica, $tipo, post('data')); - $ordine->save(); - - $id_record = $ordine->id; - } - - $righe = $ordine_cliente->getRighe(); - foreach ($righe as $riga) { - if (post('evadere')[$riga->id] == 'on' and !empty(post('qta_da_evadere')[$riga->id])) { - $qta = post('qta_da_evadere')[$riga->id]; - - $copia = $riga->replicate(); - $copia->setDocument($ordine); - - // Ripristino dei valori di default per campi potenzialmente impostati - $copia->original_id = null; - $copia->original_type = null; - $copia->qta = $qta; - $copia->qta_evasa = 0; - $copia->costo_unitario = 0; - - // Impostazione al prezzo di acquisto per Articoli - if ($copia->isArticolo()) { - $copia->setSconto(0, 'PRC'); - - $articolo = $copia->articolo; - - $fornitore = DettaglioPrezzo::dettagli($riga->idarticolo, $anagrafica->id, $dir, $qta)->first(); - if (empty($fornitore)) { - $fornitore = DettaglioPrezzo::dettaglioPredefinito($riga->idarticolo, $anagrafica->id, $dir)->first(); - } - - $prezzo_unitario = $fornitore->prezzo_unitario - ($fornitore->prezzo_unitario * $fornitore->percentuale / 100); - - $copia->setPrezzoUnitario($fornitore ? $prezzo_unitario : $articolo->prezzo_acquisto, $copia->aliquota->id); - $copia->setSconto($fornitore->sconto_percentuale ?: 0, 'PRC'); - } - - $copia->save(); - } - } - - // Modifica finale dello stato - if (post('create_document') == 'on') { - $ordine->idstatoordine = post('id_stato'); - $ordine->save(); - } - - ricalcola_costiagg_ordine($id_record); - - flash()->info(tr('Ordine _NUM_ aggiunto!', [ - '_NUM_' => $ordine->numero, - ])); - - break; - - // Aggiunta di un ordine fornitore da un preventivo - case 'add_ordine_fornitore': - $preventivo = Preventivo::find(post('id_documento')); - - // Creazione dell' ordine al volo - if (post('create_document') == 'on') { - $anagrafica = Anagrafica::find(post('idanagrafica')); - $tipo = Tipo::where('dir', $dir)->first(); - - $ordine = Ordine::build($anagrafica, $tipo, post('data')); - $ordine->save(); - - $id_record = $ordine->id; - } - - $righe = $preventivo->getRighe(); - foreach ($righe as $riga) { - if (post('evadere')[$riga->id] == 'on' and !empty(post('qta_da_evadere')[$riga->id])) { - $qta = post('qta_da_evadere')[$riga->id]; - - $copia = $riga->copiaIn($ordine, $qta, false); - $copia->save(); - - // Ripristino dei valori di default per campi potenzialmente impostati - $copia->original_id = null; - $copia->original_type = null; - $copia->qta = $qta; - $copia->qta_evasa = 0; - $copia->costo_unitario = 0; - $copia->data_evasione = null; - $copia->ora_evasione = null; - $copia->confermato = setting('Conferma automaticamente le quantità negli ordini fornitore'); - - // Impostazione al prezzo di acquisto per Articoli - if ($copia->isArticolo()) { - $copia->setSconto(0, 'PRC'); - - $articolo = $copia->articolo; - - $fornitore = DettaglioPrezzo::dettagli($riga->idarticolo, $anagrafica->id, $dir, $qta)->first(); - if (empty($fornitore)) { - $fornitore = DettaglioPrezzo::dettaglioPredefinito($riga->idarticolo, $anagrafica->id, $dir)->first(); - } - - $prezzo_unitario = $fornitore->prezzo_unitario - ($fornitore->prezzo_unitario * $fornitore->percentuale / 100); - - $copia->setPrezzoUnitario($fornitore ? $prezzo_unitario : $articolo->prezzo_acquisto, $copia->aliquota->id); - $copia->setSconto($fornitore->sconto_percentuale ?: 0, 'PRC'); - } - - $copia->save(); - } - } - - // Modifica finale dello stato - if (post('create_document') == 'on') { - $ordine->idstatoordine = post('id_stato'); - $ordine->save(); - } - - ricalcola_costiagg_ordine($id_record); - - flash()->info(tr('Ordine _NUM_ aggiunto!', [ - '_NUM_' => $ordine->numero, - ])); - - break; -} diff --git a/modules/ordini/add.php b/modules/ordini/add.php deleted file mode 100755 index 34ee0f39f..000000000 --- a/modules/ordini/add.php +++ /dev/null @@ -1,62 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$module = Modules::get($id_module); - -if ($module['name'] == 'Ordini cliente') { - $dir = 'entrata'; - - $tipo_anagrafica = tr('Cliente'); - $ajax = 'clienti'; -} else { - $dir = 'uscita'; - - $tipo_anagrafica = tr('Fornitore'); - $ajax = 'fornitori'; -} - -$id_anagrafica = !empty(get('idanagrafica')) ? get('idanagrafica') : $user['idanagrafica']; - -?>
    - - - - - - - -
    -
    - {[ "type": "date", "label": "", "name": "data", "required": 1, "value": "-now-" ]} -
    - -
    - {[ "type": "select", "label": "", "name": "idanagrafica", "required": 1, "value": "", "ajax-source": "", "icon-after": "add||tipoanagrafica=" ]} -
    -
    - - -
    -
    - -
    -
    -
    diff --git a/modules/ordini/add_preventivo.php b/modules/ordini/add_preventivo.php deleted file mode 100644 index f61a5d502..000000000 --- a/modules/ordini/add_preventivo.php +++ /dev/null @@ -1,86 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Ordini\Ordine; -use Modules\Preventivi\Preventivo; - -$documento_finale = Ordine::find($id_record); -$dir = $documento_finale->direzione; - -$id_documento = get('id_documento'); -if (!empty($id_documento)) { - $documento = Preventivo::find($id_documento); - - $options = [ - 'op' => 'add_documento', - 'type' => 'preventivo', - 'button' => tr('Aggiungi'), - 'documento' => $documento, - 'documento_finale' => $documento_finale, - 'tipo_documento_finale' => Ordine::class, - 'superamento_soglia_qta' => setting('Permetti il superamento della soglia quantità dei documenti di origine'), - ]; - - echo App::load('importa.php', [], $options, true); - - return; -} - -$id_anagrafica = $documento_finale->idanagrafica; - -echo ' -
    -
    - {[ "type": "select", "label": "'.tr('Preventivo').'", "name": "id_documento", "ajax-source": "preventivi", "select-options": {"idanagrafica": '.$id_anagrafica.', "stato": "is_fatturabile=1 OR is_completato"} ]} -
    -
    - -
    - -
    - -
    - '.tr('Caricamento in corso').'... -
    '; - -$file = basename(__FILE__); -echo ' - - -'; diff --git a/modules/ordini/ajax/select.php b/modules/ordini/ajax/select.php deleted file mode 100644 index 6ce0cf019..000000000 --- a/modules/ordini/ajax/select.php +++ /dev/null @@ -1,51 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -switch ($resource) { - /* - * Opzioni utilizzate: - * - idanagrafica - */ - case 'ordini-cliente': - if (isset($superselect['idanagrafica'])) { - $query = 'SELECT or_ordini.id AS id, - CONCAT("Ordine ", numero, " del ", DATE_FORMAT(data, "%d/%m/%Y"), " [", (SELECT `descrizione` FROM `or_statiordine` WHERE `or_statiordine`.`id` = `idstatoordine`) , "]") AS descrizione - FROM or_ordini - INNER JOIN or_tipiordine ON or_ordini.idtipoordine = or_tipiordine.id - INNER JOIN an_anagrafiche ON or_ordini.idanagrafica = an_anagrafiche.idanagrafica - |where| - ORDER BY or_ordini.id'; - - foreach ($elements as $element) { - $filter[] = 'or_ordini.id='.prepare($element); - } - - $where[] = 'or_tipiordine.dir='.prepare('entrata'); - if (empty($elements)) { - $where[] = 'an_anagrafiche.idanagrafica='.prepare($superselect['idanagrafica']); - - $stato = !empty($superselect['stato']) ? $superselect['stato'] : 'completato'; - $where[] = 'idstatoordine IN (SELECT `id` FROM `or_statiordine` WHERE '.$stato.' = 1)'; - } - } - - break; -} diff --git a/modules/ordini/bulk.php b/modules/ordini/bulk.php deleted file mode 100644 index be1b04583..000000000 --- a/modules/ordini/bulk.php +++ /dev/null @@ -1,168 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Articoli\Articolo as ArticoloOriginale; -use Modules\Fatture\Fattura; -use Modules\Fatture\Stato; -use Modules\Fatture\Tipo; -use Modules\Ordini\Ordine; - -$module_fatture = 'Fatture di vendita'; - -// Segmenti -$id_fatture = Modules::get($module_fatture)['id']; -if (!isset($_SESSION['module_'.$id_fatture]['id_segment'])) { - $segments = Modules::getSegments($id_fatture); - $_SESSION['module_'.$id_fatture]['id_segment'] = isset($segments[0]['id']) ? $segments[0]['id'] : null; -} -$id_segment = $_SESSION['module_'.$id_fatture]['id_segment']; -$idconto = setting('Conto predefinito fatture di vendita'); - -switch (post('op')) { - case 'crea_fattura': - $documenti = collect(); - $numero_totale = 0; - $descrizione_tipo = 'Fattura immediata di vendita'; - - $tipo_documento = Tipo::where('descrizione', $descrizione_tipo)->first(); - - $stato_documenti_accodabili = Stato::where('descrizione', 'Bozza')->first(); - $accodare = post('accodare'); - - $data = date('Y-m-d'); - $id_segment = post('id_segment'); - - // Lettura righe selezionate - foreach ($id_records as $id) { - $documento_import = Ordine::find($id); - $anagrafica = $documento_import->anagrafica; - $id_anagrafica = $anagrafica->id; - - // Proseguo solo se i documenti scelti sono fatturabili - $ordine = $dbo->fetchOne('SELECT or_statiordine.descrizione AS stato FROM or_ordini LEFT JOIN or_statiordine ON or_ordini.idstatoordine=or_statiordine.id WHERE or_ordini.id='.prepare($id))['stato']; - if (!in_array($ordine, ['Fatturato', 'Evaso', 'Bozza', 'In attesa di conferma', 'Annullato'])) { - $righe = $documento_import->getRighe(); - if (!empty($righe)) { - ++$numero_totale; - - // Ricerca fattura per anagrafica tra le registrate - $fattura = $documenti->first(function ($item, $key) use ($id_anagrafica) { - return $item->anagrafica->id == $id_anagrafica; - }); - - // Ricerca fattura per anagrafica se l'impostazione di accodamento è selezionata - if (!empty($accodare) && empty($fattura)) { - $fattura = Fattura::where('idanagrafica', $id_anagrafica) - ->where('idstatodocumento', $stato_documenti_accodabili->id) - ->where('idtipodocumento', $tipo_documento->id) - ->first(); - - if (!empty($fattura)) { - $documenti->push($fattura); - } - } - - // Creazione fattura per anagrafica - if (empty($fattura)) { - $fattura = Fattura::build($anagrafica, $tipo_documento, $data, $id_segment); - $documenti->push($fattura); - } - - // Inserimento righe - foreach ($righe as $riga) { - $qta = $riga->qta_rimanente; - - if ($qta > 0) { - $copia = $riga->copiaIn($fattura, $qta); - - //Fix per idconto righe fattura - $articolo = ArticoloOriginale::find($copia->idarticolo); - $copia->id_conto = ($articolo->idconto_vendita ? $articolo->idconto_vendita : $idconto); - - // Aggiornamento seriali dalla riga dell'ordine - if ($copia->isArticolo()) { - $copia->serials = $riga->serials; - } - } - } - } - } - } - - if ($numero_totale > 0) { - flash()->info(tr('_NUM_ ordini fatturati!', [ - '_NUM_' => $numero_totale, - ])); - } else { - flash()->warning(tr('Nessun ordine fatturato!')); - } - break; - - case 'cambia_stato': - $id_stato = post('id_stato'); - - $n_ordini = 0; - - foreach ($id_records as $id) { - $ordine = Ordine::find($id); - $ordine->idstatoordine = $id_stato; - $ordine->save(); - - ++$n_ordini; - } - - if ($n_ordini > 0) { - flash()->info(tr('Stato cambiato a _NUM_ ordini!', [ - '_NUM_' => $n_ordini, - ])); - } else { - flash()->warning(tr('Nessun ordine modificato!')); - } - - break; -} -if ($module['name'] == 'Ordini cliente') { - $operations['crea_fattura'] = [ - 'text' => ' '.tr('Fattura _TYPE_', ['_TYPE_' => strtolower($module['name'])]), - 'data' => [ - 'title' => tr('Fatturare i _TYPE_ selezionati?', ['_TYPE_' => strtolower($module['name'])]), - 'msg' => '{[ "type": "checkbox", "label": "'.tr('Aggiungere alle _TYPE_ non ancora emesse?', ['_TYPE_' => strtolower($module_fatture)]).'", "placeholder": "'.tr('Aggiungere alle _TYPE_ nello stato bozza?', ['_TYPE_' => strtolower($module_fatture)]).'", "name": "accodare" ]} -
    {[ "type": "select", "label": "'.tr('Sezionale').'", "name": "id_segment", "required": 1, "values": "query=SELECT id, name AS descrizione FROM zz_segments WHERE id_module=\''.$id_fatture.'\' AND is_fiscale = 1 ORDER BY name", "value": "'.$id_segment.'" ]}', - 'button' => tr('Procedi'), - 'class' => 'btn btn-lg btn-warning', - 'blank' => false, - ], - ]; -} - -$operations['cambia_stato'] = [ - 'text' => ' '.tr('Cambia stato'), - 'data' => [ - 'title' => tr('Vuoi davvero cambiare lo stato per questi ordini?'), - 'msg' => tr('Seleziona lo stato in cui spostare tutti gli ordini').'.
    -
    {[ "type": "select", "label": "'.tr('Stato').'", "name": "id_stato", "required": 1, "values": "query=SELECT id, descrizione FROM or_statiordine" ]}', - 'button' => tr('Procedi'), - 'class' => 'btn btn-lg btn-warning', - 'blank' => false, - ], -]; - - return $operations; diff --git a/modules/ordini/buttons.php b/modules/ordini/buttons.php deleted file mode 100755 index 3b7240612..000000000 --- a/modules/ordini/buttons.php +++ /dev/null @@ -1,71 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$stati = $dbo->fetchArray('SELECT descrizione FROM `or_statiordine` WHERE `is_fatturabile` = 1'); -foreach ($stati as $stato) { - $stati_importabili[] = $stato['descrizione']; -} - -echo ' -
    implode(', ', $stati_importabili), - ]).'"> - - -
    '; diff --git a/modules/ordini/crea_documento.php b/modules/ordini/crea_documento.php deleted file mode 100755 index c7ae8e9eb..000000000 --- a/modules/ordini/crea_documento.php +++ /dev/null @@ -1,60 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\DDT\DDT; -use Modules\Fatture\Fattura; -use Modules\Interventi\Intervento; -use Modules\Ordini\Ordine; - -$documento = Ordine::find($id_record); - -$module = Modules::get($documento->module); - -if (get('documento') == 'fattura') { - $final_module = $module['name'] == 'Ordini cliente' ? 'Fatture di vendita' : 'Fatture di acquisto'; - $op = 'add_documento'; - $tipo_documento_finale = Fattura::class; -} elseif (get('documento') == 'ordine_fornitore') { - $final_module = 'Ordini fornitore'; - $op = 'add_ordine_cliente'; - $tipo_documento_finale = Ordine::class; -} elseif (get('documento') == 'intervento') { - $final_module = 'Interventi'; - $op = $module->name == 'Ordini cliente' ? 'add_documento' : 'add_intervento'; - $tipo_documento_finale = Intervento::class; -} else { - $final_module = $module['name'] == 'Ordini cliente' ? 'Ddt di vendita' : 'Ddt di acquisto'; - $op = 'add_ordine'; - $tipo_documento_finale = DDT::class; -} - -$options = [ - 'op' => $op, - 'type' => 'ordine', - 'module' => $final_module, - 'button' => tr('Aggiungi'), - 'create_document' => true, - 'serials' => true, - 'documento' => $documento, - 'tipo_documento_finale' => $tipo_documento_finale, -]; - -echo App::load('importa.php', [], $options, true); diff --git a/modules/ordini/edit.php b/modules/ordini/edit.php deleted file mode 100755 index 45695d7b2..000000000 --- a/modules/ordini/edit.php +++ /dev/null @@ -1,394 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$block_edit = $record['flag_completato']; - -$module = Modules::get($id_module); - -if ($module['name'] == 'Ordini cliente') { - $dir = 'entrata'; -} else { - $dir = 'uscita'; -} - -?>
    - - - - -
    -
    -

    -
    - -
    -
    - -
    > - {[ "type": "text", "label": "", "name": "numero", "required": 1, "class": "text-center", "value": "$numero$" ]} -
    - -
    - {[ "type": "text", "label": "", "name": "numero_esterno", "class": "text-center", "value": "$numero_esterno$" ]} -
    - -
    - {[ "type": "date", "label": "", "name": "data", "required": 1, "value": "$data$" ]} -
    - -
    - - {[ "type": "select", "label": "", "name": "idstatoordine", "required": 1, "values": "query=SELECT * FROM or_statiordine", "value": "$idstatoordine$", "extra": "readonly", "class": "unblockable" ]} - - {[ "type": "select", "label": "", "name": "idstatoordine", "required": 1, "values": "query=SELECT * FROM or_statiordine WHERE descrizione IN('Bozza', 'Accettato', 'In attesa di conferma', 'Annullato')", "value": "$idstatoordine$", "class": "unblockable" ]} - - {[ "type": "select", "label": "", "name": "idstatoordine", "required": 1, "values": "query=SELECT * FROM or_statiordine", "value": "$idstatoordine$", "class": "unblockable" ]} - -
    - -
    - -
    -
    - - {[ "type": "select", "label": "", "name": "idanagrafica", "required": 1, "value": "$idanagrafica$", "ajax-source": "clienti" ]} - - {[ "type": "select", "label": "", "name": "idanagrafica", "required": 1, "values": "query=SELECT an_anagrafiche.idanagrafica AS id, ragione_sociale AS descrizione FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE descrizione='Fornitore' AND deleted_at IS NULL ORDER BY ragione_sociale", "value": "$idanagrafica$" ]} - - -
    '; - if (!empty($record['idreferente'])) { - echo Plugins::link('Referenti', $record['idanagrafica'], null, null, 'class="pull-right"'); - } - echo ' - {[ "type": "select", "label": "'.tr('Referente').'", "name": "idreferente", "value": "$idreferente$", "ajax-source": "referenti", "select-options": {"idanagrafica": '.$record['idanagrafica'].'} ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Sede').'", "name": "idsede", "required": 1, "ajax-source": "sedi", "select-options": {"idanagrafica": '.$record['idanagrafica'].'}, "value": "'.$record['idsede'].'" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Pagamento').'", "name": "idpagamento", "required": 0, "ajax-source": "pagamenti", "value": "$idpagamento$" ]} -
    -
    '; - - if ($dir == 'entrata') { - ?> -
    -
    - {[ "type": "text", "label": "", "name": "numero_cliente", "required":0, "value": "", "help": "Obbligatorio per valorizzare CIG/CUP. È possible inserire:
    • N. determina
    • RDO
    • Ordine MEPA
    '); ?>" ]} -
    - -
    - {[ "type": "date", "label": "", "name": "data_cliente", "value": "" ]} -
    - -
    - {[ "type": "number", "label": "", "name": "sconto_finale", "value": "sconto_finale_percentuale ?: $ordine->sconto_finale; ?>", "icon-after": "choice|untprc|sconto_finale) ? 'PRC' : 'UNT'; ?>", "help": "." ]} -
    -
    - - -
    -
    - {[ "type": "textarea", "label": "", "name": "note", "value": "$note$" ]} -
    -
    - -
    -
    - {[ "type": "textarea", "label": "", "name": "note_aggiuntive", "value": "$note_aggiuntive$" ]} -
    -
    -
    -
    - - - - -
    -
    -
    -

    - - -
    - -
    -

    -
    -
    -
    -
    -
    - {[ "type": "text", "label": "", "name": "codice_commessa", "required": 0, "value": "$codice_commessa$", "maxlength": 100 ]} -
    - -
    - {[ "type": "text", "label": "", "name": "num_item", "required": 0, "value": "$num_item$", "maxlength": 15 ]} -
    -
    -
    -
    - {[ "type": "text", "label": "", "name": "codice_cig", "required": 0, "value": "$codice_cig$", "maxlength": 15 ]} -
    - -
    - {[ "type": "text", "label": "", "name": "codice_cup", "required": 0, "value": "$codice_cup$", "maxlength": 15 ]} -
    -
    -
    -
    -
    -
    - - - -
    -
    -

    '.tr('Righe').'

    -
    - -
    '; - -if (!$block_edit) { - echo ' -
    '; - - $prev_query = 'SELECT COUNT(*) AS tot FROM co_preventivi WHERE idanagrafica='.prepare($record['idanagrafica']).' AND idstato IN(SELECT id FROM co_statipreventivi WHERE is_fatturabile = 1) AND default_revision=1 AND co_preventivi.id IN (SELECT idpreventivo FROM co_righe_preventivi WHERE co_righe_preventivi.idpreventivo = co_preventivi.id AND (qta - qta_evasa) > 0)'; - $preventivi = $dbo->fetchArray($prev_query)[0]['tot']; - if ($dir == 'entrata') { - echo ' - '; - } - echo ' - '; - - echo ' - '; - - echo ' - '; - - echo ' - '; - - echo ' - '; - - echo ' -
    '; - - if ($dir == 'entrata') { - echo ' - '; - } - - echo ' -
    -
    '; -} - -echo ' -
    -
    -
    -
    -
    - -{( "name": "filelist_and_upload", "id_module": "$id_module$", "id_record": "$id_record$" )} - -{( "name": "log_email", "id_module": "$id_module$", "id_record": "$id_record$" )} - -'; - -// Collegamenti diretti -// Fatture o ddt collegati a questo ordine -$elementi = $dbo->fetchArray('SELECT `co_documenti`.`id`, `co_documenti`.`data`, `co_documenti`.`numero`, `co_documenti`.`numero_esterno`, `co_tipidocumento`.`descrizione` AS tipo_documento, `co_tipidocumento`.`dir` FROM `co_documenti` JOIN `co_tipidocumento` ON `co_tipidocumento`.`id` = `co_documenti`.`idtipodocumento` WHERE `co_documenti`.`id` IN (SELECT `iddocumento` FROM `co_righe_documenti` WHERE `idordine` = '.prepare($id_record).') - -UNION SELECT `dt_ddt`.`id`, `dt_ddt`.`data`, `dt_ddt`.`numero`, `dt_ddt`.`numero_esterno`, `dt_tipiddt`.`descrizione` AS tipo_documento, `dt_tipiddt`.`dir` FROM `dt_ddt` JOIN `dt_tipiddt` ON `dt_tipiddt`.`id` = `dt_ddt`.`idtipoddt` WHERE `dt_ddt`.`id` IN (SELECT `idddt` FROM `dt_righe_ddt` WHERE `idordine` = '.prepare($id_record).') ORDER BY `data`'); - -if (!empty($elementi)) { - echo ' -
    -
    -

    '.tr('Documenti collegati: _NUM_', [ - '_NUM_' => count($elementi), - ]).'

    -
    - -
    -
    -
    -
      '; - - foreach ($elementi as $elemento) { - $descrizione = tr('_DOC_ num. _NUM_ del _DATE_', [ - '_DOC_' => $elemento['tipo_documento'], - '_NUM_' => !empty($elemento['numero_esterno']) ? $elemento['numero_esterno'] : $elemento['numero'], - '_DATE_' => Translator::dateToLocale($elemento['data']), - ]); - - if (!in_array($elemento['tipo_documento'], ['Ddt in uscita', 'Ddt in entrata'])) { - $modulo = ($elemento['dir'] == 'entrata') ? 'Fatture di vendita' : 'Fatture di acquisto'; - } else { - $modulo = ($elemento['dir'] == 'entrata') ? 'Ddt di vendita' : 'Ddt di acquisto'; - } - - $id = $elemento['id']; - - echo ' -
    • '.Modules::link($modulo, $id, $descrizione).'
    • '; - } - - echo ' -
    -
    -
    '; -} - -if (!empty($elementi)) { - echo ' -
    - '.tr('Eliminando questo documento si potrebbero verificare problemi nelle altre sezioni del gestionale').'. -
    '; -} - -?> - - - - - diff --git a/modules/ordini/init.php b/modules/ordini/init.php deleted file mode 100755 index 1419df330..000000000 --- a/modules/ordini/init.php +++ /dev/null @@ -1,39 +0,0 @@ -. - */ - -use Modules\Ordini\Ordine; - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $ordine = Ordine::with('tipo', 'stato')->find($id_record); - - $record = $dbo->fetchOne('SELECT *, - or_ordini.note, - or_ordini.idpagamento, - or_ordini.id AS idordine, - or_statiordine.descrizione AS `stato`, - or_tipiordine.descrizione AS `descrizione_tipodoc`, - (SELECT tipo FROM an_anagrafiche WHERE idanagrafica = or_ordini.idanagrafica) AS tipo_anagrafica, - (SELECT completato FROM or_statiordine WHERE or_statiordine.id=or_ordini.idstatoordine) AS flag_completato - FROM or_ordini LEFT OUTER JOIN or_statiordine ON or_ordini.idstatoordine=or_statiordine.id - INNER JOIN an_anagrafiche ON or_ordini.idanagrafica=an_anagrafiche.idanagrafica - INNER JOIN or_tipiordine ON or_ordini.idtipoordine=or_tipiordine.id - WHERE or_ordini.id='.prepare($id_record)); -} diff --git a/modules/ordini/modutil.php b/modules/ordini/modutil.php deleted file mode 100755 index 9ec47df66..000000000 --- a/modules/ordini/modutil.php +++ /dev/null @@ -1,242 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Ordini\Ordine; - -/** - * Funzione per generare un nuovo numero per l'ordine. - * - * @deprecated 2.4.5 - */ -function get_new_numeroordine($data) -{ - global $dir; - - return Ordine::getNextNumero($data, $dir); -} - -/** - * Funzione per calcolare il numero secondario successivo utilizzando la maschera dalle impostazioni. - * - * @deprecated 2.4.5 - */ -function get_new_numerosecondarioordine($data) -{ - global $dir; - - return Ordine::getNextNumeroSecondario($data, $dir); -} - -/** - * Calcolo imponibile ordine (totale_righe - sconto). - * - * @deprecated 2.4.5 - */ -function get_imponibile_ordine($idordine) -{ - $ordine = Ordine::find($idordine); - - return $ordine->imponibile; -} - -/** - * Calcolo totale ordine (imponibile + iva). - * - * @deprecated 2.4.5 - */ -function get_totale_ordine($idordine) -{ - $ordine = Ordine::find($idordine); - - return $ordine->totale; -} - -/** - * Calcolo netto a pagare ordine (totale - ritenute - bolli). - * - * @deprecated 2.4.5 - */ -function get_netto_ordine($idordine) -{ - $ordine = Ordine::find($idordine); - - return $ordine->netto; -} - -/** - * Calcolo iva detraibile ordine. - * - * @deprecated 2.4.5 - */ -function get_ivadetraibile_ordine($idordine) -{ - $ordine = Ordine::find($idordine); - - return $ordine->iva_detraibile; -} - -/** - * Calcolo iva indetraibile ordine. - * - * @deprecated 2.4.5 - */ -function get_ivaindetraibile_ordine($idordine) -{ - $ordine = Ordine::find($idordine); - - return $ordine->iva_indetraibile; -} - -/** - * Ricalcola i costi aggiuntivi in ordine (rivalsa inps, ritenuta d'acconto, marca da bollo) - * Deve essere eseguito ogni volta che si aggiunge o toglie una riga - * $idordine int ID del ordine - * $idrivalsainps int ID della rivalsa inps da applicare. Se omesso viene utilizzata quella impostata di default - * $idritenutaacconto int ID della ritenuta d'acconto da applicare. Se omesso viene utilizzata quella impostata di default - * $bolli float Costi aggiuntivi delle marche da bollo. Se omesso verrà usata la cifra predefinita. - */ -function ricalcola_costiagg_ordine($idordine, $idrivalsainps = '', $idritenutaacconto = '', $bolli = '') -{ - global $dir; - - $dbo = database(); - - // Se ci sono righe nel ordine faccio i conteggi, altrimenti azzero gli sconti e le spese aggiuntive (inps, ritenuta, marche da bollo) - $query = 'SELECT COUNT(id) AS righe FROM or_righe_ordini WHERE idordine='.prepare($idordine); - $rs = $dbo->fetchArray($query); - if ($rs[0]['righe'] > 0) { - $totale_imponibile = get_imponibile_ordine($idordine); - $totale_ordine = get_totale_ordine($idordine); - - // Leggo gli id dei costi aggiuntivi - if ($dir == 'uscita') { - $query2 = 'SELECT idrivalsainps, idritenutaacconto, bollo FROM or_ordini WHERE id='.prepare($idordine); - $rs2 = $dbo->fetchArray($query2); - $idrivalsainps = $rs2[0]['idrivalsainps']; - $idritenutaacconto = $rs2[0]['idritenutaacconto']; - $bollo = $rs2[0]['bollo']; - } - - // Leggo la rivalsa inps se c'è (per i ordine di vendita lo leggo dalle impostazioni) - if ($dir == 'entrata') { - if (!empty($idrivalsainps)) { - $idrivalsainps = setting('Percentuale rivalsa'); - } - } - - $query = 'SELECT percentuale FROM co_rivalse WHERE id='.prepare($idrivalsainps); - $rs = $dbo->fetchArray($query); - $rivalsainps = $totale_imponibile / 100 * $rs[0]['percentuale']; - - // Aggiorno la rivalsa inps - $dbo->query("UPDATE or_ordini SET rivalsainps='$rivalsainps' WHERE id=".prepare($idordine)); - - // Leggo la ritenuta d'acconto se c'è - $totale_ordine = get_totale_ordine($idordine); - - // Leggo la rivalsa inps se c'è (per i ordine di vendita lo leggo dalle impostazioni) - if (!empty($idritenutaacconto)) { - if ($dir == 'entrata') { - $idritenutaacconto = setting("Percentuale ritenuta d'acconto"); - } - } - - $query = 'SELECT percentuale FROM co_ritenutaacconto WHERE id='.prepare($idritenutaacconto); - $rs = $dbo->fetchArray($query); - $ritenutaacconto = $totale_ordine / 100 * $rs[0]['percentuale']; - $netto_a_pagare = $totale_ordine - $ritenutaacconto; - - // Leggo la marca da bollo se c'è e se il netto a pagare supera la soglia - $bolli = str_replace(',', '.', $bolli); - $bolli = floatval($bolli); - if ($dir == 'uscita') { - if ($bolli != 0.00) { - $bolli = str_replace(',', '.', $bolli); - if (abs($bolli) > 0 && abs($netto_a_pagare > setting("Soglia minima per l'applicazione della marca da bollo"))) { - $marca_da_bollo = str_replace(',', '.', $bolli); - } else { - $marca_da_bollo = 0.00; - } - } - } else { - $marca_da_bollo = 0.00; - } - - // Leggo l'iva predefinita per calcolare l'iva aggiuntiva sulla rivalsa inps - $qi = 'SELECT percentuale FROM co_iva WHERE id='.prepare(setting('Iva predefinita')); - $rsi = $dbo->fetchArray($qi); - $iva_rivalsainps = $rivalsainps / 100 * $rsi[0]['percentuale']; - - $dbo->query('UPDATE or_ordini SET ritenutaacconto='.prepare($ritenutaacconto).', bollo='.prepare($marca_da_bollo).', iva_rivalsainps='.prepare($iva_rivalsainps).' WHERE id='.prepare($idordine)); - } else { - $dbo->query("UPDATE or_ordini SET ritenutaacconto='0', bollo='0', rivalsainps='0' WHERE id=".prepare($idordine)); - } -} - -/** - * Restituisce lo stato dell'ordine in base alle righe. - */ -function get_stato_ordine($idordine) -{ - $dbo = database(); - - $rs_ordine = $dbo->fetchArray("SELECT IFNULL(SUM(qta), 0) AS qta FROM or_righe_ordini WHERE idordine='".$idordine."'"); - $qta_ordine = $rs_ordine[0]['qta']; - - //Righe dell'ordine in ddt - $rs_ddt = $dbo->fetchArray('SELECT IFNULL(SUM(qta), 0) AS qta FROM dt_righe_ddt WHERE idordine='.prepare($idordine)); - $qta_ddt = $rs_ddt[0]['qta']; - - //Righe dell'ordine in fattura - $rs_fattura = $dbo->fetchArray('SELECT IFNULL(SUM(qta), 0) AS qta FROM co_righe_documenti WHERE idordine='.prepare($idordine)); - $qta_fattura = $rs_fattura[0]['qta']; - - //Righe dell'ordine in fattura passando da ddt - $rs_ddt_fattura = $dbo->fetchArray("SELECT IFNULL(SUM(qta), 0) AS qta FROM co_righe_documenti WHERE idddt IN(SELECT DISTINCT idddt FROM dt_righe_ddt WHERE idordine='".$idordine."')"); - $qta_ddt_fattura = $rs_ddt_fattura[0]['qta']; - - if ($qta_ddt == 0) { - $stato = 'Accettato'; - } - if ($qta_fattura == 0) { - $stato = 'Accettato'; - } - if ($qta_ddt > 0 && $qta_ddt < $qta_ordine && $qta_ordine > 0) { - $stato = 'Parzialmente evaso'; - } - if ($qta_ddt == $qta_ordine && $qta_ordine > 0) { - $stato = 'Evaso'; - } - if ($qta_fattura > 0 && $qta_fattura < $qta_ordine && $qta_ordine > 0) { - $stato = 'Parzialmente fatturato'; - } - if ($qta_fattura == $qta_ordine && $qta_ordine > 0) { - $stato = 'Fatturato'; - } - if ($qta_ddt_fattura > 0 && $qta_ddt_fattura < $qta_ordine && $qta_ordine > 0) { - $stato = 'Parzialmente fatturato'; - } - if ($qta_ddt_fattura == $qta_ordine && $qta_ordine > 0) { - $stato = 'Fatturato'; - } - - return $stato; -} diff --git a/modules/ordini/plugins/ordini.consuntivo.php b/modules/ordini/plugins/ordini.consuntivo.php deleted file mode 100644 index ce8a259cf..000000000 --- a/modules/ordini/plugins/ordini.consuntivo.php +++ /dev/null @@ -1,288 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -use Modules\Interventi\Intervento; - -// CONSUNTIVO - -// Tabella con riepilogo interventi -$interventi = Intervento::where('id_ordine', $id_record)->get(); -if (!empty($interventi)) { - echo ' - - - - - - - - - '; - - // Tabella con i dati - foreach ($interventi as $intervento) { - // Riga per il singolo intervento - echo ' - - - - - - - - - - - - - '; - - // Riga con dettagli - echo ' - - - '; - } - - $array_interventi = $interventi->toArray(); - $totale_ore = sum(array_column($array_interventi, 'ore_totali')); - $totale_km = sum(array_column($array_interventi, 'km_totali')); - $totale_costo = sum(array_column($array_interventi, 'spesa')); - $totale_addebito = sum(array_column($array_interventi, 'imponibile')); - $totale = sum(array_column($array_interventi, 'totale_imponibile')); - - // Totali - echo ' - - '; - - echo ' - '; - - echo ' - '; - - echo ' - '; - - echo ' - '; - - echo ' - - '; - - $stati = $interventi->groupBy('idstatointervento'); - if (count($stati) > 0) { - // Totali per stato - echo ' - - - '; - - foreach ($stati as $interventi_collegati) { - $stato = $interventi_collegati->first()->stato; - $totale_stato = sum(array_column($interventi_collegati->toArray(), 'totale_imponibile')); - - echo ' - - - - - - - '; - } - } - - echo ' -
    '.tr('Attività').''.tr('Ore').''.tr('Km').''.tr('Costo').''.tr('Addebito').''.tr('Tot. scontato').'
    - - '.Modules::link('Interventi', $intervento->id, tr('Intervento num. _NUM_ del _DATE_', [ - '_NUM_' => $intervento->codice, - '_DATE_' => Translator::dateToLocale($intervento->inizio), - ])).' - - '.numberFormat($intervento->ore_totali).' - - '.numberFormat($intervento->km_totali).' - - '.moneyFormat($intervento->spesa).' - - '.moneyFormat($intervento->imponibile).' - - '.moneyFormat($intervento->totale_imponibile).' -
    '; - - // Lettura sessioni di lavoro - $sessioni = $intervento->sessioni; - if (!empty($sessioni)) { - echo ' - - - - - - - - - - - - - '; - - foreach ($sessioni as $sessione) { - // Visualizzo lo sconto su ore o km se c'è - $sconto_ore = !empty($sessione->sconto_totale_manodopera) ? '
    '.moneyFormat(-$sessione->sconto_totale_manodopera).'' : ''; - $sconto_km = !empty($sessione->sconto_totale_viaggio) ? '
    '.moneyFormat(-$sessione->sconto_totale_viaggio).'' : ''; - - echo ' - - - - - - - - - - - - '; - } - - echo ' -
    '.tr('Tecnico').''.tr('Tipo attività').''.tr('Ore').''.tr('Km').''.tr('Costo ore').''.tr('Costo km').''.tr('Diritto ch.').''.tr('Prezzo ore').''.tr('Prezzo km').''.tr('Diritto ch.').'
    '.$sessione->anagrafica->ragione_sociale.''.$sessione->tipo->descrizione.''.numberFormat($sessione->ore).''.numberFormat($sessione->km).''.moneyFormat($sessione->costo_manodopera).''.moneyFormat($sessione->costo_viaggio).''.moneyFormat($sessione->costo_diritto_chiamata).''.moneyFormat($sessione->prezzo_manodopera).$sconto_ore.''.moneyFormat($sessione->prezzo_viaggio).$sconto_km.''.moneyFormat($sessione->prezzo_diritto_chiamata).'
    '; - } - - // Lettura articoli utilizzati - $articoli = $intervento->articoli; - if (!$articoli->isEmpty()) { - echo ' - - - - - - - '; - - foreach ($articoli as $articolo) { - $sconto = !empty($articolo->sconto) ? '
    '.moneyFormat(-$articolo->sconto).'' : ''; - - echo ' - - - - - - '; - } - - echo ' -
    '.tr('Materiale').''.tr('Q.tà').''.tr('Prezzo di acquisto').''.tr('Prezzo di vendita').'
    - '.Modules::link('Articoli', $articolo->idarticolo, $articolo->descrizione).' - '.numberFormat($articolo->qta, 'qta').''.moneyFormat($articolo->spesa).''.moneyFormat($articolo->imponibile).$sconto.'
    '; - } - - // Lettura spese aggiuntive - $righe = $intervento->righe; - if (!$righe->isEmpty()) { - echo ' - - - - - - - '; - - foreach ($righe as $riga) { - $sconto = !empty($riga->sconto) ? '
    '.moneyFormat(-$riga->sconto).'' : ''; - - echo ' - - - - - - '; - } - - echo ' -
    '.tr('Altre spese').''.tr('Q.tà').''.tr('Prezzo di acquisto').''.tr('Prezzo di vendita').'
    - '.$riga->descrizione.' - '.numberFormat($riga->qta, 'qta').''.moneyFormat($riga->spesa).''.moneyFormat($riga->imponibile).$sconto.'
    '; - } - - echo ' -
    - '.tr('Totale').' - - '.numberFormat($totale_ore).' - - '.numberFormat($totale_km).' - - '.moneyFormat($totale_costo).' - - '.moneyFormat($totale_addebito).' - - '.moneyFormat($totale).' -
    -
    '.tr('Totale interventi per stato', [], ['upper' => true]).' -
    - '.$stato->descrizione.': - - '.moneyFormat($totale_stato).' -
    '; -} - -// Bilancio del preventivo -$budget = $ordine->totale_imponibile; -$diff = sum($budget, -$totale); - -echo ' -
    -
    - '.tr('Rapporto budget/spesa').':
    '; -if ($diff > 0) { - echo ' - +'.moneyFormat($diff).''; -} elseif ($diff < 0) { - echo ' - '.moneyFormat($diff).''; -} else { - echo ' - '.moneyFormat($diff).''; -} - echo ' -
    -

    -
    '; - -/* - Stampa consuntivo -*/ -echo ' -
    - '.Prints::getLink('Consuntivo ordine', $id_record, 'btn-primary', tr('Stampa consuntivo')).' -
    '; diff --git a/modules/ordini/quantita_impegnate.php b/modules/ordini/quantita_impegnate.php deleted file mode 100644 index 6449a7607..000000000 --- a/modules/ordini/quantita_impegnate.php +++ /dev/null @@ -1,78 +0,0 @@ -. - */ - -use Modules\Ordini\Ordine; - -include_once __DIR__.'/../../core.php'; - -$ordine = Ordine::find($id_record); -$articoli = $ordine->articoli->groupBy('idarticolo'); - -if ($articoli->isEmpty()) { - echo ' -

    '.tr('Il documento non contiene articoli').'.

    '; - - return; -} - -echo ' - - - - - - - - - - - '; - -foreach ($articoli as $elenco) { - $qta = $elenco->sum('qta'); - $articolo = $elenco->first()->articolo; - - $codice = $articolo ? $articolo->codice : tr('Articolo eliminato'); - $descrizione = $articolo ? $articolo->descrizione : $elenco->first()->descrizione; - - $qta_impegnata = $database->fetchOne("SELECT SUM(qta) as qta - FROM or_righe_ordini - JOIN or_ordini ON or_ordini.id = or_righe_ordini.idordine - WHERE idstatoordine = (SELECT id FROM or_statiordine WHERE descrizione = 'Bozza') - AND idtipoordine IN (SELECT id FROM or_tipiordine WHERE dir = 'entrata') - AND confermato = 1 - AND idarticolo=".prepare($articolo->id).' - GROUP BY idarticolo')['qta']; - $qta_impegnata = floatval($qta_impegnata); - - $class = $qta_impegnata + $qta > $articolo->qta ? 'danger' : 'success'; - $descrizione_riga = $codice.' - '.$descrizione; - $text = $articolo ? Modules::link('Articoli', $articolo->id, $descrizione_riga) : $descrizione_riga; - - echo ' - - - - - - '; -} -echo ' - -
    '.tr('Articolo').''.tr('Q.tà').''.tr('Q.tà magazzino').''.tr('Q.tà impegnata').'
    '.$text.''.numberFormat($qta, 'qta').''.numberFormat($articolo->qta, 'qta').''.numberFormat($qta_impegnata, 'qta').'
    '; diff --git a/modules/ordini/row-add.php b/modules/ordini/row-add.php deleted file mode 100755 index 60a62be91..000000000 --- a/modules/ordini/row-add.php +++ /dev/null @@ -1,88 +0,0 @@ -. - */ - -use Modules\Ordini\Ordine; - -include_once __DIR__.'/../../core.php'; - -// Info contratto -$documento = Ordine::find($id_record); -$dir = $documento->direzione; - -// Impostazioni per la gestione -$options = [ - 'op' => 'manage_riga', - 'action' => 'add', - 'dir' => $documento->direzione, - 'idanagrafica' => $documento['idanagrafica'], - 'totale_imponibile_documento' => $documento->totale_imponibile, - 'totale_documento' => $documento->totale, - 'select-options' => [ - 'articoli' => [ - 'idanagrafica' => $documento->idanagrafica, - 'dir' => $documento->direzione, - 'permetti_movimento_a_zero' => 1, - ], - ], -]; - -// Dati di default -$result = [ - 'descrizione' => '', - 'qta' => 1, - 'um' => '', - 'prezzo' => 0, - 'sconto_unitario' => 0, - 'tipo_sconto' => '', - 'idiva' => '', -]; - -// Leggo l'iva predefinita per l'anagrafica e se non c'è leggo quella predefinita generica -$iva = $dbo->fetchArray('SELECT idiva_'.($dir == 'uscita' ? 'acquisti' : 'vendite').' AS idiva FROM an_anagrafiche WHERE idanagrafica='.prepare($documento['idanagrafica'])); -$result['idiva'] = $iva[0]['idiva'] ?: setting('Iva predefinita'); - -// Importazione della gestione dedicata -$file = 'riga'; -if (get('is_descrizione') !== null) { - $file = 'descrizione'; - - $options['op'] = 'manage_descrizione'; -} elseif (get('is_articolo') !== null) { - $file = 'articolo'; - - // Aggiunta sconto di default da listino per le vendite - $listino = $dbo->fetchOne('SELECT prc_guadagno FROM an_anagrafiche INNER JOIN mg_listini ON an_anagrafiche.idlistino_vendite=mg_listini.id WHERE idanagrafica='.prepare($documento['idanagrafica'])); - - if (!empty($listino['prc_guadagno'])) { - $result['sconto_percentuale'] = $listino['prc_guadagno']; - $result['tipo_sconto'] = 'PRC'; - } - - $options['op'] = 'manage_articolo'; -} elseif (get('is_sconto') !== null) { - $file = 'sconto'; - - $options['op'] = 'manage_sconto'; -} elseif (get('is_barcode') !== null) { - $file = 'barcode'; - - $options['op'] = 'manage_barcode'; -} - -echo App::load($file.'.php', $result, $options); diff --git a/modules/ordini/row-edit.php b/modules/ordini/row-edit.php deleted file mode 100755 index 1e9deafc8..000000000 --- a/modules/ordini/row-edit.php +++ /dev/null @@ -1,68 +0,0 @@ -. - */ - -use Modules\Ordini\Ordine; - -include_once __DIR__.'/../../core.php'; - -// Info contratto -$documento = Ordine::find($id_record); - -// Impostazioni per la gestione -$options = [ - 'op' => 'manage_riga', - 'action' => 'edit', - 'dir' => $documento->direzione, - 'idanagrafica' => $documento['idanagrafica'], - 'totale_imponibile_documento' => $documento->totale_imponibile, - 'totale_documento' => $documento->totale, - 'select-options' => [ - 'articoli' => [ - 'idanagrafica' => $documento->idanagrafica, - 'dir' => $documento->direzione, - 'permetti_movimento_a_zero' => 1, - ], - ], -]; - -// Dati della riga -$id_riga = get('riga_id'); -$type = get('riga_type'); -$riga = $documento->getRiga($type, $id_riga); - -$result = $riga->toArray(); -$result['prezzo'] = $riga->prezzo_unitario; - -// Importazione della gestione dedicata -$file = 'riga'; -if ($riga->isDescrizione()) { - $file = 'descrizione'; - - $options['op'] = 'manage_descrizione'; -} elseif ($riga->isArticolo()) { - $file = 'articolo'; - - $options['op'] = 'manage_articolo'; -} elseif ($riga->isSconto()) { - $file = 'sconto'; - - $options['op'] = 'manage_sconto'; -} - -echo App::load($file.'.php', $result, $options); diff --git a/modules/ordini/row-list.php b/modules/ordini/row-list.php deleted file mode 100755 index ad4a8434d..000000000 --- a/modules/ordini/row-list.php +++ /dev/null @@ -1,422 +0,0 @@ -. - */ - -include_once __DIR__.'/init.php'; - -echo ' -
    - - - - - - - - - - - - - - - '; - -// Righe documento -$today = new Carbon\Carbon(); -$today = $today->startOfDay(); -$righe = $ordine->getRighe(); -$num = 0; -foreach ($righe as $riga) { - ++$num; - - $extra = ''; - $mancanti = 0; - - // Individuazione dei seriali - if ($riga->isArticolo() && !empty($riga->abilita_serial)) { - $serials = $riga->serials; - $mancanti = abs($riga->qta) - count($serials); - - if ($mancanti > 0) { - $extra = 'class="warning"'; - } else { - $mancanti = 0; - } - } - - echo ' - - - - '; - - // Data prevista evasione - $info_evasione = ''; - if (!empty($riga->data_evasione)) { - $evasione = new Carbon\Carbon($riga->data_evasione); - if ($today->diffInDays($evasione, false) < 0) { - $evasione_icon = 'fa fa-warning text-danger'; - $evasione_help = tr('Da consegnare _NUM_ giorni fa', - [ - '_NUM_' => $today->diffInDays($evasione), - ] - ); - } elseif ($today->diffInDays($evasione, false) == 0) { - $evasione_icon = 'fa fa-clock-o text-warning'; - $evasione_help = tr('Da consegnare oggi'); - } else { - $evasione_icon = 'fa fa-check text-success'; - $evasione_help = tr('Da consegnare fra _NUM_ giorni', - [ - '_NUM_' => $today->diffInDays($evasione), - ] - ); - } - - if (!empty($riga->ora_evasione)) { - $ora_evasione = '
    '.Translator::timeToLocale($riga->ora_evasione).''; - } else { - $ora_evasione = ''; - } - - $info_evasione = ' '.Translator::dateToLocale($riga->data_evasione).$ora_evasione.''; - } - - echo ' - '; - - if ($riga->isDescrizione()) { - echo ' - - - - '; - } else { - // Quantità e unità di misura - echo ' - '; - - // Prezzi unitari - echo ' - '; - - // Iva - echo ' - '; - - // Importo - echo ' - '; - } - - // Possibilità di rimuovere una riga solo se l'ordine non è evaso - echo ' - - '; -} - -echo ' - '; - -// Calcoli -$imponibile = abs($ordine->imponibile); -$sconto = $ordine->sconto; -$totale_imponibile = abs($ordine->totale_imponibile); -$iva = abs($ordine->iva); -$totale = abs($ordine->totale); -$sconto_finale = $ordine->getScontoFinale(); -$netto_a_pagare = $ordine->netto; - -// IMPONIBILE -echo ' - - - - - '; - -// SCONTO -if (!empty($sconto)) { - echo ' - - - - - '; - - // TOTALE IMPONIBILE - echo ' - - - - - '; -} - -// IVA -echo ' - - - - - '; - -// TOTALE -echo ' - - - - - '; - -// SCONTO FINALE -if (!empty($sconto_finale)) { - echo ' - - - - - '; -} - -// NETTO A PAGARE -if ($totale != $netto_a_pagare) { - echo ' - - - - - '; -} - -echo ' -
    '.tr('#').''.tr('Descrizione').''.tr('Prev. evasione').''.tr('Q.tà').' '.tr('Prezzo unitario').''.tr('Iva unitaria').''.tr('Importo').'
    - '.$num.' - '; - - $numero_riferimenti_riga = $riga->referenceTargets()->count(); - $numero_riferimenti_collegati = $riga->referenceSources()->count(); - $riferimenti_presenti = $numero_riferimenti_riga; - $testo_aggiuntivo = $riferimenti_presenti ? $numero_riferimenti_riga : ''; - - echo ' - '; - - // Aggiunta dei riferimenti ai documenti - if ($riga->hasOriginalComponent()) { - echo ' - '.reference($riga->getOriginalComponent()->getDocument(), tr('Origine')).''; - } - - if ($riga->isArticolo()) { - echo Modules::link('Articoli', $riga->idarticolo, $riga->codice.' - '.$riga->descrizione); - } else { - echo nl2br($riga->descrizione); - } - - if ($riga->isArticolo() && !empty($riga->abilita_serial)) { - if (!empty($mancanti)) { - echo ' -
    '.tr('_NUM_ serial mancanti', [ - '_NUM_' => $mancanti, - ]).''; - } - if (!empty($serials)) { - echo ' -
    '.tr('SN').': '.implode(', ', $serials); - } - } - - echo ' -
    - '.$info_evasione.' - - - '.numberFormat($riga->qta_rimanente, 'qta').' / '.numberFormat($riga->qta, 'qta').' '.$riga->um.' - - '.moneyFormat($riga->prezzo_unitario_corrente); - - if ($dir == 'entrata' && $riga->costo_unitario != 0) { - echo ' -
    - '.tr('Acquisto').': '.moneyFormat($riga->costo_unitario).' - '; - } - - if (abs($riga->sconto_unitario) > 0) { - $text = discountInfo($riga); - - echo ' -
    '.$text.''; - } - - echo ' -
    - '.moneyFormat($riga->iva_unitaria_scontata).' -
    '.$riga->aliquota->descrizione.(($riga->aliquota->esente) ? ' ('.$riga->aliquota->codice_natura_fe.')' : null).' -
    - '.moneyFormat($riga->importo).' - '; - - if ($record['flag_completato'] == 0) { - echo ' -
    '; - - if ($riga->isArticolo() && !empty($riga->abilita_serial)) { - echo ' - - - '; - } - - echo ' - - - - - - - - - - - -
    '; - } - - echo ' -
    - '.tr('Imponibile', [], ['upper' => true]).': - - '.moneyFormat($imponibile, 2).' -
    - '.tr('Sconto/maggiorazione', [], ['upper' => true]).': - - '.moneyFormat($sconto, 2).' -
    - '.tr('Totale imponibile', [], ['upper' => true]).': - - '.moneyFormat($totale_imponibile, 2).' -
    - '.tr('Iva', [], ['upper' => true]).': - - '.moneyFormat($iva, 2).' -
    - '.tr('Totale', [], ['upper' => true]).': - - '.moneyFormat($totale, 2).' -
    - '.tr('Sconto finale', [], ['upper' => true]).': - - '.moneyFormat($sconto_finale, 2).' -
    - '.tr('Netto a pagare', [], ['upper' => true]).': - - '.moneyFormat($netto_a_pagare, 2).' -
    -
    '; - -echo ' -'; diff --git a/modules/ordini/src/Components/Articolo.php b/modules/ordini/src/Components/Articolo.php deleted file mode 100755 index f85e0daab..000000000 --- a/modules/ordini/src/Components/Articolo.php +++ /dev/null @@ -1,30 +0,0 @@ -. - */ - -namespace Modules\Ordini\Components; - -use Common\Components\Article; - -class Articolo extends Article -{ - use RelationTrait; - - protected $table = 'or_righe_ordini'; - protected $serialRowID = 'ordine'; -} diff --git a/modules/ordini/src/Components/Descrizione.php b/modules/ordini/src/Components/Descrizione.php deleted file mode 100755 index 763f8bb68..000000000 --- a/modules/ordini/src/Components/Descrizione.php +++ /dev/null @@ -1,29 +0,0 @@ -. - */ - -namespace Modules\Ordini\Components; - -use Common\Components\Description; - -class Descrizione extends Description -{ - use RelationTrait; - - protected $table = 'or_righe_ordini'; -} diff --git a/modules/ordini/src/Components/RelationTrait.php b/modules/ordini/src/Components/RelationTrait.php deleted file mode 100755 index a4a1adaef..000000000 --- a/modules/ordini/src/Components/RelationTrait.php +++ /dev/null @@ -1,47 +0,0 @@ -. - */ - -namespace Modules\Ordini\Components; - -use Modules\Ordini\Ordine; - -trait RelationTrait -{ - public function getDocumentID() - { - return 'idordine'; - } - - public function document() - { - return $this->belongsTo(Ordine::class, $this->getDocumentID()); - } - - public function ordine() - { - return $this->document(); - } - - public function getNettoAttribute() - { - $result = $this->totale; - - return $result; - } -} diff --git a/modules/ordini/src/Components/Riga.php b/modules/ordini/src/Components/Riga.php deleted file mode 100755 index bf57b1897..000000000 --- a/modules/ordini/src/Components/Riga.php +++ /dev/null @@ -1,29 +0,0 @@ -. - */ - -namespace Modules\Ordini\Components; - -use Common\Components\Row; - -class Riga extends Row -{ - use RelationTrait; - - protected $table = 'or_righe_ordini'; -} diff --git a/modules/ordini/src/Components/Sconto.php b/modules/ordini/src/Components/Sconto.php deleted file mode 100755 index ba561316a..000000000 --- a/modules/ordini/src/Components/Sconto.php +++ /dev/null @@ -1,29 +0,0 @@ -. - */ - -namespace Modules\Ordini\Components; - -use Common\Components\Discount; - -class Sconto extends Discount -{ - use RelationTrait; - - protected $table = 'or_righe_ordini'; -} diff --git a/modules/ordini/src/Ordine.php b/modules/ordini/src/Ordine.php deleted file mode 100755 index 66cbbb00a..000000000 --- a/modules/ordini/src/Ordine.php +++ /dev/null @@ -1,259 +0,0 @@ -. - */ - -namespace Modules\Ordini; - -use Common\Components\Component; -use Common\Document; -use Modules\Anagrafiche\Anagrafica; -use Modules\DDT\DDT; -use Modules\Interventi\Intervento; -use Traits\RecordTrait; -use Traits\ReferenceTrait; -use Util\Generator; - -class Ordine extends Document -{ - use ReferenceTrait; - use RecordTrait; - - /** - * @var bool Disabilita movimentazione automatica - */ - public static $movimenta_magazzino = false; - - protected $table = 'or_ordini'; - - protected $with = [ - 'tipo', - ]; - - /** - * Crea un nuovo ordine. - * - * @param string $data - * - * @return self - */ - public static function build(Anagrafica $anagrafica, Tipo $tipo_documento, $data) - { - $model = new static(); - - $stato_documento = Stato::where('descrizione', 'Bozza')->first(); - - $id_anagrafica = $anagrafica->id; - $direzione = $tipo_documento->dir; - - $database = database(); - - if ($direzione == 'entrata') { - $conto = 'vendite'; - } else { - $conto = 'acquisti'; - } - - // Tipo di pagamento e banca predefinite dall'anagrafica - $id_pagamento = $database->fetchOne('SELECT id FROM co_pagamenti WHERE id = :id_pagamento', [ - ':id_pagamento' => $anagrafica['idpagamento_'.$conto], - ])['id']; - - // Se il ordine è un ordine cliente e non è stato associato un pagamento predefinito al cliente leggo il pagamento dalle impostazioni - if ($direzione == 'entrata' && empty($id_pagamento)) { - $id_pagamento = setting('Tipo di pagamento predefinito'); - } - - $model->anagrafica()->associate($anagrafica); - $model->tipo()->associate($tipo_documento); - $model->stato()->associate($stato_documento); - - $model->save(); - - // Salvataggio delle informazioni - $model->data = $data; - - if (!empty($id_pagamento)) { - $model->idpagamento = $id_pagamento; - } - - $model->numero = static::getNextNumero($data, $direzione); - $model->numero_esterno = static::getNextNumeroSecondario($data, $direzione); - - $model->save(); - - return $model; - } - - /** - * Restituisce il nome del modulo a cui l'oggetto è collegato. - * - * @return string - */ - public function getModuleAttribute() - { - return $this->direzione == 'entrata' ? 'Ordini cliente' : 'Ordini fornitore'; - } - - public function getDirezioneAttribute() - { - return $this->tipo->dir; - } - - public function anagrafica() - { - return $this->belongsTo(Anagrafica::class, 'idanagrafica'); - } - - public function tipo() - { - return $this->belongsTo(Tipo::class, 'idtipoordine'); - } - - public function stato() - { - return $this->belongsTo(Stato::class, 'idstatoordine'); - } - - public function articoli() - { - return $this->hasMany(Components\Articolo::class, 'idordine'); - } - - public function righe() - { - return $this->hasMany(Components\Riga::class, 'idordine'); - } - - public function sconti() - { - return $this->hasMany(Components\Sconto::class, 'idordine'); - } - - public function descrizioni() - { - return $this->hasMany(Components\Descrizione::class, 'idordine'); - } - - public function interventi() - { - return $this->hasMany(Intervento::class, 'id_ordine'); - } - - /** - * Effettua un controllo sui campi del documento. - * Viene richiamato dalle modifiche alle righe del documento. - */ - public function triggerEvasione(Component $trigger) - { - parent::triggerEvasione($trigger); - - if (setting('Cambia automaticamente stato ordini fatturati')) { - $righe = $this->getRighe(); - - $qta_evasa = $righe->sum('qta_evasa'); - $qta = $righe->sum('qta'); - $parziale = $qta != $qta_evasa; - - $stato_attuale = $this->stato; - - // Impostazione del nuovo stato - if ($qta_evasa == 0) { - $descrizione = 'Accettato'; - } elseif (!in_array($stato_attuale->descrizione, ['Parzialmente fatturato', 'Fatturato']) && $trigger->getDocument() instanceof DDT) { - $descrizione = $parziale ? 'Parzialmente evaso' : 'Evaso'; - } else { - $descrizione = $parziale ? 'Parzialmente fatturato' : 'Fatturato'; - } - - $stato = Stato::where('descrizione', $descrizione)->first(); - $this->stato()->associate($stato); - $this->save(); - } - } - - // Metodi statici - - /** - * Calcola il nuovo numero di ordine. - * - * @param string $data - * @param string $direzione - * @param int $id_segment - * - * @return string - */ - public static function getNextNumero($data, $direzione) - { - $maschera = '#'; - - $ultimo = Generator::getPreviousFrom($maschera, 'or_ordini', 'numero', [ - 'YEAR(data) = '.prepare(date('Y', strtotime($data))), - 'idtipoordine IN (SELECT id FROM or_tipiordine WHERE dir = '.prepare($direzione).')', - ]); - $numero = Generator::generate($maschera, $ultimo); - - return $numero; - } - - /** - * Calcola il nuovo numero secondario di ordine. - * - * @param string $data - * @param string $direzione - * - * @return string - */ - public static function getNextNumeroSecondario($data, $direzione) - { - if ($direzione == 'uscita') { - return ''; - } - - $maschera = setting('Formato numero secondario ordine'); - - $ultimo = Generator::getPreviousFrom($maschera, 'or_ordini', 'numero_esterno', [ - 'YEAR(data) = '.prepare(date('Y', strtotime($data))), - 'idtipoordine IN (SELECT id FROM or_tipiordine WHERE dir = '.prepare($direzione).')', - ]); - $numero = Generator::generate($maschera, $ultimo, 1, Generator::dateToPattern($data)); - - return $numero; - } - - // Opzioni di riferimento - - public function getReferenceName() - { - return $this->tipo->descrizione; - } - - public function getReferenceNumber() - { - return $this->numero_esterno ?: $this->numero; - } - - public function getReferenceDate() - { - return $this->data; - } - - public function getReferenceRagioneSociale() - { - return $this->anagrafica->ragione_sociale; - } -} diff --git a/modules/ordini/src/Stato.php b/modules/ordini/src/Stato.php deleted file mode 100755 index 2ed1eb198..000000000 --- a/modules/ordini/src/Stato.php +++ /dev/null @@ -1,35 +0,0 @@ -. - */ - -namespace Modules\Ordini; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; - -class Stato extends Model -{ - use SimpleModelTrait; - - protected $table = 'or_statiordine'; - - public function ordini() - { - return $this->hasMany(Ordine::class, 'idstatoordine'); - } -} diff --git a/modules/ordini/src/Tipo.php b/modules/ordini/src/Tipo.php deleted file mode 100755 index 1bd88243d..000000000 --- a/modules/ordini/src/Tipo.php +++ /dev/null @@ -1,35 +0,0 @@ -. - */ - -namespace Modules\Ordini; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; - -class Tipo extends Model -{ - use SimpleModelTrait; - - protected $table = 'or_tipiordine'; - - public function ordini() - { - return $this->hasMany(Ordine::class, 'idtipoordine'); - } -} diff --git a/modules/ordini/variables.php b/modules/ordini/variables.php deleted file mode 100755 index 20b0492c6..000000000 --- a/modules/ordini/variables.php +++ /dev/null @@ -1,31 +0,0 @@ -. - */ - -$r = $dbo->fetchOne('SELECT *, or_ordini.idanagrafica, - IF( (an_referenti.email IS NOT NULL AND an_referenti.email!=""), an_referenti.email, an_anagrafiche.email) AS email -FROM or_ordini INNER JOIN an_anagrafiche ON an_anagrafiche.idanagrafica=or_ordini.idanagrafica LEFT OUTER JOIN an_referenti ON an_referenti.id=or_ordini.idreferente WHERE or_ordini.id='.prepare($id_record)); - -// Variabili da sostituire -return [ - 'email' => $r['email'], - 'id_anagrafica' => $r['idanagrafica'], - 'numero' => empty($r['numero_esterno']) ? $r['numero'] : $r['numero_esterno'], - 'note' => $r['note'], - 'data' => Translator::dateToLocale($r['data']), -]; diff --git a/modules/pagamenti/actions.php b/modules/pagamenti/actions.php deleted file mode 100755 index 597875fd5..000000000 --- a/modules/pagamenti/actions.php +++ /dev/null @@ -1,115 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -switch (filter('op')) { - case 'update': - $descrizione = filter('descrizione'); - - if (isset($descrizione)) { - foreach (post('id') as $key => $id) { - // Data fatturazione - $giorno = 0; - - // Data fatturazione fine mese - if (post('scadenza')[$key] == 2) { - $giorno = -1; - } - - // Data fatturazione giorno fisso - if (post('scadenza')[$key] == 3) { - $giorno = post('giorno')[$key]; - } - - // Data fatturazione fine mese (giorno fisso) - elseif (post('scadenza')[$key] == 4) { - $giorno = -post('giorno')[$key] - 1; - } - - $array = [ - 'num_giorni' => post('distanza')[$key], - 'giorno' => $giorno, - 'prc' => post('percentuale')[$key], - 'descrizione' => $descrizione, - 'idconto_vendite' => post('idconto_vendite'), - 'idconto_acquisti' => post('idconto_acquisti'), - 'codice_modalita_pagamento_fe' => post('codice_modalita_pagamento_fe'), - ]; - - if (!empty($id)) { - $dbo->update('co_pagamenti', $array, ['id' => $id]); - } else { - $dbo->INSERT('co_pagamenti', $array); - } - } - flash()->info(tr('Salvataggio completato!')); - } else { - flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio!')); - } - - break; - - case 'add': - $descrizione = filter('descrizione'); - $codice_modalita_pagamento_fe = filter('codice_modalita_pagamento_fe'); - - if (isset($descrizione)) { - $dbo->query('INSERT INTO `co_pagamenti` (`descrizione`, `codice_modalita_pagamento_fe`, `prc` ) VALUES ('.prepare($descrizione).', '.prepare($codice_modalita_pagamento_fe).', 100 )'); - $id_record = $dbo->lastInsertedID(); - - flash()->info(tr('Aggiunta nuova tipologia di _TYPE_', [ - '_TYPE_' => 'pagamento', - ])); - } else { - flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio!')); - } - - break; - - case 'delete': - if (!empty($id_record)) { - $dbo->query('DELETE FROM `co_pagamenti` WHERE `id`='.prepare($id_record)); - - flash()->info(tr('Tipologia di _TYPE_ eliminata con successo!', [ - '_TYPE_' => 'pagamento', - ])); - } - - break; - - case 'delete_rata': - $id = filter('id'); - if (isset($id)) { - $dbo->query('DELETE FROM `co_pagamenti` WHERE `id`='.prepare($id)); - flash()->info(tr('Elemento eliminato con successo!')); - - if ($id_record == $id) { - $res = $dbo->fetchArray('SELECT * FROM `co_pagamenti` WHERE `id`!='.prepare($id).' AND `descrizione`='.prepare($record['descrizione'])); - if (count($res) != 0) { - redirect(base_path().'/editor.php?id_module='.$id_module.'&id_record='.$res[0]['id']); - } else { - // $_POST['backto'] = 'record-list'; - redirect(base_path().'/controller.php?id_module='.$id_module); - } - } - } - - break; -} diff --git a/modules/pagamenti/add.php b/modules/pagamenti/add.php deleted file mode 100755 index 3be6a6c1d..000000000 --- a/modules/pagamenti/add.php +++ /dev/null @@ -1,42 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1 ]} -
    - -
    - {[ "type": "select", "label": "", "name": "codice_modalita_pagamento_fe", "value": "", "values": "query=SELECT codice as id, CONCAT(codice, ' - ', descrizione) AS descrizione FROM fe_modalita_pagamento", "required": 1 ]} -
    -
    - - -
    -
    - -
    -
    -
    diff --git a/modules/pagamenti/ajax/select.php b/modules/pagamenti/ajax/select.php deleted file mode 100755 index d42e95d6c..000000000 --- a/modules/pagamenti/ajax/select.php +++ /dev/null @@ -1,52 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -switch ($resource) { - /* - * Opzioni utilizzate: - * - codice_modalita_pagamento_fe - */ - case 'pagamenti': - $query = "SELECT co_pagamenti.id, - CONCAT_WS(' - ', codice_modalita_pagamento_fe, descrizione) AS descrizione, - banca_vendite.id AS id_banca_vendite, - CONCAT(banca_vendite.nome, ' - ', banca_vendite.iban) AS descrizione_banca_vendite, - banca_acquisti.id AS id_banca_acquisti, - CONCAT(banca_acquisti.nome, ' - ', banca_acquisti.iban) AS descrizione_banca_acquisti - FROM co_pagamenti - LEFT JOIN co_banche banca_vendite ON co_pagamenti.idconto_vendite = banca_vendite.id_pianodeiconti3 - LEFT JOIN co_banche banca_acquisti ON co_pagamenti.idconto_acquisti = banca_acquisti.id_pianodeiconti3 - |where| GROUP BY co_pagamenti.descrizione ORDER BY co_pagamenti.descrizione ASC"; - - foreach ($elements as $element) { - $filter[] = 'co_pagamenti.id = '.prepare($element); - } - - if (!empty($superselect['codice_modalita_pagamento_fe'])) { - $where[] = 'codice_modalita_pagamento_fe = '.prepare($superselect['codice_modalita_pagamento_fe']); - } - - if (!empty($search)) { - $search_fields[] = 'descrizione LIKE '.prepare('%'.$search.'%'); - } - - break; -} diff --git a/modules/pagamenti/edit.php b/modules/pagamenti/edit.php deleted file mode 100755 index 7582c6709..000000000 --- a/modules/pagamenti/edit.php +++ /dev/null @@ -1,263 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - - -
    -
    -

    -
    - -
    -
    -
    - {[ "type": "text", "label": "", "name": "descrizione", "value": "$descrizione$", "required": 1 ]} -
    - -
    - {[ "type": "select", "label": "", "name": "codice_modalita_pagamento_fe", "value": "$codice_modalita_pagamento_fe$", "values": "query=SELECT codice as id, CONCAT(codice, ' - ', descrizione) AS descrizione FROM fe_modalita_pagamento", "required": 1, "help": "" ]} -
    -
    - -
    -
    - {[ "type": "select", "label": "", "name": "idconto_vendite", "value": "$idconto_vendite$", "ajax-source": "conti" ]} -
    - -
    - {[ "type": "select", "label": "", "name": "idconto_acquisti", "value": "$idconto_acquisti$", "ajax-source": "conti" ]} -
    -
    -
    -
    - -
    -
    -

    -
    - -
    -
    - $i, - 'text' => $i, - ]; -} - -$tipi_scadenza_pagamento = [ - [ - 'id' => 1, - 'text' => tr('Data fatturazione'), - ], - [ - 'id' => 2, - 'text' => tr('Data fatturazione fine mese'), - ], - [ - 'id' => 3, - 'text' => tr('Data fatturazione giorno fisso'), - ], - [ - 'id' => 4, - 'text' => tr('Data fatturazione fine mese (giorno fisso)'), - ], -]; - -$results = $dbo->fetchArray('SELECT * FROM `co_pagamenti` WHERE descrizione='.prepare($record['descrizione']).' ORDER BY `num_giorni` ASC'); -$numero_rata = 1; -foreach ($results as $result) { - $tipo_scadenza_pagamento = 3; - if ($result['giorno'] == 0) { - $tipo_scadenza_pagamento = 1; - } elseif ($result['giorno'] == -1) { - $tipo_scadenza_pagamento = 2; - } elseif ($result['giorno'] < -1) { - $tipo_scadenza_pagamento = 4; - } - - $giorno_pagamento = null; - if ($result['giorno'] != 0 && $result['giorno'] != -1) { - $giorno_pagamento = ($result['giorno'] < -1) ? -$result['giorno'] - 1 : $result['giorno']; - } - - echo ' -
    -
    -

    '.tr('Rata _NUMBER_', [ - '_NUMBER_' => $numero_rata, - ]).'

    - -
    -
    - - -
    -
    - {[ "type": "number", "label": "'.tr('Percentuale').'", "name": "percentuale['.$numero_rata.']", "decimals": "2", "min-value": "0", "value": "'.$result['prc'].'", "icon-after": "" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Scadenza').'", "name": "scadenza['.$numero_rata.']", "values": '.json_encode($tipi_scadenza_pagamento).', "value": "'.$tipo_scadenza_pagamento.'" ]} -
    -
    - -
    -
    - {[ "type": "select", "label": "'.tr('Giorno').'", "name": "giorno['.$numero_rata.']", "values": '.json_encode($giorni_pagamento).', "value": "'.$giorno_pagamento.'", "extra": "'; - if ($result['giorno'] == 0 || $result['giorno'] == -1) { - echo ' disabled'; - } - echo '" ]} -
    - -
    - {[ "type": "number", "label": "'.tr('Distanza in giorni').'", "name": "distanza['.$numero_rata.']", "decimals": "0", "min-value": "0", "value": "'.$result['num_giorni'].'" ]} -
    -
    -
    -
    '; - ++$numero_rata; -} -?> -
    - -
    - - - -
    -
    -
    -
    - -
    -
    -

    - -

    -
    -
    -

    .

    -
    -
    - - - - - -
    -
    -

    '.tr('Nuova rata').'

    -
    -
    - - -
    -
    - {[ "type": "number", "label": "'.tr('Percentuale').'", "decimals": "2", "name": "percentuale[-id-]", "icon-after": "" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Scadenza').'", "name": "scadenza[-id-]", "values": '.json_encode($tipi_scadenza_pagamento).', "value": 1 ]} -
    -
    - -
    -
    - {[ "type": "select", "label": "'.tr('Giorno').'", "name": "giorno[-id-]", "values": '.json_encode($giorni_pagamento).' ]} -
    - -
    - {[ "type": "number", "label": "'.tr('Distanza in giorni').'", "name": "distanza[-id-]", "decimals": "0" ]} -
    -
    -
    -
    -'; - -?> - - diff --git a/modules/pagamenti/init.php b/modules/pagamenti/init.php deleted file mode 100755 index b38b7baef..000000000 --- a/modules/pagamenti/init.php +++ /dev/null @@ -1,24 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT * FROM `co_pagamenti` WHERE id='.prepare($id_record)); -} diff --git a/modules/pagamenti/src/Pagamento.php b/modules/pagamenti/src/Pagamento.php deleted file mode 100755 index 1726a5faa..000000000 --- a/modules/pagamenti/src/Pagamento.php +++ /dev/null @@ -1,122 +0,0 @@ -. - */ - -namespace Modules\Pagamenti; - -use Common\SimpleModelTrait; -use DateTime; -use Illuminate\Database\Eloquent\Model; - -class Pagamento extends Model -{ - use SimpleModelTrait; - - protected $table = 'co_pagamenti'; - - public function fatture() - { - return $this->hasMany(Fattura::class, 'idpagamento'); - } - - public function rate() - { - return $this->hasMany(Pagamento::class, 'descrizione', 'descrizione'); - } - - public function calcola($importo, $data) - { - $rate = $this->rate->sortBy('num_giorni'); - $number = count($rate); - - $totale = 0.0; - - $results = []; - $count = 0; - foreach ($rate as $key => $rata) { - $date = new DateTime($data); - - // X giorni esatti - if ($rata['giorno'] == 0) { - // Offset della rata - $date->modify('+'.($rata['num_giorni']).' day'); - } - - // Ultimo del mese - elseif ($rata['giorno'] < 0) { - // Offset della rata in mesi - $date->modify('+'.($rata['num_giorni'].' day')); - $date->modify('last day of this month'); - - // Opzione ultimo del mese più X giorni - $giorni = -$rata['giorno'] - 1; - if ($giorni > 0) { - $date->modify('+'.($giorni).' day'); - } else { - $date->modify('last day of this month'); - } - } - - // Giorno preciso del mese - else { - // Offset della rata - $date->modify('+'.($rata['num_giorni']).' day'); - - // Individuazione giorno effettivo (se il giorno indicato è eccessivamente grande, viene preso il massimo possibile) - $date->modify('last day of this month'); - $last_day = $date->format('d'); - $day = $rata['giorno'] > $last_day ? $last_day : $rata['giorno']; - - // Correzione data - $date->setDate($date->format('Y'), $date->format('m'), $day); - } - - // Comversione della data in stringa standard - $scadenza = $date->format('Y-m-d'); - - // All'ultimo ciclo imposto come cifra da pagare il totale della fattura meno gli importi già inseriti in scadenziario per evitare di inserire cifre arrotondate "male" - if ($count + 1 == $number) { - $da_pagare = sum($importo, -$totale, 2); - } - - // Totale da pagare (totale x percentuale di pagamento nei casi pagamenti multipli) - else { - $da_pagare = sum($importo / 100 * $rata['prc'], 0, 2); - } - - $totale = sum($da_pagare, $totale, 2); - - $results[] = [ - 'scadenza' => $scadenza, - 'importo' => $da_pagare, - ]; - - ++$count; - } - - return $results; - } - - /** - * @return bool - */ - public function isRiBa() - { - return $this->codice_modalita_pagamento_fe == 'MP12'; - } -} diff --git a/modules/partitario/actions.php b/modules/partitario/actions.php deleted file mode 100755 index 6cb2ef41d..000000000 --- a/modules/partitario/actions.php +++ /dev/null @@ -1,227 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\PrimaNota\Mastrino; -use Modules\PrimaNota\Movimento; - -switch (post('op')) { - // Aggiunta nuovo conto nel partitario - case 'add': - $id_conto = post('id_conto'); - $numero = post('numero'); - $descrizione = post('descrizione'); - $lvl = post('lvl'); - - if (post('id_conto') !== null) { - if ($lvl == '2') { - // Controllo che non sia stato usato un numero non valido del conto - $query = 'SELECT idpianodeiconti1, numero FROM co_pianodeiconti2 WHERE numero='.prepare($numero).' AND idpianodeiconti1='.prepare($id_conto); - $rs = $dbo->fetchArray($query); - - if (sizeof($rs) == 0) { - $query = 'INSERT INTO co_pianodeiconti2(numero, descrizione, idpianodeiconti1) VALUES('.prepare($numero).', '.prepare($descrizione).', '.prepare($id_conto).')'; - } - } else { - // Controllo che non sia stato usato un numero non valido del conto - $query = 'SELECT idpianodeiconti2, numero FROM co_pianodeiconti3 WHERE numero='.prepare($numero).' AND idpianodeiconti2='.prepare($id_conto); - $rs = $dbo->fetchArray($query); - - if (sizeof($rs) == 0) { - $query = 'INSERT INTO co_pianodeiconti3(numero, descrizione, idpianodeiconti2, dir) VALUES('.prepare($numero).', '.prepare($descrizione).', '.prepare($id_conto).', (SELECT dir FROM co_pianodeiconti2 WHERE id='.prepare($id_conto).'))'; - } - } - - if ($dbo->query($query)) { - flash()->info(tr('Nuovo conto aggiunto!')); - } else { - flash()->error(tr('Il numero scelto è già esistente!')); - } - } - - break; - - // Modifica conto di livello 2 e 3 nel partitario - case 'edit': - $idconto = post('idconto'); - $idpianodeiconti = post('idpianodeiconti'); - $numero = post('numero'); - $descrizione = post('descrizione'); - $dir = post('dir'); - - $lvl = post('lvl'); - if ($lvl == 2) { - $duplicate_query = 'SELECT numero FROM co_pianodeiconti2 WHERE numero='.prepare($numero).' AND NOT id='.prepare($idconto).' AND idpianodeiconti1='.prepare($idpianodeiconti); - - $update_query = 'UPDATE co_pianodeiconti2 SET numero='.prepare($numero).', descrizione='.prepare($descrizione).', dir='.prepare($dir).' WHERE id='.prepare($idconto); - } else { - $duplicate_query = 'SELECT idpianodeiconti2, numero FROM co_pianodeiconti3 WHERE numero='.prepare($numero).' AND NOT id='.prepare($idconto).' AND idpianodeiconti2='.prepare($idpianodeiconti); - - $update_query = 'UPDATE co_pianodeiconti3 SET numero='.prepare($numero).', descrizione='.prepare($descrizione).', percentuale_deducibile='.prepare(post('percentuale_deducibile')).' WHERE id='.prepare($idconto); - } - - // Controllo che non sia stato usato un numero non valido del conto - if ($dbo->fetchNum($duplicate_query) == 0) { - if ($dbo->query($update_query)) { - flash()->info(tr('Descrizione conto modificata!')); - } - } else { - flash()->error(tr('Il numero scelto è già esistente!')); - } - - break; - - // Eliminazione conto dal partitario - case 'del': - $idconto = post('idconto'); - - //Controllo che non esistano movimenti associati al conto - $movimenti = $dbo->fetchNum('SELECT id FROM co_movimenti WHERE idconto = '.prepare($idconto)); - - if ($idconto != '' and empty($movimenti)) { - //Se elimino il conto lo scollego anche da eventuali anagrafiche (cliente e fornitore) - $dbo->query('UPDATE an_anagrafiche SET idconto_cliente = NULL WHERE idconto_cliente = '.prepare($idconto)); - $dbo->query('UPDATE an_anagrafiche SET idconto_fornitore = NULL WHERE idconto_fornitore = '.prepare($idconto)); - - $query = 'DELETE FROM co_pianodeiconti3 WHERE id='.prepare($idconto); - - if ($dbo->query($query)) { - flash()->info(tr('Conto eliminato!')); - } - } - break; - - // Apertura bilancio - case 'apri-bilancio': - // Eliminazione eventuali movimenti di apertura fatti finora - $dbo->query('DELETE FROM co_movimenti WHERE is_apertura=1 AND data='.prepare($_SESSION['period_start'])); - - $idconto_apertura = setting('Conto per Apertura conti patrimoniali'); - $idconto_chiusura = setting('Conto per Chiusura conti patrimoniali'); - - // Lettura di tutti i conti dello stato patrimoniale con saldo != 0 - $conti = $dbo->fetchArray('SELECT co_pianodeiconti3.id, SUM(co_movimenti.totale) AS totale FROM ((co_pianodeiconti3 INNER JOIN co_pianodeiconti2 ON co_pianodeiconti3.idpianodeiconti2=co_pianodeiconti2.id) INNER JOIN co_pianodeiconti1 ON co_pianodeiconti2.idpianodeiconti1=co_pianodeiconti1.id) INNER JOIN co_movimenti ON co_pianodeiconti3.id=co_movimenti.idconto WHERE co_pianodeiconti1.descrizione="Patrimoniale" AND data < '.prepare($_SESSION['period_start']).' AND co_pianodeiconti3.id NOT IN('.prepare($idconto_apertura).', '.prepare($idconto_chiusura).') AND is_apertura=0 AND is_chiusura=0 GROUP BY co_pianodeiconti3.id HAVING totale != 0'); - - $mastrino = Mastrino::build(tr('Apertura conto'), $_SESSION['period_start'], 0, true); - - $totale = 0; - - foreach ($conti as $conto) { - if ($conto['totale'] >= 0) { - $dare = abs($conto['totale']); - $avere = 0; - } else { - $dare = 0; - $avere = abs($conto['totale']); - } - - $movimento = Movimento::build($mastrino, $conto['id']); - $movimento->setTotale($avere, $dare); - $movimento->is_apertura = true; - $movimento->save(); - - $totale += $conto['totale']; - } - - // Movimento sul conto di apertura - $totale = -$totale; - - if ($totale >= 0) { - $dare = abs($totale); - $avere = 0; - } else { - $dare = 0; - $avere = abs($totale); - } - - $movimento = Movimento::build($mastrino, $idconto_apertura); - $movimento->setTotale($avere, $dare); - $movimento->is_apertura = true; - $movimento->save(); - - flash()->info(tr('Apertura bilancio completata!')); - - break; - - // Chiusura bilancio - case 'chiudi-bilancio': - // Eliminazione eventuali movimenti di chiusura fatti finora - $dbo->query('DELETE FROM co_movimenti WHERE is_chiusura=1 AND data='.prepare($_SESSION['period_end'])); - - $idconto_apertura = setting('Conto per Apertura conti patrimoniali'); - $idconto_chiusura = setting('Conto per Chiusura conti patrimoniali'); - - // Lettura di tutti i conti dello stato patrimoniale con saldo != 0 - $conti = $dbo->fetchArray('SELECT co_pianodeiconti3.id, SUM(co_movimenti.totale) AS totale FROM ((co_pianodeiconti3 INNER JOIN co_pianodeiconti2 ON co_pianodeiconti3.idpianodeiconti2=co_pianodeiconti2.id) INNER JOIN co_pianodeiconti1 ON co_pianodeiconti2.idpianodeiconti1=co_pianodeiconti1.id) INNER JOIN co_movimenti ON co_pianodeiconti3.id=co_movimenti.idconto WHERE co_pianodeiconti1.descrizione="Patrimoniale" AND data <= '.prepare($_SESSION['period_end']).' AND co_pianodeiconti3.id NOT IN('.prepare($idconto_apertura).', '.prepare($idconto_chiusura).') AND is_apertura=0 AND is_chiusura=0 GROUP BY co_pianodeiconti3.id HAVING totale != 0'); - - $mastrino = Mastrino::build(tr('Chiusura conto'), $_SESSION['period_end'], 0, true); - - $totale = 0; - - foreach ($conti as $conto) { - if ($conto['totale'] < 0) { - $dare = abs($conto['totale']); - $avere = 0; - } else { - $dare = 0; - $avere = abs($conto['totale']); - } - - $movimento = Movimento::build($mastrino, $conto['id']); - $movimento->setTotale($avere, $dare); - $movimento->is_chiusura = true; - $movimento->save(); - - $totale += $conto['totale']; - } - - // Movimento sul conto di chiusura - //$totale = -$totale; - - if ($totale >= 0) { - $dare = abs($totale); - $avere = 0; - } else { - $dare = 0; - $avere = abs($totale); - } - - $movimento = Movimento::build($mastrino, $idconto_chiusura); - $movimento->setTotale($avere, $dare); - $movimento->is_chiusura = true; - $movimento->save(); - - flash()->info(tr('Chiusura bilancio completata!')); - - break; - - case 'aggiorna_reddito': - $start = post('start'); - $end = post('end'); - $id_conto = post('id_conto'); - - $dbo->query('UPDATE co_movimenti - INNER JOIN co_pianodeiconti3 ON co_pianodeiconti3.id = co_movimenti.idconto - SET co_movimenti.totale_reddito = (co_movimenti.totale * co_pianodeiconti3.percentuale_deducibile / 100) - WHERE co_pianodeiconti3.id = '.prepare($id_conto).' AND - co_movimenti.data BETWEEN '.prepare($start).' AND '.prepare($end)); - - break; -} diff --git a/modules/partitario/add_conto.php b/modules/partitario/add_conto.php deleted file mode 100755 index 1be7a76ce..000000000 --- a/modules/partitario/add_conto.php +++ /dev/null @@ -1,49 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$id_conto = get('id'); -$lvl = get('lvl'); - -?>
    - - - - - - -
    - -
    - {[ "type": "text", "label": "", "name": "numero", "required": 1, "class": "text-center", "value": "000000", "extra": "maxlength=\"6\"" ]} -
    - -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1 ]} -
    -
    -
    - -
    - -
    -
    -
    - diff --git a/modules/partitario/aggiorna_reddito.php b/modules/partitario/aggiorna_reddito.php deleted file mode 100644 index 180556cf0..000000000 --- a/modules/partitario/aggiorna_reddito.php +++ /dev/null @@ -1,56 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$id_conto = get('id'); - -// Informazioni sul conto -$query = 'SELECT *, idpianodeiconti2 AS idpianodeiconti FROM co_pianodeiconti3 WHERE id='.prepare($id_conto); -$conto = $dbo->fetchOne($query); - -echo ' -

    '.tr('Seleziona il periodo temporale per il quale desideri aggiornare la percentuale di deducibilità del conto "_DESC_". La nuova percentuale è: _PERC_%', [ - '_DESC_' => $conto['descrizione'], - '_PERC_' => numberFormat($conto['percentuale_deducibile'], 0), - ]).'.

    -
    - - - - -
    -
    - {[ "type": "date", "label": "'.tr('Inizio del periodo').'", "name": "start", "required": 1, "value": "'.$_SESSION['period_start'].'" ]} -
    - -
    - {[ "type": "date", "label": "'.tr('Fine del periodo').'", "name": "end", "required": 1, "value": "'.$_SESSION['period_end'].'" ]} -
    -
    - -
    - -
    -
    -
    - -'; diff --git a/modules/partitario/ajax/select.php b/modules/partitario/ajax/select.php deleted file mode 100755 index 94a1cd456..000000000 --- a/modules/partitario/ajax/select.php +++ /dev/null @@ -1,155 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -switch ($resource) { - case 'conti': - $query = 'SELECT co_pianodeiconti2.* FROM co_pianodeiconti2 LEFT JOIN co_pianodeiconti3 ON co_pianodeiconti3.idpianodeiconti2=co_pianodeiconti2.id |where| GROUP BY co_pianodeiconti2.id ORDER BY co_pianodeiconti2.numero ASC, co_pianodeiconti3.numero ASC'; - - if ($search != '') { - $wh = 'WHERE (co_pianodeiconti3.descrizione LIKE '.prepare('%'.$search.'%')." OR CONCAT( co_pianodeiconti2.numero, '.', co_pianodeiconti3.numero ) LIKE ".prepare('%'.$search.'%').')'; - } else { - $wh = ''; - } - $query = str_replace('|where|', $wh, $query); - - $rs = $dbo->fetchArray($query); - foreach ($rs as $r) { - $results[] = ['text' => $r['numero'].' '.$r['descrizione'], 'children' => []]; - - $subquery = 'SELECT co_pianodeiconti3.* FROM co_pianodeiconti3 INNER JOIN co_pianodeiconti2 ON co_pianodeiconti3.idpianodeiconti2=co_pianodeiconti2.id |where|'; - - $where = []; - $filter = []; - $search_fields = []; - - foreach ($elements as $element) { - $filter[] = 'co_pianodeiconti3.id='.prepare($element); - } - if (!empty($filter)) { - $where[] = '('.implode(' OR ', $filter).')'; - } - - $where[] = 'idpianodeiconti2='.prepare($r['id']); - - if (!empty($search)) { - $search_fields[] = '(co_pianodeiconti3.descrizione LIKE '.prepare('%'.$search.'%')." OR CONCAT(co_pianodeiconti2.numero, '.', co_pianodeiconti3.numero) LIKE ".prepare('%'.$search.'%').')'; - } - if (!empty($search_fields)) { - $where[] = '('.implode(' OR ', $search_fields).')'; - } - - $wh = ''; - if (count($where) != 0) { - $wh = 'WHERE '.implode(' AND ', $where); - } - $subquery = str_replace('|where|', $wh, $subquery); - - $rs2 = $dbo->fetchArray($subquery); - foreach ($rs2 as $r2) { - $results[count($results) - 1]['children'][] = ['id' => $r2['id'], 'text' => $r['numero'].'.'.$r2['numero'].' '.$r2['descrizione']]; - } - } - - break; - - case 'conti-vendite': - $query = "SELECT co_pianodeiconti3.id, CONCAT( co_pianodeiconti2.numero, '.', co_pianodeiconti3.numero, ' ', co_pianodeiconti3.descrizione ) AS descrizione FROM co_pianodeiconti3 INNER JOIN (co_pianodeiconti2 INNER JOIN co_pianodeiconti1 ON co_pianodeiconti2.idpianodeiconti1=co_pianodeiconti1.id) ON co_pianodeiconti3.idpianodeiconti2=co_pianodeiconti2.id |where| ORDER BY co_pianodeiconti2.numero ASC, co_pianodeiconti3.numero ASC"; - - foreach ($elements as $element) { - $filter[] = 'co_pianodeiconti3.id='.prepare($element); - } - - $where[] = "(co_pianodeiconti2.dir='entrata' OR co_pianodeiconti2.dir='entrata/uscita')"; - - if (!empty($search)) { - $search_fields[] = "CONCAT( co_pianodeiconti2.numero, '.', co_pianodeiconti3.numero, ' ', co_pianodeiconti3.descrizione ) LIKE ".prepare('%'.$search.'%'); - } - - break; - - case 'conti-acquisti': - $query = "SELECT co_pianodeiconti3.id, CONCAT( co_pianodeiconti2.numero, '.', co_pianodeiconti3.numero, ' ', co_pianodeiconti3.descrizione ) AS descrizione FROM co_pianodeiconti3 INNER JOIN (co_pianodeiconti2 INNER JOIN co_pianodeiconti1 ON co_pianodeiconti2.idpianodeiconti1=co_pianodeiconti1.id) ON co_pianodeiconti3.idpianodeiconti2=co_pianodeiconti2.id |where| ORDER BY co_pianodeiconti2.numero ASC, co_pianodeiconti3.numero ASC"; - - foreach ($elements as $element) { - $filter[] = 'co_pianodeiconti3.id='.prepare($element); - } - - $where[] = "(co_pianodeiconti2.dir='uscita' OR co_pianodeiconti2.dir='entrata/uscita')"; - - if (!empty($search)) { - $search_fields[] = "CONCAT( co_pianodeiconti2.numero, '.', co_pianodeiconti3.numero, ' ', co_pianodeiconti3.descrizione ) LIKE ".prepare('%'.$search.'%'); - } - - break; - - case 'conti-modelliprimanota': - $query = 'SELECT co_pianodeiconti2.* FROM co_pianodeiconti2 LEFT JOIN co_pianodeiconti3 ON co_pianodeiconti3.idpianodeiconti2=co_pianodeiconti2.id |where| GROUP BY co_pianodeiconti2.id'; - - if ($search != '') { - $wh = 'WHERE (co_pianodeiconti3.descrizione LIKE '.prepare('%'.$search.'%')." OR CONCAT( co_pianodeiconti2.numero, '.', co_pianodeiconti3.numero ) LIKE ".prepare('%'.$search.'%').')'; - } else { - $wh = ''; - } - $query = str_replace('|where|', $wh, $query); - - $rs = $dbo->fetchArray($query); - foreach ($rs as $r) { - $results[] = ['text' => $r['numero'].' '.$r['descrizione'], 'children' => []]; - - $subquery = 'SELECT co_pianodeiconti3.* FROM co_pianodeiconti3 INNER JOIN co_pianodeiconti2 ON co_pianodeiconti3.idpianodeiconti2=co_pianodeiconti2.id |where|'; - - $where = []; - $filter = []; - $search_fields = []; - - foreach ($elements as $element) { - $filter[] = 'co_pianodeiconti3.id='.prepare($element); - } - if (!empty($filter)) { - $where[] = '('.implode(' OR ', $filter).')'; - } - - $where[] = 'idpianodeiconti2='.prepare($r['id']); - - if (!empty($search)) { - $search_fields[] = '(co_pianodeiconti3.descrizione LIKE '.prepare('%'.$search.'%')." OR CONCAT(co_pianodeiconti2.numero, '.', co_pianodeiconti3.numero) LIKE ".prepare('%'.$search.'%').')'; - } - if (!empty($search_fields)) { - $where[] = '('.implode(' OR ', $search_fields).')'; - } - - $wh = ''; - if (count($where) != 0) { - $wh = 'WHERE '.implode(' AND ', $where); - } - $subquery = str_replace('|where|', $wh, $subquery); - - $rs2 = $dbo->fetchArray($subquery); - foreach ($rs2 as $r2) { - $results[count($results) - 1]['children'][] = ['id' => $r2['id'], 'text' => $r['numero'].'.'.$r2['numero'].' '.$r2['descrizione']]; - } - - $results[] = ['text' => 'Conto cliente/fornitore fattura', 'children' => []]; - $results[count($results) - 1]['children'][] = ['id' => '-1', 'text' => '{Conto cliente/fornitore fattura}']; - } - - break; -} diff --git a/modules/partitario/dettagli_conto.php b/modules/partitario/dettagli_conto.php deleted file mode 100755 index 47a285078..000000000 --- a/modules/partitario/dettagli_conto.php +++ /dev/null @@ -1,115 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$prima_nota = Modules::get('Prima nota'); - -$id_conto = get('id_conto'); - -// Calcolo totale conto da elenco movimenti di questo conto -$query = 'SELECT co_movimenti.*, - SUM(totale) AS totale, - dir FROM co_movimenti -LEFT OUTER JOIN co_documenti ON co_movimenti.iddocumento = co_documenti.id -LEFT OUTER JOIN co_tipidocumento ON co_documenti.idtipodocumento = co_tipidocumento.id -WHERE co_movimenti.idconto='.prepare($id_conto).' AND - co_movimenti.data >= '.prepare($_SESSION['period_start']).' AND - co_movimenti.data <= '.prepare($_SESSION['period_end']).' -GROUP BY co_movimenti.idmastrino -ORDER BY co_movimenti.data ASC, co_movimenti.descrizione'; -$movimenti = $dbo->fetchArray($query); - -if (!empty($movimenti)) { - echo ' - - - - - - - - '; - - $scalare = 0; - - // Elenco righe del partitario - foreach ($movimenti as $movimento) { - echo ' - - '; - - // Data - echo ' - '; - - // Dare - if ($movimento['totale'] > 0) { - echo ' - - '; - } - - // Avere - else { - echo ' - - '; - } - - $scalare += $movimento['totale']; - - echo ' - '; - - echo ' - '; - } - - echo ' -
    '.tr('Causale').''.tr('Data').''.tr('Dare').''.tr('Avere').''.tr('Scalare').'
    '; - - $modulo_fattura = ($movimento['dir'] == 'entrata') ? Modules::get('Fatture di vendita') : Modules::get('Fatture di acquisto'); - - if (!empty($movimento['primanota'])) { - echo Modules::link($prima_nota->id, $movimento['idmastrino'], $movimento['descrizione']); - } else { - echo Modules::link($modulo_fattura->id, $movimento['iddocumento'], $movimento['descrizione']); - } - - echo ' - - '.dateFormat($movimento['data']).' - - '.moneyFormat(abs($movimento['totale']), 2).' - - '.moneyFormat(abs($movimento['totale']), 2).' - - '.moneyFormat($scalare, 2).' -
    - -'; -} else { - echo ' -'.tr('Nessun movimento presente').''; -} diff --git a/modules/partitario/edit.php b/modules/partitario/edit.php deleted file mode 100755 index 01fd77ef1..000000000 --- a/modules/partitario/edit.php +++ /dev/null @@ -1,467 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -// Verifico se è già stata eseguita l'apertura bilancio -$bilancio_gia_aperto = $dbo->fetchNum('SELECT id FROM co_movimenti WHERE is_apertura=1 AND data BETWEEN '.prepare($_SESSION['period_start']).' AND '.prepare($_SESSION['period_end'])); - -$msg = tr('Sei sicuro di voler aprire il bilancio?'); -$btn_class = 'btn-info'; - -if ($bilancio_gia_aperto) { - $msg .= ' '.tr('I movimenti di apertura già esistenti verranno annullati e ricreati').'.'; - $btn_class = 'btn-default'; -} - -echo ' -
    - '.Prints::getLink('Bilancio', null, 'btn btn-lg btn-info', tr('Stampa bilancio'), 'fa fa-print').' - -
    '; - -// Livello 1 -$query1 = 'SELECT * FROM `co_pianodeiconti1` ORDER BY id DESC'; -$primo_livello = $dbo->fetchArray($query1); -foreach ($primo_livello as $conto_primo) { - $totale_attivita = []; - $totale_passivita = []; - - $costi = []; - $ricavi = []; - - $titolo = $conto_primo['descrizione'] == 'Economico' ? tr('Conto economico') : tr('Stato patrimoniale'); - - echo ' -
    -
    -
    -

    - '.$titolo.' - -

    -
    - '.Prints::getLink('Mastrino', $conto_primo['id'], null, tr('Stampa'), null, 'lev=1').' -
    -
    - -
    '; - - // Livello 2 - $query2 = 'SELECT * FROM `co_pianodeiconti2` WHERE idpianodeiconti1 = '.prepare($conto_primo['id']).' ORDER BY numero ASC'; - $secondo_livello = $dbo->fetchArray($query2); - - foreach ($secondo_livello as $conto_secondo) { - // Livello 2 - echo ' -
    - '.Prints::getLink('Mastrino', $conto_secondo['id'], 'btn-info btn-xs', '', null, 'lev=2').' - - -
    - -
    - '.$conto_secondo['numero'].' '.$conto_secondo['descrizione'].' - -
    - -
    - - - - - '; - if ($conto_primo['descrizione'] == 'Economico') { - echo ' - '; - } - echo ' - - - - '; - - // Livello 3 - $query3 = 'SELECT `co_pianodeiconti3`.*, movimenti.numero_movimenti, movimenti.totale, movimenti.totale_reddito, anagrafica.idanagrafica, anagrafica.deleted_at - FROM `co_pianodeiconti3` - LEFT OUTER JOIN ( - SELECT idanagrafica, - idconto_cliente, - idconto_fornitore, - deleted_at - FROM an_anagrafiche - ) AS anagrafica ON co_pianodeiconti3.id IN (anagrafica.idconto_cliente, anagrafica.idconto_fornitore) - LEFT OUTER JOIN ( - SELECT COUNT(idconto) AS numero_movimenti, - idconto, - SUM(totale) AS totale, - SUM(totale_reddito) AS totale_reddito - FROM co_movimenti - WHERE data BETWEEN '.prepare($_SESSION['period_start']).' AND '.prepare($_SESSION['period_end']).' GROUP BY idconto - ) movimenti ON co_pianodeiconti3.id=movimenti.idconto - WHERE `idpianodeiconti2` = '.prepare($conto_secondo['id']).' ORDER BY numero ASC'; - $terzo_livello = $dbo->fetchArray($query3); - foreach ($terzo_livello as $conto_terzo) { - // Se il conto non ha documenti collegati posso eliminarlo - $numero_movimenti = $conto_terzo['numero_movimenti']; - - $totale_conto = $conto_terzo['totale']; - $totale_reddito = $conto_terzo['totale_reddito']; - if ($conto_primo['descrizione'] != 'Patrimoniale') { - $totale_conto = -$totale_conto; - $totale_reddito = -$totale_reddito; - } - - $totale_conto2 += $totale_conto; - $totale_reddito2 += $totale_reddito; - - echo ' - - - - '; - if ($conto_primo['descrizione'] == 'Economico') { - echo ' - '; - } - echo ' - '; - } - - echo ' - - - - - - '; - if ($conto_primo['descrizione'] == 'Economico') { - echo ''; - } - echo ' - - -
    '.tr('Descrizione').''.tr('Importo').''.tr('Importo reddito').'
    '; - - // Possibilità di esplodere i movimenti del conto - if (!empty($numero_movimenti)) { - echo ' - '; - } - - // Span con i pulsanti - echo ' - '; - - // Possibilità di visionare l'anagrafica - $id_anagrafica = $conto_terzo['idanagrafica']; - $anagrafica_deleted = $conto_terzo['deleted_at']; - if (isset($id_anagrafica)) { - echo Modules::link('Anagrafiche', $id_anagrafica, ' '); - } - - // Stampa mastrino - if (!empty($numero_movimenti)) { - echo ' - '.Prints::getLink('Mastrino', $conto_terzo['id'], 'btn-info btn-xs', '', null, 'lev=3'); - } - - // Pulsante per aggiornare il totale reddito del conto di livello 3 - echo ' - '; - - // Pulsante per modificare il nome del conto di livello 3 - echo ' - '; - - // Possibilità di eliminare il conto se non ci sono movimenti collegati - if ($numero_movimenti <= 0) { - echo ' - - - '; - } - - echo ' - '; - - // Span con info del conto - echo ' - -  '.$conto_secondo['numero'].'.'.$conto_terzo['numero'].' '.$conto_terzo['descrizione'].($conto_terzo['percentuale_deducibile'] < 100 ? ' ('.tr('deducibile al _PERC_%', ['_PERC_' => Translator::numberToLocale($conto_terzo['percentuale_deducibile'], 0)]).')' : '').' - - - - '.moneyFormat($totale_conto, 2).' - - '.moneyFormat($totale_reddito, 2).' -
    '.tr('Totale').''.moneyFormat($totale_conto2).''.moneyFormat($totale_reddito2).'
    - -

    -
    '; - // Somma dei totali - if ($conto_primo['descrizione'] == 'Patrimoniale') { - if ($totale_conto2 > 0) { - $totale_attivita[] = abs($totale_conto2); - } else { - $totale_passivita[] = abs($totale_conto2); - } - } else { - if ($totale_conto2 > 0) { - $totale_ricavi[] = abs($totale_conto2); - } else { - $totale_costi[] = abs($totale_conto2); - } - } - - $totale_conto2 = 0; - $totale_reddito2 = 0; - } - - echo ' -
    - - '; - - // Riepiloghi - if ($conto_primo['descrizione'] == 'Patrimoniale') { - $attivita = abs(sum($totale_attivita)); - $passivita = abs(sum($totale_passivita)); - $utile_perdita = abs(sum($totale_ricavi)) - abs(sum($totale_costi)); - if ($utile_perdita < 0) { - $pareggio1 = $attivita + abs($utile_perdita); - $pareggio2 = abs($passivita); - } else { - $pareggio1 = $attivita; - $pareggio2 = abs($passivita) + abs($utile_perdita); - } - - // Attività - echo ' - - - - '; - - // Passività - echo ' - - - '; - - // Perdita d'esercizio - if ($utile_perdita < 0) { - echo ' - - - - - - - '; - } else { - echo ' - - - - - - - '; - } - - // Totale a pareggio - echo ' - - - - - - - - '; - } else { - echo ' - - - - - - - - - - - - - - '; - } - - echo ' -
    - '.tr('Totale attività').': - - '.moneyFormat($attivita, 2).' - - '.tr('Passività').': - - '.moneyFormat($passivita, 2).' -
    - '.tr("Perdita d'esercizio").': - - '.moneyFormat(sum($utile_perdita), 2).' -
    - '.tr('Utile').': - - '.moneyFormat(sum($utile_perdita), 2).' -
    - '.tr('Totale a pareggio').': - - '.moneyFormat(sum($pareggio1), 2).' - - '.tr('Totale a pareggio').': - - '.moneyFormat(sum($pareggio2), 2).' -
    - '.tr('Ricavi').': - - '.moneyFormat(sum($totale_ricavi), 2).' -
    - '.tr('Costi').': - - '.moneyFormat(sum($totale_costi), 2).' -
    - '.tr('Utile/perdita').': - - '.moneyFormat(sum($totale_ricavi) - abs(sum($totale_costi)), 2).' -
    -
    -
    '; -} - -// Verifico se è già stata eseguita l'apertura bilancio -$bilancio_gia_chiuso = $dbo->fetchNum('SELECT id FROM co_movimenti WHERE is_chiusura=1 AND data BETWEEN '.prepare($_SESSION['period_start']).' AND '.prepare($_SESSION['period_end'])); - -$msg = tr('Sei sicuro di voler aprire il bilancio?'); -$btn_class = 'btn-info'; - -if ($bilancio_gia_chiuso) { - $msg .= ' '.tr('I movimenti di apertura già esistenti verranno annullati e ricreati').'.'; - $btn_class = 'btn-default'; -} - -echo ' -
    - -
    - -
    -
    - -'; diff --git a/modules/partitario/edit_conto.php b/modules/partitario/edit_conto.php deleted file mode 100755 index 4225fa014..000000000 --- a/modules/partitario/edit_conto.php +++ /dev/null @@ -1,71 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$idconto = get('id'); -$lvl = get('lvl'); - -// Info conto -if ($lvl == 2) { - $query = 'SELECT *, idpianodeiconti1 AS idpianodeiconti FROM co_pianodeiconti2 WHERE id='.prepare($idconto); -} else { - $query = 'SELECT *, idpianodeiconti2 AS idpianodeiconti, (SELECT dir FROM co_pianodeiconti2 WHERE co_pianodeiconti2.id=co_pianodeiconti3.idpianodeiconti2) AS dir FROM co_pianodeiconti3 WHERE id='.prepare($idconto); -} - -$info = $dbo->fetchOne($query); - -?>
    - - - - - - - -
    -
    - {[ "type": "text", "label": "", "name": "numero", "required": 1, "class": "text-center", "value": "", "extra": "maxlength=\"6\"" ]} -
    - -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1, "value": ]} -
    -
    -
    -
    - {[ "type": "number", "decimals": 0, "label": "", "name": "percentuale_deducibile", "value": "", "icon-after": "", "max-value": "100", "min-value": "0" ]} -
    - -
    - {[ "type": "select", "label": "", "name": "dir", "value": "", "values": "list=\"entrata\":\"Ricavo\", \"uscita\":\"Costo\", \"entrata/uscita\":\"Ricavo e Costo\", \"\": \"Non usare\"" ]} -
    -
    -
    - -
    - -
    -
    -
    - - - diff --git a/modules/piano_sconto/actions.php b/modules/piano_sconto/actions.php deleted file mode 100644 index efcc2883f..000000000 --- a/modules/piano_sconto/actions.php +++ /dev/null @@ -1,53 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\PianiSconto\PianoSconto; - -switch (post('op')) { - case 'update': - $listino->nome = post('nome'); - $listino->note = post('note'); - - $listino->percentuale = post('prc_guadagno'); - $listino->percentuale_combinato = post('prc_combinato'); - - $listino->save(); - - flash()->info(tr('Informazioni salvate correttamente!')); - break; - - case 'add': - $listino = PianoSconto::build(post('nome'), post('prc_guadagno')); - - $listino->percentuale_combinato = post('prc_combinato'); - - $listino->save(); - $id_record = $listino->id; - - flash()->info(tr('Nuovo listino aggiunto!')); - break; - - case 'delete': - $listino->delete(); - - flash()->info(tr('Listino eliminato!')); - break; -} diff --git a/modules/piano_sconto/add.php b/modules/piano_sconto/add.php deleted file mode 100755 index 5a0179b9b..000000000 --- a/modules/piano_sconto/add.php +++ /dev/null @@ -1,69 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "nome", "required": 1 ]} -
    - -
    - {[ "type": "text", "label": "", "name": "prc_combinato", "value": "$prc_combinato$", "icon-after": "%", "class": "math-mask text-right", "help": "" ]} -
    - -
    - {[ "type": "number", "label": "", "name": "prc_guadagno", "required": 1, "value": "0", "icon-after": "%", "help": "" ]} -
    -
    - - -
    -
    - -
    -
    -
    - - diff --git a/modules/piano_sconto/edit.php b/modules/piano_sconto/edit.php deleted file mode 100755 index 1800d9300..000000000 --- a/modules/piano_sconto/edit.php +++ /dev/null @@ -1,67 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "nome", "required": 1, "value": "$nome$" ]} -
    - -
    - {[ "type": "text", "label": "", "name": "prc_combinato", "value": "$prc_combinato$", "icon-after": "%", "class": "math-mask text-right", "help": "", "disabled": "" ]} -
    - -
    - {[ "type": "number", "label": "", "name": "prc_guadagno", "required": 1, "value": "$prc_guadagno$", "icon-after": "%", "help": "", "disabled": "" ]} -
    -
    - -
    -
    - {[ "type": "textarea", "label": "", "name": "note", "value": "$note$" ]} -
    -
    -
    - - - - - - diff --git a/modules/piano_sconto/init.php b/modules/piano_sconto/init.php deleted file mode 100644 index 96f1bbef5..000000000 --- a/modules/piano_sconto/init.php +++ /dev/null @@ -1,28 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\PianiSconto\PianoSconto; - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT * FROM mg_listini WHERE id='.prepare($id_record)); - - $listino = PianoSconto::find($id_record); -} diff --git a/modules/piano_sconto/src/PianoSconto.php b/modules/piano_sconto/src/PianoSconto.php deleted file mode 100644 index 8c9ff872c..000000000 --- a/modules/piano_sconto/src/PianoSconto.php +++ /dev/null @@ -1,76 +0,0 @@ -. - */ - -namespace Modules\PianiSconto; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; - -class PianoSconto extends Model -{ - use SimpleModelTrait; - - protected $table = 'mg_listini'; - - public static function build($nome, $percentuale) - { - $model = new static(); - - $model->nome = $nome; - $model->percentuale = $percentuale; - $model->save(); - - return $model; - } - - public function setPercentualeCombinatoAttribute($value) - { - $this->prc_combinato = $value; - } - - public function getPercentualeCombinatoAttribute() - { - return $this->prc_combinato; - } - - public function setPercentualeAttribute($value) - { - $value = floatval($value); - if (abs($value) > 100) { - $value = ($value > 0) ? 100 : -100; - } - - $this->prc_guadagno = $value; - } - - public function getPercentualeAttribute() - { - return $this->prc_guadagno; - } - - public function save(array $options = []) - { - $combinato = $this->prc_combinato; - if (!empty($combinato)) { - $this->percentuale = parseScontoCombinato($combinato); - } - - return parent::save($options); - } -} diff --git a/modules/porti/actions.php b/modules/porti/actions.php deleted file mode 100755 index e172fdea7..000000000 --- a/modules/porti/actions.php +++ /dev/null @@ -1,81 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -switch (filter('op')) { - case 'update': - $descrizione = filter('descrizione'); - - if ($dbo->fetchNum('SELECT * FROM `dt_porto` WHERE `descrizione`='.prepare($descrizione).' AND `id`!='.prepare($id_record)) == 0) { - $predefined = post('predefined'); - if (!empty($predefined)) { - $dbo->query('UPDATE dt_porto SET predefined = 0'); - } - - $dbo->update('dt_porto', [ - 'descrizione' => $descrizione, - 'predefined' => $predefined, - ], ['id' => $id_record]); - - flash()->info(tr('Salvataggio completato!')); - } else { - flash()->error(tr("E' già presente una tipologia di _TYPE_ con la stessa descrizione", [ - '_TYPE_' => 'porto', - ])); - } - break; - - case 'add': - $descrizione = filter('descrizione'); - - if ($dbo->fetchNum('SELECT * FROM `dt_porto` WHERE `descrizione`='.prepare($descrizione)) == 0) { - $dbo->insert('dt_porto', [ - 'descrizione' => $descrizione, - ]); - $id_record = $dbo->lastInsertedID(); - - flash()->info(tr('Aggiunta nuova tipologia di _TYPE_', [ - '_TYPE_' => 'porto', - ])); - } else { - flash()->error(tr("E' già presente una tipologia di _TYPE_ con la stessa descrizione", [ - '_TYPE_' => 'porto', - ])); - } - - break; - - case 'delete': - $documenti = $dbo->fetchNum('SELECT id FROM dt_ddt WHERE idporto='.prepare($id_record).' - UNION SELECT id FROM co_documenti WHERE idporto='.prepare($id_record).' - UNION SELECT id FROM co_preventivi WHERE idporto='.prepare($id_record)); - - if (isset($id_record) && empty($documenti)) { - $dbo->query('DELETE FROM `dt_porto` WHERE `id`='.prepare($id_record)); - - flash()->info(tr('Tipologia di _TYPE_ eliminata con successo!', [ - '_TYPE_' => 'porto', - ])); - } else { - flash()->error(tr('Sono presenti dei documenti collegati a questo porto.')); - } - - break; -} diff --git a/modules/porti/add.php b/modules/porti/add.php deleted file mode 100755 index 3fc7a45c4..000000000 --- a/modules/porti/add.php +++ /dev/null @@ -1,38 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1 ]} -
    -
    - - -
    -
    - -
    -
    -
    diff --git a/modules/porti/edit.php b/modules/porti/edit.php deleted file mode 100755 index d5f5772c3..000000000 --- a/modules/porti/edit.php +++ /dev/null @@ -1,65 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - - -
    -
    -

    -
    - -
    -
    -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1, "value": "$descrizione$" ]} -
    - -
    - {[ "type": "checkbox", "label": "", "name": "predefined", "value": "$predefined$", "help":"." ]} -
    -
    -
    -
    - -
    - -fetchNum('SELECT id FROM dt_ddt WHERE idporto='.prepare($id_record).' -UNION SELECT id FROM co_documenti WHERE idporto='.prepare($id_record).' -UNION SELECT id FROM co_preventivi WHERE idporto='.prepare($id_record)); - -if (!empty($numero_documenti)) { - echo ' -
    - '.tr('Ci sono _NUM_ documenti collegati', [ - '_NUM_' => $numero_documenti, - ]).'. -
    '; -} -?> - - - - diff --git a/modules/porti/init.php b/modules/porti/init.php deleted file mode 100755 index 492811916..000000000 --- a/modules/porti/init.php +++ /dev/null @@ -1,24 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT * FROM `dt_porto` WHERE id='.prepare($id_record)); -} diff --git a/modules/preventivi/actions.php b/modules/preventivi/actions.php deleted file mode 100755 index c8c761c63..000000000 --- a/modules/preventivi/actions.php +++ /dev/null @@ -1,401 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Carbon\Carbon; -use Modules\Anagrafiche\Anagrafica; -use Modules\Articoli\Articolo as ArticoloOriginale; -use Modules\Preventivi\Components\Articolo; -use Modules\Preventivi\Components\Descrizione; -use Modules\Preventivi\Components\Riga; -use Modules\Preventivi\Components\Sconto; -use Modules\Preventivi\Preventivo; -use Modules\TipiIntervento\Tipo as TipoSessione; - -switch (post('op')) { - case 'add': - $idanagrafica = post('idanagrafica'); - $nome = post('nome'); - $idtipointervento = post('idtipointervento'); - $data_bozza = post('data_bozza'); - $id_sede = post('idsede'); - - $anagrafica = Anagrafica::find($idanagrafica); - $tipo = TipoSessione::find($idtipointervento); - - $preventivo = Preventivo::build($anagrafica, $tipo, $nome, $data_bozza, $id_sede); - $id_record = $preventivo->id; - - flash()->info(tr('Aggiunto preventivo numero _NUM_!', [ - '_NUM_' => $preventivo['numero'], - ])); - - break; - - case 'update': - if (isset($id_record)) { - $preventivo->idstato = post('idstato'); - $preventivo->nome = post('nome'); - $preventivo->idanagrafica = post('idanagrafica'); - $preventivo->idsede = post('idsede'); - $preventivo->idagente = post('idagente'); - $preventivo->idreferente = post('idreferente'); - $preventivo->idpagamento = post('idpagamento'); - $preventivo->idporto = post('idporto'); - $preventivo->tempi_consegna = post('tempi_consegna'); - $preventivo->numero = post('numero'); - $preventivo->condizioni_fornitura = post('condizioni_fornitura'); - - // Informazioni sulle date del documento - $preventivo->data_bozza = post('data_bozza') ?: null; - $preventivo->data_rifiuto = post('data_rifiuto') ?: null; - - // Dati relativi alla validità del documento - $preventivo->validita = post('validita'); - $preventivo->tipo_validita = post('tipo_validita'); - $preventivo->data_accettazione = post('data_accettazione') ?: null; - $preventivo->data_conclusione = post('data_conclusione') ?: null; - - $preventivo->esclusioni = post('esclusioni'); - $preventivo->garanzia = post('garanzia'); - $preventivo->descrizione = post('descrizione'); - $preventivo->id_documento_fe = post('id_documento_fe'); - $preventivo->num_item = post('num_item'); - $preventivo->codice_cig = post('codice_cig'); - $preventivo->codice_cup = post('codice_cup'); - $preventivo->idtipointervento = post('idtipointervento'); - $preventivo->idiva = post('idiva'); - $preventivo->setScontoFinale(post('sconto_finale'), post('tipo_sconto_finale')); - - $preventivo->save(); - - flash()->info(tr('Preventivo modificato correttamente!')); - } - - break; - - // Duplica preventivo - case 'copy': - // Copia del preventivo - $new = $preventivo->replicate(); - $new->numero = Preventivo::getNextNumero(Carbon::now()); - $new->data_bozza = Carbon::now(); - $new->data_conclusione = Carbon::now()->addMonth(); - $new->stato = 'Bozza'; - $new->save(); - - $new->master_revision = $new->id; - $new->save(); - - $id_record = $new->id; - - // Copia delle righe - $righe = $preventivo->getRighe(); - foreach ($righe as $riga) { - $new_riga = $riga->replicate(); - $new_riga->setDocument($new); - - $new_riga->qta_evasa = 0; - $new_riga->save(); - } - - flash()->info(tr('Preventivo duplicato correttamente!')); - break; - - case 'addintervento': - if (post('idintervento') !== null) { - // Selezione costi da intervento - $idintervento = post('idintervento'); - $rs = $dbo->fetchArray('SELECT * FROM in_interventi WHERE id='.prepare($idintervento)); - $costo_km = $rs[0]['prezzo_km_unitario']; - $costo_orario = $rs[0]['prezzo_ore_unitario']; - - $dbo->update('in_interventi', [ - 'id_preventivo' => $id_record, - ], ['id' => $idintervento]); - - // Imposto il preventivo nello stato "In lavorazione" se inizio ad aggiungere interventi - $dbo->query("UPDATE `co_preventivi` SET idstato=(SELECT `id` FROM `co_statipreventivi` WHERE `descrizione`='In lavorazione') WHERE `id`=".prepare($id_record)); - - flash()->info(tr('Intervento _NUM_ aggiunto!', [ - '_NUM_' => $rs[0]['codice'], - ])); - } - break; - - // Scollegamento intervento da preventivo - case 'unlink': - if (isset($_GET['idpreventivo']) && isset($_GET['idintervento'])) { - $idintervento = get('idintervento'); - - $dbo->update('in_interventi', [ - 'id_preventivo' => null, - ], ['id' => $idintervento]); - - flash()->info(tr('Intervento _NUM_ rimosso!', [ - '_NUM_' => $idintervento, - ])); - } - break; - - // Eliminazione preventivo - case 'delete': - try { - $preventivo->delete(); - - flash()->info(tr('Preventivo eliminato!')); - } catch (InvalidArgumentException $e) { - flash()->error(tr('Sono stati utilizzati alcuni serial number nel documento: impossibile procedere!')); - } - - break; - - case 'manage_barcode': - foreach (post('qta') as $id_articolo => $qta) { - if ($id_articolo == '-id-') { - continue; - } - - // Dati di input - $sconto = post('sconto')[$id_articolo]; - $tipo_sconto = post('tipo_sconto')[$id_articolo]; - $prezzo_unitario = post('prezzo_unitario')[$id_articolo]; - $id_dettaglio_fornitore = post('id_dettaglio_fornitore')[$id_articolo]; - $id_iva = $originale->idiva_vendita ? $originale->idiva_vendita : setting('Iva predefinita'); - - // Creazione articolo - $originale = ArticoloOriginale::find($id_articolo); - $articolo = Articolo::build($preventivo, $originale); - $articolo->id_dettaglio_fornitore = $id_dettaglio_fornitore ?: null; - - $articolo->setPrezzoUnitario($prezzo_unitario, $id_iva); - if ($dir == 'entrata') { - $articolo->costo_unitario = $originale->prezzo_acquisto; - } - $articolo->setSconto($sconto, $tipo_sconto); - $articolo->qta = $qta; - - $articolo->save(); - } - - flash()->info(tr('Articoli aggiunti!')); - - break; - - case 'manage_articolo': - if (post('idriga') != null) { - $articolo = Articolo::find(post('idriga')); - } else { - $originale = ArticoloOriginale::find(post('idarticolo')); - $articolo = Articolo::build($preventivo, $originale); - $articolo->id_dettaglio_fornitore = post('id_dettaglio_fornitore') ?: null; - } - - $qta = post('qta'); - - $articolo->descrizione = post('descrizione'); - $articolo->um = post('um') ?: null; - $articolo->data_evasione = post('data_evasione') ?: null; - $articolo->ora_evasione = post('ora_evasione') ?: null; - $articolo->confermato = post('confermato') ?: 0; - - $articolo->costo_unitario = post('costo_unitario') ?: 0; - $articolo->setPrezzoUnitario(post('prezzo_unitario'), post('idiva')); - $articolo->setSconto(post('sconto'), post('tipo_sconto')); - - try { - $articolo->qta = $qta; - } catch (UnexpectedValueException $e) { - flash()->error(tr('Alcuni serial number sono già stati utilizzati!')); - } - - $articolo->save(); - - // Impostare data evasione su tutte le righe - if (post('data_evasione_all') == 1) { - $righe = $preventivo->getRighe()->where('is_descrizione', '=', '0'); - - foreach ($righe as $riga) { - $riga->data_evasione = post('data_evasione') ?: null; - $riga->ora_evasione = post('ora_evasione') ?: null; - $riga->save(); - } - } - // Impostare confermato su tutte le righe - if (post('confermato_all') == 1) { - $righe = $preventivo->getRighe()->where('is_descrizione', '=', '0'); - - foreach ($righe as $riga) { - $riga->confermato = post('confermato') ?: 0; - $riga->save(); - } - } - - if (post('idriga') != null) { - flash()->info(tr('Articolo modificato!')); - } else { - flash()->info(tr('Articolo aggiunto!')); - } - - break; - - case 'manage_sconto': - if (post('idriga') != null) { - $sconto = Sconto::find(post('idriga')); - } else { - $sconto = Sconto::build($preventivo); - } - - $sconto->descrizione = post('descrizione'); - $sconto->setScontoUnitario(post('sconto_unitario'), post('idiva')); - - $sconto->save(); - - if (post('idriga') != null) { - flash()->info(tr('Sconto/maggiorazione modificato!')); - } else { - flash()->info(tr('Sconto/maggiorazione aggiunto!')); - } - - break; - - case 'manage_riga': - if (post('idriga') != null) { - $riga = Riga::find(post('idriga')); - } else { - $riga = Riga::build($preventivo); - } - - $qta = post('qta'); - - $riga->descrizione = post('descrizione'); - $riga->um = post('um') ?: null; - $riga->data_evasione = post('data_evasione') ?: null; - $riga->ora_evasione = post('ora_evasione') ?: null; - $riga->confermato = post('confermato') ?: 0; - - $riga->costo_unitario = post('costo_unitario') ?: 0; - $riga->setPrezzoUnitario(post('prezzo_unitario'), post('idiva')); - $riga->setSconto(post('sconto'), post('tipo_sconto')); - - $riga->qta = $qta; - - $riga->save(); - - // Impostare data evasione su tutte le righe - if (post('data_evasione_all') == 1) { - $righe = $preventivo->getRighe()->where('is_descrizione', '=', '0'); - - foreach ($righe as $riga) { - $riga->data_evasione = post('data_evasione') ?: null; - $riga->ora_evasione = post('ora_evasione') ?: null; - $riga->save(); - } - } - // Impostare confermato su tutte le righe - if (post('confermato_all') == 1) { - $righe = $preventivo->getRighe()->where('is_descrizione', '=', '0'); - - foreach ($righe as $riga) { - $riga->confermato = post('confermato') ?: 0; - $riga->save(); - } - } - - if (post('idriga') != null) { - flash()->info(tr('Riga modificata!')); - } else { - flash()->info(tr('Riga aggiunta!')); - } - - break; - - case 'manage_descrizione': - if (post('idriga') != null) { - $riga = Descrizione::find(post('idriga')); - } else { - $riga = Descrizione::build($preventivo); - } - - $riga->descrizione = post('descrizione'); - - $riga->save(); - - if (post('idriga') != null) { - flash()->info(tr('Riga descrittiva modificata!')); - } else { - flash()->info(tr('Riga descrittiva aggiunta!')); - } - - break; - - // Eliminazione riga - case 'delete_riga': - $id_riga = post('riga_id'); - $type = post('riga_type'); - - $riga = $preventivo->getRiga($type, $id_riga); - - if (!empty($riga)) { - $riga->delete(); - - flash()->info(tr('Riga eliminata!')); - } - - break; - - case 'add_revision': - // Rimozione flag default_revision dal record principale e dalle revisioni - $dbo->query('UPDATE co_preventivi SET default_revision=0 WHERE master_revision = '.prepare($preventivo->master_revision)); - - // Copia del preventivo - $new = $preventivo->replicate(); - $new->stato = 'Bozza'; - $new->save(); - - $new->default_revision = 1; - $new->numero_revision = $new->ultima_revisione + 1; - $new->descrizione_revision = post('descrizione'); - $new->save(); - - $id_record = $new->id; - - // Copia delle righe - $righe = $preventivo->getRighe(); - foreach ($righe as $riga) { - $new_riga = $riga->replicate(); - $new_riga->setDocument($new); - - $new_riga->qta_evasa = 0; - $new_riga->save(); - } - - flash()->info(tr('Aggiunta nuova revisione!')); - break; - - case 'update_position': - $order = explode(',', post('order', true)); - - foreach ($order as $i => $id_riga) { - $dbo->query('UPDATE `co_righe_preventivi` SET `order` = '.prepare($i + 1).' WHERE id='.prepare($id_riga)); - } - - break; -} diff --git a/modules/preventivi/add.php b/modules/preventivi/add.php deleted file mode 100755 index 159ad4329..000000000 --- a/modules/preventivi/add.php +++ /dev/null @@ -1,67 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$id_anagrafica = !empty(get('idanagrafica')) ? get('idanagrafica') : $user['idanagrafica']; - -?>
    - - - - - - -
    -
    - {[ "type": "date", "label": "", "name": "data_bozza", "value": "", "required": 1 ]} -
    -
    - {[ "type": "text", "label": "", "name": "nome", "required": 1 ]} -
    -
    -
    -
    - {[ "type": "select", "label": "", "name": "idanagrafica", "required": 1, "value": "", "ajax-source": "clienti", "icon-after": "add||tipoanagrafica=Cliente&readonly_tipo=1" ]} -
    - -
    - {[ "type": "select", "label": "", "name": "idsede", "ajax-source": "sedi", "placeholder": "Sede legale" ]} -
    -
    -
    -
    - {[ "type": "select", "label": "", "name": "idtipointervento", "required": 1, "values": "query=SELECT idtipointervento AS id, descrizione FROM in_tipiintervento" ]} -
    -
    - - -
    -
    - -
    -
    -
    - - diff --git a/modules/preventivi/ajax.php b/modules/preventivi/ajax.php deleted file mode 100755 index 488a7d658..000000000 --- a/modules/preventivi/ajax.php +++ /dev/null @@ -1,27 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (get('op') == 'get_costo_orario') { - $idtipointervento = get('idtipointervento'); - - $rs = $dbo->fetchArray('SELECT costo_orario FROM in_tipiintervento WHERE idtipointervento='.prepare($idtipointervento)); - echo $rs[0]['costo_orario']; -} diff --git a/modules/preventivi/ajax/search.php b/modules/preventivi/ajax/search.php deleted file mode 100755 index 4701a463b..000000000 --- a/modules/preventivi/ajax/search.php +++ /dev/null @@ -1,74 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -$link_id = Modules::get('Preventivi')['id']; - -$fields = [ - 'Codice preventivo' => 'numero', - 'Nome' => 'nome', - 'Descrizione' => 'descrizione', -]; - -$query = 'SELECT *'; - -foreach ($fields as $name => $value) { - $query .= ', '.$value." AS '".str_replace("'", "\'", $name)."'"; -} - -$query .= ' FROM co_preventivi WHERE idanagrafica IN('.implode(',', $idanagrafiche).') '; - -foreach ($fields as $name => $value) { - $query .= ' OR '.$value.' LIKE "%'.$term.'%"'; -} - -$query .= Modules::getAdditionalsQuery('Preventivi'); - -$rs = $dbo->fetchArray($query); - -foreach ($rs as $r) { - $result = []; - - $result['link'] = base_path().'/editor.php?id_module='.$link_id.'&id_record='.$r['id']; - $result['title'] = 'Preventivo '.$r['numero']; - - if ($r['data_accettazione'] == '0000-00-00') { - $result['title'] .= ' del '.Translator::dateToLocale($r['data_accettazione']); - } - - $result['category'] = 'Preventivi'; - - // Campi da evidenziare - $result['labels'] = []; - foreach ($fields as $name => $value) { - if (string_contains($r[$name], $term)) { - $text = str_replace($term, "".$term.'', $r[$name]); - - $result['labels'][] = $name.': '.$text.'
    '; - } - } - - // Aggiunta nome anagrafica come ultimo campo - if (sizeof($ragioni_sociali) > 1) { - $result['labels'][] = 'Anagrafica: '.$ragioni_sociali[$r['idanagrafica']].'
    '; - } - - $results[] = $result; -} diff --git a/modules/preventivi/ajax/select.php b/modules/preventivi/ajax/select.php deleted file mode 100755 index 8bf963562..000000000 --- a/modules/preventivi/ajax/select.php +++ /dev/null @@ -1,50 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -switch ($resource) { - /* - * Opzioni utilizzate: - * - idanagrafica - * - stato - */ - case 'preventivi': - if (isset($superselect['idanagrafica'])) { - $query = 'SELECT co_preventivi.id AS id, an_anagrafiche.idanagrafica, CONCAT("Preventivo ", numero, " del ", DATE_FORMAT(data_bozza, "%d/%m/%Y"), " - ", co_preventivi.nome, " [", (SELECT `descrizione` FROM `co_statipreventivi` WHERE `co_statipreventivi`.`id` = `idstato`) , "]") AS descrizione, co_preventivi.idtipointervento, (SELECT descrizione FROM in_tipiintervento WHERE in_tipiintervento.idtipointervento = co_preventivi.idtipointervento) AS idtipointervento_descrizione, (SELECT tempo_standard FROM in_tipiintervento WHERE in_tipiintervento.idtipointervento = co_preventivi.idtipointervento) AS tempo_standard, (SELECT SUM(subtotale) FROM co_righe_preventivi WHERE idpreventivo=co_preventivi.id GROUP BY idpreventivo) AS totale, (SELECT SUM(sconto) FROM co_righe_preventivi WHERE idpreventivo=co_preventivi.id GROUP BY idpreventivo) AS sconto FROM co_preventivi INNER JOIN an_anagrafiche ON co_preventivi.idanagrafica=an_anagrafiche.idanagrafica |where| ORDER BY id'; - - foreach ($elements as $element) { - $filter[] = 'id='.prepare($element); - } - - if (empty($elements)) { - $where[] = 'an_anagrafiche.idanagrafica='.prepare($superselect['idanagrafica']); - $where[] = 'co_preventivi.default_revision=1'; - - $stato = !empty($superselect['stato']) ? $superselect['stato'] : 'is_pianificabile'; - $where[] = 'idstato IN (SELECT `id` FROM `co_statipreventivi` WHERE '.$stato.' = 1)'; - } - - if (!empty($search)) { - $search_fields[] = 'nome LIKE '.prepare('%'.$search.'%'); - } - } - - break; -} diff --git a/modules/preventivi/bulk.php b/modules/preventivi/bulk.php deleted file mode 100755 index 686c0e76f..000000000 --- a/modules/preventivi/bulk.php +++ /dev/null @@ -1,133 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Articoli\Articolo as ArticoloOriginale; -use Modules\Fatture\Fattura; -use Modules\Fatture\Stato; -use Modules\Fatture\Tipo; -use Modules\Preventivi\Preventivo; - -$module_fatture = 'Fatture di vendita'; - -// Segmenti -$id_fatture = Modules::get($module_fatture)['id']; -if (!isset($_SESSION['module_'.$id_fatture]['id_segment'])) { - $segments = Modules::getSegments($id_fatture); - $_SESSION['module_'.$id_fatture]['id_segment'] = isset($segments[0]['id']) ? $segments[0]['id'] : null; -} -$id_segment = $_SESSION['module_'.$id_fatture]['id_segment']; - -switch (post('op')) { - case 'crea_fattura': - $documenti = collect(); - $numero_totale = 0; - - // Informazioni della fattura - $descrizione_tipo = 'Fattura immediata di vendita'; - $tipo_documento = Tipo::where('descrizione', $descrizione_tipo)->first(); - - $stato_documenti_accodabili = Stato::where('descrizione', 'Bozza')->first(); - $accodare = post('accodare'); - - $data = date('Y-m-d'); - $id_segment = post('id_segment'); - $idconto = setting('Conto predefinito fatture di vendita'); - - // Lettura righe selezionate - foreach ($id_records as $id) { - $documento_import = Preventivo::find($id); - $anagrafica = $documento_import->anagrafica; - $id_anagrafica = $anagrafica->id; - - if (!$documento_import->stato->is_pianificabile) { - break; - } - - // Proseguo solo se i documenti scelti sono fatturabili - $righe = $documento_import->getRighe(); - if (!empty($righe)) { - ++$numero_totale; - - // Ricerca fattura per anagrafica tra le registrate - $fattura = $documenti->first(function ($item, $key) use ($id_anagrafica) { - return $item->anagrafica->id == $id_anagrafica; - }); - - // Ricerca fattura per anagrafica se l'impostazione di accodamento è selezionata - if (!empty($accodare) && empty($fattura)) { - $fattura = Fattura::where('idanagrafica', $id_anagrafica) - ->where('idstatodocumento', $stato_documenti_accodabili->id) - ->where('idtipodocumento', $tipo_documento->id) - ->first(); - - if (!empty($fattura)) { - $documenti->push($fattura); - } - } - - // Creazione fattura per anagrafica - if (empty($fattura)) { - $fattura = Fattura::build($anagrafica, $tipo_documento, $data, $id_segment); - $documenti->push($fattura); - } - - // Inserimento righe - foreach ($righe as $riga) { - $qta = $riga->qta_rimanente; - - if ($qta > 0) { - $copia = $riga->copiaIn($fattura, $qta); - - //Fix per idconto righe fattura - $articolo = ArticoloOriginale::find($copia->idarticolo); - $copia->id_conto = ($articolo->idconto_vendita ? $articolo->idconto_vendita : $idconto); - - // Aggiornamento seriali dalla riga dell'ordine - if ($copia->isArticolo()) { - $copia->serials = $riga->serials; - } - } - } - } - } - - if ($numero_totale > 0) { - flash()->info(tr('_NUM_ preventivi fatturati!', [ - '_NUM_' => $numero_totale, - ])); - } else { - flash()->warning(tr('Nessun preventivi fatturato!')); - } - break; -} - -$operations['crea_fattura'] = [ - 'text' => ' '.tr('Fattura _TYPE_', ['_TYPE_' => strtolower($module['name'])]), - 'data' => [ - 'title' => tr('Fatturare i _TYPE_ selezionati?', ['_TYPE_' => strtolower($module['name'])]), - 'msg' => '{[ "type": "checkbox", "label": "'.tr('Aggiungere alle fatture di vendita non ancora emesse?').'", "placeholder": "'.tr('Aggiungere alle fatture di vendita nello stato bozza?').'", "name": "accodare" ]}
    {[ "type": "select", "label": "'.tr('Sezionale').'", "name": "id_segment", "required": 1, "values": "query=SELECT id, name AS descrizione FROM zz_segments WHERE id_module=\''.$id_fatture.'\' AND is_fiscale = 1 ORDER BY name", "value": "'.$id_segment.'" ]}', - 'button' => tr('Procedi'), - 'class' => 'btn btn-lg btn-warning', - 'blank' => false, - ], -]; - -return $operations; diff --git a/modules/preventivi/buttons.php b/modules/preventivi/buttons.php deleted file mode 100644 index 6d0eda880..000000000 --- a/modules/preventivi/buttons.php +++ /dev/null @@ -1,92 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo ' -'; - -$stati_abilitati = $dbo->fetchOne('SELECT GROUP_CONCAT(`descrizione` SEPARATOR ", ") AS stati_abilitati FROM `co_statipreventivi` WHERE `is_revisionabile` = 1 ')['stati_abilitati']; - -// Crea revisione -echo ' -
    - -
    '; - -$rs_documento = $dbo->fetchArray('SELECT * FROM co_righe_preventivi WHERE idpreventivo='.prepare($id_record)); - -$disabled = ($record['is_fatturabile'] || $record['is_completato']) && !empty($rs_documento); - -$stati_abilitati = $dbo->fetchOne('SELECT GROUP_CONCAT(`descrizione` SEPARATOR ", ") AS stati_abilitati FROM `co_statipreventivi` WHERE `is_fatturabile` = 1 OR `is_completato` = 1 ')['stati_abilitati']; - -// Creazione altri documenti -echo ' -'; - -// Duplica preventivo -echo ' -
    - - -
    '; diff --git a/modules/preventivi/crea_documento.php b/modules/preventivi/crea_documento.php deleted file mode 100644 index 5193c25c8..000000000 --- a/modules/preventivi/crea_documento.php +++ /dev/null @@ -1,62 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Contratti\Contratto; -use Modules\DDT\DDT; -use Modules\Fatture\Fattura; -use Modules\Ordini\Ordine; -use Modules\Preventivi\Preventivo; - -$documento = Preventivo::find($id_record); - -if (get('documento') == 'fattura') { - $final_module = 'Fatture di vendita'; - $op = 'add_documento'; - $tipo_documento_finale = Fattura::class; -} elseif (get('documento') == 'ordine_cliente') { - $final_module = 'Ordini cliente'; - $op = 'add_preventivo'; - $tipo_documento_finale = Ordine::class; -} elseif (get('documento') == 'ordine_fornitore') { - $final_module = 'Ordini fornitore'; - $op = 'add_ordine_fornitore'; - $tipo_documento_finale = Ordine::class; -} elseif (get('documento') == 'ddt') { - $final_module = 'Ddt di vendita'; - $op = 'add_documento'; - $tipo_documento_finale = DDT::class; -} else { - $final_module = 'Contratti'; - $op = 'add_preventivo'; - $tipo_documento_finale = Contratto::class; -} - -$options = [ - 'op' => $op, - 'type' => 'preventivo', - 'module' => $final_module, - 'button' => tr('Aggiungi'), - 'create_document' => true, - 'documento' => $documento, - 'tipo_documento_finale' => $tipo_documento_finale, -]; - -echo App::load('importa.php', [], $options, true); diff --git a/modules/preventivi/crea_revisione.php b/modules/preventivi/crea_revisione.php deleted file mode 100644 index e9f941dda..000000000 --- a/modules/preventivi/crea_revisione.php +++ /dev/null @@ -1,44 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Preventivi\Preventivo; - -$revisione = Preventivo::find($id_record)->ultima_revisione; -?> - -
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "descrizione", "value": "Revisione n. " ]} -
    -
    - -
    -
    - -
    -
    -
    diff --git a/modules/preventivi/edit.php b/modules/preventivi/edit.php deleted file mode 100755 index f6363d56f..000000000 --- a/modules/preventivi/edit.php +++ /dev/null @@ -1,420 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$block_edit = $record['is_completato']; - -// Mostro un avviso se ci sono più revisioni del preventivo -if (count($preventivo->revisioni) > 1) { - echo ' -
    - - '.tr('Questo preventivo presenta _N_ revisioni', - [ - '_N_' => count($preventivo->revisioni), - ]).' -
    - '; -} - -?>
    - - - - - -
    -
    -

    -
    - -
    -
    -
    - {[ "type": "text", "label": "", "name": "numero", "required": 1, "class": "text-center", "value": "$numero$", "icon-after": "revisioni) > 1) ? tr('rev.').' '.$preventivo->numero_revision : ''; ?>" ]} -
    - -
    - {[ "type": "date", "label": "", "name": "data_bozza", "value": "$data_bozza$" ]} -
    - -
    - {[ "type": "date", "label": "", "name": "data_accettazione", "value": "$data_accettazione$" ]} -
    - -
    - {[ "type": "date", "label": "", "name": "data_conclusione", "value": "$data_conclusione$", "disabled": "isDataConclusioneAutomatica() ? '1", "help": "'.tr('La Data di conclusione è calcolata in automatico in base al valore del campo Validità') : 0; ?>" ]} -
    - -
    - {[ "type": "date", "label": "", "name": "data_rifiuto", "value": "$data_rifiuto$" ]} -
    -
    - - -
    - '.Modules::link('Anagrafiche', $record['idanagrafica'], null, null, 'class="pull-right"').' - {[ "type": "select", "label": "'.tr('Cliente').'", "name": "idanagrafica", "required": 1, "value": "$idanagrafica$", "ajax-source": "clienti" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Sede').'", "name": "idsede", "value": "$idsede$", "ajax-source": "sedi", "select-options": {"idanagrafica": '.$record['idanagrafica'].'}, "placeholder": "Sede legale" ]} -
    - -
    '; - - if (!empty($record['idreferente'])) { - echo Plugins::link('Referenti', $record['idanagrafica'], null, null, 'class="pull-right"'); - } - echo ' - {[ "type": "select", "label": "'.tr('Referente').'", "name": "idreferente", "value": "$idreferente$", "ajax-source": "referenti", "select-options": {"idanagrafica": '.$record['idanagrafica'].'} ]} -
    - -
    '; - if ($record['idagente'] != 0) { - echo Modules::link('Anagrafiche', $record['idagente'], null, null, 'class="pull-right"'); - } -echo ' - {[ "type": "select", "label": "'.tr('Agente').'", "name": "idagente", "values": "query=SELECT an_anagrafiche.idanagrafica AS id, ragione_sociale AS descrizione FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE descrizione=\'Agente\' AND deleted_at IS NULL ORDER BY ragione_sociale", "value": "$idagente$" ]} -
    -
    '; - ?> - -
    -
    - {[ "type": "text", "label": "", "name": "nome", "required": 1, "value": "$nome$" ]} -
    - -
    - - - {[ "type": "select", "label": "", "name": "idpagamento", "values": "query=SELECT id, descrizione FROM co_pagamenti GROUP BY descrizione ORDER BY descrizione", "value": "$idpagamento$" ]} -
    - -
    - {[ "type": "select", "label": "", "name": "idstato", "required": 1, "values": "query=SELECT id, descrizione FROM co_statipreventivi", "value": "$idstato$", "class": "unblockable" ]} -
    - -
    - -
    -
    - {[ "type": "number", "label": "", "name": "validita", "decimals": "0", "value": "$validita$", "icon-after": "choice|period|", "help": "" ]} -
    - -
    - {[ "type": "select", "label": "", "name": "idtipointervento", "required": 1, "values": "query=SELECT idtipointervento AS id, descrizione FROM in_tipiintervento ORDER BY descrizione", "value": "$idtipointervento$" ]} -
    - - - - -
    - {[ "type": "text", "label": "", "name": "tempi_consegna", "value": "$tempi_consegna$" ]} -
    - -
    - {[ "type": "number", "label": "", "name": "sconto_finale", "value": "sconto_finale_percentuale ?: $preventivo->sconto_finale; ?>", "icon-after": "choice|untprc|sconto_finale) ? 'PRC' : 'UNT'; ?>", "help": "." ]} -
    - -
    -
    - -
    - -
    -
    - {[ "type": "textarea", "label": "", "name": "esclusioni", "class": "autosize", "value": "$esclusioni$" ]} -
    -
    - -
    -
    - {[ "type": "textarea", "label": "", "name": "garanzia", "class": "autosize", "value": "$garanzia$" ]} -
    -
    - -
    -
    - {[ "type": "textarea", "label": "", "name": "descrizione", "class": "autosize", "value": "$descrizione$" ]} -
    -
    - -
    -
    - {[ "type": "ckeditor", "use_full_ckeditor": 1, "label": "", "name": "condizioni_fornitura", "class": "autosize", "value": "$condizioni_fornitura$" ]} -
    -
    - - - -
    - - - - - -
    -
    -
    -

    - - -
    - -
    -

    -
    -
    -
    -
    -
    - {[ "type": "text", "label": "", "name": "id_documento_fe", "required": 0, "help": "Obbligatorio per valorizzare CIG/CUP. È possible inserire:
    • N. determina
    • RDO
    • Ordine MEPA
    '); ?>", "value": "$id_documento_fe$", "maxlength": 20 ]} -
    - -
    - {[ "type": "text", "label": "", "name": "num_item", "required": 0, "value": "$num_item$", "maxlength": 15 ]} -
    -
    -
    -
    - {[ "type": "text", "label": "", "name": "codice_cig", "required": 0, "value": "$codice_cig$", "maxlength": 15 ]} -
    - -
    - {[ "type": "text", "label": "", "name": "codice_cup", "required": 0, "value": "$codice_cup$", "maxlength": 15 ]} -
    -
    -
    -
    -
    -
    -
    - - -
    -
    -

    '.tr('Righe').'

    -
    - -
    '; - -if (!$block_edit) { - echo ' - '; - - echo ' - '; - - echo ' - '; - - echo ' - '; - - echo ' - '; -} - -echo ' - -
    -
    - -
    -
    -
    -
    -
    - -{( "name": "filelist_and_upload", "id_module": "$id_module$", "id_record": "$id_record$" )} - -{( "name": "log_email", "id_module": "$id_module$", "id_record": "$id_record$" )} - -'; - -// Fatture, ordini collegate a questo preventivo -$elementi = $dbo->fetchArray('SELECT `co_documenti`.`id`, `co_documenti`.`data`, `co_documenti`.`numero`, `co_documenti`.`numero_esterno`, `co_tipidocumento`.`descrizione` AS tipo_documento, IF(`co_tipidocumento`.`dir` = \'entrata\', \'Fatture di vendita\', \'Fatture di acquisto\') AS modulo FROM `co_documenti` JOIN `co_tipidocumento` ON `co_tipidocumento`.`id` = `co_documenti`.`idtipodocumento` WHERE `co_documenti`.`id` IN (SELECT `iddocumento` FROM `co_righe_documenti` WHERE `idpreventivo` = '.prepare($id_record).') - -UNION -SELECT `or_ordini`.`id`, `or_ordini`.`data`, `or_ordini`.`numero`, `or_ordini`.`numero_esterno`, \'Ordine cliente\', \'Ordini cliente\' FROM `or_ordini` JOIN `or_righe_ordini` ON `or_righe_ordini`.`idordine` = `or_ordini`.`id` WHERE `or_righe_ordini`.`idpreventivo` = '.prepare($id_record).' - -UNION -SELECT `in_interventi`.`id`, `in_interventi`.`data_richiesta`, `in_interventi`.`codice`, NULL, \'Attività\', \'Interventi\' FROM `in_interventi` JOIN `in_righe_interventi` ON `in_righe_interventi`.`idintervento` = `in_interventi`.`id` WHERE (`in_righe_interventi`.`original_document_id` = '.prepare($preventivo->id).' AND `in_righe_interventi`.`original_document_type` = '.prepare(get_class($preventivo)).') OR `in_interventi`.`id_preventivo` = '.prepare($id_record).' - -ORDER BY `data`'); - -if (!empty($elementi)) { - echo ' -
    -
    -

    '.tr('Documenti collegati: _NUM_', [ - '_NUM_' => count($elementi), - ]).'

    -
    - -
    -
    -
    -
      '; - - foreach ($elementi as $elemento) { - $descrizione = tr('_DOC_ num. _NUM_ del _DATE_', [ - '_DOC_' => $elemento['tipo_documento'], - '_NUM_' => !empty($elemento['numero_esterno']) ? $elemento['numero_esterno'] : $elemento['numero'], - '_DATE_' => Translator::dateToLocale($elemento['data']), - ]); - - echo ' -
    • '.Modules::link($elemento['modulo'], $elemento['id'], $descrizione).'
    • '; - } - - echo ' -
    -
    -
    '; -} - -if (!empty($elementi)) { - echo ' -
    - '.tr('Eliminando questo documento si potrebbero verificare problemi nelle altre sezioni del gestionale').'. -
    '; -} - -?> - - - - diff --git a/modules/preventivi/init.php b/modules/preventivi/init.php deleted file mode 100755 index b0ab05c5e..000000000 --- a/modules/preventivi/init.php +++ /dev/null @@ -1,33 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $preventivo = Modules\Preventivi\Preventivo::with('stato')->find($id_record); - - $record = $dbo->fetchOne('SELECT co_preventivi.*, - (SELECT tipo FROM an_anagrafiche WHERE idanagrafica = co_preventivi.idanagrafica) AS tipo_anagrafica, - co_statipreventivi.is_fatturabile, - co_statipreventivi.is_completato, - co_statipreventivi.is_revisionabile, - co_statipreventivi.descrizione AS stato - FROM co_preventivi LEFT JOIN co_statipreventivi ON co_preventivi.idstato=co_statipreventivi.id - WHERE co_preventivi.id='.prepare($id_record)); -} diff --git a/modules/preventivi/modutil.php b/modules/preventivi/modutil.php deleted file mode 100755 index 749a9a67e..000000000 --- a/modules/preventivi/modutil.php +++ /dev/null @@ -1,49 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Preventivi\Preventivo; - -function get_imponibile_preventivo($idpreventivo) -{ - $preventivo = Preventivo::find($idpreventivo); - - return $preventivo->totale_imponibile; -} - -/** - * Restituisce lo stato dell'ordine in base alle righe. - */ -function get_stato_preventivo($idpreventivo) -{ - $dbo = database(); - - $rs = $dbo->fetchArray('SELECT SUM(qta) AS qta, SUM(qta_evasa) AS qta_evasa FROM co_righe_preventivi GROUP BY idpreventivo HAVING idpreventivo='.prepare($idpreventivo)); - - if ($rs[0]['qta_evasa'] > 0) { - if ($rs[0]['qta'] > $rs[0]['qta_evasa']) { - return 'Parzialmente evaso'; - } elseif ($rs[0]['qta'] == $rs[0]['qta_evasa']) { - return 'Evaso'; - } - } else { - return 'Non evaso'; - } -} diff --git a/modules/preventivi/plugins/preventivi.consuntivo.php b/modules/preventivi/plugins/preventivi.consuntivo.php deleted file mode 100755 index af70ab127..000000000 --- a/modules/preventivi/plugins/preventivi.consuntivo.php +++ /dev/null @@ -1,312 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -use Modules\Interventi\Intervento; - -// CONSUNTIVO - -// Tabella con riepilogo interventi -$interventi = Intervento::where('id_preventivo', $id_record)->get(); -if (!empty($interventi)) { - echo ' - - - - - - - - - '; - - // Tabella con i dati - foreach ($interventi as $intervento) { - // Riga per il singolo intervento - echo ' - - - - - - - - - - - - - '; - - // Riga con dettagli - echo ' - - - '; - } - - $array_interventi = $interventi->toArray(); - $totale_ore = sum(array_column($array_interventi, 'ore_totali')); - $totale_km = sum(array_column($array_interventi, 'km_totali')); - $totale_costo = sum(array_column($array_interventi, 'spesa')); - $totale_addebito = sum(array_column($array_interventi, 'imponibile')); - $totale = sum(array_column($array_interventi, 'totale_imponibile')); - - // Totali - echo ' - - '; - - echo ' - '; - - echo ' - '; - - echo ' - '; - - echo ' - '; - - echo ' - - '; - - $stati = $interventi->groupBy('idstatointervento'); - if (count($stati) > 0) { - // Totali per stato - echo ' - - - '; - - foreach ($stati as $interventi_collegati) { - $stato = $interventi_collegati->first()->stato; - $totale_stato = sum(array_column($interventi_collegati->toArray(), 'totale_imponibile')); - - echo ' - - - - - - - '; - } - } - - echo ' -
    '.tr('Attività').''.tr('Ore').''.tr('Km').''.tr('Costo').''.tr('Addebito').''.tr('Tot. scontato').'
    - - '.Modules::link('Interventi', $intervento->id, tr('Intervento num. _NUM_ del _DATE_', [ - '_NUM_' => $intervento->codice, - '_DATE_' => Translator::dateToLocale($intervento->inizio), - ])).' - - '.numberFormat($intervento->ore_totali).' - - '.numberFormat($intervento->km_totali).' - - '.moneyFormat($intervento->spesa).' - - '.moneyFormat($intervento->imponibile).' - - '.moneyFormat($intervento->totale_imponibile).' -
    '; - - // Lettura sessioni di lavoro - $sessioni = $intervento->sessioni; - if (!empty($sessioni)) { - echo ' - - - - - - - - - - - - - '; - - foreach ($sessioni as $sessione) { - // Visualizzo lo sconto su ore o km se c'è - $sconto_ore = !empty($sessione->sconto_totale_manodopera) ? '
    '.moneyFormat(-$sessione->sconto_totale_manodopera).'' : ''; - $sconto_km = !empty($sessione->sconto_totale_viaggio) ? '
    '.moneyFormat(-$sessione->sconto_totale_viaggio).'' : ''; - - echo ' - - - - - - - - - - - - '; - } - - echo ' -
    '.tr('Tecnico').''.tr('Tipo attività').''.tr('Ore').''.tr('Km').''.tr('Costo ore').''.tr('Costo km').''.tr('Diritto ch.').''.tr('Prezzo ore').''.tr('Prezzo km').''.tr('Diritto ch.').'
    '.$sessione->anagrafica->ragione_sociale.''.$sessione->tipo->descrizione.''.numberFormat($sessione->ore).''.numberFormat($sessione->km).''.moneyFormat($sessione->costo_manodopera).''.moneyFormat($sessione->costo_viaggio).''.moneyFormat($sessione->costo_diritto_chiamata).''.moneyFormat($sessione->prezzo_manodopera).$sconto_ore.''.moneyFormat($sessione->prezzo_viaggio).$sconto_km.''.moneyFormat($sessione->prezzo_diritto_chiamata).'
    '; - } - - // Lettura articoli utilizzati - $articoli = $intervento->articoli; - if (!$articoli->isEmpty()) { - echo ' - - - - - - - '; - - foreach ($articoli as $articolo) { - $sconto = !empty($articolo->sconto) ? '
    '.moneyFormat(-$articolo->sconto).'' : ''; - - echo ' - - - - - - '; - } - - echo ' -
    '.tr('Materiale').''.tr('Q.tà').''.tr('Prezzo di acquisto').''.tr('Prezzo di vendita').'
    - '.Modules::link('Articoli', $articolo->idarticolo, $articolo->descrizione).' - '.numberFormat($articolo->qta, 'qta').''.moneyFormat($articolo->spesa).''.moneyFormat($articolo->imponibile).$sconto.'
    '; - } - - // Lettura spese aggiuntive - $righe = $intervento->righe; - if (!$righe->isEmpty()) { - echo ' - - - - - - - '; - - foreach ($righe as $riga) { - $sconto = !empty($riga->sconto) ? '
    '.moneyFormat(-$riga->sconto).'' : ''; - - echo ' - - - - - - '; - } - - echo ' -
    '.tr('Altre spese').''.tr('Q.tà').''.tr('Prezzo di acquisto').''.tr('Prezzo di vendita').'
    - '.$riga->descrizione.' - '.numberFormat($riga->qta, 'qta').''.moneyFormat($riga->spesa).''.moneyFormat($riga->imponibile).$sconto.'
    '; - } - - echo ' -
    - '.tr('Totale').' - - '.numberFormat($totale_ore).' - - '.numberFormat($totale_km).' - - '.moneyFormat($totale_costo).' - - '.moneyFormat($totale_addebito).' - - '.moneyFormat($totale).' -
    -
    '.tr('Totale interventi per stato', [], ['upper' => true]).' -
    - '.$stato->descrizione.': - - '.moneyFormat($totale_stato).' -
    '; -} - -// Bilancio del preventivo -$budget = $preventivo->totale_imponibile; -$diff = sum($budget, -$totale); - -echo ' -
    -
    - '.tr('Rapporto budget/spesa').':
    '; -if ($diff > 0) { - echo ' - +'.moneyFormat($diff).''; -} elseif ($diff < 0) { - echo ' - '.moneyFormat($diff).''; -} else { - echo ' - '.moneyFormat($diff).''; -} - echo ' -
    -

    -
    '; - -/* - Stampa consuntivo -*/ -echo ' -
    - '.Prints::getLink('Consuntivo preventivo', $id_record, 'btn-primary', tr('Stampa consuntivo')).' -
    '; - -// Aggiunta interventi se il preventivo é aperto o in attesa o pagato (non si possono inserire interventi collegati ad altri preventivi) -if (in_array($record['stato'], ['Accettato', 'In lavorazione', 'Pagato'])) { - echo ' -
    - - - -
    -
    - {[ "type": "select", "label": "'.tr('Aggiungi un altro intervento a questo preventivo').'", "name": "idintervento", "values": "query=SELECT id, CONCAT(\'Intervento \', codice, \' del \', DATE_FORMAT(IFNULL((SELECT MIN(orario_inizio) FROM in_interventi_tecnici WHERE in_interventi_tecnici.idintervento=in_interventi.id), data_richiesta), \'%d/%m/%Y\')) AS descrizione FROM in_interventi WHERE id_preventivo IS NULL AND id NOT IN( SELECT idintervento FROM co_righe_documenti WHERE idintervento IS NOT NULL) AND id NOT IN( SELECT idintervento FROM co_promemoria WHERE idintervento IS NOT NULL) AND idanagrafica='.prepare($record['idanagrafica']).'" ]} -
    -
    - - -
    -
    - -
    -
    -
    '; -} diff --git a/modules/preventivi/row-add.php b/modules/preventivi/row-add.php deleted file mode 100755 index 77d59ff7c..000000000 --- a/modules/preventivi/row-add.php +++ /dev/null @@ -1,87 +0,0 @@ -. - */ - -use Modules\Preventivi\Preventivo; - -include_once __DIR__.'/../../core.php'; - -// Info contratto -$documento = Preventivo::find($id_record); - -// Impostazioni per la gestione -$options = [ - 'op' => 'manage_riga', - 'action' => 'add', - 'dir' => $documento->direzione, - 'idanagrafica' => $documento['idanagrafica'], - 'totale_imponibile_documento' => $documento->totale_imponibile, - 'totale_documento' => $documento->totale, - 'select-options' => [ - 'articoli' => [ - 'idanagrafica' => $documento->idanagrafica, - 'dir' => $documento->direzione, - 'permetti_movimento_a_zero' => 1, - ], - ], -]; - -// Dati di default -$result = [ - 'descrizione' => '', - 'qta' => 1, - 'um' => '', - 'prezzo' => 0, - 'sconto_unitario' => 0, - 'tipo_sconto' => '', - 'idiva' => '', -]; - -// Leggo l'iva predefinita per l'anagrafica e se non c'è leggo quella predefinita generica -$iva = $dbo->fetchArray('SELECT idiva_vendite AS idiva FROM an_anagrafiche WHERE idanagrafica='.prepare($documento['idanagrafica'])); -$result['idiva'] = $iva[0]['idiva'] ?: setting('Iva predefinita'); - -// Importazione della gestione dedicata -$file = 'riga'; -if (get('is_descrizione') !== null) { - $file = 'descrizione'; - - $options['op'] = 'manage_descrizione'; -} elseif (get('is_articolo') !== null) { - $file = 'articolo'; - - // Aggiunta sconto di default da listino per le vendite - $listino = $dbo->fetchOne('SELECT prc_guadagno FROM an_anagrafiche INNER JOIN mg_listini ON an_anagrafiche.idlistino_vendite=mg_listini.id WHERE idanagrafica='.prepare($documento['idanagrafica'])); - - if (!empty($listino['prc_guadagno'])) { - $result['sconto_percentuale'] = $listino['prc_guadagno']; - $result['tipo_sconto'] = 'PRC'; - } - - $options['op'] = 'manage_articolo'; -} elseif (get('is_sconto') !== null) { - $file = 'sconto'; - - $options['op'] = 'manage_sconto'; -} elseif (get('is_barcode') !== null) { - $file = 'barcode'; - - $options['op'] = 'manage_barcode'; -} - -echo App::load($file.'.php', $result, $options); diff --git a/modules/preventivi/row-edit.php b/modules/preventivi/row-edit.php deleted file mode 100755 index 48801052b..000000000 --- a/modules/preventivi/row-edit.php +++ /dev/null @@ -1,67 +0,0 @@ -. - */ - -use Modules\Preventivi\Preventivo; - -include_once __DIR__.'/../../core.php'; - -// Info contratto -$documento = Preventivo::find($id_record); - -// Impostazioni per la gestione -$options = [ - 'op' => 'manage_riga', - 'action' => 'edit', - 'dir' => $documento->direzione, - 'idanagrafica' => $documento['idanagrafica'], - 'totale_imponibile_documento' => $documento->totale_imponibile, - 'totale_documento' => $documento->totale, - 'select-options' => [ - 'articoli' => [ - 'idanagrafica' => $documento->idanagrafica, - 'dir' => $documento->direzione, - 'permetti_movimento_a_zero' => 1, - ], - ], -]; - -// Dati della riga -$id_riga = get('riga_id'); -$type = get('riga_type'); -$riga = $documento->getRiga($type, $id_riga); - -$result = $riga->toArray(); -$result['prezzo'] = $riga->prezzo_unitario; - -// Importazione della gestione dedicata -$file = 'riga'; -if ($riga->isDescrizione()) { - $file = 'descrizione'; - - $options['op'] = 'manage_descrizione'; -} elseif ($riga->isArticolo()) { - $file = 'articolo'; - - $options['op'] = 'manage_articolo'; -} elseif ($riga->isSconto()) { - $file = 'sconto'; - - $options['op'] = 'manage_sconto'; -} -echo App::load($file.'.php', $result, $options); diff --git a/modules/preventivi/row-list.php b/modules/preventivi/row-list.php deleted file mode 100755 index 6eea49daf..000000000 --- a/modules/preventivi/row-list.php +++ /dev/null @@ -1,386 +0,0 @@ -. - */ - -include_once __DIR__.'/init.php'; - -echo ' -
    - - - - - - - - - - - - - - '; - -// Righe documento -$today = new Carbon\Carbon(); -$today = $today->startOfDay(); -$righe = $preventivo->getRighe(); -$num = 0; -foreach ($righe as $riga) { - ++$num; - - echo ' - - - - '; - - // Data prevista evasione - $info_evasione = ''; - if (!empty($riga->data_evasione)) { - $evasione = new Carbon\Carbon($riga->data_evasione); - if ($today->diffInDays($evasione, false) < 0) { - $evasione_icon = 'fa fa-warning text-danger'; - $evasione_help = tr('Da consegnare _NUM_ giorni fa', - [ - '_NUM_' => $today->diffInDays($evasione), - ] - ); - } elseif ($today->diffInDays($evasione, false) == 0) { - $evasione_icon = 'fa fa-clock-o text-warning'; - $evasione_help = tr('Da consegnare oggi'); - } else { - $evasione_icon = 'fa fa-check text-success'; - $evasione_help = tr('Da consegnare fra _NUM_ giorni', - [ - '_NUM_' => $today->diffInDays($evasione), - ] - ); - } - - if (!empty($riga->ora_evasione)) { - $ora_evasione = '
    '.Translator::timeToLocale($riga->ora_evasione).''; - } else { - $ora_evasione = ''; - } - - $info_evasione = ' '.Translator::dateToLocale($riga->data_evasione).$ora_evasione.''; - } - - echo ' - '; - - if ($riga->isDescrizione()) { - echo ' - - - - '; - } else { - // Quantità e unità di misura - echo ' - '; - - // Prezzi unitari - echo ' - '; - - // Iva - echo ' - '; - - // Importo - echo ' - '; - } - - // Possibilità di rimuovere una riga solo se il preventivo non è stato pagato - echo ' - - '; -} - -echo ' - '; - -// Calcoli -$imponibile = abs($preventivo->imponibile); -$sconto = $preventivo->sconto; -$totale_imponibile = abs($preventivo->totale_imponibile); -$iva = abs($preventivo->iva); -$totale = abs($preventivo->totale); -$sconto_finale = $preventivo->getScontoFinale(); -$netto_a_pagare = $preventivo->netto; - -// Totale imponibile scontato -echo ' - - - - - '; - -// SCONTO -if (!empty($sconto)) { - echo ' - - - - - '; - - // Totale imponibile scontato - echo ' - - - - - '; -} - -// Totale iva -echo ' - - - - - '; - -// Totale -echo ' - - - - - '; - -// SCONTO FINALE -if (!empty($sconto_finale)) { - echo ' - - - - - '; -} - -// NETTO A PAGARE -if ($totale != $netto_a_pagare) { - echo ' - - - - - '; -} - -// Margine -$margine = $preventivo->margine; -$margine_class = ($margine <= 0 and $preventivo->totale > 0) ? 'danger' : 'success'; -$margine_icon = ($margine <= 0 and $preventivo->totale > 0) ? 'warning' : 'check'; - -echo ' - - - - - - - - - - - '; - -echo ' -
    '.tr('#').''.tr('Descrizione').''.tr('Prev. evasione').''.tr('Q.tà').' '.tr('Prezzo unitario').''.tr('Iva unitaria').''.tr('Importo').'
    - '.$num.' - '; - - // Aggiunta dei riferimenti ai documenti - if ($riga->hasOriginalComponent()) { - echo ' - '.reference($riga->getOriginalComponent()->getDocument(), tr('Origine')).''; - } - - // Descrizione - $descrizione = nl2br($riga->descrizione); - if ($riga->isArticolo()) { - $descrizione = Modules::link('Articoli', $riga->idarticolo, $riga->codice.' - '.$descrizione); - } - echo ' - '.$descrizione.' - - '.$info_evasione.' - - - '.numberFormat($riga->qta_rimanente, 'qta').' / '.numberFormat($riga->qta, 'qta').' '.$riga->um.' - - '.moneyFormat($riga->prezzo_unitario_corrente); - - if ($dir == 'entrata' && $riga->costo_unitario != 0) { - echo ' -
    - '.tr('Acquisto').': '.moneyFormat($riga->costo_unitario).' - '; - } - - if (abs($riga->sconto_unitario) > 0) { - $text = discountInfo($riga); - - echo ' -
    '.$text.''; - } - - echo ' -
    - '.moneyFormat($riga->iva_unitaria_scontata).' -
    '.$riga->aliquota->descrizione.(($riga->aliquota->esente) ? ' ('.$riga->aliquota->codice_natura_fe.')' : null).' -
    - '.moneyFormat($riga->importo).' - '; - - if (empty($record['is_completato'])) { - echo ' -
    - - - - - - - - - - - -
    '; - } - - echo ' -
    - '.tr('Imponibile', [], ['upper' => true]).': - - '.moneyFormat($preventivo->imponibile, 2).' -
    - '.tr('Sconto/maggiorazione', [], ['upper' => true]).': - - '.moneyFormat($preventivo->sconto, 2).' -
    - '.tr('Totale imponibile', [], ['upper' => true]).': - - '.moneyFormat($totale_imponibile, 2).' -
    - '.tr('Iva', [], ['upper' => true]).': - - '.moneyFormat($preventivo->iva, 2).' -
    - '.tr('Totale', [], ['upper' => true]).': - - '.moneyFormat($preventivo->totale, 2).' -
    - '.tr('Sconto finale', [], ['upper' => true]).': - - '.moneyFormat($sconto_finale, 2).' -
    - '.tr('Netto a pagare', [], ['upper' => true]).': - - '.moneyFormat($netto_a_pagare, 2).' -
    - '.tr('Costi').': - - '.moneyFormat($preventivo->spesa).' -
    - '.tr('Margine (_PRC_%)', [ - '_PRC_' => numberFormat($preventivo->margine_percentuale), - ]).': - - '.moneyFormat($preventivo->margine).' -
    -
    '; - -echo ' -'; diff --git a/modules/preventivi/src/Components/Articolo.php b/modules/preventivi/src/Components/Articolo.php deleted file mode 100755 index e9cf5d39d..000000000 --- a/modules/preventivi/src/Components/Articolo.php +++ /dev/null @@ -1,29 +0,0 @@ -. - */ - -namespace Modules\Preventivi\Components; - -use Common\Components\Article; - -class Articolo extends Article -{ - use RelationTrait; - - protected $table = 'co_righe_preventivi'; -} diff --git a/modules/preventivi/src/Components/Descrizione.php b/modules/preventivi/src/Components/Descrizione.php deleted file mode 100755 index 09ab3b8ba..000000000 --- a/modules/preventivi/src/Components/Descrizione.php +++ /dev/null @@ -1,29 +0,0 @@ -. - */ - -namespace Modules\Preventivi\Components; - -use Common\Components\Description; - -class Descrizione extends Description -{ - use RelationTrait; - - protected $table = 'co_righe_preventivi'; -} diff --git a/modules/preventivi/src/Components/RelationTrait.php b/modules/preventivi/src/Components/RelationTrait.php deleted file mode 100755 index d9cb3ff00..000000000 --- a/modules/preventivi/src/Components/RelationTrait.php +++ /dev/null @@ -1,47 +0,0 @@ -. - */ - -namespace Modules\Preventivi\Components; - -use Modules\Preventivi\Preventivo; - -trait RelationTrait -{ - public function getDocumentID() - { - return 'idpreventivo'; - } - - public function document() - { - return $this->belongsTo(Preventivo::class, $this->getDocumentID()); - } - - public function preventivo() - { - return $this->document(); - } - - public function getNettoAttribute() - { - $result = $this->totale; - - return $result; - } -} diff --git a/modules/preventivi/src/Components/Riga.php b/modules/preventivi/src/Components/Riga.php deleted file mode 100755 index ca85579e8..000000000 --- a/modules/preventivi/src/Components/Riga.php +++ /dev/null @@ -1,29 +0,0 @@ -. - */ - -namespace Modules\Preventivi\Components; - -use Common\Components\Row; - -class Riga extends Row -{ - use RelationTrait; - - protected $table = 'co_righe_preventivi'; -} diff --git a/modules/preventivi/src/Components/Sconto.php b/modules/preventivi/src/Components/Sconto.php deleted file mode 100755 index 4a570cb1d..000000000 --- a/modules/preventivi/src/Components/Sconto.php +++ /dev/null @@ -1,29 +0,0 @@ -. - */ - -namespace Modules\Preventivi\Components; - -use Common\Components\Discount; - -class Sconto extends Discount -{ - use RelationTrait; - - protected $table = 'co_righe_preventivi'; -} diff --git a/modules/preventivi/src/Preventivo.php b/modules/preventivi/src/Preventivo.php deleted file mode 100755 index b43199221..000000000 --- a/modules/preventivi/src/Preventivo.php +++ /dev/null @@ -1,338 +0,0 @@ -. - */ - -namespace Modules\Preventivi; - -use Carbon\Carbon; -use Carbon\CarbonInterval; -use Common\Components\Component; -use Common\Document; -use Modules\Anagrafiche\Anagrafica; -use Modules\Fatture\Fattura; -use Modules\Interventi\Intervento; -use Modules\TipiIntervento\Tipo as TipoSessione; -use Traits\RecordTrait; -use Traits\ReferenceTrait; -use Util\Generator; - -class Preventivo extends Document -{ - use ReferenceTrait; - use RecordTrait; - - /** - * @var bool Disabilita movimentazione automatica - */ - public static $movimenta_magazzino = false; - - protected $table = 'co_preventivi'; - - /** - * Crea un nuovo preventivo. - * - * @param string $nome - * - * @return self - */ - public static function build(Anagrafica $anagrafica, TipoSessione $tipo_sessione, $nome, $data_bozza, $id_sede) - { - $model = new static(); - - $stato_documento = Stato::where('descrizione', 'Bozza')->first(); - - $id_anagrafica = $anagrafica->id; - $id_agente = $anagrafica->idagente; - $id_pagamento = $anagrafica->idpagamento_vendite; - - $costo_orario = $tipo_sessione['costo_orario']; - $costo_diritto_chiamata = $tipo_sessione['costo_diritto_chiamata']; - - $id_iva = setting('Iva predefinita'); - if (empty($id_pagamento)) { - $id_pagamento = setting('Tipo di pagamento predefinito'); - } - - $model->anagrafica()->associate($anagrafica); - $model->stato()->associate($stato_documento); - $model->tipoSessione()->associate($tipo_sessione); - - $model->numero = static::getNextNumero($data_bozza); - - // Salvataggio delle informazioni - $model->nome = $nome; - if (empty($data_bozza)) { - $model->data_bozza = Carbon::now(); - } else { - $model->data_bozza = $data_bozza; - } - $model->data_conclusione = Carbon::now()->addMonth(); - - if (!empty($id_sede)) { - $model->idsede = $id_sede; - } - - if (!empty($id_agente)) { - $model->idagente = $id_agente; - } - - if (!empty($id_iva)) { - $model->idiva = $id_iva; - } - if (!empty($id_pagamento)) { - $model->idpagamento = $id_pagamento; - } - $model->condizioni_fornitura = setting('Condizioni generali di fornitura'); - - $model->save(); - - // Gestione delle revisioni - $model->master_revision = $model->id; - $model->default_revision = 1; - - $model->save(); - - return $model; - } - - // Attributi Eloquent - - public function getOreInterventiAttribute() - { - if (!isset($this->info['ore_interventi'])) { - $sessioni = collect(); - - $interventi = $this->interventi; - foreach ($interventi as $intervento) { - $sessioni = $sessioni->merge($intervento->sessioni); - } - - $this->info['ore_interventi'] = $sessioni->sum('ore'); - } - - return $this->info['ore_interventi']; - } - - public function setTipoValiditaAttribute($value) - { - $this->attributes['tipo_validita'] = $value == 'manual' ? null : $value; - } - - /** - * Controlla se la data di conclusione del documento deve essere calcolata in modo automatico. - * - * @return bool - */ - public function isDataConclusioneAutomatica() - { - return !empty($this->validita) && !empty($this->tipo_validita) && !empty($this->data_accettazione); - } - - /** - * Restituisce il nome del modulo a cui l'oggetto è collegato. - * - * @return string - */ - public function getModuleAttribute() - { - return 'Preventivi'; - } - - public function getDirezioneAttribute() - { - return 'entrata'; - } - - public function anagrafica() - { - return $this->belongsTo(Anagrafica::class, 'idanagrafica'); - } - - public function stato() - { - return $this->belongsTo(Stato::class, 'idstato'); - } - - public function tipoSessione() - { - return $this->belongsTo(TipoSessione::class, 'idtipointervento'); - } - - public function articoli() - { - return $this->hasMany(Components\Articolo::class, 'idpreventivo'); - } - - public function righe() - { - return $this->hasMany(Components\Riga::class, 'idpreventivo'); - } - - public function sconti() - { - return $this->hasMany(Components\Sconto::class, 'idpreventivo'); - } - - public function descrizioni() - { - return $this->hasMany(Components\Descrizione::class, 'idpreventivo'); - } - - public function interventi() - { - return $this->hasMany(Intervento::class, 'id_preventivo'); - } - - public function fixBudget() - { - $this->budget = $this->totale_imponibile ?: 0; - } - - public function fixDataConclusione() - { - // Calcolo della data di conclusione in base alla validità - if ($this->isDataConclusioneAutomatica()) { - $intervallo = CarbonInterval::make($this->validita.' '.$this->tipo_validita); - $this->data_conclusione = Carbon::make($this->data_accettazione)->add($intervallo); - } - } - - public function save(array $options = []) - { - $this->fixBudget(); - $this->fixDataConclusione(); - - return parent::save($options); - } - - public function delete() - { - $this->interventi()->update(['id_preventivo' => null]); - $revision = $this->master_revision; - - $result = parent::delete(); - - self::where('master_revision', $revision)->delete(); - - return $result; - } - - /** - * Effettua un controllo sui campi del documento. - * Viene richiamato dalle modifiche alle righe del documento. - */ - public function triggerEvasione(Component $trigger) - { - parent::triggerEvasione($trigger); - - $righe = $this->getRighe(); - - $qta_evasa = $righe->sum('qta_evasa'); - $qta = $righe->sum('qta'); - $parziale = $qta != $qta_evasa; - - $stato_attuale = $this->stato; - - // Impostazione del nuovo stato - if ($qta_evasa == 0) { - $descrizione = 'In lavorazione'; - $codice_intervento = 'OK'; - } elseif ($trigger->getDocument() instanceof Fattura) { - $descrizione = $parziale ? 'Parzialmente fatturato' : 'Fatturato'; - $codice_intervento = 'FAT'; - } else { - $descrizione = $this->stato->descrizione; - $codice_intervento = 'OK'; - } - - $stato = Stato::where('descrizione', $descrizione)->first(); - $this->stato()->associate($stato); - $this->save(); - - // Trasferimento degli interventi collegati - $interventi = $this->interventi; - $stato_intervento = \Modules\Interventi\Stato::where('codice', $codice_intervento)->first(); - foreach ($interventi as $intervento) { - $intervento->stato()->associate($stato_intervento); - $intervento->save(); - } - } - - // Metodi statici - - /** - * Calcola il nuovo numero di preventivo. - * - * @return string - */ - public static function getNextNumero($data) - { - $maschera = setting('Formato codice preventivi'); - - if ((strpos($maschera, 'YYYY') !== false) or (strpos($maschera, 'yy') !== false)) { - $ultimo = Generator::getPreviousFrom($maschera, 'co_preventivi', 'numero', [ - 'YEAR(data_bozza) = '.prepare(date('Y', strtotime($data))), - ]); - } else { - $ultimo = Generator::getPreviousFrom($maschera, 'co_preventivi', 'numero'); - } - - $numero = Generator::generate($maschera, $ultimo); - - return $numero; - } - - // Opzioni di riferimento - - public function getReferenceName() - { - return 'Preventivo'; - } - - public function getReferenceNumber() - { - return $this->numero; - } - - public function getReferenceDate() - { - return $this->data_bozza; - } - - public function getReferenceRagioneSociale() - { - return $this->anagrafica->ragione_sociale; - } - - public function getRevisioniAttribute() - { - $revisioni = Preventivo::where('master_revision', '=', $this->master_revision)->get()->pluck('id')->toArray(); - - return $revisioni; - } - - public function getUltimaRevisioneAttribute() - { - return Preventivo::selectRaw('MAX(numero_revision) AS revisione')->where('master_revision', $this->master_revision)->get()->toArray()[0]['revisione']; - } - - public function setStatoAttribute($stato) - { - $this->idstato = Stato::where('descrizione', $stato)->first()['id']; - } -} diff --git a/modules/preventivi/src/Stato.php b/modules/preventivi/src/Stato.php deleted file mode 100755 index f8ebadbe1..000000000 --- a/modules/preventivi/src/Stato.php +++ /dev/null @@ -1,35 +0,0 @@ -. - */ - -namespace Modules\Preventivi; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; - -class Stato extends Model -{ - use SimpleModelTrait; - - protected $table = 'co_statipreventivi'; - - public function preventivi() - { - return $this->hasMany(Preventivo::class, 'idstatopreventivo'); - } -} diff --git a/modules/preventivi/variables.php b/modules/preventivi/variables.php deleted file mode 100755 index b2b01564c..000000000 --- a/modules/preventivi/variables.php +++ /dev/null @@ -1,36 +0,0 @@ -. - */ - -$r = $dbo->fetchOne('SELECT *, - an_anagrafiche.ragione_sociale, co_preventivi.idanagrafica, - IF( (an_referenti.email IS NOT NULL AND an_referenti.email!=""), an_referenti.email, an_anagrafiche.email) AS email -FROM co_preventivi INNER JOIN an_anagrafiche ON co_preventivi.idanagrafica=an_anagrafiche.idanagrafica LEFT OUTER JOIN an_referenti ON an_referenti.id=co_preventivi.idreferente WHERE co_preventivi.id='.prepare($id_record)); - -$revisione = $dbo->fetchNum('SELECT * FROM co_preventivi WHERE master_revision = (SELECT master_revision FROM co_preventivi WHERE id = '.prepare($id_record).') AND id < '.prepare($id_record)); - -// Variabili da sostituire -return [ - 'email' => $r['email'], - 'numero' => $r['numero'], - 'ragione_sociale' => $r['ragione_sociale'], - 'descrizione' => $r['descrizione'], - 'data' => Translator::dateToLocale($r['data_bozza']), - 'id_anagrafica' => $r['idanagrafica'], - 'revisione' => $revisione, -]; diff --git a/modules/preventivi/widgets/preventivi.dashboard.php b/modules/preventivi/widgets/preventivi.dashboard.php deleted file mode 100755 index 4ab44f94c..000000000 --- a/modules/preventivi/widgets/preventivi.dashboard.php +++ /dev/null @@ -1,55 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -$id_module = Modules::get('Preventivi')['id']; - -$rs = $dbo->fetchArray("SELECT *, (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=co_preventivi.idanagrafica) AS ragione_sociale FROM co_preventivi WHERE idstato=(SELECT id FROM co_statipreventivi WHERE descrizione='In lavorazione') AND default_revision = 1 ORDER BY data_conclusione ASC"); - -if (!empty($rs)) { - echo " - - - - - - "; - - foreach ($rs as $preventivo) { - $data_accettazione = ($preventivo['data_accettazione'] != '0000-00-00') ? Translator::dateToLocale($preventivo['data_accettazione']) : ''; - $data_conclusione = ($preventivo['data_conclusione'] != '0000-00-00') ? Translator::dateToLocale($preventivo['data_conclusione']) : ''; - - if (strtotime($preventivo['data_conclusione']) < strtotime(date('Y-m-d')) && $data_conclusione != '') { - $attr = ' class="danger"'; - } else { - $attr = ''; - } - - echo ''; - echo ''; - echo ''; - } - - echo ' -
    PreventivoData inizioData conclusione
    '.$preventivo['nome']."
    ".$preventivo['ragione_sociale'].'
    '.$data_accettazione.''.$data_conclusione.'
    '; -} else { - echo ' -

    '.tr('Non ci sono preventivi in lavorazione').'.

    '; -} diff --git a/modules/primanota/actions.php b/modules/primanota/actions.php deleted file mode 100755 index 432ef6efa..000000000 --- a/modules/primanota/actions.php +++ /dev/null @@ -1,108 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Fatture\Fattura; -use Modules\PrimaNota\Mastrino; -use Modules\PrimaNota\Movimento; -use Modules\Scadenzario\Scadenza; - -switch (post('op')) { - case 'add': - $data = post('data'); - $descrizione = post('descrizione'); - $is_insoluto = post('is_insoluto'); - $id_anagrafica = post('id_anagrafica'); - $mastrino = Mastrino::build($descrizione, $data, $is_insoluto, true, $id_anagrafica); - - $conti = post('idconto'); - foreach ($conti as $i => $id_conto) { - $id_scadenza = post('id_scadenza')[$i]; - $id_documento = post('id_documento')[$i]; - $dare = post('dare')[$i]; - $avere = post('avere')[$i]; - $scadenza = Scadenza::find($id_scadenza); - $fattura = Fattura::find($id_documento); - - $movimento = Movimento::build($mastrino, $id_conto, $fattura, $scadenza); - $movimento->setTotale($avere, $dare); - $movimento->save(); - } - - $mastrino->aggiornaScadenzario(); - - $id_record = $mastrino->id; - - flash()->info(tr('Movimento aggiunto in prima nota!')); - - // Creo il modello di prima nota - if (!empty(post('crea_modello'))) { - if (empty(post('idmastrino'))) { - $idmastrino = get_new_idmastrino('co_movimenti_modelli'); - } else { - $dbo->query('DELETE FROM co_movimenti_modelli WHERE idmastrino='.prepare(post('idmastrino'))); - $idmastrino = post('idmastrino'); - } - - foreach ($conti as $i => $id_conto) { - $idconto = post('idconto')[$i]; - $query = 'INSERT INTO co_movimenti_modelli(idmastrino, nome, descrizione, idconto) VALUES('.prepare($idmastrino).', '.prepare($descrizione).', '.prepare($descrizione).', '.prepare($id_conto).')'; - $dbo->query($query); - } - } - - break; - - case 'update': - $data = post('data'); - $descrizione = post('descrizione'); - $note = post('note'); - - $mastrino->descrizione = $descrizione; - $mastrino->data = $data; - $mastrino->note = $note; - - $mastrino->cleanup(); - - $conti = post('idconto'); - foreach ($conti as $i => $id_conto) { - $id_scadenza = post('id_scadenza')[$i]; - $id_documento = post('id_documento')[$i]; - $dare = post('dare')[$i]; - $avere = post('avere')[$i]; - - $scadenza = Scadenza::find($id_scadenza); - $fattura = Fattura::find($id_documento); - - $movimento = Movimento::build($mastrino, $id_conto, $fattura, $scadenza); - $movimento->setTotale($avere, $dare); - $movimento->save(); - } - - $mastrino->aggiornaScadenzario(); - - flash()->info(tr('Movimento modificato in prima nota!')); - break; - - // eliminazione movimento prima nota - case 'delete': - $mastrino->delete(); - break; -} diff --git a/modules/primanota/add.php b/modules/primanota/add.php deleted file mode 100755 index 102e82f61..000000000 --- a/modules/primanota/add.php +++ /dev/null @@ -1,442 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Anagrafiche\Anagrafica; -use Modules\Fatture\Fattura; - -/** - * Questo file gestisce la lettura delle informazioni di Scadenze e Fatture indicate per la generazione della Prima Nota. Per maggiori informazioni sulla grafica inerente alla visualizzazione delle diverse righe, consulare il file `movimenti.php`. - * - * Questo file prevede diverse operazioni per la generazione di un singolo array `$movimenti` contenente tutti i movimenti da presentare nella Prima Nota. In particolare: - * - Individua Scadenze e Fatture per ID da URL - * - Legge le informazioni relative alle Scadenze per presentare i movimenti in Dare e Avere - * - Legge le informazioni relative alla Scadenze le Fatture indicate (sola della prima Scadenza insoluta se `is_insoluto` impostato): - * - Per Fatture di vendita, il totale è Avere (a meno di Note di credito oppure insoluto) - * - Per Fatture di acquisto, il totale è Dare (a meno di Note di credito oppure insoluto) - * - Inverte Dare e Avere se l'importo indicato è negativo [TODO: documentare la casistica] - * - Genera la causale predefinita per la Prima Nota sulla base delle Scadenze indicate - * - * Nel caso in cui sia indicato una singola Scadenza (con o senza Fattura associata) viene permessa la gestione attraverso un Modello di Prima Nota, che prevede una compilazione di base per alcuni movimenti specificati nel relativo modulo. - * Nota: questo comportamento viene abilitato dalla variabile `$permetti_modelli`. - */ -$module = Modules::get('Prima nota'); -$movimenti = []; - -// Registrazione da remoto -$id_records = get('id_records'); -if (!empty($id_records)) { - $id_records = str_replace(';', ',', $id_records); - if (get('origine') == 'fatture') { - $id_documenti = $id_records; - } else { - $id_scadenze = $id_records; - } -} - -// ID predefiniti -$singola_scadenza = get('single') != null; -$is_insoluto = get('is_insoluto') != null; - -$id_documenti = $id_documenti ?: get('id_documenti'); -$id_documenti = $id_documenti ? explode(',', $id_documenti) : []; - -$id_scadenze = $id_scadenze ?: get('id_scadenze'); -$id_scadenze = $id_scadenze ? explode(',', $id_scadenze) : []; - -// Controllo per l'utilizzo dei modelli di Prima Nota (per singolo documento o singola scadenza) -$permetti_modelli = (count($id_documenti) + count($id_scadenze)) <= 1; - -// Scadenze -foreach ($id_scadenze as $id_scadenza) { - $scadenza = $database->fetchOne('SELECT *, SUM(da_pagare - pagato) AS rata FROM co_scadenziario WHERE id='.prepare($id_scadenza)); - if (!empty($scadenza['iddocumento'])) { - $id_documenti[] = $scadenza['iddocumento']; - continue; - } - $dir = $scadenza['rata'] > 0 ? 'entrata' : 'uscita'; - $scadenza['rata'] = abs($scadenza['rata']); - - $descrizione_conto = ($dir == 'entrata') ? 'Riepilogativo clienti' : 'Riepilogativo fornitori'; - $conto = $database->fetchOne('SELECT id FROM co_pianodeiconti3 WHERE descrizione = '.prepare($descrizione_conto)); - $id_conto_controparte = $conto['id']; - - $righe_documento = []; - $righe_documento[] = [ - 'iddocumento' => null, - 'id_scadenza' => $scadenza['id'], - 'id_conto' => null, - 'dare' => ($dir == 'entrata') ? 0 : $scadenza['rata'], - 'avere' => ($dir == 'entrata') ? $scadenza['rata'] : 0, - ]; - - $righe_documento[] = [ - 'iddocumento' => null, - 'id_scadenza' => $scadenza['id'], - 'id_conto' => $id_conto_controparte, - 'dare' => ($dir == 'entrata') ? $scadenza['rata'] : 0, - 'avere' => ($dir == 'entrata') ? 0 : $scadenza['rata'], - ]; - - // Se è un insoluto, inverto i valori - if ($is_insoluto) { - foreach ($righe_documento as $key => $value) { - $tmp = $value['avere']; - $righe_documento[$key]['avere'] = $righe_documento[$key]['dare']; - $righe_documento[$key]['dare'] = $tmp; - } - } - - $movimenti = array_merge($movimenti, $righe_documento); -} - -// Fatture -$numeri_fatture = []; -$counter = 0; -$is_ultimo_importo_avere = false; - -$id_documenti = array_unique($id_documenti); -$id_anagrafica_movimenti = null; -foreach ($id_documenti as $id_documento) { - $fattura = Fattura::find($id_documento); - $tipo = $fattura->tipo; - $dir = $fattura->direzione; - - // Inclusione delle sole fatture in stato Emessa, Parzialmente pagato o Pagato - if (!in_array($fattura->stato->descrizione, ['Emessa', 'Parzialmente pagato', 'Pagato'])) { - ++$counter; - continue; - } - - if (empty($id_anagrafica_movimenti)) { - $id_anagrafica_movimenti = $fattura->idanagrafica; - } elseif ($fattura->idanagrafica != $id_anagrafica_movimenti) { - $id_anagrafica_movimenti = null; - } - - $numeri_fatture[] = !empty($fattura['numero_esterno']) ? $fattura['numero_esterno'] : $fattura['numero']; - - $is_nota_credito = $tipo->reversed; - $is_importo_avere = ($dir == 'entrata' && !$is_nota_credito && !$is_insoluto) || ($dir == 'uscita' && ($is_nota_credito || $is_insoluto)); - - // Predisposizione prima riga - $conto_field = 'idconto_'.($dir == 'entrata' ? 'vendite' : 'acquisti'); - $id_conto_aziendale = $fattura->pagamento[$conto_field] ?: setting('Conto aziendale predefinito'); - - // Predisposizione conto crediti clienti - $conto_field = 'idconto_'.($dir == 'entrata' ? 'cliente' : 'fornitore'); - $id_conto_controparte = $fattura->anagrafica[$conto_field]; - - // Se sto registrando un insoluto, leggo l'ultima scadenza pagata altrimenti leggo la scadenza della fattura - if ($is_insoluto) { - $scadenze = $database->fetchArray('SELECT id, ABS(da_pagare) AS rata, iddocumento FROM co_scadenziario WHERE iddocumento='.prepare($id_documento).' AND ABS(da_pagare) = ABS(pagato) ORDER BY updated_at DESC LIMIT 0, 1'); - } else { - $scadenze = $database->fetchArray('SELECT id, ABS(da_pagare - pagato) AS rata, iddocumento FROM co_scadenziario WHERE iddocumento='.prepare($id_documento).' AND ABS(da_pagare) > ABS(pagato)'.(!empty($id_scadenze) ? 'AND id IN('.implode(',', $id_scadenze).')' : '').' ORDER BY YEAR(scadenza) ASC, MONTH(scadenza) ASC'); - } - - // Selezione prima scadenza - if ($singola_scadenza && !empty($scadenze)) { - $scadenze = [$scadenze[0]]; - } - - $righe_documento = []; - - // Riga controparte - foreach ($scadenze as $scadenza) { - $righe_documento[] = [ - 'iddocumento' => $scadenza['iddocumento'], - 'id_scadenza' => $scadenza['id'], - 'id_conto' => $id_conto_controparte, - 'dare' => $is_importo_avere ? 0 : $scadenza['rata'], - 'avere' => $is_importo_avere ? $scadenza['rata'] : 0, - ]; - } - - // Riga aziendale - $totale = sum(array_column($scadenze, 'rata')); - - $righe_documento[] = [ - 'iddocumento' => $scadenze[0]['iddocumento'], - 'id_scadenza' => $scadenze[0]['id'], - 'id_conto' => $id_conto_aziendale, - 'dare' => $is_importo_avere ? $totale : 0, - 'avere' => $is_importo_avere ? 0 : $totale, - ]; - - $is_ultimo_importo_avere = $is_importo_avere; - $movimenti = array_merge($movimenti, $righe_documento); -} - -// Inverto dare e avere per importi negativi -foreach ($movimenti as $key => $value) { - if ($movimenti[$key]['dare'] < 0 || $movimenti[$key]['avere'] < 0) { - $tmp = abs($movimenti[$key]['dare']); - $movimenti[$key]['dare'] = abs($movimenti[$key]['avere']); - $movimenti[$key]['avere'] = $tmp; - } -} - -// Descrizione -$numero_scadenze = count($id_scadenze); -$numero_documenti = count($id_documenti); -if ($numero_documenti + $numero_scadenze > 1) { - if (!empty($id_anagrafica_movimenti)) { - $anagrafica_movimenti = Anagrafica::find($id_anagrafica_movimenti); - - $descrizione = $is_ultimo_importo_avere ? tr('Inc. fatture _NAME_ num. _LIST_') : tr('Pag. fatture _NAME_ num. _LIST_'); - $descrizione = replace($descrizione, [ - '_NAME_' => $anagrafica_movimenti->ragione_sociale, - '_LIST_' => implode(', ', $numeri_fatture), - ]); - } else { - $descrizione = $is_ultimo_importo_avere ? tr('Inc. fatture num. _LIST_') : tr('Pag. fatture _NAME_ num. _LIST_'); - $descrizione = replace($descrizione, [ - '_LIST_' => implode(', ', $numeri_fatture), - ]); - } -} elseif ($numero_documenti == 1) { - $numero_fattura = !empty($fattura['numero_esterno']) ? $fattura['numero_esterno'] : $fattura['numero']; - $tipo_fattura = $fattura->isNota() ? $tipo->descrizione : tr('Fattura'); - - if (!empty($is_insoluto)) { - $operation = tr('Registrazione insoluto'); - } else { - $operation = $is_ultimo_importo_avere ? tr('Inc.') : tr('Pag.'); - } - - $descrizione = tr('_OP_ _DOC_ num. _NUM_ del _DATE_ (_NAME_)', [ - '_OP_' => $operation, - '_DOC_' => strtolower($tipo_fattura), - '_NUM_' => $numero_fattura, - '_DATE_' => Translator::dateToLocale($fattura['data']), - '_NAME_' => $fattura->anagrafica['ragione_sociale'], - ]); -} elseif ($numero_scadenze == 1) { - $descrizione = tr('Pag. _OP_ del _DATE_', [ - '_OP_' => $scadenza['descrizione'], - '_DATE_' => Translator::dateToLocale($scadenza['scadenza']), - ]); -} - -if (!empty($id_records) && get('origine') == 'fatture' && !empty($counter)) { - $descrizione_stati = []; - $stati = $database->fetchArray("SELECT * FROM `co_statidocumento` WHERE descrizione IN ('Emessa', 'Parzialmente pagato', 'Pagato') ORDER BY descrizione"); - foreach ($stati as $stato) { - $descrizione_stati[] = ' '.$stato['descrizione'].''; - } - - echo ' -
    -

    '.tr('Solo le fatture in stato _STATE_ possono essere registrate contabilmente ignorate', [ - '_STATE_' => implode(', ', $descrizione_stati), - ]).'.

    -

    '.tr('Sono state ignorate _NUM_ fatture', [ - '_NUM_' => $counter, - ]).'.

    -
    '; -} -if (!empty(get('id_anagrafica'))) { - $id_anagrafica = get('id_anagrafica'); -} else { - $id_anagrafica = $dbo->fetchOne('SELECT idanagrafica FROM co_documenti WHERE id IN('.(get('id_documenti') ?: '0').')')['idanagrafica']; -} -echo ' -
    - - - - - - '; - -if ($permetti_modelli) { - echo ' -
    -
    - {[ "type": "select", "label": "'.tr('Modello prima nota').'", "name": "modello_primanota", "values": "query=SELECT idmastrino AS id, nome AS descrizione, descrizione as causale FROM co_movimenti_modelli GROUP BY idmastrino" ]} -
    -
    '; -} - -echo ' -
    -
    - {[ "type": "date", "label": "'.tr('Data movimento').'", "name": "data", "required": 1, "value": "-now-" ]} -
    - -
    - {[ "type": "text", "label": "'.tr('Causale').'", "name": "descrizione", "id": "desc", "required": 1, "value": '.json_encode($descrizione).' ]} -
    -
    '; - -if (!empty($id_anagrafica)) { - $id_conto_anticipo_fornitori = setting('Conto anticipo fornitori'); - $id_conto_anticipo_clienti = setting('Conto anticipo clienti'); - - $anticipo_cliente = $dbo->fetchOne('SELECT ABS(SUM(totale)) AS totale FROM co_movimenti WHERE co_movimenti.id_anagrafica='.prepare($id_anagrafica).' AND co_movimenti.idconto='.prepare($id_conto_anticipo_clienti)); - - $anticipo_fornitore = $dbo->fetchOne('SELECT ABS(SUM(totale)) AS totale FROM co_movimenti WHERE co_movimenti.id_anagrafica='.prepare($id_anagrafica).' AND co_movimenti.idconto='.prepare($id_conto_anticipo_fornitori)); - - if ($anticipo_fornitore['totale'] != 0) { - echo ' -
    - '.tr('Attenzione: è stato anticipato al fornitore un importo di _TOTALE_', - [ - '_TOTALE_' => moneyFormat($anticipo_fornitore['totale']), - ] - ).' -
    '; - } - - if ($anticipo_cliente['totale'] != 0) { - echo ' -
    - '.tr('Attenzione: è stato ricevuto un anticipo dal cliente di _TOTALE_', - [ - '_TOTALE_' => moneyFormat($anticipo_cliente['totale']), - ] - ).' -
    '; - } -} - -include $structure->filepath('movimenti.php'); - -echo ' - -
    -
    - - - -
    -
    -
    '; - -echo ' -'; - -if ($permetti_modelli) { - $variables = Modules::get('Fatture di vendita')->getPlaceholders($id_documenti[0]); - - echo ' -'; -} diff --git a/modules/primanota/ajax/complete.php b/modules/primanota/ajax/complete.php deleted file mode 100755 index 95cf83f01..000000000 --- a/modules/primanota/ajax/complete.php +++ /dev/null @@ -1,35 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -switch ($resource) { - case 'get_conti': - $idmastrino = get('idmastrino'); - $conti = []; - $rs_conti = $dbo->fetchArray('SELECT *, (SELECT CONCAT ((SELECT numero FROM co_pianodeiconti2 WHERE id=co_pianodeiconti3.idpianodeiconti2), ".", numero, " ", descrizione) FROM co_pianodeiconti3 WHERE id=co_movimenti_modelli.idconto) AS descrizione_conto FROM co_movimenti_modelli WHERE idmastrino='.prepare($idmastrino).' GROUP BY id ORDER BY id'); - - for ($i = 0; $i < sizeof($rs_conti); ++$i) { - $conti[$i] = $rs_conti[$i]['idconto'].';'.$rs_conti[$i]['descrizione_conto'].';'.$rs_conti[$i]['totale']; - } - - echo implode(',', $conti); - - break; -} diff --git a/modules/primanota/edit.php b/modules/primanota/edit.php deleted file mode 100755 index c90e7099a..000000000 --- a/modules/primanota/edit.php +++ /dev/null @@ -1,101 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - - - - -
    - fetchArray('SELECT DISTINCT iddocumento, (SELECT IFNULL(numero_esterno, numero) FROM co_documenti WHERE id=co_movimenti.iddocumento) AS numero FROM co_movimenti WHERE idmastrino='.prepare($record['idmastrino']).' AND iddocumento!=0'); - - if (sizeof($rs_doc) > 0) { - if (sizeof($rs_doc) == 1) { - $rs = $dbo->fetchArray('SELECT dir FROM co_tipidocumento INNER JOIN co_documenti ON co_tipidocumento.id=co_documenti.idtipodocumento WHERE co_documenti.id='.prepare($rs_doc[0]['iddocumento'])); - $modulo = ($rs[0]['dir'] == 'entrata') ? 'Fatture di vendita' : 'Fatture di acquisto'; ?> -
    -
    - -
    - -
    -
    - -
    - - -
    - {[ "type": "date", "label": "", "name": "data", "required": 1, "value": "$data$" ]} -
    - -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1, "value": "$descrizione$" ]} -
    -
    -movimenti->toArray(); - -include $structure->filepath('movimenti.php'); - -?> - - -
    -
    - {[ "type": "textarea", "label": "", "name": "note", "required": 0, "value": "$note$" ]} -
    -
    - -
    - -{( "name": "filelist_and_upload", "id_module": "$id_module$", "id_record": "$id_record$" )} - - - - - - diff --git a/modules/primanota/init.php b/modules/primanota/init.php deleted file mode 100755 index 6b495ca6c..000000000 --- a/modules/primanota/init.php +++ /dev/null @@ -1,28 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\PrimaNota\Mastrino; - -if (isset($id_record)) { - $mastrino = Mastrino::find($id_record); - - $record = $dbo->fetchOne('SELECT * FROM co_movimenti WHERE idmastrino = '.prepare($id_record)); -} diff --git a/modules/primanota/movimenti.php b/modules/primanota/movimenti.php deleted file mode 100755 index bf4ba691e..000000000 --- a/modules/primanota/movimenti.php +++ /dev/null @@ -1,330 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Fatture\Fattura; - -function renderRiga($id, $riga) -{ - // Conto - echo ' - - - - - - {[ "type": "select", "name": "idconto['.$id.']", "id": "conto'.$id.'", "value": "'.($riga['id_conto'] ?: '').'", "ajax-source": "conti" ]} - '; - - // Dare - echo ' - - {[ "type": "number", "name": "dare['.$id.']", "id": "dare'.$id.'", "value": "'.($riga['dare'] ?: 0).'" ]} - '; - - // Avere - echo ' - - {[ "type": "number", "name": "avere['.$id.']", "id": "avere'.$id.'", "value": "'.($riga['avere'] ?: 0).'" ]} - - '; -} - -function renderTabella($nome, $righe) -{ - global $counter; - - $prima_riga = $righe->first(); - $id_documento = $prima_riga ? $prima_riga['iddocumento'] : null; - $id_scadenza = $prima_riga ? $prima_riga['id_scadenza'] : null; - - echo ' -
    - - -

    '.$nome.'

    - - - - - - - - - - - '; - - foreach ($righe as $riga) { - renderRiga($counter++, $riga); - } - - // Totale per controllare sbilancio - echo ' - - - - - '; - - // Totale dare - echo ' - '; - - // Totale avere - echo ' - - '; - - echo ' - -
    '.tr('Conto').''.tr('Dare').''.tr('Avere').'
    '.tr('Totale').': - '.currency().' - - '.currency().' -
    '; - - // Verifica dello sbilancio - echo ' -
    - '.tr('Sbilancio di _MONEY_', [ - '_MONEY_' => ' '.currency(), - ]).' -
    -
    '; -} - -$counter = 0; -$movimenti = collect($movimenti); - -// Elenco per documenti -$scadenze = $movimenti - ->where('iddocumento', '<>', '0') - ->groupBy('iddocumento'); -foreach ($scadenze as $id_documento => $righe) { - $documento = Fattura::find($id_documento); - - $nome = tr('Documento num. _NUM_', [ - '_NUM_' => $documento['numero_esterno'] ?: $documento['numero'], - ]); - - renderTabella($nome, $righe); -} - -// Elenco per scadenze -$scadenze = $movimenti - ->where('iddocumento', '=', '0') - ->where('id_scadenza', '<>', '') - ->groupBy('id_scadenza'); -foreach ($scadenze as $id_scadenza => $righe) { - $nome = tr('Scadenza num. _ID_', [ - '_ID_' => $id_scadenza, - ]); - - renderTabella($nome, $righe); -} - -// Elenco generale -$movimenti_generali = $movimenti - ->where('iddocumento', '=', '0') - ->where('id_scadenza', '=', ''); -if ($movimenti_generali->isEmpty()) { - $movimenti_generali->push([]); - $movimenti_generali->push([]); -} -$nome = tr('Generale'); - -renderTabella($nome, $movimenti_generali); - -// Nuova riga -echo ' - - '; - -renderRiga('-id-', [ - 'iddocumento' => '-id_documento-', - 'id_scadenza' => '-id_scadenza-', -]); - -echo ' - -
    '; - -echo ' -'; diff --git a/modules/primanota/src/Mastrino.php b/modules/primanota/src/Mastrino.php deleted file mode 100755 index 6cb2ce126..000000000 --- a/modules/primanota/src/Mastrino.php +++ /dev/null @@ -1,258 +0,0 @@ -. - */ - -namespace Modules\PrimaNota; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; -use Modules\Fatture\Fattura; -/* - * Struttura ausiliaria dedicata alla raggruppamento e alla gestione di un insieme di Movimenti, unificati attraverso il numero di mastrino. - * - * Questa classe non è utilizzabile come normale modello Eloquent poichè non prevede operazioni di modifica a livello di database. - * La creazione di un record può essere utilizzata per la gestione di un insieme di Movimenti, mentre l'eliminazione provoca la rimozione in cascata dei Movimenti associati al Mastrino. - */ -use Modules\Scadenzario\Scadenza; - -class Mastrino extends Model -{ - use SimpleModelTrait; - - public $incrementing = false; - protected $table = 'co_movimenti'; - protected $primaryKey = 'idmastrino'; - - protected $hidden = [ - 'idmastrino', - 'data_documento', - 'iddocumento', - 'id_anagrafica', - ]; - - public static function build($descrizione, $data, $is_insoluto = false, $contabile = false, $id_anagrafica = null) - { - $model = new static(); - - $model->idmastrino = self::getNextMastrino(); - $model->data = $data; - $model->descrizione = $descrizione; - $model->is_insoluto = $is_insoluto; - $model->primanota = $contabile; - $model->id_anagrafica = $id_anagrafica; - - return $model; - } - - /** - * Rimuove tutti i movimenti collegati al mastrino. - * - * @return mixed - */ - public function cleanup() - { - $movimenti = $this->movimenti; - foreach ($movimenti as $movimento) { - $movimento->delete(); - } - - return $movimenti; - } - - public function save(array $options = []) - { - return true; - } - - public function delete() - { - $movimenti = $this->cleanup(); - $this->aggiornaScadenzario($movimenti); - - return parent::delete(); - } - - // Attributi - - public function getIdAttribute() - { - return $this->idmastrino; - } - - public function getTotaleAttribute() - { - $movimenti = $this->movimenti->where('totale', '>', 0); - - $totale = $movimenti->sum('totale'); - - return $totale; - } - - // Metodi generali - - public function aggiornaScadenzario($movimenti = null) - { - // Aggiornamento dello scadenzario disponibile solo da Mastrino di PrimaNota - if (empty($this->primanota)) { - return; - } - $movimenti = $movimenti ?: $this->movimenti; - - // Aggiornamento delle scadenze per i singoli documenti - $documenti = []; - $scadenze = []; - foreach ($movimenti as $movimento) { - $scadenza = $movimento->scadenza; - $documento = $movimento->documento; - - // Retrocompatibilità per versioni <= 2.4.11 - if (!empty($documento)) { - if (!in_array($documento->id, $documenti)) { - $documenti[] = $documento->id; - - $this->correggiScadenza($movimento, $scadenza, $documento); - } - } elseif (!empty($scadenza)) { - $id_documento = $scadenza->documento->id; - - if (!in_array($id_documento, $documenti) && !in_array($scadenza->id, $scadenze)) { - $documenti[] = $id_documento; - $scadenze[] = $scadenza->id; - - $this->correggiScadenza($movimento, $scadenza); - } - } - } - - // Fix dello stato della Fattura - $database = database(); - foreach ($documenti as $id_documento) { - // Verifico se la fattura è stata pagata tutta, così imposto lo stato a "Pagato" - $totali = $database->fetchOne('SELECT SUM(pagato) AS tot_pagato, SUM(da_pagare) AS tot_da_pagare FROM co_scadenziario WHERE iddocumento='.prepare($id_documento)); - - $totale_pagato = abs(floatval($totali['tot_pagato'])); - $totale_da_pagare = abs(floatval($totali['tot_da_pagare'])); - - // Aggiorno lo stato della fattura - if ($totale_pagato == $totale_da_pagare) { - $stato = 'Pagato'; - } elseif ($totale_pagato != $totale_da_pagare && $totale_pagato != 0) { - $stato = 'Parzialmente pagato'; - } else { - $stato = 'Emessa'; - } - - $database->query('UPDATE co_documenti SET idstatodocumento = (SELECT id FROM co_statidocumento WHERE descrizione = '.prepare($stato).') WHERE id = '.prepare($id_documento)); - } - } - - // Relazioni Eloquent - - public function fattura() - { - return $this->belongsTo(Fattura::class, 'iddocumento'); - } - - public function movimenti() - { - return $this->hasMany(Movimento::class, 'idmastrino'); - } - - // Metodi statici - - public static function getNextMastrino() - { - $ultimo = database()->fetchOne('SELECT MAX(idmastrino) AS max FROM co_movimenti'); - - return intval($ultimo['max']) + 1; - } - - /** - * Funzione dedicata alla distribuzione del totale pagato del movimento nelle relative scadenze associate. - */ - protected function correggiScadenza(Movimento $movimento, Scadenza $scadenza = null, Fattura $documento = null) - { - $is_nota = false; - $documento = $documento ?: $scadenza->documento; - - // Gestione delle scadenze di un documento - if ($documento) { - $dir = $documento->direzione; - $scadenze = $documento->scadenze->sortBy('scadenza'); - - $movimenti = $documento->movimentiContabili; - - if ($dir == 'entrata') { - $totale_movimenti = $movimenti->where('totale', '<', 0)->where('is_insoluto', 0)->sum('totale'); - $totale_insoluto = $movimenti->where('totale', '<', 0)->where('is_insoluto', 1)->sum('totale'); - } - - if ($dir == 'uscita') { - $totale_movimenti = $movimenti->where('totale', '>', 0)->where('is_insoluto', 0)->sum('totale'); - $totale_insoluto = $movimenti->where('totale', '>', 0)->where('is_insoluto', 1)->sum('totale'); - } - - $totale_da_distribuire = $totale_movimenti - $totale_insoluto; - $is_nota = $documento->isNota(); - } - - // Gestione di una singola scadenza - else { - $scadenze = [$scadenza]; - $dir = $movimento->totale < 0 ? 'entrata' : 'uscita'; - - $totale_da_distribuire = Movimento::where('id_scadenza', '=', $scadenza->id) - ->where('totale', '>', 0) - ->sum('totale'); - } - - $totale_da_distribuire = abs($totale_da_distribuire); - - // Ciclo tra le rate dei pagamenti per inserire su `pagato` l'importo effettivamente pagato - // Nel caso il pagamento superi la rata, devo distribuirlo sulle rate successive - foreach ($scadenze as $scadenza) { - $scadenza_da_pagare = abs($scadenza['da_pagare']); - - // Nel caso in cui il totale da distribuire sia stato esaurito, imposta il pagato a zero - if ($totale_da_distribuire <= 0) { - $pagato = 0; - } - - // Se il totale da distribuire è superiore al valore da pagare della scadenza, completa il pagamento - elseif ($totale_da_distribuire >= $scadenza_da_pagare) { - $pagato = $scadenza_da_pagare; - $totale_da_distribuire -= $scadenza_da_pagare; - } - - // In caso alternativo, assegno il rimanente da distribuire interamente alla scadenza - else { - $pagato = $totale_da_distribuire; - $totale_da_distribuire = 0; - } - - // Inversione di segno per la direzione del movimento contabile - $pagato = $dir == 'uscita' ? -$pagato : $pagato; - $pagato = $is_nota ? -$pagato : $pagato; // Inversione di segno per le note - - // Salvataggio delle informazioni - $scadenza->pagato = $pagato; - $scadenza->data_pagamento = $pagato ? $this->data : null; - $scadenza->save(); - } - } -} diff --git a/modules/primanota/src/Movimento.php b/modules/primanota/src/Movimento.php deleted file mode 100755 index daa86ec52..000000000 --- a/modules/primanota/src/Movimento.php +++ /dev/null @@ -1,120 +0,0 @@ -. - */ - -namespace Modules\PrimaNota; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; -use Modules\Fatture\Fattura; -use Modules\Scadenzario\Scadenza; - -class Movimento extends Model -{ - use SimpleModelTrait; - - protected $table = 'co_movimenti'; - - protected $appends = [ - 'id_conto', - 'avere', - 'dare', - ]; - - public static function build(Mastrino $mastrino, $id_conto, Fattura $documento = null, Scadenza $scadenza = null) - { - $model = new static(); - - // Informazioni dipendenti dal mastrino - $model->idmastrino = $mastrino->idmastrino; - $model->data = $mastrino->data; - $model->descrizione = $mastrino->descrizione; - $model->note = $mastrino->note; - $model->primanota = $mastrino->primanota; - $model->is_insoluto = $mastrino->is_insoluto; - $model->id_anagrafica = $mastrino->id_anagrafica; - - // Conto associato - $model->idconto = $id_conto; - - // Associazione al documento indicato - $documento_scadenza = $scadenza ? $scadenza->documento : null; - $documento = $documento ?: $documento_scadenza; - if (!empty($documento)) { - $model->id_anagrafica = $documento->idanagrafica; - $model->iddocumento = $documento->id; - } - - // Associazione alla scadenza indicata - $model->id_scadenza = $scadenza ? $scadenza->id : null; - - $model->save(); - - return $model; - } - - public function setTotale($avere, $dare) - { - if (!empty($avere)) { - $totale = -$avere; - } else { - $totale = $dare; - } - - $this->totale = $totale; - } - - public function save(array $options = []) - { - // Aggiornamento automatico di totale_reddito - $conto = database()->fetchOne('SELECT * FROM co_pianodeiconti3 WHERE id = '.prepare($this->id_conto)); - $percentuale = floatval($conto['percentuale_deducibile']); - $this->totale_reddito = $this->totale * $percentuale / 100; - - return parent::save($options); - } - - // Attributi - - public function getIdContoAttribute() - { - return $this->attributes['idconto']; - } - - public function getAvereAttribute() - { - return $this->totale < 0 ? abs($this->totale) : 0; - } - - public function getDareAttribute() - { - return $this->totale > 0 ? abs($this->totale) : 0; - } - - // Relazioni Eloquent - - public function scadenza() - { - return $this->belongsTo(Scadenza::class, 'id_scadenza'); - } - - public function documento() - { - return $this->belongsTo(Fattura::class, 'iddocumento'); - } -} diff --git a/modules/relazioni_anagrafiche/actions.php b/modules/relazioni_anagrafiche/actions.php deleted file mode 100755 index d8a0e9c46..000000000 --- a/modules/relazioni_anagrafiche/actions.php +++ /dev/null @@ -1,83 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -switch (filter('op')) { - case 'update': - $descrizione = filter('descrizione'); - $colore = filter('colore'); - - if (isset($descrizione)) { - if ($dbo->fetchNum('SELECT * FROM `an_relazioni` WHERE `descrizione`='.prepare($descrizione).' AND `id`!='.prepare($id_record)) == 0) { - $dbo->query('UPDATE `an_relazioni` SET `descrizione`='.prepare($descrizione).', `colore`='.prepare($colore).' WHERE `id`='.prepare($id_record)); - flash()->info(tr('Salvataggio completato.')); - } else { - flash()->error(tr("E' già presente una relazione _NAME_.", [ - '_TYPE_' => $descrizione, - ])); - } - } else { - flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio')); - } - - break; - - case 'add': - $descrizione = filter('descrizione'); - $colore = filter('colore'); - - if (isset($descrizione)) { - if ($dbo->fetchNum('SELECT * FROM `an_relazioni` WHERE `descrizione`='.prepare($descrizione)) == 0) { - $dbo->query('INSERT INTO `an_relazioni` (`descrizione`, `colore` ) VALUES ('.prepare($descrizione).', '.prepare($colore).' )'); - - $id_record = $dbo->lastInsertedID(); - - if (isAjaxRequest()) { - echo json_encode(['id' => $id_record, 'text' => $descrizione]); - } - - flash()->info(tr('Aggiunta nuova relazione _NAME_', [ - '_NAME_' => $descrizione, - ])); - } else { - flash()->error(tr("E' già presente una relazione di _NAME_.", [ - '_NAME_' => $descrizione, - ])); - } - } else { - flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio')); - } - - break; - - case 'delete': - $righe = $dbo->fetchNum('SELECT idanagrafica FROM an_anagrafiche WHERE idrelazione='.prepare($id_record)); - - if (isset($id_record) && empty($righe)) { - $dbo->query('DELETE FROM `an_relazioni` WHERE `id`='.prepare($id_record)); - flash()->info(tr('Relazione _NAME_ eliminata con successo!', [ - '_NAME_' => $descrizione, - ])); - } else { - flash()->error(tr('Sono presenti '.count($righe).' anagrafiche collegate a questa relazione.')); - } - - break; -} diff --git a/modules/relazioni_anagrafiche/add.php b/modules/relazioni_anagrafiche/add.php deleted file mode 100755 index 128f30d00..000000000 --- a/modules/relazioni_anagrafiche/add.php +++ /dev/null @@ -1,51 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1 ]} -
    - -
    - {[ "type": "text", "label": "", "name": "colore", "required": 1, "class": "colorpicker text-center", "value": "", "extra": "maxlength='7'", "icon-after": "
    " ]} -
    -
    - - -
    -
    - -
    -
    -
    - - diff --git a/modules/relazioni_anagrafiche/edit.php b/modules/relazioni_anagrafiche/edit.php deleted file mode 100755 index b45a1d658..000000000 --- a/modules/relazioni_anagrafiche/edit.php +++ /dev/null @@ -1,77 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - - -
    -
    -

    -
    - -
    -
    -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1, "value": "$descrizione$" ]} -
    - -
    - {[ "type": "text", "label": "", "name": "colore", "required": 1, "class": "colorpicker text-center", "value": "$colore$", "extra": "maxlength='7'", "icon-after": "
    " ]} -
    - -
    -
    -
    - -
    - -fetchNum('SELECT idanagrafica FROM an_anagrafiche WHERE idrelazione='.prepare($id_record)); - -if (!empty($righe)) { - echo ' -
    - '.tr('Ci sono _NUM_ anagrafiche collegate', [ - '_NUM_' => $righe, - ]).'. -
    '; -} else { - ?> - - - - - - - - - diff --git a/modules/relazioni_anagrafiche/init.php b/modules/relazioni_anagrafiche/init.php deleted file mode 100755 index 32b524fdf..000000000 --- a/modules/relazioni_anagrafiche/init.php +++ /dev/null @@ -1,24 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT * FROM `an_relazioni` WHERE id='.prepare($id_record)); -} diff --git a/modules/ritenute/actions.php b/modules/ritenute/actions.php deleted file mode 100755 index 656b66005..000000000 --- a/modules/ritenute/actions.php +++ /dev/null @@ -1,77 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -switch (filter('op')) { - case 'update': - $descrizione = filter('descrizione'); - $percentuale = filter('percentuale'); - $percentuale_imponibile = filter('percentuale_imponibile'); - - if (isset($descrizione) && isset($percentuale) && isset($percentuale_imponibile)) { - if ($dbo->fetchNum('SELECT * FROM `co_ritenutaacconto` WHERE `descrizione`='.prepare($descrizione).' AND `id`!='.prepare($id_record)) == 0) { - $dbo->query('UPDATE `co_ritenutaacconto` SET `descrizione`='.prepare($descrizione).', `percentuale`='.prepare($percentuale).', `percentuale_imponibile`='.prepare($percentuale_imponibile).' WHERE `id`='.prepare($id_record)); - flash()->info(tr('Salvataggio completato!')); - } else { - flash()->error(tr("E' già presente una tipologia di _TYPE_ con la stessa descrizione!", [ - '_TYPE_' => "ritenuta d'acconto", - ])); - } - } else { - flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio!')); - } - - break; - - case 'add': - $descrizione = filter('descrizione'); - $percentuale = filter('percentuale'); - $percentuale_imponibile = filter('percentuale_imponibile'); - - if (isset($descrizione) && isset($percentuale) && isset($percentuale_imponibile)) { - if ($dbo->fetchNum('SELECT * FROM `co_ritenutaacconto` WHERE `descrizione`='.prepare($descrizione)) == 0) { - $dbo->query('INSERT INTO `co_ritenutaacconto` (`descrizione`, `percentuale`, `percentuale_imponibile`) VALUES ('.prepare($descrizione).', '.prepare($percentuale).', '.prepare($percentuale_imponibile).')'); - $id_record = $dbo->lastInsertedID(); - - flash()->info(tr('Aggiunta nuova tipologia di _TYPE_', [ - '_TYPE_' => "ritenuta d'acconto", - ])); - } else { - flash()->error(tr("E' già presente una tipologia di _TYPE_ con la stessa descrizione!", [ - '_TYPE_' => "ritenuta d'acconto", - ])); - } - } else { - flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio!')); - } - - break; - - case 'delete': - if (isset($id_record)) { - $dbo->query('DELETE FROM `co_ritenutaacconto` WHERE `id`='.prepare($id_record)); - - flash()->info(tr('Tipologia di _TYPE_ eliminata con successo!', [ - '_TYPE_' => "ritenuta d'acconto", - ])); - } - - break; -} diff --git a/modules/ritenute/add.php b/modules/ritenute/add.php deleted file mode 100755 index cb257d94b..000000000 --- a/modules/ritenute/add.php +++ /dev/null @@ -1,48 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1 ]} -
    -
    - -
    -
    - {[ "type": "number", "label": "", "name": "percentuale", "min-value": "1", "max-value": "100", "icon-after": "", "value": "100" ]} -
    - -
    - {[ "type": "number", "label": "", "name": "percentuale_imponibile", "min-value": "1", "max-value": "100", "help": "", "icon-after": "", "value": "100"]} -
    -
    - - -
    -
    - -
    -
    -
    diff --git a/modules/ritenute/edit.php b/modules/ritenute/edit.php deleted file mode 100755 index 5b16ad821..000000000 --- a/modules/ritenute/edit.php +++ /dev/null @@ -1,71 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -// Presenza di documenti associati -if ($record['doc_associati'] > 0) { - echo ' -
    '.tr('Non puoi eliminare questa ritenuta.').' '.tr('Ci sono _NUM_ documenti associati.', [ - '_NUM_' => $record['doc_associati'], -]).'
    '; -} - -?> - -
    - - - - -
    -
    -

    -
    - -
    -
    -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1, "value": "$descrizione$" ]} -
    -
    - -
    -
    - {[ "type": "number", "label": "", "name": "percentuale", "min-value": "1", "max-value": "100", "value": "$percentuale$", "icon-after": "" ]} -
    - -
    - {[ "type": "number", "label": "", "name": "percentuale_imponibile", "value": "$percentuale_imponibile$", "min-value": "1", "max-value": "100", "help": "", "icon-after": "" ]} -
    -
    -
    -
    - -
    - - - '.tr('Elimina').' -'; -} diff --git a/modules/ritenute/init.php b/modules/ritenute/init.php deleted file mode 100755 index d4981cc18..000000000 --- a/modules/ritenute/init.php +++ /dev/null @@ -1,24 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT *, (SELECT COUNT(idritenutaacconto) FROM co_righe_documenti WHERE co_righe_documenti.idritenutaacconto = '.prepare($id_record).') AS doc_associati FROM `co_ritenutaacconto` WHERE id='.prepare($id_record)); -} diff --git a/modules/ritenute/src/RitenutaAcconto.php b/modules/ritenute/src/RitenutaAcconto.php deleted file mode 100755 index 5741cf515..000000000 --- a/modules/ritenute/src/RitenutaAcconto.php +++ /dev/null @@ -1,30 +0,0 @@ -. - */ - -namespace Modules\Ritenute; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; - -class RitenutaAcconto extends Model -{ - use SimpleModelTrait; - - protected $table = 'co_ritenutaacconto'; -} diff --git a/modules/ritenute_contributi/actions.php b/modules/ritenute_contributi/actions.php deleted file mode 100755 index f924cc6c2..000000000 --- a/modules/ritenute_contributi/actions.php +++ /dev/null @@ -1,77 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -switch (filter('op')) { - case 'update': - $descrizione = filter('descrizione'); - $percentuale = filter('percentuale'); - $percentuale_imponibile = filter('percentuale_imponibile'); - - if (isset($descrizione) && isset($percentuale) && isset($percentuale_imponibile)) { - if ($dbo->fetchNum('SELECT * FROM `co_ritenuta_contributi` WHERE `descrizione`='.prepare($descrizione).' AND `id`!='.prepare($id_record)) == 0) { - $dbo->query('UPDATE `co_ritenuta_contributi` SET `descrizione`='.prepare($descrizione).', `percentuale`='.prepare($percentuale).', `percentuale_imponibile`='.prepare($percentuale_imponibile).' WHERE `id`='.prepare($id_record)); - flash()->info(tr('Salvataggio completato!')); - } else { - flash()->error(tr("E' già presente una tipologia di _TYPE_ con la stessa descrizione!", [ - '_TYPE_' => "ritenuta d'acconto", - ])); - } - } else { - flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio!')); - } - - break; - - case 'add': - $descrizione = filter('descrizione'); - $percentuale = filter('percentuale'); - $percentuale_imponibile = filter('percentuale_imponibile'); - - if (isset($descrizione) && isset($percentuale) && isset($percentuale_imponibile)) { - if ($dbo->fetchNum('SELECT * FROM `co_ritenuta_contributi` WHERE `descrizione`='.prepare($descrizione)) == 0) { - $dbo->query('INSERT INTO `co_ritenuta_contributi` (`descrizione`, `percentuale`, `percentuale_imponibile`) VALUES ('.prepare($descrizione).', '.prepare($percentuale).', '.prepare($percentuale_imponibile).')'); - $id_record = $dbo->lastInsertedID(); - - flash()->info(tr('Aggiunta nuova tipologia di _TYPE_', [ - '_TYPE_' => "ritenuta d'acconto", - ])); - } else { - flash()->error(tr("E' già presente una tipologia di _TYPE_ con la stessa descrizione!", [ - '_TYPE_' => "ritenuta d'acconto", - ])); - } - } else { - flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio!')); - } - - break; - - case 'delete': - if (isset($id_record)) { - $dbo->query('DELETE FROM `co_ritenuta_contributi` WHERE `id`='.prepare($id_record)); - - flash()->info(tr('Tipologia di _TYPE_ eliminata con successo!', [ - '_TYPE_' => "ritenuta d'acconto", - ])); - } - - break; -} diff --git a/modules/ritenute_contributi/add.php b/modules/ritenute_contributi/add.php deleted file mode 100755 index 02f009495..000000000 --- a/modules/ritenute_contributi/add.php +++ /dev/null @@ -1,48 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1 ]} -
    -
    - -
    -
    - {[ "type": "number", "label": "", "name": "percentuale", "min-value": "1", "max-value": "100","icon-after": "", "value": "100" ]} -
    - -
    - {[ "type": "number", "label": "", "name": "percentuale_imponibile", "min-value": "1", "max-value": "100", "help": "", "icon-after": "", "value": "100" ]} -
    -
    - - -
    -
    - -
    -
    -
    diff --git a/modules/ritenute_contributi/edit.php b/modules/ritenute_contributi/edit.php deleted file mode 100755 index 5b16ad821..000000000 --- a/modules/ritenute_contributi/edit.php +++ /dev/null @@ -1,71 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -// Presenza di documenti associati -if ($record['doc_associati'] > 0) { - echo ' -
    '.tr('Non puoi eliminare questa ritenuta.').' '.tr('Ci sono _NUM_ documenti associati.', [ - '_NUM_' => $record['doc_associati'], -]).'
    '; -} - -?> - -
    - - - - -
    -
    -

    -
    - -
    -
    -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1, "value": "$descrizione$" ]} -
    -
    - -
    -
    - {[ "type": "number", "label": "", "name": "percentuale", "min-value": "1", "max-value": "100", "value": "$percentuale$", "icon-after": "" ]} -
    - -
    - {[ "type": "number", "label": "", "name": "percentuale_imponibile", "value": "$percentuale_imponibile$", "min-value": "1", "max-value": "100", "help": "", "icon-after": "" ]} -
    -
    -
    -
    - -
    - - - '.tr('Elimina').' -'; -} diff --git a/modules/ritenute_contributi/init.php b/modules/ritenute_contributi/init.php deleted file mode 100755 index f91af9a1d..000000000 --- a/modules/ritenute_contributi/init.php +++ /dev/null @@ -1,24 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT *, (SELECT COUNT(id_ritenuta_contributi) FROM co_documenti WHERE co_documenti.id_ritenuta_contributi = '.prepare($id_record).') AS doc_associati FROM `co_ritenuta_contributi` WHERE id='.prepare($id_record)); -} diff --git a/modules/ritenute_contributi/src/RitenutaContributi.php b/modules/ritenute_contributi/src/RitenutaContributi.php deleted file mode 100755 index 04b54c236..000000000 --- a/modules/ritenute_contributi/src/RitenutaContributi.php +++ /dev/null @@ -1,36 +0,0 @@ -. - */ - -namespace Modules\RitenuteContributi; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; -use Modules\Fatture\Fattura; - -class RitenutaContributi extends Model -{ - use SimpleModelTrait; - - protected $table = 'co_ritenuta_contributi'; - - public function fatture() - { - return $this->hasMany(Fattura::class, 'id_ritenuta_contributi'); - } -} diff --git a/modules/rivalse/actions.php b/modules/rivalse/actions.php deleted file mode 100755 index fab9f32cb..000000000 --- a/modules/rivalse/actions.php +++ /dev/null @@ -1,77 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -switch (filter('op')) { - case 'update': - $descrizione = filter('descrizione'); - $percentuale = filter('percentuale'); - $indetraibile = filter('indetraibile'); - - if (isset($descrizione) && isset($percentuale) && isset($indetraibile)) { - if ($dbo->fetchNum('SELECT * FROM `co_rivalse` WHERE `descrizione`='.prepare($descrizione).' AND `id`!='.prepare($id_record)) == 0) { - $dbo->query('UPDATE `co_rivalse` SET `descrizione`='.prepare($descrizione).', `percentuale`='.prepare($percentuale).', `indetraibile`='.prepare($indetraibile).' WHERE `id`='.prepare($id_record)); - flash()->info(tr('Salvataggio completato!')); - } else { - flash()->error(tr("E' già presente una tipologia di _TYPE_ con la stessa descrizione!", [ - '_TYPE_' => "ritenuta d'acconto", - ])); - } - } else { - flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio!')); - } - - break; - - case 'add': - $descrizione = filter('descrizione'); - $percentuale = filter('percentuale'); - $indetraibile = filter('indetraibile'); - - if (isset($descrizione) && isset($percentuale) && isset($indetraibile)) { - if ($dbo->fetchNum('SELECT * FROM `co_rivalse` WHERE `descrizione`='.prepare($descrizione)) == 0) { - $dbo->query('INSERT INTO `co_rivalse` (`descrizione`, `percentuale`, `indetraibile`) VALUES ('.prepare($descrizione).', '.prepare($percentuale).', '.prepare($indetraibile).')'); - $id_record = $dbo->lastInsertedID(); - - flash()->info(tr('Aggiunta nuova tipologia di _TYPE_', [ - '_TYPE_' => "ritenuta d'acconto", - ])); - } else { - flash()->error(tr("E' già presente una tipologia di _TYPE_ con la stessa descrizione!", [ - '_TYPE_' => "ritenuta d'acconto", - ])); - } - } else { - flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio!')); - } - - break; - - case 'delete': - if (isset($id_record)) { - $dbo->query('DELETE FROM `co_rivalse` WHERE `id`='.prepare($id_record)); - - flash()->info(tr('Tipologia di _TYPE_ eliminata con successo!', [ - '_TYPE_' => "ritenuta d'acconto", - ])); - } - - break; -} diff --git a/modules/rivalse/add.php b/modules/rivalse/add.php deleted file mode 100755 index fda8edc17..000000000 --- a/modules/rivalse/add.php +++ /dev/null @@ -1,48 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1 ]} -
    -
    - -
    -
    - {[ "type": "number", "label": "", "name": "percentuale", "icon-after": "" ]} -
    - -
    - {[ "type": "number", "label": "", "name": "indetraibile", "icon-after": "" ]} -
    -
    - - -
    -
    - -
    -
    -
    diff --git a/modules/rivalse/edit.php b/modules/rivalse/edit.php deleted file mode 100755 index 3ac12681b..000000000 --- a/modules/rivalse/edit.php +++ /dev/null @@ -1,55 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - - -
    -
    -

    -
    - -
    -
    -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1, "value": "$descrizione$" ]} -
    -
    - -
    -
    - {[ "type": "number", "label": "", "name": "percentuale", "value": "$percentuale$", "icon-after": "" ]} -
    - -
    - {[ "type": "number", "label": "", "name": "indetraibile", "value": "$indetraibile$", "icon-after": "" ]} -
    -
    -
    -
    - -
    - - - - diff --git a/modules/rivalse/init.php b/modules/rivalse/init.php deleted file mode 100755 index 3f56d98bb..000000000 --- a/modules/rivalse/init.php +++ /dev/null @@ -1,24 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT * FROM `co_rivalse` WHERE id='.prepare($id_record)); -} diff --git a/modules/rivalse/src/RivalsaINPS.php b/modules/rivalse/src/RivalsaINPS.php deleted file mode 100755 index 839c9ea89..000000000 --- a/modules/rivalse/src/RivalsaINPS.php +++ /dev/null @@ -1,30 +0,0 @@ -. - */ - -namespace Modules\Rivalse; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; - -class RivalsaINPS extends Model -{ - use SimpleModelTrait; - - protected $table = 'co_rivalse'; -} diff --git a/modules/scadenzario/actions.php b/modules/scadenzario/actions.php deleted file mode 100755 index 21cc32b18..000000000 --- a/modules/scadenzario/actions.php +++ /dev/null @@ -1,121 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -switch (post('op')) { - case 'add': - $data = post('data'); - $tipo = post('tipo'); - $da_pagare = post('da_pagare'); - $descrizione = post('descrizione'); - - $dbo->query('INSERT INTO co_scadenziario(descrizione, tipo, data_emissione, scadenza, da_pagare, pagato) VALUES('.prepare($descrizione).', '.prepare($tipo).', CURDATE(), '.prepare($data).', '.prepare($da_pagare).", '0')"); - $id_record = $dbo->lastInsertedID(); - - flash()->info(tr('Scadenza inserita!')); - break; - - case 'update': - $tipo = post('tipo'); - $descrizione = post('descrizione'); - $iddocumento = post('iddocumento') ?: 0; - - $totale_pagato = 0; - $id_scadenza_non_completa = null; - foreach (post('da_pagare') as $id => $da_pagare) { - $pagato = post('pagato')[$id]; - $scadenza = post('scadenza')[$id]; - $data_concordata = post('data_concordata')[$id]; - - $pagato = floatval($pagato); - $da_pagare = floatval($da_pagare); - - if (!empty($iddocumento)) { - $id_tipo = $dbo->selectOne('co_documenti', 'idtipodocumento', ['id' => $iddocumento])['idtipodocumento']; - $tipo_documento = $dbo->selectOne('co_tipidocumento', '*', ['id' => $id_tipo]); - - if ($tipo_documento['dir'] == 'uscita') { - if ($pagato > 0) { - $pagato = -$pagato; - } - if ($da_pagare > 0) { - $da_pagare = -$da_pagare; - } - } else { - if ($pagato < 0) { - $pagato = -$pagato; - } - if ($da_pagare < 0) { - $da_pagare = -$da_pagare; - } - } - - if (!empty($tipo_documento['reversed'])) { - $pagato = -$pagato; - $da_pagare = -$da_pagare; - } - } - - $totale_pagato = sum($totale_pagato, $pagato); - - $id_scadenza = post('id_scadenza')[$id]; - if (!empty($id_scadenza)) { - $database->update('co_scadenziario', [ - 'descrizione' => $descrizione, - 'da_pagare' => $da_pagare, - 'pagato' => $pagato, - 'scadenza' => $scadenza, - 'data_concordata' => $data_concordata, - 'note' => post('note'), - ], ['id' => $id_scadenza]); - - if ($da_pagare == 0) { - $database->delete('co_scadenziario', ['id' => $id]); - } - } else { - $database->insert('co_scadenziario', [ - 'descrizione' => $descrizione, - 'tipo' => $tipo, - 'iddocumento' => $iddocumento, - 'da_pagare' => $da_pagare, - 'pagato' => $pagato, - 'scadenza' => $scadenza, - 'data_concordata' => $data_concordata, - 'data_emissione' => date('Y-m-d'), - 'note' => post('note'), - ]); - - $id_scadenza = $database->lastInsertedID(); - } - - if ($pagato != $da_pagare) { - $id_scadenza_non_completa = $id_scadenza; - } - } - - flash()->info(tr('Scadenze aggiornate!')); - - break; - - case 'delete': - $dbo->query("DELETE FROM co_scadenziario WHERE id='".$id_record."'"); - flash()->info(tr('Scadenza eliminata!')); - break; -} diff --git a/modules/scadenzario/add.php b/modules/scadenzario/add.php deleted file mode 100755 index 7b5cb4ba8..000000000 --- a/modules/scadenzario/add.php +++ /dev/null @@ -1,54 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?> - -
    - - - - -
    -
    - {[ "type": "select", "label": "", "name": "tipo", "required": 1, "ajax-source": "tipi_scadenze", "icon-after": "add|" ]} -
    - -
    - {[ "type": "date", "label": "", "name": "data", "required": 1, "value": "-now-" ]} -
    - -
    - {[ "type": "number", "label": "", "name": "da_pagare", "required": 1, "value": "", "help": "Le scadenze inserite con importo positivo indicano un credito da un cliente, le scadenze inserite con importo negativo indicano un debito verso un fornitore" ]} -
    -
    - -
    -
    - {[ "type": "textarea", "label": "", "name": "descrizione", "required": 1, "value": "" ]} -
    -
    - -
    - -
    - -
    -
    \ No newline at end of file diff --git a/modules/scadenzario/bulk.php b/modules/scadenzario/bulk.php deleted file mode 100755 index a51974355..000000000 --- a/modules/scadenzario/bulk.php +++ /dev/null @@ -1,32 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$operations['registrazione-contabile'] = [ - 'text' => ' '.tr('Registrazione contabile').'', - 'data' => [ - 'title' => tr('Registrazione contabile'), - 'type' => 'modal', - 'origine' => 'scadenzario', - 'url' => base_path().'/add.php?id_module='.Modules::get('Prima nota')['id'], - ], -]; - -return $operations; diff --git a/modules/scadenzario/controller_after.php b/modules/scadenzario/controller_after.php deleted file mode 100755 index 0fadedb5a..000000000 --- a/modules/scadenzario/controller_after.php +++ /dev/null @@ -1,40 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (empty($dbo->fetchArray('SELECT * FROM co_scadenziario'))) { - $class = 'muted'; - $disabled = 'disabled'; -} else { - $class = 'primary'; - $disabled = ''; -} - -?>
    - - -
    -
    - - - -
    -
    -
    diff --git a/modules/scadenzario/edit.php b/modules/scadenzario/edit.php deleted file mode 100755 index f6c430995..000000000 --- a/modules/scadenzario/edit.php +++ /dev/null @@ -1,295 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$dir = $documento->direzione; -$numero = $documento->numero_esterno ?: $documento->numero; - -echo ' -
    - - - - - - - - -
    -
    -

    - '.tr('Dettagli scadenza').' - -

    -
    - -
    -
    - - -
    '; - -if (!empty($documento)) { - echo ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    '.($dir == 'entrata' ? tr('Cliente') : tr('Fornitore')).': - '.Modules::link('Anagrafiche', $documento->anagrafica->id, $documento->anagrafica->ragione_sociale).' -
    '.tr('Documento').':'.$documento->tipo->descrizione.'
    '.tr('Numero').':'.$numero.'
    '.tr('Data').':'.Translator::dateToLocale($documento->data).'
    '.tr('Netto a pagare').':'.moneyFormat($documento->netto).'
    '.tr('Note').': - {[ "type": "textarea", "name": "note", "value": "'.$record['note'].'" ]} -
    - - '.Modules::link($documento->module, $record['iddocumento'], ' '.tr('Apri documento'), null, 'class="btn btn-primary"'); -} else { - $scadenza = $dbo->fetchOne('SELECT * FROM co_scadenziario WHERE id = '.prepare($id_record)); - - echo input([ - 'type' => 'textarea', - 'label' => tr('Descrizione'), - 'name' => 'descrizione', - 'required' => 1, - 'value' => $scadenza['descrizione'], - ]); -} - -echo ' -
    - - -
    - - - - - - - - - - - '; - -foreach ($scadenze as $i => $scadenza) { - if ($scadenza['da_pagare'] == $scadenza['pagato']) { - $class = 'success'; - } elseif (abs($scadenza['pagato']) == 0) { - $class = 'danger'; - } elseif (abs($scadenza['pagato']) <= abs($scadenza['da_pagare'])) { - $class = 'warning'; - } else { - $class = 'danger'; - } - - echo ' - - - - - - - - - - - '; -} - -echo ' - - - - - - - - - -
    '.tr('Data').''.tr('Importo').''.tr('Pagato').''.tr('Data concordata').'
    - {[ "type": "date", "name": "scadenza['.$i.']", "value": "'.$scadenza['scadenza'].'" ]} - - {[ "type": "number", "name": "da_pagare['.$i.']", "decimals": 2, "value": "'.numberFormat($scadenza['da_pagare'], 2).'", "onchange": "controlloTotale()" ]} - - {[ "type": "number", "name": "pagato['.$i.']", "decimals": 2, "value": "'.numberFormat($scadenza['pagato']).'" ]} - - {[ "type": "date", "name": "data_concordata['.$i.']", "value": "'.$scadenza['data_concordata'].'" ]} -
    '.tr('Totale').''.numberFormat($totale_da_pagare).'
    '; - -if ($totale_da_pagare != 0) { - echo ' - - -
    -
    '; -} -?> - -
    ''.moneyFormat($totale_da_pagare).'', - ]); ?>.
    '', - '_CURRENCY_' => currency(), - ]); ?>. -
    - - -
    -
    -
    -
    -
    - -fetchOne('SELECT id FROM co_scadenziario WHERE iddocumento='.prepare($documento->id).' ORDER BY id')['id']; -} -?> - -{( "name": "filelist_and_upload", "id_module": "$id_module$", "id_record": "" )} - -{( "name": "log_email", "id_module": "$id_module$", "id_record": "$id_record$" )} - - - '.tr('Elimina').' -'; -} - -echo ' - - - - - - - - - - - - - - -
    - {[ "type": "date", "name": "scadenza[-id-]" ]} - - {[ "type": "number", "name": "da_pagare[-id-]", "decimals": 2, "onchange": "controlloTotale()" ]} - - {[ "type": "number", "name": "pagato[-id-]", "decimals": 2 ]} - - {[ "type": "date", "name": "data_concordata[-id-]" ]} -
    - -'; - -// Abilitazione dei controlli solo per Scadenze collegate a documenti -if (!empty($documento)) { - echo ' -'; -} diff --git a/modules/scadenzario/init.php b/modules/scadenzario/init.php deleted file mode 100755 index 304d429de..000000000 --- a/modules/scadenzario/init.php +++ /dev/null @@ -1,36 +0,0 @@ -. - */ - -use Modules\Fatture\Fattura; - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT * FROM co_scadenziario WHERE id = '.prepare($id_record)); - $documento = Fattura::find($record['iddocumento']); - - // Scelgo la query in base alla scadenza - if (!empty($documento)) { - $scadenze = $dbo->fetchArray('SELECT * FROM co_scadenziario WHERE iddocumento = '.prepare($documento->id).' ORDER BY scadenza ASC'); - $totale_da_pagare = $documento->netto; - } else { - $scadenze = $dbo->fetchArray('SELECT * FROM co_scadenziario WHERE id = '.prepare($id_record).' ORDER BY scadenza ASC'); - $totale_da_pagare = sum(array_column($scadenze, 'da_pagare')); - } -} diff --git a/modules/scadenzario/src/Scadenza.php b/modules/scadenzario/src/Scadenza.php deleted file mode 100755 index d846cb490..000000000 --- a/modules/scadenzario/src/Scadenza.php +++ /dev/null @@ -1,58 +0,0 @@ -. - */ - -namespace Modules\Scadenzario; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; -use Modules\Fatture\Fattura; - -class Scadenza extends Model -{ - use SimpleModelTrait; - - protected $table = 'co_scadenziario'; - - protected $dates = [ - 'scadenza', - 'data_pagamento', - ]; - - public static function build($descrizione, $importo, $data_scadenza, $type = 'fattura', $is_pagato = false) - { - $model = new static(); - - $model->descrizione = $descrizione; - $model->scadenza = $data_scadenza; - $model->da_pagare = $importo; - $model->tipo = $type; - - $model->pagato = $is_pagato ? $importo : 0; - $model->data_pagamento = $is_pagato ? $data_scadenza : null; - - $model->save(); - - return $model; - } - - public function documento() - { - return $this->belongsTo(Fattura::class, 'iddocumento'); - } -} diff --git a/modules/scadenzario/variables.php b/modules/scadenzario/variables.php deleted file mode 100755 index ef55d49ed..000000000 --- a/modules/scadenzario/variables.php +++ /dev/null @@ -1,46 +0,0 @@ -. - */ - -$r = $dbo->fetchOne('SELECT co_scadenziario.*, co_documenti.*, - an_anagrafiche.email, - an_anagrafiche.pec, - an_anagrafiche.ragione_sociale, - co_scadenziario.da_pagare - co_scadenziario.pagato AS totale, - (SELECT pec FROM em_accounts WHERE em_accounts.id='.prepare($template['id_account']).') AS is_pec, - (SELECT descrizione FROM co_pagamenti WHERE co_pagamenti.id = co_documenti.idpagamento) AS pagamento -FROM co_scadenziario - INNER JOIN co_documenti ON co_documenti.id = co_scadenziario.iddocumento - INNER JOIN an_anagrafiche ON co_documenti.idanagrafica=an_anagrafiche.idanagrafica -WHERE co_scadenziario.pagato != co_scadenziario.da_pagare AND co_scadenziario.iddocumento = (SELECT iddocumento FROM co_scadenziario s WHERE id='.prepare($id_record).')'); - -$logo_azienda = str_replace(base_dir(), base_path(), App::filepath('templates/base|custom|/logo_azienda.jpg')); - -// Variabili da sostituire -return [ - 'email' => $r['is_pec'] ? $r['pec'] : $r['email'], - 'id_anagrafica' => $r['idanagrafica'], - 'ragione_sociale' => $r['ragione_sociale'], - 'numero' => empty($r['numero_esterno']) ? $r['numero'] : $r['numero_esterno'], - 'note' => $r['note'], - 'pagamento' => $r['pagamento'], - 'totale' => Translator::numberToLocale(abs($r['totale'])), - 'data_scadenza' => Translator::dateToLocale($r['scadenza']), - 'data' => Translator::dateToLocale($r['data']), - 'logo_azienda' => !empty($logo_azienda) ? '' : '', -]; diff --git a/modules/segmenti/actions.php b/modules/segmenti/actions.php deleted file mode 100755 index 0a2d37a27..000000000 --- a/modules/segmenti/actions.php +++ /dev/null @@ -1,100 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -switch (post('op')) { - case 'update': - $pattern = string_contains(post('pattern'), '#') ? post('pattern') : '####'; - $predefined = post('predefined'); - $module = post('module'); - - if (empty(Modules::getSegments($module))) { - $predefined = 1; - } - - if ($predefined) { - $dbo->query('UPDATE zz_segments SET predefined = 0 WHERE id_module = '.prepare($module)); - } - - $predefined_accredito = post('predefined_accredito'); - if ($predefined_accredito) { - $dbo->query('UPDATE zz_segments SET predefined_accredito = 0 WHERE id_module = '.prepare($module)); - } - - $predefined_addebito = post('predefined_addebito'); - if ($predefined_addebito) { - $dbo->query('UPDATE zz_segments SET predefined_addebito = 0 WHERE id_module = '.prepare($module)); - } - - $dbo->update('zz_segments', [ - 'id_module' => $module, - 'name' => post('name'), - 'clause' => $_POST['clause'], - 'pattern' => $pattern, - 'note' => post('note'), - 'position' => post('position'), - 'predefined' => $predefined, - 'is_fiscale' => post('is_fiscale'), - 'predefined_accredito' => $predefined_accredito, - 'predefined_addebito' => $predefined_addebito, - ], ['id' => $id_record]); - - flash()->info(tr('Modifiche salvate correttamente')); - - break; - - case 'add': - $pattern = string_contains(post('pattern'), '#') ? post('pattern') : '####'; - $predefined = post('predefined'); - $module = post('module'); - - if (empty(Modules::getSegments($module))) { - $predefined = 1; - } - - if ($predefined) { - $dbo->query('UPDATE zz_segments SET predefined = 0 WHERE id_module = '.prepare($module)); - } - - $dbo->insert('zz_segments', [ - 'id_module' => $module, - 'name' => post('name'), - 'clause' => '1=1', - 'pattern' => $pattern, - 'note' => post('note'), - 'predefined' => $predefined, - ]); - - $id_record = $dbo->lastInsertedID(); - - flash()->info(tr('Nuovo segmento aggiunto')); - - break; - - case 'delete': - $dbo->query('DELETE FROM zz_segments WHERE id='.prepare($id_record)); - - // TODO - // eliminare riferimento sulle fatture eventuali collegate a questo segmento? - - flash()->info(tr('Segmento eliminato')); - - break; -} diff --git a/modules/segmenti/add.php b/modules/segmenti/add.php deleted file mode 100755 index 7ae6d80ba..000000000 --- a/modules/segmenti/add.php +++ /dev/null @@ -1,62 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "name", "required": 1, "value": "$name$" ]} -
    - -
    - {[ "type": "text", "label": "", "name": "pattern", "class": "alphanumeric-mask", "value": "$pattern$", "maxlength": 25, "placeholder":"####/YYYY" ]} -
    -
    - -
    - -
    - {[ "type": "select", "label": "", "name": "module", "required": 1, "values": "query=SELECT id, IF(title!='', title, name) AS descrizione FROM zz_modules WHERE enabled = 1 AND options != 'custom' ORDER BY descrizione ASC", "value": "" ]} -
    - -
    - {[ "type": "checkbox", "label": "", "name": "predefined", "value": "0", "help": "", "placeholder": "" ]} -
    - -
    - -
    - -
    - {[ "type": "textarea", "label": "Note", "name": "note" ]} -
    - -
    - - -
    -
    - -
    -
    -
    diff --git a/modules/segmenti/edit.php b/modules/segmenti/edit.php deleted file mode 100755 index 46a25c971..000000000 --- a/modules/segmenti/edit.php +++ /dev/null @@ -1,189 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - - - -
    -
    -

    -
    - -
    -
    - -
    - {[ "type": "text", "label": "", "name": "name", "required": 1, "value": "$name$" ]} -
    - -
    - {[ "type": "select", "label": "", "name": "module", "required": 1, "values": "query=SELECT id, name AS descrizione FROM zz_modules WHERE ( enabled = 1 AND options != 'custom' ) OR id = ORDER BY name ASC", "value": "", "extra": "" ]} -
    - -
    - {[ "type": "checkbox", "label": "", "name": "predefined", "value": "$predefined$", "help": "", "placeholder": "", "extra": "" ]} -
    - -
    - -
    - -
    - {[ "type": "textarea", "label": "", "name": "clause", "required": 1, "value": "$clause$" ]} -
    - -
    - {[ "type": "select", "label": "", "name": "position", "required": 1, "values":"list=\"WHR\": \"WHERE\", \"HVN\": \"HAVING\"", "value": "$position$" ]} -
    - -
    -'.tr('Query risultante').':

    -

    '.htmlentities($module_query).'

    '; - -$_SESSION['module_'.$id_module]['id_segment'] = $previous; -$_SESSION['module_'.$record['id_module']]['id_segment'] = $previous_module; - -?> -
    -
    - {[ "type": "textarea", "label": "", "name": "note", "value": "$note$" ]} -
    -
    -
    -
    - - - -
    -
    -

    -
    - -
    -
    -
    - {[ "type": "text", "label": "", "name": "pattern", "value": "$pattern$", "maxlength": 25, "placeholder":"####/YYYY", "extra": " 0) ? 'readonly' : ''; ?>" ]} -
    - -
    - {[ "type": "checkbox", "label": "", "name": "is_fiscale", "value": "$is_fiscale$", "extra": " 0) ? 'readonly' : ''; ?>" ]} -
    -
    - -
    -
    - {[ "type": "checkbox", "label": "", "name": "predefined_accredito", "value": "$predefined_accredito$", "help": "", "placeholder": "" ]} -
    - -
    - {[ "type": "checkbox", "label": "", "name": "predefined_addebito", "value": "$predefined_addebito$", "help": "", "placeholder": "" ]} -
    -
    - - -
    -
    -

    tr('Maschera'), - ]); ?>

    -
    - -
    -

    :

    -
      - tr('Numero progressivo del documento, con zeri non significativi per raggiungere il numero desiderato di caratteri'), - 'YYYY' => tr('Anno corrente a 4 cifre'), - 'yy' => tr('Anno corrente a 2 cifre'), -]; - - foreach ($list as $key => $value) { - echo ' -
    • '.tr('_TEXT_: _FIELD_', [ - '_TEXT_' => ''.$key.'', - '_FIELD_' => $value, - ]).'
    • '; - } ?> -
    - -

    .

    -
    -
    - -
    -
    - -
    - - 0) { - echo "
    "; - - echo tr("Ci sono _TOT_ righe collegate al segmento per il modulo '_MODULO_'. Il comando elimina è stato disattivato, eliminare le righe per attivare il comando 'Elimina segmento'.", [ - '_TOT_' => $tot, - '_MODULO_' => $record['modulo'], - ]); - - echo '
    '; -} elseif ($records['predefined']) { - echo "
    "; - - echo tr("Questo è il segmento predefinito per il modulo '_MODULO_'. Il comando elimina è stato disattivato.", [ - '_MODULO_' => $record['modulo'], - ]); - - echo '
    '; -} elseif ($record['n_sezionali'] < 2) { - echo "
    "; - - echo tr("Questo è l'unico segmento per il modulo '_MODULO_'. Il comando elimina è stato disattivato.", [ - '_MODULO_' => $record['modulo'], - ]); - - echo '
    '; -} else { - echo ' - - '.tr('Elimina').' -'; -} -?> diff --git a/modules/segmenti/init.php b/modules/segmenti/init.php deleted file mode 100755 index 8fa58305f..000000000 --- a/modules/segmenti/init.php +++ /dev/null @@ -1,30 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT *, (SELECT options FROM zz_modules WHERE id = zz_segments.id_module) options, (SELECT name FROM zz_modules WHERE id = zz_segments.id_module) AS modulo, (SELECT COUNT(t.id) FROM zz_segments t WHERE t.id_module = zz_segments.id_module) AS n_sezionali FROM zz_segments WHERE id='.prepare($id_record)); - - $array = preg_match('/(?<=FROM)\s([^\s]+)\s/', $record['options'], $table); - if (strpos($table[0], 'co_documenti') !== false) { - $righe = $dbo->fetchArray('SELECT COUNT(*) AS tot FROM '.$table[0].' WHERE id_segment = '.prepare($id_record)); - $tot = $righe[0]['tot']; - } -} diff --git a/modules/smtp/actions.php b/modules/smtp/actions.php deleted file mode 100755 index 9a86b2db6..000000000 --- a/modules/smtp/actions.php +++ /dev/null @@ -1,122 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -switch (filter('op')) { - case 'add': - $dbo->insert('em_accounts', [ - 'name' => post('name'), - 'from_name' => post('from_name'), - 'from_address' => post('from_address'), - ]); - - $id_record = $dbo->lastInsertedID(); - - flash()->info(tr('Nuovo account email aggiunto!')); - - break; - - case 'update': - $predefined = post('predefined'); - if (!empty($predefined)) { - $dbo->query('UPDATE em_accounts SET predefined = 0'); - } - - $abilita_oauth2 = post('abilita_oauth2'); - - $dbo->update('em_accounts', [ - 'name' => post('name'), - 'note' => post('note'), - 'server' => post('server'), - 'port' => post('port'), - 'username' => post('username'), - 'password' => post('password'), - 'from_name' => post('from_name'), - 'from_address' => post('from_address'), - 'encryption' => post('encryption'), - 'pec' => post('pec'), - 'timeout' => post('timeout'), - 'ssl_no_verify' => post('ssl_no_verify'), - 'predefined' => $predefined, - 'provider' => post('provider'), - 'client_id' => post('client_id'), - 'client_secret' => post('client_secret'), - ], ['id' => $id_record]); - - flash()->info(tr('Informazioni salvate correttamente!')); - - // Rimozione informazioni OAuth2 in caso di disabilitazione - if (!$abilita_oauth2) { - $dbo->update('em_accounts', [ - 'provider' => null, - 'client_id' => null, - 'client_secret' => null, - 'access_token' => null, - 'refresh_token' => null, - ], ['id' => $id_record]); - } - - // Validazione indirizzo email mittente - $check_email = Validate::isValidEmail(post('from_address')); - - // Controllo sulla validazione - if (!empty($check_email['valid-format'])) { - flash()->info(tr('Sintassi email verificata')); - } else { - flash()->error(tr("Attenzione: l'indirizzo email _EMAIL_ sembra non essere valido", [ - '_EMAIL_' => post('from_address'), - ])); - } - - // Controllo sulla verifica - if (!empty($check_email['smtp-check'])) { - flash()->info(tr('SMTP email verificato')); - } else { - flash()->warning(tr('SMTP email non verificato')); - } - - if (isAjaxRequest()) { - echo json_encode(['id' => $id_record]); - } - - break; - - case 'test': - $result = $account->testConnection(); - - echo json_encode([ - 'test' => $result, - ]); - - break; - - case 'delete': - $account->delete(); - - flash()->info(tr('Account email eliminato!')); - - break; - - case 'oauth2': - $redirect = base_path().'/oauth2.php?id_account='.$account->id; - redirect($redirect); - - break; -} diff --git a/modules/smtp/add.php b/modules/smtp/add.php deleted file mode 100755 index 2957ac65d..000000000 --- a/modules/smtp/add.php +++ /dev/null @@ -1,48 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "name", "required": 1 ]} -
    -
    - -
    -
    - {[ "type": "text", "label": "", "name": "from_name" ]} -
    - -
    - {[ "type": "email", "label": "", "name": "from_address", "required": 1 ]} -
    -
    - - -
    -
    - -
    -
    -
    diff --git a/modules/smtp/ajax/select.php b/modules/smtp/ajax/select.php deleted file mode 100755 index 45d8184d4..000000000 --- a/modules/smtp/ajax/select.php +++ /dev/null @@ -1,37 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -switch ($resource) { - case 'smtp': - $query = 'SELECT id AS id, CONCAT_WS(" - ", name, from_address ) AS descrizione FROM em_accounts |where| ORDER BY name'; - - foreach ($elements as $element) { - $filter[] = 'id = '.prepare($element); - } - if (empty($filter)) { - $where[] = 'deleted_at IS NULL'; - } - if (!empty($search)) { - $search_fields[] = 'name LIKE '.prepare('%'.$search.'%'); - } - - break; -} diff --git a/modules/smtp/buttons.php b/modules/smtp/buttons.php deleted file mode 100755 index 0e09a86ff..000000000 --- a/modules/smtp/buttons.php +++ /dev/null @@ -1,57 +0,0 @@ -. - */ - -echo ' - - -'; diff --git a/modules/smtp/edit.php b/modules/smtp/edit.php deleted file mode 100755 index fb980e735..000000000 --- a/modules/smtp/edit.php +++ /dev/null @@ -1,213 +0,0 @@ -. - */ - -use Modules\Emails\OAuth2; - -include_once __DIR__.'/../../core.php'; - -echo ' -
    - - - - -
    -
    -

    '.tr('Dati').'

    -
    - -
    -
    -
    - {[ "type": "text", "label": "'.tr('Nome account').'", "name": "name", "value": "$name$", "required": 1 ]} -
    - -
    - {[ "type": "checkbox", "label": "'.tr('Indirizzo PEC').'", "name": "pec", "value": "$pec$" ]} -
    - -
    - {[ "type": "checkbox", "label": "'.tr('Indirizzo predefinito').'", "name": "predefined", "value": "$predefined$", "help": "'.tr('Account da utilizzare per l\'invio di tutte le email dal gestionale.').'" ]} -
    -
    - -
    -
    - {[ "type": "text", "label": "'.tr('Nome visualizzato').'", "name": "from_name", "value": "$from_name$" ]} -
    - -
    - {[ "type": "email", "label": "'.tr('Email mittente').'", "name": "from_address", "value": "$from_address$", "required": 1 ]} -
    - -
    - {[ "type": "checkbox", "label": "'.tr('Non verificare il certificato SSL').'", "name": "ssl_no_verify", "value": "$ssl_no_verify$" ]} -
    - - -
    - -
    -
    - {[ "type": "text", "label": "'.tr('Server SMTP').'", "name": "server", "required": 1, "value": "$server$" ]} -
    - -
    - {[ "type": "number", "label": "'.tr('Porta SMTP').'", "name": "port", "required": 1, "class": "text-center", "decimals":"0", "max-value":"65535", "value": "$port$" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Sicurezza SMTP').'", "name": "encryption", "values": "list=\"\": \"'.tr('Nessuna').'\", \"tls\": \"TLS\", \"ssl\": \"SSL\"", "value": "$encryption$" ]} -
    -
    - -
    -
    - {[ "type": "text", "label": "'.tr('Username SMTP').'", "name": "username", "value": "$username$" ]} -
    - -
    - {[ "type": "password", "label": "'.tr('Password SMTP').'", "name": "password", "value": "$password$" ]} -
    - -
    - {[ "type": "number", "label": "'.tr('Timeout coda di invio (millisecondi)').'", "name": "timeout", "value": "$timeout$", "decimals": 1, "min-value": 100 ]} -
    -
    - -
    -
    - {[ "type": "textarea", "label": "'.tr('Note').'", "name": "note", "value": "$note$" ]} -
    -
    - -
    -
    '; - -// Elenco provider disponibili -$providers = OAuth2::$providers; -$elenco_provider = []; -foreach ($providers as $key => $provider) { - $elenco_provider[] = [ - 'id' => $key, - 'text' => $provider['name'], - 'help' => $provider['help'], - ]; -} - -echo ' - -
    -
    -

    '.tr('OAuth2').'

    -
    - -
    -
    -
    - - {[ "type": "select", "label": "'.tr('Provider account').'", "name": "provider", "value": "$provider$", "values": '.json_encode($elenco_provider).', "disabled": "'.intval(empty($account->provider)).'" ]} -
    - -
    - {[ "type": "checkbox", "label": "'.tr('Abilita OAuth2').'", "name": "abilita_oauth2", "value": "'.intval(!empty($account->provider)).'" ]} -
    - - - -
    - {[ "type": "text", "label": "'.tr('Client ID').'", "name": "client_id", "value": "$client_id$", "disabled": "'.intval(empty($account->provider)).'" ]} -
    - -
    - {[ "type": "text", "label": "'.tr('Client Secret').'", "name": "client_secret", "value": "$client_secret$", "disabled": "'.intval(empty($account->provider)).'" ]} -
    -
    -
    -
    -
    - -'; - -// Collegamenti diretti -// Template email collegati a questo account -$elementi = $dbo->fetchArray('SELECT `id`, `name` FROM `em_templates` WHERE `id_account` = '.prepare($id_record)); - -if (!empty($elementi)) { - echo ' -
    -
    -

    '.tr('Template email collegati: _NUM_', [ - '_NUM_' => count($elementi), - ]).'

    -
    - -
    -
    -
    -
      '; - - foreach ($elementi as $elemento) { - echo ' -
    • '.Modules::link('Template email', $elemento['id'], $elemento['name']).'
    • '; - } - - echo ' -
    -
    -
    '; -} else { - echo ' - - '.tr('Elimina').' -'; -} diff --git a/modules/smtp/init.php b/modules/smtp/init.php deleted file mode 100755 index 1903e0c0b..000000000 --- a/modules/smtp/init.php +++ /dev/null @@ -1,28 +0,0 @@ -. - */ - -use Modules\Emails\Account; - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $account = Account::find($id_record); - - $record = $dbo->fetchOne('SELECT * FROM em_accounts WHERE id='.prepare($id_record).' AND deleted_at IS NULL'); -} diff --git a/modules/spedizioni/actions.php b/modules/spedizioni/actions.php deleted file mode 100755 index 9fb925198..000000000 --- a/modules/spedizioni/actions.php +++ /dev/null @@ -1,82 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -switch (filter('op')) { - case 'update': - $descrizione = filter('descrizione'); - $vettore = post('esterno'); - - if ($dbo->fetchNum('SELECT * FROM `dt_spedizione` WHERE `descrizione`='.prepare($descrizione).' AND `id`!='.prepare($id_record)) == 0) { - $predefined = post('predefined'); - if (!empty($predefined)) { - $dbo->query('UPDATE dt_spedizione SET predefined = 0'); - } - - $dbo->update('dt_spedizione', [ - 'descrizione' => $descrizione, - 'predefined' => $predefined, - 'esterno' => $vettore, - ], ['id' => $id_record]); - - flash()->info(tr('Salvataggio completato!')); - } else { - flash()->error(tr("E' già presente una tipologia di _TYPE_ con la stessa descrizione", [ - '_TYPE_' => 'spedizione', - ])); - } - break; - - case 'add': - $descrizione = filter('descrizione'); - - if ($dbo->fetchNum('SELECT * FROM `dt_spedizione` WHERE `descrizione`='.prepare($descrizione)) == 0) { - $dbo->insert('dt_spedizione', [ - 'descrizione' => $descrizione, - ]); - $id_record = $dbo->lastInsertedID(); - - flash()->info(tr('Aggiunta nuova tipologia di _TYPE_', [ - '_TYPE_' => 'spedizione', - ])); - } else { - flash()->error(tr("E' già presente una tipologia di _TYPE_ con la stessa descrizione", [ - '_TYPE_' => 'spedizione', - ])); - } - - break; - - case 'delete': - $documenti = $dbo->fetchNum('SELECT id FROM dt_ddt WHERE idspedizione='.prepare($id_record).' - UNION SELECT id FROM co_documenti WHERE idspedizione='.prepare($id_record)); - - if (isset($id_record) && empty($documenti)) { - $dbo->query('DELETE FROM `dt_spedizione` WHERE `id`='.prepare($id_record)); - - flash()->info(tr('Tipologia di _TYPE_ eliminata con successo!', [ - '_TYPE_' => 'spedizione', - ])); - } else { - flash()->error(tr('Sono presenti dei documenti collegati a questo porto.')); - } - - break; -} diff --git a/modules/spedizioni/add.php b/modules/spedizioni/add.php deleted file mode 100755 index 3fc7a45c4..000000000 --- a/modules/spedizioni/add.php +++ /dev/null @@ -1,38 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1 ]} -
    -
    - - -
    -
    - -
    -
    -
    diff --git a/modules/spedizioni/edit.php b/modules/spedizioni/edit.php deleted file mode 100755 index 9dd222ceb..000000000 --- a/modules/spedizioni/edit.php +++ /dev/null @@ -1,68 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - - -
    -
    -

    -
    - -
    -
    -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1, "value": "$descrizione$" ]} -
    - -
    - {[ "type": "checkbox", "label": "", "name": "predefined", "value": "$predefined$", "help":"." ]} -
    - -
    - {[ "type": "checkbox", "label": "", "name": "esterno", "value": "$esterno$", "help":"." ]} -
    -
    -
    -
    - -
    - -fetchNum('SELECT id FROM dt_ddt WHERE idspedizione='.prepare($id_record).' -UNION SELECT id FROM co_documenti WHERE idspedizione='.prepare($id_record)); - -if (!empty($numero_documenti)) { - echo ' -
    - '.tr('Ci sono _NUM_ documenti collegati', [ - '_NUM_' => $numero_documenti, - ]).'. -
    '; -} -?> - - - - diff --git a/modules/spedizioni/init.php b/modules/spedizioni/init.php deleted file mode 100755 index 86d4bcb01..000000000 --- a/modules/spedizioni/init.php +++ /dev/null @@ -1,24 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT * FROM `dt_spedizione` WHERE id='.prepare($id_record)); -} diff --git a/modules/stampe/actions.php b/modules/stampe/actions.php deleted file mode 100755 index b0388437d..000000000 --- a/modules/stampe/actions.php +++ /dev/null @@ -1,41 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -switch (post('op')) { - case 'update': - if (!empty(intval(post('predefined'))) && !empty(post('module'))) { - $dbo->query('UPDATE zz_prints SET predefined = 0 WHERE zz_prints.id != '.prepare($id_record).' AND id_module = '.post('module')); - } - - $print->title = post('title'); - $print->filename = post('filename'); - $print->options = post('options'); - //$print->id_module = post('module'); - //$print->enabled = post('enabled'); - $print->order = post('order'); - $print->predefined = intval(post('predefined')); - - $print->save(); - - flash()->info(tr('Modifiche salvate correttamente')); - - break; -} diff --git a/modules/stampe/edit.php b/modules/stampe/edit.php deleted file mode 100755 index 0e93ecc2f..000000000 --- a/modules/stampe/edit.php +++ /dev/null @@ -1,123 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Models\PrintTemplate; - -?>
    - - - - - -
    -
    -

    -
    - -
    -
    - -
    - {[ "type": "text", "label": "", "name": "title", "required": 1, "value": "$title$" ]} -
    - -
    - {[ "type": "text", "label": "", "name": "filename", "required": 1, "value": "$filename$" ]} -
    - - - -
    - -
    - -
    - {[ "type": "select", "label": "", "name": "module", "required": 1, "values": "query=SELECT id, name AS descrizione FROM zz_modules WHERE ( enabled = 1 AND options != 'custom' ) OR id = ORDER BY name ASC", "value": "", "disabled": "1" ]} -
    - -
    - {[ "type": "checkbox", "label": "", "name": "enabled", "value": "$enabled$", "disabled": "1" ]} -
    - -
    - {[ "type": "number", "label": "", "name": "order", "required": 0, "value": "$order$", "decimals":0 ]} -
    - - where('id_module', $record['id_module'])->orderBy('id')->first())) { - $stampa_predefinita->name = 'Nessuna'; - } - ?> - -
    - {[ "type": "checkbox", "label": "", "help" : "name); ?>", "name": "predefined", "value": "$predefined$", "disabled": "" ]} -
    - -
    - -
    - -
    - {[ "type": "textarea", "label": "", "name": "options", "value": "$options$", "help": "" ]} -
    -
    -
    -
    -
    - -getPlaceholders($id_record); - -echo ' - -
    -
    -

    '.tr('Variabili').'

    -
    - -
    '; - -if (!empty($variables)) { - echo ' -

    '.tr('Puoi utilizzare le seguenti variabili per generare il nome del file').':

    -
      '; - - foreach ($variables as $variable => $value) { - echo ' -
    • {'.$variable.'}
    • '; - } - - echo ' -
    '; -} else { - echo ' -

    '.tr('Non sono state definite variabili da utilizzare nel template').'.

    '; -} - -echo ' -
    -
    - -
    '; - -?> diff --git a/modules/stampe/init.php b/modules/stampe/init.php deleted file mode 100755 index ce17fcaf8..000000000 --- a/modules/stampe/init.php +++ /dev/null @@ -1,27 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Models\PrintTemplate; - -if (isset($id_record)) { - $print = PrintTemplate::find($id_record); - $record = $print->toArray(); -} diff --git a/modules/stampe_contabili/edit.php b/modules/stampe_contabili/edit.php deleted file mode 100755 index 7e7f15b90..000000000 --- a/modules/stampe_contabili/edit.php +++ /dev/null @@ -1,77 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo ' - -
    - '.tr('Attenzione', [], ['upper']).': '.tr('le suddette stampe contabili non sono da considerarsi valide ai fini fiscali').'. -
    - -
    -
    -
    -
    -

    '.tr('Registri IVA').'

    -
    -
    - -
    - - - - - -
    -
    -
    - -
    -
    -
    -

    '.tr('Comunicazione dati fatture (ex-spesometro)
    dal _START_ al _END_', [ - '_START_' => Translator::dateToLocale($_SESSION['period_start']), - '_END_' => Translator::dateToLocale($_SESSION['period_end']), - ]).'

    -
    - -
    - '.Prints::getLink('Spesometro', $id_record, 'btn-primary col-md-5', '
    '.tr('Stampa dati fatture').'
    '.tr(' vendite e acquisti'), '|default| fa-2x', 'dir=uscita').' -
    -
    -
    - -
    -
    -
    -

    '.tr('Fatturato
    dal _START_ al _END_', [ - '_START_' => Translator::dateToLocale($_SESSION['period_start']), - '_END_' => Translator::dateToLocale($_SESSION['period_end']), - ]).'

    -
    - -
    - '.Prints::getLink('Fatturato', $id_record, 'btn-primary col-md-5', '
    '.tr('Stampa fatturato').'
    '.tr('in entrata'), '|default| fa-2x', 'dir=entrata').' - - '.Prints::getLink('Fatturato', $id_record, 'btn-primary col-md-5 col-md-push-2', '
    '.tr('Stampa fatturato').'
    '.tr('in uscita'), '|default| fa-2x', 'dir=uscita').' -
    -
    -
    -
    '; diff --git a/modules/stampe_contabili/stampe_contabili.php b/modules/stampe_contabili/stampe_contabili.php deleted file mode 100644 index 3ea773a9e..000000000 --- a/modules/stampe_contabili/stampe_contabili.php +++ /dev/null @@ -1,90 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$id_record = filter('id_record'); -$dir = filter('dir'); -$nome_stampa = filter('nome_stampa'); - -// Trovo id_print della stampa -$link = Prints::getHref($nome_stampa, $id_record); - -echo ' -
    - -
    '; - - if ($nome_stampa != 'Liquidazione IVA') { - echo ' -
    - {[ "type": "select", "label": "'.tr('Sezionale').'", "name": "id_sezionale", "required": "1", "values": "query=SELECT id AS id, name AS descrizione FROM zz_segments WHERE id_module = (SELECT id FROM zz_modules WHERE name = \''.(($dir == 'entrata') ? 'Fatture di vendita' : 'Fatture di acquisto').'\') AND is_fiscale = 1 UNION SELECT 0 AS id, \'Tutti i sezionali\' AS descrizione" ]} -
    '; - } - echo ' -
    - {[ "type": "date", "label": "'.tr('Data inizio').'", "required": "1", "name": "date_start", "value": "'.Translator::dateToLocale($_SESSION['period_start']).'" ]} -
    - -
    - {[ "type": "date", "label": "'.tr('Data fine').'", "required": "1", "name": "date_end", "value": "'.Translator::dateToLocale($_SESSION['period_end']).'" ]} -
    - -
    '; - -echo ' -
    -
    - {[ "type": "select", "label": "'.tr('Formato').'", "name": "format", "required": "1", "values": "list=\"A4\": \"'.tr('A4').'\", \"A3\": \"'.tr('A3').'\"", "value": "'.$_SESSION['stampe_contabili']['format'].'" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Orientamento').'", "name": "orientation", "required": "1", "values": "list=\"L\": \"'.tr('Orizzontale').'\", \"P\": \"'.tr('Verticale').'\"", "value": "'.$_SESSION['stampe_contabili']['orientation'].'" ]} -
    - -
    -

     

    - -
    -
    - -
    - -'; - -echo ' -'; diff --git a/modules/stati_contratto/actions.php b/modules/stati_contratto/actions.php deleted file mode 100755 index 21bf277cb..000000000 --- a/modules/stati_contratto/actions.php +++ /dev/null @@ -1,68 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -switch (post('op')) { - case 'update': - $dbo->update('co_staticontratti', [ - 'descrizione' => (count($dbo->fetchArray('SELECT descrizione FROM co_staticontratti WHERE descrizione = '.prepare(post('descrizione')))) > 0) ? $dbo->fetchOne('SELECT descrizione FROM co_staticontratti WHERE id ='.$id_record)['descrizione'] : post('descrizione'), - 'icona' => post('icona'), - 'is_completato' => post('is_completato') ?: null, - 'is_fatturabile' => post('is_fatturabile') ?: null, - 'is_pianificabile' => post('is_pianificabile') ?: null, - ], ['id' => $id_record]); - - flash()->info(tr('Informazioni salvate correttamente.')); - - break; - - case 'add': - $descrizione = post('descrizione'); - $icona = post('icona'); - $is_completato = post('is_completato') ?: null; - $is_fatturabile = post('is_fatturabile') ?: null; - $is_pianificabile = post('is_pianificabile') ?: null; - - //controlla descrizione che non sia duplicata - if (count($dbo->fetchArray('SELECT descrizione FROM co_staticontratti WHERE descrizione='.prepare($descrizione))) > 0) { - flash()->error(tr('Stato di contratto già esistente.')); - } else { - $query = 'INSERT INTO co_staticontratti(descrizione, icona, is_completato, is_fatturabile, is_pianificabile) VALUES ('.prepare($descrizione).', '.prepare($icona).', '.prepare($is_completato).', '.prepare($is_fatturabile).', '.prepare($is_pianificabile).' )'; - $dbo->query($query); - $id_record = $dbo->lastInsertedID(); - flash()->info(tr('Nuovo stato contratto aggiunto.')); - } - - break; - - case 'delete': - //scelgo se settare come eliminato o cancellare direttamente la riga se non è stato utilizzato nei contratti - if (count($dbo->fetchArray('SELECT id FROM co_contratti WHERE idstato='.prepare($id_record))) > 0) { - $query = 'UPDATE co_staticontratti SET deleted_at = NOW() WHERE can_delete = 1 AND id='.prepare($id_record); - } else { - $query = 'DELETE FROM co_staticontratti WHERE can_delete = 1 AND id='.prepare($id_record); - } - - $dbo->query($query); - - flash()->info(tr('Stato contratto eliminato.')); - - break; -} diff --git a/modules/stati_contratto/add.php b/modules/stati_contratto/add.php deleted file mode 100755 index a2ca44b1f..000000000 --- a/modules/stati_contratto/add.php +++ /dev/null @@ -1,55 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1 ]} -
    -
    - -
    -
    - {[ "type": "checkbox", "label": "", "name": "is_completato", "value": "$is_completato$", "help": "", "placeholder": "", "extra": "" ]} -
    - -
    - {[ "type": "checkbox", "label": "", "name": "is_pianificabile", "value": "$is_pianificabile$", "help": "", "placeholder": "", "extra": "" ]} -
    - -
    - {[ "type": "checkbox", "label": "", "name": "is_fatturabile", "value": "$is_fatturabile$", "help": "", "placeholder": "", "extra": "" ]} -
    -
    - {[ "type": "text", "label": "", "name": "icona", "required": 1, "class": "text-center", "value": "fa ", "extra": "" ]} -
    -
    - - -
    -
    - -
    -
    -
    diff --git a/modules/stati_contratto/edit.php b/modules/stati_contratto/edit.php deleted file mode 100755 index 0e7cee00f..000000000 --- a/modules/stati_contratto/edit.php +++ /dev/null @@ -1,79 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if ($record['can_delete']) { - $attr = ''; -} else { - $attr = 'readonly'; - echo '
    '.tr('Alcune impostazioni non possono essere modificate per questo stato.').'
    '; -} - -?> -
    - - - - -
    -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1, "value": "$descrizione$", "extra": "" ]} -
    - -
    - {[ "type": "text", "label": "", "name": "icona", "required": 1, "class": "text-center", "value": "$icona$", "extra": "", "icon-after": "' : ''; ?>" ]} -
    - -
    -
    -
    -

    -
    - -
    - {[ "type": "checkbox", "label": "", "name": "is_completato", "value": "$is_completato$", "help": "", "placeholder": "", "extra": "" ]} - {[ "type": "checkbox", "label": "", "name": "is_pianificabile", "value": "$is_pianificabile$", "help": "", "placeholder": "", "extra": "" ]} - {[ "type": "checkbox", "label": "", "name": "is_fatturabile", "value": "$is_fatturabile$", "help": "", "placeholder": "", "extra": "" ]} -
    -
    -
    -
    -
    - - - - '.tr('Ci sono _NUM_ contratti collegati', [ - '_NUM_' => $contratti, - ]).'. -'; -} - -if (!empty($record['can_delete'])) { - echo ' - - '.tr('Elimina').' -'; -} - -?> diff --git a/modules/stati_contratto/init.php b/modules/stati_contratto/init.php deleted file mode 100755 index a35ab34af..000000000 --- a/modules/stati_contratto/init.php +++ /dev/null @@ -1,24 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT * FROM co_staticontratti WHERE id='.prepare($id_record)); -} diff --git a/modules/stati_contratto/src/API/v1/StatiContratti.php b/modules/stati_contratto/src/API/v1/StatiContratti.php deleted file mode 100755 index 3309787a1..000000000 --- a/modules/stati_contratto/src/API/v1/StatiContratti.php +++ /dev/null @@ -1,45 +0,0 @@ -. - */ - -namespace Modules\StatiContratto\API\v1; - -use API\Interfaces\RetrieveInterface; -use API\Resource; - -class StatiContratti extends Resource implements RetrieveInterface -{ - public function retrieve($request) - { - $table = 'co_staticontratti'; - - $select = [ - '*', - ]; - - $where = $request['where']; - if (empty($where['deleted_at'])) { - $where['deleted_at'] = null; - } - - return [ - 'select' => $select, - 'table' => $table, - ]; - } -} diff --git a/modules/stati_intervento/actions.php b/modules/stati_intervento/actions.php deleted file mode 100755 index b7175e723..000000000 --- a/modules/stati_intervento/actions.php +++ /dev/null @@ -1,73 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -switch (post('op')) { - case 'update': - $dbo->update('in_statiintervento', [ - 'codice' => post('codice'), - 'descrizione' => post('descrizione'), - 'colore' => post('colore'), - 'is_completato' => post('is_completato'), - 'is_fatturabile' => post('is_fatturabile'), - 'notifica' => post('notifica'), - 'notifica_cliente' => post('notifica_cliente'), - 'notifica_tecnici' => post('notifica_tecnici'), - 'id_email' => post('email') ?: null, - 'destinatari' => post('destinatari'), - ], ['idstatointervento' => $id_record]); - - flash()->info(tr('Informazioni salvate correttamente.')); - - break; - - case 'add': - $codice = post('codice'); - $descrizione = post('descrizione'); - $colore = post('colore'); - - //controllo che il codice non sia duplicato - if (count($dbo->fetchArray('SELECT idstatointervento FROM in_statiintervento WHERE codice='.prepare($codice))) > 0) { - flash()->warning(tr('Attenzione: lo stato attività _COD_ risulta già esistente.', [ - '_COD_' => $codice, - ])); - } else { - $query = 'INSERT INTO in_statiintervento(codice, descrizione, colore) VALUES ('.prepare($codice).', '.prepare($descrizione).', '.prepare($colore).')'; - $dbo->query($query); - $id_record = $database->lastInsertedID(); - flash()->info(tr('Nuovo stato attività aggiunto.')); - } - - break; - - case 'delete': - //scelgo se settare come eliminato o cancellare direttamente la riga se non è stato utilizzato negli interventi - if (count($dbo->fetchArray('SELECT id FROM in_interventi WHERE idstatointervento='.prepare($id_record))) > 0) { - $query = 'UPDATE in_statiintervento SET deleted_at = NOW() WHERE idstatointervento='.prepare($id_record).' AND `can_delete`=1'; - } else { - $query = 'DELETE FROM in_statiintervento WHERE idstatointervento='.prepare($id_record).' AND `can_delete`=1'; - } - - $dbo->query($query); - - flash()->info(tr('Stato attività eliminato.')); - - break; -} diff --git a/modules/stati_intervento/add.php b/modules/stati_intervento/add.php deleted file mode 100755 index e49e65050..000000000 --- a/modules/stati_intervento/add.php +++ /dev/null @@ -1,56 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "codice", "maxlength": 10, "class": "alphanumeric-mask", "required": 1 ]} -
    - -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1 ]} -
    - -
    - {[ "type": "text", "label": "", "name": "colore", "id": "colore_", "required": 1, "class": "colorpicker text-center", "value": "#ffffff", "extra": "maxlength='7'", "icon-after": "
    " ]} -
    -
    - - -
    -
    - -
    -
    -
    - - diff --git a/modules/stati_intervento/edit.php b/modules/stati_intervento/edit.php deleted file mode 100755 index 3bbf9849e..000000000 --- a/modules/stati_intervento/edit.php +++ /dev/null @@ -1,132 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if ($record['can_delete']) { - $attr = ''; -} else { - $attr = 'readonly'; - echo '
    '.tr('Alcune impostazioni non possono essere modificate per questo stato attività.').'
    '; -} -?> -
    - - - - -
    -
    -
    -
    - {[ "type": "text", "label": "", "name": "codice", "value": "$codice$", "extra": "" ]} -
    - -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1, "value": "$descrizione$" ]} -
    - -
    - {[ "type": "text", "label": "", "name": "colore", "required": 1, "class": "colorpicker text-center", "value": "$colore$", "extra": "maxlength='7'", "icon-after": "
    " ]} -
    -
    - -
    - -
    - {[ "type": "checkbox", "label": "", "name": "notifica", "help": ".", "value": "$notifica$" ]} -
    - -
    - {[ "type": "select", "label": "", "name": "email", "value": "$id_email$", "values": "query=SELECT id, name AS descrizione FROM em_templates WHERE id_module = AND deleted_at IS NULL", "disabled": ]} -
    - - -
    -
    - -
    - {[ "type": "checkbox", "label": "", "name": "notifica_cliente", "help": ".", "value": "$notifica_cliente$" ]} -
    - -
    - {[ "type": "checkbox", "label": "", "name": "notifica_tecnici", "help": ".", "value": "$notifica_tecnici$" ]} -
    - -
    - {[ "type": "text", "label": "", "name": "destinatari", "value": "$destinatari$", "disabled": ]} -
    - -
    -
    - -
    -
    -
    -

    -
    - -
    - {[ "type": "checkbox", "label": "", "name": "is_completato", "value": "$is_completato$", "help": "", "placeholder": "", "extra": "" ]} - {[ "type": "checkbox", "label": "", "name": "is_fatturabile", "value": "$is_fatturabile$", "help": "", "placeholder": "", "extra": "" ]} -
    -
    -
    -
    -
    - - - - - - - diff --git a/modules/stati_intervento/init.php b/modules/stati_intervento/init.php deleted file mode 100755 index c1635575b..000000000 --- a/modules/stati_intervento/init.php +++ /dev/null @@ -1,24 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT * FROM in_statiintervento WHERE idstatointervento='.prepare($id_record)); -} diff --git a/modules/stati_intervento/src/API/v1/StatiInterventi.php b/modules/stati_intervento/src/API/v1/StatiInterventi.php deleted file mode 100755 index 7a49bcddd..000000000 --- a/modules/stati_intervento/src/API/v1/StatiInterventi.php +++ /dev/null @@ -1,49 +0,0 @@ -. - */ - -namespace Modules\StatiIntervento\API\v1; - -use API\Interfaces\RetrieveInterface; -use API\Resource; - -class StatiInterventi extends Resource implements RetrieveInterface -{ - public function retrieve($request) - { - $table = 'in_statiintervento'; - - $select = $request['select']; - if (empty($select)) { - $select = [ - '*', - 'id' => 'idstatointervento', - ]; - } - - $where = $request['where']; - if (empty($where['deleted_at'])) { - $where['deleted_at'] = null; - } - - return [ - 'select' => $select, - 'table' => $table, - ]; - } -} diff --git a/modules/stati_preventivo/actions.php b/modules/stati_preventivo/actions.php deleted file mode 100755 index 52cdb651e..000000000 --- a/modules/stati_preventivo/actions.php +++ /dev/null @@ -1,69 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -switch (post('op')) { - case 'update': - $dbo->update('co_statipreventivi', [ - 'descrizione' => (count($dbo->fetchArray('SELECT descrizione FROM co_statipreventivi WHERE descrizione = '.prepare(post('descrizione')))) > 0) ? $dbo->fetchOne('SELECT descrizione FROM co_statipreventivi WHERE id ='.$id_record)['descrizione'] : post('descrizione'), - 'icona' => post('icona'), - 'is_completato' => post('is_completato') ?: null, - 'is_fatturabile' => post('is_fatturabile') ?: null, - 'is_pianificabile' => post('is_pianificabile') ?: null, - 'is_revisionabile' => post('is_revisionabile') ?: null, - ], ['id' => $id_record]); - - flash()->info(tr('Informazioni salvate correttamente.')); - - break; - - case 'add': - $descrizione = post('descrizione'); - $icona = post('icona'); - $is_completato = post('is_completato') ?: null; - $is_fatturabile = post('is_fatturabile') ?: null; - $is_pianificabile = post('is_pianificabile') ?: null; - - //controlla descrizione che non sia duplicata - if (count($dbo->fetchArray('SELECT descrizione FROM co_statipreventivi WHERE descrizione='.prepare($descrizione))) > 0) { - flash()->error(tr('Stato di preventivo già esistente.')); - } else { - $query = 'INSERT INTO co_statipreventivi(descrizione, icona, is_completato, is_fatturabile, is_pianificabile) VALUES ('.prepare($descrizione).', '.prepare($icona).', '.prepare($is_completato).', '.prepare($is_fatturabile).', '.prepare($is_pianificabile).' )'; - $dbo->query($query); - $id_record = $dbo->lastInsertedID(); - flash()->info(tr('Nuovo stato preventivo aggiunto.')); - } - - break; - - case 'delete': - //scelgo se settare come eliminato o cancellare direttamente la riga se non è stato utilizzato nei preventivi - if (count($dbo->fetchArray('SELECT id FROM co_preventivi WHERE idstato='.prepare($id_record))) > 0) { - $query = 'UPDATE co_statipreventivi SET deleted_at = NOW() WHERE can_delete = 1 AND id='.prepare($id_record); - } else { - $query = 'DELETE FROM co_statipreventivi WHERE can_delete = 1 AND id='.prepare($id_record); - } - - $dbo->query($query); - - flash()->info(tr('Stato preventivo eliminato.')); - - break; -} diff --git a/modules/stati_preventivo/add.php b/modules/stati_preventivo/add.php deleted file mode 100755 index b99f8313f..000000000 --- a/modules/stati_preventivo/add.php +++ /dev/null @@ -1,55 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1 ]} -
    -
    - -
    -
    - {[ "type": "checkbox", "label": "", "name": "is_completato", "value": "$is_completato$", "help": "", "placeholder": "", "extra": "" ]} -
    - -
    - {[ "type": "checkbox", "label": "", "name": "is_pianificabile", "value": "$is_pianificabile$", "help": "", "placeholder": "", "extra": "" ]} -
    - -
    - {[ "type": "checkbox", "label": "", "name": "is_fatturabile", "value": "$is_fatturabile$", "help": "", "placeholder": "", "extra": "" ]} -
    -
    - {[ "type": "text", "label": "", "name": "icona", "required": 1, "class": "text-center", "value": "fa ", "extra": "" ]} -
    -
    - - -
    -
    - -
    -
    -
    diff --git a/modules/stati_preventivo/edit.php b/modules/stati_preventivo/edit.php deleted file mode 100755 index 071b83e0c..000000000 --- a/modules/stati_preventivo/edit.php +++ /dev/null @@ -1,81 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if ($record['can_delete']) { - $attr = ''; -} else { - $attr = 'readonly'; - echo '
    '.tr('Alcune impostazioni non possono essere modificate per questo stato.').'
    '; -} - -?> -
    - - - - -
    -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1, "value": "$descrizione$", "extra": "" ]} -
    - -
    - {[ "type": "text", "label": "", "name": "icona", "required": 1, "class": "text-center", "value": "$icona$", "extra": "", "icon-after": "' : ''; ?>" ]} -
    - -
    -
    -
    -

    -
    - -
    - {[ "type": "checkbox", "label": "", "name": "is_pianificabile", "value": "$is_pianificabile$", "help": "", "placeholder": "", "extra": "" ]} - {[ "type": "checkbox", "label": "", "name": "is_fatturabile", "value": "$is_fatturabile$", "help": "", "placeholder": "", "extra": "" ]} - {[ "type": "checkbox", "label": "", "name": "is_completato", "value": "$is_completato$", "help": "", "placeholder": "", "extra": "" ]} - {[ "type": "checkbox", "label": "", "name": "is_revisionabile", "value": "$is_revisionabile$", "help": "", "placeholder": "", "extra": "" ]} -
    -
    -
    -
    - -
    - - - - '.tr('Ci sono _NUM_ preventivi collegati', [ - '_NUM_' => $preventivi, - ]).'. -'; -} - -if (!empty($record['can_delete'])) { - echo ' - - '.tr('Elimina').' -'; -} - -?> diff --git a/modules/stati_preventivo/init.php b/modules/stati_preventivo/init.php deleted file mode 100755 index 2eef0d824..000000000 --- a/modules/stati_preventivo/init.php +++ /dev/null @@ -1,24 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT * FROM co_statipreventivi WHERE id='.prepare($id_record)); -} diff --git a/modules/stati_preventivo/src/API/v1/StatiPreventivi.php b/modules/stati_preventivo/src/API/v1/StatiPreventivi.php deleted file mode 100755 index 99d2e6681..000000000 --- a/modules/stati_preventivo/src/API/v1/StatiPreventivi.php +++ /dev/null @@ -1,45 +0,0 @@ -. - */ - -namespace Modules\StatiPreventivo\API\v1; - -use API\Interfaces\RetrieveInterface; -use API\Resource; - -class StatiPreventivi extends Resource implements RetrieveInterface -{ - public function retrieve($request) - { - $table = 'co_statipreventivi'; - - $select = [ - '*', - ]; - - $where = $request['where']; - if (empty($where['deleted_at'])) { - $where['deleted_at'] = null; - } - - return [ - 'select' => $select, - 'table' => $table, - ]; - } -} diff --git a/modules/statistiche/actions.php b/modules/statistiche/actions.php deleted file mode 100755 index 9ffe2b9ef..000000000 --- a/modules/statistiche/actions.php +++ /dev/null @@ -1,55 +0,0 @@ -. - */ - -use Modules\Statistiche\Stats; - -include_once __DIR__.'/../../core.php'; - -$calendar_id = filter('calendar_id'); -$start = filter('start'); -$end = filter('end'); - -switch (filter('op')) { - case 'fatturato': - $results = $dbo->fetchArray("SELECT ROUND(SUM(IF(reversed=1, -(co_righe_documenti.subtotale - co_righe_documenti.sconto), (co_righe_documenti.subtotale - co_righe_documenti.sconto))), 2) AS result, YEAR(co_documenti.data) AS year, MONTH(co_documenti.data) AS month FROM co_documenti INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id INNER JOIN co_righe_documenti ON co_righe_documenti.iddocumento=co_documenti.id INNER JOIN zz_segments ON co_documenti.id_segment=zz_segments.id WHERE co_tipidocumento.dir='entrata' AND co_tipidocumento.descrizione!='Bozza' AND co_documenti.data BETWEEN ".prepare($start).' AND '.prepare($end).' AND is_fiscale=1 GROUP BY YEAR(co_documenti.data), MONTH(co_documenti.data) ORDER BY YEAR(co_documenti.data) ASC, MONTH(co_documenti.data) ASC'); - - $results = Stats::monthly($results, $start, $end); - - echo json_encode([ - 'label' => tr('Fatturato').' - '.tr('Periodo _NUM_', [ - '_NUM_' => $calendar_id, - ]), - 'results' => $results, - ]); - - break; - case 'acquisti': - $results = $dbo->fetchArray("SELECT ROUND(SUM(IF(reversed=1, -(co_righe_documenti.subtotale - co_righe_documenti.sconto), (co_righe_documenti.subtotale - co_righe_documenti.sconto))), 2) AS result, YEAR(co_documenti.data) AS year, MONTH(co_documenti.data) AS month FROM co_documenti INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id INNER JOIN co_righe_documenti ON co_righe_documenti.iddocumento=co_documenti.id INNER JOIN zz_segments ON co_documenti.id_segment=zz_segments.id WHERE co_tipidocumento.dir='uscita' AND co_tipidocumento.descrizione!='Bozza' AND co_documenti.data BETWEEN ".prepare($start).' AND '.prepare($end).' AND is_fiscale=1 GROUP BY YEAR(co_documenti.data), MONTH(co_documenti.data) ORDER BY YEAR(co_documenti.data) ASC, MONTH(co_documenti.data) ASC'); - - $results = Stats::monthly($results, $start, $end); - - echo json_encode([ - 'label' => tr('Acquisti').' - '.tr('Periodo _NUM_', [ - '_NUM_' => $calendar_id, - ]), - 'results' => $results, - ]); - - break; -} diff --git a/modules/statistiche/edit.php b/modules/statistiche/edit.php deleted file mode 100755 index be1590398..000000000 --- a/modules/statistiche/edit.php +++ /dev/null @@ -1,444 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Statistiche\Stats; - -echo ' -'; - -$start = $_SESSION['period_start']; -$end = $_SESSION['period_end']; - -echo ' -
    -
    -

    - '.tr('Periodi temporali').' -

    -
    - - -
    -
    - -
    - -
    -
    '; - -// Fatturato -echo ' -
    -
    -

    '.tr('Vendite e acquisti').'

    - -
    - -
    -
    - -
    '; - -echo ' - - - - -'; - -// Script per il grafico del fatturato -echo ' -'; - -// Clienti top -$clienti = $dbo->fetchArray('SELECT SUM(IF(reversed=1, -(co_righe_documenti.subtotale - co_righe_documenti.sconto), (co_righe_documenti.subtotale - co_righe_documenti.sconto))) AS totale, (SELECT COUNT(*) FROM co_documenti WHERE co_documenti.idanagrafica =an_anagrafiche.idanagrafica AND co_documenti.data BETWEEN '.prepare($start).' AND '.prepare($end).") AS qta, an_anagrafiche.idanagrafica, an_anagrafiche.ragione_sociale FROM co_documenti INNER JOIN co_statidocumento ON co_statidocumento.id = co_documenti.idstatodocumento INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id INNER JOIN co_righe_documenti ON co_righe_documenti.iddocumento=co_documenti.id INNER JOIN an_anagrafiche ON an_anagrafiche.idanagrafica=co_documenti.idanagrafica WHERE co_tipidocumento.dir='entrata' AND (co_statidocumento.descrizione = 'Pagato' OR co_statidocumento.descrizione = 'Parzialmente pagato' OR co_statidocumento.descrizione = 'Emessa' ) AND co_documenti.data BETWEEN ".prepare($start).' AND '.prepare($end).' GROUP BY an_anagrafiche.idanagrafica ORDER BY SUM(subtotale - co_righe_documenti.sconto) DESC LIMIT 20'); - -$totale = $dbo->fetchArray("SELECT SUM(IF(reversed=1, -(co_righe_documenti.subtotale - co_righe_documenti.sconto), (co_righe_documenti.subtotale - co_righe_documenti.sconto))) AS totale FROM co_documenti INNER JOIN co_statidocumento ON co_statidocumento.id = co_documenti.idstatodocumento INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id INNER JOIN co_righe_documenti ON co_righe_documenti.iddocumento=co_documenti.id WHERE (co_statidocumento.descrizione = 'Pagato' OR co_statidocumento.descrizione = 'Parzialmente pagato' OR co_statidocumento.descrizione = 'Emessa' ) AND co_tipidocumento.dir='entrata' AND co_documenti.data BETWEEN ".prepare($start).' AND '.prepare($end)); - -echo ' -
    -
    -
    -
    -

    '.tr('I 20 clienti TOP').'

    - -
    - -
    -
    -
    '; -if (!empty($clienti)) { - echo ' - - - - - - - '; - foreach ($clienti as $cliente) { - echo ' - - - - - - '; - } - echo ' -
    '.tr('Ragione sociale').''.tr('Num. fatture').''.tr('Totale').''.tr('Percentuale').' 
    '.Modules::link('Anagrafiche', $cliente['idanagrafica'], $cliente['ragione_sociale']).''.intval($cliente['qta']).''.moneyFormat($cliente['totale'], 2).''.Translator::numberToLocale($cliente['totale'] * 100 / $totale[0]['totale'], 2).' %
    '; -} else { - echo ' -

    '.tr('Nessuna vendita').'...

    '; -} -echo ' - -
    -
    -
    '; - -// Articoli più venduti -$articoli = $dbo->fetchArray("SELECT SUM(IF(reversed=1, -co_righe_documenti.qta, co_righe_documenti.qta)) AS qta, SUM(IF(reversed=1, -(co_righe_documenti.subtotale - co_righe_documenti.sconto), (co_righe_documenti.subtotale - co_righe_documenti.sconto))) AS totale, mg_articoli.id, mg_articoli.codice, mg_articoli.descrizione, mg_articoli.um FROM co_documenti INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id INNER JOIN co_righe_documenti ON co_righe_documenti.iddocumento=co_documenti.id INNER JOIN mg_articoli ON mg_articoli.id=co_righe_documenti.idarticolo WHERE co_tipidocumento.dir='entrata' AND co_documenti.data BETWEEN ".prepare($start).' AND '.prepare($end).' GROUP BY co_righe_documenti.idarticolo ORDER BY SUM(co_righe_documenti.qta) DESC LIMIT 20'); - -$totale = $dbo->fetchArray("SELECT SUM(IF(reversed=1, -co_righe_documenti.qta, co_righe_documenti.qta)) AS totale_qta, SUM(IF(reversed=1, -(co_righe_documenti.subtotale - co_righe_documenti.sconto), (co_righe_documenti.subtotale - co_righe_documenti.sconto))) AS totale FROM co_documenti INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id INNER JOIN co_righe_documenti ON co_righe_documenti.iddocumento=co_documenti.id INNER JOIN mg_articoli ON mg_articoli.id=co_righe_documenti.idarticolo WHERE co_tipidocumento.dir='entrata' AND co_documenti.data BETWEEN ".prepare($start).' AND '.prepare($end)); - -echo ' -
    -
    -
    -

    '.tr('I 20 articoli più venduti').'

    - -
    - -
    -
    -
    '; -if (!empty($articoli)) { - echo ' - - - - - - - '; - foreach ($articoli as $articolo) { - echo ' - - - - - - '; - } - echo ' -
    '.tr('Articolo').''.tr('Q.tà').''.tr('Percentuale').' '.tr('Totale').'
    '.Modules::link('Articoli', $articolo['id'], $articolo['codice'].' - '.$articolo['descrizione']).''.Translator::numberToLocale($articolo['qta'], 'qta').' '.$articolo['um'].''.Translator::numberToLocale($articolo['qta'] * 100 / $totale[0]['totale_qta'], 2).' %'.moneyFormat($articolo['totale'], 2).'
    '; -} else { - echo ' -

    '.tr('Nessun articolo è stato venduto').'...

    '; -} -echo ' - -
    -
    -
    -
    '; - -// Interventi per tipologia -$tipi = $dbo->fetchArray('SELECT * FROM `in_tipiintervento`'); - -$dataset = ''; -foreach ($tipi as $tipo) { - $interventi = $dbo->fetchArray('SELECT COUNT(*) AS result, YEAR(in_interventi.data_richiesta) AS year, MONTH(in_interventi.data_richiesta) AS month FROM in_interventi WHERE in_interventi.idtipointervento = '.prepare($tipo['idtipointervento']).' AND in_interventi.data_richiesta BETWEEN '.prepare($start).' AND '.prepare($end).' GROUP BY YEAR(in_interventi.data_richiesta), MONTH(in_interventi.data_richiesta) ORDER BY YEAR(in_interventi.data_richiesta) ASC, MONTH(in_interventi.data_richiesta) ASC'); - - $interventi = Stats::monthly($interventi, $start, $end); - - //Random color - $background = '#'.dechex(rand(256, 16777215)); - - $dataset .= '{ - label: "'.$tipo['descrizione'].'", - backgroundColor: "'.$background.'", - data: [ - '.implode(',', array_column($interventi, 'result')).' - ] - },'; -} - -echo ' -
    -
    -

    '.tr('Interventi per tipologia').'

    - -
    - -
    -
    - -
    '; - -// Script per il grafico degli interventi per tipologia -echo ' -'; - -// Interventi per tecnico -$tecnici = $dbo->fetchArray("SELECT an_anagrafiche.idanagrafica AS id, ragione_sociale, colore FROM an_anagrafiche -INNER JOIN -an_tipianagrafiche_anagrafiche ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica -INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica -LEFT OUTER JOIN in_interventi_tecnici ON in_interventi_tecnici.idtecnico = an_anagrafiche.idanagrafica -INNER JOIN in_interventi ON in_interventi_tecnici.idintervento=in_interventi.id -WHERE an_anagrafiche.deleted_at IS NULL AND an_tipianagrafiche.descrizione='Tecnico' -GROUP BY an_anagrafiche.idanagrafica -ORDER BY ragione_sociale ASC"); - -$dataset = ''; -foreach ($tecnici as $tecnico) { - $sessioni = $dbo->fetchArray('SELECT SUM(in_interventi_tecnici.ore) AS result, CONCAT(CAST(SUM(in_interventi_tecnici.ore) AS char(20)),\' ore\') AS ore_lavorate, YEAR(in_interventi_tecnici.orario_inizio) AS year, MONTH(in_interventi_tecnici.orario_inizio) AS month FROM in_interventi_tecnici INNER JOIN `in_interventi` ON `in_interventi_tecnici`.`idintervento` = `in_interventi`.`id` LEFT JOIN `in_statiintervento` ON `in_interventi`.`idstatointervento`=`in_statiintervento`.`idstatointervento` WHERE in_interventi_tecnici.idtecnico = '.prepare($tecnico['id']).' AND in_interventi_tecnici.orario_inizio BETWEEN '.prepare($start).' AND '.prepare($end).' AND `in_statiintervento`.`is_completato` = 1 GROUP BY YEAR(in_interventi_tecnici.orario_inizio), MONTH(in_interventi_tecnici.orario_inizio) ORDER BY YEAR(in_interventi_tecnici.orario_inizio) ASC, MONTH(in_interventi_tecnici.orario_inizio) ASC'); - - $sessioni = Stats::monthly($sessioni, $start, $end); - - //Colore tecnico - $background = strtoupper($tecnico['colore']); - if (empty($background) || $background == '#FFFFFF') { - //Random color - $background = '#'.dechex(rand(256, 16777215)); - } - - $dataset .= '{ - label: "'.$tecnico['ragione_sociale'].'", - backgroundColor: "'.$background.'", - data: [ - '.implode(',', array_column($sessioni, 'result')).' - ], - - },'; -} - -echo ' -
    -
    -

    '.tr('Ore di lavoro per tecnico').'

    - -
    - -
    -
    - -
    '; - -// Script per il grafico ore interventi per tecnico -echo ' -'; diff --git a/modules/statistiche/js/calendar.js b/modules/statistiche/js/calendar.js deleted file mode 100755 index e2fc239db..000000000 --- a/modules/statistiche/js/calendar.js +++ /dev/null @@ -1,43 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -class Calendar { - constructor(info, id){ - this.info = info; - this.id = id; - - this.elements = new Array(); - } - - addElement(object){ - this.elements.push(object); - } - - update(start, end) { - this.elements.forEach(function (element) { - element.update(start, end); - }); - } - - remove() { - this.elements.forEach(function (element) { - element.remove(); - }); - } - -} diff --git a/modules/statistiche/js/functions.js b/modules/statistiche/js/functions.js deleted file mode 100755 index 57c28f360..000000000 --- a/modules/statistiche/js/functions.js +++ /dev/null @@ -1,80 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -var manager = manager ? manager : undefined; - -function remove_calendar(button) { - var name = $(button).parent().find("input").attr("id"); - - if (manager.remove(name)) { - $("#group-" + name).remove(); - } else { - swal({ - title: globals.translations.singleCalendar, - type: "info", - }); - } -} - -function add_calendar() { - var last = $("#calendars").find("input").last().attr("id"); - var last_id = last ? last.split("-")[1] : 0; - last_id = parseInt(last_id) + 1; - - var name = "calendar-" + last_id; - - $("#calendars").append(`
    -
    - ` + last_id + ` - - - - -
    -
    -
    `); - - start_complete_calendar("#" + name, function (start, end) { - var name = $(this.element).attr("id"); - var start = start.format("YYYY-MM-DD"); - var end = end.format("YYYY-MM-DD"); - - manager.update(name, start, end); - }); - - // Inizializzazone calendario - var calendar = manager.add(last_id, name); - - init_calendar(calendar); - - manager.init(name); -} - -function get_months(start, end) { - var months = []; - while (start.isSameOrBefore(end, "month")) { - string = start.format("MMMM YYYY"); - - months.push(string.charAt(0).toUpperCase() + string.slice(1)); - - start.add(1, "months"); - } - - return months; -} - diff --git a/modules/statistiche/js/init.js b/modules/statistiche/js/init.js deleted file mode 100755 index 236c53937..000000000 --- a/modules/statistiche/js/init.js +++ /dev/null @@ -1,29 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -// Inzializzazione manager standard -var info = { - url: local_url, - id_module: globals.id_module, - id_record: globals.id_record, - start_date: globals.start_date, - end_date: globals.end_date, -}; - -var manager = new Manager(info); -add_calendar(); diff --git a/modules/statistiche/js/manager.js b/modules/statistiche/js/manager.js deleted file mode 100755 index f985a83d2..000000000 --- a/modules/statistiche/js/manager.js +++ /dev/null @@ -1,56 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -class Manager { - constructor(info) { - this.info = info; - - this.calendars = {}; - } - - remove(name) { - if (Object.keys(this.calendars).length > 1) { - this.calendars[name].remove(); - delete this.calendars[name]; - - return true; - } - - return false; - } - - add(id, name) { - var calendar = new Calendar(this.info, id); - this.calendars[name] = calendar; - - return calendar; - } - - init(name) { - var calendar = this.calendars[name]; - - var start = this.info.start_date; - var end = this.info.end_date; - - calendar.update(start, end); - } - - update(name, start, end){ - this.calendars[name].update(start, end); - } -} diff --git a/modules/statistiche/js/stat.js b/modules/statistiche/js/stat.js deleted file mode 100755 index 85d222800..000000000 --- a/modules/statistiche/js/stat.js +++ /dev/null @@ -1,54 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -class Stat { - constructor(calendar, file, data = {}){ - this.calendar = calendar; - - this.file = file; - this.data = data; - - this.data.id_module = this.calendar.info.id_module; - this.data.id_record = this.calendar.info.id_record; - this.data.calendar_id = this.calendar.id; - } - - getCalendarID(){ - return this.calendar.id; - } - - getData(start, end, callback) { - var data = JSON.parse(JSON.stringify(this.data)); - - data.start = start; - data.end = end; - - $.ajax({ - url: this.calendar.info.url + "/" + this.file, - type: "get", - data: data, - success: function(data){ - callback(data) - } - }); - } - - add(start, end){} - update(start, end){} - remove(){} -} diff --git a/modules/statistiche/js/stats/line_chart.js b/modules/statistiche/js/stats/line_chart.js deleted file mode 100755 index 33aebbd98..000000000 --- a/modules/statistiche/js/stats/line_chart.js +++ /dev/null @@ -1,113 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -class LineChart extends Stat { - constructor(calendar, file, data = {}, chart){ - super(calendar, file, data); - - this.chart = chart; - } - - add(start, end, color = null) { - var calendar_id = this.calendar.id; - var chart = this.chart; - - var color = color ? color : this.getRandomColor(); - - this.getData(start, end, function(response) { - var data = JSON.parse(response); - - var label = data.label; - - var dataset = []; - var labels = []; - - data.results.forEach(function (item) { - dataset.push(item.result); - - var date = moment().month(item.month - 1).year(item.year); - labels.push(date.format("MMMM YYYY")); - }); - - while (chart.data.labels.length < data.results.length) { - chart.data.labels.push(""); - } - - chart.data.datasets.push({ - calendar_id: calendar_id, - label: label, - backgroundColor: color + '55', - borderColor: color, - data: dataset, - labels: labels, - fill: true, - }); - - chart.update(); - }); - } - - update(start, end) { - var color = this.remove(); - - this.add(start, end, color); - } - - getRandomColor() { - var letters = '0123456789ABCDEF'; - var color = '#'; - for (var i = 0; i < 6; i++) { - color += letters[Math.floor(Math.random() * 16)]; - } - return color; - } - - remove() { - var chart = this.chart; - var calendar_id = this.calendar.id; - - var max_length = 0; - var dataset_index = undefined; - - chart.data.datasets.forEach(function (item, index) { - if(item.calendar_id == calendar_id) { - dataset_index = index; - } else { - if (item.data.length > max_length) { - max_length = item.data.length; - } - } - }); - - var color = null; - if (dataset_index != undefined) { - color = chart.data.datasets[dataset_index].backgroundColor; - - chart.data.datasets.splice(dataset_index, 1); - chart.data.labels.splice(dataset_index, 1); - } - - while (chart.data.labels.length > max_length) { - chart.data.labels.pop(""); - } - - chart.update(); - - return color; - } -} diff --git a/modules/statistiche/js/stats/table.js b/modules/statistiche/js/stats/table.js deleted file mode 100755 index 22291d258..000000000 --- a/modules/statistiche/js/stats/table.js +++ /dev/null @@ -1,51 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -class Table extends Stat { - constructor(calendar, file, data = {}, id){ - super(calendar, file, data); - - this.id = id; - } - - add(start, end) { - var id = this.id; - var calendar_id = this.calendar.id; - - this.getData(start, end, function(data) { - var row = $(id).find("#row-" + calendar_id); - - if (!row.length) { - $(id).append(data); - } else { - row.after(data); - row.remove(); - } - - $(id).find("#row-" + calendar_id).effect("highlight", {}, 3000); - }); - } - - update(start, end) { - this.add(start, end) - } - - remove() { - $(this.id).find("#row-" + this.calendar.id).remove(); - } -} diff --git a/modules/statistiche/js/stats/widget.js b/modules/statistiche/js/stats/widget.js deleted file mode 100755 index 94f7baf66..000000000 --- a/modules/statistiche/js/stats/widget.js +++ /dev/null @@ -1,21 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -class Widget extends Table { - -} diff --git a/modules/statistiche/src/Stats.php b/modules/statistiche/src/Stats.php deleted file mode 100755 index 5644bf459..000000000 --- a/modules/statistiche/src/Stats.php +++ /dev/null @@ -1,62 +0,0 @@ -. - */ - -namespace Modules\Statistiche; - -use ArrayObject; -use DateTime; - -class Stats -{ - public static function monthly($original, $start, $end) - { - // Copia dei dati - $array = new ArrayObject($original); - $data = $array->getArrayCopy(); - - // Ordinamento - array_multisort(array_column($data, 'year'), SORT_ASC, - array_column($data, 'month'), SORT_ASC, - $data); - - // Differenza delle date in mesi - $d1 = new DateTime($start); - $d2 = new DateTime($end); - $count = $d1->diff($d2)->m + ($d1->diff($d2)->y * 12) + 1; - - $year = $d1->format('Y'); - $month = intval($d1->format('m')) - 1; - for ($i = 0; $i < $count; ++$i) { - $year = $month >= 12 ? $year + 1 : $year; - $month = $month % 12; - - if (!isset($data[$i]) || intval($data[$i]['month']) != $month + 1) { - array_splice($data, $i, 0, [[ - 'result' => 0, - 'year' => $year, - 'month' => $month + 1, - ]]); - } - - ++$month; - } - - return $data; - } -} diff --git a/modules/stato_email/actions.php b/modules/stato_email/actions.php deleted file mode 100755 index 6f1e6bba6..000000000 --- a/modules/stato_email/actions.php +++ /dev/null @@ -1,52 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; -use Notifications\EmailNotification; - -switch (post('op')) { - case 'send': - $email = EmailNotification::build($mail); - - // Invio mail - if ($email->send()) { - $mail->sent_at = date('Y-m-d H:i:s'); - $mail->save(); - flash()->info(tr('Email inviata.')); - } else { - flash()->error(tr('Errore durante invio email.')); - } - - break; - - case 'retry': - $mail->attempt = 0; - - $mail->save(); - break; - - case 'delete': - if (empty($mail->sent_at)) { - $mail->delete(); - - flash()->info(tr('Email rimossa dalla coda di invio.')); - } - - break; -} diff --git a/modules/stato_email/bulk.php b/modules/stato_email/bulk.php deleted file mode 100644 index 2e0a30114..000000000 --- a/modules/stato_email/bulk.php +++ /dev/null @@ -1,55 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Emails\Mail; - -switch (post('op')) { - case 'delete-bulk': - $i = 0; - foreach ($id_records as $id_record) { - if (isset($id_record)) { - $mail = Mail::find($id_record); - if (empty($mail->sent_at)) { - $mail->delete(); - ++$i; - } - } - } - - if ($i > 0) { - flash()->info(tr('Email rimosse dalla coda di invio')); - } else { - flash()->warning(tr('Nessuna email rimossa dalla coda di invio')); - } - - break; -} - -$operations['delete-bulk'] = [ - 'text' => ' '.tr('Elimina email selezionate e non ancora inviate').'', - 'data' => [ - 'msg' => tr('Vuoi davvero eliminare dalla coda di invio le email selezionate?'), - 'button' => tr('Procedi'), - 'class' => 'btn btn-lg btn-danger', - ], -]; - -return $operations; diff --git a/modules/stato_email/buttons.php b/modules/stato_email/buttons.php deleted file mode 100644 index fe42a48a6..000000000 --- a/modules/stato_email/buttons.php +++ /dev/null @@ -1,40 +0,0 @@ -. - */ - -if (($record['attempt'] >= 10) && empty($record['sent_at'])) { - echo ' - - '.tr('Email fallita il: ').Translator::timestampToLocale($record['failed_at']).' -  '; - - echo ' - - '.tr('Rimetti in coda').' - '; - - echo ' - - '.tr('Invia immeditamente').' - '; -} elseif (!empty($record['sent_at'])) { - echo ' - - '.tr('Email inviata il: ').Translator::timestampToLocale($record['sent_at']).' - '; -} diff --git a/modules/stato_email/edit.php b/modules/stato_email/edit.php deleted file mode 100755 index 29ddea8bd..000000000 --- a/modules/stato_email/edit.php +++ /dev/null @@ -1,174 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo ' - -
    -
    -

    '.tr('Informazioni').'

    -
    - -
    - -
    -
    -

    '.tr('Template').'

    - '.Modules::link('Template email', $mail->template->id, $mail->template->name).' -
    - -
    -

    '.tr('Utente').'

    - '.Modules::link('Anagrafiche', $mail->user->anagrafica->id, $mail->user->nome_completo).' -
    - -
    -

    '.tr('Data di invio').'

    - '.($mail->sent_at ? timestampFormat($mail->sent_at) : '-').' -
    - -
    -

    '.tr('Ultimo tentativo').'

    - '.($mail->processing_at ? timestampFormat($mail->processing_at) : '-').' ('.tr('totale: _TOT_', [ - '_TOT_' => $mail->attempt, - ]).') -
    -
    - -
    -
    '; - -echo ' -

    '.tr('Account mittente').'

    -
    -'.$mail->template->account->from_name.' <'.$mail->template->account->from_address.'> - '.Modules::link('Account email', $mail->template->account->id, $mail->template->account->name).' -
    '; - -echo ' -

    '.tr('Oggetto').'

    -
    -'.$mail->subject.' -
    '; - -// Destinatari -$receivers = $mail->receivers; -echo ' -
    -
    -

    '.tr('Destinatari').'

    - - - - - - - - - '; - -foreach ($receivers as $receiver) { - echo ' - - - - '; -} - -echo ' - -
    '.tr('Tipo').''.tr('Indirizzo').'
    '.$receiver->type.''.$receiver->address.'
    -
    '; - -// Stampe -$prints = $mail->prints; -echo ' -
    -

    '.tr('Stampe').'

    - - - - - - - - - '; - -foreach ($prints as $print) { - echo ' - - - - '; -} - -echo ' - -
    '.tr('Stampa').''.tr('Nome').'
    - '.$print->name.' - '.$print->pivot->name.'
    -
    '; - -// Stampe -$uploads = $mail->uploads; -echo ' -
    -

    '.tr('Allegati').'

    - - - - - - - - - '; - -foreach ($uploads as $upload) { - echo ' - - - - '; -} - -echo ' - -
    '.tr('Allegato').''.tr('Nome').'
    - '.$upload->name.' - '.$upload->pivot->name.'
    -
    '; - -echo ' -
    '; - -echo ' -

    '.tr('Contenuto').'

    -
    - '.$mail->content.' -
    '; - -//Posso eliminare l'email solo se questa non è già stata inviata -if (empty($mail->sent_at)) { - echo ' - - '.tr('Elimina').' -'; -} diff --git a/modules/stato_email/init.php b/modules/stato_email/init.php deleted file mode 100755 index 17412c5e8..000000000 --- a/modules/stato_email/init.php +++ /dev/null @@ -1,28 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Emails\Mail; - -if (isset($id_record)) { - $mail = Mail::find($id_record); - - $record = $mail->toArray(); -} diff --git a/modules/stato_servizi/actions.php b/modules/stato_servizi/actions.php deleted file mode 100755 index b23573a4d..000000000 --- a/modules/stato_servizi/actions.php +++ /dev/null @@ -1,197 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use API\Services; -use Models\Cache; -use Util\FileSystem; - -$id = post('id'); - -switch (filter('op')) { - case 'uninstall': - if (!empty($id)) { - // Leggo l'id del modulo - $rs = $dbo->fetchArray('SELECT id, name, directory FROM zz_modules WHERE id='.prepare($id).' AND `default`=0'); - $modulo = $rs[0]['title']; - $module_dir = $rs[0]['directory']; - - if (count($rs) == 1) { - // Elimino il modulo dal menu - $dbo->query('DELETE FROM zz_modules WHERE id='.prepare($id).' OR parent='.prepare($id)); - - $uninstall_script = base_dir().'/modules/'.$module_dir.'/update/uninstall.php'; - - if (file_exists($uninstall_script)) { - include_once $uninstall_script; - } - - delete(base_dir().'/modules/'.$module_dir.'/'); - - flash()->info(tr('Modulo "_MODULE_" disinstallato!', [ - '_MODULE_' => $modulo, - ])); - } - } - - break; - - case 'disable': - $dbo->query('UPDATE `zz_modules` SET `enabled` = 0 WHERE (`id` = '.prepare($id).' OR `parent` = '.prepare($id).') AND `id` != '.prepare(Modules::get('Stato dei servizi')['id'])); - - flash()->info(tr('Modulo "_MODULE_" disabilitato!', [ - '_MODULE_' => Modules::get($id)['title'], - ])); - - break; - - case 'enable': - $dbo->query('UPDATE `zz_modules` SET `enabled` = 1 WHERE `id` = '.prepare($id).' OR `parent` = '.prepare($id)); - - flash()->info(tr('Modulo "_MODULE_" abilitato!', [ - '_MODULE_' => Modules::get($id)['title'], - ])); - - break; - - case 'disable_widget': - $dbo->query('UPDATE zz_widgets SET enabled = 0 WHERE id = '.prepare($id)); - - $rs = $dbo->fetchArray('SELECT id, name FROM zz_widgets WHERE id='.prepare($id)); - $widget = $rs[0]['name']; - - flash()->info(tr('Widget "_WIDGET_" disabilitato!', [ - '_WIDGET_' => $widget, - ])); - - break; - - case 'enable_widget': - $dbo->query('UPDATE zz_widgets SET enabled=1 WHERE id='.prepare($id)); - - $rs = $dbo->fetchArray('SELECT id, name FROM zz_widgets WHERE id='.prepare($id)); - $widget = $rs[0]['name']; - - flash()->info(tr('Widget "_WIDGET_" abilitato!', [ - '_WIDGET_' => $widget, - ])); - - break; - - case 'change_position_widget_top': - $dbo->query("UPDATE zz_widgets SET location='controller_top' WHERE id=".prepare($id)); - - $rs = $dbo->fetchArray('SELECT id, name FROM zz_widgets WHERE id='.prepare($id)); - $widget = $rs[0]['name']; - - flash()->info(tr('Posizione del widget "_WIDGET_" aggiornata!', [ - '_WIDGET_' => $widget, - ])); - - break; - - case 'change_position_widget_right': - $dbo->query("UPDATE zz_widgets SET location='controller_right' WHERE id=".prepare($id)); - - $rs = $dbo->fetchArray('SELECT id, name FROM zz_widgets WHERE id='.prepare($id)); - $widget = $rs[0]['name']; - - flash()->info(tr('Posizione del widget "_WIDGET_" aggiornata!', [ - '_WIDGET_' => $widget, - ])); - - break; - - // Ordinamento moduli di primo livello - case 'sort_modules': - $order = explode(',', post('order', true)); - - foreach ($order as $i => $id) { - $dbo->query('UPDATE zz_modules SET `order`='.prepare($i).' WHERE id='.prepare($id)); - } - - break; - - case 'sort_widgets': - $order = explode(',', post('order', true)); - - foreach ($order as $i => $id) { - $dbo->query('UPDATE zz_widgets SET `order`='.prepare($i).' WHERE id='.prepare($id)); - } - - break; - - case 'sizes': - $results = []; - - $backup_dir = App::getConfig()['backup_dir']; - - $dirs = [ - $backup_dir => tr('Backup'), - base_dir().'/files' => tr('Allegati'), - base_dir().'/logs' => tr('Logs'), - ]; - - foreach ($dirs as $dir => $description) { - $size = FileSystem::folderSize($dir, ['htaccess']); - - $results[] = [ - 'description' => $description, - 'size' => $size, - 'formattedSize' => FileSystem::formatBytes($size), - 'count' => FileSystem::fileCount($dir, ['htaccess']) ?: 0, - 'dbSize' => ($description == 'Allegati') ? $dbo->fetchOne('SELECT SUM(`size`) AS dbsize FROM zz_files')['dbsize'] : '', - 'dbCount' => ($description == 'Allegati') ? $dbo->fetchOne('SELECT COUNT(`id`) AS dbcount FROM zz_files')['dbcount'] : '', - 'dbExtensions' => ($description == 'Allegati') ? $dbo->fetchArray("SELECT SUBSTRING_INDEX(filename, '.', -1) AS extension, COUNT(*) AS num FROM zz_files GROUP BY extension ORDER BY num DESC LIMIT 10") : '', - ]; - } - - echo json_encode($results); - - break; - - case 'informazioni-fe': - $info = Cache::pool('Informazioni su spazio FE'); - if (!$info->isValid()) { - $response = Services::request('POST', 'informazioni_fe'); - $response = Services::responseBody($response); - - $info->set($response['result']); - } - - $informazioni = $info->content; - - // Formattazione dei contenuti - $history = (array) $informazioni['history']; - foreach ($history as $key => $value) { - $history[$key]['size'] = Filesystem::formatBytes($value['size']); - $history[$key]['invoices_size'] = Filesystem::formatBytes($value['invoices_size']); - $history[$key]['notifies_size'] = Filesystem::formatBytes($value['notifies_size']); - } - - echo json_encode([ - 'invoice_number' => $informazioni['invoice_number'], - 'size' => Filesystem::formatBytes($informazioni['size']), - 'invoices_size' => Filesystem::formatBytes($informazioni['invoices_size']), - 'notifies_size' => Filesystem::formatBytes($informazioni['notifies_size']), - 'history' => $history, - ]); - break; -} diff --git a/modules/stato_servizi/edit.php b/modules/stato_servizi/edit.php deleted file mode 100755 index a416b55c0..000000000 --- a/modules/stato_servizi/edit.php +++ /dev/null @@ -1,238 +0,0 @@ -. - */ - -// Elenco moduli installati -use API\Services; -use Carbon\Carbon; -use Models\Cache; - -echo ' -
    -
    -

    '.tr('Moduli installati').'

    - - - - - - - - '; - -$modules = Modules::getHierarchy(); - -$osm_version = Update::getVersion(); - -echo submodules($modules); - -echo ' -
    '.tr('Nome').''.tr('Versione').''.tr('Stato').''.tr('Compatibilità').''.tr('Opzioni').'
    -
    '; - -if (Services::isEnabled()) { - // Informazioni su Services - $servizi = Cache::pool('Informazioni su Services')->content; - - if (!empty($servizi)) { - // Elaborazione dei servizi in scadenza - $limite_scadenze = (new Carbon())->addDays(60); - $servizi_in_scadenza = []; - foreach ($servizi as $servizio) { - // Gestione per data di scadenza - $scadenza = new Carbon($servizio['expiration_at']); - if ( - (isset($servizio['expiration_at']) && $scadenza->lessThan($limite_scadenze)) - ) { - $servizi_in_scadenza[] = $servizio['name'].' ('.$scadenza->diffForHumans().')'; - } - // Gestione per crediti - elseif ( - (isset($servizio['credits']) && $servizio['credits'] < 100) - ) { - $servizi_in_scadenza[] = $servizio['name'].' ('.$servizio['credits'].' crediti)'; - } - } - - echo ' -
    -
    -
    -

    - '.tr('Informazioni su Services').' -

    -
    -
    - -
    '; - - if (empty($servizi_in_scadenza)) { - echo ' -

    '.tr('Nessun servizio in scadenza').'.

    '; - } else { - echo ' -

    '.tr('I seguenti servizi sono in scadenza:').'

    -
      '; - foreach ($servizi_in_scadenza as $servizio) { - echo ' -
    • '.$servizio.'
    • '; - } - echo ' -
    '; - } - - echo ' - -

    - -

    '.tr('Statistiche su Fatture Elettroniche').'

    - - - - - - - - - - - - - - - - - -
    '.tr('Anno').''.tr('Documenti archiviati').' - - - - '.tr('Totale spazio occupato').' - - - -
    '.tr('Totale').'
    -
    -
    - - '; - } else { - echo ' -
    '; - } -} - -// Widgets -echo ' -
    -

    '.tr('Widgets').'

    - - - - - - - '; - -$widgets = $dbo->fetchArray('SELECT zz_widgets.id, zz_widgets.name AS widget_name, zz_modules.name AS module_name, zz_widgets.enabled AS enabled, location, help FROM zz_widgets INNER JOIN zz_modules ON zz_widgets.id_module=zz_modules.id ORDER BY `id_module` ASC, `zz_widgets`.`order` ASC'); - -$previous = ''; - -foreach ($widgets as $widget) { - // Nome modulo come titolo sezione - if ($widget['module_name'] != $previous) { - echo ' - - - '; - } - - // STATO - if ($widget['enabled']) { - $stato = ''; - $class = 'success'; - } else { - $stato = ''; - $class = 'warning'; - } - - // Possibilità di disabilitare o abilitare i moduli tranne quello degli aggiornamenti - if ($widget['enabled']) { - $stato = "".$stato."\n"; - } else { - $stato = "".$stato."\n"; - } - - // POSIZIONE - if ($widget['location'] == 'controller_top') { - $location = tr('Schermata modulo in alto'); - } elseif ($widget['location'] == 'controller_right') { - $location = tr('Schermata modulo a destra'); - } - - if ($widget['location'] == 'controller_right') { - $posizione = " "; - $posizione = "".$posizione."\n"; - } elseif ($widget['location'] == 'controller_top') { - $posizione = " '; - $posizione = "".$posizione."\n"; - } - - echo ' - - - - - - '; - - $previous = $widget['module_name']; -} - -echo ' -
    '.tr('Nome').''.tr('Posizione').''.tr('Stato').''.tr('Posizione').'
    '.$widget['module_name'].'
    '.$widget['widget_name'].((!empty($widget['help'])) ? ' ' : '').''.$location.''.$stato.''.$posizione.'
    -
    -
    '; diff --git a/modules/stato_servizi/modutil.php b/modules/stato_servizi/modutil.php deleted file mode 100755 index 54e3a43e3..000000000 --- a/modules/stato_servizi/modutil.php +++ /dev/null @@ -1,98 +0,0 @@ -. - */ - -function submodules($list, $depth = 0) -{ - $osm_version = Update::getVersion(); - - $id_module = Modules::getCurrent()['id']; - - $result = ''; - - foreach ($list as $sub) { - $locked = in_array($sub['name'], ['Utenti e permessi', 'Stato dei servizi']); - - // STATO - if (!empty($sub['enabled'])) { - $text = tr('Abilitato'); - $text .= !$locked ? '. '.tr('Clicca per disabilitarlo').'...' : ''; - $stato = ''; - } else { - $stato = ''; - $class = 'warning'; - } - - // Possibilità di disabilitare o abilitare i moduli tranne quello degli aggiornamenti - if (!$locked) { - if ($sub['enabled']) { - $stato = "".$stato."\n"; - } else { - $stato = "".$stato."\n"; - } - } - - // COMPATIBILITA' - // Controllo per ogni versione se la regexp combacia per dire che è compatibile o meno - $compatibilities = explode(',', $sub['compatibility']); - - $comp = false; - foreach ($compatibilities as $compatibility) { - $comp = (preg_match('/'.$compatibility.'/', $osm_version)) ? true : $comp; - } - - if ($comp) { - $compatible = ''; - ($sub['enabled']) ? $class = 'success' : $class = 'warning'; - } else { - $compatible = ''; - $class = 'danger'; - } - - $result .= ' - - '.str_repeat(' ', $depth * 4).'- '.$sub['title'].' - '.$sub['version'].' - '.$stato.' - '.$compatible.''; - - $result .= ' - '; - - // Possibilità di disinstallare solo se il modulo non è tra quelli predefiniti - if (empty($sub['default'])) { - $result .= ' - - - "; - } else { - $result .= " - - - "; - } - - $result .= ' - - '; - - $result .= submodules($sub['all_children'], $depth + 1); - } - - return $result; -} diff --git a/modules/stato_servizi/src/API/v1/FolderSize.php b/modules/stato_servizi/src/API/v1/FolderSize.php deleted file mode 100755 index 677497e99..000000000 --- a/modules/stato_servizi/src/API/v1/FolderSize.php +++ /dev/null @@ -1,72 +0,0 @@ -. - */ - -namespace Modules\StatoServizi\API\v1; - -use API\Interfaces\RetrieveInterface; -use API\Resource; -use App; -use Util\FileSystem; - -class FolderSize extends Resource implements RetrieveInterface -{ - public function retrieve($request) - { - $dirs = $request['dirs']; - - if (empty($dirs)) { - $backup_dir = App::getConfig()['backup_dir']; - - $dirs = [ - $backup_dir => tr('Backup'), - base_dir().'/files' => tr('Allegati'), - base_dir().'/logs' => tr('Logs'), - ]; - } else { - $array = explode(',', $dirs); - foreach ($array as $key => $value) { - $dirs = [ - base_dir().'/'.$value => $key, - ]; - } - } - - $results = []; - $total = 0; - foreach ($dirs as $dir => $description) { - $size = FileSystem::folderSize($dir); - - $results[] = [ - 'description' => $description, - 'size' => $size, - 'formattedSize' => FileSystem::formatBytes($size), - ]; - - $total += $size; - } - - $response = [ - 'dirs' => $results, - 'size' => $total, - 'formattedSize' => FileSystem::formatBytes($total), - ]; - - return $response; - } -} diff --git a/modules/stato_servizi/src/ServicesHook.php b/modules/stato_servizi/src/ServicesHook.php deleted file mode 100644 index a5bb439e2..000000000 --- a/modules/stato_servizi/src/ServicesHook.php +++ /dev/null @@ -1,75 +0,0 @@ -. - */ - -namespace Modules\StatoServizi; - -use API\Services; -use Carbon\Carbon; -use Hooks\CachedManager; - -class ServicesHook extends CachedManager -{ - public function getCacheName() - { - return 'Informazioni su Services'; - } - - public function cacheData() - { - $response = Services::request('POST', 'informazioni_servizi'); - $body = Services::responseBody($response); - - return $body['services']; - } - - public function response() - { - $servizi = $this->getCache()->content; - - // Elaborazione dei servizi in scadenza - $limite_scadenze = (new Carbon())->addDays(60); - $servizi_in_scadenza = []; - foreach ($servizi as $servizio) { - // Gestione per data di scadenza - $scadenza = new Carbon($servizio['expiration_at']); - if ( - (isset($servizio['expiration_at']) && $scadenza->lessThan($limite_scadenze)) - ) { - $servizi_in_scadenza[] = $servizio['name'].' ('.$scadenza->diffForHumans().')'; - } - - // Gestione per crediti - elseif ( - (isset($servizio['credits']) && $servizio['credits'] < 100) - ) { - $servizi_in_scadenza[] = $servizio['name'].' ('.$servizio['credits'].' crediti)'; - } - } - - $message = tr('I seguenti servizi sono in scadenza: _LIST_', [ - '_LIST_' => implode(', ', $servizi_in_scadenza), - ]); - - return [ - 'icon' => 'fa fa-refresh text-warning', - 'message' => $message, - 'show' => !empty($servizi_in_scadenza), - ]; - } -} diff --git a/modules/stato_servizi/src/SpaceHook.php b/modules/stato_servizi/src/SpaceHook.php deleted file mode 100644 index 2100d077a..000000000 --- a/modules/stato_servizi/src/SpaceHook.php +++ /dev/null @@ -1,61 +0,0 @@ -. - */ - -namespace Modules\StatoServizi; - -use Hooks\CachedManager; -use Util\FileSystem; - -class SpaceHook extends CachedManager -{ - public function getCacheName() - { - return 'Spazio utilizzato'; - } - - public function cacheData() - { - if (!empty(setting('Soft quota'))) { - return FileSystem::folderSize(base_dir(), ['htaccess']); - } - - return false; - } - - public function response() - { - $osm_size = $this->getCache()->content; - - $soft_quota = (float) setting('Soft quota'); // Impostazione in GB - $soft_quota = $soft_quota * (1024 ** 3); // Trasformazione in GB - - $message = tr('Attenzione: occupati _TOT_ dei _QUOTA_ previsti', [ - '_TOT_' => FileSystem::formatBytes($osm_size), - '_QUOTA_' => FileSystem::formatBytes($soft_quota), - ]); - - $space_limit = ($soft_quota / 100) * 95; // 95% dello spazio indicato - - return [ - 'icon' => 'fa fa-database text-warning', - 'message' => $message, - 'show' => ($osm_size > $space_limit), - ]; - } -} diff --git a/modules/stato_servizi/widgets/spazio_utilizzato.php b/modules/stato_servizi/widgets/spazio_utilizzato.php deleted file mode 100755 index 7f7703706..000000000 --- a/modules/stato_servizi/widgets/spazio_utilizzato.php +++ /dev/null @@ -1,167 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -$module = Modules::get('Stato dei servizi'); - -echo ' -'; - -// Operazioni JavaScript -echo ' - -
    -
    - -
    '; diff --git a/modules/tecnici_tariffe/actions.php b/modules/tecnici_tariffe/actions.php deleted file mode 100755 index a3d1975da..000000000 --- a/modules/tecnici_tariffe/actions.php +++ /dev/null @@ -1,74 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -switch (post('op')) { - case 'update': - foreach ($tipi_interventi as $tipo_intervento) { - $id_tipo_intervento = $tipo_intervento['id']; - - $values = [ - 'costo_ore' => post('costo_ore')[$id_tipo_intervento], - 'costo_km' => post('costo_km')[$id_tipo_intervento], - 'costo_dirittochiamata' => post('costo_dirittochiamata')[$id_tipo_intervento], - 'costo_ore_tecnico' => post('costo_ore_tecnico')[$id_tipo_intervento], - 'costo_km_tecnico' => post('costo_km_tecnico')[$id_tipo_intervento], - 'costo_dirittochiamata_tecnico' => post('costo_dirittochiamata_tecnico')[$id_tipo_intervento], - ]; - - // Aggiorno il record - $dbo->update('in_tariffe', $values, [ - 'idtipointervento' => $id_tipo_intervento, - 'idtecnico' => $id_record, - ]); - } - - flash()->info(tr('Informazioni salvate correttamente!')); - - break; - - case 'import': - $id_tipo_intervento = post('idtipointervento'); - - $importi = $dbo->fetchOne('SELECT * FROM in_tipiintervento WHERE idtipointervento='.prepare($id_tipo_intervento)); - - $values = [ - 'costo_ore' => $importi['costo_orario'], - 'costo_km' => $importi['costo_km'], - 'costo_dirittochiamata' => $importi['costo_diritto_chiamata'], - 'costo_ore_tecnico' => $importi['costo_orario_tecnico'], - 'costo_km_tecnico' => $importi['costo_km_tecnico'], - 'costo_dirittochiamata_tecnico' => $importi['costo_diritto_chiamata_tecnico'], - ]; - - foreach ($tipi_interventi as $tipo_intervento) { - if ($tipo_intervento['id'] == $id_tipo_intervento) { - break; - } - } - - // Aggiorno il record - $dbo->update('in_tariffe', $values, [ - 'idtipointervento' => $id_tipo_intervento, - 'idtecnico' => $id_record, - ]); - - break; -} diff --git a/modules/tecnici_tariffe/edit.php b/modules/tecnici_tariffe/edit.php deleted file mode 100755 index db32477e0..000000000 --- a/modules/tecnici_tariffe/edit.php +++ /dev/null @@ -1,113 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo ' -
    - - - -
    - -
    -

    '.$record['ragione_sociale'].'

    -
    - '.Modules::link('Anagrafiche', $record['idanagrafica']).' -
    -
    - -
    - - - - - - - - - - - - - - - - '; - - // Tipi di interventi - foreach ($tipi_interventi as $tipo_intervento) { - echo ' - - - - - - - - - - - - - - - - - - '; - } -echo ' -
    '.tr('Attività').' - '.tr('Addebito orario').' - - - '.tr('Addebito km').' - - - '.tr('Addebito diritto ch.').' - - - '.tr('Costo orario').' - - - '.tr('Costo km').' - - - '.tr('Costo diritto ch.').' - -
    '.$tipo_intervento['descrizione'].' - {[ "type": "number", "name": "costo_ore['.$tipo_intervento['id'].']", "required": 1, "value": "'.$tipo_intervento['costo_ore'].'" ]} - - {[ "type": "number", "name": "costo_km['.$tipo_intervento['id'].']", "required": 1, "value": "'.$tipo_intervento['costo_km'].'" ]} - - {[ "type": "number", "name": "costo_dirittochiamata['.$tipo_intervento['id'].']", "required": 1, "value": "'.$tipo_intervento['costo_dirittochiamata'].'" ]} - - {[ "type": "number", "name": "costo_ore_tecnico['.$tipo_intervento['id'].']", "required": 1, "value": "'.$tipo_intervento['costo_ore_tecnico'].'" ]} - - {[ "type": "number", "name": "costo_km_tecnico['.$tipo_intervento['id'].']", "required": 1, "value": "'.$tipo_intervento['costo_km_tecnico'].'" ]} - - {[ "type": "number", "name": "costo_dirittochiamata_tecnico['.$tipo_intervento['id'].']", "required": 1, "value": "'.$tipo_intervento['costo_dirittochiamata_tecnico'].'" ]} - - - - -
    -
    -
    '; diff --git a/modules/tecnici_tariffe/init.php b/modules/tecnici_tariffe/init.php deleted file mode 100755 index b49b2d5fc..000000000 --- a/modules/tecnici_tariffe/init.php +++ /dev/null @@ -1,26 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT idanagrafica, ragione_sociale, colore FROM an_anagrafiche WHERE idanagrafica = '.prepare($id_record)); - - $tipi_interventi = $dbo->fetchArray('SELECT *, in_tipiintervento.idtipointervento AS id, in_tariffe.idtipointervento AS esiste FROM in_tipiintervento LEFT JOIN in_tariffe ON in_tipiintervento.idtipointervento = in_tariffe.idtipointervento AND in_tariffe.idtecnico = '.prepare($id_record).' ORDER BY descrizione'); -} diff --git a/modules/tipi_anagrafiche/actions.php b/modules/tipi_anagrafiche/actions.php deleted file mode 100755 index 4943e2921..000000000 --- a/modules/tipi_anagrafiche/actions.php +++ /dev/null @@ -1,65 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -switch (post('op')) { - case 'update': - $idtipoanagrafica = post('id_record'); - $descrizione = post('descrizione'); - - $block = ['Cliente', 'Tecnico', 'Azienda', 'Fornitore']; - // Nome accettato - - if (!in_array($descrizione, $block)) { - $dbo->query('UPDATE an_tipianagrafiche SET descrizione='.prepare($descrizione).' WHERE idtipoanagrafica='.prepare($idtipoanagrafica)); - flash()->info(tr('Informazioni salvate correttamente!')); - } else { - // Nome non consentito - flash()->error(tr('Nome non consentito!')); - } - - break; - - case 'add': - $descrizione = post('descrizione'); - - if (!empty($descrizione)) { - // Verifico che il nome non sia duplicato - $rs = $dbo->fetchArray('SELECT descrizione FROM an_tipianagrafiche WHERE descrizione='.prepare($descrizione)); - - if (count($rs) > 0) { - flash()->error(tr('Nome già esistente!')); - } else { - $query = 'INSERT INTO an_tipianagrafiche (descrizione) VALUES ('.prepare($descrizione).')'; - $dbo->query($query); - - $id_record = $dbo->lastInsertedID(); - flash()->info(tr('Nuovo tipo di anagrafica aggiunto!')); - } - } - break; - - case 'delete': - $query = 'DELETE FROM an_tipianagrafiche WHERE idtipoanagrafica='.prepare($id_record); - $dbo->query($query); - - flash()->info(tr('Tipo di anagrafica eliminato!')); - break; -} diff --git a/modules/tipi_anagrafiche/add.php b/modules/tipi_anagrafiche/add.php deleted file mode 100755 index 67c3df35c..000000000 --- a/modules/tipi_anagrafiche/add.php +++ /dev/null @@ -1,41 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?> - - - -
    - -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1 ]} -
    - -
    - - -
    -
    - -
    -
    -
    - diff --git a/modules/tipi_anagrafiche/edit.php b/modules/tipi_anagrafiche/edit.php deleted file mode 100755 index 4fc6e6974..000000000 --- a/modules/tipi_anagrafiche/edit.php +++ /dev/null @@ -1,68 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -// Se lo stato intervento è uno di quelli di default, non lo lascio modificare -if ($record['default']) { - $attr = "readonly='true'"; - $warning_text = '
    '.tr('Non puoi modificare questo tipo di anagrafica!').'
    '; -} else { - $attr = ''; - $warning_text = ''; -} - -// Se il tipo di anagrafica è uno di quelli di default, non lo lascio modificare -if (!empty($record['default'])) { - // Disabilito il pulsante di salvataggio - echo ' - - - '.$warning_text; -} - -?> - -
    - - - - -
    - -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1, "value": "$descrizione$", "extra": "" ]} -
    - -
    -
    - - - '.tr('Elimina').' -'; -} diff --git a/modules/tipi_anagrafiche/init.php b/modules/tipi_anagrafiche/init.php deleted file mode 100755 index 01f917333..000000000 --- a/modules/tipi_anagrafiche/init.php +++ /dev/null @@ -1,24 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT * FROM an_tipianagrafiche WHERE idtipoanagrafica='.prepare($id_record)); -} diff --git a/modules/tipi_documento/actions.php b/modules/tipi_documento/actions.php deleted file mode 100644 index 9822df3a3..000000000 --- a/modules/tipi_documento/actions.php +++ /dev/null @@ -1,111 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -switch (filter('op')) { - case 'update': - $descrizione = filter('descrizione'); - $dir = filter('dir'); - $codice_tipo_documento_fe = filter('codice_tipo_documento_fe'); - - if (isset($descrizione) && isset($dir) && isset($codice_tipo_documento_fe)) { - if ($dbo->fetchNum('SELECT * FROM `co_tipidocumento` WHERE `dir`='.prepare($dir).' AND `descrizione`='.prepare($descrizione).' AND `codice_tipo_documento_fe`='.prepare($codice_tipo_documento_fe).' AND `id`!='.prepare($id_record)) == 0) { - $predefined = post('predefined'); - if (!empty($predefined)) { - $dbo->query('UPDATE co_tipidocumento SET predefined = 0 WHERE dir = '.prepare($dir)); - } - - $dbo->update('co_tipidocumento', [ - 'descrizione' => $descrizione, - 'dir' => $dir, - 'codice_tipo_documento_fe' => $codice_tipo_documento_fe, - 'help' => filter('help'), - 'predefined' => $predefined, - 'enabled' => post('enabled'), - ], ['id' => $id_record]); - - flash()->info(tr('Salvataggio completato!')); - } else { - flash()->error(tr("E' già presente una tipologia di _TYPE_ con la stessa combinazione di direzione, descrizione e tipo documento FE", [ - '_TYPE_' => 'tipo documento', - ])); - } - } else { - flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio')); - } - - break; - - case 'add': - $descrizione = filter('descrizione'); - $dir = filter('dir'); - $codice_tipo_documento_fe = filter('codice_tipo_documento_fe'); - - if (isset($descrizione) && isset($dir) && isset($codice_tipo_documento_fe)) { - if ($dbo->fetchNum('SELECT * FROM `co_tipidocumento` WHERE `dir`='.prepare($dir).' AND `descrizione`='.prepare($descrizione).' AND `codice_tipo_documento_fe`='.prepare($codice_tipo_documento_fe)) == 0) { - $dbo->insert('co_tipidocumento', [ - 'descrizione' => $descrizione, - 'dir' => $dir, - 'codice_tipo_documento_fe' => $codice_tipo_documento_fe, - ]); - $id_record = $dbo->lastInsertedID(); - - if (isAjaxRequest()) { - echo json_encode(['id' => $id_record, 'text' => $descrizione]); - } - - flash()->info(tr('Aggiunta nuova tipologia di _TYPE_', [ - '_TYPE_' => 'tipo documento', - ])); - } else { - flash()->error(tr("E' già presente una tipologia di _TYPE_ con la stessa combinazione di direzione, descrizione e tipo documento FE", [ - '_TYPE_' => 'tipo documento', - ])); - } - } else { - flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio')); - } - - break; - - case 'delete': - $documenti = $dbo->fetchNum('SELECT id FROM co_documenti WHERE idtipodocumento ='.prepare($id_record)); - - if (isset($id_record) && empty($documenti)) { - $dbo->query('DELETE FROM `co_tipidocumento` WHERE `id`='.prepare($id_record)); - flash()->info(tr('Tipologia di _TYPE_ eliminata con successo.', [ - '_TYPE_' => 'tipo documento', - ])); - } else { - $dbo->update('co_tipidocumento', [ - 'deleted_at' => date(), - 'predefined' => 0, - 'enabled' => 0, - ], ['id' => $id_record]); - - flash()->info(tr('Tipologia di _TYPE_ eliminata con successo.', [ - '_TYPE_' => 'tipo documento', - ])); - - //flash()->error(tr('Sono presenti dei documenti collegati a questo tipo documento')); - } - - break; -} diff --git a/modules/tipi_documento/add.php b/modules/tipi_documento/add.php deleted file mode 100644 index 240032387..000000000 --- a/modules/tipi_documento/add.php +++ /dev/null @@ -1,46 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1 ]} -
    - -
    - {[ "type": "select", "label": "", "name": "dir", "values": "list=\"\": \"Non specificato\", \"entrata\": \"\", \"uscita\": \"\"", "required": 1 ]} -
    - -
    - {[ "type": "select", "label": "", "name": "codice_tipo_documento_fe", "values": "query=SELECT codice AS id, CONCAT_WS(' - ', codice, descrizione) AS descrizione FROM fe_tipi_documento", "required": 1 ]} -
    -
    - - -
    -
    - -
    -
    -
    \ No newline at end of file diff --git a/modules/tipi_documento/ajax/select.php b/modules/tipi_documento/ajax/select.php deleted file mode 100644 index 435dc9bca..000000000 --- a/modules/tipi_documento/ajax/select.php +++ /dev/null @@ -1,37 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -switch ($resource) { - case 'tipi_documento': - $query = 'SELECT id, descrizione FROM co_tipidocumento |where| ORDER BY descrizione ASC'; - - $where[] = 'co_tipidocumento.enabled = 1'; - $where[] = 'dir='.$superselect['dir']; - - foreach ($elements as $element) { - $filter[] = 'id='.prepare($element); - } - if (!empty($search)) { - $search_fields[] = 'descrizione LIKE '.prepare('%'.$search.'%'); - } - - break; -} diff --git a/modules/tipi_documento/edit.php b/modules/tipi_documento/edit.php deleted file mode 100644 index 61d8b40b6..000000000 --- a/modules/tipi_documento/edit.php +++ /dev/null @@ -1,75 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1, "value": "$descrizione$" ]} -
    - -
    - {[ "type": "select", "label": "", "name": "dir", "value": "$dir$", "values": "list=\"\": \"Non specificato\", \"entrata\": \"\", \"uscita\": \"\"", "required": 1 ]} -
    - -
    - {[ "type": "select", "label": "", "name": "codice_tipo_documento_fe", "value": "$codice_tipo_documento_fe$", "values": "query=SELECT codice AS id, CONCAT_WS(' - ', codice, descrizione) AS descrizione FROM fe_tipi_documento", "required": 1 ]} -
    - -
    - {[ "type": "checkbox", "label": "", "name": "predefined", "value": "", "help":"." ]} -
    - -
    - {[ "type": "checkbox", "label": "", "name": "enabled", "disabled": "", "value": "" ]} -
    - -
    - {[ "type": "checkbox", "label": "", "name": "reversed", "value": "", "readonly": 1 ]} -
    - -
    - {[ "type": "text", "label": "", "name": "help", "value": "$help$" ]} -
    - -
    - -
    - -fetchNum('SELECT id FROM co_documenti WHERE idtipodocumento='.prepare($id_record)); - -if (!empty($numero_documenti)) { - echo ' -
    - '.tr('Ci sono _NUM_ documenti collegati', [ - '_NUM_' => $numero_documenti, - ]).'. -
    '; -} -?> - - - - diff --git a/modules/tipi_documento/init.php b/modules/tipi_documento/init.php deleted file mode 100644 index 09c8d3361..000000000 --- a/modules/tipi_documento/init.php +++ /dev/null @@ -1,24 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT * FROM `co_tipidocumento` WHERE id='.prepare($id_record)); -} diff --git a/modules/tipi_intervento/actions.php b/modules/tipi_intervento/actions.php deleted file mode 100755 index 826aa5d28..000000000 --- a/modules/tipi_intervento/actions.php +++ /dev/null @@ -1,115 +0,0 @@ -. - */ - -use Modules\TipiIntervento\Tipo; - -include_once __DIR__.'/../../core.php'; - -switch (post('op')) { - case 'update': - $tipo->descrizione = post('descrizione'); - $tipo->tempo_standard = post('tempo_standard'); - - $tipo->costo_orario = post('costo_orario'); - $tipo->costo_km = post('costo_km'); - $tipo->costo_diritto_chiamata = post('costo_diritto_chiamata'); - $tipo->costo_orario_tecnico = post('costo_orario_tecnico'); - $tipo->costo_km_tecnico = post('costo_km_tecnico'); - $tipo->costo_diritto_chiamata_tecnico = post('costo_diritto_chiamata_tecnico'); - - $tipo->save(); - - flash()->info(tr('Informazioni tipo intervento salvate correttamente!')); - - break; - - case 'add': - $codice = post('codice'); - $descrizione = post('descrizione'); - - $tipo = Tipo::build($codice, $descrizione); - - $tipo->tempo_standard = post('tempo_standard'); - - $tipo->costo_orario = post('costo_orario'); - $tipo->costo_km = post('costo_km'); - $tipo->costo_diritto_chiamata = post('costo_diritto_chiamata'); - $tipo->costo_orario_tecnico = post('costo_orario_tecnico'); - $tipo->costo_km_tecnico = post('costo_km_tecnico'); - $tipo->costo_diritto_chiamata_tecnico = post('costo_diritto_chiamata_tecnico'); - - $tipo->save(); - - // Fix per impostare i valori inziali a tutti i tecnici - $tipo->fixTecnici(); - - $id_record = $tipo->id; - - flash()->info(tr('Nuovo tipo di intervento aggiunto!')); - - break; - - case 'delete': - // Permetto eliminazione tipo intervento solo se questo non è utilizzado da nessun'altra parte a gestionale - // UNION SELECT `in_tariffe`.`idtipointervento` FROM `in_tariffe` WHERE `in_tariffe`.`idtipointervento` = '.prepare($id_record).' - // UNION SELECT `co_contratti_tipiintervento`.`idtipointervento` FROM `co_contratti_tipiintervento` WHERE `co_contratti_tipiintervento`.`idtipointervento` = '.prepare($id_record).' - $elementi = $dbo->fetchArray('SELECT `in_interventi`.`idtipointervento` FROM `in_interventi` WHERE `in_interventi`.`idtipointervento` = '.prepare($id_record).' - UNION - SELECT `an_anagrafiche`.`idtipointervento_default` AS `idtipointervento` FROM `an_anagrafiche` WHERE `an_anagrafiche`.`idtipointervento_default` = '.prepare($id_record).' - UNION - SELECT `co_preventivi`.`idtipointervento` FROM `co_preventivi` WHERE `co_preventivi`.`idtipointervento` = '.prepare($id_record).' - UNION - SELECT `co_promemoria`.`idtipointervento` FROM `co_promemoria` WHERE `co_promemoria`.`idtipointervento` = '.prepare($id_record).' - UNION - SELECT `in_interventi_tecnici`.`idtipointervento` FROM `in_interventi_tecnici` WHERE `in_interventi_tecnici`.`idtipointervento` = '.prepare($id_record).' - ORDER BY `idtipointervento`'); - - if (empty($elementi)) { - // Elimino anche le tariffe collegate ai vari tecnici - $query = 'DELETE FROM in_tariffe WHERE idtipointervento='.prepare($id_record); - $dbo->query($query); - - // Elimino anche le tariffe collegate ai contratti - $query = 'DELETE FROM co_contratti_tipiintervento WHERE idtipointervento='.prepare($id_record); - $dbo->query($query); - - $query = 'DELETE FROM in_tipiintervento WHERE idtipointervento='.prepare($id_record); - $dbo->query($query); - - flash()->info(tr('Tipo di intervento eliminato!')); - break; - } - - // no break - case 'import': - $values = [ - 'costo_ore' => $record['costo_orario'], - 'costo_km' => $record['costo_km'], - 'costo_dirittochiamata' => $record['costo_diritto_chiamata'], - 'costo_ore_tecnico' => $record['costo_orario_tecnico'], - 'costo_km_tecnico' => $record['costo_km_tecnico'], - 'costo_dirittochiamata_tecnico' => $record['costo_diritto_chiamata_tecnico'], - ]; - - $dbo->update('in_tariffe', $values, [ - 'idtipointervento' => $id_record, - ]); - - break; -} diff --git a/modules/tipi_intervento/add.php b/modules/tipi_intervento/add.php deleted file mode 100755 index 6e0123c36..000000000 --- a/modules/tipi_intervento/add.php +++ /dev/null @@ -1,90 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "codice", "maxlength": 10, "class": "alphanumeric-mask", "required": 1 ]} -
    - -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1 ]} -
    - -
    - {[ "type": "number", "label": "", "name": "tempo_standard", "help": "Esempi:
    • 60 minuti = 1 ora
    • 30 minuti = 0,5 ore
    • 15 minuti = 0,25 ore
    '); ?>", "min-value": "0", "max-value": "24", "class": "text-center", "value": "$tempo_standard$", "icon-after": "ore" ]} -
    -
    - -
    -
    -

    -
    - -
    -
    -
    - {[ "type": "number", "label": "", "name": "costo_orario", "required": 1, "value": "$costo_orario$", "icon-after": "" ]} -
    - -
    - {[ "type": "number", "label": "", "name": "costo_km", "required": 1, "value": "$costo_km$", "icon-after": "" ]} -
    - -
    - {[ "type": "number", "label": "", "name": "costo_diritto_chiamata", "required": 1, "value": "$costo_diritto_chiamata$", "icon-after": "" ]} -
    -
    -
    -
    - -
    -
    -

    -
    - -
    -
    -
    - {[ "type": "number", "label": "", "name": "costo_orario_tecnico", "required": 1, "value": "$costo_orario_tecnico$", "icon-after": "" ]} -
    - -
    - {[ "type": "number", "label": "", "name": "costo_km_tecnico", "required_tecnico": 1, "value": "$costo_km_tecnico$", "icon-after": "" ]} -
    - -
    - {[ "type": "number", "label": "", "name": "costo_diritto_chiamata_tecnico", "required": 1, "value": "$costo_diritto_chiamata_tecnico$", "icon-after": "" ]} -
    -
    -
    -
    - - -
    -
    - -
    -
    -
    diff --git a/modules/tipi_intervento/buttons.php b/modules/tipi_intervento/buttons.php deleted file mode 100755 index 035e7be7f..000000000 --- a/modules/tipi_intervento/buttons.php +++ /dev/null @@ -1,23 +0,0 @@ -. - */ - -echo ' - - '.tr('Applica a tutti i tecnici').' -'; diff --git a/modules/tipi_intervento/edit.php b/modules/tipi_intervento/edit.php deleted file mode 100755 index 23dcfd56d..000000000 --- a/modules/tipi_intervento/edit.php +++ /dev/null @@ -1,154 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - - -
    -
    - {[ "type": "span", "label": "", "name": "codice", "value": "$codice$" ]} -
    - -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1, "value": "$descrizione$" ]} -
    - -
    - {[ "type": "number", "label": "", "name": "tempo_standard", "help": "Esempi:
    • 60 minuti = 1 ora
    • 30 minuti = 0,5 ore
    • 15 minuti = 0,25 ore
    Suggerisce il tempo solitamente impiegato per questa tipologia di attivita'); ?>.", "min-value": "0", "max-value": "24", "class": "text-center", "value": "$tempo_standard$", "icon-after": "ore" ]} -
    - -
    - -
    -
    -

    -
    - -
    -
    -
    - {[ "type": "number", "label": "", "name": "costo_orario", "required": 1, "value": "$costo_orario$", "icon-after": "", "help": "" ]} -
    - -
    - {[ "type": "number", "label": "", "name": "costo_km", "required": 1, "value": "$costo_km$", "icon-after": "", "help": "" ]} -
    - -
    - {[ "type": "number", "label": "", "name": "costo_diritto_chiamata", "required": 1, "value": "$costo_diritto_chiamata$", "icon-after": "", "help": "" ]} -
    -
    -
    -
    - - -
    -
    -

    -
    - -
    -
    -
    - {[ "type": "number", "label": "", "name": "costo_orario_tecnico", "required": 1, "value": "$costo_orario_tecnico$", "icon-after": "", "help": "" ]} -
    - -
    - {[ "type": "number", "label": "", "name": "costo_km_tecnico", "required_tecnico": 1, "value": "$costo_km_tecnico$", "icon-after": "", "help": "" ]} -
    - -
    - {[ "type": "number", "label": "", "name": "costo_diritto_chiamata_tecnico", "required": 1, "value": "$costo_diritto_chiamata_tecnico$", "icon-after": "", "help": "" ]} -
    -
    -
    -
    -
    - -fetchArray('SELECT `in_interventi`.`idtipointervento`, id, codice AS numero, data_richiesta AS data, "Intervento" AS tipo_documento FROM `in_interventi` WHERE `in_interventi`.`idtipointervento` = '.prepare($id_record).' -UNION -SELECT `in_interventi_tecnici`.`idtipointervento`, idintervento AS id, codice AS numero, orario_inizio AS data, "Sessione intervento" AS tipo_documento FROM `in_interventi_tecnici` LEFT JOIN in_interventi ON in_interventi_tecnici.idintervento=in_interventi.id WHERE `in_interventi_tecnici`.`idtipointervento` = '.prepare($id_record).' -UNION -SELECT `an_anagrafiche`.`idtipointervento_default` AS `idtipointervento`, idanagrafica AS id, codice, "0000-00-00" AS data, "Anagrafica" AS tipo_documento FROM `an_anagrafiche` WHERE `an_anagrafiche`.`idtipointervento_default` = '.prepare($id_record).' -UNION -SELECT `co_preventivi`.`idtipointervento`, id, numero, data_bozza AS data, "Preventivo" AS tipo_documento FROM `co_preventivi` WHERE `co_preventivi`.`idtipointervento` = '.prepare($id_record).' -UNION -SELECT `co_promemoria`.`idtipointervento`, idcontratto AS id, numero, data_richiesta AS data, "Promemoria contratto" AS tipo_documento FROM `co_promemoria` LEFT JOIN co_contratti ON co_promemoria.idcontratto=co_contratti.id WHERE `co_promemoria`.`idtipointervento` = '.prepare($id_record).' -ORDER BY `idtipointervento`'); - -if (!empty($elementi)) { - echo ' -
    -
    -

    '.tr('Documenti collegati: _NUM_', [ - '_NUM_' => count($elementi), - ]).'

    -
    - -
    -
    -
    -
      '; - - foreach ($elementi as $elemento) { - $descrizione = tr('_DOC_ num. _NUM_ del _DATE_', [ - '_DOC_' => $elemento['tipo_documento'], - '_NUM_' => $elemento['numero'], - '_DATE_' => Translator::dateToLocale($elemento['data']), - ]); - - if (in_array($elemento['tipo_documento'], ['Intervento'])) { - $modulo = 'Interventi'; - } - if (in_array($elemento['tipo_documento'], ['Sessione intervento'])) { - $modulo = 'Interventi'; - } - if (in_array($elemento['tipo_documento'], ['Anagrafica'])) { - $modulo = 'Anagrafiche'; - } - if (in_array($elemento['tipo_documento'], ['Preventivo'])) { - $modulo = 'Preventivi'; - } - if (in_array($elemento['tipo_documento'], ['Promemoria contratto'])) { - $modulo = 'Contratti'; - } - $id = $elemento['id']; - - echo ' -
    • '.Modules::link($modulo, $id, $descrizione).'
    • '; - } - - echo ' -
    -
    -
    '; -} else { - echo ' - - '.tr('Elimina').' -'; -} diff --git a/modules/tipi_intervento/init.php b/modules/tipi_intervento/init.php deleted file mode 100755 index 4785658f6..000000000 --- a/modules/tipi_intervento/init.php +++ /dev/null @@ -1,27 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; -use Modules\TipiIntervento\Tipo; - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT * FROM in_tipiintervento WHERE idtipointervento='.prepare($id_record)); - - $tipo = Tipo::find($id_record); -} diff --git a/modules/tipi_intervento/src/API/v1/TipiInterventi.php b/modules/tipi_intervento/src/API/v1/TipiInterventi.php deleted file mode 100755 index be6a3e0bd..000000000 --- a/modules/tipi_intervento/src/API/v1/TipiInterventi.php +++ /dev/null @@ -1,44 +0,0 @@ -. - */ - -namespace Modules\TipiIntervento\API\v1; - -use API\Interfaces\RetrieveInterface; -use API\Resource; - -class TipiInterventi extends Resource implements RetrieveInterface -{ - public function retrieve($request) - { - $table = 'in_tipiintervento'; - - $select = $request['select']; - if (empty($select)) { - $select = [ - '*', - 'id' => 'idtipointervento', - ]; - } - - return [ - 'select' => $select, - 'table' => $table, - ]; - } -} diff --git a/modules/tipi_intervento/src/Tipo.php b/modules/tipi_intervento/src/Tipo.php deleted file mode 100755 index 3304d0413..000000000 --- a/modules/tipi_intervento/src/Tipo.php +++ /dev/null @@ -1,95 +0,0 @@ -. - */ - -namespace Modules\TipiIntervento; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; -use Modules\Anagrafiche\Anagrafica; - -class Tipo extends Model -{ - use SimpleModelTrait; - - protected $table = 'in_tipiintervento'; - protected $primaryKey = 'idtipointervento'; - - /** - * Crea un nuovo tipo di intervento. - * - * @param string $codice - * @param string $descrizione - * @param string $tempo_standard - * - * @return self - */ - public static function build($codice, $descrizione) - { - $model = new static(); - - $model->codice = $codice; - $model->descrizione = $descrizione; - - // Salvataggio delle informazioni - $model->save(); - - return $model; - } - - public function fixTecnici() - { - // Fix per le relazioni con i tecnici - $tecnici = Anagrafica::fromTipo('Tecnico')->get(); - foreach ($tecnici as $tecnico) { - Anagrafica::fixTecnico($tecnico); - } - } - - /** - * Restituisce l'identificativo. - * - * @return string - */ - public function getIdAttribute() - { - return $this->idtipointervento; - } - - /** - * Imposta il tempo stamdard per il tipo di intervento. - * - * @param string $value - */ - public function setTempoStandardAttribute($value) - { - $result = round(($value / 2.5), 1) * 2.5; - - $this->attributes['tempo_standard'] = $result; - } - - public function preventivi() - { - return $this->hasMany(Preventivo::class, 'idtipointervento'); - } - - public function interventi() - { - return $this->hasMany(Intervento::class, 'idtipointervento'); - } -} diff --git a/modules/tipi_scadenze/actions.php b/modules/tipi_scadenze/actions.php deleted file mode 100755 index 9fe9c45a0..000000000 --- a/modules/tipi_scadenze/actions.php +++ /dev/null @@ -1,114 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -switch (filter('op')) { - case 'update': - $descrizione = filter('descrizione'); - $nome = filter('nome'); - - if (isset($nome)) { - //Se non esiste già una tipo di scadenza con lo stesso nome - if ($dbo->fetchNum('SELECT * FROM `co_tipi_scadenze` WHERE `nome`='.prepare($nome).' AND `id`!='.prepare($id_record)) == 0) { - //nome_prev - $nome_prev = $dbo->fetchOne('SELECT nome AS nome_prev FROM `co_tipi_scadenze` WHERE `id`='.prepare($id_record))['nome_prev']; - - $dbo->update('co_tipi_scadenze', [ - 'nome' => $nome, - 'descrizione' => $descrizione, - ], ['id' => $id_record]); - - //aggiorno anche il segmento - $dbo->update('zz_segments', [ - 'clause' => 'co_scadenziario.tipo="'.$nome.'"', - 'name' => 'Scadenzario '.$nome, - ], [ - 'clause' => 'co_scadenziario.tipo="'.$nome_prev.'"', - 'name' => 'Scadenzario '.$nome_prev, - 'id_module' => Modules::get('Scadenzario')['id'], - ]); - - flash()->info(tr('Salvataggio completato!')); - } else { - flash()->error(tr("E' già presente una tipologia di _TYPE_ con nome: _NOME_", [ - '_TYPE_' => 'scadenza', - '_NOME_' => $nome, - ])); - } - } else { - flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio')); - } - - break; - - case 'add': - $descrizione = filter('descrizione'); - $nome = filter('nome'); - - if (isset($nome)) { - //Se non esiste già un tipo di scadenza con lo stesso nome - if ($dbo->fetchNum('SELECT * FROM `co_tipi_scadenze` WHERE `nome`='.prepare($nome)) == 0) { - $dbo->insert('co_tipi_scadenze', [ - 'nome' => $nome, - 'descrizione' => $descrizione, - ]); - $id_record = $dbo->lastInsertedID(); - - //Aggiungo anche il segmento - $dbo->insert('zz_segments', [ - 'id_module' => Modules::get('Scadenzario')['id'], - 'name' => 'Scadenzario '.$nome, - 'clause' => 'co_scadenziario.tipo="'.$nome.'"', - 'position' => 'WHR', - ]); - - if (isAjaxRequest()) { - echo json_encode(['id' => $nome, 'text' => $descrizione]); - } - - flash()->info(tr('Aggiunta nuova tipologia di _TYPE_', [ - '_TYPE_' => 'scadenza', - ])); - } else { - flash()->error(tr("E' già presente una tipologia di _TYPE_ con nome: _NOME_", [ - '_TYPE_' => 'scadenza', - '_NOME_' => $nome, - ])); - } - } else { - flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio')); - } - - break; - - case 'delete': - $documenti = $dbo->fetchNum('SELECT id FROM co_scadenziario WHERE tipo = (SELECT nome FROM co_tipi_scadenze WHERE id = '.prepare($id_record).')'); - - if (isset($id_record) && empty($documenti)) { - $dbo->query('DELETE FROM `co_tipi_scadenze` WHERE `can_delete` = 1 AND `id`='.prepare($id_record)); - flash()->info(tr('Tipologia di _TYPE_ eliminata con successo.', [ - '_TYPE_' => 'scadenza', - ])); - } else { - flash()->error(tr('Sono presenti delle scadenze collegate a questo tipo di scadenza')); - } - - break; -} diff --git a/modules/tipi_scadenze/add.php b/modules/tipi_scadenze/add.php deleted file mode 100755 index a7f0c2bce..000000000 --- a/modules/tipi_scadenze/add.php +++ /dev/null @@ -1,41 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "nome", "required": 1 ]} -
    -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1 ]} -
    -
    - - -
    -
    - -
    -
    -
    diff --git a/modules/tipi_scadenze/ajax/select.php b/modules/tipi_scadenze/ajax/select.php deleted file mode 100755 index d79a09bd5..000000000 --- a/modules/tipi_scadenze/ajax/select.php +++ /dev/null @@ -1,36 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -switch ($resource) { - case 'tipi_scadenze': - $query = 'SELECT nome AS id, descrizione FROM co_tipi_scadenze |where| ORDER BY nome ASC'; - - foreach ($elements as $element) { - $filter[] = 'id='.prepare($element); - } - - if (!empty($search)) { - $search_fields[] = 'nome LIKE '.prepare('%'.$search.'%'); - $search_fields[] = 'descrizione LIKE '.prepare('%'.$search.'%'); - } - - break; -} diff --git a/modules/tipi_scadenze/edit.php b/modules/tipi_scadenze/edit.php deleted file mode 100755 index baeaa2ed0..000000000 --- a/modules/tipi_scadenze/edit.php +++ /dev/null @@ -1,77 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -// Collegamenti con scadenzaio (numerici) -$scadenze = $dbo->fetchNum('SELECT id FROM co_scadenziario WHERE tipo = '.prepare($record['nome'])); - -if ($record['can_delete'] and empty($scadenze)) { - $attr = ''; -} else { - $attr = 'readonly'; - echo '
    '.tr('Alcune impostazioni non possono essere modificate per questo tipo di scadenza.').'
    '; -} -?> -
    - - - - -
    -
    -

    -
    - -
    -
    - -
    - {[ "type": "text", "label": "", "name": "nome", "required": 1, "value": "$nome$", "extra": "" ]} -
    - -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1, "value": "$descrizione$" ]} -
    - -
    -
    -
    - -
    - - - '.tr('Ci sono _NUM_ scadenze collegate', [ - '_NUM_' => count($scadenze), - ]).'. - '; - } ?> - - - - - - diff --git a/modules/tipi_scadenze/init.php b/modules/tipi_scadenze/init.php deleted file mode 100755 index 67d151352..000000000 --- a/modules/tipi_scadenze/init.php +++ /dev/null @@ -1,24 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT * FROM `co_tipi_scadenze` WHERE id='.prepare($id_record)); -} diff --git a/modules/utenti/actions.php b/modules/utenti/actions.php deleted file mode 100755 index 5f8392ac4..000000000 --- a/modules/utenti/actions.php +++ /dev/null @@ -1,247 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Models\User; - -$id_utente = filter('id_utente'); - -switch (filter('op')) { - // Aggiunta nuovo gruppo - case 'add': - $nome = filter('nome'); - - // Verifico che questo nome gruppo non sia già stato usato - if ($dbo->fetchNum('SELECT nome FROM zz_groups WHERE nome='.prepare($nome)) == 0) { - $dbo->query('INSERT INTO zz_groups(nome, editable) VALUES('.prepare($nome).', 1)'); - $id_record = $dbo->lastInsertedID(); - - flash()->info(tr('Gruppo aggiunto!')); - } else { - flash()->error(tr('Gruppo già esistente!')); - } - break; - - // Abilita utente - case 'enable_user': - if ($dbo->query('UPDATE zz_users SET enabled=1 WHERE id='.prepare($id_utente))) { - flash()->info(tr('Utente abilitato!')); - } - break; - - // Disabilita utente - case 'disable_user': - if ($dbo->query('UPDATE zz_users SET enabled=0 WHERE id='.prepare($id_utente))) { - flash()->info(tr('Utente disabilitato!')); - } - break; - - // Cambio di password e username dell'utente - case 'update_user': - $username = filter('username'); - $email = filter('email'); - $password = filter('password'); - - $id_utente = filter('id_utente'); - if ($dbo->fetchNum('SELECT username FROM zz_users WHERE id != '.prepare($id_utente).' AND username='.prepare($username)) == 0) { - //Aggiunta/modifica utente - if (!empty($id_utente)) { - $utente = User::find($id_utente); - - $utente->username = $username; - $utente->email = $email; - - $cambia_password = filter('change_password'); - if (!empty($cambia_password)) { - $utente->password = $password; - } - } else { - $gruppo = \Models\Group::find($id_record); - $utente = User::build($gruppo, $username, $email, $password); - } - - // Foto - if (!empty($_FILES['photo']['tmp_name'])) { - $utente->photo = $_FILES['photo']; - } - - // Anagrafica - $id_anagrafica = filter('idanag'); - $utente->id_anagrafica = $id_anagrafica; - - $utente->save(); - - $dbo->query('DELETE FROM zz_user_sedi WHERE id_user = '.prepare($id_utente)); - $sedi = post('idsede'); - if (empty($sedi)) { - $sedi = [0]; - } - foreach ($sedi as $id_sede) { - $dbo->query('INSERT INTO `zz_user_sedi` (`id_user`,`idsede`) VALUES ('.prepare($id_utente).', '.prepare($id_sede).')'); - } - } else { - flash()->error(tr('Utente già esistente!')); - } - - break; - - // Aggiunta di un nuovo utente - case 'self_update': - $password = filter('password'); - - $utente = Auth::user(); - - if (!empty($password)) { - $utente->password = $password; - } elseif (!empty($_FILES['photo']['tmp_name'])) { - $utente->photo = $_FILES['photo']; - } - - $utente->save(); - - redirect(base_path().'/modules/utenti/info.php'); - - break; - - // Elimina utente + disattivazione token - case 'delete_user': - if ($dbo->query('DELETE FROM zz_users WHERE id='.prepare($id_utente))) { - flash()->info(tr('Utente eliminato!')); - - if ($dbo->query('DELETE FROM zz_tokens WHERE id_utente='.prepare($id_utente))) { - flash()->info(tr('Token eliminato!')); - } - } - break; - - // Abilita API utente - case 'token_enable': - $utente = User::find($id_utente); - - $already_token = $dbo->fetchOne('SELECT `id` FROM `zz_tokens` WHERE `id_utente` = '.prepare($id_utente))['id']; - - if (empty($already_token)) { - //Quando richiamo getApiTokens, non trovando nessun token abilitato ne crea uno nuovo - $tokens = $utente->getApiTokens(); - - foreach ($tokens as $token) { - $dbo->query('UPDATE zz_tokens SET enabled = 1 WHERE id = '.prepare($token['id'])); - flash()->info(tr('Token creato!')); - } - } elseif ($dbo->query('UPDATE zz_tokens SET enabled = 1 WHERE id_utente = '.prepare($id_utente))) { - flash()->info(tr('Token abilitato!')); - } - - break; - - // Disabilita API utente - case 'token_disable': - $utente = User::find($id_utente); - $tokens = $utente->getApiTokens(); - - foreach ($tokens as $token) { - $dbo->query('UPDATE zz_tokens SET enabled = 0 WHERE id = '.prepare($token['id'])); - } - - flash()->info(tr('Token disabilitato!')); - break; - - // Elimina gruppo - case 'deletegroup': - // Verifico se questo gruppo si può eliminare - $query = 'SELECT editable FROM zz_groups WHERE id='.prepare($id_record); - $rs = $dbo->fetchArray($query); - - if ($rs[0]['editable'] == 1) { - if ($dbo->query('DELETE FROM zz_groups WHERE id='.prepare($id_record))) { - $dbo->query('DELETE FROM zz_users WHERE idgruppo='.prepare($id_record)); - $dbo->query('DELETE FROM zz_tokens WHERE id_utente IN (SELECT id FROM zz_users WHERE idgruppo='.prepare($id_record).')'); - $dbo->query('DELETE FROM zz_permissions WHERE idgruppo='.prepare($id_record)); - flash()->info(tr('Gruppo e relativi utenti eliminati!')); - } - } else { - flash()->error(tr('Questo gruppo non si può eliminare!')); - } - - break; - - // Impostazione/reimpostazione dei permessi di accesso di default - case 'restore_permission': - //Gruppo Tecnici - if ($dbo->fetchArray('SELECT `nome` FROM `zz_groups` WHERE `id` = '.prepare($id_record))[0]['nome'] == 'Tecnici') { - $permessi = []; - $permessi['Dashboard'] = 'rw'; - $permessi['Anagrafiche'] = 'rw'; - $permessi['Interventi'] = 'rw'; - $permessi['Magazzino'] = 'rw'; - $permessi['Articoli'] = 'rw'; - - $dbo->query('DELETE FROM zz_permissions WHERE idgruppo='.prepare($id_record)); - - foreach ($permessi as $module_name => $permesso) { - $module_id = $dbo->fetchArray('SELECT `id` FROM `zz_modules` WHERE `name` = "'.$module_name.'"')[0]['id']; - - $dbo->insert('zz_permissions', [ - 'idgruppo' => $id_record, - 'idmodule' => $module_id, - 'permessi' => $permesso, - ]); - } - - flash()->info(tr('Permessi reimpostati')); - } - - break; - - // Aggiornamento dei permessi di accesso - case 'update_permission': - $permessi = filter('permesso'); - $idmodulo = filter('idmodulo'); - - // Verifico che ci sia il permesso per questo gruppo - if ($permessi != '-') { - $rs = $dbo->fetchArray('SELECT * FROM zz_permissions WHERE idgruppo='.prepare($id_record).' AND idmodule='.prepare($idmodulo)); - if (empty($rs)) { - $query = 'INSERT INTO zz_permissions(idgruppo, idmodule, permessi) VALUES('.prepare($id_record).', '.prepare($idmodulo).', '.prepare($permessi).')'; - } else { - $query = 'UPDATE zz_permissions SET permessi='.prepare($permessi).' WHERE id='.prepare($rs[0]['id']); - } - - // Aggiunta dei permessi relativi alle viste - $count = $dbo->fetchNum('SELECT * FROM `zz_group_view` WHERE `id_gruppo` = '.prepare($id_record).' AND `id_vista` IN (SELECT `id` FROM `zz_views` WHERE `id_module`='.prepare($idmodulo).')'); - - if (empty($count)) { - $results = $dbo->fetchArray('SELECT `id_vista` FROM `zz_group_view` WHERE `id_vista` IN (SELECT `id` FROM `zz_views` WHERE `id_module`='.prepare($idmodulo).')'); - - foreach ($results as $result) { - $dbo->attach('zz_group_view', ['id_vista' => $result['id_vista']], ['id_gruppo' => $id_record]); - } - } - } else { - $query = 'DELETE FROM zz_permissions WHERE idgruppo='.prepare($id_record).' AND idmodule='.prepare($idmodulo); - } - - $dbo->query($query); - - ob_end_clean(); - echo 'ok'; - - break; -} diff --git a/modules/utenti/add.php b/modules/utenti/add.php deleted file mode 100755 index afb7a3023..000000000 --- a/modules/utenti/add.php +++ /dev/null @@ -1,38 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "nome", "required": 1 ]} -
    -
    - - -
    -
    - -
    -
    -
    diff --git a/modules/utenti/ajax/select.php b/modules/utenti/ajax/select.php deleted file mode 100755 index 689ae3008..000000000 --- a/modules/utenti/ajax/select.php +++ /dev/null @@ -1,114 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -switch ($resource) { - case 'anagrafiche_utenti': - $query = 'SELECT `an_anagrafiche`.`idanagrafica` AS id, `an_anagrafiche`.`ragione_sociale` AS descrizione, `an_tipianagrafiche`.`descrizione` AS optgroup FROM `an_tipianagrafiche` INNER JOIN `an_tipianagrafiche_anagrafiche` ON `an_tipianagrafiche`.`idtipoanagrafica`=`an_tipianagrafiche_anagrafiche`.`idtipoanagrafica` INNER JOIN `an_anagrafiche` ON `an_anagrafiche`.`idanagrafica`=`an_tipianagrafiche_anagrafiche`.`idanagrafica` |where| ORDER BY `optgroup` ASC'; - - $where[] = 'an_anagrafiche.deleted_at IS NULL'; - - foreach ($elements as $element) { - $filter[] = 'an_anagrafiche.idanagrafica='.prepare($element); - } - - if (!empty($search)) { - $search_fields[] = 'an_anagrafiche.ragione_sociale LIKE '.prepare('%'.$search.'%'); - } - - if (!empty($search_fields)) { - $where[] = '('.implode(' OR ', $search_fields).')'; - } - - if (!empty($filter)) { - $where[] = '('.implode(' OR ', $filter).')'; - } - - $wh = ''; - if (count($where) != 0) { - $wh = 'WHERE '.implode(' AND ', $where); - } - $query = str_replace('|where|', $wh, $query); - - $rs = $dbo->fetchArray($query); - foreach ($rs as $r) { - if ($prev != $r['optgroup']) { - $results[] = ['text' => $r['optgroup'], 'children' => []]; - $prev = $r['optgroup']; - } - - $results[count($results) - 1]['children'][] = [ - 'id' => $r['id'], - 'text' => $r['descrizione'], - 'descrizione' => $r['descrizione'], - ]; - } - - break; - - case 'utenti': - $query = "SELECT zz_users.id AS id, if(`an_anagrafiche`.`idanagrafica` IS NOT NULL, CONCAT(`an_anagrafiche`.`ragione_sociale`, ' (', zz_users.username, ')'), zz_users.username) AS descrizione, `an_tipianagrafiche`.`descrizione` AS optgroup - FROM zz_users - LEFT JOIN `an_anagrafiche` ON `an_anagrafiche`.`idanagrafica` = `zz_users`.`idanagrafica` - INNER JOIN `an_tipianagrafiche_anagrafiche` ON `an_anagrafiche`.`idanagrafica`=`an_tipianagrafiche_anagrafiche`.`idanagrafica` - INNER JOIN `an_tipianagrafiche` ON `an_tipianagrafiche`.`idtipoanagrafica`=`an_tipianagrafiche_anagrafiche`.`idtipoanagrafica` - |where| ORDER BY `optgroup` ASC"; - - $where[] = 'an_anagrafiche.deleted_at IS NULL'; - - foreach ($elements as $element) { - $filter[] = 'zz_users.id='.prepare($element); - } - - if (!empty($search)) { - $search_fields[] = 'an_anagrafiche.ragione_sociale LIKE '.prepare('%'.$search.'%'); - $search_fields[] = 'zz_users.username LIKE '.prepare('%'.$search.'%'); - } - - if (!empty($search_fields)) { - $where[] = '('.implode(' OR ', $search_fields).')'; - } - - if (!empty($filter)) { - $where[] = '('.implode(' OR ', $filter).')'; - } - - $wh = ''; - if (count($where) != 0) { - $wh = 'WHERE '.implode(' AND ', $where); - } - $query = str_replace('|where|', $wh, $query); - - $rs = $dbo->fetchArray($query); - foreach ($rs as $r) { - if ($prev != $r['optgroup']) { - $results[] = ['text' => $r['optgroup'], 'children' => []]; - $prev = $r['optgroup']; - } - - $results[count($results) - 1]['children'][] = [ - 'id' => $r['id'], - 'text' => $r['descrizione'], - 'descrizione' => $r['descrizione'], - ]; - } - - break; -} diff --git a/modules/utenti/components/base.php b/modules/utenti/components/base.php deleted file mode 100755 index bf9d108df..000000000 --- a/modules/utenti/components/base.php +++ /dev/null @@ -1,64 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (!empty(filter('idanagrafica'))) { - $utente['id_anagrafica'] = filter('idanagrafica'); -} - -echo ' -
    -
    - {[ "type": "text", "label": "'.tr('Username').'", "name": "username", "required": 1, "value": "'.$utente['username'].'", "validation": "username||'.($utente['id'] ?: 0).'" ]} -
    -
    '; - -echo ' - -
    -
    - {[ "type": "text", "label": "'.tr('Email').'", "name": "email", "required": 0, "value": "'.$utente['email'].'" ]} -
    -
    '; - - echo ' - -
    -
    - {[ "type": "select", "label": "'.tr('Collega ad una anagrafica').'", "name": "idanag", "required": 1, "ajax-source": "anagrafiche_utenti", "value": "'.$utente['id_anagrafica'].'", "icon-after": "add|'.Modules::get('Anagrafiche')['id'].(isset($gruppo) ? '|tipoanagrafica='.$gruppo : '').'" ]} -
    -
    - -
    -
    - {[ "type": "select", "label": "'.tr('Sede').'", "name": "idsede[]", "ajax-source": "sedi_azienda", "multiple": "1", "value":"'.($sedi ?: '').'", "help": "'.tr('Sede Azienda abilitata per la movimentazione degli articoli.').'" ]} -
    -
    '; - -echo ' - '; diff --git a/modules/utenti/components/password.php b/modules/utenti/components/password.php deleted file mode 100755 index 7f9291caa..000000000 --- a/modules/utenti/components/password.php +++ /dev/null @@ -1,27 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo ' -
    -
    - {[ "type": "password", "label": "'.tr('Password').'", "name": "password", "strength": "#submit-button" ]} -
    -
    '; diff --git a/modules/utenti/components/photo.php b/modules/utenti/components/photo.php deleted file mode 100755 index e63a606f4..000000000 --- a/modules/utenti/components/photo.php +++ /dev/null @@ -1,33 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$user_photo = $user->photo; -if ($user_photo) { - echo ' -
    '.$user['username'].'
    '; -} - -echo ' -
    -
    - {[ "type": "file", "label": "'.tr('Foto utente').'", "name": "photo", "help": "'.tr('Dimensione consigliata 100x100 pixel').'" ]} -
    -
    '; diff --git a/modules/utenti/edit.php b/modules/utenti/edit.php deleted file mode 100755 index 530dc9a0e..000000000 --- a/modules/utenti/edit.php +++ /dev/null @@ -1,240 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$utenti = $dbo->fetchArray('SELECT *, (SELECT ragione_sociale FROM an_anagrafiche WHERE an_anagrafiche.idanagrafica=zz_users.idanagrafica ) AS ragione_sociale, (SELECT GROUP_CONCAT(descrizione SEPARATOR ", ") FROM an_tipianagrafiche INNER JOIN an_tipianagrafiche_anagrafiche ON an_tipianagrafiche.idtipoanagrafica=an_tipianagrafiche_anagrafiche.idtipoanagrafica WHERE idanagrafica=zz_users.idanagrafica GROUP BY idanagrafica) AS tipo FROM zz_users WHERE idgruppo='.prepare($record['id'])); - -echo ' -
    -
    -

    '.tr('Utenti _GROUP_', [ - '_GROUP_' => $record['nome'], - ]).'

    -
    - -
    '; - -if (!empty($utenti)) { - echo ' -
    - - - - - - - - - '; - - foreach ($utenti as $utente) { - echo ' - - '; - - if (!empty($utente['email'])) { - echo ' - '; - } else { - echo ' - '; - } - - if (!empty($utente['idanagrafica'])) { - echo ' - - '; - } else { - echo ' - - '; - } - - $sedi = $dbo->fetchOne('SELECT GROUP_CONCAT(nomesede SEPARATOR ", " ) as nomesede FROM zz_user_sedi INNER JOIN ((SELECT "0" AS id, "Sede legale" AS nomesede) UNION (SELECT id, nomesede FROM an_sedi)) sedi ON zz_user_sedi.idsede=sedi.id WHERE id_user='.prepare($utente['id']).' GROUP BY id_user ')['nomesede']; - - echo ' - '; - - echo ' - - '; - } - - echo ' -
    '.tr('Nome utente').''.tr('Email').''.tr('Ragione sociale').''.tr('Tipo di anagrafica').''.tr('Sedi').''.tr('Opzioni').'
    - '.$utente['username'].' - '.$utente['email'].'-'.Modules::link('Anagrafiche', $utente['idanagrafica'], $utente['ragione_sociale']).''.$utente['tipo'].'--'.$sedi.''; - - // Disabilitazione utente, se diverso da id_utente #1 (admin) - if ($utente['id'] == '1') { - echo ' -
    - -
    '; - } elseif ($utente['enabled'] == 1) { - echo ' - - - '; - } else { - echo ' - - - '; - } - - // Cambio password e nome utente - echo ' - '; - - // Disabilitazione token API, se diverso da id_utente #1 (admin) - $token = $dbo->fetchOne('SELECT `enabled` FROM `zz_tokens` WHERE `id_utente` = '.prepare($utente['id']).'')['enabled']; - - if ($utente['id'] == '1') { - echo ' -
    - -
    '; - } elseif (!empty($token)) { - echo ' - - - '; - } else { - echo ' - - - '; - } - - // Eliminazione utente, se diverso da id_utente #1 (admin) - if ($utente['id'] == '1') { - echo ' -
    - -
    '; - } else { - echo ' - - - '; - } - - echo ' -
    -
    '; -} else { - echo ' -
    - '.tr('Non ci sono utenti in questo gruppo').'. -
    '; -} - -echo ' - - '.tr('Aggiungi utente').' - -
    -
    '; - -// Aggiunta nuovo utente -echo ' -
    '; - -echo ' -
    -
    -

    '.tr('Permessi _GROUP_', [ - '_GROUP_' => $record['nome'], - ]).((empty($record['editable'])) ? ''.tr('Reimposta permessi').'' : '').'

    - -
    - -
    '; -if ($record['nome'] != 'Amministratori') { - echo ' -
    - - - - - '; - - $moduli = Modules::getHierarchy(); - - $permessi_disponibili = [ - '-' => tr('Nessun permesso'), - 'r' => tr('Sola lettura'), - 'rw' => tr('Lettura e scrittura'), - ]; - - for ($m = 0; $m < count($moduli); ++$m) { - echo menuSelection($moduli[$m], $id_record, -1, $permessi_disponibili); - } - - echo ' -
    '.tr('Modulo').''.tr('Permessi').'
    -
    '; -} else { - echo ' -
    - '.tr('Gli amministratori hanno accesso a qualsiasi modulo').'. -
    '; -} -echo ' -
    -
    '; - -// Eliminazione gruppo (se non è tra quelli di default) -if ($record['editable'] == 1) { - echo ' - - '; -} - -echo ' -'; diff --git a/modules/utenti/info.php b/modules/utenti/info.php deleted file mode 100755 index c3afa0b9f..000000000 --- a/modules/utenti/info.php +++ /dev/null @@ -1,147 +0,0 @@ -. - */ - -$skip_permissions = true; -include_once __DIR__.'/../../core.php'; - -$pageTitle = tr('Utente'); - -include_once App::filepath('include|custom|', 'top.php'); - -if (post('op') == 'self_update') { - include_once __DIR__.'/actions.php'; -} - -$user = Auth::user(); -$token = auth()->getToken(); - -$rs = $dbo->fetchArray('SELECT * FROM an_anagrafiche WHERE idanagrafica = '.prepare($user['idanagrafica'])); -$anagrafica = []; -if (!empty($rs)) { - $anagrafica = $rs[0]; -} - -$api = base_url().'/api/?token='.$token; -$module = Modules::get('Utenti e permessi'); - -echo ' -
    -
    -

    '.$user['username'].'

    -
    '.$user['gruppo'].'
    -
    - -
    '; - -$user_photo = $user->photo; -if ($user_photo) { - echo ' - '.$user['username'].''; -} else { - echo ' - '; -} - -echo ' -
    - -
    '; - -echo ' -
    -
    - -
    -
    -

    '.tr('API').'

    -
    - -
    -

    '.tr("Puoi utilizzare il token per accedere all'API del gestionale e per visualizzare il calendario su applicazioni esterne").'.

    - -

    '.tr('Token personale').': '.$token.'

    -

    '.tr("URL dell'API").': '.$api.'

    - -
    -
    -
    '; - -$link = $api.'&resource=sync'; -echo ' - -
    -
    -
    -

    '.tr('Calendario interventi').'

    -
    - -
    -

    '.tr("Per accedere al calendario eventi attraverso l'API, accedi al seguente link").':

    - '.$link.' -
    - -
    -

    '.tr('Configurazione').'

    -
    -
    -
    -

    '.tr("Per _ANDROID_, scarica un'applicazione dedicata dal _LINK_", [ - '_ANDROID_' => ''.tr('Android').'', - '_LINK_' => ''.tr('Play Store').'', - ]).'.

    - -

    '.tr("Per _APPLE_, puoi configurare un nuovo calendario dall'app standard del calendario", [ - '_APPLE_' => ''.tr('Apple').'', - ]).'.

    - -

    '.tr('Per _PC_ e altri client di posta, considerare le relative funzionalità o eventuali plugin', [ - '_PC_' => ''.tr('PC').'', - ]).'.

    -
    -
    -
    - -
    '; - -include_once App::filepath('include|custom|', 'bottom.php'); diff --git a/modules/utenti/init.php b/modules/utenti/init.php deleted file mode 100755 index c988b3493..000000000 --- a/modules/utenti/init.php +++ /dev/null @@ -1,24 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT * FROM `zz_groups` WHERE `id`='.prepare($id_record)); -} diff --git a/modules/utenti/modutil.php b/modules/utenti/modutil.php deleted file mode 100755 index 7335805d7..000000000 --- a/modules/utenti/modutil.php +++ /dev/null @@ -1,56 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -function menuSelection($element, $group_id, $depth, $permessi_disponibili) -{ - $dbo = database(); - ++$depth; - - $result = ' - - '.str_repeat('     ', $depth).$element['title'].' - - - - '; - - $submenus = $element['all_children']; - if (!empty($submenus)) { - foreach ($submenus as $submenu) { - $result .= menuSelection($submenu, $group_id, $depth, $permessi_disponibili, $perms_names); - } - } - - return $result; -} diff --git a/modules/utenti/self.php b/modules/utenti/self.php deleted file mode 100755 index 82628d6f2..000000000 --- a/modules/utenti/self.php +++ /dev/null @@ -1,49 +0,0 @@ -. - */ - -$skip_permissions = true; -include_once __DIR__.'/../../core.php'; - -$resource = filter('resource'); - -$user = Auth::user(); -$utente = $user->toArray(); - -echo ' -
    - '; - -if ($resource == 'password') { - include $structure->filepath('components/password.php'); -} elseif ($resource == 'photo') { - include $structure->filepath('components/photo.php'); -} - -echo ' - -
    -
    - -
    -
    -
    - -'; diff --git a/modules/utenti/src/API/v1/Login.php b/modules/utenti/src/API/v1/Login.php deleted file mode 100755 index 4d9947fb0..000000000 --- a/modules/utenti/src/API/v1/Login.php +++ /dev/null @@ -1,63 +0,0 @@ -. - */ - -namespace Modules\Utenti\API\v1; - -use API\Interfaces\CreateInterface; -use API\Resource; -use API\Response; -use Auth; -use Update; - -class Login extends Resource implements CreateInterface -{ - public function create($request) - { - $database = database(); - - // Controllo sulle credenziali - if (auth()->attempt($request['username'], $request['password'])) { - $user = $this->getUser(); - $token = auth()->getToken(); - - // Informazioni da restituire tramite l'API - $response['user'] = $database->fetchOne('SELECT `an_anagrafiche`.`idanagrafica` AS idanagrafica, `ragione_sociale`, `codice`, `piva`, `codice_fiscale`, `indirizzo`, `citta`, `provincia`, (SELECT `nome` FROM `an_nazioni` WHERE `an_nazioni`.`id` = `an_anagrafiche`.`id_nazione`) AS nazione, `telefono`, `fax`, `cellulare`, `an_anagrafiche`.`email` FROM `zz_users` LEFT JOIN `an_anagrafiche` ON `an_anagrafiche`.`idanagrafica` = `zz_users`.`idanagrafica` WHERE `id` = :id', [ - ':id' => $user['id'], - ]); - - $response['token'] = $token; - $response['group'] = $user['gruppo']; - $response['google_maps_token'] = setting('Google Maps API key'); - $response['prezzi_al_tecnico'] = setting('Mostra i prezzi al tecnico'); - - $response['version'] = Update::getVersion(); - } else { - $response = [ - 'status' => Response::getStatus()['unauthorized']['code'], - ]; - - // Se è in corso un brute-force, aggiunge il timeout - if (Auth::isBrute()) { - $response['timeout'] = Auth::getBruteTimeout(); - } - } - - return $response; - } -} diff --git a/modules/utenti/src/API/v1/Logout.php b/modules/utenti/src/API/v1/Logout.php deleted file mode 100755 index 2e0dd0b0e..000000000 --- a/modules/utenti/src/API/v1/Logout.php +++ /dev/null @@ -1,43 +0,0 @@ -. - */ - -namespace Modules\Utenti\API\v1; - -use API\Interfaces\CreateInterface; -use API\Resource; - -class Logout extends Resource implements CreateInterface -{ - public function create($request) - { - $database = database(); - $user = $this->getUser(); - - if (!empty($request['token']) && !empty($user)) { - // Cancellazione della chiave - $database->query('DELETE FROM `zz_tokens` WHERE `token` = '.prepare($request['token']).' AND `id_utente` = '.prepare($user['id'])); - } else { - $response = [ - 'status' => API\Response::getStatus()['unauthorized']['code'], - ]; - } - - return $response; - } -} diff --git a/modules/utenti/user.php b/modules/utenti/user.php deleted file mode 100755 index 95865ee3e..000000000 --- a/modules/utenti/user.php +++ /dev/null @@ -1,119 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Models\Group; -use Models\User; - -Permissions::check('rw'); - -$id_utente = filter('id_utente'); -$user = User::find($id_utente); -$utente = $user ? $user->toArray() : []; - -// Gruppo della selezione -if (!empty($id_record)) { - $gruppo_utente = Group::find($id_record)->descrizione; - - $gruppi = [ - 'Clienti' => 'Cliente', - 'Tecnici' => 'Tecnico', - 'Agenti' => 'Agente', - ]; - $gruppo = $gruppi[$gruppo_utente]; -} - -// Lettura sedi dell'utente già impostate -if (!empty($user)) { - $sedi = $dbo->fetchOne('SELECT GROUP_CONCAT(idsede) as sedi FROM zz_user_sedi WHERE id_user='.prepare($id_utente).' GROUP BY id_user')['sedi']; -} - -echo ' -
    - - - - '; - -include $structure->filepath('components/photo.php'); -include $structure->filepath('components/base.php'); - -if (!empty($user)) { - echo ' -
    -
    - {[ "type": "checkbox", "label": "'.tr('Cambia password').'", "name": "change_password", "value": "0" ]} -
    -
    - - '; -} - -include $structure->filepath('components/password.php'); - -echo ' - -
    -
    - -
    -
    -
    - - - -'; diff --git a/modules/utenti/validation.php b/modules/utenti/validation.php deleted file mode 100755 index 03888447f..000000000 --- a/modules/utenti/validation.php +++ /dev/null @@ -1,50 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Models\User; - -$name = filter('name'); -$value = filter('value'); - -switch ($name) { - case 'username': - $disponibile = User::where([ - ['username', $value], - ['id', '<>', $id_record], - ])->count() == 0; - - $message = $disponibile ? tr("L'username è disponbile") : tr("L'username è già in uso"); - $result = $disponibile; - - // Lunghezza minima del nome utente (username) - $min_length_username = 4; - if (strlen($value) < $min_length_username) { - $message .= '. '.tr("Lunghezza dell'username non sufficiente").'.'; - $result = false; - } - - $response = [ - 'result' => $result, - 'message' => $message, - ]; - - break; -} diff --git a/modules/utenti/variables.php b/modules/utenti/variables.php deleted file mode 100755 index 4a1d982d0..000000000 --- a/modules/utenti/variables.php +++ /dev/null @@ -1,28 +0,0 @@ -. - */ - -$record = \Models\User::find($id_record); - -$reset_token = $record->reset_token; - -return [ - 'username' => $record->username, - 'reset_token' => $reset_token, - 'reset_link' => base_url().'/reset.php?reset_token='.$reset_token, -]; diff --git a/modules/viste/actions.php b/modules/viste/actions.php deleted file mode 100755 index 0a7a88c8a..000000000 --- a/modules/viste/actions.php +++ /dev/null @@ -1,185 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Models\Module; - -switch (filter('op')) { - case 'update': - $options2 = htmlspecialchars_decode(post('options2'), ENT_QUOTES); - - if (check_query($options2)) { - $dbo->query('UPDATE `zz_modules` SET `title`='.prepare(post('title')).', `options2`='.prepare($options2).' WHERE `id`='.prepare($id_record)); - - $rs = true; - } else { - $rs = false; - } - - if ($rs) { - flash()->info(tr('Salvataggio completato!')); - } else { - flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio!')); - } - - break; - - case 'fields': - $rs = true; - - // Fix per la protezone contro XSS, che interpreta la sequenza " $query) { - if (check_query($query)) { - $array = [ - 'name' => post('name')[$c], - 'query' => $query, - 'visible' => post('visible')[$c], - 'search' => post('search')[$c], - 'slow' => post('slow')[$c], - 'format' => post('format')[$c], - 'summable' => post('sum')[$c], - 'search_inside' => post('search_inside')[$c], - 'order_by' => post('order_by')[$c], - 'id_module' => $id_record, - ]; - - if (!empty(post('id')[$c]) && !empty($query)) { - $id = post('id')[$c]; - - $dbo->update('zz_views', $array, ['id' => $id]); - } elseif (!empty($query)) { - $array['order'] = orderValue('zz_views', 'id_module', $id_record); - - $dbo->insert('zz_views', $array); - - $id = $dbo->lastInsertedID(); - } - - // Aggiornamento dei permessi relativi - $dbo->sync('zz_group_view', ['id_vista' => $id], ['id_gruppo' => (array) post('gruppi')[$c]]); - } else { - $rs = false; - } - } - - if ($rs) { - flash()->info(tr('Salvataggio completato!')); - } else { - flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio!')); - } - - break; - - case 'filters': - $rs = true; - - // Fix per la protezone contro XSS, che interpreta la sequenza " $query) { - $query = $_POST['query'][$c]; - - if (check_query($query)) { - $array = [ - 'name' => post('name')[$c], - 'idgruppo' => post('gruppo')[$c], - 'idmodule' => $id_record, - 'clause' => $query, - 'position' => !empty(post('position')[$c]) ? 'HVN' : 'WHR', - ]; - - if (!empty(post('id')[$c]) && !empty($query)) { - $id = post('id')[$c]; - - $dbo->update('zz_group_module', $array, ['id' => $id]); - } elseif (!empty($query)) { - $dbo->insert('zz_group_module', $array); - - $id = $dbo->lastInsertedID(); - } - } else { - $rs = false; - } - } - - if ($rs) { - flash()->info(tr('Salvataggio completato!')); - } else { - flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio!')); - } - - break; - - case 'change': - $id = filter('id'); - - $rs = $dbo->fetchArray('SELECT enabled FROM zz_group_module WHERE id='.prepare($id)); - - $dbo->update('zz_group_module', [ - 'enabled' => !empty($rs[0]['enabled']) ? 0 : 1, - ], ['id' => $id]); - - flash()->info(tr('Salvataggio completato!')); - - break; - - case 'test': - $module_query = Util\Query::getQuery(Module::find($id_record)); - - $dbo->fetchArray($module_query.' LIMIT 1'); - - break; - - case 'delete': - $id = filter('id'); - - $dbo->query('DELETE FROM `zz_views` WHERE `id`='.prepare($id)); - $dbo->query('DELETE FROM `zz_group_view` WHERE `id_vista`='.prepare($id)); - - flash()->info(tr('Eliminazione completata!')); - - break; - - case 'delete_filter': - $id = filter('id'); - - $dbo->query('DELETE FROM `zz_group_module` WHERE `id`='.prepare($id)); - - flash()->info(tr('Eliminazione completata!')); - - break; - - case 'update_position': - $order = explode(',', post('order', true)); - - foreach ($order as $i => $id_riga) { - $dbo->query('UPDATE `zz_views` SET `order` = '.prepare($i).' WHERE id='.prepare($id_riga)); - } - - break; - - case 'update_visible': - $visible = filter('visible'); - $id_riga = filter('id_vista'); - - $dbo->query('UPDATE `zz_views` SET `visible` = '.prepare($visible).' WHERE id = '.prepare($id_riga)); - - break; -} diff --git a/modules/viste/edit.php b/modules/viste/edit.php deleted file mode 100755 index fd5be85fa..000000000 --- a/modules/viste/edit.php +++ /dev/null @@ -1,154 +0,0 @@ -. - */ - -use Models\Module; - -include_once __DIR__.'/../../core.php'; - -$enable_readonly = !setting('Modifica Viste di default'); - -echo ' -
    - - - - -
    -
    -

    '.tr('Opzioni generali').'

    -
    - -
    '; -$options = ($record['options2'] == '') ? $record['options'] : $record['options2']; -if ($options == 'menu') { - echo ' -

    '.tr('Il modulo che stai analizzando è un semplice menu').'.

    '; -} elseif ($options == 'custom') { - echo ' -

    '.tr("Il modulo che stai analizzando possiede una struttura complessa, che prevede l'utilizzo di file personalizzati per la gestione delle viste").'.

    '; -} - -echo ' -
    -
    - {[ "type": "text", "label": "'.tr('Codice del modulo').'", "name": "name", "value": "'.$record['name'].'", "readonly": "1" ]} -
    - -
    - {[ "type": "text", "label": "'.tr('Nome del modulo').'", "name": "title", "value": "'.$record['title'].'", "help": "'.tr('Il nome che identifica il modulo').'" ]} -
    -
    - -
    -
    - {[ "type": "textarea", "label": "'.tr('Query di default').'", "name": "options", "value": '.json_encode(str_replace(']}', '] }', $record['options'])).', "readonly": "1", "class": "autosize" ]} -
    - -
    - {[ "type": "textarea", "label": "'.tr('Query personalizzata').'", "name": "options2", "value": '.json_encode(str_replace(']}', '] }', $record['options2'])).', "class": "autosize", "help": "'.tr('La query in sostituzione a quella di default: custom, menu oppure SQL').'" ]} -
    -
    '; - -if ($options != '' && $options != 'menu' && $options != 'custom') { - $module_query = Util\Query::getQuery(Module::find($id_record)); - - $beautiful_query = nl2br(htmlentities($module_query)); - $beautiful_query = str_replace(' ', '    ', $beautiful_query); - - echo ' -
    -
    -

    '.tr('Query risultante').':

    -
    '.$beautiful_query.'
    - -
    -
    - - - -
    -
    -
    -
    '; -} - -echo ' -
    -
    -
    '; - -if (!empty($options) && $options != 'custom' && $options != 'menu') { - echo ' -'; - - echo ' -'; -} diff --git a/modules/viste/fields.php b/modules/viste/fields.php deleted file mode 100755 index cb03faaca..000000000 --- a/modules/viste/fields.php +++ /dev/null @@ -1,262 +0,0 @@ -. - */ - -echo ' - -
    - - - -
    -
    -
    '; - -$key = 0; -$fields = $dbo->fetchArray('SELECT * FROM zz_views WHERE id_module='.prepare($record['id']).' ORDER BY `order` ASC'); -foreach ($fields as $key => $field) { - $editable = !($field['default'] && $enable_readonly); - - echo ' -
    -
    -

    '. - tr('Campo in posizione _POSITION_', [ - '_POSITION_' => $field['order'], - ]).' ('.$field['name'].') -

    - -
    - -
    '; - - if ($editable) { - echo ' - - '.tr('Elimina').' - '; - } - - echo ' -
    -
    -
    - - -
    - {[ "type": "text", "label": "'.tr('Nome').'", "name": "name['.$key.']", "value": "'.$field['name'].'", "readonly": "'.(!$editable).'", "help": "'.tr('Nome con cui il campo viene identificato e visualizzato nella tabella').'" ]} -
    -
    - -
    -
    - {[ "type": "textarea", "label": "'.tr('Query prevista').'", "name": "query['.$key.']", "value": "'.prepareToField($field['query']).'", "readonly": "'.(!$editable).'", "required": "1", "help": "'.tr('Nome effettivo del campo sulla tabella oppure subquery che permette di ottenere il valore del campo').'.
    '.tr('ATTENZIONE: utilizza sempre i caratteri < o > seguiti da spazio!').'" ]} -
    -
    - -
    -
    - {[ "type": "select", "label": "'.tr('Gruppi con accesso').'", "name": "gruppi['.$key.'][]", "multiple": "1", "values": "query=SELECT id, nome AS descrizione FROM zz_groups ORDER BY id ASC", "value": "'; - $results = $dbo->fetchArray('SELECT GROUP_CONCAT(DISTINCT id_gruppo SEPARATOR \',\') AS gruppi FROM zz_group_view WHERE id_vista='.prepare($field['id'])); - - echo $results[0]['gruppi'].'"'; - - echo ', "help": "'.tr('Gruppi di utenti in grado di visualizzare questo campo').'" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Visibilità').'", "name": "visible['.$key.']", "values": "list=\"0\":\"'.tr('Nascosto (variabili di stato)').'\",\"1\": \"'.tr('Visibile nella sezione').'\"", "value": "'.$field['visible'].'", "help": "'.tr('Stato del campo: visibile nella tabella oppure nascosto').'" ]} -
    -
    - -
    -
    - {[ "type": "checkbox", "label": "'.tr('Ricercabile').'", "name": "search['.$key.']", "value": "'.$field['search'].'", "help": "'.tr('Indica se il campo è ricercabile').'" ]} -
    - -
    - {[ "type": "checkbox", "label": "'.tr('Ricerca lenta').'", "name": "slow['.$key.']", "value": "'.$field['slow'].'", "help": "'.tr("Indica se la ricerca per questo campo è lenta (da utilizzare nel caso di evidenti rallentamenti, mostra solo un avviso all'utente").'" ]} -
    - -
    - {[ "type": "checkbox", "label": "'.tr('Sommabile').'", "name": "sum['.$key.']", "value": "'.$field['summable'].'", "help": "'.tr('Indica se il campo è da sommare').'" ]} -
    - -
    - {[ "type": "checkbox", "label": "'.tr('Formattabile').'", "name": "format['.$key.']", "value": "'.$field['format'].'", "help": "'.tr('Indica se il campo è formattabile in modo automatico').'" ]} -
    -
    - -
    -
    - {[ "type": "text", "label": "'.tr('Ricerca tramite').'", "name": "search_inside['.$key.']", "value": "'.$field['search_inside'].'", "readonly": "'.(!$editable).'", "help": "'.tr('Query personalizzata per la ricerca (consigliata per colori e icone)').'.
    '.tr('ATTENZIONE: utilizza sempre i caratteri < o > seguiti da spazio!').'" ]} -
    - -
    - {[ "type": "text", "label": "'.tr('Ordina tramite').'", "name": "order_by['.$key.']", "value": "'.$field['order_by'].'", "readonly": "'.(!$editable).'", "help": "'.tr("Query personalizzata per l'ordinamento (date e numeri formattati tramite query)").'.
    '.tr('ATTENZIONE: utilizza sempre i caratteri < o > seguiti da spazio!').'" ]} -
    -
    -
    -
    '; -} - -echo ' -
    - -
    -
    - - - -
    -
    - -
    - -
    -
    -
    -

    '.tr('Ordine di visualizzazione').'

    -
    - -
    '; - -foreach ($fields as $field) { - echo ' -

    - - '; - - if ($field['visible']) { - echo ''.$field['name'].''; - } else { - echo ''.$field['name'].''; - } - - echo ' -

    '; -} - -echo ' -
    -
    -
    -
    -
    '; - -echo ' -
    -
    -
    -

    '.tr('Nuovo campo').'

    -
    -
    -
    - -
    - {[ "type": "text", "label": "'.tr('Nome').'", "name": "name[-id-]" ]} -
    -
    - -
    -
    - {[ "type": "textarea", "label": "'.tr('Query prevista').'", "name": "query[-id-]" ]} -
    -
    - -
    -
    - {[ "type": "select", "label": "'.tr('Gruppi con accesso').'", "name": "gruppi[-id-][]", "multiple": "1", "values": "query=SELECT id, nome AS descrizione FROM zz_groups ORDER BY id ASC" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Visibilità').'", "name": "visible[-id-]", "values": "list=\"0\":\"'.tr('Nascosto (variabili di stato)').'\",\"1\": \"'.tr('Visibile nella sezione').'\"" ]} -
    -
    - -
    -
    - {[ "type": "checkbox", "label": "'.tr('Ricercabile').'", "name": "search[-id-]" ]} -
    - -
    - {[ "type": "checkbox", "label": "'.tr('Ricerca lenta').'", "name": "slow[-id-]" ]} -
    - -
    - {[ "type": "checkbox", "label": "'.tr('Sommabile').'", "name": "sum[-id-]" ]} -
    - -
    - {[ "type": "checkbox", "label": "'.tr('Formattabile').'", "name": "format[-id-]" ]} -
    -
    - -
    -
    - {[ "type": "text", "label": "'.tr('Ricerca tramite').'", "name": "search_inside[-id-]" ]} -
    - -
    - {[ "type": "text", "label": "'.tr('Ordina tramite').'", "name": "order_by[-id-]" ]} -
    -
    - -
    -
    -
    '; - -echo ' -'; diff --git a/modules/viste/filters.php b/modules/viste/filters.php deleted file mode 100755 index 9db68586d..000000000 --- a/modules/viste/filters.php +++ /dev/null @@ -1,161 +0,0 @@ -. - */ - -echo ' -
    - - - -
    '; - -$num = 0; -$additionals = $dbo->fetchArray('SELECT * FROM zz_group_module WHERE idmodule='.prepare($record['id']).' ORDER BY `id` ASC'); - -if (!empty($additionals)) { - foreach ($additionals as $num => $additional) { - $editable = !($additional['default'] && $enable_readonly); - - echo ' -
    -
    -

    '. - tr('Filtro: _NAME_', [ -'_NAME_' => $additional['name'], -]).' -

    -
    - -
    '; - - if ($editable) { - echo ' - - '.tr('Elimina').' - '; - } - - echo ' - - '.($additional['enabled'] ? tr('Disabilita') : tr('Abilita')).' - '; - echo ' -
    -
    - -
    -
    - {[ "type": "textarea", "label": "'.tr('Query').'", "name": "query['.$num.']", "value": "'.prepareToField($additional['clause']).'"'; - if (!$editable) { - echo ', "readonly": '.intval(!$editable).''; - } - echo ' ]} -
    -
    - -
    - - -
    - {[ "type": "text", "label": "'.tr('Name').'", "name": "name['.$num.']", "value": "'.$additional['name'].'" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Gruppo').'", "name": "gruppo['.$num.']", "values": "query=SELECT id, nome AS descrizione FROM zz_groups ORDER BY id ASC", "value": "'.$additional['idgruppo'].'", "readonly": '.intval(!$editable).' ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Posizione').'", "name": "position['.$num.']", "values": "list=\"0\":\"'.tr('WHERE').'\",\"1\": \"'.tr('HAVING').'\"", "value": "'.$additional['position'].'", "readonly": '.intval(!$editable).' ]} -
    -
    - -
    -
    '; - } -} else { - echo '
    -
    - - '.tr('Informazione:').' '.tr('Nessun filtro per questo modulo').'. -
    '; -} - -echo ' -
    - -
    -
    - - - -
    -
    -
    '; - -echo ' -
    -
    -
    -

    '.tr('Nuovo filtro').'

    -
    -
    - -
    -
    - {[ "type": "textarea", "label": "'.tr('Query').'", "name": "query[-id-]" ]} -
    -
    - -
    - - -
    - {[ "type": "text", "label": "'.tr('Nome').'", "name": "name[-id-]" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Gruppo').'", "name": "gruppo[-id-]", "values": "query=SELECT id, nome AS descrizione FROM zz_groups ORDER BY id ASC" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Posizione').'", "name": "position[-id-]", "values": "list=\"0\":\"'.tr('WHERE').'\",\"1\": \"'.tr('HAVING').'\"" ]} -
    -
    -
    -
    -
    '; - -echo ' -'; diff --git a/modules/viste/init.php b/modules/viste/init.php deleted file mode 100755 index 3deac71b6..000000000 --- a/modules/viste/init.php +++ /dev/null @@ -1,24 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT * FROM `zz_modules` WHERE id='.prepare($id_record)); -} diff --git a/modules/voci_servizio/actions.php b/modules/voci_servizio/actions.php deleted file mode 100755 index 320eeb2ab..000000000 --- a/modules/voci_servizio/actions.php +++ /dev/null @@ -1,47 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -switch (post('op')) { - case 'update': - $descrizione = post('descrizione'); - $categoria = post('categoria'); - - $dbo->query('UPDATE in_vociservizio SET descrizione='.prepare($descrizione).', categoria='.prepare($categoria).' WHERE id='.prepare($id_record)); - - flash()->info(tr('Informazioni salvate correttamente!')); - - break; - - case 'add': - $descrizione = post('descrizione'); - $categoria = post('categoria'); - - $dbo->query('INSERT INTO in_vociservizio(descrizione, categoria) VALUES ('.prepare($descrizione).', '.prepare($categoria).')'); - $id_record = $dbo->lastInsertedID(); - - flash()->info(tr('Nuova voce di servizio aggiunta!')); - - break; - - case 'delete': - $dbo->query('DELETE FROM in_vociservizio WHERE id='.prepare($id_record)); - break; -} diff --git a/modules/voci_servizio/add.php b/modules/voci_servizio/add.php deleted file mode 100755 index 36fef7e77..000000000 --- a/modules/voci_servizio/add.php +++ /dev/null @@ -1,42 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "categoria", "required": 1 ]} -
    - -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1 ]} -
    -
    - - -
    -
    - -
    -
    -
    diff --git a/modules/voci_servizio/edit.php b/modules/voci_servizio/edit.php deleted file mode 100755 index 94adba782..000000000 --- a/modules/voci_servizio/edit.php +++ /dev/null @@ -1,40 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - - -
    -
    - {[ "type": "text", "label": "", "name": "categoria", "required": 1, "value": "$categoria$" ]} -
    - -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1, "value": "$descrizione$" ]} -
    -
    -
    - - - - diff --git a/modules/voci_servizio/init.php b/modules/voci_servizio/init.php deleted file mode 100755 index 504775833..000000000 --- a/modules/voci_servizio/init.php +++ /dev/null @@ -1,24 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT * FROM in_vociservizio WHERE id='.prepare($id_record)); -} diff --git a/modules/zone/actions.php b/modules/zone/actions.php deleted file mode 100755 index 4579e188b..000000000 --- a/modules/zone/actions.php +++ /dev/null @@ -1,76 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -switch (post('op')) { - case 'update': - $id_zona = post('id_record'); - $nome = post('nome'); - $descrizione = post('descrizione'); - - // Verifico che il nome o la descrizione non esistano già - $n = $dbo->fetchNum('SELECT id FROM an_zone WHERE (nome='.prepare($nome).' OR descrizione='.prepare($descrizione).') AND NOT id='.prepare($id_zona)); - - // Zona già esistente - if ($n > 0) { - flash()->error(tr('Zona già esistente!')); - } - // Zona non esistente - else { - $dbo->query('UPDATE an_zone SET nome='.prepare($nome).', descrizione='.prepare($descrizione).' WHERE id='.prepare($id_zona).' AND `default`=0'); - flash()->info(tr('Informazioni salvate correttamente!')); - } - - break; - - case 'add': - $nome = post('nome'); - $descrizione = post('descrizione'); - - // Verifico che il nome non sia duplicato - $n = $dbo->fetchNum('SELECT id FROM an_zone WHERE nome='.prepare($nome).' OR descrizione='.prepare($descrizione)); - - if ($n > 0) { - flash()->error(tr('Nome già esistente!')); - } else { - $query = 'INSERT INTO an_zone(`nome`, `descrizione`, `default`) VALUES ('.prepare($nome).', '.prepare($descrizione).', 0)'; - $dbo->query($query); - - $id_record = $dbo->lastInsertedID(); - - if (isAjaxRequest()) { - echo json_encode(['id' => $id_record, 'text' => $nome.' - '.$descrizione]); - } - - flash()->info(tr('Aggiunta una nuova zona!')); - } - - break; - - case 'delete': - $dbo->query('DELETE FROM an_zone WHERE id='.prepare($id_record).' AND `default`=0'); - - // Reimposto a 0 tutti gli idzona su an_anagrafiche (scollego la zona da tutte le anagrafiche associate) - $dbo->query('UPDATE an_anagrafiche SET idzona = 0 WHERE idanagrafica='.prepare($id_record)); - - flash()->info(tr('Zona eliminata!')); - - break; -} diff --git a/modules/zone/add.php b/modules/zone/add.php deleted file mode 100755 index d55aa60d3..000000000 --- a/modules/zone/add.php +++ /dev/null @@ -1,42 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?>
    - - - -
    -
    - {[ "type": "text", "label": "", "name": "nome", "required": 1, "maxlength": 25, "class": "alphanumeric-mask" ]} -
    - -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1 ]} -
    -
    - - -
    -
    - -
    -
    -
    diff --git a/modules/zone/ajax/select.php b/modules/zone/ajax/select.php deleted file mode 100755 index cffb7dcc0..000000000 --- a/modules/zone/ajax/select.php +++ /dev/null @@ -1,35 +0,0 @@ -. - */ - -include_once __DIR__.'/../../../core.php'; - -switch ($resource) { - case 'zone': - $query = 'SELECT `id`, CONCAT(`nome`, \' - \', `descrizione`) AS `descrizione` FROM an_zone |where| ORDER BY descrizione ASC'; - - foreach ($elements as $element) { - $filter[] = 'id='.prepare($element); - } - if (!empty($search)) { - $search_fields[] = 'nome LIKE '.prepare('%'.$search.'%'); - $search_fields[] = 'descrizione LIKE '.prepare('%'.$search.'%'); - } - - break; -} diff --git a/modules/zone/edit.php b/modules/zone/edit.php deleted file mode 100755 index 15dad42f8..000000000 --- a/modules/zone/edit.php +++ /dev/null @@ -1,41 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -?> -
    - - - - -
    -
    - {[ "type": "text", "label": "", "name": "nome", "required": 1, "maxlength": 25, "class": "alphanumeric-mask", "value": "$nome$" ]} -
    - -
    - {[ "type": "text", "label": "", "name": "descrizione", "required": 1, "value": "$descrizione$" ]} -
    -
    -
    - - - - diff --git a/modules/zone/init.php b/modules/zone/init.php deleted file mode 100755 index 4c27daed9..000000000 --- a/modules/zone/init.php +++ /dev/null @@ -1,24 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT * FROM an_zone WHERE id='.prepare($id_record)); -} diff --git a/oauth2.php b/oauth2.php deleted file mode 100644 index 49c325c5a..000000000 --- a/oauth2.php +++ /dev/null @@ -1,53 +0,0 @@ -first(); -} else { - $account = Account::find(get('id_account')); - - // Impostazione access token a null per reimpostare la configurazione - $account->access_token = null; - $account->refresh_token = null; - $account->save(); -} - -if (empty($account)) { - echo tr('Errore durante il completamento della configurazione: account non trovato'); - - return; -} - -// Inizializzazione -$oauth2 = new OAuth2($account); - -// Redirect all'URL di autorizzazione del servizio esterno -$redirect = $oauth2->configure($code, $state); - -// Redirect automatico al record -if (empty($redirect)) { - $modulo_account_email = Module::pool('Account email'); - $redirect = base_path().'/editor.php?id_module='.$modulo_account_email->id.'&id_record='.$account->id; -} - -if (empty($_GET['error'])) { - redirect($redirect); - exit(); -} else { - echo $_GET['error'].'
    '.$_GET['error_description'].' -

    -'.tr('Riprova').''; -} diff --git a/package.json b/package.json old mode 100755 new mode 100644 index d1cb56a98..c22c5a886 --- a/package.json +++ b/package.json @@ -1,82 +1,15 @@ { "private": true, - "main": "gulpfile.js", - "dependencies": { - "admin-lte": "^2.4.0", - "autocompleter": "^6.1.1", - "autonumeric": "^4.6.0", - "autosize": "^3.0.21", - "bootstrap": "^3.3.7", - "bootstrap-colorpicker": "2.5.1", - "bootstrap-daterangepicker": "^2.1.25", - "bootstrap-maxlength": "^1.10.0", - "chart.js": "^2.7.0", - "ckeditor4": "ckeditor/ckeditor-releases#full/latest", - "components-jqueryui": "^1.12.1", - "datatables.net-bs": "^1.10.15", - "datatables.net-buttons-bs": "^1.3.1", - "datatables.net-scroller-bs": "^1.4.2", - "datatables.net-select-bs": "^1.2.2", - "dropzone": "^5.7.2", - "eonasdan-bootstrap-datetimepicker": "^4.17.47", - "font-awesome": "^4.7.0", - "fullcalendar": "^3.4.0", - "geocomplete": "^1.7.0", - "hotkeys-js": "^3.8.5", - "html5sortable": "^0.13.2", - "inputmask": "^3.3.9", - "jquery": "^3.5.1", - "jquery-form": "^4.2.1", - "jquery-ui-touch-punch": "^0.2.3", - "jquery.shorten": "^1.0.0", - "moment": "^2.18.1", - "numeral": "^2.0.6", - "parsleyjs": "^2.7.2", - "pdf.js": "mozilla/pdf.js#gh-pages", - "pwstrength-bootstrap": "^3.0.4", - "select2": "^4.0.3", - "select2-bootstrap-theme": "^0.1.0-beta.10", - "signature_pad": "^2.1.1", - "smartwizard": "^4.2.2", - "sweetalert2": "^6.11.4", - "toastr": "^2.1.4", - "tooltipster": "^4.2.5" + "scripts": { + "dev": "npm run development", + "development": "mix", + "watch": "mix watch", + "watch-poll": "mix watch -- --watch-options-poll=1000", + "hot": "mix watch --hot", + "prod": "npm run production", + "production": "mix --production" }, "devDependencies": { - "@babel/core": "^7.11.1", - "@babel/preset-env": "^7.11.0", - "archiver": "^3.0.0", - "cwd": "^0.10.0", - "del": "^4.0.0", - "globby": "^11.0.1", - "gulp": "^4.0.2", - "gulp-autoprefixer": "^7.0.0", - "gulp-babel": "^8.0.0", - "gulp-clean-css": "^4.0.0", - "gulp-concat": "^2.6.0", - "gulp-debug": "^4.0.0", - "gulp-flatten": "^0.4.0", - "gulp-if": "^2.0.2", - "gulp-json-minify": "^1.0.5", - "gulp-less": "^4.0.1", - "gulp-rename": "^1.4.0", - "gulp-sass": "^4.0.2", - "gulp-stylus": "^2.6.0", - "gulp-uglify": "^3.0.2", - "gulp-util": "^3.0.8", - "inquirer": "^4.0.1", - "main-bower-files": "^2.13.1", - "md5-file": "^5.0.0", - "shelljs": "^0.7.7" - }, - "scripts": { - "gulp": "gulp", - "release-OSM": "yarn run develop-OSM && php composer.phar install --no-dev && gulp release", - "develop-OSM": "yarn install && yarn run install-OSM && yarn run assets-OSM", - "install-OSM": "php composer.phar update", - "assets-OSM": "yarn upgrade && yarn run build-OSM", - "build-OSM": "gulp", - "dump-OSM": "php composer.phar dump-autoload", - "windows-fix": "yarn global add windows-build-tools" + "laravel-mix": "^6" } } diff --git a/pdfgen.php b/pdfgen.php deleted file mode 100755 index efe378703..000000000 --- a/pdfgen.php +++ /dev/null @@ -1,50 +0,0 @@ -. - */ - -include_once __DIR__.'/core.php'; - -$directory = !empty($directory) ? $directory : null; -$id_print = get('id_print'); - -// Retrocompatibilitaà -$ptype = get('ptype'); -if (!empty($ptype)) { - $print = $dbo->fetchArray('SELECT id, previous FROM zz_prints WHERE directory = '.prepare($ptype).' ORDER BY predefined DESC LIMIT 1'); - $id_print = $print[0]['id']; - - $id_record = !empty($id_record) ? $id_record : get($print[0]['previous']); -} - -$result = Prints::render($id_print, $id_record, $directory); - -if (empty($result)) { - echo ' -
    -

    - '.tr('Record non trovato').' -

    - '.tr('Stai cercando di accedere ad un record eliminato o non presente').'. -

    -
    - - - '.tr('Indietro').' - -
    '; -} diff --git a/plugins/checks.php b/plugins/checks.php deleted file mode 100755 index 9f6635891..000000000 --- a/plugins/checks.php +++ /dev/null @@ -1,134 +0,0 @@ -. - */ - -include_once __DIR__.'/../core.php'; - -$checklist_module = Modules::get('Checklists'); -$checks_id = 'checklist_'.$id_module.'_'.$id_plugin; - -echo ' -
    -
    -
    -

    '.tr('Checklist').'

    -
    -
    -
    -
    - - '.tr('Caricamento...').' -
    -
    '; - -// Form per la creazione di una nuova checklist -if ($structure->permission == 'rw') { - echo ' - - -
    -
    '; -} - -$checks = $structure->mainChecks($id_record); - -echo ' -
      '; - - foreach ($checks as $check) { - echo renderChecklist($check); - } - - echo ' -
    -
    -
    -
    '; - -echo ' - - -'; diff --git a/plugins/componenti/actions.php b/plugins/componenti/actions.php deleted file mode 100644 index 9a899844c..000000000 --- a/plugins/componenti/actions.php +++ /dev/null @@ -1,124 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Carbon\Carbon; - -$operazione = filter('op'); - -switch ($operazione) { - case 'update': - $articolo = (array) post('id_articolo'); - $data_installazione = (array) post('data_installazione'); - $data_disinstallazione = (array) post('data_disinstallazione'); - $data_registrazione = (array) post('data_registrazione'); - $note = (array) post('note'); - - $key = key($articolo); - - if (post('sostituito')) { - $field_articolo = 'pre_id_articolo'; - } else { - $field_articolo = 'id_articolo'; - } - - $dbo->update('my_componenti_articoli', [ - $field_articolo => $articolo[$key], - 'data_installazione' => $data_installazione[$key] ?: null, - 'data_disinstallazione' => $data_disinstallazione[$key] ?: null, - 'data_registrazione' => $data_registrazione[$key] ?: null, - 'note' => $note[$key], - ], ['id' => $key]); - - flash()->info(tr('Salvataggio completato!')); - $dbo->commitTransaction(); - header('Location: '.base_path().'/editor.php?id_module='.$id_module.'&id_record='.$id_record.'#tab_'.$id_plugin); - exit; - - break; - - case 'add': - $dbo->insert('my_componenti_articoli', [ - 'id_impianto' => $id_record, - 'data_registrazione' => Carbon::now(), - 'id_articolo' => post('id_articolo'), - ]); - - flash()->info(tr('Salvataggio completato!')); - - break; - - case 'sostituisci': - $old_id = get('id_old'); - $old = $dbo->selectOne('my_componenti_articoli', '*', ['id' => $old_id]); - - if (!empty($old['id_articolo'])) { - if (empty($old['data_disinstallazione'])) { - $data = Carbon::now(); - } else { - $data = $old['data_disinstallazione']; - } - - $dbo->update('my_componenti_articoli', [ - 'pre_id_articolo' => $old['id_articolo'], - 'id_articolo' => 0, - 'data_disinstallazione' => $data, - ], [ - 'id' => $old_id, - ]); - - $dbo->query('CREATE TEMPORARY TABLE tmp SELECT * FROM my_componenti_articoli WHERE id= '.prepare($old_id)); - $dbo->query('ALTER TABLE tmp DROP id'); - $dbo->query('INSERT INTO my_componenti_articoli SELECT NULL,tmp. * FROM tmp'); - $new_id = $dbo->lastInsertedID(); - $dbo->query('DROP TEMPORARY TABLE tmp'); - - $dbo->update('my_componenti_articoli', [ - 'id_articolo' => $old['id_articolo'], - 'pre_id_articolo' => 0, - 'data_registrazione' => Carbon::now(), - 'data_installazione' => $data, - 'data_disinstallazione' => null, - ], [ - 'id' => $new_id, - ]); - - flash()->info(tr('Informazioni salvate correttamente!')); - } else { - flash()->warning(tr('Inserire un articolo prima di effettuare la sostituzione!')); - } - - $dbo->commitTransaction(); - header('Location: '.base_path().'/editor.php?id_module='.$id_module.'&id_record='.$id_record.'#tab_'.$id_plugin); - exit; - - break; - - case 'delete': - $dbo->query('DELETE FROM my_componenti_articoli WHERE id='.prepare(get('id'))); - - flash()->info(tr('Componente eliminato!')); - - $dbo->commitTransaction(); - header('Location: '.base_path().'/editor.php?id_module='.$id_module.'&id_record='.$id_record.'#tab_'.$id_plugin); - exit; - - break; -} diff --git a/plugins/componenti/add.php b/plugins/componenti/add.php deleted file mode 100644 index 833d680a7..000000000 --- a/plugins/componenti/add.php +++ /dev/null @@ -1,40 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo ' -
    - - - - -
    -
    - {["type": "select", "label": "'.tr('Articolo').'", "name": "id_articolo", "ajax-source": "articoli", "value": "", "required": 1, "select-options": {"permetti_movimento_a_zero": 1} ]} -
    -
    - - -
    -
    - -
    -
    -
    '; diff --git a/plugins/componenti/allegati.php b/plugins/componenti/allegati.php deleted file mode 100644 index 4936cbc74..000000000 --- a/plugins/componenti/allegati.php +++ /dev/null @@ -1,22 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo '{( "name": "filelist_and_upload", "id":"'.rand(1, 999).'", "id_record": "'.get('id').'", "id_module": "'.$id_module.'", "id_plugin": "'.$id_plugin.'" )}'; diff --git a/plugins/componenti/edit.php b/plugins/componenti/edit.php deleted file mode 100644 index 3e8010aab..000000000 --- a/plugins/componenti/edit.php +++ /dev/null @@ -1,194 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo '
    '; - -$componenti = $dbo->fetchArray('SELECT my_componenti_articoli.*, my_impianti.idanagrafica, CONCAT(a.codice, " - ", a.descrizione) AS art_sostituito, CONCAT(b.codice, " - ", b.descrizione) AS art_installato, a.codice FROM my_componenti_articoli LEFT JOIN my_impianti ON my_componenti_articoli.id_impianto=my_impianti.id LEFT JOIN mg_articoli AS a ON my_componenti_articoli.pre_id_articolo=a.id LEFT JOIN mg_articoli AS b ON my_componenti_articoli.id_articolo=b.id WHERE id_impianto='.prepare($id_record).' ORDER BY data_registrazione, id_articolo DESC'); - -$installati = 0; -$disinstallati = 0; - -foreach ($componenti as $componente) { - if (!empty($componente['pre_id_articolo'])) { - $id_articolo = $componente['pre_id_articolo']; - $check_value = 1; - $box = 'danger'; - $articolo = $componente['art_sostituito']; - $data = dateFormat($componente['data_disinstallazione']); - $text = 'DISINSTALLATO'; - $class = 'danger'; - $title = ''.tr('Storico').''; - $table = 'default'; - if ($disinstallati == 0) { - echo ' -
    -
    -

    ARTICOLI DISINSTALLATI

    -
    -
    -
    '; - ++$disinstallati; - } - } else { - $id_articolo = $componente['id_articolo']; - $check_value = 0; - $box = 'primary'; - $articolo = $componente['art_installato']; - $data = dateFormat($componente['data_installazione']); - $text = 'INSTALLATO'; - $class = 'primary'; - $title = ''.tr('Dati').''; - $table = 'primary'; - if ($installati == 0) { - echo ' -
    -
    -

    ARTICOLI INSTALLATI

    -
    -
    -
    '; - ++$installati; - } - } - - $allegati = $dbo->fetchOne('SELECT COUNT(id) AS num FROM zz_files WHERE id_plugin='.prepare($id_plugin).' AND id_record='.$componente['id'].' GROUP BY id_record')['num']; - - if ($allegati) { - $icon = 'fa fa-check text-success'; - } else { - $icon = 'fa fa-times text-danger'; - } - - echo ' -
    - - - - - - - -
    -
    -
    - - - - - - - - - - - - - - - -
    '.tr('ARTICOLO').' - '.$text.''.tr('REGISTRAZIONE').''.tr('ALLEGATI').'
    '.$articolo.''.$data.''.dateFormat($componente['data_registrazione']).'
    -
    - -
    - -
    -
    -
    -
    -
    -

    '.$title.'

    -
    - - -
    - -
    -
    - {[ "type":"select","label":"'.tr('Articolo').'","name":"id_articolo['.$componente['id'].']", "required":"1","value":"'.$id_articolo.'", "ajax-source": "articoli", "select-options": {"permetti_movimento_a_zero": 1} ]} -
    -
    - {[ "type":"date","label":"'.tr('Data registrazione').'","name":"data_registrazione['.$componente['id'].']", "value":"'.$componente['data_registrazione'].'" ]} -
    -
    - {[ "type":"date","label":"'.tr('Data installazione').'","name":"data_installazione['.$componente['id'].']", "value":"'.$componente['data_installazione'].'" ]} -
    - -
    - {[ "type":"date","label":"'.tr('Data disinstallazione').'","name":"data_disinstallazione['.$componente['id'].']", "value":"'.$componente['data_disinstallazione'].'" ]} -
    -
    - -
    -
    - {[ "type":"textarea","label":"'.tr('Note').'","name":"note['.$componente['id'].']", "value":"'.$componente['note'].'" ]} -
    -
    - - -
    -
    - -
    - '; - - if (!empty($componente['id_articolo'])) { - echo ' -
    - -
    '; - } - echo ' -
    - -
    -
    -
    -
    -
    -
    -
    -
    '; -} - -echo ' -'; diff --git a/plugins/dichiarazioni_intento/actions.php b/plugins/dichiarazioni_intento/actions.php deleted file mode 100755 index 5a6c777eb..000000000 --- a/plugins/dichiarazioni_intento/actions.php +++ /dev/null @@ -1,68 +0,0 @@ -. - */ - -use Modules\Anagrafiche\Anagrafica; -use Plugins\DichiarazioniIntento\Dichiarazione; - -include_once __DIR__.'/../../core.php'; - -$operazione = filter('op'); - -switch ($operazione) { - case 'add': - $anagrafica = Anagrafica::find($id_parent); - $dichiarazione = Dichiarazione::build($anagrafica, post('data'), post('numero_protocollo'), post('numero_progressivo'), post('data_inizio'), post('data_fine')); - - $dichiarazione->massimale = post('massimale'); - $dichiarazione->data_protocollo = post('data_protocollo'); - $dichiarazione->data_emissione = post('data_emissione'); - $dichiarazione->save(); - - $id_record = $dichiarazione->id; - - if (isAjaxRequest() && !empty($id_record)) { - echo json_encode(['id' => $id_record, 'text' => $dichiarazione->numero_protocollo.' - '.$dichiarazione->numero_progressivo]); - } - - flash()->info(tr("Dichiarazione d'intento aggiunta!")); - - break; - - case 'update': - $dichiarazione->massimale = post('massimale'); - $dichiarazione->data = post('data'); - $dichiarazione->numero_protocollo = post('numero_protocollo'); - $dichiarazione->numero_progressivo = post('numero_progressivo'); - $dichiarazione->data_inizio = post('data_inizio'); - $dichiarazione->data_fine = post('data_fine'); - $dichiarazione->data_protocollo = post('data_protocollo'); - $dichiarazione->data_emissione = post('data_emissione'); - $dichiarazione->save(); - - flash()->info(tr("Dichiarazione d'intento aggiornata!")); - - break; - - case 'delete': - $dichiarazione->delete(); - - flash()->info(tr("Dichiarazione d'intento eliminata!")); - - break; -} diff --git a/plugins/dichiarazioni_intento/add.php b/plugins/dichiarazioni_intento/add.php deleted file mode 100755 index 1b239f2e6..000000000 --- a/plugins/dichiarazioni_intento/add.php +++ /dev/null @@ -1,75 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo ' -
    - - - - - - - -
    - -
    - {[ "type": "text", "label": "'.tr('Numero progressivo').'", "name": "numero_progressivo", "required": 1 ]} -
    - -
    - {[ "type": "date", "label": "'.tr('Data di ricezione').'", "name": "data", "required": 1, "value": "-now-" ]} -
    - -
    - {[ "type": "text", "label": "'.tr('Numero protocollo').'", "name": "numero_protocollo", "required": 1 ]} -
    - -
    - {[ "type": "date", "label": "'.tr('Data protocollo').'", "name": "data_protocollo", "required": 1 ]} -
    - -
    - -
    -
    - {[ "type": "date", "label": "'.tr('Data di inizio').'", "name": "data_inizio", "required": 1 ]} -
    - -
    - {[ "type": "date", "label": "'.tr('Data di fine').'", "name": "data_fine", "required": 1 ]} -
    - -
    - {[ "type": "number", "label": "'.tr('Massimale').'", "name": "massimale", "required": 1, "icon-after": "'.currency().'" ]} -
    - -
    - {[ "type": "date", "label": "'.tr('Data di emissione').'", "name": "data_emissione", "required": 1 ]} -
    -
    - - -
    -
    - -
    -
    -
    '; diff --git a/plugins/dichiarazioni_intento/edit.php b/plugins/dichiarazioni_intento/edit.php deleted file mode 100755 index a5bb76d84..000000000 --- a/plugins/dichiarazioni_intento/edit.php +++ /dev/null @@ -1,101 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo ' -
    - - - - - - -
    -
    - {[ "type": "text", "label": "'.tr('Numero progressivo').'", "name": "numero_progressivo", "required": 1, "value": "'.$record['numero_progressivo'].'" ]} -
    - -
    - {[ "type": "date", "label": "'.tr('Data di ricezione').'", "name": "data", "required": 1, "value": "'.$record['data'].'" ]} -
    - -
    - {[ "type": "text", "label": "'.tr('Numero protocollo').'", "name": "numero_protocollo", "required": 1, "value": "'.$record['numero_protocollo'].'" ]} -
    - -
    - {[ "type": "date", "label": "'.tr('Data protocollo').'", "name": "data_protocollo", "value": "'.$record['data_protocollo'].'", "required": 1 ]} -
    -
    - -
    -
    - {[ "type": "date", "label": "'.tr('Data di inizio').'", "name": "data_inizio", "required": 1, "value": "'.$record['data_inizio'].'" ]} -
    - -
    - {[ "type": "date", "label": "'.tr('Data di fine').'", "name": "data_fine", "required": 1, "value": "'.$record['data_fine'].'" ]} -
    - -
    - {[ "type": "number", "label": "'.tr('Massimale').'", "name": "massimale", "required": 1, "icon-after": "'.currency().'", "value": "'.$record['massimale'].'" ]} -
    - -
    - {[ "type": "date", "label": "'.tr('Data di emissione').'", "name": "data_emissione", "value": "'.$record['data_emissione'].'", "required": 1 ]} -
    -
    - -
    -
    - '.tr('Totale utilizzato').': '.moneyFormat($record['totale']).' -
    -
     
    -
    - -'; - -// Collegamenti diretti (numerici) -$numero_documenti = $dbo->fetchNum('SELECT id FROM co_documenti WHERE id_dichiarazione_intento='.prepare($id_record)); - -if (!empty($numero_documenti)) { - echo ' -
    - '.tr('Ci sono _NUM_ documenti collegati', [ - '_NUM_' => $numero_documenti, - ]).'. -
    '; -} - -echo ' - - -
    -
    - - '.tr('Elimina').' - - - -
    -
    -
    '; diff --git a/plugins/dichiarazioni_intento/init.php b/plugins/dichiarazioni_intento/init.php deleted file mode 100755 index eb7bf0adc..000000000 --- a/plugins/dichiarazioni_intento/init.php +++ /dev/null @@ -1,28 +0,0 @@ -. - */ - -use Plugins\DichiarazioniIntento\Dichiarazione; - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $dichiarazione = Dichiarazione::find($id_record); - - $record = $dichiarazione ? $dichiarazione->toArray() : []; -} diff --git a/plugins/dichiarazioni_intento/src/Dichiarazione.php b/plugins/dichiarazioni_intento/src/Dichiarazione.php deleted file mode 100755 index e1218c184..000000000 --- a/plugins/dichiarazioni_intento/src/Dichiarazione.php +++ /dev/null @@ -1,102 +0,0 @@ -. - */ - -namespace Plugins\DichiarazioniIntento; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Eloquent\SoftDeletes; -use Modules\Anagrafiche\Anagrafica; -use Modules\Fatture\Fattura; - -/* - * Classe per la gestione delle dichiarazione d'intento. - * - * @since 2.4.11 - */ -class Dichiarazione extends Model -{ - use SimpleModelTrait; - use SoftDeletes; - - protected $table = 'co_dichiarazioni_intento'; - - /** - * Crea una nuova dichiarazione d'intento. - * - * @param $data - * @param $numero_protocollo - * @param $numero_progressivo - * @param $data_inizio - * @param $data_fine - * - * @return self - */ - public static function build(Anagrafica $anagrafica, $data, $numero_protocollo, $numero_progressivo, $data_inizio, $data_fine) - { - $model = new static(); - - $model->anagrafica()->associate($anagrafica); - - $model->data = $data; - $model->numero_protocollo = $numero_protocollo; - $model->numero_progressivo = $numero_progressivo; - $model->data_inizio = $data_inizio; - $model->data_fine = $data_fine; - - $model->save(); - - return $model; - } - - /** - * Metodo per ricalcolare il totale utlizzato della dichiarazione. - */ - public function fixTotale() - { - $this->setRelations([]); - - $righe = collect(); - $fatture = $this->fatture; - foreach ($fatture as $fattura) { - $righe = $righe->merge($fattura->getRighe()); - } - - // Filtro delle righe per IVA - $id_iva = setting("Iva per lettere d'intento"); - $righe_dichiarazione = $righe->filter(function ($item, $key) use ($id_iva) { - return $item->aliquota != null && $item->aliquota->id == $id_iva; - }); - - $totale = $righe_dichiarazione->sum('totale_imponibile') ?: 0; - $this->totale = $totale; - } - - // Relazioni Eloquent - - public function anagrafica() - { - return $this->belongsTo(Anagrafica::class, 'id_anagrafica'); - } - - public function fatture() - { - return $this->hasMany(Fattura::class, 'id_dichiarazione_intento'); - } -} diff --git a/plugins/exportFE/actions.php b/plugins/exportFE/actions.php deleted file mode 100755 index d72859d86..000000000 --- a/plugins/exportFE/actions.php +++ /dev/null @@ -1,89 +0,0 @@ -. - */ - -include_once __DIR__.'/init.php'; - -use Plugins\ExportFE\Interaction; -use Plugins\ReceiptFE\Ricevuta; - -switch (filter('op')) { - case 'generate': - if (!empty($fattura_pa)) { - $file = $fattura_pa->save(); - - flash()->info(tr('Fattura elettronica generata correttamente!')); - - if (!$fattura_pa->isValid()) { - $errors = $fattura_pa->getErrors(); - - flash()->warning(tr('La fattura elettronica potrebbe avere delle irregolarità!').' '.tr('Controllare i seguenti campi: _LIST_', [ - '_LIST_' => implode(', ', $errors), - ]).'.'); - } - } else { - flash()->error(tr('Impossibile generare la fattura elettronica')); - } - - break; - - case 'send': - $result = Interaction::sendInvoice($id_record); - - echo json_encode($result); - - break; - - case 'verify': - $result = Interaction::getInvoiceRecepits($id_record); - $last_recepit = $result['results'][0]; - - // Messaggi relativi - if (empty($last_recepit)) { - echo json_encode($result); - - return; - } - - // Importazione ultima ricevuta individuata - $fattura = Ricevuta::process($last_recepit); - $numero_esterno = $fattura ? $fattura->numero_esterno : null; - - echo json_encode([ - 'file' => $last_recepit, - 'fattura' => $numero_esterno, - ]); - - break; - - case 'gestione_ricevuta': - $name = filter('name'); - $type = filter('type'); - - $cambia_stato = $type != 'download'; - $fattura = Ricevuta::process($name, $cambia_stato); - - $numero_esterno = $fattura ? $fattura->numero_esterno : null; - - echo json_encode([ - 'file' => $name, - 'fattura' => $fattura, - ]); - - break; -} diff --git a/plugins/exportFE/download.php b/plugins/exportFE/download.php deleted file mode 100755 index d46057841..000000000 --- a/plugins/exportFE/download.php +++ /dev/null @@ -1,23 +0,0 @@ -. - */ - -include_once __DIR__.'/init.php'; - -$file = $fattura->getFatturaElettronica(); -download(base_dir().'/'.$file->filepath, $file->original_name); diff --git a/plugins/exportFE/edit.php b/plugins/exportFE/edit.php deleted file mode 100755 index a69d5d108..000000000 --- a/plugins/exportFE/edit.php +++ /dev/null @@ -1,304 +0,0 @@ -. - */ - -include_once __DIR__.'/init.php'; - -use Plugins\ExportFE\FatturaElettronica; -use Plugins\ExportFE\Interaction; -use Util\XML; - -if ($fattura !== null) { - /* Per le PA EC02 e EC01 sono dei stati successivi a NE il quale a sua volta è successivo a RC. EC01 e EC02 sono definiti all'interno della ricevuta di NE che di fatto indica il rifiuto o l'accettazione. */ - $stato_fe = $database->fetchOne('SELECT * FROM fe_stati_documento WHERE codice = '.prepare($fattura->codice_stato_fe)); - $abilita_genera = $fattura->stato->descrizione != 'Bozza' && (empty($fattura->codice_stato_fe) || intval($stato_fe['is_generabile'])); - $ricevuta_principale = $fattura->getRicevutaPrincipale(); - - if (!empty($fattura_pa)) { - $generata = $fattura_pa->isGenerated(); - } else { - $generata = false; - } - - $checks = FatturaElettronica::controllaFattura($fattura); - if (!empty($checks)) { - echo ' -
    -

    '.tr('Prima di procedere alla generazione della fattura elettronica completa le seguenti informazioni').':

    '; - - foreach ($checks as $check) { - echo ' -

    '.$check['name'].' '.$check['link'].'

    -
      '; - - foreach ($check['errors'] as $error) { - if (!empty($error)) { - echo ' -
    • '.$error.'
    • '; - } - } - - echo ' -
    '; - } - - echo ' -
    '; - } - - echo ' -

    '.tr("Per effettuare la generazione dell'XML della fattura elettronica clicca sul pulsante _BTN_", [ - '_BTN_' => 'Genera', - ]).'. '.tr('Successivamente sarà possibile procedere alla visualizzazione e al download della fattura generata attraverso i pulsanti dedicati').'.

    - -

    '.tr("Tutti gli allegati inseriti all'interno della categoria \"Allegati Fattura Elettronica\" saranno inclusi nell'XML").'.

    -
    '; - - echo ' -
    -
    - - - - - - -
    '; - - $file = $generata ? $fattura->getFatturaElettronica() : null; - - echo ' - - - - - '.tr('Visualizza').' - '; - - // Scelgo quando posso inviarla - $inviabile = Interaction::isEnabled() && $generata && intval($stato_fe['is_inviabile']); - - echo ' - - - - '.tr('Scarica').' - '; - - echo ' - - - - '; - - $verify = Interaction::isEnabled() && $generata; - echo ' - - - -
    '; - - echo '

    '; - - // Messaggio informativo sulla ricevuta principale impostata - if (!empty($ricevuta_principale)) { - echo ' -
    -
    - '.timestampFormat($record['data_stato_fe']); - - if (!empty($ultima_ricevuta)) { - echo ' - - '.tr('Visualizza ricevuta').' - '; - } - - echo ' -
    - - - - '.$stato_fe['codice'].' - '.$stato_fe['descrizione'].' - '; - - if (!empty($record['descrizione_ricevuta_fe'])) { - echo ' -
    '.tr('Note', [], ['upper' => true]).': '.$record['descrizione_ricevuta_fe']; - } - - if ($fattura->codice_stato_fe == 'GEN') { - echo ' -
    '.tr("La fattura è stata generata ed è pronta per l'invio").'.'; - } - - echo ' -
    '; - - // Lettura della ricevuta - if (!empty($ricevuta_principale) && file_exists($ricevuta_principale->filepath)) { - $contenuto_ricevuta = XML::readFile($ricevuta_principale->filepath); - $lista_errori = $contenuto_ricevuta['ListaErrori']; - - if (!empty($lista_errori)) { - echo ' -

    '.tr('Elenco degli errori').'

    - - - - - - - - '; - - $lista_errori = $lista_errori[0] ? $lista_errori : [$lista_errori]; - foreach ($lista_errori as $errore) { - $errore = $errore['Errore']; - echo ' - - - - '; - } - - echo ' - -
    '.tr('Codice').''.tr('Descrizione').'
    '.$errore['Codice'].''.htmlentities($errore['Descrizione']).'
    '; - } - } - } - - echo ' - '; -} diff --git a/plugins/exportFE/init.php b/plugins/exportFE/init.php deleted file mode 100755 index 4dca2ff76..000000000 --- a/plugins/exportFE/init.php +++ /dev/null @@ -1,29 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Fatture\Fattura; -use Plugins\ExportFE\FatturaElettronica; - -try { - $fattura = Fattura::find($id_record); - $fattura_pa = new FatturaElettronica($id_record); -} catch (UnexpectedValueException $e) { -} diff --git a/plugins/exportFE/notifiche.php b/plugins/exportFE/notifiche.php deleted file mode 100644 index 28c384c1b..000000000 --- a/plugins/exportFE/notifiche.php +++ /dev/null @@ -1,150 +0,0 @@ -'.tr('Il documento non ha notifiche disponibili').'.

    - -

    '.tr("Nota: se la fattura in questione è stata inviata molto tempo fa, il servizio utilizzato non ha reso disponibile l'associazione diretta tra la fattura e le notifiche").'. '.tr("L'importazione delle notifiche in questione procedere comunque regolarmente").'.

    '; - - return; -} - -echo ' -

    '.tr("Segue l'elenco completo delle notifiche/ricevute relative alla fatture elettronica di questo documento").'.

    -

    '.tr('La procedura di importazione prevede di impostare in modo autonomo la notifica più recente come principale, ma si verificano alcune situazioni in cui il comportamento richiesto deve essere distinto').'. '.tr('Qui si può procedere a scaricare una specifica notifica e a impostarla manualmente come principale per il documento').'.

    - -

    '.tr('Nota: in caso di fattura scartata per duplicazione, se non sono disponibili notifiche contattare i fornitori del servizio').'.

    - - - - - - - - - - - '; - -foreach ($recepits as $nome) { - $upload = $documento->uploads() - ->where('original_name', $nome) - ->first(); - - // Individuazione codice ricevuta - $filename = explode('.', $nome)[0]; - $pieces = explode('_', $filename); - $codice_stato = $pieces[2]; - - // Informazioni sullo stato indicato - $stato_fe = $database->fetchOne('SELECT * FROM fe_stati_documento WHERE codice = '.prepare($codice_stato)); - - echo ' - - - - - '; -} - -echo ' - -
    '.tr('Nome').''.tr('Scaricata').''.tr('Opzioni').'
    '.$nome.''; - - if (empty($upload)) { - echo tr('No'); - } else { - echo ' - - '.tr('Visualizza').' - '; - } - - echo ' - '; - - if (empty($upload)) { - echo ' - '; - } - - if (empty($upload) || $upload->id != $documento->id_ricevuta_principale) { - echo ' - '; - } elseif ($upload->id == $documento->id_ricevuta_principale) { - echo ' - '; - } - - echo ' -
    - -'; diff --git a/plugins/exportFE/src/FatturaElettronica.php b/plugins/exportFE/src/FatturaElettronica.php deleted file mode 100755 index 1a077d3a9..000000000 --- a/plugins/exportFE/src/FatturaElettronica.php +++ /dev/null @@ -1,1757 +0,0 @@ -. - */ - -namespace Plugins\ExportFE; - -use FluidXml\FluidXml; -use GuzzleHttp\Client; -use Modules; -use Modules\Anagrafiche\Anagrafica; -use Modules\Fatture\Fattura; -use Modules\Fatture\Gestori\Bollo; -use Prints; -use Translator; -use UnexpectedValueException; -use Uploads; -use Validate; - -/** - * Classe per la gestione della fatturazione elettronica in XML. - * - * @since 2.4.2 - */ -class FatturaElettronica -{ - /** @var Anagrafica Informazioni sull'anagrafica Azienda */ - protected static $azienda = []; - - /** @var Anagrafica Informazioni sull'anagrafica Cliente del documento */ - protected $cliente = []; - - /** @var Modules\Fatture\Fattura Informazioni sul documento */ - protected $documento = null; - - /** @var Validator Oggetto dedicato alla validazione dell'XML */ - protected $validator = null; - - /** @var array Contratti collegati al documento */ - protected $contratti = []; - /** @var array Ordini di acquisto collegati al documento */ - protected $ordini = []; - /** @var array Righe del documento */ - protected $righe = []; - - /** @var array XML della fattura */ - protected $xml = null; - - public function __construct($id_documento) - { - // Documento - $this->documento = Fattura::find($id_documento); - - // Controllo sulla possibilità di creare la fattura elettronica - // Posso fatturare ai privati utilizzando il codice fiscale - if ($this->documento->stato->descrizione == 'Bozza') { - throw new UnexpectedValueException(); - } - } - - public function __toString() - { - return $this->toXML(); - } - - /** - * @return bool - */ - public function isGenerated() - { - $documento = $this->getDocumento(); - $file = $documento->getFatturaElettronica(); - - return !empty($documento['progressivo_invio']) && file_exists(base_dir().'/'.$file->filepath); - } - - /** - * Restituisce le informazioni sull'anagrafica azienda. - * - * @return Anagrafica - */ - public static function getAzienda() - { - if (empty(static::$azienda)) { - static::$azienda = Anagrafica::find(setting('Azienda predefinita')); - } - - return static::$azienda; - } - - /** - * Restituisce le informazioni sull'anagrafica cliente legata al documento. - * - * @return Anagrafica - */ - public function getCliente() - { - return $this->getDocumento()->anagrafica; - } - - /** - * Restituisce le righe del documento. - * - * @return array - */ - public function getRighe() - { - if (empty($this->righe)) { - $this->righe = $this->getDocumento()->getRighe(); - } - - return $this->righe; - } - - /** - * Restituisce i contratti collegati al documento (contratti e interventi e ordini). - * - * @return array - */ - public function getContratti() - { - if (empty($this->contratti)) { - $documento = $this->getDocumento(); - $database = database(); - - $contratti = $database->fetchArray('SELECT `id_documento_fe` AS id_documento, `num_item`, `codice_cig`, `codice_cup` FROM `co_contratti` INNER JOIN `co_righe_documenti` ON `co_righe_documenti`.`idcontratto` = `co_contratti`.`id` WHERE `co_righe_documenti`.`iddocumento` = '.prepare($documento['id']).' AND `id_documento_fe` IS NOT NULL AND `co_righe_documenti`.`idordine` = 0'); - - $preventivi = $database->fetchArray('SELECT `id_documento_fe` AS id_documento, `num_item`, `codice_cig`, `codice_cup` FROM `co_preventivi` INNER JOIN `co_righe_documenti` ON `co_righe_documenti`.`idpreventivo` = `co_preventivi`.`id` WHERE `co_righe_documenti`.`iddocumento` = '.prepare($documento['id']).' AND `id_documento_fe` IS NOT NULL AND `co_righe_documenti`.`idordine` = 0'); - - $interventi = $database->fetchArray('SELECT `id_documento_fe` AS id_documento, `num_item`, `codice_cig`, `codice_cup` FROM `in_interventi` INNER JOIN `co_righe_documenti` ON `co_righe_documenti`.`idintervento` = `in_interventi`.`id` WHERE `co_righe_documenti`.`iddocumento` = '.prepare($documento['id']).' AND `id_documento_fe` IS NOT NULL AND `co_righe_documenti`.`idcontratto` = 0 AND `co_righe_documenti`.`idpreventivo` = 0'); - - $dati_aggiuntivi = $documento->dati_aggiuntivi_fe; - $dati = $dati_aggiuntivi['dati_contratto'] ?: []; - - $this->contratti = array_merge($contratti, $preventivi, $interventi, $dati); - } - - return $this->contratti; - } - - /** - * Restituisce gli ordini di acquisto collegati al documento. - * - * @return array - */ - public function getOrdiniAcquisto() - { - if (empty($this->ordini)) { - $documento = $this->getDocumento(); - $database = database(); - - $ordini = $database->fetchArray('SELECT `or_ordini`.`numero_cliente` AS id_documento, `or_ordini`.`num_item`, `or_ordini`.`codice_cig`, `or_ordini`.`codice_cup`, `or_ordini`.`codice_commessa`, `or_ordini`.`data_cliente`, `co_righe_documenti`.`order` AS riferimento_linea FROM `or_ordini` INNER JOIN `co_righe_documenti` ON `co_righe_documenti`.`idordine` = `or_ordini`.`id` WHERE `co_righe_documenti`.`iddocumento` = '.prepare($documento['id'])); - - $dati_aggiuntivi = $documento->dati_aggiuntivi_fe; - $dati = $dati_aggiuntivi['dati_ordine'] ?: []; - - $this->ordini = array_merge($ordini, $dati); - } - - return $this->ordini; - } - - /** - * Restituisce i ddt collegati al documento. - * - * @return array - */ - public function getDDT() - { - if (empty($this->ddt)) { - $documento = $this->getDocumento(); - $database = database(); - - $ddt = $database->fetchArray('SELECT `dt_ddt`.`numero_esterno` AS id_documento, `co_righe_documenti`.`order` AS riferimento_linea, `dt_ddt`.`data` FROM `dt_ddt` INNER JOIN `co_righe_documenti` ON `co_righe_documenti`.`idddt` = `dt_ddt`.`id` WHERE `co_righe_documenti`.`iddocumento` = '.prepare($documento['id'])); - - $dati_aggiuntivi = $documento->dati_aggiuntivi_fe; - $dati = $dati_aggiuntivi['dati_ddt'] ?: []; - - $this->ddt = array_merge($ddt, $dati); - } - - return $this->ddt; - } - - /** - * Restituisce le fatture collegate al documento. - * - * @return array - */ - public function getFattureCollegate() - { - if (empty($this->fatture_collegate)) { - $documento = $this->getDocumento(); - $database = database(); - - $note_accredito = $database->fetchArray('SELECT numero_esterno AS id_documento, data FROM co_documenti WHERE id='.prepare($documento['ref_documento'])); - - $dati_aggiuntivi = $documento->dati_aggiuntivi_fe; - $dati = $dati_aggiuntivi['dati_fatture'] ?: []; - - $this->fatture_collegate = array_merge($note_accredito, $dati); - } - - return $this->fatture_collegate; - } - - /** - * Restituisce le informazioni relative al documento. - * - * @return Fattura - */ - public function getDocumento() - { - return $this->documento; - } - - /** - * Restituisce lo stato di validazione interna dell'XML della fattura. - * - * @return bool - */ - public function isValid() - { - return empty($this->getErrors()); - } - - /** - * Restituisce l'elenco delle irregolarità interne all'XML della fattura. - * - * @return bool - */ - public function getErrors() - { - if (!isset($this->validator)) { - $this->toXML(); - } - - return $this->validator->getErrors(); - } - - /** - * Ottiene il codice destinatario a partire dal database ufficiale indicepa www.indicepa.gov.it. - * - * @param $codice_fiscale - * - * @throws \GuzzleHttp\Exception\GuzzleException - * - * @return string|null - */ - public static function PA($codice_fiscale) - { - $id = setting('Authorization ID Indice PA'); - - if (empty($id)) { - return null; - } - - // Configurazione per localhost: CURLOPT_SSL_VERIFYPEER - $client = new Client(['curl' => [CURLOPT_SSL_VERIFYPEER => false]]); - - $response = $client->request('POST', 'https://www.indicepa.gov.it/public-ws/WS01_SFE_CF.php', [ - 'form_params' => [ - 'AUTH_ID' => $id, - 'CF' => $codice_fiscale, - ], - ]); - - $json = json_decode($response->getBody(), true); - - return isset($json['data'][0]['OU'][0]['cod_uni_ou']) ? $json['data'][0]['OU'][0]['cod_uni_ou'] : null; - } - - public static function getDirectory() - { - return Uploads::getDirectory(Modules::get('Fatture di vendita')['id']); - } - - /** - * Salva il file XML. - * - * @return string Nome del file - */ - public function save() - { - $this->delete(); - - $name = 'Fattura Elettronica'; - $data = $this->getUploadData(); - - // Generazione nome XML - $filename = $this->getFilename(true); - - // Rimozione allegato precedente - $precedente = $this->getDocumento()->getFatturaElettronica(); - if (!empty($precedente)) { - $precedente->delete(); - } - - // Registrazione come allegato - Uploads::upload($this->toXML(), array_merge($data, [ - 'name' => $name, - 'original_name' => $filename, - ])); - - // Aggiornamento effettivo - database()->update('co_documenti', [ - 'progressivo_invio' => $this->getDocumento()['progressivo_invio'], - 'codice_stato_fe' => 'GEN', - 'id_ricevuta_principale' => null, - 'data_stato_fe' => date('Y-m-d H:i:s'), - ], ['id' => $this->getDocumento()['id']]); - - return ($result === false) ? null : $filename; - } - - /** - * Rimuove la fattura generata. - */ - public function delete() - { - $previous = $this->getFilename(); - $data = $this->getUploadData(); - - Uploads::delete($previous, $data); - } - - /** - * Restituisce il nome del file XML per la fattura elettronica. - * - * @param bool $new - * - * @return string - */ - public function getFilename($new = false) - { - if (!empty(setting('Terzo intermediario'))) { - $anagrafica = Anagrafica::find(setting('Terzo intermediario')); - } else { - $anagrafica = static::getAzienda(); - } - - $prefix = 'IT'.(!empty($anagrafica['codice_fiscale'] and ($anagrafica['codice_fiscale'] != $anagrafica['piva'])) ? $anagrafica['codice_fiscale'] : str_replace($anagrafica->nazione->iso2, '', $anagrafica['piva'])); - - if (empty($this->documento['progressivo_invio']) || !empty($new)) { - $database = database(); - - do { - $code = date('y').secure_random_string(3); - } while ($database->fetchNum('SELECT `id` FROM `co_documenti` WHERE `progressivo_invio` = '.prepare($code)) != 0); - - // Registrazione - $this->documento['progressivo_invio'] = $code; - } - - return $prefix.'_'.$this->documento['progressivo_invio'].'.xml'; - } - - /** - * Restituisce il codice XML della fattura elettronica. - * - * @return string - */ - public function toXML() - { - if (empty($this->xml)) { - $this->errors = []; - - $cliente = $this->getCliente(); - - // Inizializzazione libreria per la generazione della fattura in XML - $fattura = new FluidXml(null, ['stylesheet' => 'http://www.fatturapa.gov.it/export/fatturazione/sdi/fatturapa/v1.2.1/fatturaPA_v1.2.1.xsl']); - - // Generazione dell'elemento root - $fattura->namespace('p', 'http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2'); - $root = $fattura->addChild('p:FatturaElettronica', true); - $rootNode = $root[0]; - - // Completamento dei tag - $attributes = [ - 'versione' => ($cliente['tipo'] == 'Ente pubblico') ? 'FPA12' : 'FPR12', - 'xmlns:ds' => 'http://www.w3.org/2000/09/xmldsig#', - 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', - 'xsi:schemaLocation' => 'http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2.1 http://www.fatturapa.gov.it/export/fatturazione/sdi/fatturapa/v1.2.1/Schema_del_file_xml_FatturaPA_versione_1.2.1.xsd', - ]; - - // Attributo SistemaEmittente (max 10 caratteri) - if (empty(setting('Terzo intermediario'))) { - $attributes['SistemaEmittente'] = 'OSM'; - } - - foreach ($attributes as $key => $value) { - $rootNode->setAttribute($key, $value); - } - - // Generazione della fattura elettronica - $this->validator = new Validator([ - 'FatturaElettronicaHeader' => static::getHeader($this), - 'FatturaElettronicaBody' => static::getBody($this), - ]); - $xml = $this->validator->validate(); - $fattura->add($xml); - - $this->xml = $fattura->__toString(); - } - - return $this->xml; - } - - public static function controllaFattura(Fattura $fattura) - { - $database = database(); - $errors = []; - - // Controlli sulla fattura stessa - if ($fattura->stato->descrizione == 'Bozza') { - $missing = [ - 'state' => tr('Stato ("Emessa")'), - ]; - } - - if (!empty($missing)) { - $link = Modules::link('Fatture di vendita', $fattura->id); - $errors[] = [ - 'link' => $link, - 'name' => tr('Fattura'), - 'errors' => $missing, - ]; - } - - // Natura obbligatoria per iva con esenzione - $iva = $database->fetchArray('SELECT * FROM `co_iva` WHERE `id` IN (SELECT idiva FROM co_righe_documenti WHERE iddocumento = '.prepare($fattura->id).') AND esente = 1'); - $fields = [ - 'codice_natura_fe' => 'Natura IVA', - ]; - - foreach ($iva as $data) { - $missing = []; - if (!empty($data)) { - foreach ($fields as $key => $name) { - if (empty($data[$key])) { - $missing[] = $name; - } - } - } - - if (!empty($missing)) { - $link = Modules::link('IVA', $data['id']); - $errors[] = [ - 'link' => $link, - 'name' => tr('IVA _DESC_', [ - '_DESC_' => $data['descrizione'], - ]), - 'errors' => $missing, - ]; - } - } - - // Campi obbligatori per il pagamento - $data = $fattura->pagamento; - $fields = [ - 'codice_modalita_pagamento_fe' => 'Codice modalità pagamento FE', - ]; - - $missing = []; - if (!empty($data)) { - foreach ($fields as $key => $name) { - if (empty($data[$key])) { - $missing[] = $name; - } - } - } - - if (!empty($missing)) { - $link = Modules::link('Pagamenti', $data['id']); - $errors[] = [ - 'link' => $link, - 'name' => tr('Pagamento'), - 'errors' => $missing, - ]; - } - - // Campi obbligatori per l'anagrafica Azienda - $data = FatturaElettronica::getAzienda(); - $fields = [ - 'piva' => 'Partita IVA', - // 'codice_fiscale' => 'Codice Fiscale', - 'citta' => 'Città', - 'indirizzo' => 'Indirizzo', - 'cap' => 'C.A.P.', - 'nazione' => 'Nazione', - ]; - - $missing = []; - if (!empty($data)) { - foreach ($fields as $key => $name) { - if (empty($data[$key]) && !empty($name)) { - $missing[] = $name; - } - } - } - - if (!empty($missing)) { - $link = Modules::link('Anagrafiche', $data['id']); - $errors[] = [ - 'link' => $link, - 'name' => tr('Anagrafica Azienda'), - 'errors' => $missing, - ]; - } - - // Campi obbligatori per l'anagrafica Cliente - $data = $fattura->anagrafica; - $fields = [ - // 'piva' => 'Partita IVA', - // 'codice_fiscale' => 'Codice Fiscale', - 'citta' => 'Città', - 'indirizzo' => 'Indirizzo', - 'cap' => 'C.A.P.', - 'nazione' => 'Nazione', - ]; - - // se privato/pa o azienda - if ($data['tipo'] == 'Privato' or $data['tipo'] == 'Ente pubblico') { - // se privato/pa chiedo obbligatoriamente codice fiscale - $fields['codice_fiscale'] = ($data['nazione']->iso2 == 'IT' ? 'Codice Fiscale' : ''); - // se pa chiedo codice unico ufficio - $fields['codice_destinatario'] = ($data['tipo'] == 'Ente pubblico' && empty($data['codice_destinatario'])) ? 'Codice unico ufficio' : ''; - } else { - // se azienda chiedo partita iva - $fields['piva'] = 'Partita IVA'; - // se italiana e non ho impostato ne il codice destinatario ne indirizzo PEC chiedo la compilazione di almeno uno dei due - $fields['codice_destinatario'] = (empty($data['codice_destinatario']) and empty($data['pec']) && intval($data['nazione']->iso2 == 'IT')) ? 'Codice destinatario o indirizzo PEC' : ''; - } - - $missing = []; - if (!empty($data)) { - foreach ($fields as $key => $name) { - if (empty($data[$key]) && !empty($name)) { - $missing[] = $name; - } - } - } - - if (!empty($missing)) { - $link = Modules::link('Anagrafiche', $data['id']); - $errors[] = [ - 'link' => $link, - 'name' => tr('Anagrafica Cliente'), - 'errors' => $missing, - ]; - } - - // Campi obbligatori per l'anagrafica di tipo Vettore - $id_vettore = $fattura['idvettore']; - if (!empty($id_vettore)) { - $data = Anagrafica::find($id_vettore); - $fields = [ - 'piva' => 'Partita IVA', - 'nazione' => 'Nazione', - ]; - - $missing = []; - if (!empty($data)) { - foreach ($fields as $key => $name) { - if (empty($data[$key]) && !empty($name)) { - $missing[] = $name; - } - } - } - - if (!empty($missing)) { - $link = Modules::link('Anagrafiche', $data['id']); - $errors[] = [ - 'link' => $link, - 'name' => tr('Anagrafica Vettore'), - 'errors' => $missing, - ]; - } - } - - return $errors; - } - - /** - * Restituisce l'array responsabile per la generazione del tag DatiTrasmission. - * - * @return array - */ - protected static function getDatiTrasmissione($fattura) - { - // Se in impostazioni ho definito un terzo intermediario (es. Aruba, Teamsystem) - if (!empty(setting('Terzo intermediario'))) { - $anagrafica = Anagrafica::find(setting('Terzo intermediario')); - } else { - $anagrafica = static::getAzienda(); - } - - $documento = $fattura->getDocumento(); - $cliente = $fattura->getCliente(); - - $sede = database()->fetchOne('SELECT `codice_destinatario` FROM `an_sedi` WHERE `id` = '.prepare($documento['idsede_destinazione'])); - if (!empty($sede)) { - $codice_destinatario = $sede['codice_destinatario']; - } else { - $codice_destinatario = $cliente->codice_destinatario; - } - - // Se sto fatturando ad un ente pubblico il codice destinatario di default è 99999 (sei nove), in alternativa uso 0000000 (sette zeri) - $default_code = ($cliente['tipo'] == 'Ente pubblico') ? '999999' : '0000000'; - // Se il mio cliente non ha sede in Italia il codice destinatario di default diventa (XXXXXXX) (sette X) - $default_code = ($cliente->nazione->iso2 != 'IT') ? 'XXXXXXX' : $default_code; - - // Generazione dell'header - // Se all'Anagrafe Tributaria il trasmittente è censito con il codice fiscale, es. ditte individuali - $result = [ - 'IdTrasmittente' => [ - 'IdPaese' => $anagrafica->nazione->iso2, - 'IdCodice' => (!empty($anagrafica['codice_fiscale']) and ($anagrafica['codice_fiscale'] != $anagrafica['piva'])) ? $anagrafica['codice_fiscale'] : str_replace($anagrafica->nazione->iso2, '', $anagrafica['piva']), - ], - ]; - - $result[] = [ - 'ProgressivoInvio' => $documento['progressivo_invio'], - 'FormatoTrasmissione' => ($cliente['tipo'] == 'Ente pubblico') ? 'FPA12' : 'FPR12', - 'CodiceDestinatario' => !empty($codice_destinatario) ? $codice_destinatario : $default_code, - ]; - - // Telefono di contatto - if (!empty($anagrafica['telefono'])) { - $result['ContattiTrasmittente']['Telefono'] = $anagrafica['telefono']; - } - - // Email di contatto - if (!empty($anagrafica['email'])) { - $result['ContattiTrasmittente']['Email'] = $anagrafica['email']; - } - - // Inizializzazione PEC solo se anagrafica azienda e codice destinatario non compilato, per privato e PA la PEC non serve - if (empty($cliente['codice_destinatario']) && $cliente['tipo'] == 'Azienda' && !empty($cliente['pec'])) { - $result['PECDestinatario'] = $cliente['pec']; - } - - return $result; - } - - /** - * Restituisce l'array responsabile per la generazione dei tag DatiAnagrafici per Azienda e Cliente. - * - * @return array - */ - protected static function getDatiAnagrafici($anagrafica, $azienda = false) - { - $result = []; - - $is_privato_estero = ($anagrafica->nazione->iso2 != 'IT' && $anagrafica->tipo == 'Privato'); - - // Partita IVA (obbligatoria se presente) - if (!empty($anagrafica['piva'])) { - if (!empty($anagrafica->nazione->iso2)) { - $result['IdFiscaleIVA']['IdPaese'] = $anagrafica->nazione->iso2; - } - //Rimuovo eventuali idicazioni relative alla nazione - $result['IdFiscaleIVA']['IdCodice'] = str_replace($anagrafica->nazione->iso2, '', $anagrafica['piva']); - } - - // Codice fiscale - //TODO: Nella fattura elettronica, emessa nei confronti di soggetti titolari di partita IVA (nodo CessionarioCommittente), non va indicato il codice fiscale se è già presente la partita iva. - if (!empty($anagrafica['codice_fiscale'])) { - $result['CodiceFiscale'] = preg_replace('/\s+/', '', $anagrafica['codice_fiscale']); - - //$result['CodiceFiscale'] = str_replace($anagrafica->nazione->iso2, '', $result['CodiceFiscale']); - - //Rimuovo eventuali idicazioni relative all'iso2 della nazione, solo se la stringa inizia con quest'ultima. - $result['CodiceFiscale'] = preg_replace('/^'.preg_quote($anagrafica->nazione->iso2, '/').'/', '', $anagrafica['codice_fiscale']); - } - - // Partita IVA: se privato estero non va considerato il codice fiscale ma la partita iva con 9 zeri - if ($is_privato_estero) { - $result['IdFiscaleIVA']['IdPaese'] = $anagrafica->nazione->iso2; - $result['IdFiscaleIVA']['IdCodice'] = '999999999'; - unset($result['Anagrafica']['CodiceFiscale']); - } - - if (!empty($anagrafica['nome']) or !empty($anagrafica['cognome'])) { - $result['Anagrafica'] = [ - //'Denominazione' => $anagrafica['ragione_sociale'], - 'Nome' => $anagrafica['nome'], - 'Cognome' => $anagrafica['cognome'], - // TODO: 'Titolo' => $anagrafica['ragione_sociale'], - // TODO: CodEORI - ]; - } else { - $result['Anagrafica'] = [ - 'Denominazione' => $anagrafica['ragione_sociale'], - //'Nome' => $anagrafica['nome'], - //'Cognome' => $anagrafica['cognome'], - // TODO: 'Titolo' => $anagrafica['ragione_sociale'], - // TODO: CodEORI - ]; - } - - // Informazioni specifiche azienda - if ($azienda) { - $result['RegimeFiscale'] = setting('Regime Fiscale'); - } - - return $result; - } - - /** - * Restituisce l'array responsabile per la generazione dei tag Sede per Azienda e Cliente. - * - * @param array $anagrafica - * - * @return array - */ - protected static function getSede($anagrafica) - { - $result = [ - 'Indirizzo' => $anagrafica['indirizzo'], - 'CAP' => ($anagrafica->nazione->iso2 == 'IT') ? $anagrafica['cap'] : '00000', - 'Comune' => $anagrafica['citta'], - ]; - - // Provincia impostata e SOLO SE nazione ITALIA - if (!empty($anagrafica['provincia']) && $anagrafica->nazione->iso2 == 'IT') { - $result['Provincia'] = strtoupper($anagrafica['provincia']); - } - - if (!empty($anagrafica->nazione->iso2)) { - $result['Nazione'] = $anagrafica->nazione->iso2; - } - - return $result; - } - - /** - * Restituisce l'array responsabile per la generazione del tag CedentePrestatore (mia Azienda ovvero il fornitore) (1.2). - * - * @return array - */ - protected static function getCedentePrestatore($fattura) - { - $documento = $fattura->getDocumento(); - - //Fattura per conto terzi, il cliente diventa il cedente al posto della mia Azienda (fornitore) - if ($documento['is_fattura_conto_terzi']) { - $azienda = $fattura->getCliente(); - } else { - $azienda = static::getAzienda(); - } - - $result = [ - 'DatiAnagrafici' => static::getDatiAnagrafici($azienda, true), - 'Sede' => static::getSede($azienda), - ]; - - // IscrizioneREA - if (!empty($azienda['codicerea'])) { - $codice = explode('-', clean($azienda['codicerea'], '\-')); - - if (!empty($codice[0]) && !empty($codice[1])) { - $result['IscrizioneREA'] = [ - 'Ufficio' => strtoupper($codice[0]), - 'NumeroREA' => $codice[1], - ]; - } - - if (!empty($azienda['capitale_sociale'])) { - $result['IscrizioneREA']['CapitaleSociale'] = $azienda['capitale_sociale']; - } - - $result['IscrizioneREA']['StatoLiquidazione'] = 'LN'; // Non in liquidazione - } - - // Contatti - - // Telefono - if (!empty($azienda['telefono'])) { - $result['Contatti']['Telefono'] = $azienda['telefono']; - } - - // Fax - if (!empty($azienda['fax'])) { - $result['Contatti']['Fax'] = $azienda['fax']; - } - - // Email - if (!empty($azienda['email'])) { - $result['Contatti']['Email'] = $azienda['email']; - } - - // Riferimento Amministrazione - if (!empty($azienda['riferimento_amministrazione'])) { - $result['RiferimentoAmministrazione'] = $azienda['riferimento_amministrazione']; - } - - return $result; - } - - /** - * Restituisce l'array responsabile per la generazione del tag CessionarioCommittente (Cliente) (1.4). - * - * @return array - */ - protected static function getCessionarioCommittente($fattura) - { - $documento = $fattura->getDocumento(); - - //Fattura per conto terzi, la mia Azienda (fornitore) diventa il cessionario al posto del cliente - if ($documento['is_fattura_conto_terzi']) { - $cliente = static::getAzienda(); - } else { - $cliente = $fattura->getCliente(); - } - - $result = [ - 'DatiAnagrafici' => static::getDatiAnagrafici($cliente), - 'Sede' => static::getSede($cliente), - ]; - - return $result; - } - - /** - * Restituisce l'array responsabile per la generazione del tag TerzoIntermediarioOSoggettoEmittente (1.5). - * - * @return array - */ - protected static function getTerzoIntermediarioOSoggettoEmittente($fattura) - { - $intermediario = Anagrafica::find(setting('Terzo intermediario')); - - $result = [ - 'DatiAnagrafici' => static::getDatiAnagrafici($intermediario), - ]; - - return $result; - } - - protected static function chunkSplit($str, $chunklen) - { - $res = []; - $k = ceil(strlen($str) / $chunklen); - for ($i = 0; $i < $k; ++$i) { - $res[] = substr($str, $i * $chunklen, $chunklen); - } - - return $res; - } - - /** - * Restituisce l'array responsabile per la generazione del tag DatiGeneraliDocumento. - * - * @return array - */ - protected static function getDatiGeneraliDocumento($fattura) - { - $documento = $fattura->getDocumento(); - $azienda = static::getAzienda(); - $cliente = $fattura->getCliente(); - - $result = [ - 'TipoDocumento' => $documento->tipo->codice_tipo_documento_fe, - 'Divisa' => 'EUR', - 'Data' => $documento['data'], - 'Numero' => $documento['numero_esterno'], - ]; - - $righe = $fattura->getRighe(); - - // Ritenuta d'Acconto - $id_ritenuta = null; - $totale_ritenutaacconto = 0; - - // Rivalsa - $id_rivalsainps = null; - $totale_rivalsainps = 0; - - foreach ($righe as $riga) { - if (!empty($riga['idritenutaacconto']) and empty($riga['is_descrizione'])) { - $id_ritenuta = $riga['idritenutaacconto']; - $totale_ritenutaacconto += $riga['ritenutaacconto']; - } - - if (!empty($riga['idrivalsainps']) and empty($riga['is_descrizione'])) { - $id_rivalsainps = $riga['idrivalsainps']; - $totale_rivalsainps += $riga['rivalsainps']; - $aliquota_iva_rivalsainps = $riga['idiva']; - } - } - - if (!empty($id_ritenuta)) { - $percentuale = database()->fetchOne('SELECT percentuale FROM co_ritenutaacconto WHERE id = '.prepare($id_ritenuta))['percentuale']; - // Con la nuova versione in vigore dal 01/01/2021, questo nodo diventa ripetibile. - $result['DatiRitenuta'] = [ - 'TipoRitenuta' => (Validate::isValidTaxCode($azienda['codice_fiscale']) and $cliente['tipo'] == 'Privato') ? 'RT01' : 'RT02', - 'ImportoRitenuta' => $totale_ritenutaacconto, - 'AliquotaRitenuta' => $percentuale, - 'CausalePagamento' => setting("Causale ritenuta d'acconto"), - ]; - } - - // Bollo (2.1.1.6) - // ImportoBollo --> con la nuova versione in vigore dal 01/01/2021, la compilazione di questo nodo è diventata facoltativa. - // considerato che l'importo è noto e può essere solo di 2,00 Euro. - $bollo = new Bollo($documento); - if (!empty($bollo->getBollo())) { - $result['DatiBollo'] = [ - 'BolloVirtuale' => 'SI', - ]; - } - - // Cassa Previdenziale (Rivalsa) (2.1.1.7) - if (!empty($id_rivalsainps)) { - $iva = database()->fetchOne('SELECT `percentuale`, `codice_natura_fe` FROM `co_iva` WHERE `id` = '.prepare($aliquota_iva_rivalsainps)); - $percentuale = database()->fetchOne('SELECT percentuale FROM co_rivalse WHERE id = '.prepare($id_rivalsainps))['percentuale']; - - $dati_cassa = [ - 'TipoCassa' => setting('Tipo Cassa Previdenziale'), - 'AlCassa' => $percentuale, - 'ImportoContributoCassa' => $totale_rivalsainps, - 'ImponibileCassa' => $documento->imponibile, - 'AliquotaIVA' => $iva['percentuale'], - ]; - - if ($riga->calcolo_ritenuta_acconto == 'IMP+RIV') { - $dati_cassa['Ritenuta'] = 'SI'; - } - - if (!empty($iva['codice_natura_fe'])) { - $dati_cassa['Natura'] = $iva['codice_natura_fe']; - } - - //$dati_cassa['RiferimentoAmministrazione'] = ''; - - $result['DatiCassaPrevidenziale'] = $dati_cassa; - } - - // Sconto / Maggiorazione (2.1.1.8) - $sconti_maggiorazioni = []; - $sconto_finale = $documento->getScontoFinale(); - if (!empty($sconto_finale)) { - $sconto = [ - 'Tipo' => 'SC', - ]; - - if (!empty($documento->sconto_finale_percentuale)) { - $sconto['Percentuale'] = $documento->sconto_finale_percentuale; - } else { - $sconto['Importo'] = $documento->sconto_finale; - } - - $sconti_maggiorazioni[] = $sconto; - } - - if (!empty($documento->dati_aggiuntivi_fe['sconto_maggiorazione_tipo'])) { - $sconto = [ - 'Tipo' => $documento->dati_aggiuntivi_fe['sconto_maggiorazione_tipo'], - ]; - - if (!empty($documento->dati_aggiuntivi_fe['sconto_maggiorazione_percentuale'])) { - $sconto['Percentuale'] = $documento->dati_aggiuntivi_fe['sconto_maggiorazione_percentuale']; - } - - if (!empty($documento->dati_aggiuntivi_fe['sconto_maggiorazione_importo'])) { - $sconto['Importo'] = $documento->dati_aggiuntivi_fe['sconto_maggiorazione_importo']; - } - - $sconti_maggiorazioni[] = $sconto; - } - - if (!empty($sconti_maggiorazioni)) { - $result['ScontoMaggiorazione'] = $sconti_maggiorazioni; - } - - // Importo Totale Documento (2.1.1.9) - // Valorizzare l’importo complessivo lordo della fattura (onnicomprensivo di Iva, bollo, contributi previdenziali, ecc…) - $result['ImportoTotaleDocumento'] = abs($documento->totale); - - // Arrotondamento - Eventuale arrotondamento sul totale documento (ammette anche il segno negativo) (2.1.1.10) - - // Causale - Descrizione della causale del documento (2.1.1.11) - $causali = self::chunkSplit($documento['note'], 200); - foreach ($causali as $causale) { - $result[] = ['Causale' => $causale]; - } - - // Art73 - Ciò consente al cedente/prestatore l'emissione nello stesso anno di più documenti aventi stesso numero (2.1.1.12) - $dati_aggiuntivi = $documento->dati_aggiuntivi_fe; - if (!empty($dati_aggiuntivi['art73'])) { - $result['Art73'] = 'SI'; - } - - return $result; - } - - /** - * Restituisce l'array responsabile per la generazione del tag DatiTrasporto. - * - * @return array - */ - protected static function getDatiTrasporto($fattura) - { - $documento = $fattura->getDocumento(); - $database = database(); - - $causale = $database->fetchOne('SELECT descrizione FROM dt_causalet WHERE id = '.prepare($documento['idcausalet']))['descrizione']; - $aspetto = $database->fetchOne('SELECT descrizione FROM dt_aspettobeni WHERE id = '.prepare($documento['idaspettobeni']))['descrizione']; - - $result = []; - - // Se imposto il vettore deve essere indicata anche la p.iva nella sua anagrafica - if ($documento->tipo->descrizione == 'Fattura accompagnatoria di vendita') { - if ($documento['idvettore']) { - $vettore = Anagrafica::find($documento['idvettore']); - $result['DatiAnagraficiVettore'] = static::getDatiAnagrafici($vettore); - } - - if (!empty($causale)) { - $result['CausaleTrasporto'] = $causale; - } - - if (!empty($documento['n_colli'])) { - $result['NumeroColli'] = $documento['n_colli']; - } - - if (!empty($aspetto)) { - $result['Descrizione'] = $aspetto; - } - - if ($documento['tipo_resa']) { - $result['TipoResa'] = $documento['tipo_resa']; - } - } - - if (!empty($documento['idsede_destinazione'])) { - $sede = $database->fetchOne('SELECT * FROM an_sedi WHERE id='.prepare($documento['idsede_destinazione'])); - - if (!empty($sede['indirizzo'])) { - $result['IndirizzoResa']['Indirizzo'] = $sede['indirizzo']; - } - - if (!empty($sede['cap'])) { - $result['IndirizzoResa']['CAP'] = $sede['cap']; - } - - if (!empty($sede['citta'])) { - $result['IndirizzoResa']['Comune'] = $sede['citta']; - } - - if (!empty($sede['provincia'])) { - $result['IndirizzoResa']['Provincia'] = $sede['provincia']; - } - - if (!empty($sede['id_nazione'])) { - $rs_nazione = $database->fetchOne('SELECT * FROM an_nazioni WHERE id='.prepare($sede['id_nazione'])); - - $result['IndirizzoResa']['Nazione'] = $rs_nazione['iso2']; - } - } - - return $result; - } - - /** - * Restituisce l'array responsabile per la generazione del tag DatiOrdineAcquisto. - * - * @return array - */ - protected static function getDatiOrdineAcquisto($fattura, $lista = null) - { - $lista = isset($lista) ? $lista : $fattura->getOrdiniAcquisto(); - - $result = []; - foreach ($lista as $element) { - if (empty($element['id_documento'])) { - continue; - } - - $dati = []; - - foreach ($element['riferimento_linea'] as $linea) { - $dati[] = [ - 'RiferimentoNumeroLinea' => $linea, - ]; - } - - $dati['IdDocumento'] = $element['id_documento']; - - if (!empty($element['data'])) { - $dati['Data'] = $element['data']; - } - - if (!empty($element['num_item'])) { - $dati['NumItem'] = $element['num_item']; - } - - if (!empty($element['codice_commessa'])) { - $dati['CodiceCommessaConvenzione'] = $element['codice_commessa']; - } - - if (!empty($element['codice_cup'])) { - $dati['CodiceCUP'] = $element['codice_cup']; - } - - if (!empty($element['codice_cig'])) { - $dati['CodiceCIG'] = $element['codice_cig']; - } - $result[] = $dati; - } - - return $result; - } - - /** - * Restituisce l'array responsabile per la generazione del tag DatiDdt. - * - * @return array - */ - protected static function getDatiDDT($fattura) - { - $ddt = $fattura->getDDT(); - - $result = []; - foreach ($ddt as $element) { - if (empty($element['id_documento'])) { - continue; - } - - $dati = []; - - $dati['NumeroDDT'] = $element['id_documento']; - - if (!empty($element['data'])) { - $dati['DataDDT'] = $element['data']; - } - - if (!empty($element['riferimento_linea'])) { - $dati['RiferimentoNumeroLinea'] = $element['riferimento_linea']; - } - - $result[] = $dati; - } - - return $result; - } - - /** - * Restituisce l'array responsabile per la generazione del tag DatiContratto. - * - * @return array - */ - protected static function getDatiContratto($fattura) - { - $contratti = $fattura->getContratti(); - - return self::getDatiOrdineAcquisto($fattura, $contratti); - } - - /** - * Restituisce l'array responsabile per la generazione del tag DatiConvenzione. - * - * @return array - */ - protected static function getDatiConvenzione($fattura) - { - $documento = $fattura->getDocumento(); - - $dati_aggiuntivi = $documento->dati_aggiuntivi_fe; - $dati = $dati_aggiuntivi['dati_convenzione'] ?: []; - - return self::getDatiOrdineAcquisto($fattura, $dati); - } - - /** - * Restituisce l'array responsabile per la generazione del tag DatiRicezione. - * - * @return array - */ - protected static function getDatiRicezione($fattura) - { - $documento = $fattura->getDocumento(); - - $dati_aggiuntivi = $documento->dati_aggiuntivi_fe; - $dati = $dati_aggiuntivi['dati_ricezione'] ?: []; - - return self::getDatiOrdineAcquisto($fattura, $dati); - } - - /** - * Restituisce l'array responsabile per la generazione del tag DatiFattureCollegate. - * - * @return array - */ - protected static function getDatiFattureCollegate($fattura) - { - $fatture = $fattura->getFattureCollegate(); - - return self::getDatiOrdineAcquisto($fattura, $fatture); - } - - /** - * Restituisce l'array responsabile per la generazione del tag DatiDocumento. - * - * @return array - */ - protected static function getDatiGenerali($fattura) - { - $documento = $fattura->getDocumento(); - $cliente = $fattura->getCliente(); - - $result = [ - 'DatiGeneraliDocumento' => static::getDatiGeneraliDocumento($fattura), - ]; - - // Controllo le le righe per la fatturazione di ordini - $dati_ordini = static::getDatiOrdineAcquisto($fattura); - if (!empty($dati_ordini)) { - foreach ($dati_ordini as $dato) { - if (!empty($dato)) { - $result[] = [ - 'DatiOrdineAcquisto' => $dato, - ]; - } - } - } - - // Controllo le le righe per la fatturazione di contratti - $dati_contratti = static::getDatiContratto($fattura); - if (!empty($dati_contratti)) { - foreach ($dati_contratti as $dato) { - if (!empty($dato)) { - $result[] = [ - 'DatiContratto' => $dato, - ]; - } - } - } - - // Controllo le le righe per la fatturazione di contratti - $dati_convenzioni = static::getDatiConvenzione($fattura); - if (!empty($dati_convenzioni)) { - foreach ($dati_convenzioni as $dato) { - if (!empty($dato)) { - $result[] = [ - 'DatiConvenzione' => $dato, - ]; - } - } - } - - // Controllo le le righe per la fatturazione di contratti - $dati_ricezioni = static::getDatiRicezione($fattura); - if (!empty($dati_ricezioni)) { - foreach ($dati_ricezioni as $dato) { - if (!empty($dato)) { - $result[] = [ - 'DatiRicezione' => $dato, - ]; - } - } - } - - // Controllo le le righe per la fatturazione di contratti - $dati_fatture_collegate = static::getDatiFattureCollegate($fattura); - if (!empty($dati_fatture_collegate)) { - foreach ($dati_fatture_collegate as $dato) { - if (!empty($dato)) { - $result[] = [ - 'DatiFattureCollegate' => $dato, - ]; - } - } - } - - // Controllo le le righe per la fatturazione di contratti - $dati_ddt = static::getDatiDDT($fattura); - if (!empty($dati_ddt)) { - foreach ($dati_ddt as $dato) { - if (!empty($dato)) { - $result[] = [ - 'DatiDDT' => $dato, - ]; - } - } - } - - if ($documento->tipo->descrizione == 'Fattura accompagnatoria di vendita' || !empty($documento['idsede_destinazione'])) { - $result['DatiTrasporto'] = static::getDatiTrasporto($fattura); - } - - return $result; - } - - /** - * Restituisce l'array responsabile per la generazione del tag DatiBeniServizi. - * - * @param $fattura - * - * @throws \Exception - * - * @return array - */ - protected static function getDatiBeniServizi($fattura) - { - $documento = $fattura->getDocumento(); - $ritenuta_contributi = $documento->ritenutaContributi; - $righe = $documento->getRighe(); - - $database = database(); - - $result = []; - - // Righe del documento - $iva_descrizioni = $righe->first(function ($item, $key) { - return $item->aliquota != null; - })->aliquota; - - foreach ($righe as $idx => $riga) { - $dati_aggiuntivi = $riga->dati_aggiuntivi_fe; - - $dettaglio = [ - 'NumeroLinea' => $riga['order'], - ]; - - // 2.2.1.2 - if (!empty($dati_aggiuntivi['tipo_cessione_prestazione'])) { - $dettaglio['TipoCessionePrestazione'] = $dati_aggiuntivi['tipo_cessione_prestazione']; - } - - // 2.2.1.3 - if ($riga->isArticolo()) { - //$tipo_codice = $database->fetchOne('SELECT `mg_categorie`.`nome` FROM `mg_categorie` INNER JOIN `mg_articoli` ON `mg_categorie`.`id` = `mg_articoli`.`id_categoria` WHERE `mg_articoli`.`id` = '.prepare($riga['idarticolo']))['nome']; - - $codice_articolo = [ - 'CodiceTipo' => 'COD', - 'CodiceValore' => $riga->codice, - ]; - - $dettaglio['CodiceArticolo'] = $codice_articolo; - } - - // Non ammesso ’ - // $descrizione = html_entity_decode($riga['descrizione'], ENT_HTML5, 'UTF-8'); - $descrizione = str_replace('>', ' ', $riga['descrizione']); - $descrizione = str_replace('…', '...', $descrizione); - $descrizione = str_replace('’', ' ', $descrizione); - $descrizione = str_replace('ø', 'diametro', $descrizione); - - // Aggiunta dei riferimenti ai documenti - if (setting('Riferimento dei documenti in Fattura Elettronica') && $riga->hasOriginalComponent()) { - $descrizione .= "\n".$riga->getOriginalComponent()->getDocument()->getReference(); - } - - $dettaglio['Descrizione'] = $descrizione; - - $qta = abs($riga->qta) ?: 1; - $dettaglio['Quantita'] = $qta; - - if (!empty($riga['um'])) { - $dettaglio['UnitaMisura'] = $riga['um']; - } - - if (!empty($dati_aggiuntivi['data_inizio_periodo'])) { - $dettaglio['DataInizioPeriodo'] = $dati_aggiuntivi['data_inizio_periodo']; - } - if (!empty($dati_aggiuntivi['data_fine_periodo'])) { - $dettaglio['DataFinePeriodo'] = $dati_aggiuntivi['data_fine_periodo']; - } - - $dettaglio['PrezzoUnitario'] = $riga->prezzo_unitario ?: 0; - - // Sconto (2.2.1.10) - $sconto_unitario = (float) $riga->sconto_unitario; - - if (!empty($sconto_unitario)) { - $sconto = [ - 'Tipo' => $sconto_unitario > 0 ? 'SC' : 'MG', - ]; - - if ($riga['tipo_sconto'] == 'PRC') { - $sconto['Percentuale'] = abs($riga->sconto_percentuale); - } else { - $sconto['Importo'] = abs($sconto_unitario); - } - - $dettaglio['ScontoMaggiorazione'] = $sconto; - } - - $aliquota = $riga->aliquota ?: $iva_descrizioni; - $percentuale = floatval($aliquota->percentuale); - - $prezzo_totale = $riga->totale_imponibile; - $prezzo_totale = $prezzo_totale ?: 0; - $dettaglio['PrezzoTotale'] = $prezzo_totale; - - $dettaglio['AliquotaIVA'] = $percentuale; - - if (!empty($riga['idritenutaacconto']) && empty($riga['is_descrizione'])) { - if ($riga['calcolo_ritenuta_acconto'] == 'IMP+RIV') { - $dettaglio['Ritenuta'] = 'SI'; - } - } - - // Controllo aggiuntivo codice_natura_fe per evitare che venga riportato il tag vuoto - if (empty($percentuale) && !empty($aliquota['codice_natura_fe'])) { - $dettaglio['Natura'] = $aliquota['codice_natura_fe']; - } - - if (!empty($dati_aggiuntivi['riferimento_amministrazione'])) { - $dettaglio['RiferimentoAmministrazione'] = $dati_aggiuntivi['riferimento_amministrazione']; - } - - // AltriDatiGestionali (2.2.1.16) - Ritenuta ENASARCO - // https://forum.italia.it/uploads/default/original/2X/d/d35d721c3a3a601d2300378724a270154e23af52.jpeg - if (!empty($riga['ritenuta_contributi'])) { - $dettaglio[]['AltriDatiGestionali'] = [ - 'TipoDato' => 'CASSA-PREV', - 'RiferimentoTesto' => setting('Tipo Cassa Previdenziale').' - '.$ritenuta_contributi->descrizione.' ('.Translator::numberToLocale($ritenuta_contributi->percentuale).'%)', - 'RiferimentoNumero' => $riga->ritenuta_contributi, - ]; - } - - $rs_ritenuta = $database->fetchOne('SELECT percentuale_imponibile FROM co_ritenutaacconto WHERE id='.prepare($riga['idritenutaacconto'])); - if (!empty($rs_ritenuta['percentuale_imponibile'])) { - $dettaglio[]['AltriDatiGestionali'] = [ - 'TipoDato' => 'IMPON-RACC', - 'RiferimentoTesto' => 'Imponibile % ritenuta d\'acconto', - 'RiferimentoNumero' => $rs_ritenuta['percentuale_imponibile'], - ]; - } - - // Dichiarazione d'intento - $dichiarazione = $documento->dichiarazione; - $id_iva_dichiarazione = setting("Iva per lettere d'intento"); - if (!empty($dichiarazione) && $riga->aliquota->id == $id_iva_dichiarazione) { - $dettaglio[]['AltriDatiGestionali'] = [ - 'TipoDato' => 'AswDichInt', - 'RiferimentoTesto' => $dichiarazione->numero_protocollo, - 'RiferimentoNumero' => $dichiarazione->numero_progressivo, - 'RiferimentoData' => $dichiarazione->data_emissione, - ]; - } - - // Dati aggiuntivi dinamici - if (!empty($dati_aggiuntivi['altri_dati'])) { - foreach ($dati_aggiuntivi['altri_dati'] as $dato) { - $altri_dati = []; - - if (!empty($dato['tipo_dato'])) { - $altri_dati['TipoDato'] = $dato['tipo_dato']; - } - - if (!empty($dato['riferimento_testo'])) { - $altri_dati['RiferimentoTesto'] = $dato['riferimento_testo']; - } - - if (!empty($dato['riferimento_numero'])) { - $altri_dati['RiferimentoNumero'] = $dato['riferimento_numero']; - } - - if (!empty($dato['riferimento_data'])) { - $altri_dati['RiferimentoData'] = $dato['riferimento_data']; - } - - $dettaglio[]['AltriDatiGestionali'] = $altri_dati; - } - } - - $result[] = [ - 'DettaglioLinee' => $dettaglio, - ]; - } - - // Riepiloghi per IVA per percentuale - $riepiloghi_percentuale = $righe->filter(function ($item, $key) { - return $item->aliquota != null && $item->aliquota->codice_natura_fe == null; - })->groupBy(function ($item, $key) { - return $item->aliquota->percentuale; - }); - foreach ($riepiloghi_percentuale as $riepilogo) { - $totale = round($riepilogo->sum('totale_imponibile') + $riepilogo->sum('rivalsa_inps'), 2); - $imposta = round($riepilogo->sum('iva') + $riepilogo->sum('iva_rivalsa_inps'), 2); - - $totale = $totale; - $imposta = $imposta; - - $dati = $riepilogo->first()->aliquota; - - $iva = [ - 'AliquotaIVA' => $dati['percentuale'], - 'ImponibileImporto' => $totale, - 'Imposta' => $imposta, - 'EsigibilitaIVA' => $dati['esigibilita'], - ]; - - // Con split payment EsigibilitaIVA sempre a S - if ($documento['split_payment']) { - $iva['EsigibilitaIVA'] = 'S'; - } - - // TODO: la dicitura può essere diversa tra diverse IVA con stessa percentuale/natura - // nei riepiloghi viene fatto un accorpamento percentuale/natura - if (!empty($riepilogo['dicitura'])) { - // $iva['RiferimentoNormativo'] = $riepilogo['dicitura']; - } - - // 2.2.2 - $result[] = [ - 'DatiRiepilogo' => $iva, - ]; - } - - // Riepiloghi per IVA per natura - $riepiloghi_natura = $righe->filter(function ($item, $key) { - return $item->aliquota != null && $item->aliquota->codice_natura_fe != null; - })->groupBy(function ($item, $key) { - return $item->aliquota->codice_natura_fe; - }); - foreach ($riepiloghi_natura as $riepilogo) { - $totale = round($riepilogo->sum('totale_imponibile') + $riepilogo->sum('rivalsa_inps'), 2); - $imposta = round($riepilogo->sum('iva') + $riepilogo->sum('iva_rivalsa_inps'), 2); - - $totale = $totale; - $imposta = $imposta; - - $dati = $riepilogo->first()->aliquota; - - $iva = [ - 'AliquotaIVA' => 0, - 'Natura' => $dati->codice_natura_fe, - 'ImponibileImporto' => $totale, - 'Imposta' => $imposta, - 'EsigibilitaIVA' => $dati->esigibilita, - 'RiferimentoNormativo' => $dati->descrizione, - ]; - - // Con split payment EsigibilitaIVA sempre a S - if ($documento['split_payment']) { - $iva['EsigibilitaIVA'] = 'S'; - } - - // 2.2.2 - $result[] = [ - 'DatiRiepilogo' => $iva, - ]; - } - - return $result; - } - - /** - * Restituisce l'array responsabile per la generazione del tag DatiPagamento (2.4). - * - * @return array - */ - protected static function getDatiPagamento($fattura) - { - $documento = $fattura->getDocumento(); - - $fattura = Fattura::find($documento['id']); - $banca = $fattura->getBanca(); - - $database = database(); - - $co_pagamenti = $database->fetchOne('SELECT * FROM `co_pagamenti` WHERE `id` = '.prepare($documento['idpagamento'])); - - $result = [ - 'CondizioniPagamento' => ($co_pagamenti['prc'] == 100) ? 'TP02' : 'TP01', - ]; - - $co_scadenziario = $database->fetchArray('SELECT * FROM `co_scadenziario` WHERE `iddocumento` = '.prepare($documento['id'])); - foreach ($co_scadenziario as $scadenza) { - $pagamento = [ - 'ModalitaPagamento' => $co_pagamenti['codice_modalita_pagamento_fe'], - 'DataScadenzaPagamento' => $scadenza['scadenza'], - 'ImportoPagamento' => abs($scadenza['da_pagare']), - ]; - - if (!empty($banca->nome)) { - $pagamento['IstitutoFinanziario'] = $banca->nome; - } - - if (!empty($banca->iban)) { - $pagamento['IBAN'] = clean($banca->iban); - } - - // BIC senza parte per filiale (causa errori di validazione) - if (!empty($banca->bic)) { - $pagamento['BIC'] = substr($banca->bic, 0, 8); - } - - $result[]['DettaglioPagamento'] = $pagamento; - } - - return $result; - } - - /** - * Restituisce l'array responsabile per la generazione del tag Allegati. - * - * @return array - */ - protected static function getAllegati($fattura) - { - $documento = $fattura->getDocumento(); - $cliente = $fattura->getCliente(); - $attachments = []; - - // Informazioni sul modulo - $id_module = Modules::get('Fatture di vendita')['id']; - $directory = Uploads::getDirectory($id_module); - - // Allegati - $allegati = Uploads::get([ - 'id_module' => $id_module, - 'id_record' => $documento['id'], - ]); - - // Inclusione - foreach ($allegati as $allegato) { - if ($allegato['category'] == 'Allegati Fattura Elettronica') { - $file = base_dir().'/'.$directory.'/'.$allegato['filename']; - - $attachments[] = [ - 'NomeAttachment' => $allegato['name'], - 'FormatoAttachment' => Uploads::fileInfo($file)['extension'], - 'Attachment' => base64_encode(file_get_contents($file)), - ]; - } - } - - // Aggiunta della stampa - $print = false; - if ($cliente['tipo'] == 'Privato') { - $print = setting('Allega stampa per fattura verso Privati'); - } elseif ($cliente['tipo'] == 'Azienda') { - $print = setting('Allega stampa per fattura verso Aziende'); - } else { - $print = setting('Allega stampa per fattura verso PA'); - } - - if (!$print) { - return $attachments; - } - - $data = $fattura->getUploadData(); - - // Generazione stampa - $print = Prints::getModulePredefinedPrint($id_module); - $info = Prints::render($print['id'], $documento['id'], null, true); - - // Salvataggio stampa come allegato - $name = 'Stampa allegata'; - $is_presente = database()->fetchNum('SELECT id FROM zz_files WHERE id_module = '.prepare($id_module).' AND id_record = '.prepare($documento['id']).' AND name = '.prepare($name)); - if (empty($is_presente)) { - Uploads::upload($info['pdf'], array_merge($data, [ - 'name' => $name, - 'original_name' => $info['path'], - ])); - } - - // Introduzione allegato in Fattura Elettronica - $attachments[] = [ - 'NomeAttachment' => 'Fattura', - 'FormatoAttachment' => 'PDF', - 'Attachment' => base64_encode($info['pdf']), - ]; - - return $attachments; - } - - /** - * Restituisce l'array responsabile per la generazione del tag FatturaElettronicaHeader. - * - * @return array - */ - protected static function getHeader($fattura) - { - $result = [ - 'DatiTrasmissione' => static::getDatiTrasmissione($fattura), - 'CedentePrestatore' => static::getCedentePrestatore($fattura), - 'CessionarioCommittente' => static::getCessionarioCommittente($fattura), - ]; - - // 1.5 Terzo Intermediario - if (!empty(setting('Terzo intermediario'))) { - $result['TerzoIntermediarioOSoggettoEmittente'] = static::getTerzoIntermediarioOSoggettoEmittente($fattura); - - // 1.6 Soggetto terzo - $result['SoggettoEmittente'] = 'TZ'; - } - - // 1.5 o Soggetto Emittente (Autofattura) - da parte del fornitore (mia Azienda) per conto del cliente esonerato - // In caso di acquisto di prodotti da un agricolo in regime agevolato (art. 34, comma 6, del d.P.R. n. 633/72) da parte di un operatore IVA obbligato alla FE, quest'ultimo emetterà una FE usando la tipologia "TD01" per conto dell'agricoltore venditore - if ($fattura->getDocumento()['is_fattura_conto_terzi']) { - $result['TerzoIntermediarioOSoggettoEmittente'] = [ - 'DatiAnagrafici' => static::getDatiAnagrafici(static::getAzienda()), - ]; - - // 1.6 Cessionario/Committente - $result['SoggettoEmittente'] = 'CC'; - } - - return $result; - } - - /** - * Restituisce l'array responsabile per la generazione del tag FatturaElettronicaBody. - * - * @return array - */ - protected static function getBody($fattura) - { - $result = [ - 'DatiGenerali' => static::getDatiGenerali($fattura), - 'DatiBeniServizi' => static::getDatiBeniServizi($fattura), - 'DatiPagamento' => static::getDatiPagamento($fattura), - ]; - - // Allegati - $allegati = static::getAllegati($fattura); - if (!empty($allegati)) { - foreach ($allegati as $allegato) { - $result[] = [ - 'Allegati' => $allegato, - ]; - } - } - - return $result; - } - - protected function getUploadData() - { - return [ - 'category' => tr('Fattura Elettronica'), - 'id_module' => Modules::get('Fatture di vendita')['id'], - 'id_record' => $this->getDocumento()['id'], - ]; - } -} diff --git a/plugins/exportFE/src/Interaction.php b/plugins/exportFE/src/Interaction.php deleted file mode 100755 index 4adc6583f..000000000 --- a/plugins/exportFE/src/Interaction.php +++ /dev/null @@ -1,95 +0,0 @@ -. - */ - -namespace Plugins\ExportFE; - -use API\Services; -use Modules\Fatture\Fattura; -use UnexpectedValueException; - -/** - * Classe per la gestione delle API esterne per l'invio delle Fatture Elettroniche e la ricerca di ricevute collegate. - * - * @since 2.4.3 - */ -class Interaction extends Services -{ - public static function sendInvoice($id_record) - { - try { - $fattura_elettronica = new FatturaElettronica($id_record); - $fattura = Fattura::find($id_record); - $file = $fattura->getFatturaElettronica(); - - $response = static::request('POST', 'invio_fattura_xml', [ - 'xml' => $file->getContent(), - 'filename' => $fattura_elettronica->getFilename(), - ]); - $body = static::responseBody($response); - - // Aggiornamento dello stato - if ($body['status'] == 200 || $body['status'] == 301) { - database()->update('co_documenti', [ - 'codice_stato_fe' => 'WAIT', - 'data_stato_fe' => date('Y-m-d H:i:s'), - ], ['id' => $id_record]); - } elseif ($body['status'] == 405) { - database()->update('co_documenti', [ - 'codice_stato_fe' => 'ERR', - 'data_stato_fe' => date('Y-m-d H:i:s'), - ], ['id' => $id_record]); - } - - return [ - 'code' => $body['status'], - 'message' => $body['message'], - ]; - } catch (UnexpectedValueException $e) { - } - - return [ - 'code' => 400, - 'message' => tr('Fattura non generata correttamente'), - ]; - } - - public static function getInvoiceRecepits($id_record) - { - try { - $fattura_elettronica = new FatturaElettronica($id_record); - $filename = $fattura_elettronica->getFilename(); - - $response = static::request('POST', 'notifiche_fattura', [ - 'name' => $filename, - ]); - $body = static::responseBody($response); - - return [ - 'code' => $body['status'], - 'results' => $body['results'], - ]; - } catch (UnexpectedValueException $e) { - } - - return [ - 'code' => 400, - 'message' => tr('Fattura non generata correttamente'), - ]; - } -} diff --git a/plugins/exportFE/src/InvoiceHook.php b/plugins/exportFE/src/InvoiceHook.php deleted file mode 100755 index 482d756c9..000000000 --- a/plugins/exportFE/src/InvoiceHook.php +++ /dev/null @@ -1,89 +0,0 @@ -. - */ - -namespace Plugins\ExportFE; - -use Hooks\Manager; -use Modules\Fatture\Fattura; - -/** - * Hook dedicato all'invio automatico delle Fatture Elettroniche inserite in coda di invio tramite azioni di gruppo. - */ -class InvoiceHook extends Manager -{ - public function isSingleton() - { - return true; - } - - public function needsExecution() - { - if (!Interaction::isEnabled()) { - return false; - } - - $remaining = Fattura::where('hook_send', 1) - ->where('codice_stato_fe', 'QUEUE') - ->count(); - - return !empty($remaining); - } - - public function execute() - { - $fattura = Fattura::where('hook_send', 1) - ->where('codice_stato_fe', 'QUEUE') - ->first(); - - $result = Interaction::sendInvoice($fattura->id); - - if ($result['code'] == 200 || $result['code'] == 301) { - $fattura->hook_send = false; - $fattura->save(); - } - - return $result; - } - - public function response() - { - $completed = !$this->needsExecution(); - $message = tr('Invio fatture elettroniche in corso...'); - $icon = 'text-info'; - - $errors = Fattura::where('hook_send', 1) - ->where('codice_stato_fe', 'ERR') - ->count(); - - if ($completed) { - if (empty($errors)) { - $message = tr('Invio fatture elettroniche completato!'); - } else { - $message = tr('Invio fatture elettroniche completato con errori'); - $icon = 'text-danger'; - } - } - - return [ - 'icon' => 'fa fa-envelope '.$icon, - 'message' => $message, - 'show' => !$completed || !empty($errors), - ]; - } -} diff --git a/plugins/exportFE/src/Validator.php b/plugins/exportFE/src/Validator.php deleted file mode 100755 index a1ad8491c..000000000 --- a/plugins/exportFE/src/Validator.php +++ /dev/null @@ -1,683 +0,0 @@ -. - */ - -namespace Plugins\ExportFE; - -use DateTime; -use Respect\Validation\Validator as v; -use Stringy\Stringy as S; - -class Validator -{ - /** @var array Elenco di campi dello standard per la formattazione e la validazione */ - public static $validators = [ - 'IdPaese' => [ - 'type' => 'string', - 'size' => 2, - ], - 'IdCodice' => [ - 'type' => 'string', - 'size' => [1, 28], - ], - 'ProgressivoInvio' => [ - 'type' => 'normalizedString', - 'size' => [1, 10], - ], - 'FormatoTrasmissione' => [ - 'type' => 'string', - 'size' => 5, - ], - 'CodiceDestinatario' => [ - 'type' => 'string', - 'size' => [6, 7], - ], - 'Telefono' => [ - 'type' => 'normalizedString', - 'size' => [5, 12], - ], - 'Email' => [ - 'type' => 'string', - 'size' => [7, 256], - ], - 'PECDestinatario' => [ - 'type' => 'normalizedString', - 'size' => [7, 256], - ], - 'CodiceFiscale' => [ - 'type' => 'string', - 'size' => [11, 16], - ], - 'Denominazione' => [ - 'type' => 'normalizedString', - 'size' => [1, 80], - ], - 'Nome' => [ - 'type' => 'normalizedString', - 'size' => [1, 60], - ], - 'Cognome' => [ - 'type' => 'normalizedString', - 'size' => [1, 60], - ], - 'Titolo' => [ - 'type' => 'normalizedString', - 'size' => [2, 10], - ], - 'CodEORI' => [ - 'type' => 'string', - 'size' => [13, 17], - ], - 'AlboProfessionale' => [ - 'type' => 'normalizedString', - 'size' => [1, 60], - ], - 'ProvinciaAlbo' => [ - 'type' => 'string', - 'size' => 2, - ], - 'NumeroIscrizioneAlbo' => [ - 'type' => 'normalizedString', - 'size' => [1, 60], - ], - 'DataIscrizioneAlbo' => [ - 'type' => 'date', - 'size' => 10, - ], - 'RegimeFiscale' => [ - 'type' => 'string', - 'size' => 4, - ], - 'Indirizzo' => [ - 'type' => 'normalizedString', - 'size' => [1, 60], - ], - 'NumeroCivico' => [ - 'type' => 'normalizedString', - 'size' => [1, 8], - ], - 'CAP' => [ - 'type' => 'string', - 'size' => 5, - ], - 'Comune' => [ - 'type' => 'normalizedString', - 'size' => [1, 60], - ], - 'Provincia' => [ - 'type' => 'string', - 'size' => 2, - ], - 'Nazione' => [ - 'type' => 'string', - 'size' => 2, - ], - 'Ufficio' => [ - 'type' => 'string', - 'size' => 2, - ], - 'NumeroREA' => [ - 'type' => 'normalizedString', - 'size' => [1, 20], - ], - 'CapitaleSociale' => [ - 'type' => 'decimal', - 'size' => [4, 15], - ], - 'SocioUnico' => [ - 'type' => 'string', - 'size' => 2, - ], - 'StatoLiquidazione' => [ - 'type' => 'string', - 'size' => 2, - ], - 'Fax' => [ - 'type' => 'normalizedString', - 'size' => [5, 12], - ], - 'RiferimentoAmministrazione' => [ - 'type' => 'normalizedString', - 'size' => [1, 20], - ], - 'SoggettoEmittente' => [ - 'type' => 'string', - 'size' => 2, - ], - 'TipoDocumento' => [ - 'type' => 'string', - 'size' => 4, - ], - 'Divisa' => [ - 'type' => 'string', - 'size' => 3, - ], - 'Data' => [ - 'type' => 'date', - 'size' => 10, - ], - 'Numero' => [ - 'type' => 'normalizedString', - 'size' => [1, 20], - ], - 'TipoRitenuta' => [ - 'type' => 'string', - 'size' => 4, - ], - 'ImportoRitenuta' => [ - 'type' => 'decimal', - 'size' => [4, 15], - ], - 'AliquotaRitenuta' => [ - 'type' => 'decimal', - 'size' => [4, 6], - ], - 'CausalePagamento' => [ - 'type' => 'string', - 'size' => [1, 2], - ], - 'BolloVirtuale' => [ - 'type' => 'string', - 'size' => 2, - ], - 'ImportoBollo' => [ - 'type' => 'decimal', - 'size' => [4, 15], - ], - 'TipoCassa' => [ - 'type' => 'string', - 'size' => 4, - ], - 'AlCassa' => [ - 'type' => 'decimal', - 'size' => [4, 6], - ], - 'ImportoContributoCassa' => [ - 'type' => 'decimal', - 'size' => [4, 15], - ], - 'ImponibileCassa' => [ - 'type' => 'decimal', - 'size' => [4, 15], - ], - 'AliquotaIVA' => [ - 'type' => 'decimal', - 'size' => [4, 6], - ], - 'Ritenuta' => [ - 'type' => 'string', - 'size' => 2, - ], - 'Natura' => [ - 'type' => 'string', - 'size' => 2, - ], - 'Tipo' => [ - 'type' => 'string', - 'size' => 2, - ], - 'Percentuale' => [ - 'type' => 'decimal', - 'size' => [4, 6], - ], - 'Importo' => [ - 'type' => 'decimal', - 'size' => [4, 15], - ], - 'ImportoTotaleDocumento' => [ - 'type' => 'decimal', - 'size' => [4, 15], - ], - 'Arrotondamento' => [ - 'type' => 'decimal', - 'size' => [4, 21], - ], - 'Causale' => [ - 'type' => 'normalizedString', - 'size' => [1, 200], - ], - 'Art73' => [ - 'type' => 'string', - 'size' => 2, - ], - 'RiferimentoNumeroLinea' => [ - 'type' => 'integer', - 'size' => [1, 4], - ], - 'IdDocumento' => [ - 'type' => 'normalizedString', - 'size' => [1, 20], - ], - 'NumItem' => [ - 'type' => 'normalizedString', - 'size' => [1, 20], - ], - 'CodiceCommessaConvenzione' => [ - 'type' => 'normalizedString', - 'size' => [1, 100], - ], - 'CodiceCUP' => [ - 'type' => 'normalizedString', - 'size' => [1, 15], - ], - 'CodiceCIG' => [ - 'type' => 'normalizedString', - 'size' => [1, 15], - ], - 'RiferimentoFase' => [ - 'type' => 'integer', - 'size' => [1, 3], - ], - 'NumeroDDT' => [ - 'type' => 'normalizedString', - 'size' => [1, 20], - ], - 'DataDDT' => [ - 'type' => 'date', - 'size' => 10, - ], - 'NumeroLicenzaGuida' => [ - 'type' => 'normalizedString', - 'size' => [1, 20], - ], - 'MezzoTrasporto' => [ - 'type' => 'normalizedString', - 'size' => [1, 80], - ], - 'CausaleTrasporto' => [ - 'type' => 'normalizedString', - 'size' => [1, 100], - ], - 'NumeroColli' => [ - 'type' => 'integer', - 'size' => [1, 4], - ], - 'Descrizione' => [ - 'type' => 'normalizedString', - 'size' => [1, 1000], - ], - 'UnitaMisuraPeso' => [ - 'type' => 'normalizedString', - 'size' => [1, 10], - ], - 'PesoLordo' => [ - 'type' => 'decimal', - 'size' => [4, 7], - ], - 'PesoNetto' => [ - 'type' => 'decimal', - 'size' => [4, 7], - ], - 'DataOraRitiro' => [ - 'type' => 'date', - 'size' => 19, - ], - 'DataInizioTrasporto' => [ - 'type' => 'date', - 'size' => 10, - ], - 'TipoResa' => [ - 'type' => 'string', - 'size' => 3, - ], - 'DataOraConsegna' => [ - 'type' => 'date', - 'size' => 19, - ], - 'NumeroFatturaPrincipale' => [ - 'type' => 'string', - 'size' => [1, 20], - ], - 'DataFatturaPrincipale' => [ - 'type' => 'date', - 'size' => 10, - ], - 'NumeroLinea' => [ - 'type' => 'integer', - 'size' => [1, 4], - ], - 'TipoCessionePrestazione' => [ - 'type' => 'string', - 'size' => 2, - ], - 'CodiceArticolo' => [ - 'type' => 'normalizedString', - ], - 'CodiceTipo' => [ - 'type' => 'normalizedString', - 'size' => [1, 35], - ], - 'CodiceValore' => [ - 'type' => 'normalizedString', - 'size' => [1, 35], - ], - 'Quantita' => [ - 'type' => 'decimal', - 'size' => [4, 21], - ], - 'UnitaMisura' => [ - 'type' => 'normalizedString', - 'size' => [1, 10], - ], - 'DataInizioPeriodo' => [ - 'type' => 'date', - 'size' => 10, - ], - 'DataFinePeriodo' => [ - 'type' => 'date', - 'size' => 10, - ], - 'PrezzoUnitario' => [ - 'type' => 'decimal', - 'size' => [4, 21], - ], - 'PrezzoTotale' => [ - 'type' => 'decimal', - 'size' => [4, 21], - ], - 'TipoDato' => [ - 'type' => 'normalizedString', - 'size' => [1, 10], - ], - 'RiferimentoTesto' => [ - 'type' => 'normalizedString', - 'size' => [1, 60], - ], - 'RiferimentoNumero' => [ - 'type' => 'decimal', - 'size' => [4, 21], - ], - 'RiferimentoData' => [ - 'type' => 'normalizedString', - 'size' => 10, - ], - 'SpeseAccessorie' => [ - 'type' => 'decimal', - 'size' => [4, 15], - ], - 'ImponibileImporto' => [ - 'type' => 'decimal', - 'size' => [4, 15], - ], - 'Imposta' => [ - 'type' => 'decimal', - 'size' => [4, 15], - ], - 'EsigibilitaIVA' => [ - 'type' => 'string', - 'size' => 1, - ], - 'RiferimentoNormativo' => [ - 'type' => 'normalizedString', - 'size' => [1, 100], - ], - 'TotalePercorso' => [ - 'type' => 'normalizedString', - 'size' => [1, 15], - ], - 'CondizioniPagamento' => [ - 'type' => 'string', - 'size' => 4, - ], - 'Beneficiario' => [ - 'type' => 'string', - 'size' => [1, 200], - ], - 'ModalitaPagamento' => [ - 'type' => 'string', - 'size' => 4, - ], - 'DataRiferimentoTerminiPagamento' => [ - 'type' => 'date', - 'size' => 10, - ], - 'GiorniTerminiPagamento' => [ - 'type' => 'integer', - 'size' => [1, 3], - ], - 'DataScadenzaPagamento' => [ - 'type' => 'date', - 'size' => 10, - ], - 'ImportoPagamento' => [ - 'type' => 'decimal', - 'size' => [4, 15], - ], - 'CodUfficioPostale' => [ - 'type' => 'normalizedString', - 'size' => [1, 20], - ], - 'CognomeQuietanzante' => [ - 'type' => 'normalizedString', - 'size' => [1, 60], - ], - 'NomeQuietanzante' => [ - 'type' => 'normalizedString', - 'size' => [1, 60], - ], - 'CFQuietanzante' => [ - 'type' => 'string', - 'size' => 16, - ], - 'TitoloQuietanzante' => [ - 'type' => 'normalizedString', - 'size' => [2, 10], - ], - 'IstitutoFinanziario' => [ - 'type' => 'normalizedString', - 'size' => [1, 80], - ], - 'IBAN' => [ - 'type' => 'string', - 'size' => [15, 34], - ], - 'ABI' => [ - 'type' => 'string', - 'size' => 5, - ], - 'CAB' => [ - 'type' => 'string', - 'size' => 5, - ], - 'BIC' => [ - 'type' => 'string', - 'size' => [8, 11], - ], - 'ScontoPagamentoAnticipato' => [ - 'type' => 'decimal', - 'size' => [4, 15], - ], - 'DataLimitePagamentoAnticipato' => [ - 'type' => 'date', - 'size' => 10, - ], - 'PenalitaPagamentiRitardati' => [ - 'type' => 'decimal', - 'size' => [4, 15], - ], - 'DataDecorrenzaPenale' => [ - 'type' => 'date', - 'size' => 10, - ], - 'CodicePagamento' => [ - 'type' => 'string', - 'size' => [1, 60], - ], - 'NomeAttachment' => [ - 'type' => 'normalizedString', - 'size' => [1, 60], - ], - 'AlgoritmoCompressione' => [ - 'type' => 'string', - 'size' => [1, 10], - ], - 'FormatoAttachment' => [ - 'type' => 'string', - 'size' => [1, 10], - ], - 'DescrizioneAttachment' => [ - 'type' => 'normalizedString', - 'size' => [1, 100], - ], - 'Attachment' => [ - 'type' => 'base64Binary', - ], - ]; - - /** @var array Irregolarità nella fattura XML */ - protected $errors = null; - - /** @var string XML da validare */ - protected $xml = null; - - public function __construct($xml) - { - $this->xml = $xml; - } - - /** - * @return array - */ - public function getErrors() - { - if (!isset($this->errors)) { - $this->validate(); - } - - return $this->errors; - } - - /** - * @return bool - */ - public function isValid() - { - return empty($this->getErrors()); - } - - /** - * Restituisce lo stato di validazione interna dell'XML della fattura. - * - * @return bool - */ - public function validate() - { - $this->errors = []; - - return $this->prepareForXML($this->xml); - } - - /** - * Prepara i contenuti per la generazione dell'XML della fattura. - * Effettua inoltre dei controlli interni di validità sui campi previsti dallo standard. - * - * @param mixed $input - * @param string $key - * - * @return mixed - */ - public function prepareForXML($input, $key = null) - { - $output = null; - if (is_array($input)) { - foreach ($input as $key => $value) { - $output[$key] = $this->prepareForXML($value, $key); - } - } elseif (!is_null($input)) { - $info = static::$validators[$key]; - $size = isset($info['size']) ? $info['size'] : null; - - $output = $input; - - // Operazioni di normalizzazione - // Formattazione decimali - if ($info['type'] == 'decimal') { - if (in_array($key, ['PrezzoUnitario'])) { - $output = number_format($output, 6, '.', ''); - } elseif (in_array($key, ['Quantita'])) { - //Se i decimali per la quantità sono < 2 li imposto a 2 che è il minimo per lo standard della fatturazione elettronica - if (setting('Cifre decimali per quantità') == 1) { - $output = number_format($output, 2, '.', ''); - } else { - $output = number_format($output, setting('Cifre decimali per quantità'), '.', ''); - } - } else { - $output = number_format($output, 2, '.', ''); - } - } - - // Formattazione date - elseif ($info['type'] == 'date') { - $object = DateTime::createFromFormat('Y-m-d H:i:s', $output); - if (is_object($object)) { - $output = $object->format('Y-m-d'); - } - } - - // Formattazione testo - elseif ($info['type'] == 'string' || $info['type'] == 'normalizedString') { - $output = replace(html_entity_decode($output), [ - '&' => '&', - '"' => '"', - "'" => ''', - '<' => '<', - '>' => '>', - - // Caratteri personalizzati - '€' => 'euro', - '—' => '-', - '…' => '...', - ]); - - $output = preg_replace('/[^ -~òèéàùì°]+/', ' ', $output); - } - - // Riduzione delle dimensioni - if ($info['type'] != 'integer' && isset($size[1])) { - $output = trim($output); - $output = S::create($output)->substr(0, $size[1])->__toString(); - } - - // Validazione - if ($info['type'] == 'string' || $info['type'] == 'normalizedString') { - $validator = v::stringType(); - - if (isset($size[1])) { - $validator = $validator->length($size[0], $size[1]); - } - } elseif ($info['type'] == 'decimal') { - $validator = v::floatVal(); - } elseif ($info['type'] == 'integer') { - $validator = v::intVal(); - } elseif ($info['type'] == 'date') { - $validator = v::date(); - } - - if (!empty($validator)) { - $validation = $validator->validate($output); - - // Segnalazione dell'irregolarità - if (!intval($validation)) { - $this->errors[] = $key; - } - } - } - - return $output; - } -} diff --git a/plugins/importFE/actions.php b/plugins/importFE/actions.php deleted file mode 100755 index bcc75a4da..000000000 --- a/plugins/importFE/actions.php +++ /dev/null @@ -1,403 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\DDT\DDT; -use Modules\Ordini\Ordine; -use Plugins\ImportFE\FatturaElettronica; -use Plugins\ImportFE\Interaction; - -$file = null; -switch (filter('op')) { - case 'list': - $list = Interaction::getRemoteList(); - - echo json_encode($list); - - break; - - case 'save': - $temp_name = $_FILES['blob']['tmp_name']; - $name = $_FILES['blob']['name']; - - if (string_ends_with($name, '.zip')) { - $directory = FatturaElettronica::getImportDirectory(); - - Util\Zip::extract($temp_name, $directory); - - // Redirect forzato per l'importazione - echo json_encode([ - 'id' => 1, - ]); - exit(); - } else { - $content = file_get_contents($temp_name); - - $file = FatturaElettronica::store($_FILES['blob']['name'], $content); - } - - // no break - case 'prepare': - if (!isset($file)) { - $name = filter('name'); - $file = Interaction::getInvoiceFile($name); - } - - try { - if (!FatturaElettronica::isValid($file)) { - echo json_encode([ - 'already' => 1, - ]); - - return; - } - } catch (Exception $e) { - } - - // Individuazione ID fisico - $files = Interaction::getFileList(); - foreach ($files as $key => $value) { - if ($value['name'] == $file) { - $index = $key; - - break; - } - } - - echo json_encode([ - 'id' => $index + 1, - ]); - - break; - - case 'delete': - $file_id = get('file_id'); - - $directory = FatturaElettronica::getImportDirectory(); - $files = Interaction::getFileList(); - $file = $files[$file_id]; - - if (!empty($file)) { - delete($directory.'/'.$file['name']); - } - - break; - - case 'download': - $file_id = get('file_id'); - - $directory = FatturaElettronica::getImportDirectory(); - $files = Interaction::getFileList(); - $file = $files[$file_id]; - - if (!empty($file)) { - download($directory.'/'.$file['name']); - } - - break; - - case 'generate': - $filename = post('filename'); - - $info = [ - 'id_pagamento' => post('pagamento'), - 'id_segment' => post('id_segment'), - 'id_tipo' => post('id_tipo'), - 'ref_fattura' => post('ref_fattura'), - 'data_registrazione' => post('data_registrazione'), - 'articoli' => post('articoli'), - 'iva' => post('iva'), - 'conto' => post('conto'), - 'tipo_riga_riferimento' => post('tipo_riga_riferimento'), - 'id_riga_riferimento' => post('id_riga_riferimento'), - 'tipo_riga_riferimento_vendita' => post('tipo_riga_riferimento_vendita'), - 'id_riga_riferimento_vendita' => post('id_riga_riferimento_vendita'), - 'movimentazione' => post('movimentazione'), - 'crea_articoli' => post('crea_articoli'), - 'is_ritenuta_pagata' => post('is_ritenuta_pagata'), - ]; - - $fattura_pa = FatturaElettronica::manage($filename); - $id_fattura = $fattura_pa->save($info); - - ricalcola_costiagg_fattura($id_fattura); - elimina_scadenze($id_fattura); - elimina_movimenti($id_fattura, 0); - aggiungi_scadenza($id_fattura, post('pagamento')); - aggiungi_movimento($id_fattura, 'uscita'); - - $fattura_pa->delete(); - - // Aggiorno la tipologia di anagrafica fornitore - $anagrafica = $database->fetchOne('SELECT idanagrafica FROM co_documenti WHERE co_documenti.id='.prepare($id_fattura)); - $rs_t = $database->fetchOne("SELECT * FROM an_tipianagrafiche_anagrafiche WHERE idtipoanagrafica=(SELECT an_tipianagrafiche.idtipoanagrafica FROM an_tipianagrafiche WHERE an_tipianagrafiche.descrizione='Fornitore') AND idanagrafica=".prepare($anagrafica['idanagrafica'])); - - // Se non trovo corrispondenza aggiungo all'anagrafica la tipologia fornitore - if (empty($rs_t)) { - $database->query("INSERT INTO an_tipianagrafiche_anagrafiche (idtipoanagrafica, idanagrafica) VALUES ((SELECT an_tipianagrafiche.idtipoanagrafica FROM an_tipianagrafiche WHERE an_tipianagrafiche.descrizione='Fornitore'), ".prepare($anagrafica['idanagrafica']).')'); - } - - // Processo il file ricevuto - if (Interaction::isEnabled()) { - $process_result = Interaction::processInvoice($filename); - if ($process_result != '') { - flash()->error($process_result); - redirect(base_path().'/controller.php?id_module='.$id_module); - - return; - } - } - - $files = Interaction::getFileList(); - $file = $files[$id_record - 1]; - - if (get('sequence') == null) { - redirect(base_path().'/editor.php?id_module='.$id_module.'&id_record='.$id_fattura); - } elseif (!empty($file)) { - redirect(base_path().'/editor.php?id_module='.$id_module.'&id_plugin='.$id_plugin.'&id_record='.$id_record.'&sequence=1'); - } else { - flash()->info(tr('Tutte le fatture salvate sono state importate!')); - redirect(base_path().'/controller.php?id_module='.$id_module); - } - break; - - case 'process': - $name = get('name'); - - // Processo il file ricevuto - if (Interaction::isEnabled()) { - $process_result = Interaction::processInvoice($name); - if (!empty($process_result)) { - flash()->error($process_result); - } - } - - break; - - case 'compile': - // Gestione del caso di anagrafica inesistente - if (empty($anagrafica)) { - echo json_encode([]); - - return; - } - - $fatture = $anagrafica->fattureAcquisto() - ->contabile() - ->orderBy('created_at', 'DESC') - ->take(10) - ->get(); - - $righe = collect(); - foreach ($fatture as $fattura) { - $righe->push($fattura->righe); - $righe->push($fattura->articoli); - } - $righe = $righe->flatten(); - - // Gestione del caso di anagrafica senza fatture o con fatture senza righe - if ($fatture->isEmpty() || $righe->isEmpty()) { - echo json_encode([]); - - return; - } - - // Ricerca del tipo di documento più utilizzato - $tipi = $fatture->groupBy(function ($item, $key) { - return $item->tipo->id; - })->transform(function ($item, $key) { - return $item->count(); - }); - $id_tipo = $tipi->sort()->keys()->last(); - - // Ricerca del tipo di pagamento più utilizzato - $pagamenti = $fatture->mapToGroups(function ($item, $key) { - return [$item->pagamento->id => $item->pagamento]; - }); - $id_pagamento = $pagamenti->map(function ($item, $key) { - return $item->count(); - })->sort()->keys()->last(); - $pagamento = $pagamenti[$id_pagamento]->first(); - - // Ricerca del conto più utilizzato - $conti = $righe->groupBy(function ($item, $key) { - return $item->idconto; - })->transform(function ($item, $key) { - return $item->count(); - }); - $id_conto = $conti->sort()->keys()->last(); - $conto = $database->fetchOne('SELECT * FROM co_pianodeiconti3 WHERE id = '.prepare($id_conto)); - - // Ricerca dell'IVA più utilizzata secondo percentuali - $iva = []; - $percentuali_iva = $righe->groupBy(function ($item, $key) { - return $item->aliquota->percentuale; - }); - foreach ($percentuali_iva as $key => $values) { - $aliquote = $values->mapToGroups(function ($item, $key) { - return [$item->aliquota->id => $item->aliquota]; - }); - $id_aliquota = $aliquote->map(function ($item, $key) { - return $item->count(); - })->sort()->keys()->last(); - $aliquota = $aliquote[$id_aliquota]->first(); - - $iva[$key] = [ - 'id' => $aliquota->id, - 'descrizione' => $aliquota->descrizione, - ]; - } - - echo json_encode([ - 'id_tipo' => $id_tipo, - 'pagamento' => [ - 'id' => $pagamento->id, - 'descrizione' => $pagamento->descrizione, - ], - 'conto' => [ - 'id' => $conto['id'], - 'descrizione' => $conto['descrizione'], - ], - 'iva' => $iva, - ]); - break; - - case 'riferimenti-automatici': - if (empty($anagrafica)) { - echo json_encode([]); - - return; - } - - $results = []; - - // Iterazione sulle singole righe - $righe = $fattura_pa->getRighe(); - foreach ($righe as $key => $riga) { - $collegamento = null; - - // Visualizzazione codici articoli - $codici = $riga['CodiceArticolo'] ?: []; - $codici = !empty($codici) && !isset($codici[0]) ? [$codici] : $codici; - - // Ricerca dell'articolo collegato al codice - $id_articolo = null; - foreach ($codici as $codice) { - if (!empty($anagrafica) && empty($id_articolo)) { - $id_articolo = $database->fetchOne('SELECT id_articolo AS id FROM mg_fornitore_articolo WHERE codice_fornitore = '.prepare($codice['CodiceValore']).' AND id_fornitore = '.prepare($anagrafica->id))['id']; - } - - if (empty($id_articolo)) { - $id_articolo = $database->fetchOne('SELECT id FROM mg_articoli WHERE codice = '.prepare($codice['CodiceValore']))['id']; - } - - if (!empty($id_articolo)) { - break; - } - } - - $query = "SELECT dt_righe_ddt.id, dt_righe_ddt.idddt AS id_documento, dt_righe_ddt.is_descrizione, dt_righe_ddt.idarticolo, dt_righe_ddt.is_sconto, 'ddt' AS ref, - CONCAT('DDT num. ', IF(numero_esterno != '', numero_esterno, numero), ' del ', DATE_FORMAT(data, '%d/%m/%Y'), ' [', (SELECT descrizione FROM dt_statiddt WHERE id = idstatoddt) , ']') AS opzione - FROM dt_righe_ddt - INNER JOIN dt_ddt ON dt_ddt.id = dt_righe_ddt.idddt - WHERE dt_ddt.idanagrafica = ".prepare($anagrafica->id)." AND |where_ddt| - - UNION SELECT or_righe_ordini.id, or_righe_ordini.idordine AS id_documento, or_righe_ordini.is_descrizione, or_righe_ordini.idarticolo, or_righe_ordini.is_sconto, 'ordine' AS ref, - CONCAT('Ordine num. ', IF(numero_esterno != '', numero_esterno, numero), ' del ', DATE_FORMAT(data, '%d/%m/%Y'), ' [', (SELECT descrizione FROM or_statiordine WHERE id = idstatoordine) , ']') AS opzione - FROM or_righe_ordini - INNER JOIN or_ordini ON or_ordini.id = or_righe_ordini.idordine - WHERE or_ordini.idanagrafica = ".prepare($anagrafica->id).' AND |where_ordini|'; - - // Ricerca di righe DDT/Ordine con stesso Articolo - if (!empty($id_articolo)) { - $query_articolo = replace($query, [ - '|where_ddt|' => 'dt_righe_ddt.idarticolo = '.prepare($id_articolo), - '|where_ordini|' => 'or_righe_ordini.idarticolo = '.prepare($id_articolo), - ]); - - $collegamento = $database->fetchOne($query_articolo); - } - - // Ricerca di righe DDT/Ordine per stessa descrizione - if (empty($collegamento)) { - $query_descrizione = replace($query, [ - '|where_ddt|' => 'dt_righe_ddt.descrizione = '.prepare($riga['Descrizione']), - '|where_ordini|' => 'or_righe_ordini.descrizione = '.prepare($riga['Descrizione']), - ]); - - $collegamento = $database->fetchOne($query_descrizione); - } - - // Ricerca di righe DDT/Ordine per stesso importo - if (empty($collegamento)) { - $query_descrizione = replace($query, [ - '|where_ddt|' => 'dt_righe_ddt.prezzo_unitario = '.prepare($riga['PrezzoUnitario']), - '|where_ordini|' => 'or_righe_ordini.prezzo_unitario = '.prepare($riga['PrezzoUnitario']), - ]); - - $collegamento = $database->fetchOne($query_descrizione); - } - - if (!empty($collegamento)) { - // Individuazione del documento - $documento = $collegamento['ref'] == 'ddt' ? DDT::find($collegamento['id_documento']) : Ordine::find($collegamento['id_documento']); - - // Individuazione della classe di gestione per la riga - $namespace = $collegamento['ref'] == 'ddt' ? 'Modules\\DDT\\Components\\' : 'Modules\\Ordini\\Components\\'; - if (!empty($collegamento['idarticolo'])) { - $type = 'Articolo'; - } elseif (!empty($collegamento['is_sconto'])) { - $type = 'Sconto'; - } elseif (!empty($collegamento['is_descrizione'])) { - $type = 'Descrizione'; - } else { - $type = 'Riga'; - } - - // Ricerca della riga - $riga = $documento->getRiga($namespace.$type, $collegamento['id']); - $riga_origine = $riga->getOriginalComponent(); - - // Compilazione dei dati - $results[$key] = [ - 'documento' => [ - 'tipo' => $collegamento['ref'], - 'id' => $collegamento['id_documento'], - 'descrizione' => reference($documento, tr('Origine')), - 'opzione' => $collegamento['opzione'], - ], - 'riga' => [ - 'tipo' => get_class($riga), - 'id' => $riga->id, - 'descrizione' => $riga->descrizione, - 'qta' => $riga->qta, - 'um' => $riga->um, - 'prezzo_unitario' => $riga->prezzo_unitario ?: $riga_origine->prezzo_unitario, - 'id_iva' => $riga->id_iva, - 'iva_percentuale' => $riga->aliquota->percentuale, - ], - ]; - } - } - - echo json_encode($results); - - break; -} diff --git a/plugins/importFE/buttons.php b/plugins/importFE/buttons.php deleted file mode 100755 index f0f04815f..000000000 --- a/plugins/importFE/buttons.php +++ /dev/null @@ -1,119 +0,0 @@ -. - */ - -echo ' -
    - -
    - -
    - -
    - -'; diff --git a/plugins/importFE/edit.php b/plugins/importFE/edit.php deleted file mode 100755 index aadb0e7ca..000000000 --- a/plugins/importFE/edit.php +++ /dev/null @@ -1,238 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Plugins\ImportFE\Interaction; - -if (!empty($record)) { - include $structure->filepath('generate.php'); - - return; -} - -echo ' - - -
    -
    -

    - '.tr('Carica un XML').' - - - - - -

    -
    -
    -
    -
    - {[ "type": "file", "name": "blob", "required": 1 ]} -
    - -
    - -
    -
    -
    -
    '; - -echo ' -
    -
    -

    - '.tr('Fatture da importare').' -

    - -
    - '; - -// Ricerca automatica -if (Interaction::isEnabled()) { - echo ' - '; -} - -echo ' -
    -
    -
    '; - -if (Interaction::isEnabled()) { - echo ' -

    '.tr('Per vedere le fatture da importare utilizza il pulsante _BUTTON_', [ - '_BUTTON_' => '"'.tr('Ricerca fatture di acquisto').'"', - ]).'.

    '; -} else { - include $structure->filepath('list.php'); -} - - echo ' - -
    -
    - -'; diff --git a/plugins/importFE/generate.php b/plugins/importFE/generate.php deleted file mode 100755 index 64b17a488..000000000 --- a/plugins/importFE/generate.php +++ /dev/null @@ -1,680 +0,0 @@ -. - */ - -use Carbon\Carbon; -use Plugins\ImportFE\FatturaElettronica; - -include_once __DIR__.'/../../core.php'; - -echo ' -'; - -$skip_link = $has_next ? base_path().'/editor.php?id_module='.$id_module.'&id_plugin='.$id_plugin.'&id_record='.($id_record + 1).'&sequence='.get('sequence') : base_path().'/editor.php?id_module='.$id_module; - -if (empty($fattura_pa)) { - if (!empty($error)) { - echo ' -

    '.tr("Errore durante l'apertura della fattura elettronica _NAME_", [ - '_NAME_' => $record['name'], -]).'.

    '; - } elseif (!empty($imported)) { - echo ' -

    '.tr('La fattura elettrnica _NAME_ è già stata importata in passato', [ - '_NAME_' => $record['name'], -]).'.

    '; - } - - echo ' -
    -
    '; - - if (!empty($imported)) { - echo ' - '; - } - - echo ' - -
    -
    - -'; - - return; -} -// Fornitore -$fornitore = $fattura_pa->getAnagrafe(); - -$ragione_sociale = $fornitore['ragione_sociale'] ?: $fornitore['cognome'].' '.$fornitore['nome']; -$codice_fiscale = $fornitore['codice_fiscale']; -$partita_iva = $fornitore['partita_iva']; - -$sede = $fornitore['sede']; - -$cap = $sede['cap']; -$citta = $sede['comune']; -$provincia = $sede['provincia']; - -// Dati generali -$fattura_body = $fattura_pa->getBody(); -$dati_generali = $fattura_body['DatiGenerali']['DatiGeneraliDocumento']; - -$tipo_documento = $database->fetchOne('SELECT CONCAT("(", codice, ") ", descrizione) AS descrizione FROM fe_tipi_documento WHERE codice = '.prepare($dati_generali['TipoDocumento']))['descrizione']; - -// Gestione per fattura elettroniche senza pagamento definito -$pagamenti = []; -if (isset($fattura_body['DatiPagamento'])) { - $pagamenti = $fattura_body['DatiPagamento']; - $pagamenti = isset($pagamenti[0]) ? $pagamenti : [$pagamenti]; -} - -// Individuazione metodo di pagamento di base -$metodi = isset($pagamenti[0]['DettaglioPagamento']) ? $pagamenti[0]['DettaglioPagamento'] : []; -$metodi = isset($metodi[0]) ? $metodi : [$metodi]; - -$codice_modalita_pagamento = $metodi[0]['ModalitaPagamento']; - -echo ' -
    - - - -
    -
    -

    - '.$ragione_sociale.' - - '.(empty($anagrafica) ? ''.tr('Nuova anagrafica').'' : ''.Modules::link('Anagrafiche', $anagrafica->id, '', null, '')).'
    - - - '.(!empty($codice_fiscale) ? (tr('Codice Fiscale').': '.$codice_fiscale.'
    ') : '').' - '.(!empty($partita_iva) ? (tr('Partita IVA').': '.$partita_iva.'
    ') : '').' - '.$cap.' '.$citta.' ('.$provincia.')
    -
    -

    -
    - -
    -

    - '.$dati_generali['Numero'].' - - - '.tr('Visualizza').' - - -
    - '.$tipo_documento.' -
    '.Translator::dateToLocale($dati_generali['Data']).' -
    '.$dati_generali['Divisa'].' -
    -

    -
    '; - -// Blocco DatiPagamento è valorizzato (opzionale) -if (!empty($pagamenti)) { - echo ' -
    -

    '.tr('Pagamento').'

    - -

    '.tr('La fattura importata presenta _NUM_ rat_E_ di pagamento con le seguenti scadenze', [ - '_NUM_' => count($metodi), - '_E_' => ((count($metodi) > 1) ? 'e' : 'a'), - ]).':

    -
      '; - - foreach ($pagamenti as $pagamento) { - $rate = $pagamento['DettaglioPagamento']; - $rate = isset($rate[0]) ? $rate : [$rate]; - - // Scadenze di pagamento - foreach ($rate as $rata) { - $descrizione = !empty($rata['ModalitaPagamento']) ? $database->fetchOne('SELECT descrizione FROM fe_modalita_pagamento WHERE codice = '.prepare($rata['ModalitaPagamento']))['descrizione'] : ''; - $data = !empty($rata['DataScadenzaPagamento']) ? FatturaElettronica::parseDate($rata['DataScadenzaPagamento']) : ''; - - echo ' -
    1. - '.dateFormat($data).' - '.moneyFormat($rata['ImportoPagamento']).' - ('.$descrizione.') -
    2. '; - } - } - - echo ' -
    -
    '; -} - -echo ' -
    '; - -// Tipo del documento -$query = "SELECT id, CONCAT (descrizione, IF((codice_tipo_documento_fe IS NULL), '', CONCAT(' (', codice_tipo_documento_fe, ')' ) )) AS descrizione FROM co_tipidocumento WHERE dir = 'uscita'"; -$query_tipo = $query.' AND codice_tipo_documento_fe = '.prepare($dati_generali['TipoDocumento']); -$numero_tipo = $database->fetchNum($query_tipo); -if (!empty($numero_tipo)) { - $query = $query_tipo; -} - -echo ' -
    -
    - {[ "type": "select", "label": "'.tr('Tipo fattura').'", "name": "id_tipo", "required": 1, "values": "query='.$query.'", "value": "'.($numero_tipo == 1 ? $database->fetchOne($query_tipo)['id'] : '').'" ]} -
    '; - -// Sezionale -echo ' -
    - {[ "type": "select", "label": "'.tr('Sezionale').'", "name": "id_segment", "required": 1, "values": "query=SELECT id, name AS descrizione FROM zz_segments WHERE is_fiscale = 1 AND id_module='.$id_module.' ORDER BY name", "value": "'.$_SESSION['module_'.$id_module]['id_segment'].'" ]} -
    '; - -// Data di registrazione -$data_registrazione = get('data_registrazione'); -$data_registrazione = new Carbon($data_registrazione); -echo ' -
    - {[ "type": "date", "label": "'.tr('Data di registrazione').'", "name": "data_registrazione", "required": 1, "value": "'.($data_registrazione ?: $dati_generali['Data']).'", "max-date": "-now-", "min-date": "'.$dati_generali['Data'].'" ]} -
    '; - -if (!empty($anagrafica)) { - $query = "SELECT - co_documenti.id, - CONCAT('Fattura num. ', co_documenti.numero_esterno, ' del ', DATE_FORMAT(co_documenti.data, '%d/%m/%Y')) AS descrizione - FROM co_documenti - INNER JOIN co_tipidocumento ON co_tipidocumento.id = co_documenti.idtipodocumento - WHERE - co_tipidocumento.dir = 'uscita' AND - (co_documenti.data BETWEEN NOW() - INTERVAL 1 YEAR AND NOW()) AND - co_documenti.idstatodocumento IN (SELECT id FROM co_statidocumento WHERE descrizione != 'Bozza') AND - co_documenti.idanagrafica = ".prepare($anagrafica->id); - - // Riferimenti ad altre fatture - if (in_array($dati_generali['TipoDocumento'], ['TD04', 'TD05'])) { - echo ' -
    - {[ "type": "select", "label": "'.tr('Fattura collegata').'", "name": "ref_fattura", "required": 0, "values": "query='.$query.'" ]} -
    '; - } elseif ($dati_generali['TipoDocumento'] == 'TD06') { - $query .= "AND co_documenti.id_segment = (SELECT id FROM zz_segments WHERE name = 'Fatture pro-forma' AND id_module = ".prepare($id_module).')'; - - echo ' -
    - {[ "type": "select", "label": "'.tr('Collega a fattura pro-forma').'", "name": "ref_fattura", "values": "query='.$query.'" ]} -
    '; - } -} - -echo ' -
    '; - -// Pagamento -echo ' -
    -
    - - - {[ "type": "select", "label": "'.tr('Pagamento').'", "name": "pagamento", "required": 1, "ajax-source": "pagamenti", "select-options": '.json_encode(['codice_modalita_pagamento_fe' => $codice_modalita_pagamento]).' ]} -
    '; - -// Movimentazioni -echo ' -
    - {[ "type": "checkbox", "label": "'.tr('Movimenta gli articoli').'", "name": "movimentazione", "value": 1 ]} -
    - -
    - {[ "type": "checkbox", "label": "'.tr('Creazione automatica articoli').'", "name": "crea_articoli", "value": 0, "help": "'.tr("Nel caso di righe con tag CodiceArticolo, il gestionale procede alla creazione dell'articolo se la riga non risulta assegnata manualmente").'" ]} -
    '; - - $ritenuta = $dati_generali['DatiRitenuta']; - - if (!empty($ritenuta)) { - echo ' -
    - {[ "type": "checkbox", "label": "'.tr('Ritenuta pagata dal fornitore').'", "name": "is_ritenuta_pagata", "value": 0, "help": "'.tr('Attivare se la ritenuta è stata pagata dal fornitore').'" ]} -
    '; - } - echo ' -
    '; - -// Righe -$righe = $fattura_pa->getRighe(); -if (!empty($righe)) { - echo ' -

    - '.tr('Righe').' - -
    -

    - -
    - - - - - - - - - - - '; - - foreach ($righe as $key => $riga) { - $query = "SELECT id, IF(codice IS NULL, descrizione, CONCAT(codice, ' - ', descrizione)) AS descrizione FROM co_iva WHERE deleted_at IS NULL AND percentuale = ".prepare($riga['AliquotaIVA']); - $start_query = $query; - - if (!empty($riga['Natura'])) { - $query .= ' AND codice_natura_fe = '.prepare($riga['Natura']); - - // Fallback per natura iva mancante - if (empty($dbo->fetchArray($query))) { - $query = $start_query; - } - } - - $query .= ' ORDER BY descrizione ASC'; - - // Visualizzazione codici articoli - $codici = $riga['CodiceArticolo'] ?: []; - $codici = !empty($codici) && !isset($codici[0]) ? [$codici] : $codici; - - $codici_articoli = []; - foreach ($codici as $codice) { - $codici_articoli[] = $codice['CodiceValore'].' ('.$codice['CodiceTipo'].')'; - } - - // Individuazione articolo con codice relativo - $id_articolo = null; - $codice_principale = $codici[0]['CodiceValore']; - if (!empty($codice_principale)) { - if (!empty($anagrafica) && empty($id_articolo)) { - $id_articolo = $database->fetchOne('SELECT id_articolo AS id FROM mg_fornitore_articolo WHERE codice_fornitore = '.prepare($codice_principale).' AND id_fornitore = '.prepare($anagrafica->id))['id']; - } - - if (empty($id_articolo)) { - $id_articolo = $database->fetchOne('SELECT id FROM mg_articoli WHERE codice = '.prepare($codice_principale))['id']; - } - } - - $qta = $riga['Quantita']; - $um = $riga['UnitaMisura']; - $prezzo_unitario = $riga['PrezzoUnitario'] ?: $riga['Importo']; - - echo ' - - - - - - - - - - - - - '; - } - - echo ' - -
    '.tr('Descrizione').''.tr('Quantità').''.tr('Prezzo unitario').''.tr('Aliquota').'
    - '.(empty($codice_principale) ? '' : '').' - - - - '.$riga['Descrizione'].'
    - - '.(!empty($codici_articoli) ? ''.implode(', ', $codici_articoli).'
    ' : '').' - - -
    - '.numberFormat($qta, 'qta').' '.$um.' - - - '.moneyFormat($prezzo_unitario).' - - - '.replace('_VALUE_ _DESC_', [ - '_VALUE_' => empty($riga['Natura']) ? numberFormat($riga['AliquotaIVA'], 0).'%' : $riga['Natura'], - '_DESC_' => $riga['RiferimentoNormativo'] ? ' - '.$riga['RiferimentoNormativo'] : '', - ]).' - -
    - '.$riga['AliquotaIVA'].' - - - - - - - - - - - - -
    - -
    -
    - {[ "type": "select", "name": "articoli['.$key.']", "ajax-source": "articoli", "select-options": '.json_encode(['permetti_movimento_a_zero' => 1, 'dir' => 'entrata', 'idanagrafica' => $anagrafica ? $anagrafica->id : '']).', "icon-after": "add|'.Modules::get('Articoli')['id'].'|codice='.str_replace('\\', '/', htmlentities($codice_principale)).'&descrizione='.str_replace('\\', '/', htmlentities($riga['Descrizione'])).'", "value": "'.$id_articolo.'", "label": "'.tr('Articolo').'" ]} -
    - -
    - {[ "type": "select", "name": "conto['.$key.']", "ajax-source": "conti-acquisti", "required": 1, "label": "'.tr('Conto acquisti').'" ]} -
    - -
    - {[ "type": "select", "name": "iva['.$key.']", "values": '.json_encode('query='.$query).', "required": 1, "label": "'.tr('Aliquota IVA').'" ]} -
    -
    - -
    -
    - {[ "type": "select", "name": "selezione_riferimento['.$key.']", "ajax-source": "riferimenti-fe", "select-options": '.json_encode(['id_anagrafica' => $anagrafica ? $anagrafica->id : '']).', "label": "'.tr('Riferimento acquisto').'", "icon-after": '.json_encode('').', "help": "'.tr('Articoli contenuti in Ordini o DDT del Fornitore').'" ]} -
    - -
    - {[ "type": "select", "name": "selezione_riferimento_vendita['.$key.']", "ajax-source": "riferimenti-vendita-fe", "select-options": '.json_encode(['id_articolo' => $id_articolo]).', "label": "'.tr('Riferimento vendita').'", "icon-after": '.json_encode('').', "help": "'.tr('Articoli contenuti in Ordini Cliente').'" ]} -
    -
    - -
    - -
    -
    '; - - echo ' - '; -} else { - echo ' -

    '.tr('Non ci sono righe nella fattura').'.

    '; -} - -echo ' -
    -
    - - '.tr('Salta fattura').' - - - -
    -
    -
    - -'; diff --git a/plugins/importFE/init.php b/plugins/importFE/init.php deleted file mode 100755 index 81ce24648..000000000 --- a/plugins/importFE/init.php +++ /dev/null @@ -1,48 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Plugins\ImportFE\FatturaElettronica; -use Plugins\ImportFE\Interaction; - -if (isset($id_record)) { - $files = Interaction::getFileList(); - $record = $files[$id_record - 1]; - - $has_next = isset($files[$id_record]); - - try { - $fattura_pa = FatturaElettronica::manage($record['name']); - $anagrafica = $fattura_pa->findAnagrafica(); - } catch (UnexpectedValueException $e) { - $imported = true; - } catch (Exception $e) { - $error = true; - } - - // Rimozione .p7m dal nome del file (causa eventuale estrazione da ZIP) - $record['name'] = str_replace('.p7m', '', $record['name']); - - if (empty($record)) { - flash()->warning(tr('Nessuna fattura da importare!')); - - redirect(base_path().'/controller.php?id_module='.$id_module); - } -} diff --git a/plugins/importFE/list.php b/plugins/importFE/list.php deleted file mode 100755 index 15409d6d8..000000000 --- a/plugins/importFE/list.php +++ /dev/null @@ -1,234 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Plugins\ImportFE\Interaction; - -$list = Interaction::getInvoiceList(); - -$directory = Plugins\ImportFE\FatturaElettronica::getImportDirectory(); - -if (!empty($list)) { - echo ' - - - - - - - - - - - '; - - foreach ($list as $element) { - $name = $element['name']; - $data = $element['date_sent'] ?: ''; - - echo ' - '; - - if (!empty($element['file'])) { - echo ' - - - - - - - - - - - - - - '; - } - - echo ' - -
    '.tr('Descrizione').''.tr('Fornitore').''.tr('Data di registrazione').''.tr('Totale imponibile').'#
    -

    '.$name.'

    -
    --- - '; - } else { - $date = new DateTime($element['date']); - $date = $date->format('Y-m-d'); - - $descrizione = ''; - if ($element['type'] == 'TD01') { - $descrizione = tr('Fattura num. _NUM_ del _DATE_', [ - '_NUM_' => $element['number'], - '_DATE_' => dateFormat($date), - ]); - } elseif ($element['type'] == 'TD04') { - $descrizione = tr('Nota di credito num. _NUM_ del _DATE_', [ - '_NUM_' => $element['number'], - '_DATE_' => dateFormat($date), - ]); - } elseif ($element['type'] == 'TD05') { - $descrizione = tr('Nota di debito num. _NUM_ del _DATE_', [ - '_NUM_' => $element['number'], - '_DATE_' => dateFormat($date), - ]); - } elseif ($element['type'] == 'TD06') { - $descrizione = tr('Parcella num. _NUM_ del _DATE_', [ - '_NUM_' => $element['number'], - '_DATE_' => dateFormat($date), - ]); - } - - echo ' - - '.$descrizione.' ['.$name.'] - '.$element['sender'].''.dateFormat($element['date_sent']).''.moneyFormat($element['amount']).' - '; - } - - if (file_exists($directory.'/'.$name)) { - echo ' - '; - } - - echo ' - - -
    '; -} else { - echo ' -

    '.tr('Nessuna fattura da importare').'.

    '; -} - -echo ' -'; diff --git a/plugins/importFE/riferimento.php b/plugins/importFE/riferimento.php deleted file mode 100755 index db03de050..000000000 --- a/plugins/importFE/riferimento.php +++ /dev/null @@ -1,125 +0,0 @@ -. - */ - -use Modules\DDT\DDT; -use Modules\Ordini\Ordine; - -include_once __DIR__.'/../../core.php'; -include_once __DIR__.'/init.php'; - -$direzione = 'uscita'; -$id_riga = get('id_riga'); -$qta = get('qta'); - -$id_documento = get('id_documento'); -$tipo_documento = get('tipo_documento'); -$dir = get('dir'); -if ($tipo_documento == 'ordine') { - $documento = Ordine::find($id_documento); - $righe_utilizzate = get('righe_ordini'); -} else { - $documento = DDT::find($id_documento); - $righe_utilizzate = get('righe_ddt'); -} - -echo ' - - - - - - - - - '; - -$id_riferimento = get('id_riferimento'); -$righe = $documento->getRighe(); -foreach ($righe as $riga) { - $qta_rimanente = $riga->qta_rimanente - $righe_utilizzate[$riga->id]; - $riga_origine = $riga->getOriginalComponent(); - - $dettagli = [ - 'tipo' => get_class($riga), - 'id' => $riga->id, - 'descrizione' => str_replace(' ', '_', $riga->descrizione), - 'qta' => $riga->qta, - 'um' => $riga->um, - 'prezzo_unitario' => $riga->prezzo_unitario ?: $riga_origine->prezzo_unitario, - 'id_iva' => $riga->id_iva, - 'iva_percentuale' => $riga->aliquota->percentuale, - ]; - - echo ' - id ? 'class="success"' : '').' data-dettagli='.json_encode($dettagli).'> - - - - - '; -} - -echo ' - -
    '.tr('Descrizione').' - '.tr('Q.tà').' - '.tr('Prezzo unitario').'#
    '.(!empty($riga->codice) ? $riga->codice.' - ' : '').$riga->descrizione.''.numberFormat($qta_rimanente, 'qta').' / '.numberFormat($riga->qta, 'qta').' '.$riga->um.''.moneyFormat($riga->prezzo_unitario_corrente).''; - - if ($qta_rimanente >= $qta) { - echo ' - '; - } - - echo ' -
    - - - -'; diff --git a/plugins/importFE/src/FatturaElettronica.php b/plugins/importFE/src/FatturaElettronica.php deleted file mode 100755 index 60e366f50..000000000 --- a/plugins/importFE/src/FatturaElettronica.php +++ /dev/null @@ -1,395 +0,0 @@ -. - */ - -namespace Plugins\ImportFE; - -use Modules; -use Modules\Anagrafiche\Anagrafica; -use Modules\Anagrafiche\Nazione; -use Modules\Anagrafiche\Tipo as TipoAnagrafica; -use Modules\Fatture\Fattura; -use Modules\Fatture\Stato as StatoFattura; -use Modules\Fatture\Tipo as TipoFattura; -use UnexpectedValueException; -use Uploads; -use Util\XML; - -/** - * Classe per la gestione della fatturazione elettronica in XML. - * - * @since 2.4.9 - */ -class FatturaElettronica -{ - protected static $directory = null; - - /** @var array Percorso del file XML */ - protected $file = null; - - /** @var array XML della fattura */ - protected $xml = null; - - /** @var Fattura Fattura collegata */ - protected $fattura = null; - - public function __construct($name) - { - $this->file = static::getImportDirectory().'/'.$name; - - if (string_ends_with($name, '.p7m')) { - $file = XML::decodeP7M($this->file); - - if (!empty($file)) { - delete($this->file); - - $this->file = $file; - } - } - - $this->xml = XML::readFile($this->file); - - // Individuazione fattura pre-esistente - $dati_generali = $this->getBody()['DatiGenerali']['DatiGeneraliDocumento']; - $data = $dati_generali['Data']; - $numero = $dati_generali['Numero']; - $progressivo_invio = $this->getHeader()['DatiTrasmissione']['ProgressivoInvio']; - - $fattura = Fattura::where([ - 'progressivo_invio' => $progressivo_invio, - 'numero_esterno' => $numero, - 'data' => $data, - ])->first(); - - if (!empty($fattura)) { - throw new UnexpectedValueException(); - } - } - - public static function getImportDirectory() - { - if (!isset(self::$directory)) { - $module = Modules::get('Fatture di acquisto'); - - $plugins = $module->plugins; - if (!empty($plugins)) { - $plugin = $plugins->first(function ($value, $key) { - return $value->name == 'Fatturazione Elettronica'; - }); - - self::$directory = base_dir().'/'.$plugin->upload_directory; - } - } - - return self::$directory; - } - - public static function store($filename, $content) - { - $directory = static::getImportDirectory(); - $file = $directory.'/'.$filename; - - directory($directory); - file_put_contents($file, $content); - - return $filename; - } - - public static function isValid($name) - { - try { - new static($name); - - return true; - } catch (UnexpectedValueException $e) { - $file = static::getImportDirectory().'/'.$name; - delete($file); - - return false; - } - } - - public static function manage($name) - { - try { - $manager = new FatturaOrdinaria($name); - - $tipo = $manager->getBody()['DatiGenerali']['DatiGeneraliDocumento']['TipoDocumento']; - if ($tipo == 'TD06') { - $manager = new Parcella($name); - } - } catch (UnexpectedValueException $e) { - $manager = new FatturaSemplificata($name); - } - - return $manager; - } - - public function getHeader() - { - return $this->xml['FatturaElettronicaHeader']; - } - - public function getBody() - { - return $this->xml['FatturaElettronicaBody']; - } - - public function delete() - { - delete($this->file); - } - - public function getAllegati() - { - $result = $this->getBody()['Allegati']; - - $result = $this->forceArray($result); - - return array_clean($result); - } - - public function saveAllegati() - { - $allegati = $this->getAllegati(); - - $module = Modules::get('Fatture di acquisto'); - - $info = [ - 'category' => tr('Fattura Elettronica'), - 'id_module' => $module->id, - 'id_record' => $this->fattura->id, - ]; - - foreach ($allegati as $allegato) { - $content = base64_decode($allegato['Attachment']); - - $extension = '.pdf'; - if (!empty($allegato['FormatoAttachment'])) { - $extension = '.'.strtolower($allegato['FormatoAttachment']); - } - - $original = $allegato['NomeAttachment'].$extension; - Uploads::upload($content, array_merge($info, [ - 'name' => $allegato['NomeAttachment'], - 'original_name' => $original, - ])); - } - - // Registrazione XML come allegato - Uploads::upload($this->file, array_merge($info, [ - 'name' => tr('Fattura Elettronica'), - 'original_name' => basename($this->file), - ])); - } - - public function findAnagrafica($type = 'Fornitore') - { - $info = $this->getAnagrafe(); - - $tipologia = TipoAnagrafica::where('descrizione', $type)->first(); - - $anagrafica = Anagrafica::whereHas('tipi', function ($query) use ($tipologia) { - $query->where('an_tipianagrafiche.idtipoanagrafica', '=', $tipologia->id); - }); - - if (!empty($info['partita_iva']) && !empty($info['codice_fiscale'])) { - $anagrafica->where('piva', $info['partita_iva']) - ->orWhere('codice_fiscale', $info['codice_fiscale']); - } elseif (!empty($info['codice_fiscale'])) { - $anagrafica->where('codice_fiscale', $info['codice_fiscale']); - } elseif (!empty($info['partita_iva'])) { - $anagrafica->where('piva', $info['partita_iva']); - } - - return $anagrafica->first(); - } - - /** - * Restituisce l'anagrafica collegata alla fattura, eventualmente generandola con i dati forniti. - * - * @param string $type - * - * @return Anagrafica - */ - public function saveAnagrafica($type = 'Fornitore') - { - $anagrafica = $this->findAnagrafica($type); - - if (!empty($anagrafica)) { - return $anagrafica; - } - - $info = $this->getAnagrafe(); - - $anagrafica = Anagrafica::build($info['ragione_sociale'], $info['nome'], $info['cognome'], [ - TipoAnagrafica::where('descrizione', $type)->first()->id, - ]); - - if (!empty($info['partita_iva'])) { - $anagrafica->partita_iva = $info['partita_iva']; - } - - if (!empty($info['codice_fiscale'])) { - $anagrafica->codice_fiscale = $info['codice_fiscale']; - } - - // Informazioni sull'anagrafica - if (!empty($info['rea'])) { - if (!empty($info['rea']['codice'])) { - $anagrafica->codicerea = $info['rea']['codice']; - } - - if (!empty($info['rea']['capitale_sociale'])) { - $anagrafica->capitale_sociale = $info['rea']['capitale_sociale']; - } - } - - $anagrafica->save(); - - // Informazioni sulla sede - $sede = $anagrafica->sedeLegale; - - $sede->indirizzo = $info['sede']['indirizzo']; - $sede->cap = $info['sede']['cap']; - $sede->citta = $info['sede']['citta']; - if (!empty($info['sede']['provincia'])) { - $sede->provincia = $info['sede']['provincia']; - } - $sede->nazione()->associate(Nazione::where('iso2', $info['sede']['nazione'])->first()); - - $contatti = $info['contatti']; - if (!empty($contatti)) { - if (!empty($contatti['telefono'])) { - $sede->telefono = $contatti['telefono']; - } - - if (!empty($contatti['fax'])) { - $sede->fax = $contatti['fax']; - } - - if (!empty($contatti['email'])) { - $sede->email = $contatti['email']; - } - } - - $sede->save(); - - return $anagrafica; - } - - /** - * Registra la fattura elettronica come fattura del gestionale. - * - * @param int $id_pagamento - * @param int $id_sezionale - * @param int $id_tipo - * @param string $data_registrazione - * @param int $ref_fattura - * - * @return Fattura - */ - public function saveFattura($id_pagamento, $id_sezionale, $id_tipo, $data_registrazione, $ref_fattura, $is_ritenuta_pagata = false) - { - $dati_generali = $this->getBody()['DatiGenerali']['DatiGeneraliDocumento']; - $data = self::parseDate($dati_generali['Data']); - - $fattura = $this->prepareFattura($id_tipo, $data, $id_sezionale, $ref_fattura); - $this->fattura = $fattura; - - $numero_esterno = $dati_generali['Numero']; - $progressivo_invio = $this->getHeader()['DatiTrasmissione']['ProgressivoInvio']; - - $fattura->progressivo_invio = $progressivo_invio; - $fattura->numero_esterno = $numero_esterno; - $fattura->idpagamento = $id_pagamento; - $fattura->is_ritenuta_pagata = $is_ritenuta_pagata; - - // Riferimento per nota di credito e debito - $fattura->ref_documento = $ref_fattura ?: null; - - // Per il destinatario, la data di registrazione della fattura assume grande rilievo ai fini IVA, poiché determina la decorrenza dei termini per poter esercitare il diritto alla detrazione. - // La data di ricezione della fattura è contenuta all’interno della “ricevuta di consegna” visibile al trasmittente della stessa. - $fattura->data_registrazione = $data_registrazione; - $fattura->data_competenza = $fattura->data; - - $stato_documento = StatoFattura::where('descrizione', 'Emessa')->first(); - $fattura->stato()->associate($stato_documento); - - $causali = $dati_generali['Causale']; - if (!empty($causali)) { - $note = ''; - foreach ($causali as $causale) { - $note .= $causale; - } - - $fattura->note = $note; - } - - // Sconto finale da ScontoMaggiorazione: non importato - $fattura->save(); - - // Fix generazione idsede - $fattura->refresh(); - - return $fattura; - } - - public function getFattura() - { - return $this->fattura; - } - - public function save($info = []) - { - $this->saveFattura($info['id_pagamento'], $info['id_segment'], $info['id_tipo'], $info['data_registrazione'], $info['ref_fattura'], $info['is_ritenuta_pagata']); - - $this->saveRighe($info['articoli'], $info['iva'], $info['conto'], $info['movimentazione'], $info['crea_articoli'], $info['tipo_riga_riferimento'], $info['id_riga_riferimento'], $info['tipo_riga_riferimento_vendita'], $info['id_riga_riferimento_vendita']); - - $this->saveAllegati(); - - return $this->getFattura()->id; - } - - public static function parseDate($data) - { - return date('Y-m-d', strtotime($data)); - } - - protected function prepareFattura($id_tipo, $data, $id_sezionale, $ref_fattura) - { - $anagrafica = $this->saveAnagrafica(); - - $tipo = TipoFattura::where('id', $id_tipo)->first(); - - $fattura = Fattura::build($anagrafica, $tipo, $data, $id_sezionale); - $this->fattura = $fattura; - - // Riferimento per nota di credito e debito - $fattura->ref_documento = $ref_fattura ?: null; - - return $fattura; - } - - protected function forceArray($result) - { - $result = isset($result[0]) ? $result : [$result]; - - return $result; - } -} diff --git a/plugins/importFE/src/FatturaOrdinaria.php b/plugins/importFE/src/FatturaOrdinaria.php deleted file mode 100755 index 5644eecff..000000000 --- a/plugins/importFE/src/FatturaOrdinaria.php +++ /dev/null @@ -1,414 +0,0 @@ -. - */ - -namespace Plugins\ImportFE; - -use Common\Components\Component; -use Modules\Anagrafiche\Anagrafica; -use Modules\Articoli\Articolo as ArticoloOriginale; -use Modules\Articoli\Categoria; -use Modules\Fatture\Components\Articolo; -use Modules\Fatture\Components\Riga; -use Modules\Fatture\Fattura; -use Plugins\ListinoClienti\DettaglioPrezzo; -use UnexpectedValueException; -use Util\XML; - -/** - * Classe per la gestione della fatturazione elettronica in XML. - * - * @since 2.4.2 - */ -class FatturaOrdinaria extends FatturaElettronica -{ - public function __construct($name) - { - parent::__construct($name); - - if ($this->getHeader()['DatiTrasmissione']['FormatoTrasmissione'] == 'FSM10') { - throw new UnexpectedValueException(); - } - } - - public function getAnagrafe() - { - $dati = $this->getHeader()['CedentePrestatore']; - - $anagrafe = $dati['DatiAnagrafici']; - $rea = $dati['IscrizioneREA']; - $sede = $dati['Sede']; - $contatti = $dati['Contatti']; - - $info = [ - 'partita_iva' => $anagrafe['IdFiscaleIVA']['IdCodice'], - 'codice_fiscale' => $anagrafe['CodiceFiscale'], - 'ragione_sociale' => $anagrafe['Anagrafica']['Denominazione'], - 'nome' => $anagrafe['Anagrafica']['Nome'], - 'cognome' => $anagrafe['Anagrafica']['Cognome'], - 'rea' => [ - 'codice' => $rea['Ufficio'].'-'.$rea['NumeroREA'], - 'capitale_sociale' => $rea['CapitaleSociale'], - ], - 'sede' => [ - 'indirizzo' => $sede['Indirizzo'].' '.$sede['NumeroCivico'], - 'cap' => $sede['CAP'], - 'citta' => $sede['Comune'], - 'provincia' => $sede['Provincia'], - 'nazione' => $sede['Nazione'], - ], - 'contatti' => [ - 'telefono' => $contatti['Telefono'], - 'fax' => $contatti['Fax'], - 'email' => $contatti['email'], - ], - ]; - - return $info; - } - - public function getRighe() - { - $result = $this->getBody()['DatiBeniServizi']['DettaglioLinee']; - $result = $this->forceArray($result); - - // Aggiunta degli arrotondamenti IVA come righe indipendenti - $riepiloghi = $this->getBody()['DatiBeniServizi']['DatiRiepilogo']; - $riepiloghi = $this->forceArray($riepiloghi); - foreach ($riepiloghi as $riepilogo) { - $valore = isset($riepilogo['Arrotondamento']) ? floatval($riepilogo['Arrotondamento']) : 0; - if (!empty($valore)) { - $descrizione = tr('Arrotondamento IVA _VALUE_', [ - '_VALUE_' => empty($riepilogo['Natura']) ? numberFormat($riepilogo['AliquotaIVA']).'%' : $riepilogo['Natura'], - ]); - - $result[] = [ - 'Descrizione' => $descrizione, - 'PrezzoUnitario' => $valore, - 'Quantita' => 1, - 'AliquotaIVA' => $riepilogo['AliquotaIVA'], - 'Natura' => $riepilogo['Natura'], - ]; - } - } - - return $this->forceArray($result); - } - - public function saveRighe($articoli, $iva, $conto, $movimentazione = true, $crea_articoli = false, $tipi_riferimenti = [], $id_riferimenti = [], $tipi_riferimenti_vendita = [], $id_riferimenti_vendita = []) - { - $info = $this->getRitenutaRivalsa(); - - $righe = $this->getRighe(); - $fattura = $this->getFattura(); - - $id_ritenuta_acconto = $info['id_ritenuta_acconto']; - $id_rivalsa = $info['id_rivalsa']; - $calcolo_ritenuta_acconto = $info['rivalsa_in_ritenuta'] ? 'IMP+RIV' : 'IMP'; - $ritenuta_contributi = !empty($fattura->id_ritenuta_contributi); - - foreach ($righe as $key => $riga) { - $articolo = ArticoloOriginale::find($articoli[$key]); - - $riga['PrezzoUnitario'] = floatval($riga['PrezzoUnitario']); - $riga['Quantita'] = floatval($riga['Quantita']); - - $codici = $riga['CodiceArticolo'] ?: []; - $codici = !empty($codici) && !isset($codici[0]) ? [$codici] : $codici; - - // Creazione articolo relativo - if (!empty($codici) && !empty($crea_articoli) && empty($articolo)) { - $codice = $codici[0]['CodiceValore']; - $articolo = ArticoloOriginale::where('codice', $codice)->first(); - - if (empty($articolo)) { - $nome_categoria = 'Importazione automatica'; - $categoria = Categoria::where('nome', $nome_categoria)->first(); - if (empty($categoria)) { - $categoria = Categoria::build($nome_categoria); - } - - $articolo = ArticoloOriginale::build($codice, $riga['Descrizione'], $categoria); - $articolo->prezzo_acquisto = $riga['PrezzoUnitario']; - $articolo->id_fornitore = $fattura->idanagrafica; - $articolo->um = $riga['UnitaMisura']; - $articolo->idconto_acquisto = $conto[$key]; - $articolo->save(); - - $direzione = 'uscita'; - $anagrafica = Anagrafica::find($fattura->idanagrafica); - $dettaglio_prezzo = DettaglioPrezzo::build($articolo, $anagrafica, $direzione); - - $dettaglio_prezzo->setPrezzoUnitario($riga['PrezzoUnitario']); - $dettaglio_prezzo->save(); - } - } - - if (!empty($articolo)) { - $obj = Articolo::build($fattura, $articolo); - - $obj->movimentazione($movimentazione); - - $target_type = 'Modules\Fatture\Components\Articolo'; - } else { - $obj = Riga::build($fattura); - - $target_type = 'Modules\Fatture\Components\Riga'; - } - - $obj->descrizione = $riga['Descrizione']; - - // Collegamento al documento di riferimento - if (!empty($tipi_riferimenti[$key]) && is_subclass_of($tipi_riferimenti[$key], Component::class)) { - $riga_origine = ($tipi_riferimenti[$key])::find($id_riferimenti[$key]); - list($riferimento_precedente, $nuovo_riferimento) = $obj->impostaOrigine($riga_origine); - - // Correzione della descrizione - $obj->descrizione = str_replace($riferimento_precedente, '', $obj->descrizione); - $obj->descrizione .= $nuovo_riferimento; - } - - $obj->save(); - - if (!empty($tipi_riferimenti_vendita[$key])) { - database()->insert('co_riferimenti_righe', [ - 'source_type' => $tipi_riferimenti_vendita[$key], - 'source_id' => $id_riferimenti_vendita[$key], - 'target_type' => $target_type, - 'target_id' => $obj->id, - ]); - } - - $obj->id_iva = $iva[$key]; - $obj->idconto = $conto[$key]; - - $obj->id_rivalsa_inps = $id_rivalsa; - $obj->ritenuta_contributi = $ritenuta_contributi; - - if (!empty($riga['Ritenuta'])) { - $obj->id_ritenuta_acconto = $id_ritenuta_acconto; - $obj->calcolo_ritenuta_acconto = $calcolo_ritenuta_acconto; - } - - // Nel caso il prezzo sia negativo viene gestito attraverso l'inversione della quantità (come per le note di credito) - // TODO: per migliorare la visualizzazione, sarebbe da lasciare negativo il prezzo e invertire gli sconti. - $prezzo = $riga['PrezzoUnitario']; - $prezzo = $riga['PrezzoUnitario'] < 0 ? -$prezzo : $prezzo; - $qta = $riga['Quantita'] ?: 1; - $qta = $riga['PrezzoUnitario'] < 0 ? -$qta : $qta; - - // Prezzo e quantità - $obj->prezzo_unitario = $prezzo; - $obj->qta = $qta; - - if (!empty($riga['UnitaMisura'])) { - $obj->um = $riga['UnitaMisura']; - } - - // Sconti e maggiorazioni - $sconti = $riga['ScontoMaggiorazione']; - if (!empty($sconti)) { - $sconti = $sconti[0] ? $sconti : [$sconti]; - $tipo = !empty($sconti[0]['Percentuale']) ? 'PRC' : 'UNT'; - - $lista = []; - foreach ($sconti as $sconto) { - $unitario = $sconto['Percentuale'] ?: $sconto['Importo']; - - // Sconto o Maggiorazione - $lista[] = ($sconto['Tipo'] == 'SC') ? $unitario : -$unitario; - } - - if ($tipo == 'PRC') { - $elenco = implode('+', $lista); - $sconto = calcola_sconto([ - 'sconto' => $elenco, - 'prezzo' => $obj->prezzo_unitario, - 'tipo' => 'PRC', - 'qta' => $obj->qta, - ]); - - /* - * Trasformazione di sconti multipli in sconto percentuale combinato. - * Esempio: 40% + 30% è uno sconto del 42%. - */ - $sconto_unitario = $sconto * 100 / $obj->imponibile; - } else { - $sconto_unitario = sum($lista); - } - - $obj->setSconto($sconto_unitario, $tipo); - } - - $obj->save(); - } - - // Ricaricamento della fattura - $fattura->refresh(); - - // Arrotondamenti differenti nella fattura XML - $totali_righe = array_column($righe, 'PrezzoTotale'); - $totale_righe = sum($totali_righe); - - $dati_generali = $this->getBody()['DatiGenerali']['DatiGeneraliDocumento']; - $totale_documento = floatval($dati_generali['ImportoTotaleDocumento']); - - $diff = $totale_documento ? abs($totale_documento) - abs($fattura->totale) : abs($totale_righe) - abs($fattura->totale_imponibile); - if (!empty($diff)) { - // Rimozione dell'IVA calcolata automaticamente dal gestionale - $iva_arrotondamento = database()->fetchOne('SELECT * FROM co_iva WHERE percentuale=0 AND deleted_at IS NULL'); - $diff = $diff * 100 / (100 + $iva_arrotondamento['percentuale']); - - $obj = Riga::build($fattura); - - $obj->descrizione = tr('Arrotondamento calcolato in automatico'); - $obj->id_iva = $iva_arrotondamento['id']; - $obj->idconto = $conto[0]; - $obj->prezzo_unitario = round($diff, 4); - $obj->qta = 1; - - $obj->save(); - } - } - - protected function prepareFattura($id_tipo, $data, $id_sezionale, $ref_fattura) - { - $fattura = parent::prepareFattura($id_tipo, $data, $id_sezionale, $ref_fattura); - $database = database(); - - $righe = $this->getRighe(); - - $totali = array_column($righe, 'PrezzoTotale'); - $totale = sum($totali); - - foreach ($righe as $riga) { - $dati = $riga['AltriDatiGestionali']; - if (!empty($dati)) { - $dati = isset($dati[0]) ? $dati : [$dati]; - - foreach ($dati as $dato) { - if ($dato['TipoDato'] == 'CASSA-PREV') { - $descrizione = $dato['RiferimentoTesto']; - $importo = floatval($dato['RiferimentoNumero']); - - preg_match('/^(.+?) - (.+?) \((.+?)%\)$/', trim($descrizione), $m); - - $nome = ucwords(strtolower($m[2])); - $percentuale = $m[3]; - - $totale_previsto = round($importo / $percentuale * 100, 2); - $percentuale_importo = round($totale_previsto / $totale * 100, 2); - - $ritenuta_contributi = $database->fetchOne('SELECT * FROM`co_ritenuta_contributi` WHERE `percentuale` = '.prepare($percentuale).' AND `percentuale_imponibile` = '.prepare($percentuale_importo)); - if (empty($ritenuta_contributi)) { - $database->query('INSERT INTO `co_ritenuta_contributi` (`descrizione`, `percentuale`, `percentuale_imponibile`) VALUES ('.prepare($nome).', '.prepare($percentuale).', '.prepare($percentuale_importo).')'); - } - - $ritenuta_contributi = $database->fetchOne('SELECT * FROM`co_ritenuta_contributi` WHERE `percentuale` = '.prepare($percentuale).' AND `percentuale_imponibile` = '.prepare($percentuale_importo)); - - $fattura->id_ritenuta_contributi = $ritenuta_contributi['id']; - } - } - } - } - - return $fattura; - } - - protected function getRitenutaRivalsa() - { - $database = database(); - $dati_generali = $this->getBody()['DatiGenerali']['DatiGeneraliDocumento']; - - // Righe - $righe = $this->getRighe(); - - $rivalsa_in_ritenuta = false; - - // Rivalsa - $casse = $dati_generali['DatiCassaPrevidenziale']; - if (!empty($casse)) { - $totali = array_column($righe, 'PrezzoTotale'); - $totale = sum($totali); - - $casse = isset($casse[0]) ? $casse : [$casse]; - - $importi = []; - foreach ($casse as $cassa) { - $importi[] = floatval($cassa['ImportoContributoCassa']); - if ($cassa['Ritenuta']) { - $rivalsa_in_ritenuta = true; - } - } - $importo = sum($importi); - - $percentuale = round($importo / $totale * 100, 2); - - $rivalsa = $database->fetchOne('SELECT * FROM`co_rivalse` WHERE `percentuale` = '.prepare($percentuale)); - if (empty($rivalsa)) { - $descrizione = tr('Rivalsa _PRC_%', [ - '_PRC_' => numberFormat($percentuale), - ]); - - $database->query('INSERT INTO `co_rivalse` (`descrizione`, `percentuale`) VALUES ('.prepare($descrizione).', '.prepare($percentuale).')'); - } - - $rivalsa = $database->fetchOne('SELECT * FROM`co_rivalse` WHERE `percentuale` = '.prepare($percentuale)); - $id_rivalsa = $rivalsa['id']; - } - - // Ritenuta d'Acconto - $ritenuta = $dati_generali['DatiRitenuta']; - if (!empty($ritenuta)) { - $totali = []; - foreach ($righe as $riga) { - if (!empty($riga['Ritenuta'])) { - $totali[] = $riga['PrezzoTotale']; - } - } - $totale = sum($totali); - - $percentuale = floatval($ritenuta['AliquotaRitenuta']); - $importo = floatval($ritenuta['ImportoRitenuta']); - - $totale_previsto = round($importo / $percentuale * 100, 2); - $percentuale_importo = round($totale_previsto / $totale * 100, 2); - $percentuale_importo = min($percentuale_importo, 100); // Nota: Fix per la percentuale che superava il 100% nel caso di importi con Rivalsa compresa - - $ritenuta_acconto = $database->fetchOne('SELECT * FROM`co_ritenutaacconto` WHERE `percentuale` = '.prepare($percentuale).' AND `percentuale_imponibile` = '.prepare($percentuale_importo)); - if (empty($ritenuta_acconto)) { - $descrizione = tr('Ritenuta _PRC_% sul _TOT_%', [ - '_PRC_' => numberFormat($percentuale), - '_TOT_' => numberFormat($percentuale_importo), - ]); - - $database->query('INSERT INTO `co_ritenutaacconto` (`descrizione`, `percentuale`, `percentuale_imponibile`) VALUES ('.prepare($descrizione).', '.prepare($percentuale).', '.prepare($percentuale_importo).')'); - } - - $ritenuta_acconto = $database->fetchOne('SELECT * FROM`co_ritenutaacconto` WHERE `percentuale` = '.prepare($percentuale).' AND `percentuale_imponibile` = '.prepare($percentuale_importo)); - - $id_ritenuta_acconto = $ritenuta_acconto['id']; - } - - return [ - 'id_ritenuta_acconto' => $id_ritenuta_acconto, - 'id_rivalsa' => $id_rivalsa, - 'rivalsa_in_ritenuta' => $rivalsa_in_ritenuta, - ]; - } -} diff --git a/plugins/importFE/src/FatturaSemplificata.php b/plugins/importFE/src/FatturaSemplificata.php deleted file mode 100755 index f11ff721d..000000000 --- a/plugins/importFE/src/FatturaSemplificata.php +++ /dev/null @@ -1,140 +0,0 @@ -. - */ - -namespace Plugins\ImportFE; - -use Modules\Articoli\Articolo as ArticoloOriginale; -use Modules\Fatture\Components\Articolo; -use Modules\Fatture\Components\Riga; -use UnexpectedValueException; -use Util\XML; - -/** - * Classe per la gestione della fatturazione elettronica in XML. - * - * @since 2.4.2 - */ -class FatturaSemplificata extends FatturaElettronica -{ - public function __construct($name) - { - parent::__construct($name); - - if ($this->getHeader()['DatiTrasmissione']['FormatoTrasmissione'] != 'FSM10') { - throw new UnexpectedValueException(); - } - } - - public function getAnagrafe() - { - $anagrafe = $this->getHeader()['CedentePrestatore']; - - $rea = $anagrafe['IscrizioneREA']; - $sede = $anagrafe['Sede']; - $contatti = $anagrafe['Contatti']; - - $info = [ - 'partita_iva' => $anagrafe['IdFiscaleIVA']['IdCodice'], - 'codice_fiscale' => $anagrafe['CodiceFiscale'], - 'ragione_sociale' => $anagrafe['Denominazione'], - 'nome' => $anagrafe['Nome'], - 'cognome' => $anagrafe['Cognome'], - 'rea' => [ - 'codice' => $rea['Ufficio'].'-'.$rea['NumeroREA'], - 'capitale_sociale' => $rea['CapitaleSociale'], - ], - 'sede' => [ - 'indirizzo' => $sede['Indirizzo'].' '.$sede['NumeroCivico'], - 'cap' => $sede['CAP'], - 'citta' => $sede['Comune'], - 'provincia' => $sede['Provincia'], - 'nazione' => $sede['Nazione'], - ], - ]; - - return $info; - } - - public function getRighe() - { - $result = $this->getBody()['DatiBeniServizi']; - $result = $this->forceArray($result); - - foreach ($result as $index => $item) { - $result[$index]['Quantita'] = 1; - - if (!empty($item['DatiIVA']['Aliquota'])) { - $result[$index]['AliquotaIVA'] = $item['DatiIVA']['Aliquota']; - } else { - $imposta = floatval($item['DatiIVA']['Imposta']); - $importo = floatval($item['Importo']); - - $prezzo = $importo - $imposta; - - $aliquota = !empty($prezzo) ? $imposta / $prezzo * 100 : 0; - $result[$index]['AliquotaIVA'] = $aliquota; - } - } - - return $result; - } - - public function saveRighe($articoli, $iva, $conto, $movimentazione = true, $crea_articoli = false, $tipi_riferimenti = [], $id_riferimenti = [], $tipi_riferimenti_vendita = [], $id_riferimenti_vendita = []) - { - $righe = $this->getRighe(); - $fattura = $this->getFattura(); - - foreach ($righe as $key => $riga) { - $articolo = ArticoloOriginale::find($articoli[$key]); - $importo = floatval($riga['Importo']); - - $imposta_unitaria = floatval($riga['DatiIVA']['Imposta']); - $imposta_percentuale = floatval($riga['DatiIVA']['Aliquota']) / 100; - if (empty($imposta_percentuale)) { - $prezzo = $importo - $imposta_unitaria; - } else { - $prezzo = $importo / (1 + $imposta_percentuale); - } - - if (!empty($articolo)) { - $obj = Articolo::build($fattura, $articolo); - - $obj->movimentazione($movimentazione); - } else { - $obj = Riga::build($fattura); - } - - $obj->descrizione = $riga['Descrizione']; - $obj->id_iva = $iva[$key]; - $obj->idconto = $conto[$key]; - - // Nel caso il prezzo sia negativo viene gestito attraverso l'inversione della quantità (come per le note di credito) - // TODO: per migliorare la visualizzazione, sarebbe da lasciare negativo il prezzo e invertire gli sconti. - $prezzo = $prezzo < 0 ? -$prezzo : $prezzo; - $qta = 1; - $qta = $riga['Importo'] < 0 ? -$qta : $qta; - - // Prezzo e quantità - $obj->prezzo_unitario = $prezzo; - $obj->qta = $qta; - - $obj->save(); - } - } -} diff --git a/plugins/importFE/src/Interaction.php b/plugins/importFE/src/Interaction.php deleted file mode 100755 index 90019cd28..000000000 --- a/plugins/importFE/src/Interaction.php +++ /dev/null @@ -1,122 +0,0 @@ -. - */ - -namespace Plugins\ImportFE; - -use API\Services; -use Models\Cache; - -/** - * Classe per la gestione delle API esterne per l'importazione delle Fatture Elettroniche di acquisto. - * - * @since 2.4.3 - */ -class Interaction extends Services -{ - public static function getInvoiceList() - { - $list = self::getRemoteList(); - - // Ricerca fisica - $result = self::getFileList($list); - - // Aggiornamento cache hook - Cache::pool('Fatture Elettroniche')->set($result); - - return $result; - } - - public static function getRemoteList() - { - $list = []; - - // Ricerca da remoto - if (self::isEnabled()) { - $response = static::request('POST', 'fatture_da_importare'); - $body = static::responseBody($response); - - if ($body['status'] == '200') { - $list = $body['results']; - } - } - - return $list; - } - - public static function getFileList($list = []) - { - $names = array_column($list, 'name'); - - // Ricerca fisica - $directory = FatturaElettronica::getImportDirectory(); - - $files = glob($directory.'/*.xml*'); - foreach ($files as $id => $file) { - $name = basename($file); - $pos = array_search($name, $names); - - if ($pos === false) { - $list[] = [ - 'id' => $id, - 'name' => $name, - 'file' => true, - ]; - } else { - $list[$pos]['id'] = $id; - } - } - - return $list; - } - - public static function getInvoiceFile($name) - { - $directory = FatturaElettronica::getImportDirectory(); - $file = $directory.'/'.$name; - - if (!file_exists($file)) { - $response = static::request('POST', 'fattura_da_importare', [ - 'name' => $name, - ]); - $body = static::responseBody($response); - - if (!empty($body['content'])) { - FatturaElettronica::store($name, $body['content']); - } - } - - return $name; - } - - public static function processInvoice($filename) - { - $response = static::request('POST', 'fattura_xml_salvata', [ - 'filename' => $filename, - ]); - - $body = static::responseBody($response); - - $message = ''; - if ($body['status'] != '200') { - $message = $body['status'].' - '.$body['message']; - } - - return $message; - } -} diff --git a/plugins/importFE/src/InvoiceHook.php b/plugins/importFE/src/InvoiceHook.php deleted file mode 100755 index 80731e9fa..000000000 --- a/plugins/importFE/src/InvoiceHook.php +++ /dev/null @@ -1,71 +0,0 @@ -. - */ - -namespace Plugins\ImportFE; - -use Hooks\CachedManager; -use Modules; - -/** - * Hook dedicato all'importazione automatica delle Fatture Elettroniche di acquisto rilevate dal sistema automatico di gestione. - */ -class InvoiceHook extends CachedManager -{ - public function getCacheName() - { - return 'Fatture Elettroniche'; - } - - public function cacheData() - { - return Interaction::getInvoiceList(); - } - - public function response() - { - $results = (array) $this->getCache()->content; - - $count = count($results); - $notify = false; - - $module = Modules::get('Fatture di acquisto'); - $plugins = $module->plugins; - - if (!empty($plugins)) { - $notify = !empty($count); - - $plugin = $plugins->first(function ($value, $key) { - return $value->name == 'Fatturazione Elettronica'; - }); - - $link = base_path().'/controller.php?id_module='.$module->id.'#tab_'.$plugin->id; - } - - $message = tr('Ci sono _NUM_ fatture passive da importare', [ - '_NUM_' => $count, - ]); - - return [ - 'icon' => 'fa fa-file-text-o text-yellow', - 'link' => $link, - 'message' => $message, - 'show' => $notify, - ]; - } -} diff --git a/plugins/importFE/src/Parcella.php b/plugins/importFE/src/Parcella.php deleted file mode 100755 index 8fe134a34..000000000 --- a/plugins/importFE/src/Parcella.php +++ /dev/null @@ -1,65 +0,0 @@ -. - */ - -namespace Plugins\ImportFE; - -use Modules\Fatture\Fattura; -use Modules\Fatture\Tipo as TipoFattura; -use Util\XML; - -/** - * Classe per la gestione delle parcelle in XML. - * - * @since 2.4.11 - */ -class Parcella extends FatturaOrdinaria -{ - /** - * Prepara la fattura elettronica come fattura del gestionale. - * - * @param int $id_tipo - * @param string $data - * @param int $id_sezionale - * @param int $ref_fattura - * - * @return Fattura - */ - public function prepareFattura($id_tipo, $data, $id_sezionale, $ref_fattura) - { - if (empty($ref_fattura)) { - return parent::prepareFattura($id_tipo, $data, $id_sezionale, $ref_fattura); - } - - $anagrafica = $this->saveAnagrafica(); - - $tipo = TipoFattura::where('id', $id_tipo)->first(); - - $fattura = Fattura::find($ref_fattura); - - // Rimozione righe precedenti (query per evitare procedure automatiche di compensazione) - database()->query('DELETE FROM co_righe_documenti WHERE iddocumento = '.prepare($fattura->id)); - - $fattura->anagrafica()->associate($anagrafica); - $fattura->tipo()->associate($tipo); - $fattura->data = $data; - $fattura->id_segment = $id_sezionale; - - return $fattura; - } -} diff --git a/plugins/importFE/view.php b/plugins/importFE/view.php deleted file mode 100755 index 4e39f135d..000000000 --- a/plugins/importFE/view.php +++ /dev/null @@ -1,39 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$directory = Plugins\ImportFE\FatturaElettronica::getImportDirectory(); -$filename = get('filename'); - -$content = file_get_contents($directory.'/'.$filename); - -// XML -$xml = new DOMDocument(); -$xml->loadXML($content); - -// XSL -$xsl = new DOMDocument(); -$xsl->load(base_dir().'/plugins/xml/asso-invoice.xsl'); - -// XSLT -$xslt = new XSLTProcessor(); -$xslt->importStylesheet($xsl); - -echo $xslt->transformToXML($xml); diff --git a/plugins/listino_clienti/actions.php b/plugins/listino_clienti/actions.php deleted file mode 100644 index f7564c73c..000000000 --- a/plugins/listino_clienti/actions.php +++ /dev/null @@ -1,90 +0,0 @@ -. - */ - -use Modules\Anagrafiche\Anagrafica; -use Modules\Articoli\Articolo; -use Plugins\ListinoClienti\DettaglioPrezzo; - -include_once __DIR__.'/../../core.php'; - -switch (filter('op')) { - case 'update_prezzi': - // Informazioni di base - $id_articolo = filter('id_articolo'); - $id_anagrafica = filter('id_anagrafica'); - $direzione = filter('dir') == 'uscita' ? 'uscita' : 'entrata'; - - $articolo = Articolo::find($id_articolo); - $anagrafica = Anagrafica::find($id_anagrafica); - - $modifica_prezzi = filter('modifica_prezzi'); - if (empty($modifica_prezzi)) { - $dbo->query('DELETE FROM mg_prezzi_articoli WHERE id_articolo='.prepare($id_articolo).' AND id_anagrafica='.prepare($id_anagrafica).' AND minimo IS NULL AND massimo IS NULL'); - } else { - // Salvataggio del prezzo predefinito - $prezzo_unitario = filter('prezzo_unitario_fisso'); - $sconto = filter('sconto_fisso'); - $dettaglio_predefinito = DettaglioPrezzo::dettaglioPredefinito($id_articolo, $id_anagrafica, $direzione) - ->first(); - if (empty($dettaglio_predefinito)) { - $dettaglio_predefinito = DettaglioPrezzo::build($articolo, $anagrafica, $direzione); - } - $dettaglio_predefinito->sconto_percentuale = $sconto; - $dettaglio_predefinito->setPrezzoUnitario($prezzo_unitario); - $dettaglio_predefinito->save(); - if ($articolo->id_fornitore == $anagrafica->idanagrafica && $direzione == 'uscita') { - $prezzo_unitario = $prezzo_unitario - ($prezzo_unitario * $sconto / 100); - $articolo->prezzo_acquisto = $prezzo_unitario; - $articolo->save(); - } - } - - // Salvataggio dei prezzi variabili - $prezzo_qta = filter('prezzo_qta'); - $dettagli = DettaglioPrezzo::dettagli($id_articolo, $id_anagrafica, $direzione); - if (!empty($prezzo_qta)) { - $prezzi_unitari = (array) filter('prezzo_unitario'); - $minimi = filter('minimo'); - $massimi = filter('massimo'); - $sconti = (array) filter('sconto'); - - // Rimozione dei prezzi cancellati - $registrati = filter('dettaglio'); - $dettagli = $dettagli->whereNotIn('id', $registrati)->delete(); - - // Aggiornamento e creazione dei prezzi registrati - foreach ($prezzi_unitari as $key => $prezzo_unitario) { - if (isset($registrati[$key])) { - $dettaglio = DettaglioPrezzo::find($registrati[$key]); - } else { - $dettaglio = DettaglioPrezzo::build($articolo, $anagrafica, $direzione); - } - - $dettaglio->minimo = $minimi[$key]; - $dettaglio->massimo = $massimi[$key]; - $dettaglio->sconto_percentuale = $sconti[$key]; - $dettaglio->setPrezzoUnitario($prezzo_unitario); - $dettaglio->save(); - } - } else { - $dettagli->delete(); - } - - break; -} diff --git a/plugins/listino_clienti/dettaglio_prezzi.php b/plugins/listino_clienti/dettaglio_prezzi.php deleted file mode 100644 index fee2fe273..000000000 --- a/plugins/listino_clienti/dettaglio_prezzi.php +++ /dev/null @@ -1,270 +0,0 @@ -. - */ - -use Modules\Anagrafiche\Anagrafica; -use Modules\Articoli\Articolo; -use Plugins\ListinoClienti\DettaglioPrezzo; - -include_once __DIR__.'/../../core.php'; - -$prezzi_ivati = setting('Utilizza prezzi di vendita comprensivi di IVA'); - -// Informazioni di base -$id_articolo = get('id_articolo'); -$id_anagrafica = get('id_anagrafica'); -$direzione = get('direzione') == 'uscita' ? 'uscita' : 'entrata'; - -// Modelli di interesse -$articolo = Articolo::find($id_articolo); -$anagrafica = Anagrafica::find($id_anagrafica); - -if ($direzione == 'entrata') { - $prezzo_predefinito = $prezzi_ivati ? $articolo->prezzo_vendita_ivato : $articolo->prezzo_vendita; -} else { - $prezzo_predefinito = $articolo->prezzo_acquisto; -} -// Individuazione dei prezzi registrati -$dettagli = DettaglioPrezzo::dettagli($id_articolo, $id_anagrafica, $direzione) - ->get(); - -$dettaglio_predefinito = DettaglioPrezzo::dettaglioPredefinito($id_articolo, $id_anagrafica, $direzione) - ->first(); -if ($articolo->id_fornitore == $anagrafica->idanagrafica) { - $color = 'success'; - $icon = 'check'; - $text = tr('Sì'); -} else { - $color = 'danger'; - $icon = 'times'; - $text = tr('No'); -} -echo ' - - - - '; - if ($direzione == 'uscita') { - echo ''; - } else { - echo ''; - } - echo ' - - - - '; - if ($direzione == 'uscita') { - echo ''; - } else { - echo ''; - } - echo ' - -
    '.($direzione == 'entrata' ? tr('Cliente') : tr('Fornitore')).''.tr('Prezzo predefinito').''.tr('Fornitore predefinito').'
    '.$anagrafica->ragione_sociale.''.moneyFormat($prezzo_predefinito).' '.$text.'
    - -
    - - - - - - - - -
    -
    - {[ "type": "checkbox", "label": "'.tr('Imposta prezzo per questa anagrafica').'", "name": "modifica_prezzi", "value": "'.intval(!empty($dettaglio_predefinito)).'" ]} -
    -
    - -
    -
    -
    - {[ "type": "number", "label": "'.tr('Prezzo specifico').'", "name": "prezzo_unitario_fisso", "value": "'.($prezzi_ivati ? $dettaglio_predefinito->prezzo_unitario_ivato : $dettaglio_predefinito->prezzo_unitario).'", "icon-after": "'.currency().'", "help": "'.($prezzi_ivati ? tr('Importo IVA inclusa') : '').'" ]} -
    - -
    - {[ "type": "number", "label": "'.tr('Sconto specifico').'", "name": "sconto_fisso", "value": "'.$dettaglio_predefinito->sconto_percentuale.'", "icon-after": "%"]} -
    -
    -
    - -
    -
    - {[ "type": "checkbox", "label": "'.tr('Imposta un prezzo in base alla quantità').'", "name": "prezzo_qta", "value": "'.intval($dettagli->count() != 0).'" ]} -
    -
    - -
    -
    -

    - '.tr('Prezzi per quantità').' -

    - - -
    - -
    -

    '.tr("Inserire i prezzi da associare all'articolo e all'anagrafica in relazione alla quantità di acquisto").'.

    -

    '.tr('Per impostare un prezzo generale per quantità non incluse in questi limiti, utilizzare il campo sopra indicato').'.

    - - - - - - - - - - - - - '; - -foreach ($dettagli as $key => $dettaglio) { - echo ' - - - - - - - - '; -} - -echo ' - -
    '.tr('Quantità minima').''.tr('Quantità massima').' - '.tr('Prezzo unitario').($prezzi_ivati ? '' : '').' - '.tr('Sconto').'#
    - - {[ "type": "number", "name": "minimo['.$key.']", "min-value": 0, "value": "'.$dettaglio->minimo.'" ]} - - {[ "type": "number", "name": "massimo['.$key.']", "min-value": 0, "value": "'.$dettaglio->massimo.'" ]} - - {[ "type": "number", "name": "prezzo_unitario['.$key.']", "icon-after": "'.currency().'", "value": "'.($prezzi_ivati ? $dettaglio->prezzo_unitario_ivato : $dettaglio->prezzo_unitario).'" ]} - - {[ "type": "number", "name": "sconto['.$key.']", "min-value": 0, "value": "'.$dettaglio->sconto.'", "icon-after":"%" ]} - - -
    -
    -
    - -
    - -
    -
    - -
    -
    -
    - - - - - - - - - - - - - - - -
    - {[ "type": "number", "name": "minimo[-id-]", "min-value": 0 ]} - - {[ "type": "number", "name": "massimo[-id-]", "min-value": 0 ]} - - {[ "type": "number", "name": "prezzo_unitario[-id-]", "icon-after": "'.currency().'" ]} - - {[ "type": "number", "name": "sconto[-id-]", "min-value": 0, "icon-after": "%" ]} - - -
    - - - -'; diff --git a/plugins/listino_clienti/edit.php b/plugins/listino_clienti/edit.php deleted file mode 100644 index c460c4d3b..000000000 --- a/plugins/listino_clienti/edit.php +++ /dev/null @@ -1,156 +0,0 @@ -. - */ - -use Carbon\Carbon; -use Plugins\ListinoClienti\DettaglioPrezzo; - -include_once __DIR__.'/../../core.php'; - -$id_articolo = $id_record; -echo ' -
    -
    -

    '.tr('Informazioni specifiche per cliente').'

    -
    - -
    -
    -
    - {[ "type": "select", "label": "'.tr('Cliente').'", "name": "id_cliente_informazioni", "required":"1", "ajax-source": "clienti" ]} -
    - -
    - -
    -
    -
    -
    - -

    '.tr('Elenco clienti').'

    '; - -$clienti = DettaglioPrezzo::where('id_articolo', $id_articolo) - ->where('dir', 'entrata') - ->get() - ->groupBy('id_anagrafica'); -if (!$clienti->isEmpty()) { - echo ' - - - - - - - - - - - - - '; - - foreach ($clienti as $id_cliente => $prezzi) { - $anagrafica = $prezzi->first()->anagrafica; - - echo ' - - - - - '; - - foreach ($prezzi as $key => $dettaglio) { - echo ' - - - - - - - - - - - - - '; - } - } - - echo ' - -
    '.tr('Cliente').''.tr('Q.tà minima').''.tr('Q.tà massima').''.tr('Prezzo unitario').''.tr('Sconto').'#
    - '.Modules::link('Anagrafiche', $anagrafica->id, $anagrafica->ragione_sociale).' - - -
    - '.($dettaglio->minimo ? numberFormat($dettaglio->minimo) : '-').' - - '.($dettaglio->massimo ? numberFormat($dettaglio->massimo) : '-').' - - '.moneyFormat($dettaglio->prezzo_unitario).' -

    '.Carbon::parse($dettaglio['updated_at'])->diffForHumans().'

    -
    - '.numberFormat($dettaglio->sconto_percentuale).'% - '; - - if (!isset($dettaglio->minimo) && !isset($dettaglio->massimo)) { - echo ' - '.tr('Prezzo predefinito').''; - } - - echo ' -
    '; -} else { - echo ' -
    - '.tr('Nessuna informazione disponibile').'... -
    '; -} - -echo ' -'; diff --git a/plugins/listino_clienti/src/DettaglioPrezzo.php b/plugins/listino_clienti/src/DettaglioPrezzo.php deleted file mode 100644 index 9822c40a2..000000000 --- a/plugins/listino_clienti/src/DettaglioPrezzo.php +++ /dev/null @@ -1,117 +0,0 @@ -. - */ - -namespace Plugins\ListinoClienti; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; -use Modules\Anagrafiche\Anagrafica; -use Modules\Articoli\Articolo; -use Modules\Iva\Aliquota; - -/* - * Classe per la gestione delle relazioni articolo-prezzo sulla base di un range di quantità e di una specifica anagrafica. - * - * @since 2.4.18 - */ -class DettaglioPrezzo extends Model -{ - use SimpleModelTrait; - - protected $table = 'mg_prezzi_articoli'; - - /** - * Crea una nuova relazione tra Articolo e Anagrafica per la gestione dei prezzi. - * - * @return self - */ - public static function build(Articolo $articolo, Anagrafica $anagrafica, $direzione = 'uscita') - { - $model = new static(); - - $model->anagrafica()->associate($anagrafica); - $model->articolo()->associate($articolo); - $model->dir = $direzione == 'uscita' ? 'uscita' : 'entrata'; - - $model->save(); - - return $model; - } - - /** - * Imposta il prezzo di vendita sulla base dell'impstazione per l'utilizzo dei prezzi comprensivi di IVA. - * - * @param $prezzo_unitario - */ - public function setPrezzoUnitario($prezzo_unitario) - { - $id_iva = $this->articolo->idiva_vendita; - - // Calcolo prezzo di vendita ivato e non ivato - $prezzi_ivati = setting('Utilizza prezzi di vendita comprensivi di IVA'); - $percentuale_aliquota = floatval(Aliquota::find($id_iva)->percentuale); - if ($prezzi_ivati) { - $this->prezzo_unitario_ivato = $prezzo_unitario; - $this->prezzo_unitario = $prezzo_unitario / (1 + $percentuale_aliquota / 100); - } else { - $this->prezzo_unitario = $prezzo_unitario; - $this->prezzo_unitario_ivato = $prezzo_unitario * (1 + $percentuale_aliquota / 100); - } - } - - // Relazioni Eloquent - - public function anagrafica() - { - return $this->belongsTo(Anagrafica::class, 'id_anagrafica'); - } - - public function articolo() - { - return $this->belongsTo(Articolo::class, 'id_articolo'); - } - - public static function dettaglioPredefinito($id_articolo, $id_anagrafica, $direzione) - { - return self::where('id_articolo', $id_articolo) - ->where('id_anagrafica', $id_anagrafica) - ->where('dir', $direzione) - ->whereNull('minimo') - ->whereNull('massimo'); - } - - public static function dettagli($id_articolo, $id_anagrafica, $direzione, $qta = null) - { - $dettagli = self::where('id_articolo', $id_articolo) - ->where('id_anagrafica', $id_anagrafica) - ->where('dir', $direzione); - - if ($qta == null) { - $dettagli = $dettagli - ->whereNotNull('minimo') - ->whereNotNull('massimo'); - } else { - $dettagli = $dettagli - ->where('minimo', '<=', $qta) - ->where('massimo', '>=', $qta); - } - - return $dettagli; - } -} diff --git a/plugins/listino_fornitori/actions.php b/plugins/listino_fornitori/actions.php deleted file mode 100644 index 256974ca4..000000000 --- a/plugins/listino_fornitori/actions.php +++ /dev/null @@ -1,67 +0,0 @@ -. - */ - -use Modules\Anagrafiche\Anagrafica; -use Modules\Articoli\Articolo; -use Plugins\ListinoFornitori\DettaglioFornitore; - -include_once __DIR__.'/../../core.php'; - -switch (filter('op')) { - case 'update_fornitore': - $id_articolo = filter('id_articolo'); - $articolo = Articolo::find($id_articolo); - - $id_anagrafica = filter('id_anagrafica'); - $precedente = DettaglioFornitore::where('id_articolo', $id_record) - ->where('id_fornitore', $id_anagrafica) - ->first(); - - if (empty($precedente)) { - $anagrafica = Anagrafica::find($id_anagrafica); - - $fornitore = DettaglioFornitore::build($anagrafica, $articolo); - } else { - $fornitore = $precedente->replicate(); - $precedente->delete(); - } - - $fornitore->codice_fornitore = post('codice_fornitore'); - $fornitore->descrizione = post('descrizione'); - $fornitore->qta_minima = post('qta_minima'); - $fornitore->giorni_consegna = post('giorni_consegna'); - - $fornitore->save(); - - flash()->info(tr('Informazioni salvate correttamente!')); - break; - - case 'delete_fornitore': - $id_riga = post('id_riga'); - - $fornitore = DettaglioFornitore::find($id_riga); - $fornitore->delete(); - - flash()->info(tr('Relazione articolo-fornitore rimossa correttamente!')); - break; - - case 'update_prezzi': - require base_dir().'/plugins/listino_clienti/actions.php'; - break; -} diff --git a/plugins/listino_fornitori/dettaglio_fornitore.php b/plugins/listino_fornitori/dettaglio_fornitore.php deleted file mode 100644 index 52053f776..000000000 --- a/plugins/listino_fornitori/dettaglio_fornitore.php +++ /dev/null @@ -1,90 +0,0 @@ -. - */ - -use Modules\Anagrafiche\Anagrafica; -use Modules\Articoli\Articolo; -use Plugins\ListinoFornitori\DettaglioFornitore; - -include_once __DIR__.'/../../core.php'; - -$id_articolo = get('id_articolo'); -$articolo = Articolo::find($id_articolo); - -$id_anagrafica = get('id_anagrafica'); -$anagrafica = Anagrafica::find($id_anagrafica); - -$id_riga = get('id_riga'); -$fornitore = []; -if (!empty($id_riga)) { - $fornitore = DettaglioFornitore::find($id_riga); -} else { - $fornitore = $articolo->dettaglioFornitore($id_anagrafica); -} - -echo ' -

    '.tr('Informazioni relative al fornitore _NAME_', [ - '_NAME_' => $anagrafica->ragione_sociale, -]).'.

    - -
    - - - - - - - - -
    -
    - {[ "type": "text", "label": "'.tr('Codice fornitore').'", "name": "codice_fornitore", "required": 1, "value": "'.$fornitore['codice_fornitore'].'" ]} -
    -
    - -
    -
    - {[ "type": "textarea", "label": "'.tr('Descrizione').'", "name": "descrizione", "required": 1, "value": "'.$fornitore['descrizione'].'" ]} -
    -
    - -
    -
    - {[ "type": "number", "label": "'.tr('Qta minima ordinabile').'", "name": "qta_minima", "required": 0, "value": "'.$fornitore['qta_minima'].'", "icon-after": "'.$articolo->um.'" ]} -
    - -
    - {[ "type": "text", "label": "'.tr('Tempi di consegna').'", "name": "giorni_consegna", "class": "text-right", "required": 0, "value": "'.$fornitore['giorni_consegna'].'", "icon-after": "'.tr('gg').'" ]} -
    -
    - -
    - -
    -
    - -
    -
    -
    - -'; diff --git a/plugins/listino_fornitori/edit.php b/plugins/listino_fornitori/edit.php deleted file mode 100644 index de9a667a8..000000000 --- a/plugins/listino_fornitori/edit.php +++ /dev/null @@ -1,225 +0,0 @@ -. - */ - -use Carbon\Carbon; -use Models\Plugin; -use Plugins\ListinoClienti\DettaglioPrezzo; -use Plugins\ListinoFornitori\DettaglioFornitore; - -include_once __DIR__.'/../../core.php'; - -$id_articolo = $id_record; -echo ' -
    -
    -

    '.tr('Informazioni specifiche per fornitore').'

    -
    - -
    -
    -
    - {[ "type": "select", "label": "'.tr('Fornitore').'", "name": "id_fornitore_informazioni", "required":"1", "ajax-source": "fornitori" ]} -
    - -
    -
    - - - -
    -
    -
    -
    -
    - -

    '.tr('Elenco fornitori').'

    '; - -$dettagli_fornitori = DettaglioFornitore::where('id_articolo', $id_record)->get() - ->mapToGroups(function ($item, $key) { - return [$item->id_fornitore => $item]; - }); -$prezzi_fornitori = DettaglioPrezzo::where('id_articolo', $id_articolo) - ->where('dir', 'uscita') - ->get() - ->groupBy('id_anagrafica'); - -$fornitori_disponibili = $dettagli_fornitori->keys() - ->merge($prezzi_fornitori->keys()) - ->unique(); - -if (!$fornitori_disponibili->isEmpty()) { - echo ' - - '; - - foreach ($fornitori_disponibili as $id_fornitore) { - $dettaglio = $dettagli_fornitori[$id_fornitore] ? $dettagli_fornitori[$id_fornitore]->first() : null; - $prezzi = $prezzi_fornitori[$id_fornitore]; - - $anagrafica = $dettaglio ? $dettaglio->anagrafica : $prezzi->first()->anagrafica; - - echo ' - - - - - - - - - - id == $articolo->id_fornitore) ? 'class="success"' : '').'> - '; - - if (!empty($dettaglio)) { - echo ' - - - - - - - '; - } else { - echo ' - - - - '; - } - - echo ' - - '; - - /* - $dettaglio_predefinito = $prezzi->whereStrict('minimo', null) - ->whereStrict('massimo', null) - ->first(); - - $prezzi = $prezzi->reject(function ($item, $key) use ($dettaglio_predefinito) { - return $item->id == $dettaglio_predefinito->id; - }); - */ - if (!empty($prezzi) && !$prezzi->isEmpty()) { - echo ' - - - - - - - - '; - - foreach ($prezzi as $key => $dettaglio) { - echo ' - id == $articolo->id_fornitore) ? 'class="success"' : '').'> - - - - - - - - - - - - '; - } - } - } - - echo ' - -
    '.tr('Fornitore').''.tr('Codice').''.tr('Descrizione').''.tr('Q.tà minima ordinabile').''.tr('Tempi di consegna').'#
    - '.Modules::link('Anagrafiche', $anagrafica->id, $anagrafica->ragione_sociale).' - - '.$dettaglio['codice_fornitore'].' - - '.$dettaglio['descrizione'].' - - '.numberFormat($dettaglio['qta_minima']).' '.$articolo->um.' - - '.tr('_NUM_ gg', [ - '_NUM_' => numberFormat($dettaglio['giorni_consegna'], 0), - ]).' - ---- - '; - - if (!empty($dettaglio)) { - echo ' - - - - - - - - '; - } - - echo ' -
    '.tr('Q.tà minima').''.tr('Q.tà massima').''.tr('Prezzo unitario').''.tr('Sconto').'
    - '.($dettaglio->minimo ? numberFormat($dettaglio->minimo) : '-').' - - '.($dettaglio->massimo ? numberFormat($dettaglio->massimo) : '-').' - - '.moneyFormat($dettaglio->prezzo_unitario).' -

    '.$dettaglio->updated_at->diffForHumans().'

    -
    - '.numberFormat($dettaglio->sconto_percentuale).'% - '; - - if (!isset($dettaglio->minimo) && !isset($dettaglio->massimo)) { - echo ' - '.tr('Prezzo predefinito').''; - } - - echo ' -
    '; -} else { - echo ' -
    - '.tr('Nessuna informazione disponibile').'... -
    '; -} - -echo ' -'; diff --git a/plugins/listino_fornitori/src/DettaglioFornitore.php b/plugins/listino_fornitori/src/DettaglioFornitore.php deleted file mode 100644 index b921cc10e..000000000 --- a/plugins/listino_fornitori/src/DettaglioFornitore.php +++ /dev/null @@ -1,68 +0,0 @@ -. - */ - -namespace Plugins\ListinoFornitori; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Eloquent\SoftDeletes; -use Modules\Anagrafiche\Anagrafica; -use Modules\Articoli\Articolo; - -/* - * Classe per la gestione delle relazioni tra articolo e fornitore. - * - * @since 2.4.15 - */ -class DettaglioFornitore extends Model -{ - use SimpleModelTrait; - use SoftDeletes; - - protected $table = 'mg_fornitore_articolo'; - - /** - * Crea una nuova relazione tra Articolo e Fornitore. - * - * @return self - */ - public static function build(Anagrafica $fornitore, Articolo $articolo) - { - $model = new static(); - - $model->anagrafica()->associate($fornitore); - $model->articolo()->associate($articolo); - - $model->save(); - - return $model; - } - - // Relazioni Eloquent - - public function anagrafica() - { - return $this->belongsTo(Anagrafica::class, 'id_fornitore'); - } - - public function articolo() - { - return $this->belongsTo(Articolo::class, 'id_articolo'); - } -} diff --git a/plugins/listino_fornitori/src/METEL.php b/plugins/listino_fornitori/src/METEL.php deleted file mode 100644 index 605dde068..000000000 --- a/plugins/listino_fornitori/src/METEL.php +++ /dev/null @@ -1,104 +0,0 @@ -. - */ - -namespace Plugins\ListinoFornitori; - -/** - * Formato: https://www.metel.it/wp-content/uploads/2020/04/536_L001_1r18_listino_021.pdf. - * - * @since 2.4.18 - */ -class METEL -{ - const HEADER = [ - 1 => 'Identificazione tracciato', - 21 => 'Sigla Azienda', - 24 => 'Partita IVA', - 35 => 'Numero listino prezzi', - 41 => 'Decorrenza listino prezzi', - 49 => 'Data ultima variazione/immissione', - 57 => 'Descrizione listino prezzi', - 87 => 'Filler (spazi)', - 126 => 'Versione tracciato listino prezzi', - 129 => 'Data decorrenza listino grossista', - 137 => 'Isopartita', - 153 => 'Filler (spazi)', - ]; - - public const ROW = [ - 1 => 'Sigla Marchio', - 4 => 'Codice Prodotto Azienda', - 20 => 'Codice EAN', - 33 => 'Descrizione prodotto', - 76 => 'Quantità cartone', - 81 => 'Quantità multipla ordinazione', - 86 => 'Quantità minima ordinazione', - 91 => 'Quantità massima ordinazione', - 97 => 'Lead Time', - 98 => 'Prezzo al rivenditore', - 109 => 'Prezzo al Pubblico', - 120 => 'Moltiplicatore prezzo', - 126 => 'Codice Valuta', - 129 => 'Unità di misura', - 132 => 'Prodotto Composto', - 133 => 'Stato del prodotto', - 134 => 'Data ultima variazione', - 142 => 'Famiglia di sconto', - 160 => 'Famiglia statistica', - 178 => 'Codice Electrocod', - 188 => 'Codice Etim', - 198 => 'Codice Barcode', - 233 => 'Qualificatore Codice Barcode', - ]; - - public function parse($string, $fields) - { - $fields_number = count($fields); - $keys = array_keys($fields); - - $results = []; - for ($i = 0; $i < $fields_number; ++$i) { - $key = $keys[$i]; - $start = $key - 1; - - if ($fields_number - 1 == $i) { - $end = strlen($string); - } else { - $end = $keys[$i + 1] - 1; - } - - $length = $end - $start; - - $piece = substr($string, $start, $length); - $results[$fields[$key]] = trim($piece); - } - - return $results; - } - - public function parseHeader($content) - { - return $this->parse($content, static::HEADER); - } - - public function parseRow($content) - { - return $this->parse($content, static::ROW); - } -} diff --git a/plugins/notes.php b/plugins/notes.php deleted file mode 100755 index 1e945f917..000000000 --- a/plugins/notes.php +++ /dev/null @@ -1,125 +0,0 @@ -. - */ - -include_once __DIR__.'/../core.php'; - -if (!$notes->isEmpty()) { - echo ' -
    -
    -

    '.tr('Note interne').'

    -
    - -
    -
    '; - - foreach ($notes as $nota) { - $utente = $nota->user; - $photo = $utente->photo; - - echo ' -
    -
    - '.$utente->nome_completo.' - - '.timestampFormat($nota->created_at).' - -
    '; - - if ($photo) { - echo ' - '; - } else { - echo ' - - '; - } - - echo ' -
    -
    '; - - if (!empty($nota->notification_date)) { - echo ' - - '.dateFormat($nota->notification_date).' - - - '; - } - - if ($user->is_admin || $utente->id == $user->id) { - echo ' - '; - } - - echo ' -
    - '.$nota->content.' -
    -
    '; - } - echo ' -
    -
    -
    '; -} else { - echo ' -
    '.tr('Informazione:').' '.tr('Non sono presenti note interne.').'
    '; -} - -if ($structure->permission == 'rw') { - echo ' -
    - - -
    -
    - {[ "type": "ckeditor", "label": "'.tr('Nuova nota').'", "name": "contenuto", "required": 1, "class": "unblockable" ]} -
    -
    - {[ "type": "date", "label": "'.tr('Data di notifica').'", "name": "data_notifica", "class": "unblockable", "help": "'.tr('Eventuale data di notifica di un promemoria di questa nota.').'" ]} -
    -
    - -
    -
    - -
    -
    -
    '; -} - -echo ' -'; diff --git a/plugins/piani_sconto_maggiorazione/edit.php b/plugins/piani_sconto_maggiorazione/edit.php deleted file mode 100644 index 231fcf8d5..000000000 --- a/plugins/piani_sconto_maggiorazione/edit.php +++ /dev/null @@ -1,66 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo ' -
    -
    -

    '.tr('Prezzo articolo secondo i piani di sconto/magg.').'

    -
    - -
    '; - - $listini = $dbo->fetchArray('SELECT * FROM mg_listini ORDER BY id ASC'); - - if (!empty($listini)) { - echo ' - - - - - '; - - // listino base - echo ' - - - - '; - - foreach ($listini as $listino) { - $prezzo_vendita = $articolo->prezzo_vendita - $articolo->prezzo_vendita * $listino['prc_guadagno'] / 100; - echo ' - - - - '; - } - - echo ' -
    '.tr('Piano di sconto/magg.').''.tr('Prezzo di vendita finale').'
    '.tr('Base').''.moneyFormat($articolo->prezzo_vendita).'
    '.$listino['nome'].''.moneyFormat($prezzo_vendita).'
    '; - } else { - echo ' -
    -'.tr('Non ci sono piani di sconto/magg. caricati').'... '.Modules::link('Piani di sconto/maggiorazione', null, tr('Crea')).' -
    '; - } -echo ' -
    -
    '; diff --git a/plugins/pianificazione_fatturazione/actions.php b/plugins/pianificazione_fatturazione/actions.php deleted file mode 100755 index 46ba6d83f..000000000 --- a/plugins/pianificazione_fatturazione/actions.php +++ /dev/null @@ -1,189 +0,0 @@ -. - */ - -use Modules\Articoli\Articolo as ArticoloOriginale; -use Modules\Contratti\Components\Articolo; -use Modules\Contratti\Components\Riga; -use Modules\Contratti\Contratto; -use Modules\Fatture\Fattura; -use Modules\Fatture\Tipo; -use Plugins\PianificazioneFatturazione\Pianificazione; - -include_once __DIR__.'/../../core.php'; -include_once __DIR__.'/../modutil.php'; - -$operazione = filter('op'); - -// Pianificazione fatturazione -switch ($operazione) { - case 'add': - $contratto = Contratto::find($id_record); - - if (post('scadenza') == 'Mensile') { - $timeing = '+1 month'; - } - if (post('scadenza') == 'Bimestrale') { - $timeing = '+2 month'; - } - if (post('scadenza') == 'Trimestrale') { - $timeing = '+3 month'; - } - if (post('scadenza') == 'Quadrimestrale') { - $timeing = '+4 month'; - } - if (post('scadenza') == 'Semestrale') { - $timeing = '+6 month'; - } - if (post('scadenza') == 'Annuale') { - $timeing = '+12 month'; - } - - $selezioni = collect(post('selezione_periodo')); - $periodi = post('periodo'); - - $numero_fatture = 0; - $date_pianificazioni = []; - $pianificazioni = []; - foreach ($selezioni as $key => $selezione) { - $date = new DateTime($periodi[$key]); - - if (post('cadenza_fatturazione') == 'Inizio') { - $date->modify('first day of this month'); - } elseif (post('cadenza_fatturazione') == 'Giorno' && !empty(post('giorno_fisso'))) { - $date->modify('last day of this month'); - $last_day = $date->format('d'); - $day = post('giorno_fisso') > $last_day ? $last_day : post('giorno_fisso'); - - // Correzione data - $date->setDate($date->format('Y'), $date->format('m'), $day); - } - - // Comversione della data in stringa standard - $data_scadenza = $date->format('Y-m-d'); - - ++$numero_fatture; - - // Creazione pianificazione - $pianificazione = Pianificazione::build($contratto, $data_scadenza); - $date_pianificazioni[] = $data_scadenza; - $pianificazioni[$numero_fatture] = $pianificazione->id; - } - - if ($numero_fatture > 0) { - $righe_contratto = $contratto->getRighe(); - $subtotale = []; - - // Creazione nuove righe - $qta = post('qta'); - foreach ($righe_contratto as $r) { - $qta_evasa = $r->qta_evasa; - $data_scadenza = ''; - $inizio = $date_pianificazioni[0]; - $fine = date('Y-m-d', strtotime($inizio.' -1 days')); - $fine = date('Y-m-d', strtotime($fine.' '.$timeing)); - for ($rata = 1; $rata <= $numero_fatture; ++$rata) { - if ($qta_evasa < $r->qta) { - $qta_riga = ($qta[$r->id] <= ($r->qta - $qta_evasa) ? $qta[$r->id] : ($r->qta - $qta_evasa)); - $descrizione = post('descrizione')[$r->id]; - - $descrizione = variables($descrizione, $inizio, $fine)['descrizione']; - - $inizio = $fine; - $fine = date('Y-m-d', strtotime($timeing, strtotime($inizio))); - $inizio = date('Y-m-d', strtotime($inizio.' +1 days')); - - $prezzo_unitario = ($r->subtotale / $r->qta); - - if (!empty($r->idarticolo)) { - $articolo = ArticoloOriginale::find($r->idarticolo); - $riga = Articolo::build($contratto, $articolo); - } else { - $riga = Riga::build($contratto); - } - - $riga->descrizione = $descrizione; - $riga->setPrezzoUnitario($prezzo_unitario, $r->idiva); - $riga->qta = $qta_riga; - $riga->idpianificazione = $pianificazioni[$rata]; - - $riga->save(); - - $qta_evasa += $qta_riga; - $pianificata[] = $pianificazioni[$rata]; - } else { - $non_pianificata[] = $pianificazioni[$rata]; - } - } - $r->delete(); - } - $tot_non_pianificati = implode(', ', array_unique(array_diff($non_pianificata, $pianificata))); - if (!empty($tot_non_pianificati)) { - $dbo->query('DELETE FROM `co_fatturazione_contratti` WHERE `id` IN ('.$tot_non_pianificati.')'); - } - } - - break; - - case 'reset': - $dbo->query('DELETE FROM `co_fatturazione_contratti` WHERE `idcontratto`='.prepare($id_record)); - flash()->info(tr('Pianificazione rimossa')); - - break; - - case 'add_fattura': - $id_rata = post('rata'); - $accodare = post('accodare'); - $pianificazione = Pianificazione::find($id_rata); - $contratto = $pianificazione->contratto; - - $data = post('data'); - $id_segment = post('id_segment'); - $tipo = Tipo::find(post('idtipodocumento')); - - if (!empty($accodare)) { - $documento = $dbo->fetchOne('SELECT co_documenti.id FROM co_documenti INNER JOIN co_statidocumento ON co_documenti.idstatodocumento = co_statidocumento.id WHERE co_statidocumento.descrizione = \'Bozza\' AND idanagrafica = '.prepare($contratto->idanagrafica)); - - $id_documento = $documento['id']; - } - - // Creazione fattura - if (empty($id_documento)) { - $fattura = Fattura::build($contratto->anagrafica, $tipo, $data, $id_segment); - } else { - $fattura = Fattura::find($id_documento); - } - $fattura->note = post('note'); - $fattura->save(); - - $id_conto = post('id_conto'); - - // Copia righe - $righe = $pianificazione->getRighe(); - foreach ($righe as $riga) { - $copia = $riga->copiaIn($fattura, $riga->qta); - $copia->id_conto = $id_conto; - $copia->save(); - } - - // Salvataggio fattura nella pianificazione - $pianificazione->fattura()->associate($fattura); - $pianificazione->save(); - - break; -} diff --git a/plugins/pianificazione_fatturazione/add_pianificazione.php b/plugins/pianificazione_fatturazione/add_pianificazione.php deleted file mode 100755 index 42ac9c2f7..000000000 --- a/plugins/pianificazione_fatturazione/add_pianificazione.php +++ /dev/null @@ -1,244 +0,0 @@ -. - */ - -use Modules\Contratti\Contratto; - -include_once __DIR__.'/../../core.php'; -include_once __DIR__.'/../modutil.php'; - -$contratto = Contratto::find($id_record); - -$giorni_fatturazione = []; -for ($i = 1; $i <= 31; ++$i) { - $giorni_fatturazione[] = [ - 'id' => $i, - 'text' => $i, - ]; -} - -echo ' -
    - - - - - - - - - -
    '; - -echo ' - - -'; diff --git a/plugins/pianificazione_fatturazione/ajax_cadenza.php b/plugins/pianificazione_fatturazione/ajax_cadenza.php deleted file mode 100644 index de02237a2..000000000 --- a/plugins/pianificazione_fatturazione/ajax_cadenza.php +++ /dev/null @@ -1,103 +0,0 @@ -. - */ - -use Carbon\Carbon; -use Modules\Contratti\Contratto; - -include_once __DIR__.'/../../core.php'; - -$contratto = Contratto::find($id_record); - -if (get('scadenza') == 'Mensile') { - $timeing = '+1 month'; -} -if (get('scadenza') == 'Bimestrale') { - $timeing = '+2 month'; -} -if (get('scadenza') == 'Trimestrale') { - $timeing = '+3 month'; -} -if (get('scadenza') == 'Quadrimestrale') { - $timeing = '+4 month'; -} -if (get('scadenza') == 'Semestrale') { - $timeing = '+6 month'; -} -if (get('scadenza') == 'Annuale') { - $timeing = '+12 month'; -} - -$data_inizio = new Carbon(get('data_inizio')); - -echo ' -
    '; - - $data_corrente = $data_inizio->startOfMonth(); - $data_conclusione = $contratto->data_conclusione; - $count = 0; - - while ($data_corrente->lessThanOrEqualTo($data_conclusione)) { - $data = $data_corrente->endOfMonth()->format('Y-m-d'); - $data_fatturazione = ($data_fatturazione ?: date('Y-m', strtotime($data))); - unset($checked); - - if ($id_module == Modules::get('Contratti')['id']) { - if ($data == date('Y-m-t', strtotime($timeing, strtotime($data_fatturazione))) || $data_fatturazione == date('Y-m', strtotime($data_corrente))) { - $checked = 'checked'; - $data_fatturazione = date('Y-m', strtotime($data)); - } - } - - echo ' -
    - - -
    '; - - $data_corrente = $data_corrente->addDay(); - ++$count; - } - - echo ' -
    - -'; diff --git a/plugins/pianificazione_fatturazione/crea_fattura.php b/plugins/pianificazione_fatturazione/crea_fattura.php deleted file mode 100755 index 3e3a9974f..000000000 --- a/plugins/pianificazione_fatturazione/crea_fattura.php +++ /dev/null @@ -1,154 +0,0 @@ -. - */ - -use Plugins\PianificazioneFatturazione\Pianificazione; - -include_once __DIR__.'/../../core.php'; - -$id_rata = get('rata'); -$pianificazione = Pianificazione::find($id_rata); -$contratto = $pianificazione->contratto; - -$id_pianificazione = $pianificazione->id; -$numero_rata = $contratto->pianificazioni->search(function ($item) use ($id_pianificazione) { - return $item->id = $id_pianificazione; -}) + 1; - -$module_fattura = Modules::get('Fatture di vendita'); - -$id_conto = setting('Conto predefinito fatture di vendita'); -$data = date('Y-m', strtotime($pianificazione->data_scadenza)).'-'.date('d', strtotime($contratto->data_accettazione)); - -echo ' -
    - - - - - - '; - -// Data -echo ' -
    -
    - {[ "type": "date", "label": "'.tr('Data').'", "name": "data", "required": 1, "class": "text-center", "value": "'.$pianificazione->data_scadenza.'" ]} -
    '; - -// Tipo di documento -echo ' -
    - {[ "type": "select", "label": "'.tr('Tipo di fattura').'", "name": "idtipodocumento", "required": 1, "values": "query=SELECT * FROM co_tipidocumento WHERE dir=\'entrata\'" ]} -
    -
    '; - -// Sezionale -echo ' -
    -
    - {[ "type": "select", "label": "'.tr('Sezionale').'", "name": "id_segment", "required": 1, "values": "query=SELECT id, name AS descrizione FROM zz_segments WHERE id_module='.$module_fattura['id'].' ORDER BY name", "value":"'.$_SESSION['module_'.$module_fattura['id']]['id_segment'].'" ]} -
    '; - -// Conto -echo ' -
    - {[ "type": "select", "label": "'.tr('Conto').'", "name": "id_conto", "required": 1, "value": "'.$id_conto.'", "ajax-source": "conti-vendite" ]} -
    -
    '; - -//Accoda a fatture non emesse -echo ' -
    -
    - {[ "type": "checkbox", "label": "'.tr('Aggiungere alle fatture di vendita non ancora emesse?').'", "placeholder": "'.tr('Aggiungere alle fatture di vendita nello stato bozza?').'", "name": "accodare" ]} -
    -
    '; - -//gestione replace -$descrizione = get_var('Descrizione fattura pianificata'); -$modules = MODULES::get('Contratti')['id']; -$variables = include Modules::filepath($modules, 'variables.php'); -foreach ($variables as $variable => $value) { - $descrizione = str_replace('{'.$variable.'}', $value, $descrizione); -} -$descrizione = str_replace('{rata}', $numero_rata, $descrizione); -$descrizione = str_replace('{zona}', $zona, $descrizione); - -echo ' -
    -
    - {[ "type": "textarea", "label": "'.tr('Note della fattura').'", "name": "note", "value": "'.$descrizione.'" ]} -
    -
    '; - -// Righe -echo ' -
    -
    -

    - '.tr('Righe previste').' -

    -
    -
    - - - - - - - - - - - '; - -$righe = $pianificazione->getRighe(); -foreach ($righe as $riga) { - echo ' - - - - - - - '; -} - -echo ' - -
    '.tr('Descrizione').''.tr('Q.tà').''.tr('Prezzo unitario').''.tr('IVA').''.tr('Totale imponbile').'
    '.$riga->descrizione.''.$riga->qta.''.moneyFormat($riga->prezzo_unitario).' - '.moneyFormat($riga->iva).'
    - '.$riga->aliquota->descrizione.' -
    '.moneyFormat($riga->totale_imponibile).'
    -
    -
    '; - -echo ' - -
    -
    - -
    -
    -
    '; - -echo ' -'; diff --git a/plugins/pianificazione_fatturazione/edit.php b/plugins/pianificazione_fatturazione/edit.php deleted file mode 100755 index 31ad4eed4..000000000 --- a/plugins/pianificazione_fatturazione/edit.php +++ /dev/null @@ -1,138 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Contratti\Contratto; -use Modules\Contratti\Stato; - -$contratto = Contratto::find($id_record); -if (empty($contratto)) { - return; -} - -$is_pianificabile = $contratto->stato->is_pianificabile && !empty($contratto['data_accettazione']) && !empty($contratto['data_conclusione']); // Contratto permette la pianificazione -$is_pianificato = false; -$stati_pianificabili = Stato::where('is_pianificabile', 1)->get(); -$elenco_stati = $stati_pianificabili->implode('descrizione', ', '); - -echo ' -

    '.tr('Qui puoi pianificare la suddivisione del budget del contratto in rate uguali fatturabili in modo separato').'. '.tr('Questa procedura può essere effettuata solo una volta, e sovrascriverà in modo irreversibile tutte le righe del contratto').'.

    -

    '.tr('Per poter procedere, il contratto deve avere data accettazione e data conclusione definita ed essere in uno dei seguenti stati: _LINK_', [ - '_LINK_' => ''.$elenco_stati.'', -]).'.

    - -
    - '.tr("Tutte le righe del contratto vengono convertite in righe generiche, rendendo impossibile risalire ad eventuali articoli utilizzati all'interno del contratto e pertanto non movimentando il magazzino").'. -
    '; - -$pianificazioni = $contratto->pianificazioni; -if (!$pianificazioni->isEmpty()) { - echo ' -
    - - - - - - - - - - '; - - $previous = null; - foreach ($pianificazioni as $pianificazione) { - echo ' - - '; - - // Documento collegato - echo ' - - - '; - - // Creazione fattura - echo ' - - '; - } - - echo ' - -
    '.tr('Scadenza').''.tr('Documento').''.tr('Importo').'#
    '; - - // Data scadenza - if (!$pianificazione->data_scadenza->equalTo($previous)) { - $previous = $pianificazione->data_scadenza; - echo ' - '.ucfirst($pianificazione->data_scadenza->formatLocalized('%B %Y')).''; - } - - echo ' - '; - $fattura = $pianificazione->fattura; - if (!empty($fattura)) { - $is_pianificato = true; - echo ' - '.Modules::link('Fatture di vendita', $fattura->id, tr('Fattura num. _NUM_ del _DATE_', [ - '_NUM_' => $fattura->numero_esterno, - '_DATE_' => dateFormat($fattura->data), - ])).' ( '.$fattura->stato->descrizione.')'; - } else { - echo ' - '.tr('Non ancora fatturato'); - } - echo ' - - '.moneyFormat($pianificazione->totale_imponibile).' - - -
    '; - - echo ''; - - echo '
    '; -} else { - echo ' -
    - '.tr('Pianificazione della fatturazione non impostata per questo contratto').'. -
    - - -
    '; -} - - echo ' - '; diff --git a/plugins/pianificazione_fatturazione/modutil.php b/plugins/pianificazione_fatturazione/modutil.php deleted file mode 100644 index 7b8c3cfd5..000000000 --- a/plugins/pianificazione_fatturazione/modutil.php +++ /dev/null @@ -1,37 +0,0 @@ - 'Gennaio', - '02' => 'Febbraio', - '03' => 'Marzo', - '04' => 'Aprile', - '05' => 'Maggio', - '06' => 'Giugno', - '07' => 'Luglio', - '08' => 'Agosto', - '09' => 'Settembre', - '11' => 'Ottobre', - '11' => 'Novembre', - '12' => 'Dicembre', - ]; - - $result['list'] = '
      -
    • {periodo}
    • -
    • {data_inizio}
    • -
    • {data_fine}
    • -
    • {mese_fatturazione}
    • -
    '; - - if (!empty($descrizione)) { - $result['descrizione'] = str_replace('{periodo}', 'durata dal '.Translator::dateToLocale($inizio).' al '.Translator::dateToLocale($fine), $descrizione); - $result['descrizione'] = str_replace('{data_inizio}', Translator::dateToLocale($inizio), $result['descrizione']); - $result['descrizione'] = str_replace('{data_fine}', Translator::dateToLocale($fine), $result['descrizione']); - $result['descrizione'] = str_replace('{mese_fatturazione}', $mese[date('m', strtotime($inizio))], $result['descrizione']); - } - - return $result; - } diff --git a/plugins/pianificazione_fatturazione/src/Pianificazione.php b/plugins/pianificazione_fatturazione/src/Pianificazione.php deleted file mode 100755 index 42ee2b691..000000000 --- a/plugins/pianificazione_fatturazione/src/Pianificazione.php +++ /dev/null @@ -1,158 +0,0 @@ -. - */ - -namespace Plugins\PianificazioneFatturazione; - -use Common\Document; -use Modules\Contratti\Contratto; -use Modules\Fatture\Fattura; - -class Pianificazione extends Document -{ - protected $table = 'co_fatturazione_contratti'; - - /** - * The attributes that should be mutated to dates. - * - * @var array - */ - protected $dates = [ - 'data_scadenza', - ]; - - /** - * Crea un nuovo promemoria. - * - * @param string $data_richiesta - * - * @return self - */ - public static function build(Contratto $contratto, $data_scadenza) - { - $model = new static(); - - $model->contratto()->associate($contratto); - - $model->data_scadenza = $data_scadenza; - - // Salvataggio delle informazioni - $model->save(); - - return $model; - } - - public function getPluginAttribute() - { - return 'Pianificazione fatturazione'; - } - - public function getDirezioneAttribute() - { - return 'entrata'; - } - - public function anagrafica() - { - return $this->contratto->anagrafica(); - } - - public function contratto() - { - return $this->belongsTo(Contratto::class, 'idcontratto'); - } - - public function fattura() - { - return $this->belongsTo(Fattura::class, 'iddocumento'); - } - - public function getNumeroPianificazione() - { - $pianificazioni = $this->contratto->pianificazioni; - - $p = $this; - - return $pianificazioni->search(function ($item) use ($p) { - return $item->id == $p->id; - }) + 1; - } - - public function getRighe() - { - $righe = $this->contratto->getRighe(); - $pianificazioni = $this->contratto->pianificazioni; - $numero_righe = $righe->count() / $pianificazioni->count(); - - $p = $this; - $index = $pianificazioni->search(function ($item) use ($p) { - return $item->id == $p->id; - }); - - $skip = $pianificazioni->count(); - - return $righe->filter(function ($value, $key) use ($skip, $index) { - return $key % $skip == $index; - }); - } - - public function articoli() - { - return $this->contratto->articoli(); - } - - public function righe() - { - return $this->contratto->righe(); - } - - public function sconti() - { - return $this->contratto->sconti(); - } - - public function descrizioni() - { - return $this->contratto->descrizioni(); - } - - public function getReferenceName() - { - // TODO: Implement getReferenceName() method. - } - - public function getReferenceNumber() - { - // TODO: Implement getReferenceNumber() method. - } - - public function getReferenceDate() - { - // TODO: Implement getReferenceDate() method. - } - - public function getReferenceRagioneSociale() - { - return $this->anagrafica->ragione_sociale; - } - - public function getReference() - { - // TODO: Implement getReference() method. - } -} diff --git a/plugins/pianificazione_fatturazione/widgets/rate_contrattuali.php b/plugins/pianificazione_fatturazione/widgets/rate_contrattuali.php deleted file mode 100644 index 4bfe6cf13..000000000 --- a/plugins/pianificazione_fatturazione/widgets/rate_contrattuali.php +++ /dev/null @@ -1,128 +0,0 @@ -. - */ - -use Plugins\PianificazioneFatturazione\Pianificazione; - -include_once __DIR__.'/../../../core.php'; - -$pianificazioni = Pianificazione::doesntHave('fattura') - ->orderBy('data_scadenza', 'asc') - ->whereHas('contratto', function ($q) { - $q->whereHas('stato', function ($q) { - $q->where('is_fatturabile', 1); - }); - }) - ->get(); -if ($pianificazioni->isEmpty()) { - echo ' -

    '.tr('Non ci sono fatture da emettere').'.

    '; - - return; -} - -$raggruppamenti = $pianificazioni->groupBy(function ($item) { - return ucfirst($item->data_scadenza->formatLocalized('%B %Y')); -}); - -$counter = 0; -foreach ($raggruppamenti as $mese => $raggruppamento) { - ++$counter; - - // Se cambia il mese ricreo l'intestazione della tabella - if ($counter == 1) { - $attr = ''; - $class = 'fa-minus-circle'; - } else { - $attr = 'style="display:none;"'; - $class = 'fa-plus-circle'; - } - - echo " -

    - - ".$mese.' - -

    '; - - echo ' -
    - - - - - - - - - - - '; - - // Elenco fatture da emettere - foreach ($pianificazioni as $pianificazione) { - $contratto = $pianificazione->contratto; - $anagrafica = $contratto->anagrafica; - $numero_pianificazioni = $contratto->pianificazioni()->count(); - - if (strtolower($pianificazione->data_scadenza->formatLocalized('%B %Y')) == strtolower($mese)) { - echo ' - - - - - - '; - - // Pulsanti - echo ' - - '; - } - } - - echo ' - -
    '.tr('Entro il').''.tr('Ragione sociale').''.tr('Importo').'
    - '.dateFormat($pianificazione->data_scadenza).' -
    '.reference($contratto).' -
    - '.Modules::link('Anagrafiche', $anagrafica->id, nl2br($anagrafica->ragione_sociale)).' - - '.moneyFormat($pianificazione->totale).'
    - '.tr('Rata _IND_/_NUM_ (totale: _TOT_)', [ - '_IND_' => numberFormat($pianificazione->getNumeroPianificazione(), 0), - '_NUM_' => numberFormat($numero_pianificazioni, 0), - '_TOT_' => moneyFormat($contratto->totale), - ]).' -
    - -
    -
    '; -} - -$modulo_pianificazione = Modules::get('Contratti'); -$plugin_pianificazione = Plugins::get('Pianificazione fatturazione'); -echo ' -'; diff --git a/plugins/pianificazione_interventi/actions.php b/plugins/pianificazione_interventi/actions.php deleted file mode 100755 index 276d3742b..000000000 --- a/plugins/pianificazione_interventi/actions.php +++ /dev/null @@ -1,285 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Carbon\Carbon; -use Carbon\CarbonInterval; -use Modules\Articoli\Articolo as ArticoloOriginale; -use Modules\Contratti\Contratto; -use Modules\Interventi\Intervento; -use Modules\Interventi\Stato; -use Modules\TipiIntervento\Tipo as TipoSessione; -use Plugins\PianificazioneInterventi\Components\Articolo; -use Plugins\PianificazioneInterventi\Components\Riga; -use Plugins\PianificazioneInterventi\Promemoria; - -$operazione = filter('op'); - -// Pianificazione intervento -switch ($operazione) { - case 'add-promemoria': - $contratto = Contratto::find($id_parent); - $tipo = TipoSessione::find(filter('idtipointervento')); - - $promemoria = Promemoria::build($contratto, $tipo, filter('data_richiesta')); - echo $promemoria->id; - - break; - - case 'edit-promemoria': - $dbo->update('co_promemoria', [ - 'data_richiesta' => post('data_richiesta'), - 'idtipointervento' => post('idtipointervento'), - 'richiesta' => post('richiesta'), - 'idimpianti' => implode(',', post('idimpianti') ?: []), - 'idsede' => implode(',', post('idsede_c') ?: []), - ], ['id' => $id_record]); - - flash()->info(tr('Promemoria inserito!')); - - break; - - // Eliminazione pianificazione - case 'delete-promemoria': - $id = post('id'); - - $dbo->query('DELETE FROM `co_promemoria` WHERE id='.prepare($id)); - $dbo->query('DELETE FROM `co_righe_promemoria` WHERE id_promemoria='.prepare($id)); - - flash()->info(tr('Pianificazione eliminata!')); - - break; - - // Eliminazione tutti i promemoria di questo contratto con non hanno l'intervento associato - case 'delete-non-associati': - $dbo->query('DELETE FROM `co_righe_promemoria` WHERE id_promemoria IN (SELECT id FROM `co_promemoria` WHERE idcontratto = :id_contratto AND idintervento IS NULL)', [ - ':id_contratto' => $id_record, - ]); - - $dbo->query('DELETE FROM `co_promemoria` WHERE idcontratto = :id_contratto AND idintervento IS NULL', [ - ':id_contratto' => $id_record, - ]); - - flash()->info(tr('Tutti i promemoria non associati sono stati eliminati!')); - - break; - - // Pianificazione ciclica - case 'pianificazione': - $intervallo = post('intervallo'); - $data_inizio = post('data_inizio'); - - $count = 0; - $count_interventi = 0; - $count_promemoria = 0; - - $date_con_promemoria = []; - $date_con_intervento = []; - if (post('pianifica_promemoria')) { - $promemoria_originale = Promemoria::find($id_record); - $contratto = $promemoria_originale->contratto; - - // Promemoria del contratto raggruppati per data - $promemoria_contratto = $contratto->promemoria() - ->where('idtipointervento', $promemoria_originale->tipo->id) - ->get() - ->groupBy(function ($item) { - return $item->data_richiesta->toDateString(); - }); - - $date_preimpostate = $promemoria_contratto->keys()->toArray(); - - $data_conclusione = $contratto->data_conclusione; - $data_inizio = new Carbon($data_inizio); - $data_richiesta = $data_inizio->copy(); - $interval = CarbonInterval::make($intervallo.' days'); - - $stato = Stato::where('codice', 'WIP')->first(); // Stato "In programmazione" - - // Ciclo partendo dalla data_richiesta fino alla data conclusione del contratto - while ($data_richiesta->lessThanOrEqualTo($data_conclusione)) { - // Creazione ciclica del promemoria se non ne esiste uno per la data richiesta - $data_promemoria = $data_richiesta->format('Y-m-d'); - if (!in_array($data_promemoria, $date_preimpostate)) { - $promemoria_corrente = $promemoria_originale->replicate(); - $promemoria_corrente->data_richiesta = $data_richiesta; - $promemoria_corrente->idintervento = null; - $promemoria_corrente->save(); - - // Copia delle righe - $righe = $promemoria_originale->getRighe(); - foreach ($righe as $riga) { - $copia = $riga->replicate(); - $copia->setDocument($promemoria_corrente); - $copia->save(); - } - - // Copia degli allegati - $allegati = $promemoria_originale->uploads(); - foreach ($allegati as $allegato) { - $allegato->copia([ - 'id_module' => $allegato->id_module, - 'id_plugin' => $allegato->id_plugin, - 'id_record' => $promemoria_corrente->id, - ]); - } - - ++$count_promemoria; - } else { - $promemoria_corrente = $promemoria_contratto[$data_promemoria]->first(); - $date_con_promemoria[] = dateFormat($data_promemoria); - } - - // Creazione intervento collegato se non presente - if (post('pianifica_intervento') && empty($promemoria->intervento)) { - // Creazione intervento - $intervento = Intervento::build($contratto->anagrafica, $promemoria_originale->tipo, $stato, $data_richiesta); - $intervento->idsede_destinazione = $promemoria_corrente->idsede ?: 0; - $intervento->richiesta = $promemoria_corrente->richiesta; - $intervento->idclientefinale = post('idclientefinale') ?: 0; - $intervento->id_contratto = $contratto->id; - $intervento->save(); - - // Aggiungo i tecnici selezionati - $idtecnici = post('idtecnico'); - foreach ($idtecnici as $idtecnico) { - add_tecnico($intervento->id, $idtecnico, $data_promemoria.' '.post('orario_inizio'), $data_promemoria.' '.post('orario_fine')); - } - - // Copia delle informazioni del promemoria - $promemoria_corrente->pianifica($intervento); - - ++$count_interventi; - } elseif (post('pianifica_intervento')) { - $date_con_intervento[] = dateFormat($data_promemoria); - } - - // Calcolo nuova data richiesta, non considero l'intervallo al primo ciclo - $data_richiesta = $data_richiesta->add($interval); - ++$count; - } - } - - if ($count == 0) { - flash()->warning(tr('Nessun promemoria pianificato')); - } else { - flash()->info(tr('Sono stati creati _NUM_ promemoria!', [ - '_NUM_' => $count_promemoria, - ])); - - if (!empty($date_con_promemoria)) { - flash()->warning(tr('Le seguenti date presentano già un promemoria pianificato: _LIST_', [ - '_LIST_' => implode(', ', $date_con_promemoria), - ])); - } - - if (post('pianifica_intervento')) { - flash()->info(tr('Sono stati pianificati _NUM_ interventi!', [ - '_NUM_' => $count_interventi, - ])); - - if (!empty($date_con_intervento)) { - flash()->warning(tr('I promemoria delle seguenti date presentano già un intervento collegato: _LIST_', [ - '_LIST_' => implode(', ', $date_con_intervento), - ])); - } - } - } - break; - - case 'manage_articolo': - if (post('idriga') != null) { - $articolo = Articolo::find(post('idriga')); - } else { - $originale = ArticoloOriginale::find(post('idarticolo')); - $articolo = Articolo::build($promemoria, $originale); - $articolo->id_dettaglio_fornitore = post('id_dettaglio_fornitore') ?: null; - } - - $qta = post('qta'); - - $articolo->descrizione = post('descrizione'); - $articolo->um = post('um') ?: null; - - $articolo->costo_unitario = post('costo_unitario') ?: 0; - $articolo->setPrezzoUnitario(post('prezzo_unitario'), post('idiva')); - $articolo->setSconto(post('sconto'), post('tipo_sconto')); - - try { - $articolo->qta = $qta; - } catch (UnexpectedValueException $e) { - flash()->error(tr('Alcuni serial number sono già stati utilizzati!')); - } - - $articolo->save(); - - if (post('idriga') != null) { - flash()->info(tr('Articolo modificato!')); - } else { - flash()->info(tr('Articolo aggiunto!')); - } - - break; - - case 'manage_riga': - if (post('idriga') != null) { - $riga = Riga::find(post('idriga')); - } else { - $riga = Riga::build($promemoria); - } - - $qta = post('qta'); - - $riga->descrizione = post('descrizione'); - $riga->um = post('um') ?: null; - - $riga->costo_unitario = post('costo_unitario') ?: 0; - $riga->setPrezzoUnitario(post('prezzo_unitario'), post('idiva')); - $riga->setSconto(post('sconto'), post('tipo_sconto')); - - $riga->qta = $qta; - - $riga->save(); - - if (post('idriga') != null) { - flash()->info(tr('Riga modificata!')); - } else { - flash()->info(tr('Riga aggiunta!')); - } - - break; - - case 'delete_riga': - $id_riga = post('idriga'); - $type = post('type'); - $riga = $promemoria->getRiga($type, $id_riga); - - if (!empty($riga)) { - try { - $riga->delete(); - - flash()->info(tr('Riga rimossa!')); - } catch (InvalidArgumentException $e) { - flash()->error(tr('Alcuni serial number sono già stati utilizzati!')); - } - } - - break; -} diff --git a/plugins/pianificazione_interventi/edit.php b/plugins/pianificazione_interventi/edit.php deleted file mode 100755 index 50c02fe70..000000000 --- a/plugins/pianificazione_interventi/edit.php +++ /dev/null @@ -1,206 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Contratti\Contratto; -use Modules\Contratti\Stato; - -$contratto = Contratto::find($id_record); -if (empty($contratto)) { - return; -} - -$is_pianificabile = $contratto->stato->is_pianificabile && !empty($contratto['data_accettazione']); // Contratto permette la pianificazione -$elenco_promemoria = $contratto->promemoria->sortBy('data_richiesta'); - -$stati_pianificabili = Stato::where('is_pianificabile', 1)->get(); -$elenco_stati = $stati_pianificabili->implode('descrizione', ', '); - -echo ' -

    '.tr('Puoi pianificare dei "promemoria" o direttamente gli interventi da effettuare entro determinate scadenze').'. '.tr('Per poter pianificare i promemoria, il contratto deve avere data accettazione e data conclusione definita ed essere in uno dei seguenti stati: _LINK_', [ - '_LINK_' => ''.$elenco_stati.'', -]).' - - - -

    '; - -echo ' -
    -
    -
    - {[ "type": "select", "placeholder": "'.tr('Tipo di promemoria').'", "name": "id_tipo_promemoria", "required": 1, "ajax-source": "tipiintervento", "class": "unblockable" ]} -
    - -
    - -
    -
    -
    '; - -// Nessun intervento pianificato -if (!$elenco_promemoria->isEmpty()) { - echo ' - - - - - - - - - - - - - - - '; - - // Elenco promemoria - foreach ($elenco_promemoria as $promemoria) { - // Sede - if ($promemoria['idsede'] == '-1') { - echo '- '.tr('Nessuna').' -'; - } elseif (empty($promemoria['idsede'])) { - $info_sede = tr('Sede legale'); - } else { - $info_sede = $dbo->fetchOne("SELECT id, CONCAT( CONCAT_WS( ' (', CONCAT_WS(', ', nomesede, citta), indirizzo ), ')') AS descrizione FROM an_sedi WHERE id=".prepare($promemoria->idsede))['descrizione']; - } - - // Intervento svolto - $intervento = $promemoria->intervento; - if (!empty($intervento)) { - $info_intervento = Modules::link('Interventi', $intervento['id'], tr('Intervento num. _NUM_ del _DATE_', [ - '_NUM_' => $intervento->codice, - '_DATE_' => dateFormat($intervento->data_richiesta), - ])); - - $disabled = 'disabled'; - $title = 'Per eliminare il promemoria, eliminare prima l\'intervento associato.'; - } else { - $info_intervento = '- '.('Nessuno').' -'; - $disabled = ''; - $title = 'Elimina promemoria...'; - } - - // Informazioni sugli impianti - $info_impianti = ''; - if (!empty($promemoria['idimpianti'])) { - $impianti = $dbo->fetchArray('SELECT id, matricola, nome FROM my_impianti WHERE id IN ('.($promemoria['idimpianti']).')'); - - foreach ($impianti as $impianto) { - $info_impianti .= Modules::link('MyImpianti', $impianto['id'], tr('_NOME_ (_MATRICOLA_)', [ - '_NOME_' => $impianto['nome'], - '_MATRICOLA_' => $impianto['matricola'], - ])).'
    '; - } - } - - // Informazioni sulle righe - $info_righe = ''; - $righe = $promemoria->getRighe(); - foreach ($righe as $riga) { - $info_righe .= tr('_QTA_ _UM_ x _DESC_', [ - '_DESC_' => ($riga->isArticolo() ? Modules::link('Articoli', $riga['idarticolo'], $riga['descrizione']) : $riga['descrizione']), - '_QTA_' => Translator::numberToLocale($riga['qta']), - '_UM_' => $riga['um'], - ]).'
    '; - } - - // Informazioni sugli allegati - $info_allegati = ''; - $allegati = $promemoria->uploads(); - foreach ($allegati as $allegato) { - $info_allegati .= tr(' _NOME_ (_ORIGINAL_)', [ - '_ORIGINAL_' => $allegato['original_name'], - '_NOME_' => $allegato['name'], - ]).'
    '; - } - - echo ' - - - - - - - - - - - '; - } - echo ' - -
    '.tr('Data').''.tr('Tipo intervento').''.tr('Descrizione').''.tr('Intervento').''.tr('Sede').''.tr('Impianti').''.tr('Materiali').''.tr('Allegati').''.tr('Opzioni').'
    '.Translator::dateToLocale($promemoria['data_richiesta']).''.$promemoria->tipo->descrizione.''.nl2br($promemoria['richiesta']).''.$info_intervento.''.$info_sede.''.$info_impianti.''.$info_righe.''.$info_allegati.' - - - - - - -
    '; - - if (!empty($promemorias)) { - echo ' -
    -
    - -
    '; - } -} else { - echo ' -
    - '.tr('Nessun promemoria pianificato per il contratto corrente').'. -
    '; -} - -echo ' -'; diff --git a/plugins/pianificazione_interventi/init.php b/plugins/pianificazione_interventi/init.php deleted file mode 100755 index ecc0749eb..000000000 --- a/plugins/pianificazione_interventi/init.php +++ /dev/null @@ -1,26 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Plugins\PianificazioneInterventi\Promemoria; - -if (isset($id_record)) { - $promemoria = Promemoria::find($id_record); -} diff --git a/plugins/pianificazione_interventi/pianificazione.php b/plugins/pianificazione_interventi/pianificazione.php deleted file mode 100755 index 7f4b31079..000000000 --- a/plugins/pianificazione_interventi/pianificazione.php +++ /dev/null @@ -1,314 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$plugin = Plugins::get($id_plugin); - -$id_module = Modules::get('Contratti')['id']; -$block_edit = filter('add') ? false : true; - -// Informazioni contratto -$contratto = $dbo->fetchOne('SELECT * FROM `co_contratti` WHERE `id` = :id', [ - ':id' => $id_parent, -]); -$data_accettazione = $contratto['data_accettazione']; -$data_conclusione = $contratto['data_conclusione']; -$id_anagrafica = $contratto['idanagrafica']; - -// Impianti del contratto -$impianti = $dbo->fetchArray('SELECT `idimpianto` FROM `my_impianti_contratti` WHERE `idcontratto` = :id', [ - ':id' => $id_parent, -]); -$id_impianti = array_column($impianti, 'idimpianto'); - -// solo se ho selezionato un solo impianto nel contratto, altrimenti non so quale sede e tecnico prendere -if (count($id_impianti) == 1) { - $id_sede = $dbo->fetchOne('SELECT idsede FROM my_impianti WHERE id = '.prepare($id_impianti[0]))['idsede']; - $id_tecnico = $dbo->fetchOne('SELECT idtecnico FROM my_impianti WHERE id = '.prepare($id_impianti[0]))['idtecnico']; -} - -// Informazioni del promemoria -$record = $dbo->fetchOne('SELECT *, (SELECT descrizione FROM in_tipiintervento WHERE idtipointervento=co_promemoria.idtipointervento) AS tipointervento, (SELECT tempo_standard FROM in_tipiintervento WHERE idtipointervento = co_promemoria.idtipointervento) AS tempo_standard FROM co_promemoria WHERE id = :id', [ - ':id' => $id_record, -]); -$data_richiesta = $record['data_richiesta'] ?: date('Y-m-d'); -$id_sede = $record['idsede']; -$tempo_standard = $record['tempo_standard']; -$idtipointervento = $record['idtipointervento']; - -if (!empty($id_sede)) { - $id_impianti = explode(',', trim($record['idimpianti'])); -} - -$pianificazione = [ - [ - 'id' => 0, - 'text' => tr('Pianificare a partire da questo promemoria _DATE_', [ - '_DATE_' => $data_richiesta, - ]), - ], - [ - 'id' => 1, - 'text' => tr('Pianificare a partire da oggi _DATE_', [ - '_DATE_' => date('Y-m-d'), - ]), - ], -]; - -// orari inizio fine interventi (8h standard) -$orario_inizio = '09:00'; -$orario_fine = !empty($tempo_standard) ? date('H:i', strtotime($orario_inizio) + ((60 * 60) * $tempo_standard)) : '17:00'; - -echo ' -
    - - - - - - '; - - echo ' - -
    -
    -

    '.tr('Dati').'

    -
    - -
    - -
    -
    - {[ "type": "date", "label": "'.tr('Data promemoria').'", "name": "data_richiesta", "required": 1, "value": "'.$data_accettazione.'", "readonly": '.intval($block_edit).', "min-date": "'.$data_accettazione.'", "max-date": "'.$data_conclusione.'" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Tipo intervento').'", "name": "idtipointervento", "required": 1, "id": "idtipointervento_", "value": "'.$record['idtipointervento'].'", "readonly": '.intval($block_edit).', "ajax-source": "tipiintervento", "value": "'.$idtipointervento.'" ]} -
    -
    - -
    -
    - {[ "type": "select", "label": "'.tr('Sede').'", "name": "idsede_c", "values": "query=SELECT 0 AS id, \'Sede legale\' AS descrizione UNION SELECT id, CONCAT( CONCAT_WS( \' (\', CONCAT_WS(\', \', `nomesede`, `citta`), `indirizzo` ), \')\') AS descrizione FROM an_sedi WHERE idanagrafica='.$id_anagrafica.'", "value": "'.$id_sede.'", "readonly": '.intval($block_edit).', "required" : "1" ]} -
    - -
    - {[ "type": "select", "multiple": "1", "label": "'.tr('Impianti a contratto').'", "name": "idimpianti[]", "help": "'.tr('Impianti della sede selezionata per il Contratto').'", "values": "query=SELECT my_impianti.id AS id, my_impianti.nome AS descrizione FROM my_impianti_contratti INNER JOIN my_impianti ON my_impianti_contratti.idimpianto = my_impianti.id WHERE my_impianti_contratti.idcontratto = '.$id_parent.' ORDER BY descrizione", "value": "'.implode(',', $id_impianti).'", "readonly": '.intval($block_edit).' ]} -
    -
    - -
    -
    - {[ "type": "textarea", "label": "'.tr('Descrizione').'", "name": "richiesta", "id": "richiesta_", "readonly": '.intval($block_edit).', "value": "'.$record['richiesta'].'" ]} -
    -
    -
    -
    '; - -echo ' - -
    -
    -

    '.tr('Righe').'

    -
    - -
    -
    -
    '; - - if (!$block_edit) { - echo ' - - '.tr('Articolo').' - '; - - echo ' - - '.tr('Riga').' - '; - } - - echo ' -
    -
    - -
    -
    - -
    '; - -include $structure->filepath('row-list.php'); - - echo ' -
    -
    -
    '; - -echo '{( "name": "filelist_and_upload", "id_record": "'.$id_record.'", "id_module": "'.$id_module.'", "id_plugin": "'.$id_plugin.'", "readonly": '.intval($block_edit).' )}'; - -echo ' - -
    -
    -

    '.tr('Promemoria ciclico?').'

    -
    - -
    - - - -
    - -
    - {[ "type": "checkbox", "label": "'.tr('Promemoria ciclico').'", "name": "pianifica_promemoria", "value": "0", "placeholder": "'.tr('Pianificare promemoria ciclici').'", "help": "'.tr('Pianificare ciclicamente altri promemoria identici a questo').'" ]} -
    - -
    - {[ "type": "number", "label": "'.tr('Intervallo').'", "name": "intervallo", "decimals": 0, "required": 1, "icon-after": "GG", "min-value": "1", "maxlength": "3", "disabled": "1" ]} -
    - -
    - {[ "type": "date", "label": "'.tr('Inizio pianificazione').'", "help": "'.tr('Intervallo compreso dalla data accettazione contratto fino alla data di conclusione').'", "name": "data_inizio", "value": "'.$data_accettazione.'", "disabled": "1", "min-date": "'.$data_accettazione.'", "max-date": "'.$data_conclusione.'" ]} -
    - -
    - {[ "type": "date", "label": "'.tr('Fine pianificazione').'", "help": "'.tr('Data conclusione contratto').'", "name": "data_conclusione", "extra": "readonly", "value": "'.$data_conclusione.'" ]} -
    -
    - -
    -
    '; - -echo ' - -
    -
    -

    '.tr('Pianificare interventi?').'

    -
    - -
    - -
    -
    - {[ "type": "checkbox", "label": "'.tr("Pianifica anche l'intervento").'", "name": "pianifica_intervento", "value": "0", "placeholder": "'.tr("Pianificare già l'intervento").'", "disabled": "1" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Tecnici').'", "multiple": "1", "name": "idtecnico[]", "ajax-source": "tecnici", "disabled": "1", "value": "'.$id_tecnico.'" ]} -
    - - -
    - {[ "type": "time", "label": "'.tr('Orario inizio').'", "name": "orario_inizio", "value": "'.$orario_inizio.'", "disabled": "1" ]} -
    - -
    - {[ "type": "time", "label": "'.tr('Orario fine').'", "name": "orario_fine", "value": "'.$orario_fine.'", "disabled": "1" ]} -
    -
    - -
    -
    '; - -echo ' - - -
    -
    - -
    -
    -
    '; - -echo ' -'; - -echo ' -'; diff --git a/plugins/pianificazione_interventi/row-add.php b/plugins/pianificazione_interventi/row-add.php deleted file mode 100755 index cf1eb3c75..000000000 --- a/plugins/pianificazione_interventi/row-add.php +++ /dev/null @@ -1,96 +0,0 @@ -. - */ - -use Plugins\PianificazioneInterventi\Promemoria; - -include_once __DIR__.'/../../core.php'; - -$documento = Promemoria::find($id_record); - -// Impostazioni per la gestione -$options = [ - 'op' => 'manage_riga', - 'action' => 'add', - 'dir' => $documento->direzione, - 'idanagrafica' => $documento['idanagrafica'], - 'totale_imponibile_documento' => $documento->totale_imponibile, - 'totale_documento' => $documento->totale, - 'id_plugin' => $id_plugin, // Modificato -]; - -// Dati di default -$result = [ - 'descrizione' => '', - 'qta' => 1, - 'um' => '', - 'prezzo' => 0, - 'sconto_unitario' => 0, - 'tipo_sconto' => '', - 'idiva' => '', - 'idconto' => $idconto, - 'ritenuta_contributi' => true, -]; - -// Leggo l'iva predefinita per l'anagrafica e se non c'è leggo quella predefinita generica -$iva = $dbo->fetchArray('SELECT idiva_vendite AS idiva FROM an_anagrafiche WHERE idanagrafica='.prepare($documento['idanagrafica'])); -$result['idiva'] = $iva[0]['idiva'] ?: setting('Iva predefinita'); - -// Importazione della gestione dedicata -$file = 'riga'; -if (get('is_descrizione') !== null) { - $file = 'descrizione'; - - $options['op'] = 'manage_descrizione'; -} elseif (get('is_articolo') !== null) { - $file = 'articolo'; - - // Aggiunta sconto di default da listino per le vendite - $listino = $dbo->fetchOne('SELECT prc_guadagno FROM an_anagrafiche INNER JOIN mg_listini ON an_anagrafiche.idlistino_vendite=mg_listini.id WHERE idanagrafica='.prepare($documento['idanagrafica'])); - - if (!empty($listino['prc_guadagno'])) { - $result['sconto_percentuale'] = $listino['prc_guadagno']; - $result['tipo_sconto'] = 'PRC'; - } - - $options['op'] = 'manage_articolo'; -} elseif (get('is_sconto') !== null) { - $file = 'sconto'; - - $options['op'] = 'manage_sconto'; -} - -// Modificato -echo ' -
    '; - -echo App::load($file.'.php', $result, $options); - -echo ' -
    -'; diff --git a/plugins/pianificazione_interventi/row-edit.php b/plugins/pianificazione_interventi/row-edit.php deleted file mode 100755 index 7dadeea42..000000000 --- a/plugins/pianificazione_interventi/row-edit.php +++ /dev/null @@ -1,79 +0,0 @@ -. - */ - -use Plugins\PianificazioneInterventi\Promemoria; - -include_once __DIR__.'/../../core.php'; - -$documento = Promemoria::find($id_record); - -// Impostazioni per la gestione -$options = [ - 'op' => 'manage_riga', - 'action' => 'edit', - 'dir' => $documento->direzione, - 'idanagrafica' => $documento['idanagrafica'], - 'totale_imponibile_documento' => $documento->totale_imponibile, - 'totale_documento' => $documento->totale, - 'id_plugin' => $id_plugin, // Modificato -]; - -// Dati della riga -$id_riga = get('idriga'); -$type = get('type'); -$riga = $documento->getRiga($type, $id_riga); - -$result = $riga->toArray(); -$result['prezzo'] = $riga->prezzo_unitario; - -// Importazione della gestione dedicata -$file = 'riga'; -if ($riga->isDescrizione()) { - $file = 'descrizione'; - - $options['op'] = 'manage_descrizione'; -} elseif ($riga->isArticolo()) { - $file = 'articolo'; - - $options['op'] = 'manage_articolo'; -} elseif ($riga->isSconto()) { - $file = 'sconto'; - - $options['op'] = 'manage_sconto'; -} - -// Modificato -echo ' -
    '; - -echo App::load($file.'.php', $result, $options); - -echo ' -
    -'; diff --git a/plugins/pianificazione_interventi/row-list.php b/plugins/pianificazione_interventi/row-list.php deleted file mode 100755 index 6ed41a16d..000000000 --- a/plugins/pianificazione_interventi/row-list.php +++ /dev/null @@ -1,185 +0,0 @@ -. - */ - -use Plugins\PianificazioneInterventi\Promemoria; - -include_once __DIR__.'/../../core.php'; - -$block_edit = filter('add') ? false : true; -$show_prezzi = true; - -$promemoria = $promemoria ?: Promemoria::find($id_record); -$righe = $promemoria->getRighe(); - -if (!$righe->isEmpty()) { - echo ' - - - - - - '; - - if ($show_prezzi) { - echo ' - - - '; - } - - if (!$block_edit) { - echo ' - '; - } - echo ' - - - - '; - - foreach ($righe as $riga) { - $extra = ''; - $mancanti = $riga->isArticolo() ? $riga->missing_serials_number : 0; - if ($mancanti > 0) { - $extra = 'class="warning"'; - } - $descrizione = (!empty($riga->articolo) ? $riga->codice.' - ' : '').$riga['descrizione']; - - echo ' - - '; - - // Quantità - echo ' - '; - - if ($show_prezzi) { - // Costo unitario - echo ' - '; - - // Prezzo unitario - echo ' - '; - - echo ' - '; - - // Prezzo di vendita - echo ' - '; - } - - // Pulsante per riportare nel magazzino centrale. - // Visibile solo se l'intervento non è stato nè fatturato nè completato. - if (!$block_edit) { - echo ' - '; - } - echo ' - '; - } - - echo ' - -
    '.tr('Descrizione').''.tr('Q.tà').''.tr('Prezzo di acquisto').''.tr('Prezzo di vendita').''.tr('Iva').''.tr('Imponibile').''.tr('#').'
    - '.Modules::link($riga->isArticolo() ? Modules::get('Articoli')['id'] : null, $riga->isArticolo() ? $riga['idarticolo'] : null, $descrizione); - - if ($riga->isArticolo()) { - if (!empty($mancanti)) { - echo ' -
    '.tr('_NUM_ serial mancanti', [ - '_NUM_' => $mancanti, - ]).''; - } - - $serials = $riga->serials; - if (!empty($serials)) { - echo ' -
    '.tr('SN').': '.implode(', ', $serials); - } - } - - echo ' -
    - '.Translator::numberToLocale($riga->qta, 'qta').' '.$riga->um.' - - '.moneyFormat($riga->costo_unitario).' - - '.moneyFormat($riga->prezzo_unitario); - - if (abs($riga->sconto_unitario) > 0) { - $text = discountInfo($riga); - - echo ' -
    '.$text.''; - } - - echo ' -
    - '.moneyFormat($riga->iva_unitaria_scontata).' -
    '.$riga->aliquota->descrizione.(($riga->aliquota->esente) ? ' ('.$riga->aliquota->codice_natura_fe.')' : null).' -
    - '.moneyFormat($riga->importo).' - '; - - if ($riga->abilita_serial) { - echo ' - '; - } - - echo ' - - - -
    '; -} else { - echo ' -

    '.tr('Nessuna riga presente').'.

    '; -} - -?> - - diff --git a/plugins/pianificazione_interventi/src/Components/Articolo.php b/plugins/pianificazione_interventi/src/Components/Articolo.php deleted file mode 100755 index 28ef560a5..000000000 --- a/plugins/pianificazione_interventi/src/Components/Articolo.php +++ /dev/null @@ -1,29 +0,0 @@ -. - */ - -namespace Plugins\PianificazioneInterventi\Components; - -use Common\Components\Article; - -class Articolo extends Article -{ - use RelationTrait; - - protected $table = 'co_righe_promemoria'; -} diff --git a/plugins/pianificazione_interventi/src/Components/Descrizione.php b/plugins/pianificazione_interventi/src/Components/Descrizione.php deleted file mode 100755 index f89c6f92d..000000000 --- a/plugins/pianificazione_interventi/src/Components/Descrizione.php +++ /dev/null @@ -1,29 +0,0 @@ -. - */ - -namespace Plugins\PianificazioneInterventi\Components; - -use Common\Components\Description; - -class Descrizione extends Description -{ - use RelationTrait; - - protected $table = 'co_righe_promemoria'; -} diff --git a/plugins/pianificazione_interventi/src/Components/RelationTrait.php b/plugins/pianificazione_interventi/src/Components/RelationTrait.php deleted file mode 100755 index ec507c206..000000000 --- a/plugins/pianificazione_interventi/src/Components/RelationTrait.php +++ /dev/null @@ -1,63 +0,0 @@ -. - */ - -namespace Plugins\PianificazioneInterventi\Components; - -use Plugins\PianificazioneInterventi\Promemoria; - -trait RelationTrait -{ - protected $disableOrder = true; - - public function getDocumentID() - { - return 'id_promemoria'; - } - - public function document() - { - return $this->belongsTo(Promemoria::class, $this->getDocumentID()); - } - - public function contratto() - { - return $this->document(); - } - - public function fixIvaIndetraibile() - { - } - - public function getQtaEvasaAttribute() - { - return 0; - } - - public function setQtaEvasaAttribute($value) - { - } - - /** - * Effettua i conti per il subtotale della riga. - */ - protected function fixSubtotale() - { - $this->fixIva(); - } -} diff --git a/plugins/pianificazione_interventi/src/Components/Riga.php b/plugins/pianificazione_interventi/src/Components/Riga.php deleted file mode 100755 index d7c246774..000000000 --- a/plugins/pianificazione_interventi/src/Components/Riga.php +++ /dev/null @@ -1,29 +0,0 @@ -. - */ - -namespace Plugins\PianificazioneInterventi\Components; - -use Common\Components\Row; - -class Riga extends Row -{ - use RelationTrait; - - protected $table = 'co_righe_promemoria'; -} diff --git a/plugins/pianificazione_interventi/src/Components/Sconto.php b/plugins/pianificazione_interventi/src/Components/Sconto.php deleted file mode 100755 index f4dac7b2c..000000000 --- a/plugins/pianificazione_interventi/src/Components/Sconto.php +++ /dev/null @@ -1,29 +0,0 @@ -. - */ - -namespace Plugins\PianificazioneInterventi\Components; - -use Common\Components\Discount; - -class Sconto extends Discount -{ - use RelationTrait; - - protected $table = 'co_righe_promemoria'; -} diff --git a/plugins/pianificazione_interventi/src/Promemoria.php b/plugins/pianificazione_interventi/src/Promemoria.php deleted file mode 100755 index 88a6de1d4..000000000 --- a/plugins/pianificazione_interventi/src/Promemoria.php +++ /dev/null @@ -1,184 +0,0 @@ -. - */ - -namespace Plugins\PianificazioneInterventi; - -use Common\Document; -use Modules\Contratti\Contratto; -use Modules\Interventi\Intervento; -use Modules\TipiIntervento\Tipo as TipoSessione; -use Traits\RecordTrait; - -class Promemoria extends Document -{ - use RecordTrait; - - /** - * @var bool Disabilita movimentazione automatica - */ - public static $movimenta_magazzino = false; - - protected $table = 'co_promemoria'; - - /** - * The attributes that should be mutated to dates. - * - * @var array - */ - protected $dates = [ - 'data_richiesta', - ]; - - /** - * Crea un nuovo promemoria. - * - * @param string $data_richiesta - * - * @return self - */ - public static function build(Contratto $contratto, TipoSessione $tipo, $data_richiesta) - { - $model = new static(); - - $model->contratto()->associate($contratto); - $model->tipo()->associate($tipo); - - $model->data_richiesta = $data_richiesta; - $model->idsede = $contratto->idsede; - - // Salvataggio delle informazioni - $model->save(); - - return $model; - } - - public function getPluginAttribute() - { - return 'Pianificazione interventi'; - } - - public function getDirezioneAttribute() - { - return 'entrata'; - } - - public function pianifica(Intervento $intervento, $copia_impianti = true) - { - $this->intervento()->associate($intervento); // Collego l'intervento ai promemoria - $this->save(); - - // Copia delle righe - $righe = $this->getRighe(); - foreach ($righe as $riga) { - $copia = $riga->copiaIn($intervento, $riga->qta); - } - - // Copia degli allegati - $allegati = $this->uploads(); - foreach ($allegati as $allegato) { - $allegato->copia([ - 'id_module' => $intervento->getModule()->id, - 'id_record' => $intervento->id, - ]); - } - - // Collego gli impianti del promemoria all'intervento - $database = database(); - if ($copia_impianti && !empty($this->idimpianti)) { - $impianti = explode(',', $this->idimpianti); - $impianti = array_unique($impianti); - foreach ($impianti as $impianto) { - $database->insert('my_impianti_interventi', [ - 'idintervento' => $intervento->id, - 'idimpianto' => $impianto, - ]); - } - } - } - - public function anagrafica() - { - return $this->contratto->anagrafica(); - } - - public function contratto() - { - return $this->belongsTo(Contratto::class, 'idcontratto'); - } - - public function intervento() - { - return $this->belongsTo(Intervento::class, 'idintervento'); - } - - public function tipo() - { - return $this->belongsTo(TipoSessione::class, 'idtipointervento'); - } - - public function articoli() - { - return $this->hasMany(Components\Articolo::class, 'id_promemoria'); - } - - public function righe() - { - return $this->hasMany(Components\Riga::class, 'id_promemoria'); - } - - public function sconti() - { - return $this->hasMany(Components\Sconto::class, 'id_promemoria'); - } - - public function descrizioni() - { - return $this->hasMany(Components\Descrizione::class, 'id_promemoria'); - } - - public function getModuleAttribute() - { - // TODO: Implement getModuleAttribute() method. - } - - public function getReferenceName() - { - // TODO: Implement getReferenceName() method. - } - - public function getReferenceNumber() - { - // TODO: Implement getReferenceNumber() method. - } - - public function getReferenceDate() - { - // TODO: Implement getReferenceDate() method. - } - - public function getReferenceRagioneSociale() - { - return $this->anagrafica->ragione_sociale; - } - - public function getReference() - { - // TODO: Implement getReference() method. - } -} diff --git a/plugins/pianificazione_interventi/widgets/promemoria_da_pianificare.php b/plugins/pianificazione_interventi/widgets/promemoria_da_pianificare.php deleted file mode 100644 index d211f42ef..000000000 --- a/plugins/pianificazione_interventi/widgets/promemoria_da_pianificare.php +++ /dev/null @@ -1,131 +0,0 @@ -. - */ - -use Plugins\PianificazioneInterventi\Promemoria; - -include_once __DIR__.'/../../../core.php'; - -$elenco_promemoria = Promemoria::doesntHave('intervento')->orderByraw('data_richiesta ASC')->get(); - -$array_promemoria = []; -foreach ($elenco_promemoria as $promemoria) { - $data_pro = new Carbon($promemoria->data_richiesta); - $array_promemoria[$data_pro->format('Y-m')][] = $promemoria; -} - -if ($elenco_promemoria->isEmpty()) { - echo ' -

    '.tr('Non ci sono promemoria da pianificare').'.

    '; - - return; -} - -$raggruppamenti = $elenco_promemoria->groupBy(function ($item) { - return $item->data_richiesta->format('Y-m'); -}); - -$counter = 0; -foreach ($raggruppamenti as $mese => $raggruppamento) { - ++$counter; - - // Se cambia il mese ricreo l'intestazione della tabella - if ($counter == 1) { - $attr = ''; - $class = 'fa-minus-circle'; - } else { - $attr = 'style="display:none;"'; - $class = 'fa-plus-circle'; - } - - $nome_mese = new Carbon($mese.'-01'); - - echo " -

    - - ".ucfirst($nome_mese->formatLocalized('%B %Y')).' - -

    '; - - echo ' -
    - - - - - - - - - - - - - '; - - // Elenco promemoria da pianificare - foreach ($array_promemoria[$mese] as $promemoria) { - $contratto = $promemoria->contratto; - $anagrafica = $contratto->anagrafica; - - echo ' - - - - - - - - - - '; - - // Pulsanti - echo ' - - '; - } - - echo ' - -
    '.tr('Cliente').''.tr('Contratto').''.tr('Entro').''.tr('Tipo attività').''.tr('Descrizione').'
    - '.Modules::link('Anagrafiche', $anagrafica->id, nl2br($anagrafica->ragione_sociale)).'
    Presso: '; - - // Sede promemoria - if ($promemoria->idsede == '-1') { - echo '- '.('Nessuna').' -'; - } elseif (empty($promemoria->idsede)) { - echo tr('Sede legale'); - } else { - $rsp2 = $dbo->fetchArray("SELECT id, CONCAT( CONCAT_WS( ' (', CONCAT_WS(', ', nomesede, citta), indirizzo ), ')') AS descrizione FROM an_sedi WHERE id=".prepare($promemoria->idsede)); - - echo $rsp2[0]['descrizione']; - } - - echo ' -
    - '.reference($contratto).' - '.dateFormat($promemoria->data_richiesta).''.$promemoria->tipo->descrizione.''.nl2br($promemoria->richiesta).' - - - -
    -
    '; -} diff --git a/plugins/receiptFE/actions.php b/plugins/receiptFE/actions.php deleted file mode 100755 index 77239d30b..000000000 --- a/plugins/receiptFE/actions.php +++ /dev/null @@ -1,95 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Plugins\ReceiptFE\Interaction; -use Plugins\ReceiptFE\Ricevuta; - -switch (filter('op')) { - case 'import': - $list = Interaction::getReceiptList(); - - $results = []; - foreach ($list as $element) { - $name = $element['name']; - $fattura = Ricevuta::process($name); - - $numero_esterno = $fattura ? $fattura->numero_esterno : null; - $results[] = [ - 'file' => $name, - 'fattura' => $numero_esterno, - ]; - } - - echo json_encode($results); - - break; - - case 'save': - $content = file_get_contents($_FILES['blob']['tmp_name']); - $file = Ricevuta::store($_FILES['blob']['name'], $content); - - $name = $file; - - // no break - case 'prepare': - $name = $name ?: get('name'); - $fattura = Ricevuta::process($name); - - $numero_esterno = $fattura ? $fattura->numero_esterno : null; - - echo json_encode([ - 'file' => $name, - 'fattura' => $fattura, - ]); - - break; - - case 'list': - include __DIR__.'/rows.php'; - - break; - - case 'delete': - $file_id = get('file_id'); - - $directory = Ricevuta::getImportDirectory(); - $files = Interaction::getFileList(); - $file = $files[$file_id]; - - if (!empty($file)) { - delete($directory.'/'.$file['name']); - } - - break; - - case 'process': - $name = get('name'); - - // Processo il file ricevuto - if (Interaction::isEnabled()) { - $process_result = Interaction::processReceipt($name); - if (!empty($process_result)) { - flash()->error($process_result); - } - } - - break; -} diff --git a/plugins/receiptFE/edit.php b/plugins/receiptFE/edit.php deleted file mode 100755 index 8ef4f4a2e..000000000 --- a/plugins/receiptFE/edit.php +++ /dev/null @@ -1,293 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Carbon\Carbon; -use Modules\Fatture\Fattura; -use Plugins\ReceiptFE\Interaction; -use Util\XML; - -echo ' -

    '.tr('Le ricevute delle Fatture Elettroniche permettono di individuare se una determinata fattura tramessa è stata accettata dal Sistema Di Interscambio').'.

    '; - -if (Interaction::isEnabled()) { - echo ' -

    '.tr('Tramite il pulsante _BTN_ è possibile procedere al recupero delle ricevute, aggiornando automaticamente lo stato delle relative fatture e allegandole ad esse', [ - '_BTN_' => ' '.tr('Ricerca ricevute').'', -]).'.

    '; -} - -// Messaggio informativo su fatture con stato di errore -$fatture_generate_errore = Fattura::vendita() - ->whereIn('codice_stato_fe', ['NS', 'ERR', 'EC02']) - ->where('data_stato_fe', '>=', $_SESSION['period_start']) - ->orderBy('data_stato_fe') - ->get(); - -if (!empty($fatture_generate_errore->count())) { - echo ' - '; -} - -// Controllo se ci sono fatture in elaborazione da più di 7 giorni per le quali non ho ancora una ricevuta -$data_limite = (new Carbon())->subDays(7); -$fatture_generate = Fattura::vendita() - ->where('codice_stato_fe', 'WAIT') - ->where('data_stato_fe', '>=', $_SESSION['period_start']) - ->where('data_stato_fe', '<', $data_limite) - ->orderBy('data_stato_fe') - ->get(); - -if (!empty($fatture_generate->count())) { - echo ' - '; -} -echo ' -
    -
    -

    - '.tr('Carica un XML').' - - - - - -

    -
    -
    -
    -
    - {[ "type": "file", "name": "blob", "required": 1 ]} -
    - -
    - -
    -
    -
    -
    '; - -echo ' -
    -
    -

    - '.tr('Ricevute da importare').' -

    '; - -// Ricerca automatica -if (Interaction::isEnabled()) { - echo ' -
    - - - -
    '; -} - -echo ' -
    -
    '; - -if (Interaction::isEnabled()) { - echo ' -

    '.tr('Per vedere le ricevute da importare utilizza il pulsante _BUTTON_', [ - '_BUTTON_' => ' '.tr('Ricerca ricevute').'', - ]).'.

    '; -} else { - include $structure->filepath('list.php'); -} - - echo ' - -
    -
    '; - -echo ' -'; diff --git a/plugins/receiptFE/list.php b/plugins/receiptFE/list.php deleted file mode 100755 index 610d6e841..000000000 --- a/plugins/receiptFE/list.php +++ /dev/null @@ -1,168 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Carbon\Carbon; -use Plugins\ReceiptFE\Interaction; -use Plugins\ReceiptFE\Ricevuta; - -$list = Interaction::getReceiptList(); - -$directory = Ricevuta::getImportDirectory(); - -if (!empty($list)) { - echo ' - - - - - - - - - '; - - foreach ($list as $element) { - $name = $element['name']; - $file = $directory.'/'.$name; - - $local = file_exists($file); - $data_modifica = $local ? Carbon::createFromTimestamp(filemtime($file)) : null; - - echo ' - - - - - '; - } - - echo ' - -
    '.tr('Nome').''.tr('Data di caricamento').'#
    '.$name.''.($local ? dateFormat($data_modifica) : '-').''; - - if ($local) { - echo ' - '; - } else { - echo ' - '; - } - - echo ' - -
    '; -} else { - echo ' -

    '.tr('Nessuna ricevuta da importare').'.

    '; -} - -echo ' -'; diff --git a/plugins/receiptFE/src/Interaction.php b/plugins/receiptFE/src/Interaction.php deleted file mode 100755 index 35edd3a15..000000000 --- a/plugins/receiptFE/src/Interaction.php +++ /dev/null @@ -1,127 +0,0 @@ -. - */ - -namespace Plugins\ReceiptFE; - -use API\Services; -use Models\Cache; - -/** - * Classe per la gestione delle API esterne per la gestione e l'importazione delle ricevute per le Fatture Elettroniche. - * - * @since 2.4.3 - */ -class Interaction extends Services -{ - public static function getReceiptList() - { - $list = self::getRemoteList(); - - // Ricerca fisica - $result = self::getFileList($list); - - // Aggiornamento cache hook - Cache::pool('Ricevute Elettroniche')->set($result); - - return $result; - } - - public static function getRemoteList() - { - $list = []; - - // Ricerca da remoto - if (self::isEnabled()) { - $response = static::request('POST', 'notifiche_da_importare'); - $body = static::responseBody($response); - - if ($body['status'] == '200') { - $results = $body['results']; - - foreach ($results as $result) { - $list[] = [ - 'name' => $result, - ]; - } - } - } - - return $list ?: []; - } - - public static function getFileList($list = []) - { - $names = array_column($list, 'name'); - - // Ricerca fisica - $directory = Ricevuta::getImportDirectory(); - - $files = glob($directory.'/*.xml*'); - foreach ($files as $id => $file) { - $name = basename($file); - $pos = array_search($name, $names); - - if ($pos === false) { - $list[] = [ - 'id' => $id, - 'name' => $name, - 'file' => true, - ]; - } else { - $list[$pos]['id'] = $id; - } - } - - return $list; - } - - public static function getReceipt($name) - { - $directory = Ricevuta::getImportDirectory(); - $file = $directory.'/'.$name; - - if (!file_exists($file)) { - $response = static::request('POST', 'notifica_da_importare', [ - 'name' => $name, - ]); - $body = static::responseBody($response); - - if (!empty($body['content'])) { - Ricevuta::store($name, $body['content']); - } - } - - return $name; - } - - public static function processReceipt($filename) - { - $response = static::request('POST', 'notifica_xml_salvata', [ - 'filename' => $filename, - ]); - $body = static::responseBody($response); - - $result = true; - if ($body['status'] != '200') { - $result = $body['status'].' - '.$body['message']; - } - - return $result; - } -} diff --git a/plugins/receiptFE/src/MissingReceiptTask.php b/plugins/receiptFE/src/MissingReceiptTask.php deleted file mode 100644 index 30b5d56ce..000000000 --- a/plugins/receiptFE/src/MissingReceiptTask.php +++ /dev/null @@ -1,62 +0,0 @@ -. - */ - -namespace Plugins\ReceiptFE; - -use Carbon\Carbon; -use Modules\Fatture\Fattura; -use Plugins\ExportFE\Interaction; -use Tasks\Manager; - -/** - * Task dedicata all'importazione forzata delle ricevute per Fatture in stato di Attesa da più di 7 giorni. - * Questa funzione è necessaria per evitare eventuali problemi causati da importazioni segnato come eseguite ma non completate con successo, che si verificano in rari casi durante l'interazione con il sistema di gestione Fatture Elettroniche. - * - * @see ReceiptTask Gestione ricevute rilevate correttamente. - */ -class MissingReceiptTask extends Manager -{ - public function execute() - { - if (!Interaction::isEnabled()) { - return; - } - - // Controllo se ci sono fatture in elaborazione da più di 7 giorni per le quali non ho ancora una ricevuta - $data_limite = (new Carbon())->subDays(7); - $in_attesa = Fattura::vendita() - ->where('codice_stato_fe', 'WAIT') - ->where('data_stato_fe', '>=', $_SESSION['period_start']) - ->where('data_stato_fe', '<', $data_limite) - ->orderBy('data_stato_fe') - ->get(); - - // Ricerca delle ricevute dedicate - foreach ($in_attesa as $fattura) { - $ricevute = Interaction::getInvoiceRecepits($fattura->id); - - // Importazione di tutte le ricevute trovate - foreach ($ricevute as $ricevuta) { - $name = $ricevuta['name']; - - Ricevuta::process($name); - } - } - } -} diff --git a/plugins/receiptFE/src/NotificheRicevuteHook.php b/plugins/receiptFE/src/NotificheRicevuteHook.php deleted file mode 100644 index 19b809461..000000000 --- a/plugins/receiptFE/src/NotificheRicevuteHook.php +++ /dev/null @@ -1,89 +0,0 @@ -. - */ - -namespace Plugins\ReceiptFE; - -use Carbon\Carbon; -use Hooks\Manager; -use Modules; -use Modules\Fatture\Fattura; -use Plugins; - -/** - * Hook specializzato per il conteggio e la segnalazione di Fatture senza ricevute oppure con ricevuta in stato di errore. - * - * @see MissingReceiptTask,ReceiptTask,ReceiptHook Per procedura automatica di importazione - */ -class NotificheRicevuteHook extends Manager -{ - public function response() - { - // Messaggio informativo su fatture con stato di errore - $con_errore = Fattura::vendita() - ->whereIn('codice_stato_fe', ['NS', 'ERR', 'EC02']) - ->where('data_stato_fe', '>=', $_SESSION['period_start']) - ->orderBy('data_stato_fe') - ->count(); - - // Controllo se ci sono fatture in elaborazione da più di 7 giorni per le quali non ho ancora una ricevuta - $data_limite = (new Carbon())->subDays(7); - $in_attesa = Fattura::vendita() - ->where('codice_stato_fe', 'WAIT') - ->where('data_stato_fe', '>=', $_SESSION['period_start']) - ->where('data_stato_fe', '<', $data_limite) - ->orderBy('data_stato_fe') - ->count(); - - // Messaggio di importazione - if (!empty($in_attesa) && !empty($con_errore)) { - $message = tr('Sono presenti _ERR_ fatture elettroniche con ricevute di scarto o errori di trasmissione, _WAIT_ in attesa di ricevuta da più di 7 giorni', [ - '_ERR_' => $con_errore, - '_WAIT_' => $in_attesa, - ]); - } elseif (empty($in_attesa) && !empty($con_errore)) { - $message = tr('Sono presenti _ERR_ fatture elettroniche con ricevute di scarto o errori di trasmissione', [ - '_ERR_' => $con_errore, - ]); - } - if (!empty($in_attesa) && empty($con_errore)) { - $message = tr('Sono presenti _WAIT_ in attesa di ricevuta da più di 7 giorni', [ - '_WAIT_' => $in_attesa, - ]); - } - - $module = Modules::get('Fatture di vendita'); - $plugin = Plugins::get('Ricevute FE'); - - return [ - 'icon' => 'fa fa-ticket text-yellow', - 'message' => $message, - 'show' => $con_errore != 0 || $in_attesa != 0, - 'link' => base_path().'/controller.php?id_module='.$module->id.'#tab_'.$plugin->id, - ]; - } - - public function execute() - { - } - - public function needsExecution() - { - return false; - } -} diff --git a/plugins/receiptFE/src/ReceiptHook.php b/plugins/receiptFE/src/ReceiptHook.php deleted file mode 100755 index 3ba0de8b2..000000000 --- a/plugins/receiptFE/src/ReceiptHook.php +++ /dev/null @@ -1,119 +0,0 @@ -. - */ - -namespace Plugins\ReceiptFE; - -use Hooks\Manager; -use Models\Cache; -use Modules; - -/** - * Hook per l'importazione e il conteggio delle ricevute rilevate come da importare. - * - * @see MissingReceiptTask,ReceiptTask Per procedura più strutturata di importazione - */ -class ReceiptHook extends Manager -{ - public function isSingleton() - { - return true; - } - - public function needsExecution() - { - // Lettura cache - $todo_cache = Cache::pool('Ricevute Elettroniche'); - - return !$todo_cache->isValid() || !empty($todo_cache->content); - } - - public function execute() - { - // Lettura cache - $todo_cache = Cache::pool('Ricevute Elettroniche'); - $completed_cache = Cache::pool('Ricevute Elettroniche importate'); - - // Refresh cache - if (!$todo_cache->isValid()) { - $list = Interaction::getRemoteList(); - - $todo_cache->set($list); - $completed_cache->set([]); - - return; - } - - // Caricamento elenco di importazione - $todo = $todo_cache->content; - if (empty($todo)) { - return; - } - - // Caricamento elenco di ricevute imporate - $completed = $completed_cache->content; - $count = count($todo); - - // Esecuzione di 10 imporazioni - for ($i = 0; $i < 10 && $i < $count; ++$i) { - $element = $todo[$i]; - - // Importazione ricevuta - $name = $element['name']; - $fattura = Ricevuta::process($name); - - if (!empty($fattura)) { - $completed[] = $element; - unset($todo[$i]); - } - } - - // Aggiornamento cache - $todo_cache->set($todo); - $completed_cache->set($completed); - } - - public function response() - { - // Lettura cache - $todo_cache = Cache::pool('Ricevute Elettroniche'); - $completed_cache = Cache::pool('Ricevute Elettroniche importate'); - - $completed_number = count($completed_cache->content); - $total_number = $completed_number + count($todo_cache->content); - - // Messaggio di importazione - $message = tr('Sono state importate _NUM_ ricevute su _TOT_', [ - '_NUM_' => $completed_number, - '_TOT_' => $total_number, - ]); - - // Notifica sullo stato dell'importazione - $notify = $total_number != 0; - $color = $total_number == $completed_number ? 'success' : 'yellow'; - - $module = Modules::get('Fatture di vendita'); - - return [ - 'icon' => 'fa fa-ticket text-'.$color, - 'message' => $message, - 'show' => $notify, - 'link' => base_path().'/controller.php?id_module='.$module->id, - ]; - } -} diff --git a/plugins/receiptFE/src/ReceiptTask.php b/plugins/receiptFE/src/ReceiptTask.php deleted file mode 100644 index 61df80651..000000000 --- a/plugins/receiptFE/src/ReceiptTask.php +++ /dev/null @@ -1,46 +0,0 @@ -. - */ - -namespace Plugins\ReceiptFE; - -use Tasks\Manager; - -/** - * Task dedicata all'importazione di tutte le ricevute individuate dal sistema automatico di gestione Fatture Elettroniche. - * - * @see MissingReceiptTask Gestione ricevute non individuate per malfunzionamenti. - */ -class ReceiptTask extends Manager -{ - public function execute() - { - if (!Interaction::isEnabled()) { - return; - } - - $list = Interaction::getReceiptList(); - - // Esecuzione dell'importazione - foreach ($list as $element) { - $name = $element['name']; - - Ricevuta::process($name); - } - } -} diff --git a/plugins/receiptFE/src/Ricevuta.php b/plugins/receiptFE/src/Ricevuta.php deleted file mode 100755 index 970711804..000000000 --- a/plugins/receiptFE/src/Ricevuta.php +++ /dev/null @@ -1,262 +0,0 @@ -. - */ - -namespace Plugins\ReceiptFE; - -use Models\Upload; -use Modules\Fatture\Fattura; -use Modules\Fatture\Stato; -use Plugins; -use UnexpectedValueException; -use Util\XML; -use Util\Zip; - -/** - * Classe per la gestione delle ricevute collegate alle Fatture elettroniche in formato XML. - * - * @since 2.4.2 - */ -class Ricevuta -{ - protected static $directory = null; - - /** @var array Percorso del file XML */ - protected $file = null; - /** @var array XML della ricevuta */ - protected $xml = null; - - /** @var array XML della ricevuta */ - protected $fattura = null; - - public function __construct($name) - { - $file = static::getImportDirectory().'/'.$name; - - // Estrazione implicita per il formato ZIP - if (string_ends_with($name, '.zip')) { - $original_file = $file; - - $extraction_dir = static::getImportDirectory().'/tmp'; - Zip::extract($file, $extraction_dir); - - $name = basename($name, '.zip').'.xml'; - $file = static::getImportDirectory().'/'.$name; - copy($extraction_dir.'/'.$name, $file); - - delete($original_file); - delete($extraction_dir); - } - - $this->file = $file; - $this->xml = XML::readFile($this->file); - - $filename = explode('.', $name)[0]; - $pieces = explode('_', $filename); - - $progressivo_invio = $pieces[1]; - - $this->fattura = Fattura::where([ - 'progressivo_invio' => $progressivo_invio, - ])->first(); - - if (empty($this->fattura)) { - throw new UnexpectedValueException(); - } - } - - /** - * Funzione per gestire in modo autonomo il download, l'importazione e il salvataggio di una specifica ricevuta identificata tramite nome. - * - * @param string $name - * @param bool $cambia_stato - * - * @return Fattura|null - */ - public static function process($name, $cambia_stato = true) - { - Interaction::getReceipt($name); - - $fattura = null; - try { - $receipt = new Ricevuta($name); - $receipt->save($cambia_stato); - - $fattura = $receipt->getFattura(); - - $receipt->cleanup(); - - Interaction::processReceipt($name); - } catch (UnexpectedValueException $e) { - } - - return $fattura; - } - - /** - * Salva il file indicato nella cartella temporanea per una futura elaborazione. - * - * @param string $filename - * @param string $content - * - * @return string - */ - public static function store($filename, $content) - { - $directory = static::getImportDirectory(); - $file = $directory.'/'.$filename; - - directory($directory); - file_put_contents($file, $content); - - return $filename; - } - - /** - * Restituisce la cartella temporanea utilizzabile per il salvataggio della ricevuta. - * - * @return string|null - */ - public static function getImportDirectory() - { - if (!isset(self::$directory)) { - $plugin = Plugins::get('Ricevute FE'); - - self::$directory = base_dir().'/'.$plugin->upload_directory; - } - - return self::$directory; - } - - /** - * @param string $codice - * - * @return Upload|null - */ - public function saveAllegato($codice) - { - $filename = basename($this->file); - $fattura = $this->getFattura(); - - // Controllo sulla presenza della stessa ricevuta - $module = $fattura->getModule(); - $upload_esistente = $module - ->uploads($fattura->id) - ->where('original_name', $filename) - ->first(); - if (!empty($upload_esistente)) { - return $upload_esistente; - } - - // Registrazione del file XML come allegato - $upload = Upload::build($this->file, [ - 'id_module' => $module->id, - 'id_record' => $fattura->id, - 'original' => $filename, - ], tr('Ricevuta _TYPE_', [ - '_TYPE_' => $codice, - ]), tr('Fattura Elettronica')); - - return $upload; - } - - /** - * Aggiorna lo stato della fattura relativa alla ricevuta in modo tale da rispecchiare i dati richiesti. - * - * @param $codice - * @param $id_allegato - */ - public function saveStato($codice, $id_allegato) - { - $fattura = $this->getFattura(); - - // Modifica lo stato solo se la fattura non è già stata consegnata (per evitare problemi da doppi invii) - // In realtà per le PA potrebbe esserci lo stato NE (che può contenere un esito positivo EC01 o negativo EC02) successivo alla RC, quindi aggiungo eccezione nel caso il nuovo codice della ricevuta sia NE. - if ($fattura->codice_stato_fe == 'RC' && $codice != 'EC01' && $codice != 'EC02') { - return; - } - - // Processo la ricevuta e salvo data ricezione, codice e messaggio - $descrizione = $this->xml['Destinatario']['Descrizione']; - $data = $this->xml['DataOraRicezione']; - - $fattura->data_stato_fe = $data ? date('Y-m-d H:i:s', strtotime($data)) : ''; - $fattura->codice_stato_fe = $codice; - $fattura->descrizione_ricevuta_fe = $descrizione; - $fattura->id_ricevuta_principale = $id_allegato; - - $fattura->save(); - } - - /** - * Effettua le operazioni di salvataggio della ricevuta nella fattura relativa. - */ - public function save($cambia_stato = true) - { - $name = basename($this->file); - $filename = explode('.', $name)[0]; - $pieces = explode('_', $filename); - $codice_stato = $pieces[2]; - - // Individuazione codice per il nome dell'allegato - $codice_nome = $codice_stato; - if ($codice_nome == 'NS') { - $lista_errori = $this->xml['ListaErrori']; - $errore = $lista_errori[0] ?: $lista_errori; - $codice_nome = $codice_nome.' - '.$errore['Errore']['Codice']; - } - - $upload = $this->saveAllegato($codice_nome); - - // Correzione eventuale per lo stato della fattura in Bozza - $fattura = $this->getFattura(); - if ($fattura->stato->descrizione == 'Bozza') { - $stato_emessa = Stato::where('descrizione', 'Emessa')->first(); - $fattura->stato()->associate($stato_emessa); - $fattura->save(); - } - - // Controllo per il cambio di stato FE - if ($cambia_stato) { - // In caso di Notifica Esito il codice è definito dal nodo della ricevuta - if ($codice_stato == 'NE') { - $codice_stato = $this->xml['EsitoCommittente']['Esito']; - } - - $this->saveStato($codice_stato, $upload->id); - } - } - - /** - * Restituisce la fattura identificata per la ricevuta. - * - * @return Fattura|null - */ - public function getFattura() - { - return $this->fattura; - } - - /** - * Rimuove i file temporanei relativi alla ricevuta. - */ - public function cleanup() - { - delete($this->file); - } -} diff --git a/plugins/referenti/actions.php b/plugins/referenti/actions.php deleted file mode 100755 index dbeda2089..000000000 --- a/plugins/referenti/actions.php +++ /dev/null @@ -1,69 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$operazione = filter('op'); - -switch ($operazione) { - case 'addreferente': - if (!empty(post('nome'))) { - $dbo->insert('an_referenti', [ - 'idanagrafica' => $id_parent, - 'nome' => post('nome'), - 'mansione' => post('mansione'), - 'telefono' => post('telefono'), - 'email' => post('email'), - 'idsede' => post('idsede'), - ]); - $id_record = $dbo->lastInsertedID(); - - if (isAjaxRequest() && !empty($id_record)) { - echo json_encode(['id' => $id_record, 'text' => post('nome')]); - } - - flash()->info(tr('Aggiunto nuovo referente!')); - } else { - flash()->warning(tr('Errore durante aggiunta del referente')); - } - - break; - - case 'updatereferente': - $dbo->update('an_referenti', [ - 'idanagrafica' => $id_parent, - 'nome' => post('nome'), - 'mansione' => post('mansione'), - 'telefono' => post('telefono'), - 'email' => post('email'), - 'idsede' => post('idsede'), - ], ['id' => $id_record]); - - flash()->info(tr('Salvataggio completato!')); - - break; - - case 'deletereferente': - $dbo->query('DELETE FROM `an_referenti` WHERE `id`='.prepare($id_record)); - $dbo->query('UPDATE co_preventivi SET idreferente = 0 WHERE `idreferente` = '.prepare($id_record)); - - flash()->info(tr('Referente eliminato!')); - - break; -} diff --git a/plugins/referenti/add.php b/plugins/referenti/add.php deleted file mode 100755 index d2e9cf51f..000000000 --- a/plugins/referenti/add.php +++ /dev/null @@ -1,71 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo ' -
    - - - - - - - -
    -
    - {[ "type": "text", "label": "'.tr('Nominativo').'", "name": "nome", "required": 1 ]} -
    - -
    - {[ "type": "text", "label": "'.tr('Mansione').'", "name": "mansione", "required": 1 ]} -
    -
    - -
    -
    - {[ "type": "text", "label": "'.tr('Telefono').'", "name": "telefono" ]} -
    - -
    - {[ "type": "text", "label": "'.tr('Indirizzo email').'", "name": "email" ]} -
    -
    - -
    -
    - {[ "type": "select", "label": "'.tr('Sede').'", "name": "idsede", "values": "query=SELECT 0 AS id, \'Sede legale\' AS descrizione UNION SELECT id, CONCAT_WS(\' - \', nomesede, citta) AS descrizione FROM an_sedi WHERE idanagrafica='.$id_parent.'", "value": "0", "required": 1 ]} -
    -
    - - -
    -
    - -
    -
    -
    '; -?> - diff --git a/plugins/referenti/edit.php b/plugins/referenti/edit.php deleted file mode 100755 index 8b58fd5ae..000000000 --- a/plugins/referenti/edit.php +++ /dev/null @@ -1,74 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo ' -
    - - - - - - -
    -
    - {[ "type": "text", "label": "'.tr('Nominativo').'", "name": "nome", "required": 1, "value" : "$nome$" ]} -
    - -
    - {[ "type": "text", "label": "'.tr('Mansione').'", "name": "mansione", "required": 1, "value" : "$mansione$" ]} -
    -
    - -
    -
    - {[ "type": "text", "label": "'.tr('Telefono').'", "name": "telefono", "value" : "$telefono$" ]} -
    - -
    - {[ "type": "text", "label": "'.tr('Indirizzo email').'", "name": "email", "value" : "$email$" ]} -
    -
    - -
    -
    - {[ "type": "select", "label": "'.tr('Sede').'", "name": "idsede", "values": "query=SELECT 0 AS id, \'Sede legale\' AS descrizione UNION SELECT id, CONCAT_WS(\' - \', nomesede, citta) AS descrizione FROM an_sedi WHERE idanagrafica='.$id_parent.'", "value" : "$idsede$", "required": 1 ]} -
    -
    - - -
    -
    - - '.tr('Elimina').' - - - -
    -
    -
    '; -?> - diff --git a/plugins/referenti/init.php b/plugins/referenti/init.php deleted file mode 100755 index 5be6b70c6..000000000 --- a/plugins/referenti/init.php +++ /dev/null @@ -1,24 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT * FROM an_referenti WHERE id='.prepare($id_record)); -} diff --git a/plugins/revisioni/actions.php b/plugins/revisioni/actions.php deleted file mode 100755 index 9b98fe0aa..000000000 --- a/plugins/revisioni/actions.php +++ /dev/null @@ -1,41 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$operazione = filter('op'); - -switch ($operazione) { - case 'edit_revision': - $master_revision = post('master_revision'); - $id_record = post('idrevisione'); - //Tolgo il flag default_revision da tutte le revisioni e dal record_principale - $dbo->query('UPDATE co_preventivi SET default_revision=0 WHERE master_revision='.prepare($master_revision)); - $dbo->query('UPDATE co_preventivi SET default_revision=1 WHERE id='.prepare($id_record)); - - flash()->info(tr('Revisione aggiornata!')); - break; - - case 'delete_revision': - $idrevisione = post('idrevisione'); - $dbo->query('DELETE FROM co_preventivi WHERE id='.prepare($idrevisione)); - - flash()->info(tr('Revisione eliminata!')); - break; -} diff --git a/plugins/revisioni/edit.php b/plugins/revisioni/edit.php deleted file mode 100755 index 75341039c..000000000 --- a/plugins/revisioni/edit.php +++ /dev/null @@ -1,109 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$revisione_principale = $dbo->fetchOne('SELECT master_revision FROM co_preventivi WHERE id = '.prepare($id_record)); - -$revisioni = $dbo->fetchArray('SELECT * FROM co_preventivi WHERE master_revision = '.prepare($revisione_principale['master_revision']).' OR id = '.prepare($revisione_principale['master_revision']).' ORDER BY created_at'); - -echo " -
    - - - - - - -
    - ".tr('Seleziona la spunta e clicca salva per cambiare la revisione del preventivo')." -
    - - - - - - - "; - -foreach ($revisioni as $i => $revisione) { - if ($revisione['master_revision'] == $revisione['id'] || $revisione['default_revision'] == 1) { - $disabled = 'disabled'; - } else { - $disabled = ''; - } - - if ($revisione['default_revision']) { - $cheched = 'checked'; - } else { - $cheched = ''; - } - - echo " - - - - - "; -} - -echo ' -
    #Descrizione
    - - - '.tr('(REV. _NUM_) _DESC_ creata il _DATE_ alle _TIME_', [ - '_NUM_' => ($revisione['numero_revision']), - '_DESC_' => ($revisione['descrizione_revision']), - '_DATE_' => dateFormat($revisione['created_at']), - '_TIME_' => timeFormat($revisione['created_at']), - ])." - - -
    '; - -echo " -
    -
    - -
    -
    -
    '; - -echo " -
    - - - - - -
    "; - -echo ' -'; diff --git a/plugins/rinnovi_contratti/edit.php b/plugins/rinnovi_contratti/edit.php deleted file mode 100755 index e35970a17..000000000 --- a/plugins/rinnovi_contratti/edit.php +++ /dev/null @@ -1,92 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; -include_once __DIR__.'/../init.php'; - -$id_contratto_precedente = $record['idcontratto_prev']; - -echo ' -
    - - - - -
    -
    -

    '.tr('Informazioni per rinnovo').'

    -
    - -
    - -
    -
    - {[ "type": "checkbox", "label": "'.tr('Rinnovabile').'", "name": "rinnovabile", "help": "'.tr('Il contratto è rinnovabile?').'", "value": "$rinnovabile$" ]} -
    - -
    - {[ "type": "checkbox", "label": "'.tr('Rinnovo automatico').'", "name": "rinnovo_automatico", "help": "'.tr('Il contratto è da rinnovare automaticamente alla scadenza').'", "value": "$rinnovo_automatico$", "disabled": '.($record['rinnovabile'] ? 0 : 1).' ]} -
    - - -
    - {[ "type": "number", "label": "'.tr('Preavviso per rinnovo').'", "name": "giorni_preavviso_rinnovo", "decimals": "2", "value": "$giorni_preavviso_rinnovo$", "icon-after": "giorni", "disabled": '.($record['rinnovabile'] ? 0 : 1).' ]} -
    - -
    - {[ "type": "number", "label": "'.tr('Ore rimanenti rinnovo').'", "name": "ore_preavviso_rinnovo", "decimals": "2", "value": "$ore_preavviso_rinnovo$", "icon-after": "ore", "disabled": '.($record['rinnovabile'] ? 0 : 1).', "help": "'.tr('Ore residue nel contratto prima di visualizzare una avviso per un eventuale rinnovo anticipato.').'" ]} -
    -
    - -
    - -
    -
    -
    -
    '; - -echo ' - - - - - - - '; - -while (!empty($id_contratto_precedente)) { - $rs = $dbo->fetchArray('SELECT nome, numero, data_accettazione, data_conclusione, budget, idcontratto_prev FROM co_contratti WHERE id='.prepare($id_contratto_precedente)); - - echo ' - - - - - - '; - - $id_contratto_precedente = $rs[0]['idcontratto_prev']; -} - -echo ' -
    '.tr('Descrizione').''.tr('Totale').''.tr('Data inizio').''.tr('Data conclusione').'
    - '.Modules::link($id_module, $id_contratto_precedente, tr('Contratto num. _NUM_', [ - '_NUM_' => $rs[0]['numero'], - ]).'
    '.$rs[0]['nome'].'').' -
    '.moneyFormat($rs[0]['budget']).''.Translator::dateToLocale($rs[0]['data_accettazione']).''.Translator::dateToLocale($rs[0]['data_conclusione']).'
    '; diff --git a/plugins/sedi/actions.php b/plugins/sedi/actions.php deleted file mode 100755 index ff5f30723..000000000 --- a/plugins/sedi/actions.php +++ /dev/null @@ -1,89 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$operazione = filter('op'); - -switch ($operazione) { - case 'addsede': - if (!empty(post('nomesede'))) { - $dbo->insert('an_sedi', [ - 'idanagrafica' => $id_parent, - 'nomesede' => post('nomesede'), - 'indirizzo' => post('indirizzo'), - 'codice_destinatario' => post('codice_destinatario'), - 'citta' => post('citta'), - 'cap' => post('cap'), - 'provincia' => strtoupper(post('provincia')), - 'km' => post('km'), - 'cellulare' => post('cellulare'), - 'telefono' => post('telefono'), - 'email' => post('email'), - 'id_nazione' => !empty(post('id_nazione')) ? post('id_nazione') : null, - 'idzona' => !empty(post('id_zona')) ? post('id_zona') : 0, - ]); - $id_record = $dbo->lastInsertedID(); - - if (isAjaxRequest() && !empty($id_record)) { - echo json_encode(['id' => $id_record, 'text' => post('nomesede').' - '.post('citta')]); - } - - flash()->info(tr('Aggiunta una nuova sede!')); - } else { - flash()->warning(tr('Errore durante aggiunta della sede')); - } - - break; - - case 'updatesede': - $dbo->update('an_sedi', [ - 'nomesede' => post('nomesede'), - 'indirizzo' => post('indirizzo'), - 'codice_destinatario' => post('codice_destinatario'), - 'piva' => post('piva'), - 'codice_fiscale' => post('codice_fiscale'), - 'citta' => post('citta'), - 'cap' => post('cap'), - 'provincia' => strtoupper(post('provincia')), - 'km' => post('km'), - 'cellulare' => post('cellulare'), - 'telefono' => post('telefono'), - 'email' => post('email'), - 'fax' => post('fax'), - 'id_nazione' => !empty(post('id_nazione')) ? post('id_nazione') : null, - 'idzona' => post('idzona'), - 'note' => post('note'), - 'gaddress' => post('gaddress'), - 'lat' => post('lat'), - 'lng' => post('lng'), - ], ['id' => $id_record]); - - flash()->info(tr('Salvataggio completato!')); - - break; - - case 'deletesede': - $id = filter('id'); - $dbo->query('DELETE FROM `an_sedi` WHERE `id` = '.prepare($id).''); - - flash()->info(tr('Sede eliminata!')); - - break; -} diff --git a/plugins/sedi/add.php b/plugins/sedi/add.php deleted file mode 100755 index 44b5e4ddf..000000000 --- a/plugins/sedi/add.php +++ /dev/null @@ -1,95 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo ' -
    - - - - - - - -
    -
    - {[ "type": "text", "label": "'.tr('Nome sede').'", "name": "nomesede", "required": 1 ]} -
    -
    - -
    -
    - {[ "type": "text", "label": "'.tr('Indirizzo').'", "name": "indirizzo", "required": 0 ]} -
    - -
    - {[ "type": "text", "label": "'.($record['tipo_anagrafica'] == 'Ente pubblico' ? tr('Codice unico ufficio') : tr('Codice destinatario')).'", "name": "codice_destinatario", "required": 0, "class": "text-center text-uppercase alphanumeric-mask", "value": "$codice_destinatario$", "maxlength": '.($record['tipo_anagrafica'] == 'Ente pubblico' ? '6' : '7').', "extra": "'.(empty($record['tipo_anagrafica']) || $record['tipo_anagrafica'] == 'Privato' ? 'disabled' : '').'", "help": "'.tr('Attenzione: per impostare il codice specificare prima \'Tipologia\' e \'Nazione\' dell\'anagrafica:
    • Ente pubblico (B2G/PA) - Codice Univoco Ufficio (www.indicepa.gov.it), 6 caratteri
    • Azienda (B2B) - Codice Destinatario, 7 caratteri
    • Privato (B2C) - viene utilizzato il Codice Fiscale
    ').'", "readonly": "'.intval($record['iso2'] != 'IT').'" ]} -
    - -
    - -
    -
    - {[ "type": "text", "label": "'.tr('Città').'", "name": "citta", "required": 1 ]} -
    - -
    - {[ "type": "text", "label": "'.tr('C.A.P.').'", "name": "cap" ]} -
    - -
    - {[ "type": "text", "label": "'.tr('Provincia').'", "name": "provincia", "maxlength": 2, "class": "text-center provincia-mask text-uppercase", "extra": "onkeyup=\"this.value = this.value.toUpperCase();\"" ]} -
    - -
    - {[ "type": "text", "label": "'.tr('Km').'", "name": "km" ]} -
    -
    - -
    -
    - {[ "type": "select", "label": "'.tr('Nazione').'", "name": "id_nazione", "ajax-source": "nazioni" ]} -
    -
    - {[ "type": "select", "label": "'.tr('Zona').'", "name": "idzona", "ajax-source": "zone", "placeholder": "'.tr('Nessuna zona').'", "icon-after": "add|'.Modules::get('Zone')['id'].'" ]} -
    -
    - -
    -
    - {[ "type": "text", "label": "'.tr('Cellulare').'", "name": "cellulare" ]} -
    - -
    - {[ "type": "text", "label": "'.tr('Telefono').'", "name": "telefono" ]} -
    - -
    - {[ "type": "text", "label": "'.tr('Indirizzo email').'", "name": "email" ]} -
    -
    - - -
    -
    - -
    -
    -
    '; diff --git a/plugins/sedi/edit.php b/plugins/sedi/edit.php deleted file mode 100755 index 47faa461e..000000000 --- a/plugins/sedi/edit.php +++ /dev/null @@ -1,211 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$google = setting('Google Maps API key'); - -/* -if (!empty($google)) { - echo ' -'; -} -*/ - -echo ' -
    - - - - - - -
    -
    - {[ "type": "text", "label": "'.tr('Nome sede').'", "name": "nomesede", "required": 1, "value": "$nomesede$" ]} -
    -
    - -
    -
    - {[ "type": "text", "label": "'.tr('Indirizzo').'", "name": "indirizzo", "id": "indirizzo_", "required": 0, "value": "$indirizzo$" ]} -
    - -
    - {[ "type": "text", "label": "'.($record['tipo_anagrafica'] == 'Ente pubblico' ? tr('Codice unico ufficio') : tr('Codice destinatario')).'", "name": "codice_destinatario", "required": 0, "class": "text-center text-uppercase alphanumeric-mask", "value": "$codice_destinatario$", "maxlength": '.($record['tipo_anagrafica'] == 'Ente pubblico' ? '6' : '7').', "extra": "'.(empty($record['tipo_anagrafica']) || $record['tipo_anagrafica'] == 'Privato' ? 'disabled' : '').'", "help": "'.tr('Attenzione: per impostare il codice specificare prima \'Tipologia\' e \'Nazione\' dell\'anagrafica:
    • Ente pubblico (B2G/PA) - Codice Univoco Ufficio (www.indicepa.gov.it), 6 caratteri
    • Azienda (B2B) - Codice Destinatario, 7 caratteri
    • Privato (B2C) - viene utilizzato il Codice Fiscale
    ').'", "readonly": "'.intval($record['iso2'] != 'IT').'" ]} -
    -
    - -
    -
    - {[ "type": "text", "label": "'.tr('Città').'", "name": "citta", "id": "citta_", "value": "$citta$", "required": 1 ]} -
    - -
    - {[ "type": "text", "label": "'.tr('C.A.P.').'", "name": "cap", "value": "$cap$" ]} -
    - -
    - {[ "type": "text", "label": "'.tr('Provincia').'", "name": "provincia", "value": "$provincia$", "maxlength": 2, "class": "text-center provincia-mask text-uppercase", "extra": "onkeyup=\"this.value = this.value.toUpperCase();\"" ]} -
    - -
    - {[ "type": "number", "label": "'.tr('Km').'", "name": "km", "value": "$km$" ]} -
    -
    - -
    -
    - {[ "type": "select", "label": "'.tr('Nazione').'", "name": "id_nazione", "value": "$id_nazione$", "ajax-source": "nazioni" ]} -
    - -
    - {[ "type": "text", "label": "'.tr('Telefono').'", "name": "telefono", "value": "$telefono$" ]} -
    -
    - -
    -
    - {[ "type": "text", "label": "'.tr('Fax').'", "name": "fax", "value": "$fax$" ]} -
    - -
    - {[ "type": "text", "label": "'.tr('Cellulare').'", "name": "cellulare", "value": "$cellulare$" ]} -
    -
    - -
    -
    - {[ "type": "text", "label": "'.tr('Indirizzo email').'", "name": "email", "value": "$email$" ]} -
    - -
    - {[ "type": "select", "label": "'.tr('Zona').'", "name": "idzona", "ajax-source": "zone", "value": "$idzona$", "placeholder": "'.tr('Nessuna zona').'", "icon-after": "add|'.Modules::get('Zone')['id'].'" ]} -
    -
    -
    -
    - {[ "type": "textarea", "label": "'.tr('Note').'", "name": "note", "value": "$note$" ]} -
    -
    '; - -if (!empty($google)) { - echo ' -
    -
    - {[ "type": "text", "label": "'.tr('Indirizzo Google').'", "name": "gaddress", "value": "$gaddress$", "extra": "data-geo=\'formatted_address\'" ]} -
    - -
    - {[ "type": "text", "label": "'.tr('Latitudine').'", "name": "lat", "id": "lat_", "value": "$lat$", "extra": "data-geo=\'lat\'", "class": "text-right" ]} -
    - -
    - {[ "type": "text", "label": "'.tr('Longitudine').'", "name": "lng", "id": "lng_", "value": "$lng$", "extra": "data-geo=\'lng\'", "class": "text-right" ]} -
    '; - - // Vedi su google maps - if (!empty($record['indirizzo']) || (empty($record['citta']))) { - echo ' -
    -
    -    - '; - - echo ' - -
    '; - } - - echo ' -
    '; - - if (!empty($record['gaddress']) || (!empty($record['lat']) && !empty($record['lng']))) { - echo ' -

    '; - } -} else { - echo ' -
    - '.Modules::link('Impostazioni', null, tr('Per abilitare la visualizzazione delle anagrafiche nella mappa, inserire la Google Maps API Key nella scheda Impostazioni'), true, null, true, null, '&search=Google Maps API key').'. -
    '; -} - -// Permetto eliminazione tipo sede solo se non è utilizzata da nessun'altra parte nel gestionale -$elementi = $dbo->fetchArray('SELECT `zz_user_sedi`.`id_user` AS `id` FROM `zz_user_sedi` WHERE `zz_user_sedi`.`idsede` = '.prepare($id_record).' -UNION -SELECT `an_referenti`.`id` AS `id` FROM `an_referenti` WHERE `an_referenti`.`idsede` = '.prepare($id_record).' -UNION -SELECT `co_documenti`.`id` AS `id` FROM `co_documenti` WHERE `co_documenti`.`idsede_destinazione` = '.prepare($id_record).' -ORDER BY `id`'); - -if (!empty($elementi)) { - echo ' -
    - '.tr('Ci sono _NUM_ documenti collegati', [ - '_NUM_' => count($elementi), - ]).'. -
    '; - - $disabled = 'disabled'; -} - -echo ' - -
    -
    - - - -
    -
    -
    '; - -echo ' -'; diff --git a/plugins/sedi/init.php b/plugins/sedi/init.php deleted file mode 100755 index 170575f03..000000000 --- a/plugins/sedi/init.php +++ /dev/null @@ -1,33 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -// id_record = sede -if (isset($id_record)) { - $record = $dbo->fetchOne('SELECT * FROM an_sedi WHERE id='.prepare($id_record)); - $record['lat'] = floatval($record['lat']); - $record['lng'] = floatval($record['lng']); -} - -// id_parent = anagrafica -if (isset($id_parent)) { - $record['tipo_anagrafica'] = $dbo->fetchOne('SELECT tipo FROM an_anagrafiche WHERE an_anagrafiche.idanagrafica ='.prepare($id_parent))['tipo']; - $record['iso2'] = $dbo->fetchOne('SELECT iso2 FROM an_nazioni INNER JOIN an_anagrafiche ON an_nazioni.id = an_anagrafiche.id_nazione WHERE an_anagrafiche.idanagrafica ='.prepare($id_parent))['iso2']; -} diff --git a/plugins/statistiche_anagrafiche/edit.php b/plugins/statistiche_anagrafiche/edit.php deleted file mode 100755 index 1ea0224fc..000000000 --- a/plugins/statistiche_anagrafiche/edit.php +++ /dev/null @@ -1,74 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo ' -
    -
    -
    -

    - '.tr('Periodi temporali').' -

    -
    - - -
    -
    - -
    - -
    -
    - -
    - -
    '; - -$statistiche = Modules::get('Statistiche'); - -if ($statistiche != null) { - echo ' - - - - - - '; -} - -echo ' -'; - -if ($statistiche != null) { - echo ' - '; -} diff --git a/plugins/statistiche_anagrafiche/info.php b/plugins/statistiche_anagrafiche/info.php deleted file mode 100755 index 00982bb41..000000000 --- a/plugins/statistiche_anagrafiche/info.php +++ /dev/null @@ -1,207 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Anagrafiche\Anagrafica; -use Modules\Contratti\Contratto; -use Modules\DDT\DDT; -use Modules\Fatture\Fattura; -use Modules\Interventi\Intervento; -use Modules\Ordini\Ordine; -use Modules\Preventivi\Preventivo; - -$calendar_id = filter('calendar_id'); -$start = filter('start'); -$end = filter('end'); - -$anagrafica = Anagrafica::withTrashed()->find($id_record); -if (empty($anagrafica)) { - return; -} - -// Preventivi -$preventivi = Preventivo::whereBetween('data_bozza', [$start, $end]) - ->where('idanagrafica', $id_record) - ->where('default_revision', 1) - ->get(); -$totale_preventivi = $preventivi->sum('totale_imponibile'); - -// Contratti -$contratti = Contratto::whereBetween('data_bozza', [$start, $end]) - ->where('idanagrafica', $id_record) - ->get(); -$totale_contratti = $contratti->sum('totale_imponibile'); - -// Ordini cliente -$ordini_cliente = Ordine::whereBetween('data', [$start, $end]) - ->where('idanagrafica', $id_record) - ->get(); -$totale_ordini_cliente = $ordini_cliente->sum('totale_imponibile'); - -// Interventi -$interventi = []; -// Clienti -if ($anagrafica->isTipo('Cliente')) { - $interventi = $dbo->fetchArray('SELECT in_interventi.id FROM in_interventi WHERE in_interventi.idanagrafica='.prepare($id_record).' AND data_richiesta BETWEEN '.prepare($start).' AND '.prepare($end)); -} - -// Tecnici -elseif ($anagrafica->isTipo('Tecnico')) { - $interventi = $dbo->fetchArray('SELECT in_interventi.id FROM in_interventi INNER JOIN in_interventi_tecnici ON in_interventi.id = in_interventi_tecnici.idintervento WHERE in_interventi_tecnici.idtecnico='.prepare($id_record).' AND data_richiesta BETWEEN '.prepare($start).' AND '.prepare($end)); -} - -$interventi = Intervento::whereIn('id', array_column($interventi, 'id'))->get(); -$totale_interventi = $interventi->sum('totale_imponibile'); - -// Ddt in uscita -$ddt_uscita = DDT::whereBetween('data', [$start, $end]) - ->where('idanagrafica', $id_record) - ->whereHas('tipo', function ($query) { - $query->where('dt_tipiddt.dir', '=', 'entrata'); - }) - ->get(); -$totale_ddt_uscita = $ddt_uscita->sum('totale_imponibile'); - -// Fatture di vendita -$fatture_vendita = Fattura::whereBetween('data', [$start, $end]) - ->where('idanagrafica', $id_record) - ->whereHas('tipo', function ($query) { - return $query->where('co_tipidocumento.dir', '=', 'entrata') - ->where('co_tipidocumento.reversed', '=', 0); - }) - ->get(); -$note_credito = Fattura::whereBetween('data', [$start, $end]) - ->where('idanagrafica', $id_record) - ->whereHas('tipo', function ($query) { - return $query->where('co_tipidocumento.dir', '=', 'entrata') - ->where('co_tipidocumento.reversed', '=', 1); - }) - ->get(); -$totale_fatture_vendita = $fatture_vendita->sum('totale_imponibile') - $note_credito->sum('totale_imponibile'); - -echo ' -
    -
    -

    '.tr('Dal _START_ al _END_', [ - '_START_' => dateFormat($start), - '_END_' => dateFormat($end), - ]).' - '.tr('Periodo _NUM_', [ - '_NUM_' => $calendar_id, - ]).'

    -
    - -
    - -
    -
    -
    - -
    - '.tr('Preventivi').' - '.($preventivi->count() > 0 ? ''.tr('Visualizza').' ' : '').' -
    - - '.$preventivi->count().'
    - '.moneyFormat($totale_preventivi).' -
    -
    -
    -
    - -
    -
    - -
    - '.tr('Contratti').' - '.($contratti->count() > 0 ? ''.tr('Visualizza').' ' : '').' -
    - - '.$contratti->count().'
    - '.moneyFormat($totale_contratti).' -
    -
    -
    -
    - -
    -
    - -
    - '.tr('Ordini cliente').' - '.($ordini_cliente->count() > 0 ? ''.tr('Visualizza').' ' : '').' -
    - - '.$ordini_cliente->count().'
    - '.moneyFormat($totale_ordini_cliente).' -
    -
    -
    -
    -
    - -
    -
    -
    - -
    - '.tr('Attività').' - '.($interventi->count() > 0 ? ''.tr('Visualizza').' ' : '').' -
    - - '.$interventi->count().'
    - '.moneyFormat($totale_interventi).' -
    -
    -
    -
    - -
    -
    - -
    - '.tr('Ddt in uscita').' - '.($ddt_uscita->count() > 0 ? ''.tr('Visualizza').' ' : '').' -
    - - '.$ddt_uscita->count().'
    - '.moneyFormat($totale_ddt_uscita).' -
    -
    -
    -
    - -
    -
    - -
    - '.tr('Fatture').' - '.($fatture_vendita->count() > 0 ? ''.tr('Visualizza').' ' : '').' -
    - - '.$fatture_vendita->count().'
    - '.moneyFormat($totale_fatture_vendita).' -
    -
    -
    -
    -
    - -
    -
    '; diff --git a/plugins/statistiche_articoli/edit.php b/plugins/statistiche_articoli/edit.php deleted file mode 100755 index 15716704b..000000000 --- a/plugins/statistiche_articoli/edit.php +++ /dev/null @@ -1,132 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo ' -
    -
    -
    -

    - '.tr('Periodi temporali').' -

    -
    - - -
    -
    - -
    - -
    -
    - -
    -
    -

    - - '.tr('Prezzo medio acquisto').' -

    -
    - -
    - - - - - - - - - - - - - - - - -
    #'.tr('Periodo').''.tr('Prezzo minimo').''.tr('Prezzo medio').''.tr('Prezzo massimo').''.tr('Oscillazione').''.tr('Oscillazione in %').''.tr('Andamento prezzo').'
    -
    -
    - -
    -
    -

    - - '.tr('Prezzo medio vendita').' -

    -
    - -
    - - - - - - - - - - - - - - - - -
    #'.tr('Periodo').''.tr('Prezzo minimo').''.tr('Prezzo medio').''.tr('Prezzo massimo').''.tr('Oscillazione').''.tr('Oscillazione in %').''.tr('Andamento prezzo').'
    -
    -
    '; - -$statistiche = Modules::get('Statistiche'); - -if ($statistiche != null) { - echo ' - - - - - '; -} - -echo ' - - - -'; - -if ($statistiche != null) { - echo ' - '; -} diff --git a/plugins/statistiche_articoli/js/prezzo.js b/plugins/statistiche_articoli/js/prezzo.js deleted file mode 100755 index eb348a255..000000000 --- a/plugins/statistiche_articoli/js/prezzo.js +++ /dev/null @@ -1,25 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -class Prezzo extends Table { - constructor(calendar, id, direzione){ - super(calendar, "manage_prezzi.php", { - direzione: direzione - }, id); - } -} diff --git a/plugins/statistiche_articoli/manage_prezzi.php b/plugins/statistiche_articoli/manage_prezzi.php deleted file mode 100755 index 85b0d6f15..000000000 --- a/plugins/statistiche_articoli/manage_prezzi.php +++ /dev/null @@ -1,57 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Plugins\StatisticheArticoli\Stats; - -$calendar_id = filter('calendar_id'); -$direzione = filter('direzione'); -$start = filter('start'); -$end = filter('end'); - -$prezzi = Stats::prezzi($id_record, $start, $end, $direzione); -$prezzo_min = $prezzi['min']; -$prezzo_max = $prezzi['max']; -$prezzo_medio = $prezzi['media']; - -$oscillazione = $prezzo_max['prezzo'] - $prezzo_min['prezzo']; -$oscillazione_percentuale = $prezzo_medio ? $oscillazione * 100 / $prezzo_medio : 0; - -$data_min = strtotime($prezzo_min['data']); -$data_max = strtotime($prezzo_max['data']); -if ($data_min == $data_max) { - $andamento = tr('N.D.'); -} elseif ($data_min < $data_max) { - $andamento = tr('In aumento'); -} else { - $andamento = tr('In diminuzione'); -} - -echo ' - - '.$calendar_id.' - '.dateFormat($start).' - '.dateFormat($end).' - '.moneyFormat($prezzo_min['prezzo']).' - '.moneyFormat($prezzo_medio).' - '.moneyFormat($prezzo_max['prezzo']).' - '.moneyFormat($oscillazione).' - '.Translator::numberToLocale($oscillazione_percentuale, '2').' % - '.$andamento.' -'; diff --git a/plugins/statistiche_articoli/src/Stats.php b/plugins/statistiche_articoli/src/Stats.php deleted file mode 100755 index ba016f3af..000000000 --- a/plugins/statistiche_articoli/src/Stats.php +++ /dev/null @@ -1,42 +0,0 @@ -. - */ - -namespace Plugins\StatisticheArticoli; - -class Stats -{ - public static function prezzi($id_articolo, $start, $end, $dir = 'uscita') - { - $database = database(); - - $from = 'FROM co_righe_documenti INNER JOIN co_documenti ON co_righe_documenti.iddocumento = co_documenti.id WHERE co_righe_documenti.subtotale != 0 AND co_documenti.idtipodocumento IN (SELECT id FROM co_tipidocumento WHERE dir = '.prepare($dir).') AND co_documenti.data BETWEEN '.prepare($start).' AND '.prepare($end).' AND co_righe_documenti.idarticolo='.prepare($id_articolo); - - $prezzo_medio = $database->fetchOne('SELECT (SUM(subtotale) - SUM(sconto)) / SUM(qta) AS prezzo '.$from)['prezzo']; - - $prezzo = 'SELECT (subtotale - sconto) / qta AS prezzo, co_documenti.data '.$from.' ORDER BY prezzo'; - $prezzo_min = $database->fetchOne($prezzo.' ASC'); - $prezzo_max = $database->fetchOne($prezzo.' DESC'); - - return [ - 'media' => $prezzo_medio, - 'max' => $prezzo_max, - 'min' => $prezzo_min, - ]; - } -} diff --git a/plugins/xml/AT.xsl b/plugins/xml/AT.xsl deleted file mode 100755 index 6a72cd0ca..000000000 --- a/plugins/xml/AT.xsl +++ /dev/null @@ -1,155 +0,0 @@ - - - - - - - - - - - - - - - - - - -
    -
    -
    - -
    - - File con firma elettronica - - - Versione -
    -

    Attestazione di avvenuta trasmissione della fattura con impossibilità di recapito

    - -
      -
    • - Identificativo SdI: - -
    • - -
    • - Nome File: - -
    • - -
    • - Data Ora Ricezione: - -
    • - - -
    • -

      Riferimento Archivio:

      -
        -
      • - Identificativo SdI: - -
      • -
      • - Nome File: - -
      • -
      -
    • -
      - -
    • - Destinatario: - -
    • - -
    • - Message Id: - -
    • - -
    • - Pec Message-ID: - -
    • -
      - - -
    • - Note: - -
    • -
      - -
    • - Hash del File Originale: - -
    • -
    -
    -
    -
    - -
    - - -
    -
    diff --git a/plugins/xml/DT.xsl b/plugins/xml/DT.xsl deleted file mode 100755 index 5085cb66a..000000000 --- a/plugins/xml/DT.xsl +++ /dev/null @@ -1,163 +0,0 @@ - - - - - - - - - - - - - - - - - - -
    -
    -
    - -
    - - File con firma elettronica - - - Versione -
    - - - - - Flusso semplificato - -
    -

    Notifica Decorrenza Termini

    - -
      -
    • - Identificativo SdI: - -
    • - - -
    • -

      Riferimento Fattura

      -
        -
      • - Numero Fattura: - -
      • -
      • - Anno Fattura: - -
      • - -
      • - Posizione Fattura: - -
      • -
        -
      -
    • -
      - -
    • - Nome File: - -
    • - - -
    • - Descrizione: - -
    • -
      - -
    • - Message Id: - -
    • - - -
    • - Pec Message Id: - -
    • -
      - - -
    • - Note: - -
    • -
      - -
    - -
    -
    -
    - -
    - - -
    -
    diff --git a/plugins/xml/EC.xsl b/plugins/xml/EC.xsl deleted file mode 100755 index cdd15b8da..000000000 --- a/plugins/xml/EC.xsl +++ /dev/null @@ -1,150 +0,0 @@ - - - - - - - - - - - - - - - - - - -
    -
    -
    - -
    - - File con firma elettronica - - - Versione -
    -

    Notifica Esito Committente

    - -
      -
    • - Identificativo SdI: - -
    • - - -
    • -

      Riferimento Fattura

      -
        -
      • - Numero Fattura: - -
      • -
      • - Anno Fattura: - -
      • - -
      • - Posizione Fattura: - -
      • -
        -
      -
    • -
      - -
    • - Esito: - - - - - - (Accettazione) - (Rifiuto) - -
    • - - -
    • - Descrizione: - -
    • -
      - - -
    • - Message Id Committente: - -
    • -
      -
    -
    -
    -
    - -
    - - -
    -
    diff --git a/plugins/xml/MC.xsl b/plugins/xml/MC.xsl deleted file mode 100755 index cbfe0f61e..000000000 --- a/plugins/xml/MC.xsl +++ /dev/null @@ -1,278 +0,0 @@ - - - - - - - - - - - - - - - - - - -
    -
    -
    - -
    - - File con firma digitale - - - Versione -
    -

    Notifica Mancata Consegna

    - -
      -
    • - Identificativo SdI: - -
    • - -
    • - Nome File: - -
    • - - -
    • -

      Riferimento Archivio

      -
        -
      • - Identificativo SdI: - -
      • -
      • - Nome File: - -
      • -
      -
    • -
      - - -
    • - Descrizione: - -
    • -
      - -
    • - Message Id: - -
    • - - -
    • - Pec Message Id: - -
    • -
      - - - Note: -
      - -
        - - - - -
      -
      -
    -
    -
    -
    - -
    - - -
    -
    -
    - -
    - - File con firma digitale - - - Versione -
    -

    Ricevuta di impossibilità di recapito

    - -
      -
    • - Identificativo SdI: - -
    • - -
    • - Nome File: - -
    • - - -
    • - Hash: - -
    • -
      - -
    • - Data Ora Ricezione: - -
    • - -
    • - Data Messa a Disposizione: - -
    • - - -
    • -

      Riferimento Archivio

      -
        -
      • - Identificativo SdI: - -
      • -
      • - Nome File: - -
      • -
      -
    • -
      - - -
    • - Descrizione: - -
    • -
      - -
    • - Message Id: - -
    • - - -
    • - Pec Message Id: - -
    • -
      - - -
    • - Note: - -
    • -
      -
    -
    -
    -
    - -
    - - -
    - - - - - - - - - - -
  • - - -
  • - - - - - -
    - - - - - - -
  • - -
  • -
    -
    -
    -
    -
    - -
    diff --git a/plugins/xml/MT.xsl b/plugins/xml/MT.xsl deleted file mode 100755 index 372a83122..000000000 --- a/plugins/xml/MT.xsl +++ /dev/null @@ -1,228 +0,0 @@ - - - - - - - - - - - - - - - - - - -
    -
    -
    - -
    - Versione -
    -

    Notifica Metadati

    - -
      -
    • - Identificativo SdI: - -
    • - -
    • - Nome File: - -
    • - -
    • - Codice Destinatario: - -
    • - -
    • - Formato: - -
    • - -
    • - Tentativi Invio: - -
    • - -
    • - Message Id: - -
    • - - -
    • - Note: - -
    • -
      -
    - -
    -
    -
    - -
    - - - -
    -
    -
    - -
    - Versione -
    -

    Notifica Metadati

    - -
      -
    • - Identificativo SdI: - -
    • - -
    • - Nome File: - -
    • - - -
    • - Hash: - -
    • -
      - -
    • - Codice Destinatario: - -
    • - -
    • - Formato: - -
    • - -
    • - Tentativi Invio: - -
    • - -
    • - Message Id: - -
    • - - -
    • - Note: - -
    • -
      -
    - -
    -
    -
    - -
    - - -
    - - - - - - - - - - -
  • - - -
  • - - - - - -
    - - - - - - -
  • - -
  • -
    -
    -
    -
    -
    -
    diff --git a/plugins/xml/NE.xsl b/plugins/xml/NE.xsl deleted file mode 100755 index 71b40b7b0..000000000 --- a/plugins/xml/NE.xsl +++ /dev/null @@ -1,193 +0,0 @@ - - - - - - - - - - - - - - - - - - -
    -
    -
    - -
    - - File con firma elettronica - - - Versione -
    - - - - - Flusso semplificato - -
    -

    Notifica Esito

    - -
      -
    • - Identificativo SdI: - -
    • - -
    • - Nome File: - -
    • - - - -
    • - Message Id: - -
    • -
      - - -
    • - PEC Message Id: - -
    • -
      - - -
    • - Note: - -
    • -
      - -

      Esito Committente

      - - -
    • -
    • - Identificativo SdI: - -
    • - -
    • -

      Riferimento Fattura

      -
        -
      • - Numero Fattura: - -
      • -
      • - Anno Fattura: - -
      • - -
      • - Posizione Fattura: - -
      • -
        -
      -
    • - -
      - -
    • - Esito: - - - - - - (Accettazione) - (Rifiuto) - -
    • - - -
    • - Descrizione: - -
    • -
      - - -
    • - Message Id Committente: - -
    • -
      -
    -
    -
    -
    - -
    - - -
    -
    diff --git a/plugins/xml/NS.xsl b/plugins/xml/NS.xsl deleted file mode 100755 index 33cfb1583..000000000 --- a/plugins/xml/NS.xsl +++ /dev/null @@ -1,308 +0,0 @@ - - - - - - - - - - - - - - - - - - -
    -
    -
    - -
    - - File con firma digitale - - - Versione -
    -

    Notifica Scarto

    - -
      -
    • - Identificativo SdI: - -
    • - -
    • - Nome File: - -
    • - -
    • - Data Ora Ricezione: - -
    • - - - -
    • -

      Riferimento Archivio

      -
        -
      • - Identificativo SdI: - -
      • -
      • - Nome File: - -
      • -
      -
    • -
      - - - -
    • - Message Id: - -
    • -
      - - -
    • - Pec Message Id: - -
    • -
      - - - Note: -
      - -
        - - - - -
      -
      - -
    • - - - - - - - - - - - - -
      Lista errori
      CodiceDescrizione
      -
    • -
    -
    -
    -
    - -
    - -
    -
    -
    - -
    - - File con firma digitale - - - Versione -
    -

    Ricevuta di Scarto

    - -
      -
    • - Identificativo SdI: - -
    • - -
    • - Nome File: - -
    • - - -
    • - Hash: - -
    • -
      - -
    • - Data Ora Ricezione: - -
    • - - - -
    • -

      Riferimento Archivio

      -
        -
      • - Identificativo SdI: - -
      • -
      • - Nome File: - -
      • -
      -
    • -
      - - - -
    • - Message Id: - -
    • -
      - - -
    • - Pec Message Id: - -
    • -
      - - - Note: -
      - -
        - - - - -
      -
      - -
    • - - - - - - - - - - - - -
      Lista errori
      CodiceDescrizione
      -
    • -
    -
    -
    -
    - -
    - - - -
    - - - - - - - - - - -
  • - - -
  • - - - - - -
    - - - - - - -
  • - -
  • -
    -
    -
    -
    -
    - -
    diff --git a/plugins/xml/RC.xsl b/plugins/xml/RC.xsl deleted file mode 100755 index 75609ea14..000000000 --- a/plugins/xml/RC.xsl +++ /dev/null @@ -1,294 +0,0 @@ - - - - - - - - - - - - - - - - - - -
    -
    -
    - -
    - - File con firma elettronica - - - Versione -
    - - - - - Flusso semplificato - -
    -

    Ricevuta Consegna

    - -
      -
    • - Identificativo SdI: - -
    • - -
    • - Nome File: - -
    • - -
    • - Data Ora Ricezione: - -
    • - -
    • - Data Ora Consegna: - -
    • - -
    • - Destinatario: - -
    • - - -
    • -

      Riferimento Archivio:

      -
        -
      • - Identificativo SdI: - -
      • -
      • - Nome File: - -
      • -
      -
    • -
      - -
    • - Message Id: - -
    • - -
    • - Pec Message-ID: - -
    • -
      - - - Note: -
      - -
        - - - - -
      -
      -
    -
    -
    -
    - -
    - - - -
    -
    -
    - -
    - - File con firma elettronica - - - Versione -
    - - - - - Flusso semplificato - -
    -

    Ricevuta Consegna

    - -
      -
    • - Identificativo SdI: - -
    • - -
    • - Nome File: - -
    • - - -
    • - Hash: - -
    • -
      - -
    • - Data Ora Ricezione: - -
    • - -
    • - Data Ora Consegna: - -
    • - -
    • - Destinatario: - -
    • - - -
    • -

      Riferimento Archivio:

      -
        -
      • - Identificativo SdI: - -
      • -
      • - Nome File: - -
      • -
      -
    • -
      - -
    • - Message Id: - -
    • - -
    • - Pec Message-ID: - -
    • -
      - - - Note: - - -
    -
    -
    -
    - -
    - - -
    - - - - - - - - - - -
  • - - -
  • - - - - - -
    - - - - - - -
  • - -
  • -
    -
    -
    -
    -
    - -
    diff --git a/plugins/xml/SE.xsl b/plugins/xml/SE.xsl deleted file mode 100755 index 7164a9317..000000000 --- a/plugins/xml/SE.xsl +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - - - - - - - - - - - - -
    -
    -
    - -
    - - File con firma elettronica - - - Versione -
    - -

    Scarto Esito committente

    - -
      -
    • - Identificativo SdI: - -
    • - - -
    • -

      Riferimento Fattura

      -
        -
      • - Numero Fattura: - -
      • -
      • - Anno Fattura: - -
      • - -
      • - Posizione Fattura: - -
      • -
        -
      -
    • -
      - -
    • - Scarto: - - - - - - (NOTIFICA NON CONFORME AL FORMATO) - (NOTIFICA NON AMMISSIBILE) - -
    • - -
    • - Message Id: - -
    • - - -
    • - Message-ID committente: - -
    • -
      - - -
    • - Pec Message-ID: - -
    • -
      - - -
    • - Note: - -
    • -
      -
    - -
    -
    -
    - -
    - - -
    -
    diff --git a/plugins/xml/asso-invoice.xsl b/plugins/xml/asso-invoice.xsl deleted file mode 100755 index 17199dcb5..000000000 --- a/plugins/xml/asso-invoice.xsl +++ /dev/null @@ -1,3117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - del - - - - - - CUP: - - - - CIG: - - - - - - - - - - - - - - DDT - - - del - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - () - -
    -
    - - - - - - - - - () - - - -
    - Periodo - - da - - - - - - a - - - - -
    - -
    - - - - - - - -
    - Tipo dato: - - - (dati relativi a lotti e scadenze) - - -
    - - -
    - - - - Lotto: - - - Rif. testo: - - - -
    -
    - - - - -
    - - - - Scadenza: - - - Rif. data: - - - - - - - -
    -
    - - -
    - - - - Quantità del suddetto lotto: - - - Rif. numero: - - - -
    -
    - - - -
    - -
    - - -
    - RIF.AMM. -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - -
    -
    - - - - - - - - - - - - - - - - - - -
    - -
    -
    - - - -
    - -
    -
    -
    - - - - -
    -
    - - - - - - - - -
    - - - - - - - - - - ------------------------ - - - - -
    - - - -
    - -
    - -
    - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - -
    - -
    - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - Ritenuta persone fisiche - - - Ritenuta persone giuridiche - - - Contributo INPS - - - Contributo ENASARCO - - - Contributo ENPAM - - - Altro contributo previdenziale - - - - - (!!! codice non previsto !!!) - - - - - - - - - - - - - - - - - - - - - - - - (decodifica come da modello CU) - - - - - - - - - - - - - - - - - - - - - Beneficiario
    -
    - - - IBAN -
    -
    - - - - - ABI - - - - CAB - - - - BIC - -
    -
    - - - -
    -
    - - - Codice ufficio postale - -
    -
    - - - Quietanzante - -
    -
    - - - - - Data limite pagamento anticipato - - - - - - Sconto anticipato - - -
    -
    - - - - - Data penale - - - - - - Importo penale - - - -
    -
    - - - Codice pagamento - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - -
    - -
    -
    - - - - - - - - - -
    - - - - - - - -
    - - -
    - - - - - - - - - - -
    - - - Identificativo fiscale ai fini IVA: - - - - - - -
    - -
    - - - - Codice fiscale: - - - - - - -
    - -
    - - - - Denominazione: - - - - - - -
    - -
    - - - - Cognome nome: - - - - - - - - - - - - - - - -
    - - -
    - - - - Regime fiscale: - - - - - - - - - - ordinario - - - contribuenti minimi - - - nuove iniziative produttive - Non più valido in quanto abrogato dalla legge di stabilità 2015 - - - agricoltura e attività connesse e pesca - - - vendita sali e tabacchi - - - commercio fiammiferi - - - editoria - - - gestione servizi telefonia pubblica - - - rivendita documenti di trasporto pubblico e di sosta - - - intrattenimenti, giochi e altre attività di cui alla tariffa allegata al DPR 640/72 - - - agenzie viaggi e turismo - - - agriturismo - - - vendite a domicilio - - - rivendita beni usati, oggetti d’arte, d’antiquariato o da collezione - - - agenzie di vendite all’asta di oggetti d’arte, antiquariato o da collezione - - - IVA per cassa P.A. - - - IVA per cassa - art. 32-bis, D.L. 83/2012 - - - Regime forfettario - - - altro - - - - - (!!! codice non previsto !!!) - - - - - -
    - -
    - - - -
    - - - - Indirizzo: - - - - - - - - -
    - -
    - - - - Comune: - - - - - - - - - Provincia: - - - - - - - - - -
    -
    - - - - Cap: - - - - - - - - - Nazione: - - - - - - - - -
    -
    -
    - - - - Telefono: - - - - - - - - -
    - -
    - - - - Email: - - - - - - - - - -
    - -
    - - - - Riferimento Amministrazione: - - - - - - - - - -
    - -
    - - -
    - - - Identificativo fiscale ai fini IVA: - - - - - - -
    - -
    - - - - Codice fiscale: - - - - - - -
    - - -
    - - Denominazione: - - - -
    -
    - - -
    - - Cognome nome: - - - - - - - - - - - - -
    -
    - -
    - - - - Regime fiscale: - - - - - - - - - - ordinario - - - contribuenti minimi - - - nuove iniziative produttive - Non più valido in quanto abrogato dalla legge di stabilità 2015 - - - agricoltura e attività connesse e pesca - - - vendita sali e tabacchi - - - commercio fiammiferi - - - editoria - - - gestione servizi telefonia pubblica - - - rivendita documenti di trasporto pubblico e di sosta - - - intrattenimenti, giochi e altre attività di cui alla tariffa allegata al DPR 640/72 - - - agenzie viaggi e turismo - - - agriturismo - - - vendite a domicilio - - - rivendita beni usati, oggetti d’arte, d’antiquariato o da collezione - - - agenzie di vendite all’asta di oggetti d’arte, antiquariato o da collezione - - - IVA per cassa P.A. - - - IVA per cassa - art. 32-bis, D.L. 83/2012 - - - Regime forfettario - - - altro - - - - - !!! codice non previsto !!! - - - - - -
    - - - -
    - - - - Indirizzo: - - - - - - - - -
    - -
    - - - - Comune: - - - - - - - - - Provincia: - - - - - - - - - -
    -
    - - - - Cap: - - - - - - - - - Nazione: - - - - - - - - -
    -
    -
    -
    - -
    - - - -
    - - - - - - - - - - - - - - - - - -
    - - - Identificativo fiscale ai fini IVA: - - - - - - -
    - -
    - - - - Codice fiscale: - - - - - - -
    - -
    - - - - Denominazione: - - - - - - -
    - -
    - - - - Cognome nome: - - - - - - - - - - - - - - - -
    - - -
    - - - -
    - - -
    - - -
    - - - -
    - - - - - - - -
    - -
    - - - - - - - -
    - - - Identificativo fiscale ai fini IVA: - - - - - - -
    - -
    - - - - Codice fiscale: - - - - - - -
    - -
    - - - - Denominazione: - - - - - - -
    - -
    - - - - Cognome nome: - - - - - - - - - - - - - - - -
    - - -
    - - - -
    - - - - Indirizzo: - - - - - - - - -
    - - - -
    - - - - Comune: - - - - - - - - - Provincia: - - - - - - - - - -
    -
    - - - - Cap: - - - - - - - - - Nazione: - - - - - - - - -
    -
    - - - - Pec: - - - - - -
    - - -
    -
    - - - -
    - - - Identificativo fiscale ai fini IVA: - - - - - - -
    - -
    - - - - Codice fiscale: - - - - - - -
    -
    - -
    - - - - Denominazione: - - - - - - -
    - -
    - - - - Cognome nome: - - - - - - - - - - - - - - - -
    - - - -
    - - - - Indirizzo: - - - - - - - - -
    - - - -
    - - - - Comune: - - - - - - - - - Provincia: - - - - - - - - - -
    -
    - - - - Cap: - - - - - - - - - Nazione: - - - - - - - - -
    -
    - - - - Pec: - - - - - -
    - - -
    - -
    -
    -
    -
    -
    - -
    - -
    - - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Tipologia documentoArt. 73Imposta bolloNumero documentoData documentoCodice destinatario
    - - - - - - - - - - - fattura - - - acconto/anticipo su fattura - - - acconto/anticipo su parcella - - - nota di credito - - - nota di debito - - - parcella - - - integrazione fattura reverse charge interno - - - integrazione/autofattura per acquisto servizi da estero - - - integrazione per acquisto beni intracomunitari - - - integrazione/autofattura per acquisto beni ex art.17 c.2 DPR 633/72 - - - autofattura per regolarizzazione e integrazione delle fatture - art.6 c.8 d.lgs.471/97 o art.46 c.5 D.L.331/93 - - - autofattura per splafonamento - - - estrazione beni da Deposito IVA - - - estrazione beni da Deposito IVA con versamento IVA - - - fattura differita - art.21 c.4 lett. a) - - - fattura differita - art.21 c.4 terzo periodo lett. b) - - - cessione di beni ammortizzabili e per passaggi interni - art.36 DPR 633/72 - - - fattura per autoconsumo o per cessioni gratuite senza rivalsa - - - - - fattura semplificata - - - nota di credito semplificata - - - nota di debito semplificata - - - - - (!!! codice non previsto !!!) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Indicata PEC - - - - - - - - -
    - - -
    - - - - - - - - - - - - - - - - - -
    Causale
    - - - - -
    -
    - -
    -
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    DescrizioneImposta%IVAPrezzo totale
    - - - - - - -
    - RIF.NORM. -
    -
    - -
    - - - - - - - - - - - - - - - -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Cod. articoloDescrizioneQuantitàPrezzo unitarioUMSconto o magg.%IVAPrezzo totale
    - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Dati Cassa PrevidenzialeImponibile%Contr.Ritenuta%IVAImporto
    - - - - - - - - - - - (Cassa Nazionale Previdenza e Assistenza Avvocati - e Procuratori legali) - - - (Cassa Previdenza Dottori Commercialisti) - - - (Cassa Previdenza e Assistenza Geometri) - - - (Cassa Nazionale Previdenza e Assistenza - Ingegneri e Architetti liberi profess.) - - - (Cassa Nazionale del Notariato) - - - (Cassa Nazionale Previdenza e Assistenza - Ragionieri e Periti commerciali) - - - (Ente Nazionale Assistenza Agenti e Rappresentanti - di Commercio-ENASARCO) - - - (Ente Nazionale Previdenza e Assistenza Consulenti - del Lavoro-ENPACL) - - - (Ente Nazionale Previdenza e Assistenza - Medici-ENPAM) - - - (Ente Nazionale Previdenza e Assistenza - Farmacisti-ENPAF) - - - (Ente Nazionale Previdenza e Assistenza - Veterinari-ENPAV) - - - (Ente Nazionale Previdenza e Assistenza Impiegati - dell'Agricoltura-ENPAIA) - - - (Fondo Previdenza Impiegati Imprese di Spedizione - e Agenzie Marittime) - - - (Istituto Nazionale Previdenza Giornalisti - Italiani-INPGI) - - - (Opera Nazionale Assistenza Orfani Sanitari - Italiani-ONAOSI) - - - (Cassa Autonoma Assistenza Integrativa - Giornalisti Italiani-CASAGIT) - - - (Ente Previdenza Periti Industriali e Periti - Industriali Laureati-EPPI) - - - (Ente Previdenza e Assistenza - Pluricategoriale-EPAP) - - - (Ente Nazionale Previdenza e Assistenza - Biologi-ENPAB) - - - (Ente Nazionale Previdenza e Assistenza - Professione Infermieristica-ENPAPI) - - - (Ente Nazionale Previdenza e Assistenza - Psicologi-ENPAP) - - - (INPS) - - - - - (!!! codice non previsto !!!) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - -
    - - - -
    - - - - - - - - -
    RIEPILOGHI IVA E TOTALI
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    esigibilità iva / riferimenti normativi%IVASpese accessorieArr.Totale imponibileTotale imposta
    - - - - - - - - - - - - (esigibilità immediata) - - - (esigibilità differita) - - - (scissione dei pagamenti) - - - (!!! codice non previsto !!!) - - - - - - - Esigib. non dich. (si presume immediata) - - - - - -
    - -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - - - - - - - - - -
    - Imposta bollo - - Sconto/Maggiorazione - Arr. - Totale documento -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
    - - - - - - - - - - - - - - - - - -
    Dati ritenuta d'accontoAliquota ritenutaCausale Importo
    - -
    - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Modalità pagamentoDettagliScadenzeImporto
    - - - - - - - - - - - Contanti - - - Assegno - - - Assegno circolare - - - Contanti presso Tesoreria - - - Bonifico - - - Vaglia cambiario - - - Bollettino bancario - - - Carta di pagamento - - - RID - - - RID utenze - - - RID veloce - - - RIBA - - - MAV - - - Quietanza erario - - - Giroconto su conti di contabilità speciale - - - Domiciliazione bancaria - - - Domiciliazione postale - - - Bollettino di c/c postale - - - SEPA Direct Debit - - - SEPA Direct Debit CORE - - - SEPA Direct Debit B2B - - - Trattenuta su somme già riscosse - - - PagoPA - - - - - - - - - - - - - - - - - ------------------------ - - - - - - - - - - Data termine - - - - - - gg - - - - Giorni termine - - - - -
    -
    - - - Data scadenza - - - -
    - - - - - - -
    - - -
    - - -
    - * -
    - -
    - -
    -
    - -
    - -
    - - - - -
    Allegati:
    - -
      - -
    • -
      - - - - -
      -
    • - - -
      - -
    - -
    - - - - -
    - - - -
    - -
    - - - - - -
    - - -
    - - - -
    -
    - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - -
    -
    \ No newline at end of file diff --git a/public/.htaccess b/public/.htaccess new file mode 100644 index 000000000..3aec5e27e --- /dev/null +++ b/public/.htaccess @@ -0,0 +1,21 @@ + + + Options -MultiViews -Indexes + + + RewriteEngine On + + # Handle Authorization Header + RewriteCond %{HTTP:Authorization} . + RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] + + # Redirect Trailing Slashes If Not A Folder... + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_URI} (.+)/$ + RewriteRule ^ %1 [L,R=301] + + # Send Requests To Front Controller... + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^ index.php [L] + diff --git a/files/temp/.gitkeep b/public/favicon.ico similarity index 100% rename from files/temp/.gitkeep rename to public/favicon.ico diff --git a/public/index.php b/public/index.php new file mode 100644 index 000000000..66ea93cd0 --- /dev/null +++ b/public/index.php @@ -0,0 +1,55 @@ +make(Kernel::class); + +$response = tap($kernel->handle( + $request = Request::capture() +))->send(); + +$kernel->terminate($request, $response); diff --git a/public/web.config b/public/web.config new file mode 100644 index 000000000..323482f1e --- /dev/null +++ b/public/web.config @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/reset.php b/reset.php deleted file mode 100755 index 4c73e998f..000000000 --- a/reset.php +++ /dev/null @@ -1,159 +0,0 @@ -. - */ - -$skip_permissions = true; -include_once __DIR__.'/core.php'; - -use Models\User; -use Modules\Emails\Mail; -use Modules\Emails\Template; -use Notifications\EmailNotification; - -$token = get('reset_token'); - -switch (post('op')) { - case 'reset': - $username = post('username'); - $email = post('email'); - - $database->insert('zz_logs', [ - 'username' => $username, - 'ip' => get_client_ip(), - 'stato' => Auth::getStatus()['failed']['code'], - ]); - - try { - $utente = User::where('username', $username)->where('email', $email)->first(); - if (!empty($utente)) { - $utente->reset_token = secure_random_string(); - $utente->save(); - - $template = Template::pool('Reset password'); - - $mail = Mail::build($utente, $template, $utente->id); - $mail->addReceiver($utente->email); - $mail->save(); - - $email = EmailNotification::build($mail); - $email->send(); - } - - flash()->info(tr("Se le informazioni inserite corrispondono ai dati di un utente, riceverai a breve un'email all'indirizzo collegato").'.'); - } catch (Exception $e) { - flash()->error(tr("Errore durante la gestione della richiesta: si prega di contattare l'amministratore").'.'); - } - - redirect(base_path().'/index.php'); - exit(); - break; - - case 'update': - $password = post('password'); - - $utente = User::where('reset_token', $token)->first(); - if (!empty($utente)) { - $utente->password = $password; - $utente->reset_token = null; - - $utente->save(); - } - - flash()->info(tr('Password cambiata!')); - - redirect(base_path().'/index.php'); - exit(); - break; -} - -$pageTitle = tr('Reimpostazione password'); - -include_once App::filepath('include|custom|', 'top.php'); - -// Controllo se è una beta e in caso mostro un warning -if (Auth::isBrute()) { - echo ' -
    -
    -

    '.tr('Attenzione').'

    -
    - -
    -

    '.tr('Sono stati effettuati troppi tentativi di accesso consecutivi!').'

    -

    '.tr('Tempo rimanente (in secondi)').': '.(Auth::getBruteTimeout() + 1).'

    -
    -
    - '; -} - -echo ' -
    -
    - -

    '.$pageTitle.'

    -
    - -
    '; - -if (empty($token)) { - echo ' - - -

    '.tr("Per reimpostare password, inserisci l'username con cui hai accesso al gestionale e l'indirizzo email associato all'utente").'.
    - '.tr("Se i dati inseriti risulteranno corretti riceverai un'email dove sarà indicato il link da cui potrai reimpostare la tua password").'.

    - - {[ "type": "text", "label": "'.tr('Username').'", "placeholder": "'.tr('Username').'", "name": "username", "icon-before": "", "required": 1 ]} - - {[ "type": "email", "label": "'.tr('Email').'", "placeholder": "'.tr('Email').'", "name": "email", "icon-before": "", "required": 1 ]}'; -} else { - echo ' - - -

    '.tr('Inserisci la nuova password per il tuo account').':

    - - {[ "type": "password", "label": "'.tr('Password').'", "name": "password", "required": 1, "strength": "#submit-button", "icon-before": "" ]}'; -} - -echo ' -
    - - -
    '; - -include_once App::filepath('include|custom|', 'bottom.php'); diff --git a/tests/_data/.gitkeep b/resources/css/app.css old mode 100755 new mode 100644 similarity index 100% rename from tests/_data/.gitkeep rename to resources/css/app.css diff --git a/update/2_4_17_1.sql b/resources/js/app.js similarity index 100% rename from update/2_4_17_1.sql rename to resources/js/app.js diff --git a/resources/lang/en/auth.php b/resources/lang/en/auth.php new file mode 100644 index 000000000..6598e2c06 --- /dev/null +++ b/resources/lang/en/auth.php @@ -0,0 +1,20 @@ + 'These credentials do not match our records.', + 'password' => 'The provided password is incorrect.', + 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', + +]; diff --git a/resources/lang/en/pagination.php b/resources/lang/en/pagination.php new file mode 100644 index 000000000..d48141187 --- /dev/null +++ b/resources/lang/en/pagination.php @@ -0,0 +1,19 @@ + '« Previous', + 'next' => 'Next »', + +]; diff --git a/resources/lang/en/passwords.php b/resources/lang/en/passwords.php new file mode 100644 index 000000000..2345a56b5 --- /dev/null +++ b/resources/lang/en/passwords.php @@ -0,0 +1,22 @@ + 'Your password has been reset!', + 'sent' => 'We have emailed your password reset link!', + 'throttled' => 'Please wait before retrying.', + 'token' => 'This password reset token is invalid.', + 'user' => "We can't find a user with that email address.", + +]; diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php new file mode 100644 index 000000000..6100f8080 --- /dev/null +++ b/resources/lang/en/validation.php @@ -0,0 +1,156 @@ + 'The :attribute must be accepted.', + 'active_url' => 'The :attribute is not a valid URL.', + 'after' => 'The :attribute must be a date after :date.', + 'after_or_equal' => 'The :attribute must be a date after or equal to :date.', + 'alpha' => 'The :attribute must only contain letters.', + 'alpha_dash' => 'The :attribute must only contain letters, numbers, dashes and underscores.', + 'alpha_num' => 'The :attribute must only contain letters and numbers.', + 'array' => 'The :attribute must be an array.', + 'before' => 'The :attribute must be a date before :date.', + 'before_or_equal' => 'The :attribute must be a date before or equal to :date.', + 'between' => [ + 'numeric' => 'The :attribute must be between :min and :max.', + 'file' => 'The :attribute must be between :min and :max kilobytes.', + 'string' => 'The :attribute must be between :min and :max characters.', + 'array' => 'The :attribute must have between :min and :max items.', + ], + 'boolean' => 'The :attribute field must be true or false.', + 'confirmed' => 'The :attribute confirmation does not match.', + 'current_password' => 'The password is incorrect.', + 'date' => 'The :attribute is not a valid date.', + 'date_equals' => 'The :attribute must be a date equal to :date.', + 'date_format' => 'The :attribute does not match the format :format.', + 'different' => 'The :attribute and :other must be different.', + 'digits' => 'The :attribute must be :digits digits.', + 'digits_between' => 'The :attribute must be between :min and :max digits.', + 'dimensions' => 'The :attribute has invalid image dimensions.', + 'distinct' => 'The :attribute field has a duplicate value.', + 'email' => 'The :attribute must be a valid email address.', + 'ends_with' => 'The :attribute must end with one of the following: :values.', + 'exists' => 'The selected :attribute is invalid.', + 'file' => 'The :attribute must be a file.', + 'filled' => 'The :attribute field must have a value.', + 'gt' => [ + 'numeric' => 'The :attribute must be greater than :value.', + 'file' => 'The :attribute must be greater than :value kilobytes.', + 'string' => 'The :attribute must be greater than :value characters.', + 'array' => 'The :attribute must have more than :value items.', + ], + 'gte' => [ + 'numeric' => 'The :attribute must be greater than or equal :value.', + 'file' => 'The :attribute must be greater than or equal :value kilobytes.', + 'string' => 'The :attribute must be greater than or equal :value characters.', + 'array' => 'The :attribute must have :value items or more.', + ], + 'image' => 'The :attribute must be an image.', + 'in' => 'The selected :attribute is invalid.', + 'in_array' => 'The :attribute field does not exist in :other.', + 'integer' => 'The :attribute must be an integer.', + 'ip' => 'The :attribute must be a valid IP address.', + 'ipv4' => 'The :attribute must be a valid IPv4 address.', + 'ipv6' => 'The :attribute must be a valid IPv6 address.', + 'json' => 'The :attribute must be a valid JSON string.', + 'lt' => [ + 'numeric' => 'The :attribute must be less than :value.', + 'file' => 'The :attribute must be less than :value kilobytes.', + 'string' => 'The :attribute must be less than :value characters.', + 'array' => 'The :attribute must have less than :value items.', + ], + 'lte' => [ + 'numeric' => 'The :attribute must be less than or equal :value.', + 'file' => 'The :attribute must be less than or equal :value kilobytes.', + 'string' => 'The :attribute must be less than or equal :value characters.', + 'array' => 'The :attribute must not have more than :value items.', + ], + 'max' => [ + 'numeric' => 'The :attribute must not be greater than :max.', + 'file' => 'The :attribute must not be greater than :max kilobytes.', + 'string' => 'The :attribute must not be greater than :max characters.', + 'array' => 'The :attribute must not have more than :max items.', + ], + 'mimes' => 'The :attribute must be a file of type: :values.', + 'mimetypes' => 'The :attribute must be a file of type: :values.', + 'min' => [ + 'numeric' => 'The :attribute must be at least :min.', + 'file' => 'The :attribute must be at least :min kilobytes.', + 'string' => 'The :attribute must be at least :min characters.', + 'array' => 'The :attribute must have at least :min items.', + ], + 'multiple_of' => 'The :attribute must be a multiple of :value.', + 'not_in' => 'The selected :attribute is invalid.', + 'not_regex' => 'The :attribute format is invalid.', + 'numeric' => 'The :attribute must be a number.', + 'password' => 'The password is incorrect.', + 'present' => 'The :attribute field must be present.', + 'regex' => 'The :attribute format is invalid.', + 'required' => 'The :attribute field is required.', + 'required_if' => 'The :attribute field is required when :other is :value.', + 'required_unless' => 'The :attribute field is required unless :other is in :values.', + 'required_with' => 'The :attribute field is required when :values is present.', + 'required_with_all' => 'The :attribute field is required when :values are present.', + 'required_without' => 'The :attribute field is required when :values is not present.', + 'required_without_all' => 'The :attribute field is required when none of :values are present.', + 'prohibited' => 'The :attribute field is prohibited.', + 'prohibited_if' => 'The :attribute field is prohibited when :other is :value.', + 'prohibited_unless' => 'The :attribute field is prohibited unless :other is in :values.', + 'same' => 'The :attribute and :other must match.', + 'size' => [ + 'numeric' => 'The :attribute must be :size.', + 'file' => 'The :attribute must be :size kilobytes.', + 'string' => 'The :attribute must be :size characters.', + 'array' => 'The :attribute must contain :size items.', + ], + 'starts_with' => 'The :attribute must start with one of the following: :values.', + 'string' => 'The :attribute must be a string.', + 'timezone' => 'The :attribute must be a valid timezone.', + 'unique' => 'The :attribute has already been taken.', + 'uploaded' => 'The :attribute failed to upload.', + 'url' => 'The :attribute must be a valid URL.', + 'uuid' => 'The :attribute must be a valid UUID.', + + /* + |-------------------------------------------------------------------------- + | Custom Validation Language Lines + |-------------------------------------------------------------------------- + | + | Here you may specify custom validation messages for attributes using the + | convention "attribute.rule" to name the lines. This makes it quick to + | specify a specific custom language line for a given attribute rule. + | + */ + + 'custom' => [ + 'attribute-name' => [ + 'rule-name' => 'custom-message', + ], + ], + + /* + |-------------------------------------------------------------------------- + | Custom Validation Attributes + |-------------------------------------------------------------------------- + | + | The following language lines are used to swap our attribute placeholder + | with something more reader friendly such as "E-Mail Address" instead + | of "email". This simply helps us make our message more expressive. + | + */ + + 'attributes' => [], + +]; diff --git a/routes/api.php b/routes/api.php new file mode 100644 index 000000000..bcb8b1898 --- /dev/null +++ b/routes/api.php @@ -0,0 +1,19 @@ +get('/user', function (Request $request) { + return $request->user(); +}); diff --git a/routes/channels.php b/routes/channels.php new file mode 100644 index 000000000..5d451e1fa --- /dev/null +++ b/routes/channels.php @@ -0,0 +1,18 @@ +id === (int) $id; +}); diff --git a/routes/console.php b/routes/console.php new file mode 100644 index 000000000..e05f4c9a1 --- /dev/null +++ b/routes/console.php @@ -0,0 +1,19 @@ +comment(Inspiring::quote()); +})->purpose('Display an inspiring quote'); diff --git a/routes/web.php b/routes/web.php new file mode 100644 index 000000000..75f03a47a --- /dev/null +++ b/routes/web.php @@ -0,0 +1,15 @@ + + */ + +$uri = urldecode( + parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) +); + +// This file allows us to emulate Apache's "mod_rewrite" functionality from the +// built-in PHP web server. This provides a convenient way to test a Laravel +// application without having installed a "real" web server software here. +if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) { + return false; +} + +require_once __DIR__.'/public/index.php'; diff --git a/src/AJAX.php b/src/AJAX.php deleted file mode 100755 index c92ebe43d..000000000 --- a/src/AJAX.php +++ /dev/null @@ -1,325 +0,0 @@ -. - */ - -use Util\Query; - -/** - * Classe per la gestione delle funzioni AJAX richiamabili del progetto. - * - * @since 2.4 - */ -class AJAX -{ - /** - * Controlla se è in corso una richiesta AJAX generata dal progetto. - * - * @return bool - */ - public static function isAjaxRequest() - { - return \Whoops\Util\Misc::isAjaxRequest() && filter('ajax') !== null; - } - - /** - * Individua le opzioni di selezione a partire dalla risorsa richiesta. - * - * @param string $resource - * @param array $elements - * @param mixed $search - * @param int $page - * @param int $length - * @param array $options - * - * @return array - */ - public static function select($resource, $elements = [], $search = null, $page = 0, $length = 100, $options = []) - { - if (!isset($elements)) { - $elements = []; - } - $elements = (!is_array($elements)) ? explode(',', $elements) : $elements; - - $files = self::find('ajax/select.php', false); - - // File di gestione predefinita - array_unshift($files, base_dir().'/ajax_select.php'); - - foreach ($files as $file) { - $results = self::getSelectResults($file, $resource, $elements, [ - 'offset' => $page * $length, - 'length' => $length, - ], $search, $options); - - if (isset($results)) { - break; - } - } - - $results = isset($results) ? $results : []; - - $total = array_key_exists('recordsFiltered', $results) ? $results['recordsFiltered'] : count($results); - $list = array_key_exists('results', $results) ? $results['results'] : $results; - - return [ - 'results' => $list ?: [], - 'recordsFiltered' => $total, - ]; - } - - /** - * Completa la query SQL a partire da parametri definiti e ne restituisce i risultati. - * - * @param string $query - * @param array $where - * @param array $filter - * @param array $search - * @param array $limit - * @param array $custom - * - * @return array - */ - public static function selectResults($query, $where, $filter = [], $search = [], $limit = [], $custom = []) - { - if (string_contains($query, '|filter|')) { - $query = str_replace('|filter|', !empty($filter) ? 'WHERE '.implode(' OR ', $filter) : '', $query); - } elseif (!empty($filter)) { - $where[] = '('.implode(' OR ', $filter).')'; - } - - if (!empty($search)) { - $where[] = '('.implode(' OR ', $search).')'; - } - - $query = str_replace('|where|', !empty($where) ? 'WHERE '.implode(' AND ', $where) : '', $query); - $query .= ' LIMIT '.$limit['offset'].', '.$limit['length']; - - $data = Query::executeAndCount($query); - $rows = $data['results']; - - $results = []; - foreach ($rows as $row) { - $result = $row; - foreach ($custom as $key => $value) { - $result[$key] = $row[$value]; - } - - $results[] = $result; - } - - return [ - 'results' => $results, - 'recordsFiltered' => $data['count'], - ]; - } - - /** - * Effettua la ricerca di un termine all'intero delle risorse disponibili. - * - * @param string $term - * - * @return array - */ - public static function search($term) - { - if (strlen($term) < 2) { - return; - } - - $files = self::find('ajax/search.php'); - - // File di gestione predefinita - array_unshift($files, base_dir().'/ajax_search.php'); - - $results = []; - foreach ($files as $file) { - $module_results = self::getSearchResults($file, $term); - - $results = array_merge($results, $module_results); - } - - return $results; - } - - /** - * Completa il codice HTML per la risorsa richiesta. - * - * @param string $resource - * - * @return string - */ - public static function complete($resource) - { - $files = self::find('ajax/complete.php'); - - // File di gestione predefinita - array_unshift($files, base_dir().'/ajax_complete.php'); - - foreach ($files as $file) { - $result = self::getCompleteResults($file, $resource); - if (!empty($result)) { - break; - } - } - - return $result; - } - - /** - * Individua i file per cui l'utente possiede i permessi di accesso. - * - * @param string $file - * @param bool $permissions - * - * @return array - */ - public static function find($file, $permissions = true) - { - $dirname = substr($file, 0, strrpos($file, '/') + 1); - - // Individuazione delle cartelle accessibili - if (!empty($permissions)) { - $modules = Modules::getAvailableModules(); - } else { - $modules = Models\Module::withoutGlobalScope('enabled')->get(); - } - - $modules = $modules->toArray(); - - $dirs = array_unique(array_column($modules, 'directory')); - $pieces = array_chunk($dirs, 5); - - // Individuazione dei file esistenti - $list = []; - foreach ($pieces as $piece) { - // File nativi - $files = glob(base_dir().'/modules/{'.implode(',', $piece).'}/'.$file, GLOB_BRACE); - - // File personalizzati - $custom_files = glob(base_dir().'/modules/{'.implode(',', $piece).'}/custom/'.$file, GLOB_BRACE); - - // Pulizia dei file nativi che sono stati personalizzati - foreach ($custom_files as $key => $value) { - $index = array_search(str_replace('custom/'.$dirname, $dirname, $value), $files); - if ($index !== false) { - unset($files[$index]); - } - } - - $list = array_merge($list, $files, $custom_files); - } - - asort($list); - - return $list; - } - - /** - * Ottiene i risultati del select all'interno di un file specifico (modulo). - * - * @param string $file - * @param string $resource - * @param array $elements - * @param array $limit - * @param mixed $search - * @param array $options - * - * @return array|null - */ - protected static function getSelectResults($file, $resource, $elements = [], $limit = [], $search = null, $options = []) - { - $where = []; - $filter = []; - $search_fields = []; - - $custom = [ - 'id' => 'id', - 'text' => 'descrizione', - ]; - - // Database - $dbo = $database = database(); - - // Opzioni di selezione - $superselect = $options; - - require $file; - - if (!isset($results) && !empty($query)) { - $results = self::selectResults($query, $where, $filter, $search_fields, $limit, $custom); - } - - return isset($results) ? $results : null; - } - - /** - * Ottiene i risultati della ricerca all'interno di un file specifico (modulo). - * - * @param string $file - * @param string $term - * - * @return array - */ - protected static function getSearchResults($file, $term) - { - // Database - $dbo = $database = database(); - - // Ricerca anagrafiche per ragione sociale per potere mostrare gli interventi, fatture, - // ordini, ecc della persona ricercata - $idanagrafiche = ['-1']; - $ragioni_sociali = ['-1']; - $rs = $dbo->fetchArray('SELECT idanagrafica, ragione_sociale FROM an_anagrafiche WHERE ragione_sociale LIKE "%'.$term.'%"'); - - for ($a = 0; $a < sizeof($rs); ++$a) { - $idanagrafiche[] = $rs[$a]['idanagrafica']; - $ragioni_sociali[$rs[$a]['idanagrafica']] = $rs[$a]['ragione_sociale']; - } - - $results = []; - - require $file; - - $results = (array) $results; - foreach ($results as $key => $value) { - $results[$key]['value'] = $key; - } - - return $results; - } - - /** - * Ottiene i risultati della richiesta di completamento all'interno di un file specifico (modulo). - * - * @param string $file - * @param string $resource - * - * @return string - */ - protected static function getCompleteResults($file, $resource) - { - // Database - $dbo = $database = database(); - - ob_start(); - require $file; - $result = ob_get_clean(); - - return $result; - } -} diff --git a/src/API/App/AppResource.php b/src/API/App/AppResource.php deleted file mode 100644 index 3487908e8..000000000 --- a/src/API/App/AppResource.php +++ /dev/null @@ -1,326 +0,0 @@ -. - */ - -namespace API\App; - -use API\Interfaces\CreateInterface; -use API\Interfaces\DeleteInterface; -use API\Interfaces\RetrieveInterface; -use API\Interfaces\UpdateInterface; -use API\Resource; -use Carbon\Carbon; -use Exception; -use Illuminate\Support\Collection; - -/** - * Risorsa di base per la gestione delle operazioni standard di comunicazione con l'applicazione. - * Implementa le operazioni di *retrieve* in tre fasi, e rende disponibile l'espansione per operazioni di *create*, *update* e *delete*. - */ -abstract class AppResource extends Resource implements RetrieveInterface, CreateInterface, UpdateInterface, DeleteInterface -{ - /** - * Gestisce le operazioni di *retrieve* in tre fasi: - * - Cleanup (elenco di record da rimuovere nell'applicazione); - * - Record modificati (elenco di record che sono stati aggiornati nel gestionale); - * - Dettagli del record. - * - * @param $request - * - * @return array[] - */ - public function retrieve($request) - { - $id = $request['id']; - $last_sync_at = $request['last_sync_at'] && $request['last_sync_at'] != 'undefined' ? new Carbon($request['last_sync_at']) : null; - - // Gestione delle operazioni di cleanup - if (strpos($request['resource'], 'cleanup') !== false) { - $list = []; - if (!empty($last_sync_at)) { - $list = $this->getCleanupData($last_sync_at); - } - $list = $this->forceToString($list); - - return [ - 'records' => $list, - ]; - } - - // Gestione dell'enumerazione dei record modificati - if (!isset($id)) { - $list = $this->getModifiedRecords($last_sync_at); - $list = $this->forceToString($list); - - return [ - 'records' => $list, - ]; - } - - // Gestione della visualizzazione dei dettagli del record - $details = $this->retrieveRecord($id); - $details = $this->forceToString($details); - - return [ - 'record' => $details, - ]; - } - - /** - * Gestisce la richiesta di creazione di un record, delegando le operazioni relative a *createRecord* e forzando i risultati in formato stringa. - * - * @param $request - * - * @return array - */ - public function create($request) - { - $data = $request['data']; - $response_data = $this->createRecord($data); - $response_data = $this->forceToString($response_data); - - return [ - 'id' => $response_data['id'], - 'data' => $response_data, - ]; - } - - /** - * Gestisce la richiesta di modifica di un record, delegando le operazioni relative a *updateRecord* e forzando i risultati in formato stringa. - * - * @param $request - * - * @return array - */ - public function update($request) - { - $data = $request['data']; - $response_data = $this->updateRecord($data); - $response_data = $this->forceToString($response_data); - - return [ - 'data' => $response_data, - ]; - } - - /** - * Gestisce la richiesta di eliminazione di un record, delegando le operazioni relative a *deleteRecord*. - * - * @param $request - */ - public function delete($request) - { - $id = $request['id']; - $this->deleteRecord($id); - } - - /** - * Restituisce un array contenente gli ID dei record eliminati. - * - * @param $last_sync - * - * @return array - */ - abstract public function getCleanupData($last_sync); - - /** - * Restituisce un array contenente gli ID dei record modificati e da sincronizzare. - * - * @param string $last_sync_at - * - * @return array - */ - abstract public function getModifiedRecords($last_sync_at); - - /** - * Restituisce i dettagli relativi a un singolo record identificato tramite ID. - * - * @param string $id - * - * @return array - */ - abstract public function retrieveRecord($id); - - /** - * Crea un nuovo record relativo alla risorsa, restituendo l'ID relativo ed eventuali campi da aggiornare in remoto. - * - * @param array $data - * - * @return array - */ - public function createRecord($data) - { - return []; - } - - /** - * Aggiorna un record relativo alla risorsa, restituendo eventuali campi da aggiornare in remoto. - * - * @param array $data - * - * @return array - */ - public function updateRecord($data) - { - return []; - } - - /** - * Elimina un record relativo alla risorsa. - * - * @param string $id - * - * @return void - */ - public function deleteRecord($id) - { - } - - /** - * Genera la mappatura id => updated_at necessaria per la gestione dei record modificati. - * - * @param $records - * - * @return array[] - */ - protected function mapModifiedRecords($records) - { - if ($records instanceof Collection) { - return $records->mapToGroups(function ($item, $key) { - return [$item['id'] => $item]; - })->toArray(); - } - - return array_reduce($records, function ($accumulator, $item) { - $accumulator[$item['id']] = $item; - - return $accumulator; - }) ?: []; - } - - /** - * Converte i valori numerici in stringhe. - * - * @param $list - * - * @return array - */ - protected function forceToString($list) - { - $result = []; - // Fix per la gestione dei contenuti numerici - foreach ($list as $key => $value) { - if (is_numeric($value)) { - $result[$key] = (string) $value; - } elseif (is_array($value)) { - $result[$key] = $this->forceToString($value); - } else { - $result[$key] = $value; - } - } - - return $result; - } - - /** - * Restituisce gli ID dei potenziali record mancanti, sulla base della colonna indicata e a partire da *last_sync_at*. - * - * @param string $table_name Tabella da analizzare - * @param string $column Colonna di tipo AUTO_INCREMENT della tabella - * @param null $last_sync_at - * - * @throws Exception - * - * @return array - */ - protected function getMissingIDs($table_name, $column, $last_sync_at = null) - { - $database = database(); - $db_name = $database->getDatabaseName(); - - // Ottiene il valore successivo della colonna di tipo AUTO_INCREMENT - $next_autoincrement = $database->fetchOne('SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '.prepare($table_name).' AND TABLE_SCHEMA = '.prepare($db_name))['AUTO_INCREMENT']; - - /* - // Ottiene l'ultimo record con data precedente a quella impostata - $last_id = null; - if ($last_sync_at) { - $last_record = $database->fetchOne('SELECT '.$column.' AS id FROM '.$table_name.' WHERE created_at <= '.prepare($last_sync_at).' ORDER BY '.$column.' DESC'); - $last_id = $last_record['id']; - } - */ - - // Ottiene i vuoti all'interno della sequenza AUTO_INCREMENT - $query = 'SELECT (t1.'.$column.' + 1) AS start, (SELECT MIN(t3.'.$column.') - 1 FROM '.$table_name.' t3 WHERE t3.'.$column.' > t1.'.$column.') AS end FROM '.$table_name.' t1 WHERE NOT EXISTS (SELECT t2.'.$column.' FROM '.$table_name.' t2 WHERE t2.'.$column.' = t1.'.$column.' + 1)'; - /* - if ($last_id) { - $query .= ' AND t1.'.$column.' >= '.prepare($last_id); - } - */ - $query .= ' ORDER BY start'; - $steps = $database->fetchArray($query); - - // Gestione dell'eliminazione dei primi record della tabella - $exists_first = $database->fetchNum('SELECT * FROM '.$table_name.' WHERE '.$column.' = 1'); - if (!$exists_first) { - $first = $database->fetchOne('SELECT MIN('.$column.') AS min FROM '.$table_name); - $steps[] = [ - 'start' => 1, - 'end' => $first['min'] - 1, - ]; - } - - $total = []; - foreach ($steps as $step) { - if ($step['end'] == null) { - $step['end'] = $next_autoincrement - 1; - } - - if ($step['end'] >= $step['start']) { - $total = array_merge($total, range($step['start'], $step['end'])); - } - } - - return $total; - } - - /** - * Restituisce gli ID dei record con campo *deleted_at* maggiore di *last_sync_at*. - * - * @param string $table_name Tabella da analizzare - * @param string $column Colonna di tipo AUTO_INCREMENT della tabella - * @param null $last_sync_at - * - * @throws Exception - * - * @return array - */ - protected function getDeleted($table_name, $column, $last_sync_at = null) - { - $query = 'SELECT '.$column.' AS id FROM '.$table_name.' WHERE deleted_at'; - if ($last_sync_at) { - $query .= ' > '.prepare($last_sync_at); - } else { - $query .= ' IS NOT NULL'; - } - - $results = database()->fetchArray($query); - - return array_column($results, 'id'); - } -} diff --git a/src/API/App/v1/AliquoteIva.php b/src/API/App/v1/AliquoteIva.php deleted file mode 100644 index b3d2c761e..000000000 --- a/src/API/App/v1/AliquoteIva.php +++ /dev/null @@ -1,58 +0,0 @@ -. - */ - -namespace API\App\v1; - -use API\App\AppResource; - -class AliquoteIva extends AppResource -{ - public function getCleanupData($last_sync_at) - { - return $this->getDeleted('co_iva', 'id', $last_sync_at); - } - - public function getModifiedRecords($last_sync_at) - { - $query = 'SELECT co_iva.id, co_iva.updated_at FROM co_iva WHERE deleted_at IS NULL'; - - // Filtro per data - if ($last_sync_at) { - $query .= ' AND co_iva.updated_at > '.prepare($last_sync_at); - } - - $records = database()->fetchArray($query); - - return $this->mapModifiedRecords($records); - } - - public function retrieveRecord($id) - { - // Gestione della visualizzazione dei dettagli del record - $query = 'SELECT co_iva.id, - co_iva.descrizione, - co_iva.percentuale - FROM co_iva - WHERE co_iva.id = '.prepare($id); - - $record = database()->fetchOne($query); - - return $record; - } -} diff --git a/src/API/App/v1/AllegatiInterventi.php b/src/API/App/v1/AllegatiInterventi.php deleted file mode 100644 index 7a51d567f..000000000 --- a/src/API/App/v1/AllegatiInterventi.php +++ /dev/null @@ -1,124 +0,0 @@ -. - */ - -namespace API\App\v1; - -use API\App\AppResource; -use API\Exceptions\InternalError; -use Models\Upload; -use Modules; - -class AllegatiInterventi extends AppResource -{ - public function getCleanupData($last_sync_at) - { - // Elenco di interventi di interesse - $risorsa_interventi = $this->getRisorsaInterventi(); - $interventi = $risorsa_interventi->getCleanupData($last_sync_at); - - // Elenco allegati degli interventi da rimuovere - $da_interventi = []; - if (!empty($interventi)) { - $query = 'SELECT zz_files.id FROM zz_files WHERE id_module = (SELECT `id` FROM `zz_modules` WHERE `name` = "Interventi") AND id_record IN ('.implode(',', $interventi).')'; - $allegati_interventi = database()->fetchArray($query); - $da_interventi = array_column($allegati_interventi, 'id'); - } - - // Allegati rimossi manualmente - $mancanti = $this->getMissingIDs('zz_files', 'id', $last_sync_at); - $results = array_unique(array_merge($da_interventi, $mancanti)); - - return $results; - } - - public function getModifiedRecords($last_sync_at) - { - // Elenco di interventi di interesse - $risorsa_interventi = $this->getRisorsaInterventi(); - $interventi = $risorsa_interventi->getModifiedRecords(null); - if (empty($interventi)) { - return []; - } - - $id_interventi = array_keys($interventi); - $query = 'SELECT zz_files.id, zz_files.updated_at FROM zz_files WHERE id_module = (SELECT `id` FROM `zz_modules` WHERE `name` = "Interventi") AND id_record IN ('.implode(',', $id_interventi).')'; - - // Filtro per data - if ($last_sync_at) { - $query .= ' AND zz_files.updated_at > '.prepare($last_sync_at); - } - - $records = database()->fetchArray($query); - - return $this->mapModifiedRecords($records); - } - - public function retrieveRecord($id) - { - // Gestione della visualizzazione dei dettagli del record - $upload = Upload::find($id); - - $record = [ - 'id' => $upload->id, - 'tipo' => $upload->extension, - 'nome' => $upload->name, - 'categoria' => $upload->category, - 'size' => $upload->size, - 'id_intervento' => $upload->id_record, - 'data_creazione' => $upload->created_at, - ]; - - return $record; - } - - public function createRecord($data) - { - $module = Modules::get('Interventi'); - - // Creazione del file temporaneo - $content = explode(',', $data['contenuto']); - if (count($content) < 1) { - throw new InternalError(); - } - - $file = temp_file($data['nome']); - file_put_contents($file, base64_decode($content[1])); - - // Salvataggio del file come allegato - $upload = Upload::build($file, [ - 'id_module' => $module['id'], - 'id_record' => $data['id_intervento'], - ], $data['nome'], $data['categoria']); - - // Chiusura e rimozione del file temporaneo - delete($file); - - return [ - 'id' => $upload->id, - 'tipo' => $upload->extension, - 'size' => $upload->size, - 'contenuto' => '', - ]; - } - - protected function getRisorsaInterventi() - { - return new Interventi(); - } -} diff --git a/src/API/App/v1/Articoli.php b/src/API/App/v1/Articoli.php deleted file mode 100644 index 686aaeaa3..000000000 --- a/src/API/App/v1/Articoli.php +++ /dev/null @@ -1,66 +0,0 @@ -. - */ - -namespace API\App\v1; - -use API\App\AppResource; - -class Articoli extends AppResource -{ - public function getCleanupData($last_sync_at) - { - return $this->getDeleted('mg_articoli', 'id', $last_sync_at); - } - - public function getModifiedRecords($last_sync_at) - { - $query = 'SELECT mg_articoli.id, mg_articoli.updated_at FROM mg_articoli WHERE deleted_at IS NULL'; - - // Filtro per data - if ($last_sync_at) { - $query .= ' AND mg_articoli.updated_at > '.prepare($last_sync_at); - } - - $records = database()->fetchArray($query); - - return $this->mapModifiedRecords($records); - } - - public function retrieveRecord($id) - { - // Gestione della visualizzazione dei dettagli del record - $query = 'SELECT mg_articoli.id AS id, - mg_articoli.codice, - mg_articoli.barcode, - mg_articoli.descrizione, - mg_articoli.prezzo_vendita, - mg_articoli.prezzo_acquisto, - mg_articoli.qta, - mg_articoli.um, - mg_articoli.idiva_vendita AS id_iva, - (SELECT nome FROM mg_categorie WHERE id = mg_articoli.id_categoria) AS categoria, - (SELECT nome FROM mg_categorie WHERE id = mg_articoli.id_sottocategoria) AS sottocategoria - FROM mg_articoli - WHERE mg_articoli.id = '.prepare($id); - - $record = database()->fetchOne($query); - - return $record; - } -} diff --git a/src/API/App/v1/Clienti.php b/src/API/App/v1/Clienti.php deleted file mode 100644 index 6e277d088..000000000 --- a/src/API/App/v1/Clienti.php +++ /dev/null @@ -1,165 +0,0 @@ -. - */ - -namespace API\App\v1; - -use API\App\AppResource; -use Modules\Anagrafiche\Anagrafica; - -class Clienti extends AppResource -{ - public function getCleanupData($last_sync_at) - { - return $this->getDeleted('an_anagrafiche', 'idanagrafica', $last_sync_at); - } - - public function getModifiedRecords($last_sync_at) - { - $parameters = []; - $query = "SELECT - an_anagrafiche.idanagrafica AS id, - an_anagrafiche.updated_at - FROM an_anagrafiche - INNER JOIN an_tipianagrafiche_anagrafiche ON an_tipianagrafiche_anagrafiche.idanagrafica = an_anagrafiche.idanagrafica - INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica = an_tipianagrafiche.idtipoanagrafica - WHERE an_tipianagrafiche.descrizione = 'Cliente' AND an_anagrafiche.deleted_at IS NULL"; - - // Sincronizzazione limitata ai Clienti con Interventi di interesse per il Tecnico corrente - $sincronizza_lavorati = setting('Sincronizza solo i Clienti per cui il Tecnico ha lavorato in passato'); - if (!empty($sincronizza_lavorati)) { - // Elenco di interventi di interesse - $risorsa_interventi = $this->getRisorsaInterventi(); - // Da applicazione, i Clienti sono sincronizzati prima degli Interventi: last_sync_at permette di identificare le stesse modifiche - $interventi = $risorsa_interventi->getModifiedRecords(null); - if (empty($interventi)) { - return []; - } - - $id_interventi = array_keys($interventi); - $query .= ' - AND an_anagrafiche.idanagrafica IN ( - SELECT idanagrafica FROM in_interventi - WHERE in_interventi.id IN ('.implode(',', $id_interventi).') - )'; - } - - // Filtro per data (solo nel caso in cui la sincronizzazione non sia totale) - if ($last_sync_at) { - $query .= ' AND an_anagrafiche.updated_at > '.prepare($last_sync_at); - } - - $records = database()->fetchArray($query, $parameters); - - return $this->mapModifiedRecords($records); - } - - public function retrieveRecord($id) - { - // Gestione della visualizzazione dei dettagli del record - $query = 'SELECT an_anagrafiche.idanagrafica AS id, - an_anagrafiche.ragione_sociale, - an_anagrafiche.tipo, - an_anagrafiche.piva AS partita_iva, - an_anagrafiche.codice_fiscale, - an_anagrafiche.indirizzo, - an_anagrafiche.indirizzo2, - an_anagrafiche.citta, - an_anagrafiche.cap, - an_anagrafiche.provincia, - an_anagrafiche.km, - IFNULL(an_anagrafiche.lat, 0.00) AS latitudine, - IFNULL(an_anagrafiche.lng, 0.00) AS longitudine, - an_nazioni.nome AS nazione, - an_anagrafiche.fax, - an_anagrafiche.telefono, - an_anagrafiche.cellulare, - an_anagrafiche.email, - an_anagrafiche.sitoweb AS sito_web, - an_anagrafiche.note, - an_anagrafiche.deleted_at, - an_anagrafiche.idtipointervento_default AS id_tipo_intervento_default - FROM an_anagrafiche - LEFT OUTER JOIN an_nazioni ON an_anagrafiche.id_nazione = an_nazioni.id - WHERE an_anagrafiche.idanagrafica = '.prepare($id); - - $record = database()->fetchOne($query); - - return $record; - } - - public function createRecord($data) - { - $ragione_sociale = $data['ragione_sociale']; - $id_tipo = [1]; - - $anagrafica = Anagrafica::build($ragione_sociale, null, null, $id_tipo); - $id_record = $anagrafica->id; - - $anagrafica->ragione_sociale = $data['ragione_sociale']; - $anagrafica->tipo = $data['tipo']; - $anagrafica->piva = $data['partita_iva']; - $anagrafica->codice_fiscale = $data['codice_fiscale']; - $anagrafica->indirizzo = $data['indirizzo']; - $anagrafica->cap = $data['cap']; - $anagrafica->citta = $data['citta']; - $anagrafica->provincia = $data['provincia']; - $anagrafica->telefono = $data['telefono']; - $anagrafica->cellulare = $data['cellulare']; - $anagrafica->email = $data['email']; - - $anagrafica->save(); - - return [ - 'id' => $id_record, - ]; - } - - public function updateRecord($data) - { - $anagrafica = Anagrafica::find($data['id']); - - $this->aggiornaRecord($anagrafica, $data); - $anagrafica->save(); - - return []; - } - - protected function getRisorsaInterventi() - { - return new Interventi(); - } - - protected function aggiornaRecord($record, $data) - { - $database = database(); - - // Aggiornamento anagrafica - $record->ragione_sociale = $data['ragione_sociale']; - $record->tipo = $data['tipo']; - $record->piva = $data['partita_iva']; - $record->codice_fiscale = $data['codice_fiscale']; - $record->indirizzo = $data['indirizzo']; - $record->cap = $data['cap']; - $record->citta = $data['citta']; - $record->provincia = $data['provincia']; - $record->telefono = $data['telefono']; - $record->cellulare = $data['cellulare']; - $record->email = $data['email']; - } -} diff --git a/src/API/App/v1/Contratti.php b/src/API/App/v1/Contratti.php deleted file mode 100644 index 39b50ac10..000000000 --- a/src/API/App/v1/Contratti.php +++ /dev/null @@ -1,85 +0,0 @@ -. - */ - -namespace API\App\v1; - -use API\App\AppResource; -use API\Interfaces\RetrieveInterface; - -class Contratti extends AppResource implements RetrieveInterface -{ - public function getCleanupData($last_sync_at) - { - $query = 'SELECT DISTINCT(co_contratti.id) AS id FROM co_contratti - INNER JOIN co_staticontratti ON co_staticontratti.id = co_contratti.idstato - WHERE co_staticontratti.is_pianificabile = 0'; - if ($last_sync_at) { - $query .= ' AND (co_contratti.updated_at > '.prepare($last_sync_at).' OR co_staticontratti.updated_at > '.prepare($last_sync_at).')'; - } - $records = database()->fetchArray($query); - - $da_stati = array_column($records, 'id'); - $mancanti = $this->getMissingIDs('co_contratti', 'id', $last_sync_at); - - $results = array_unique(array_merge($da_stati, $mancanti)); - - return $results; - } - - public function getModifiedRecords($last_sync_at) - { - $query = "SELECT - DISTINCT(co_contratti.id) AS id, - co_contratti.updated_at - FROM co_contratti - INNER JOIN co_staticontratti ON co_staticontratti.id = co_contratti.idstato - INNER JOIN an_anagrafiche ON an_anagrafiche.idanagrafica = co_contratti.idanagrafica - INNER JOIN an_tipianagrafiche_anagrafiche ON an_tipianagrafiche_anagrafiche.idanagrafica = an_anagrafiche.idanagrafica - INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica = an_tipianagrafiche.idtipoanagrafica - WHERE an_tipianagrafiche.descrizione = 'Cliente' AND co_staticontratti.is_pianificabile = 1 AND an_anagrafiche.deleted_at IS NULL"; - - // Filtro per data - if ($last_sync_at) { - $query .= ' AND co_contratti.updated_at > '.prepare($last_sync_at); - } - - $records = database()->fetchArray($query); - - return $this->mapModifiedRecords($records); - } - - public function retrieveRecord($id) - { - // Gestione della visualizzazione dei dettagli del record - $query = 'SELECT co_contratti.id, - co_contratti.idanagrafica AS id_cliente, - IF(co_contratti.idsede = 0, NULL, co_contratti.idsede) AS id_sede, - co_contratti.nome, - co_contratti.numero, - co_contratti.data_bozza, - co_staticontratti.descrizione AS stato - FROM co_contratti - INNER JOIN co_staticontratti ON co_staticontratti.id = co_contratti.idstato - WHERE co_contratti.id = '.prepare($id); - - $record = database()->fetchOne($query); - - return $record; - } -} diff --git a/src/API/App/v1/ControlloClienti.php b/src/API/App/v1/ControlloClienti.php deleted file mode 100644 index 9eb0263cf..000000000 --- a/src/API/App/v1/ControlloClienti.php +++ /dev/null @@ -1,62 +0,0 @@ -. - */ - -namespace API\App\v1; - -use API\Interfaces\RetrieveInterface; -use API\Resource; -use Modules\Anagrafiche\Anagrafica; -use Modules\Anagrafiche\Tipo; - -class ControlloClienti extends Resource implements RetrieveInterface -{ - public function retrieve($data) - { - // Ricerca per Partita IVA - $partita_iva = $data['partita_iva']; - if (!empty($partita_iva)) { - $cliente_partita_iva = Anagrafica::where('piva', $partita_iva) - ->first(); - } - - // Ricerca per Codice fiscale - $codice_fiscale = $data['codice_fiscale']; - if (!empty($codice_fiscale)) { - $cliente_codice_fiscale = Anagrafica::where('codice_fiscale', $codice_fiscale) - ->first(); - } - - $cliente = $cliente_partita_iva ?: $cliente_codice_fiscale; - - // Aggiunta tipologia Cliente se non presente nell'anagrafica trovata - if (!empty($cliente) && !$cliente->isTipo('Cliente')) { - $tipo_cliente = Tipo::where('descrizione', '=', 'Cliente')->first(); - $tipi = $cliente->tipi->pluck('idtipoanagrafica')->toArray(); - - $tipi[] = $tipo_cliente->id; - - $cliente->tipologie = $tipi; - $cliente->save(); - } - - return [ - 'id' => $cliente ? $cliente->id : '', - ]; - } -} diff --git a/src/API/App/v1/Flash/Intervento.php b/src/API/App/v1/Flash/Intervento.php deleted file mode 100644 index a659b0460..000000000 --- a/src/API/App/v1/Flash/Intervento.php +++ /dev/null @@ -1,98 +0,0 @@ -. - */ - -namespace API\App\v1\Flash; - -use API\App\v1\AllegatiInterventi; -use API\App\v1\Clienti; -use API\App\v1\Interventi; -use API\App\v1\RigheInterventi; -use API\App\v1\SessioniInterventi; -use API\Interfaces\UpdateInterface; -use API\Resource; -use Carbon\Carbon; - -class Intervento extends Resource implements UpdateInterface -{ - public function update($request) - { - // Elenco risorse API - $risorse = [ - 'cliente' => new Clienti(), - 'intervento' => new Interventi(), - - 'righe' => new RigheInterventi(), - 'sessioni' => new SessioniInterventi(), - 'allegati' => new AllegatiInterventi(), - ]; - $sezioni = array_keys($risorse); - - // Generazione record semplificati - $records = []; - foreach ($sezioni as $sezione) { - if (isset($request[$sezione][0])) { - foreach ($request[$sezione] as $record) { - $records[] = [$record, $risorse[$sezione]]; - } - } elseif (!empty($request[$sezione])) { - $records[] = [$request[$sezione], $risorse[$sezione]]; - } - } - - // Controlli sui conflitti - $conflict = false; - foreach ($records as $key => [$record, $risorsa]) { - $ultima_modifica = new Carbon($record['updated_at']); - $ultima_sincronizzazione = new Carbon($record['last_sync_at']); - if (!empty($record['last_sync_at']) && !$ultima_modifica->greaterThan($ultima_sincronizzazione)) { - unset($records[$key]); - continue; - } - - $modifiche = $risorsa->getModifiedRecords($record['last_sync_at']); - $modifiche = array_keys($modifiche); - - if (in_array($record['id'], $modifiche)) { - $conflict = true; - break; - } - } - - // Messaggio di conflitto in caso di problematica riscontrata - if ($conflict) { - return [ - 'status' => 200, - 'message' => 'CONFLICT', - ]; - } - - // Salvataggio delle modifiche - foreach ($records as [$record, $risorsa]) { - if (!empty($record['deleted_at'])) { - $risorsa->deleteRecord($record['id']); - } elseif (!empty($record['remote_id'])) { - $risorsa->updateRecord($record); - } else { - $risorsa->createRecord($record); - } - } - - return []; - } -} diff --git a/src/API/App/v1/Impianti.php b/src/API/App/v1/Impianti.php deleted file mode 100644 index ab491d282..000000000 --- a/src/API/App/v1/Impianti.php +++ /dev/null @@ -1,76 +0,0 @@ -. - */ - -namespace API\App\v1; - -use API\App\AppResource; -use Illuminate\Database\Eloquent\Builder; -use Modules\Impianti\Impianto; - -class Impianti extends AppResource -{ - public function getCleanupData($last_sync_at) - { - return $this->getMissingIDs('my_impianti', 'id', $last_sync_at); - } - - public function getModifiedRecords($last_sync_at) - { - $statement = Impianto::select('id', 'updated_at') - ->whereHas('anagrafica.tipi', function (Builder $query) { - $query->where('descrizione', '=', 'Cliente'); - }); - - // Filtro per data - if ($last_sync_at) { - $statement = $statement->where('updated_at', '>', $last_sync_at); - } - - $records = $statement->get(); - - return $this->mapModifiedRecords($records); - } - - public function retrieveRecord($id) - { - // Gestione della visualizzazione dei dettagli del record - $query = 'SELECT my_impianti.id, - my_impianti.idanagrafica AS id_cliente, - my_impianti.idsede AS id_sede, - my_impianti.matricola, - my_impianti.nome, - my_impianti.descrizione, - my_impianti.data AS data_installazione, - my_impianti.proprietario, - my_impianti.ubicazione, - my_impianti.palazzo, - my_impianti.scala, - my_impianti.piano, - my_impianti.interno, - my_impianti.occupante, - my_impianti_categorie.nome AS categoria - FROM my_impianti - LEFT JOIN my_impianti_categorie ON my_impianti_categorie.id = my_impianti.id_categoria - WHERE my_impianti.id = '.prepare($id); - - $record = database()->fetchOne($query); - - return $record; - } -} diff --git a/src/API/App/v1/Impostazioni.php b/src/API/App/v1/Impostazioni.php deleted file mode 100644 index 47fec632a..000000000 --- a/src/API/App/v1/Impostazioni.php +++ /dev/null @@ -1,80 +0,0 @@ -. - */ - -namespace API\App\v1; - -use API\App\AppResource; - -class Impostazioni extends AppResource -{ - public function getCleanupData($last_sync_at) - { - return []; - } - - public function getModifiedRecords($last_sync_at) - { - $query = "SELECT zz_settings.id, zz_settings.updated_at FROM zz_settings WHERE (sezione = 'Applicazione'"; - - // Aggiunta delle impostazioni esterne alla sezione Applicazione - $impostazioni_esterne = $this->getImpostazioniEsterne(); - if (!empty($impostazioni_esterne)) { - $impostazioni = []; - foreach ($impostazioni_esterne as $imp) { - $impostazioni[] = prepare($imp); - } - - $query .= ' OR nome IN ('.implode(', ', $impostazioni).')'; - } - $query .= ')'; - - // Filtro per data - if ($last_sync_at) { - $query .= ' AND zz_settings.updated_at > '.prepare($last_sync_at); - } - - $records = database()->fetchArray($query); - - return $this->mapModifiedRecords($records); - } - - public function retrieveRecord($id) - { - // Gestione della visualizzazione dei dettagli del record - $query = 'SELECT id AS id, - nome, - valore AS contenuto, - tipo - FROM zz_settings - WHERE zz_settings.id = '.prepare($id); - - $record = database()->fetchOne($query); - - return $record; - } - - protected function getImpostazioniEsterne() - { - return [ - 'Mostra prezzi al tecnico', - "Stato dell'attività alla chiusura", - "Stato dell'attività dopo la firma", - ]; - } -} diff --git a/src/API/App/v1/Interventi.php b/src/API/App/v1/Interventi.php deleted file mode 100644 index a6c6999ce..000000000 --- a/src/API/App/v1/Interventi.php +++ /dev/null @@ -1,265 +0,0 @@ -. - */ - -namespace API\App\v1; - -use API\App\AppResource; -use Auth; -use Carbon\Carbon; -use Intervention\Image\ImageManagerStatic; -use Modules\Anagrafiche\Anagrafica; -use Modules\Interventi\Intervento; -use Modules\Interventi\Stato; -use Modules\TipiIntervento\Tipo as TipoSessione; - -class Interventi extends AppResource -{ - public function getDateDiInteresse() - { - // Periodo per selezionare gli interventi - $today = new Carbon(); - $mesi_precedenti = intval(setting('Mesi per lo storico delle Attività')); - $start = $today->copy()->subMonths($mesi_precedenti); - $end = $today->copy()->addMonth(1); - - return [ - 'today' => $today, - 'start' => $start, - 'end' => $end, - ]; - } - - public function getCleanupData($last_sync_at) - { - // Periodo per selezionare interventi - $date = $this->getDateDiInteresse(); - $start = $date['start']; - $end = $date['end']; - - $remove_end = $start->copy(); - $remove_start = $remove_end->copy()->subMonths(2); - - // Informazioni sull'utente - $id_tecnico = Auth::user()->id_anagrafica; - - $query = 'SELECT in_interventi.id FROM in_interventi WHERE - deleted_at IS NOT NULL - OR ( - in_interventi.id NOT IN ( - SELECT idintervento FROM in_interventi_tecnici - WHERE in_interventi_tecnici.idintervento = in_interventi.id - AND in_interventi_tecnici.orario_fine BETWEEN :period_start AND :period_end - AND in_interventi_tecnici.idtecnico = :id_tecnico_q1 - ) - AND in_interventi.id IN ( - SELECT idintervento FROM in_interventi_tecnici - WHERE in_interventi_tecnici.idintervento = in_interventi.id - AND in_interventi_tecnici.orario_fine BETWEEN :remove_period_start AND :remove_period_end - AND in_interventi_tecnici.idtecnico = :id_tecnico_q2 - ) - )'; - $records = database()->fetchArray($query, [ - ':period_end' => $end, - ':period_start' => $start, - ':remove_period_end' => $remove_end, - ':remove_period_start' => $remove_start, - ':id_tecnico_q1' => $id_tecnico, - ':id_tecnico_q2' => $id_tecnico, - ]); - - $interventi = array_column($records, 'id'); - $mancanti = $this->getMissingIDs('in_interventi', 'id', $last_sync_at); - - return array_merge($mancanti, $interventi); - } - - public function getModifiedRecords($last_sync_at) - { - // Periodo per selezionare interventi - $date = $this->getDateDiInteresse(); - $start = $date['start']; - $end = $date['end']; - - // Informazioni sull'utente - $id_tecnico = Auth::user()->id_anagrafica; - - $query = 'SELECT - in_interventi.id, - in_interventi.updated_at - FROM in_interventi WHERE - deleted_at IS NULL AND ( - in_interventi.id IN ( - SELECT idintervento FROM in_interventi_tecnici - WHERE in_interventi_tecnici.idintervento = in_interventi.id - AND in_interventi_tecnici.orario_fine BETWEEN :period_start AND :period_end - AND in_interventi_tecnici.idtecnico = :id_tecnico - ) - OR ( - in_interventi.id NOT IN ( - SELECT idintervento FROM in_interventi_tecnici - ) - AND in_interventi.idstatointervento IN (SELECT idstatointervento FROM in_statiintervento WHERE is_completato = 0) - ) - )'; - - // Filtro per data - // Gestione di tecnici assegnati o impianti modificati - // Possibile problematica: in caso di rimozione di un tecnico assegnato o impianto collegato, la modifica non viene rilevata - if ($last_sync_at) { - $query .= ' AND ( - in_interventi.updated_at > '.prepare($last_sync_at).' OR - in_interventi.id IN ( - SELECT idintervento FROM my_impianti_interventi WHERE my_impianti_interventi.created_at > '.prepare($last_sync_at).' - UNION SELECT id_intervento FROM in_interventi_tecnici_assegnati WHERE in_interventi_tecnici_assegnati.created_at > '.prepare($last_sync_at).' - ) - )'; - } - - $records = database()->fetchArray($query, [ - ':period_start' => $start, - ':period_end' => $end, - ':id_tecnico' => $id_tecnico, - ]); - - return $this->mapModifiedRecords($records); - } - - public function retrieveRecord($id) - { - $database = database(); - - // Gestione della visualizzazione dei dettagli del record - $query = "SELECT id, - codice, - richiesta, - data_richiesta, - data_scadenza, - descrizione, - idanagrafica AS id_cliente, - id_contratto, - id_preventivo, - idtipointervento AS id_tipo_intervento, - idstatointervento AS id_stato_intervento, - informazioniaggiuntive AS informazioni_aggiuntive, - IF(idsede_destinazione = 0, NULL, idsede_destinazione) AS id_sede, - firma_file, - IF(firma_data = '0000-00-00 00:00:00', '', firma_data) AS firma_data, - firma_nome - FROM in_interventi - WHERE in_interventi.id = ".prepare($id); - - $record = $database->fetchOne($query); - - // Individuazione degli impianti collegati - $impianti = $database->fetchArray('SELECT idimpianto AS id FROM my_impianti_interventi WHERE idintervento = '.prepare($id)); - $record['impianti'] = array_column($impianti, 'id'); - - // Individuazione dei tecnici assegnati - $tecnici = $database->fetchArray('SELECT id_tecnico AS id FROM in_interventi_tecnici_assegnati WHERE id_intervento = '.prepare($id)); - $record['tecnici_assegnati'] = array_column($tecnici, 'id'); - - return $record; - } - - public function createRecord($data) - { - $anagrafica = Anagrafica::find($data['id_cliente']); - $tipo = TipoSessione::find($data['id_tipo_intervento']); - $stato = Stato::find($data['id_stato_intervento']); - - $data_richiesta = new Carbon($data['data_richiesta']); - $intervento = Intervento::build($anagrafica, $tipo, $stato, $data_richiesta); - - $this->aggiornaRecord($intervento, $data); - $intervento->save(); - - return [ - 'id' => $intervento->id, - 'codice' => $intervento->codice, - ]; - } - - public function updateRecord($data) - { - $intervento = Intervento::find($data['id']); - - $this->aggiornaRecord($intervento, $data); - $intervento->save(); - - return []; - } - - protected function aggiornaRecord($record, $data) - { - $database = database(); - - // Aggiornamento intervento - $record->idstatointervento = $data['id_stato_intervento']; - $record->id_contratto = $data['id_contratto'] ?: null; - $record->id_preventivo = $data['id_preventivo'] ?: null; - $record->richiesta = $data['richiesta']; - $record->descrizione = $data['descrizione']; - $record->informazioniaggiuntive = $data['informazioni_aggiuntive']; - - // Salvataggio firma eventuale - if (empty($record->firma_nome) && !empty($data['firma_nome'])) { - $record->firma_nome = $data['firma_nome']; - $record->firma_data = $data['firma_data']; - - // Salvataggio fisico - $firma_file = $this->salvaFirma($data['firma_contenuto']); - $record->firma_file = $firma_file; - } - - // Aggiornamento degli impianti collegati - $database->query('DELETE FROM my_impianti_interventi WHERE idintervento = '.prepare($record->id)); - foreach ($data['impianti'] as $id_impianto) { - $database->insert('my_impianti_interventi', [ - 'idimpianto' => $id_impianto, - 'idintervento' => $record->id, - ]); - } - - // Aggiornamento dei tecnici assegnati - $database->query('DELETE FROM in_interventi_tecnici_assegnati WHERE id_intervento = '.prepare($record->id)); - $tecnici_assegnati = (array) $data['tecnici_assegnati']; - $database->sync('in_interventi_tecnici_assegnati', [ - 'id_intervento' => $record->id, - ], [ - 'id_tecnico' => $tecnici_assegnati, - ]); - } - - protected function salvaFirma($firma_base64) - { - // Salvataggio firma - $firma_file = 'firma_'.time().'.png'; - - $data = explode(',', $firma_base64); - - $img = ImageManagerStatic::make(base64_decode($data[1])); - $img->resize(680, 202, function ($constraint) { - $constraint->aspectRatio(); - }); - - $img->save(base_dir().'/files/interventi/'.$firma_file); - - return $firma_file; - } -} diff --git a/src/API/App/v1/Login.php b/src/API/App/v1/Login.php deleted file mode 100644 index d9a7ea8ed..000000000 --- a/src/API/App/v1/Login.php +++ /dev/null @@ -1,77 +0,0 @@ -. - */ - -namespace API\App\v1; - -use API\Interfaces\CreateInterface; -use API\Resource; -use API\Response; -use Auth; -use Update; - -class Login extends Resource implements CreateInterface -{ - public function create($request) - { - $database = database(); - - // Controllo sulle credenziali - if (auth()->attempt($request['username'], $request['password'])) { - $user = $this->getUser(); - $token = auth()->getToken(); - - // Informazioni sull'utente, strettamente collegato ad una anagrafica di tipo Tecnico - $utente = $database->fetchOne("SELECT - `an_anagrafiche`.`idanagrafica` AS id_anagrafica, - `an_anagrafiche`.`ragione_sociale` - FROM `zz_users` - INNER JOIN `an_anagrafiche` ON `an_anagrafiche`.`idanagrafica` = `zz_users`.`idanagrafica` - INNER JOIN an_tipianagrafiche_anagrafiche ON an_tipianagrafiche_anagrafiche.idanagrafica = an_anagrafiche.idanagrafica - INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica = an_tipianagrafiche.idtipoanagrafica - WHERE an_tipianagrafiche.descrizione = 'Tecnico' AND `an_anagrafiche`.`deleted_at` IS NULL AND `id` = :id", [ - ':id' => $user['id'], - ]); - - if (!empty($utente)) { - // Informazioni da restituire tramite l'API - $response = [ - 'id_anagrafica' => (string) $utente['id_anagrafica'], - 'ragione_sociale' => $utente['ragione_sociale'], - 'token' => $token, - 'version' => Update::getVersion(), - ]; - } else { - $response = [ - 'status' => Response::getStatus()['unauthorized']['code'], - ]; - } - } else { - $response = [ - 'status' => Response::getStatus()['unauthorized']['code'], - ]; - - // Se è in corso un brute-force, aggiunge il timeout - if (Auth::isBrute()) { - $response['timeout'] = Auth::getBruteTimeout(); - } - } - - return $response; - } -} diff --git a/src/API/App/v1/MovimentiManuali.php b/src/API/App/v1/MovimentiManuali.php deleted file mode 100644 index 13da165b7..000000000 --- a/src/API/App/v1/MovimentiManuali.php +++ /dev/null @@ -1,56 +0,0 @@ -. - */ - -namespace API\App\v1; - -use API\App\AppResource; -use Carbon\Carbon; -use Modules\Articoli\Articolo; - -class MovimentiManuali extends AppResource -{ - public function getCleanupData($last_sync_at) - { - return []; - } - - public function getModifiedRecords($last_sync_at) - { - return []; - } - - public function retrieveRecord($id) - { - return []; - } - - public function createRecord($data) - { - $articolo = Articolo::find($data['id_articolo']); - $data_movimento = new Carbon($data['created_at']); - - $id_movimento = $articolo->movimenta($data['qta'], $data['descrizione'], $data_movimento, true, [ - 'idsede' => $data['id_sede_azienda'], - ]); - - return [ - 'id' => $id_movimento, - ]; - } -} diff --git a/src/API/App/v1/Preventivi.php b/src/API/App/v1/Preventivi.php deleted file mode 100644 index 3c1754b04..000000000 --- a/src/API/App/v1/Preventivi.php +++ /dev/null @@ -1,82 +0,0 @@ -. - */ - -namespace API\App\v1; - -use API\App\AppResource; -use API\Interfaces\RetrieveInterface; - -class Preventivi extends AppResource implements RetrieveInterface -{ - public function getCleanupData($last_sync_at) - { - $query = 'SELECT DISTINCT(co_preventivi.id) AS id FROM co_preventivi - INNER JOIN co_statipreventivi ON co_statipreventivi.id = co_preventivi.idstato - WHERE co_statipreventivi.is_pianificabile = 0'; - if ($last_sync_at) { - $query .= ' AND (co_preventivi.updated_at > '.prepare($last_sync_at).' OR co_statipreventivi.updated_at > '.prepare($last_sync_at).')'; - } - $records = database()->fetchArray($query); - - $da_stati = array_column($records, 'id'); - $mancanti = $this->getMissingIDs('co_preventivi', 'id', $last_sync_at); - - $results = array_unique(array_merge($da_stati, $mancanti)); - - return $results; - } - - public function getModifiedRecords($last_sync_at) - { - $query = "SELECT DISTINCT(co_preventivi.id) AS id, co_preventivi.updated_at FROM co_preventivi - INNER JOIN co_statipreventivi ON co_statipreventivi.id = co_preventivi.idstato - INNER JOIN an_anagrafiche ON an_anagrafiche.idanagrafica = co_preventivi.idanagrafica - INNER JOIN an_tipianagrafiche_anagrafiche ON an_tipianagrafiche_anagrafiche.idanagrafica = an_anagrafiche.idanagrafica - INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica = an_tipianagrafiche.idtipoanagrafica - WHERE an_tipianagrafiche.descrizione = 'Cliente' AND co_statipreventivi.is_pianificabile = 1 AND an_anagrafiche.deleted_at IS NULL"; - - // Filtro per data - if ($last_sync_at) { - $query .= ' AND co_preventivi.updated_at > '.prepare($last_sync_at); - } - - $records = database()->fetchArray($query); - - return $this->mapModifiedRecords($records); - } - - public function retrieveRecord($id) - { - // Gestione della visualizzazione dei dettagli del record - $query = 'SELECT co_preventivi.id, - co_preventivi.idanagrafica AS id_cliente, - IF(co_preventivi.idsede = 0, NULL, co_preventivi.idsede) AS id_sede, - co_preventivi.nome, - co_preventivi.numero, - co_preventivi.data_bozza, - co_statipreventivi.descrizione AS stato - FROM co_preventivi - INNER JOIN co_statipreventivi ON co_statipreventivi.id = co_preventivi.idstato - WHERE co_preventivi.id = '.prepare($id); - - $record = database()->fetchOne($query); - - return $record; - } -} diff --git a/src/API/App/v1/RapportinoIntervento.php b/src/API/App/v1/RapportinoIntervento.php deleted file mode 100644 index 5cda04c05..000000000 --- a/src/API/App/v1/RapportinoIntervento.php +++ /dev/null @@ -1,99 +0,0 @@ -. - */ - -namespace API\App\v1; - -use API\Interfaces\CreateInterface; -use API\Interfaces\RetrieveInterface; -use API\Resource; -use Modules\Emails\Mail; -use Modules\Emails\Template; -use Notifications\EmailNotification; - -class RapportinoIntervento extends Resource implements RetrieveInterface, CreateInterface -{ - public function retrieve($request) - { - $database = database(); - $id_record = $request['id']; - - $template = Template::where('name', 'Rapportino intervento')->first(); - $module = $template->module; - $account = $template->account; - - $body = $module->replacePlaceholders($id_record, $template['body']); - $subject = $module->replacePlaceholders($id_record, $template['subject']); - $email = $module->replacePlaceholders($id_record, '{email}'); - - $prints = $database->fetchArray('SELECT id, title, EXISTS(SELECT id_print FROM em_print_template WHERE id_template = '.prepare($template['id']).' AND em_print_template.id_print = zz_prints.id) AS selected FROM zz_prints WHERE id_module = '.prepare($module->id).' AND enabled = 1'); - - return [ - 'sender' => $account['from_name'].'<'.$account['from_address'].'>', - 'email' => $email, - 'subject' => $subject, - 'body' => $body, - 'prints' => $prints, - 'read_notify' => $template->read_notify, - ]; - } - - public function create($request) - { - $data = $request['data']; - $id_record = $data['id']; - - $template = Template::where('name', 'Rapportino intervento')->first(); - $mail = Mail::build($this->getUser(), $template, $id_record); - - // Rimozione allegati predefiniti - $mail->resetPrints(); - - // Destinatari - $receivers = $data['receivers']; - foreach ($receivers as $receiver) { - $mail->addReceiver($receiver['email'], $receiver['tipo']); - } - - // Contenuti - $mail->subject = $data['subject']; - $mail->content = $data['body']; - $mail->read_notify = $data['read_notify']; - - // Stampe da allegare - $prints = $data['prints']; - foreach ($prints as $print_id) { - $mail->addPrint($print_id); - } - - $mail->save(); - - // Tentativo di invio diretto - $email = EmailNotification::build($mail); - $email_success = $email->send(); - - // Rimozione email in casi di errore - if (!$email_success) { - $mail->delete(); - } - - return [ - 'sent' => $email_success, - ]; - } -} diff --git a/src/API/App/v1/Referenti.php b/src/API/App/v1/Referenti.php deleted file mode 100644 index ab245c556..000000000 --- a/src/API/App/v1/Referenti.php +++ /dev/null @@ -1,67 +0,0 @@ -. - */ - -namespace API\App\v1; - -use API\App\AppResource; -use API\Interfaces\RetrieveInterface; - -class Referenti extends AppResource implements RetrieveInterface -{ - public function getCleanupData($last_sync_at) - { - return $this->getMissingIDs('an_referenti', 'id', $last_sync_at); - } - - public function getModifiedRecords($last_sync_at) - { - $query = "SELECT DISTINCT(an_referenti.id) AS id, an_referenti.updated_at FROM an_referenti - INNER JOIN an_anagrafiche ON an_anagrafiche.idanagrafica = an_referenti.idanagrafica - INNER JOIN an_tipianagrafiche_anagrafiche ON an_tipianagrafiche_anagrafiche.idanagrafica = an_anagrafiche.idanagrafica - INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica = an_tipianagrafiche.idtipoanagrafica - WHERE an_tipianagrafiche.descrizione = 'Cliente' AND an_anagrafiche.deleted_at IS NULL"; - - // Filtro per data - if ($last_sync_at) { - $query .= ' AND an_referenti.updated_at > '.prepare($last_sync_at); - } - - $records = database()->fetchArray($query); - - return $this->mapModifiedRecords($records); - } - - public function retrieveRecord($id) - { - // Gestione della visualizzazione dei dettagli del record - $query = 'SELECT id, - idanagrafica AS id_cliente, - IF(idsede = 0, NULL, idsede) AS id_sede, - nome, - mansione, - telefono, - email - FROM an_referenti - WHERE an_referenti.id = '.prepare($id); - - $record = database()->fetchOne($query); - - return $record; - } -} diff --git a/src/API/App/v1/Revisione.php b/src/API/App/v1/Revisione.php deleted file mode 100644 index 860308c17..000000000 --- a/src/API/App/v1/Revisione.php +++ /dev/null @@ -1,35 +0,0 @@ -. - */ - -namespace API\App\v1; - -use API\Interfaces\RetrieveInterface; -use API\Resource; - -class Revisione extends Resource implements RetrieveInterface -{ - const REVISION = '1.2'; - - public function retrieve($request) - { - return [ - 'revisione' => self::REVISION, - ]; - } -} diff --git a/src/API/App/v1/RigheInterventi.php b/src/API/App/v1/RigheInterventi.php deleted file mode 100644 index fd2c53104..000000000 --- a/src/API/App/v1/RigheInterventi.php +++ /dev/null @@ -1,243 +0,0 @@ -. - */ - -namespace API\App\v1; - -use API\App\AppResource; -use API\Exceptions\InternalError; -use Auth; -use Carbon\Carbon; -use Modules\Articoli\Articolo as ArticoloOriginale; -use Modules\Interventi\Components\Articolo; -use Modules\Interventi\Components\Riga; -use Modules\Interventi\Components\Sconto; -use Modules\Interventi\Intervento; -use UnexpectedValueException; - -class RigheInterventi extends AppResource -{ - public function getCleanupData($last_sync_at) - { - // Periodo per selezionare interventi - $today = new Carbon(); - $start = $today->copy()->subMonths(2); - $end = $today->copy()->addMonth(1); - - // Informazioni sull'utente - $user = Auth::user(); - $id_tecnico = $user->id_anagrafica; - - // Elenco di interventi di interesse - $risorsa_interventi = $this->getRisorsaInterventi(); - $interventi = $risorsa_interventi->getCleanupData($last_sync_at); - - // Elenco sessioni degli interventi da rimuovere - $da_interventi = []; - if (!empty($interventi)) { - $query = 'SELECT in_righe_interventi.id - FROM in_righe_interventi - INNER JOIN in_interventi ON in_righe_interventi.idintervento = in_interventi.id - WHERE - in_interventi.id IN ('.implode(',', $interventi).')'; - $records = database()->fetchArray($query); - - $da_interventi = array_column($records, 'id'); - } - - $mancanti = $this->getMissingIDs('in_righe_interventi', 'id', $last_sync_at); - $results = array_unique(array_merge($da_interventi, $mancanti)); - - return $results; - } - - public function getModifiedRecords($last_sync_at) - { - // Periodo per selezionare interventi - $today = new Carbon(); - $start = $today->copy()->subMonths(2); - $end = $today->copy()->addMonth(1); - - // Informazioni sull'utente - $user = Auth::user(); - $id_tecnico = $user->id_anagrafica; - - // Elenco di interventi di interesse - $risorsa_interventi = $this->getRisorsaInterventi(); - $interventi = $risorsa_interventi->getModifiedRecords(null); - if (empty($interventi)) { - return []; - } - - $id_interventi = array_keys($interventi); - $query = 'SELECT in_righe_interventi.id, in_righe_interventi.updated_at FROM in_righe_interventi WHERE in_righe_interventi.idintervento IN ('.implode(',', $id_interventi).')'; - - // Filtro per data - if ($last_sync_at) { - $query .= ' AND in_righe_interventi.updated_at > '.prepare($last_sync_at); - } - $records = database()->fetchArray($query); - - return $this->mapModifiedRecords($records); - } - - public function retrieveRecord($id) - { - // Individuazione riga tramite classi - $riga = $this->getRecord($id); - - // Generazione del record ristretto ai campi di interesse - $record = [ - 'id' => $riga->id, - 'id_intervento' => $riga->idintervento, - 'descrizione' => $riga->descrizione, - 'qta' => $riga->qta, - 'um' => $riga->um, - 'ordine' => $riga->order, - - // Caratteristiche della riga - 'id_articolo' => $riga->idarticolo, - 'is_articolo' => intval($riga->isArticolo()), - 'is_riga' => intval($riga->isRiga()), - 'is_descrizione' => intval($riga->isDescrizione()), - 'is_sconto' => intval($riga->isSconto()), - - // Campi contabili - 'costo_unitario' => $riga->costo_unitario, - 'prezzo_unitario' => $riga->prezzo_unitario, - 'tipo_sconto' => $riga->tipo_sconto, - 'sconto_percentuale' => $riga->sconto_percentuale, - 'sconto_unitario' => $riga->sconto_unitario, - 'id_iva' => $riga->idiva, - 'iva_unitaria' => $riga->iva_unitaria, - 'prezzo_unitario_ivato' => $riga->prezzo_unitario_ivato, - 'sconto_iva_unitario' => $riga->sconto_iva_unitario, - 'sconto_unitario_ivato' => $riga->sconto_unitario_ivato, - - // Campi contabili di riepilogo - 'imponibile' => $riga->imponibile, - 'sconto' => $riga->sconto, - 'totale_imponibile' => $riga->totale_imponibile, - 'iva' => $riga->iva, - 'totale' => $riga->totale, - ]; - - return $record; - } - - public function createRecord($data) - { - $intervento = Intervento::find($data['id_intervento']); - if ($data['is_articolo']) { - $originale = ArticoloOriginale::find($data['id_articolo']); - $riga = Articolo::build($intervento, $originale); - } elseif ($data['is_sconto']) { - // TODO: sconti - } else { - $riga = Riga::build($intervento); - } - - $this->aggiornaRecord($riga, $data); - $riga->save(); - - return [ - 'id' => $riga->id, - ]; - } - - public function updateRecord($data) - { - $riga = $this->getRecord($data['id']); - - $this->aggiornaRecord($riga, $data); - $riga->save(); - - return []; - } - - public function deleteRecord($id) - { - $riga = $this->getRecord($id); - $riga->delete(); - } - - protected function getRisorsaInterventi() - { - return new Interventi(); - } - - protected function getRecord($id) - { - // Individuazione delle caratteristiche del record - $data = database()->fetchOne('SELECT idintervento AS id_intervento, - IF(idarticolo IS NULL OR idarticolo = 0, 0, 1) AS is_articolo, - is_descrizione, - is_sconto - FROM in_righe_interventi WHERE in_righe_interventi.id = '.prepare($id)); - - // Individuazione riga tramite classi - $type = $this->getType($data); - $intervento = Intervento::find($data['id_intervento']); - - return $intervento->getRiga($type, $id); - } - - protected function getType($data) - { - if (!empty($data['is_sconto'])) { - $type = Sconto::class; - } elseif (!empty($data['is_articolo'])) { - $type = Articolo::class; - } else { - $type = Riga::class; - } - - return $type; - } - - protected function aggiornaRecord($record, $data) - { - $record->descrizione = $data['descrizione']; - $record->um = $data['um'] ?: null; - - if (empty($data['id_iva'])) { - if ($data['is_articolo']) { - $originale = ArticoloOriginale::find($data['id_articolo']); - $data['id_iva'] = $originale->idiva_vendita; - } else { - $data['id_iva'] = setting('Iva predefinita'); - } - } - - try { - $record->qta = $data['qta']; - } catch (UnexpectedValueException $e) { - throw new InternalError(); - } - - // Impostazione prezzo unitario - $data['prezzo_unitario'] = $data['prezzo_unitario'] ?: 0; - $record->setPrezzoUnitario($data['prezzo_unitario'], $data['id_iva']); - - // Impostazione sconto - $sconto = $data['sconto_percentuale'] ?: $data['sconto_unitario']; - if (!empty($sconto)) { - $record->setSconto($sconto, $data['tipo_sconto']); - } - } -} diff --git a/src/API/App/v1/Sedi.php b/src/API/App/v1/Sedi.php deleted file mode 100644 index 07b6ab5ab..000000000 --- a/src/API/App/v1/Sedi.php +++ /dev/null @@ -1,78 +0,0 @@ -. - */ - -namespace API\App\v1; - -use API\App\AppResource; - -class Sedi extends AppResource -{ - public function getCleanupData($last_sync_at) - { - return $this->getMissingIDs('an_sedi', 'id', $last_sync_at); - } - - public function getModifiedRecords($last_sync_at) - { - $query = "SELECT DISTINCT(an_sedi.id) AS id, an_sedi.updated_at FROM an_sedi - INNER JOIN an_anagrafiche ON an_anagrafiche.idanagrafica = an_sedi.idanagrafica - INNER JOIN an_tipianagrafiche_anagrafiche ON an_tipianagrafiche_anagrafiche.idanagrafica = an_anagrafiche.idanagrafica - INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica = an_tipianagrafiche.idtipoanagrafica - WHERE an_tipianagrafiche.descrizione = 'Cliente' AND an_anagrafiche.deleted_at IS NULL"; - - // Filtro per data - if ($last_sync_at) { - $query .= ' AND an_sedi.updated_at > '.prepare($last_sync_at); - } - - $records = database()->fetchArray($query); - - return $this->mapModifiedRecords($records); - } - - public function retrieveRecord($id) - { - // Gestione della visualizzazione dei dettagli del record - $query = 'SELECT an_sedi.id, - an_sedi.idanagrafica AS id_cliente, - an_sedi.nomesede AS nome, - an_sedi.piva AS partita_iva, - an_sedi.codice_fiscale, - an_sedi.indirizzo, - an_sedi.indirizzo2, - an_sedi.citta, - an_sedi.cap, - an_sedi.provincia, - an_sedi.km, - IFNULL(an_sedi.lat, 0.00) AS latitudine, - IFNULL(an_sedi.lng, 0.00) AS longitudine, - an_nazioni.nome AS nazione, - an_sedi.telefono, - an_sedi.cellulare, - an_sedi.fax, - an_sedi.email - FROM an_sedi - LEFT OUTER JOIN an_nazioni ON an_sedi.id_nazione = an_nazioni.id - WHERE an_sedi.id = '.prepare($id); - - $record = database()->fetchOne($query); - - return $record; - } -} diff --git a/src/API/App/v1/SediAzienda.php b/src/API/App/v1/SediAzienda.php deleted file mode 100644 index 755ff4878..000000000 --- a/src/API/App/v1/SediAzienda.php +++ /dev/null @@ -1,78 +0,0 @@ -. - */ - -namespace API\App\v1; - -use API\App\AppResource; - -class SediAzienda extends AppResource -{ - public function getCleanupData($last_sync_at) - { - return $this->getMissingIDs('an_sedi', 'id', $last_sync_at); - } - - public function getModifiedRecords($last_sync_at) - { - $query = "SELECT DISTINCT(an_sedi.id) AS id, an_sedi.updated_at FROM an_sedi - INNER JOIN an_anagrafiche ON an_anagrafiche.idanagrafica = an_sedi.idanagrafica - INNER JOIN an_tipianagrafiche_anagrafiche ON an_tipianagrafiche_anagrafiche.idanagrafica = an_anagrafiche.idanagrafica - INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica = an_tipianagrafiche.idtipoanagrafica - WHERE an_tipianagrafiche.descrizione = 'Azienda' AND an_anagrafiche.deleted_at IS NULL"; - - // Filtro per data - if ($last_sync_at) { - $query .= ' AND an_sedi.updated_at > '.prepare($last_sync_at); - } - - $records = database()->fetchArray($query); - - return $this->mapModifiedRecords($records); - } - - public function retrieveRecord($id) - { - // Gestione della visualizzazione dei dettagli del record - $query = 'SELECT an_sedi.id, - an_sedi.idanagrafica AS id_cliente, - an_sedi.nomesede AS nome, - an_sedi.piva AS partita_iva, - an_sedi.codice_fiscale, - an_sedi.indirizzo, - an_sedi.indirizzo2, - an_sedi.citta, - an_sedi.cap, - an_sedi.provincia, - an_sedi.km, - IFNULL(an_sedi.lat, 0.00) AS latitudine, - IFNULL(an_sedi.lng, 0.00) AS longitudine, - an_nazioni.nome AS nazione, - an_sedi.telefono, - an_sedi.cellulare, - an_sedi.fax, - an_sedi.email - FROM an_sedi - LEFT OUTER JOIN an_nazioni ON an_sedi.id_nazione = an_nazioni.id - WHERE an_sedi.id = '.prepare($id); - - $record = database()->fetchOne($query); - - return $record; - } -} diff --git a/src/API/App/v1/SegnalazioneBug.php b/src/API/App/v1/SegnalazioneBug.php deleted file mode 100644 index a79b8b7f1..000000000 --- a/src/API/App/v1/SegnalazioneBug.php +++ /dev/null @@ -1,76 +0,0 @@ -. - */ - -namespace API\App\v1; - -use API\Interfaces\CreateInterface; -use API\Interfaces\RetrieveInterface; -use API\Resource; -use Modules\Emails\Account; -use Notifications\EmailNotification; - -class SegnalazioneBug extends Resource implements RetrieveInterface, CreateInterface -{ - protected static $bug_email = 'info@openstamanager.com'; - - public function retrieve($request) - { - $account = Account::where('predefined', true)->first(); - - return [ - 'sender' => [ - 'name' => $account['from_name'], - 'email' => $account['from_address'], - ], - 'receiver' => self::$bug_email, - ]; - } - - public function create($request) - { - $account = Account::where('predefined', true)->first(); - - // Preparazione email - $mail = new EmailNotification($account); - - // Destinatario - $mail->AddAddress(self::$bug_email); - - // Oggetto - $mail->subject = 'Segnalazione bug App OSM '.$request['version']; - - $infos = [ - ]; - - $body = ''; - foreach ($infos as $key => $value) { - $body .= '

    '.$key.': '.$value.'

    '; - } - - // Contenuti - $mail->content = $body; - - // Tentativo di invio diretto - $email_success = $mail->send(); - - return [ - 'sent' => $email_success, - ]; - } -} diff --git a/src/API/App/v1/SessioniInterventi.php b/src/API/App/v1/SessioniInterventi.php deleted file mode 100644 index 25a3817fb..000000000 --- a/src/API/App/v1/SessioniInterventi.php +++ /dev/null @@ -1,214 +0,0 @@ -. - */ - -namespace API\App\v1; - -use API\App\AppResource; -use Auth; -use Carbon\Carbon; -use Modules\Anagrafiche\Anagrafica; -use Modules\Interventi\Components\Sessione; -use Modules\Interventi\Intervento; - -class SessioniInterventi extends AppResource -{ - public function getCleanupData($last_sync_at) - { - // Periodo per selezionare interventi - $mesi_precedenti = intval(setting('Mesi per lo storico delle Attività')); - $today = new Carbon(); - $start = $today->copy()->subMonths($mesi_precedenti); - $end = $today->copy()->addMonth(1); - - // Informazioni sull'utente - $user = Auth::user(); - $id_tecnico = $user->id_anagrafica; - - // Elenco di interventi di interesse - $risorsa_interventi = $this->getRisorsaInterventi(); - $interventi = $risorsa_interventi->getCleanupData($last_sync_at); - - // Elenco sessioni degli interventi da rimuovere - $da_interventi = []; - if (!empty($interventi)) { - $query = 'SELECT in_interventi_tecnici.id - FROM in_interventi_tecnici - INNER JOIN in_interventi ON in_interventi_tecnici.idintervento = in_interventi.id - WHERE - in_interventi.id IN ('.implode(',', $interventi).') - OR (orario_fine NOT BETWEEN :period_start AND :period_end)'; - $records = database()->fetchArray($query, [ - ':period_end' => $end, - ':period_start' => $start, - ]); - $da_interventi = array_column($records, 'id'); - } - - $mancanti = $this->getMissingIDs('in_interventi_tecnici', 'id', $last_sync_at); - - $results = array_unique(array_merge($da_interventi, $mancanti)); - - return $results; - } - - public function getModifiedRecords($last_sync_at) - { - // Periodo per selezionare interventi - $mesi_precedenti = intval(setting('Mesi per lo storico delle Attività')); - $today = new Carbon(); - $start = $today->copy()->subMonths($mesi_precedenti); - $end = $today->copy()->addMonth(1); - - // Informazioni sull'utente - $user = Auth::user(); - $id_tecnico = $user->id_anagrafica; - - // Elenco di interventi di interesse - $risorsa_interventi = $this->getRisorsaInterventi(); - $interventi = $risorsa_interventi->getModifiedRecords(null); - if (empty($interventi)) { - return []; - } - - $id_interventi = array_keys($interventi); - $query = 'SELECT in_interventi_tecnici.id - FROM in_interventi_tecnici - INNER JOIN in_interventi ON in_interventi_tecnici.idintervento = in_interventi.id - WHERE - in_interventi.id IN ('.implode(',', $id_interventi).') - AND (orario_fine BETWEEN :period_start AND :period_end)'; - - // Filtro per data - if ($last_sync_at) { - $query .= ' AND in_interventi_tecnici.updated_at > '.prepare($last_sync_at); - } - $records = database()->fetchArray($query, [ - ':period_start' => $start, - ':period_end' => $end, - ]); - - return $this->mapModifiedRecords($records); - } - - public function retrieveRecord($id) - { - // Gestione della visualizzazione dei dettagli del record - $query = "SELECT id, - idintervento AS id_intervento, - idtecnico AS id_tecnico, - idtipointervento AS id_tipo_intervento, - orario_inizio, - orario_fine, - km, - - prezzo_ore_unitario AS prezzo_orario, - IF(tipo_sconto = 'UNT', sconto_unitario, sconto_unitario * prezzo_ore_unitario / 100) AS sconto_orario, - IF(tipo_sconto = 'PRC', sconto_unitario, 0) AS sconto_orario_percentuale, - tipo_sconto AS tipo_sconto_orario, - - prezzo_km_unitario AS prezzo_chilometrico, - IF(tipo_scontokm = 'UNT', scontokm_unitario, scontokm_unitario * prezzo_km_unitario / 100) AS sconto_chilometrico, - IF(tipo_scontokm = 'PRC', scontokm_unitario, 0) AS sconto_chilometrico_percentuale, - tipo_sconto AS tipo_sconto_chilometrico, - - prezzo_dirittochiamata AS prezzo_diritto_chiamata - FROM in_interventi_tecnici - WHERE in_interventi_tecnici.id = ".prepare($id); - - $record = database()->fetchOne($query); - - return $record; - } - - public function createRecord($data) - { - // Informazioni sull'utente - $user = Auth::user(); - $id_tecnico = $user->id_anagrafica; - - // Informazioni di base - $intervento = Intervento::find($data['id_intervento']); - $anagrafica = Anagrafica::find($id_tecnico); - - // Creazione della sessione - $sessione = Sessione::build($intervento, $anagrafica, $data['orario_inizio'], $data['orario_fine']); - - $this->aggiornaSessione($sessione, $data); - $sessione->save(); - - return [ - 'id' => $sessione->id, - ]; - } - - public function updateRecord($data) - { - $sessione = Sessione::find($data['id']); - - $this->aggiornaSessione($sessione, $data); - $sessione->save(); - - return []; - } - - public function deleteRecord($id) - { - $sessione = Sessione::find($id); - $sessione->delete(); - } - - protected function getRisorsaInterventi() - { - return new Interventi(); - } - - /** - * Aggiorna i dati della sessione sulla base dei dati caricati dall'applicazione. - * - * @param $sessione - * @param $data - * - * @return array - */ - protected function aggiornaSessione($sessione, $data) - { - $id_tipo = $data['id_tipo_intervento']; - $sessione->setTipo($id_tipo); - - // Campi di base - $sessione->orario_inizio = $data['orario_inizio']; - $sessione->orario_fine = $data['orario_fine']; - $sessione->km = $data['km']; - - // Prezzi - $sessione->prezzo_ore_unitario = $data['prezzo_orario']; - $sessione->prezzo_km_unitario = $data['prezzo_chilometrico']; - $sessione->prezzo_dirittochiamata = $data['prezzo_diritto_chiamata']; - - // Sconto orario - $sessione->sconto_unitario = $data['sconto_orario_percentuale'] ?: $data['sconto_orario']; - $sessione->tipo_sconto = $data['tipo_sconto_orario']; - - // Sconto chilometrico - $sessione->scontokm_unitario = $data['sconto_chilometrico_percentuale'] ?: $data['sconto_chilometrico']; - $sessione->tipo_scontokm = $data['tipo_sconto_chilometrico']; - - return []; - } -} diff --git a/src/API/App/v1/StatiIntervento.php b/src/API/App/v1/StatiIntervento.php deleted file mode 100644 index 6dd592657..000000000 --- a/src/API/App/v1/StatiIntervento.php +++ /dev/null @@ -1,60 +0,0 @@ -. - */ - -namespace API\App\v1; - -use API\App\AppResource; - -class StatiIntervento extends AppResource -{ - public function getCleanupData($last_sync_at) - { - return $this->getDeleted('in_statiintervento', 'idstatointervento', $last_sync_at); - } - - public function getModifiedRecords($last_sync_at) - { - $query = 'SELECT in_statiintervento.idstatointervento AS id, in_statiintervento.updated_at FROM in_statiintervento'; - - // Filtro per data - if ($last_sync_at) { - $query .= ' WHERE in_statiintervento.updated_at > '.prepare($last_sync_at); - } - - $records = database()->fetchArray($query); - - return $this->mapModifiedRecords($records); - } - - public function retrieveRecord($id) - { - // Gestione della visualizzazione dei dettagli del record - $query = 'SELECT in_statiintervento.idstatointervento AS id, - in_statiintervento.codice, - in_statiintervento.descrizione, - in_statiintervento.colore, - in_statiintervento.is_completato - FROM in_statiintervento - WHERE in_statiintervento.idstatointervento = '.prepare($id); - - $record = database()->fetchOne($query); - - return $record; - } -} diff --git a/src/API/App/v1/TariffeContratti.php b/src/API/App/v1/TariffeContratti.php deleted file mode 100644 index 8b2e09d43..000000000 --- a/src/API/App/v1/TariffeContratti.php +++ /dev/null @@ -1,86 +0,0 @@ -. - */ - -namespace API\App\v1; - -use API\App\AppResource; - -class TariffeContratti extends AppResource -{ - public function getCleanupData($last_sync_at) - { - $query = 'SELECT CONCAT(idtipointervento, "-", idcontratto) AS id - FROM co_contratti_tipiintervento - INNER JOIN co_contratti ON co_contratti.id = co_contratti_tipiintervento.idcontratto - INNER JOIN co_staticontratti ON co_staticontratti.id = co_contratti.idstato - WHERE co_staticontratti.is_pianificabile = 0'; - if ($last_sync_at) { - $query .= ' AND (co_contratti.updated_at > '.prepare($last_sync_at).' OR co_staticontratti.updated_at > '.prepare($last_sync_at).')'; - } - $records = database()->fetchArray($query); - - $da_contratti = array_column($records, 'id'); - - // Le associazioni Contratti - Tariffe per tipi non sono cancellabili a database - // Per le ultime versioni, sono anzi sempre presenti! - return $da_contratti; - } - - public function getModifiedRecords($last_sync_at) - { - $query = 'SELECT - CONCAT(idtipointervento, "-", idcontratto) AS id, - co_contratti_tipiintervento.updated_at - FROM co_contratti_tipiintervento - INNER JOIN co_contratti ON co_contratti.id = co_contratti_tipiintervento.idcontratto - INNER JOIN co_staticontratti ON co_staticontratti.id = co_contratti.idstato - WHERE co_staticontratti.is_pianificabile = 1'; - - // Filtro per data - if ($last_sync_at) { - $query .= ' AND co_contratti_tipiintervento.updated_at > '.prepare($last_sync_at); - } - - $records = database()->fetchArray($query); - - return $this->mapModifiedRecords($records); - } - - public function retrieveRecord($id) - { - $pieces = explode('-', $id); - $id_tipo_intervento = $pieces[0]; - $id_contratto = $pieces[1]; - - // Gestione della visualizzazione dei dettagli del record - $query = 'SELECT CONCAT(idtipointervento, "-", idcontratto) AS id, - NULL AS id_tecnico, - idtipointervento AS id_tipo_intervento, - idcontratto AS id_contratto, - costo_ore AS prezzo_orario, - costo_km AS prezzo_chilometrico, - costo_dirittochiamata AS prezzo_diritto_chiamata - FROM co_contratti_tipiintervento - WHERE co_contratti_tipiintervento.idtipointervento = '.prepare($id_tipo_intervento).' AND co_contratti_tipiintervento.idcontratto = '.prepare($id_contratto); - - $record = database()->fetchOne($query); - - return $record; - } -} diff --git a/src/API/App/v1/TariffeTecnici.php b/src/API/App/v1/TariffeTecnici.php deleted file mode 100644 index 25f34f1b5..000000000 --- a/src/API/App/v1/TariffeTecnici.php +++ /dev/null @@ -1,62 +0,0 @@ -. - */ - -namespace API\App\v1; - -use API\App\AppResource; - -class TariffeTecnici extends AppResource -{ - public function getCleanupData($last_sync_at) - { - return $this->getMissingIDs('in_tariffe', 'id', $last_sync_at); - } - - public function getModifiedRecords($last_sync_at) - { - $query = 'SELECT id, updated_at FROM in_tariffe'; - - // Filtro per data - if ($last_sync_at) { - $query .= ' WHERE updated_at > '.prepare($last_sync_at); - } - - $records = database()->fetchArray($query); - - return $this->mapModifiedRecords($records); - } - - public function retrieveRecord($id) - { - // Gestione della visualizzazione dei dettagli del record - $query = 'SELECT id, - idtecnico AS id_tecnico, - idtipointervento AS id_tipo_intervento, - NULL AS id_contratto, - costo_ore AS prezzo_orario, - costo_km AS prezzo_chilometrico, - costo_dirittochiamata AS prezzo_diritto_chiamata - FROM in_tariffe - WHERE id = '.prepare($id); - - $record = database()->fetchOne($query); - - return $record; - } -} diff --git a/src/API/App/v1/Tecnici.php b/src/API/App/v1/Tecnici.php deleted file mode 100644 index f81c755c5..000000000 --- a/src/API/App/v1/Tecnici.php +++ /dev/null @@ -1,62 +0,0 @@ -. - */ - -namespace API\App\v1; - -use API\App\AppResource; -use Illuminate\Database\Eloquent\Builder; -use Modules\Anagrafiche\Anagrafica; - -class Tecnici extends AppResource -{ - public function getCleanupData($last_sync_at) - { - return $this->getDeleted('an_anagrafiche', 'idanagrafica', $last_sync_at); - } - - public function getModifiedRecords($last_sync_at) - { - $statement = Anagrafica::select('idanagrafica', 'updated_at') - ->whereHas('tipi', function (Builder $query) { - $query->where('descrizione', '=', 'Tecnico'); - }); - - // Filtro per data - if ($last_sync_at) { - $statement = $statement->where('updated_at', '>', $last_sync_at); - } - - $records = $statement->get(); - - return $this->mapModifiedRecords($records); - } - - public function retrieveRecord($id) - { - // Gestione della visualizzazione dei dettagli del record - $query = 'SELECT an_anagrafiche.idanagrafica AS id, - an_anagrafiche.ragione_sociale - FROM an_anagrafiche - WHERE an_anagrafiche.idanagrafica = '.prepare($id); - - $record = database()->fetchOne($query); - - return $record; - } -} diff --git a/src/API/App/v1/TipiIntervento.php b/src/API/App/v1/TipiIntervento.php deleted file mode 100644 index 2b1881074..000000000 --- a/src/API/App/v1/TipiIntervento.php +++ /dev/null @@ -1,60 +0,0 @@ -. - */ - -namespace API\App\v1; - -use API\App\AppResource; - -class TipiIntervento extends AppResource -{ - public function getCleanupData($last_sync_at) - { - return $this->getMissingIDs('in_tipiintervento', 'idtipointervento', $last_sync_at); - } - - public function getModifiedRecords($last_sync_at) - { - $query = 'SELECT in_tipiintervento.idtipointervento AS id, in_tipiintervento.updated_at FROM in_tipiintervento'; - - // Filtro per data - if ($last_sync_at) { - $query .= ' WHERE in_tipiintervento.updated_at > '.prepare($last_sync_at); - } - - $records = database()->fetchArray($query); - - return $this->mapModifiedRecords($records); - } - - public function retrieveRecord($id) - { - // Gestione della visualizzazione dei dettagli del record - $query = 'SELECT in_tipiintervento.idtipointervento AS id, - in_tipiintervento.descrizione, - costo_orario AS prezzo_orario, - costo_km AS prezzo_chilometrico, - costo_diritto_chiamata AS prezzo_diritto_chiamata - FROM in_tipiintervento - WHERE in_tipiintervento.idtipointervento = '.prepare($id); - - $record = database()->fetchOne($query); - - return $record; - } -} diff --git a/src/API/Common/Allegato.php b/src/API/Common/Allegato.php deleted file mode 100755 index ce648e76e..000000000 --- a/src/API/Common/Allegato.php +++ /dev/null @@ -1,62 +0,0 @@ -. - */ - -namespace API\Common; - -use API\Interfaces\CreateInterface; -use API\Interfaces\RetrieveInterface; -use API\Resource; -use Models\Upload; -use Modules; - -class Allegato extends Resource implements RetrieveInterface, CreateInterface -{ - public function create($request) - { - $module = Modules::get($request['module']); - - $name = !empty($request['name']) ? $request['name'] : null; - $category = !empty($request['category']) ? $request['category'] : null; - - $upload = Upload::build($_FILES['upload'], [ - 'id_module' => $module['id'], - 'id_record' => $request['id'], - ], $name, $category); - - return [ - 'id' => $upload->id, - 'filename' => $upload->filename, - ]; - } - - public function retrieve($request) - { - $upload = Upload::where('name', $request['name']) - ->where('id', $request['id']) - ->where('id_record', $request['id_record']) - ->first(); - if (!empty($upload)) { - download(base_dir().'/'.$upload->filepath, $upload->original_name); - } - - return [ - 'custom' => '', - ]; - } -} diff --git a/src/API/Common/Stampa.php b/src/API/Common/Stampa.php deleted file mode 100755 index 9bf2c5bc8..000000000 --- a/src/API/Common/Stampa.php +++ /dev/null @@ -1,53 +0,0 @@ -. - */ - -namespace API\Common; - -use API\Interfaces\RetrieveInterface; -use API\Resource; -use Models\PrintTemplate; -use Prints; - -class Stampa extends Resource implements RetrieveInterface -{ - public function retrieve($request) - { - $content = ''; - - $print = PrintTemplate::where('name', $request['name'])->first(); - if (!empty($print)) { - $directory = base_dir().'/files/api'; - - $string = strpos($request['resource'], 'binary') !== false; - $data = Prints::render($print->id, $request['id_record'], $directory, $string); - - if (!$string) { - download($data['path']); - } else { - $content = $data['pdf']; - } - delete($data['path']); - } - - return [ - 'content' => base64_encode($content), - 'filename' => $data['name'], - ]; - } -} diff --git a/src/API/Common/Task.php b/src/API/Common/Task.php deleted file mode 100644 index ef33474c0..000000000 --- a/src/API/Common/Task.php +++ /dev/null @@ -1,107 +0,0 @@ -. - */ - -namespace API\Common; - -use API\Interfaces\CreateInterface; -use API\Interfaces\RetrieveInterface; -use API\Resource; -use Carbon\Carbon; -use Models\Cache; -use Tasks\Log; - -class Task extends Resource implements RetrieveInterface, CreateInterface -{ - public function retrieve($request) - { - $logs = Log::latest() - ->take(1000)->get() - ->groupBy('task.name'); - - return [ - 'results' => $logs->toArray(), - ]; - } - - public function create($request) - { - $database = database(); - - // Rimozione della registrazione del cron attuale - $ultima_esecuzione = Cache::pool('Ultima esecuzione del cron'); - $ultima_esecuzione->set(null); - - // Segnalazione della chiusura al cron attuale - $cron_id = Cache::pool('ID del cron'); - $cron_id->set(null); - - // Rimozione dell'eventuale blocco sul cron - $disattiva = Cache::pool('Disabilita cron'); - $disattiva->set(null); - - // Salvataggio delle modifiche - $database->commitTransaction(); - - // Attesa della conclusione per il cron precedente - $in_esecuzione = Cache::pool('Cron in esecuzione'); - while ($in_esecuzione->content) { - $timestamp = (new Carbon())->addMinutes(1)->getTimestamp(); - time_sleep_until($timestamp); - - $in_esecuzione->refresh(); - } - - // Chiamata al cron per l'avvio - $this->request(); - - // Riavvio transazione - $database->beginTransaction(); - } - - /** - * Richiesta HTTP fire-and-forget. - * - * @source https://cwhite.me/blog/fire-and-forget-http-requests-in-php - */ - protected function request() - { - $endpoint = base_url().'/cron.php'; - $postData = json_encode([]); - - $endpointParts = parse_url($endpoint); - $endpointParts['path'] = $endpointParts['path'] ?: '/'; - $endpointParts['port'] = $endpointParts['port'] ?: ($endpointParts['scheme'] === 'https' ? 443 : 80); - - $contentLength = strlen($postData); - - $request = "POST {$endpointParts['path']} HTTP/1.1\r\n"; - $request .= "Host: {$endpointParts['host']}\r\n"; - $request .= "User-Agent: OpenSTAManager API v1\r\n"; - $request .= "Authorization: Bearer api_key\r\n"; - $request .= "Content-Length: {$contentLength}\r\n"; - $request .= "Content-Type: application/json\r\n\r\n"; - $request .= $postData; - - $prefix = substr($endpoint, 0, 8) === 'https://' ? 'tls://' : ''; - - $socket = fsockopen($prefix.$endpointParts['host'], $endpointParts['port']); - fwrite($socket, $request); - fclose($socket); - } -} diff --git a/src/API/Exceptions/InternalError.php b/src/API/Exceptions/InternalError.php deleted file mode 100755 index 71e8f2271..000000000 --- a/src/API/Exceptions/InternalError.php +++ /dev/null @@ -1,26 +0,0 @@ -. - */ - -namespace API\Exceptions; - -use Exception; - -class InternalError extends Exception -{ -} diff --git a/src/API/Exceptions/ResourceNotFound.php b/src/API/Exceptions/ResourceNotFound.php deleted file mode 100755 index 7f18de5d0..000000000 --- a/src/API/Exceptions/ResourceNotFound.php +++ /dev/null @@ -1,26 +0,0 @@ -. - */ - -namespace API\Exceptions; - -use Exception; - -class ResourceNotFound extends Exception -{ -} diff --git a/src/API/Exceptions/ServiceError.php b/src/API/Exceptions/ServiceError.php deleted file mode 100755 index c1364f60b..000000000 --- a/src/API/Exceptions/ServiceError.php +++ /dev/null @@ -1,26 +0,0 @@ -. - */ - -namespace API\Exceptions; - -use Exception; - -class ServiceError extends Exception -{ -} diff --git a/src/API/Exceptions/Unauthorized.php b/src/API/Exceptions/Unauthorized.php deleted file mode 100755 index 0356eb9c2..000000000 --- a/src/API/Exceptions/Unauthorized.php +++ /dev/null @@ -1,26 +0,0 @@ -. - */ - -namespace API\Exceptions; - -use Exception; - -class Unauthorized extends Exception -{ -} diff --git a/src/API/Interfaces/CreateInterface.php b/src/API/Interfaces/CreateInterface.php deleted file mode 100755 index 0e9c619d0..000000000 --- a/src/API/Interfaces/CreateInterface.php +++ /dev/null @@ -1,25 +0,0 @@ -. - */ - -namespace API\Interfaces; - -interface CreateInterface -{ - public function create($request); -} diff --git a/src/API/Interfaces/DeleteInterface.php b/src/API/Interfaces/DeleteInterface.php deleted file mode 100755 index 60cd85b2c..000000000 --- a/src/API/Interfaces/DeleteInterface.php +++ /dev/null @@ -1,25 +0,0 @@ -. - */ - -namespace API\Interfaces; - -interface DeleteInterface -{ - public function delete($request); -} diff --git a/src/API/Interfaces/RetrieveInterface.php b/src/API/Interfaces/RetrieveInterface.php deleted file mode 100755 index d005009ab..000000000 --- a/src/API/Interfaces/RetrieveInterface.php +++ /dev/null @@ -1,25 +0,0 @@ -. - */ - -namespace API\Interfaces; - -interface RetrieveInterface -{ - public function retrieve($request); -} diff --git a/src/API/Interfaces/UpdateInterface.php b/src/API/Interfaces/UpdateInterface.php deleted file mode 100755 index d208583ee..000000000 --- a/src/API/Interfaces/UpdateInterface.php +++ /dev/null @@ -1,25 +0,0 @@ -. - */ - -namespace API\Interfaces; - -interface UpdateInterface -{ - public function update($request); -} diff --git a/src/API/Manager.php b/src/API/Manager.php deleted file mode 100755 index c93acb8b6..000000000 --- a/src/API/Manager.php +++ /dev/null @@ -1,231 +0,0 @@ -. - */ - -namespace API; - -use API\Exceptions\InternalError; -use API\Exceptions\ResourceNotFound; -use Auth; -use Models\ApiResource as Resource; -use PDOException; - -/** - * Classe per la gestione delle API del progetto. - * - * @since 2.4.11 - */ -class Manager -{ - protected $resource; - protected $type; - - /** - * @throws \InvalidArgumentException - */ - public function __construct($resource, $type, $version) - { - $object = Resource::where('version', $version) - ->where('type', $type) - ->where('resource', $resource) - ->first(); - - if (empty($object)) { - throw new ResourceNotFound(); - } - - $this->resource = $object; - $this->type = $type; - } - - public function manage($request) - { - $type = $this->type; - - $response = $this->{$type}($request); - - return $response; - } - - /** - * Gestisce le richieste di informazioni riguardanti gli elementi esistenti. - * - * @param array $request - * - * @return string - */ - public function retrieve($request) - { - $user = Auth::user(); - - $where = []; - $order = []; - - // Selezione personalizzata - $select = !empty($request['display']) ? explode(',', substr($request['display'], 1, -1)) : null; - - // Ricerca personalizzata - $values = isset($request['filter']) ? (array) $request['filter'] : []; - foreach ($values as $key => $value) { - // Rimozione delle parentesi - $value = substr($value, 1, -1); - - // Individuazione della tipologia (array o string) - $where[$key] = string_contains($value, ',') ? explode(',', $value) : $value; - } - - // Ordinamento personalizzato - $values = isset($request['order']) ? (array) $request['order'] : []; - foreach ($values as $value) { - $pieces = explode('|', $value); - $order[] = empty($pieces[1]) ? $pieces[0] : [$pieces[0] => $pieces[1]]; - } - - // Paginazione automatica dell'API - $page = isset($request['page']) ? (int) $request['page'] : 0; - $length = setting('Lunghezza pagine per API'); - - $data = array_merge($request, [ - 'user' => $user, - 'select' => $select, - 'where' => $where, - 'order' => $order, - 'page' => $page, - 'length' => $length, - ]); - - $response = $this->getResponse($data); - $parameters = $response['parameters']; - - $table = $response['table']; - $select = $response['select'] ?: $select; - $select = $select ?: '*'; - - $query = $response['query']; - - try { - $database = database(); - - // Generazione automatica delle query - if (!empty($table)) { - // Date di interesse - if (!empty($request['upd'])) { - $where['#updated_at'] = 'updated_at >= '.prepare($request['upd']); - } - if (!empty($request['crd'])) { - $where['#created_at'] = 'created_at >= '.prepare($request['crd']); - } - - // Query per ottenere le informazioni - $query = $database->select($table, $select, $where, $order, [], true); - - foreach ($where as $key => $value) { - $parameters[] = $value; - } - } - - if (!empty($query)) { - $response = []; - - $response['records'] = $database->fetchArray($query.' LIMIT '.($page * $length).', '.$length, $parameters); - $count = $database->fetchNum($query, $parameters); - - $response['total-count'] = $count; - } - - if (empty($response['pages'])) { - $response['pages'] = intval(ceil($response['total-count'] / $length)); - } - } catch (PDOException $e) { - // Log dell'errore - $logger = logger(); - $logger->addRecord(\Monolog\Logger::ERROR, $e); - - throw new InternalError(); - } - - return $response; - } - - /** - * Gestisce le richieste di creazione nuovi elementi. - * - * @param array $request - * - * @return string - */ - public function create($request) - { - return $this->getResponse($request); - } - - /** - * Gestisce le richieste di aggiornamento di elementi esistenti. - * - * @param array $request - * - * @return string - */ - public function update($request) - { - return $this->getResponse($request); - } - - /** - * Gestisce le richieste di eliminazione di elementi esistenti. - * - * @param array $request - * - * @return string - */ - public function delete($request) - { - return $this->getResponse($request); - } - - public function getResponse($request) - { - $class = $this->resource->class; - - if (!class_exists($class)) { - throw new ResourceNotFound(); - } - - $object = new $class(); - $method = $this->type; - - // Operazioni di inizializzazione - $block = $object->open($request); - if (!empty($block)) { - throw new ResourceNotFound(); - } - - $database = database(); - $database->beginTransaction(); - - // Operazioni della risorsa - $response = $object->{$method}($request); - - $database->commitTransaction(); - - // Operazioni di completamento - $object->close($request, $response); - - return $response; - } -} diff --git a/src/API/Resource.php b/src/API/Resource.php deleted file mode 100755 index 6b72f9de4..000000000 --- a/src/API/Resource.php +++ /dev/null @@ -1,48 +0,0 @@ -. - */ - -namespace API; - -class Resource -{ - /** - * @param $request - * - * @return bool se true, la richiesta di apertura di considera fallita e viene restituito 404 - */ - public function open($request) - { - return false; - } - - /** - * @param $request - * @param $response - * - * @retrun void - */ - public function close($request, $response) - { - } - - public function getUser() - { - return auth()->getUser(); - } -} diff --git a/src/API/Response.php b/src/API/Response.php deleted file mode 100755 index 8c2cef81a..000000000 --- a/src/API/Response.php +++ /dev/null @@ -1,272 +0,0 @@ -. - */ - -namespace API; - -use API\Exceptions\InternalError; -use API\Exceptions\ResourceNotFound; -use API\Exceptions\ServiceError; -use Auth; -use Exception; -use Filter; -use Models\ApiResource as Resource; - -/** - * Classe per la gestione delle API del progetto. - * - * @since 2.4.11 - */ -class Response -{ - /** @var array Stati previsti dall'API */ - protected static $status = [ - 'ok' => [ - 'code' => 200, - 'message' => 'OK', - ], - 'internalError' => [ - 'code' => 400, - 'message' => "Errore interno dell'API", - ], - 'unauthorized' => [ - 'code' => 401, - 'message' => 'Non autorizzato', - ], - 'notFound' => [ - 'code' => 404, - 'message' => 'Non trovato', - ], - 'externalError' => [ - 'code' => 409, - 'message' => 'Errore in un servizio esterno', - ], - 'serverError' => [ - 'code' => 500, - 'message' => 'Errore del server', - ], - 'incompatible' => [ - 'code' => 503, - 'message' => 'Servizio non disponibile', - ], - ]; - - public static function manage() - { - // Gestione della richiesta - $method = $_SERVER['REQUEST_METHOD']; - $type = null; - switch ($method) { - // Richiesta PUT (modifica elementi) - case 'PUT': - $type = 'update'; - break; - - // Richiesta POST (creazione elementi) - case 'POST': - $type = 'create'; - break; - - // Richiesta GET (ottenimento elementi) - case 'GET': - $type = 'retrieve'; - break; - - // Richiesta DELETE (eliminazione elementi) - case 'DELETE': - $type = 'delete'; - break; - } - - $request = self::getRequest(); - $version = $request['version']; - - // Controllo sull'accesso - if (!Auth::check() && $request['resource'] != 'login') { - return self::response([ - 'status' => self::$status['unauthorized']['code'], - ]); - } - - // Controllo sulla compatibilità dell'API - if (!self::isCompatible()) { - return self::response([ - 'status' => self::$status['incompatible']['code'], - ]); - } - - if ($type == 'retrieve' && empty($request['resource'])) { - $resources = self::getResources($type, $version)->toArray(); - $list = array_column($resources, 'resource') ?: []; - - return self::response([ - 'resources' => $list, - ]); - } - - try { - $manager = new Manager($request['resource'], $type, $version); - - $response = $manager->manage($request); - } catch (ResourceNotFound $e) { - return self::error('notFound'); - } catch (InternalError $e) { - return self::error('internalError'); - } catch (ServiceError $e) { - return self::error('externalError'); - } catch (Exception $e) { - return self::error('serverError'); - } - - return self::response($response); - } - - /** - * Genera i contenuti di risposta nel caso si verifichi un errore. - * - * @param string|int $error - * - * @return string - */ - public static function error($error) - { - $keys = array_keys(self::$status); - $error = (in_array($error, $keys)) ? $error : 'serverError'; - - $code = self::$status[$error]['code']; - - http_response_code($code); - - return self::response([ - 'status' => $code, - ]); - } - - /** - * Formatta i contenuti della risposta secondo il formato JSON. - * - * @param array $array - * - * @return string - */ - public static function response($array) - { - if (empty($array['custom'])) { - // Aggiunta dello status di default - if (empty($array['status'])) { - $array['status'] = self::$status['ok']['code']; - } - - // Aggiunta del messaggio in base allo status - if (empty($array['message'])) { - $codes = array_column(self::$status, 'code'); - $messages = array_column(self::$status, 'message'); - - $array['message'] = $messages[array_search($array['status'], $codes)]; - http_response_code($array['status']); - } - - $flags = JSON_FORCE_OBJECT; - // Beautify forzato dei risultati - if (get('beautify') !== null) { - $flags |= JSON_PRETTY_PRINT; - } - - $result = json_encode($array, $flags); - } else { - $result = $array['custom']; - } - - return $result; - } - - /** - * Restituisce l'elenco degli stati dell'API. - * - * @return array - */ - public static function getStatus() - { - return self::$status; - } - - /** - * Controlla se la richiesta effettuata è rivolta all'API. - * - * @return bool - */ - public static function isAPIRequest() - { - return getURLPath() == slashes(base_path().'/api/index.php'); - } - - /** - * Restituisce i parametri specificati dalla richiesta. - * - * @param bool $raw - * - * @return array - */ - public static function getRequest($raw = false) - { - $request = []; - - if (self::isAPIRequest()) { - $request = file_get_contents('php://input'); - - if (empty($raw)) { - $request = (array) json_decode($request, true); - $request = Filter::sanitize($request); - - // Fallback per input standard vuoto (richiesta da browser o upload file) - if (empty($request)) { // $_SERVER['REQUEST_METHOD'] == 'GET' - $request = Filter::getGET(); - } - - if (empty($request['token'])) { - $request['token'] = ''; - } - - if (empty($request['version'])) { - $request['version'] = 'v1'; - } - } - } - - return $request; - } - - /** - * Controlla se il database è compatibile con l'API. - * - * @return bool - */ - public static function isCompatible() - { - $database = database(); - - return version_compare($database->getMySQLVersion(), '5.6.5') >= 0; - } - - protected static function getResources($type, $version) - { - $resources = Resource::where('version', $version)->where('type', $type)->get(); - - return $resources; - } -} diff --git a/src/API/Services.php b/src/API/Services.php deleted file mode 100755 index b81cc3239..000000000 --- a/src/API/Services.php +++ /dev/null @@ -1,81 +0,0 @@ -. - */ - -namespace API; - -use GuzzleHttp\Client; - -/** - * Classe per l'interazione con API esterne. - * - * @since 2.4.3 - */ -class Services -{ - protected static $client = null; - - public static function isEnabled() - { - return !empty(setting('OSMCloud Services API Token')); - } - - public static function request($type, $resource, $data = [], $options = []) - { - $client = static::getClient(); - - $json = array_merge($data, [ - 'token' => setting('OSMCloud Services API Token'), - 'version' => setting('OSMCloud Services API Version'), - 'resource' => $resource, - ]); - - $options = array_merge($options, [ - 'json' => $json, - 'http_errors' => false, - ]); - - return $client->request($type, '', $options); - } - - public static function responseBody($response) - { - $body = $response->getBody(); - - return json_decode($body, true) ?: []; - } - - /** - * Restituisce l'oggetto per la connessione all'API del progetto. - * - * @return Client - */ - protected static function getClient() - { - if (!isset(self::$client)) { - $url = setting('OSMCloud Services API URL'); - - self::$client = new Client([ - 'base_uri' => $url, - 'verify' => false, - ]); - } - - return self::$client; - } -} diff --git a/src/App.php b/src/App.php deleted file mode 100755 index a89d7d2ad..000000000 --- a/src/App.php +++ /dev/null @@ -1,350 +0,0 @@ -. - */ - -use Util\Messages; - -/** - * Classe per la gestione delle utenze. - * - * @since 2.4 - */ -class App -{ - public static $docroot; - public static $rootdir; - public static $baseurl; - - /** @var array Identificativo del modulo corrente */ - protected static $current_module; - /** @var int Identificativo dell'elemento corrente */ - protected static $current_element; - - /** @var Messages Gestione dei messaggi flash */ - protected static $flash = null; - - /** @var bool Stato di debug */ - protected static $config = []; - - /** @var array Elenco degli assets del progetto */ - protected static $assets = [ - // CSS - 'css' => [ - 'app.min.css', - 'style.min.css', - 'themes.min.css', - ], - - // Print CSS - 'print' => [ - 'print.min.css', - ], - - // JS - 'js' => [ - 'app.min.js', - 'functions.min.js', - 'custom.min.js', - 'i18n/parsleyjs/|lang|.min.js', - 'i18n/select2/|lang|.min.js', - 'i18n/moment/|lang|.min.js', - 'i18n/fullcalendar/|lang|.min.js', - ], - ]; - - /** - * Restituisce la configurazione dell'installazione in utilizzo del progetto. - * - * @return array - */ - public static function getConfig() - { - if (empty(self::$config['db_host'])) { - if (file_exists(base_dir().'/config.inc.php')) { - include base_dir().'/config.inc.php'; - - $config = get_defined_vars(); - } else { - $config = []; - } - - $defaultConfig = self::getDefaultConfig(); - - $result = array_merge($defaultConfig, $config); - - // Operazioni di normalizzazione sulla configurazione - $result['debug'] = isset(self::$config['debug']) ? self::$config['debug'] : !empty($result['debug']); - $result['lang'] = $result['lang'] == 'it' ? 'it_IT' : $result['lang']; - - self::$config = $result; - } - - return self::$config; - } - - /** - * Imposta e restituisce lo stato di debug del progetto. - * - * @param bool $value - * - * @return bool - */ - public static function debug($value = null) - { - if (is_bool($value)) { - self::$config['debug'] = $value; - } - - if (!isset(self::$config['debug'])) { - App::getConfig(); - } - - return self::$config['debug']; - } - - /** - * Restituisce l'oggetto dedicato alla gestione dei messaggi per l'utente. - * - * @return Messages - */ - public static function flash() - { - if (empty(self::$flash)) { - $storage = null; - self::$flash = new Messages($storage, 'messages'); - } - - return self::$flash; - } - - /** - * Individua i percorsi di base necessari per il funzionamento del gestionale. - * Attenzione: questo metodo deve essere eseguito all'interno di un file nella cartella principale del progetto per permettere il corretto funzionamento degli URL. - */ - public static function definePaths($docroot) - { - if (!defined('DOCROOT')) { - // Individuazione di $rootdir - $rootdir = substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/')).'/'; - if (strrpos($rootdir, '/'.basename($docroot).'/') !== false) { - $rootdir = substr($rootdir, 0, strrpos($rootdir, '/'.basename($docroot).'/')).'/'.basename($docroot); - } else { - $rootdir = '/'; - } - $rootdir = rtrim($rootdir, '/'); - $rootdir = str_replace('%2F', '/', rawurlencode($rootdir)); - - // Individuazione di $baseurl - $baseurl = (isHTTPS(true) ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'].$rootdir; - - // Impostazione delle variabili globali - define('DOCROOT', $docroot); - define('ROOTDIR', $rootdir); - define('BASEURL', $baseurl); - - self::$docroot = $docroot; - self::$rootdir = $rootdir; - self::$baseurl = $baseurl; - } - } - - /** - * Individua i percorsi principali del progetto. - * - * @return array - */ - public static function getPaths() - { - $assets = base_path().'/assets/dist'; - - return [ - 'assets' => $assets, - 'css' => $assets.'/css', - 'js' => $assets.'/js', - 'img' => $assets.'/img', - ]; - } - - /** - * Restituisce l'elenco degli assets del progetto. - * - * @return array - */ - public static function getAssets() - { - // Assets aggiuntivi - $config = self::getConfig(); - - $version = Update::getVersion(); - - // Impostazione dei percorsi - $paths = self::getPaths(); - $lang = trans()->getCurrentLocale(); - - // Sezioni: nome - percorso - $sections = [ - 'css' => 'css', - 'print' => 'css', - 'js' => 'js', - ]; - - $first_lang = explode('_', $lang); - $lang_replace = [ - $lang, - strtolower($lang), - strtolower($first_lang[0]), - strtoupper($first_lang[0]), - str_replace('_', '-', $lang), - str_replace('_', '-', strtolower($lang)), - ]; - - $assets = []; - - foreach ($sections as $section => $dir) { - $result = array_unique(array_merge(self::$assets[$section], $config['assets'][$section])); - - foreach ($result as $key => $element) { - $element = string_starts_with($element, 'http') ? $element : $paths[$dir].'/'.$element; - - if (string_contains($element, '|lang|')) { - foreach ($lang_replace as $replace) { - $name = str_replace('|lang|', $replace, $element); - - if (file_exists(base_dir().str_replace(base_path(), '', $name))) { - $element = $name; - break; - } - } - } - - $result[$key] = $element.'?v='.$version; - } - - $assets[$section] = $result; - } - - return $assets; - } - - /** - * Restituisce il codice HTML per il form contenente il file indicato. - * - * @param string $file - * @param array $result - * @param array $options - * @param bool $disableForm - * - * @return string - */ - public static function load($file, $result, $options, $disableForm = false) - { - $form = $disableForm ? '|response|' : self::internalLoad('form.php', $result, $options); - - $response = self::internalLoad($file, $result, $options); - - $form = str_replace('|response|', $response, $form); - - return $form; - } - - /** - * Restituisce il codice HTML generato del file indicato. - * - * @param string $file - * @param array $result - * @param array $options - * @param string $directory - * - * @return string - */ - public static function internalLoad($file, $result, $options, $directory = null) - { - $module = Modules::getCurrent(); - - $database = $dbo = database(); - - $id_module = $module['id']; - $id_record = filter('id_record'); - $id_plugin = $options['id_plugin']; - - $directory = empty($directory) ? 'include|custom|/common/' : $directory; - - ob_start(); - include self::filepath($directory, $file); - $response = ob_get_clean(); - - return $response; - } - - /** - * Individua il percorso per il file da includere considerando gli eventuali custom. - * - * @param string $path - * @param string $file - * - * @return string|null - */ - public static function filepath($path, $file = null) - { - $path = string_contains($path, base_dir()) ? $path : base_dir().'/'.ltrim($path, '/'); - $path = empty($file) ? $path : rtrim($path, '/').'/'.$file; - - $original_file = str_replace('|custom|', '', $path); - $custom_file = str_replace('|custom|', '/custom', $path); - - $result = ''; - if (file_exists($custom_file)) { - $result = $custom_file; - } elseif (file_exists($original_file)) { - $result = $original_file; - } - - return slashes($result); - } - - /** - * Restituisce la configurazione di default del progetto. - * - * @return array - */ - protected static function getDefaultConfig() - { - if (file_exists(base_dir().'/config.example.php')) { - include base_dir().'/config.example.php'; - } - - $db_host = ''; - $db_username = ''; - $db_password = ''; - $db_name = ''; - $port = ''; - $lang = ''; - - $formatter = [ - 'timestamp' => 'd/m/Y H:i', - 'date' => 'd/m/Y', - 'time' => 'H:i', - 'number' => [ - 'decimals' => ',', - 'thousands' => '.', - ], - ]; - - return get_defined_vars(); - } -} diff --git a/src/Auth.php b/src/Auth.php deleted file mode 100755 index 4d06f4a61..000000000 --- a/src/Auth.php +++ /dev/null @@ -1,481 +0,0 @@ -. - */ - -use API\Response as API; -use Models\User; - -/** - * Classe per la gestione delle utenze. - * - * @since 2.3 - */ -class Auth extends \Util\Singleton -{ - /** @var array Stati previsti dal sistema di autenticazione */ - protected static $status = [ - 'success' => [ - 'code' => 1, - 'message' => 'Login riuscito!', - ], - 'failed' => [ - 'code' => 0, - 'message' => 'Autenticazione fallita!', - ], - 'disabled' => [ - 'code' => 2, - 'message' => 'Utente non abilitato!', - ], - 'unauthorized' => [ - 'code' => 5, - 'message' => "L'utente non ha nessun permesso impostato!", - ], - ]; - - /** @var array Opzioni di sicurezza relative all'hashing delle password */ - protected static $password_options = [ - 'algorithm' => PASSWORD_BCRYPT, - 'options' => [], - ]; - - /** @var array Opzioni per la protezione contro attacchi brute-force */ - protected static $brute_options = [ - 'attemps' => 3, - 'timeout' => 180, - ]; - /** @var bool Informazioni riguardanti la condizione brute-force */ - protected static $is_brute; - - /** @var array Informazioni riguardanti l'utente autenticato */ - protected $user; - /** @var string Stato del tentativo di accesso */ - protected $current_status; - /** @var string|null Nome del primo modulo su cui l'utente ha permessi di navigazione */ - protected $first_module; - - protected function __construct() - { - $database = database(); - - if ($database->isInstalled()) { - // Controllo dell'accesso da API - if (API::isAPIRequest()) { - $token = API::getRequest()['token']; - - $user = $database->fetchArray('SELECT `id_utente` FROM `zz_tokens` WHERE `enabled` = 1 AND `token` = :token', [ - ':token' => $token, - ]); - - $id = !empty($user) ? $user[0]['id_utente'] : null; - } - // Controllo sulla sessione attiva - elseif (!empty($_SESSION['id_utente'])) { - $id = $_SESSION['id_utente']; - } - - if (!empty($id)) { - $this->identifyUser($id); - } - - $this->saveToSession(); - } - } - - /** - * Effettua un tentativo di accesso con le credenziali fornite. - * - * @param string $username - * @param string $password - * - * @return bool - */ - public function attempt($username, $password) - { - session_regenerate_id(); - - // Controllo sulla disponibilità dell'accesso (brute-forcing non in corso) - if (self::isBrute()) { - return false; - } - - $database = database(); - - $log = []; - $log['username'] = $username; - $log['ip'] = get_client_ip(); - - $status = 'failed'; - - $users = $database->fetchArray('SELECT id, password, enabled FROM zz_users WHERE username = :username LIMIT 1', [ - ':username' => $username, - ]); - if (!empty($users)) { - $user = $users[0]; - - if (!empty($user['enabled'])) { - $this->identifyUser($user['id']); - $module = $this->getFirstModule(); - - if ( - $this->isAuthenticated() && - $this->password_check($password, $user['password'], $user['id']) && - !empty($module) - ) { - // Accesso completato - $log['id_utente'] = $this->user->id; - $status = 'success'; - - // Salvataggio nella sessione - $this->saveToSession(); - } else { - if (empty($module)) { - $status = 'unauthorized'; - } - - // Logout automatico - $this->destory(); - } - } else { - $status = 'disabled'; - } - } - - // Salvataggio dello stato corrente - $log['stato'] = self::getStatus()[$status]['code']; - $this->current_status = $status; - - // Salvataggio del tentativo nel database - $database->insert('zz_logs', $log); - - return $this->isAuthenticated(); - } - - /** - * Controlla se l'utente è autenticato. - * - * @return bool - */ - public function isAuthenticated() - { - return !empty($this->user); - } - - /** - * Controlla se l'utente appartiene al gruppo degli Amministratori. - * - * @return bool - */ - public function isAdmin() - { - return $this->isAuthenticated() && !empty($this->user->is_admin); - } - - /** - * Restituisce le informazioni riguardanti l'utente autenticato. - * - * @return User - */ - public function getUser() - { - return $this->user; - } - - /** - * Restituisce lo stato corrente. - * - * @return string - */ - public function getCurrentStatus() - { - return $this->current_status; - } - - /** - * Restituisce il token di accesso all'API per l'utente autenticato. - * - * @return string - */ - public function getToken() - { - $token = null; - - if ($this->isAuthenticated()) { - $user = self::user(); - - $tokens = $user->getApiTokens(); - $token = $tokens[0]['token']; - } - - return $token; - } - - /** - * Distrugge le informazioni riguardanti l'utente autenticato, forzando il logout. - */ - public function destory() - { - if ($this->isAuthenticated() || !empty($_SESSION['id_utente'])) { - $this->user = []; - $this->first_module = null; - - session_unset(); - session_regenerate_id(); - - if (!API::isAPIRequest()) { - flash()->clearMessages(); - } - } - } - - /** - * Restituisce il nome del primo modulo navigabile dall'utente autenticato. - * - * @return string|null - */ - public function getFirstModule() - { - if (empty($this->first_module)) { - $parameters = []; - - $query = 'SELECT id FROM zz_modules WHERE enabled = 1'; - if (!$this->isAdmin()) { - $query .= " AND id IN (SELECT idmodule FROM zz_permissions WHERE idgruppo = (SELECT id FROM zz_groups WHERE nome = :group) AND permessi IN ('r', 'rw'))"; - - $parameters[':group'] = $this->getUser()['gruppo']; - } - - $database = database(); - $results = $database->fetchArray($query." AND options != '' AND options != 'menu' AND options IS NOT NULL ORDER BY `order` ASC", $parameters); - - if (!empty($results)) { - $module = null; - - $first = setting('Prima pagina'); - if (!in_array($first, array_column($results, 'id'))) { - $module = $results[0]['id']; - } else { - $module = $first; - } - - $this->first_module = $module; - } - } - - return $this->first_module; - } - - /** - * Restituisce l'hashing della password per la relativa memorizzazione nel database. - * - * @param string $password - * - * @return string|bool - */ - public static function hashPassword($password) - { - return password_hash($password, self::$password_options['algorithm'], self::$password_options['options']); - } - - /** - * Restituisce l'elenco degli stati del sistema di autenticazione. - * - * @return array - */ - public static function getStatus() - { - return self::$status; - } - - /** - * Controlla se l'utente è autenticato. - * - * @return bool - */ - public static function check() - { - return self::getInstance()->isAuthenticated(); - } - - /** - * Controlla se l'utente appartiene al gruppo degli Amministratori. - * - * @return bool - */ - public static function admin() - { - return self::getInstance()->isAdmin(); - } - - /** - * Restituisce le informazioni riguardanti l'utente autenticato. - * - * @return User - */ - public static function user() - { - return self::getInstance()->getUser(); - } - - /** - * Distrugge le informazioni riguardanti l'utente autenticato, forzando il logout. - */ - public static function logout() - { - return self::getInstance()->destory(); - } - - /** - * Restituisce il nome del primo modulo navigabile dall'utente autenticato. - * - * @return string - */ - public static function firstModule() - { - return self::getInstance()->getFirstModule(); - } - - /** - * Controlla se sono in corso molti tentativi di accesso (possibile brute-forcing in corso). - * - * @return bool - */ - public static function isBrute() - { - $database = database(); - - if (!$database->isInstalled() || !$database->tableExists('zz_logs') || Update::isUpdateAvailable()) { - return false; - } - - if (!isset(self::$is_brute)) { - $results = $database->fetchArray('SELECT COUNT(*) AS tot FROM zz_logs WHERE ip = :ip AND stato = :state AND DATE_ADD(created_at, INTERVAL :timeout SECOND) >= NOW()', [ - ':ip' => get_client_ip(), - ':state' => self::getStatus()['failed']['code'], - ':timeout' => self::$brute_options['timeout'], - ]); - - self::$is_brute = $results[0]['tot'] > self::$brute_options['attemps']; - } - - return self::$is_brute; - } - - /** - * Restituisce il tempo di attesa rimanente per lo sblocco automatico dellla protezione contro attacchi brute-force. - * - * @return int - */ - public static function getBruteTimeout() - { - if (!self::isBrute()) { - return 0; - } - - $database = database(); - - $results = $database->fetchArray('SELECT TIME_TO_SEC(TIMEDIFF(DATE_ADD(created_at, INTERVAL '.self::$brute_options['timeout'].' SECOND), NOW())) AS diff FROM zz_logs WHERE ip = :ip AND stato = :state AND DATE_ADD(created_at, INTERVAL :timeout SECOND) >= NOW() ORDER BY created_at DESC LIMIT 1', [ - ':ip' => get_client_ip(), - ':state' => self::getStatus()['failed']['code'], - ':timeout' => self::$brute_options['timeout'], - ]); - - return intval($results[0]['diff']); - } - - /** - * Controlla la corrispondenza delle password ed eventualmente effettua un rehashing. - * - * @param string $password - * @param string $hash - * @param int $user_id - */ - protected function password_check($password, $hash, $user_id) - { - $result = false; - $rehash = false; - - // Retrocompatibilità - if ($hash == md5($password)) { - $rehash = true; - - $result = true; - } - - // Nuova versione - if (password_verify($password, $hash)) { - $rehash = password_needs_rehash($hash, self::$password_options['algorithm'], self::$password_options['options']); - - $result = true; - } - - // Controllo in automatico per futuri cambiamenti dell'algoritmo di password - if ($rehash) { - $database = database(); - $database->update('zz_users', ['password' => self::hashPassword($password)], ['id' => $user_id]); - } - - return $result; - } - - /** - * Memorizza le informazioni riguardanti l'utente all'interno della sessione. - */ - protected function saveToSession() - { - if (session_status() == PHP_SESSION_ACTIVE && $this->isAuthenticated()) { - // Retrocompatibilità - foreach ($this->user as $key => $value) { - $_SESSION[$key] = $value; - } - $_SESSION['id_utente'] = $this->user->id; - - $identifier = md5($_SESSION['id_utente'].$_SERVER['HTTP_USER_AGENT']); - if ((empty($_SESSION['last_active']) || time() < $_SESSION['last_active'] + (60 * 60)) && (empty($_SESSION['identifier']) || $_SESSION['identifier'] == $identifier)) { - $_SESSION['last_active'] = time(); - $_SESSION['identifier'] = $identifier; - } - } - } - - /** - * Identifica l'utente interessato dall'autenticazione. - * - * @param int $user_id - */ - protected function identifyUser($user_id) - { - $database = database(); - - try { - $results = $database->fetchArray('SELECT id, idanagrafica, username, (SELECT nome FROM zz_groups WHERE zz_groups.id = zz_users.idgruppo) AS gruppo FROM zz_users WHERE id = :user_id AND enabled = 1 LIMIT 1', [ - ':user_id' => $user_id, - ]); - - if (!empty($results)) { - $this->user = User::with('group')->find($user_id); - - if (!API::isAPIRequest() && !empty($this->user->reset_token)) { - $this->user->reset_token = null; - $this->user->save(); - } - } - } catch (PDOException $e) { - $this->destory(); - } - } -} diff --git a/src/Backup.php b/src/Backup.php deleted file mode 100755 index f3543acba..000000000 --- a/src/Backup.php +++ /dev/null @@ -1,312 +0,0 @@ -. - */ - -use Ifsnop\Mysqldump\Mysqldump; -use Util\Generator; -use Util\Zip; - -/** - * Classe per la gestione dei backup. - * - * @since 2.4 - */ -class Backup -{ - /** @var string Pattern per i nomi dei backup */ - public const PATTERN = 'OSM backup YYYY-m-d H_i_s'; - - /** @var array Elenco delle variabili che identificano i backup giornalieri */ - protected static $daily_replaces = [ - 'YYYY', 'm', 'd', - ]; - - /** - * Restituisce il percorso su previsto per il salvataggio dei backup. - * - * @return string - */ - public static function getDirectory() - { - $result = App::getConfig()['backup_dir']; - - $result = rtrim($result, '/'); - if (!directory($result) || !is_writable($result)) { - //throw new UnexpectedValueException(); - } - - return slashes($result); - } - - /** - * Restituisce l'elenco dei backup disponibili. - * - * @param string $pattern Eventuale pattern alternativo - * - * @return array - */ - public static function getList($pattern = null) - { - $directory = self::getDirectory(); - if (!is_writable($directory) || !is_readable($directory)) { - return []; - } - - // Costruzione del pattern - if (empty($pattern)) { - $replaces = self::getReplaces(); - $regexs = array_column($replaces, 'regex'); - - $pattern = str_replace(array_keys($replaces), array_values($regexs), self::PATTERN); - } - - // Individuazione dei backup - $backups = Symfony\Component\Finder\Finder::create() - ->name('/^'.$pattern.'/') - ->sortByName() - ->in($directory) - ->depth('== 0'); - - $results = []; - foreach ($backups as $backup) { - $results[] = $backup->getRealPath(); - } - - return $results; - } - - /** - * Restituisce i valori utilizzati sulle variabili sostituite. - * - * @return array - */ - public static function readName($string) - { - return Generator::read(self::PATTERN, basename($string)); - } - - /** - * Controlla se il backup giornaliero è stato effettuato. - * - * @return bool|null - */ - public static function isDailyComplete() - { - // Costruzione del pattern - $replaces = self::getReplaces(); - - foreach ($replaces as $key => $replace) { - if (in_array($key, self::$daily_replaces)) { - $replaces[$key] = $replace['value']; - } else { - $replaces[$key] = $replace['regex']; - } - } - - $pattern = str_replace(array_keys($replaces), array_values($replaces), self::PATTERN); - - // Individuazione dei backup - $backups = self::getList($pattern); - - return !empty($backups); - } - - /** - * Effettua il backup giornaliero. - * - * @return bool|null - */ - public static function daily() - { - // Creazione del backup eventuale - if (!self::isDailyComplete()) { - return self::create(); - } - - return false; - } - - /** - * Esegue il backup del progetto. - * - * @return bool - */ - public static function create() - { - $backup_dir = self::getDirectory(); - $backup_name = self::getNextName(); - - set_time_limit(0); - - // Backup del database - $database_file = self::getDatabaseDirectory().'/database.sql'; - self::database($database_file); - - // Percorsi da ignorare di default - $ignores = [ - 'files' => [ - 'config.inc.php', - ], - 'dirs' => [ - 'node_modules', - 'tests', - 'tmp', - ], - ]; - - if (string_starts_with($backup_dir, slashes(base_dir()))) { - $ignores['dirs'][] = basename($backup_dir); - } - - // Creazione backup in formato ZIP - if (extension_loaded('zip')) { - $result = Zip::create([ - base_dir(), - self::getDatabaseDirectory(), - ], $backup_dir.'/'.$backup_name.'.zip', $ignores); - } - - // Creazione backup attraverso la copia dei file - else { - $result = copyr([ - base_dir(), - self::getDatabaseDirectory(), - ], $backup_dir.'/'.$backup_name.'.zip', $ignores); - } - - // Rimozione cartella temporanea - delete($database_file); - - self::cleanup(); - - return $result; - } - - /** - * Effettua il dump del database. - * - * @param string $file - */ - public static function database($file) - { - $config = App::getConfig(); - - $dump = new Mysqldump('mysql:host='.$config['db_host'].';dbname='.$config['db_name'], $config['db_username'], $config['db_password'], [ - 'add-drop-table' => true, - 'add-locks' => false, - ]); - - $dump->start($file); - } - - /** - * Rimuove i backup più vecchi. - */ - public static function cleanup() - { - $max_backups = intval(setting('Numero di backup da mantenere')); - - $backups = self::getList(); - $count = count($backups); - - // Rimozione dei backup più vecchi - for ($i = 0; $i < $count - $max_backups; ++$i) { - delete($backups[$i]); - } - } - - /** - * Ripristina un backup esistente. - * - * @param string $path - */ - public static function restore($path, $cleanup = true) - { - $database = database(); - $extraction_dir = is_dir($path) ? $path : Zip::extract($path); - - // TODO: Forzo il log out di tutti gli utenti e ne impedisco il login - // fino a ripristino ultimato - - // Rimozione del database - $tables = include base_dir().'/update/tables.php'; - - // Ripristino del database - $database_file = $extraction_dir.'/database.sql'; - if (file_exists($database_file)) { - $database->query('SET foreign_key_checks = 0'); - foreach ($tables as $table) { - $database->query('DROP TABLE IF EXISTS `'.$table.'`'); - } - $database->query('DROP TABLE IF EXISTS `updates`'); - - // Ripristino del database - $database->multiQuery($database_file); - $database->query('SET foreign_key_checks = 1'); - } - - // Salva il file di configurazione - $config = file_get_contents(base_dir().'/config.inc.php'); - - // Copia i file dalla cartella temporanea alla root - copyr($extraction_dir, base_dir()); - - // Ripristina il file di configurazione dell'installazione - file_put_contents(base_dir().'/config.inc.php', $config); - - // Pulizia - if (!empty($cleanup)) { - delete($extraction_dir); - } - delete(base_dir().'/database.sql'); - } - - /** - * Restituisce il percorso su cui salvare temporaneamente il dump del database. - * - * @return string - */ - protected static function getDatabaseDirectory() - { - $result = self::getDirectory().'/database'; - - if (!directory($result)) { - throw new UnexpectedValueException(); - } - - return slashes($result); - } - - /** - * Restituisce l'elenco delle variabili da sostituire normalizzato per l'utilizzo. - */ - protected static function getReplaces() - { - return Generator::getReplaces(); - } - - /** - * Restituisce il nome previsto per il backup successivo. - * - * @return string - */ - protected static function getNextName() - { - return Generator::generate(self::PATTERN); - } -} diff --git a/src/Common/Components/Accounting.php b/src/Common/Components/Accounting.php deleted file mode 100644 index 7fad0d717..000000000 --- a/src/Common/Components/Accounting.php +++ /dev/null @@ -1,436 +0,0 @@ -. - */ - -namespace Common\Components; - -use Illuminate\Database\Eloquent\Builder; -use Modules\Iva\Aliquota; - -/** - * Classe dedicata alla gestione delle informazioni contabili standard di una componente dei Documenti. - * - * Prevede i seguenti campi nel database: - * - * @property float costo_unitario - * @property float prezzo_unitario - * @property float iva_unitaria = prezzo_unitario * percentuale_iva - * @property float prezzo_unitario_ivato = prezzo_unitario + iva_unitaria - * @property float sconto_unitario - * @property float sconto_iva_unitario = sconto_unitario * percentuale_iva - * @property float sconto_unitario_ivato = sconto_unitario + sconto_iva_unitario - * @property float iva_unitaria_scontata = iva_unitaria - sconto_iva_unitario - - * Introduce i seguenti campi ausiliari: - * @property float imponibile = prezzo_unitario * qta - * @property float sconto = sconto_unitario * qta - * @property float totale_imponibile = (prezzo_unitario - sconto_unitario) * qta [Imponibile con sconto] - * @property float iva = (iva_unitaria - sconto_iva_unitario) * qta - * @property float totale = (prezzo_unitario_ivato - sconto_unitario_ivato) * qta [Totale imponibile con IVA] - * @property float importo = se incorpora_iva: totale, altrimenti: totale_imponibile - * @property float spesa = costo_unitario * qta - * - * Per una estensione del sistema dei totali (Rivalsa, Ritenuta, ...), si consiglia di introdurre un relativo Netto a pagare. [Fatture] - * - * @since 2.4.18 - */ -abstract class Accounting extends Component -{ - protected $casts = [ - 'qta' => 'float', - 'qta_evasa' => 'float', - 'prezzo_unitario' => 'float', - 'prezzo_unitario_ivato' => 'float', - 'iva_unitaria' => 'float', - 'iva_unitaria_scontata' => 'float', - 'sconto_percentuale' => 'float', - 'sconto_unitario' => 'float', - 'sconto_iva_unitario' => 'float', - 'sconto_unitario_ivato' => 'float', - //'qta_evasa' => 'float', - ]; - - protected $appends = [ - 'prezzo_unitario_corrente', - 'sconto_unitario_corrente', - 'max_qta', - 'spesa', - 'imponibile', - 'sconto', - 'totale_imponibile', - 'iva', - 'totale', - ]; - - protected $hidden = [ - 'document', - 'aliquota', - ]; - - public function getIvaIndetraibileAttribute() - { - return $this->iva / 100 * $this->aliquota->indetraibile; - } - - public function aliquota() - { - return $this->belongsTo(Aliquota::class, 'idiva'); - } - - public function getIvaAttribute() - { - return ($this->iva_unitaria - $this->sconto_iva_unitario) * $this->qta; - } - - /** - * Imposta il prezzo unitario secondo le informazioni indicate per valore e tipologia (UNT o PRC). - * - * @param $value - * @param $type - */ - public function setPrezzoUnitario($prezzo_unitario, $id_iva) - { - $this->id_iva = $id_iva; - - // Gestione IVA incorporata - if ($this->incorporaIVA()) { - $this->prezzo_unitario_ivato = $prezzo_unitario; - } else { - $this->prezzo_unitario = $prezzo_unitario; - } - } - - /** - * Restituisce il totale (imponibile + iva) dell'elemento. - * - * @return float - */ - public function getTotaleAttribute() - { - return ($this->prezzo_unitario_ivato - $this->sconto_unitario_ivato) * $this->qta; - } - - /** - * Restituisce l'imponibile dell'elemento (prezzo unitario senza IVA * qta). - * - * @return float - */ - public function getImponibileAttribute() - { - return $this->prezzo_unitario * $this->qta; - } - - /** - * Restituisce il tipo di sconto della riga corrente. - * - * @return float - */ - public function getTipoScontoAttribute() - { - return $this->sconto_percentuale ? 'PRC' : 'UNT'; - } - - /** - * Restituisce il margine totale (imponibile - spesa) relativo all'elemento. - * - * @return float - */ - public function getMargineAttribute() - { - return $this->totale_imponibile - $this->spesa; - } - - /** - * Restituisce l'importo (unitario oppure unitario ivato a seconda dell'impostazione 'Utilizza prezzi di vendita con IVA incorporata') per la riga. - * - * @return float - */ - public function getImportoAttribute() - { - return $this->incorporaIVA() ? $this->totale : $this->totale_imponibile; - } - - /** - * Restituisce il totale imponibile dell'elemento (imponibile - sconto unitario senza IVA). - * - * @return float - */ - public function getTotaleImponibileAttribute() - { - $result = $this->prezzo_unitario >= 0 ? $this->imponibile : -$this->imponibile; - - $result -= $this->sconto; - - return $this->prezzo_unitario >= 0 ? $result : -$result; - } - - /** - * Imposta il sconto unitario ivato (con IVA) per la riga corrente. - * - * @param $value - */ - public function setScontoUnitarioIvatoAttribute($value) - { - $this->attributes['sconto_unitario_ivato'] = $value; - $percentuale_iva = floatval($this->aliquota->percentuale) / 100; - - $this->attributes['sconto_iva_unitario'] = $value * $percentuale_iva / (1 + $percentuale_iva); // Calcolo IVA - $this->attributes['sconto_unitario'] = $value - $this->attributes['sconto_iva_unitario']; - } - - /** - * Restituisce la spesa (costo_unitario * qta) relativa all'elemento. - * - * @return float - */ - public function getSpesaAttribute() - { - return $this->costo_unitario * $this->qta; - } - - /** - * Restituisce l'iva detraibile dell'elemento. - * - * @return float - */ - public function getIvaDetraibileAttribute() - { - return $this->iva - $this->iva_indetraibile; - } - - /** - * Restituisce l'iva unitaria con lo sconto applicato. - * - * @return float - */ - public function getIvaUnitariaScontataAttribute() - { - return $this->iva_unitaria - $this->sconto_iva_unitario; - } - - /** - * Restituisce lo sconto unitario corrente (unitario oppure unitario ivato a seconda dell'impostazione 'Utilizza prezzi di vendita comprensivi di IVA') per la riga. - * - * @return float - */ - public function getScontoUnitarioCorrenteAttribute() - { - // Gestione IVA incorporata - if ($this->incorporaIVA()) { - return $this->sconto_unitario_ivato; - } else { - return $this->sconto_unitario; - } - } - - /** - * Imposta lo sconto secondo le informazioni indicate per valore e tipologia (UNT o PRC). - * - * @param $value - * @param $type - */ - public function setSconto($value, $type) - { - $incorpora_iva = $this->incorporaIVA(); - - if ($type == 'PRC') { - $this->attributes['sconto_percentuale'] = $value; - - $sconto = calcola_sconto([ - 'sconto' => $value, - 'prezzo' => $incorpora_iva ? $this->prezzo_unitario_ivato : $this->prezzo_unitario, - 'tipo' => 'PRC', - 'qta' => 1, - ]); - } else { - $this->attributes['sconto_percentuale'] = 0; - $sconto = $value; - } - - // Gestione IVA incorporata - if ($incorpora_iva) { - $this->sconto_unitario_ivato = $sconto; - } else { - $this->sconto_unitario = $sconto; - } - } - - public function incorporaIVA() - { - return $this->getDocument()->direzione == 'entrata' && setting('Utilizza prezzi di vendita comprensivi di IVA'); - } - - /** - * Imposta il prezzo unitario (senza IVA) per la riga corrente. - * - * @param $value - */ - public function setPrezzoUnitarioAttribute($value) - { - $this->attributes['prezzo_unitario'] = $value; - $percentuale_iva = floatval($this->aliquota->percentuale) / 100; - - $this->attributes['iva_unitaria'] = $value * $percentuale_iva; // Calcolo IVA - $this->attributes['prezzo_unitario_ivato'] = $value + $this->attributes['iva_unitaria']; - } - - /** - * Restituisce lo sconto della riga corrente in euro. - * - * @return float - */ - public function getScontoAttribute() - { - return $this->qta * $this->sconto_unitario; - } - - /** - * Restituisce il prezzo unitario corrente (unitario oppure unitario ivato a seconda dell'impostazione 'Utilizza prezzi di vendita comprensivi di IVA') per la riga. - * - * @return float - */ - public function getPrezzoUnitarioCorrenteAttribute() - { - // Gestione IVA incorporata - if ($this->incorporaIVA()) { - return $this->prezzo_unitario_ivato; - } else { - return $this->prezzo_unitario; - } - } - - /** - * Restituisce il margine percentuale relativo all'elemento. - * - * @return float - */ - public function getMarginePercentualeAttribute() - { - return $this->imponibile ? (1 - ($this->spesa / $this->imponibile)) * 100 : 100; - } - - /** - * Imposta il prezzo unitario ivato (con IVA) per la riga corrente. - * - * @param $value - */ - public function setPrezzoUnitarioIvatoAttribute($value) - { - $this->attributes['prezzo_unitario_ivato'] = $value; - $percentuale_iva = floatval($this->aliquota->percentuale) / 100; - - $this->attributes['iva_unitaria'] = $value * $percentuale_iva / (1 + $percentuale_iva); // Calcolo IVA - $this->attributes['prezzo_unitario'] = $value - $this->attributes['iva_unitaria']; - } - - /** - * Imposta il sconto unitario (senza IVA) per la riga corrente. - * - * @param $value - */ - public function setScontoUnitarioAttribute($value) - { - $this->attributes['sconto_unitario'] = $value; - $percentuale_iva = floatval($this->aliquota->percentuale) / 100; - - $this->attributes['sconto_iva_unitario'] = $value * $percentuale_iva; // Calcolo IVA - $this->attributes['sconto_unitario_ivato'] = $value + $this->attributes['sconto_iva_unitario']; - } - - /** - * Imposta l'identificatore dell'IVA. - * - * @param int $value - */ - public function setIdIvaAttribute($value) - { - $this->attributes['idiva'] = $value; - $this->load('aliquota'); - } - - public function getSubtotaleAttribute() - { - return $this->imponibile; - } - - /** - * Salva la riga, impostando i campi dipendenti dai singoli parametri. - * - * @return bool - */ - public function save(array $options = []) - { - // Fix dei campi statici - $this->fixSubtotale(); - $this->fixSconto(); - - $this->fixIva(); - - return parent::save($options); - } - - /** - * Effettua i conti per il subtotale della riga. - */ - protected function fixSubtotale() - { - $this->attributes['subtotale'] = $this->imponibile; - } - - /** - * Effettua i conti per l'IVA. - */ - protected function fixIva() - { - $this->attributes['iva'] = $this->iva; - - $descrizione = $this->aliquota->descrizione; - if (!empty($descrizione)) { - $this->attributes['desc_iva'] = $descrizione; - } - - $this->fixIvaIndetraibile(); - } - - /** - * Effettua i conti per l'IVA indetraibile. - */ - protected function fixIvaIndetraibile() - { - $this->attributes['iva_indetraibile'] = $this->iva_indetraibile; - } - - /** - * Effettua i conti per lo sconto totale. - */ - protected function fixSconto() - { - $this->attributes['sconto'] = $this->sconto; - $this->attributes['tipo_sconto'] = $this->sconto_percentuale ? 'PRC' : 'UNT'; - } - - protected static function boot() - { - parent::boot(); - - // Pre-caricamento Aliquota IVA - static::addGlobalScope('aliquota', function (Builder $builder) { - $builder->with('aliquota'); - }); - } -} diff --git a/src/Common/Components/Article.php b/src/Common/Components/Article.php deleted file mode 100755 index ad1f64f0d..000000000 --- a/src/Common/Components/Article.php +++ /dev/null @@ -1,408 +0,0 @@ -. - */ - -namespace Common\Components; - -use Common\Document; -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Builder; -use Modules\Articoli\Articolo as Original; -use Modules\Articoli\Movimento; -use Plugins\ListinoFornitori\DettaglioFornitore; -use UnexpectedValueException; - -abstract class Article extends Accounting -{ - use SimpleModelTrait; - - protected $abilita_movimentazione = true; - - protected $serialRowID = null; - protected $serialsList = null; - - protected $qta_movimentazione = 0; - - public static function build(Document $document, Original $articolo) - { - $model = new static(); - $model->setDocument($document); - - $model->articolo()->associate($articolo); - - $model->descrizione = $articolo->descrizione; - $model->abilita_serial = $articolo->abilita_serial; - $model->um = $articolo->um; - - return $model; - } - - public function isDescrizione() - { - return false; - } - - public function isSconto() - { - return false; - } - - public function isRiga() - { - return false; - } - - public function isArticolo() - { - return true; - } - - /** - * Metodo dedicato a gestire in automatico la movimentazione del magazzino in relazione all'articolo di riferimento sulla base delle caratteristiche del movimento (magazzino abilitato o meno). - * - * @param $qta - */ - public function movimenta($qta) - { - if (!$this->getDocument()->movimenta_magazzino) { - return; - } - - $movimenta = true; - - // Movimenta il magazzino solo se l'articolo non è già stato movimentato da un documento precedente - if ($this->hasOriginalComponent()) { - $original = $this->getOriginalComponent(); - $movimenta = !$original->getDocument()->movimenta_magazzino; - } - - if ($movimenta) { - $this->movimentaMagazzino($qta); - } - } - - public function getDirection() - { - return $this->getDocument()->direzione; - } - - /** - * Restituisce il codice impostato per l'articolo corrente. - */ - public function getCodiceAttribute() - { - return $this->dettaglioFornitore->codice_fornitore ?: $this->articolo->codice; - } - - /** - * Imposta i seriali collegati all'articolo. - * - * @param array $serials - */ - public function setSerialsAttribute($serials) - { - if (!$this->useSerials()) { - return; - } - - // Inversione di movimento nei seriali in caso di nota di credito - $dir = $this->getDirection(); - - $document = $this->getDocument(); - - if ($document instanceof \Modules\Fatture\Fattura) { - if ($document->isNota()) { - if ($this->getDirection() == 'uscita') { - $dir = 'entrata'; - } else { - $dir = 'uscita'; - } - } - } - - $serials = array_clean($serials); - - database()->sync('mg_prodotti', [ - 'id_riga_'.$this->serialRowID => $this->id, - 'dir' => $dir, - 'id_articolo' => $this->idarticolo, - ], [ - 'serial' => $serials, - ]); - - $this->serialsList = $serials; - } - - /** - * Rimuove i seriali collegati all'articolo. - * - * @param array $serials - */ - public function removeSerials($serials) - { - if (!$this->useSerials()) { - return; - } - - database()->detach('mg_prodotti', [ - 'id_riga_'.$this->serialRowID => $this->id, - 'dir' => $this->getDirection(), - 'id_articolo' => $this->idarticolo, - ], [ - 'serial' => array_clean($serials), - ]); - - $this->serialsList = null; - } - - /** - * Restituisce l'elenco dei seriali collegati all'articolo del documento. - * - * @return array - */ - public function getSerialsAttribute() - { - if (!$this->useSerials()) { - return []; - } - - if (!isset($this->serialsList)) { - // Individuazione dei seriali - $results = database()->fetchArray('SELECT serial FROM mg_prodotti WHERE serial IS NOT NULL AND id_riga_'.$this->serialRowID.' = '.prepare($this->id)); - - $this->serialsList = array_column($results, 'serial'); - } - - return $this->serialsList; - } - - /** - * Restituisce il numero di seriali mancanti per il completamento dell'articolo. - * - * @return float - */ - public function getMissingSerialsNumberAttribute() - { - if (!$this->useSerials()) { - return 0; - } - - $missing = $this->qta - count($this->serials); - - return $missing; - } - - /** - * Modifica la quantità dell'articolo e movimenta automaticamente il magazzino. - * - * @param float $value - */ - public function setQtaAttribute($value) - { - if (!$this->cleanupSerials($value)) { - throw new UnexpectedValueException(); - } - - $diff = parent::setQtaAttribute($value); - - if ($this->abilita_movimentazione) { - $this->qta_movimentazione += $diff; - } - } - - public function articolo() - { - return $this->belongsTo(Original::class, 'idarticolo') - ->withTrashed(); - } - - public function dettaglioFornitore() - { - return $this->belongsTo(DettaglioFornitore::class, 'id_dettaglio_fornitore')->withTrashed(); - } - - public function movimentazione($value = true) - { - $this->abilita_movimentazione = $value; - } - - /** - * Salva l'articolo, eventualmente movimentandone il magazzino. - * - * @return bool - */ - public function save(array $options = []) - { - if (!empty($this->qta_movimentazione)) { - $this->movimenta($this->qta_movimentazione); - $this->qta_movimentazione = 0; - } - - return parent::save($options); - } - - public function canDelete() - { - $serials = $this->usedSerials(); - - return empty($serials); - } - - public function delete() - { - if (!$this->canDelete()) { - throw new \InvalidArgumentException(); - } - - $this->serials = []; - - $this->qta = 0; // Fix movimentazione automatica - if (!empty($this->qta_movimentazione)) { - $this->movimenta($this->qta_movimentazione); - } - - return parent::delete(); - } - - protected function useSerials() - { - return !empty($this->abilita_serial) && !empty($this->serialRowID); - } - - protected function movimentaMagazzino($qta) - { - $documento = $this->getDocument(); - $data = $documento->getReferenceDate(); - - $qta_movimento = $documento->direzione == 'uscita' ? $qta : -$qta; - $movimento = Movimento::descrizioneMovimento($qta_movimento, $documento->direzione).' - '.$documento->getReference(); - - if ($documento instanceof \Modules\Interventi\Intervento) { - $id_sede = $this->idsede_partenza; - } else { - $id_sede = $documento->direzione == 'uscita' ? $documento->idsede_destinazione : $documento->idsede_partenza; - } - - // Fix per valori di sede a NULL - $id_sede = $id_sede ?: 0; - - $this->articolo->movimenta($qta_movimento, $movimento, $data, false, [ - 'reference_type' => get_class($documento), - 'reference_id' => $documento->id, - 'idsede' => $id_sede, - ]); - } - - protected static function boot() - { - parent::boot(); - - // Pre-caricamento Articolo - static::addGlobalScope('articolo', function (Builder $builder) { - $builder->with('articolo', 'dettaglioFornitore'); - }); - - $table = static::getTableName(); - static::addGlobalScope('articles', function (Builder $builder) use ($table) { - $builder->whereNotNull($table.'.idarticolo')->where($table.'.idarticolo', '<>', 0); - }); - } - - /** - * Restituisce l'elenco dei seriali collegati e utilizzati da altri documenti. - * - * @return array - */ - protected function usedSerials() - { - if (!$this->useSerials()) { - return []; - } - if ($this->getDirection() == 'uscita') { - $results = database()->fetchArray("SELECT serial FROM mg_prodotti WHERE serial IN (SELECT DISTINCT serial FROM mg_prodotti WHERE dir = 'entrata') AND serial IS NOT NULL AND id_riga_".$this->serialRowID.' = '.prepare($this->id)); - - return array_column($results, 'serial'); - } - - return []; - } - - /** - * Pulisce i seriali non utilizzati nel caso di riduzione della quantità, se possibile. - * - * @param $new_qta - * - * @return bool - */ - protected function cleanupSerials($new_qta) - { - if (!$this->useSerials()) { - return true; - } - - // Se la nuova quantità è minore della precedente - if ($this->qta > $new_qta) { - $seriali_usati = $this->usedSerials(); - $count_seriali_usati = count($seriali_usati); - - // Controllo sulla possibilità di rimuovere i seriali (se non utilizzati da documenti di vendita) - if ($this->getDirection() == 'uscita' && $new_qta < $count_seriali_usati) { - return false; - } else { - // Controllo sul numero di seriali effettivi da rimuovere - $seriali = $this->serials; - - if ($new_qta < count($seriali)) { - $rimovibili = array_diff($seriali, $seriali_usati); - - // Rimozione dei seriali aggiuntivi - $serials = array_slice($rimovibili, 0, $new_qta - $count_seriali_usati); - - $this->serials = array_merge($seriali_usati, $serials); - } - } - } - - return true; - } - - /** - * Azione personalizzata per la copia dell'oggetto (dopo la copia). - * - * Forza il salvataggio del prezzo_unitario, per rendere compatibile il sistema con gli Interventi. - * - * @param $original - */ - protected function customAfterDataCopiaIn($original) - { - $this->prezzo_unitario = $original->prezzo_unitario; - $this->sconto_unitario = $original->sconto_unitario; - - parent::customAfterDataCopiaIn($original); - } - - /** - * Azione personalizzata per la copia dell'oggetto (inizializzazione della copia). - * - * @param $original - */ - protected function customInitCopiaIn($original) - { - $this->articolo()->associate($original->articolo); - } -} diff --git a/src/Common/Components/Component.php b/src/Common/Components/Component.php deleted file mode 100644 index 3ca4b0140..000000000 --- a/src/Common/Components/Component.php +++ /dev/null @@ -1,438 +0,0 @@ -. - */ - -namespace Common\Components; - -use Common\Document; -use Common\RowReference; -use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\Model; -use InvalidArgumentException; - -/** - * Classe dedicata alla gestione delle informazioni di base dei componenti dei Documenti, e in particolare di: - * - Collegamento con il Documento do origine - * - Riferimento di origine - * - Riferimenti informativi tra righe di altri documenti - * - Importazione tra documenti distinti di un componente. - * - * @property string original_type - * @property string original_id - * @property string original_document_id - * @property string original_document_type - * - * @template T - * - * @since 2.4.18 - */ -abstract class Component extends Model -{ - /** - * Componente di origine da cui il compontente corrente deriva. - * - * @var Component|null - */ - protected $original_model = null; - - protected $guarded = []; - - protected $appends = [ - 'max_qta', - ]; - - protected $hidden = [ - 'document', - ]; - - public function hasOriginalComponent() - { - return !empty($this->original_type) && !empty($this->getOriginalComponent()); - } - - public function getOriginalComponent() - { - if (!isset($this->original_model) && !empty($this->original_type)) { - $class = $this->original_type; - - $this->original_model = $class::find($this->original_id); - } - - return $this->original_model; - } - - public function referenceSources() - { - $class = get_class($this); - - return $this->hasMany(RowReference::class, 'target_id') - ->where('target_type', $class); - } - - public function referenceTargets() - { - $class = get_class($this); - - return $this->hasMany(RowReference::class, 'source_id') - ->where('source_type', $class); - } - - /** - * Restituisce l'eventuale limite sulla quantità massima derivato dal componente di origine. - * - * @return mixed|null - */ - public function getMaxQtaAttribute() - { - if (!$this->hasOriginalComponent()) { - return null; - } - - $original = $this->getOriginalComponent(); - - return $original->qta_rimanente + $this->qta; - } - - /** - * Modifica la quantità del componente. - * - * @param float $value - * - * @return float - */ - public function setQtaAttribute($value) - { - list($qta, $diff) = $this->parseQta($value); - $this->attributes['qta'] = $qta; - - // Aggiornamento della quantità evasa di origine - if ($this->hasOriginalComponent()) { - $original = $this->getOriginalComponent(); - - $original->qta_evasa += $diff; - $original->save(); - } - - return $diff; - } - - /** - * Restituisce la quantità rimanente del componente. - * - * @return float - */ - public function getQtaRimanenteAttribute() - { - return $this->qta - $this->qta_evasa; - } - - /** - * Gestisce la possibilità di eliminare il componente. - * - * @return bool - */ - public function canDelete() - { - return true; - } - - public function delete() - { - if (!$this->canDelete()) { - throw new InvalidArgumentException(); - } - - if ($this->hasOriginalComponent()) { - $original = $this->getOriginalComponent(); - } - - $this->qta = 0; - $result = parent::delete(); - - // Trigger per la modifica delle righe - $this->getDocument()->triggerComponent($this); - - // Trigger per l'evasione delle quantità - if ($this->hasOriginalComponent()) { - $original->getDocument()->triggerEvasione($this); - } - - // Ordine delle righe successivamente alla rimozione - if (empty($this->disableOrder)) { - reorderRows($this->table, $this->getDocumentID(), $this->getDocument()['id']); - } - - return $result; - } - - /** - * Copia l'oggetto (articolo, riga, descrizione) nel corrispettivo per il documento indicato. - * - * @param Document $document Documento di destinazione - * @param float|null $qta Quantità da riportare - * @param bool $evadi_qta_parent Definisce se evadere la quantità di provenienza - * - * @return self - */ - public function copiaIn(Document $document, $qta = null, $evadi_qta_parent = true) - { - // Individuazione classe di destinazione - $class = get_class($document); - $namespace = implode('\\', explode('\\', $class, -1)); - - $current = get_class($this); - $pieces = explode('\\', $current); - $type = end($pieces); - - $object = $namespace.'\\Components\\'.$type; - - // Attributi dell'oggetto da copiare - $attributes = $this->getAttributes(); - - // Rimozione attributi problematici - $remove = ['id', 'order', 'original_id', 'original_type', 'original_document_id', 'original_document_type']; - $attributes = array_diff_key($attributes, array_flip($remove)); - - if ($qta !== null) { - $attributes['qta'] = $qta; - } - - $attributes['qta_evasa'] = 0; - - // Creazione del nuovo oggetto - $model = new $object(); - - // Rimozione attributo in conflitto - unset($attributes[$model->getDocumentID()]); - - // Riferimento di origine per l'evasione automatica della riga - if ($evadi_qta_parent) { - // Mantenimento dell'origine della riga precedente - // Utilizzato per la rimozione del riferimento precedente dalla descrizione - $model->original_id = $this->original_id; - $model->original_type = $this->original_type; - - // Aggiornamento dei riferimenti - list($riferimento_precedente, $nuovo_riferimento) = $model->impostaOrigine($this); - - // Correzione della descrizione - $attributes['descrizione'] = str_replace($riferimento_precedente, '', $attributes['descrizione']); - $attributes['descrizione'] .= $nuovo_riferimento; - } - - // Impostazione del genitore - $model->setDocument($document); - - // Azioni specifiche di inizializzazione - $model->customInitCopiaIn($this); - - $model->save(); - - // Impostazione degli attributi - $model = $object::find($model->id); - $accepted = $model->getAttributes(); - - // Azioni specifiche precedenti - $model->customBeforeDataCopiaIn($this); - - $attributes = array_intersect_key($attributes, $accepted); - $model->fill($attributes); - - // Azioni specifiche successive - $model->customAfterDataCopiaIn($this); - - $model->save(); - - return $model; - } - - /** - * Imposta l'origine del componente, restituendo un array contenente i replace da effettuare per modificare la descrizione in modo coerente. - * - * @param string $type - * @param string $id - * - * @return array - */ - public function impostaOrigine($riga) - { - $riferimento_precedente = null; - $nuovo_riferimento = null; - - // Rimozione del riferimento precedente dalla descrizione - if ($this->hasOriginalComponent()) { - $riferimento_precedente = self::getDescrizioneRiferimento( - $this->getOriginalComponent()->getDocument() - ); - } - - // Informazioni del nuovo riferimento - if (!empty($riga)) { - $this->original_id = $riga->id; - $this->original_type = get_class($riga); - - $documento_origine = $riga->getDocument(); - $this->original_document_id = $documento_origine->id; - $this->original_document_type = get_class($documento_origine); - - // Aggiunta del riferimento nella descrizione - $nuovo_riferimento = self::getDescrizioneRiferimento( - $documento_origine - ); - } - // Rimozione dei riferimenti precedenti - else { - $this->original_id = null; - $this->original_type = null; - $this->original_document_id = null; - $this->original_document_type = null; - } - - return [$riferimento_precedente, $nuovo_riferimento]; - } - - public static function getDescrizioneRiferimento(Document $origine) - { - $riferimento = $origine->getReference(); - - return "\nRif. ".strtolower($riferimento); - } - - /** - * Imposta il proprietario dell'oggetto e l'ordine relativo all'interno delle righe. - * - * @param Document $document Documento di riferimento - * @psalm-param T $document - */ - public function setDocument(Document $document) - { - $this->document()->associate($document); - - // Ordine delle righe - if (empty($this->disableOrder)) { - $this->order = orderValue($this->table, $this->getDocumentID(), $document->id); - } - } - - /** - * @return Document - * @psalm-return T - */ - public function getDocument() - { - return $this->document; - } - - abstract public function document(); - - /** - * @return string - */ - abstract public function getDocumentID(); - - public function save(array $options = []) - { - $result = parent::save($options); - - // Trigger per la modifica delle righe - $this->getDocument()->triggerComponent($this); - - // Trigger per l'evasione delle quantità - if ($this->hasOriginalComponent()) { - $original = $this->getOriginalComponent(); - - $original->getDocument()->triggerEvasione($this); - } - - return $result; - } - - public function replicate(array $except = null) - { - $new = parent::replicate($except); - - $new->qta_evasa = 0; - $new->original_type = null; - $new->original_id = null; - - return $new; - } - - /** - * Verifica e calcola quantità e differenziale delle quantità. - * - * @param $value - * - * @return array [nuova quantità, differenza rispetto alla quantità precedente] - */ - protected function parseQta($value) - { - $previous = $this->qta; - $diff = $value - $previous; - - // Controlli su eventuale massimo per la quantità - if ($this->hasOriginalComponent()) { - $original = $this->getOriginalComponent(); - - // Controllo per evitare di superare la quantità totale del componente di origine - if ($original->qta_rimanente < $diff && empty(setting('Permetti il superamento della soglia quantità dei documenti di origine'))) { - $diff = $original->qta_rimanente; - $value = $previous + $diff; - } - } - - return [$value, $diff]; - } - - /** - * Azione personalizzata per la copia dell'oggetto (inizializzazione della copia). - * - * @param $original - */ - protected function customInitCopiaIn($original) - { - } - - /** - * Azione personalizzata per la copia dell'oggetto (dopo la copia). - * - * @param $original - */ - protected function customBeforeDataCopiaIn($original) - { - } - - /** - * Azione personalizzata per la copia dell'oggetto (dopo la copia). - * - * @param $original - */ - protected function customAfterDataCopiaIn($original) - { - } - - protected static function boot() - { - // Pre-caricamento Documento - static::addGlobalScope('document', function (Builder $builder) { - $builder->with('document'); - }); - - parent::boot(); - } -} diff --git a/src/Common/Components/Description.php b/src/Common/Components/Description.php deleted file mode 100755 index 8490de507..000000000 --- a/src/Common/Components/Description.php +++ /dev/null @@ -1,82 +0,0 @@ -. - */ - -namespace Common\Components; - -use Common\Document; -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Builder; - -abstract class Description extends Component -{ - use SimpleModelTrait; - - public static function build(Document $document) - { - $model = new static(); - - $model->is_descrizione = 1; - $model->qta = 1; - - $model->setDocument($document); - - return $model; - } - - public function isDescrizione() - { - return true; - } - - public function isSconto() - { - return false; - } - - public function isRiga() - { - return false; - } - - public function isArticolo() - { - return false; - } - - /** - * Azione personalizzata per la copia dell'oggetto (inizializzazione della copia). - * - * @param $original - */ - protected function customInitCopiaIn($original) - { - $this->is_descrizione = $original->is_descrizione; - } - - protected static function boot($bypass = false) - { - // Pre-caricamento Documento - parent::boot(); - - $table = static::getTableName(); - static::addGlobalScope('descriptions', function (Builder $builder) use ($table) { - $builder->where($table.'.is_descrizione', '=', 1); - }); - } -} diff --git a/src/Common/Components/Discount.php b/src/Common/Components/Discount.php deleted file mode 100755 index 258bd9120..000000000 --- a/src/Common/Components/Discount.php +++ /dev/null @@ -1,128 +0,0 @@ -. - */ - -namespace Common\Components; - -use Common\Document; -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Builder; - -abstract class Discount extends Accounting -{ - use SimpleModelTrait; - - public static function build(Document $document) - { - $model = new static(); - $model->setDocument($document); - - $model->is_sconto = 1; - $model->qta = 1; - - return $model; - } - - public function isDescrizione() - { - return false; - } - - public function isSconto() - { - return true; - } - - public function isRiga() - { - return false; - } - - public function isArticolo() - { - return false; - } - - public function getIvaAttribute() - { - return $this->attributes['iva']; - } - - public function isMaggiorazione() - { - return $this->totale_imponibile < 0; - } - - /** - * Imposta lo sconto unitario secondo le informazioni indicate per valore e tipologia (UNT o PRC). - * - * @param float $valore_unitario - * @param int $id_iva - */ - public function setScontoUnitario($valore_unitario, $id_iva) - { - $this->id_iva = $id_iva; - - // Gestione IVA incorporata - if ($this->incorporaIVA()) { - $this->sconto_unitario_ivato = $valore_unitario; - } else { - $this->sconto_unitario = $valore_unitario; - } - } - - public function setPrezzoUnitario($prezzo_unitario, $id_iva) - { - throw new \InvalidArgumentException(); - } - - public function setSconto($value, $type) - { - throw new \InvalidArgumentException(); - } - - /** - * Effettua i conti per l'IVA. - */ - protected function fixIva() - { - $this->attributes['iva'] = parent::getIvaAttribute(); - - $descrizione = $this->aliquota->descrizione; - if (!empty($descrizione)) { - $this->attributes['desc_iva'] = $descrizione; - } - - $this->fixIvaIndetraibile(); - } - - protected function customInitCopiaIn($original) - { - $this->is_sconto = $original->is_sconto; - } - - protected static function boot($bypass = false) - { - parent::boot(); - - $table = static::getTableName(); - static::addGlobalScope('discounts', function (Builder $builder) use ($table) { - $builder->where($table.'.is_sconto', '=', 1); - }); - } -} diff --git a/src/Common/Components/Row.php b/src/Common/Components/Row.php deleted file mode 100755 index d17fffd46..000000000 --- a/src/Common/Components/Row.php +++ /dev/null @@ -1,90 +0,0 @@ -. - */ - -namespace Common\Components; - -use Common\Document; -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Builder; - -abstract class Row extends Accounting -{ - use SimpleModelTrait; - - public static function build(Document $document) - { - $model = new static(); - $model->setDocument($document); - - return $model; - } - - public function isDescrizione() - { - return false; - } - - public function isSconto() - { - return false; - } - - public function isRiga() - { - return true; - } - - public function isArticolo() - { - return false; - } - - protected static function boot() - { - parent::boot(); - - $table = static::getTableName(); - static::addGlobalScope('not_articles', function (Builder $builder) use ($table) { - $builder->whereNull($table.'.idarticolo')->orWhere($table.'.idarticolo', '=', 0); - }); - - static::addGlobalScope('not_discounts', function (Builder $builder) use ($table) { - $builder->where($table.'.is_sconto', '=', 0); - }); - - static::addGlobalScope('not_descriptions', function (Builder $builder) use ($table) { - $builder->where($table.'.is_descrizione', '=', 0); - }); - } - - /** - * Azione personalizzata per la copia dell'oggetto (dopo la copia). - * - * Forza il salvataggio del prezzo_unitario, per rendere compatibile il sistema con gli Interventi. - * - * @param $original - */ - protected function customAfterDataCopiaIn($original) - { - $this->prezzo_unitario = $original->prezzo_unitario; - $this->sconto_unitario = $original->sconto_unitario; - - parent::customAfterDataCopiaIn($original); - } -} diff --git a/src/Common/Document.php b/src/Common/Document.php deleted file mode 100755 index 364f0b674..000000000 --- a/src/Common/Document.php +++ /dev/null @@ -1,320 +0,0 @@ -. - */ - -namespace Common; - -use Common\Components\Component; -use Illuminate\Database\Eloquent\Model as Model; - -abstract class Document extends Model implements ReferenceInterface, DocumentInterface -{ - /** - * Abilita la movimentazione automatica degli Articoli, finalizzata alla gestione interna del magazzino. - * - * @var bool - */ - public static $movimenta_magazzino = true; - protected $casts = [ - 'sconto_finale' => 'float', - 'sconto_finale_percentuale' => 'float', - ]; - - /** - * Restituisce il valore della variabile statica $movimenta_magazzino per il documento. - * - * @return bool - */ - public function getMovimentaMagazzinoAttribute() - { - return static::$movimenta_magazzino; - } - - public function getRighe() - { - $results = $this->mergeCollections($this->descrizioni, $this->righe, $this->articoli, $this->sconti); - - return $results->sortBy(function ($item) { - return [$item->order, $item->id]; - }); - } - - public function getRiga($type, $id) - { - $righe = $this->getRighe(); - - return $righe->first(function ($item) use ($type, $id) { - return $item instanceof $type && $item->id == $id; - }); - } - - public function getRigheRaggruppate() - { - $righe = $this->getRighe(); - - $groups = $righe->groupBy(function ($item, $key) { - if (!$item->hasOriginalComponent()) { - return null; - } - - $parent = $item->getOriginalComponent()->getDocument(); - - return serialize($parent); - }); - - return $groups; - } - - abstract public function righe(); - - abstract public function articoli(); - - abstract public function descrizioni(); - - abstract public function sconti(); - - abstract public function getDirezioneAttribute(); - - public function triggerEvasione(Component $trigger) - { - $this->setRelations([]); - } - - public function triggerComponent(Component $trigger) - { - $this->setRelations([]); - } - - /** - * Calcola l'imponibile del documento. - * - * @return float - */ - public function getImponibileAttribute() - { - return $this->calcola('imponibile'); - } - - /** - * Calcola lo sconto totale del documento. - * - * @return float - */ - public function getScontoAttribute() - { - return $this->calcola('sconto'); - } - - /** - * Calcola il totale imponibile del documento. - * - * @return float - */ - public function getTotaleImponibileAttribute() - { - return $this->calcola('totale_imponibile'); - } - - /** - * Calcola l'IVA totale del documento. - * - * @return float - */ - public function getIvaAttribute() - { - return $this->calcola('iva'); - } - - /** - * Calcola il totale del documento. - * - * @return float - */ - public function getTotaleAttribute() - { - return $this->calcola('totale'); - } - - /** - * Calcola la spesa totale relativa alla fattura. - * - * @return float - */ - public function getSpesaAttribute() - { - return $this->calcola('spesa'); - } - - /** - * Calcola il margine del documento. - * - * @return float - */ - public function getMargineAttribute() - { - return $this->calcola('margine'); - } - - /** - * Restituisce il margine percentuale del documento. - * - * @return float - */ - public function getMarginePercentualeAttribute() - { - return $this->imponibile ? (1 - ($this->spesa / $this->totale_imponibile)) * 100 : 100; - } - - public function delete() - { - $righe = $this->getRighe(); - - $can_delete = true; - foreach ($righe as $riga) { - $can_delete &= $riga->canDelete(); - } - - if (!$can_delete) { - throw new \InvalidArgumentException(); - } - - foreach ($righe as $riga) { - $riga->delete(); - } - - return parent::delete(); - } - - public function toArray() - { - $array = parent::toArray(); - - $result = array_merge($array, [ - 'spesa' => $this->spesa, - 'imponibile' => $this->imponibile, - 'sconto' => $this->sconto, - 'totale_imponibile' => $this->totale_imponibile, - 'iva' => $this->iva, - 'totale' => $this->totale, - ]); - - return $result; - } - - /** - * Imposta lo sconto finale. - * - * @param $sconto - * @param $tipo - */ - public function setScontoFinale($sconto, $tipo) - { - if ($tipo == 'PRC') { - $this->sconto_finale_percentuale = $sconto; - $this->sconto_finale = 0; - } else { - $this->sconto_finale = $sconto; - $this->sconto_finale_percentuale = 0; - } - } - - /** - * Restituisce lo sconto finale. - */ - public function getScontoFinale() - { - $netto = $this->calcola('netto'); - - if (!empty($this->sconto_finale_percentuale)) { - $sconto = $netto * ($this->sconto_finale_percentuale / 100); - } else { - $sconto = $this->sconto_finale; - } - - return $sconto; - } - - /** - * Calcola il netto a pagare del documento. - * - * @return float - */ - public function getNettoAttribute() - { - $netto = $this->calcola('netto'); - $sconto_finale = $this->getScontoFinale(); - - return $netto - $sconto_finale; - } - - /** - * Costruisce una nuova collezione Laravel a partire da quelle indicate. - * - * @param array<\Illuminate\Support\Collection> ...$args - * - * @return \Illuminate\Support\Collection - */ - protected function mergeCollections(...$args) - { - $collection = collect($args); - - return $collection->collapse(); - } - - /** - * Calcola la somma degli attributi indicati come parametri. - * Il metodo **non** deve essere adattato per ulteriori funzionalità: deve esclusivamente calcolare la somma richiesta in modo esplicito dagli argomenti. - * - * @param mixed ...$args - * - * @return float - */ - protected function calcola(...$args) - { - $result = 0; - foreach ($args as $arg) { - $result += $this->getRigheContabili()->sum($arg); - } - - return $this->round($result); - } - - /** - * Restituisce la collezione di righe e articoli con valori rilevanti per i conti. - * - * @return iterable - */ - protected function getRigheContabili() - { - return $this->getRighe(); - } - - /** - * Funzione per l'arrotondamento degli importi. - * - * @param float $value - * - * @return float - */ - protected function round($value) - { - $decimals = 2; - - return round($value, $decimals); - } -} diff --git a/src/Common/DocumentInterface.php b/src/Common/DocumentInterface.php deleted file mode 100644 index f0ba392f0..000000000 --- a/src/Common/DocumentInterface.php +++ /dev/null @@ -1,69 +0,0 @@ -. - */ - -namespace Common; - -use Common\Components\Component; - -interface DocumentInterface -{ - /** - * Restituisce la collezione di righe e articoli con valori rilevanti per i conti. - * - * @return iterable - */ - public function getRighe(); - - /** - * Restituisce la riga identificata dall'ID indicato. - * - * @param $type - * @param $id - * - * @return mixed - */ - public function getRiga($type, $id); - - /** - * Restituisce la collezione di righe e articoli con valori rilevanti per i conti, raggruppate sulla base dei documenti di provenienza. - * La chiave è la serializzazione del documento di origine, oppure null in caso non esista. - * - * @return iterable - */ - public function getRigheRaggruppate(); - - /** - * Restituisce la direzione in relazione al flusso di denaro impostata per il documento. - * - * @return string 'entrata'|'uscita' - */ - public function getDirezioneAttribute(); - - /** - * Metodo richiamato a seguito di modifiche sull'evasione generale delle righe del documento. - * Utilizzabile per l'impostazione automatica degli stati. - */ - public function triggerEvasione(Component $trigger); - - /** - * Metodo richiamato a seguito della modifica o creazione di una riga del documento. - * Utilizzabile per l'impostazione automatica di campi statici del documento. - */ - public function triggerComponent(Component $trigger); -} diff --git a/src/Common/Model.php b/src/Common/Model.php deleted file mode 100755 index 9487ab693..000000000 --- a/src/Common/Model.php +++ /dev/null @@ -1,30 +0,0 @@ -. - */ - -namespace Common; - -use Illuminate\Database\Eloquent\Model as Original; - -/** - * @deprecated 2.4.18 - */ -abstract class Model extends Original -{ - use SimpleModelTrait; -} diff --git a/src/Common/ReferenceInterface.php b/src/Common/ReferenceInterface.php deleted file mode 100755 index dc95fce23..000000000 --- a/src/Common/ReferenceInterface.php +++ /dev/null @@ -1,33 +0,0 @@ -. - */ - -namespace Common; - -interface ReferenceInterface -{ - public function getReferenceName(); - - public function getReferenceNumber(); - - public function getReferenceDate(); - - public function getReferenceRagioneSociale(); - - public function getReference(); -} diff --git a/src/Common/RowReference.php b/src/Common/RowReference.php deleted file mode 100644 index b0101bb40..000000000 --- a/src/Common/RowReference.php +++ /dev/null @@ -1,37 +0,0 @@ -. - */ - -namespace Common; - -class RowReference extends Model -{ - use SimpleModelTrait; - - protected $table = 'co_riferimenti_righe'; - - public function source() - { - return $this->morphTo(); - } - - public function target() - { - return $this->morphTo(); - } -} diff --git a/src/Common/SimpleModelTrait.php b/src/Common/SimpleModelTrait.php deleted file mode 100644 index 6c3a7b6cd..000000000 --- a/src/Common/SimpleModelTrait.php +++ /dev/null @@ -1,44 +0,0 @@ -. - */ - -namespace Common; - -trait SimpleModelTrait -{ - // Retrocompatibilità MySQL - public function setUpdatedAtAttribute($value) - { - // to Disable updated_at - } - - public static function getTableName() - { - return with(new static())->getTable(); - } - - /** - * Crea una nuova istanza del modello. - * - * @return static - */ - public static function build() - { - return new static(); - } -} diff --git a/src/Database.php b/src/Database.php deleted file mode 100755 index a37707b38..000000000 --- a/src/Database.php +++ /dev/null @@ -1,705 +0,0 @@ -. - */ - -use Illuminate\Database\Capsule\Manager as Capsule; - -/** - * Classe per gestire la connessione al database. - * - * @since 2.3 - */ -class Database extends Util\Singleton -{ - /** @var \Illuminate\Database\Capsule\Manager Gestore di connessione Laravel */ - protected $capsule; - - /** @var string Nome del database */ - protected $database_name; - - /** @var bool Stato di connessione del database */ - protected $is_connected; - /** @var bool Stato di installazione del database */ - protected $is_installed; - - /** @var string Versione corrente di MySQL */ - protected $mysql_version; - - /** - * Costruisce la nuova connessione al database. - * Ispirato dal framework open-source Medoo. - * - * @param string|array $server - * @param string $username - * @param string $password - * @param string $database_name - * @param string $charset - * - * @since 2.3 - * - * @return Database - */ - protected function __construct($server, $username, $password, $database_name, $charset = null) - { - if (is_array($server)) { - $host = $server['host']; - $port = !empty($server['port']) ? $server['port'] : null; - } else { - $temp = explode(':', $server); - $host = $temp[0]; - $port = !empty($temp[1]) ? $temp[1] : null; - } - - // Possibilità di specificare una porta per il servizio MySQL diversa dalla standard 3306 - $port = !empty(App::getConfig()['port']) ? App::getConfig()['port'] : $port; - - $this->database_name = $database_name; - - if (!empty($host) && !empty($database_name)) { - try { - // Istanziamento di Eloquent - $this->capsule = new Capsule(); - $this->capsule->addConnection([ - 'driver' => 'mysql', - 'host' => $host, - 'database' => $database_name, - 'username' => $username, - 'password' => $password, - 'charset' => 'utf8', - 'prefix' => '', - 'port' => $port, - ]); - - $this->is_connected = !empty($this->getPDO()); - - // Impostazione del charset della comunicazione - if (empty($charset) && version_compare($this->getMySQLVersion(), '5.5.3') >= 0) { - $this->getPDO()->exec("SET NAMES 'utf8mb4'"); - } - - // Fix per problemi di compatibilità delle password MySQL 4.1+ (da versione precedente) - //$this->getPDO()->exec('SET SESSION old_passwords = 0'); - //$this->getPDO()->exec('SET PASSWORD = PASSWORD('.$this->prepare($this->password).')'); - - // Reset della modalità di esecuzione MySQL per la sessione corrente - $this->getPDO()->exec("SET sql_mode = ''"); - - $this->capsule->setAsGlobal(); - $this->capsule->bootEloquent(); - } catch (PDOException $e) { - if ($e->getCode() == 1049 || $e->getCode() == 1044) { - $e = new PDOException(($e->getCode() == 1049) ? tr('Database non esistente!') : tr('Credenziali di accesso invalide!')); - } - - throw $e; - } - } - } - - /** - * Restituisce la connessione attiva al database, creandola nel caso non esista. - * - * @since 2.3 - * - * @return Database - */ - public static function getConnection($new = false, $data = []) - { - $class = get_called_class(); - - if (empty(parent::$instance[$class]) || !parent::$instance[$class]->isConnected() || $new) { - $config = App::getConfig(); - - // Sostituzione degli eventuali valori aggiuntivi - $config = array_merge($config, $data); - - parent::$instance[$class] = new self($config['db_host'], $config['db_username'], $config['db_password'], $config['db_name']); - } - - return parent::$instance[$class]; - } - - public static function getInstance() - { - return self::getConnection(); - } - - /** - * Restituisce l'oggetto PDO artefice della connessione. - * - * @since 2.3 - * - * @return \DebugBar\DataCollector\PDO\TraceablePDO|PDO - */ - public function getPDO() - { - return $this->capsule->getConnection()->getPDO(); - } - - public function getCapsule() - { - return $this->capsule; - } - - /** - * Controlla se la connessione è valida e andata a buon fine. - * - * @since 2.3 - * - * @return bool - */ - public function isConnected() - { - return $this->is_connected; - } - - /** - * Controlla se il database necessario al progetto esiste. - * - * @since 2.3 - * - * @return bool - */ - public function isInstalled() - { - if (empty($this->is_installed)) { - $this->is_installed = $this->tableExists('zz_modules'); - } - - return $this->is_installed; - } - - /** - * Restituisce la versione del DBMS MySQL in utilizzo. - * - * @since 2.3 - * - * @return string - */ - public function getMySQLVersion() - { - if (empty($this->mysql_version) && $this->isConnected()) { - $ver = $this->fetchArray('SELECT VERSION()'); - if (!empty($ver[0]['VERSION()'])) { - $this->mysql_version = explode('-', $ver[0]['VERSION()'])[0]; - } - } - - return $this->mysql_version; - } - - /** - * Restituisce il nome del database a cui si è connessi. - * - * @since 2.3 - * - * @return string - */ - public function getDatabaseName() - { - return $this->database_name; - } - - /** - * Esegue la query indicata, restituendo l'identificativo della nuova entità se si tratta di una query di inserimento. - * - * @since 2.0 - * - * @param string $query Query da eseguire - * @param array $parameters - * - * @return int - */ - public function query($query, $parameters = []) - { - $statement = $this->getPDO()->prepare($query); - $statement->execute($parameters); - - $id = $this->lastInsertedID(); - if ($id == 0) { - return 1; - } else { - return $id; - } - } - - /** - * Restituisce un'array strutturato in base ai nomi degli attributi della selezione. - * - * @param string $query Query da eseguire - * @param array $parameters - * @param bool $numeric - * - * @throws Exception - * - * @return array - */ - public function fetchArray($query, $parameters = [], $numeric = false) - { - $mode = empty($numeric) ? PDO::FETCH_ASSOC : PDO::FETCH_NUM; - - $statement = $this->getPDO()->prepare($query); - $statement->execute($parameters); - - $result = $statement->fetchAll($mode); - - return $result; - } - - /** - * Restituisce un'array strutturato in base agli indici degli attributi della selezione. - * - * @since 2.0 - * @deprecated 2.3 - * - * @param string $query Query da eseguire - * - * @return array - */ - public function fetchRows($query) - { - return $this->fetchArray($query, [], true); - } - - /** - * Restituisce il primo elemento della selezione, strutturato in base ai nomi degli attributi. - * - * @since 2.0 - * @deprecated 2.3 - * - * @param string $query Query da eseguire - * - * @return array - */ - public function fetchRow($query) - { - return $this->fetchOne($query); - } - - /** - * Restituisce il primo elemento della selezione, strutturato in base ai nomi degli attributi. - * Attenzione: aggiunge il LIMIT relativo a fine della query. - * - * @since 2.4 - * - * @param string $query Query da eseguire - * - * @return array - */ - public function fetchOne($query, $parameters = []) - { - if (!string_contains($query, 'LIMIT')) { - $query .= ' LIMIT 1'; - } - - $result = $this->fetchArray($query, $parameters); - - if (isset($result[0])) { - return $result[0]; - } - - return $result; - } - - /** - * Restituisce il numero dei risultati della selezione. - * - * @since 2.0 - * - * @param string $query Query da eseguire - * - * @return int - */ - public function fetchNum($query, $parameters = []) - { - $result = $this->fetchArray('SELECT COUNT(*) as `tot` FROM ('.$query.') AS `count`', $parameters); - - if (!empty($result)) { - return $result[0]['tot']; - } - - return 0; - } - - public function tableExists($table) - { - if ($this->isConnected()) { - return $this->capsule->schema()->hasTable($table); - } - - return null; - } - - /** - * Restituisce l'identificativo dell'ultimo elemento inserito. - * - * @since 2.0 - * @deprecated 2.3 - * - * @return int - */ - public function last_inserted_id() - { - return $this->lastInsertedID(); - } - - /** - * Restituisce l'identificativo dell'ultimo elemento inserito. - * - * @since 2.3 - * - * @return int - */ - public function lastInsertedID() - { - try { - return $this->getPDO()->lastInsertId(); - } catch (PDOException $e) { - throw new PDOException(tr("Impossibile ottenere l'ultimo identificativo creato")); - } - } - - /** - * Prepara il parametro inserito per l'inserimento in una query SQL. - * Attenzione: protezione di base contro SQL Injection. - * - * @param string $parameter - * - * @since 2.3 - * - * @return mixed - */ - public function prepare($parameter) - { - return $this->getPDO()->quote($parameter); - } - - /** - * Costruisce la query per l'INSERT definito dagli argomenti. - * - * @since 2.3 - * - * @param string $table - * @param array $array - * - * @return string|array - */ - public function insert($table, $array) - { - if (!is_string($table) || !is_array($array)) { - throw new UnexpectedValueException(); - } - - if (!isset($array[0]) || !is_array($array[0])) { - $array = [$array]; - } - - return Capsule::table($table)->insert($array); - } - - /** - * Costruisce la query per l'UPDATE definito dagli argomenti. - * - * @since 2.3 - * - * @param string $table - * @param array $array - * @param array $conditions - * - * @return string|array - */ - public function update($table, $array, $conditions) - { - if (!is_string($table) || !is_array($array) || !is_array($conditions)) { - throw new UnexpectedValueException(); - } - - return Capsule::table($table)->where($conditions)->update($array); - } - - /** - * Costruisce la query per il SELECT definito dagli argomenti. - * - * @since 2.3 - * - * @param string $table - * @param array $array - * @param array $conditions - * @param array $order - * @param string|array $limit - * @param bool $return - * - * @return string|array - */ - public function select($table, $array = [], $conditions = [], $order = [], $limit = null, $return = false) - { - if ( - !is_string($table) || - (!empty($order) && !is_string($order) && !is_array($order)) || - (!empty($limit) && !is_string($limit) && !is_integer($limit) && !is_array($limit)) - ) { - throw new UnexpectedValueException(); - } - - // Valori da ottenere - $select = []; - foreach ((array) $array as $key => $value) { - $select[] = $value.(is_numeric($key) ? '' : ' AS '.$key); - } - $select = !empty($select) ? $select : ['*']; - - $statement = Capsule::table($table)->where($conditions)->select($select); - - // Impostazioni di ordinamento - if (!empty($order)) { - foreach ((array) $order as $key => $value) { - $order = is_numeric($key) ? 'ASC' : strtoupper($value); - $field = is_numeric($key) ? $value : $key; - - if ($order == 'ASC') { - $statement = $statement->orderBy($field); - } else { - $statement = $statement->orderBy($field, 'DESC'); - } - } - } - - // Eventuali limiti - if (!empty($limit)) { - $offset = is_array($limit) ? $limit[0] : null; - $count = is_array($limit) ? $limit[1] : $limit; - - if ($offset) { - $statement = $statement->offset($offset); - } - - $statement = $statement->limit($count); - } - - if (!empty($return)) { - return $statement->toSql(); - } else { - $result = $statement->get()->toArray(); - - return json_decode(json_encode($result), true); - } - } - - /** - * Costruisce la query per il SELECT definito dagli argomenti (LIMIT 1). - * - * @since 2.4.1 - * - * @param string $table - * @param array $array - * @param array $conditions - * @param array $order - * @param bool $return - * - * @return string|array - */ - public function selectOne($table, $array = [], $conditions = [], $order = [], $return = false) - { - $limit = 1; - - $result = $this->select($table, $array, $conditions, $order, $limit, $return); - - if (!is_string($result) && isset($result[0])) { - return $result[0]; - } - - return $result; - } - - /** - * Costruisce la query per l'DELETE definito dagli argomenti. - * - * @since 2.4.1 - * - * @param string $table - * @param array $conditions - * - * @return string|array - */ - public function delete($table, $conditions) - { - if (!is_string($table) || !is_array($conditions)) { - throw new UnexpectedValueException(); - } - - // Costruzione della query - return Capsule::table($table)->where($conditions)->delete(); - } - - /** - * Sincronizza i valori indicati associati alle condizioni, rimuovendo le combinazioni aggiuntive e inserendo quelle non ancora presenti. - * - * @since 2.3 - * - * @param string $table - * @param array $conditions Condizioni di sincronizzazione - * @param array $list Valori da sincronizzare - */ - public function sync($table, $conditions, $list) - { - if ( - !is_string($table) || - !is_array($conditions) || - !is_array($list) - ) { - throw new UnexpectedValueException(); - } - - $field = key($list); - $sync = array_unique((array) current($list)); - - if (!empty($field)) { - $results = array_column($this->select($table, $field, $conditions), $field); - - $detachs = array_unique(array_diff($results, $sync)); - $this->detach($table, $conditions, [$field => $detachs]); - - $this->attach($table, $conditions, $list); - } - } - - /** - * Inserisce le le combinazioni tra i valori indicati e le condizioni. - * - * @since 2.3 - * - * @param string $table - * @param array $conditions Condizioni - * @param array $list Valori da aggiungere - */ - public function attach($table, $conditions, $list) - { - if ( - !is_string($table) || - !is_array($conditions) || - !is_array($list) - ) { - throw new UnexpectedValueException(); - } - - $field = key($list); - $sync = array_unique((array) current($list)); - $inserts = []; - - if (!empty($field)) { - $results = array_column($this->select($table, $field, $conditions), $field); - - $inserts = array_unique(array_diff($sync, $results)); - foreach ($inserts as $insert) { - $this->insert($table, array_merge($conditions, [$field => $insert])); - } - } - - return count($inserts); - } - - /** - * Rimuove le le combinazioni tra i valori indicati e le condizioni. - * - * @since 2.3 - * - * @param string $table - * @param array $conditions Condizioni - * @param array $list Valori da rimuovere - */ - public function detach($table, $conditions, $list) - { - if ( - !is_string($table) || - !is_array($conditions) || - !is_array($list) - ) { - throw new UnexpectedValueException(); - } - - $field = key($list); - $sync = array_unique((array) current($list)); - - if (!empty($field) && !empty($sync)) { - foreach ($sync as $element) { - $conditions[$field] = $element; - - $this->delete($table, $conditions); - } - } - } - - public function beginTransaction() - { - Capsule::beginTransaction(); - } - - public function commitTransaction() - { - Capsule::commit(); - } - - public function rollbackTransaction() - { - Capsule::rollBack(); - } - - /** - * Get a new raw query expression. - * - * @param mixed $value - * - * @return \Illuminate\Database\Query\Expression - */ - public function raw($value) - { - return $this->getCapsule()->getConnection()->raw($value); - } - - /** - * Begin a fluent query against a database table. - * - * @param string $table - * - * @return \Illuminate\Database\Query\Builder - */ - public function table($table) - { - return $this->getCapsule()->getConnection()->table($table); - } - - /** - * Esegue le query interne ad un file ".sql". - * - * @since 2.0 - * - * @param string $filename Percorso per raggiungere il file delle query - * @param string $delimiter Delimitatore delle query - */ - public function multiQuery($filename, $start = 0) - { - $queries = readSQLFile($filename, ';'); - $end = count($queries); - - for ($i = $start; $i < $end; ++$i) { - $this->query($queries[$i]); - } - - return true; - } -} diff --git a/src/Exporter/CSVExporter.php b/src/Exporter/CSVExporter.php deleted file mode 100644 index 26ef16bfe..000000000 --- a/src/Exporter/CSVExporter.php +++ /dev/null @@ -1,100 +0,0 @@ -. - */ - -namespace Exporter; - -use League\Csv\Writer; - -/** - * Classe dedicata alla gestione dell'importazione da file CSV. - * - * @since 2.4.18 - */ -abstract class CSVExporter implements ExporterInterface -{ - protected $csv; - protected $records; - - public function __construct($file) - { - // Impostazione automatica per i caratteri di fine riga - if (!ini_get('auto_detect_line_endings')) { - ini_set('auto_detect_line_endings', '1'); - } - - // Gestione del file CSV - $this->csv = Writer::createFromPath($file, 'w+'); - $this->csv->setDelimiter(';'); - } - - abstract public function getAvailableFields(); - - abstract public function getRecords(); - - public function setRecords($records) - { - $this->records = $records; - } - - public function setHeader() - { - $fields = $this->getAvailableFields(); - $header = array_map(function ($item) { - return $item['label']; - }, $fields); - - return $this->csv->insertOne($header); - } - - public function exportRecords() - { - // Esportazione header - $fields = $this->getAvailableFields(); - $this->csv->insertOne(array_column($fields, 'label')); - - $records = $this->records ?: $this->getRecords(); - foreach ($records as $record) { - // Esportazione del record - $this->export($record); - } - - return count($records); - } - - public function export($record) - { - $fields = $this->getAvailableFields(); - - $row = []; - foreach ($fields as $field) { - $nome = $field['field']; - - // Navigazione secondo dot notation - $dot_notation = explode('.', $nome); - $contenuto = $record; - foreach ($dot_notation as $segment) { - $contenuto = isset($contenuto[$segment]) ? $contenuto[$segment] : null; - } - - $row[] = $contenuto; - } - - return $this->csv->insertOne($row); - } -} diff --git a/src/Exporter/ExporterInterface.php b/src/Exporter/ExporterInterface.php deleted file mode 100644 index bef096ffd..000000000 --- a/src/Exporter/ExporterInterface.php +++ /dev/null @@ -1,74 +0,0 @@ -. - */ - -namespace Exporter; - -/** - * Interfaccia che definisce la struttura di base per la gestione delle esportazioni dei dati del gestionale in formati esterni. - * - * @since 2.4.18 - */ -interface ExporterInterface -{ - /** - * Restitusice i campi disponibili all'esportazione. - * - * @return mixed - */ - public function getAvailableFields(); - - /** - * Imposta l'header (potenziale) per il documento da importare. - * - * @return mixed - */ - public function setHeader(); - - /** - * Restituisce l'insieme dei record del gestionale da esportare. - * - * @return array - */ - public function getRecords(); - - /** - * Imposta l'insieme dei record del gestionale da esportare. - * - * @param $records - * - * @return void - */ - public function setRecords($records); - - /** - * Esporta l'insieme dei record del documento nel gestionale. - * - * @return int - */ - public function exportRecords(); - - /** - * Gestisce le operazioni di esportazione per un singolo record. - * - * @param $record - * - * @return bool - */ - public function export($record); -} diff --git a/src/Extensions/EloquentCollector.php b/src/Extensions/EloquentCollector.php deleted file mode 100755 index 640fcd9e6..000000000 --- a/src/Extensions/EloquentCollector.php +++ /dev/null @@ -1,82 +0,0 @@ -. - */ - -namespace Extensions; - -use Illuminate\Database\Capsule\Manager; -use PDO; - -class EloquentCollector extends \DebugBar\DataCollector\PDO\PDOCollector -{ - protected $capsule; - - public function __construct($capsule) - { - parent::__construct(); - $this->capsule = $capsule; - $this->addConnection($this->getTraceablePdo(), 'Eloquent PDO'); - } - - // Override - public function getName() - { - return 'eloquent_pdo'; - } - - // Override - public function getWidgets() - { - return [ - 'eloquent' => [ - 'icon' => 'inbox', - 'widget' => 'PhpDebugBar.Widgets.SQLQueriesWidget', - 'map' => 'eloquent_pdo', - 'default' => '[]', - ], - 'eloquent:badge' => [ - 'map' => 'eloquent_pdo.nb_statements', - 'default' => 0, - ], - ]; - } - - /** - * @return Manager; - */ - protected function getEloquentCapsule() - { - return $this->capsule; - } - - /** - * @return PDO - */ - protected function getEloquentPdo() - { - return $this->getEloquentCapsule()->getConnection()->getPdo(); - } - - /** - * @return \DebugBar\DataCollector\PDO\TraceablePDO - */ - protected function getTraceablePdo() - { - return new \DebugBar\DataCollector\PDO\TraceablePDO($this->getEloquentPdo()); - } -} diff --git a/src/Extensions/MessageHandler.php b/src/Extensions/MessageHandler.php deleted file mode 100755 index 15cf14321..000000000 --- a/src/Extensions/MessageHandler.php +++ /dev/null @@ -1,63 +0,0 @@ -. - */ - -namespace Extensions; - -use Monolog\Handler\AbstractProcessingHandler; - -/** - * Gestore dei messaggi di avvertenza in caso di malfunzionamento del gestionale. - * - * @since 2.4.6 - */ -class MessageHandler extends AbstractProcessingHandler -{ - protected function write(array $record) - { - if (\Whoops\Util\Misc::isAjaxRequest()) { - return; - } - - $message = tr("Si è verificato un'errore").' [uid: '.$record['extra']['uid'].'].'; - - if (auth()->check()) { - $message .= ' - '.tr('Se il problema persiste siete pregati di chiedere assistenza tramite il forum apposito (_LINK_FORUM_)', [ - '_LINK_FORUM_' => 'https://forum.openstamanager.com/', - ]).'.'; - - if (auth()->isAdmin()) { - $message .= ' -
    '.$record['message'].''; - } - } - - // Messaggio nella sessione - try { - flash()->error($message); - } catch (\Exception $e) { - } - - // Messaggio visivo immediato - echo ' -
    - '.$message.' -
    '; - } -} diff --git a/src/Filter.php b/src/Filter.php deleted file mode 100755 index fabf40fbe..000000000 --- a/src/Filter.php +++ /dev/null @@ -1,210 +0,0 @@ -. - */ - -/** - * Classe per gestire la sanitarizzazione degli input, basata sul framework open-source HTMLPurifier. - * - * @since 2.3 - */ -class Filter -{ - /** @var HTMLPurifier */ - protected static $purifier; - - /** @var array Elenco dei contenuti inviati via POST */ - protected static $post = []; - /** @var array Elenco dei contenuti inviati via GET */ - protected static $get = []; - - /** - * Restituisce il valore presente nei dati ottenuti dall'input dell'utente. - * - * @param string $property - * @param string $method - * - * @return string - */ - public static function getValue($property, $method = null, $raw = false) - { - $value = null; - - if (empty($method)) { - $value = (self::post($property, $raw) !== null) ? self::post($property, $raw) : self::get($property, $raw); - } elseif (strtolower($method) == 'post') { - $value = self::post($property, $raw); - } elseif (strtolower($method) == 'get') { - $value = self::get($property, $raw); - } - - return $value; - } - - /** - * Restituisce i contenuti dalla sezione POST. - * - * @return array - */ - public static function getPOST() - { - if (empty(self::$post)) { - self::$post['raw'] = self::sanitize($_POST); - self::$post['data'] = self::parse(self::$post['raw']); - } - - return self::$post['data']; - } - - /** - * Restituisce il valore presente nei dati ottenuti dalla sezione POST. - * - * @param string $property - * - * @return string - */ - public static function post($property, $raw = false) - { - self::getPOST(); - - $category = empty($raw) ? 'data' : 'raw'; - - if (isset(self::$post[$category][$property])) { - return self::$post[$category][$property]; - } - } - - /** - * Restituisce i contenuti dalla sezione GET. - * - * @return array - */ - public static function getGET() - { - if (empty(self::$get)) { - self::$get['raw'] = self::sanitize($_GET); - self::$get['data'] = self::parse(self::$get['raw']); - } - - return self::$get['data']; - } - - /** - * Restituisce il valore presente nei dati ottenuti dalla sezione GET. - * - * @param string $property - * - * @return string - */ - public static function get($property, $raw = false) - { - self::getGET(); - - $category = empty($raw) ? 'data' : 'raw'; - - if (isset(self::$get[$category][$property])) { - return self::$get[$category][$property]; - } - } - - /** - * Sanitarizza i contenuti dell'input. - * - * @param mixed $input Contenuti - * - * @return mixed - */ - public static function sanitize($input) - { - $output = null; - if (is_array($input)) { - foreach ($input as $key => $value) { - $output[$key] = self::sanitize($value); - } - } else { - $output = trim(self::getPurifier()->purify($input)); - } - - return $output; - } - - /** - * Interpreta e formatta correttamente i contenuti dell'input. - * - * @param mixed $input Contenuti - * - * @return mixed - */ - public static function parse($input) - { - $output = null; - if (is_array($input)) { - foreach ($input as $key => $value) { - $output[$key] = self::parse($value); - } - } elseif (!is_null($input)) { - $output = formatter()->parse($input); - } - - return $output; - } - - /** - * Restituisce l'istanza di HTMLPurifier in utilizzo. - * - * @return \HTMLPurifier - */ - public static function getPurifier() - { - if (empty(self::$purifier)) { - $config = \HTMLPurifier_Config::createDefault(); - - $config->set('HTML.Allowed', 'br,p[style],b[style],strong[style],i[style],em[style],u[style],strike,a[style|href|title|target],ol[style],ul[style],li[style],hr[style],blockquote[style],img[style|alt|title|width|height|src|align],table[style|width|bgcolor|align|cellspacing|cellpadding|border],tr[style],td[style],th[style],tbody,thead,caption,col,colgroup,span[style],sup'); - - //$config->set('Cache.SerializerPath', realpath(__DIR__.'/cache/HTMLPurifier')); - $config->set('Cache.DefinitionImpl', null); - $config->set('URI.AllowedSchemes', [ - 'http' => true, - 'https' => true, - 'mailto' => true, - 'ftp' => true, - 'tel' => true, - 'data' => true, - ]); - - self::$purifier = new \HTMLPurifier($config); - } - - return self::$purifier; - } - - /** - * Imposta una proprietà specifica a un valore personalizzato. - * - * @param string $method - * @param string $property - * @param mixed $value - */ - public static function set($method, $property, $value) - { - if (strtolower($method) == 'post') { - self::$post['data'][$property] = $value; - } elseif (strtolower($method) == 'get') { - self::$get['data'][$property] = $value; - } - } -} diff --git a/src/HTMLBuilder/HTMLBuilder.php b/src/HTMLBuilder/HTMLBuilder.php deleted file mode 100755 index 027a8442f..000000000 --- a/src/HTMLBuilder/HTMLBuilder.php +++ /dev/null @@ -1,502 +0,0 @@ -. - */ - -namespace HTMLBuilder; - -/** - * Classe dedicata alla gestione della conversione di tag in codice HTML. - * - * Tag di input - * - * Campo di input generico: - * {[ "type": "text", "required": 1, "value": "$idintervento$" ]} - * - * Campo di testo normale e non modificabile: - * {[ "type": "span", "value": "$testo$" ]} - * - * Campo select automatizzatp: - * {[ "type": "select", "required": 1, "values": "query=SELECT id, descrizione FROM co_contratti WHERE idanagrafica=$idanagrafica$", "value": "$idcontratto$" ]} - * - * La sostituzione dei parametri compresi tra $$ viene effettuata attraverso il parametro $records. - * - * Tag personalizzati - * - * Struttura per l'inserimento e la visualizzazione dei file: - * {( "name": "filelist_and_upload", "id_module": "3", "id_record": "17" )} - * - * @since 2.3 - */ -class HTMLBuilder -{ - /** @var array Codici di apertura dei tag personalizzati */ - public static $open = [ - 'handler' => '{[', - 'manager' => '{(', - ]; - - /** @var array Codici di chiusura dei tag personalizzati */ - public static $close = [ - 'handler' => ']}', - 'manager' => ')}', - ]; - - /** @var array Elenco degli attributi che necessitano esclusivamente di essere presenti */ - protected static $specifics = [ - 'multiple', - 'checked', - 'disabled', - 'readonly', - 'required', - ]; - - /** @var array Elenco dei gestori dei campi HTML */ - protected static $handlers = [ - 'list' => [ - 'default' => Handler\DefaultHandler::class, - 'image' => Handler\MediaHandler::class, - 'select' => Handler\SelectHandler::class, - 'checkbox' => Handler\ChoicesHandler::class, - 'radio' => Handler\ChoicesHandler::class, - 'bootswitch' => Handler\ChoicesHandler::class, - 'timestamp' => Handler\DateHandler::class, - 'date' => Handler\DateHandler::class, - 'time' => Handler\DateHandler::class, - 'ckeditor' => Handler\CKEditorHandler::class, - ], - 'instances' => [], - ]; - - /** @var array Generatore del contenitore per i campi HTML */ - protected static $wrapper = [ - 'class' => Wrapper\HTMLWrapper::class, - 'istance' => null, - ]; - - /** @var array Elenco dei gestori delle strutture HTML */ - protected static $managers = [ - 'list' => [ - 'filelist_and_upload' => Manager\FileManager::class, - 'button' => Manager\ButtonManager::class, - //'csrf' => Manager\CSRFManager::class, - 'custom_fields' => Manager\FieldManager::class, - 'widgets' => Manager\WidgetManager::class, - 'log_email' => Manager\EmailManager::class, - ], - 'instances' => [], - ]; - - /** @var int Limite di ricorsione interna */ - protected static $max_recursion = 10; - - /** @var array Elenco degli elementi abilitati per la sostituzione automatica nei valori ($nome$) */ - protected static $record = []; - - /** - * Esegue la sostituzione dei tag personalizzati con il relativo codice HTML. - * - * @param string $html - * - * @return string - */ - public static function replace($html, $depth = 0) - { - // Gestione dei manager generici - preg_match_all('/'.preg_quote(self::$open['manager']).'(.+?)'.preg_quote(self::$close['manager']).'/is', $html, $managers); - - foreach ($managers[0] as $value) { - $json = self::decode($value, 'manager'); - $class = self::getManager($json['name']); - - $result = ''; - try { - $result = !empty($class) ? $class->manage($json) : ''; - } catch (\Exception $exception) { - logger()->error($exception->getMessage(), [ - 'code' => $exception->getCode(), - 'message' => $exception->getMessage(), - 'file' => $exception->getFile(), - 'line' => $exception->getLine(), - 'trace' => $exception->getTraceAsString(), - ]); - } - - // Ricorsione - if ($depth < self::$max_recursion) { - $result = self::replace($result, $depth + 1); - } - - $html = str_replace($value, !empty($result) ? $result : $value, $html); - } - - // Gestione del formato di input HTML semplificato - preg_match_all('/'.preg_quote(self::$open['handler']).'(.+?)'.preg_quote(self::$close['handler']).'/is', $html, $handlers); - - foreach ($handlers[0] as $value) { - $json = self::decode($value, 'handler'); - - $result = null; - try { - $result = self::generate($json); - } catch (\Exception $exception) { - logger()->error($exception->getMessage(), [ - 'code' => $exception->getCode(), - 'message' => $exception->getMessage(), - 'file' => $exception->getFile(), - 'line' => $exception->getLine(), - 'trace' => $exception->getTraceAsString(), - ]); - } - - // Ricorsione - if ($depth < self::$max_recursion) { - $result = self::replace($result, $depth + 1); - } - - $html = str_replace($value, !empty($result) ? $result : $value, $html); - } - - return $html; - } - - /** - * Esegue la sostituzione per un singolo tag personalizzato con il relativo codice HTML. - * - * @return string - */ - public static function parse(array $json) - { - $result = null; - try { - $result = self::generate($json); - } catch (\Exception $exception) { - logger()->error($exception->getMessage(), [ - 'code' => $exception->getCode(), - 'message' => $exception->getMessage(), - 'file' => $exception->getFile(), - 'line' => $exception->getLine(), - 'trace' => $exception->getTraceAsString(), - ]); - } - - // Ricorsione - $result = self::replace($result); - - return !empty($result) ? $result : json_encode($json); - } - - /** - * Restituisce il nome della classe resposabile per la gestione di una determinata tipologia di tag di input. - * - * @param string $input - * - * @return string - */ - public static function getHandlerName($input) - { - $result = empty(self::$handlers['list'][$input]) ? self::$handlers['list']['default'] : self::$handlers['list'][$input]; - - return $result; - } - - /** - * Restituisce l'istanza della classe resposabile per la gestione di una determinata tipologia di tag di input. - * - * @param string $input - * - * @return mixed - */ - public static function getHandler($input) - { - $class = self::getHandlerName($input); - if (empty(self::$handlers['instances'][$class])) { - self::$handlers['instances'][$class] = new $class(); - } - - return self::$handlers['instances'][$class]; - } - - /** - * Imposta una determinata classe come resposabile per la gestione di una determinata tipologia di tag di input. - * - * @param string $input - * @param string|mixed $class - */ - public static function setHandler($input, $class) - { - $original = $class; - - $class = is_object($class) ? $class : new $class(); - - if ($class instanceof Handler\HandlerInterface) { - self::$handlers['list'][$input] = $original; - self::$handlers['instances'][$original] = $class; - } - } - - /** - * Restituisce l'oggetto responsabile per la costruzione del codice HTML contenente gli input effettivi. - * - * @return mixed - */ - public static function getWrapper() - { - if (empty(self::$wrapper['instance'])) { - $class = self::$wrapper['class']; - self::$wrapper['instance'] = new $class(); - } - - return self::$wrapper['instance']; - } - - /** - * Imposta l'oggetto responsabile per la costruzione del codice HTML contenente gli input effettivi. - * - * @param string|mixed $class - */ - public static function setWrapper($class) - { - $original = $class; - - $class = is_object($class) ? $class : new $class(); - - if ($class instanceof Wrapper\WrapperInterface) { - self::$wrapper['class'] = $original; - self::$wrapper['instance'] = $class; - } - } - - /** - * Restituisce l'oggetto responsabile per la costruzione del codice HTML per il tag personalizzato. - * - * @param string $input - * - * @return mixed - */ - public static function getManager($input) - { - $result = null; - - $class = self::$managers['list'][$input]; - if (!empty($class)) { - if (empty(self::$managers['instances'][$class])) { - self::$managers['instances'][$class] = new $class(); - } - - $result = self::$managers['instances'][$class]; - } - - return $result; - } - - /** - * Imposta l'oggetto responsabile per la costruzione del codice HTML per il tag personalizzato. - * - * @param string $input - * @param string|mixed $class - */ - public static function setManager($input, $class) - { - $original = $class; - - $class = is_object($class) ? $class : new $class(); - - if ($class instanceof Manager\ManagerInterface) { - self::$managers['list'][$input] = $original; - self::$managers['instances'][$original] = $class; - } - } - - /** - * Imposta l'oggetto responsabile per la costruzione del codice HTML per il tag personalizzato. - * - * @param array $record - */ - public static function setRecord($record) - { - self::$record = $record; - } - - /** - * Genera il codice HTML per i singoli tag di input. - * - * @param string $json - * - * @return string - */ - protected static function generate($json) - { - // Elaborazione del formato - $elaboration = self::elaborate($json); - $values = $elaboration[0]; - $extras = $elaboration[1]; - - $result = null; - if (!empty($values)) { - // Generazione dell'elemento - $html = self::getHandler($values['type'])->handle($values, $extras); - - // Generazione del parte iniziale del contenitore - $before = self::getWrapper()->before($values, $extras); - - // Generazione del parte finale del contenitore - $after = self::getWrapper()->after($values, $extras); - - $result = $before.$html.$after; - - // Elaborazione del codice HTML - $result = self::process($result, $values, $extras); - } - - return $result; - } - - /** - * Decodifica i tag personalizzati e li converte in un array basato sul formato JSON. - * - * @param string $string - * @param string $type - * - * @return array - */ - protected static function decode($string, $type) - { - $string = '{'.substr($string, strlen(self::$open[$type]), -strlen(self::$close[$type])).'}'; - - // Fix per contenuti con newline integrati - $string = str_replace(["\n", "\r"], ['\\n', '\\r'], $string); - - $json = (array) json_decode($string, true); - - return $json; - } - - /** - * Elabora l'array contenente le impostazioni del tag per renderlo fruibile alla conversione in HTML (per i tag di input). - * - * @param array $json - * - * @return array - */ - protected static function elaborate($json) - { - $values = []; - $extras = []; - - if (!empty($json)) { - // Conversione delle variabili con i campi di database ($record) - foreach ($json as $key => $value) { - if (empty($value) && !is_numeric($value)) { - unset($json[$key]); - } - // Sostituzione delle variabili $nome$ col relativo valore da database - elseif (is_string($json[$key]) && preg_match_all('/\$([a-z0-9\_]+)\$/i', $json[$key], $m)) { - for ($i = 0; $i < count($m[0]); ++$i) { - $record = isset(self::$record[$m[1][$i]]) ? self::$record[$m[1][$i]] : ''; - $json[$key] = str_replace($m[0][$i], prepareToField($record), $json[$key]); - } - } - } - - // Valori speciali che richiedono solo la propria presenza - foreach (self::$specifics as $specific) { - if (isset($json[$specific])) { - if (!empty($json[$specific])) { - $extras[] = trim($specific); - } - unset($json[$specific]); - } - } - - // Campo personalizzato "extra" - if (isset($json['extra'])) { - if (!empty($json['extra'])) { - $extras[] = trim($json['extra']); - } - unset($json['extra']); - } - - // Attributi normali - foreach ($json as $key => $value) { - $values[trim($key)] = is_string($value) ? trim($value) : $value; - } - - // Valori particolari - $values['name'] = str_replace(' ', '_', $values['name']); - $values['id'] = empty($values['id']) ? $values['name'] : $values['id']; - $values['id'] = str_replace(['[', ']', ' '], ['', '', '_'], $values['id']); - $values['value'] = isset($values['value']) ? $values['value'] : ''; - - // Gestione delle classi CSS - $values['class'] = []; - $values['class'][] = 'form-control'; - if (!empty($json['class'])) { - $classes = explode(' ', $json['class']); - foreach ($classes as $class) { - if (!empty($class)) { - $values['class'][] = trim($class); - } - } - } - - // Gestione grafica dell'attributo required - if (in_array('required', $extras)) { - if (!empty($values['label'])) { - $values['label'] .= '*'; - } elseif (!empty($values['placeholder'])) { - $values['placeholder'] .= '*'; - } - } - } - - return [$values, $extras]; - } - - /** - * Sostituisce i placeholder delle impostazioni con i relativi valori (per i tag di input). - * - * @param string $result - * @param array $values - * @param array $extras - * - * @return string - */ - protected static function process($result, $values, $extras) - { - unset($values['label']); - - $values['class'] = array_unique($values['class']); - - $attributes = []; - foreach ($values as $key => $value) { - // Fix per la presenza di apici doppi - $value = prepareToField(is_array($value) ? implode(' ', $value) : $value); - if (string_contains($result, '|'.$key.'|')) { - $result = str_replace('|'.$key.'|', $value, $result); - } elseif (!empty($value) || is_numeric($value)) { - $attributes[] = $key.'="'.$value.'"'; - } - } - - $attributes = array_unique(array_merge($attributes, $extras)); - - $result = str_replace('|attr|', implode(' ', $attributes), $result); - - return $result; - } -} diff --git a/src/HTMLBuilder/Handler/CKEditorHandler.php b/src/HTMLBuilder/Handler/CKEditorHandler.php deleted file mode 100755 index 101b07f40..000000000 --- a/src/HTMLBuilder/Handler/CKEditorHandler.php +++ /dev/null @@ -1,39 +0,0 @@ -. - */ - -namespace HTMLBuilder\Handler; - -/** - * Gestione dell'input di tipo "ckeditor". - * - * @since 2.4.2 - */ -class CKEditorHandler implements HandlerInterface -{ - public function handle(&$values, &$extras) - { - $values['class'][] = 'openstamanager-input'; - $values['class'][] = 'editor-input'; - - // Generazione del codice HTML - return ' - - '; - } -} diff --git a/src/HTMLBuilder/Handler/ChoicesHandler.php b/src/HTMLBuilder/Handler/ChoicesHandler.php deleted file mode 100755 index a0be01ee9..000000000 --- a/src/HTMLBuilder/Handler/ChoicesHandler.php +++ /dev/null @@ -1,91 +0,0 @@ -. - */ - -namespace HTMLBuilder\Handler; - -/** - * Gestione dell'input di tipo "checkbox". - * - * @since 2.3 - */ -class ChoicesHandler implements HandlerInterface -{ - public function handle(&$values, &$extras) - { - // Delega della gestione al metodo specifico per il tipo di input richiesto - $result = $this->{$values['type']}($values, $extras); - - return $result; - } - - /** - * Gestione dell'input di tipo "checkbox". - * Esempio: {[ "type": "checkbox", "label": "Checkbox di test", "placeholder": "Test", "name": "checkbox", "value": "1" ]}. - * - * @param array $values - * @param array $extras - * - * @return string - */ - protected function checkbox(&$values, &$extras) - { - unset($values['class'][0]); - - // Restrizione dei valori permessi - $values['value'] = (empty($values['value']) || $values['value'] == 'off') ? false : true; - - // Gestione della proprietà "checked" - if (!empty($values['value']) && !in_array('checked', $extras)) { - $extras[] = 'checked'; - } - - // Gestione della proprietà "readonly" - if (in_array('readonly', $extras)) { - $extras[] = 'disabled'; - } - - $class = ''; - if (in_array('disabled', $extras)) { - $class = ' disabled'; - } - - // Gestione dei placeholder - $values['placeholder'] = isset($values['placeholder']) ? $values['placeholder'] : $values['label']; - - // Generazione del codice HTML - // "+ this.checked" rende il valore booleano un numero - $result = ' -
    - - -
    - - -
    -
    '; - - return $result; - } -} diff --git a/src/HTMLBuilder/Handler/DateHandler.php b/src/HTMLBuilder/Handler/DateHandler.php deleted file mode 100755 index 329188835..000000000 --- a/src/HTMLBuilder/Handler/DateHandler.php +++ /dev/null @@ -1,148 +0,0 @@ -. - */ - -namespace HTMLBuilder\Handler; - -/** - * Gestione dell'input di tipo "timestamp", "date" e "time". - * - * @since 2.3 - */ -class DateHandler implements HandlerInterface -{ - public function handle(&$values, &$extras) - { - $values['class'][] = 'openstamanager-input'; - - // Impostazione alla data corrente se il contenuto corrisponde a "now" - $detect = [ - 'value', - 'max-date', - 'min-date', - ]; - foreach ($detect as $attr) { - if (isset($values[$attr]) && $values[$attr] == '-now-') { - $values[$attr] = date(\Intl\Formatter::getStandardFormats()['timestamp']); - } - } - - // Restrizione dei valori permessi - // Timestamp - if ($values['type'] == 'timestamp' && formatter()->isStandardTimestamp($values['value'])) { - $values['value'] = \Translator::timestampToLocale($values['value']); - } - - // Data - elseif ($values['type'] == 'date' && formatter()->isStandardDate($values['value'])) { - $values['value'] = \Translator::dateToLocale($values['value']); - } - - // Orario - elseif ($values['type'] == 'time' && formatter()->isStandardTime($values['value'])) { - $values['value'] = \Translator::timeToLocale($values['value']); - } - - // Controllo sulla correttezza sintattica del valore impostato - if (!( - ($values['type'] == 'timestamp' && formatter()->isFormattedTimestamp($values['value'])) || - ($values['type'] == 'date' && formatter()->isFormattedDate($values['value'])) || - ($values['type'] == 'time' && formatter()->isFormattedTime($values['value'])) - )) { - $values['value'] = ''; - } - - // Delega della gestione al metodo specifico per il tipo di input richiesto - $result = $this->{$values['type']}($values, $extras); - - $values['type'] = 'text'; - - // Generazione del codice HTML di default - if (empty($result)) { - if (empty($values['label'])) { - $result = ' -
    '; - - if (empty($values['icon-before']) || empty($values['icon-after'])) { - $result .= ' -
    '; - } - } - - $result .= ' - '; - - if (empty($values['label'])) { - if (empty($values['icon-before']) || empty($values['icon-after'])) { - $result .= ' -
    '; - } - - $result .= ' -
    '; - } - } - - return $result; - } - - /** - * Gestione dell'input di tipo "timestamp". - * Esempio: {[ "type": "timestamp", "label": "Timestamp di test", "name": "timestamp", "value": "2018-01-01 12:00:30" ]}. - * - * @param array $values - * @param array $extras - * - * @return string - */ - protected function timestamp(&$values, &$extras) - { - $values['class'][] = 'text-center'; - $values['class'][] = 'timestamp-picker'; - } - - /** - * Gestione dell'input di tipo "date". - * Esempio: {[ "type": "date", "label": "Data di test", "name": "date", "value": "2018-01-01" ]}. - * - * @param array $values - * @param array $extras - * - * @return string - */ - protected function date(&$values, &$extras) - { - $values['class'][] = 'text-center'; - $values['class'][] = 'datepicker'; - } - - /** - * Gestione dell'input di tipo "time". - * Esempio: {[ "type": "time", "label": "Orario di test", "name": "time", "value": "12:00:30" ]}. - * - * @param array $values - * @param array $extras - * - * @return string - */ - protected function time(&$values, &$extras) - { - $values['class'][] = 'text-center'; - $values['class'][] = 'timepicker'; - } -} diff --git a/src/HTMLBuilder/Handler/DefaultHandler.php b/src/HTMLBuilder/Handler/DefaultHandler.php deleted file mode 100755 index 4151535d4..000000000 --- a/src/HTMLBuilder/Handler/DefaultHandler.php +++ /dev/null @@ -1,281 +0,0 @@ -. - */ - -namespace HTMLBuilder\Handler; - -/** - * Gestione dell'input di tipo "text", "file", "password", "email", "number", "textarea" e "hidden". - * - * @since 2.3 - */ -class DefaultHandler implements HandlerInterface -{ - public function handle(&$values, &$extras) - { - $values['class'][] = 'openstamanager-input'; - - // Delega della gestione al metodo specifico per il tipo di input richiesto - if (in_array($values['type'], get_class_methods($this))) { - $result = $this->{$values['type']}($values, $extras); - } - - // Caso non previsto - else { - $result = $this->custom($values, $extras); - } - - return $result; - } - - /** - * Gestione dell'input di tipo non altrimenti previsto. - * Esempio: {[ "type": "undefined", "label": "Custom di test", "placeholder": "Test", "name": "custom", "value": "custom" ]}. - * - * @param array $values - * @param array $extras - * - * @return string - */ - protected function custom(&$values, &$extras) - { - // Generazione del codice HTML - return ' - |value|'; - } - - /** - * Gestione dell'input di tipo "text". - * Esempio: {[ "type": "text", "label": "Text di test", "placeholder": "Test", "name": "text" ]}. - * - * @param array $values - * @param array $extras - * - * @return string - */ - protected function text(&$values, &$extras) - { - // Generazione del codice HTML - return ' - '; - } - - /** - * Gestione dell'input di tipo "file". - * Esempio: {[ "type": "file", "label": "File di test", "placeholder": "Test", "name": "file" ]}. - * - * @param array $values - * @param array $extras - * - * @return string - */ - protected function file(&$values, &$extras) - { - // Delega al metodo "text", per la generazione del codice HTML - return $this->text($values, $extras); - } - - /** - * Gestione dell'input di tipo "password". - * Esempio: {[ "type": "password", "label": "Password di test", "placeholder": "Test", "name": "password" ]}. - * - * @param array $values - * @param array $extras - * - * @return string - */ - protected function password(&$values, &$extras) - { - $values['icon-after'] = ''; - - $result = ' - '; - - if (!empty($values['strength'])) { - $result .= ' -
    - - - '; - } - - // Delega al metodo "text", per la generazione del codice HTML - $result .= $this->text($values, $extras); - - return $result; - } - - /** - * Gestione dell'input di tipo "hidden". - * Esempio: {[ "type": "hidden", "label": "Hidden di test", "placeholder": "Test", "name": "hidden" ]}. - * - * @param array $values - * @param array $extras - * - * @return string - */ - protected function hidden(&$values, &$extras) - { - $original = $values; - - $values = []; - $values['type'] = $original['type']; - $values['value'] = $original['value']; - $values['name'] = $original['name']; - $values['id'] = $original['id']; - $values['class'] = []; - - // Delega al metodo "text", per la generazione del codice HTML - return $this->text($values, $extras); - } - - /** - * Gestione dell'input di tipo "email". - * Esempio: {[ "type": "email", "label": "Email di test", "placeholder": "Test", "name": "email" ]}. - * - * @param array $values - * @param array $extras - * - * @return string - */ - protected function email(&$values, &$extras) - { - $values['class'][] = 'email-mask'; - - $values['type'] = 'text'; - - // Delega al metodo "text", per la generazione del codice HTML - return $this->text($values, $extras); - } - - /** - * Gestione dell'input di tipo "number". - * Esempio: {[ "type": "number", "label": "Number di test", "placeholder": "Test", "name": "number" ]}. - * - * @param array $values - * @param array $extras - * - * @return string - */ - protected function number(&$values, &$extras) - { - $values['class'][] = 'number-input'; - - $values['value'] = !empty($values['value']) ? $values['value'] : 0; - - // Gestione della precisione (numero specifico, oppure "qta" per il valore previsto nell'impostazione "Cifre decimali per quantità"). - $decimals = null; - if (isset($values['decimals'])) { - if (is_numeric($values['decimals'])) { - $decimals = $values['decimals']; - } elseif (string_starts_with($values['decimals'], 'qta')) { - $decimals = setting('Cifre decimali per quantità'); - $values['decimals'] = $decimals; - - // Se non è previsto un valore minimo, lo imposta a 1 - $values['min-value'] = isset($values['min-value']) ? $values['min-value'] : '0.'.str_repeat('0', $decimals - 1).'1'; - } - } - - // Delega al metodo "text", per la generazione del codice HTML - $values['type'] = 'text'; - - return $this->text($values, $extras); - } - - /** - * Gestione dell'input di tipo "textarea". - * Esempio: {[ "type": "textarea", "label": "Textarea di test", "placeholder": "Test", "name": "textarea" ]}. - * - * @param array $values - * @param array $extras - * - * @return string - */ - protected function textarea(&$values, &$extras) - { - $values['class'][] = 'autosize'; - - // Generazione del codice HTML - return ' - '; - } -} diff --git a/src/HTMLBuilder/Handler/HandlerInterface.php b/src/HTMLBuilder/Handler/HandlerInterface.php deleted file mode 100755 index 677c2acf9..000000000 --- a/src/HTMLBuilder/Handler/HandlerInterface.php +++ /dev/null @@ -1,38 +0,0 @@ -. - */ - -namespace HTMLBuilder\Handler; - -/** - * Intefaccia utilizzata per interagire con la classe HTMLBuilder. - * - * @since 2.3 - */ -interface HandlerInterface -{ - /** - * Gestore pubblico, liberamente implementabile per la creazione del codice HTML. - * - * @param array $values - * @param array $extras - * - * @return string - */ - public function handle(&$values, &$extras); -} diff --git a/src/HTMLBuilder/Handler/MediaHandler.php b/src/HTMLBuilder/Handler/MediaHandler.php deleted file mode 100755 index 627a60eb6..000000000 --- a/src/HTMLBuilder/Handler/MediaHandler.php +++ /dev/null @@ -1,76 +0,0 @@ -. - */ - -namespace HTMLBuilder\Handler; - -/** - * Gestione dell'input di tipo "image". - * - * @since 2.3 - */ -class MediaHandler implements HandlerInterface -{ - public function handle(&$values, &$extras) - { - $values['class'][] = 'openstamanager-input'; - - // Delega della gestione al metodo specifico per il tipo di input richiesto - $result = $this->{$values['type']}($values, $extras); - - return $result; - } - - /** - * Gestione dell'input di tipo "image". - * Esempio: {[ "type": "image", "label": "Immagine di test", "name": "image", "class": "img-thumbnail", "value": "image_path" ]}. - * - * @param array $values - * @param array $extras - * - * @return string - */ - public function image(&$values, &$extras) - { - unset($values['class'][0]); - - // Valore non imposato - if (empty($values['value'])) { - $values['type'] = 'file'; - - // Generazione del codice HTML - return ' - '; - } - - // Valore presente - // Visualizzazione dell'immagine e della relativa spunta per la cancellazione - else { - $values['class'][] = 'img-thumbnail'; - $values['class'][] = 'img-responsive'; - - // Generazione del codice HTML - return ' -
    - - '; - } - } -} diff --git a/src/HTMLBuilder/Handler/SelectHandler.php b/src/HTMLBuilder/Handler/SelectHandler.php deleted file mode 100755 index b38802c5a..000000000 --- a/src/HTMLBuilder/Handler/SelectHandler.php +++ /dev/null @@ -1,260 +0,0 @@ -. - */ - -namespace HTMLBuilder\Handler; - -use AJAX; - -/** - * Gestione dell'input di tipo "select". - * - * @since 2.3 - */ -class SelectHandler implements HandlerInterface -{ - public function handle(&$values, &$extras) - { - $values['class'][] = 'openstamanager-input'; - $values['class'][] = 'select-input'; - $values['data-select2-id'][] = $values['id'].'_'.rand(0, 999); - - $source = isset($values['ajax-source']) ? $values['ajax-source'] : (isset($values['select-source']) ? $values['select-source'] : null); - - // Individuazione della classe per la corretta gestione JavaScript - $values['class'][] = !empty($source) ? 'superselectajax' : 'superselect'; - - // Individuazione e gestione dei valori tramite array - $values['value'] = explode(',', $values['value']); - if (count($values['value']) === 1 && strlen($values['value'][0]) === 0) { - $values['value'] = []; - } - - // Se il valore presente non è valido, carica l'eventuale valore predefinito - if (empty($values['value']) && !is_numeric($values['value']) && !empty($values['valore_predefinito'])) { - $values['value'] = setting($values['valore_predefinito']); - } - - // Cast del valore impostato in array - $values['value'] = (array) $values['value']; - - // Inizializzazione del codice HTML - $result = ' - '; - - // Rimozione proprietà "readonly" in favore di "disabled" - $pos = array_search('readonly', $extras); - if ($pos !== false) { - $extras[$pos] = 'disabled'; - $extras = array_unique($extras); - } - - // Gestione delle proprietà "disabled" - if (in_array('disabled', $extras)) { - $result .= ' - '; - } - - return $result; - } - - /** - * Gestione dell'input di tipo "select" con richieste AJAX (nome della richiesta indicato tramite attributo "ajax-source"). - * Esempio: {[ "type": "select", "label": "Select di test", "name": "test", "ajax-source": "test", "select-options": "id_test=1,test=si" ]}. - * - * @param string $op - * @param array $elements - * @param array $info - * - * @return string - */ - protected function select2($op, $elements, $info) - { - // Richiamo del file dedicato alle richieste AJAX per ottenere il valore iniziale del select - $response = AJAX::select($op, $elements, null, 0, 100, $info); - - $html = ''; - $results = $response['results']; - foreach ($results as $element) { - $element = (array) $element; - if (isset($element['children'][0])) { - $element = (array) $element['children'][0]; - } - - $attributes = []; - if (in_array($element['id'], $elements)) { - $attributes[] = 'selected'; - } - - if (!empty($element['_bgcolor_'])) { - $attributes[] = 'style="background:'.$element['_bgcolor_'].'; color:'.color_inverse($element['_bgcolor_'].';"'); - } - - // Leggo ulteriori campi oltre a id e descrizione per inserirli nell'option nella forma "data-nomecampo1", "data-nomecampo2", ecc - unset($element['optgroup']); - $attributes[] = "data-select-attributes='".replace(json_encode($element), ["'" => "\'"])."'"; - - $html .= ' - '; - } - - return $html; - } - - /** - * Gestione dell'input di tipo "select" basato su un array associativo. - * Esempio: {[ "type": "select", "name": "tipo", "values": [{"id":"M","text":"Maschio"},{"id":"F","text":"Femmina"},{"id":"U","text":"Unisex"}], "value": "U", "placeholder": "Non specificato" ]}. - * - * @param array $array - * @param array $values - * - * @return string - */ - protected function selectArray($array, $values) - { - $result = ''; - - $prev = ''; - foreach ($array as $element) { - if (!empty($element['optgroup'])) { - if ($prev != $element['optgroup']) { - $result .= ' - '; - $prev = $element['optgroup']; - } - } - - $element['text'] = empty($element['text']) ? $element['descrizione'] : $element['text']; - - $attributes = []; - if (in_array($element['id'], $values)) { - $attributes[] = 'selected'; - } - - if (!empty($element['_bgcolor_'])) { - $attributes[] = 'style="background:'.$element['_bgcolor_'].'; color:'.color_inverse($element['_bgcolor_']).';"'; - } - - // Leggo ulteriori campi oltre a id e descrizione per inserirli nell'option nella forma "data-nomecampo1", "data-nomecampo2", ecc - unset($element['optgroup']); - $attributes[] = "data-select-attributes='".replace(json_encode($element), ["'" => "\'"])."'"; - - $result .= ' - '; - } - - return $result; - } - - /** - * Gestione dell'input di tipo "select" basato su una query specifica. - * Esempio: {[ "type": "select", "label": "Select di test", "name": "select", "values": "query=SELECT id, name as text FROM table" ]}. - * - * @param string $query - * @param array $values - * - * @throws \Exception - * - * @return string - */ - protected function selectQuery($query, $values) - { - $database = database(); - - $array = $database->fetchArray($query); - - return $this->selectArray($array, $values); - } - - /** - * Gestione dell'input di tipo "select" basato su una lista parzialmente JSON. - * Esempio: {[ "type": "select", "label": "Sesso", "name": "sesso", "values": "list=\"\": \"Non specificato\", \"M\": \"Maschio\", \"F\": \"Femmina\", \"U\": \"Unisex\"", "value": "M" ]}. - * - * @param array $values - * @param array $extras - * - * @return string - */ - protected function selectList($datas, &$values) - { - $array = []; - - foreach ($datas as $key => $value) { - if (!empty($key)) { - $array[] = ['id' => $key, 'text' => $value]; - } elseif (empty($values['placeholder'])) { - $values['placeholder'] = $value; - } - } - - return $this->selectArray($array, $values['value']); - } -} diff --git a/src/HTMLBuilder/Manager/ButtonManager.php b/src/HTMLBuilder/Manager/ButtonManager.php deleted file mode 100755 index 14751347e..000000000 --- a/src/HTMLBuilder/Manager/ButtonManager.php +++ /dev/null @@ -1,195 +0,0 @@ -. - */ - -namespace HTMLBuilder\Manager; - -use Modules\Emails\Template; - -/** - * @since 2.4 - */ -class ButtonManager implements ManagerInterface -{ - public function manage($options) - { - $options['parameters'] = isset($options['parameters']) ? $options['parameters'] : null; - - // Impostazione id HTML automatico - if (empty($options['html_id'])) { - $options['html_id'] = ($options['type'] == 'print') ? 'print-button' : 'email-button'; - } - - if (isset($options['id'])) { - $result = $this->link($options); - } else { - $result = $this->dropdown($options); - } - - return $result; - } - - protected function getInfo($options) - { - if ($options['type'] == 'print') { - $print = \Prints::get($options['id']); - - $result = [ - 'link' => \Prints::getHref($options['id'], $options['id_record'], $options['parameters']), - 'title' => tr('Stampa').' '.((strtoupper($print['title']) == $print['title']) ? $print['title'] : lcfirst($print['title'])), - 'icon' => $print['icon'], - ]; - } else { - $template = Template::find($options['id']); - - $result = [ - 'link' => base_path().'/mail.php?id_module='.$options['id_module'].'&id_record='.$options['id_record'].'&id='.$options['id'].$options['parameters'], - 'title' => tr('Invia').' '.((strtoupper($template['name']) == $template['name']) ? $template['name'] : lcfirst($template['name'])), - 'icon' => $template['icon'], - 'type' => 'modal', - ]; - } - - return $result; - } - - protected function link($options) - { - $info = $this->getInfo($options); - - $class = isset($options['class']) ? $options['class'] : 'btn-info'; - $class = !empty($class) ? ' class="btn '.$class.'" ' : ''; - - $title = isset($options['label']) ? $options['label'] : $info['title']; - - $icon = !empty($options['icon']) ? $options['icon'] : $info['icon']; - $icon = str_replace('|default|', $info['icon'], $icon); - - // Modal - if (isset($info['type']) && $info['type'] == 'modal') { - $result = ' -'; - } - - // Link normale - else { - $result = ' -'; - } - - $result .= ' - '.$title.' -'; - - return $result; - } - - protected function getList($options) - { - if (!empty($options['id_plugin'])) { - return []; - } - - if ($options['type'] == 'print') { - $results = \Prints::getModulePrints($options['id_module']); - } else { - $results = Template::where('id_module', $options['id_module'])->get()->toArray(); - } - - return $results; - } - - protected function dropdown($options) - { - $list = $this->getList($options); - $count = count($list); - - $options['class'] = isset($options['class']) ? $options['class'] : 'btn-info'; - - if ($count > 1) { - $result = ' -
    '; - - $predefined = array_search(1, array_column($list, 'predefined')); - if ($predefined !== false) { - $element = $list[$predefined]; - - $result .= $this->link([ - 'type' => $options['type'], - 'id' => $element['id'], - 'id_module' => $options['id_module'], - 'id_record' => $options['id_record'], - 'class' => $options['class'], - 'parameters' => $options['parameters'], - 'html_id' => $options['html_id'].'_p', - ]); - - unset($list[$predefined]); - } - - $result .= ' - - -
    '; - } elseif ($count == 1) { - $result = $this->link([ - 'type' => $options['type'], - 'id' => $list[0]['id'], - 'id_module' => $options['id_module'], - 'id_record' => $options['id_record'], - 'class' => $options['class'], - 'parameters' => $options['parameters'], - 'html_id' => $options['html_id'], - ]); - } else { - $result = ' '; - } - - return $result; - } - - protected function defaultText($options) - { - if ($options['type'] == 'print') { - $result = ' '.tr('Stampa'); - } else { - $result = ' '.tr('Invia'); - } - - return $result; - } -} diff --git a/src/HTMLBuilder/Manager/EmailManager.php b/src/HTMLBuilder/Manager/EmailManager.php deleted file mode 100755 index 9a15788c8..000000000 --- a/src/HTMLBuilder/Manager/EmailManager.php +++ /dev/null @@ -1,118 +0,0 @@ -. - */ - -namespace HTMLBuilder\Manager; - -use Modules; -use Modules\Emails\Mail; - -/** - * Gestione allegati. - * - * @since 2.4.2 - */ -class EmailManager implements ManagerInterface -{ - /** - * Gestione "log_email". - * Esempio: {( "name": "log_email", "id_module": "2", "id_record": "1" )}. - * - * @param array $options - * - * @return string - */ - public function manage($options) - { - // Visualizzo il log delle operazioni di invio email - $emails = Mail::whereRaw('id IN (SELECT id_email FROM zz_operations WHERE id_record = '.prepare($options['id_record']).' AND id_module = '.prepare($options['id_module']).' AND id_email IS NOT NULL)') - ->orderBy('created_at', 'DESC') - ->get(); - - if ($emails->isEmpty()) { - return ' '; - } - - // Codice HTML - $result = ' -
    -
    -

    '.tr('Email inviate: _NUM_', [ - '_NUM_' => $emails->count(), - ]).'

    -
    - -
    -
    -
    -
      '; - - foreach ($emails as $email) { - $receivers = $email->receivers->pluck('address')->toArray(); - - $prints = []; - $list = $email->prints; - foreach ($list as $print) { - $prints[] = $print['title']; - } - - $uploads = []; - $list = $email->uploads; - foreach ($list as $upload) { - $uploads[] = $upload['name']; - } - - $sent = !empty($email['sent_at']) ? tr('inviata il _DATE_ alle _HOUR_', [ - '_DATE_' => dateFormat($email['sent_at']), - '_HOUR_' => timeFormat($email['sent_at']), - ]) : tr('in coda di invio'); - - $descrizione = Modules::link('Stato email', $email->id, tr('Email "_EMAIL_" da _USER_', [ - '_EMAIL_' => $email->template->name, - '_USER_' => $email->user->username, - ])); - - $result .= ' -
    • - '.$descrizione.' ('.$sent.'). -
        -
      • '.tr('Destinatari').': '.implode(', ', $receivers).'.
      • '; - - if (!empty($prints)) { - $result .= ' -
      • '.tr('Stampe').': '.implode(', ', $prints).'.
      • '; - } - - if (!empty($uploads)) { - $result .= ' -
      • '.tr('Allegati').': '.implode(', ', $uploads).'.
      • '; - } - - $result .= ' -
      -
    • '; - } - - $result .= ' -
    -
    -
    '; - - return $result; - } -} diff --git a/src/HTMLBuilder/Manager/FieldManager.php b/src/HTMLBuilder/Manager/FieldManager.php deleted file mode 100755 index da7dc524a..000000000 --- a/src/HTMLBuilder/Manager/FieldManager.php +++ /dev/null @@ -1,118 +0,0 @@ -. - */ - -namespace HTMLBuilder\Manager; - -/** - * @since 2.4 - */ -class FieldManager implements ManagerInterface -{ - public function manage($options) - { - $info = $this->getInfo($options); - - return $this->generate($info); - } - - public function getInfo($options) - { - $database = database(); - - $query = 'SELECT `zz_fields`.*'.(isset($options['id_record']) ? ', `zz_field_record`.`value`' : '').' FROM `zz_fields`'; - - if (isset($options['id_record'])) { - $query .= ' LEFT JOIN `zz_field_record` ON `zz_fields`.`id` = `zz_field_record`.`id_field` AND `zz_field_record`.`id_record` = '.prepare($options['id_record']); - } - - $query .= ' WHERE '; - - if (!empty($options['id_plugin'])) { - $query .= '`id_plugin` = '.prepare($options['id_plugin']); - } else { - $query .= '`id_module` = '.prepare($options['id_module']); - } - - if (isset($options['place']) && $options['place'] == 'add') { - $query .= ' AND `on_add` = 1'; - } - - $query .= ' AND `top` = '.((isset($options['position']) && $options['position'] == 'top') ? 1 : 0).' ORDER BY `order`'; - - $results = $database->fetchArray($query); - - return $results; - } - - public function generate($fields) - { - // Spazio per evitare problemi con la sostituzione del tag - $result = ' '; - - if (!empty($fields)) { - $result .= ' -
    -
    -

    '.tr('Campi aggiuntivi').'

    -
    -
    '; - - // Costruzione dei campi - foreach ($fields as $key => $field) { - if ($key % 3 == 0) { - $result .= ' -
    '; - } - - $field['value'] = isset($field['value']) ? $field['value'] : ''; - - $replace = [ - 'value' => $field['value'], - 'label' => $field['name'], - 'name' => $field['html_name'], - ]; - - foreach ($replace as $name => $value) { - $field['content'] = str_replace('|'.$name.'|', $value, $field['content']); - } - - $result .= ' -
    - '.$field['content'].' -
    '; - - if (($key + 1) % 3 == 0) { - $result .= ' -
    '; - } - } - - if (($key + 1) % 3 != 0) { - $result .= ' -
    '; - } - - $result .= ' -
    -
    '; - } - - return $result; - } -} diff --git a/src/HTMLBuilder/Manager/FileManager.php b/src/HTMLBuilder/Manager/FileManager.php deleted file mode 100755 index 5d0ab902f..000000000 --- a/src/HTMLBuilder/Manager/FileManager.php +++ /dev/null @@ -1,265 +0,0 @@ -. - */ - -namespace HTMLBuilder\Manager; - -use Models\Setting; -use Models\Upload; -use Util\FileSystem; - -/** - * Gestione allegati. - * - * @since 2.3 - */ -class FileManager implements ManagerInterface -{ - /** - * Gestione "filelist_and_upload". - * Esempio: {( "name": "filelist_and_upload", "id_module": "2", "id_record": "1", "readonly": "false" )}. - * - * @param array $options - * - * @return string - */ - public function manage($options) - { - $options['readonly'] = !empty($options['readonly']) ? true : false; - $options['showpanel'] = isset($options['showpanel']) ? $options['showpanel'] : true; - - $options['id_plugin'] = !empty($options['id_plugin']) ? $options['id_plugin'] : null; - - // ID del form - $attachment_id = 'attachments_'.$options['id_module'].'_'.$options['id_plugin']; - - $upload_max_filesize = ini_get('upload_max_filesize'); - $upload_max_filesize = substr($upload_max_filesize, 0, -1); - - $dbo = database(); - - // Codice HTML - $result = ' -
    '; - - if (!empty($options['showpanel'])) { - $result .= ' -
    -
    -

    '.tr('Allegati').'

    -
    -
    '; - } - - $count = 0; - - $where = '`id_module` '.(!empty($options['id_module']) && empty($options['id_plugin']) ? '= '.prepare($options['id_module']) : 'IS NULL').' AND `id_plugin` '.(!empty($options['id_plugin']) ? '= '.prepare($options['id_plugin']) : 'IS NULL').''; - - // Categorie - $categories = $dbo->fetchArray('SELECT DISTINCT(BINARY `category`) AS `category` FROM `zz_files` WHERE '.$where.' ORDER BY `category`'); - foreach ($categories as $category) { - $category = $category['category']; - - $rs = $dbo->fetchArray('SELECT * FROM `zz_files` WHERE BINARY `category`'.(!empty($category) ? '= '.prepare($category) : 'IS NULL').' AND `id_record` = '.prepare($options['id_record']).' AND '.$where); - - if (!empty($rs)) { - $result .= ' -
    -
    -

    '.(!empty($category) ? $category : tr('Generale')).'

    - - {[ "type": "text", "class": "hidden category-name", "value": "'.$category.'" ]} - -
    '; - - if (!empty($category) && !in_array($category, ['Fattura Elettronica'])) { - $result .= ' - - - - - '; - } - - $result .= ' - -
    -
    -
    - - - - - - - - - '; - - foreach ($rs as $r) { - $file = Upload::find($r['id']); - - $result .= ' - - - - - - - '; - - ++$count; - } - - $result .= ' - -
    '.tr('Nome').''.tr('Data').'#
    '; - - if ($file->user && $file->user->photo) { - $result .= ' - '; - } else { - $result .= ' - - '; - } - - $result .= ' - - - '.$r['name'].' - - - ('.$file->extension.')'.((!empty($file->size)) ? ' ('.FileSystem::formatBytes($file->size).')' : '').' '.(((setting('Logo stampe') == $r['filename']) || (setting('Filigrana stampe') == $r['filename'])) ? '' : '').''.' - '.timestampFormat($r['created_at']).' - '; - - // Anteprime supportate dal browser - if ($file->hasPreview()) { - $result .= ' - '; - } else { - $result .= ' - '; - } - - if (!$options['readonly']) { - $result .= ' - - - '; - } - - $result .= ' -
    -
    -
    - -
    -
    '; - } - } - - // Form per l'upload di un nuovo file - if (!$options['readonly']) { - $result .= ' -
    -
    -
    - -
    -
    -
    '; - } - // In caso di readonly, se non è stato caricato nessun allegato mostro almeno box informativo - elseif ($count == 0) { - $result .= ' -
    - - '.tr('Nessun allegato è stato caricato').'. -
    '; - } - - if (!empty($options['showpanel'])) { - $result .= ' -
    -
    -
    '; - } - - $source = array_clean(array_column($categories, 'category')); - - $result .= ' - - -'; - - return $result; - } -} diff --git a/src/HTMLBuilder/Manager/ManagerInterface.php b/src/HTMLBuilder/Manager/ManagerInterface.php deleted file mode 100755 index 1a31ceb9e..000000000 --- a/src/HTMLBuilder/Manager/ManagerInterface.php +++ /dev/null @@ -1,28 +0,0 @@ -. - */ - -namespace HTMLBuilder\Manager; - -/** - * @since 2.3 - */ -interface ManagerInterface -{ - public function manage($options); -} diff --git a/src/HTMLBuilder/Manager/WidgetManager.php b/src/HTMLBuilder/Manager/WidgetManager.php deleted file mode 100755 index ad9597861..000000000 --- a/src/HTMLBuilder/Manager/WidgetManager.php +++ /dev/null @@ -1,278 +0,0 @@ -. - */ - -namespace HTMLBuilder\Manager; - -use Util\Query; - -/** - * @since 2.4 - */ -class WidgetManager implements ManagerInterface -{ - public function manage($options) - { - $result = ''; - - if (isset($options['id'])) { - $result = $this->widget($options); - } else { - $result = $this->group($options); - } - - return $result; - } - - protected function widget($options) - { - $database = database(); - - // Widget richiesto - $widget = $database->fetchArray('SELECT * FROM zz_widgets WHERE id = '.prepare($options['id']))[0]; - - $result = ' '; - - // Generazione del widget in base al tipo - switch ($widget['type']) { - // Stampa - case 'print': - $result = $this->prints($widget); - - break; - - // Statistiche - case 'stats': - $result = $this->stats($widget); - - break; - - // Chart (codice PHP) - case 'chart': - $result = $this->chart($widget); - - break; - - // Personalizzato (codice PHP e icona) - case 'custom': - $result = $this->custom($widget); - - break; - } - - return $result; - } - - protected static function getModule() - { - return \Modules::get('Stato dei servizi'); - } - - protected function prints($widget) - { - return $this->stats($widget); - } - - protected function stats($widget) - { - // Individuazione della query relativa - $query = $widget['query']; - - $additionals = \Modules::getAdditionalsQuery($widget['id_module']); - if (!empty($additionals)) { - $query = str_replace('1=1', '1=1 '.$additionals, $query); - } - - $query = Query::replacePlaceholder($query); - - // Individuazione del risultato della query - $database = database(); - $value = null; - if (!empty($query)) { - $value = $database->fetchArray($query)[0]['dato']; - if (!preg_match('/\\d/', $value)) { - $value = '-'; - } - } - - return $this->render($widget, $widget['text'], $value); - } - - protected function chart($widget, $number = null) - { - $content = null; - if (!empty($widget['php_include'])) { - $is_title_request = true; - - ob_start(); - include base_dir().'/'.$widget['php_include']; - $content = ob_get_clean(); - } - - return $this->render($widget, $content, $number); - } - - protected function custom($widget) - { - $content = null; - if (!empty($widget['php_include'])) { - $is_number_request = true; - ob_start(); - include base_dir().'/'.$widget['php_include']; - $content = ob_get_clean(); - } - - return $this->render($widget, $widget['text'], $content); - } - - protected function render($widget, $title, $number = null) - { - $result = ' - '; - - if (!empty($widget['more_link'])) { - $result .= ' -'; - - if (!empty($widget['icon'])) { - $result .= ' - '; - } - - $result .= ' -
    - -
    - - '.$title.' - - '.(!empty($widget['help']) ? '' : '').' - '; - - if (isset($number)) { - $result .= ' - '.$number.''; - } - - $result .= ' -
    '; - - $result .= ' - '; - - if (!empty($widget['more_link'])) { - $result .= ' -
    '; - } - - return $result; - } - - protected function group($options) - { - $query = 'SELECT id FROM zz_widgets WHERE id_module = '.prepare($options['id_module']).' AND (|position|) AND enabled = 1 ORDER BY `order` ASC'; - - // Mobile (tutti i widget a destra) - if (isMobile()) { - if ($options['position'] == 'right') { - $position = "location = '".$options['place']."_right' OR location = '".$options['place']."_top'"; - } elseif ($options['position'] == 'top') { - $position = '1=0'; - } - } - - // Widget a destra - elseif ($options['position'] == 'right') { - $position = "location = '".$options['place']."_right'"; - } - - // Widget in alto - elseif ($options['position'] == 'top') { - $position = "location = '".$options['place']."_top'"; - } - - $query = str_replace('|position|', $position, $query); - - // Individuazione dei widget interessati - $database = database(); - $widgets = $database->fetchArray($query); - - $result = ' '; - - // Generazione del codice HTML - if (!empty($widgets)) { - $row_max = count($widgets); - if ($row_max > 4) { - $row_max = 4; - } elseif ($row_max < 2) { - $row_max = 2; - } - - $result = ' -
      '; - - // Aggiungo ad uno ad uno tutti i widget - foreach ($widgets as $widget) { - $result .= ' -
    • '; - - $info = array_merge($options, [ - 'id' => $widget['id'], - ]); - $result .= $this->widget($info); - - $result .= ' -
    • '; - } - - $result .= ' -
    '; - } - - return $result; - } -} diff --git a/src/HTMLBuilder/Wrapper/HTMLWrapper.php b/src/HTMLBuilder/Wrapper/HTMLWrapper.php deleted file mode 100755 index 985ad73a3..000000000 --- a/src/HTMLBuilder/Wrapper/HTMLWrapper.php +++ /dev/null @@ -1,286 +0,0 @@ -. - */ - -namespace HTMLBuilder\Wrapper; - -use Modules; - -/** - * @since 2.3 - */ -class HTMLWrapper implements WrapperInterface -{ - public function before(&$values, &$extras) - { - $result = ''; - - // Valori particolari - $values['icon-before'] = isset($values['icon-before']) ? $this->parser($values, $extras, $values['icon-before']) : null; - $values['icon-after'] = isset($values['icon-after']) ? $this->parser($values, $extras, $values['icon-after']) : null; - - // Generazione dell'etichetta - if (!empty($values['label'])) { - $result .= ' -
    - '; - } - - if (!empty($values['icon-before']) || !empty($values['icon-after']) || !empty($values['validation'])) { - $result .= ' -
    '; - - if (!empty($values['icon-before'])) { - $result .= ' - '.$values['icon-before'].''; - } - } - - return $result; - } - - public function after(&$values, &$extras) - { - $rand = rand(0, 99); - $pseudo_id = $values['id'].$rand; - - $result = ''; - - if (!empty($values['icon-before']) || !empty($values['icon-after']) || !empty($values['validation'])) { - if (!empty($values['icon-after'])) { - $result .= ' - '.$values['icon-after'].''; - } - - if (!empty($values['validation'])) { - $result .= ' - - - '; - } - - $result .= ' -
    '; - - unset($values['icon-before']); - unset($values['icon-after']); - unset($values['icon-custom']); - } - - if (!empty($values['help']) && !empty($values['show-help'])) { - $result .= ' - '.$values['help'].''; - - unset($values['help']); - unset($values['show-help']); - } - - $values['data-parsley-errors-container'] = '#'.$pseudo_id.'-errors'; - - $result .= ' -
    '; - - if (!empty($values['label'])) { - $result .= ' -
    '; - unset($values['label']); - } - - if (!empty($values['validation'])) { - $values['valid'] = '1'; - - $value = explode('|', $values['validation']); - $name = $value[0]; - $id_module = isset($value[1]) ? $value[1] : '$id_module$'; - $id_record = isset($value[2]) ? $value[2] : '$id_record$'; - - $result .= ' - '; - } - - return $result; - } - - protected function parser(&$values, &$extras, $string) - { - $result = $string; - - if (string_starts_with($string, 'add|')) { - $result = $this->add($values, $extras, $string); - $values['icon-custom'] = 'no-padding'; - } elseif (string_starts_with($string, 'choice|')) { - $result = $this->choice($values, $extras, $string); - $values['icon-custom'] = 'no-padding'; - } - - if (string_contains($string, 'permission, ['r', 'rw'])) { - $result = ' -'; - } - - return $result; - } - - protected function choice(&$values, &$extras, $string) - { - $result = null; - - $pieces = explode('|', $string); - $type = $pieces[1]; - $extra = !empty($pieces[3]) ? $pieces[3] : null; - - if ($type == 'untprc') { - $choices = [ - [ - 'id' => 'PRC', - 'descrizione' => '%', - ], - [ - 'id' => 'UNT', - 'descrizione' => currency(), - ], - ]; - } elseif ($type == 'email') { - $choices = [ - [ - 'id' => 'a', - 'descrizione' => tr('A').'     ', - ], - [ - 'id' => 'cc', - 'descrizione' => tr('CC').'  ', - ], - [ - 'id' => 'bcc', - 'descrizione' => tr('CCN'), - ], - ]; - } elseif ($type == 'period') { - $choices = [ - [ - 'id' => 'manual', - 'descrizione' => tr('giorno/i (manuale)'), - ], - [ - 'id' => 'days', - 'descrizione' => tr('giorno/i'), - ], - [ - 'id' => 'months', - 'descrizione' => tr('mese/i'), - ], - [ - 'id' => 'years', - 'descrizione' => tr('anno/i'), - ], - ]; - } - - $value = (empty($pieces[2]) || !in_array($pieces[2], array_column($choices, 'id'))) ? $choices[0]['id'] : $pieces[2]; - - $result = '{[ "type": "select", "name": "tipo_'.prepareToField($values['name']).'", "id": "tipo_'.prepareToField($values['name']).'_'.rand(0, 99).'", "value": "'.prepareToField($value).'", "values": '.json_encode($choices).', "class": "no-search", "extra": "'.$extra.'" ]}'; - - $result = \HTMLBuilder\HTMLBuilder::replace($result); - - return $result; - } -} diff --git a/src/HTMLBuilder/Wrapper/WrapperInterface.php b/src/HTMLBuilder/Wrapper/WrapperInterface.php deleted file mode 100755 index 469c6ce48..000000000 --- a/src/HTMLBuilder/Wrapper/WrapperInterface.php +++ /dev/null @@ -1,32 +0,0 @@ -. - */ - -namespace HTMLBuilder\Wrapper; - -/** - * Interfaccia di base per la gestione della struttura HTML contenente gli input effettivi (generati dai tag di input). - * - * @since 2.3 - */ -interface WrapperInterface -{ - public function before(&$values, &$extras); - - public function after(&$values, &$extras); -} diff --git a/src/Hooks/CachedManager.php b/src/Hooks/CachedManager.php deleted file mode 100755 index 8e2eac49c..000000000 --- a/src/Hooks/CachedManager.php +++ /dev/null @@ -1,65 +0,0 @@ -. - */ - -namespace Hooks; - -use Models\Cache; -use Models\Hook; - -abstract class CachedManager extends Manager -{ - protected $cache = null; - - public function __construct(Hook $hook) - { - parent::__construct($hook); - - $this->cache = Cache::pool($this->getCacheName()); - } - - abstract public function cacheData(); - - abstract public function getCacheName(); - - public function needsExecution() - { - return !$this->isCached(); - } - - public function execute() - { - if (!$this->isCached()) { - $data = $this->cacheData(); - - $this->getCache()->set($data); - } - - return $this->getCache()->content; - } - - public function getCache() - { - return $this->cache; - } - - public function isCached() - { - return $this->getCache()->isValid(); - } -} diff --git a/src/Hooks/Manager.php b/src/Hooks/Manager.php deleted file mode 100755 index a8e608f19..000000000 --- a/src/Hooks/Manager.php +++ /dev/null @@ -1,89 +0,0 @@ -. - */ - -namespace Hooks; - -use Models\Hook; - -abstract class Manager -{ - protected $hook = null; - - public function __construct(Hook $hook) - { - $this->hook = $hook; - } - - /** - * Restituisce le informazioni sull'esecuzione dell'hook. - * - * @return mixed - */ - abstract public function execute(); - - /** - * Restituisce le informazioni per la visualizzazione dell'hook. - * - * @return array - */ - abstract public function response(); - - /** - * Restituisce se l'hook è un singletion, cioè deve essere richiamato solo da una istanza di navigazione. - * - * @return bool - */ - public function isSingleton() - { - return false; - } - - /** - * Restituisce se l'hook ha bisogno di una esecuzione. - * - * @return bool - */ - abstract public function needsExecution(); - - /** - * Gestisce la chiamata per l'esecuzione dell'hook. - * - * @return array|mixed - */ - public function manage() - { - if (!$this->needsExecution()) { - return []; - } - - $results = $this->execute(); - - return []; - } - - /** - * Restituisce l'hook Eloquent relativo alla classe. - * - * @return Hook|null - */ - protected function getHook() - { - return $this->getHook(); - } -} diff --git a/src/Importer/CSVImporter.php b/src/Importer/CSVImporter.php deleted file mode 100644 index 4cac500fa..000000000 --- a/src/Importer/CSVImporter.php +++ /dev/null @@ -1,157 +0,0 @@ -. - */ - -namespace Importer; - -use Filter; -use League\Csv\Reader; - -/** - * Classe dedicata alla gestione dell'importazione da file CSV. - * - * @since 2.4.17 - */ -abstract class CSVImporter implements ImporterInterface -{ - protected $csv; - - protected $column_associations; - protected $primary_key; - - public function __construct($file) - { - // Impostazione automatica per i caratteri di fine riga - if (!ini_get('auto_detect_line_endings')) { - ini_set('auto_detect_line_endings', '1'); - } - - // Gestione del file CSV - $this->csv = Reader::createFromPath($file, 'r'); - $this->csv->setDelimiter(';'); - - $this->column_associations = []; - } - - public function init() - { - } - - public function complete() - { - } - - public function getColumnAssociations() - { - return $this->column_associations; - } - - public function setColumnAssociation($column_key, $field_key) - { - $this->column_associations[$column_key] = $this->getAvailableFields()[$field_key]['field']; - } - - abstract public function getAvailableFields(); - - public function getHeader() - { - $first_row = $this->getRows(0, 1); - - return array_shift($first_row); - } - - public function getRows($offset, $length) - { - $rows = []; - for ($i = 0; $i < $length; ++$i) { - // Lettura di una singola riga alla volta - $row = $this->csv->fetchOne($offset + $i); - if (empty($row)) { - break; - } - - // Aggiunta all'insieme dei record - $rows[] = Filter::parse($row); - } - - return $rows; - } - - public function importRows($offset, $length) - { - $rows = $this->getRows($offset, $length); - foreach ($rows as $row) { - // Interpretazione della riga come record - $record = $this->getRecord($row); - - // Importazione del record - $this->import($record); - } - - return count($rows); - } - - abstract public function import($record); - - public function getPrimaryKey() - { - return $this->primary_key; - } - - public function setPrimaryKey($field_key) - { - $this->primary_key = $this->getAvailableFields()[$field_key]['field']; - } - - public static function createExample($filepath) - { - $content = static::getExample(); - - $file = fopen($filepath, 'w'); - fprintf($file, chr(0xEF).chr(0xBB).chr(0xBF)); - - foreach ($content as $row) { - fputcsv($file, $row, ';'); - } - - fclose($file); - } - - /** - * Interpreta una riga del CSV secondo i campi impostati dinamicamente. - * - * @param $row - * - * @return array - */ - protected function getRecord($row) - { - $associations = $this->getColumnAssociations(); - - // Interpretazione della riga come record - $record = []; - foreach ($row as $key => $value) { - $field = isset($associations[$key]) ? $associations[$key] : null; - if (!empty($field)) { - $record[$field] = $value; - } - } - - return $record; - } -} diff --git a/src/Importer/ImporterInterface.php b/src/Importer/ImporterInterface.php deleted file mode 100644 index 30eef3294..000000000 --- a/src/Importer/ImporterInterface.php +++ /dev/null @@ -1,123 +0,0 @@ -. - */ - -namespace Importer; - -/** - * Interfaccia che definisce la struttura di base per la gestione delle importazioni di documenti come dati del gestionale. - * - * @since 2.4.17 - */ -interface ImporterInterface -{ - /** - * Esegue le operazioni di inizializzazione per la procedura di importazione. - * - * @return mixed - */ - public function init(); - - /** - * Esegue le operazioni di finalizazione per la procedura di importazione. - * - * @return mixed - */ - public function complete(); - - /** - * Restituisce le associazioni impostate tra colonne e campi del documento. - * - * @return mixed - */ - public function getColumnAssociations(); - - /** - * Imposta l'associazione di una specifica colonna del documento al relativo campo del documento. - * - * @param $column_key - * @param $field_key - * - * @return mixed - */ - public function setColumnAssociation($column_key, $field_key); - - /** - * Restitusice i campi disponibili all'importazione. - * - * @return mixed - */ - public function getAvailableFields(); - - /** - * Restituisce l'header (potenziale) per il documento da importare. - * - * @return mixed - */ - public function getHeader(); - - /** - * Restituisce un sottoinsieme delle righe del documento. - * - * @param $offset - * @param $length - * - * @return array - */ - public function getRows($offset, $length); - - /** - * Importa un sottoinsieme delle righe del documento nel gestionale. - * - * @param $offset - * @param $length - * - * @return int - */ - public function importRows($offset, $length); - - /** - * Gestisce le operazioni di importazione per un singolo record. - * - * @param $record - * - * @return bool - */ - public function import($record); - - /** - * Restituisce la chiave primaria impostata dall'utente. - * - * @return mixed - */ - public function getPrimaryKey(); - - /** - * Imposta la chiave primaria selezionata dall'utente. - * - * @param $field_key - */ - public function setPrimaryKey($field_key); - - /** - * Restituisce un esempio di dato importabile. - * - * @return array - */ - public static function getExample(); -} diff --git a/src/Intl/FileLoader.php b/src/Intl/FileLoader.php deleted file mode 100755 index c7edc98b7..000000000 --- a/src/Intl/FileLoader.php +++ /dev/null @@ -1,70 +0,0 @@ -. - */ - -namespace Intl; - -/** - * Classe dedicata al caricamento delle risorse per le traduzioni. - * - * @since 2.3 - */ -class FileLoader extends \Symfony\Component\Translation\Loader\FileLoader -{ - protected static $loaders = []; - protected $include_filename; - - public function __construct($include_filename = false) - { - $this->include_filename = $include_filename; - } - - protected function loadResource($resource) - { - $result = []; - - $extension = strtolower(pathinfo($resource, PATHINFO_EXTENSION)); - $loader = $this->getLoader($extension); - if (!empty($extension) && $extension != 'po' && !empty($loader)) { - $result = $loader->loadResource($resource); - - if (!empty($this->include_filename)) { - $result = array_combine( - array_map(function ($k) use ($resource, $extension) { - return basename($resource, '.'.$extension).'.'.$k; - }, array_keys($result)), - $result - ); - } - } - - return $result; - } - - protected function getLoader($name) - { - if (empty(self::$loaders[$name])) { - $class = '\Symfony\Component\Translation\Loader\\'.ucfirst($name).'FileLoader'; - if (class_exists($class)) { - self::$loaders[$name] = new $class(); - } - } - - return !empty(self::$loaders[$name]) ? self::$loaders[$name] : null; - } -} diff --git a/src/Intl/Formatter.php b/src/Intl/Formatter.php deleted file mode 100755 index 1b5b3ee54..000000000 --- a/src/Intl/Formatter.php +++ /dev/null @@ -1,607 +0,0 @@ -. - */ - -namespace Intl; - -use DateTime; -use NumberFormatter; - -/** - * Classe per gestire la formattazione di date e numeri in convenzioni differenti. - * - * @since 2.3 - */ -class Formatter -{ - protected static $standards = [ - 'timestamp' => 'Y-m-d H:i:s', - 'date' => 'Y-m-d', - 'time' => 'H:i:s', - 'number' => [ - 'decimals' => '.', - 'thousands' => '', - ], - ]; - - /** @var NumberFormatter|array Oggetto dedicato alla formattazione dei numeri */ - protected $numberFormatter; - protected $precision; - - /** @var string Pattern per i timestamp */ - protected $timestampPattern; - /** @var string Pattern per le date */ - protected $datePattern; - /** @var string Pattern per gli orari */ - protected $timePattern; - - /** @var array Pattern per SQL */ - protected $sql = []; - - public function __construct($locale, $timestamp = null, $date = null, $time = null, $number = []) - { - if (class_exists('NumberFormatter')) { - $this->numberFormatter = new NumberFormatter($locale, NumberFormatter::DECIMAL); - - $this->numberFormatter->setAttribute(NumberFormatter::ROUNDING_MODE, NumberFormatter::ROUND_HALFUP); - } else { - $this->numberFormatter = $number; - } - - $this->setTimestampPattern($timestamp); - - $this->setDatePattern($date); - - $this->setTimePattern($time); - } - - /** - * Restituisce gli elementi di separazione secondo la formattazione in utilizzo. - * - * @return array - */ - public static function getStandardFormats() - { - return static::$standards; - } - - /** - * Restituisce gli elementi di separazione secondo la formattazione in utilizzo. - * - * @return mixed - */ - public function format($value) - { - if (!empty($value)) { - if ($this->isStandardDate($value)) { - $value = $this->formatDate($value); - } elseif ($this->isStandardTime($value)) { - $value = $this->formatTime($value); - } elseif ($this->isStandardTimestamp($value)) { - $value = $this->formatTimestamp($value); - } elseif ($this->isStandardNumber($value)) { - $value = $this->formatNumber($value); - } - } - - return $value; - } - - /** - * Restituisce gli elementi di separazione secondo la formattazione in utilizzo. - * - * @return mixed - */ - public function parse($value) - { - if (!empty($value)) { - if ($this->isFormattedDate($value)) { - $value = $this->parseDate($value); - } elseif ($this->isFormattedTime($value)) { - $value = $this->parseTime($value); - } elseif ($this->isFormattedTimestamp($value)) { - $value = $this->parseTimestamp($value); - } elseif ($this->isFormattedNumber($value)) { - $value = $this->parseNumber($value); - } - } - - return $value; - } - - // Gestione della conversione dei numeri - - /** - * Converte un numero da una formattazione all'altra. - * - * @param string $value - * @param int $decimals - * - * @return string|bool - */ - public function formatNumber($value, $decimals = null) - { - $value = trim($value); - $value = floatval($value); - - if (isset($decimals)) { - $original = $this->getPrecision(); - $this->setPrecision($decimals); - } - - if (is_object($this->numberFormatter)) { - $result = $this->numberFormatter->format($value); - } else { - $number = number_format($value, $this->getPrecision(), self::getStandardFormats()['number']['decimals'], self::getStandardFormats()['number']['thousands']); - - $result = $this->customNumber($number, self::getStandardFormats()['number'], $this->getNumberSeparators()); - } - - if (isset($decimals)) { - $this->setPrecision($original); - } - - return is_numeric($value) ? $result : false; - } - - /** - * Converte un numero da una formattazione all'altra. - * - * @param string $value - * - * @return float|bool - */ - public function parseNumber($value) - { - // Controllo sull'effettiva natura del numero - $sign = null; - if ($value[0] == '+' || $value[0] == '-') { - $sign = $value[0]; - $value = substr($value, 1); - } - - $number = str_replace(array_values($this->getNumberSeparators()), '', $value); - - $pieces = explode($this->getNumberSeparators()['decimals'], $value); - $integer = str_replace(array_values($this->getNumberSeparators()), '', $pieces[0]); - - if (!ctype_digit($number) || (strlen($integer) != strlen((int) $integer)) || is_numeric($value)) { - return false; - } - - $value = $sign.$value; - - if (is_object($this->numberFormatter)) { - $result = $this->numberFormatter->parse($value); - } else { - $result = $this->customNumber($value, $this->getNumberSeparators(), self::getStandardFormats()['number']); - } - - $result = is_numeric($result) ? floatval($result) : false; - - return $result; - } - - /** - * Controlla se l'elemento indicato è un numero. - * - * @param string $value - * - * @return bool - */ - public function isStandardNumber($value) - { - $result = $this->formatNumber($value); - - return !is_bool($result); - } - - /** - * Controlla se l'elemento indicato è un numero. - * - * @param string $value - * - * @return bool - */ - public function isFormattedNumber($value) - { - $result = $this->parseNumber($value); - - return !is_bool($result); - } - - /** - * Imposta la precisione di default per i numeri da formattare. - * - * @param int $decimals - */ - public function setPrecision($decimals) - { - if (is_object($this->numberFormatter)) { - $this->numberFormatter->setAttribute(NumberFormatter::FRACTION_DIGITS, $decimals); - } else { - $this->precision = $decimals; - } - } - - /** - * Restituisce la precisione di default per i numeri da formattare. - * - * @return int - */ - public function getPrecision() - { - return is_object($this->numberFormatter) ? $this->numberFormatter->getAttribute(NumberFormatter::FRACTION_DIGITS) : $this->precision; - } - - /** - * Restituisce gli elementi di separazione secondo la formattazione in utilizzo. - * - * @return array - */ - public function getNumberSeparators() - { - return [ - 'decimals' => is_object($this->numberFormatter) ? $this->numberFormatter->getSymbol(NumberFormatter::DECIMAL_SEPARATOR_SYMBOL) : $this->numberFormatter['decimals'], - 'thousands' => is_object($this->numberFormatter) ? $this->numberFormatter->getSymbol(NumberFormatter::GROUPING_SEPARATOR_SYMBOL) : $this->numberFormatter['thousands'], - ]; - } - - /** - * Converte l'elemento in una rappresentazione numerica. - * - * @param string $value - * - * @return string|bool - */ - public function customNumber($value, $current, $format) - { - $value = trim($value); - - if (strlen($value) == 0) { - return false; - } - - $sign = null; - if ($value[0] == '+' || $value[0] == '-') { - $sign = $value[0]; - $value = trim(substr($value, 1)); - } elseif (!is_numeric($value[0])) { - return false; - } - - if (strlen($value) == 0) { - return false; - } - - $pieces = explode($current['decimals'], $value); - if (count($pieces) > 2) { - return false; - } - $integer = $pieces[0]; - $decimal = (isset($pieces[1])) ? $pieces[1] : null; - - if (!empty($current['thousands'])) { - $error = true; - if (floor(strlen($integer) / 4) == substr_count($integer, $current['thousands'])) { - $values = str_split(strrev($integer), 4); - - foreach ($values as $key => $value) { - if (strlen($value) == 4 && string_ends_with($value, $current['thousands'])) { - $values[$key] = substr($value, 0, -1); - } - } - - $integer = strrev(implode($values)); - - $error = substr_count($integer, $current['thousands']); - } - - if (!empty($error)) { - return false; - } - } - - if (!ctype_digit($integer) || (strlen($integer) != strlen((int) $integer)) || (isset($decimal) && !ctype_digit($decimal))) { - return false; - } - - $result = $sign.number_format($integer, 0, '', $format['thousands']); - - if (isset($decimal)) { - $result .= $format['decimals'].$decimal; - } - - return $result; - } - - // Gestione della conversione dei timestamp - - /** - * Converte un timestamp da una formattazione all'altra. - * - * @param string $value - * - * @return string|bool - */ - public function formatTimestamp($value) - { - $object = DateTime::createFromFormat(static::$standards['timestamp'], $value); - $result = is_object($object) ? $object->format($this->getTimestampPattern()) : false; - - return $result; - } - - /** - * Converte un timestamp da una formattazione all'altra. - * - * @param string $value - * - * @return string|bool - */ - public function parseTimestamp($value) - { - $object = DateTime::createFromFormat($this->getTimestampPattern(), $value); - $result = is_object($object) ? $object->format(static::$standards['timestamp']) : false; - - return $result; - } - - /** - * Controlla se l'elemento indicato è un timestamp. - * - * @param string $value - * - * @return bool - */ - public function isStandardTimestamp($value) - { - $result = $this->formatTimestamp($value); - - return !is_bool($result); - } - - /** - * Controlla se l'elemento indicato è un timestamp. - * - * @param string $value - * - * @return bool - */ - public function isFormattedTimestamp($value) - { - $result = $this->parseTimestamp($value); - - return !is_bool($result); - } - - /** - * Restituisce il formato del timestamp. - * - * @return string - */ - public function getTimestampPattern($type = null) - { - return $this->timestampPattern; - } - - /** - * Imposta il formato del timestamp. - * - * @return string - */ - public function setTimestampPattern($pattern) - { - return $this->timestampPattern = $pattern; - } - - // Gestione della conversione delle date - - /** - * Converte una data da una formattazione all'altra. - * - * @param string $value - * - * @return string|bool - */ - public function formatDate($value) - { - $object = DateTime::createFromFormat(static::$standards['date'], $value); - - // Fallback per la gestione dei timestamp - $object = !is_object($object) ? DateTime::createFromFormat(static::$standards['timestamp'], $value) : $object; - - $result = is_object($object) ? $object->format($this->getDatePattern()) : false; - - return $result; - } - - /** - * Converte una data da una formattazione all'altra. - * - * @param string $value - * - * @return string|bool - */ - public function parseDate($value) - { - $object = DateTime::createFromFormat($this->getDatePattern(), $value); - $result = is_object($object) ? $object->format(static::$standards['date']) : false; - - return $result; - } - - /** - * Controlla se l'elemento indicato è una data. - * - * @param string $value - * - * @return bool - */ - public function isStandardDate($value) - { - $result = $this->formatDate($value); - - return !is_bool($result); - } - - /** - * Controlla se l'elemento indicato è una data. - * - * @param string $value - * - * @return bool - */ - public function isFormattedDate($value) - { - $result = $this->parseDate($value); - - return !is_bool($result); - } - - /** - * Restituisce il formato del timestamp. - * - * @return string - */ - public function getDatePattern() - { - return $this->datePattern; - } - - /** - * Imposta il formato del timestamp. - * - * @return string - */ - public function setDatePattern($pattern) - { - return $this->datePattern = $pattern; - } - - // Gestione della conversione degli orarii - - /** - * Converte un orario da una formattazione all'altra. - * - * @param string $value - * - * @return string|bool - */ - public function formatTime($value) - { - $object = DateTime::createFromFormat(static::$standards['time'], $value); - - // Fallback per la gestione dei timestamp - $object = !is_object($object) ? DateTime::createFromFormat(static::$standards['timestamp'], $value) : $object; - - $result = is_object($object) ? $object->format($this->getTimePattern()) : false; - - return $result; - } - - /** - * Converte un orario da una formattazione all'altra. - * - * @param string $value - * - * @return string|bool - */ - public function parseTime($value) - { - $object = DateTime::createFromFormat($this->getTimePattern(), $value); - $result = is_object($object) ? $object->format(static::$standards['time']) : false; - - return $result; - } - - /** - * Controlla se l'elemento indicato è un orario. - * - * @param string $value - * - * @return bool - */ - public function isStandardTime($value) - { - $result = $this->formatTime($value); - - return !is_bool($result); - } - - /** - * Controlla se l'elemento indicato è un orario. - * - * @param string $value - * - * @return bool - */ - public function isFormattedTime($value) - { - $result = $this->parseTime($value); - - return !is_bool($result); - } - - /** - * Restituisce il formato del orario. - * - * @return string - */ - public function getTimePattern($type = null) - { - return $this->timePattern; - } - - /** - * Imposta il formato del orario. - * - * @return string - */ - public function setTimePattern($pattern) - { - return $this->timePattern = $pattern; - } - - public function getSQLPatterns() - { - if (empty($this->sql)) { - $formats = [ - 'd' => '%d', - 'm' => '%m', - 'Y' => '%Y', - 'H' => '%H', - 'i' => '%i', - ]; - - $result = [ - 'timestamp' => $this->getTimestampPattern(), - 'date' => $this->getDatePattern(), - 'time' => $this->getTimePattern(), - ]; - - foreach ($result as $key => $value) { - $result[$key] = replace($value, $formats); - } - - $this->sql = $result; - } - - return $this->sql; - } -} diff --git a/src/Models/ApiResource.php b/src/Models/ApiResource.php deleted file mode 100755 index b7130009b..000000000 --- a/src/Models/ApiResource.php +++ /dev/null @@ -1,32 +0,0 @@ -. - */ - -namespace Models; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; - -class ApiResource extends Model -{ - use SimpleModelTrait; - - protected $table = 'zz_api_resources'; - - /* Relazioni Eloquent */ -} diff --git a/src/Models/Cache.php b/src/Models/Cache.php deleted file mode 100755 index b7eaefc9b..000000000 --- a/src/Models/Cache.php +++ /dev/null @@ -1,108 +0,0 @@ -. - */ - -namespace Models; - -use Carbon\Carbon; -use Carbon\CarbonInterval; -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; -use Traits\LocalPoolTrait; - -/** - * Risorsa di cache per la gestione delle informazioni temporanee del gestionale. - * Da utilizzare in sola lettura oppure in creazione e diretta scritture. - */ -class Cache extends Model -{ - use SimpleModelTrait; - use LocalPoolTrait; - - protected $table = 'zz_cache'; - - protected $casts = [ - 'content' => 'array', - ]; - - protected $dates = [ - 'expire_at', - ]; - - public static function build($name, $valid_time, $expire_at = null) - { - $model = new self(); - - $model->name = $name; - $model->valid_time = $valid_time; - $model->expire_at = $expire_at; - - $model->save(); - - return $model; - } - - public function isValid() - { - return $this->valid; - } - - public function getValidAttribute() - { - return !empty($this->expire_at) && $this->expire_at->greaterThanOrEqualTo(Carbon::now()); - } - - public function set($content) - { - $this->content = $content; - - return $this->save(); - } - - public function save(array $options = []) - { - if (!empty($this->valid_time)) { - $interval = CarbonInterval::make($this->valid_time); - $this->expire_at = (new Carbon())->add($interval); - } elseif (empty($this->expire_at)) { - $interval = CarbonInterval::make('6 hours'); - $this->expire_at = (new Carbon())->add($interval); - } - - return parent::save($options); - } - - public function delete() - { - if (empty($this->valid_time)) { - return parent::delete(); - } - - return false; - } - - public function scopeValid($query) - { - return $query->where('expire_at', '>', Carbon::now()); - } - - public function scopeInvalid($query) - { - return $query->where('expire_at', '<=', Carbon::now()); - } -} diff --git a/src/Models/Clause.php b/src/Models/Clause.php deleted file mode 100755 index 97f13819a..000000000 --- a/src/Models/Clause.php +++ /dev/null @@ -1,48 +0,0 @@ -. - */ - -namespace Models; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; -use Util\Query; - -class Clause extends Model -{ - use SimpleModelTrait; - - protected $table = 'zz_group_module'; - - /* Relazioni Eloquent */ - - public function groups() - { - return $this->hasMany(Group::class, 'idgruppo'); - } - - public function module() - { - return $this->belongsTo(Module::class, 'idmodule'); - } - - public function getClauseAttribute($value) - { - return Query::replacePlaceholder($value); - } -} diff --git a/src/Models/Group.php b/src/Models/Group.php deleted file mode 100755 index 27cf5ed77..000000000 --- a/src/Models/Group.php +++ /dev/null @@ -1,47 +0,0 @@ -. - */ - -namespace Models; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; - -class Group extends Model -{ - use SimpleModelTrait; - - protected $table = 'zz_groups'; - - /* Relazioni Eloquent */ - - public function users() - { - return $this->hasMany(User::class, 'idgruppo'); - } - - public function modules() - { - return $this->belongsToMany(Module::class, 'zz_permissions', 'idgruppo', 'idmodule')->withPivot('permessi'); - } - - public function views() - { - return $this->belongsToMany(View::class, 'zz_group_view', 'id_gruppo', 'id_vista'); - } -} diff --git a/src/Models/Hook.php b/src/Models/Hook.php deleted file mode 100755 index 5cc03dc1e..000000000 --- a/src/Models/Hook.php +++ /dev/null @@ -1,165 +0,0 @@ -. - */ - -namespace Models; - -use Carbon\Carbon; -use Carbon\CarbonInterval; -use Common\SimpleModelTrait; -use Hooks\Manager; -use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\Model; -use Traits\LocalPoolTrait; - -class Hook extends Model -{ - use SimpleModelTrait; - use LocalPoolTrait; - - protected $table = 'zz_hooks'; - - protected $appends = [ - 'permission', - ]; - - /** - * Restituisce i permessi relativi all'account in utilizzo. - * - * @return string - */ - public function getPermissionAttribute() - { - return $this->module ? $this->module->permission : 'rw'; - } - - /** - * Restituisce le informazioni sull'esecuzione dell'hook. - * - * @return array - */ - public function execute($token) - { - $hook = $this->getClass(); - - if ($hook->isSingleton() && $token != $this->processing_token) { - return; - } - - $result = $hook->manage(); - - if ($hook->isSingleton()) { - $this->unlock($token); - } - - $result['execute'] = $hook->needsExecution(); - - return $result; - } - - /** - * Restituisce le informazioni per l'inizializzazione grafica dell'hook. - * - * @return array - */ - public function response() - { - $hook = $this->getClass(); - - $response = $hook->response(); - - return $response; - } - - /** - * Imposta il lock sull'hook se non già impostato. - * Timeout di 10 minuti. - * - * @return string|null - */ - public function lock() - { - $hook = $this->getClass(); - if (!$hook->isSingleton()) { - return true; - } - - $result = empty($this->processing_at); - - // Forzatura in caso di freeze per più di 10 minuti - $date = new Carbon($this->processing_at); - $interval = CarbonInterval::make('10 minutes'); - $date = $date->add($interval); - - $now = new Carbon(); - $result |= $date->lessThan($now); - - $token = null; - if ($result) { - $token = random_string(); - - $this->processing_token = $token; - $this->processing_at = date('Y-m-d H:i:s'); - $this->save(); - } - - return $token; - } - - /** - * Rimuove il lock sull'hook. - * - * @return string|null - */ - public function unlock($token) - { - if ($token == $this->processing_token) { - $this->processing_token = null; - $this->processing_at = null; - $this->save(); - } - } - - public function getClass() - { - $class = $this->class; - $hook = new $class($this); - - if (!$hook instanceof Manager) { - throw new \UnexpectedValueException(); - } - - return $hook; - } - - /* Relazioni Eloquent */ - - public function module() - { - return $this->belongsTo(Module::class, 'id_module'); - } - - protected static function boot() - { - parent::boot(); - - static::addGlobalScope('enabled', function (Builder $builder) { - $builder->where('enabled', true); - }); - } -} diff --git a/src/Models/Log.php b/src/Models/Log.php deleted file mode 100755 index dce61b163..000000000 --- a/src/Models/Log.php +++ /dev/null @@ -1,37 +0,0 @@ -. - */ - -namespace Models; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; - -class Log extends Model -{ - use SimpleModelTrait; - - protected $table = 'zz_logs'; - - /* Relazioni Eloquent */ - - public function user() - { - return $this->belongsTo(User::class, 'id_utente'); - } -} diff --git a/src/Models/Module.php b/src/Models/Module.php deleted file mode 100755 index 8f22831f4..000000000 --- a/src/Models/Module.php +++ /dev/null @@ -1,213 +0,0 @@ -. - */ - -namespace Models; - -use Auth; -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\Model; -use Modules\Checklists\Traits\ChecklistTrait; -use Modules\Emails\Template; -use Traits\Components\NoteTrait; -use Traits\Components\UploadTrait; -use Traits\LocalPoolTrait; -use Traits\ManagerTrait; - -class Module extends Model -{ - use SimpleModelTrait; - use ManagerTrait; - use UploadTrait; - use LocalPoolTrait; - use NoteTrait; - use ChecklistTrait; - - protected $table = 'zz_modules'; - protected $main_folder = 'modules'; - protected $component_identifier = 'id_module'; - - protected $variables = []; - - protected $appends = [ - 'permission', - 'option', - ]; - - protected $hidden = [ - 'options', - 'options2', - ]; - - public function replacePlaceholders($id_record, $value) - { - $replaces = $this->getPlaceholders($id_record); - - $value = str_replace(array_keys($replaces), array_values($replaces), $value); - - return $value; - } - - public function getPlaceholders($id_record) - { - if (!isset($this->variables[$id_record])) { - $dbo = $database = database(); - - // Lettura delle variabili nei singoli moduli - $path = $this->filepath('variables.php'); - if (!empty($path)) { - $variables = include $path; - } - - // Sostituzione delle variabili di base - $replaces = []; - foreach ($variables as $key => $value) { - $replaces['{'.$key.'}'] = $value; - } - - $this->variables[$id_record] = $replaces; - } - - return $this->variables[$id_record]; - } - - /** - * Restituisce i permessi relativi all'account in utilizzo. - * - * @return string - */ - public function getPermissionAttribute() - { - if (Auth::user()->is_admin) { - return 'rw'; - } - - $group = Auth::user()->group->id; - - $pivot = $this->pivot ?: $this->groups->first(function ($item) use ($group) { - return $item->id == $group; - })->pivot; - - return $pivot->permessi ?: '-'; - } - - /** - * Restituisce i permessi relativi all'account in utilizzo. - * - * @return string - */ - public function getViewsAttribute() - { - $user = Auth::user(); - - $views = database()->fetchArray('SELECT * FROM `zz_views` WHERE `id_module` = :module_id AND - `id` IN ( - SELECT `id_vista` FROM `zz_group_view` WHERE `id_gruppo` = ( - SELECT `idgruppo` FROM `zz_users` WHERE `id` = :user_id - )) - ORDER BY `order` ASC', [ - 'module_id' => $this->id, - 'user_id' => $user->id, - ]); - - return $views; - } - - public function getOptionAttribute() - { - return !empty($this->options2) ? $this->options2 : $this->options; - } - - /* Relazioni Eloquent */ - - public function plugins() - { - return $this->hasMany(Plugin::class, 'idmodule_to'); - } - - public function prints() - { - return $this->hasMany(PrintTemplate::class, 'id_module'); - } - - public function Templates() - { - return $this->hasMany(Template::class, 'id_module'); - } - - public function views() - { - return $this->hasMany(View::class, 'id_module'); - } - - public function groups() - { - return $this->belongsToMany(Group::class, 'zz_permissions', 'idmodule', 'idgruppo')->withPivot('permessi'); - } - - public function clauses() - { - return $this->hasMany(Clause::class, 'idmodule'); - } - - /* Gerarchia */ - - public function children() - { - return $this->hasMany(self::class, 'parent')->withoutGlobalScope('enabled') - ->orderBy('order'); - } - - public function parent() - { - return $this->belongsTo(self::class, 'parent')->withoutGlobalScope('enabled'); - } - - public function allParents() - { - return $this->parent()->with('allParents'); - } - - public function allChildren() - { - return $this->children()->with('allChildren'); - } - - public static function getHierarchy() - { - return self::with('allChildren') - ->withoutGlobalScope('enabled') - ->whereNull('parent') - ->orderBy('order') - ->get(); - } - - protected static function boot() - { - parent::boot(); - - static::addGlobalScope('enabled', function (Builder $builder) { - $builder->where('enabled', true); - }); - - static::addGlobalScope('permission', function (Builder $builder) { - $builder->with('groups'); - }); - } -} diff --git a/src/Models/Note.php b/src/Models/Note.php deleted file mode 100755 index 7e3f231a3..000000000 --- a/src/Models/Note.php +++ /dev/null @@ -1,79 +0,0 @@ -. - */ - -namespace Models; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; - -class Note extends Model -{ - use SimpleModelTrait; - - protected $table = 'zz_notes'; - - /** - * Crea una nuova nota. - * - * @param Module|Plugin $structure - * @param int $id_record - * @param string $contenuto - * @param string|null $data_notifica - * - * @return self - */ - public static function build(User $user, $structure, $id_record, $contenuto, $data_notifica = null) - { - $model = new static(); - - $model->user()->associate($user); - - if ($structure instanceof Module) { - $model->module()->associate($structure); - } elseif ($structure instanceof Plugin) { - $model->plugin()->associate($structure); - } - - $model->id_record = $id_record; - - $model->content = $contenuto; - $model->notification_date = $data_notifica; - - $model->save(); - - return $model; - } - - /* Relazioni Eloquent */ - - public function user() - { - return $this->belongsTo(User::class, 'id_utente'); - } - - public function plugin() - { - return $this->belongsTo(Plugin::class, 'id_plugin'); - } - - public function module() - { - return $this->belongsTo(Module::class, 'id_module'); - } -} diff --git a/src/Models/OperationLog.php b/src/Models/OperationLog.php deleted file mode 100755 index d8e823014..000000000 --- a/src/Models/OperationLog.php +++ /dev/null @@ -1,85 +0,0 @@ -. - */ - -namespace Models; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; -use Modules\Emails\Mail; - -class OperationLog extends Model -{ - use SimpleModelTrait; - - protected $table = 'zz_operations'; - - protected static $info = []; - - public static function setInfo($name, $value) - { - self::$info[$name] = $value; - } - - public static function getInfo($name) - { - return self::$info[$name]; - } - - public static function build($operation) - { - if (!\Auth::check()) { - return null; - } - - $model = new static(); - - foreach (self::$info as $key => $value) { - $model->{$key} = $value; - } - - $model->op = $operation; - $model->id_utente = \Auth::user()->id; - - $model->save(); - - return $model; - } - - /* Relazioni Eloquent */ - - public function user() - { - return $this->belongsTo(User::class, 'id_utente'); - } - - public function plugin() - { - return $this->belongsTo(Plugin::class, 'id_plugin'); - } - - public function module() - { - return $this->belongsTo(Module::class, 'id_module'); - } - - public function email() - { - return $this->belongsTo(Mail::class, 'id_email'); - } -} diff --git a/src/Models/Plugin.php b/src/Models/Plugin.php deleted file mode 100755 index fe4b277de..000000000 --- a/src/Models/Plugin.php +++ /dev/null @@ -1,138 +0,0 @@ -. - */ - -namespace Models; - -use App; -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\Model; -use Modules\Checklists\Traits\ChecklistTrait; -use Traits\Components\NoteTrait; -use Traits\Components\UploadTrait; -use Traits\LocalPoolTrait; -use Traits\ManagerTrait; - -class Plugin extends Model -{ - use SimpleModelTrait; - use ManagerTrait; - use LocalPoolTrait; - use UploadTrait { - getUploadDirectoryAttribute as protected defaultUploadDirectory; - } - use NoteTrait; - use ChecklistTrait; - - protected $table = 'zz_plugins'; - protected $main_folder = 'plugins'; - protected $component_identifier = 'id_plugin'; - - protected $appends = [ - 'permission', - 'option', - ]; - - protected $hidden = [ - 'options', - 'options2', - ]; - - /** - * Restituisce i permessi relativi all'account in utilizzo. - * - * @return string - */ - public function getPermissionAttribute() - { - return $this->originalModule->permission; - } - - public function getOptionAttribute() - { - return !empty($this->options2) ? $this->options2 : $this->options; - } - - /* Metodi personalizzati */ - - /** - * Restituisce l'eventuale percorso personalizzato per il file di creazione dei record. - * - * @return string - */ - public function getCustomAddFile() - { - if (empty($this->script)) { - return; - } - - $directory = 'modules/'.$this->originalModule->directory.'|custom|/plugins'; - - return App::filepath($directory, $this->script); - } - - /** - * Restituisce l'eventuale percorso personalizzato per il file di modifica dei record. - * - * @return string - */ - public function getCustomEditFile() - { - if (empty($this->script)) { - return; - } - - return $this->getAddFile(); - } - - /** - * Restituisce il percorso per il salvataggio degli upload. - * - * @return string - */ - public function getUploadDirectoryAttribute() - { - if (!empty($this->script)) { - return $this->uploads_directory.'/'.basename($this->script, '.php'); - } - - return $this->defaultUploadDirectory(); - } - - /* Relazioni Eloquent */ - - public function originalModule() - { - return $this->belongsTo(Module::class, 'idmodule_from'); - } - - public function module() - { - return $this->belongsTo(Module::class, 'idmodule_to'); - } - - protected static function boot() - { - parent::boot(); - - static::addGlobalScope('enabled', function (Builder $builder) { - $builder->where('enabled', true); - }); - } -} diff --git a/src/Models/PrintTemplate.php b/src/Models/PrintTemplate.php deleted file mode 100755 index 3d9030f12..000000000 --- a/src/Models/PrintTemplate.php +++ /dev/null @@ -1,52 +0,0 @@ -. - */ - -namespace Models; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\Model; -use Traits\LocalPoolTrait; -use Traits\PathTrait; - -class PrintTemplate extends Model -{ - use SimpleModelTrait; - use PathTrait; - use LocalPoolTrait; - - protected $table = 'zz_prints'; - protected $main_folder = 'templates'; - - /* Relazioni Eloquent */ - - public function module() - { - return $this->belongsTo(Module::class, 'id_module'); - } - - protected static function boot() - { - parent::boot(); - - static::addGlobalScope('enabled', function (Builder $builder) { - $builder->where('enabled', true); - }); - } -} diff --git a/src/Models/Setting.php b/src/Models/Setting.php deleted file mode 100755 index 4706d8a3a..000000000 --- a/src/Models/Setting.php +++ /dev/null @@ -1,52 +0,0 @@ -. - */ - -namespace Models; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; -use Traits\LocalPoolTrait; - -class Setting extends Model -{ - use SimpleModelTrait; - use LocalPoolTrait; - - protected $table = 'zz_settings'; - - protected $appends = [ - 'description', - ]; - - public function getDescriptionAttribute() - { - $value = $this->valore; - - // Valore corrispettivo - $query = str_replace('query=', '', $this->tipo); - if ($query != $this->tipo) { - $data = database()->fetchArray($query); - if (!empty($data)) { - $value = $data[0]['descrizione']; - } - } - - return $value; - } -} diff --git a/src/Models/Upload.php b/src/Models/Upload.php deleted file mode 100755 index f3af59eef..000000000 --- a/src/Models/Upload.php +++ /dev/null @@ -1,362 +0,0 @@ -. - */ - -namespace Models; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; -use Intervention\Image\ImageManagerStatic; -use UnexpectedValueException; -use Util\FileSystem; - -class Upload extends Model -{ - use SimpleModelTrait; - - /** @var array Elenco delle tipologie di file pericolose */ - protected static $not_allowed_types = [ - 'php' => 'application/php', - 'php5' => 'application/php', - 'phtml' => 'application/php', - 'html' => 'text/html', - 'htm' => 'text/html', - ]; - - protected $table = 'zz_files'; - - protected $file_info; - - /** - * @return mixed|string - */ - public function getCategoryAttribute() - { - return $this->attributes['category'] ?: 'Generale'; - } - - /** - * @param $value - */ - public function setCategoryAttribute($value) - { - if ($value == 'Generale' || $value == '') { - $value = null; - } - - $this->attributes['category'] = $value; - } - - /** - * Crea un nuovo upload. - * - * @param string|array $source - * @param array $data - * @param null $name - * @param null $category - * - * @return self - */ - public static function build($source, $data, $name = null, $category = null) - { - $model = new static(); - - // Informazioni di base - $original_name = isset($source['name']) ? $source['name'] : basename($source); - $name = isset($data['name']) ? $data['name'] : $name; - $category = isset($data['category']) ? $data['category'] : $category; - - // Nome e categoria dell'allegato - $model->name = !empty($name) ? $name : $original_name; - $model->category = $category; - - // Nome di origine dell'allegato - $original_name = !empty($data['original_name']) ? $data['original_name'] : $original_name; // Campo "original_name" variato in modo dinamico - $model->original_name = $original_name; // Fix per "original" di Eloquent - - // Informazioni sulle relazioni - $model->id_module = !empty($data['id_module']) && empty($data['id_plugin']) ? $data['id_module'] : null; - $model->id_plugin = !empty($data['id_plugin']) ? $data['id_plugin'] : null; - $model->id_record = !empty($data['id_record']) ? $data['id_record'] : null; - - // Definizione del nome fisico del file - $directory = base_dir().'/'.$model->directory; - $filename = self::getNextName($original_name, $directory); - if (empty($filename)) { - throw new UnexpectedValueException("Estensione dell'allegato non supportata"); - } - $model->filename = $filename; - - // Creazione del file fisico - directory($directory); - $file = slashes($directory.DIRECTORY_SEPARATOR.$filename); - if ( - (is_array($source) && is_uploaded_file($source['tmp_name']) && !move_uploaded_file($source['tmp_name'], $file)) || - (is_string($source) && is_file($source) && !copy($source, $file)) || - (is_string($source) && !is_file($source) && file_put_contents($file, $source) === false) - ) { - throw new UnexpectedValueException("Errore durante il salvataggio dell'allegato"); - } - - // Aggiornamento dimensione fisica e responsabile del caricamento - $model->size = FileSystem::fileSize($file); - $model->user()->associate(auth()->getUser()); - - // Rimozione estensione dal nome visibile - $extension = $model->extension; - if (string_ends_with($model->name, $extension)) { - $length = strlen($extension) + 1; - $model->name = substr($model->name, 0, -$length); - } - - $model->save(); - - return $model; - } - - /** - * @return array - */ - public function getInfoAttribute() - { - if (!isset($this->file_info)) { - $filepath = $this->filepath; - $infos = self::getInfo($filepath); - - $this->file_info = $infos; - } - - return $this->file_info; - } - - /** - * @return string|null - */ - public function getExtensionAttribute() - { - return strtolower($this->info['extension']); - } - - /** - * @return string - */ - public function getDirectoryAttribute() - { - $parent = $this->plugin ?: $this->module; - - return $parent->upload_directory; - } - - /** - * @return string - */ - public function getFilepathAttribute() - { - return $this->directory.'/'.$this->filename; - } - - /** - * @return string - */ - public function getFileurlAttribute() - { - return str_replace('\\', '/', $this->filepath); - } - - /** - * @return string - */ - public function getOriginalNameAttribute() - { - return $this->attributes['original']; - } - - public function setOriginalNameAttribute($value) - { - $this->attributes['original'] = $value; - } - - /** - * Restituisce i contenuti del file. - * - * @return false|string - */ - public function getContent() - { - return file_get_contents($this->filepath); - } - - /** - * @return bool - */ - public function isImage() - { - $list = ['jpg', 'png', 'gif', 'jpeg', 'bmp', 'svg']; - - return in_array($this->extension, $list); - } - - /** - * @return bool - */ - public function isFatturaElettronica() - { - return $this->extension == 'xml' && strtolower($this->category) == 'fattura elettronica'; - } - - /** - * @return bool - */ - public function isPDF() - { - return $this->extension == 'pdf'; - } - - /** - * @return bool - */ - public function hasPreview() - { - return $this->isImage() || $this->isFatturaElettronica() || $this->isPDF(); - } - - public function delete() - { - $info = $this->info; - $directory = base_dir().'/'.$this->directory; - - $files = [ - $directory.'/'.$info['basename'], - $directory.'/'.$info['filename'].'_thumb600.'.$info['extension'], - $directory.'/'.$info['filename'].'_thumb100.'.$info['extension'], - $directory.'/'.$info['filename'].'_thumb250.'.$info['extension'], - ]; - - delete($files); - - return parent::delete(); - } - - public function save(array $options = []) - { - if ($this->isImage()) { - //self::generateThumbnails($this); - } - - return parent::save($options); - } - - public function copia($data) - { - $result = self::build(base_dir().'/'.$this->filepath, $data, $this->name, $this->category); - - return $result; - } - - public static function getInfo($file) - { - return pathinfo($file); - } - - /* Relazioni Eloquent */ - - public function module() - { - return $this->belongsTo(Module::class, 'id_module'); - } - - public function plugin() - { - return $this->belongsTo(Plugin::class, 'id_plugin'); - } - - public function user() - { - return $this->belongsTo(User::class, 'created_by'); - } - - /** - * Controlla se l'estensione è supportata dal sistema di upload. - * - * @param string $extension - * - * @return bool - */ - protected static function isSupportedType($extension) - { - return !in_array(strtolower($extension), array_keys(self::$not_allowed_types)); - } - - /** - * Genera casualmente il nome fisico per il file. - * - * @return string - */ - protected static function getNextName($file, $directory) - { - $extension = self::getInfo($file)['extension']; - $extension = strtolower($extension); - - // Controllo sulle estensioni permesse - $allowed = self::isSupportedType($extension); - if (!$allowed) { - return false; - } - - do { - $filename = random_string().'.'.$extension; - } while (file_exists($directory.'/'.$filename)); - - return $filename; - } - - /** - * Genera le thumbnails per le immagini. - */ - protected static function generateThumbnails($upload) - { - $info = $upload->info; - $directory = $upload->directory; - - $filepath = $upload->filepath; - - if (!in_array(mime_content_type($filepath), ['image/x-png', 'image/gif', 'image/jpeg'])) { - return; - } - - $driver = extension_loaded('gd') ? 'gd' : 'imagick'; - ImageManagerStatic::configure(['driver' => $driver]); - - $img = ImageManagerStatic::make($filepath); - - $img->resize(600, null, function ($constraint) { - $constraint->aspectRatio(); - }); - $img->save(slashes($directory.'/'.$info['filename'].'_thumb600.'.$info['extension'])); - - $img->resize(250, null, function ($constraint) { - $constraint->aspectRatio(); - }); - $img->save(slashes($directory.'/'.$info['filename'].'_thumb250.'.$info['extension'])); - - $img->resize(100, null, function ($constraint) { - $constraint->aspectRatio(); - }); - $img->save(slashes($directory.'/'.$info['filename'].'_thumb100.'.$info['extension'])); - } -} diff --git a/src/Models/User.php b/src/Models/User.php deleted file mode 100755 index fe7f4cc82..000000000 --- a/src/Models/User.php +++ /dev/null @@ -1,245 +0,0 @@ -. - */ - -namespace Models; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; -use Intervention\Image\ImageManagerStatic; -use Modules\Anagrafiche\Anagrafica; - -class User extends Model -{ - use SimpleModelTrait; - - protected $table = 'zz_users'; - - protected $appends = [ - 'is_admin', - 'gruppo', - 'id_anagrafica', - ]; - - /** - * The attributes that are mass assignable. - * - * @var array - */ - protected $fillable = [ - 'name', 'email', 'password', - ]; - - protected $is_admin; - protected $gruppo; - - /** - * The attributes that should be hidden for arrays. - * - * @var array - */ - protected $hidden = [ - 'password', 'remember_token', - ]; - - /** - * Crea un nuovo utente. - * - * @param string $username - * @param string $email - * @param string $password - * - * @return self - */ - public static function build(Group $gruppo, $username, $email, $password) - { - $model = new static(); - - $model->group()->associate($gruppo); - - $model->username = $username; - $model->email = $email; - $model->password = $password; - - $model->enabled = 1; - - $model->save(); - - return $model; - } - - public function getIsAdminAttribute() - { - if (!isset($this->is_admin)) { - $this->is_admin = $this->getGruppoAttribute() == 'Amministratori'; - } - - return $this->is_admin; - } - - public function getIdAnagraficaAttribute() - { - return $this->attributes['idanagrafica']; - } - - public function setIdAnagraficaAttribute($value) - { - $this->attributes['idanagrafica'] = $value; - } - - public function getGruppoAttribute() - { - if (!isset($this->gruppo)) { - $this->gruppo = $this->group->nome; - } - - return $this->gruppo; - } - - public function getSediAttribute() - { - $database = database(); - - // Estraggo le sedi dell'utente loggato - $sedi = $database->fetchArray('SELECT idsede FROM zz_user_sedi WHERE id_user='.prepare($this->id)); - - // Se l'utente non ha sedi, è come se ce le avesse tutte disponibili per retrocompatibilità - if (empty($sedi)) { - $sedi = $database->fetchArray('SELECT "0" AS idsede UNION SELECT id AS idsede FROM an_sedi WHERE idanagrafica='.prepare($this->idanagrafica)); - } - - return array_column($sedi, 'idsede'); - } - - public function setPasswordAttribute($value) - { - $this->attributes['password'] = \Auth::hashPassword($value); - } - - public function getPhotoAttribute() - { - if (empty($this->image_file_id)) { - return null; - } - - $image = Upload::find($this->image_file_id); - - return base_path().'/'.$image->filepath; - } - - public function setPhotoAttribute($value) - { - $module = \Modules::get('Utenti e permessi'); - - $data = [ - 'id_module' => $module->id, - 'id_record' => $this->id, - ]; - - // Foto precedenti - $old_photo = Upload::where($data)->get(); - - // Informazioni sull'immagine - $filepath = is_array($value) ? $value['tmp_name'] : $value; - $info = Upload::getInfo(is_array($value) ? $value['name'] : $value); - $file = base_dir().'/files/temp_photo.'.$info['extension']; - - // Ridimensionamento - $driver = extension_loaded('gd') ? 'gd' : 'imagick'; - ImageManagerStatic::configure(['driver' => $driver]); - - $img = ImageManagerStatic::make($filepath)->resize(100, 100, function ($constraint) { - $constraint->aspectRatio(); - }); - $img->save(slashes($file)); - - // Aggiunta nuova foto - $upload = Upload::build($file, $data); - - // Rimozione foto precedenti - delete($file); - if (!empty($upload)) { - foreach ($old_photo as $old) { - $old->delete(); - } - } - - $this->image_file_id = $upload->id; - } - - public function getNomeCompletoAttribute() - { - $anagrafica = $this->anagrafica; - if (empty($anagrafica)) { - return $this->username; - } - - return $anagrafica->ragione_sociale.' ('.$this->username.')'; - } - - public function getApiTokens() - { - $query = 'SELECT * FROM `zz_tokens` WHERE `enabled` = 1 AND `id_utente` = '.prepare($this->id); - $database = database(); - - // Generazione del token per l'utente - $tokens = $database->fetchArray($query); - if (empty($tokens)) { - $token = secure_random_string(); - - $database->insert('zz_tokens', [ - 'id_utente' => $this->id, - 'token' => $token, - ]); - } - - return $database->fetchArray($query); - } - - /* Relazioni Eloquent */ - - public function group() - { - return $this->belongsTo(Group::class, 'idgruppo'); - } - - public function logs() - { - return $this->hasMany(Log::class, 'id_utente'); - } - - public function notes() - { - return $this->hasMany(Note::class, 'id_utente'); - } - - public function anagrafica() - { - return $this->belongsTo(Anagrafica::class, 'idanagrafica'); - } - - public function image() - { - return $this->belongsTo(Upload::class, 'image_file_id'); - } - - public function modules() - { - return $this->group->modules(); - } -} diff --git a/src/Models/View.php b/src/Models/View.php deleted file mode 100755 index 597474906..000000000 --- a/src/Models/View.php +++ /dev/null @@ -1,48 +0,0 @@ -. - */ - -namespace Models; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; -use Util\Query; - -class View extends Model -{ - use SimpleModelTrait; - - protected $table = 'zz_views'; - - public function getQueryAttribute($value) - { - return Query::replacePlaceholder($value); - } - - /* Relazioni Eloquent */ - - public function groups() - { - return $this->belongsToMany(Group::class, 'zz_group_view', 'id_vista', 'id_gruppo'); - } - - public function module() - { - return $this->belongsTo(Module::class, 'id_module'); - } -} diff --git a/src/Modules.php b/src/Modules.php deleted file mode 100755 index f411b85c9..000000000 --- a/src/Modules.php +++ /dev/null @@ -1,383 +0,0 @@ -. - */ - -use Models\Module; -use Util\Query; - -/** - * Classe per la gestione delle informazioni relative ai moduli installati. - * - * @since 2.3 - */ -class Modules -{ - /** @var array Elenco delle condizioni aggiuntive disponibili */ - protected static $additionals = []; - /** @var array Elenco dei segmenti disponibili */ - protected static $segments = []; - - /** @var array Elenco gerarchico dei moduli */ - protected static $hierarchy; - - /** - * Restituisce tutte le informazioni di tutti i moduli installati. - * - * @return array - */ - public static function getModules() - { - $results = Module::getAll(); - - // Caricamento dei plugin - if (!$results->first()->relationLoaded('plugins')) { - $results->load('plugins'); - } - - return $results; - } - - /** - * Restituisce l'elenco dei moduli con permessi di accesso accordati. - * - * @return array - */ - public static function getAvailableModules() - { - // Individuazione dei moduli con permesso di accesso - $modules = self::getModules(); - - foreach ($modules as $key => $module) { - if ($module->permission == '-') { - unset($modules[$key]); - } - } - - return $modules; - } - - /** - * Restituisce le informazioni relative a un singolo modulo specificato. - * - * @param string|int $module - * - * @return Module - */ - public static function get($module) - { - self::getModules(); - - return Module::pool($module); - } - - /** - * Restituisce il modulo attualmente in utilizzo. - * - * @return Module - */ - public static function getCurrent() - { - return Module::getCurrent(); - } - - /** - * Imposta il modulo attualmente in utilizzo. - * - * @param int $id - */ - public static function setCurrent($id) - { - Module::setCurrent($id); - } - - /** - * Restituisce i permessi accordati all'utente in relazione al modulo specificato. - * - * @param string|int $module - * - * @return string - */ - public static function getPermission($module) - { - $result = self::get($module); - - return $result ? $result->permission : null; - } - - /** - * Restituisce i filtri aggiuntivi dell'utente in relazione al modulo specificato. - * - * @param int $id - * - * @return string - */ - public static function getAdditionals($module, $include_segments = true) - { - $module = self::get($module); - $user = Auth::user(); - - if (!isset(self::$additionals[$module['id']])) { - $database = database(); - - $additionals['WHR'] = []; - $additionals['HVN'] = []; - - $results = $database->fetchArray('SELECT * FROM `zz_group_module` WHERE `idgruppo` = (SELECT `idgruppo` FROM `zz_users` WHERE `id` = '.prepare($user['id']).') AND `enabled` = 1 AND `idmodule` = '.prepare($module['id'])); - foreach ($results as $result) { - if (!empty($result['clause'])) { - $result['clause'] = Query::replacePlaceholder($result['clause']); - - $additionals[$result['position']][] = $result['clause']; - } - } - - // Aggiunta dei segmenti - if ($include_segments) { - $segments = self::getSegments($module['id']); - $id_segment = isset($_SESSION['module_'.$module['id']]) ? $_SESSION['module_'.$module['id']]['id_segment'] : null; - foreach ($segments as $result) { - if (!empty($result['clause']) && $result['id'] == $id_segment) { - $result['clause'] = Query::replacePlaceholder($result['clause']); - - $additionals[$result['position']][] = $result['clause']; - } - } - } - - self::$additionals[$module['id']] = $additionals; - } - - return (array) self::$additionals[$module['id']]; - } - - /** - * Restituisce i filtri aggiuntivi dell'utente in relazione al modulo specificato. - * - * @param int $module - * - * @return array - */ - public static function getSegments($module) - { - if (Update::isUpdateAvailable()) { - return []; - } - - $module = self::get($module)['id']; - - if (!isset(self::$segments[$module])) { - $database = database(); - - self::$segments[$module] = $database->fetchArray('SELECT * FROM `zz_segments` WHERE `id_module` = '.prepare($module).' ORDER BY `predefined` DESC, `id` ASC'); - } - - return (array) self::$segments[$module]; - } - - /** - * Restituisce le condizioni SQL aggiuntive del modulo. - * - * @param string $name - * - * @return array - */ - public static function getAdditionalsQuery($module, $type = null, $include_segments = true) - { - $array = self::getAdditionals($module, $include_segments); - if (!empty($type) && isset($array[$type])) { - $result = (array) $array[$type]; - } else { - $result = array_merge((array) $array['WHR'], (array) $array['HVN']); - } - - $result = implode(' AND ', $result); - - $result = empty($result) ? $result : ' AND '.$result; - - return $result; - } - - public static function replaceAdditionals($id_module, $query) - { - $result = $query; - - // Aggiunta delle condizione WHERE - $result = str_replace('1=1', '1=1'.self::getAdditionalsQuery($id_module, 'WHR'), $result); - - // Aggiunta delle condizione HAVING - $result = str_replace('2=2', '2=2'.self::getAdditionalsQuery($id_module, 'HVN'), $result); - - return $result; - } - - /** - * Restituisce tutte le informazioni dei moduli installati in una scala gerarchica fino alla profondità indicata. - * - * @param int $depth - * - * @return array - */ - public static function getHierarchy() - { - if (!isset(self::$hierarchy)) { - self::$hierarchy = Module::getHierarchy()->toArray(); - } - - return self::$hierarchy; - } - - /** - * Restituisce il menu principale del progetto. - * - * @param int $depth Profondità del menu - * - * @return string - */ - public static function getMainMenu($depth = 3) - { - $menus = self::getHierarchy(); - - $module = Modules::getCurrent(); - $module_name = isset($module) ? $module->name : ''; - - $result = ''; - foreach ($menus as $menu) { - $result .= self::sidebarMenu($menu, $module_name, $depth)[0]; - } - - return $result; - } - - /** - * Costruisce un link HTML per il modulo e il record indicati. - * - * @param string|int $modulo - * @param int $id_record - * @param string $testo - * @param bool|string $alternativo - * @param string $extra - * @param bool $blank - * @param string $anchor - * @param string $params - * - * @return string - */ - public static function link($modulo, $id_record = null, $testo = null, $alternativo = true, $extra = null, $blank = true, $anchor = null, $params = null) - { - $testo = isset($testo) ? nl2br($testo) : tr('Visualizza scheda'); - $alternativo = is_bool($alternativo) && $alternativo ? $testo : $alternativo; - - // Aggiunta automatica dell'icona di riferimento - if (!string_contains($testo, ''; - } - - $module = self::get($modulo); - - $extra .= !empty($blank) ? ' target="_blank"' : ''; - - if (!empty($module) && in_array($module->permission, ['r', 'rw'])) { - $link = !empty($id_record) ? 'editor.php?id_module='.$module['id'].'&id_record='.$id_record : 'controller.php?id_module='.$module['id']; - - return ''.$testo.''; - } else { - return $alternativo; - } - } - - /** - * Individua il percorso per il file. - * - * @param string|int $element - * @param string $file - * - * @return string|null - */ - public static function filepath($element, $file) - { - $element = self::get($element); - - return $element ? $element->filepath($file) : null; - } - - /** - * Restituisce l'insieme dei menu derivato da un'array strutturato ad albero. - * - * @param array $element - * @param int $actual - * @param int $max_depth - * @param int $actual_depth - * - * @return string - */ - protected static function sidebarMenu($element, $actual = null, $max_depth = 3, $actual_depth = 0) - { - if ($actual_depth >= $max_depth) { - return ''; - } - - $link = (!empty($element['option']) && $element['option'] != 'menu') ? base_path().'/controller.php?id_module='.$element['id'] : 'javascript:;'; - $title = $element['title']; - $target = '_self'; // $target = ($element['new'] == 1) ? '_blank' : '_self'; - $active = ($actual == $element['name']); - $show = (self::getPermission($element['id']) != '-' && !empty($element['enabled'])) ? true : false; - - $submenus = $element['all_children']; - if (!empty($submenus)) { - $temp = ''; - foreach ($submenus as $submenu) { - $r = self::sidebarMenu($submenu, $actual, $actual_depth + 1); - $active = $active || $r[1]; - if (!$show && $r[2]) { - $link = 'javascript:;'; - } - $show = $show || $r[2]; - $temp .= $r[0]; - } - } - - $result = ''; - if ($show) { - $result .= '
  • - - - '.$title.''; - if (!empty($submenus) && !empty($temp)) { - $result .= ' - - - - -
      - '.$temp.' -
    '; - } else { - $result .= ' - '; - } - $result .= ' -
  • '; - } - - return [$result, $active, $show]; - } -} diff --git a/src/Notifications/EmailNotification.php b/src/Notifications/EmailNotification.php deleted file mode 100755 index 6e2a08857..000000000 --- a/src/Notifications/EmailNotification.php +++ /dev/null @@ -1,313 +0,0 @@ -. - */ - -namespace Notifications; - -use Modules\Emails\Account; -use Modules\Emails\Mail; -use PHPMailer\PHPMailer\Exception; -use PHPMailer\PHPMailer\OAuth; -use PHPMailer\PHPMailer\PHPMailer; -use PHPMailer\PHPMailer\SMTP; -use Prints; -use Uploads; - -class EmailNotification extends PHPMailer implements NotificationInterface -{ - protected $mail; - protected $directory; - - protected $infos = []; - - public function __construct($account = null, $exceptions = null) - { - parent::__construct(true); - - $this->CharSet = 'UTF-8'; - - // Configurazione di base - $account = $account instanceof Account ? $account : Account::find($account); - if (empty($account)) { - $account = Account::where('predefined', true)->first(); - } - - // Preparazione email - $this->IsHTML(true); - - if (!empty($account['server'])) { - $this->IsSMTP(); - - // Impostazioni di debug - $this->SMTPDebug = 2; - $this->Debugoutput = function ($str, $level) { - $this->infos[] = $str; - }; - - // Impostazioni dell'host - $this->Host = $account['server']; - $this->Port = $account['port']; - - // Impostazioni di autenticazione - if (!empty($account['username'])) { - $this->SMTPAuth = true; - $this->Username = $account['username']; - - // Configurazione OAuth2 - if (!empty($account['access_token'])) { - $oauth2 = $account->getGestoreOAuth2(); - - $this->AuthType = 'XOAUTH2'; - $this->setOAuth( - new OAuth([ - 'provider' => $oauth2->getProvider(), - 'refreshToken' => $oauth2->getRefreshToken(), - 'clientId' => $account->client_id, - 'clientSecret' => $account->client_secret, - 'userName' => $account->username, - ]) - ); - } else { - $this->Password = $account['password']; - } - } - - // Impostazioni di sicurezza - if (in_array(strtolower($account['encryption']), ['ssl', 'tls'])) { - $this->SMTPSecure = strtolower($account['encryption']); - } - - // Disabilitazione verifica host - if (!empty($account['ssl_no_verify'])) { - $this->SMTPOptions = [ - 'ssl' => [ - 'verify_peer' => false, - 'verify_peer_name' => false, - 'allow_self_signed' => true, - ], - ]; - } - } - - $this->From = $account['from_address']; - $this->FromName = $account['from_name']; - - $this->WordWrap = 78; - } - - public static function build(Mail $mail, $exceptions = null) - { - $result = new self($mail->account->id, $exceptions); - - $result->setMail($mail); - - return $result; - } - - public function setMail($mail) - { - $this->mail = $mail; - - // Registazione della processazione - if (!empty($this->mail)) { - $this->mail->processing_at = date('Y-m-d H:i:s'); - $this->mail->save(); - } - - // Destinatari - $receivers = $mail->receivers; - foreach ($receivers as $receiver) { - $this->addReceiver($receiver['address'], $receiver['type']); - } - - // Allegati - $uploads = $mail->uploads; - foreach ($uploads as $upload) { - $this->addUpload($upload->id); - } - - // Stampe - $prints = $mail->prints; - foreach ($prints as $print) { - $this->addPrint($print['id'], $mail->id_record); - } - - // Conferma di lettura - if (!empty($mail->read_notify)) { - $this->ConfirmReadingTo = $mail->From; - } - - // Reply To - if (!empty($mail->options['reply_to'])) { - $this->AddReplyTo($mail->options['reply_to']); - } - - // Oggetto - $this->Subject = $mail->subject; - - // Contenuto - $this->Body = $mail->content; - } - - public function getMail() - { - return $this->mail; - } - - /** - * Invia l'email impostata. - * - * @throws Exception - * - * @return bool - */ - public function send() - { - if (empty($this->AltBody)) { - $this->AltBody = strip_tags($this->Body); - } - - $exception = null; - try { - $result = parent::send(); - } catch (Exception $e) { - $result = false; - $exception = $e; - } - - // Registazione invio - if (!empty($this->mail)) { - if ($result) { - $this->mail->sent_at = date('Y-m-d H:i:s'); - } else { - $this->mail->failed_at = date('Y-m-d H:i:s'); - } - - // Salvataggio del numero di tentativi - $this->mail->attempt = $this->mail->attempt + 1; - - $this->mail->save(); - } - - $this->SmtpClose(); - - // Pulizia file generati - //delete($this->getTempDirectory()); - - // Segnalazione degli errori - if (!$result) { - $logger = logger(); - dd($this->infos); - foreach ($this->infos as $info) { - $logger->addRecord(\Monolog\Logger::ERROR, $info); - } - } - - if (!empty($exception)) { - throw $exception; - } - - return $result; - } - - /** - * Testa la connessione al server SMTP. - * - * @return bool - */ - public function testSMTP() - { - if ($this->smtpConnect()) { - $this->smtpClose(); - - return true; - } - - return false; - } - - /** - * Aggiunge un allegato del gestionale alla notifica. - * - * @param string $file_id - */ - public function addUpload($file_id) - { - $attachment = database()->fetchOne('SELECT * FROM zz_files WHERE id = '.prepare($file_id)); - - $this->addAttachment(base_dir().'/'.Uploads::getDirectory($attachment['id_module'], $attachment['id_plugin']).'/'.$attachment['filename'], $attachment['original']); - } - - /** - * Aggiunge una stampa alla notifica. - * - * @param string|int $print - * @param int $id_record - * @param string $name - */ - public function addPrint($print, $id_record, $name = null) - { - $print = Prints::get($print); - - $info = Prints::render($print['id'], $id_record, null, true); - $name = $name ?: $info['path']; - - $this->AddStringAttachment($info['pdf'], $name); - } - - /** - * Aggiunge un destinatario. - * - * @param array $receiver - * @param array $type - */ - public function addReceiver($receiver, $type = null) - { - $pieces = explode('<', $receiver); - $count = count($pieces); - - $name = null; - if ($count > 1) { - $email = substr(end($pieces), 0, -1); - $name = substr($receiver, 0, strpos($receiver, '<'.$email)); - } else { - $email = $receiver; - } - - if (!empty($email)) { - if ($type == 'cc') { - $this->AddCC($email, $name); - } elseif ($type == 'bcc') { - $this->AddBCC($email, $name); - } else { - $this->AddAddress($email, $name); - } - } - } - - protected function getTempDirectory() - { - if (!isset($this->directory)) { - $this->directory = base_dir().'/files/notifications/'.rand(0, 999); - - directory($this->directory); - } - - return $this->directory; - } -} diff --git a/src/Notifications/Notification.php b/src/Notifications/Notification.php deleted file mode 100755 index 2b80de785..000000000 --- a/src/Notifications/Notification.php +++ /dev/null @@ -1,89 +0,0 @@ -. - */ - -namespace Notifications; - -abstract class Notification implements NotificationInterface -{ - public $receivers = []; - public $content = null; - - public function __construct($receivers = null, $content = null) - { - $this->setReceivers($receivers); - $this->setContent($content); - } - - /** - * Restituisce i destinatari della notifica. - * - * @return array - */ - public function getReceivers() - { - return $this->receivers; - } - - /** - * Imposta i destinatari della notifica. - * - * @param string|array $value - */ - public function setReceivers($value) - { - $this->receivers = []; - - $values = is_array($value) ? $value : explode(';', $value); - foreach ($values as $value) { - $this->addReceiver($value); - } - } - - /** - * Aggiunge un destinataro alla notifica. - * - * @param string $value - */ - public function addReceiver($value) - { - $this->receivers[] = $value; - } - - /** - * Restituisce i contenuti della notifica. - * - * @return string - */ - public function getContent() - { - return $this->content; - } - - /** - * Imposta i contenuti della notifica. - * - * @param string $value - */ - public function setContent($value) - { - $this->content = $value; - } - - abstract public function send(); -} diff --git a/src/Notifications/NotificationInterface.php b/src/Notifications/NotificationInterface.php deleted file mode 100755 index dc6263332..000000000 --- a/src/Notifications/NotificationInterface.php +++ /dev/null @@ -1,25 +0,0 @@ -. - */ - -namespace Notifications; - -interface NotificationInterface -{ - public function send(); -} diff --git a/src/Permissions.php b/src/Permissions.php deleted file mode 100755 index 3bb2a1e67..000000000 --- a/src/Permissions.php +++ /dev/null @@ -1,108 +0,0 @@ -. - */ - -/** - * Classe per gestire i permessi di accesso alle diverse sezioni del progetto. - * - * @since 2.3 - */ -class Permissions -{ - /** @var array Elenco dei permessi necessari */ - protected static $permissions = []; - /** @var bool Condizione riguardante il controllo effettivo dei permessi */ - protected static $skip_permissions = false; - - /** - * Aggiunge un modulo di cui eseguire il controllo dei permessi. - * - * @param string $id - */ - public static function addModule($module) - { - $id = Modules::get($module)['id']; - if (!in_array($id, self::$permissions)) { - self::$permissions[] = $id; - } - } - - /** - * Ignora il controllo dei permessi per la pagina corrente. - */ - public static function skip() - { - self::$skip_permissions = true; - } - - /** - * Riabilita il controllo dei permessi per la pagina corrente. - */ - public static function execute() - { - self::$skip_permissions = false; - } - - /** - * Restituisce la variabile per cui si effettua o meno il controllo dei permessi per la pagina corrente. - * - * @return bool - */ - public static function getSkip() - { - return self::$skip_permissions; - } - - /** - * Esegue il controllo dei permessi. - * - * @return bool - */ - public static function check($permissions = [], $die = true) - { - if (empty($permissions)) { - $permissions = ['r', 'rw']; - } elseif (!is_array($permissions)) { - $permissions = [$permissions]; - } - - $result = true; - - if (!self::getSkip()) { - if (!Auth::check() && getURLPath() == slashes(base_path().'/index.php')) { - redirect(base_path().'/index.php'); - $result = false; - exit(); - } else { - if (!empty(self::$permissions)) { - foreach (self::$permissions as $module) { - if (!in_array(Modules::getPermission($module), $permissions)) { - $result = false; - } - } - } - - if (!$result && $die) { - exit(tr('Accesso negato')); - } - } - } - - return $result; - } -} diff --git a/src/Plugins.php b/src/Plugins.php deleted file mode 100755 index 3b90ff89e..000000000 --- a/src/Plugins.php +++ /dev/null @@ -1,143 +0,0 @@ -. - */ - -use Models\Plugin; - -/** - * Classe per la gestione delle informazioni relative ai plugin installati. - * - * @since 2.3 - */ -class Plugins -{ - /** @var array Elenco dei plugin disponibili */ - protected static $plugins = []; - protected static $references = []; - - /** - * Restituisce tutte le informazioni di tutti i plugin installati. - * - * @return array - */ - public static function getPlugins() - { - if (empty(self::$plugins)) { - $plugins = []; - $references = []; - - $modules = Modules::getModules(); - foreach ($modules as $module) { - foreach ($module->plugins as $result) { - $plugins[$result['id']] = $result; - $references[$result['name']] = $result['id']; - } - } - - self::$plugins = $plugins; - self::$references = $references; - } - - return self::$plugins; - } - - /** - * Restituisce le informazioni relative a un singolo modulo specificato. - * - * @param string|int $plugin - * - * @return Plugin - */ - public static function get($plugin) - { - $plugins = self::getPlugins(); - - if (!is_numeric($plugin) && !empty(self::$references[$plugin])) { - $plugin = self::$references[$plugin]; - } - - return $plugins[$plugin]; - } - - /** - * Restituisce il modulo attualmente in utilizzo. - * - * @return Plugin - */ - public static function getCurrent() - { - return Plugin::getCurrent(); - } - - /** - * Imposta il modulo attualmente in utilizzo. - * - * @param int $id - */ - public static function setCurrent($id) - { - Plugin::setCurrent($id); - - // Fix modulo - $plugin = self::getCurrent(); - if (isset($plugin)) { - Modules::setCurrent($plugin->module->id); - } - } - - /** - * Individua il percorso per il file. - * - * @param string|int $element - * @param string $file - * - * @return string|null - */ - public static function filepath($element, $file) - { - $element = self::get($element); - - return $element ? $element->filepath($file) : null; - } - - /** - * Costruisce un link HTML per il modulo e il record indicati. - * - * @param string|int $plugin - * @param int $id_record - * @param string $testo - * @param bool|string $alternativo - * @param string $extra - * @param bool $blank - * - * @return string - */ - public static function link($plugin, $id_record = null, $testo = null, $alternativo = true, $extra = null, $blank = true) - { - $plugin = self::get($plugin); - $alternativo = is_bool($alternativo) && $alternativo ? $testo : $alternativo; - - if (!empty($plugin) && in_array($plugin->permission, ['r', 'rw'])) { - $anchor = 'tab_'.$plugin->id; - - return Modules::link($plugin->module->id, $id_record, $testo, $alternativo, $extra, $blank, $anchor); - } - - return $alternativo; - } -} diff --git a/src/Prints.php b/src/Prints.php deleted file mode 100755 index fc875bf26..000000000 --- a/src/Prints.php +++ /dev/null @@ -1,650 +0,0 @@ -. - */ - -use Mpdf\Mpdf; -use Util\Query; - -/** - * Classe per la gestione delle informazioni relative alle stampe installate. - * - * @since 2.3 - */ -class Prints -{ - /** @var array Elenco delle stampe disponibili */ - protected static $prints = []; - /** @var array Elenco delle stampe per modulo */ - protected static $modules = []; - - /** - * Restituisce tutte le informazioni di tutti i moduli installati. - * - * @return array - */ - public static function getPrints() - { - if (empty(self::$prints)) { - $database = database(); - - $results = $database->fetchArray('SELECT * FROM zz_prints WHERE enabled = 1 ORDER BY `order`'); - - $prints = []; - - // Inizializzazione dei riferimenti - $modules = Modules::getModules(); - foreach ($modules as $module) { - self::$modules[$module['id']] = []; - } - - foreach ($results as $result) { - $result['full_directory'] = base_dir().'/templates/'.$result['directory']; - - $prints[$result['id']] = $result; - $prints[$result['name']] = $result['id']; - - self::$modules[$result['id_module']][] = $result['id']; - } - - self::$prints = $prints; - } - - return self::$prints; - } - - /** - * Restituisce le informazioni relative a una singolo stampa specificata. - * - * @param string|int $print - * - * @return array - */ - public static function get($print) - { - if (!is_numeric($print) && !empty(self::getPrints()[$print])) { - $print = self::getPrints()[$print]; - } - - return self::getPrints()[$print]; - } - - /** - * Restituisce le informazioni relative alle stampe di un singolo modulo specificato. - * - * @param string|int $module - * - * @return array - */ - public static function getModulePrints($module) - { - $module_id = Modules::get($module)['id']; - - self::getPrints(); - - $result = []; - - foreach ((array) self::$modules[$module_id] as $value) { - $print = self::get($value); - - if (!empty($print['is_record'])) { - $result[] = $print; - } - } - - return $result; - } - - /** - * Restituisce le informazioni relative alle stampe di un singolo modulo specificato. - * - * @param string|int $module - * - * @return array - */ - public static function getModulePredefinedPrint($module) - { - $prints = self::getModulePrints($module); - - $predefined = array_search(1, array_column($prints, 'predefined')); - - if ($predefined !== false) { - return $prints[$predefined]; - } elseif (!empty($prints)) { - return $prints[0]; - } - - return false; - } - - /** - * Genera la stampa in PDF richiesta. - * - * @param string|int $print - * @param int $id_record - * @param string $directory - * @param bool $return_string - */ - public static function render($print, $id_record, $directory = null, $return_string = false) - { - //ob_end_clean(); // Compatibilità con versioni vecchie delle stampe - $dbo = $database = database(); - $infos = self::get($print); - - $additional_checks = false; - if (!$return_string) { - Permissions::addModule($infos['id_module']); - - $has_access = true; - if (!empty($infos['is_record'])) { - $module = Modules::get($infos['id_module']); - - Query::setSegments(false); - $query = Query::getQuery($module, [ - 'id' => $id_record, - ]); - Query::setSegments(true); - - $has_access = !empty($query) ? $dbo->fetchNum($query) !== 0 : true; - } - - $additional_checks = !Permissions::check([], false) || !$has_access; - } - - if (empty($infos) || empty($infos['enabled']) || $additional_checks) { - return false; - } - - // Individuazione della configurazione - if (!empty($directory) && !directory($directory)) { - $error = tr('Non hai i permessi per creare directory e files in _DIRECTORY_', [ - '_DIRECTORY_' => $directory, - ]); - - flash()->error($error); - - echo ' -

    '.$error.'

    '; - - exit(); - } - - if (self::isOldStandard($print)) { - return self::oldLoader($infos['id'], $id_record, $directory, $return_string); - } else { - return self::loader($infos['id'], $id_record, $directory, $return_string); - } - } - - /** - * Individua il link per la stampa. - * - * @param string|int $print - * @param int $id_record - * @param string $get - * - * @return string - */ - public static function getHref($print, $id_record, $get = '') - { - $infos = self::get($print); - - if (empty($infos)) { - return false; - } - - $link = base_path().'/pdfgen.php?'; - - if (self::isOldStandard($infos['id'])) { - $link .= 'ptype='.$infos['directory']; - - $link .= !empty($infos['previous']) && !empty($id_record) ? '&'.$infos['previous'].'='.$id_record : ''; - } else { - $link .= 'id_print='.$infos['id']; - - $link .= !empty($id_record) ? '&id_record='.$id_record : ''; - } - - $link .= !empty($get) ? '&'.$get : ''; - - return $link; - } - - /** - * Restituisce il codice semplificato per il link alla stampa. - * - * @deprecated 2.4.1 - * - * @param string|int $print - * @param int $id_record - * @param string $btn - * @param string $title - * @param string $icon - * @param string $get - * - * @return string - */ - public static function getLink($print, $id_record, $btn = null, $title = null, $icon = null, $get = '') - { - return '{( "name": "button", "type": "print", "id": "'.$print.'", "id_record": "'.$id_record.'", "label": "'.$title.'", "icon": "'.$icon.'", "parameters": "'.$get.'", "class": "'.$btn.'" )}'; - } - - /** - * Restituisce il link per la visualizzazione della stampa. - * - * @param string|int $print - * @param int $id_record - * @param string $directory - * - * @return string - */ - public static function getPreviewLink($print, $id_record, $directory) - { - $info = self::render($print, $id_record, $directory); - - return self::getPDFLink($info['path']); - } - - /** - * Restituisce il link per la visualizzazione del PDF. - * - * @param string $path - * - * @return string - */ - public static function getPDFLink($path) - { - return base_path().'/assets/dist/pdfjs/web/viewer.html?file='.base_url().'/'.ltrim(str_replace(base_dir(), '', $path), '/'); - } - - /** - * Individua il percorso per il file. - * - * @param string|int $template - * @param string $file - * - * @return string|null - */ - public static function filepath($template, $file) - { - $template = self::get($template); - $directory = 'templates/'.$template['directory'].'|custom|'; - - return App::filepath($directory, $file); - } - - /** - * Restituisce un array associativo dalla codifica JSON delle opzioni di stampa. - * - * @param string $string - * - * @return array - */ - protected static function readOptions($string) - { - // Fix per contenuti con newline integrate - $string = str_replace(["\n", "\r"], ['\\n', '\\r'], $string); - - $result = (array) json_decode($string, true); - - return $result; - } - - /** - * Controlla se la stampa segue lo standard HTML2PDF. - * - * @param string|int $print - * - * @return bool - */ - protected static function isOldStandard($print) - { - $infos = self::get($print); - - return file_exists($infos['full_directory'].'/pdfgen.'.$infos['directory'].'.php') || file_exists($infos['full_directory'].'/custom/pdfgen.'.$infos['directory'].'.php'); - } - - /** - * Controlla se la stampa segue lo standard MPDF. - * - * @param string|int $print - * - * @return bool - */ - protected static function isNewStandard($print) - { - return !self::isOldStandard($print); - } - - /** - * Crea la stampa secondo il formato deprecato HTML2PDF. - * - * @param string|int $id_print - * @param int $id_record - * @param string $directory - * @param bool $return_string - */ - protected static function oldLoader($id_print, $id_record, $directory = null, $return_string = false) - { - $format = 'A4'; - - $body = ''; - $report = ''; - $footer = ''; - - $infos = self::get($id_print); - $options = self::readOptions($infos['options']); - $docroot = base_dir(); - - $dbo = $database = database(); - - $user = Auth::user(); - - $_GET[$infos['previous']] = $id_record; - ${$infos['previous']} = $id_record; - $ptype = $infos['directory']; - - $orientation = 'P'; - $body_table_params = "style='width:210mm;'"; - $table = 'margin-left:1.7mm'; - $font_size = '10pt'; - - // Decido se usare la stampa personalizzata (se esiste) oppure quella standard - if (file_exists($infos['full_directory'].'/custom/pdfgen.'.$infos['directory'].'.php')) { - include $infos['full_directory'].'/custom/pdfgen.'.$infos['directory'].'.php'; - } else { - include $infos['full_directory'].'/pdfgen.'.$infos['directory'].'.php'; - } - - // Sostituzione di variabili generiche - $report = str_replace('$body$', $body, $report); - $report = str_replace('$footer$', $footer, $report); - - $report = str_replace('$font_size$', $font_size, $report); - $report = str_replace('$body_table_params$', $body_table_params, $report); - $report = str_replace('$table$', $table, $report); - - // Footer di default - if (!string_contains($report, '')) { - $report .= '$default_footer$'; - } - - // Operazioni di sostituzione - include base_dir().'/templates/replace.php'; - - $mode = !empty($directory) ? 'F' : 'I'; - $mode = !empty($return_string) ? 'S' : $mode; - - $file = self::getFile($infos, $id_record, $directory, $replaces); - $title = $file['name']; - $path = $file['path']; - - $html2pdf = new Spipu\Html2Pdf\Html2Pdf($orientation, $format, 'it', true, 'UTF-8'); - - $html2pdf->writeHTML($report); - $html2pdf->pdf->setTitle($title); - - $pdf = $html2pdf->output($path, $mode); - $file['pdf'] = $pdf; - - return $file; - } - - protected static function getFile($record, $id_record, $directory, $original_replaces) - { - $module = Modules::get($record['id_module']); - - $name = $record['filename'].'.pdf'; - $name = $module->replacePlaceholders($id_record, $name); - - $replaces = []; - foreach ($original_replaces as $key => $value) { - $key = str_replace('$', '', $key); - - $replaces['{'.$key.'}'] = $value; - } - - $name = replace($name, $replaces); - - $filename = sanitizeFilename($name); - $file = (empty($directory)) ? $filename : rtrim($directory, '/').'/'.$filename; - - return [ - 'name' => $name, - 'path' => $file, - ]; - } - - /** - * Crea la stampa secondo il formato modulare MPDF. - * - * @param string|int $id_print - * @param int $id_record - * @param string $directory - * @param bool $return_string - */ - protected static function loader($id_print, $id_record, $directory = null, $return_string = false) - { - $infos = self::get($id_print); - $options = self::readOptions($infos['options']); - - $dbo = $database = database(); - - $user = Auth::user(); - - // Generazione a singoli pezzi - $single_pieces = self::filepath($id_print, 'piece.php'); - - // Impostazioni di default - $default = include App::filepath('templates/base|custom|', 'settings.php'); - - // Impostazioni personalizzate della stampa - $print_settings = self::filepath($id_print, 'settings.php'); - if (!empty($print_settings)) { - $custom = include $print_settings; - } - - // Individuazione delle impostazioni finali - $settings = array_merge($default, (array) $custom); - $settings = array_merge($settings, (array) $options); - - // Individuazione delle variabili fondamentali per la sostituzione dei contenuti - $print_init = self::filepath($id_print, 'init.php'); - if (!empty($print_init)) { - include $print_init; - } - - // Individuazione delle variabili per la sostituzione - include base_dir().'/templates/info.php'; - - // Instanziamento dell'oggetto mPDF - $mpdf = new Mpdf([ - 'format' => $settings['format'], - 'orientation' => strtoupper($settings['orientation']) == 'L' ? 'L' : 'P', - 'font-size' => $settings['font-size'], - 'margin_left' => $settings['margins']['left'], - 'margin_right' => $settings['margins']['right'], - - 'setAutoTopMargin' => $settings['margins']['top'] === 'auto' ? 'stretch' : false, - 'margin_top' => $settings['margins']['top'] === 'auto' ? 0 : $settings['margins']['top'], // Disabilitato se setAutoTopMargin impostato - - 'setAutoBottomMargin' => $settings['margins']['bottom'] === 'auto' ? 'stretch' : false, - 'margin_bottom' => $settings['margins']['bottom'] === 'auto' ? 0 : $settings['margins']['bottom'], // Disabilitato se setAutoBottomMargin impostato - - 'default_font' => 'dejavusanscondensed', - - // Abilitazione per lo standard PDF/A - //'PDFA' => true, - //'PDFAauto' => true, - ]); - - if (setting('Filigrana stampe')) { - $mpdf->SetWatermarkImage( - base_dir().'/files/anagrafiche/'.setting('Filigrana stampe'), - 0.5, - 'F', - 'F' - ); - - // false = 'showWatermarkImage' => false, - if ($settings['showWatermarkImage'] == null) { - $mpdf->showWatermarkImage = true; - } else { - $mpdf->showWatermarkImage = intval($settings['showWatermarkImage']); - } - } - - // Inclusione dei fogli di stile CSS - $styles = [ - App::filepath('templates/base|custom|', 'bootstrap.css'), - App::filepath('templates/base|custom|', 'style.css'), - ]; - - foreach ($styles as $value) { - $mpdf->WriteHTML(file_get_contents($value), 1); - } - - // Impostazione del font-size - $mpdf->WriteHTML('body {font-size: '.$settings['font-size'].'pt;}', 1); - - // Generazione totale - if (empty($single_pieces)) { - ob_start(); - $print_body = self::filepath($id_print, 'body.php'); - if (!empty($print_body)) { - include $print_body; - } - $report = ob_get_clean(); - - if (!empty($autofill)) { - $result = $autofill->generate(); - - $report = str_replace('|autofill|', $result, $report); - } - } - - // Generazione dei contenuti dell'header - ob_start(); - $print_header = self::filepath($id_print, 'header.php'); - if (!empty($print_header)) { - include $print_header; - } - $head = ob_get_clean(); - - // Header di default - $head = !empty($head) ? $head : '$default_header$'; - - // Generazione dei contenuti del footer - ob_start(); - $print_footer = self::filepath($id_print, 'footer.php'); - if (!empty($print_footer)) { - include $print_footer; - } - $foot = ob_get_clean(); - - // Footer di default - $foot = !empty($foot) ? $foot : '$default_footer$'; - - // Operazioni di sostituzione - include base_dir().'/templates/replace.php'; - - // Impostazione di header e footer - $mpdf->SetHTMLHeader($head); - $mpdf->SetHTMLFooter($foot); - - // Generazione dei contenuti della stampa - - if (!empty($single_pieces)) { - ob_start(); - $print_top = self::filepath($id_print, 'top.php'); - if (!empty($print_top)) { - include $print_top; - } - $top = ob_get_clean(); - - $top = str_replace(array_keys($replaces), array_values($replaces), $top); - - $mpdf->WriteHTML($top); - - $print_piece = self::filepath($id_print, 'piece.php'); - foreach ($records as $record) { - ob_start(); - if (!empty($print_piece)) { - include $print_piece; - } - $piece = ob_get_clean(); - - $mpdf->WriteHTML($piece); - } - - ob_start(); - $print_bottom = self::filepath($id_print, 'bottom.php'); - if (!empty($print_bottom)) { - include $print_bottom; - } - $bottom = ob_get_clean(); - - $bottom = str_replace(array_keys($replaces), array_values($replaces), $bottom); - - $mpdf->WriteHTML($bottom); - - $report = ''; - } - - // Footer per l'ultima pagina - if (!empty($options['last-page-footer'])) { - $is_last_page = true; - - // Generazione dei contenuti del footer - ob_start(); - $print_footer = self::filepath($id_print, 'footer.php'); - if (!empty($print_footer)) { - include $print_footer; - } - $foot = ob_get_clean(); - } - - // Operazioni di sostituzione - include base_dir().'/templates/replace.php'; - - $mode = !empty($directory) ? 'F' : 'I'; - $mode = !empty($return_string) ? 'S' : $mode; - - $file = self::getFile($infos, $id_record, $directory, $replaces); - $title = $file['name']; - $path = $file['path']; - - // Impostazione del titolo del PDF - $mpdf->SetTitle($title); - - // Aggiunta dei contenuti - $mpdf->WriteHTML($report); - - // Impostazione footer per l'ultima pagina - if (!empty($options['last-page-footer'])) { - $mpdf->WriteHTML(''); - - $mpdf->WriteHTML('
    '.$foot.'
    '); - } - - // Creazione effettiva del PDF - $pdf = $mpdf->Output($path, $mode); - $file['pdf'] = $pdf; - - return $file; - } -} diff --git a/src/Settings.php b/src/Settings.php deleted file mode 100755 index b4fa996e3..000000000 --- a/src/Settings.php +++ /dev/null @@ -1,224 +0,0 @@ -. - */ - -use Models\Setting; -use Respect\Validation\Validator as v; - -/** - * Classe per la gestione dell impostazioni del progetto. - * - * @since 2.3 - */ -class Settings -{ - /** @var array Elenco delle impostazioni disponibili */ - protected static $settings = []; - protected static $references = []; - protected static $sections = []; - - /** - * Restituisce tutte le informazioni di tutti le impostazioni presenti. - * - * @return array - */ - public static function getSettings() - { - if (empty(self::$settings)) { - $settings = []; - $references = []; - $sections = []; - - $results = Setting::all(); - - foreach ($results as $result) { - $settings[$result->id] = $result; - $references[$result->nome] = $result->id; - - if (!isset($sections[$result['sezione']])) { - $sections[$result['sezione']] = []; - } - $sections[$result['sezione']][] = $result->id; - } - - self::$settings = $settings; - self::$references = $references; - self::$sections = $sections; - } - - return self::$settings; - } - - /** - * Restituisce le informazioni relative ad una singola impostazione specificata. - * - * @param string|int $setting - * - * @return array - */ - public static function get($setting) - { - $settings = self::getSettings(); - - if (!is_numeric($setting) && !empty(self::$references[$setting])) { - $setting = self::$references[$setting]; - } - - return $settings[$setting]; - } - - /** - * Restituisce il valore corrente dell'impostazione ricercata. - * - * @param string|int $setting - * - * @return string - */ - public static function getValue($setting) - { - return self::get($setting)->valore; - } - - /** - * Imposta il valore dell'impostazione indicata. - * - * @param string|int $setting - * @param mixed $value - * - * @return bool - */ - public static function setValue($setting, $value) - { - $setting = self::get($setting); - $value = (is_array($value) ? implode(',', $value) : $value); - - // Trasformazioni - // Boolean (checkbox) - if ($setting->tipo == 'boolean') { - $value = (empty($value) || $value == 'off') ? false : true; - } - - // Validazioni - // integer - if ($setting->tipo == 'integer') { - $validator = v::intVal(); - } - - // list - // verifico che il valore scelto sia nella lista enumerata nel db - elseif (preg_match("/list\[(.+?)\]/", $setting->tipo, $m)) { - $validator = v::in(explode(',', $m[1])); - } - - // multiple - // verifico che il valore scelto sia nella lista enumerata nel db - elseif (preg_match("/multiple\[(.+?)\]/", $setting->tipo, $m[0][0])) { - //$validator = v::in(explode(',', $m[0][0][1])); - } - - // Boolean (checkbox) - elseif ($setting->tipo == 'boolean') { - $validator = v::boolType(); - } - - if (empty($validator) || $validator->validate($value)) { - $setting->valore = $value; - $setting->save(); - - return true; - } - - return false; - } - - /** - * Genera l'input HTML per la modifica dell'impostazione. - * - * @param string|int $setting - * @param bool $required - * - * @return string - */ - public static function input($setting, $required = false) - { - $setting = self::get($setting); - - // Lista predefinita - if (preg_match("/list\[(.+?)\]/", $setting->tipo, $m)) { - $values = explode(',', $m[1]); - - $list = []; - foreach ($values as $value) { - $list[] = [ - 'id' => $value, - 'text' => $value, - ]; - } - - $result = ' - {[ "type": "select", "multiple": 0, "label": '.json_encode($setting->nome).', "readonly": "'.!$setting->editable.'", "name": "setting['.$setting->id.']", "values": '.json_encode($list).', "value": "'.$setting->valore.'", "required": "'.intval($required).'", "help": "'.$setting->help.'" ]}'; - } - - // Lista multipla - elseif (preg_match("/multiple\[(.+?)\]/", $setting->tipo, $m)) { - $values = explode(',', $m[1]); - - $list = []; - foreach ($values as $value) { - $list[] = [ - 'id' => $value, - 'text' => $value, - ]; - } - - $result = ' - {[ "type": "select", "multiple": 1, "label": '.json_encode($setting->nome).', "readonly": "'.!$setting->editable.'", "name": "setting['.$setting->id.'][]", "values": '.json_encode($list).', "value": "'.$setting->valore.'", "required": "'.intval($required).'", "help": "'.$setting->help.'" ]}'; - } - - // Lista da query - elseif (preg_match('/^query=(.+?)$/', $setting->tipo, $m)) { - $result = ' - {[ "type": "select", "label": '.json_encode($setting->nome).', "readonly": "'.!$setting->editable.'", "name": "setting['.$setting->id.']", "values": "'.str_replace('"', '\"', $setting->tipo).'", "value": "'.$setting->valore.'", "required": "'.intval($required).'", "help": "'.$setting->help.'" ]}'; - } - - // Boolean (checkbox) - elseif ($setting->tipo == 'boolean') { - $result = ' - {[ "type": "checkbox", "label": '.json_encode($setting->nome).', "readonly": "'.!$setting->editable.'", "name": "setting['.$setting->id.']", "placeholder": "'.tr('Attivo').'", "value": "'.$setting->valore.'", "required": "'.intval($required).'", "help": "'.$setting->help.'" ]}'; - } - - // Campi di default - elseif (in_array($setting->tipo, ['textarea', 'ckeditor', 'timestamp', 'date', 'time'])) { - $result = ' - {[ "type": "'.$setting->tipo.'", "label": '.json_encode($setting->nome).', "readonly": "'.!$setting->editable.'", "name": "setting['.$setting->id.']", "value": '.json_encode($setting->valore).', "required": "'.intval($required).'", "help": "'.$setting->help.'" ]}'; - } - - // Campo di testo - else { - $numerico = in_array($setting->tipo, ['integer', 'decimal']); - - $tipo = preg_match('/password/i', $setting->nome, $m) ? 'password' : $setting->tipo; - $tipo = $numerico ? 'number' : 'text'; - - $result = ' - {[ "type": "'.$tipo.'", "label": '.json_encode($setting->nome).', "readonly": "'.!$setting->editable.'", "name": "setting['.$setting->id.']", "value": "'.$setting->valore.'"'.($numerico && $setting->tipo == 'integer' ? ', "decimals": 0' : '').', "required": "'.intval($required).'", "help": "'.$setting->help.'" ]}'; - } - - return $result; - } -} diff --git a/src/Tasks/Log.php b/src/Tasks/Log.php deleted file mode 100644 index b99bfaeb9..000000000 --- a/src/Tasks/Log.php +++ /dev/null @@ -1,46 +0,0 @@ -. - */ - -namespace Tasks; - -use Common\SimpleModelTrait; -use Illuminate\Database\Eloquent\Model; - -/* - * Risorsa per la gestione dei log per le task ricorrenti del gestionale. - */ -class Log extends Model -{ - use SimpleModelTrait; - - protected $table = 'zz_tasks_logs'; - - protected $casts = [ - 'context' => 'array', - ]; - - protected $hidden = [ - 'task', - ]; - - public function task() - { - return $this->belongsTo(Task::class, 'id_task'); - } -} diff --git a/src/Tasks/Manager.php b/src/Tasks/Manager.php deleted file mode 100644 index 11f6f5d14..000000000 --- a/src/Tasks/Manager.php +++ /dev/null @@ -1,32 +0,0 @@ -. - */ - -namespace Tasks; - -abstract class Manager implements TaskInterface -{ - protected $task; - - public function __construct(Task $task) - { - $this->task = $task; - } - - abstract public function execute(); -} diff --git a/src/Tasks/Task.php b/src/Tasks/Task.php deleted file mode 100644 index a5e3fedab..000000000 --- a/src/Tasks/Task.php +++ /dev/null @@ -1,105 +0,0 @@ -. - */ - -namespace Tasks; - -use Carbon\Carbon; -use Common\SimpleModelTrait; -use Cron\CronExpression; -use Illuminate\Database\Eloquent\Model; - -/* - * Risorsa per la gestione delle task ricorrenti del gestionale. - */ -class Task extends Model -{ - use SimpleModelTrait; - - protected $table = 'zz_tasks'; - - protected $dates = [ - 'next_execution_at', - 'last_executed_at', - ]; - - public function log($level, $message, $context = []) - { - $log = new Log(); - - $log->level = $level; - $log->message = $message; - $log->context = $context; - - $log->task()->associate($this); - - $log->save(); - } - - public function execute() - { - // Registrazione dell'inizio nei log - $this->log('info', 'Inizio esecuzione'); - - // Individuazione del gestore - $class = $this->attributes['class']; - $manager = new $class($this); - - // Esecuzione - $result = $manager->execute(); - - // Salvtagggio dell'esecuzione - $this->last_executed_at = new Carbon(); - - // Individuazione della data per la prossima esecuzione dalla relativa espressione - $this->registerNextExecution($this->last_executed_at); - $this->save(); - - // Registrazione del completamento nei log - $this->log('info', 'Fine esecuzione'); - - return $result; - } - - public function registerMissedExecution(Carbon $now) - { - // Registrazione del completamento nei log - $this->log('warning', 'Esecuzione mancata', [ - 'timestamp' => $this->next_execution_at->toDateTimeString(), - ]); - - $this->registerNextExecution($now); - $this->save(); - } - - public function registerNextExecution(Carbon $now) - { - $cron = CronExpression::factory($this->expression); - $this->next_execution_at = Carbon::instance($cron->getNextRunDate($now)); - } - - public function delete() - { - return false; - } - - public function logs() - { - return $this->hasMany(Log::class, 'id_task'); - } -} diff --git a/src/Tasks/TaskInterface.php b/src/Tasks/TaskInterface.php deleted file mode 100644 index a50de9491..000000000 --- a/src/Tasks/TaskInterface.php +++ /dev/null @@ -1,28 +0,0 @@ -. - */ - -namespace Tasks; - -interface TaskInterface -{ - /** - * @return mixed - */ - public function execute(); -} diff --git a/src/Traits/Components/NoteTrait.php b/src/Traits/Components/NoteTrait.php deleted file mode 100755 index 6113746e3..000000000 --- a/src/Traits/Components/NoteTrait.php +++ /dev/null @@ -1,35 +0,0 @@ -. - */ - -namespace Traits\Components; - -use Models\Note; - -trait NoteTrait -{ - public function notes() - { - return $this->hasMany(Note::class, $this->component_identifier); - } - - public function recordNotes($id_record) - { - return $this->notes()->where('id_record', $id_record)->orderBy('created_at')->get(); - } -} diff --git a/src/Traits/Components/UploadTrait.php b/src/Traits/Components/UploadTrait.php deleted file mode 100755 index dee1182f7..000000000 --- a/src/Traits/Components/UploadTrait.php +++ /dev/null @@ -1,47 +0,0 @@ -. - */ - -namespace Traits\Components; - -use Models\Upload; - -trait UploadTrait -{ - protected $uploads_directory = 'files'; - - /** - * Restituisce il percorso per il salvataggio degli upload. - * - * @return string - */ - public function getUploadDirectoryAttribute() - { - $directory = $this->directory ?: 'common'; - - $result = $this->uploads_directory.'/'.$directory; - directory($result); - - return $result; - } - - public function uploads($id_record) - { - return $this->hasMany(Upload::class, $this->component_identifier)->where('id_record', $id_record)->get(); - } -} diff --git a/src/Traits/HierarchyTrait.php b/src/Traits/HierarchyTrait.php deleted file mode 100755 index 015cc42cc..000000000 --- a/src/Traits/HierarchyTrait.php +++ /dev/null @@ -1,50 +0,0 @@ -. - */ - -namespace Traits; - -trait HierarchyTrait -{ - public function children() - { - return $this->hasMany(self::class, self::$parent_identifier); - } - - public function parent() - { - return $this->belongsTo(self::class, self::$parent_identifier); - } - - public function allParents() - { - return $this->parent()->with('allParents'); - } - - public function allChildren() - { - return $this->children()->with('allChildren'); - } - - public static function getHierarchy() - { - return self::with('allChildren') - ->whereNull(self::$parent_identifier) - ->get(); - } -} diff --git a/src/Traits/LocalPoolTrait.php b/src/Traits/LocalPoolTrait.php deleted file mode 100644 index 0a476c998..000000000 --- a/src/Traits/LocalPoolTrait.php +++ /dev/null @@ -1,113 +0,0 @@ -. - */ - -namespace Traits; - -use Illuminate\Support\Collection; - -trait LocalPoolTrait -{ - /** @var Collection Collezione degli oggetti disponibili */ - protected static $collection = null; - /** @var bool Controllo sul salvataggio globale */ - protected static $all = false; - - /** @var int Identificatore dell'oggetto in utilizzo */ - protected static $current; - - /** @var string Nome della colonna "id" (Primary Key) */ - protected static $id = 'id'; - /** @var string Nome della colonna "name" */ - protected static $name = 'name'; - - /** - * Restituisce tutti gli oggetti. - * - * @return Collection - */ - public static function getAll() - { - if (!self::$all) { - self::$collection = self::all(); - - self::$all = true; - } - - return self::$collection; - } - - /** - * Restituisce l'oggetto relativo all'identificativo specificato. - * - * @param string|int $identifier - * - * @return static - */ - public static function pool($identifier) - { - // Inizializzazione - if (!isset(self::$collection)) { - self::$collection = collect(); - } - - // Ricerca - $result = self::$collection->first(function ($item) use ($identifier) { - return $item->{self::$name} == $identifier || $item->{self::$id} == $identifier; - }); - - if (!empty($result)) { - return $result; - } - - // Consultazione Database - $result = self::where(self::$id, $identifier) - ->orWhere(self::$name, $identifier) - ->first(); - - if (!empty($result)) { - self::$collection->push($result); - } - - return $result; - } - - /** - * Restituisce l'oggetto attualmente impostato. - * - * @return static - */ - public static function getCurrent() - { - if (!isset(self::$current)) { - return null; - } - - return self::pool(self::$current); - } - - /** - * Imposta il modulo attualmente in utilizzo. - * - * @param int $id - */ - public static function setCurrent($id) - { - self::$current = $id; - } -} diff --git a/src/Traits/ManagerTrait.php b/src/Traits/ManagerTrait.php deleted file mode 100755 index 1d475f2ff..000000000 --- a/src/Traits/ManagerTrait.php +++ /dev/null @@ -1,77 +0,0 @@ -. - */ - -namespace Traits; - -trait ManagerTrait -{ - use PathTrait; - - /** - * Restituisce il percorso per il file di crezione dei record. - * - * @return string - */ - public function getAddFile() - { - if (method_exists($this, 'getCustomAddFile')) { - $result = $this->getCustomAddFile(); - - if (!empty($result)) { - return $result; - } - } - - $php = $this->filepath('add.php'); - $html = $this->filepath('add.html'); - - return !empty($php) ? $php : $html; - } - - /** - * Controlla l'esistenza del file di crezione dei record. - * - * @return bool - */ - public function hasAddFile() - { - return !empty($this->getAddFile()); - } - - /** - * Restituisce il percorso per il file di modifica dei record. - * - * @return string - */ - public function getEditFile() - { - if (method_exists($this, 'getCustomEditFile')) { - $result = $this->getCustomEditFile(); - - if (!empty($result)) { - return $result; - } - } - - $php = $this->filepath('edit.php'); - $html = $this->filepath('edit.html'); - - return !empty($php) ? $php : $html; - } -} diff --git a/src/Traits/PathTrait.php b/src/Traits/PathTrait.php deleted file mode 100755 index a207c97a8..000000000 --- a/src/Traits/PathTrait.php +++ /dev/null @@ -1,64 +0,0 @@ -. - */ - -namespace Traits; - -use App; - -trait PathTrait -{ - /** - * Restituisce il percorso per i contenuti della struttura. - * - * @return string - */ - public function getPathAttribute() - { - return $this->main_folder.'/'.$this->directory; - } - - /** - * Restituisce il percorso completo per il file indicato della struttura. - * - * @param $file - * - * @return string|null - */ - public function filepath($file) - { - return App::filepath($this->path.'|custom|', $file); - } - - /** - * Restituisce l'URL completa per il file indicato della struttura. - * - * @param $file - * - * @return string|null - */ - public function fileurl($file) - { - $filepath = $this->filepath($file); - - $result = str_replace(base_dir(), base_path(), $filepath); - $result = str_replace('\\', '/', $result); - - return $result; - } -} diff --git a/src/Traits/RecordTrait.php b/src/Traits/RecordTrait.php deleted file mode 100755 index 2b11a95ad..000000000 --- a/src/Traits/RecordTrait.php +++ /dev/null @@ -1,69 +0,0 @@ -. - */ - -namespace Traits; - -use Models\Module; -use Models\Plugin; - -trait RecordTrait -{ - abstract public function getModuleAttribute(); - - public function getModule() - { - return !empty($this->module) ? Module::pool($this->module) : null; - } - - public function getPlugin() - { - return !empty($this->plugin) ? Plugin::pool($this->plugin) : null; - } - - /** - * @param string $name - */ - public function customField($name) - { - $field = database()->table('zz_fields') - ->leftJoin('zz_field_record', 'zz_fields.id', '=', 'zz_field_record.id_field') - ->where('zz_fields.name', '=', $name) - ->where('zz_fields.id_module', '=', $this->getModule()->id) - ->where('zz_field_record.id_record', '=', $this->id) - ->first(); - - return $field->value; - } - - public function uploads() - { - $module = $this->getModule(); - $plugin = $this->getPlugin(); - - if (!empty($module)) { - return $module->uploads($this->id); - } - - if (!empty($plugin)) { - return $plugin->uploads($this->id); - } - - return collect(); - } -} diff --git a/src/Traits/ReferenceTrait.php b/src/Traits/ReferenceTrait.php deleted file mode 100755 index a0261fd4b..000000000 --- a/src/Traits/ReferenceTrait.php +++ /dev/null @@ -1,65 +0,0 @@ -. - */ - -namespace Traits; - -trait ReferenceTrait -{ - abstract public function getReferenceName(); - - abstract public function getReferenceNumber(); - - abstract public function getReferenceDate(); - - abstract public function getReferenceRagioneSociale(); - - public function getReference($show_ragione_sociale = null) - { - // Informazioni disponibili - $name = $this->getReferenceName(); - - $number = $this->getReferenceNumber(); - $date = $this->getReferenceDate(); - - $ragione_sociale = $this->getReferenceRagioneSociale(); - - // Testi predefiniti - if (!empty($date) && !empty($number) && !empty($ragione_sociale) && !empty($show_ragione_sociale)) { - $description = tr('_DOC_ num. _NUM_ del _DATE_ (_RAGIONE_SOCIALE_)'); - } elseif (!empty($date) && !empty($number)) { - $description = tr('_DOC_ num. _NUM_ del _DATE_'); - } elseif (!empty($number)) { - $description = tr('_DOC_ num. _NUM_'); - } elseif (!empty($date)) { - $description = tr('_DOC_ del _DATE_'); - } else { - $description = tr('_DOC_'); - } - - // Creazione descrizione - $description = replace($description, [ - '_DOC_' => $name, - '_NUM_' => $number, - '_RAGIONE_SOCIALE_' => $ragione_sociale, - '_DATE_' => dateFormat($date), - ]); - - return $description; - } -} diff --git a/src/Translator.php b/src/Translator.php deleted file mode 100755 index 9505eb2df..000000000 --- a/src/Translator.php +++ /dev/null @@ -1,382 +0,0 @@ -. - */ - -use Carbon\Carbon; -use Carbon\CarbonInterval; - -/** - * Classe per gestire le traduzioni del progetto. - * - * @since 2.3 - */ -class Translator extends Util\Singleton -{ - /** @var Intl\Formatter Oggetto per la conversione di date e numeri nella lingua selezionata */ - protected static $formatter; - /** @var string Simbolo della valuta corrente */ - protected static $currency; - - /** @var Symfony\Component\Translation\Translator Oggetto dedicato alle traduzioni */ - protected $translator; - - /** @var array Lingue disponibili */ - protected $locales = []; - /** @var string Lingua selezionata */ - protected $locale; - - public function __construct($default_locale = 'it_IT', $fallback_locales = ['it_IT']) - { - $translator = new Symfony\Component\Translation\Translator($default_locale); - $translator->setFallbackLocales($fallback_locales); - // Imposta la classe per il caricamento - $translator->addLoader('default', new Intl\FileLoader()); - - $this->translator = $translator; - - $this->locale = $default_locale; - self::setFormatter($default_locale, []); - } - - /** - * Ricerca e aggiunge le traduzioni presenti nei percorsi predefiniti (cartella locale sia nella root che nei diversi moduli). - * - * @param string $string - */ - public function addLocalePath($string) - { - $paths = glob($string); - foreach ($paths as $path) { - $this->addLocales($path); - } - } - - /** - * Restituisce l'elenco dei linguaggi disponibili. - * - * @return array - */ - public function getAvailableLocales() - { - return $this->locales; - } - - /** - * Controlla se il linguaggio indicato è disponibile. - * - * @param string $language - * - * @return bool - */ - public function isLocaleAvailable($language) - { - return in_array($language, $this->getAvailableLocales()); - } - - /** - * Imposta il linguaggio in utilizzo. - * - * @param string $locale - */ - public function setLocale($locale, $formatter = []) - { - if (!empty($locale) && $this->isLocaleAvailable($locale)) { - $this->translator->setLocale($locale); - $this->locale = $locale; - - $result = setlocale(LC_TIME, $locale); - Carbon::setLocale($locale); - - if (empty($result)) { - $result = setlocale(LC_TIME, $locale.'.UTF-8'); - } else { - Carbon::setUtf8(true); - } - - $reduced = explode('_', $locale)[0]; - CarbonInterval::setLocale($reduced); - - if (empty($result)) { - $result = setlocale(LC_TIME, $reduced); - } - - self::setFormatter($locale, $formatter); - } - } - - /** - * Restituisce il linguaggio attualmente in utilizzo. - * - * @return string - */ - public function getCurrentLocale() - { - return $this->locale; - } - - /** - * Restituisce l'oggetto responsabile della gestione delle traduzioni. - * - * @return Symfony\Component\Translation\Translator - */ - public function getTranslator() - { - return $this->translator; - } - - /** - * Restituisce la traduzione richiesta. - * - * @param string $string - * @param array $parameters - * @param array $operations - * - * @return string - */ - public static function translate($string, $parameters = [], $operations = []) - { - $result = self::getInstance()->getTranslator()->trans($string, $parameters); - - // Operazioni aggiuntive sul risultato - if (!empty($operations)) { - $result = new Stringy\Stringy($result); - - if (!empty($operations['upper'])) { - $result = $result->toUpperCase(); - } elseif (!empty($operations['lower'])) { - $result = $result->toLowerCase(); - } - } - - return (string) $result; - } - - /** - * Restituisce l'oggetto responsabile della localizzazione di date e numeri. - * - * @return Intl\Formatter - */ - public static function getFormatter() - { - return self::$formatter; - } - - /** - * Restituisce il simbolo della valuta del gestione. - * - * @since 2.4.9 - * - * @return string - */ - public static function getCurrency() - { - if (!isset(self::$currency)) { - $id = setting('Valuta'); - $valuta = database()->fetchOne('SELECT symbol FROM zz_currencies WHERE id = '.prepare($id)); - - self::$currency = $valuta['symbol']; - } - - return self::$currency; - } - - /** - * Converte il numero dalla formattazione locale a quella inglese. - * - * @param string $string - * - * @return string - */ - public static function numberToEnglish($string) - { - return self::getFormatter()->parseNumber($string); - } - - /** - * Converte il numero dalla formattazione inglese a quella locale. - * - * @param string $string - * @param string|int $decimals - * - * @return string - */ - public static function numberToLocale($string, $decimals = null) - { - $string = !isset($string) ? 0 : $string; - - if (!empty($decimals) && is_string($decimals)) { - $decimals = ($decimals == 'qta') ? setting('Cifre decimali per quantità') : null; - } - - return self::getFormatter()->formatNumber($string, $decimals); - } - - /** - * Converte la data dalla formattazione locale a quella inglese. - * - * @param string $string - * - * @return string - */ - public static function dateToEnglish($string) - { - return self::getFormatter()->parseDate($string); - } - - /** - * Converte la data dalla formattazione inglese a quella locale. - * - * @param string $string - * @param string $fail - * - * @return string - */ - public static function dateToLocale($string) - { - return self::getFormatter()->formatDate($string); - } - - /** - * Converte la data dalla formattazione locale a quella inglese. - * - * @param string $string - * - * @return string - */ - public static function timeToEnglish($string) - { - return self::getFormatter()->parseTime($string); - } - - /** - * Converte la data dalla formattazione inglese a quella locale. - * - * @param string $string - * @param string $fail - * - * @return string - */ - public static function timeToLocale($string) - { - return self::getFormatter()->formatTime($string); - } - - /** - * Converte un timestamp dalla formattazione locale a quella inglese. - * - * @param string $timestamp - * - * @return string - */ - public static function timestampToEnglish($string) - { - return self::getFormatter()->parseTimestamp($string); - } - - /** - * Converte un timestamp dalla formattazione inglese a quella locale. - * - * @param string $timestamp - * @param string $fail - * - * @return string - */ - public static function timestampToLocale($string) - { - return self::getFormatter()->formatTimestamp($string); - } - - /** - * Converte il numero in ore. - * - * @param string $string - * - * @return string - */ - public static function numberToHours($string) - { - $string = !isset($string) ? 0 : $string; - - $ore = number_format($string, 2); - $splitted_hour = explode('.', $ore); - $hour = $splitted_hour[0]; - $minutes = ($splitted_hour[1] / 100) * 60; - $time = $hour.':'.sprintf('%02d', $minutes); - - return $time; - } - - /** - * Aggiunge i contenuti della cartella specificata alle traduzioni disponibili. - * - * @param string $path - */ - protected function addLocales($path) - { - // Individua i linguaggi disponibili - $dirs = glob($path.DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR); - foreach ($dirs as $dir) { - $this->addLocale(basename($dir)); - } - - // Aggiunge le singole traduzioni - foreach ($this->locales as $lang) { - $done = []; - - $files = glob($path.DIRECTORY_SEPARATOR.$lang.DIRECTORY_SEPARATOR.'*.*'); - foreach ($files as $file) { - if (!in_array(basename($file), $done)) { - $this->translator->addResource('default', $file, $lang); - - $done[] = basename($file); - } - } - } - } - - /** - * Aggiunge il linguaggio indicato all'elenco di quelli disponibili. - * - * @param string $language - */ - protected function addLocale($language) - { - if (!$this->isLocaleAvailable($language)) { - $this->locales[] = $language; - } - } - - /** - * Imposta l'oggetto responsabile della localizzazione di date e numeri. - */ - protected static function setFormatter($locale, $options) - { - self::$formatter = new Intl\Formatter( - $locale, - empty($options['timestamp']) ? 'd/m/Y H:i' : $options['timestamp'], - empty($options['date']) ? 'd/m/Y' : $options['date'], - empty($options['time']) ? 'H:i' : $options['time'], - empty($options['number']) ? [ - 'decimals' => ',', - 'thousands' => '.', - ] : $options['number'] - ); - - self::$formatter->setPrecision(auth()->check() ? setting('Cifre decimali per importi') : 2); - } -} diff --git a/src/Update.php b/src/Update.php deleted file mode 100755 index bb507410d..000000000 --- a/src/Update.php +++ /dev/null @@ -1,627 +0,0 @@ -. - */ - -/** - * Classe dedicata alla gestione delle procedure di aggiornamento del database del progetto. - * - * @since 2.3 - */ -class Update -{ - protected static $current_version; - - /** @var array Elenco degli aggiornamenti da completare */ - protected static $updates; - /** @var array Percorsi da controllare per gli aggiornamenti */ - protected static $directories = [ - 'modules', - 'plugins', - ]; - - /** - * Restituisce l'elenco degli aggiornamento incompleti o non ancora effettuati. - * - * @return array - */ - public static function getTodoUpdates() - { - if (!is_array(self::$updates)) { - self::prepareToUpdate(); - - $database = database(); - - $updates = $database->isConnected() ? $database->fetchArray('SELECT * FROM `updates` WHERE `done` != 1 OR `done` IS NULL ORDER BY `done` DESC, `id` ASC') : []; - - foreach ($updates as $key => $value) { - $name = explode('/', $value['directory']); - $updates[$key]['name'] = ucwords(end($name)).' '.$value['version']; - - $updates[$key]['filename'] = str_replace('.', '_', $value['version']); - - $updates[$key]['directory'] = $value['directory'].'/update/'; - } - - self::$updates = $updates; - } - - return self::$updates; - } - - /** - * Restituisce il primo aggiornamento che deve essere completato. - * - * @return array - */ - public static function getCurrentUpdate() - { - $todos = self::getTodoUpdates(); - - return !empty($todos) ? $todos[0] : null; - } - - /** - * Controlla che la stringa inserita possieda una struttura corrispondente a quella di una versione. - * - * @param string $string - * - * @return bool - */ - public static function isVersion($string) - { - return preg_match('/^\d+(?:\.\d+)+$/', $string) === 1; - } - - /** - * Controlla ci sono aggiornamenti da fare per il database. - * - * @return bool - */ - public static function isUpdateAvailable() - { - $todos = self::getTodoUpdates(); - - return !empty($todos); - } - - /** - * Controlla se la procedura di aggiornamento è conclusa. - * - * @return bool - */ - public static function isUpdateCompleted() - { - return !self::isUpdateAvailable(); - } - - /** - * Controlla se l'aggiornamento è in esecuzione. - * - * @return bool - */ - public static function isUpdateLocked() - { - $todos = array_column(self::getTodoUpdates(), 'done'); - foreach ($todos as $todo) { - if ($todo !== null && $todo !== 1) { - return true; - } - } - - return false; - } - - /** - * Restituisce la versione corrente del software gestita dal database. - * - * @return string - */ - public static function getDatabaseVersion() - { - if (!isset(self::$current_version)) { - $database = database(); - - $results = $database->fetchArray("SELECT version FROM `updates` WHERE version NOT LIKE '%\_%' ORDER BY INET_ATON(SUBSTRING_INDEX(CONCAT(version,'.0.0.0'),'.',4)) DESC LIMIT 1"); - self::$current_version = $results[0]['version']; - } - - return self::$current_version; - } - - /** - * Restituisce la versione corrente del software (file VERSION nella root e versione a database). - * - * @return string - */ - public static function getVersion() - { - $result = self::getFile('VERSION'); - - if (empty($result)) { - $database = database(); - - if ($database->isInstalled()) { - $result = self::getDatabaseVersion(); - } else { - $updatelist = self::getCoreUpdates(); - $result = end($updatelist)['version']; - } - } - - return $result; - } - - /** - * Controlla se la versione corrente del software è una beta (versione instabile). - * - * @return bool - */ - public static function isBeta() - { - $version = self::getVersion(); - - return string_contains($version, 'beta'); - } - - /** - * Restituisce la revisione corrente del software gestita dal file system (file REVISION nella root). - * - * @return string - */ - public static function getRevision() - { - return self::getFile('REVISION'); - } - - /** - * Effettua una pulizia del database a seguito del completamento dell'aggiornamento. - * - * @return bool - */ - public static function updateCleanup() - { - if (self::isUpdateCompleted()) { - $database = database(); - - // Aggiornamento all'ultima release della versione e compatibilità moduli - $database->query('UPDATE `zz_modules` SET `compatibility`='.prepare(self::getVersion()).', `version`='.prepare(self::getVersion()).' WHERE `default` = 1'); - - // Normalizzazione di charset e collation - self::normalizeDatabase($database->getDatabaseName()); - - if (class_exists('\Models\Cache')) { - \Models\Cache::pool('Ultima versione di OpenSTAManager disponibile')->set(null); - } - - return true; - } - - return false; - } - - /** - * Esegue una precisa sezione dell'aggiornamento fa fare, partendo dalle query e passando poi allo script relativo. - * Prima dell'esecuzione dello script viene inoltre eseguita un'operazione di normalizzazione dei campi delle tabelle del database finalizzata a generalizzare la gestione delle informazioni per l'API: vengono quindi aggiunti i campi created_at e, se permesso dalla versione di MySQL, updated_at ad ogni tabella registrata del software. - * - * @param int $rate Numero di singole query da eseguire dell'aggiornamento corrente - * - * @return array|bool - */ - public static function doUpdate($rate = 20) - { - set_time_limit(0); - ignore_user_abort(true); - - if (!self::isUpdateCompleted()) { - $update = self::getCurrentUpdate(); - - $file = base_dir().'/'.$update['directory'].$update['filename']; - - $database = database(); - - try { - // Esecuzione delle query - if (!empty($update['sql']) && (!empty($update['done']) || is_null($update['done'])) && file_exists($file.'.sql')) { - $queries = readSQLFile($file.'.sql', ';'); - $count = count($queries); - - $start = empty($update['done']) ? 0 : $update['done'] - 2; - $end = ($start + $rate + 1) > $count ? $count : $start + $rate + 1; - - if ($start < $end) { - for ($i = $start; $i < $end; ++$i) { - try { - $database->query($queries[$i]); - } catch (\Exception $e) { - throw new PDOException(tr('Aggiornamento fallito').': '.$queries[$i]); - } - - $database->query('UPDATE `updates` SET `done` = :done WHERE id = :id', [ - ':done' => $i + 3, - ':id' => $update['id'], - ]); - } - - // Restituisce l'indice della prima e dell'ultima query eseguita, con la differenza relativa per l'avanzamento dell'aggiornamento - return [ - $start, - $end, - $count, - ]; - } - } - - // Imposta l'aggiornamento nello stato di esecuzione dello script - $database->query('UPDATE `updates` SET `done` = :done WHERE id = :id', [ - ':done' => 0, - ':id' => $update['id'], - ]); - - // Permessi di default delle viste - if ($database->tableExists('zz_views')) { - $gruppi = $database->fetchArray('SELECT `id` FROM `zz_groups`'); - $viste = $database->fetchArray('SELECT `id` FROM `zz_views` WHERE `id` NOT IN (SELECT `id_vista` FROM `zz_group_view`)'); - - $array = []; - foreach ($viste as $vista) { - foreach ($gruppi as $gruppo) { - $array[] = [ - 'id_gruppo' => $gruppo['id'], - 'id_vista' => $vista['id'], - ]; - } - } - if (!empty($array)) { - $database->insert('zz_group_view', $array); - } - } - - // Normalizzazione di charset e collation - self::normalizeDatabase($database->getDatabaseName()); - - // Normalizzazione dei campi per l'API - self::executeScript(base_dir().'/update/api.php'); - - // Esecuzione dello script - if (!empty($update['script']) && file_exists($file.'.php')) { - self::executeScript($file.'.php'); - } - - // Imposta l'aggiornamento come completato - $database->query('UPDATE `updates` SET `done` = :done WHERE id = :id', [ - ':done' => 1, - ':id' => $update['id'], - ]); - - // Normalizzazione di charset e collation - self::normalizeDatabase($database->getDatabaseName()); - - return true; - } catch (\Exception $e) { - $logger = logger(); - $logger->addRecord(\Monolog\Logger::EMERGENCY, $e->getMessage()); - } - - return false; - } - - return true; - } - - /** - * Restituisce un riepilogo sulla struttura delle tabelle del gestionale. - * - * @throws Exception - * - * @return array - */ - public static function getDatabaseStructure() - { - // Tabelle registrate per il gestionale - $tables = include base_dir().'/update/tables.php'; - - $database = database(); - $database_name = $database->getDatabaseName(); - - $info = []; - foreach ($tables as $table) { - if ($database->tableExists($table)) { - // Individuazione delle colonne per la tabella - $query = 'SHOW COLUMNS FROM `'.$table.'` IN `'.$database_name.'`'; - $columns_found = $database->fetchArray($query); - - // Organizzazione delle colonne per nome - $columns = []; - foreach ($columns_found as $column) { - $column = array_change_key_case($column); - $name = $column['field']; - unset($column['field']); - - $columns[$name] = $column; - } - - // Individuazione delle chiavi esterne della tabella - $fk_query = 'SELECT - CONSTRAINT_NAME AS `name`, - COLUMN_NAME AS `column`, - REFERENCED_TABLE_NAME AS `referenced_table`, - REFERENCED_COLUMN_NAME AS `referenced_column` - FROM information_schema.KEY_COLUMN_USAGE - WHERE TABLE_NAME = '.prepare($table).' - AND TABLE_SCHEMA = '.prepare($database_name).' - AND REFERENCED_TABLE_SCHEMA = '.prepare($database_name); - $fks_found = $database->fetchArray($fk_query); - - // Organizzazione delle chiavi esterne per nome - $fks = []; - foreach ($fks_found as $fk) { - $fk = array_change_key_case($fk); - $name = $fk['name']; - unset($fk['name']); - - $fks[$name] = $fk; - } - - $info[$table] = array_merge($columns, [ - 'foreign_keys' => $fks, - ]); - } - } - - return $info; - } - - /** - * Controlla la presenza di aggiornamenti e prepara il database per la procedura. - */ - protected static function prepareToUpdate() - { - $database = database(); - - $database_ready = $database->isConnected() && $database->tableExists('updates'); - - // Individuazione di tutti gli aggiornamenti presenti - // Aggiornamenti del gestionale - $core = self::getCoreUpdates(); - - // Aggiornamenti supportati - $modules = self::getCustomUpdates(); - - $results = array_merge($core, $modules); - $paths = array_column($results, 'path'); - - // Individuazione di tutti gli aggiornamenti inseriti nel database - $updates = ($database_ready) ? $database->fetchArray('SELECT * FROM `updates`') : []; - $versions = []; - foreach ($updates as $update) { - $versions[] = self::findUpdatePath($update); - } - - $reset = count(array_intersect($paths, $versions)) != count($results); - - // Memorizzazione degli aggiornamenti - if ($reset && $database->isConnected()) { - // Reimpostazione della tabella degli aggiornamenti - $create = base_dir().'/update/create_updates.sql'; - if (file_exists($create)) { - $database->query('DROP TABLE IF EXISTS `updates`'); - $database->multiQuery($create); - } - - // Inserimento degli aggiornamenti individuati - foreach ($results as $result) { - // Individuazione di script e sql - $sql = file_exists($result['path'].'.sql') ? 1 : 0; - $script = file_exists($result['path'].'.php') ? 1 : 0; - - // Reimpostazione degli stati per gli aggiornamenti precedentemente presenti - $pos = array_search($result['path'], $versions); - $done = ($pos !== false) ? $updates[$pos]['done'] : null; - - $directory = explode('update/', $result['path'])[0]; - $database->insert('updates', [ - 'directory' => rtrim($directory, '/'), - 'version' => $result['version'], - 'sql' => $sql, - 'script' => $script, - 'done' => $done, - ]); - } - - // Normalizzazione di charset e collation - self::normalizeDatabase($database->getDatabaseName()); - } - } - - /** - * Restituisce l'elenco degli aggiornamento del gestionale presenti nella cartella update. - * - * @return array - */ - protected static function getCoreUpdates() - { - return self::getUpdates(base_dir().'/update'); - } - - /** - * Restituisce l'elenco degli aggiornamento nel percorso indicato. - * - * @param string $directory - * - * @return array - */ - protected static function getUpdates($directory) - { - $results = []; - $previous = []; - - $files = glob($directory.'/*.{php,sql}', GLOB_BRACE); - natsort($files); - foreach ($files as $file) { - $infos = pathinfo($file); - $version = str_replace('_', '.', $infos['filename']); - - if (array_search($version, $previous) === false && self::isVersion($version)) { - $path = str_replace(base_dir(), '', $infos['dirname'].'/'.$infos['filename']); - $path = ltrim($path, '/'); - - $results[] = [ - 'path' => $path, - 'version' => $version, - ]; - $previous[] = $version; - } - } - - return $results; - } - - /** - * Restituisce l'elenco degli aggiornamento delle strutture supportate, presenti nella cartella update. - * - * @return array - */ - protected static function getCustomUpdates() - { - $results = []; - - foreach (self::$directories as $dir) { - $folders = glob(base_dir().'/'.$dir.'/*/update', GLOB_ONLYDIR); - - foreach ($folders as $folder) { - $results = array_merge($results, self::getUpdates($folder)); - } - } - - return $results; - } - - protected static function findUpdatePath($update) - { - $version = str_replace('.', '_', $update['version']); - - $old_standard = string_contains($update['version'], '_'); - if (empty($update['directory']) && !$old_standard) { - return 'update/'.$version; - } - - if ($old_standard) { - $module = implode('_', explode('_', $update['version'], -1)); - $version = explode('_', $update['version']); - $version = end($version); - - $version = str_replace('.', '_', $version); - - return 'modules/'.$module.'/update/'.$version; - } - - return $update['directory'].'/update/'.$version; - } - - /** - * Ottiene i contenuti di un file. - * - * @param string $file - * - * @return string - */ - protected static function getFile($file) - { - $file = (string_contains($file, base_dir().DIRECTORY_SEPARATOR)) ? $file : base_dir().DIRECTORY_SEPARATOR.$file; - - $result = ''; - - $filepath = realpath($file); - if (!empty($filepath)) { - $result = file_get_contents($filepath); - $result = str_replace(["\r\n", "\n"], '', $result); - } - - return trim($result); - } - - /** - * Normalizza l'infrastruttura del database indicato, generalizzando charset e collation all'interno del database e delle tabelle ed effettuando una conversione delle tabelle all'engine InnoDB. - * Attenzione: se l'engine InnoDB non è supportato, il server ignorerà la conversione dell'engine e le foreign key del gestionale non funzioneranno adeguatamente. - * - * @param string $database_name - */ - protected static function normalizeDatabase($database_name) - { - set_time_limit(0); - ignore_user_abort(true); - - $database = database(); - - $database->getPDO()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); - - $mysql_ver = $database->getMySQLVersion(); - - if (version_compare($mysql_ver, '5.5.3') >= 0) { - $character_set = 'utf8mb4'; - $collation = 'utf8mb4_general_ci'; - } else { - $character_set = 'utf8'; - $collation = 'utf8_general_ci'; - } - - // Normalizzazione del database (le nuove tabelle verranno automaticamente impostate secondo la codifica predefinita) - $default_collation = $database->fetchArray('SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = '.prepare($database_name).' LIMIT 1')[0]['DEFAULT_COLLATION_NAME']; - - if ($default_collation != $collation) { - $database->query('ALTER DATABASE `'.$database_name.'` CHARACTER SET '.$character_set.' COLLATE '.$collation); - } - - // Normalizzazione delle tabelle - $tables = $database->fetchArray('SHOW TABLE STATUS IN `'.$database_name.'` WHERE Collation != '.prepare($collation)." AND Name != 'updates'"); - - if (!empty($tables)) { - $database->query('SET foreign_key_checks = 0'); - - // Conversione delle tabelle - foreach ($tables as $table) { - $database->query('ALTER TABLE `'.$table['Name'].'` CONVERT TO CHARACTER SET '.$character_set.' COLLATE '.$collation); - } - - $database->query('SET foreign_key_checks = 1'); - } - - // Normalizzazione dell'engine MySQL - $engines = $database->fetchArray('SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '.prepare($database_name)." AND ENGINE != 'InnoDB'"); - foreach ($engines as $engine) { - $database->query('ALTER TABLE `'.$engine['TABLE_NAME'].'` ENGINE=InnoDB'); - } - - $database->getPDO()->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); - } - - /** - * Esegue uno script PHP in un'ambiente il più possibile protetto. - * - * @param string $script - */ - protected static function executeScript($script) - { - $dbo = $database = database(); - - // Informazioni relative a MySQL - $mysql_ver = $database->getMySQLVersion(); - - include $script; - } -} diff --git a/src/Uploads.php b/src/Uploads.php deleted file mode 100755 index 1c7280426..000000000 --- a/src/Uploads.php +++ /dev/null @@ -1,155 +0,0 @@ -. - */ - -use Models\Upload; - -/** - * Classe per la gestione degli upload del progetto. - * - * @since 2.4.1 - */ -class Uploads -{ - /** - * Restituisce l'elenco degli allegati registrati per un determinato modulo/plugin e record. - * - * @param array $data - * - * @return array - */ - public static function get($data) - { - $database = database(); - - $uploads = $database->select('zz_files', '*', [ - 'id_module' => !empty($data['id_module']) && empty($data['id_plugin']) ? $data['id_module'] : null, - 'id_plugin' => !empty($data['id_plugin']) ? $data['id_plugin'] : null, - 'id_record' => $data['id_record'], - ]); - - return $uploads; - } - - /** - * Restituisce il nome della cartella per l'upload degli allegati per un determinato modulo/plugin. - * - * @param string|int $id_module - * @param string|int $id_plugin - * - * @return string - */ - public static function getDirectory($id_module, $id_plugin = null) - { - if (empty($id_plugin)) { - $structure = Modules::get($id_module); - } else { - $structure = Plugins::get($id_plugin); - } - - return $structure->upload_directory; - } - - /** - * Effettua l'upload di un file nella cartella indicata. - * - * @param string|array $source - * @param array $data - * @param array $options - * - * @return Upload - */ - public static function upload($source, $data, $options = []) - { - return Upload::build($source, $data); - } - - /** - * Elimina l'allegato indicato. - * - * @param string $filename - * @param array $data - * - * @return string Nome del file - */ - public static function delete($filename, $data) - { - if (!empty($filename)) { - $database = database(); - - $name = $database->selectOne('zz_files', ['name'], [ - 'filename' => $filename, - 'id_module' => !empty($data['id_module']) && empty($data['id_plugin']) ? $data['id_module'] : null, - 'id_plugin' => !empty($data['id_plugin']) ? $data['id_plugin'] : null, - 'id_record' => $data['id_record'], - ])['name']; - - $fileinfo = self::fileInfo($filename); - $directory = base_dir().'/'.self::getDirectory($data['id_module'], $data['id_plugin']); - - $files = [ - $directory.'/'.$fileinfo['basename'], - $directory.'/'.$fileinfo['filename'].'_thumb600.'.$fileinfo['extension'], - $directory.'/'.$fileinfo['filename'].'_thumb100.'.$fileinfo['extension'], - $directory.'/'.$fileinfo['filename'].'_thumb250.'.$fileinfo['extension'], - ]; - - if (delete($files)) { - $database->delete('zz_files', [ - 'filename' => $fileinfo['basename'], - 'id_module' => !empty($data['id_module']) && empty($data['id_plugin']) ? $data['id_module'] : null, - 'id_plugin' => !empty($data['id_plugin']) ? $data['id_plugin'] : null, - 'id_record' => $data['id_record'], - ]); - - return $name; - } - } - - return null; - } - - /** - * Rimuove tutti gli allegati di un determinato modulo/plugin e record. - * - * @param array $data - */ - public static function deleteLinked($data) - { - $uploads = self::get($data); - - foreach ($uploads as $upload) { - self::delete($upload['filename'], $data); - } - } - - /** - * Restituisce le informazioni relative al file indicato. - * - * @param string $filepath - * - * @return array - */ - public static function fileInfo($filepath) - { - $infos = pathinfo($filepath); - $infos['extension'] = strtolower($infos['extension']); - - return $infos; - } -} diff --git a/src/Util/Autofill.php b/src/Util/Autofill.php deleted file mode 100755 index 5aaa57edc..000000000 --- a/src/Util/Autofill.php +++ /dev/null @@ -1,116 +0,0 @@ -. - */ - -namespace Util; - -/** - * Classe dedicata alla gestione delle righe fantasma per il miglioramento grafico delle stampe tabellari. - * - * @since 2.3 - */ -class Autofill -{ - protected $space = 0; - protected $current = 0; - - protected $char_number; - protected $column_number; - - protected $max_rows = 20; - protected $max_rows_first_page = 20; - protected $max_additional = 15; - - public function __construct($column_number, $char_number = 70) - { - $this->column_number = $column_number; - $this->char_number = $char_number; - } - - public function setRows($rows, $additional = null, $first_page = null) - { - $this->max_rows = $rows; - - $this->max_additional = isset($additional) ? $additional : floor($this->max_rows - $this->max_rows / 4); - $this->max_rows_first_page = isset($first_page) ? $first_page : $rows; - } - - public function count($text, $small = false) - { - $count = ceil(strlen($text) / $this->char_number); - $count += substr_count($text, PHP_EOL); - $count += substr_count($text, '
    '); - - if ($small) { - $count = $count / 3; - } - - $this->set($count); - } - - public function set($count) - { - if ($count > $this->current) { - $this->current = $count; - } - } - - public function next() - { - $this->space += $this->current; - $this->current = 0; - } - - public function getAdditionalNumber() - { - $page = ceil($this->space / $this->max_rows_first_page); - if ($page > 1) { - $rows = floor($this->space) % $this->max_rows; - } else { - $rows = floor($this->space) % $this->max_rows_first_page; - } - - $number = $this->max_additional - $rows; - - return $number > 0 ? $number : 0; - } - - public function generate() - { - $this->next(); - - $result = ''; - - $number = $this->getAdditionalNumber(); - - for ($i = 0; $i < $number; ++$i) { - $result .= ' - '; - - for ($c = 0; $c < $this->column_number; ++$c) { - $result .= ' -  '; - } - - $result .= ' - '; - } - - return $result; - } -} diff --git a/src/Util/FileSystem.php b/src/Util/FileSystem.php deleted file mode 100755 index 72513dcd2..000000000 --- a/src/Util/FileSystem.php +++ /dev/null @@ -1,185 +0,0 @@ -. - */ - -namespace Util; - -use FilesystemIterator; -use RecursiveDirectoryIterator; -use RecursiveIteratorIterator; - -/** - * @since 2.4.6 - */ -class FileSystem -{ - protected static $units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']; - - /** - * Controlla l'esistenza e i permessi di scrittura sul percorso indicato. - * - * @param string $path - * - * @return bool - */ - public static function directory($path) - { - if (is_dir($path) && is_writable($path)) { - return true; - } elseif (!is_dir($path)) { - // Filesystem Symfony - $fs = new \Symfony\Component\Filesystem\Filesystem(); - - // Tentativo di creazione - try { - $fs->mkdir($path); - - return true; - } catch (\Symfony\Component\Filesystem\Exception\IOException $e) { - } - } - - return false; - } - - /** - * Individua la dimensione di una cartella indicata. - * - * @param string $path - * - * @return int - */ - public static function folderSize($path, $exclusions = []) - { - $total = 0; - $path = realpath($path); - - if ($path !== false && $path != '' && file_exists($path)) { - foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS)) as $object) { - if (!in_array($object->getExtension(), $exclusions)) { - $total += $object->getSize(); - } - } - } - - return $total; - } - - /** - * Restituisce il numero di file contenuti nella cartella indicata. - * - * @param string $path - * - * @return int - */ - public static function fileCount($path, $exclusions = []) - { - $total = 0; - $path = realpath($path); - - if ($path !== false && $path != '' && file_exists($path)) { - foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS)) as $object) { - if (!in_array($object->getExtension(), $exclusions)) { - ++$total; - } - } - } - - return $total; - } - - /** - * Individua la dimensione del file indicato. - * - * @param string $path - * - * @return int - */ - public static function fileSize($path) - { - $path = realpath($path); - - return filesize($path); - } - - /** - * Individua la dimensione del file o cartella indicati, formattati in modo standard. - * - * @param string $path - * - * @return string - */ - public static function size($path) - { - $path = realpath($path); - - $result = is_file($path) ? self::fileSize($path) : self::folderSize($path); - - return self::formatBytes($result); - } - - /** - * Formatta i byte nell'unità di misura relativa. - * - * @param int $bytes - * @param int $precision - * - * @return string - */ - public static function formatBytes($bytes, $precision = 2) - { - $units = self::$units; - - $bytes = max($bytes, 0); - $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); - $pow = min($pow, count($units) - 1); - - // Uncomment one of the following alternatives - $bytes /= pow(1024, $pow); - // $bytes /= (1 << (10 * $pow)); - - return round($bytes, $precision).' '.$units[$pow]; - } - - /** - * Converte l'unità di misura relativa in byte. - * - * @param string $bytes - * - * @return string - */ - public static function convertBytes($bytes) - { - $units = self::$units; - - $result = 0; - $count = count($units); - for ($i = $count - 1; $i >= 0; --$i) { - $pos = strpos($bytes, $units[$i]); - if ($pos !== false) { - $value = substr($bytes, 0, $pos); - - $result = floatval($value) * pow(1024, $i); - - break; - } - } - - return $result; - } -} diff --git a/src/Util/Generator.php b/src/Util/Generator.php deleted file mode 100755 index 79b8bc196..000000000 --- a/src/Util/Generator.php +++ /dev/null @@ -1,243 +0,0 @@ -. - */ - -namespace Util; - -use Carbon\Carbon; -use Illuminate\Database\Capsule\Manager; - -/** - * Classe dedicata alla gestione e all'interpretazione delle stringhe personalizzate. - * - * @since 2.3 - */ -class Generator -{ - /** @var array Elenco delle varabili da sostituire nel pattern */ - protected static $replaces = [ - 'YYYY' => [ - 'date' => 'Y', - ], - 'yy' => [ - 'date' => 'y', - ], - 'm' => [ - 'date' => 'm', - ], - 'd' => [ - 'date' => 'd', - ], - 'H' => [ - 'date' => 'H', - ], - 'i' => [ - 'date' => 'i', - ], - 's' => [ - 'date' => 'd', - ], - ]; - - /** - * Genera un pattern sulla base del precedente. - * - * @param string $pattern - * @param string $last - * @param int $quantity - * @param array $values - * - * @return string - */ - public static function generate($pattern, $last = null, $quantity = 1, $values = [], $date = null) - { - // Costruzione del pattern - $result = self::complete($pattern, $values, $date); - $length = substr_count($result, '#'); - - // Individuazione dei valori precedenti - $previous = self::read($pattern, $last); - - $number = 1; - if (isset($previous['number'])) { - $number = intval($previous['number']) + $quantity; - } - - $result = preg_replace('/#{1,}/', str_pad($number, $length, '0', STR_PAD_LEFT), $result); - - return $result; - } - - /** - * Completa un determinato pattern con le informazioni di base. - * - * @return string - */ - public static function complete($pattern, $values = [], $date = null) - { - // Costruzione del pattern - $replaces = array_merge(self::getReplaces($date), $values); - - $keys = array_keys($replaces); - $values = array_column($replaces, 'value'); - - $result = str_replace($keys, $values, $pattern); - - return $result; - } - - /** - * Restituisce i valori utilizzati sul pattern. - * - * @return array - */ - public static function read($pattern, $string, $date = null) - { - // Costruzione del pattern - $replaces = self::getReplaces($date); - - $replaces['#'] = [ - 'regex' => '(?[0-9]+)', - ]; - - $values = array_column($replaces, 'regex'); - - $pattern = preg_replace('/#{1,}/', '#', $pattern); - $pattern = str_replace('\\#', '#', preg_quote($pattern, '/')); - $pattern = str_replace(array_keys($replaces), array_values($values), $pattern); - - // Individuazione dei valori - preg_match('/^'.$pattern.'/', $string, $m); - - return array_filter($m, 'is_string', ARRAY_FILTER_USE_KEY); - } - - /** - * Restituisce l'elenco delle variabili da sostituire normalizzato per l'utilizzo. - * - * @return array - */ - public static function getReplaces($date = null) - { - $replaces = self::$replaces; - - $date_object = new Carbon($date); - - foreach ($replaces as $key => $value) { - if (!isset($replaces[$key]['value'])) { - if (isset($replaces[$key]['date'])) { - $replaces[$key]['value'] = $date_object->format($replaces[$key]['date']); - } else { - $replaces[$key]['value'] = $key; - } - } - - if (!isset($replaces[$key]['regex'])) { - $replaces[$key]['regex'] = '(?<'.preg_quote($key).'>.{'.strlen($replaces[$key]['value']).'})'; - } - } - - return $replaces; - } - - /** - * Interpreta una data specifica per la sostituzione nei pattern. - * - * @return array - */ - public static function dateToPattern($date) - { - $replaces = self::$replaces; - - $date = strtotime($date); - $results = []; - - foreach ($replaces as $key => $value) { - if (isset($replaces[$key]['date'])) { - $results[$key]['value'] = date($replaces[$key]['date'], $date); - } - } - - return $results; - } - - /** - * Restituisce la maschera specificata per il segmento indicato. - * - * @param int $id_segment - * - * @return string - */ - public static function getMaschera($id_segment) - { - $database = database(); - - $maschera = $database->fetchOne('SELECT pattern FROM zz_segments WHERE id = :id_segment', [ - ':id_segment' => $id_segment, - ]); - - return $maschera['pattern']; - } - - public static function getPreviousFrom($maschera, $table, $field, $where = [], $date = null) - { - $order = static::getMascheraOrder($maschera, $field); - - $maschera = Generator::complete($maschera, [], $date); - $maschera = str_replace('#', '%', $maschera); - - $query = Manager::table($table)->select($field)->where($field, 'like', $maschera)->orderByRaw($order); - - foreach ($where as $and) { - $query->whereRaw($and); - } - - $result = $query->first(); - - return isset($result->{$field}) ? $result->{$field} : null; - } - - /** - * Metodo per l'individuazione del tipo di ordine da impostare per la corretta interpretazione della maschera. - * Esempi: - * - maschere con testo iniziale (FT-####-YYYY) necessitano l'ordinamento alfabetico - * - maschere di soli numeri (####-YYYY) è necessario l'ordinamento numerico forzato. - * - * @param string $maschera - * @param string $field - * - * @return string - */ - protected static function getMascheraOrder($maschera, $field) - { - // Query di default - $query = $field.' DESC'; - - // Estraggo blocchi di caratteri standard - preg_match('/[#]+/', $maschera, $matches); - - if (!empty($matches)) { - $pos1 = strpos($maschera, (string) $matches[0]); - if ($pos1 == 0) { - $query = 'CAST('.$field.' AS UNSIGNED) DESC'; - } - } - - return $query; - } -} diff --git a/src/Util/Ini.php b/src/Util/Ini.php deleted file mode 100755 index f20ab358f..000000000 --- a/src/Util/Ini.php +++ /dev/null @@ -1,183 +0,0 @@ -. - */ - -namespace Util; - -/** - * Classe dedicata alla gestione e all'interpretazione dei file INI. - * - * @since 2.3 - */ -class Ini -{ - /** - * Predispone la struttura per il salvataggio dei contenuti INI a partire da una struttura precedente. - * - * @param string $content - * @param array $values - * - * @return string - */ - public static function write($content, $values) - { - $result = ''; - - // Lettura info componente - if (!empty($content)) { - // Converto 'contenuto' di questo componente in un array - $array = self::read($content); - - // Per ogni sezione dell'array estratto dal file ini - foreach ($array as $sezione => $valori) { - $sezione = str_replace(["\r", "\n"], '
    ', $sezione); - $result .= '['.$sezione.']'.PHP_EOL; - - if (array_key_exists('valore', $valori)) { - $valori = array_replace($valori, ['valore' => $valori['valore']], ['valore' => $values[str_replace(' ', '_', $sezione)]]); - } - - foreach ($valori as $key => $value) { - $result .= $key.' = "'.addslashes($value).'"'.PHP_EOL; - } - } - } - - return $result; - } - - /** - * Interpreta i contenuti di una stringa in formato INI. - * - * @param string $string - * - * @return array - */ - public static function read($string) - { - return (array) parse_ini_string($string, true); - } - - /** - * Interpreta i contenuti di un file INI. - * - * @param string $filename - * - * @return array - */ - public static function readFile($filename) - { - $filename = (file_exists($filename)) ? $filename : base_dir().'/files/impianti/'.$filename; - - $contents = file_get_contents($filename); - - return !empty($contents) ? self::read($contents) : []; - } - - /** - * Restituisce la lista di tutti i file INI presenti all'interno della cartella indicata. - * - * @param string $dir - * @param array $exclude - */ - public static function getList($dir, $exclude = []) - { - $results = []; - - // Lettura dei files nella cartella indicata - $exclude = !empty($exclude) ? $exclude : []; - $exclude = is_array($exclude) ? $exclude : explode(',', $exclude); - - // Aggiungo tutti i componenti di possibile installazione - $files = glob(realpath($dir).'/*.ini'); - foreach ($files as $file) { - if (!in_array(basename($file), $exclude)) { - $results[] = [basename($file), self::getValue(self::readFile($file), 'Nome').' ('.basename($file).')']; - } - } - - return $results; - } - - /** - * Ottiene il valore di un campo contenuto all'interno della struttura INI. - * - * @param array $content - * @param string $value - * - * @return mixed - */ - public static function getValue($content, $value) - { - $result = !empty($content) && isset($content[$value]['valore']) ? $content[$value]['valore'] : ''; - - return $result; - } - - /** - * Predispone il form dedicato alla modifica dei contenuti della struttura INI. - * - * @param string $contenuto - * - * @return array - */ - public static function getFields($contenuto) - { - $result = []; - - // Caricamento campi dell'eventuale componente selezionato - if (!empty($contenuto)) { - $random = rand(); - $array = self::read($contenuto); - - if (is_array($array)) { - $result[] = ' -

    '.tr('Attributi per _NAME_', [ - '_NAME_' => $array['Nome']['valore'], - ]).'

    - '; - - foreach ($array as $sezione => $array_impostazioni) { - if ($sezione != 'Nome') { - $nome = $sezione; - $tipo = ($array[$sezione]['tipo'] == 'input') ? 'text' : $array[$sezione]['tipo']; - $valore = $array[$sezione]['valore']; - - $opzioni = string_contains($array[$sezione]['opzioni'] ?: '', ',') ? explode(',', $array[$sezione]['opzioni']) : []; - $values = []; - foreach ($opzioni as $o) { - $values[] = '\"'.addslashes(addslashes($o)).'\": \"'.addslashes(addslashes($o)).'\"'; - } - - $input = ' - {[ "type": "'.$tipo.'", "label": "'.$nome.':", "name": "'.$nome.'", "value": '.json_encode($valore).', "id": "'.$nome.'_'.$random.'" '.(!empty($values) ? ', "values": "list='.implode(', ', $values).'"' : '').' ]}'; - - if ($tipo == 'span') { - $input .= ' - '; - } - - $result[] = $input; - } - } - } - } - - return $result; - } -} diff --git a/src/Util/Messages.php b/src/Util/Messages.php deleted file mode 100755 index a0f21701d..000000000 --- a/src/Util/Messages.php +++ /dev/null @@ -1,43 +0,0 @@ -. - */ - -namespace Util; - -/** - * Classe dedicata alla gestione dei messaggi per l'utente. - * - * @since 2.4.2 - */ -class Messages extends \Slim\Flash\Messages -{ - public function info($message) - { - return $this->addMessage('info', $message); - } - - public function warning($message) - { - return $this->addMessage('warning', $message); - } - - public function error($message) - { - return $this->addMessage('error', $message); - } -} diff --git a/src/Util/Query.php b/src/Util/Query.php deleted file mode 100755 index a04e64c8f..000000000 --- a/src/Util/Query.php +++ /dev/null @@ -1,482 +0,0 @@ -. - */ - -namespace Util; - -use Auth; -use Modules; -use Translator; - -/** - * Classe per la gestione delle interazione di base per le query dinamiche. - * - * @since 2.4.7 - */ -class Query -{ - protected static $segments = true; - - /** - * Imposta l'utilizzo o meno dei segmenti per le query. - * - * @param bool $segments - */ - public static function setSegments($segments) - { - self::$segments = $segments; - } - - /** - * Restituisce un'insieme di array comprendenti le informazioni per la costruzione della query del modulo indicato. - * - * @param array $element - * - * @throws \Exception - * - * @return array - */ - public static function readQuery($element) - { - if (string_contains($element['option'], '|select|')) { - $result = self::readNewQuery($element); - } else { - $result = self::readOldQuery($element); - } - - return $result; - } - - /** - * Sostituisce i valori previsti all'interno delle query di moduli/plugin. - * - * @param string $query - * - * @return string - */ - public static function replacePlaceholder($query) - { - $id_parent = filter('id_parent'); - - $id_module = Modules::getCurrent()['id']; - $segment = !empty(self::$segments) ? $_SESSION['module_'.$id_module]['id_segment'] : null; - - $user = Auth::user(); - - // Sostituzione periodi temporali - preg_match('|date_period\((.+?)\)|', $query, $matches); - $date_query = $date_filter = null; - if (!empty($matches)) { - $dates = explode(',', $matches[1]); - $date_filter = $matches[0]; - - $filters = []; - if ($dates[0] != 'custom') { - foreach ($dates as $date) { - $filters[] = $date." BETWEEN '|period_start|' AND '|period_end|'"; - } - } else { - foreach ($dates as $k => $v) { - if ($k < 1) { - continue; - } - $filters[] = $v; - } - } - $date_query = !empty($filters) && !empty(self::$segments) ? ' AND ('.implode(' OR ', $filters).')' : ''; - } - - // Sostituzione periodi temporali - preg_match('|segment\((.+?)\)|', $query, $matches); - $segment_name = !empty($matches[1]) ? $matches[1] : 'id_segment'; - $segment_filter = !empty($matches[0]) ? $matches[0] : 'segment'; - - // Elenco delle sostituzioni - $replace = [ - // Identificatori - '|id_anagrafica|' => prepare($user['idanagrafica']), - '|id_utente|' => prepare($user['id']), - '|id_parent|' => prepare($id_parent), - - // Filtro temporale - '|'.$date_filter.'|' => $date_query, - - // Date - '|period_start|' => $_SESSION['period_start'], - '|period_end|' => $_SESSION['period_end'].' 23:59:59', - - // Segmenti - '|'.$segment_filter.'|' => !empty($segment) ? ' AND '.$segment_name.' = '.prepare($segment) : '', - - // Filtro dinamico per il modulo Giacenze sedi - '|giacenze_sedi_idsede|' => prepare(isset($_SESSION['giacenze_sedi']) ? $_SESSION['giacenze_sedi']['idsede'] : null), - ]; - - // Sostituzione dei formati - $patterns = formatter()->getSQLPatterns(); - - foreach ($patterns as $key => $value) { - $replace['|'.$key.'_format|'] = "'".$value."'"; - } - - // Sostituzione effettiva - $query = replace($query, $replace); - - return $query; - } - - /** - * Genera la query prevista dalla struttura indicata. - * - * @param $structure - * @param array $search - * @param array $order - * @param array $limit - * - * @throws \Exception - * - * @return mixed|string - */ - public static function getQuery($structure, $search = [], $order = [], $limit = []) - { - $total = self::readQuery($structure); - - // Lettura parametri modulo - $query = $total['query']; - - if (empty($query) || $query == 'menu' || $query == 'custom') { - return ''; - } - - // Filtri di ricerca - $search_filters = []; - foreach ($search as $field => $original_value) { - $pos = array_search($field, $total['fields']); - $value = is_array($original_value) ? $original_value : trim($original_value); - - if (isset($value) && $pos !== false) { - $search_query = $total['search_inside'][$pos]; - - // Campo con ricerca personalizzata - if (string_contains($search_query, '|search|')) { - $pieces = explode(',', $value); - foreach ($pieces as $piece) { - $piece = trim($piece); - $search_filters[] = str_replace('|search|', prepare('%'.$piece.'%'), $search_query); - } - } - - // Campi tradizionali: ricerca tramite like - else { - // Ricerca nei titoli icon_title_* per le icone icon_* - if (preg_match('/^icon_(.+?)$/', $field, $m)) { - $search_query = '`icon_title_'.$m[1].'`'; - } - - // Ricerca nei titoli color_title_* per i colori color_* - elseif (preg_match('/^color_(.+?)$/', $field, $m)) { - $search_query = '`color_title_'.$m[1].'`'; - } - - // Gestione confronti - $real_value = trim(str_replace(['<', '>'], ['<', '>'], $value)); - $more = string_starts_with($real_value, '>=') || string_starts_with($real_value, '> =') || string_starts_with($real_value, '>'); - $minus = string_starts_with($real_value, '<=') || string_starts_with($real_value, '< =') || string_starts_with($real_value, '<'); - $equal = string_starts_with($real_value, '='); - - if ($minus || $more || $equal) { - $sign = string_contains($real_value, '=') ? '=' : ''; - if ($more) { - $sign = '>'.$sign; - } elseif ($minus) { - $sign = '<'.$sign; - } else { - $sign = '='; - } - - $value = trim(str_replace(['<', '=', '>'], '', $value)); - - if ($more || $minus) { - $search_filters[] = 'CAST('.$search_query.' AS UNSIGNED) '.$sign.' '.prepare($value); - } else { - $search_filters[] = $search_query.' = '.prepare($value); - } - } else { - $search_filters[] = $search_query.' LIKE '.prepare('%'.$value.'%'); - } - } - } - - // Campo id: ricerca tramite comparazione - elseif ($field == 'id') { - // Filtro per una serie di ID - if (is_array($original_value)) { - if (!empty($original_value)) { - $search_filters[] = $field.' IN ('.implode(', ', $original_value).')'; - } - } else { - $search_filters[] = $field.' = '.prepare($value); - } - } - - // Ricerca - if (!empty($search_filters)) { - $query = str_replace('2=2', '2=2 AND ('.implode(' AND ', $search_filters).') ', $query); - } - } - - // Ordinamento dei risultati - if (isset($order['dir']) && isset($order['column'])) { - //$pos = array_search($order['column'], $total['fields']); - $pos = $order['column']; - - if ($pos !== false) { - $pieces = explode('ORDER', $query); - - $count = count($pieces); - if ($count > 1) { - unset($pieces[$count - 1]); - } - - $query = implode('ORDER', $pieces).' ORDER BY '.$total['order_by'][$order['column']].' '.$order['dir']; - } - } - - // Paginazione - if (!empty($limit) && intval($limit['length']) > 0) { - $query .= ' LIMIT '.$limit['start'].', '.$limit['length']; - } - - return $query; - } - - public static function executeAndCount($query) - { - $database = database(); - - // Esecuzione della query - $query = self::str_replace_once('SELECT', 'SELECT SQL_CALC_FOUND_ROWS', $query); - $results = $database->fetchArray($query); - - // Conteggio dei record filtrati - $count = $database->fetchOne('SELECT FOUND_ROWS() AS count'); - - return [ - 'results' => $results, - 'count' => $count['count'], - ]; - } - - /** - * Restituisce le somme richieste dalla query prevista dalla struttura. - * - * @param $structure - * @param array $search - * - * @throws \Exception - * - * @return array - */ - public static function getSums($structure, $search = []) - { - $total = self::readQuery($structure); - - // Calcolo di eventuali somme - if (empty($total['summable'])) { - return []; - } - - $result_query = self::getQuery($structure, $search); - - // Filtri derivanti dai permessi (eventuali) - if (empty($structure->originalModule)) { - $result_query = Modules::replaceAdditionals($structure->id, $result_query); - } - - $query = self::str_replace_once('SELECT', 'SELECT '.implode(', ', $total['summable']).' FROM(SELECT ', $result_query).') AS `z`'; - $sums = database()->fetchOne($query); - - $results = []; - if (!empty($sums)) { - foreach ($sums as $key => $sum) { - if (string_contains($key, 'sum_')) { - $results[str_replace('sum_', '', $key)] = Translator::numberToLocale($sum); - } - } - } - - return $results; - } - - /** - * Sostituisce la prima occorenza di una determinata stringa. - * - * @param string $str_pattern - * @param string $str_replacement - * @param string $string - * - * @since 2.3 - * - * @return string - */ - protected static function str_replace_once($str_pattern, $str_replacement, $string) - { - if (strpos($string, $str_pattern) !== false) { - $occurrence = strpos($string, $str_pattern); - - return substr_replace($string, $str_replacement, strpos($string, $str_pattern), strlen($str_pattern)); - } - - return $string; - } - - /** - * Interpreta lo standard modulare per l'individuazione delle query di un modulo/plugin del progetto. - * - * @param $element - * - * @throws \Exception - * - * @return array - */ - protected static function readNewQuery($element) - { - $fields = []; - $summable = []; - $search_inside = []; - $search = []; - $format = []; - $slow = []; - $order_by = []; - - $query = $element['option']; - - // Aggiunta eventuali filtri dai segmenti per eseguire la query filtrata - $query = str_replace('1=1', '1=1 '.Modules::getAdditionalsQuery($element['attributes']['name'], null, self::$segments), $query); - $views = self::getViews($element); - - $select = []; - - foreach ($views as $view) { - $select[] = $view['query'].(!empty($view['name']) ? " AS '".$view['name']."'" : ''); - - if (!empty($view['visible'])) { - $view['name'] = trim($view['name']); - $view['search_inside'] = trim($view['search_inside']); - $view['order_by'] = trim($view['order_by']); - - $fields[] = trim($view['name']); - - $search_inside[] = !empty($view['search_inside']) ? $view['search_inside'] : '`'.$view['name'].'`'; - $order_by[] = !empty($view['order_by']) ? $view['order_by'] : '`'.$view['name'].'`'; - $search[] = $view['search']; - $slow[] = $view['slow']; - $format[] = $view['format']; - - if ($view['summable']) { - $summable[] = 'SUM(`'.trim($view['name']."`) AS 'sum_".(count($fields) - 1)."'"); - } - } - } - - $select = empty($select) ? '*' : implode(', ', $select); - - $query = str_replace('|select|', $select, $query); - - return [ - 'query' => self::replacePlaceholder($query), - 'fields' => $fields, - 'search_inside' => $search_inside, - 'order_by' => $order_by, - 'search' => $search, - 'slow' => $slow, - 'format' => $format, - 'summable' => $summable, - ]; - } - - /** - * Interpreta lo standard JSON per l'individuazione delle query di un modulo/plugin del progetto. - * - * @param array $element - * - * @return array - */ - protected static function readOldQuery($element) - { - $options = str_replace(["\r", "\n", "\t"], ' ', $element['option']); - $options = json_decode($options, true); - $options = $options['main_query'][0]; - - $fields = []; - $order_by = []; - - $search = []; - $slow = []; - $format = []; - - $query = $options['query']; - $views = explode(',', $options['fields']); - foreach ($views as $view) { - $fields[] = trim($view); - $order_by[] = '`'.trim($view).'`'; - - $search[] = 1; - $slow[] = 0; - $format[] = 0; - } - - $search_inside = $order_by; - - return [ - 'query' => self::replacePlaceholder($query), - 'fields' => $fields, - 'search_inside' => $search_inside, - 'order_by' => $order_by, - 'search' => $search, - 'slow' => $slow, - 'format' => $format, - 'summable' => [], - ]; - } - - /** - * Restituisce le singole componenti delle query per un determinato modulo/plugin. - * - * @param $element - * - * @throws \Exception - * - * @return array - */ - protected static function getViews($element) - { - $database = database(); - - $user = Auth::user(); - - $views = $database->fetchArray('SELECT * FROM `zz_views` WHERE `id_module`='.prepare($element['id']).' AND - `id` IN ( - SELECT `id_vista` FROM `zz_group_view` WHERE `id_gruppo`=( - SELECT `idgruppo` FROM `zz_users` WHERE `id`='.prepare($user['id']).' - )) - ORDER BY `order` ASC'); - - return $views; - } -} diff --git a/src/Util/Singleton.php b/src/Util/Singleton.php deleted file mode 100755 index 5934881b1..000000000 --- a/src/Util/Singleton.php +++ /dev/null @@ -1,68 +0,0 @@ -. - */ - -namespace Util; - -/** - * Classe astratta per la generazione di oggetti istanziabili una singola volta. - * - * @since 2.3 - */ -abstract class Singleton -{ - /** @var Singleton Oggetti istanziati */ - protected static $instance = []; - - /** - * Protected constructor to prevent creating a new instance of the Singleton via the `new` operator from outside of this class. - */ - protected function __construct() - { - } - - /** - * Private clone method to prevent cloning of the instance of the Singleton instance. - */ - private function __clone() - { - } - - /** - * Private unserialize method to prevent unserializing of the Singleton instance. - */ - private function __wakeup() - { - } - - /** - * Restituisce l'istanza della classe in oggetto. - * - * @return Singleton - */ - public static function getInstance() - { - $class = get_called_class(); - - if (!isset(self::$instance[$class])) { - self::$instance[$class] = new static(); - } - - return self::$instance[$class]; - } -} diff --git a/src/Util/XML.php b/src/Util/XML.php deleted file mode 100755 index e2cedf753..000000000 --- a/src/Util/XML.php +++ /dev/null @@ -1,161 +0,0 @@ -. - */ - -namespace Util; - -use Exception; - -/** - * Classe dedicata all'interpretazione dei file XML. - * - * @since 2.4.3 - */ -class XML -{ - /** - * Interpreta i contenuti di una stringa in formato XML. - * - * @param string $string - * - * @return array - */ - public static function read($string) - { - $content = $string; - - libxml_use_internal_errors(true); - - $xml = simplexml_load_string($content, 'SimpleXMLElement', LIBXML_NOCDATA); - if ($xml === false) { - $message = libxml_get_last_error()->message; - - throw new Exception($message); - } - - $result = json_decode(json_encode($xml), true); - - return $result; - } - - /** - * Interpreta i contenuti di un file XML. - * - * @param string $file - * - * @return array - */ - public static function readFile($file) - { - return static::read(file_get_contents($file)); - } - - /** - * Interpreta i contenuti di un file XML. - * - * @param string $file - * - * @return string|bool - */ - public static function decodeP7M($file) - { - $directory = pathinfo($file, PATHINFO_DIRNAME); - $content = file_get_contents($file); - - $base64 = base64_decode(base64_encode($content), true); - if ($base64 !== false) { - $content = $base64; - } - - file_put_contents($file, self::removeBOM($content)); - - $output_file = $directory.'/'.basename($file, '.p7m'); - - exec('openssl smime -verify -noverify -in "'.$file.'" -inform DER -out "'.$output_file.'"', $output, $cmd); - if (!file_exists($output_file)) { - $signer = $directory.'/signer'; - - self::decode($file, $output_file, $signer); - - self::der2smime($file); - self::decode($file, $output_file, $signer); - - if (!file_exists($output_file)) { - return false; - } - } - - return $output_file; - } - - /** - * Decodifica il file utilizzando le funzioni native PHP. - * - * @param $file - * @param $output_file - * @param $signer - * - * @return mixed - */ - protected static function decode($file, $output_file, $signer) - { - openssl_pkcs7_verify($file, PKCS7_NOVERIFY | PKCS7_NOSIGS, $signer); - $result = openssl_pkcs7_verify($file, PKCS7_NOVERIFY | PKCS7_NOSIGS, $signer, [], $signer, $output_file); - - return $result; - } - - /** - * Remove UTF8 BOM. - * - * @param $text - * - * @return string - * - * @source https://stackoverflow.com/questions/10290849/how-to-remove-multiple-utf-8-bom-sequences - */ - protected static function removeBOM($text) - { - $bom = pack('H*', 'EFBBBF'); - $text = preg_replace("/^$bom/", '', $text); - - return $text; - } - - /** - * @param $file - * - * @return bool|int - * - * @source http://php.net/manual/en/function.openssl-pkcs7-verify.php#123118 - */ - protected static function der2smime($file) - { - $to = <<. - */ - -namespace Util; - -use Symfony\Component\Finder\Finder; -use ZipArchive; - -/** - * Classe dedicata alla gestione dei contenuti ZIP. - * - * @since 2.4.2 - */ -class Zip -{ - /** - * Controlla i requisiti per la gestione dei file ZIP. - * - * @return bool - */ - public static function requirements() - { - return extension_loaded('zip'); - } - - /** - * Estrae i contenuti di un file ZIP in una cartella temporanea. - * - * @param string $path - * @param string $destination - * - * @return string - */ - public static function extract($path, $destination = null) - { - // Lettura dell'archivio - $zip = new ZipArchive(); - if (!$zip->open($path)) { - flash()->error(self::check($path)); - - return; - } - - // Percorso di estrazione - $extraction_dir = !empty($destination) ? $destination : base_dir().'/tmp'; - directory($extraction_dir); - - // Estrazione dell'archivio - $zip->extractTo($extraction_dir); - $zip->close(); - - return $extraction_dir; - } - - /** - * Crea un file zip comprimendo ricorsivamente tutte le sottocartelle a partire da una cartella specificata. - * - * @param array|string $source - * @param string $destination - * @param array $ignores - */ - public static function create($source, $destination, $ignores = []) - { - if (!directory(dirname($destination))) { - return false; - } - - $zip = new ZipArchive(); - - $result = $zip->open($destination, ZipArchive::CREATE); - if ($result === true && is_writable(dirname($destination))) { - $finder = Finder::create() - ->files() - ->exclude((array) $ignores['dirs']) - ->ignoreDotFiles(false) - ->ignoreVCS(true) - ->in($source); - - foreach ((array) $ignores['files'] as $value) { - $finder->notName($value); - } - - foreach ($finder as $file) { - $zip->addFile($file, $file->getRelativePathname()); - } - $zip->close(); - } else { - flash()->error(tr("Errore durante la creazione dell'archivio!")); - } - - return $result === true; - } - - /** - * Controllo dei file zip e gestione errori. - * - * @param string $path - * - * @return string|bool - */ - public static function check($path) - { - $errno = zip_open($path); - zip_close($errno); - - if (!is_resource($errno)) { - // using constant name as a string to make this function PHP4 compatible - $errors = [ - ZipArchive::ER_MULTIDISK => tr('archivi multi-disco non supportati'), - ZipArchive::ER_RENAME => tr('ridenominazione del file temporaneo fallita'), - ZipArchive::ER_CLOSE => tr('impossibile chiudere il file zip'), - ZipArchive::ER_SEEK => tr('errore durante la ricerca dei file'), - ZipArchive::ER_READ => tr('errore di lettura'), - ZipArchive::ER_WRITE => tr('errore di scrittura'), - ZipArchive::ER_CRC => tr('errore CRC'), - ZipArchive::ER_ZIPCLOSED => tr("l'archivio zip è stato chiuso"), - ZipArchive::ER_NOENT => tr('file non trovato'), - ZipArchive::ER_EXISTS => tr('il file esiste già'), - ZipArchive::ER_OPEN => tr('impossibile aprire il file'), - ZipArchive::ER_TMPOPEN => tr('impossibile creare il file temporaneo'), - ZipArchive::ER_ZLIB => tr('errore nella libreria Zlib'), - ZipArchive::ER_MEMORY => tr("fallimento nell'allocare memoria"), - ZipArchive::ER_CHANGED => tr('voce modificata'), - ZipArchive::ER_COMPNOTSUPP => tr('metodo di compressione non supportato'), - ZipArchive::ER_EOF => tr('fine del file non prevista'), - ZipArchive::ER_INVAL => tr('argomento non valido'), - ZipArchive::ER_NOZIP => tr('file zip non valido'), - ZipArchive::ER_INTERNAL => tr('errore interno'), - ZipArchive::ER_INCONS => tr('archivio zip inconsistente'), - ZipArchive::ER_REMOVE => tr('impossibile rimuovere la voce'), - ZipArchive::ER_DELETED => tr('voce eliminata'), - ]; - - if (isset($errors[$errno])) { - return tr('Errore').': '.$errors[$errno]; - } - - return false; - } else { - return true; - } - } -} diff --git a/src/Validate.php b/src/Validate.php deleted file mode 100755 index 8b0b718e6..000000000 --- a/src/Validate.php +++ /dev/null @@ -1,179 +0,0 @@ -. - */ - -use API\Services; -use Mpociot\VatCalculator\Exceptions\VATCheckUnavailableException; -use Mpociot\VatCalculator\VatCalculator; -use Respect\Validation\Validator as v; - -/** - * Classe per la gestione delle funzioni VALIDATE richiamabili del progetto. - * - * @since 2.4 - */ -class Validate -{ - public static function vatCheckIT($partita_iva) - { - if ($partita_iva === '') { - return true; - } - if (strlen($partita_iva) == 13) { - $partita_iva = substr($partita_iva, 2); - } - - if (strlen($partita_iva) != 11 || preg_match('/^[0-9]+$/D', $partita_iva) != 1) { - return false; - } - - $s = 0; - for ($i = 0; $i <= 9; $i += 2) { - $s += ord($partita_iva[$i]) - ord('0'); - } - - for ($i = 1; $i <= 9; $i += 2) { - $c = 2 * (ord($partita_iva[$i]) - ord('0')); - if ($c > 9) { - $c = $c - 9; - } - $s += $c; - } - - if ((10 - $s % 10) % 10 != ord($partita_iva[10]) - ord('0')) { - return false; - } - - return true; - } - - /** - * Controlla se la partita iva inserita è valida. - * - * @param string $vat_number - * - * @return bool - */ - public static function isValidVatNumber($vat_number) - { - $result['valid-format'] = true; - - if (empty($vat_number)) { - return $result; - } - - // Controllo sulla sintassi - if (string_starts_with($vat_number, 'IT') && !static::vatCheckIT($vat_number)) { - $result['valid-format'] = false; - - return $result; - } - - /* - // Controllo con API europea ufficiale - if (extension_loaded('soap')) { - try { - $validator = new VatCalculator(); - - if (!$validator->isValidVATNumber($vat_number)) { - return false; - } - } catch (VATCheckUnavailableException $e) { - } - } */ - - // Controllo attraverso apilayer - if (Services::isEnabled()) { - $response = Services::request('post', 'check_iva', [ - 'partita_iva' => $vat_number, - ]); - $data = Services::responseBody($response); - - if (!empty($data['result'])) { - $result['valid-format'] = $data['result']['format_valid']; - $result['valid'] = $data['result']['valid']; - - $fields = []; - // Ragione sociale - $fields['ragione_sociale'] = $data['result']['company_name']; - - // Indirizzo - $address = $data['result']['company_address']; - $info = explode(PHP_EOL, $address); - $fields['indirizzo'] = $info[0]; - - $info = explode(' ', $info[1]); - - $fields['cap'] = $info[0]; - $fields['provincia'] = end($info); - - $citta = array_slice($info, 1, -1); - $fields['citta'] = implode(' ', $citta); - - $result['fields'] = $fields; - } - } - - return $result; - } - - /** - * Controlla se l'email inserita è valida. - * - * @param string $email - * - * @return array - */ - public static function isValidEmail($email) - { - $result = []; - $result['valid-format'] = true; - - if (!v::email()->validate($email)) { - $result['valid-format'] = false; - - return $result; - } - - // Controllo attraverso apilayer - if (Services::isEnabled()) { - $response = Services::request('post', 'check_email', [ - 'email' => $email, - ]); - $data = Services::responseBody($response); - - if (!empty($data['result'])) { - $result['valid-format'] = $data['result']['format_valid']; - $result['smtp-check'] = $data['result']['smtp_check']; - } - } - - return $result; - } - - public static function isValidTaxCode($codice_fiscale) - { - if (empty($codice_fiscale)) { - return true; - } - - $validator = new CodiceFiscale\Validator($codice_fiscale); - - return $validator->isFormallyValid(); - } -} diff --git a/storage/app/.gitignore b/storage/app/.gitignore new file mode 100644 index 000000000..8f4803c05 --- /dev/null +++ b/storage/app/.gitignore @@ -0,0 +1,3 @@ +* +!public/ +!.gitignore diff --git a/storage/app/public/.gitignore b/storage/app/public/.gitignore new file mode 100644 index 000000000..d6b7ef32c --- /dev/null +++ b/storage/app/public/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/storage/framework/.gitignore b/storage/framework/.gitignore new file mode 100644 index 000000000..05c4471f2 --- /dev/null +++ b/storage/framework/.gitignore @@ -0,0 +1,9 @@ +compiled.php +config.php +down +events.scanned.php +maintenance.php +routes.php +routes.scanned.php +schedule-* +services.json diff --git a/storage/framework/cache/.gitignore b/storage/framework/cache/.gitignore new file mode 100644 index 000000000..01e4a6cda --- /dev/null +++ b/storage/framework/cache/.gitignore @@ -0,0 +1,3 @@ +* +!data/ +!.gitignore diff --git a/storage/framework/cache/data/.gitignore b/storage/framework/cache/data/.gitignore new file mode 100644 index 000000000..d6b7ef32c --- /dev/null +++ b/storage/framework/cache/data/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/storage/framework/sessions/.gitignore b/storage/framework/sessions/.gitignore new file mode 100644 index 000000000..d6b7ef32c --- /dev/null +++ b/storage/framework/sessions/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/storage/framework/testing/.gitignore b/storage/framework/testing/.gitignore new file mode 100644 index 000000000..d6b7ef32c --- /dev/null +++ b/storage/framework/testing/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/storage/framework/views/.gitignore b/storage/framework/views/.gitignore new file mode 100644 index 000000000..d6b7ef32c --- /dev/null +++ b/storage/framework/views/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/storage/logs/.gitignore b/storage/logs/.gitignore new file mode 100644 index 000000000..d6b7ef32c --- /dev/null +++ b/storage/logs/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/templates/anagrafiche/body.php b/templates/anagrafiche/body.php deleted file mode 100755 index 4ce1241ac..000000000 --- a/templates/anagrafiche/body.php +++ /dev/null @@ -1,174 +0,0 @@ -. - */ - -use Modules\Interventi\Intervento; - -include_once __DIR__.'/../../core.php'; - -/* - Dati Anagrafici -*/ -echo ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    '.tr('Dettaglio anagrafica', [], ['upper' => true]).'
    '.tr('Denominazione').': '.$anagrafica['ragione_sociale'].'
    '.tr('Indirizzo').': '.$anagrafica['indirizzo'].'
    '.tr('Città').': '.$anagrafica['citta'].''.tr('Provincia').': '.$anagrafica['provincia'].''.tr('Cap').': '.$anagrafica['cap'].'
    '.tr('Partita IVA').': '.$anagrafica['piva'].''.tr('Codice fiscale').': '.$anagrafica['codice_fiscale'].'
    '.tr('Pec').': '.$anagrafica['pec'].''.tr('Email').': '.$anagrafica['email'].'
    '.tr('Telefono').': '.$anagrafica['telefono'].''.tr('cellulare').': '.$anagrafica['cellulare'].''.tr('fax').': '.$anagrafica['fax'].'
    '.tr('Agente').': '.$agente['ragione_sociale'].'
    '; - -/* - Sedi -*/ - -$sedi = $dbo->fetchArray('SELECT * FROM an_sedi WHERE idanagrafica='.prepare($anagrafica->idanagrafica)); -if (!empty($sedi)) { - echo ' - - - - '; - - for ($i = 0; count($sedi) > $i; ++$i) { - echo ' - - - - - - - - - - - - - - - '; - - if (!empty($sedi[$i + 1])) { - echo ' - '; - } - } - - echo ' -
    '.tr('Sedi', [], ['upper' => true]).'
    '.tr('Nome sede').': '.$sedi[$i]['nomesede'].'
    '.tr('Indirizzo').': '.$sedi[$i]['indirizzo'].'
    '.tr('Città').': '.$sedi[$i]['citta'].''.tr('Provincia').': '.$sedi[$i]['prov'].''.tr('Cap').': '.$sedi[$i]['cap'].'
    '.tr('telefono').': '.$sedi[$i]['telefono'].''.tr('cellulare').': '.$sedi[$i]['cellulare'].'
    '; -} - -/* - Impianti -*/ - -$impianti = $dbo->fetchArray('SELECT * FROM my_impianti WHERE idanagrafica='.prepare($anagrafica->idanagrafica)); - -if (!empty($impianti)) { - echo ' - - - - '; - - for ($i = 0; count($impianti) > $i; ++$i) { - echo ' - - - - - - - - - - '; - - if (!empty($impianti[$i + 1])) { - echo ' - '; - } - } - - echo ' -
    '.tr('Impianti', [], ['upper' => true]).'
    '.tr('Matricola').': '.$impianti[$i]['matricola'].''.tr('Data').': '.Translator::dataToLocale($impianti[$i]['data']).'
    '.tr('Nome').': '.$impianti[$i]['nome'].'
    '.tr('descrizione').': '.$impianti[$i]['descrizione'].'
    '; -} - -/* - Attività -*/ - -$interventi = $dbo->fetchArray('SELECT id, sessione.inizio FROM in_interventi LEFT JOIN (SELECT MIN(orario_inizio) AS inizio, in_interventi_tecnici.idintervento FROM in_interventi_tecnici GROUP BY in_interventi_tecnici.idintervento) AS sessione ON sessione.idintervento=in_interventi.id WHERE idanagrafica='.prepare($anagrafica->idanagrafica)); - -if (!empty($interventi)) { - echo ' - - - - '; - - for ($i = 0; count($interventi) > $i; ++$i) { - $intervento = Intervento::find($interventi[$i]['id']); - echo ' - - - - - - - - - - - - '; - - if (!empty($interventi[$i + 1])) { - echo ' - '; - } - } - - echo ' -
    '.tr('Attività', [], ['upper' => true]).'
    '.tr('Data richiesta').': '.Translator::dateToLocale($intervento->data_richiesta).''.tr('Data scadenza').': '.Translator::dateToLocale($intervento->data_scadenza).''.tr('Data inizio').': '.Translator::dateToLocale($interventi[$i]['inizio']).'
    '.tr('Tipo').': '.$intervento->tipo->descrizione.''.tr('stato').': '.$intervento->stato->descrizione.'
    '.tr('richiesta').': '.$intervento->richiesta.'
    '; -} diff --git a/templates/anagrafiche/init.php b/templates/anagrafiche/init.php deleted file mode 100755 index 8c3a3b06a..000000000 --- a/templates/anagrafiche/init.php +++ /dev/null @@ -1,25 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Anagrafiche\Anagrafica; - -$anagrafica = Anagrafica::find($id_record); -$agente = Anagrafica::find($anagrafica->idagente); diff --git a/templates/azienda/body.php b/templates/azienda/body.php deleted file mode 100755 index 051093c58..000000000 --- a/templates/azienda/body.php +++ /dev/null @@ -1,65 +0,0 @@ -. - */ - -use Modules\Banche\Banca; - -include_once __DIR__.'/../../core.php'; - -$banca = Banca::where('id_anagrafica', $anagrafica->idanagrafica) - ->where('predefined', 1) - ->first(); - -/* - Dati Anagrafici -*/ -echo ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    '.tr('Dettaglio anagrafica', [], ['upper' => true]).'
    '.tr('Denominazione').': '.$anagrafica['ragione_sociale'].'
    '.tr('Indirizzo').': '.$anagrafica['indirizzo'].'
    '.tr('Città').': '.$anagrafica['citta'].''.tr('Provincia').': '.$anagrafica['provincia'].''.tr('Cap').': '.$anagrafica['cap'].'
    '.tr('Partita IVA').': '.$anagrafica['piva'].''.tr('Codice fiscale').': '.$anagrafica['codice_fiscale'].'
    '.tr('Banca').': '.$banca->nome.''.tr('IBAN').': '.$banca->iban.''.tr('Codice destinatario').': '.$anagrafica['codice_destinatario'].'
    '.tr('Pec').': '.$anagrafica['pec'].''.tr('Email').': '.$anagrafica['email'].'
    '.tr('Telefono').': '.$anagrafica['telefono'].''.tr('cellulare').': '.$anagrafica['cellulare'].''.tr('fax').': '.$anagrafica['fax'].'
    '; diff --git a/templates/azienda/init.php b/templates/azienda/init.php deleted file mode 100755 index aa1d65294..000000000 --- a/templates/azienda/init.php +++ /dev/null @@ -1,24 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Anagrafiche\Anagrafica; - -$anagrafica = Anagrafica::find(setting('Azienda predefinita')); diff --git a/templates/barcode/body.php b/templates/barcode/body.php deleted file mode 100755 index 93d787d81..000000000 --- a/templates/barcode/body.php +++ /dev/null @@ -1,61 +0,0 @@ -. - */ - -use Modules\Articoli\Articolo; - -include_once __DIR__.'/../../core.php'; - -echo ''; - -if (!empty($_SESSION['superselect']['id_articolo_barcode'])) { - $articoli = Articolo::whereIn('id', $_SESSION['superselect']['id_articolo_barcode'])->get(); - unset($_SESSION['superselect']['id_articolo_barcode']); -} else { - $articoli = Articolo::where('id', '=', $id_record)->get(); -} - -$pages = count($articoli); -$page = 0; - -foreach ($articoli as $articolo) { - echo ' -
    -

    '.$articolo->codice.'

    -

    '.$articolo->descrizione.'


    -

    '.moneyFormat($articolo->prezzo_vendita).'

    - -

    '.$articolo->barcode.'

    -
    '; - - ++$page; - - if ($page < $pages) { - echo ''; - } -} diff --git a/templates/barcode/footer.php b/templates/barcode/footer.php deleted file mode 100755 index 1a80e0a55..000000000 --- a/templates/barcode/footer.php +++ /dev/null @@ -1,21 +0,0 @@ -. - */ - -echo ' -'; diff --git a/templates/barcode/header.php b/templates/barcode/header.php deleted file mode 100755 index 1a80e0a55..000000000 --- a/templates/barcode/header.php +++ /dev/null @@ -1,21 +0,0 @@ -. - */ - -echo ' -'; diff --git a/templates/barcode/init.php b/templates/barcode/init.php deleted file mode 100755 index 38e7f3b2b..000000000 --- a/templates/barcode/init.php +++ /dev/null @@ -1,24 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Articoli\Articolo; - -$articolo = Articolo::find($id_record); diff --git a/templates/base/bootstrap.css b/templates/base/bootstrap.css deleted file mode 100755 index c3be128da..000000000 --- a/templates/base/bootstrap.css +++ /dev/null @@ -1,1111 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */ - -html { - font-family: sans-serif; - -ms-text-size-adjust: 100%; - -webkit-text-size-adjust: 100%; -} - -body { - margin: 0; -} - -article, -aside, -details, -figcaption, -figure, -footer, -header, -hgroup, -main, -menu, -nav, -section, -summary { - display: block; -} - -audio, -canvas, -progress, -video { - display: inline-block; - vertical-align: baseline; -} - -audio:not([controls]) { - display: none; - height: 0; -} - -[hidden], -template { - display: none; -} - -a { - background-color: transparent; -} - -a:active, -a:hover { - outline: 0; -} - -abbr[title] { - border-bottom: 1px dotted; -} - -b, -strong { - font-weight: bold; -} - -dfn { - font-style: italic; -} - -h1 { - font-size: 2em; - margin: 0.67em 0; -} - -mark { - background: #ff0; - color: #000; -} - -small { - font-size: 80%; -} - -sub, -sup { - font-size: 75%; - line-height: 0; - position: relative; - vertical-align: baseline; -} - -sup { - top: -0.5em; -} - -sub { - bottom: -0.25em; -} - -img { - border: 0; -} - -svg:not(:root) { - overflow: hidden; -} - -figure { - margin: 1em 40px; -} - -hr { - -webkit-box-sizing: content-box; - -moz-box-sizing: content-box; - box-sizing: content-box; - height: 0; -} - -pre { - overflow: auto; -} - -code, -kbd, -pre, -samp { - font-family: monospace, monospace; - font-size: 1em; -} - -table { - border-collapse: collapse; - border-spacing: 0; -} - -td, -th { - padding: 0; -} - -* { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; -} - -*:before, -*:after { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; -} - -html { - font-size: 10px; - -webkit-tap-highlight-color: rgba(0, 0, 0, 0); -} - -body { - font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; - font-size: 14px; - line-height: 1.42857143; - color: #333333; - background-color: #ffffff; -} - -input, -button, -select, -textarea { - font-family: inherit; - font-size: inherit; - line-height: inherit; -} - -a { - color: #337ab7; - text-decoration: none; -} - -a:hover, -a:focus { - color: #23527c; - text-decoration: underline; -} - -a:focus { - outline: 5px auto -webkit-focus-ring-color; - outline-offset: -2px; -} - -figure { - margin: 0; -} - -img { - vertical-align: middle; -} - -.img-responsive { - display: block; - max-width: 100%; - height: auto; -} - -.img-rounded { - border-radius: 6px; -} - -.img-thumbnail { - padding: 4px; - line-height: 1.42857143; - background-color: #ffffff; - border: 1px solid #dddddd; - border-radius: 4px; - -webkit-transition: all 0.2s ease-in-out; - -o-transition: all 0.2s ease-in-out; - transition: all 0.2s ease-in-out; - display: inline-block; - max-width: 100%; - height: auto; -} - -.img-circle { - border-radius: 50%; -} - -hr { - margin-top: 20px; - margin-bottom: 20px; - border: 0; - border-top: 1px solid #eeeeee; -} - -h1, -h2, -h3, -h4, -h5, -h6, -.h1, -.h2, -.h3, -.h4, -.h5, -.h6 { - font-family: inherit; - font-weight: 500; - line-height: 1.1; - color: inherit; -} - -h1 small, -h2 small, -h3 small, -h4 small, -h5 small, -h6 small, -.h1 small, -.h2 small, -.h3 small, -.h4 small, -.h5 small, -.h6 small, -h1 .small, -h2 .small, -h3 .small, -h4 .small, -h5 .small, -h6 .small, -.h1 .small, -.h2 .small, -.h3 .small, -.h4 .small, -.h5 .small, -.h6 .small { - font-weight: normal; - line-height: 1; - color: #777777; -} - -h1, -.h1, -h2, -.h2, -h3, -.h3 { - margin-top: 20px; - margin-bottom: 10px; -} - -h1 small, -.h1 small, -h2 small, -.h2 small, -h3 small, -.h3 small, -h1 .small, -.h1 .small, -h2 .small, -.h2 .small, -h3 .small, -.h3 .small { - font-size: 65%; -} - -h4, -.h4, -h5, -.h5, -h6, -.h6 { - margin-top: 10px; - margin-bottom: 10px; -} - -h4 small, -.h4 small, -h5 small, -.h5 small, -h6 small, -.h6 small, -h4 .small, -.h4 .small, -h5 .small, -.h5 .small, -h6 .small, -.h6 .small { - font-size: 75%; -} - -h1, -.h1 { - font-size: 36px; -} - -h2, -.h2 { - font-size: 30px; -} - -h3, -.h3 { - font-size: 24px; -} - -h4, -.h4 { - font-size: 18px; -} - -h5, -.h5 { - font-size: 14px; -} - -h6, -.h6 { - font-size: 12px; -} - -p { - margin: 0 0 10px; -} - -.lead { - margin-bottom: 20px; - font-size: 16px; - font-weight: 300; - line-height: 1.4; -} - -small, -.small { - font-size: 85%; -} - -mark, -.mark { - background-color: #fcf8e3; - padding: .2em; -} - -.text-left { - text-align: left; -} - -.text-right { - text-align: right; -} - -.text-center { - text-align: center; -} - -.text-justify { - text-align: justify; -} - -.text-nowrap { - white-space: nowrap; -} - -.text-lowercase { - text-transform: lowercase; -} - -.text-uppercase { - text-transform: uppercase; -} - -.text-capitalize { - text-transform: capitalize; -} - -.text-muted { - color: #777777; -} - -.text-primary { - color: #337ab7; -} - -a.text-primary:hover, -a.text-primary:focus { - color: #286090; -} - -.text-success { - color: #3c763d; -} - -a.text-success:hover, -a.text-success:focus { - color: #2b542c; -} - -.text-info { - color: #31708f; -} - -a.text-info:hover, -a.text-info:focus { - color: #245269; -} - -.text-warning { - color: #8a6d3b; -} - -a.text-warning:hover, -a.text-warning:focus { - color: #66512c; -} - -.text-danger { - color: #a94442; -} - -a.text-danger:hover, -a.text-danger:focus { - color: #843534; -} - -.bg-primary { - color: #fff; - background-color: #337ab7; -} - -a.bg-primary:hover, -a.bg-primary:focus { - background-color: #286090; -} - -.bg-success { - background-color: #dff0d8; -} - -a.bg-success:hover, -a.bg-success:focus { - background-color: #c1e2b3; -} - -.bg-info { - background-color: #d9edf7; -} - -a.bg-info:hover, -a.bg-info:focus { - background-color: #afd9ee; -} - -.bg-warning { - background-color: #fcf8e3; -} - -a.bg-warning:hover, -a.bg-warning:focus { - background-color: #f7ecb5; -} - -.bg-danger { - background-color: #f2dede; -} - -a.bg-danger:hover, -a.bg-danger:focus { - background-color: #e4b9b9; -} - -.page-header { - padding-bottom: 9px; - margin: 40px 0 20px; - border-bottom: 1px solid #eeeeee; -} - -ul, -ol { - margin-top: 0; - margin-bottom: 10px; -} - -ul ul, -ol ul, -ul ol, -ol ol { - margin-bottom: 0; -} - -.list-unstyled { - padding-left: 0; - list-style: none; -} - -.list-inline { - padding-left: 0; - list-style: none; - margin-left: -5px; -} - -.list-inline>li { - display: inline-block; - padding-left: 5px; - padding-right: 5px; -} - -abbr[title], -abbr[data-original-title] { - cursor: help; - border-bottom: 1px dotted #777777; -} - -.initialism { - font-size: 90%; - text-transform: uppercase; -} - -blockquote { - padding: 10px 20px; - margin: 0 0 20px; - font-size: 17.5px; - border-left: 5px solid #eeeeee; -} - -blockquote p:last-child, -blockquote ul:last-child, -blockquote ol:last-child { - margin-bottom: 0; -} - -blockquote footer, -blockquote small, -blockquote .small { - display: block; - font-size: 80%; - line-height: 1.42857143; - color: #777777; -} - -blockquote footer:before, -blockquote small:before, -blockquote .small:before { - content: '\2014 \00A0'; -} - -.blockquote-reverse, -blockquote.pull-right { - padding-right: 15px; - padding-left: 0; - border-right: 5px solid #eeeeee; - border-left: 0; - text-align: right; -} - -.blockquote-reverse footer:before, -blockquote.pull-right footer:before, -.blockquote-reverse small:before, -blockquote.pull-right small:before, -.blockquote-reverse .small:before, -blockquote.pull-right .small:before { - content: ''; -} - -.blockquote-reverse footer:after, -blockquote.pull-right footer:after, -.blockquote-reverse small:after, -blockquote.pull-right small:after, -.blockquote-reverse .small:after, -blockquote.pull-right .small:after { - content: '\00A0 \2014'; -} - -address { - margin-bottom: 20px; - font-style: normal; - line-height: 1.42857143; -} - -.col-xs-1, -.col-xs-2, -.col-xs-3, -.col-xs-4, -.col-xs-5, -.col-xs-6, -.col-xs-7, -.col-xs-8, -.col-xs-9, -.col-xs-10, -.col-xs-11, -.col-xs-12, -.col-lg-12 { - position: relative; - min-height: 1px; - padding-left: 15px; - padding-right: 15px; -} - -.col-xs-1, -.col-xs-2, -.col-xs-3, -.col-xs-4, -.col-xs-5, -.col-xs-6, -.col-xs-7, -.col-xs-8, -.col-xs-9, -.col-xs-10, -.col-xs-11, -.col-xs-12 { - float: left; -} - -.col-xs-12 { - width: 100%; -} - -.col-xs-11 { - width: 91.66666667%; -} - -.col-xs-10 { - width: 83.33333333%; -} - -.col-xs-9 { - width: 75%; -} - -.col-xs-8 { - width: 66.66666667%; -} - -.col-xs-7 { - width: 58.33333333%; -} - -.col-xs-6 { - width: 50%; -} - -.col-xs-5 { - width: 41.66666667%; -} - -.col-xs-4 { - width: 33.33333333%; -} - -.col-xs-3 { - width: 25%; -} - -.col-xs-2 { - width: 16.66666667%; -} - -.col-xs-1 { - width: 8.33333333%; -} - -.col-xs-pull-12 { - right: 100%; -} - -.col-xs-pull-11 { - right: 91.66666667%; -} - -.col-xs-pull-10 { - right: 83.33333333%; -} - -.col-xs-pull-9 { - right: 75%; -} - -.col-xs-pull-8 { - right: 66.66666667%; -} - -.col-xs-pull-7 { - right: 58.33333333%; -} - -.col-xs-pull-6 { - right: 50%; -} - -.col-xs-pull-5 { - right: 41.66666667%; -} - -.col-xs-pull-4 { - right: 33.33333333%; -} - -.col-xs-pull-3 { - right: 25%; -} - -.col-xs-pull-2 { - right: 16.66666667%; -} - -.col-xs-pull-1 { - right: 8.33333333%; -} - -.col-xs-pull-0 { - right: auto; -} - -.col-xs-push-12 { - left: 100%; -} - -.col-xs-push-11 { - left: 91.66666667%; -} - -.col-xs-push-10 { - left: 83.33333333%; -} - -.col-xs-push-9 { - left: 75%; -} - -.col-xs-push-8 { - left: 66.66666667%; -} - -.col-xs-push-7 { - left: 58.33333333%; -} - -.col-xs-push-6 { - left: 50%; -} - -.col-xs-push-5 { - left: 41.66666667%; -} - -.col-xs-push-4 { - left: 33.33333333%; -} - -.col-xs-push-3 { - left: 25%; -} - -.col-xs-push-2 { - left: 16.66666667%; -} - -.col-xs-push-1 { - left: 8.33333333%; -} - -.col-xs-push-0 { - left: auto; -} - -.col-xs-offset-12 { - margin-left: 100%; -} - -.col-xs-offset-11 { - margin-left: 91.66666667%; -} - -.col-xs-offset-10 { - margin-left: 83.33333333%; -} - -.col-xs-offset-9 { - margin-left: 75%; -} - -.col-xs-offset-8 { - margin-left: 66.66666667%; -} - -.col-xs-offset-7 { - margin-left: 58.33333333%; -} - -.col-xs-offset-6 { - margin-left: 50%; -} - -.col-xs-offset-5 { - margin-left: 41.66666667%; -} - -.col-xs-offset-4 { - margin-left: 33.33333333%; -} - -.col-xs-offset-3 { - margin-left: 25%; -} - -.col-xs-offset-2 { - margin-left: 16.66666667%; -} - -.col-xs-offset-1 { - margin-left: 8.33333333%; -} - -.col-xs-offset-0 { - margin-left: 0%; -} - -table { - background-color: transparent; -} - -caption { - padding-top: 8px; - padding-bottom: 8px; - color: #777777; - text-align: left; -} - -th { - text-align: left; -} - -.table { - width: 100%; - max-width: 100%; - margin-bottom: 20px; -} - -.table>thead>tr>th, -.table>tbody>tr>th, -.table>tfoot>tr>th, -.table>thead>tr>td, -.table>tbody>tr>td, -.table>tfoot>tr>td { - padding: 8px; - line-height: 1.42857143; - vertical-align: top; - border-top: 1px solid #dddddd; -} - -.table>thead>tr>th { - vertical-align: bottom; - border-bottom: 2px solid #dddddd; -} - -.table>caption+thead>tr:first-child>th, -.table>colgroup+thead>tr:first-child>th, -.table>thead:first-child>tr:first-child>th, -.table>caption+thead>tr:first-child>td, -.table>colgroup+thead>tr:first-child>td, -.table>thead:first-child>tr:first-child>td { - border-top: 0; -} - -.table>tbody+tbody { - border-top: 2px solid #dddddd; -} - -.table .table { - background-color: #ffffff; -} - -.table-condensed>thead>tr>th, -.table-condensed>tbody>tr>th, -.table-condensed>tfoot>tr>th, -.table-condensed>thead>tr>td, -.table-condensed>tbody>tr>td, -.table-condensed>tfoot>tr>td { - padding: 5px; -} - -.table-bordered { - border: 1px solid #dddddd; -} - -.table-bordered>thead>tr>th, -.table-bordered>tbody>tr>th, -.table-bordered>tfoot>tr>th, -.table-bordered>thead>tr>td, -.table-bordered>tbody>tr>td, -.table-bordered>tfoot>tr>td { - border: 1px solid #dddddd; -} - -.table-bordered>thead>tr>th, -.table-bordered>thead>tr>td { - border-bottom-width: 2px; -} - -.table-striped>tbody>tr:nth-of-type(odd) { - background-color: #f9f9f9; -} - -table col[class*="col-"] { - position: static; - float: none; - display: table-column; -} - -table td[class*="col-"], -table th[class*="col-"] { - position: static; - float: none; - display: table-cell; -} - -.table>thead>tr>td.active, -.table>tbody>tr>td.active, -.table>tfoot>tr>td.active, -.table>thead>tr>th.active, -.table>tbody>tr>th.active, -.table>tfoot>tr>th.active, -.table>thead>tr.active>td, -.table>tbody>tr.active>td, -.table>tfoot>tr.active>td, -.table>thead>tr.active>th, -.table>tbody>tr.active>th, -.table>tfoot>tr.active>th { - background-color: #f5f5f5; -} - -.table>thead>tr>td.success, -.table>tbody>tr>td.success, -.table>tfoot>tr>td.success, -.table>thead>tr>th.success, -.table>tbody>tr>th.success, -.table>tfoot>tr>th.success, -.table>thead>tr.success>td, -.table>tbody>tr.success>td, -.table>tfoot>tr.success>td, -.table>thead>tr.success>th, -.table>tbody>tr.success>th, -.table>tfoot>tr.success>th { - background-color: #dff0d8; -} - -.table>thead>tr>td.info, -.table>tbody>tr>td.info, -.table>tfoot>tr>td.info, -.table>thead>tr>th.info, -.table>tbody>tr>th.info, -.table>tfoot>tr>th.info, -.table>thead>tr.info>td, -.table>tbody>tr.info>td, -.table>tfoot>tr.info>td, -.table>thead>tr.info>th, -.table>tbody>tr.info>th, -.table>tfoot>tr.info>th { - background-color: #d9edf7; -} - -.table>thead>tr>td.warning, -.table>tbody>tr>td.warning, -.table>tfoot>tr>td.warning, -.table>thead>tr>th.warning, -.table>tbody>tr>th.warning, -.table>tfoot>tr>th.warning, -.table>thead>tr.warning>td, -.table>tbody>tr.warning>td, -.table>tfoot>tr.warning>td, -.table>thead>tr.warning>th, -.table>tbody>tr.warning>th, -.table>tfoot>tr.warning>th { - background-color: #fcf8e3; -} - -.table>thead>tr>td.danger, -.table>tbody>tr>td.danger, -.table>tfoot>tr>td.danger, -.table>thead>tr>th.danger, -.table>tbody>tr>th.danger, -.table>tfoot>tr>th.danger, -.table>thead>tr.danger>td, -.table>tbody>tr.danger>td, -.table>tfoot>tr.danger>td, -.table>thead>tr.danger>th, -.table>tbody>tr.danger>th, -.table>tfoot>tr.danger>th { - background-color: #f2dede; -} - -.clearfix:before, -.clearfix:after, -.dl-horizontal dd:before, -.dl-horizontal dd:after, -.container:before, -.container:after, -.container-fluid:before, -.container-fluid:after, -.row:before, -.row:after { - content: " "; - display: table; -} - -.clearfix:after, -.dl-horizontal dd:after, -.container:after, -.container-fluid:after, -.row:after { - clear: both; -} - -.center-block { - display: block; - margin-left: auto; - margin-right: auto; -} - -.pull-right { - float: right !important; -} - -.pull-left { - float: left !important; -} - -.hide { - display: none !important; -} - -.show { - display: block !important; -} - -.invisible { - visibility: hidden; -} - -.text-hide { - font: 0/0 a; - color: transparent; - text-shadow: none; - background-color: transparent; - border: 0; -} - -.hidden { - display: none !important; -} - -.affix { - position: fixed; -} diff --git a/templates/base/footer.php b/templates/base/footer.php deleted file mode 100755 index d27f95d98..000000000 --- a/templates/base/footer.php +++ /dev/null @@ -1,43 +0,0 @@ -. - */ - -/* - * Footer di default. - * I contenuti di questo file vengono utilizzati per generare il footer delle stampe nel caso non esista un file footer.php all'interno della stampa. - * - * Per modificare il footer della stampa basta aggiungere un file footer.php all'interno della cartella della stampa con i contenuti da mostrare (vedasi templates/fatture/footer.php). - * - * La personalizzazione specifica del footer deve comunque seguire lo standard della cartella custom: anche se il file footer.php non esiste nella stampa originaria, se si vuole personalizzare il footer bisogna crearlo all'interno della cartella custom. - */ - -return ' - - - - - - -
    - '.tr('Stampato con OpenSTAManager').' - - '.tr('Pagina _PAGE_ di _TOTAL_', [ - '_PAGE_' => '{PAGENO}', - '_TOTAL_' => '{nb}', - ]).' -
    '; diff --git a/templates/base/header.php b/templates/base/header.php deleted file mode 100755 index 79d4522a3..000000000 --- a/templates/base/header.php +++ /dev/null @@ -1,46 +0,0 @@ -. - */ - -/* - * Header di default. - * I contenuti di questo file vengono utilizzati per generare l'header delle stampe nel caso non esista un file header.php all'interno della stampa. - * - * Per modificare l'header della stampa basta aggiungere un file header.php all'interno della cartella della stampa con i contenuti da mostrare (vedasi templates/fatture/header.php). - * - * La personalizzazione specifica dell'header deve comunque seguire lo standard della cartella custom: anche se il file header.php non esiste nella stampa originaria, se si vuole personalizzare l'header bisogna crearlo all'interno della cartella custom. - */ - -return ' -
    -
    - Logo -
    -
    -

    '.$f_ragionesociale.'

    -

    '.$f_indirizzo.'

    -

    '.$f_citta_full.'

    -

    '.(!empty($f_piva) ? tr('P.Iva').': '.$f_piva : '').'

    -

    '.(!empty($f_codicefiscale) ? tr('C.F.').': '.$f_codicefiscale : '').'

    -

    '.(!empty($f_capsoc) ? tr('Cap.Soc.').': '.$f_capsoc : '').'

    -

    '.(!empty($f_telefono) ? tr('Tel').': '.$f_telefono : '').'

    -

    '.(!empty($f_email) ? tr('Email').': '.$f_email : '').'

    -

    '.(!empty($f_pec) ? tr('PEC').': '.$f_pec : '').'

    -

    '.(!empty($f_sitoweb) ? tr('Web').': '.$f_sitoweb : '').'

    -
    -
    '; diff --git a/templates/base/logo_azienda.jpg b/templates/base/logo_azienda.jpg deleted file mode 100755 index 3fd3914522510a5f6af55ca002d656131577943f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4348 zcmcIG2UJtpwl@VrCxoJO0wL0+iU>%N7AX=0X-XSViqaGWl->m-1e5`!S7|~75d=X3 zN^z7RHAo$0C`u6!6#_qDW_+&y)_d>IU-Qnn>)hSXzWeNb_t_uYp8?>f4KM}(2m}J0 zs1w+q08Rn)P&#@#C_OzLJq$+AzyxPvVq|3EVq<54AL2TE_z)Kl51*j8Fdx5|01uCd zjEETeh@_MxuduAVtc1L{gro$`2nYs)F)=W4GBI&V@bU0T{N=IV32-m~J|H;=hyws~ zfFK;8{VsqX009uHw;YHsSymH+?*e`4T3wM!=3P%0DwPvc>F z*G;^Z@LK|Fdd3NSqUGAu@eQMK`F=e#>6TaaO#e|%2%O*{5IK4;5-IuU>Lmw%n1eGe z%kaEY&OC3FH(wd=;LrMJAE+TtEo3Y_yX%0aw~cepyOT7pqflUlRQW{=UZKZKpJiTc z;PdnRc!njkTUU3nfrYRx4*+b+PuY?WyrV7Dt-ixF;CGoHNdF}8aM0-oHUP>Fr-oV* z4uBv~5SWhc&y#=vP&yEplS>J%OwWN3HRl$QSJ6gN-A&QgtFDHC-HhfI>5_Z0A&2cUPd#RbIXo){l zn=;x&Y~0`+X;Q07sDd6Yemk3q5rX?}W>YTvIA!fzGH;tgW;Ss~QFJ=U;FO$aJ7z_p zgQu~Rzg%uiuUZ%jDnFk+GMmKOEp~efQkUuzoN6;TlFYY6&z$zcXLj#7^RCp|D))+j zdQhNV16(lvz;-(KybE6+)HD%!w%yGSvz$>QmgPBUwsdFS!%Aq|P2JT_t%VTV7;S7v zcUq}=IOC~B!{x3*{9QGhN)SEPcAicual?{m(CVHDYc%GXfMx>C{E;_et z_NbMda#3kWxu6>Co3Bx#%`jO`+jfsxu0`#m8_|jfJinJkCG4V78IFe`3}Xbe7{xjd zAqyTw{XH}PF?T1es5$=3us^d9caT)nzkn8qPV3)DfWJ$q)3Oyr4~2kPp^yVJU@CzF zicnNaD?}>j_`^A|qUKy8V)Dw`x)#nZkx?W+eEsaRwe>&pmtG6Z?&RB~f0s|Dj^q}X zB%^HWT-49XW8+RB{(VGKZ2^Z{Cr7rWuS@LMzpZ&&{L#n1$v?I6X$^7Sv0p(dL^Di@ z#(Hi6_LCE^|5kB6ck*p;`;bwnT~dGhjTEm9rR|#+SFoR(lH1F_ng@PSx&6wTw;o?% zDvjB$EFq8`2!_2B%RqTmpcFIC+x70bti#b?Smu<|D4BD&8QulWq;fV{*=r0Y=L$~3 zO>_83y9|1@=}oXrt85Pwis$VfgWm+DR7@TKL91_%@g$XO=Yl*f6pL0 zpZZ#W(w?i#8v&=cVdy(K-Di^Om)oK6lu# z)$_U4?&;AEA=Q$IEw}4^iTSI;EG2tC9p5qhQt)Z6ongIn$!c_fxHB%C%MY!6HEKKD zYq020`NcGO%ysGY@Y&wjcHwUecK$BuRfGnO;=pyQ$Hf=t=a$|PuRXBREbIChyw1Gk zaK1)>=q>A-bw?B; zD?~}MMk!@59Y^tak`Y?7a*mc>%?D9<@BL0_+F+sn!{0NrV@FAUv=%T30;YpfEBud= z2XP=3*0Aev9p}P&bHB7_^4gKJB7e3PEu`Ori4**;6X@|{y^l-@SJE%%{1v2U+#m^^ z+~u**mP1tF3psjm?WI9p(s-*9NBJ^RJl*a=XKvcSTs$Svho#G-TcVUTu7cxh3c;Sj zd!->)yiZ?^&qp!!RVYo_@5Q3}8JM5NSwAhO*ymviceURO*|Sbk*wfVe=*I9@?zYcK zhVb7NvJNOv-Bl-C5{oW9j+q}a_B>`%xyNSa1~ZXho_Kq%b0|wndg(pkGmnJf=eAE_ z4C{;cMQV+DrMW9nH#IN7<2A3Xyr|n2w-2ntMzv;X#htx%*lgg1XBTUt7CkH+&4e zED5SO6a7AJ)QsFl*P(+SXp6n&nsBi;)Zbtp9G4TYg8Wbw+z9jGm1TZx^QQAm&lS`J z0cl2B!^&BieiBdAEj)49;q498I2Yw#Jp?gwhA;i9^$?CFCf!o`&ORR}>H?M;kLFOg z;TD|Iil>D>BpUlKDB1Gkt_~bRTf{X6yQbt0KbFi5e%Pb8aS?yBi^4ugYOb13^J7cc z6q+l-qB5Gp3wjIS!i|PZg^Xqy1Gpn^gwgKSCBeqHDyhW2+Nc*9jN$Z5ku=_gaMQSv zWZt`WQiLxYI(;Ki!!_-YmzDD&8vT(lM6TAo13!1=H&QsceLm<5WN(lW6*r$J&kbqOKiVz3{3Z~xK4+iz_k6cs0KGSg~ z!Tll&&C^8W>$SgEKKzD?zPBxzz$Ps+_g`7klb}fp)dsJLzFn7hRat%q_JN<(9TJah zRx4+8KV;4SjmYtEWL3YK=qzV@+NrdVzv}uPLf^g?jG5XxdRfL33azsbz4R?Cb2mJn zYQeGHkiV&P=KUC4LVO1PFd*(uECRJH!ajMv=Z>4Q+}1E##q?=HjFWH7M@U1{&qX?P z(a_>6=GT%2>+=fYF{SUyS^EaioUKLlIN8mDinT*d9cRMJ;uf;H3}(tc#T{E+tkv?; zoo+mRZ%BL_>eyHsQLad4Aorp1ro8>SMp@+8jI$Mb2}@&NLo9l5vhYZQ&Sat^DnCBq`N>E0}m5LWFB)v9XJ~`z0=~zZdB#%n=>WA5? zlWXbIU#Jn?+S&Ab5~67~9sq|;{7T}ZvmKvyziFwkwX_hSjvVauON@4!xUMaZdX%b6 z$jgY$`pR8iF(7CI+iVX@XonN^ZNi*4ZSTd)>(vkA*eDg8L%pmq7z(%YQp?71hc{R$ z96bd&>1m1Yu{Sd|XVw`(rVf$p8(cM`3$AH= zleCvk6vZs`v3qZt3E=Y!r|E<|ofuFIxftxiCWBIMLa7 zXJ|6-i5@S8R7QU?=SJg9TEmna@PuKZ3A@CSdP{k zHTpLVG7|Fk0oEHYj$&C#7I%-k91AxaTSY^55{f<0cf`mi9X{*>(H8FO!+AcBqWH)2 pzkP8z7RFBv. - */ - -$settings = [ - 'orientation' => 'P', - 'format' => 'A4', - 'font-size' => 10, - 'margins' => [ - 'top' => 'auto', - 'bottom' => 'auto', - 'left' => 12, - 'right' => 12, - ], - 'header-font-size' => 10, -]; - -return $settings; diff --git a/templates/base/style.css b/templates/base/style.css deleted file mode 100755 index e8bb367a1..000000000 --- a/templates/base/style.css +++ /dev/null @@ -1,158 +0,0 @@ -/* - * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione - * Copyright (C) DevCode s.r.l. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -body { - background-color: white; - color: black; -} - -p { - padding: 0px; - margin: 0px; -} - -.text-bold, -.small-bold { - font-weight: bold; -} - -table { - width: 100%; - overflow: wrap; - word-break: break-all; - word-wrap: break-word; -} - -table td, -table th { - vertical-align: top; - padding: 4px; -} - -.row-bg, -table.table-striped tbody tr:nth-child(2n) td { - background-color: #eee; -} - -table.table-striped tbody tr:nth-child(2n+1) td { - background-color: #fff; -} - -table.table-bordered th { - background: #ddd; -} - -table.table-bordered thead tr:nth-child(2) th { - background: #eee; -} - -small, -.small, -.small-bold, -table#contents thead th { - font-size: 70%; -} - -table.table-normal, -table.table-normal td, -table.table-normal th { - border: 0; -} - -table.border-bottom, -table.border-bottom td, -table.border-bottom th { - border: 0; - border-bottom: 1px solid #aaa; -} - -table.table-bordered, -table.table-bordered td, -table.table-bordered th { - border: 1px solid #aaa; -} - -table thead th, -table.vertical-middle td, -table.vertical-middle th { - vertical-align: middle; -} - -table#contents tbody td { - border-top: 0; - border-bottom: 0; -} - -.row, -.col-xs-1, -.col-xs-2, -.col-xs-3, -.col-xs-4, -.col-xs-5, -.col-xs-6, -.col-xs-7, -.col-xs-8, -.col-xs-9, -.col-xs-10, -.col-xs-11, -.col-xs-12, -.col-lg-12 { - margin: 0px !important; - padding: 0px !important; -} - -.border-left { - border-left: 1px solid #aaa; -} - -.border-right { - border-right: 1px solid #aaa; -} - -.border-top { - border-top: 1px solid #aaa; -} - -.border-bottom { - border-bottom: 1px solid #aaa; -} - -.border-full { - border: 1px solid #aaa; -} - -.cell-padded { - padding: 4px; -} - -.fake-footer p, -.fake-footer span, -.fake-footer div, -.fake-footer table, -.fake-footer table.table-bordered th, -.fake-footer table.table-striped tbody tr td, -.fake-footer th, -.fake-footer tbody, -.fake-footer thead, -.fake-footer tfoot, -.fake-footer td, -.fake-footer tr { - color: white !important; - background: none !important; - border-color: white !important; -} diff --git a/templates/bilancio/body.php b/templates/bilancio/body.php deleted file mode 100644 index 4961b95e3..000000000 --- a/templates/bilancio/body.php +++ /dev/null @@ -1,312 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -// Stato Patrimoniale -echo ' -

    Stato Patrimoniale

    - -
    -
    - - - - - - - - - - - - - '; - // Mostra le righe delle attività - foreach ($liv2_patrimoniale as $liv2_p) { - if ($liv2_p['totale'] > 0) { - $totale_attivita += $liv2_p['totale']; - echo ' - - - - - '; - - foreach ($liv3_patrimoniale as $liv3_p) { - // Visualizzo solo i conti di livello 3 relativi al conto di livello 2 - if ($liv2_p['id'] == $liv3_p['idpianodeiconti2']) { - echo ' - - - - - '; - } - } - if ($liv2_p['descrizione'] == 'Crediti clienti e crediti diversi') { - echo ' - - - - - '; - } elseif ($liv2_p['descrizione'] == 'Debiti fornitori e debiti diversi') { - echo ' - - - - - '; - } - } - } - echo ' - - - - '; - if ($utile_perdita > 0) { - echo ' - - - - - - - - '; - } - echo ' - -
    Attività
    CONTODESCRIZIONESALDO
    '.$liv2_p['numero'].''.$liv2_p['descrizione'].''.numberFormat($liv2_p['totale']).'
    '.$liv3_p['numero'].''.$liv3_p['descrizione'].''.numberFormat($liv3_p['totale']).'
    Clienti'.numberFormat($crediti_clienti).'
    Fornitori'.numberFormat($debiti_fornitori).'
    Totale Attività
    '.numberFormat(abs($totale_attivita)).'
    Perdita
    '.numberFormat(abs($utile_perdita)).'
    Totale a pareggio
    '.numberFormat(abs($totale_attivita) + abs($utile_perdita)).'
    -
    - -
    - - - - - - - - - - - - - - '; - $i = 0; - // Mostra le righe delle passività - foreach ($liv2_patrimoniale as $liv2_p) { - if ($liv2_p['totale'] < 0) { - $totale_passivita += $liv2_p['totale']; - echo ' - - - - - '; - - foreach ($liv3_patrimoniale as $liv3_p) { - if ($liv2_p['id'] == $liv3_p['idpianodeiconti2']) { - echo ' - - - - - '; - } - } - if ($liv2_p['descrizione'] == 'Crediti clienti e crediti diversi') { - echo ' - - - - - '; - } elseif ($liv2_p['descrizione'] == 'Debiti fornitori e debiti diversi') { - echo ' - - - - - '; - } - } - } - echo ' - - - - '; - if ($utile_perdita < 0) { - echo ' - - - - - - - - '; - } - echo ' - -
    Passività
    CONTODESCRIZIONESALDO
    '.$liv2_p['numero'].''.$liv2_p['descrizione'].''.numberFormat(abs($liv2_p['totale'])).'
    '.$liv3_p['numero'].''.$liv3_p['descrizione'].''.numberFormat(abs($liv3_p['totale'])).'
    Clienti'.numberFormat(abs($crediti_clienti)).'
    Fornitori'.numberFormat(abs($debiti_fornitori)).'
    Totale Passività
    '.numberFormat(abs($totale_passivita)).'
    Utile
    '.numberFormat(abs($utile_perdita)).'
    Totale a pareggio
    '.numberFormat(abs($totale_passivita) + abs($utile_perdita)).'
    - -
    -
    '; - -// Conto economico -echo ' - -

    Conto Economico

    - -
    - -
    - - - - - - - - - - - - - - '; - // Mostra le righe dei costi - foreach ($liv2_economico as $liv2_e) { - if ($liv2_e['totale'] > 0) { - $totale_costi += $liv2_e['totale']; - echo ' - - - - - - '; - - foreach ($liv3_economico as $liv3_e) { - if ($liv2_e['id'] == $liv3_e['idpianodeiconti2']) { - echo ' - - - - - - '; - } - } - } - } - echo ' - - - - - '; - if ($utile_perdita < 0) { - echo ' - - - - - - - - - - '; - } - echo ' - -
    Costi
    CONTODESCRIZIONESALDOREDDITO
    '.$liv2_e['numero'].''.$liv2_e['descrizione'].''.numberFormat($liv2_e['totale']).''.numberFormat($liv2_e['totale_reddito']).'
    '.$liv3_e['numero'].''.$liv3_e['descrizione'].''.numberFormat($liv3_e['totale']).''.numberFormat($liv3_e['totale_reddito']).'
    Totale costi
    '.numberFormat(abs($totale_costi)).'
    Utile
    '.numberFormat(abs($utile_perdita)).'
    Totale a pareggio
    '.numberFormat(abs($totale_costi) + abs($utile_perdita)).'
    -
    - -
    - - - - - - - - - - - - - - '; - // Mostra le righe dei ricavi - foreach ($liv2_economico as $liv2_e) { - if ($liv2_e['totale'] < 0) { - $totale_ricavi += $liv2_e['totale']; - echo ' - - - - - - '; - - foreach ($liv3_economico as $liv3_e) { - if ($liv2_e['id'] == $liv3_e['idpianodeiconti2']) { - echo ' - - - - - - '; - } - } - } - } - echo ' - - - - - '; - if ($utile_perdita > 0) { - echo ' - - - - - - - - - '; - } - echo ' - -
    Ricavi
    CONTODESCRIZIONESALDOREDDITO
    '.$liv2_e['numero'].''.$liv2_e['descrizione'].''.numberFormat(abs($liv2_e['totale'])).''.numberFormat(abs($liv2_e['totale_reddito'])).'
    '.$liv3_e['numero'].''.$liv3_e['descrizione'].''.numberFormat(abs($liv3_e['totale'])).''.numberFormat(abs($liv3_e['totale_reddito'])).'
    Totale ricavi
    '.numberFormat(abs($totale_ricavi)).'
    Perdita
    '.numberFormat(abs($utile_perdita)).'
    Totale a pareggio
    '.numberFormat(abs($totale_ricavi) + abs($utile_perdita)).'
    - -
    -
    '; diff --git a/templates/bilancio/header.php b/templates/bilancio/header.php deleted file mode 100644 index 5df6af131..000000000 --- a/templates/bilancio/header.php +++ /dev/null @@ -1,25 +0,0 @@ -. - */ - -echo ' -
    -
    STAMPA BILANCIO '.dateFormat($date_start).' - '.dateFormat($date_end).'
    -
    '.$azienda['ragione_sociale'].'
    -

    -

    ESERCIZIO '.$esercizio.'


    '; diff --git a/templates/bilancio/init.php b/templates/bilancio/init.php deleted file mode 100644 index d25037a35..000000000 --- a/templates/bilancio/init.php +++ /dev/null @@ -1,82 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Carbon\Carbon; - -$azienda = $dbo->fetchOne('SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica='.setting('Azienda predefinita')); -$date_start = $_SESSION['period_start']; -$date_end = $_SESSION['period_end']; -$esercizio = new Carbon($date_start); -$esercizio = $esercizio->format('Y'); - -$liv2_patrimoniale = $dbo->fetchArray('SELECT co_pianodeiconti2.numero AS numero, co_pianodeiconti2.descrizione AS descrizione, SUM(totale) AS totale, co_pianodeiconti2.id AS id FROM `co_movimenti` INNER JOIN co_pianodeiconti3 ON co_movimenti.idconto=co_pianodeiconti3.id INNER JOIN co_pianodeiconti2 ON co_pianodeiconti3.idpianodeiconti2=co_pianodeiconti2.id WHERE idconto IN(SELECT id FROM co_pianodeiconti3 WHERE idpianodeiconti2 IN(SELECT id FROM co_pianodeiconti2 WHERE idpianodeiconti1=(SELECT id FROM co_pianodeiconti1 WHERE descrizione="Patrimoniale"))) AND co_movimenti.data>='.prepare($date_start).' AND co_movimenti.data<='.prepare($date_end).' GROUP BY idpianodeiconti2 ORDER BY co_pianodeiconti2.numero'); - -$liv2_economico = $dbo->fetchArray('SELECT co_pianodeiconti2.numero AS numero, co_pianodeiconti2.descrizione AS descrizione, SUM(totale) AS totale, SUM(totale_reddito) AS totale_reddito, co_pianodeiconti2.id AS id FROM `co_movimenti` INNER JOIN co_pianodeiconti3 ON co_movimenti.idconto=co_pianodeiconti3.id INNER JOIN co_pianodeiconti2 ON co_pianodeiconti3.idpianodeiconti2=co_pianodeiconti2.id WHERE idconto IN(SELECT id FROM co_pianodeiconti3 WHERE idpianodeiconti2 IN(SELECT id FROM co_pianodeiconti2 WHERE idpianodeiconti1=(SELECT id FROM co_pianodeiconti1 WHERE descrizione="Economico"))) AND co_movimenti.data>='.prepare($date_start).' AND co_movimenti.data<='.prepare($date_end).' GROUP BY idpianodeiconti2 ORDER BY co_pianodeiconti2.numero'); - -$liv3_patrimoniale = $dbo->fetchArray('SELECT co_pianodeiconti3.numero AS numero, co_pianodeiconti3.descrizione AS descrizione, SUM(totale) AS totale, co_pianodeiconti3.idpianodeiconti2 AS idpianodeiconti2 FROM `co_movimenti` INNER JOIN co_pianodeiconti3 ON co_movimenti.idconto=co_pianodeiconti3.id INNER JOIN co_pianodeiconti2 ON co_pianodeiconti3.idpianodeiconti2=co_pianodeiconti2.id WHERE idconto IN(SELECT id FROM co_pianodeiconti3 WHERE idpianodeiconti2 IN(SELECT id FROM co_pianodeiconti2 WHERE idpianodeiconti1=(SELECT id FROM co_pianodeiconti1 WHERE descrizione="Patrimoniale"))) AND idpianodeiconti2!='.prepare($fornitori).' AND co_pianodeiconti3.id NOT IN (SELECT idconto_cliente FROM an_anagrafiche) AND co_pianodeiconti3.id NOT IN (SELECT idconto_fornitore FROM an_anagrafiche) AND co_movimenti.data>='.prepare($date_start).' AND co_movimenti.data<='.prepare($date_end).' GROUP BY idconto ORDER BY co_pianodeiconti3.numero'); - -$liv3_economico = $dbo->fetchArray('SELECT co_pianodeiconti3.numero AS numero, co_pianodeiconti3.descrizione AS descrizione, SUM(totale) AS totale, SUM(totale_reddito) AS totale_reddito, co_pianodeiconti3.idpianodeiconti2 AS idpianodeiconti2 FROM `co_movimenti` INNER JOIN co_pianodeiconti3 ON co_movimenti.idconto=co_pianodeiconti3.id INNER JOIN co_pianodeiconti2 ON co_pianodeiconti3.idpianodeiconti2=co_pianodeiconti2.id WHERE idconto IN(SELECT id FROM co_pianodeiconti3 WHERE idpianodeiconti2 IN(SELECT id FROM co_pianodeiconti2 WHERE idpianodeiconti1=(SELECT id FROM co_pianodeiconti1 WHERE descrizione="Economico"))) AND co_movimenti.data>='.prepare($date_start).' AND co_movimenti.data<='.prepare($date_end).' GROUP BY idconto ORDER BY co_pianodeiconti3.numero'); - -$utile_perdita = $dbo->fetchOne('SELECT SUM(totale) AS totale FROM `co_movimenti` WHERE idconto IN(SELECT id FROM co_pianodeiconti3 WHERE idpianodeiconti2 IN(SELECT id FROM co_pianodeiconti2 WHERE idpianodeiconti1=(SELECT id FROM co_pianodeiconti1 WHERE descrizione="Economico")))AND co_movimenti.data>='.prepare($date_start).' AND co_movimenti.data<='.prepare($date_end))['totale']; - -$debiti_fornitori = $dbo->fetchArray(' -SELECT - co_pianodeiconti3.numero AS numero, - co_pianodeiconti3.descrizione AS descrizione, - SUM(totale) AS totale, - co_pianodeiconti3.idpianodeiconti2 AS idpianodeiconti2 -FROM - `co_movimenti` - INNER JOIN co_pianodeiconti3 ON co_movimenti.idconto=co_pianodeiconti3.id - INNER JOIN co_pianodeiconti2 ON co_pianodeiconti3.idpianodeiconti2=co_pianodeiconti2.id -WHERE - co_pianodeiconti2.descrizione="Debiti fornitori e debiti diversi" - AND co_pianodeiconti3.id IN (SELECT idconto_fornitore FROM an_anagrafiche) - AND co_movimenti.data>='.prepare($date_start).' - AND co_movimenti.data<='.prepare($date_end).' -GROUP BY - idconto -ORDER BY - co_pianodeiconti2.numero'); - -$debiti_fornitori = sum(array_column($debiti_fornitori, 'totale')); - -$crediti_clienti = $dbo->fetchArray(' -SELECT - co_pianodeiconti3.numero AS numero, - co_pianodeiconti3.descrizione AS descrizione, - SUM(totale) AS totale, - co_pianodeiconti3.idpianodeiconti2 AS idpianodeiconti2 -FROM - `co_movimenti` - INNER JOIN co_pianodeiconti3 ON co_movimenti.idconto=co_pianodeiconti3.id - INNER JOIN co_pianodeiconti2 ON co_pianodeiconti3.idpianodeiconti2=co_pianodeiconti2.id -WHERE - co_pianodeiconti2.descrizione="Crediti clienti e crediti diversi" - AND co_pianodeiconti3.id IN (SELECT idconto_cliente FROM an_anagrafiche) - AND co_movimenti.data>='.prepare($date_start).' - AND co_movimenti.data<='.prepare($date_end).' -GROUP BY - idconto -ORDER BY - co_pianodeiconti2.numero'); - -$crediti_clienti = sum(array_column($crediti_clienti, 'totale')); diff --git a/templates/bilancio/settings.php b/templates/bilancio/settings.php deleted file mode 100644 index 57ae9b00d..000000000 --- a/templates/bilancio/settings.php +++ /dev/null @@ -1,7 +0,0 @@ - 'A4', - 'orientation' => 'P', - 'font-size' => '9px', -]; diff --git a/templates/contratti/body.php b/templates/contratti/body.php deleted file mode 100755 index 6bf221990..000000000 --- a/templates/contratti/body.php +++ /dev/null @@ -1,385 +0,0 @@ -. - */ - -use Carbon\CarbonInterval; - -include_once __DIR__.'/../../core.php'; - -// Creazione righe fantasma -$autofill = new \Util\Autofill($options['pricing'] ? 4 : 2); -$autofill->setRows(20, 10); - -echo ' -
    -
    -
    -

    - '.tr('Contratto num. _NUM_ del _DATE_', [ - '_NUM_' => $documento['numero'], - '_DATE_' => Translator::dateToLocale($documento['data_bozza']), - ], ['upper' => true]).' -
    '; - -// Elenco impianti -$impianti = $dbo->fetchArray('SELECT nome, matricola FROM my_impianti WHERE id IN (SELECT my_impianti_contratti.idimpianto FROM my_impianti_contratti WHERE idcontratto = '.prepare($documento['id']).')'); -if (!empty($impianti)) { - $list = []; - foreach ($impianti as $impianto) { - $list[] = $impianto['nome']." (".$impianto['matricola'].')'; - } - - echo ' -
    -

    '.tr('Impianti', [], ['upper' => true]).'

    -

    '.implode(', ', $list).'

    '; -} - -echo ' -
    - -
    - - - - - - - - - - - - - - '; - - if (!empty($destinazione)) { - echo ' - - - '; - } - echo ' -
    -

    '.tr('Spett.le', [], ['upper' => true]).'

    -

    $c_ragionesociale$

    -

    $c_indirizzo$

    -

    $c_citta_full$

    -
    -

    '.tr('Partita IVA', [], ['upper' => true]).'

    -
    - $c_piva$ -
    -

    '.tr('Codice fiscale', [], ['upper' => true]).'

    -
    - $c_codicefiscale$ -
    -

    '.tr('Destinazione diversa', [], ['upper' => true]).'

    - '.$destinazione.' -
    -
    -
    '; - -// Descrizione -if (!empty($documento['descrizione'])) { - echo ' -

    '.nl2br($documento['descrizione']).'

    -
    '; -} - -// Intestazione tabella per righe -echo " - - - - - '; - -if ($options['pricing']) { - echo " - - '; -} - -echo ' - - - - '; - -// Righe documento -$righe = $documento->getRighe(); -foreach ($righe as $riga) { - $r = $riga->toArray(); - - $autofill->count($r['descrizione']); - - echo ' - - '; - - if (!$riga->isDescrizione()) { - echo ' - '; - - if ($options['pricing']) { - // Prezzo unitario - echo ' - '; - - // Imponibile - echo ' - '; - } - } else { - echo ' - '; - - if ($options['pricing']) { - echo ' - - '; - } - } - - echo ' - '; - - $autofill->next(); -} - -echo ' - |autofill| - '; - -// Calcoli -$imponibile = $documento->imponibile; -$sconto = $documento->sconto; -$totale_imponibile = $documento->totale_imponibile; -$totale_iva = $documento->iva; -$totale = $documento->totale; -$sconto_finale = $documento->getScontoFinale(); -$netto_a_pagare = $documento->netto; - -$show_sconto = $sconto > 0; - -// TOTALE COSTI FINALI -if ($options['pricing']) { - // Totale imponibile - echo ' - - - - - '; - - // Eventuale sconto incondizionato - if ($show_sconto) { - echo ' - - - - - '; - - // Totale imponibile - echo ' - - - - - '; - } - - // IVA - echo ' - - - - - '; - - // TOTALE - echo ' - - - - '; - - if ($sconto_finale) { - // SCONTO FINALE - echo ' - - - - '; - - // NETTO A PAGARE - echo ' - - - - '; - } -} -echo ' -
    ".tr('Descrizione', [], ['upper' => true])."".tr('Q.tà', [], ['upper' => true]).'".tr('Prezzo unitario', [], ['upper' => true])."".tr('Imponibile', [], ['upper' => true]).'
    - '.nl2br($r['descrizione']); - - if ($riga->isArticolo()) { - // Codice articolo - $text = tr('COD. _COD_', [ - '_COD_' => $riga->codice, - ]); - echo ' -
    '.$text.''; - - $autofill->count($text, true); - } - - echo ' -
    - '.Translator::numberToLocale(abs($riga->qta), 'qta').' '.$r['um'].' - - '.moneyFormat($riga->prezzo_unitario); - - if ($riga->sconto > 0) { - $text = discountInfo($riga, false); - - echo ' -
    '.$text.''; - - $autofill->count($text, true); - } - - echo ' -
    - '.moneyFormat($riga->totale_imponibile).' -
    - '.tr('Imponibile', [], ['upper' => true]).': - - '.moneyFormat($show_sconto ? $imponibile : $totale_imponibile, 2).' -
    - '.tr('Sconto', [], ['upper' => true]).': - - '.moneyFormat($sconto, 2).' -
    - '.tr('Totale imponibile', [], ['upper' => true]).': - - '.moneyFormat($totale_imponibile, 2).' -
    - '.tr('Totale IVA', [], ['upper' => true]).': - - '.moneyFormat($totale_iva, 2).' -
    - '.tr('Totale documento', [], ['upper' => true]).': - - '.moneyFormat($totale, 2).' -
    - '.tr('Sconto finale', [], ['upper' => true]).': - - '.moneyFormat($sconto_finale, 2).' -
    - '.tr('Netto a pagare', [], ['upper' => true]).': - - '.moneyFormat($netto_a_pagare, 2).' -
    '; - -// CONDIZIONI GENERALI DI FORNITURA -$pagamento = $dbo->fetchOne('SELECT * FROM co_pagamenti WHERE id = '.$documento['idpagamento']); - -echo ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - '.tr('Condizioni generali di fornitura', [], ['upper' => true]).' -
    - '.tr('Pagamento', [], ['upper' => true]).' - - '.$pagamento['descrizione'].' -
    - '.tr('Validità offerta', [], ['upper' => true]).' - '; - - if (!empty($documento->validita) && !empty($documento->tipo_validita)) { - $intervallo = CarbonInterval::make($documento->validita.' '.$documento->tipo_validita); - - echo $intervallo->forHumans(); - } elseif (!empty($documento->validita)) { - echo tr('_TOT_ giorni', [ - '_TOT_' => $documento->validita, - ]); - } else { - echo '-'; - } - - echo ' -
    - '.tr('Validità contratto', [], ['upper' => true]).' - '; - - if (!empty($documento['data_accettazione']) && !empty($documento['data_conclusione'])) { - echo ' - '.tr('dal _START_ al _END_', [ - '_START_' => Translator::dateToLocale($documento['data_accettazione']), - '_END_' => Translator::dateToLocale($documento['data_conclusione']), - ]); - } else { - echo '-'; - } - - echo ' -
    - '.tr('Esclusioni', [], ['upper' => true]).' - - '.nl2br($documento['esclusioni']).' -
    '; - -// Conclusione -if (empty($documento->stato->fatturabile)) { - echo ' -

    '.tr('Il tutto S.E. & O.').'

    -

    '.tr("In attesa di un Vostro Cortese riscontro, colgo l'occasione per porgere Cordiali Saluti").'

    '; -} diff --git a/templates/contratti/footer.php b/templates/contratti/footer.php deleted file mode 100755 index 81623bfaf..000000000 --- a/templates/contratti/footer.php +++ /dev/null @@ -1,37 +0,0 @@ -. - */ - -if (!$is_last_page) { - return; -} - -echo ' - - - - - - -
    - '.tr('lì').', ___________________________ - - '.tr('Firma per accettazione', [], ['upper' => true]).'

    - _____________________________________________ -
    -
    '; diff --git a/templates/contratti/init.php b/templates/contratti/init.php deleted file mode 100755 index 6132d95b3..000000000 --- a/templates/contratti/init.php +++ /dev/null @@ -1,57 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Contratti\Contratto; - -$documento = Contratto::find($id_record); - -$id_cliente = $documento['idanagrafica']; - -// Leggo i dati della destinazione (se 0=sede legale, se!=altra sede da leggere da tabella an_sedi) -$destinazione = ''; -if (!empty($documento->idsede)) { - $rsd = $dbo->fetchArray('SELECT (SELECT codice FROM an_anagrafiche WHERE idanagrafica=an_sedi.idanagrafica) AS codice, (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=an_sedi.idanagrafica) AS ragione_sociale, nomesede, indirizzo, indirizzo2, cap, citta, provincia, piva, codice_fiscale, id_nazione FROM an_sedi WHERE idanagrafica='.prepare($id_cliente).' AND id='.prepare($documento->idsede)); - - if (!empty($rsd[0]['nomesede'])) { - $destinazione .= $rsd[0]['nomesede'].'
    '; - } - if (!empty($rsd[0]['indirizzo'])) { - $destinazione .= $rsd[0]['indirizzo'].'
    '; - } - if (!empty($rsd[0]['indirizzo2'])) { - $destinazione .= $rsd[0]['indirizzo2'].'
    '; - } - if (!empty($rsd[0]['cap'])) { - $destinazione .= $rsd[0]['cap'].' '; - } - if (!empty($rsd[0]['citta'])) { - $destinazione .= $rsd[0]['citta']; - } - if (!empty($rsd[0]['provincia'])) { - $destinazione .= ' ('.$rsd[0]['provincia'].')'; - } - if (!empty($rsd[0]['id_nazione'])) { - $nazione = $database->fetchOne('SELECT * FROM an_nazioni WHERE id = '.prepare($rsd[0]['id_nazione'])); - if ($nazione['iso2'] != 'IT') { - $destinazione .= ' - '.$nazione['name']; - } - } -} diff --git a/templates/contratti/settings.php b/templates/contratti/settings.php deleted file mode 100755 index bcd7fc26d..000000000 --- a/templates/contratti/settings.php +++ /dev/null @@ -1,22 +0,0 @@ -. - */ - -return [ - 'footer-height' => 35, -]; diff --git a/templates/contratti_cons/bottom.php b/templates/contratti_cons/bottom.php deleted file mode 100755 index e208c34d8..000000000 --- a/templates/contratti_cons/bottom.php +++ /dev/null @@ -1,86 +0,0 @@ -. - */ - -include_once __DIR__.'/../riepilogo_interventi/bottom.php'; - -$budget = get_imponibile_preventivo($id_record); - -$rapporto = floatval($budget) - floatval($somma_totale_imponibile); - -$rs = $dbo->fetchArray("SELECT SUM(qta) AS totale_ore FROM `co_righe_contratti` WHERE um='ore' AND idcontratto = ".prepare($id_record)); -$totale_ore = $rs[0]['totale_ore']; -$totale_ore_impiegate = $records->sum('ore_totali'); - -if ($pricing || !empty($totale_ore)) { - // Totale imponibile - echo ' -'; - if ($pricing && empty($options['dir'])) { - // TOTALE - echo ' - - - - '; - - // BUDGET - echo ' - - - - '; - - // RAPPORTO - echo ' - - - - '; - } - - // ORE RESIDUE - if (!empty($totale_ore)) { - echo ' - - - - '; - } - - echo ' -
    - '.tr('Totale consuntivo (no iva)', [], ['upper' => true]).': - - '.moneyFormat($somma_totale_imponibile).' -
    - '.tr('Budget (no IVA)', [], ['upper' => true]).': - - '.moneyFormat($budget).' -
    - '.tr('Rapporto budget/spesa (no IVA)', [], ['upper' => true]).': - - '.moneyFormat($rapporto).' -
    - '.tr('Ore residue', [], ['upper' => true]).': - - '.Translator::numberToLocale($totale_ore - $totale_ore_impiegate).'
    -

    '.tr('Ore erogate').': '.Translator::numberToLocale($totale_ore_impiegate).'

    -

    '.tr('Ore a contratto').': '.Translator::numberToLocale($totale_ore).'

    -
    '; -} diff --git a/templates/contratti_cons/init.php b/templates/contratti_cons/init.php deleted file mode 100755 index 58a69d130..000000000 --- a/templates/contratti_cons/init.php +++ /dev/null @@ -1,30 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Contratti\Contratto; - -$documento = Contratto::find($id_record); -$records = $documento->interventi; - -$id_cliente = $documento['idanagrafica']; -$id_sede = $documento['idsede']; - -$pricing = $options['pricing']; diff --git a/templates/contratti_cons/piece.php b/templates/contratti_cons/piece.php deleted file mode 100755 index adadc8f55..000000000 --- a/templates/contratti_cons/piece.php +++ /dev/null @@ -1,20 +0,0 @@ -. - */ - -include __DIR__.'/../riepilogo_interventi/piece.php'; diff --git a/templates/contratti_cons/top.php b/templates/contratti_cons/top.php deleted file mode 100755 index e6b444c09..000000000 --- a/templates/contratti_cons/top.php +++ /dev/null @@ -1,83 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo ' -
    -
    -
    -

    '.tr('Consuntivo', [], ['upper' => true]).'

    - '.tr('Contratto num. _NUM_ del _DATE_', [ - '_NUM_' => $documento['numero'], - '_DATE_' => Translator::dateToLocale($documento['data_bozza']), - ], ['upper' => true]).' -
    -
    - -
    - - - - - - - - - - - - - - -
    -

    '.tr('Spett.le', [], ['upper' => true]).'

    -

    $c_ragionesociale$

    -

    $c_indirizzo$ $c_citta_full$

    -
    -

    '.tr('Partita IVA', [], ['upper' => true]).'

    -
    - $c_piva$ -
    -

    '.tr('Codice fiscale', [], ['upper' => true]).'

    -
    - $c_codicefiscale$ -
    -
    -
    '; - -// Descrizione -if (!empty($documento['descrizione'])) { - echo ' -

    '.nl2br($documento['descrizione']).'

    -
    '; -} - -echo ' - - - - - - - - - - - '; diff --git a/templates/dashboard/body.php b/templates/dashboard/body.php deleted file mode 100755 index 4a9ffd4b2..000000000 --- a/templates/dashboard/body.php +++ /dev/null @@ -1,184 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Carbon\Carbon; - -$calendar = $_SESSION['dashboard']; - -$date = $calendar['date']; -$date = new Carbon($date); - -if ($calendar['format'] == 'week') { - $period = explode(' ', $_SESSION['dashboard']['week']); - - $day = $period[0]; - - if (count($period) == 5) { - $maxmonth = $period[3]; - $maxday_ = $period[2]; - - $month = $period[3]; - $year = $period[4]; - } - - if (count($period) == 6) { - $maxmonth = $period[1]; - $maxday_ = $period[3]; - - $month = $period[4]; - $year = $period[5]; - } - - $months = ['gen' => '01', 'feb' => '02', 'mar' => '03', 'apr' => '04', 'mag' => '05', 'giu' => '06', 'lug' => '07', 'ago' => '08', 'set' => '09', 'ott' => '10', 'nov' => '11', 'dic' => '12']; - $month = $months[$month]; - $maxmonth = $months[$maxmonth]; - - $title = $_SESSION['dashboard']['week']; - - //numero di giorni nel mese - $maxday = cal_days_in_month(CAL_GREGORIAN, $month, $year) + 1; - - $min_date = $year.'-'.$month.'-'.$day; - $max_date = $year.'-'.$maxmonth.'-'.$maxday_; - - //aggiungo un giorno - $max_date = date('Y-m-d', date(strtotime('+1 day', strtotime($max_date)))); - - $where = ' (in_interventi_tecnici.orario_inizio) <= '.prepare($max_date).' AND (in_interventi_tecnici.orario_inizio) >= '.prepare($min_date).' AND '; -} else { - $title = $date->formatLocalized('%B %Y'); - - $min_date = $date->copy()->startOfMonth(); - $max_date = $date->copy()->endOfMonth(); - - $where = ' (in_interventi_tecnici.orario_inizio) <= '.prepare($max_date).' AND (in_interventi_tecnici.orario_inizio) >= '.prepare($min_date).' AND '; -} - -$height = '80'; - -$stati = (array) $calendar['idstatiintervento']; -$tipi = (array) $calendar['idtipiintervento']; -$tecnici = (array) $calendar['idtecnici']; - -$query = "SELECT - DATE(orario_inizio) AS data, - (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=in_interventi.idanagrafica) AS anagrafica, - GROUP_CONCAT((SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=in_interventi_tecnici.idtecnico) SEPARATOR ', ') AS tecnico -FROM in_interventi_tecnici - INNER JOIN in_interventi ON in_interventi_tecnici.idintervento=in_interventi.id - LEFT OUTER JOIN in_statiintervento ON in_interventi.idstatointervento=in_statiintervento.idstatointervento -WHERE ".$where.' - idtecnico IN('.implode(',', $tecnici).') AND - in_interventi.idstatointervento IN('.implode(',', $stati).') AND - in_interventi_tecnici.idtipointervento IN('.implode(',', $tipi).') '.Modules::getAdditionalsQuery('Interventi').' -GROUP BY in_interventi.id, data'; -$sessioni = $dbo->fetchArray($query); - -$sessioni = collect($sessioni)->groupBy('data'); - -// Intestazione tabella -echo ' -

    '.tr('Calendario _PERIOD_', [ - '_PERIOD_' => $title, -], ['upper' => true]).'

    '; - -// Elenco per la gestione -$list = []; - -// Filler per i giorni non inclusi della settimana iniziale -$week_start = $min_date->startOfWeek(); -$current_day = $week_start; -while ($current_day->lessThan($min_date)) { - $list[] = [ - 'date' => $current_day->copy(), - 'contents' => [], - ]; - - $current_day->addDay(); -} - -// Elenco del periodo indicato -while ($current_day->lessThan($max_date)) { - $list[] = [ - 'date' => $current_day->copy(), - 'contents' => $sessioni[$current_day->toDateString()] ?: [], - ]; - - $current_day->addDay(); -} - -// Filler per i giorni non inclusi della settimana finale -$week_end = $max_date->endOfWeek(); -while ($current_day->lessThan($week_end)) { - $list[] = [ - 'date' => $current_day->copy(), - 'contents' => [], - ]; - - $current_day->addDay(); -} - -// Stampa della tabella -echo ' -
    '.tr('Documento', [], ['upper' => true]).''.tr('Imponibile', [], ['upper' => true]).''.tr('Sconto', [], ['upper' => true]).''.tr('Totale imponibile', [], ['upper' => true]).'
    '; - -$count = count($list); -for ($i = 0; $i < $count; $i = $i + 7) { - echo ' - '; - - for ($c = 0; $c < 7; ++$c) { - $element = $list[$i + $c]; - - echo ' - '; - } - - echo ' - '; - - echo ' - '; - - for ($c = 0; $c < 7; ++$c) { - $element = $list[$i + $c]; - - $clienti = ''; - foreach ($element['contents'] as $sessione) { - $clienti .= $sessione['anagrafica'].'
    - '.$sessione['tecnico'].'
    '; - } - - $background = '#ffffff'; - if (empty($clienti)) { - $background = 'lightgray'; - } - - echo ' - '; - } - - echo ' - '; -} - -echo ' -
    '.ucfirst($element['date']->formatLocalized('%A %d/%m')).'
    '.$clienti.'
    '; diff --git a/templates/dashboard/header.php b/templates/dashboard/header.php deleted file mode 100755 index 340ebbd4e..000000000 --- a/templates/dashboard/header.php +++ /dev/null @@ -1,34 +0,0 @@ -. - */ - -echo ' - -
    -
    -

    $f_ragionesociale$

    -

    $f_indirizzo$ $f_citta_full$

    -

    '.(!empty($f_piva) ? tr('P.Iva').': ' : '').'$f_piva$

    -

    '.(!empty($f_codicefiscale) ? tr('C.F.').': ' : '').'$f_codicefiscale$

    -

    '.(!empty($f_capsoc) ? tr('Cap.Soc.').': ' : '').'$f_capsoc$

    -

    '.(!empty($f_telefono) ? tr('Tel').': ' : '').'$f_telefono$

    -
    -
    - Logo -
    -
    '; diff --git a/templates/dashboard/settings.php b/templates/dashboard/settings.php deleted file mode 100755 index 0eff70354..000000000 --- a/templates/dashboard/settings.php +++ /dev/null @@ -1,26 +0,0 @@ -. - */ - -$format = (isset($_SESSION['dashboard']['format'])) ? $_SESSION['dashboard']['format'] : 'A4'; -$orientation = (isset($_SESSION['dashboard']['orientation'])) ? $_SESSION['dashboard']['orientation'] : 'L'; - -return [ - 'format' => $format, - 'orientation' => $orientation, -]; diff --git a/templates/ddt/body.php b/templates/ddt/body.php deleted file mode 100755 index db52c1ead..000000000 --- a/templates/ddt/body.php +++ /dev/null @@ -1,192 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -// Creazione righe fantasma -$autofill = new \Util\Autofill($options['pricing'] ? 7 : 4); -$rows_per_page = 16; -if (!empty($options['last-page-footer'])) { - $rows_per_page += 10; -} -$autofill->setRows($rows_per_page); - -// Intestazione tabella per righe -echo " - - - - - - - '; - -if ($options['pricing']) { - echo " - - - '; -} - - echo ' - - - - '; - -// Righe documento -$righe = $documento->getRighe(); -$num = 0; -foreach ($righe as $riga) { - ++$num; - $r = $riga->toArray(); - - $autofill->count($r['descrizione']); - - echo ' - - - - - - '; - - if (!$riga->isDescrizione()) { - echo ' - '; - - if ($options['pricing']) { - // Prezzo unitario - echo ' - '; - - // Imponibile - echo ' - '; - - // Iva - echo ' - '; - } - } else { - echo ' - '; - - if ($options['pricing']) { - echo ' - - - '; - } - } - - echo ' - '; - - $autofill->next(); -} - -echo ' - |autofill| - -
    ".tr('#', [], ['upper' => true])."".tr('Cod.', [], ['upper' => true])."".tr('Descrizione', [], ['upper' => true])."".tr('Q.tà', [], ['upper' => true]).'".tr('Prezzo unitario', [], ['upper' => true])."".tr('Importo', [], ['upper' => true])."".tr('IVA', [], ['upper' => true]).' (%)
    - '.$num.' - '; - - $source_type = get_class($riga); - if ($riga->isArticolo()) { - echo $riga->codice; - } else { - echo '-'; - } - - echo ' - - '.nl2br($r['descrizione']); - - //Riferimenti odrini/ddt righe - if ($riga->referenceTargets()->count()) { - $source = $source_type::find($riga->id); - $riferimenti = $source->referenceTargets; - - foreach ($riferimenti as $riferimento) { - $documento_riferimento = $riferimento->target->getDocument(); - echo ' -
    '.$riferimento->target->descrizione.'
    '.tr('Rif. _DOCUMENT_', [ - '_DOCUMENT_' => strtolower($documento_riferimento->getReference()), - ]).'
    '; - } - } - - if ($riga->isArticolo()) { - // Codice articolo - $text = tr('COD. _COD_', [ - '_COD_' => $riga->codice, - ]); - echo ' -
    '.$text.''; - - $autofill->count($text, true); - - // Seriali - $seriali = $riga->serials; - if (!empty($seriali)) { - $text = tr('SN').': '.implode(', ', $seriali); - echo ' -
    '.$text.''; - - $autofill->count($text, true); - } - } - - // Aggiunta dei riferimenti ai documenti - /* - if (setting('Riferimento dei documenti nelle stampe') && $riga->hasOriginal()) { - $ref = $riga->getOriginal()->getDocument()->getReference(); - - if (!empty($ref)) { - echo ' -
    '.$ref.''; - - $autofill->count($ref, true); - } - } - */ - - echo ' -
    - '.Translator::numberToLocale(abs($riga->qta), 'qta').' '.$r['um'].' - - '.moneyFormat($riga->prezzo_unitario); - - if ($riga->sconto > 0) { - $text = discountInfo($riga, false); - - echo ' -
    '.$text.''; - - $autofill->count($text, true); - } - - echo ' -
    - '.moneyFormat($riga->totale_imponibile).' - - '.Translator::numberToLocale($riga->aliquota->percentuale, 0).' -
    '; diff --git a/templates/ddt/footer.php b/templates/ddt/footer.php deleted file mode 100755 index 57414fc2a..000000000 --- a/templates/ddt/footer.php +++ /dev/null @@ -1,242 +0,0 @@ -. - */ - -if (!empty($options['last-page-footer']) && !$is_last_page) { - return; -} - -// Calcoli -$imponibile = $documento->imponibile; -$sconto = $documento->sconto; -$totale_imponibile = $documento->totale_imponibile; -$totale_iva = $documento->iva; -$totale = $documento->totale; -$sconto_finale = $documento->getScontoFinale(); -$netto_a_pagare = $documento->netto; - -$volume = $documento->volume ?: $documento->volume_calcolato; -$peso_lordo = $documento->peso ?: $documento->peso_calcolato; - -// TABELLA PRINCIPALE -echo ' -'; - -if ($options['pricing']) { - // Riga 1 - echo " - - - - '; - - // Dati riga 1 - echo " - - - '; - - // Riga 2 - echo " - - - - - - - '; - - // Riga 3 - echo " - - - - - - - '; - - if ($sconto_finale) { - // Riga 4 SCONTO FINALE - echo " - - - - - - - '; - - // Riga 5 NETTO A PAGARE - echo " - - - - - - - '; - } -} else { - // Riga 1 - echo " - - - '; -} - -echo ' -
    -

    ".tr('Note', [], ['upper' => true]).'

    -

    '.nl2br($documento['note'])."

    -
    -

    ".tr('Totale imponibile', [], ['upper' => true]).'

    -
    - ".moneyFormat($totale_imponibile, 2).' -
    -

    ".tr('Totale IVA', [], ['upper' => true])."

    -
    - ".moneyFormat($totale_iva, 2).' -
    -

    ".tr('Totale documento', [], ['upper' => true])."

    -
    - ".moneyFormat($totale, 2).' -
    -

    ".tr('Sconto finale', [], ['upper' => true])."

    -
    - ".moneyFormat($sconto_finale, 2).' -
    -

    ".tr('Netto a pagare', [], ['upper' => true])."

    -
    - ".moneyFormat($netto_a_pagare, 2).' -
    -

    ".tr('Note', [], ['upper' => true]).'

    - '.nl2br($documento['note']).' -
    '; - -// Informazioni aggiuntive -echo ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - '.tr('Aspetto beni', [], ['upper' => true]).' - - '.tr('Num. colli', [], ['upper' => true]).' - - '.tr('Data ora trasporto', [], ['upper' => true]).' - - '.tr('Causale trasporto', [], ['upper' => true]).' - - '.tr('Porto', [], ['upper' => true]).' -
    - $aspettobeni$   - - $n_colli$   - - '.Translator::TimestampToLocale($documento['data_ora_trasporto']).'   - - $causalet$   - - $porto$   -
    - '.tr('Peso lordo', [], ['upper' => true]).' - - '.tr('Volume', [], ['upper' => true]).' - - '.tr('Vettore', [], ['upper' => true]).' - - '.tr('Tipo di spedizione', [], ['upper' => true]).' -
    - '.(!empty($peso_lordo) ? Translator::numberToLocale($peso_lordo).' KG' : '').' - - '.(!empty($volume) ? Translator::numberToLocale($volume).' M3' : '').' - - $vettore$   - - $spedizione$   -
    '; - -// Firme -echo ' - - - - - - - - - - - - - - -
    - '.tr('Firma conducente', [], ['upper' => true]).' - - '.tr('Firma vettore', [], ['upper' => true]).' - - '.tr('Firma destinatario', [], ['upper' => true]).' -
    '; - -if (empty($options['last-page-footer'])) { - echo '$default_footer$'; -} diff --git a/templates/ddt/header.php b/templates/ddt/header.php deleted file mode 100755 index e50a164ee..000000000 --- a/templates/ddt/header.php +++ /dev/null @@ -1,97 +0,0 @@ -. - */ - -echo ' - -$default_header$ - -
    - -
    -
    - '.tr('DDT').' -
    - - - - - - - - - - - - - - - - - - - - -
    -

    '.tr('Nr. documento', [], ['upper' => true]).'

    -

    $numero$

    -
    -

    '.tr('Data documento', [], ['upper' => true]).'

    -

    $data$

    -
    -

    '.tr('Cliente', [], ['upper' => true]).'

    -

    $c_codice$

    -
    -

    '.tr('Foglio', [], ['upper' => true]).'

    -

    {PAGENO}/{nb}

    -
    -

    '.tr('Pagamento', [], ['upper' => true]).'

    -

    $pagamento$

    -
    -

    '.tr('Partita IVA', [], ['upper' => true]).'

    - $c_piva$ -
    -

    '.tr('Codice fiscale', [], ['upper' => true]).'

    - $c_codicefiscale$ -
    -
    - -
    - - - - '; - -if (!empty($destinazione)) { - echo ' - - - '; -} - -echo ' -
    -

    '.tr('Spett.le', [], ['upper' => true]).'

    -

    $c_ragionesociale$

    -

    $c_indirizzo$
    $c_citta_full$

    -
    -

    '.tr('Destinazione diversa', [], ['upper' => true]).'

    - $c_destinazione$ -
    -
    -
    '; diff --git a/templates/ddt/init.php b/templates/ddt/init.php deleted file mode 100755 index 46e070411..000000000 --- a/templates/ddt/init.php +++ /dev/null @@ -1,103 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\DDT\DDT; - -$documento = DDT::find($id_record); - -$id_cliente = $documento['idanagrafica']; -$id_sede = $record['idsede_partenza']; - -$pagamento = $dbo->fetchOne('SELECT * FROM co_pagamenti WHERE id = '.prepare($documento['idpagamento'])); -$causale = $dbo->fetchOne('SELECT * FROM dt_causalet WHERE id = '.prepare($documento['idcausalet'])); -$porto = $dbo->fetchOne('SELECT * FROM dt_porto WHERE id = '.prepare($documento['idporto'])); -$aspetto_beni = $dbo->fetchOne('SELECT * FROM dt_aspettobeni WHERE id = '.prepare($documento['idaspettobeni'])); -$spedizione = $dbo->fetchOne('SELECT * FROM dt_spedizione WHERE id = '.prepare($documento['idspedizione'])); - -$vettore = $dbo->fetchOne('SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica = '.prepare($documento['idvettore'])); - -$tipo_doc = $documento->tipo->descrizione; -if (empty($documento['numero_esterno'])) { - $numero = 'pro-forma '.$numero; - $tipo_doc = tr('DDT pro-forma', [], ['upper' => true]); -} else { - $numero = !empty($documento['numero_esterno']) ? $documento['numero_esterno'] : $documento['numero']; -} - -// Leggo i dati della destinazione (se 0=sede legale, se!=altra sede da leggere da tabella an_sedi) -$destinazione = ''; -if (!empty($documento['idsede_destinazione'])) { - $rsd = $dbo->fetchArray('SELECT (SELECT codice FROM an_anagrafiche WHERE idanagrafica=an_sedi.idanagrafica) AS codice, (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=an_sedi.idanagrafica) AS ragione_sociale, nomesede, indirizzo, indirizzo2, cap, citta, provincia, piva, codice_fiscale, id_nazione, telefono, cellulare FROM an_sedi WHERE idanagrafica='.prepare($id_cliente).' AND id='.prepare($documento['idsede_destinazione'])); - - if (!empty($rsd[0]['nomesede'])) { - $destinazione .= $rsd[0]['nomesede'].'
    '; - } - if (!empty($rsd[0]['indirizzo'])) { - $destinazione .= $rsd[0]['indirizzo'].'
    '; - } - if (!empty($rsd[0]['indirizzo2'])) { - $destinazione .= $rsd[0]['indirizzo2'].'
    '; - } - if (!empty($rsd[0]['cap'])) { - $destinazione .= $rsd[0]['cap'].' '; - } - if (!empty($rsd[0]['citta'])) { - $destinazione .= $rsd[0]['citta']; - } - if (!empty($rsd[0]['provincia'])) { - $destinazione .= ' ('.$rsd[0]['provincia'].')'; - } - if (!empty($rsd[0]['id_nazione'])) { - $nazione = $database->fetchOne('SELECT * FROM an_nazioni WHERE id = '.prepare($rsd[0]['id_nazione'])); - if ($nazione['iso2'] != 'IT') { - $destinazione .= ' - '.$nazione['name'].'
    '; - } - } - if (!empty($rsd[0]['telefono'])) { - $destinazione .= 'Tel: '.$rsd[0]['telefono'].'
    '; - } - if (!empty($rsd[0]['cellualre'])) { - $destinazione .= 'Cell: '.$rsd[0]['cellulare']; - } -} - -// Sostituzioni specifiche -$custom = [ - 'tipo_doc' => $tipo_doc, - 'numero' => $numero, - 'data' => Translator::dateToLocale($documento['data']), - 'pagamento' => $pagamento['descrizione'], - 'c_destinazione' => $destinazione, - 'aspettobeni' => $aspetto_beni['descrizione'], - 'causalet' => $causale['descrizione'], - 'porto' => $porto['descrizione'], - 'n_colli' => !empty($documento['n_colli']) ? $documento['n_colli'] : '', - 'spedizione' => $spedizione['descrizione'], - 'vettore' => $vettore['ragione_sociale'], -]; - -// Accesso solo a: -// - cliente se è impostato l'idanagrafica di un Cliente -// - utente qualsiasi con permessi almeno in lettura sul modulo -// - admin -if ((Auth::user()['gruppo'] == 'Clienti' && $id_cliente != Auth::user()['idanagrafica'] && !Auth::admin()) || Modules::getPermission($documento->module) == '-') { - exit(tr('Non hai i permessi per questa stampa!')); -} diff --git a/templates/fatturato/body.php b/templates/fatturato/body.php deleted file mode 100755 index 3b5a13afe..000000000 --- a/templates/fatturato/body.php +++ /dev/null @@ -1,88 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if ($dir == 'entrata') { - $title = tr('Fatturato mensile dal _START_ al _END_', [ - '_START_' => Translator::dateToLocale($date_start), - '_END_' => Translator::dateToLocale($date_end), - ], ['upper' => true]); -} else { - $title = tr('Acquisti mensili dal _START_ al _END_', [ - '_START_' => Translator::dateToLocale($date_start), - '_END_' => Translator::dateToLocale($date_end), - ], ['upper' => true]); -} - -echo ' -

    '.$title.'

    '; - -// Intestazione tabella per righe -echo ' - - - - - - - - - - - '; - -echo ' - '; - -$totale_imponibile = 0; -$totale_iva = 0; -$totale_finale = 0; - -// Nel fatturato totale è corretto NON tenere in considerazione eventuali rivalse, ritenute acconto o contributi. -foreach ($raggruppamenti as $raggruppamento) { - $data = new \Carbon\Carbon($raggruppamento['data']); - $mese = ucfirst($data->formatLocalized('%B %Y')); - - $imponibile = $raggruppamento['imponibile']; - $iva = $raggruppamento['iva']; - $totale = $raggruppamento['totale']; - - echo ' - - - - - - '; - - $totale_imponibile += $imponibile; - $totale_iva += $iva; - $totale_finale += $totale; -} - -echo ' - - - - - - - -
    '.tr('Mese').''.tr('Imponibile').''.tr('IVA').''.tr('Totale').'
    '.$mese.''.moneyFormat($imponibile).''.moneyFormat($iva).''.moneyFormat($totale).'
    '.tr('Totale', [], ['upper' => true]).':'.moneyFormat($totale_imponibile).''.moneyFormat($totale_iva).''.moneyFormat($totale_finale).'
    '; diff --git a/templates/fatturato/init.php b/templates/fatturato/init.php deleted file mode 100755 index 27fdc7c5d..000000000 --- a/templates/fatturato/init.php +++ /dev/null @@ -1,41 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$dir = get('dir'); -$date_start = $_SESSION['period_start']; -$date_end = $_SESSION['period_end']; - -// Raggruppamento -$query = "SELECT data, - DATE_FORMAT(data, '%m-%Y') AS periodo, - SUM(co_righe_documenti.subtotale - co_righe_documenti.sconto) as imponibile, - SUM(iva) as iva, - SUM(co_righe_documenti.subtotale - co_righe_documenti.sconto + iva) as totale -FROM co_documenti - INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento = co_tipidocumento.id - INNER JOIN co_righe_documenti ON co_righe_documenti.iddocumento = co_documenti.id -WHERE - (data >= ".prepare($date_start).' AND data <= '.prepare($date_end).') - AND dir = '.prepare($dir).' - '.$add_where.' -GROUP BY periodo -ORDER BY data ASC'; -$raggruppamenti = $dbo->fetchArray($query); diff --git a/templates/fatture/body.php b/templates/fatture/body.php deleted file mode 100755 index 257b97e7b..000000000 --- a/templates/fatture/body.php +++ /dev/null @@ -1,245 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$v_iva = []; -$v_totale = []; - -// Creazione righe fantasma -$autofill = new \Util\Autofill(6, 40); -$rows_per_page = $fattura_accompagnatoria ? 13 : 18; -if (!empty($options['last-page-footer'])) { - $rows_per_page += 7; -} -$autofill->setRows($rows_per_page); - -// Intestazione tabella per righe -echo " - - - - - - - - - - - - - '; - -// Righe documento -$righe = $documento->getRighe(); -$num = 0; -foreach ($righe as $riga) { - ++$num; - $r = $riga->toArray(); - - $autofill->count($r['descrizione']); - - $v_iva[$r['desc_iva']] = sum($v_iva[$r['desc_iva']], $riga->iva); - $v_totale[$r['desc_iva']] = sum($v_totale[$r['desc_iva']], $riga->totale_imponibile); - - echo ' - '; - - echo ' - '; - - echo ' - '; - - if (!$riga->isDescrizione()) { - echo ' - '; - - // Prezzo unitario - echo ' - '; - - // Imponibile - echo ' - '; - - // Iva - echo ' - '; - } else { - echo ' - - - - '; - } - - echo ' - '; - - $autofill->next(); -} - -echo ' - |autofill| - -
    ".tr('#', [], ['upper' => true])."".tr('Descrizione', [], ['upper' => true])."".tr('Q.tà', [], ['upper' => true])."".tr('Prezzo unitario', [], ['upper' => true])."".tr('Importo', [], ['upper' => true])."".tr('IVA', [], ['upper' => true]).' (%)
    - '.$num.' - - '.nl2br(strip_tags($riga->descrizione)); - - if ($riga->isArticolo()) { - // Codice articolo - $text = tr('COD. _COD_', [ - '_COD_' => $riga->codice, - ]); - echo ' -
    '.$text.''; - - $autofill->count($text, true); - - // Seriali - $seriali = $riga->serials; - if (!empty($seriali)) { - $text = tr('SN').': '.implode(', ', $seriali); - echo ' -
    '.$text.''; - - $autofill->count($text, true); - } - } - - // Aggiunta dei riferimenti ai documenti - if (!empty($record['ref_documento'])) { - $data = $dbo->fetchArray("SELECT IF(numero_esterno != '', numero_esterno, numero) AS numero, data FROM co_documenti WHERE id = ".prepare($record['ref_documento'])); - - $text = tr('Rif. fattura _NUM_ del _DATE_', [ - '_NUM_' => $data[0]['numero'], - '_DATE_' => Translator::dateToLocale($data[0]['data']), - ]); - - echo ' -
    '.$text.''; - - $autofill->count($text, true); - } - - // Aggiunta dei riferimenti ai documenti - /* - if (setting('Riferimento dei documenti nelle stampe') && $riga->hasOriginal()) { - $ref = $riga->getOriginal()->getDcocument()->getReference(); - if (!empty($riga->getOriginal()->getDcocument()->numero_cliente)) { - $ref .= '
    '.tr('_DOC_ num. _NUM_ del _DATE_', [ - '_DOC_' => 'Rif. Vs. ordine cliente', - '_NUM_' => $riga->getOriginalComponent()->getDocument()->numero_cliente, - '_DATE_' => dateFormat($riga->getOriginalComponent()->getDocument()->data_cliente), - ]); - } - if (!empty($ref)) { - echo ' -
    '.$ref.''; - - $autofill->count($ref, true); - } - }*/ - - // Informazioni su CIG, CUP, ... - if ($riga->hasOriginalComponent()) { - $documento_originale = $riga->getOriginalComponent()->getDocument(); - - $num_item = $documento_originale['num_item']; - $codice_commessa = $documento_originale['codice_commessa']; - $codice_cig = $documento_originale['codice_cig']; - $codice_cup = $documento_originale['codice_cup']; - $id_documento_fe = $documento_originale['id_documento_fe']; - - $extra_riga = replace('_ID_DOCUMENTO__NUMERO_RIGA__CODICE_COMMESSA__CODICE_CIG__CODICE_CUP_', [ - '_ID_DOCUMENTO_' => $id_documento_fe ? 'DOC: '.$id_documento_fe : null, - '_NUMERO_RIGA_' => $num_item ? ', NRI: '.$num_item : null, - '_CODICE_COMMESSA_' => $codice_commessa ? ', COM: '.$codice_commessa : null, - '_CODICE_CIG_' => $codice_cig ? ', CIG: '.$codice_cig : null, - '_CODICE_CUP_' => $codice_cup ? ', CUP: '.$codice_cup : null, - ]); - - echo ' -
    '.$extra_riga.''; - } - - echo ' -
    - '.Translator::numberToLocale(abs($riga->qta), 'qta').' '.$r['um'].' - - '.moneyFormat($riga->prezzo_unitario); - - if ($riga->sconto > 0) { - $text = discountInfo($riga, false); - - echo ' -
    '.$text.''; - - $autofill->count($text, true); - } - - echo ' -
    - '.moneyFormat($riga->totale_imponibile).' - - '.Translator::numberToLocale($riga->aliquota->percentuale, 0).' -
    '; - -// Aggiungo diciture particolari per l'anagrafica cliente -$dicitura = $dbo->fetchOne('SELECT diciturafissafattura AS dicitura FROM an_anagrafiche WHERE idanagrafica = '.prepare($id_cliente)); - -if (!empty($dicitura['dicitura'])) { - echo ' -

    - '.nl2br($dicitura['dicitura']).' -

    '; -} - -// Aggiungo diciture per condizioni iva particolari -foreach ($v_iva as $key => $value) { - $dicitura = $dbo->fetchOne('SELECT dicitura FROM co_iva WHERE descrizione = '.prepare($key)); - - if (!empty($dicitura['dicitura'])) { - echo ' -

    - '.nl2br($dicitura['dicitura']).' -

    '; - } -} -echo ' -'; -echo ' - - '; - -echo ' - '; -echo ' -
    '; - - if (!empty($record['note'])) { - echo ' -

    '.tr('Note', [], ['upper' => true]).':

    -

    '.nl2br($record['note']).'

    '; - } - - echo ' -
    '; diff --git a/templates/fatture/footer.php b/templates/fatture/footer.php deleted file mode 100755 index 4a9806188..000000000 --- a/templates/fatture/footer.php +++ /dev/null @@ -1,465 +0,0 @@ -. - */ - -if (!empty($options['last-page-footer']) && !$is_last_page) { - return; -} - -// Calcoli -$imponibile = abs($documento->imponibile); -$sconto = $documento->sconto; -$totale_imponibile = abs($documento->totale_imponibile); -$totale_iva = abs($documento->iva); -$sconto_finale = abs($documento->getScontoFinale()); -$rivalsa = floatval($record['rivalsainps']); -$totale = abs($documento->totale) - $rivalsa; - -$show_sconto = $sconto > 0; - -$volume = $documento->volume ?: $documento->volume_calcolato; -$peso_lordo = $documento->peso ?: $documento->peso_calcolato; - -$width = round(100 / ($show_sconto ? 5 : 3), 2); - -$has_rivalsa = !empty($record['rivalsainps']); -$has_ritenuta = !empty($record['ritenutaacconto']) || !empty($documento->totale_ritenuta_contributi) || !empty($record['spit_payment']); -$has_split_payment = !empty($record['split_payment']); -$has_sconto_finale = !empty($sconto_finale); - -$etichette = [ - 'totale' => tr('Totale', [], ['upper' => true]), - 'totale_parziale' => tr('Totale parziale', [], ['upper' => true]), - 'totale_finale' => tr('Netto a pagare', [], ['upper' => true]), -]; - -// SCADENZE | TOTALI -// TABELLA PRINCIPALE -echo " - - - '; - -/* - * Riga di riepilogo dei totali. - * Se sconto: Imponibile | Sconto | Totale imponibile | Totale IVA | Totale - * Altrimenti: Imponibile | Totale IVA | Totale - */ -echo " - - '; - -if ($show_sconto) { - echo " - - - '; -} - -echo " - - - - - - - '; - -if ($show_sconto) { - echo " - - - - '; -} - -echo " - - - - '; - -/* - * Riga di riepilogo della Rivalsa INPS. - * Rivalsa INPS | Totale (+ Rivalsa INPS) - */ -if ($has_rivalsa) { - $rs2 = $dbo->fetchArray('SELECT percentuale FROM co_rivalse WHERE id=(SELECT idrivalsainps FROM co_righe_documenti WHERE iddocumento='.prepare($id_record).' AND idrivalsainps!=0 LIMIT 0,1)'); - - $first_colspan = 3; - $second_colspan = 2; - - if (empty($sconto)) { - --$first_colspan; - --$second_colspan; - } - - echo ' - - '; - - echo ' - - - - - - '; - - $totale = $totale + $rivalsa; - echo ' - - - '; -} - -/* - * Riga di riepilogo di Ritenuta d'acconto e Ritenuta contributi. - * Ritenuta | Totale (+ Rivalsa INPS - Ritenuta) - */ -if ($has_ritenuta) { - $rs2 = $dbo->fetchArray('SELECT percentuale FROM co_ritenutaacconto WHERE id=(SELECT idritenutaacconto FROM co_righe_documenti WHERE iddocumento='.prepare($id_record).' AND idritenutaacconto!=0 LIMIT 0,1)'); - - $first_colspan = 3; - $second_colspan = 2; - - if (empty($sconto)) { - --$first_colspan; - --$second_colspan; - } - - $contributi = (!empty($record['ritenutaacconto']) ? ' - ' : '').tr('contributi: _PRC_%', [ - '_PRC_' => Translator::numberToLocale($documento->ritenutaContributi->percentuale, 2), - ]); - $acconto = tr('acconto: _PRC_%', [ - '_PRC_' => Translator::numberToLocale($rs2[0]['percentuale'], 0), - ]); - $ritenuta_totale = abs($documento->ritenuta_acconto) + abs($documento->totale_ritenuta_contributi); - - echo ' - - '; - - echo ' - '; - - echo ' - - - - '; - - $totale = $totale - $ritenuta_totale; - echo ' - - - '; -} - -/* - * Riga di riepilogo per lo Split payment. - * Totale IVA | Totale (+ Rivalsa INPS - Ritenuta - Totale IVA) - */ -if ($has_split_payment) { - $first_colspan = 1; - $second_colspan = 2; - - echo ' - - - - - '; - - $totale = $totale - $totale_iva; - echo ' - - - - - '; -} - -/* - * Riga di riepilogo per lo Sconto finale sulla fattura. - * Sconto finale | Totale (+ Rivalsa INPS - Ritenuta - Totale IVA [se split payment] - Sconto finale) - */ -if ($has_sconto_finale) { - $first_colspan = 1; - $second_colspan = 2; - - echo ' - - - - - '; - - $totale = $totale - $sconto_finale; - echo ' - - - - - '; -} - -echo ' -
    "; - -// Tabella (scadenze + iva) -echo " - - - - - '; -// Fine elenco scadenze - -// Separatore -echo " - "; - -// Tabella iva -echo " - - - - '; -// Fine tabelle iva -echo ' -
      - - - - '; - -// Elenco scadenze -$rs2 = $dbo->fetchArray('SELECT * FROM co_scadenziario WHERE iddocumento='.prepare($id_record).' ORDER BY `data_emissione` ASC'); -if (!empty($rs2)) { - for ($i = 0; $i < sizeof($rs2); ++$i) { - echo " - - - - '; - } -} - -echo ' -
    -

    ".tr('Scadenze pagamenti', [], ['upper' => true]).'

    -
    - ".Translator::dateToLocale($rs2[$i]['scadenza'])." - - ".moneyFormat($rs2[$i]['da_pagare'], 2).' -
    -
     "; -if (!empty($v_iva)) { - echo " - - - - - - - - '; - - foreach ($v_iva as $desc_iva => $tot_iva) { - if (!empty($desc_iva)) { - echo ' - - - - - - - '; - } - } - - echo ' -
    -

    ".tr('Aliquota IVA', [], ['upper' => true])."

    -
    -

    ".tr('Importo', [], ['upper' => true])."

    -
    -

    ".tr('Importo IVA', [], ['upper' => true]).'

    -
    - '.$desc_iva." - - ".moneyFormat($v_totale[$desc_iva], 2)." - - ".moneyFormat($v_iva[$desc_iva], 2).' -
    '; -} - -echo ' -
     
    '; -// Fine tabella (scadenze + iva) -echo ' -
    - ".tr('Imponibile', [], ['upper' => true]).' - - ".tr('Sconto', [], ['upper' => true])." - - ".tr('Totale imponibile', [], ['upper' => true]).' - - ".tr('Totale IVA', [], ['upper' => true])." - - ".(!$has_rivalsa && !$has_ritenuta && !$has_split_payment && !$has_sconto_finale ? $etichette['totale'] : $etichette['totale_parziale'])." -
    - ".moneyFormat($show_sconto ? $imponibile : $totale_imponibile, 2).' - - ".moneyFormat(abs($sconto), 2)." - - ".moneyFormat($totale_imponibile, 2).' - - ".moneyFormat($totale_iva, 2)." - - ".moneyFormat($totale, 2).' -
    - '.tr('Rivalsa _PRC_%', [ - '_PRC_' => Translator::numberToLocale($rs2[0]['percentuale'], 0), - ], ['upper' => true]).' - - '.(!$has_ritenuta && !$has_split_payment && !$has_sconto_finale ? $etichette['totale_finale'] : $etichette['totale_parziale']).' -
    - '.moneyFormat($rivalsa, 2).' - - '.moneyFormat($totale, 2).' -
    - '.tr('Ritenuta (_ACCONTO__CONTRIBUTI_)', [ - '_ACCONTO_' => $acconto, - '_CONTRIBUTI_' => empty($documento->ritenutaContributi) ? null : $contributi, - ], ['upper' => true]).' - - '.(!$has_split_payment && !$has_sconto_finale ? $etichette['totale_finale'] : $etichette['totale_parziale']).' -
    - '.moneyFormat($ritenuta_totale, 2).' - - '.moneyFormat($totale, 2).' -
    - '.tr('IVA a carico del destinatario', [], ['upper' => true]).' - - '.(!$has_split_payment && !$has_sconto_finale ? $etichette['totale_finale'] : $etichette['totale_parziale']).' -
    - '.moneyFormat($totale_iva, 2).' - - '.moneyFormat($totale, 2).' -
    - '.tr('Sconto in fattura', [], ['upper' => true]).($documento->sconto_finale_percentuale ? ' ('.numberFormat($documento->sconto_finale_percentuale, 2).'%)' : '').' - - '.tr('Netto a pagare', [], ['upper' => true]).' -
    - '.moneyFormat($sconto_finale, 2).' - - '.moneyFormat($totale, 2).' -
    '; - -if ($fattura_accompagnatoria) { - // Informazioni aggiuntive - echo ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - '.tr('Peso lordo', [], ['upper' => true]).' - - '.tr('Volume', [], ['upper' => true]).' - - '.tr('Aspetto beni', [], ['upper' => true]).' - - '.tr('Colli', [], ['upper' => true]).' - - '.tr('Causale trasporto', [], ['upper' => true]).' - - '.tr('Porto', [], ['upper' => true]).' -
    - '.(!empty($peso_lordo) ? Translator::numberToLocale($peso_lordo).' KG' : '').' - - '.(!empty($volume) ? Translator::numberToLocale($volume).' M3' : '').' - - $aspettobeni$   - - $n_colli$   - - $causalet$   - - $porto$   -
    '; - - // Firme - echo ' - - - - - - - - - - - - - - -
    - '.tr('Tipo di spedizione', [], ['upper' => true]).' - - '.tr('Firma conducente', [], ['upper' => true]).' - - '.tr('Firma destinatario', [], ['upper' => true]).' -
    $spedizione$ $vettore$
    '; -} - -echo ' -
    - $dicitura_fissa_fattura$ -
    '; - -if (empty($options['last-page-footer'])) { - echo '$default_footer$'; -} diff --git a/templates/fatture/header.php b/templates/fatture/header.php deleted file mode 100755 index a8614ccca..000000000 --- a/templates/fatture/header.php +++ /dev/null @@ -1,132 +0,0 @@ -. - */ - -if ($options['hide_header']) { - echo ' - -
    -
    -
    -
    -
    -
    '; -} else { - echo ' - - $default_header$'; -} - -echo ' - -
    - -
    -
    - $tipo_doc$ -
    - - - - - - - - - - - - - - - - - - - - -
    -

    '.tr('Nr. documento', [], ['upper' => true]).'

    -

    $numero$

    -
    -

    '.tr('Data documento', [], ['upper' => true]).'

    -

    $data$

    -
    -

    '.tr('Cliente', [], ['upper' => true]).'

    -

    $c_codice$

    -
    -

    '.tr('Foglio', [], ['upper' => true]).'

    -

    {PAGENO}/{nb}

    -
    -

    '.tr('Pagamento', [], ['upper' => true]).'

    -

    $pagamento$

    -
    -

    '.tr('Banca di appoggio', [], ['upper' => true]).'

    -

    $appoggiobancario$

    -
    -

    '.tr('IBAN').'

    -

    $codiceiban$

    -
    -

    '.tr('BIC').'

    -

    $bic$

    -
    -
    - -
    - - - - - - - - - - - - - - '; - -if (!empty($destinazione)) { - echo ' - - - '; -} - -echo ' -
    -

    '.tr('Spett.le', [], ['upper' => true]).'

    -

    $c_ragionesociale$

    -

    '.(!empty($c_indirizzo) ? $c_indirizzo : '').(!empty($c_citta_full) ? '
    '.$c_citta_full : '').'

    - '.(!empty($c_codice_destinatario) ? tr('Cod.Fatturazione').': '.$c_codice_destinatario : '').' -
    -

    '.tr('Partita IVA', [], ['upper' => true]).'

    -
    - $c_piva$ -
    -

    '.tr('Codice fiscale', [], ['upper' => true]).'

    -
    - $c_codicefiscale$ -
    -

    '.tr('Destinazione diversa', [], ['upper' => true]).'

    - $c_destinazione$ -
    -
    -
    '; diff --git a/templates/fatture/init.php b/templates/fatture/init.php deleted file mode 100755 index cfcedc035..000000000 --- a/templates/fatture/init.php +++ /dev/null @@ -1,128 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Fatture\Fattura; - -$documento = Fattura::find($id_record); -$banca = $documento->getBanca(); - -// Lettura info fattura -$record = $dbo->fetchOne('SELECT *, - (SELECT descrizione FROM co_statidocumento WHERE id=idstatodocumento) AS stato_doc, - (SELECT descrizione FROM co_tipidocumento WHERE id=idtipodocumento) AS tipo_doc, - (SELECT descrizione FROM co_pagamenti WHERE id=idpagamento) AS tipo_pagamento, - (SELECT dir FROM co_tipidocumento WHERE id=idtipodocumento) AS dir, - (SELECT descrizione FROM dt_causalet WHERE id=idcausalet) AS causalet, - (SELECT descrizione FROM dt_porto WHERE id=idporto) AS porto, - (SELECT descrizione FROM dt_aspettobeni WHERE id=idaspettobeni) AS aspettobeni, - (SELECT descrizione FROM dt_spedizione WHERE id=idspedizione) AS spedizione, - (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=idvettore) AS vettore, - (SELECT id FROM co_banche WHERE id = id_banca_azienda) AS id_banca, - (SELECT is_fiscale FROM zz_segments WHERE id = id_segment) AS is_fiscale, - (SELECT tipo FROM an_anagrafiche WHERE idanagrafica=co_documenti.idanagrafica) AS tipo_cliente -FROM co_documenti WHERE id='.prepare($id_record)); - -$record['rivalsainps'] = floatval($record['rivalsainps']); -$record['ritenutaacconto'] = floatval($record['ritenutaacconto']); -$record['bollo'] = floatval($record['bollo']); - -$nome_banca = $banca->nome; -$iban_banca = $banca->iban; -$bic_banca = $banca->bic; - -$module_name = ($record['dir'] == 'entrata') ? 'Fatture di vendita' : 'Fatture di acquisto'; - -$id_cliente = $record['idanagrafica']; -$tipo_cliente = $record['tipo_cliente']; - -$tipo_doc = $record['tipo_doc']; -$numero = !empty($record['numero_esterno']) ? $record['numero_esterno'] : $record['numero']; - -// Caso particolare per le fatture pro forma -if (empty($record['is_fiscale'])) { - $tipo_doc = tr('Fattura pro forma'); -} - -// Fix per le fattura accompagnatorie -$fattura_accompagnatoria = ($record['tipo_doc'] == 'Fattura accompagnatoria di vendita'); -$tipo_doc = ($fattura_accompagnatoria) ? 'Fattura accompagnatoria di vendita' : $tipo_doc; - -// Leggo i dati della destinazione (se 0=sede legale, se!=altra sede da leggere da tabella an_sedi) -$destinazione = ''; -if (!empty($record['idsede_destinazione'])) { - $rsd = $dbo->fetchArray('SELECT (SELECT codice FROM an_anagrafiche WHERE idanagrafica=an_sedi.idanagrafica) AS codice, (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=an_sedi.idanagrafica) AS ragione_sociale, nomesede, indirizzo, indirizzo2, cap, citta, provincia, piva, codice_fiscale, id_nazione FROM an_sedi WHERE idanagrafica='.prepare($id_cliente).' AND id='.prepare($record['idsede_destinazione'])); - - if (!empty($rsd[0]['nomesede'])) { - $destinazione .= $rsd[0]['nomesede'].'
    '; - } - if (!empty($rsd[0]['indirizzo'])) { - $destinazione .= $rsd[0]['indirizzo'].'
    '; - } - if (!empty($rsd[0]['indirizzo2'])) { - $destinazione .= $rsd[0]['indirizzo2'].'
    '; - } - if (!empty($rsd[0]['cap'])) { - $destinazione .= $rsd[0]['cap'].' '; - } - if (!empty($rsd[0]['citta'])) { - $destinazione .= $rsd[0]['citta']; - } - if (!empty($rsd[0]['provincia'])) { - $destinazione .= ' ('.$rsd[0]['provincia'].')'; - } - if (!empty($rsd[0]['id_nazione'])) { - $nazione = $database->fetchOne('SELECT * FROM an_nazioni WHERE id = '.prepare($rsd[0]['id_nazione'])); - if ($nazione['iso2'] != 'IT') { - $destinazione .= ' - '.$nazione['name']; - } - } -} - -// Sostituzioni specifiche -$custom = [ - 'tipo_doc' => Stringy\Stringy::create($tipo_doc)->toUpperCase(), - 'numero' => $numero, - 'tipo_documento' => $tipo_doc, - 'data' => Translator::dateToLocale($record['data']), - 'pagamento' => $record['tipo_pagamento'], - 'c_destinazione' => $destinazione, - 'aspettobeni' => $record['aspettobeni'], - 'causalet' => $record['causalet'], - 'porto' => $record['porto'], - 'n_colli' => !empty($record['n_colli']) ? $record['n_colli'] : '', - 'spedizione' => $record['spedizione'], - 'vettore' => $record['vettore'], - 'appoggiobancario' => $nome_banca, - 'codiceiban' => $iban_banca, - 'bic' => $bic_banca, -]; - -// Accesso solo a: -// - cliente se è impostato l'idanagrafica di un Cliente -// - utente qualsiasi con permessi almeno in lettura sul modulo -// - admin -if ((Auth::user()['gruppo'] == 'Clienti' && $id_cliente != Auth::user()['idanagrafica'] && !Auth::admin()) || Modules::getPermission($module_name) == '-') { - exit(tr('Non hai i permessi per questa stampa!')); -} - -if ($fattura_accompagnatoria) { - $settings['footer-height'] += 40; -} diff --git a/templates/fatture_elettroniche/body.php b/templates/fatture_elettroniche/body.php deleted file mode 100644 index 886ea13f9..000000000 --- a/templates/fatture_elettroniche/body.php +++ /dev/null @@ -1,99 +0,0 @@ -. - */ - -use Modules\Fatture\Fattura; - -include_once __DIR__.'/../../core.php'; - -$fattura = Fattura::find($id_record); -$file = $fattura->uploads()->where('name', 'Fattura Elettronica')->first(); - -if (empty($file)) { - echo '
    '.tr('Questo documento non possiede una fattura elettronica associata').'
    '; - - return; -} - -$link = base_path().'/'.$file->filepath; - -if ($file->isFatturaElettronica()) { - $content = file_get_contents(base_dir().'/'.$file->filepath); - - // Individuazione stylesheet - $default_stylesheet = 'asso-invoice'; - - $name = basename($file->original_name); - $filename = explode('.', $name)[0]; - $pieces = explode('_', $filename); - $stylesheet = $pieces[2]; - - $stylesheet = base_dir().'/plugins/xml/'.$stylesheet.'.xsl'; - $stylesheet = file_exists($stylesheet) ? $stylesheet : base_dir().'/plugins/xml/'.$default_stylesheet.'.xsl'; - - // XML - $xml = new DOMDocument(); - $xml->loadXML($content); - - // XSL - $xsl = new DOMDocument(); - $xsl->load($stylesheet); - - // XSLT - $xslt = new XSLTProcessor(); - $xslt->importStylesheet($xsl); - echo $xslt->transformToXML($xml); - - echo ' -'; -} else { - echo ' -'; - - if ($file->isImage()) { - echo ' - '; - } else { - if ($file->isPDF()) { - $src = \Prints::getPDFLink($file->filepath); - } - - echo ' - '; - } -} diff --git a/templates/info.php b/templates/info.php deleted file mode 100755 index 535dec0e5..000000000 --- a/templates/info.php +++ /dev/null @@ -1,157 +0,0 @@ -. - */ - -$replaces = []; - -// Retrocompatibilità -$id_cliente = $id_cliente ?: $idcliente; - -// Leggo i dati della destinazione (se 0=sede legale, se!=altra sede da leggere da tabella an_sedi) -if (empty($id_sede) || $id_sede == '-1') { - $queryc = 'SELECT * FROM an_anagrafiche WHERE idanagrafica='.prepare($id_cliente); -} else { - $queryc = 'SELECT an_anagrafiche.*, an_sedi.*, if(an_sedi.codice_fiscale != "", an_sedi.codice_fiscale, an_anagrafiche.codice_fiscale) AS codice_fiscale, if(an_sedi.piva != "", an_sedi.piva, an_anagrafiche.piva) AS piva, if(an_sedi.id_nazione != "", an_sedi.id_nazione, an_anagrafiche.id_nazione) AS id_nazione FROM an_sedi JOIN an_anagrafiche ON an_anagrafiche.idanagrafica=an_sedi.idanagrafica WHERE an_sedi.idanagrafica='.prepare($id_cliente).' AND an_sedi.id='.prepare($id_sede); -} -/** - * @deprecated - */ -$cliente = $dbo->fetchOne($queryc); - -// Lettura dati aziendali -/** - * @deprecated - */ -$azienda = $dbo->fetchOne('SELECT *, (SELECT iban FROM co_banche WHERE id IN (SELECT id_banca_azienda FROM co_documenti WHERE id = '.prepare($id_record).')) AS codiceiban, (SELECT nome FROM co_banche WHERE id IN (SELECT id_banca_azienda FROM co_documenti WHERE id = '.prepare($id_record).')) AS appoggiobancario, (SELECT bic FROM co_banche WHERE id IN (SELECT id_banca_azienda FROM co_documenti WHERE id = '.prepare($id_record).")) AS bic FROM an_anagrafiche WHERE idanagrafica = (SELECT valore FROM zz_settings WHERE nome='Azienda predefinita')"); - -// Prefissi e contenuti del replace -/** - * @deprecated - */ -$replace = [ - 'c_' => isset($cliente) ? $cliente : [], - 'f_' => isset($azienda) ? $azienda : [], -]; - -// Rinominazione di particolari campi all'interno delle informazioni su anagrafica e azienda -$rename = [ - 'capitale_sociale' => 'capsoc', - 'ragione_sociale' => 'ragionesociale', - 'codice_fiscale' => 'codicefiscale', -]; - -$keys = []; - -// Predisposizione delle informazioni delle anagrafiche per la sostituzione automatica -foreach ($replace as $prefix => $values) { - $values = (array) $values; - - // Rinominazione dei campi - foreach ($rename as $key => $value) { - $val = null; - - if (isset($values[$key])) { - $val = $values[$key]; - } - - $values[$value] = $val; - unset($values[$key]); - } - - // Eventuali estensioni dei contenuti - $citta = ''; - if (!empty($values['cap'])) { - $citta .= $values['cap']; - } - if (!empty($values['citta'])) { - $citta .= ' '.$values['citta']; - } - if (!empty($values['provincia'])) { - $citta .= ' ('.$values['provincia'].')'; - } - if (!empty($values['id_nazione'])) { - $nazione = $database->fetchOne('SELECT * FROM an_nazioni WHERE id = '.prepare($values['id_nazione'])); - if ($nazione['iso2'] != 'IT') { - $citta .= ' - '.$nazione['name']; - } - } - - $values['citta_full'] = $citta; - - $replace[$prefix] = $values; - - // Individuazione dei campi minimi - $keys = array_merge($keys, array_keys($values)); -} - -$keys = array_unique($keys); - -foreach ($replace as $prefix => $values) { - // Impostazione di default per le informazioni mancanti - foreach ($keys as $key) { - if (!isset($values[$key])) { - $values[$key] = ''; - } - } - - // Salvataggio dei campi come variabili PHP e aggiunta delle informazioni per la sostituzione automatica - foreach ($values as $key => $value) { - ${$prefix.$key} = $value; - $replaces[$prefix.$key] = $value; - } -} - -// Header di default -$header_file = App::filepath('templates/base|custom|/header.php'); -$default_header = include $header_file; -$default_header = !empty($options['hide-header']) ? '' : $default_header; - -// Footer di default -$footer_file = App::filepath('templates/base|custom|/footer.php'); -$default_footer = include $footer_file; -$default_footer = !empty($options['hide-footer']) ? '' : $default_footer; - -// Logo di default -$default_logo = App::filepath('templates/base|custom|/logo_azienda.jpg'); - -// Logo generico -if (!empty(setting('Logo stampe'))) { - $custom_logo = App::filepath('files/anagrafiche/'.setting('Logo stampe')); -} - -// Logo specifico della stampa -$logo = Prints::filepath($id_print, 'logo_azienda.jpg'); - -if (empty($logo)) { - $logo = empty($custom_logo) ? $default_logo : $custom_logo; -} - -// Valori aggiuntivi per la sostituzione -$replaces = array_merge($replaces, [ - 'default_header' => $default_header, - 'default_footer' => $default_footer, - 'default_logo' => $default_logo, - 'logo' => $logo, - 'base_dir()' => base_dir(), - 'base_link()' => base_path(), - 'directory' => Prints::get($id_print)['full_directory'], - 'footer' => !empty($footer) ? $footer : '', - 'dicitura_fissa_fattura' => setting('Dicitura fissa fattura').((setting('Regime Fiscale') != 'RF02' && setting('Regime Fiscale') != 'RF19' && setting('Regime Fiscale') != 'RF18' && $tipo_cliente != 'Privato') ? tr('Documento privo di valenza fiscale (art 21 dpr 633/72).') : ''), -]); - -unset($replace); diff --git a/templates/interventi/body.php b/templates/interventi/body.php deleted file mode 100755 index aaeb9a693..000000000 --- a/templates/interventi/body.php +++ /dev/null @@ -1,495 +0,0 @@ -. - */ - -use Carbon\Carbon; - -include_once __DIR__.'/../../core.php'; - -/* - Dati intervento -*/ -echo ' - - - - - - - - '; -if (!empty($preventivo)) { - echo ' - '; -} elseif (!empty($contratto)) { - echo ' - '; -} -echo ' - '; - -// Dati cliente -echo ' - - '; - -// Codice fiscale o P.Iva - -if (!empty($c_piva)) { - echo ' - '; -} else { - echo ' - '; -} - -echo ''; - -// Indirizzo -if (!empty($s_indirizzo) or !empty($s_cap) or !empty($s_citta) or !empty($s_provincia)) { - echo ' - - - '; -} elseif (!empty($c_indirizzo) or !empty($c_cap) or !empty($c_citta) or !empty($c_provincia)) { - echo ' - - - '; -} - -echo ' - - - '; - -// riga 3 -// Elenco impianti su cui è stato fatto l'intervento -$rs2 = $dbo->fetchArray('SELECT *, (SELECT nome FROM my_impianti WHERE id=my_impianti_interventi.idimpianto) AS nome, (SELECT matricola FROM my_impianti WHERE id=my_impianti_interventi.idimpianto) AS matricola FROM my_impianti_interventi WHERE idintervento='.prepare($id_record)); -$impianti = []; -for ($j = 0; $j < count($rs2); ++$j) { - $impianti[] = ''.$rs2[$j]['nome']."(".$rs2[$j]['matricola'].')'; -} -echo ' - - - '; - -// Tipo intervento -echo ' - - - '; - -// Richiesta -// Rimosso nl2br, non necessario con ckeditor -echo ' - - - '; - -// Descrizione -// Rimosso nl2br, non necessario con ckeditor -echo ' - - - '; - -echo ' -
    '.tr('Rapporto attività e interventi', [], ['upper' => true]).'
    '.tr('Intervento n.').': '.$documento['codice'].''.tr('Data richiesta').': '.Translator::dateToLocale($documento['data_richiesta']).''.tr('Preventivo n.').': '.(!empty($preventivo) ? $preventivo['numero'].' del '.Translator::dateToLocale($preventivo['data_bozza']) : '').''.tr('Contratto n.').': '.(!empty($contratto) ? $contratto['numero'].' del '.Translator::dateToLocale($contratto['data_bozza']) : '').'
    - '.tr('Cliente').': '.$c_ragionesociale.' - - '.tr('P.Iva').': '.strtoupper($c_piva).' - - '.tr('C.F.').': '.strtoupper($c_codicefiscale).' -
    - '.((!empty($s_indirizzo)) ? tr('Via').': '.$s_indirizzo.'' : '').' - '.((!empty($s_cap)) ? tr('CAP').': '.$s_cap.'' : '').' - '.((!empty($s_citta)) ? tr('Città').': '.$s_citta.'' : '').' - '.((!empty($s_provincia)) ? tr('Provincia').': '.strtoupper($s_provincia).'' : '').' -
    - '.((!empty($c_indirizzo)) ? tr('Via').': '.$c_indirizzo.'' : '').' - '.((!empty($c_cap)) ? tr('CAP').': '.$c_cap.'' : '').' - '.((!empty($c_citta)) ? tr('Città').': '.$c_citta.'' : '').' - '.((!empty($c_provincia)) ? tr('Provincia').': '.strtoupper($c_provincia).'' : '').' -
    - '.tr('Telefono').': '.$c_telefono.''; -if (!empty($c_cellulare)) { - echo ' - '.tr('Cellulare').': '.$c_cellulare.''; -} -echo ' -
    - '.tr('Impianti').': '.implode(', ', $impianti).' -
    - '.tr('Tipo intervento').': '.$documento->tipo->descrizione.' -
    - '.tr('Richiesta').': -

    '.($documento['richiesta']).'

    -
    - '.tr('Descrizione').': -

    '.($documento['descrizione']).'

    -
    '; - -$righe = $documento->getRighe(); - -if (!$righe->isEmpty()) { - echo ' - - - - - - - - - - - - - - - - - - '; - - foreach ($righe as $riga) { - if (setting('Formato ore in stampa') == 'Sessantesimi') { - if ($riga->um == 'ore') { - $qta = Translator::numberToHours($riga->qta); - } else { - $qta = Translator::numberToLocale($riga->qta, 'qta'); - } - } else { - $qta = Translator::numberToLocale($riga->qta, 'qta'); - } - // Articolo - echo ' - - '; - - // Quantità - echo ' - '; - - // Prezzo unitario - echo ' - '; - - // Prezzo totale - echo ' - - '; - } - - echo ' - '; - - if ($options['pricing']) { - // Totale spese aggiuntive - echo ' - - - - - '; - } - - echo ' -
    - '.tr('Materiale utilizzato e spese aggiuntive', [], ['upper' => true]).' -
    - '.tr('Descrizione').' - - '.tr('Q.tà').' - - '.tr('Prezzo unitario').' - - '.tr('Importo').' -
    - '.nl2br(strip_tags($riga->descrizione)); - - if ($riga->isArticolo()) { - // Codice articolo - $text = tr('COD. _COD_', [ - '_COD_' => $riga->codice, - ]); - echo ' -
    '.$text.''; - - // Seriali - $seriali = $riga->serials; - if (!empty($seriali)) { - $text = tr('SN').': '.implode(', ', $seriali); - echo ' -
    '.$text.''; - } - } - - echo ' -
    - '.$qta.' '.$riga->um.' - - '.($options['pricing'] ? moneyFormat($riga->prezzo_unitario_corrente) : '-'); - - if ($options['pricing'] && $riga->sconto > 0) { - $text = discountInfo($riga, false); - - echo ' -
    '.$text.''; - } - - echo ' -
    - '.($options['pricing'] ? Translator::numberToLocale($riga->importo) : '-').' -
    - '.tr('Totale', [], ['upper' => true]).': - - '.moneyFormat($righe->sum('importo'), 2).' -
    '; -} - -// INTESTAZIONE ELENCO TECNICI -echo ' - - - - - - - - - - - - - - - '; - -// Sessioni di lavoro dei tecnici -$sessioni = $documento->sessioni->sortBy('orario_inizio'); -foreach ($sessioni as $i => $sessione) { - echo ' - '; - // Nome tecnico - echo ' - '; - - $inizio = new Carbon($sessione['orario_inizio']); - $fine = new Carbon($sessione['orario_fine']); - if ($inizio->isSameDay($fine)) { - $orario = timestampFormat($inizio).' - '.timeFormat($fine); - } else { - $orario = timestampFormat($inizio).' - '.timestampFormat($fine); - } - - // Orario - echo ' - '; - - // Spazio aggiuntivo - if ($i == 0) { - echo ' - '; - } else { - echo ' - '; - } - - echo ' - '; -} - -// Ore lavorate -if (setting('Formato ore in stampa') == 'Sessantesimi') { - $ore_totali = Translator::numberToHours($documento->ore_totali); -} else { - $ore_totali = Translator::numberToLocale($documento->ore_totali, 2); -} - -echo ' - - '; - -// Costo totale manodopera -if ($options['pricing']) { - echo ' - '; -} else { - echo ' - '; -} - -// Timbro e firma -$firma = !empty($documento['firma_file']) ? '' : ''; - -echo ' - - '; - -// Totale km -echo ' - - '; - -// Costo trasferta -if ($options['pricing']) { - echo ' - '; -} else { - echo ' - '; -} - -// Diritto di chiamata -if ($options['pricing']) { - echo ' - '; -} else { - echo ' - '; -} - -// Calcoli -$imponibile = abs($documento->imponibile); -$sconto = $documento->sconto; -$totale_imponibile = abs($documento->totale_imponibile); -$totale_iva = abs($documento->iva); -$totale = abs($documento->totale); -$netto_a_pagare = abs($documento->netto); - -$show_sconto = $sconto > 0; - -$incorpora_iva = setting('Utilizza prezzi di vendita comprensivi di IVA'); - -// TOTALE COSTI FINALI -if ($options['pricing']) { - if ($incorpora_iva) { - // TOTALE INTERVENTO - echo ' - - - - '; - } else { - // Totale imponibile - echo ' - - - - - '; - - // Eventuale sconto totale - if ($show_sconto) { - echo ' - - - - - '; - - // Totale imponibile - echo ' - - - - - '; - } - - // IVA - // Totale intervento - echo ' - - - - - '; - - // TOTALE INTERVENTO - echo ' - - - - '; - } -} - -echo ' -
    - '.tr('Ore tecnici', [], ['upper' => true]).' -
    - '.tr('Tecnico').' - - '.tr('Orario').' - - '.tr('I dati del ricevente verrano trattati in base alla normativa europea UE 2016/679 del 27 aprile 2016 (GDPR)').' -
    - '.$sessione->anagrafica->ragione_sociale.' - ('.$sessione->tipo->descrizione.') - - '.$orario.' - - '.tr('Si dichiara che i lavori sono stati eseguiti ed i materiali installati nel rispetto delle vigenti normative tecniche').' -
    - '.tr('Ore lavorate').':
    '.$ore_totali.' -
    - '.tr('Totale manodopera').':
    '.moneyFormat($sessioni->sum('prezzo_manodopera'), 2).' -
    - - '.$firma.'
    '; - -if (empty($documento['firma_file'])) { - echo ' ('.tr('Timbro e firma leggibile').'.)'; -} else { - echo ' '.$documento['firma_nome'].''; -} - -echo ' -
    - '.tr('Km percorsi').':
    '.Translator::numberToLocale($documento->km_totali, 2).' -
    - '.tr('Costi di trasferta').':
    '.moneyFormat($sessioni->sum('prezzo_viaggio'), 2).' -
    - - '.tr('Diritto di chiamata').':
    '.moneyFormat($sessioni->sum('prezzo_diritto_chiamata'), 2).' -
    -
    - '.tr('Totale intervento', [], ['upper' => true]).': - - '.moneyFormat($totale, 2).' -
    - '.tr('Imponibile', [], ['upper' => true]).': - - '.moneyFormat($show_sconto ? $imponibile : $totale_imponibile, 2).' -
    - '.tr('Sconto', [], ['upper' => true]).': - - '.moneyFormat($sconto, 2).' -
    - '.tr('Totale imponibile', [], ['upper' => true]).': - - '.moneyFormat($totale_imponibile, 2).' -
    - '.tr('Iva', [], ['upper' => true]).': - - '.moneyFormat($totale_iva, 2).' -
    - '.tr('Totale intervento', [], ['upper' => true]).': - - '.moneyFormat($totale, 2).' -
    '; diff --git a/templates/interventi/init.php b/templates/interventi/init.php deleted file mode 100755 index 9411e9a50..000000000 --- a/templates/interventi/init.php +++ /dev/null @@ -1,44 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Interventi\Intervento; - -$documento = Intervento::find($id_record); - -$preventivo = $dbo->fetchOne('SELECT numero, data_bozza FROM co_preventivi WHERE id = '.prepare($documento['id_preventivo'])); -$contratto = $dbo->fetchOne('SELECT nome, numero, data_bozza FROM co_contratti WHERE id = '.prepare($documento['id_contratto'])); - -$id_cliente = $documento['idanagrafica']; -$id_sede = $documento['idsede']; - -if (!empty($documento['idsede_destinazione'])) { - $sedi = $dbo->fetchOne('SELECT nomesede, cap, citta, indirizzo, provincia FROM an_sedi WHERE id = '.prepare($documento['idsede_destinazione'])); - - $s_citta = $sedi['citta']; - $s_indirizzo = $sedi['indirizzo']; - $s_cap = $sedi['cap']; - $s_provincia = $sedi['provincia']; -} - -//Se ho deciso di NON mostrare i prezzi al tencico mi assicuro che non li possa vedere dalla stampa -if (Auth::user()['gruppo'] == 'Tecnici' and $options['pricing'] == true and setting('Mostra i prezzi al tecnico') == 0) { - $options['pricing'] = false; -} diff --git a/templates/liquidazione_iva/body.php b/templates/liquidazione_iva/body.php deleted file mode 100644 index 5417f3ef7..000000000 --- a/templates/liquidazione_iva/body.php +++ /dev/null @@ -1,312 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$totale_iva_vendite = sum(array_column($iva_vendite, 'iva')); -$totale_subtotale_vendite = sum(array_column($iva_vendite, 'subtotale')); -$totale_iva_acquisti = sum(array_column($iva_acquisti, 'iva')); -$totale_subtotale_acquisti = sum(array_column($iva_acquisti, 'subtotale')); - -$totale_iva_esigibile = sum(array_column($iva_vendite_esigibile, 'iva')); -$totale_iva_nonesigibile = sum(array_column($iva_vendite_nonesigibile, 'iva')); -$subtotale_iva_esigibile = sum(array_column($iva_vendite_esigibile, 'subtotale')); -$subtotale_iva_nonesigibile = sum(array_column($iva_vendite_nonesigibile, 'subtotale')); - -$totale_iva_detraibile = sum(array_column($iva_acquisti_detraibile, 'iva')); -$totale_iva_nondetraibile = sum(array_column($iva_acquisti_nondetraibile, 'iva')); -$subtotale_iva_detraibile = sum(array_column($iva_acquisti_detraibile, 'subtotale')); -$subtotale_iva_nondetraibile = sum(array_column($iva_acquisti_nondetraibile, 'subtotale')); - -$totale_iva_vendite_anno_precedente = sum(array_column($iva_vendite_anno_precedente, 'iva')); -$totale_iva_acquisti_anno_precedente = sum(array_column($iva_acquisti_anno_precedente, 'iva')); -$totale_iva_anno_precedente = $totale_iva_vendite_anno_precedente - $totale_iva_acquisti_anno_precedente; - -$totale_iva_vendite_periodo_precedente = sum(array_column($iva_vendite_periodo_precedente, 'iva')); -$totale_iva_acquisti_periodo_precedente = sum(array_column($iva_acquisti_periodo_precedente, 'iva')); -$totale_iva_periodo_precedente = $totale_iva_vendite_periodo_precedente - $totale_iva_acquisti_periodo_precedente; - -$totale_iva = $totale_iva_esigibile - $totale_iva_detraibile; - -if ($periodo == 'Trimestrale' && $totale_iva > 0) { - $maggiorazione = $totale_iva * 0.01; - $totale_iva_maggiorata = $totale_iva + $maggiorazione; -} - -echo ' -
    VENDITE
    - - - - - - - - - - - - - - '; - -foreach ($iva_vendite_esigibile as $record) { - echo ' - - - - - - - '; -} -echo ' - - - - - - - - - -'; - -foreach ($iva_vendite_nonesigibile as $record) { - echo ' - - - - - - - '; -} -echo ' - - - - - - - - - -'; -foreach ($iva_vendite as $record) { - echo ' - - - - - - - '; -} -echo ' - - - - - - - -
    AliquotaNatura IVADescrizioneImponibileImposta
    IVA ESIGIBILE DEL PERIODO
    '.round($record['aliquota']).'%'.$record['cod_iva'].''.$record['descrizione'].''.moneyFormat($record['subtotale']).''.moneyFormat($record['iva']).'
    TOTALI'.moneyFormat($subtotale_iva_esigibile).''.moneyFormat($totale_iva_esigibile).'
    IVA NON ESIGIBILE DEL PERIODO
    '.round($record['aliquota']).'%'.$record['cod_iva'].''.$record['descrizione'].''.moneyFormat($record['subtotale']).''.moneyFormat($record['iva']).'
    TOTALI'.moneyFormat($subtotale_iva_nonesigibile).''.moneyFormat($totale_iva_nonesigibile).'
    RIEPILOGO GENERALE IVA VENDITE
    '.round($record['aliquota']).'%'.$record['cod_iva'].''.$record['descrizione'].''.moneyFormat($record['subtotale']).''.moneyFormat($record['iva']).'
    TOTALE'.moneyFormat($totale_subtotale_vendite).''.moneyFormat($totale_iva_vendite).'
    - - -
    ACQUISTI
    - - - - - - - - - - - - - - '; - -foreach ($iva_acquisti_detraibile as $record) { - echo ' - - - - - - - '; -} -echo ' - - - - - - - - - - -'; - -foreach ($iva_acquisti_nondetraibile as $record) { - echo ' - - - - - - - '; -} -echo ' - - - - - - - - - - -'; -foreach ($iva_acquisti as $record) { - echo ' - - - - - - - '; -} - -echo ' - - - - - - - -
    AliquotaNatura IVADescrizioneImponibileImposta
    IVA DETRAIBILE DEL PERIODO
    '.round($record['aliquota']).'%'.$record['cod_iva'].''.$record['descrizione'].''.moneyFormat($record['subtotale']).''.moneyFormat($record['iva']).'
    TOTALI'.moneyFormat($subtotale_iva_detraibile).''.moneyFormat($totale_iva_detraibile).'
    IVA NON DETRAIBILE DEL PERIODO
    '.round($record['aliquota']).'%'.$record['cod_iva'].''.$record['descrizione'].''.moneyFormat($record['subtotale']).''.moneyFormat($record['iva']).'
    TOTALI'.moneyFormat($subtotale_iva_nondetraibile).''.moneyFormat($totale_iva_nondetraibile).'
    RIEPILOGO GENERALE IVA ACQUISTI
    '.round($record['aliquota']).'%'.$record['cod_iva'].''.$record['descrizione'].''.moneyFormat($record['subtotale']).''.moneyFormat($record['iva']).'
    TOTALE'.moneyFormat($totale_subtotale_acquisti).''.moneyFormat($totale_iva_acquisti).'
    - -
    -
    - - - - - - - - - - - '; - if ($totale_iva_anno_precedente >= 0) { - echo ' '; - } else { - echo ' '; - } - echo ' - - '; - if ($totale_iva_periodo_precedente >= 0) { - echo ' '; - } else { - echo ' '; - } - echo ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - '; - if ($totale_iva >= 0) { - echo ' '; - } else { - echo ' '; - } - echo ' - - - - - - - - - - - - - - - - - - - - - - - - - - -
    PROSPETTO RIEPILOGATIVO DI LIQUIDAZIONE I.V.A.
    DESCRIZIONEIMPORTO
    DEBITO ANNO PRECEDENTECREDITO ANNO PRECEDENTE'.moneyFormat(abs($totale_iva_anno_precedente)).'
    DEBITO PERIODO PRECEDENTECREDITO PERIODO PRECEDENTE'.moneyFormat(abs($totale_iva_periodo_precedente)).'
    TOTALE IVA SU VENDITE ESIGIBILE'.moneyFormat($totale_iva_esigibile).'
    TOTALE IVA OGGETTIVAMENTE NON A DEBITO SU VENDITE'.moneyFormat($totale_iva_nonesigibile).'
    TOTALE IVA SU ACQUISTI DETRAIBILI'.moneyFormat($totale_iva_detraibile).'
    TOTALE IVA OGGETTIVAMENTE INDETRAIBILI SU ACQUISTI'.moneyFormat($totale_iva_nondetraibile).'
    TOTALE IVA DETRAIBILI'.moneyFormat($totale_iva_detraibile).'
    VARIAZIONE DI IMPOSTA RELATIVE A PERIODI PRECEDENTI
    DI CUI INTERESSI PER RAVVEDIMENTO
    DI CUI INTERESSI PER MAGGIORAZIONE TRIMESTRALI
    CREDITO IVA COMPENSABILE
    IVA A DEBITOIVA A CREDITO'.moneyFormat(abs($totale_iva)).'
    CREDITO SPECIALE DI IMPOSTA
    MAGGIORAZIONE 1,00%'.moneyFormat($maggiorazione).'
    IVA A DEBITO CON MAGGIORAZIONE'.moneyFormat($totale_iva_maggiorata).'
    IMPORTO DA VERSARE'.moneyFormat($totale_iva_maggiorata).'
    CREDITO INFRANNUALE DI IMPOSTA CHIESTO A RIMBORSO
    CREDITO INFRANNUALE DA UTILIZZARE IN COMPENSAZIONE
    '; diff --git a/templates/liquidazione_iva/footer.php b/templates/liquidazione_iva/footer.php deleted file mode 100644 index 4c16d9c19..000000000 --- a/templates/liquidazione_iva/footer.php +++ /dev/null @@ -1,34 +0,0 @@ -. - */ - -echo ' - - - - - - -
    - '.tr('Stampato con OpenSTAManager il _DATE_', ['_DATE_' => date('d/m/Y')]).' - - '.tr('Pagina _PAGE_ di _TOTAL_', [ - '_PAGE_' => '{PAGENO}', - '_TOTAL_' => '{nb}', - ]).' -
    '; diff --git a/templates/liquidazione_iva/header.php b/templates/liquidazione_iva/header.php deleted file mode 100644 index b24739379..000000000 --- a/templates/liquidazione_iva/header.php +++ /dev/null @@ -1,40 +0,0 @@ -. - */ - -/** - * Header di default. - * I contenuti di questo file vengono utilizzati per generare l'header delle stampe nel caso non esista un file header.php all'interno della stampa. - * - * Per modificare l'header della stampa basta aggiungere un file header.php all'interno della cartella della stampa con i contenuti da mostrare (vedasi templates/fatture/header.php). - * - * La personalizzazione specifica dell'header deve comunque seguire lo standard della cartella custom: anche se il file header.php non esiste nella stampa originaria, se si vuole personalizzare l'header bisogna crearlo all'interno della cartella custom. - */ -$year_start = date('Y', strtotime($date_start)); -$year_end = date('Y', strtotime($date_end)); - -$esercizio = $year_start == $year_end ? ' - '.tr('Esercizio _YEAR_', [ - '_YEAR_' => $year_end, -]) : ''; - -$titolo = tr('PROSPETTO LIQUIDAZIONE IVA DAL _START_ al _END_', [ - '_START_' => Translator::dateToLocale($date_start), - '_END_' => Translator::dateToLocale($date_end), -], ['upper' => true]); - -echo '
    '.$titolo.'
    '; diff --git a/templates/liquidazione_iva/init.php b/templates/liquidazione_iva/init.php deleted file mode 100644 index b23fd3175..000000000 --- a/templates/liquidazione_iva/init.php +++ /dev/null @@ -1,57 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; -use Carbon\Carbon; - -$date_start = filter('date_start'); -$date_end = filter('date_end'); - -$anno_precedente_start = (new Carbon($date_start))->subYears(1)->format('Y-m-d'); -$anno_precedente_end = (new Carbon($date_end))->subYears(1)->format('Y-m-d'); - -$periodo = $dbo->fetchOne('SELECT valore FROM zz_settings WHERE nome="Liquidazione iva"'); -if ($periodo['valore'] == 'Mensile') { - $periodo_precedente_start = (new Carbon($date_start))->subMonth(1)->format('Y-m-d'); - $periodo_precedente_end = (new Carbon($date_end))->subMonth(1)->format('Y-m-d'); -} else { - $periodo_precedente_start = (new Carbon($date_start))->subMonth(3)->format('Y-m-d'); - $periodo_precedente_end = (new Carbon($date_end))->subMonth(3)->format('Y-m-d'); -} - -$maggiorazione = 0; -$iva_vendite_esigibile = $dbo->fetchArray('SELECT co_iva.codice_natura_fe AS cod_iva, co_iva.percentuale AS aliquota, co_iva.descrizione AS descrizione, SUM((iva+iva_rivalsainps)*(IF(co_tipidocumento.reversed=0, 1, -1))) AS iva, SUM((subtotale-sconto)*(IF(co_tipidocumento.reversed=0, 1, -1))) AS subtotale FROM co_tipidocumento INNER JOIN co_documenti ON co_tipidocumento.id=co_documenti.idtipodocumento INNER JOIN co_righe_documenti ON co_documenti.id=co_righe_documenti.iddocumento INNER JOIN co_iva ON co_righe_documenti.idiva=co_iva.id WHERE co_documenti.split_payment=0 AND idstatodocumento NOT IN (SELECT id FROM co_statidocumento WHERE descrizione="Bozza" OR descrizione="Annullata") AND is_descrizione = 0 AND dir="entrata" AND co_documenti.data_competenza >= '.prepare($date_start).' AND co_documenti.data_competenza <= '.prepare($date_end).' AND idstatodocumento NOT IN (SELECT id FROM co_statidocumento WHERE descrizione="Bozza" OR descrizione="Annullata") GROUP BY idiva'); - -$iva_vendite_nonesigibile = $dbo->fetchArray('SELECT co_iva.codice_natura_fe AS cod_iva, co_iva.percentuale AS aliquota,co_iva.descrizione AS descrizione, SUM((iva+iva_rivalsainps)*(IF(co_tipidocumento.reversed=0, 1, -1))) AS iva, SUM((subtotale-sconto)*(IF(co_tipidocumento.reversed=0, 1, -1))) AS subtotale FROM co_tipidocumento INNER JOIN co_documenti ON co_tipidocumento.id=co_documenti.idtipodocumento INNER JOIN co_righe_documenti ON co_documenti.id=co_righe_documenti.iddocumento INNER JOIN co_iva ON co_righe_documenti.idiva=co_iva.id WHERE co_documenti.split_payment=1 AND idstatodocumento NOT IN (SELECT id FROM co_statidocumento WHERE descrizione="Bozza" OR descrizione="Annullata") AND is_descrizione = 0 AND dir="entrata" AND co_documenti.data_competenza >= '.prepare($date_start).' AND co_documenti.data_competenza <= '.prepare($date_end).' AND idstatodocumento NOT IN (SELECT id FROM co_statidocumento WHERE descrizione="Bozza" OR descrizione="Annullata") GROUP BY idiva'); - -$iva_vendite = $dbo->fetchArray('SELECT co_iva.codice_natura_fe AS cod_iva, co_iva.percentuale AS aliquota,co_iva.descrizione AS descrizione, SUM((iva+iva_rivalsainps)*(IF(co_tipidocumento.reversed=0, 1, -1))) AS iva, SUM((subtotale-sconto)*(IF(co_tipidocumento.reversed=0, 1, -1))) AS subtotale FROM co_tipidocumento INNER JOIN co_documenti ON co_tipidocumento.id=co_documenti.idtipodocumento INNER JOIN co_righe_documenti ON co_documenti.id=co_righe_documenti.iddocumento INNER JOIN co_iva ON co_righe_documenti.idiva=co_iva.id WHERE dir="entrata" AND idstatodocumento NOT IN (SELECT id FROM co_statidocumento WHERE descrizione="Bozza" OR descrizione="Annullata") AND is_descrizione = 0 AND co_documenti.data_competenza >= '.prepare($date_start).' AND co_documenti.data_competenza <= '.prepare($date_end).' AND idstatodocumento NOT IN (SELECT id FROM co_statidocumento WHERE descrizione="Bozza" OR descrizione="Annullata") GROUP BY idiva'); - -$iva_vendite_anno_precedente = $dbo->fetchArray('SELECT co_iva.codice_natura_fe AS cod_iva, co_iva.percentuale AS aliquota,co_iva.descrizione AS descrizione, SUM((iva+iva_rivalsainps)*(IF(co_tipidocumento.reversed=0, 1, -1))) AS iva FROM co_tipidocumento INNER JOIN co_documenti ON co_tipidocumento.id=co_documenti.idtipodocumento INNER JOIN co_righe_documenti ON co_documenti.id=co_righe_documenti.iddocumento INNER JOIN co_iva ON co_righe_documenti.idiva=co_iva.id WHERE dir="entrata" AND idstatodocumento NOT IN (SELECT id FROM co_statidocumento WHERE descrizione="Bozza" OR descrizione="Annullata") AND is_descrizione = 0 AND co_documenti.data_competenza >= '.prepare($anno_precedente_start).' AND co_documenti.data_competenza <= '.prepare($anno_precedente_end).' AND idstatodocumento NOT IN (SELECT id FROM co_statidocumento WHERE descrizione="Bozza" OR descrizione="Annullata") GROUP BY idiva'); - -$iva_vendite_periodo_precedente = $dbo->fetchArray('SELECT co_iva.codice_natura_fe AS cod_iva, co_iva.percentuale AS aliquota,co_iva.descrizione AS descrizione, SUM((iva+iva_rivalsainps)*(IF(co_tipidocumento.reversed=0, 1, -1))) AS iva FROM co_tipidocumento INNER JOIN co_documenti ON co_tipidocumento.id=co_documenti.idtipodocumento INNER JOIN co_righe_documenti ON co_documenti.id=co_righe_documenti.iddocumento INNER JOIN co_iva ON co_righe_documenti.idiva=co_iva.id WHERE dir="entrata" AND idstatodocumento NOT IN (SELECT id FROM co_statidocumento WHERE descrizione="Bozza" OR descrizione="Annullata") AND is_descrizione = 0 AND co_documenti.data_competenza >= '.prepare($periodo_precedente_start).' AND co_documenti.data_competenza <= '.prepare($periodo_precedente_end).' AND idstatodocumento NOT IN (SELECT id FROM co_statidocumento WHERE descrizione="Bozza" OR descrizione="Annullata") GROUP BY idiva'); - -$iva_acquisti_detraibile = $dbo->fetchArray('SELECT co_iva.codice_natura_fe AS cod_iva, co_iva.percentuale AS aliquota,co_iva.descrizione AS descrizione, SUM((iva+iva_rivalsainps)*(IF(co_tipidocumento.reversed=0, 1, -1))) AS iva, SUM((subtotale-sconto)*(IF(co_tipidocumento.reversed=0, 1, -1))) AS subtotale FROM co_tipidocumento INNER JOIN co_documenti ON co_tipidocumento.id=co_documenti.idtipodocumento INNER JOIN co_righe_documenti ON co_documenti.id=co_righe_documenti.iddocumento INNER JOIN co_iva ON co_righe_documenti.idiva=co_iva.id WHERE co_documenti.split_payment=0 AND dir="uscita" AND idstatodocumento NOT IN (SELECT id FROM co_statidocumento WHERE descrizione="Bozza" OR descrizione="Annullata") AND is_descrizione = 0 AND co_documenti.data_competenza >= '.prepare($date_start).' AND co_documenti.data_competenza <= '.prepare($date_end).' AND co_iva.indetraibile = 0 AND idstatodocumento NOT IN (SELECT id FROM co_statidocumento WHERE descrizione="Bozza" OR descrizione="Annullata") GROUP BY idiva'); - -$iva_acquisti_nondetraibile = $dbo->fetchArray('SELECT co_iva.codice_natura_fe AS cod_iva, co_iva.percentuale AS aliquota, co_iva.descrizione AS descrizione, co_iva.indetraibile AS indetraibile, SUM((iva+iva_rivalsainps)*(IF(co_tipidocumento.reversed=0, 1, -1))) AS iva, SUM((subtotale-sconto)*(IF(co_tipidocumento.reversed=0, 1, -1))) AS subtotale FROM co_tipidocumento INNER JOIN co_documenti ON co_tipidocumento.id=co_documenti.idtipodocumento INNER JOIN co_righe_documenti ON co_documenti.id=co_righe_documenti.iddocumento INNER JOIN co_iva ON co_righe_documenti.idiva=co_iva.id WHERE dir="uscita" AND idstatodocumento NOT IN (SELECT id FROM co_statidocumento WHERE descrizione="Bozza" OR descrizione="Annullata") AND is_descrizione = 0 AND co_documenti.data_competenza >= '.prepare($date_start).' AND co_documenti.data_competenza <= '.prepare($date_end).' AND co_iva.indetraibile != 0 AND idstatodocumento NOT IN (SELECT id FROM co_statidocumento WHERE descrizione="Bozza" OR descrizione="Annullata") GROUP BY idiva'); - -$iva_acquisti = $dbo->fetchArray('SELECT co_iva.codice_natura_fe AS cod_iva, co_iva.percentuale AS aliquota,co_iva.descrizione AS descrizione, SUM((iva+iva_rivalsainps)*(IF(co_tipidocumento.reversed=0, 1, -1))) AS iva, SUM((subtotale-sconto)*(IF(co_tipidocumento.reversed=0, 1, -1))) AS subtotale FROM co_tipidocumento INNER JOIN co_documenti ON co_tipidocumento.id=co_documenti.idtipodocumento INNER JOIN co_righe_documenti ON co_documenti.id=co_righe_documenti.iddocumento INNER JOIN co_iva ON co_righe_documenti.idiva=co_iva.id WHERE dir="uscita" AND idstatodocumento NOT IN (SELECT id FROM co_statidocumento WHERE descrizione="Bozza" OR descrizione="Annullata") AND is_descrizione = 0 AND co_documenti.data_competenza >= '.prepare($date_start).' AND co_documenti.data_competenza <= '.prepare($date_end).' AND idstatodocumento NOT IN (SELECT id FROM co_statidocumento WHERE descrizione="Bozza" OR descrizione="Annullata") GROUP BY idiva'); - -$iva_acquisti_anno_precedente = $dbo->fetchArray('SELECT co_iva.codice_natura_fe AS cod_iva, co_iva.percentuale AS aliquota,co_iva.descrizione AS descrizione, SUM((iva+iva_rivalsainps)*(IF(co_tipidocumento.reversed=0, 1, -1))) AS iva FROM co_tipidocumento INNER JOIN co_documenti ON co_tipidocumento.id=co_documenti.idtipodocumento INNER JOIN co_righe_documenti ON co_documenti.id=co_righe_documenti.iddocumento INNER JOIN co_iva ON co_righe_documenti.idiva=co_iva.id WHERE dir="uscita" AND idstatodocumento NOT IN (SELECT id FROM co_statidocumento WHERE descrizione="Bozza" OR descrizione="Annullata") AND is_descrizione = 0 AND co_documenti.data_competenza >= '.prepare($anno_precedente_start).' AND co_documenti.data_competenza <= '.prepare($anno_precedente_end).' AND idstatodocumento NOT IN (SELECT id FROM co_statidocumento WHERE descrizione="Bozza" OR descrizione="Annullata") GROUP BY idiva'); - -$iva_acquisti_periodo_precedente = $dbo->fetchArray('SELECT co_iva.codice_natura_fe AS cod_iva, co_iva.percentuale AS aliquota,co_iva.descrizione AS descrizione, SUM((iva+iva_rivalsainps)*(IF(co_tipidocumento.reversed=0, 1, -1))) AS iva FROM co_tipidocumento INNER JOIN co_documenti ON co_tipidocumento.id=co_documenti.idtipodocumento INNER JOIN co_righe_documenti ON co_documenti.id=co_righe_documenti.iddocumento INNER JOIN co_iva ON co_righe_documenti.idiva=co_iva.id WHERE dir="uscita" AND idstatodocumento NOT IN (SELECT id FROM co_statidocumento WHERE descrizione="Bozza" OR descrizione="Annullata") AND is_descrizione = 0 AND co_documenti.data_competenza >= '.prepare($periodo_precedente_start).' AND co_documenti.data_competenza <= '.prepare($periodo_precedente_end).' AND idstatodocumento NOT IN (SELECT id FROM co_statidocumento WHERE descrizione="Bozza" OR descrizione="Annullata") GROUP BY idiva'); diff --git a/templates/liquidazione_iva/settings.php b/templates/liquidazione_iva/settings.php deleted file mode 100644 index fe6e31828..000000000 --- a/templates/liquidazione_iva/settings.php +++ /dev/null @@ -1,27 +0,0 @@ -. - */ - -$format = (isset($_SESSION['stampe_contabili']['format'])) ? $_SESSION['stampe_contabili']['format'] : 'A4'; -$orientation = (isset($_SESSION['stampe_contabili']['orientation'])) ? $_SESSION['stampe_contabili']['orientation'] : 'L'; - -return [ - 'format' => $format, - 'orientation' => $orientation, - 'font-size' => '11pt', -]; diff --git a/templates/magazzino_inventario/body.php b/templates/magazzino_inventario/body.php deleted file mode 100755 index ccb78148b..000000000 --- a/templates/magazzino_inventario/body.php +++ /dev/null @@ -1,110 +0,0 @@ -. - */ - -use Util\Query; - -include_once __DIR__.'/../../core.php'; - -$id_module = Modules::get('Articoli')['id']; - -// Valori di ricerca -$where['servizio'] = '0'; - -foreach ($_SESSION['module_'.$id_module] as $name => $value) { - if (preg_match('/^search_(.+?)$/', $name, $m)) { - $where[$m[1]] = $value; - } -} - -$period_end = $_SESSION['period_end']; - -$structure = Modules::get($id_module); - -// RISULTATI VISIBILI -Util\Query::setSegments(false); -$query = Query::getQuery($structure, $where, 0, []); - -$query = Modules::replaceAdditionals($id_module, $query); - -// Modifiche alla query principale -$query = preg_replace('/FROM `mg_articoli`/', ' FROM mg_articoli LEFT JOIN (SELECT idarticolo, SUM(qta) AS qta_totale FROM mg_movimenti WHERE data <='.prepare($period_end).' GROUP BY idarticolo) movimenti ON movimenti.idarticolo=mg_articoli.id ', $query); - -$query = preg_replace('/^SELECT /', 'SELECT mg_articoli.prezzo_acquisto,', $query); -$query = preg_replace('/^SELECT /', 'SELECT mg_articoli.prezzo_vendita,', $query); -$query = preg_replace('/^SELECT /', 'SELECT mg_articoli.um,', $query); -$query = preg_replace('/^SELECT /', 'SELECT movimenti.qta_totale,', $query); - -if (post('tipo') == 'nozero') { - $query = str_replace('2=2', '2=2 AND movimenti.qta_totale > 0', $query); -} - -$data = Query::executeAndCount($query); - -echo ' -

    '.tr('Inventario al _DATE_', [ - '_DATE_' => Translator::dateToLocale($period_end), -], ['upper' => true]).'

    - - - - - - - - - - - - - - - '; - -$totali = []; -foreach ($data['results'] as $r) { - $valore_magazzino = $r['prezzo_acquisto'] * $r['qta_totale']; - - echo ' - - - - - - - - - '; - - $totali[] = $valore_magazzino; -} - -// Totali -$totale_acquisto = sum($totali); -$totale_qta = sum(array_column($rs, 'qta_totale')); -echo ' - - - - - - - - - -
    '.tr('Codice', [], ['upper' => true]).''.tr('Categoria', [], ['upper' => true]).''.tr('Descrizione', [], ['upper' => true]).''.tr('Prezzo di vendita', [], ['upper' => true]).''.tr('Q.tà', [], ['upper' => true]).''.tr('Prezzo di acquisto', [], ['upper' => true]).''.tr('Valore totale', [], ['upper' => true]).'
    '.$r['Codice'].''.$r['Categoria'].''.$r['Descrizione'].''.moneyFormat($r['prezzo_vendita']).''.Translator::numberToLocale($r['qta_totale']).' '.$r['um'].''.moneyFormat($r['prezzo_acquisto']).''.moneyFormat($valore_magazzino).'
    '.tr('Totale', [], ['upper' => true]).':'.Translator::numberToLocale($totale_qta).''.moneyFormat($totale_acquisto).'
    '; diff --git a/templates/magazzino_inventario/settings.php b/templates/magazzino_inventario/settings.php deleted file mode 100755 index 4cf7bc47d..000000000 --- a/templates/magazzino_inventario/settings.php +++ /dev/null @@ -1,23 +0,0 @@ -. - */ - -return [ - 'orientation' => 'L', - 'font-size' => '11pt', -]; diff --git a/templates/ordini/body.php b/templates/ordini/body.php deleted file mode 100755 index cdb91b5eb..000000000 --- a/templates/ordini/body.php +++ /dev/null @@ -1,336 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -// Righe documento -$righe = $documento->getRighe(); - -$columns = 7; - -//Immagine solo per documenti di vendita -if ($documento->direzione == 'entrata') { - $has_image = $righe->search(function ($item) { - return !empty($item->articolo->immagine); - }) !== false; - - if ($has_image) { - ++$columns; - $char_number = $options['pricing'] ? 26 : 63; - } -} - -if ($documento->direzione == 'uscita') { - $columns += 2; - $char_number = $options['pricing'] ? 26 : 63; -} else { - $char_number = $options['pricing'] ? 45 : 82; -} -$columns = $options['pricing'] ? $columns : $columns - 3; - -// Creazione righe fantasma -$autofill = new \Util\Autofill($columns, $char_number); -$autofill->setRows(30); - -// Intestazione tabella per righe -echo " - - - - '; - - if ($documento->direzione == 'uscita') { - echo " - - '; - } - - if ($has_image) { - echo " - '; - } - - echo " - - '; - -if ($options['pricing']) { - echo " - - - '; -} - - echo " - - - - - '; - -$num = 0; -foreach ($righe as $riga) { - ++$num; - $r = $riga->toArray(); - - $autofill->count($r['descrizione']); - - echo ' - - '; - - if ($has_image) { - if ($riga->isArticolo() && !empty($riga->articolo->image)) { - echo ' - '; - - $autofill->set(5); - } else { - echo ' - '; - } - } - - if ($documento->direzione == 'uscita') { - echo ' - - '; - } - - echo ' - '; - - if (!$riga->isDescrizione()) { - $qta = $riga->qta; - $um = $r['um']; - - if ($riga->isArticolo() && $documento->direzione == 'uscita' && !empty($riga->articolo->um_secondaria)) { - $um = $riga->articolo->um_secondaria; - $qta *= $riga->articolo->fattore_um_secondaria; - } - - echo ' - '; - - if ($options['pricing']) { - // Prezzo unitario - echo ' - '; - - // Imponibile - echo ' - '; - - // Iva - echo ' - '; - } - - echo ' - '; - } else { - echo ' - '; - - if ($options['pricing']) { - echo ' - - - '; - } - } - - echo ' - '; - - $autofill->next(); -} - -echo ' - |autofill| - '; - -// Calcoli -$imponibile = $documento->imponibile; -$sconto = $documento->sconto; -$totale_imponibile = $documento->totale_imponibile; -$totale_iva = $documento->iva; -$totale = $documento->totale; -$sconto_finale = $documento->getScontoFinale(); -$netto_a_pagare = $documento->netto; - -$show_sconto = $sconto > 0; - -$colspan = 5; -($documento->direzione == 'uscita' ? $colspan += 2 : $colspan); -($has_image ? $colspan++ : $colspan); - -// TOTALE COSTI FINALI -if ($options['pricing']) { - // Totale imponibile - echo ' - - - - - '; - - // Eventuale sconto incondizionato - if ($show_sconto) { - echo ' - - - - - '; - - // Totale imponibile - echo ' - - - - - '; - } - - // IVA - echo ' - - - - - '; - - // TOTALE - echo ' - - - - '; - - if ($sconto_finale) { - // SCONTO FINALE - echo ' - - - - '; - - // NETTO A PAGARE - echo ' - - - - '; - } -} - -echo ' -
    ".tr('#', [], ['upper' => true]).'".tr('Codice', [], ['upper' => true])."".tr('Codice fornitore', [], ['upper' => true]).'".tr('Immagine', [], ['upper' => true]).'".tr('Descrizione', [], ['upper' => true])."".tr('Q.tà', [], ['upper' => true]).'".tr('Prezzo unitario', [], ['upper' => true])."".tr('Imponibile', [], ['upper' => true])."".tr('IVA', [], ['upper' => true]).' (%)".tr('Data evasione', [], ['upper' => true]).'
    - '.$num.' - - - - '.$riga->articolo->codice.' - - '.($riga->articolo ? $riga->articolo->dettaglioFornitore($documento->idanagrafica)->codice_fornitore : '').' - - '.nl2br($r['descrizione']); - - if ($riga->isArticolo()) { - if ($documento->direzione == 'entrata') { - // Codice articolo - $text = tr('COD. _COD_', [ - '_COD_' => $riga->codice, - ]); - echo ' -
    '.$text.''; - - $autofill->count($text, true); - } - - // Seriali - $seriali = $riga->serials; - if (!empty($seriali)) { - $text = tr('SN').': '.implode(', ', $seriali); - echo ' -
    '.$text.''; - - $autofill->count($text, true); - } - } - - echo ' -
    - '.Translator::numberToLocale(abs($qta), 'qta').' '.$um.' - - '.moneyFormat($riga->prezzo_unitario); - - if ($riga->sconto > 0) { - $text = discountInfo($riga, false); - - echo ' -
    '.$text.''; - - $autofill->count($text, true); - } - - echo ' -
    - '.moneyFormat($riga->totale_imponibile).' - - '.Translator::numberToLocale($riga->aliquota->percentuale, 0).' - - '.Translator::dateToLocale($riga->data_evasione).($riga->ora_evasione ? '
    '.Translator::timeToLocale($riga->ora_evasione).'' : '').' -
    - '.tr('Imponibile', [], ['upper' => true]).': - - '.moneyFormat($show_sconto ? $imponibile : $totale_imponibile, 2).' -
    - '.tr('Sconto', [], ['upper' => true]).': - - '.moneyFormat($sconto, 2).' -
    - '.tr('Totale imponibile', [], ['upper' => true]).': - - '.moneyFormat($totale_imponibile, 2).' -
    - '.tr('Totale IVA', [], ['upper' => true]).': - - '.moneyFormat($totale_iva, 2).' -
    - '.tr('Totale documento', [], ['upper' => true]).': - - '.moneyFormat($totale, 2).' -
    - '.tr('Sconto finale', [], ['upper' => true]).': - - '.moneyFormat($sconto_finale, 2).' -
    - '.tr('Netto a pagare', [], ['upper' => true]).': - - '.moneyFormat($netto_a_pagare, 2).' -
    '; - -if (!empty($documento['note'])) { - echo ' -
    -

    '.tr('Note', [], ['upper' => true]).':

    -

    '.nl2br($documento['note']).'

    '; -} diff --git a/templates/ordini/header.php b/templates/ordini/header.php deleted file mode 100755 index a19e8867c..000000000 --- a/templates/ordini/header.php +++ /dev/null @@ -1,88 +0,0 @@ -. - */ - -echo ' -$default_header$ - -
    - - -
    -
    - $tipo_doc$ -
    - - - - - - - - - - - - - - - -
    -

    '.tr('Nr. documento', [], ['upper' => true]).'

    -

    $numero$

    -
    -

    '.tr('Data documento', [], ['upper' => true]).'

    -

    $data$

    -
    -

    '.($documento->direzione == 'entrata' ? tr('Cliente', [], ['upper' => true]) : tr('Fornitore', [], ['upper' => true])).'

    -

    $c_codice$

    -
    -

    '.tr('Foglio', [], ['upper' => true]).'

    -

    {PAGENO}/{nb}

    -
    -

    '.tr('Pagamento', [], ['upper' => true]).'

    -

    $pagamento$

    -
    -
    - - -
    - - - - '; - if (!empty($destinazione)) { - echo ' - - - '; - } - echo ' -
    -

    '.tr('Spett.le', [], ['upper' => true]).'

    -

    $c_ragionesociale$

    -

    $c_indirizzo$
    $c_citta_full$

    -

    $c_telefono$ $c_cellulare$

    -
    -

    '.tr('Destinazione diversa', [], ['upper' => true]).'

    - '.$destinazione.' -
    -
    - - -
    '; diff --git a/templates/ordini/init.php b/templates/ordini/init.php deleted file mode 100755 index 236d10db7..000000000 --- a/templates/ordini/init.php +++ /dev/null @@ -1,68 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Ordini\Ordine; - -$documento = Ordine::find($id_record); - -$id_cliente = $documento['idanagrafica']; - -// Leggo i dati della destinazione (se 0=sede legale, se!=altra sede da leggere da tabella an_sedi) -$destinazione = ''; -if (!empty($documento->idsede)) { - $rsd = $dbo->fetchArray('SELECT (SELECT codice FROM an_anagrafiche WHERE idanagrafica=an_sedi.idanagrafica) AS codice, (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=an_sedi.idanagrafica) AS ragione_sociale, nomesede, indirizzo, indirizzo2, cap, citta, provincia, piva, codice_fiscale, id_nazione FROM an_sedi WHERE idanagrafica='.prepare($id_cliente).' AND id='.prepare($documento->idsede)); - - if (!empty($rsd[0]['nomesede'])) { - $destinazione .= $rsd[0]['nomesede'].'
    '; - } - if (!empty($rsd[0]['indirizzo'])) { - $destinazione .= $rsd[0]['indirizzo'].'
    '; - } - if (!empty($rsd[0]['indirizzo2'])) { - $destinazione .= $rsd[0]['indirizzo2'].'
    '; - } - if (!empty($rsd[0]['cap'])) { - $destinazione .= $rsd[0]['cap'].' '; - } - if (!empty($rsd[0]['citta'])) { - $destinazione .= $rsd[0]['citta']; - } - if (!empty($rsd[0]['provincia'])) { - $destinazione .= ' ('.$rsd[0]['provincia'].')'; - } - if (!empty($rsd[0]['id_nazione'])) { - $nazione = $database->fetchOne('SELECT * FROM an_nazioni WHERE id = '.prepare($rsd[0]['id_nazione'])); - if ($nazione['iso2'] != 'IT') { - $destinazione .= ' - '.$nazione['name']; - } - } -} - -$numero = !empty($documento['numero_esterno']) ? $documento['numero_esterno'] : $documento['numero']; -$pagamento = $dbo->fetchOne('SELECT * FROM co_pagamenti WHERE id = '.prepare($documento->idpagamento)); - -// Sostituzioni specifiche -$custom = [ - 'tipo_doc' => Stringy\Stringy::create($documento->tipo->descrizione)->toUpperCase(), - 'numero' => $numero, - 'data' => Translator::dateToLocale($documento['data']), - 'pagamento' => $pagamento['descrizione'], -]; diff --git a/templates/ordini/settings.php b/templates/ordini/settings.php deleted file mode 100644 index 6cce79752..000000000 --- a/templates/ordini/settings.php +++ /dev/null @@ -1,24 +0,0 @@ -. - */ - -$settings = [ - 'font-size' => 8, -]; - -return $settings; diff --git a/templates/ordini_cons/bottom.php b/templates/ordini_cons/bottom.php deleted file mode 100644 index 0b8906f39..000000000 --- a/templates/ordini_cons/bottom.php +++ /dev/null @@ -1,66 +0,0 @@ -. - */ - -include_once __DIR__.'/../riepilogo_interventi/bottom.php'; - -$budget = get_imponibile_ordine($id_record); - -$rapporto = floatval($budget) - floatval($somma_totale_imponibile); - -if ($pricing && empty($options['dir'])) { - // Totale imponibile - echo ' -'; - - // TOTALE - echo ' - - - - '; - - // BUDGET - echo ' - - - - '; - - // RAPPORTO - echo ' - - - - '; - - echo ' -
    - '.tr('Totale consuntivo (no iva)', [], ['upper' => true]).': - - '.moneyFormat($somma_totale_imponibile).' -
    - '.tr('Budget (no IVA)', [], ['upper' => true]).': - - '.moneyFormat($budget).' -
    - '.tr('Rapporto budget/spesa (no IVA)', [], ['upper' => true]).': - - '.moneyFormat($rapporto).' -
    '; -} diff --git a/templates/ordini_cons/init.php b/templates/ordini_cons/init.php deleted file mode 100644 index 3b09903af..000000000 --- a/templates/ordini_cons/init.php +++ /dev/null @@ -1,30 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Ordini\Ordine; - -$documento = Ordine::find($id_record); -$records = $documento->interventi; - -$id_cliente = $documento['idanagrafica']; -$id_sede = $documento['idsede']; - -$pricing = $options['pricing']; diff --git a/templates/ordini_cons/piece.php b/templates/ordini_cons/piece.php deleted file mode 100644 index adadc8f55..000000000 --- a/templates/ordini_cons/piece.php +++ /dev/null @@ -1,20 +0,0 @@ -. - */ - -include __DIR__.'/../riepilogo_interventi/piece.php'; diff --git a/templates/ordini_cons/top.php b/templates/ordini_cons/top.php deleted file mode 100644 index 4c094801a..000000000 --- a/templates/ordini_cons/top.php +++ /dev/null @@ -1,83 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo ' -
    -
    -
    -

    '.tr('Consuntivo', [], ['upper' => true]).'

    - '.tr('Ordine num. _NUM_ del _DATE_', [ - '_NUM_' => (!empty($documento['numero_esterno']) ? $documento['numero_esterno'] : $documento['numero']), - '_DATE_' => Translator::dateToLocale($documento['data']), - ], ['upper' => true]).' -
    -
    - -
    - - - - - - - - - - - - - - -
    -

    '.tr('Spett.le', [], ['upper' => true]).'

    -

    $c_ragionesociale$

    -

    $c_indirizzo$ $c_citta_full$

    -
    -

    '.tr('Partita IVA', [], ['upper' => true]).'

    -
    - $c_piva$ -
    -

    '.tr('Codice fiscale', [], ['upper' => true]).'

    -
    - $c_codicefiscale$ -
    -
    -
    '; - -// Descrizione -if (!empty($documento['descrizione'])) { - echo ' -

    '.nl2br($documento['descrizione']).'

    -
    '; -} - -echo ' - - - - - - - - - - - '; diff --git a/templates/partitario_mastrino/bottom.php b/templates/partitario_mastrino/bottom.php deleted file mode 100644 index be07e4aef..000000000 --- a/templates/partitario_mastrino/bottom.php +++ /dev/null @@ -1,88 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if (get('lev') == '2' || get('lev') == '3') { - $dare = 0; - $avere = 0; - for ($i = 0; $i < sizeof($records); ++$i) { - if ($records[$i]['totale'] >= 0) { - $dare += $records[$i]['totale']; - } else { - $avere += $records[$i]['totale']; - } - } - echo ' - - - - - - - '; -} elseif (get('lev') == '1') { - $totale_attivo = 0; - $totale_passivo = 0; - for ($i = 0; $i < sizeof($patrimoniale); ++$i) { - if ($patrimoniale[$i]['totale'] >= 0) { - $totale_attivo += $patrimoniale[$i]['totale']; - } else { - $totale_passivo += $patrimoniale[$i]['totale']; - } - } - echo '
    '.tr('Documento', [], ['upper' => true]).''.tr('Imponibile', [], ['upper' => true]).''.tr('Sconto', [], ['upper' => true]).''.tr('Totale imponibile', [], ['upper' => true]).'
    SALDO FINALE'.moneyFormat(abs($dare)).''.moneyFormat(abs($avere)).''.moneyFormat(abs($scalare)).'
    - - - - - - - - '; - - if ($utile_perdita['totale'] <= 0) { - echo ' - - - - - '; - $totale_passivo = abs($totale_passivo + $utile_perdita['totale']); - } else { - echo ' - - - - - '; - $totale_attivo = abs($totale_attivo + $utile_perdita['totale']); - } - - echo ' - - - - - - -
    TOTALE ATTIVITÀ'.moneyFormat(abs($totale_attivo)).'PASSIVITÀ'.moneyFormat(abs($totale_passivo)).'
    UTILE'.moneyFormat(abs($utile_perdita['totale'])).'
    PERDITA'.moneyFormat(abs($utile_perdita['totale'])).'
    TOTALE A PAREGGIO'.moneyFormat(abs($totale_attivo)).'TOTALE A PAREGGIO'.moneyFormat(abs($totale_passivo)).'
    '; -} - -echo ''; diff --git a/templates/partitario_mastrino/footer.php b/templates/partitario_mastrino/footer.php deleted file mode 100644 index 7cd6d6b56..000000000 --- a/templates/partitario_mastrino/footer.php +++ /dev/null @@ -1,34 +0,0 @@ -. - */ - -echo ' - - - - - - -
    - '.tr('Stampato con OpenSTAManager il _DATE_', ['_DATE_' => date('d/m/Y')]).' - - '.tr('Pagina _PAGE_ di _TOTAL_', [ - '_PAGE_' => '{PAGENO}', - '_TOTAL_' => '{nb}', - ]).' -
    '; diff --git a/templates/partitario_mastrino/header.php b/templates/partitario_mastrino/header.php deleted file mode 100644 index 23d49cccf..000000000 --- a/templates/partitario_mastrino/header.php +++ /dev/null @@ -1,41 +0,0 @@ -. - */ - -/* - * Header di default. - * I contenuti di questo file vengono utilizzati per generare l'header delle stampe nel caso non esista un file header.php all'interno della stampa. - * - * Per modificare l'header della stampa basta aggiungere un file header.php all'interno della cartella della stampa con i contenuti da mostrare (vedasi templates/fatture/header.php). - * - * La personalizzazione specifica dell'header deve comunque seguire lo standard della cartella custom: anche se il file header.php non esiste nella stampa originaria, se si vuole personalizzare l'header bisogna crearlo all'interno della cartella custom. - */ -echo ' -
    -
    STAMPA MASTRINO '.Translator::dateToLocale($date_start).' - '.Translator::dateTolocale($date_end).'
    -
    '.$azienda['ragione_sociale'].'
    -
    -'.$conto1['descrizione'].'
    '; -if (get('lev') == '3') { - echo ' - '.$conto2['numero'].' '.$conto2['descrizione'].'
    - '.$conto3['numero'].' '.$conto3['descrizione'].'
    '; -} elseif (get('lev') == '2') { - echo ' - '.$conto2['numero'].' '.$conto2['descrizione'].'
    '; -} diff --git a/templates/partitario_mastrino/init.php b/templates/partitario_mastrino/init.php deleted file mode 100644 index a705f2d66..000000000 --- a/templates/partitario_mastrino/init.php +++ /dev/null @@ -1,41 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; -$azienda = $dbo->fetchOne('SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica='.setting('Azienda predefinita')); -$date_start = $_SESSION['period_start']; -$date_end = $_SESSION['period_end']; - -if (get('lev') == '3') { - $conto3 = $dbo->fetchOne('SELECT * FROM co_pianodeiconti3 WHERE id='.prepare($id_record)); - $conto2 = $dbo->fetchOne('SELECT * FROM co_pianodeiconti2 WHERE id='.prepare($conto3['idpianodeiconti2'])); - $conto1 = $dbo->fetchOne('SELECT * FROM co_pianodeiconti1 WHERE id='.prepare($conto2['idpianodeiconti1'])); - // Movimenti - $records = $dbo->fetchArray('SELECT * FROM co_movimenti WHERE idconto='.prepare($id_record).' AND co_movimenti.data>='.prepare($date_start).' AND co_movimenti.data<='.prepare($date_end).' ORDER BY co_movimenti.data'); -} elseif (get('lev') == '2') { - $records = $dbo->fetchArray('SELECT CONCAT(co_pianodeiconti3.numero, " ",co_pianodeiconti3.descrizione) AS descrizione, SUM(totale) AS totale FROM `co_movimenti` INNER JOIN co_pianodeiconti3 ON co_movimenti.idconto=co_pianodeiconti3.id WHERE idconto IN(SELECT id FROM co_pianodeiconti3 WHERE idpianodeiconti2='.prepare($id_record).') AND co_movimenti.data>='.prepare($date_start).' AND co_movimenti.data<='.prepare($date_end).' GROUP BY idconto HAVING totale!=0'); - $conto2 = $dbo->fetchOne('SELECT * FROM co_pianodeiconti2 WHERE id='.prepare($id_record)); - $conto1 = $dbo->fetchOne('SELECT * FROM co_pianodeiconti1 WHERE id='.prepare($conto2['idpianodeiconti1'])); -} elseif (get('lev') == '1') { - $records = $dbo->fetchArray('SELECT CONCAT(co_pianodeiconti2.numero, " ", co_pianodeiconti2.descrizione) AS titolo, CONCAT(co_pianodeiconti3.numero, " ",co_pianodeiconti3.descrizione) AS descrizione, SUM(totale) AS totale FROM `co_movimenti` INNER JOIN co_pianodeiconti3 ON co_movimenti.idconto=co_pianodeiconti3.id INNER JOIN co_pianodeiconti2 ON co_pianodeiconti3.idpianodeiconti2=co_pianodeiconti2.id WHERE idconto IN(SELECT id FROM co_pianodeiconti3 WHERE idpianodeiconti2 IN(SELECT id FROM co_pianodeiconti2 WHERE idpianodeiconti1='.prepare($id_record).')) AND co_movimenti.data>='.prepare($date_start).' AND co_movimenti.data<='.prepare($date_end).' GROUP BY idconto HAVING totale!=0 ORDER BY co_pianodeiconti2.numero'); - $conto1 = $dbo->fetchOne('SELECT * FROM co_pianodeiconti1 WHERE id='.prepare($id_record)); - $utile_perdita = $dbo->fetchOne('SELECT SUM(totale) AS totale FROM `co_movimenti` WHERE idconto IN(SELECT id FROM co_pianodeiconti3 WHERE idpianodeiconti2 IN(SELECT id FROM co_pianodeiconti2 WHERE idpianodeiconti1=(SELECT id FROM co_pianodeiconti1 WHERE descrizione="Economico")))AND co_movimenti.data>='.prepare($date_start).' AND co_movimenti.data<='.prepare($date_end)); - $patrimoniale = $dbo->fetchArray('SELECT CONCAT(co_pianodeiconti2.numero, " ", co_pianodeiconti2.descrizione) AS titolo, CONCAT(co_pianodeiconti3.numero, " ",co_pianodeiconti3.descrizione) AS descrizione, SUM(totale) AS totale FROM `co_movimenti` INNER JOIN co_pianodeiconti3 ON co_movimenti.idconto=co_pianodeiconti3.id INNER JOIN co_pianodeiconti2 ON co_pianodeiconti3.idpianodeiconti2=co_pianodeiconti2.id WHERE idconto IN(SELECT id FROM co_pianodeiconti3 WHERE idpianodeiconti2 IN(SELECT id FROM co_pianodeiconti2 WHERE idpianodeiconti1=(SELECT id FROM co_pianodeiconti1 WHERE descrizione="Patrimoniale"))) AND co_movimenti.data>='.prepare($date_start).' AND co_movimenti.data<='.prepare($date_end).' GROUP BY idconto HAVING totale!=0 ORDER BY co_pianodeiconti2.numero'); -} -$prev_titolo = ''; diff --git a/templates/partitario_mastrino/piece.php b/templates/partitario_mastrino/piece.php deleted file mode 100644 index fc030ea03..000000000 --- a/templates/partitario_mastrino/piece.php +++ /dev/null @@ -1,49 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -if ($record['titolo'] != $prev_titolo && get('lev') == 1) { - echo ' - - '.$record['titolo'].' - '; -} - -echo ' - - '.Translator::dateToLocale($record['data']).' - '.$record['descrizione'].''; - - if ($record['totale'] >= 0) { - echo ''.moneyFormat(abs($record['totale']), 2).' - '; - } else { - echo ' - '.moneyFormat(abs($record['totale']), 2).''; - } - - $scalare += $record['totale']; - - echo ' - - '.moneyFormat($scalare, 2).' - '; -echo ''; -$prev_titolo = $record['titolo']; diff --git a/templates/partitario_mastrino/settings.php b/templates/partitario_mastrino/settings.php deleted file mode 100644 index 0cb945cbc..000000000 --- a/templates/partitario_mastrino/settings.php +++ /dev/null @@ -1,22 +0,0 @@ -. - */ - -return [ - 'font-size' => '11pt', -]; diff --git a/templates/partitario_mastrino/top.php b/templates/partitario_mastrino/top.php deleted file mode 100644 index 187332633..000000000 --- a/templates/partitario_mastrino/top.php +++ /dev/null @@ -1,35 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo ' - - - - - - - - - - - '; - - $scalare = 0; diff --git a/templates/pdfgen_variables.php b/templates/pdfgen_variables.php deleted file mode 100755 index 86fc7456b..000000000 --- a/templates/pdfgen_variables.php +++ /dev/null @@ -1,57 +0,0 @@ -. - */ - -include_once __DIR__.'/info.php'; - -// Retrocompatibilità con le stampe gestite da HTML2PDF -$replaces['default_header'] = str_replace(['{PAGENO}', '{nb}'], ['[[page_cu]]', '[[page_nb]]'], $replaces['default_header']); - -$replaces['footer'] = str_replace(['{PAGENO}', '{nb}'], ['[[page_cu]]', '[[page_nb]]'], $replaces['footer']); -$replaces['default_footer'] = str_replace(['{PAGENO}', '{nb}'], ['[[page_cu]]', '[[page_nb]]'], $replaces['default_footer']); - -$prefixes = [ - 'c_', - 'f_', -]; - -foreach ($prefixes as $prefix) { - if ($replaces[$prefix.'piva'] != $replaces[$prefix.'codicefiscale']) { - $replaces[$prefix.'piva'] = !empty($replaces[$prefix.'piva']) ? 'P.Iva: '.$replaces[$prefix.'piva'] : ''; - $replaces[$prefix.'codicefiscale'] = !empty($replaces[$prefix.'codicefiscale']) ? 'C.F.: '.$replaces[$prefix.'codicefiscale'] : ''; - } else { - $replaces[$prefix.'piva'] = !empty($replaces[$prefix.'piva']) ? 'P.Iva/C.F.: '.$replaces[$prefix.'piva'] : ''; - $replaces[$prefix.'codicefiscale'] = ''; - } - - $replaces[$prefix.'codice_destinatario'] = !empty($replaces[$prefix.'codice_destinatario']) ? 'Cod.Fatturazione: '.$replaces[$prefix.'codice_destinatario'] : ''; - $replaces[$prefix.'capsoc'] = !empty($replaces[$prefix.'capsoc']) ? 'Cap.Soc.: '.$replaces[$prefix.'capsoc'] : ''; - $replaces[$prefix.'sitoweb'] = !empty($replaces[$prefix.'sitoweb']) ? 'Web: '.$replaces[$prefix.'sitoweb'] : ''; - $replaces[$prefix.'telefono'] = !empty($replaces[$prefix.'telefono']) ? 'Tel: '.$replaces[$prefix.'telefono'] : ''; - $replaces[$prefix.'fax'] = !empty($replaces[$prefix.'fax']) ? 'Fax: '.$replaces[$prefix.'fax'] : ''; - $replaces[$prefix.'cellulare'] = !empty($replaces[$prefix.'cellulare']) ? 'Cell: '.$replaces[$prefix.'cellulare'] : ''; - $replaces[$prefix.'email'] = !empty($replaces[$prefix.'email']) ? 'Email: '.$replaces[$prefix.'email'] : ''; - $replaces[$prefix.'codiceiban'] = !empty($replaces[$prefix.'codiceiban']) ? 'IBAN: '.$replaces[$prefix.'codiceiban'] : ''; - $replaces[$prefix.'pec'] = !empty($replaces[$prefix.'pec']) ? 'PEC: '.$replaces[$prefix.'pec'] : ''; - - foreach ($replaces as $key => $value) { - if (string_starts_with($key, $prefix)) { - $replaces[$key] = empty($value) ? $value : $value.'
    '; - } - } -} diff --git a/templates/preventivi/body.php b/templates/preventivi/body.php deleted file mode 100755 index 95a809470..000000000 --- a/templates/preventivi/body.php +++ /dev/null @@ -1,443 +0,0 @@ -. - */ - -use Carbon\CarbonInterval; -use Modules\Anagrafiche\Anagrafica; - -include_once __DIR__.'/../../core.php'; - -$has_images = null; - -// Righe documento -$righe = $documento->getRighe(); - -foreach ($righe as $riga) { - if ($riga->articolo->immagine) { - $has_images = 1; - } -} - -$anagrafica = Anagrafica::find($documento['idanagrafica']); -$pagamento = $dbo->fetchOne('SELECT * FROM co_pagamenti WHERE id = '.prepare($documento['idpagamento'])); - -//Verifico se c'è una banca predefinita per il mio cliente -if (!empty($anagrafica->idbanca_vendite)) { - $banca = $dbo->fetchOne('SELECT co_banche.nome, co_banche.iban, co_banche.bic FROM co_banche INNER JOIN co_pianodeiconti3 ON co_banche.id_pianodeiconti3 = co_pianodeiconti3.id WHERE co_pianodeiconti3.id = '.prepare($pagamento['idconto_vendite']).' AND co_banche.id ='.prepare($anagrafica->idbanca_vendite)); -} elseif (!empty($pagamento['idconto_vendite'])) { - //Altrimenti prendo quella associata la metodo di pagamento selezionato - $banca = $dbo->fetchOne('SELECT co_banche.nome, co_banche.iban, co_banche.bic FROM co_banche INNER JOIN co_pianodeiconti3 ON co_banche.id_pianodeiconti3 = co_pianodeiconti3.id WHERE co_pianodeiconti3.id = '.prepare($pagamento['idconto_vendite']).' AND co_banche.deleted_at IS NULL'); -} - -// Creazione righe fantasma -$autofill = new \Util\Autofill($options['pricing'] ? (($has_images) ? 7 : 6) : 3); -$autofill->setRows(20, 10); - -echo ' -
    -
    -
    - '.tr('Preventivo num. _NUM_ del _DATE_', [ - '_NUM_' => $documento['numero'].(count($documento->revisioni) > 1 ? ' '.tr('rev.').' '.$documento->numero_revision : ''), - '_DATE_' => Translator::dateToLocale($documento['data_bozza']), - ], ['upper' => true]).' -
    - -
    DATADESCRIZIONEDAREAVERESCALARE
    - - - - - - - - -
    -

    '.tr('Pagamento', [], ['upper' => true]).'

    -

    '.$pagamento['descrizione'].'

    -
    -

    '.tr('Banca di appoggio', [], ['upper' => true]).'

    -

    '.$banca['nome'].'

    -
    -

    '.tr('IBAN').'

    -

    '.$banca['iban'].'

    -
    -

    '.tr('BIC').'

    -

    '.$banca['bic'].'

    -
    - - -
    - - - - - - - - - - - - - - '; - if (!empty($destinazione)) { - echo ' - - - '; - } - echo ' -
    -

    '.tr('Spett.le', [], ['upper' => true]).'

    -

    $c_ragionesociale$

    -

    $c_indirizzo$

    -

    $c_citta_full$

    -
    -

    '.tr('Partita IVA', [], ['upper' => true]).'

    -
    - $c_piva$ -
    -

    '.tr('Codice fiscale', [], ['upper' => true]).'

    -
    - $c_codicefiscale$ -
    -

    '.tr('Destinazione diversa', [], ['upper' => true]).'

    - '.$destinazione.' -
    -
    -'; - -// Descrizione -if (!empty($documento['descrizione'])) { - echo ' -

    '.nl2br($documento['descrizione']).'

    -
    '; -} - -// Intestazione tabella per righe -echo " - - - - "; - -if ($has_images) { - echo " - "; -} - -echo " - - '; - -if ($options['pricing']) { - echo " - - - '; -} - -echo ' - - - - '; - -$num = 0; -foreach ($righe as $riga) { - ++$num; - $r = $riga->toArray(); - - $autofill->count($r['descrizione']); - - echo ' - - '; - - if ($has_images) { - echo ''; - } - - echo ' - '; - - if (!$riga->isDescrizione()) { - echo ' - '; - - if ($options['pricing']) { - // Prezzo unitario - echo ' - '; - - // Imponibile - echo ' - '; - - // Iva - echo ' - '; - } - } else { - echo ' - '; - - if ($options['pricing']) { - echo ' - - - '; - } - } - - echo ' - '; - - $autofill->next(); -} - -echo ' - |autofill| - '; - -// Calcoli -$imponibile = $documento->imponibile; -$sconto = $documento->sconto; -$totale_imponibile = $documento->totale_imponibile; -$totale_iva = $documento->iva; -$totale = $documento->totale; -$sconto_finale = $documento->getScontoFinale(); -$netto_a_pagare = $documento->netto; - -$show_sconto = $sconto > 0; - -// TOTALE COSTI FINALI -if (($options['pricing'] && !isset($options['hide_total'])) || $options['show_only_total']) { - // Totale imponibile - echo ' - - - - - '; - - // Eventuale sconto incondizionato - if ($show_sconto) { - echo ' - - - - - '; - - // Totale imponibile - echo ' - - - - - '; - } - - // IVA - echo ' - - - - - '; - - // TOTALE - echo ' - - - - '; - - if ($sconto_finale) { - // SCONTO FINALE - echo ' - - - - '; - - // NETTO A PAGARE - echo ' - - - - '; - } -} - -echo ' -
    #Foto".tr('Descrizione', [], ['upper' => true])."".tr('Q.tà', [], ['upper' => true]).'".tr('Prezzo unitario', [], ['upper' => true])."".tr('Importo', [], ['upper' => true])."".tr('IVA', [], ['upper' => true]).' (%)
    - '.$num.' - '; - if (!empty($riga->articolo->immagine)) { - echo ''; - } - - echo ' - '.nl2br($r['descrizione']); - - if ($riga->isArticolo()) { - // Codice articolo - $text = tr('COD. _COD_', [ - '_COD_' => $riga->codice, - ]); - echo ' -
    '.$text.''; - - $autofill->count($text, true); - } - - echo ' -
    - '.Translator::numberToLocale(abs($riga->qta), 'qta').' '.$r['um'].' - - '.moneyFormat($riga->prezzo_unitario); - - if ($riga->sconto > 0) { - $text = discountInfo($riga, false); - - echo ' -
    '.$text.''; - - $autofill->count($text, true); - } - - echo ' -
    - '.moneyFormat($riga->totale_imponibile).' - - '.Translator::numberToLocale($riga->aliquota->percentuale, 0).' -
    - '.tr('Imponibile', [], ['upper' => true]).': - - '.moneyFormat($show_sconto ? $imponibile : $totale_imponibile, 2).' -
    - '.tr('Sconto', [], ['upper' => true]).': - - '.moneyFormat($sconto, 2).' -
    - '.tr('Totale imponibile', [], ['upper' => true]).': - - '.moneyFormat($totale_imponibile, 2).' -
    - '.tr('Totale IVA', [], ['upper' => true]).': - - '.moneyFormat($totale_iva, 2).' -
    - '.tr('Totale documento', [], ['upper' => true]).': - - '.moneyFormat($totale, 2).' -
    - '.tr('Sconto finale', [], ['upper' => true]).': - - '.moneyFormat($sconto_finale, 2).' -
    - '.tr('Netto a pagare', [], ['upper' => true]).': - - '.moneyFormat($netto_a_pagare, 2).' -
    '; - -// CONDIZIONI GENERALI DI FORNITURA - -echo ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - '.tr('Condizioni generali di fornitura', [], ['upper' => true]).' -
    - '.tr('Pagamento', [], ['upper' => true]).' - - '.$pagamento['descrizione'].' -
    - '.tr('Validità offerta', [], ['upper' => true]).' - '; - - if (!empty($documento->validita) && !empty($documento->tipo_validita)) { - $intervallo = CarbonInterval::make($documento->validita.' '.$documento->tipo_validita); - - echo $intervallo->forHumans(); - } elseif (!empty($documento->validita)) { - echo tr('_TOT_ giorni', [ - '_TOT_' => $documento->validita, - ]); - } else { - echo '-'; - } - - echo ' -
    - '.tr('Tempi consegna', [], ['upper' => true]).' - - '.$documento['tempi_consegna'].' -
    - '.tr('Esclusioni', [], ['upper' => true]).' - - '.nl2br($documento['esclusioni']).' -
    - '.tr('Garanzia', [], ['upper' => true]).' - - '.nl2br($documento['garanzia']).' -
    '; - -// Conclusione -echo ' -

    '.tr("In attesa di un Vostro Cortese riscontro, colgo l'occasione per porgere Cordiali Saluti").'

    '; - -if (!empty($documento->condizioni_fornitura)) { - echo ''.$documento->condizioni_fornitura; -} diff --git a/templates/preventivi/footer.php b/templates/preventivi/footer.php deleted file mode 100755 index 81623bfaf..000000000 --- a/templates/preventivi/footer.php +++ /dev/null @@ -1,37 +0,0 @@ -. - */ - -if (!$is_last_page) { - return; -} - -echo ' - - - - - - -
    - '.tr('lì').', ___________________________ - - '.tr('Firma per accettazione', [], ['upper' => true]).'

    - _____________________________________________ -
    -
    '; diff --git a/templates/preventivi/init.php b/templates/preventivi/init.php deleted file mode 100755 index 2693e8467..000000000 --- a/templates/preventivi/init.php +++ /dev/null @@ -1,57 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Preventivi\Preventivo; - -$documento = Preventivo::find($id_record); - -$id_cliente = $documento['idanagrafica']; - -// Leggo i dati della destinazione (se 0=sede legale, se!=altra sede da leggere da tabella an_sedi) -$destinazione = ''; -if (!empty($documento->idsede)) { - $rsd = $dbo->fetchArray('SELECT (SELECT codice FROM an_anagrafiche WHERE idanagrafica=an_sedi.idanagrafica) AS codice, (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=an_sedi.idanagrafica) AS ragione_sociale, nomesede, indirizzo, indirizzo2, cap, citta, provincia, piva, codice_fiscale, id_nazione FROM an_sedi WHERE idanagrafica='.prepare($id_cliente).' AND id='.prepare($documento->idsede)); - - if (!empty($rsd[0]['nomesede'])) { - $destinazione .= $rsd[0]['nomesede'].'
    '; - } - if (!empty($rsd[0]['indirizzo'])) { - $destinazione .= $rsd[0]['indirizzo'].'
    '; - } - if (!empty($rsd[0]['indirizzo2'])) { - $destinazione .= $rsd[0]['indirizzo2'].'
    '; - } - if (!empty($rsd[0]['cap'])) { - $destinazione .= $rsd[0]['cap'].' '; - } - if (!empty($rsd[0]['citta'])) { - $destinazione .= $rsd[0]['citta']; - } - if (!empty($rsd[0]['provincia'])) { - $destinazione .= ' ('.$rsd[0]['provincia'].')'; - } - if (!empty($rsd[0]['id_nazione'])) { - $nazione = $database->fetchOne('SELECT * FROM an_nazioni WHERE id = '.prepare($rsd[0]['id_nazione'])); - if ($nazione['iso2'] != 'IT') { - $destinazione .= ' - '.$nazione['name']; - } - } -} diff --git a/templates/preventivi/settings.php b/templates/preventivi/settings.php deleted file mode 100755 index bcd7fc26d..000000000 --- a/templates/preventivi/settings.php +++ /dev/null @@ -1,22 +0,0 @@ -. - */ - -return [ - 'footer-height' => 35, -]; diff --git a/templates/preventivi_cons/bottom.php b/templates/preventivi_cons/bottom.php deleted file mode 100755 index 2eaa78f91..000000000 --- a/templates/preventivi_cons/bottom.php +++ /dev/null @@ -1,66 +0,0 @@ -. - */ - -include_once __DIR__.'/../riepilogo_interventi/bottom.php'; - -$budget = get_imponibile_preventivo($id_record); - -$rapporto = floatval($budget) - floatval($somma_totale_imponibile); - -if ($pricing && empty($options['dir'])) { - // Totale imponibile - echo ' -'; - - // TOTALE - echo ' - - - - '; - - // BUDGET - echo ' - - - - '; - - // RAPPORTO - echo ' - - - - '; - - echo ' -
    - '.tr('Totale consuntivo (no iva)', [], ['upper' => true]).': - - '.moneyFormat($somma_totale_imponibile).' -
    - '.tr('Budget (no IVA)', [], ['upper' => true]).': - - '.moneyFormat($budget).' -
    - '.tr('Rapporto budget/spesa (no IVA)', [], ['upper' => true]).': - - '.moneyFormat($rapporto).' -
    '; -} diff --git a/templates/preventivi_cons/init.php b/templates/preventivi_cons/init.php deleted file mode 100755 index 780f165fe..000000000 --- a/templates/preventivi_cons/init.php +++ /dev/null @@ -1,30 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Preventivi\Preventivo; - -$documento = Preventivo::find($id_record); -$records = $documento->interventi; - -$id_cliente = $documento['idanagrafica']; -$id_sede = $documento['idsede']; - -$pricing = $options['pricing']; diff --git a/templates/preventivi_cons/piece.php b/templates/preventivi_cons/piece.php deleted file mode 100755 index adadc8f55..000000000 --- a/templates/preventivi_cons/piece.php +++ /dev/null @@ -1,20 +0,0 @@ -. - */ - -include __DIR__.'/../riepilogo_interventi/piece.php'; diff --git a/templates/preventivi_cons/top.php b/templates/preventivi_cons/top.php deleted file mode 100755 index 602ca3e52..000000000 --- a/templates/preventivi_cons/top.php +++ /dev/null @@ -1,83 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo ' -
    -
    -
    -

    '.tr('Consuntivo', [], ['upper' => true]).'

    - '.tr('Preventivo num. _NUM_ del _DATE_', [ - '_NUM_' => $documento['numero'].(count($documento->revisioni) > 1 ? ' '.tr('rev.').' '.$documento->numero_revision : ''), - '_DATE_' => Translator::dateToLocale($documento['data_bozza']), - ], ['upper' => true]).' -
    -
    - -
    - - - - - - - - - - - - - - -
    -

    '.tr('Spett.le', [], ['upper' => true]).'

    -

    $c_ragionesociale$

    -

    $c_indirizzo$ $c_citta_full$

    -
    -

    '.tr('Partita IVA', [], ['upper' => true]).'

    -
    - $c_piva$ -
    -

    '.tr('Codice fiscale', [], ['upper' => true]).'

    -
    - $c_codicefiscale$ -
    -
    -
    '; - -// Descrizione -if (!empty($documento['descrizione'])) { - echo ' -

    '.nl2br($documento['descrizione']).'

    -
    '; -} - -echo ' - - - - - - - - - - - '; diff --git a/templates/registro_iva/bottom.php b/templates/registro_iva/bottom.php deleted file mode 100755 index 31c90fd01..000000000 --- a/templates/registro_iva/bottom.php +++ /dev/null @@ -1,75 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$totale_iva = sum(array_column($records, 'iva')); -$totale_subtotale = sum(array_column($records, 'subtotale')); - -echo ' - -
    '.tr('Documento', [], ['upper' => true]).''.tr('Imponibile', [], ['upper' => true]).''.tr('Sconto', [], ['upper' => true]).''.tr('Totale imponibile', [], ['upper' => true]).'
    - -

    -

    '.tr('Riepilogo IVA', [], ['upper' => true]).'

    - - - - - - - - - - - '; - -foreach ($iva as $descrizione => $tot_iva) { - if (!empty($descrizione)) { - $somma_iva = sum($iva[$descrizione]); - $somma_totale = sum($totale[$descrizione]); - - echo ' - - - - - - - '; - } -} - -echo ' - - - - - - - -
    '.tr('Iva').''.tr('Imponibile').''.tr('Imposta').'
    - '.$descrizione.' - - '.moneyFormat($somma_totale).' - - '.moneyFormat($somma_iva).' -
    - '.tr('Totale', [], ['upper' => true]).': - '.moneyFormat($totale_subtotale).''.moneyFormat($totale_iva).'
    '; diff --git a/templates/registro_iva/footer.php b/templates/registro_iva/footer.php deleted file mode 100755 index 4c16d9c19..000000000 --- a/templates/registro_iva/footer.php +++ /dev/null @@ -1,34 +0,0 @@ -. - */ - -echo ' - - - - - - -
    - '.tr('Stampato con OpenSTAManager il _DATE_', ['_DATE_' => date('d/m/Y')]).' - - '.tr('Pagina _PAGE_ di _TOTAL_', [ - '_PAGE_' => '{PAGENO}', - '_TOTAL_' => '{nb}', - ]).' -
    '; diff --git a/templates/registro_iva/init.php b/templates/registro_iva/init.php deleted file mode 100755 index 4201667d1..000000000 --- a/templates/registro_iva/init.php +++ /dev/null @@ -1,57 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$dir = $_GET['dir']; - -$id_sezionale = filter('id_sezionale'); -$sezionale = $dbo->fetchOne('SELECT name FROM zz_segments WHERE id = '.$id_sezionale)['name']; - -$date_start = filter('date_start'); -$date_end = filter('date_end'); - -$tipo = $dir == 'entrata' ? 'vendite' : 'acquisti'; - -$v_iva = []; -$v_totale = []; - -$query = 'SELECT *, - co_movimenti.id AS idmovimenti, co_documenti.id AS id, - IF(numero = "", numero_esterno, numero) AS numero, - (SELECT IF(co_tipidocumento.reversed=0, SUM(subtotale - sconto), (SUM(subtotale - sconto)*-1)) FROM co_righe_documenti AS righe2 WHERE righe2.iddocumento=co_documenti.id AND righe2.idiva=co_righe_documenti.idiva GROUP BY iddocumento) AS subtotale, - (SELECT IF(co_tipidocumento.reversed=0, SUM(subtotale - sconto + iva + rivalsainps - ritenutaacconto), (SUM(subtotale - sconto + iva + rivalsainps - ritenutaacconto)*-1)) FROM co_righe_documenti AS righe2 WHERE righe2.iddocumento=co_documenti.id AND righe2.idiva=co_righe_documenti.idiva GROUP BY iddocumento) AS totale, - (SELECT IF(co_tipidocumento.reversed=0, SUM(iva+iva_rivalsainps), (SUM(iva+iva_rivalsainps)*-1)) FROM co_righe_documenti AS righe2 WHERE righe2.iddocumento=co_documenti.id AND righe2.idiva=co_righe_documenti.idiva GROUP BY iddocumento) AS iva, - an_anagrafiche.ragione_sociale, - an_anagrafiche.codice AS codice_anagrafica -FROM co_movimenti - INNER JOIN co_documenti ON co_movimenti.iddocumento=co_documenti.id - INNER JOIN co_righe_documenti ON co_documenti.id=co_righe_documenti.iddocumento - INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id - INNER JOIN co_iva ON co_righe_documenti.idiva=co_iva.id - INNER JOIN an_anagrafiche ON an_anagrafiche.idanagrafica = co_documenti.idanagrafica -WHERE dir = '.prepare($dir).' AND idstatodocumento NOT IN (SELECT id FROM co_statidocumento WHERE descrizione="Bozza" OR descrizione="Annullata") AND is_descrizione = 0 AND co_documenti.data_registrazione >= '.prepare($date_start).' AND co_documenti.data_registrazione <= '.prepare($date_end).' AND '.((!empty($id_sezionale)) ? 'co_documenti.id_segment = '.prepare($id_sezionale).'' : '1=1').' -GROUP BY co_documenti.id, co_righe_documenti.idiva -ORDER BY CAST(co_documenti.'.(($dir == 'entrata') ? 'data' : 'numero').' AS '.(($dir == 'entrata') ? 'DATE' : 'UNSIGNED').'), co_documenti.'.(($dir == 'entrata') ? 'numero_esterno' : 'data_registrazione'); -$records = $dbo->fetchArray($query); - -// Sostituzioni specifiche -$custom = [ - 'tipo' => $tipo, -]; diff --git a/templates/registro_iva/piece.php b/templates/registro_iva/piece.php deleted file mode 100755 index 12d692d4e..000000000 --- a/templates/registro_iva/piece.php +++ /dev/null @@ -1,42 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo ' -'; - -echo ' - '.str_pad($record['idmovimenti'], 8, '0', STR_PAD_LEFT).' - '.Translator::datetoLocale($record['data_registrazione']).' - '.$record['numero_esterno'].' - '.Translator::datetoLocale($record['data']).' - '.$record['codice_tipo_documento_fe'].' - '.$record['codice_anagrafica'].' / '.safe_truncate(mb_strtoupper(html_entity_decode($record['ragione_sociale']), 'UTF-8'), 50).' - '.moneyFormat($record['totale']).''; - -echo ' - '.moneyFormat($record['subtotale']).' - '.Translator::numberToLocale($record['percentuale'], 0).' - '.$record['desc_iva'].' - '.moneyFormat($record['iva']).' - '; - -$iva[$record['desc_iva']][] = $record['iva']; -$totale[$record['desc_iva']][] = $record['subtotale']; diff --git a/templates/registro_iva/settings.php b/templates/registro_iva/settings.php deleted file mode 100755 index fe6e31828..000000000 --- a/templates/registro_iva/settings.php +++ /dev/null @@ -1,27 +0,0 @@ -. - */ - -$format = (isset($_SESSION['stampe_contabili']['format'])) ? $_SESSION['stampe_contabili']['format'] : 'A4'; -$orientation = (isset($_SESSION['stampe_contabili']['orientation'])) ? $_SESSION['stampe_contabili']['orientation'] : 'L'; - -return [ - 'format' => $format, - 'orientation' => $orientation, - 'font-size' => '11pt', -]; diff --git a/templates/registro_iva/top.php b/templates/registro_iva/top.php deleted file mode 100755 index a5c7138e3..000000000 --- a/templates/registro_iva/top.php +++ /dev/null @@ -1,65 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$year_start = date('Y', strtotime($date_start)); -$year_end = date('Y', strtotime($date_end)); - -$esercizio = $year_start == $year_end ? ' - '.tr('Esercizio _YEAR_', [ - '_YEAR_' => $year_end, -]) : ''; - -if ('entrata' == $dir) { - $titolo = tr('Registro iva vendita dal _START_ al _END_ _SEZIONALE_', [ - '_START_' => Translator::dateToLocale($date_start), - '_END_' => Translator::dateToLocale($date_end), - '_SEZIONALE_' => (!empty($sezionale)) ? ' - '.$sezionale : '', - ], ['upper' => true]); -} elseif ('uscita' == $dir) { - $titolo = tr('Registro iva acquisto dal _START_ al _END_ _SEZIONALE_', [ - '_START_' => Translator::dateToLocale($date_start), - '_END_' => Translator::dateToLocale($date_end), - '_SEZIONALE_' => (!empty($sezionale)) ? ' - '.$sezionale : '', - ], ['upper' => true]); -} - -$tipo = $dir == 'entrata' ? tr('Cliente') : tr('Fornitore'); -$i = 0; - -echo '

    '.$titolo.'

    - - - - - - - - - - - - - - - - - - - '; diff --git a/templates/replace.php b/templates/replace.php deleted file mode 100755 index 00c022f72..000000000 --- a/templates/replace.php +++ /dev/null @@ -1,35 +0,0 @@ -. - */ - -/** - * Sostituisce a delle stringhe ($nome_stringa$) i valori delle anagrafiche. - */ -$replaces = array_merge($replaces, (array) $custom); - -foreach ($replaces as $key => $value) { - $new_key = '$'.str_replace('$', '', $key).'$'; - unset($replaces[$key]); - - $replaces[$new_key] = $value; -} - -// Sostituisce alle variabili del template i valori -$head = str_replace(array_keys($replaces), array_values($replaces), $head); -$foot = str_replace(array_keys($replaces), array_values($replaces), $foot); -$report = str_replace(array_keys($replaces), array_values($replaces), $report); diff --git a/templates/riepilogo_interventi/bottom.php b/templates/riepilogo_interventi/bottom.php deleted file mode 100755 index be25d24de..000000000 --- a/templates/riepilogo_interventi/bottom.php +++ /dev/null @@ -1,37 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$somma_imponibile = sum($somma_imponibile); -$somma_sconto = sum($somma_sconto); -$somma_totale_imponibile = sum($somma_totale_imponibile); - -echo ' - - - - - - - - -
    '.tr('Prot.').''.tr('Data reg.').''.tr('No doc.').''.tr('Data doc.').''.tr('Tipo').''.$tipo.''.tr('Tot. doc.').''.tr('Imponibile').'%'.tr('Iva').''.tr('Imposta').'
    - '.tr('Totale', [], ['upper' => true]).': - '.($pricing ? moneyFormat($somma_imponibile, 2) : '-').''.($pricing ? moneyFormat($somma_sconto, 2) : '-').''.($pricing ? moneyFormat($somma_totale_imponibile, 2) : '-').'
    '; diff --git a/templates/riepilogo_interventi/footer.php b/templates/riepilogo_interventi/footer.php deleted file mode 100755 index 7cd6d6b56..000000000 --- a/templates/riepilogo_interventi/footer.php +++ /dev/null @@ -1,34 +0,0 @@ -. - */ - -echo ' - - - - - - -
    - '.tr('Stampato con OpenSTAManager il _DATE_', ['_DATE_' => date('d/m/Y')]).' - - '.tr('Pagina _PAGE_ di _TOTAL_', [ - '_PAGE_' => '{PAGENO}', - '_TOTAL_' => '{nb}', - ]).' -
    '; diff --git a/templates/riepilogo_interventi/init.php b/templates/riepilogo_interventi/init.php deleted file mode 100755 index 561ed572a..000000000 --- a/templates/riepilogo_interventi/init.php +++ /dev/null @@ -1,54 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$date_start = $_SESSION['period_start']; -$date_end = $_SESSION['period_end']; - -$module = Modules::get('Interventi'); -$id_module = $module['id']; - -$total = Util\Query::readQuery($module); - -// Lettura parametri modulo -$module_query = $total['query']; - -$search_filters = []; - -if (is_array($_SESSION['module_'.$id_module])) { - foreach ($_SESSION['module_'.$id_module] as $field => $value) { - if (!empty($value) && string_starts_with($field, 'search_')) { - $field_name = str_replace('search_', '', $field); - $field_name = str_replace('__', ' ', $field_name); - $field_name = str_replace('-', ' ', $field_name); - array_push($search_filters, '`'.$field_name.'` LIKE "%'.$value.'%"'); - } - } -} - -if (!empty($search_filters)) { - $module_query = str_replace('2=2', '2=2 AND ('.implode(' AND ', $search_filters).') ', $module_query); -} - -// Filtri derivanti dai permessi (eventuali) -$module_query = Modules::replaceAdditionals($id_module, $module_query); - -// Scadenze -$records = $dbo->fetchArray($module_query); diff --git a/templates/riepilogo_interventi/piece.php b/templates/riepilogo_interventi/piece.php deleted file mode 100755 index e1add7af5..000000000 --- a/templates/riepilogo_interventi/piece.php +++ /dev/null @@ -1,113 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -use Modules\Interventi\Intervento; - -$intervento = Intervento::find($record['id']); - -$imponibile = empty($options['dir']) ? $intervento->imponibile : $intervento->spesa; -$sconto = empty($options['dir']) ? $intervento->sconto : 0; -$totale_imponibile = empty($options['dir']) ? $intervento->totale_imponibile : $intervento->spesa; - -$somma_imponibile[] = $imponibile; -$somma_sconto[] = $sconto; -$somma_totale_imponibile[] = $totale_imponibile; - -$pricing = isset($pricing) ? $pricing : true; - -// Informazioni intervento -echo ' - - '; - -if (dateFormat($intervento->inizio)) { - echo ' -

    '.tr('Intervento _NUM_ del _DATE_', [ - '_NUM_' => $intervento->codice, - '_DATE_' => dateFormat($intervento->inizio), - ]).'

    '; -} else { - echo ' -

    '.tr('Promemoria _NUM_', [ - '_NUM_' => $intervento->codice, - ]).'

    '; -} -echo ' -

    '.tr('Cliente').': '.$intervento->anagrafica->ragione_sociale.'

    -

    '.tr('Stato').': '.$intervento->stato->descrizione.'

    -

    '.tr('Data richiesta').': '.dateFormat($intervento->data_richiesta).'

    -

    '.tr('Richiesta').': '.$intervento->richiesta.'

    - - '.($pricing ? moneyFormat($imponibile, 2) : '-').' - '.($pricing && empty($options['dir']) ? moneyFormat($sconto, 2) : '-').' - '.($pricing ? moneyFormat($totale_imponibile, 2) : '-').' -'; - -// Sessioni -$sessioni = $intervento->sessioni; -if (count($sessioni) > 0) { - echo ' - - - '.tr('Sessioni').' - '.tr('Data').' - '.tr('Inizio').' - '.tr('Fine').' -'; - - foreach ($sessioni as $sessione) { - echo ' - - - '.$sessione->anagrafica->ragione_sociale.' ('.$sessione->tipo->descrizione.') - '.dateFormat($sessione->orario_inizio).' - '.timeFormat($sessione->orario_inizio).' - '.timeFormat($sessione->orario_fine).' -'; - } -} - -// Righe -$righe = $intervento->getRighe(); -if (!$righe->isEmpty()) { - echo ' - - - '.tr('Materiale utilizzato e spese aggiuntive').' - '.tr('Qta').' - '.tr('Prezzo unitario').' - '.tr('Imponibile').' -'; - - foreach ($righe as $riga) { - $prezzo = empty($options['dir']) ? $riga->prezzo_unitario : $riga->costo_unitario; - $totale = empty($options['dir']) ? $riga->totale_imponibile : $riga->spesa; - - echo ' - - - '.$riga->descrizione.' - '.$riga->qta.' '.$riga->um.' - '.($pricing ? moneyFormat($prezzo) : '-').' - '.($pricing ? moneyFormat($totale) : '-').' -'; - } -} diff --git a/templates/riepilogo_interventi/top.php b/templates/riepilogo_interventi/top.php deleted file mode 100755 index bd29564b7..000000000 --- a/templates/riepilogo_interventi/top.php +++ /dev/null @@ -1,38 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo ' -

    '.tr('Riepilogo interventi dal _START_ al _END_', [ - '_START_' => Translator::dateToLocale($date_start), - '_END_' => Translator::dateToLocale($date_end), - ], ['upper' => true]).'

    - - - - - - - - - - - - '; diff --git a/templates/scadenzario/bottom.php b/templates/scadenzario/bottom.php deleted file mode 100755 index caf24fe8e..000000000 --- a/templates/scadenzario/bottom.php +++ /dev/null @@ -1,34 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$totale_da_pagare = sum(array_column($records, 'Importo')); -$totale_pagato = sum(array_column($records, 'Pagato')); - -echo ' - - - - - - -
    '.tr('Documento', [], ['upper' => true]).''.tr('Imponibile', [], ['upper' => true]).''.tr('Sconto', [], ['upper' => true]).''.tr('Totale imponibile', [], ['upper' => true]).'
    - '.tr('Totale', [], ['upper' => true]).': - '.moneyFormat($totale_da_pagare, 2).''.moneyFormat($totale_pagato, 2).'
    '; diff --git a/templates/scadenzario/footer.php b/templates/scadenzario/footer.php deleted file mode 100755 index 7cd6d6b56..000000000 --- a/templates/scadenzario/footer.php +++ /dev/null @@ -1,34 +0,0 @@ -. - */ - -echo ' - - - - - - -
    - '.tr('Stampato con OpenSTAManager il _DATE_', ['_DATE_' => date('d/m/Y')]).' - - '.tr('Pagina _PAGE_ di _TOTAL_', [ - '_PAGE_' => '{PAGENO}', - '_TOTAL_' => '{nb}', - ]).' -
    '; diff --git a/templates/scadenzario/init.php b/templates/scadenzario/init.php deleted file mode 100755 index 42f529dc4..000000000 --- a/templates/scadenzario/init.php +++ /dev/null @@ -1,56 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$date_start = $_SESSION['period_start']; -$date_end = $_SESSION['period_end']; - -$module = Modules::get('Scadenzario'); -$id_module = $module['id']; - -$total = Util\Query::readQuery($module); - -// Lettura parametri modulo -$module_query = $total['query']; - -$search_filters = []; - -if (is_array($_SESSION['module_'.$id_module])) { - foreach ($_SESSION['module_'.$id_module] as $field => $value) { - if (!empty($value) && string_starts_with($field, 'search_')) { - $field_name = str_replace('search_', '', $field); - $field_name = str_replace('__', ' ', $field_name); - $field_name = str_replace('-', ' ', $field_name); - array_push($search_filters, '`'.$field_name.'` LIKE "%'.$value.'%"'); - } - } -} - -if (!empty($search_filters)) { - $module_query = str_replace('2=2', '2=2 AND ('.implode(' AND ', $search_filters).') ', $module_query); -} - -$module_query = str_replace('1=1', '1=1 AND ABS(`co_scadenziario`.`pagato`) < ABS(`co_scadenziario`.`da_pagare`) ', $module_query); - -// Filtri derivanti dai permessi (eventuali) -$module_query = Modules::replaceAdditionals($id_module, $module_query); - -// Scadenze -$records = $dbo->fetchArray($module_query); diff --git a/templates/scadenzario/piece.php b/templates/scadenzario/piece.php deleted file mode 100755 index 01fe07129..000000000 --- a/templates/scadenzario/piece.php +++ /dev/null @@ -1,33 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo ' - - - '.$record['Rif. Fattura'].'
    - '.Translator::dateToLocale($record['Data emissione']).' - - '.$record['Anagrafica'].' - '.$record['Tipo di pagamento'].' - '.Translator::dateToLocale($record['Data scadenza']).' - '.moneyFormat($record['Importo'], 2).' - '.moneyFormat($record['Pagato'], 2).' - '; diff --git a/templates/scadenzario/settings.php b/templates/scadenzario/settings.php deleted file mode 100755 index 4cf7bc47d..000000000 --- a/templates/scadenzario/settings.php +++ /dev/null @@ -1,23 +0,0 @@ -. - */ - -return [ - 'orientation' => 'L', - 'font-size' => '11pt', -]; diff --git a/templates/scadenzario/top.php b/templates/scadenzario/top.php deleted file mode 100755 index cd27ddf36..000000000 --- a/templates/scadenzario/top.php +++ /dev/null @@ -1,44 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -echo ' -

    '.tr('Scadenze dal _START_ al _END_', [ - '_START_' => Translator::dateToLocale($date_start), - '_END_' => Translator::dateToLocale($date_end), - ], ['upper' => true]).'

    - - - - - - - - - - - - - - '; - -$somma_imponibile = []; -$somma_sconto = []; -$somma_totale_imponibile = []; diff --git a/templates/spesometro/body.php b/templates/spesometro/body.php deleted file mode 100755 index d03d137e7..000000000 --- a/templates/spesometro/body.php +++ /dev/null @@ -1,196 +0,0 @@ -. - */ - -include_once __DIR__.'/../../core.php'; - -$date_start = $_SESSION['period_start']; -$date_end = $_SESSION['period_end']; - -// Intestazione tabella per righe -echo " -

    ".tr('Spesometro dal _START_ al _END_', [ - '_START_' => Translator::dateToLocale($date_start), - '_END_' => Translator::dateToLocale($date_end), -], ['upper' => true])."

    - -
    '.tr('Documento', [], ['upper' => true]).''.tr('Anagrafica', [], ['upper' => true]).''.tr('Tipo di pagamento', [], ['upper' => true]).''.tr('Data scadenza', [], ['upper' => true]).''.tr('Importo', [], ['upper' => true]).''.tr('Già pagato', [], ['upper' => true]).'
    - - - - - - - - - - - - - '; - -$imponibile = []; -$iva = []; -$totale = []; - -$anagrafiche = $dbo->fetchArray('SELECT idanagrafica, piva, ragione_sociale FROM `an_anagrafiche` WHERE `idanagrafica` IN (SELECT DISTINCT `idanagrafica` FROM `co_documenti` WHERE co_documenti.data>='.prepare($date_start).' AND co_documenti.data<='.prepare($date_end).' AND `co_documenti`.`id` IN (SELECT `iddocumento` FROM co_movimenti WHERE primanota = 1)) ORDER BY `ragione_sociale`'); - -foreach ($anagrafiche as $i => $anagrafica) { - $fatture = $dbo->fetchArray('SELECT `co_documenti`.*, `co_tipidocumento`.`descrizione` AS tipo_documento, `co_tipidocumento`.`dir` FROM `co_documenti` JOIN `co_tipidocumento` ON `co_tipidocumento`.`id` = `co_documenti`.`idtipodocumento` WHERE `co_documenti`.`idanagrafica` = '.prepare($anagrafica['idanagrafica']).' AND `co_documenti`.`id` IN (SELECT `iddocumento` FROM co_movimenti WHERE primanota = 1) AND co_documenti.data>='.prepare($date_start).' AND co_documenti.data<='.prepare($date_end).' ORDER BY `data`'); - - $num = 0; - foreach ($fatture as $key => $fattura) { - $righe = $dbo->fetchArray('SELECT `idiva`, `desc_iva`, SUM(subtotale) - SUM(sconto) AS imponibile, SUM(iva) AS iva, SUM(subtotale) - SUM(sconto) + SUM(iva) AS totale FROM `co_righe_documenti` WHERE iddocumento='.prepare($fattura['id']).' GROUP BY `idiva`, `desc_iva` ORDER BY `idiva`'); - - $fatture[$key]['righe'] = $righe; - $num += count($righe); - } - - $extra = ($i % 2) != 0 ? ' class="row-bg"' : ''; - - if ($num > 0) { - echo ' - - '; - - // Partita IVA - echo ' - '; - - $count = 0; - foreach ($fatture as $fattura) { - $descrizione = tr('_DOC_ num. _NUM_ del _DATE_', [ - '_DOC_' => $fattura['tipo_documento'], - '_NUM_' => !empty($fattura['numero_esterno']) ? $fattura['numero_esterno'] : $fattura['numero'], - '_DATE_' => Translator::dateToLocale($fattura['data']), - ]); - - // Documenti replicati per IVA - foreach ($fattura['righe'] as $riga) { - if ($count != 0) { - echo ' - '; - } - ++$count; - - // Documento - echo ' - '; - - // Descrizione IVA - echo ' - '; - - // Imponible - echo ' - '; - - // IVA - echo ' - '; - - // Totale - echo ' - - '; - - if (empty($iva[$riga['desc_iva']])) { - $iva[$riga['desc_iva']] = []; - } - - $imponibile[] = $riga['imponibile']; - $iva[$riga['desc_iva']][] = $riga['iva']; - $totale[] = $riga['totale']; - } - } - } -} - -echo ' - '; - -// Totale imponibile -echo ' - - - - - '; - -foreach ($iva as $desc => $values) { - $sum = sum($values); - // Totale IVA - echo ' - - - - -'; - - $totale_iva += $sum; -} - -// Totale IVA -echo ' - - - - - '; - -// TOTALE -echo ' - - - - '; - -echo ' -
    ".tr('Ragione sociale', [], ['upper' => true])."".tr('P.Iva', [], ['upper' => true])."".tr('Documento', [], ['upper' => true])."".tr('Aliquota', [], ['upper' => true])."".tr('Imponibile', [], ['upper' => true])."".tr('IVA', [], ['upper' => true])."".tr('Totale', [], ['upper' => true]).'
    - '.$anagrafica['ragione_sociale'].' - - '.$anagrafica['piva'].' - - '.$descrizione.' - - '.$riga['desc_iva'].' - - '.moneyFormat($riga['imponibile']).' - - '.moneyFormat($riga['iva']).' - - '.moneyFormat($riga['totale']).' -
    - '.tr('Imponibile', [], ['upper' => true]).': - - '.moneyFormat(sum($imponibile)).' -
    - '.tr('IVA "_TYPE_"', [ - '_TYPE_' => $desc, - ], ['upper' => true]).': - - '.moneyFormat($sum).' -
    - '.tr('Totale IVA', [], ['upper' => true]).': - - '.moneyFormat($totale_iva).' -
    - '.tr('Totale', [], ['upper' => true]).': - - '.moneyFormat(sum($totale)).' -
    '; diff --git a/templates/spesometro/header.php b/templates/spesometro/header.php deleted file mode 100755 index 340ebbd4e..000000000 --- a/templates/spesometro/header.php +++ /dev/null @@ -1,34 +0,0 @@ -. - */ - -echo ' - -
    -
    -

    $f_ragionesociale$

    -

    $f_indirizzo$ $f_citta_full$

    -

    '.(!empty($f_piva) ? tr('P.Iva').': ' : '').'$f_piva$

    -

    '.(!empty($f_codicefiscale) ? tr('C.F.').': ' : '').'$f_codicefiscale$

    -

    '.(!empty($f_capsoc) ? tr('Cap.Soc.').': ' : '').'$f_capsoc$

    -

    '.(!empty($f_telefono) ? tr('Tel').': ' : '').'$f_telefono$

    -
    -
    - Logo -
    -
    '; diff --git a/templates/spesometro/settings.php b/templates/spesometro/settings.php deleted file mode 100755 index 207c06fc8..000000000 --- a/templates/spesometro/settings.php +++ /dev/null @@ -1,22 +0,0 @@ -. - */ - -return [ - 'orientation' => 'L', -]; diff --git a/tests/_output/.gitignore b/tests/_output/.gitignore deleted file mode 100755 index c96a04f00..000000000 --- a/tests/_output/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php deleted file mode 100755 index 173de9ed6..000000000 --- a/tests/_support/AcceptanceTester.php +++ /dev/null @@ -1,110 +0,0 @@ -retryClick($link, $context); - - $t->waitForElementNotVisible('#main_loading'); - $t->waitForElementNotVisible('#mini-loader'); - } - - /** - * Clicca sul pulsante e attende la conclusione del caricamento del modal. - * - * @param $link - * @param $context - */ - public function clickAndWaitModal($link, $context = null) - { - $t = $this; - - $t->clickAndWait($link, $context); - - $t->waitForElementVisible('.modal'); - $t->wait(1); - } - - /** - * Clicca sul pulsante dentro il modal. - * - * @param $link - */ - public function clickModalButton($link) - { - $t = $this; - - $t->clickAndWait($link, '.modal-content'); - } - - /** - * Clicca sul pulsante e attende la conclusione del caricamento del modal SWAL. - * - * @param $link - * @param $context - */ - public function clickAndWaitSwal($link, $context = null) - { - $t = $this; - - $t->clickAndWait($link, $context); - - $t->waitForElementVisible('.swal2-modal'); - } - - /** - * Clicca sul pulsante dentro il modal SWAL. - * - * @param $link - */ - public function clickSwalButton($link) - { - $t = $this; - - $t->clickAndWait($link, '.swal2-buttonswrapper'); - } - - public function navigateTo($link) - { - $this->wait(0.5); - - $this->clickAndWait($link, '.sidebar'); - } - - /** - * Effettua il login dalla pagina principale. - * - * @param string $username - * @param string $password - */ - public function login($username, $password) - { - $t = $this; - - // Operazioni di login - $t->amOnPage('/'); - - $t->fillField('username', $username); - $t->fillField('password', $password); - - $t->clickAndWait('Accedi'); - - // Controlla il completamento del login - $t->see($username, '.user-panel'); - - // Rimozione barra di debug - $t->executeJS('$(".phpdebugbar-close-btn").click()'); - } -} diff --git a/tests/_support/FunctionalTester.php b/tests/_support/FunctionalTester.php deleted file mode 100755 index e3a9dd03c..000000000 --- a/tests/_support/FunctionalTester.php +++ /dev/null @@ -1,26 +0,0 @@ -getModule('\Helper\Select2'); - - $select2->openSelect2($selector); - $select2->selectOptionForSelect2($selector, $option, $timeout); - $select2->closeSelect2($selector); - } - - /** - * Imposta il valore di un select gestito dal framework Select2. - * - * @param $selector - * @param $option - * @param int $timeout seconds. Default to 1 - */ - public function select2ajax($selector, $option, $timeout = null) - { - $select2 = $this->getModule('\Helper\Select2Ajax'); - $t = $this->getAcceptanceModule(); - - $select2->openSelect2($selector); - $t->wait(1); - $select2->selectByPosition($selector, $option, $timeout); - $select2->closeSelect2($selector); - } - - public function seePageHasElement($element) - { - try { - $this->getAcceptanceModule()->seeElement($element); - } catch (\Exception $f) { - return false; - } - - return true; - } - - public function expandSidebarLink($link) - { - $t = $this->getAcceptanceModule(); - - if (!$this->seePageHasElement("descendant-or-self::*[@class and contains(concat(' ', normalize-space(@class), ' '), ' sidebar ')]/descendant-or-self::*/li[contains(., '".$link."') and @class and contains(concat(' ', normalize-space(@class), ' '), ' menu-open ')]")) { - $t->click($link, '.sidebar'); - $t->wait(1); - } - } - - protected function getAcceptanceModule() - { - if (!$this->hasModule('WebDriver')) { - throw new \Exception('You must enable the WebDriver module', 1); - } - - return $this->getModule('WebDriver'); - } -} diff --git a/tests/_support/Helper/Common/RowHelper.php b/tests/_support/Helper/Common/RowHelper.php deleted file mode 100755 index b93a006f8..000000000 --- a/tests/_support/Helper/Common/RowHelper.php +++ /dev/null @@ -1,225 +0,0 @@ -wait(0.5); - - // Apre il modal - $t->clickAndWaitModal('Sconto/maggiorazione', '#tab_0'); - - $t->fillField('#descrizione_riga', $descrizione); - - if ($type == 'UNT') { - $t->fillField('#sconto_unitario', $value); - } else { - $t->fillField('#sconto_percentuale', $value); - } - - // Effettua il submit - $t->clickAndWait('Aggiungi', '.modal'); - - // Controlla il salvataggio finale - $t->see('Sconto/maggiorazione aggiunto'); - } - - /** - * Aggiunge una nuova riga. - * - * @param string $descrizione - * @param int $qta - * @param float $prezzo - * @param int $sconto - * @param string $tipo_sconto - * @param int $id_iva - * @param int $id_rivalsa_inps - * @param int $id_ritenuta_acconto - */ - public function addRow(AcceptanceTester $t, $descrizione, $qta, $prezzo, $sconto = 0, $tipo_sconto = 'UNT', $id_iva = null, $id_rivalsa_inps = null, $id_ritenuta_acconto = null) - { - $t->wait(0.5); - - // Apre il modal - $t->clickAndWaitModal('Riga', '#tab_0'); - - $this->fill($t, $descrizione, $qta, $prezzo, $sconto, $tipo_sconto, $id_iva, $id_rivalsa_inps, $id_ritenuta_acconto); - - // Effettua il submit - $t->clickAndWait('Aggiungi', '.modal'); - - // Controlla il salvataggio finale - $t->see('Riga aggiunta'); - } - - /** - * Aggiunge un nuovo articolo. - * - * @param string $descrizione - * @param int $qta - * @param float $prezzo - * @param int $sconto - * @param string $tipo_sconto - * @param int $id_iva - * @param int $id_rivalsa_inps - * @param int $id_ritenuta_acconto - */ - public function addArticle(AcceptanceTester $t, $id_articolo, $descrizione, $qta, $prezzo, $sconto = 0, $tipo_sconto = 'UNT', $id_iva = null, $id_rivalsa_inps = null, $id_ritenuta_acconto = null) - { - $t->wait(0.5); - - // Apre il modal - $t->clickAndWaitModal('Articolo', '#tab_0'); - - $t->select2ajax('#idarticolo', $id_articolo); - $this->fill($t, $descrizione, $qta, $prezzo, $sconto, $tipo_sconto, $id_iva, $id_rivalsa_inps, $id_ritenuta_acconto); - - // Effettua il submit - $t->clickAndWait('Aggiungi', '.modal'); - - // Controlla il salvataggio finale - $t->see('Articolo aggiunto'); - } - - /** - * Undocumented function. - */ - public function testImporti(AcceptanceTester $t, $direzione = 'entrata') - { - $this->dir = $direzione; - - // Righe di test (issue #98) - $this->addRow($t, 'Riga 1', 1, 34); - - $this->addRow($t, 'Riga 2', 1, 17.44); - $this->addRow($t, 'Riga 3', 48, 0.52); - $this->addRow($t, 'Riga 4', 66, 0.44); - $this->addRow($t, 'Riga 5', 1, 104.90); - $this->addRow($t, 'Riga 6', 1, 2); - - $t->see('212,34', $this->getFinalValue('Imponibile')); - $t->see('46,71', $this->getFinalValue('IVA')); - $t->see('259,05', $this->getFinalValue('Totale')); - - // Righe di controllo sugli sconti - $this->addRow($t, 'Riga 7 con sconto in euro', 15, 12, 2); - $this->addRow($t, 'Riga 8 con sconto percentuale', 15, 10, 20, 'PRC'); - - $t->see('542,34', $this->getFinalValue('Imponibile')); - $t->see('60,00', $this->getFinalValue('Sconto')); - $t->see('482,34', $this->getFinalValue('Totale imponibile')); - $t->see('106,11', $this->getFinalValue('IVA')); - $t->see('588,45', $this->getFinalValue('Totale')); - - // Sconto globale in euro - $this->addDiscount($t, 'Sconto unitario', 100, 'UNT'); - - $t->see('542,34', $this->getFinalValue('Imponibile')); - $t->see('160,00', $this->getFinalValue('Sconto')); - $t->see('382,34', $this->getFinalValue('Totale imponibile')); - $t->see('84,11', $this->getFinalValue('IVA')); - $t->see('466,45', $this->getFinalValue('Totale')); - - // Sconto globale in percentuale - $this->addDiscount($t, null, 10, 'PRC'); - - $this->delete($t, 'Sconto unitario'); - - $t->see('542,34', $this->getFinalValue('Imponibile')); - $t->see('98,23', $this->getFinalValue('Sconto')); - $t->see('444,11', $this->getFinalValue('Totale imponibile')); - $t->see('97,70', $this->getFinalValue('IVA')); - $t->see('541,81', $this->getFinalValue('Totale')); - } - - /** - * Completa le informazioni per la creazione di un nuovo elemento. - * - * @param [type] $descrizione - * @param [type] $qta - * @param [type] $prezzo - * @param int $sconto - * @param string $tipo_sconto - * @param [type] $id_iva - * @param [type] $id_rivalsa_inps - * @param [type] $id_ritenuta_acconto - */ - protected function fill(AcceptanceTester $t, $descrizione, $qta, $prezzo, $sconto = 0, $tipo_sconto = 'UNT', $id_iva = null, $id_rivalsa_inps = null, $id_ritenuta_acconto = null) - { - $t->fillField('#descrizione_riga', $descrizione); - $t->fillField('#qta', $qta); - - $t->fillField('#prezzo_unitario', $prezzo); - - if (!empty($sconto)) { - $t->fillField('#sconto', $sconto); - - if (in_array($tipo_sconto, ['PRC', 'UNT'])) { - $t->select2ajax('#tipo_sconto', $tipo_sconto == 'PRC' ? 0 : 1); - } - } - - if ($id_iva) { - $t->select2('#idiva', $id_iva); - } - - if ($id_rivalsa_inps) { - $t->select2('#id_rivalsa_inps', $id_rivalsa_inps); - } - if ($id_ritenuta_acconto) { - $t->select2('#id_ritenuta_acconto', $id_ritenuta_acconto); - } - } - - protected function delete(AcceptanceTester $t, $descrizione) - { - $path = $this->getPattern($descrizione).'//td[last()]'; - - $t->wait(0.5); - $t->click('.btn-danger', $path); - $t->acceptPopup(); - - $t->waitForElementNotVisible('#main_loading'); - $t->waitForElementNotVisible('#mini-loader'); - - $t->see('Riga eliminata!'); - - //$t->click('#save', '#tab_0'); - } - - /** - * Undocumented function. - * - * @param string $pattern - */ - protected function setPattern($pattern) - { - $this->tablePattern = $pattern; - } - - protected function getPattern($name) - { - return str_replace('|name|', $name, $this->tablePattern); - } - - protected function getFinalValue($name) - { - $name = strtoupper($name); - - return $this->getPattern($name).'//td[2]'; - } -} diff --git a/tests/_support/Helper/Functional.php b/tests/_support/Helper/Functional.php deleted file mode 100755 index 57e511334..000000000 --- a/tests/_support/Helper/Functional.php +++ /dev/null @@ -1,10 +0,0 @@ - -// Author: Florian Krämer -// Author: Tom Walsh -// License: MIT -// -// Installation: -// * Put this file in your 'tests/_support/Helper' directory -// * Add it in your 'tests/acceptance.suite.yml' file, like this: -// class_name: AcceptanceTester -// modules: -// enabled: -// - WebDriver: -// url: 'http://localhost:8000' -// # ... -// - \Helper\Select2 -// -// * Then run ./vendor/bin/codecept build - -class Select2 extends \Codeception\Module -{ - /** - * Wait until the select2 component is loaded. - * - * @param $selector - * @param int $timeout seconds. Default to 5 - */ - public function waitForSelect2($selector, $timeout = 5) - { - $t = $this->getAcceptanceModule(); - $selector = $this->getSelect2Selector($selector); - $t->waitForJS('return !!jQuery("'.$selector.'").data("select2");', $timeout); - } - - /** - * Checks that the given option is not selected. - * - * @param $selector - * @param $optionText - * @param int $timeout seconds. Default to 5 - */ - public function dontSeeOptionIsSelectedForSelect2($selector, $optionText, $timeout = 5) - { - $t = $this->getAcceptanceModule(); - $selector = $this->getSelect2Selector($selector); - $this->waitForSelect2($selector, $timeout); - $script = $this->_optionIsSelectedForSelect2($selector, $optionText, false); - $t->waitForJS($script, $timeout); - } - - /** - * Checks that the given option is selected. - * - * @param $selector - * @param $optionText - * @param int $timeout seconds. Default to 5 - */ - public function seeOptionIsSelectedForSelect2($selector, $optionText, $timeout = 5) - { - $t = $this->getAcceptanceModule(); - $selector = $this->getSelect2Selector($selector); - $this->waitForSelect2($selector, $timeout); - $script = $this->_optionIsSelectedForSelect2($selector, $optionText); - $t->waitForJS($script, $timeout); - } - - /** - * Selects an option in a select2 component. - * - * $t->selectOptionForSelect2('#my_select2', 'Option value'); - * $t->selectOptionForSelect2('#my_select2', ['Option value 1', 'Option value 2']); - * $t->selectOptionForSelect2('#my_select2', ['text' => 'Option text']); - * $t->selectOptionForSelect2('#my_select2', ['id' => 'Option value', 'text' => 'Option text']); - * - * @param $selector - * @param $option - * @param int $timeout seconds. Default to 1 - */ - public function selectOptionForSelect2($selector, $option, $timeout = 5) - { - $t = $this->getAcceptanceModule(); - $selector = $this->getSelect2Selector($selector); - $this->waitForSelect2($selector, $timeout); - - if (is_int($option)) { - $option = (string) $option; - } - - if (is_string($option) || (is_array($option) && array_values($option) === $option)) { - $t->executeJS('jQuery("'.$selector.'").select2("val", '.json_encode($option).');', [$timeout]); - $t->executeJS('jQuery("'.$selector.'").trigger("select2:select").trigger("change");', [$timeout]); - } elseif (is_array($option)) { - $optionId = 'null'; - if (isset($option['text']) && empty($option['id'])) { - $optionText = $option['text']; - $optionId = <<executeJS($script, [$timeout]); - } else { - $t->fail(); - } - } - - /** - * Unselect an option in the given select2 component. - * - * @param $selector - * @param $option - * @param int $timeout seconds. Default to 1 - */ - public function unselectOptionForSelect2($selector, $option = null, $timeout = 1) - { - $t = $this->getAcceptanceModule(); - $selector = $this->getSelect2Selector($selector); - $this->waitForSelect2($selector, $timeout); - if ($option && is_string($option)) { - $script = << -1) { - values.splice(index, 1); - } - \$("$selector").select2("val", values); - \$(\$("$selector").trigger("select2:select").trigger("change"); -}(jQuery)); -EOT; - $t->executeJS($script, [$timeout]); - } else { - $t->executeJS('jQuery("'.$selector.'").select2("val", "");', [$timeout]); - $t->executeJS('jQuery("'.$selector.'").trigger("select2:select").trigger("change");', [$timeout]); - } - } - - /** - * Open the Select2 component. - * - * @param string $selector - */ - public function openSelect2($selector) - { - $t = $this->getAcceptanceModule(); - $selector = $this->getSelect2Selector($selector); - $this->waitForSelect2($selector); - $t->executeJS('jQuery("'.$selector.'").select2("open");'); - } - - /** - * Close the Select2 component. - * - * @param string $selector - */ - public function closeSelect2($selector) - { - $t = $this->getAcceptanceModule(); - $selector = $this->getSelect2Selector($selector); - $this->waitForSelect2($selector); - $t->executeJS('jQuery("'.$selector.'").select2("close");'); - } - - /** - * @param $selector - * @param $optionText - * @param bool $expectedReturn Default to true - * - * @return string JavaScript - */ - protected function _optionIsSelectedForSelect2($selector, $optionText, $expectedReturn = true) - { - $returnFlag = $expectedReturn === true ? '' : '!'; - - return $script = << 0) { - isSelected = values.some(function (data) { - if (data && data.text && data.text === "$optionText") { - return data; - } - }); - } - return ${returnFlag}isSelected; -}(jQuery)); -EOT; - } - - protected function getSelect2Selector($selector) - { - return $selector; - //return preg_replace("/^\#((?!s2id_).+)$/", '#s2id_$1', $selector); - } - - protected function getAcceptanceModule() - { - if (!$this->hasModule('WebDriver')) { - throw new \Exception('You must enable the WebDriver module', 1); - } - - return $this->getModule('WebDriver'); - } -} diff --git a/tests/_support/Helper/Select2Ajax.php b/tests/_support/Helper/Select2Ajax.php deleted file mode 100755 index 7d169fbb1..000000000 --- a/tests/_support/Helper/Select2Ajax.php +++ /dev/null @@ -1,88 +0,0 @@ -execute($selector, $timeout, $code); - } - - public function selectByPosition($selector, $position, $timeout = 5) - { - $code = ' - var result = options['.$position.']; - $("'.$selector.'").selectSetNew(result.id, result.text);'; - - $this->execute($selector, $timeout, $code); - } - - protected function execute($selector, $timeout, $code) - { - $t = $this->getAcceptanceModule(); - $selector = $this->getSelect2Selector($selector); - $this->waitForSelect2($selector, $timeout); - - if (is_int($option)) { - $option = (string) $option; - } - - $results_selector = str_replace('#', '', $selector); - - $script = << ({key,value})); - - if(output[0]) { - options.push(output[0].value.data); - } - }) - - $code -}); -EOT; - - $t->executeJS($script, [$timeout]); - } -} diff --git a/tests/_support/Helper/Unit.php b/tests/_support/Helper/Unit.php deleted file mode 100755 index 4d27aa359..000000000 --- a/tests/_support/Helper/Unit.php +++ /dev/null @@ -1,10 +0,0 @@ -login('admin', 'admin'); - } - - /** - * Crea una nuova anagrafica di tipo Cliente. - */ - public function testAnagraficaCliente(AcceptanceTester $t) - { - $this->addAnag($t, 'Cliente', 1, '05024030289'); - } - - /** - * Crea una nuova anagrafica di tipo Tecnico. - */ - public function testAnagraficaTecnico(AcceptanceTester $t) - { - $this->addAnag($t, 'Tecnico', 2, '05024030289'); - } - - /** - * Crea una nuova anagrafica di tipo Fornitore. - */ - public function testAnagraficaFornitore(AcceptanceTester $t) - { - $this->addAnag($t, 'Fornitore', 4, '05024030289'); - } - - /** - * Crea una nuova anagrafica di tipo Vettore. - */ - public function testAnagraficaVettore(AcceptanceTester $t) - { - $this->addAnag($t, 'Vettore', 5, '05024030289'); - } - - /** - * Crea una nuova anagrafica di tipo Agente. - */ - public function testAnagraficaAgente(AcceptanceTester $t) - { - $this->addAnag($t, 'Agente', 6, '05024030289'); - } - - /** - * Crea una nuova anagrafica. - */ - protected function addAnag(AcceptanceTester $t, $name = 'ANAGRAFICA DI PROVA', $tipo = 1, $partita_iva = '') - { - // Seleziona il modulo da aprire - $t->navigateTo('Anagrafiche'); - - // Apre la schermata di nuovo elemento - $t->clickAndWaitModal('.btn-primary', '#tabs'); - - // Completa i campi per il nuovo elemento - $t->fillField('Denominazione', $name); - $t->select2('#idtipoanagrafica', $tipo); - $t->click('.btn-box-tool'); - $t->waitForElementVisible('#piva', 3); - $t->fillField('Partita IVA', $partita_iva); - - // Effettua il submit - $t->clickAndWait('Aggiungi', '#add-form'); - - // Controlla il salvataggio finale - $t->seeInField('Denominazione', $name); - } - - /** - * Crea una nuova anagrafica di tipo cliente e la elimina. - */ - protected function addAndDeleteAnag(AcceptanceTester $t, $name = 'ANAGRAFICA DI PROVA', $tipo = 1, $partita_iva = '') - { - $this->addAnag($t, $name, $tipo, $partita_iva); - - // Seleziona l'azione di eliminazione - $t->clickAndWaitSwal('Elimina', '#tab_0'); - - // Conferma l'eliminazione - $t->clickSwalButton('Elimina'); - - // Controlla eliminazione - $t->see('Anagrafica eliminata!', '.alert-success'); - } -} diff --git a/tests/acceptance/BackupCest.php b/tests/acceptance/BackupCest.php deleted file mode 100755 index 179553c14..000000000 --- a/tests/acceptance/BackupCest.php +++ /dev/null @@ -1,46 +0,0 @@ -login('admin', 'admin'); - } - - /** - * Crea un nuovo backup. - */ - protected function createBackup(AcceptanceTester $t) - { - // Seleziona il modulo da aprire - $t->expandSidebarLink('Strumenti'); - $t->navigateTo('Backup'); - - $t->clickAndWaitSwal('Crea backup'); - - // Conferma la creazione - $t->clickSwalButton('Crea'); - - // Controlla il salvataggio finale - $t->see('Nuovo backup creato correttamente!'); - } - - /** - * Ripristina un backup specifico. - */ - protected function restoreBackup(AcceptanceTester $t, $name = null) - { - // Seleziona il modulo da aprire - $t->expandSidebarLink('Strumenti'); - $t->navigateTo('Backup'); - } - - /** - * Crea una nuova anagrafica di tipo Cliente. - */ - protected function testBackup(AcceptanceTester $t) - { - $name = $this->createBackup($t); - } -} diff --git a/tests/acceptance/ContrattiCest.php b/tests/acceptance/ContrattiCest.php deleted file mode 100755 index f09f1659f..000000000 --- a/tests/acceptance/ContrattiCest.php +++ /dev/null @@ -1,74 +0,0 @@ -login('admin', 'admin'); - } - - /** - * Crea un nuovo contratto. - */ - public function testContratto(AcceptanceTester $t) - { - $this->addContratto($t, 'Contratto di test', 2); - - $this->rowHelper->testImporti($t); - - //$t->click('Stampa'); - } - - protected function _inject(RowHelper $rowHelper) - { - $this->rowHelper = $rowHelper; - } - - /** - * Crea un nuovo contratto. - */ - protected function addContratto(AcceptanceTester $t, $name, $anagrafica) - { - // Seleziona il modulo da aprire - $t->expandSidebarLink('Vendite'); - $t->navigateTo('Contratti'); - - // Apre la schermata di nuovo elemento - $t->clickAndWaitModal('.btn-primary', '#tabs'); - - // Completa i campi per il nuovo elemento - $t->fillField('Nome', $name); - $t->select2ajax('#idanagrafica', $anagrafica); - - // Effettua il submit - $t->clickAndWait('Aggiungi', '#add-form'); - - // Controlla il salvataggio finale - $t->see('Aggiunto contratto'); - } - - /** - * Crea una nuova anagrafica di tipo cliente e la elimina. - */ - protected function addAndDeleteContratto(AcceptanceTester $t, $name, $anagrafica = 2) - { - $this->addAnag($t, $name, $anagrafica); - - // Seleziona l'azione di eliminazione - $t->clickAndWaitSwal('Elimina', '#tab_0'); - - // Conferma l'eliminazione - $t->clickSwalButton('Elimina'); - - // Controlla eliminazione - $t->see('Contratto eliminato!', '.alert-success'); - } -} diff --git a/tests/acceptance/DDTCest.php b/tests/acceptance/DDTCest.php deleted file mode 100755 index 6aad70b4a..000000000 --- a/tests/acceptance/DDTCest.php +++ /dev/null @@ -1,84 +0,0 @@ -login('admin', 'admin'); - } - - /** - * Crea un nuovo ddt. - */ - public function testDdtDiVendita(AcceptanceTester $t) - { - $this->addDdt($t, true, 2, 2); - - $this->rowHelper->testImporti($t); - - //$t->click('Stampa'); - } - - /** - * Crea un nuovo ddt. - */ - public function testDdtDiAcquisto(AcceptanceTester $t) - { - $this->addDdt($t, false, 3, 1); - - $this->rowHelper->testImporti($t, 'uscita'); - } - - protected function _inject(RowHelper $rowHelper) - { - $this->rowHelper = $rowHelper; - } - - /** - * Crea un nuovo ddt. - */ - protected function addDdt(AcceptanceTester $t, $entrata, $anagrafica, $tipo) - { - // Seleziona il modulo da aprire - $t->expandSidebarLink('Magazzino'); - $t->navigateTo($entrata == true ? 'Ddt in uscita' : 'Ddt in entrata'); - - // Apre la schermata di nuovo elemento - $t->clickAndWaitModal('.btn-primary', '#tabs'); - - // Completa i campi per il nuovo elemento - $t->select2ajax('#idanagrafica_add', $anagrafica); - $t->select2('#idtipoddt', $tipo); - - // Effettua il submit - $t->clickAndWait('Aggiungi', '#add-form'); - - // Controlla il salvataggio finale - $t->see('Aggiunto ddt'); - } - - /** - * Crea una nuova anagrafica di tipo cliente e la elimina. - */ - protected function addAndDeleteDdt(AcceptanceTester $t, $entrata, $anagrafica, $tipo) - { - $this->addAnag($t, $entrata, $anagrafica, $tipo); - - // Seleziona l'azione di eliminazione - $t->clickAndWaitSwal('Elimina', '#tab_0'); - - // Conferma l'eliminazione - $t->clickSwalButton('Elimina'); - - // Controlla eliminazione - $t->see('Ddt eliminato!', '.alert-success'); - } -} diff --git a/tests/acceptance/FattureCest.php b/tests/acceptance/FattureCest.php deleted file mode 100755 index cb6011e1e..000000000 --- a/tests/acceptance/FattureCest.php +++ /dev/null @@ -1,86 +0,0 @@ -login('admin', 'admin'); - } - - /** - * Crea una nuova fattura di vendita. - */ - public function testFatturaDiVendita(AcceptanceTester $t) - { - $this->addFattura($t, true, 2, 2); - - $this->rowHelper->testImporti($t); - } - - /** - * Crea una nuova fattura di acquisto. - */ - public function testFatturaDiAcquisto(AcceptanceTester $t) - { - $this->addFattura($t, false, 1, 4); - - // Fix pagamento vuoto - $t->select2('#idpagamento', 109); - $t->clickAndWait('Salva'); - - $this->rowHelper->testImporti($t, 'uscita'); - } - - protected function _inject(RowHelper $rowHelper) - { - $this->rowHelper = $rowHelper; - } - - /** - * Crea una nuova fattura. - */ - protected function addFattura(AcceptanceTester $t, $entrata, $tipo, $anagrafica) - { - // Seleziona il modulo da aprire - $t->expandSidebarLink($entrata == true ? 'Vendite' : 'Acquisti'); - $t->navigateTo($entrata == true ? 'Fatture di vendita' : 'Fatture di acquisto'); - - // Apre la schermata di nuovo elemento - $t->clickAndWaitModal('.btn-primary', '#tabs'); - - // Completa i campi per il nuovo elemento - $t->select2ajax('#idanagrafica_add', $anagrafica); - $t->select2('#idtipodocumento', $tipo); - - // Effettua il submit - $t->clickAndWait('Aggiungi', '#add-form'); - - // Controlla il salvataggio finale - $t->see('Aggiunta fattura'); - } - - /** - * Crea una nuova fattura e la elimina. - */ - protected function addAndDeleteFattura(AcceptanceTester $t, $cliente, $tipo) - { - $this->addAnag($t, $cliente, $tipo); - - // Seleziona l'azione di eliminazione - $t->clickAndWaitSwal('Elimina', '#tab_0'); - - // Conferma l'eliminazione - $t->clickSwalButton('Elimina'); - - // Controlla eliminazione - $t->see('Fattura eliminata!', '.alert-success'); - } -} diff --git a/tests/acceptance/OrdiniCest.php b/tests/acceptance/OrdiniCest.php deleted file mode 100755 index f9c55d6d7..000000000 --- a/tests/acceptance/OrdiniCest.php +++ /dev/null @@ -1,87 +0,0 @@ -login('admin', 'admin'); - } - - /** - * Crea un nuovo ordine. - */ - public function testOrdineCliente(AcceptanceTester $t) - { - $this->addOrdine($t, true, 2); - - $this->rowHelper->testImporti($t); - - //$t->click('Stampa'); - } - - /** - * Crea un nuovo ordine. - */ - public function testOrdineFornitore(AcceptanceTester $t) - { - $this->addOrdine($t, false, 4); - - // Fix pagamento vuoto - $t->select2('#idpagamento', 109); - $t->clickAndWait('Salva'); - - $this->rowHelper->testImporti($t, 'uscita'); - } - - protected function _inject(RowHelper $rowHelper) - { - $this->rowHelper = $rowHelper; - } - - /** - * Crea un nuovo ordine. - */ - protected function addOrdine(AcceptanceTester $t, $entrata, $anagrafica) - { - // Seleziona il modulo da aprire - $t->expandSidebarLink($entrata == true ? 'Vendite' : 'Acquisti'); - $t->navigateTo($entrata == true ? 'Ordini cliente' : 'Ordini fornitore'); - - // Apre la schermata di nuovo elemento - $t->clickAndWaitModal('.btn-primary', '#tabs'); - - // Completa i campi per il nuovo elemento - $t->select2ajax('#idanagrafica', $anagrafica); - - // Effettua il submit - $t->clickAndWait('Aggiungi', '#add-form'); - - // Controlla il salvataggio finale - $t->see('Aggiunto ordine'); - } - - /** - * Crea una nuova anagrafica di tipo cliente e la elimina. - */ - protected function addAndDeleteOrdine(AcceptanceTester $t, $entrata, $anagrafica = 2) - { - $this->addAnag($t, $entrata, $anagrafica); - - // Seleziona l'azione di eliminazione - $t->clickAndWaitSwal('Elimina', '#tab_0'); - - // Conferma l'eliminazione - $t->clickSwalButton('Elimina'); - - // Controlla eliminazione - $t->see('Ordine eliminato!', '.alert-success'); - } -} diff --git a/tests/acceptance/PreventiviCest.php b/tests/acceptance/PreventiviCest.php deleted file mode 100755 index 322a24b01..000000000 --- a/tests/acceptance/PreventiviCest.php +++ /dev/null @@ -1,75 +0,0 @@ -login('admin', 'admin'); - } - - /** - * Crea un nuovo preventivo. - */ - public function testPreventivo(AcceptanceTester $t) - { - $this->addPreventivo($t, 'Preventivo di test', 2); - - $this->rowHelper->testImporti($t); - - //$t->click('Stampa'); - } - - protected function _inject(RowHelper $rowHelper) - { - $this->rowHelper = $rowHelper; - } - - /** - * Crea un nuovo preventivo. - */ - protected function addPreventivo(AcceptanceTester $t, $name, $anagrafica, $tipo = 'GEN') - { - // Seleziona il modulo da aprire - $t->expandSidebarLink('Vendite'); - $t->navigateTo('Preventivi'); - - // Apre la schermata di nuovo elemento - $t->clickAndWaitModal('.btn-primary', '#tabs'); - - // Completa i campi per il nuovo elemento - $t->fillField('Nome preventivo', $name); - $t->select2ajax('#idanagrafica', $anagrafica); - $t->select2ajax('#idtipointervento', $tipo); - - // Effettua il submit - $t->clickAndWait('Aggiungi', '#add-form'); - - // Controlla il salvataggio finale - $t->see('Aggiunto preventivo'); - } - - /** - * Crea una nuova anagrafica di tipo cliente e la elimina. - */ - protected function addAndDeletePreventivo(AcceptanceTester $t, $name, $anagrafica = 2, $tipo = 'GEN') - { - $this->addAnag($t, $name, $anagrafica, $tipo); - - // Seleziona l'azione di eliminazione - $t->clickAndWaitSwal('Elimina', '#tab_0'); - - // Conferma l'eliminazione - $t->clickSwalButton('Elimina'); - - // Controlla eliminazione - $t->see('Preventivo eliminato!', '.alert-success'); - } -} diff --git a/tests/acceptance/_bootstrap.php b/tests/acceptance/_bootstrap.php deleted file mode 100755 index b3d9bbc7f..000000000 --- a/tests/acceptance/_bootstrap.php +++ /dev/null @@ -1 +0,0 @@ -test(null, '|TEST'); - } - - public function testNumbersWithSuffix() - { - $this->test('|TEST'); - } - - public function testCommonNumbers() - { - $this->test(); - } - - public function testDates() - { - $this->test('/YYYY'); - $this->test('/yy'); - - $this->test(null, 'YYYY-'); - $this->test(null, 'yy-'); - } - - protected function test($prefix = null, $suffix = null) - { - $date = date('Y-m-d H:i:s'); - $info = Generator::dateToPattern($date); - - // Individuazione valori relativi a suffisso e prefisso - $prefix_value = Generator::complete($prefix, $info); - $suffix_value = Generator::complete($suffix, $info); - - $step = 3; - - // Pattern di base con numero di caratteri incrementale - $pattern = $prefix.'#'.$suffix; - - $previous = null; - for ($i = 0; $i < 10000; $i = $i + $step) { - $value = $prefix_value.$this->pad($i + 1, $length).$suffix_value; - $this->assertEquals($value, Generator::generate($pattern, $previous, $step, $info)); - - $previous = $value; - } - - // Pattern con padding - $length = 5; - $pattern = $prefix.str_repeat('#', $length).$suffix; - - $previous = null; - for ($i = 0; $i < 10000; $i = $i + $step) { - $value = $prefix_value.$this->pad($i + 1, $length).$suffix_value; - $this->assertEquals($value, Generator::generate($pattern, $previous, $step, $info)); - - $previous = $value; - } - } - - protected function pad($number, $length) - { - return str_pad($number, $length, '0', STR_PAD_LEFT); - } -} diff --git a/tests/unit/_bootstrap.php b/tests/unit/_bootstrap.php deleted file mode 100755 index 25cdd55a6..000000000 --- a/tests/unit/_bootstrap.php +++ /dev/null @@ -1,10 +0,0 @@ - $namespace) { - Autoload::addNamespace($namespace.'\\', __DIR__.'/../../'.$path.'/custom/src'); - Autoload::addNamespace($namespace.'\\', __DIR__.'/../../'.$path.'/src'); -} diff --git a/update/.htaccess b/update/.htaccess deleted file mode 100755 index 3a4288278..000000000 --- a/update/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/update/2_0.sql b/update/2_0.sql deleted file mode 100755 index b1342436b..000000000 --- a/update/2_0.sql +++ /dev/null @@ -1,2416 +0,0 @@ --- --- Struttura della tabella `an_anagrafiche` --- - -CREATE TABLE IF NOT EXISTS `an_anagrafiche` ( - `idanagrafica` int(11) NOT NULL AUTO_INCREMENT, - `codice` varchar(20) NOT NULL, - `ragione_sociale` varchar(255) NOT NULL, - `piva` varchar(15) NOT NULL, - `codice_fiscale` varchar(16) NOT NULL, - `capitale_sociale` varchar(255) NOT NULL, - `data_nascita` date NOT NULL, - `luogo_nascita` varchar(255) NOT NULL, - `indirizzo` varchar(255) NOT NULL, - `indirizzo2` varchar(255) NOT NULL, - `citta` varchar(255) NOT NULL, - `cap` varchar(10) NOT NULL, - `provincia` varchar(2) NOT NULL, - `km` float(10,2) NOT NULL, - `nazione` varchar(255) NOT NULL, - `telefono` varchar(50) NOT NULL, - `fax` varchar(50) NOT NULL, - `cellulare` varchar(50) NOT NULL, - `email` varchar(255) NOT NULL, - `sitoweb` varchar(255) NOT NULL, - `note` varchar(255) NOT NULL, - `codiceri` varchar(15) NOT NULL, - `codicerea` varchar(15) NOT NULL, - `appoggiobancario` varchar(255) NOT NULL, - `filiale` varchar(100) NOT NULL, - `codiceiban` varchar(40) NOT NULL, - `diciturafissafattura` varchar(255) NOT NULL, - `idpagamento` int(11) NOT NULL, - `idlistino` int(11) NOT NULL, - `idiva` int(11) NOT NULL, - `idsede_fatturazione` int(11) NOT NULL, - `settore` varchar(255) NOT NULL, - `marche` varchar(5000) NOT NULL, - `dipendenti` int(11) NOT NULL, - `macchine` int(11) NOT NULL, - `idagente` int(11) NOT NULL, - `idrelazione` int(11) NOT NULL, - `agentemaster` tinyint(1) NOT NULL, - `idzona` int(11) NOT NULL, - `foro_competenza` varchar(255) NOT NULL, - `nome_cognome` varchar(255) NOT NULL, - `iscrizione_tribunale` varchar(2) NOT NULL, - `cciaa` varchar(25) NOT NULL, - `cciaa_citta` varchar(100) NOT NULL, - `n_alboartigiani` varchar(25) DEFAULT NULL, - `colore` varchar(7) NOT NULL DEFAULT '#FFFFFF', - `deleted` tinyint(1) NOT NULL, - PRIMARY KEY (`idanagrafica`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `an_nazioni` --- - -CREATE TABLE IF NOT EXISTS `an_nazioni` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `nome` varchar(255) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `an_nazioni` --- - -INSERT INTO `an_nazioni` (`id`, `nome`) VALUES -(2, 'ALGERIA'), -(3, 'ANDORRA'), -(4, 'ANGOLA'), -(5, 'ANGUILLA'), -(6, 'ANTIGUA AND BARBUDA'), -(7, 'ARGENTINA'), -(8, 'ARMENIA'), -(9, 'ARUBA'), -(10, 'AUSTRALIA'), -(11, 'AUSTRIA'), -(12, 'AZERBAIJAN REPUBLIC'), -(13, 'BAHAMAS'), -(14, 'BAHRAIN'), -(15, 'BARBADOS'), -(16, 'BELGIO'), -(17, 'BELIZE'), -(18, 'BENIN'), -(19, 'BERMUDA'), -(20, 'BHUTAN'), -(21, 'BOLIVIA'), -(22, 'BOSNIA AND HERZEGOVINA'), -(23, 'BOTSWANA'), -(24, 'BRASILE'), -(25, 'BRITISH VIRGIN ISLANDS'), -(26, 'BRUNEI'), -(27, 'BULGARIA'), -(28, 'BURKINA FASO'), -(29, 'BURUNDI'), -(30, 'CAMBOGIA'), -(31, 'CANADA'), -(32, 'CAPO VERDE'), -(33, 'CAYMAN ISLANDS'), -(34, 'CHAD'), -(35, 'CHILE'), -(36, 'CHINA WORLDWIDE'), -(37, 'COLOMBIA'), -(38, 'COMOROS'), -(39, 'COOK ISLANDS'), -(40, 'COSTA RICA'), -(41, 'CROAZIA'), -(42, 'CIPRO'), -(43, 'REPUBBLICA CECA'), -(44, 'DEMOCRATIC REPUBLIC OF THE CONGO'), -(45, 'DANIMARCA'), -(46, 'DJIBOUTI'), -(47, 'DOMINICA'), -(48, 'REPUBBLICA DOMINICANA'), -(49, 'ECUADOR'), -(50, 'EL SALVADOR'), -(51, 'ERITREA'), -(52, 'ESTONIA'), -(53, 'ETHIOPIA'), -(54, 'FALKLAND ISLANDS'), -(55, 'FAROE ISLANDS'), -(56, 'FEDERATED STATES OF MICRONESIA'), -(57, 'FIJI'), -(58, 'FINLANDIA'), -(59, 'FRANCIA'), -(60, 'FRENCH GUIANA'), -(61, 'FRENCH POLYNESIA'), -(62, 'GABON REPUBLIC'), -(63, 'GAMBIA'), -(64, 'GERMANIA'), -(65, 'GIBRALTAR'), -(66, 'GRECIA'), -(67, 'GREENLAND'), -(68, 'GRENADA'), -(69, 'GUADELOUPE'), -(70, 'GUATEMALA'), -(71, 'GUINEA'), -(72, 'GUINEA BISSAU'), -(73, 'GUYANA'), -(74, 'HONDURAS'), -(75, 'HONG KONG'), -(76, 'UNGHERIA'), -(77, 'ISLANDA'), -(78, 'INDIA'), -(79, 'INDONESIA'), -(80, 'IRLANDA'), -(81, 'ISRAELE'), -(82, 'ITALIA'), -(83, 'JAMAICA'), -(84, 'GIAPPONE'), -(85, 'JORDAN'), -(86, 'KAZAKHSTAN'), -(87, 'KENYA'), -(88, 'KIRIBATI'), -(89, 'KUWAIT'), -(90, 'KYRGYZSTAN'), -(91, 'LAOS'), -(92, 'LATVIA'), -(93, 'LESOTHO'), -(94, 'LIECHTENSTEIN'), -(95, 'LITUANIA'), -(96, 'LUSSEMBURGO'), -(97, 'MADAGASCAR'), -(98, 'MALAWI'), -(99, 'MALESIA'), -(100, 'MALDIVE'), -(101, 'MALI'), -(102, 'MALTA'), -(103, 'MARSHALL ISLANDS'), -(104, 'MARTINIQUE'), -(105, 'MAURITANIA'), -(106, 'MAURITIUS'), -(107, 'MAYOTTE'), -(108, 'MESSICO'), -(109, 'MONGOLIA'), -(110, 'MONTSERRAT'), -(111, 'MAROCCO'), -(112, 'MOZAMBICO'), -(113, 'NAMIBIA'), -(114, 'NAURU'), -(115, 'NEPAL'), -(116, 'OLANDA'), -(117, 'NETHERLANDS ANTILLES'), -(118, 'NUOVA CALEDONIA'), -(119, 'NUOVA ZELANDA'), -(120, 'NICARAGUA'), -(121, 'NIGERIA'), -(122, 'NIUE'), -(123, 'NORFOLK ISLAND'), -(124, 'NORWEGIA'), -(125, 'OMAN'), -(126, 'PALAU'), -(127, 'PANAMA'), -(128, 'PAPUA NUOVA GUINEA'), -(129, 'PERU'), -(130, 'FILIPPINE'), -(131, 'PITCAIRN ISLANDS'), -(132, 'POLONIA'), -(133, 'PORTOGALLO'), -(134, 'QATAR'), -(135, 'REPUBBLICA DEL CONGO'), -(136, 'REUNION'), -(137, 'ROMANIA'), -(138, 'RUSSIA'), -(139, 'RUANDA'), -(140, 'SAINT VINCENT AND THE GRENADINES'), -(141, 'SAMOA'), -(142, 'SAN MARINO'), -(144, 'SAUDI ARABIA'), -(145, 'SENEGAL'), -(146, 'SEYCHELLES'), -(147, 'SIERRA LEONE'), -(148, 'SINGAPORE'), -(149, 'SLOVACCHIA'), -(150, 'SLOVENIA'), -(151, 'SOLOMON ISLANDS'), -(152, 'SOMALIA'), -(153, 'SUD AFRICA'), -(154, 'SUD KOREA'), -(155, 'SPAGNA'), -(156, 'SRI LANKA'), -(157, 'ST. HELENA'), -(158, 'ST. KITTS AND NEVIS'), -(159, 'ST. LUCIA'), -(160, 'ST. PIERRE AND MIQUELON'), -(161, 'SURINAME'), -(162, 'SVALBARD AND JAN MAYEN ISLANDS'), -(163, 'SWAZILAND'), -(164, 'SVEZIA'), -(165, 'SVIZZERA'), -(166, 'TAIWAN'), -(167, 'TAJIKISTAN'), -(168, 'TANZANIA'), -(169, 'THAILAND'), -(170, 'TOGO'), -(171, 'TONGA'), -(172, 'TRINIDAD E TOBAGO'), -(173, 'TUNISIA'), -(174, 'TURCHIA'), -(175, 'TURKMENISTAN'), -(176, 'TURKS AND CAICOS ISLANDS'), -(177, 'TUVALU'), -(178, 'UGANDA'), -(179, 'UCRAINA'), -(180, 'EMIRATI ARABI UNITI'), -(181, 'REGNO UNITO'), -(182, 'STATI UNITI'), -(183, 'URUGUAY'), -(184, 'VANUATU'), -(185, 'CITTÀ DEL VATICANO'), -(186, 'VENEZUELA'), -(187, 'VIETNAM'), -(188, 'WALLIS AND FUTUNA ISLANDS'), -(189, 'YEMEN'), -(190, 'ZAMBIA'), -(193, 'ALBANIA '); - --- -------------------------------------------------------- - --- --- Struttura della tabella `an_referenti` --- - -CREATE TABLE IF NOT EXISTS `an_referenti` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `nome` varchar(255) NOT NULL, - `mansione` varchar(255) NOT NULL, - `telefono` varchar(50) NOT NULL, - `email` varchar(255) NOT NULL, - `idanagrafica` int(11) NOT NULL, - `idsede` int(11) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `an_relazioni` --- - -CREATE TABLE IF NOT EXISTS `an_relazioni` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `descrizione` varchar(100) NOT NULL, - `colore` varchar(7) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `an_relazioni` --- - -INSERT INTO `an_relazioni` (`id`, `descrizione`, `colore`) VALUES -(1, 'Da contattare', '#caffb7'), -(2, 'Da richiamare', '#8fbafd'), -(3, 'Da non richiamare', '#ff908c'), -(4, 'Appuntamento fissato', '#ffc400'), -(5, 'Attivo', '#00b913'), -(6, 'Dormiente', '#a2a2a2'); - --- -------------------------------------------------------- - --- --- Struttura della tabella `an_sedi` --- - -CREATE TABLE IF NOT EXISTS `an_sedi` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `nomesede` varchar(255) NOT NULL COMMENT 'Nome sede', - `piva` varchar(15) NOT NULL COMMENT 'P.Iva', - `codice_fiscale` varchar(16) NOT NULL COMMENT 'Codice Fiscale', - `indirizzo` varchar(255) NOT NULL COMMENT 'Indirizzo', - `indirizzo2` varchar(255) NOT NULL COMMENT 'Indirizzo2', - `citta` varchar(255) NOT NULL COMMENT 'Città', - `cap` varchar(10) NOT NULL COMMENT 'C.A.P.', - `provincia` varchar(2) NOT NULL COMMENT 'Provincia', - `km` float(10,2) NOT NULL, - `nazione` varchar(255) NOT NULL COMMENT 'Nazione', - `telefono` varchar(20) NOT NULL COMMENT 'Telefono', - `fax` varchar(20) NOT NULL COMMENT 'Fax', - `cellulare` varchar(20) NOT NULL COMMENT 'Cellulare', - `email` varchar(255) NOT NULL COMMENT 'Email', - `idanagrafica` int(11) NOT NULL, - `idzona` int(11) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `an_tipianagrafiche` --- - -CREATE TABLE IF NOT EXISTS `an_tipianagrafiche` ( - `idtipoanagrafica` int(11) NOT NULL AUTO_INCREMENT, - `descrizione` varchar(255) NOT NULL, - `default` tinyint(1) DEFAULT NULL, - PRIMARY KEY (`idtipoanagrafica`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `an_tipianagrafiche` --- - -INSERT INTO `an_tipianagrafiche` (`idtipoanagrafica`, `descrizione`, `default`) VALUES -(1, 'Cliente', 1), -(2, 'Tecnico', 1), -(3, 'Azienda', 1), -(4, 'Fornitore', 1), -(5, 'Vettore', 1), -(6, 'Agente', 1); - --- -------------------------------------------------------- - --- --- Struttura della tabella `an_tipianagrafiche_anagrafiche` --- - -CREATE TABLE IF NOT EXISTS `an_tipianagrafiche_anagrafiche` ( - `idtipoanagrafica` int(11) NOT NULL, - `idanagrafica` int(11) NOT NULL, - PRIMARY KEY (`idtipoanagrafica`,`idanagrafica`), - KEY `idanagrafica` (`idanagrafica`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `an_zone` --- - -CREATE TABLE IF NOT EXISTS `an_zone` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `nome` varchar(255) NOT NULL, - `descrizione` varchar(2000) NOT NULL, - `default` tinyint(1) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `co_contratti` --- - -CREATE TABLE IF NOT EXISTS `co_contratti` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `numero` varchar(50) NOT NULL, - `nome` varchar(100) NOT NULL, - `idagente` int(11) NOT NULL, - `data_bozza` datetime DEFAULT NULL, - `data_accettazione` datetime DEFAULT NULL, - `data_rifiuto` datetime DEFAULT NULL, - `data_conclusione` datetime DEFAULT NULL, - `rinnovabile` tinyint(1) NOT NULL, - `giorni_preavviso_rinnovo` smallint(6) NOT NULL, - `budget` float(12,4) NOT NULL, - `descrizione` text, - `idstato` tinyint(4) DEFAULT NULL, - `idreferente` int(11) DEFAULT NULL, - `validita` int(11) DEFAULT NULL, - `esclusioni` text NOT NULL, - `idanagrafica` int(11) NOT NULL, - `idpagamento` int(11) NOT NULL, - `idtipointervento` varchar(25) NOT NULL, - `costo_diritto_chiamata` float(12,4) NOT NULL, - `ore_lavoro` float(12,4) NOT NULL, - `costo_orario` float(12,4) NOT NULL, - `costo_km` float(12,4) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `co_contratti_interventi` --- - -CREATE TABLE IF NOT EXISTS `co_contratti_interventi` ( - `idcontratto` int(11) NOT NULL, - `idintervento` varchar(25) NOT NULL, - PRIMARY KEY (`idcontratto`,`idintervento`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `co_documenti` --- - -CREATE TABLE IF NOT EXISTS `co_documenti` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `numero` int(11) NOT NULL, - `numero_esterno` varchar(100) NOT NULL, - `data` datetime NOT NULL, - `idanagrafica` int(11) NOT NULL, - `idcausalet` int(11) NOT NULL, - `idspedizione` int(11) NOT NULL, - `idporto` int(11) NOT NULL, - `idaspettobeni` int(11) NOT NULL, - `idvettore` int(11) NOT NULL, - `n_colli` int(11) NOT NULL, - `idsede` int(11) NOT NULL, - `idtipodocumento` tinyint(4) NOT NULL, - `idstatodocumento` tinyint(4) NOT NULL, - `idpagamento` int(11) NOT NULL, - `idconto` int(11) NOT NULL, - `idrivalsainps` int(11) NOT NULL, - `idritenutaacconto` int(11) NOT NULL, - `rivalsainps` float(12,4) NOT NULL, - `iva_rivalsainps` float(7,3) NOT NULL, - `ritenutaacconto` float(12,4) NOT NULL, - `bollo` float(12,4) NOT NULL, - `note` text NOT NULL, - `note_aggiuntive` text NOT NULL, - `buono_ordine` varchar(50) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `co_iva` --- - -CREATE TABLE IF NOT EXISTS `co_iva` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `descrizione` varchar(100) NOT NULL, - `percentuale` float(5,2) NOT NULL, - `descrizione2` varchar(200) NOT NULL, - `indetraibile` float(5,2) NOT NULL, - `esente` tinyint(1) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `co_iva` --- - -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `descrizione2`, `indetraibile`, `esente`) VALUES -(1, 'Corrispettivi in ventilazione', 0.00, '', 0.00, 0), -(2, 'Iva 4% indetraibile al 50%', 4.00, '', 50.00, 0), -(3, 'Iva 04% indetraibile al 100%', 4.00, '', 100.00, 0), -(4, 'Iva 04% Intra', 4.00, '', 0.00, 0), -(5, 'Iva 8', 8.00, '', 0.00, 0), -(6, 'Iva 9% ', 9.00, '', 0.00, 0), -(7, 'Esente art.10', 0.00, '', 0.00, 1), -(8, 'Iva 10%', 10.00, '', 0.00, 0), -(9, 'Iva 10% indetraibile al 50%', 10.00, '', 50.00, 0), -(10, 'Iva 10% indetraibile al 100%', 10.00, '', 100.00, 0), -(11, 'Iva 10% Intra', 10.00, '', 0.00, 0), -(12, 'Iva 10% indetraibile', 10.00, '', 100.00, 0), -(13, 'Esente art. 2 DPR 633/72', 0.00, '', 0.00, 1), -(14, 'N.S. iva art.4 D.P.R.633/72', 0.00, '', 0.00, 0), -(15, 'Iva 20% in reverse charge', 20.00, '', 0.00, 0), -(16, 'Esente art.15', 0.00, '', 0.00, 1), -(17, 'Non imponibile art. 7', 0.00, '', 0.00, 1), -(18, 'Iva 19%', 19.00, '', 0.00, 0), -(19, 'Iva 2%', 2.00, '', 0.00, 0), -(20, 'Iva 20%', 20.00, '', 0.00, 0), -(21, 'Iva 20% indetraibile al 90%', 20.00, '', 90.00, 0), -(22, 'Iva 20% esente prorata', 20.00, '', 100.00, 0), -(23, 'Iva 20% Intra', 20.00, '', 0.00, 0), -(24, 'Iva 20% indetraibile', 20.00, '', 100.00, 0), -(25, 'Iva 21% indetraibile 50%', 21.00, '', 50.00, 0), -(26, 'Non imponibile art.72', 0.00, '', 0.00, 1), -(27, 'Esente art. 1', 0.00, '', 0.00, 1), -(28, 'Non imponibile art.26 C.2', 0.00, '', 0.00, 1), -(29, 'Non imponibile art.74', 0.00, '', 0.00, 1), -(30, 'Non imponibile art. 41', 0.00, '', 0.00, 1), -(31, 'Fuori campo iva', 0.00, '', 0.00, 0), -(32, 'Iva 21%', 21.00, '', 0.00, 0), -(33, 'Iva 21% S.Marino', 21.00, '', 0.00, 0), -(34, 'Iva 4%', 4.00, '', 0.00, 0), -(35, 'Esente art. 74', 0.00, '', 0.00, 1), -(36, 'Iva 2% indetraibile', 2.00, '', 100.00, 0), -(37, 'Iva 4% indetraibile', 4.00, '', 100.00, 0), -(38, 'Esente art.6', 0.00, '', 0.00, 1), -(39, 'Esente art. 5', 0.00, '', 0.00, 1), -(40, 'Art. 74 ter 10% indetraibile', 10.00, '', 100.00, 0), -(41, 'Art. 74 ter 4% indetraibile', 4.00, '', 100.00, 0), -(42, 'Art. 74 ter 20% iva indetraibile', 20.00, '', 100.00, 0), -(43, 'Non imponibile art. 74 ter', 0.00, '', 0.00, 0), -(44, 'Non imponibile art. 8/C', 0.00, '', 0.00, 1), -(45, 'Esente art.10 C.27Q', 0.00, '', 0.00, 1), -(46, 'Escluso art. 2', 0.00, '', 0.00, 1), -(47, 'Non soggetto art. 7', 0.00, '', 0.00, 0), -(48, 'Non imponibile art. 8', 0.00, '', 0.00, 1), -(49, 'Non imponibile art. 9', 0.00, '', 0.00, 1), -(50, 'Esente art. 10', 0.00, '', 0.00, 1), -(51, 'Esente art. 10 n. 11', 0.00, '', 0.00, 1), -(52, 'Escluso art. 15', 0.00, '', 0.00, 1), -(53, 'Non sogg art. 17 c.5', 0.00, '', 0.00, 1), -(54, 'Esente art. 10 n. 18', 0.00, '', 0.00, 1), -(55, 'Esente art. 10 n.1 a n.9', 0.00, '', 0.00, 1), -(56, 'Art. 36 D.L. 41/95 acq.', 0.00, '', 0.00, 0), -(57, 'Non imponibile art. 40 D.L. 331 c. 5', 0.00, '', 0.00, 1), -(58, 'Non imponibile art. 41 D.L. 331/93', 0.00, '', 0.00, 1), -(59, 'Non imponibile art. 40 D.L. 331 c. 4 bis', 0.00, '', 0.00, 1), -(60, 'Non imponibile art. 40 D.L. 331 c. 6/8', 0.00, '', 0.00, 1), -(61, 'Non imponibile art. 40 D.L. 331 c. 4 bis', 0.00, '', 0.00, 1), -(62, 'Non imponibile art. 58 D.L. 331', 0.00, '', 0.00, 1), -(63, 'Non imponibile art. 71 e 72', 0.00, '', 0.00, 1), -(64, 'Non imponibile art. 74', 0.00, '', 0.00, 1), -(65, 'Non imponibile art. 8 lett. a)', 0.00, '', 0.00, 1), -(66, 'Non imponibile art. 8 lett. c)', 0.00, '', 0.00, 1), -(67, 'Non imponibile art. 9 c. 2', 0.00, '', 0.00, 1), -(68, 'Non imponibile art. 9 punto 9)', 0.00, '', 0.00, 1), -(69, 'Art. 17 comma 6 DPR 633/72 10%', 10.00, '', 0.00, 0), -(70, 'Art. 17 comma 6 DPR 633/72 20%', 20.00, '', 0.00, 0), -(71, 'Art. 17 comma 6 DPR 633/72 4%', 4.00, '', 0.00, 0), -(72, 'Acquisti da soggetti minimi', 0.00, '', 0.00, 0), -(73, 'Cess. fabbr. strum. art.10 n.8', 0.00, '', 0.00, 0), -(74, 'Art. 74 c. 7 e 8', 0.00, '', 0.00, 0), -(75, 'Fuori campo Iva', 0.00, '', 0.00, 0), -(76, 'Non Imponibile San Marino', 0.00, '', 0.00, 0), -(77, 'Esente art. 10 27 quinquies', 0.00, '', 0.00, 1), -(78, 'Autofatture 10% subappalto', 10.00, '', 0.00, 0), -(79, 'Autofatture 20% subappalto', 20.00, '', 0.00, 0), -(80, 'Autofatture 4% subappalto', 4.00, '', 0.00, 0), -(81, 'Operaz. ag. viag. normale 4%', 4.00, '', 0.00, 0), -(82, 'Operaz. ag. viag. normale 10%', 10.00, '', 0.00, 0), -(83, 'Autof. acq. fabbr. strum. 10%', 10.00, '', 0.00, 0), -(84, 'Autof. acq. fabbr. strum. 4%', 4.00, '', 0.00, 0), -(85, 'Operaz. ag. viag. normale 20%', 20.00, '', 0.00, 0), -(86, 'Autof. acq. fabbr. strum. 20%', 20.00, '', 0.00, 0), -(87, 'Art. 36 D.L. 41/95 vend.', 0.00, '', 0.00, 0), -(88, 'Art. 17 comma 6 DPR 633/72', 0.00, '', 0.00, 0), -(89, 'Iva 21% indetraibile', 21.00, '', 100.00, 0), -(90, 'Iva in reverse charge indetraibile', 0.00, '', 100.00, 0), -(91, 'Iva 22%', 22.00, '', 0.00, 0), -(92, 'Iva 22% indetraibile', 22.00, '', 100.00, 0), -(93, 'Iva 22% indetraibile al 50%', 22.00, '', 50.00, 0); - --- -------------------------------------------------------- - --- --- Struttura della tabella `co_movimenti` --- - -CREATE TABLE IF NOT EXISTS `co_movimenti` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `idmastrino` int(11) NOT NULL, - `data` datetime NOT NULL, - `data_documento` datetime NOT NULL, - `iddocumento` varchar(10) NOT NULL, - `idanagrafica` int(11) NOT NULL, - `descrizione` text NOT NULL, - `idconto` int(11) NOT NULL, - `totale` float(12,4) DEFAULT NULL, - `primanota` float(10,2) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `co_ordiniservizio` --- - -CREATE TABLE IF NOT EXISTS `co_ordiniservizio` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `idcontratto` int(11) NOT NULL, - `idintervento` varchar(25) NOT NULL, - `data_scadenza` datetime NOT NULL, - `matricola` varchar(25) NOT NULL, - `copia_centrale` tinyint(1) NOT NULL, - `copia_cliente` tinyint(1) NOT NULL, - `copia_amministratore` tinyint(1) NOT NULL, - `funzionamento_in_sicurezza` tinyint(1) NOT NULL, - `stato` enum('aperto','chiuso') NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `co_ordiniservizio_pianificazionefatture` --- - -CREATE TABLE IF NOT EXISTS `co_ordiniservizio_pianificazionefatture` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `idcontratto` int(11) NOT NULL, - `data_scadenza` datetime NOT NULL, - `idzona` int(11) NOT NULL, - `iddocumento` int(11) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `co_ordiniservizio_vociservizio` --- - -CREATE TABLE IF NOT EXISTS `co_ordiniservizio_vociservizio` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `idordineservizio` int(11) NOT NULL, - `voce` varchar(255) NOT NULL, - `categoria` varchar(255) NOT NULL, - `note` varchar(2000) NOT NULL, - `eseguito` tinyint(1) NOT NULL, - `presenza` tinyint(1) NOT NULL, - `esito` tinyint(1) NOT NULL, - `priorita` tinyint(4) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `co_pagamenti` --- - -CREATE TABLE IF NOT EXISTS `co_pagamenti` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `descrizione` varchar(50) NOT NULL, - `giorno` tinyint(4) NOT NULL, - `num_giorni` varchar(100) NOT NULL, - `prc` tinyint(4) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `co_pagamenti` --- - -INSERT INTO `co_pagamenti` (`id`, `descrizione`, `giorno`, `num_giorni`, `prc`) VALUES -(1, 'Rimessa diretta', 0, '0', 100), -(2, 'Rimessa diretta a 30gg', 0, '30', 100), -(3, 'Rimessa diretta 30gg fisso al 15', 15, '30', 100), -(4, 'Ri.Ba. 30gg d.f.', 0, '30', 100), -(5, 'Ri.Ba. 60gg d.f.', 0, '60', 100), -(6, 'Ri.Ba. 90gg d.f.', 0, '90', 100), -(7, 'Ri.Ba. 120gg d.f.', 0, '120', 100), -(8, 'Ri.Ba. 150gg d.f.', 0, '150', 100), -(9, 'Ri.Ba. 180gg d.f.', 0, '180', 100), -(10, 'Ri.Ba. 30/60gg d.f.', 0, '30', 50), -(11, 'Ri.Ba. 30/60gg d.f.', 0, '60', 50), -(12, 'Ri.Ba. 30/60/90gg d.f.', 0, '30', 33), -(13, 'Ri.Ba. 30/60/90gg d.f.', 0, '60', 33), -(14, 'Ri.Ba. 30/60/90gg d.f.', 0, '90', 34), -(15, 'Ri.Ba. 30/60/90/120gg d.f.', 0, '30', 25), -(16, 'Ri.Ba. 30/60/90/120gg d.f.', 0, '60', 25), -(17, 'Ri.Ba. 30/60/90/120gg d.f.', 0, '90', 25), -(18, 'Ri.Ba. 30/60/90/120gg d.f.', 0, '120', 25), -(19, 'Ri.Ba. 30/60/90/120/150gg d.f.', 0, '30', 20), -(20, 'Ri.Ba. 30/60/90/120/150gg d.f.', 0, '60', 20), -(21, 'Ri.Ba. 30/60/90/120/150gg d.f.', 0, '90', 20), -(22, 'Ri.Ba. 30/60/90/120/150gg d.f.', 0, '120', 20), -(23, 'Ri.Ba. 30/60/90/120/150gg d.f.', 0, '150', 20), -(24, 'Ri.Ba. 30/60/90/120/150/180gg d.f.', 0, '30', 16), -(25, 'Ri.Ba. 30/60/90/120/150/180gg d.f.', 0, '60', 16), -(26, 'Ri.Ba. 30/60/90/120/150/180gg d.f.', 0, '90', 16), -(27, 'Ri.Ba. 30/60/90/120/150/180gg d.f.', 0, '120', 16), -(28, 'Ri.Ba. 30/60/90/120/150/180gg d.f.', 0, '150', 16), -(29, 'Ri.Ba. 30/60/90/120/150/180gg d.f.', 0, '180', 20), -(30, 'Ri.Ba. 30gg d.f.f.m.', -1, '30', 100), -(31, 'Ri.Ba. 60gg d.f.f.m.', -1, '60', 100), -(32, 'Ri.Ba. 90gg d.f.f.m.', -1, '90', 100), -(33, 'Ri.Ba. 120gg d.f.f.m.', -1, '120', 100), -(34, 'Ri.Ba. 150gg d.f.f.m.', -1, '150', 100), -(35, 'Ri.Ba. 180gg d.f.f.m.', -1, '180', 100), -(36, 'Ri.Ba. 30/60gg d.f.f.m.', -1, '30', 50), -(37, 'Ri.Ba. 30/60gg d.f.f.m.', -1, '60', 50), -(38, 'Ri.Ba. 30/60/90gg d.f.f.m.', -1, '30', 33), -(39, 'Ri.Ba. 30/60/90gg d.f.f.m.', -1, '60', 33), -(40, 'Ri.Ba. 30/60/90gg d.f.f.m.', -1, '90', 34), -(41, 'Ri.Ba. 30/60/90/120gg d.f.f.m.', -1, '30', 25), -(42, 'Ri.Ba. 30/60/90/120gg d.f.f.m.', -1, '60', 25), -(43, 'Ri.Ba. 30/60/90/120gg d.f.f.m.', -1, '90', 25), -(44, 'Ri.Ba. 30/60/90/120gg d.f.f.m.', -1, '120', 25), -(45, 'Ri.Ba. 30/60/90/120/150gg d.f.f.m.', -1, '30', 20), -(46, 'Ri.Ba. 30/60/90/120/150gg d.f.f.m.', -1, '60', 20), -(47, 'Ri.Ba. 30/60/90/120/150gg d.f.f.m.', -1, '90', 20), -(48, 'Ri.Ba. 30/60/90/120/150gg d.f.f.m.', -1, '120', 20), -(49, 'Ri.Ba. 30/60/90/120/150gg d.f.f.m.', -1, '150', 20), -(50, 'Ri.Ba. 30/60/90/120/150/180gg d.f.f.m.', -1, '30', 16), -(51, 'Ri.Ba. 30/60/90/120/150/180gg d.f.f.m.', -1, '60', 16), -(52, 'Ri.Ba. 30/60/90/120/150/180gg d.f.f.m.', -1, '90', 16), -(53, 'Ri.Ba. 30/60/90/120/150/180gg d.f.f.m.', -1, '120', 16), -(54, 'Ri.Ba. 30/60/90/120/150/180gg d.f.f.m.', -1, '150', 16), -(55, 'Ri.Ba. 30/60/90/120/150/180gg d.f.f.m.', -1, '180', 20), -(56, 'Bonifico 30gg d.f.', 0, '30', 100), -(57, 'Bonifico 60gg d.f.', 0, '60', 100), -(58, 'Bonifico 90gg d.f.', 0, '90', 100), -(59, 'Bonifico 120gg d.f.', 0, '120', 100), -(60, 'Bonifico 150gg d.f.', 0, '150', 100), -(61, 'Bonifico 180gg d.f.', 0, '180', 100), -(62, 'Bonifico 30/60gg d.f.', 0, '30', 50), -(63, 'Bonifico 30/60gg d.f.', 0, '60', 50), -(64, 'Bonifico 30/60/90gg d.f.', 0, '30', 33), -(65, 'Bonifico 30/60/90gg d.f.', 0, '60', 33), -(66, 'Bonifico 30/60/90gg d.f.', 0, '90', 34), -(67, 'Bonifico 30/60/90/120gg d.f.', 0, '30', 25), -(68, 'Bonifico 30/60/90/120gg d.f.', 0, '60', 25), -(69, 'Bonifico 30/60/90/120gg d.f.', 0, '90', 25), -(70, 'Bonifico 30/60/90/120gg d.f.', 0, '120', 25), -(71, 'Bonifico 30/60/90/120/150gg d.f.', 0, '30', 20), -(72, 'Bonifico 30/60/90/120/150gg d.f.', 0, '60', 20), -(73, 'Bonifico 30/60/90/120/150gg d.f.', 0, '90', 20), -(74, 'Bonifico 30/60/90/120/150gg d.f.', 0, '120', 20), -(75, 'Bonifico 30/60/90/120/150gg d.f.', 0, '150', 20), -(76, 'Bonifico 30/60/90/120/150/180gg d.f.', 0, '30', 16), -(77, 'Bonifico 30/60/90/120/150/180gg d.f.', 0, '60', 16), -(78, 'Bonifico 30/60/90/120/150/180gg d.f.', 0, '90', 16), -(79, 'Bonifico 30/60/90/120/150/180gg d.f.', 0, '120', 16), -(80, 'Bonifico 30/60/90/120/150/180gg d.f.', 0, '150', 16), -(81, 'Bonifico 30/60/90/120/150/180gg d.f.', 0, '180', 20), -(82, 'Bonifico 30gg d.f.f.m.', -1, '30', 100), -(83, 'Bonifico 60gg d.f.f.m.', -1, '60', 100), -(84, 'Bonifico 90gg d.f.f.m.', -1, '90', 100), -(85, 'Bonifico 120gg d.f.f.m.', -1, '120', 100), -(86, 'Bonifico 150gg d.f.f.m.', -1, '150', 100), -(87, 'Bonifico 180gg d.f.f.m.', -1, '180', 100), -(88, 'Bonifico 30/60gg d.f.f.m.', -1, '30', 50), -(89, 'Bonifico 30/60gg d.f.f.m.', -1, '60', 50), -(90, 'Bonifico 30/60/90gg d.f.f.m.', -1, '30', 33), -(91, 'Bonifico 30/60/90gg d.f.f.m.', -1, '60', 33), -(92, 'Bonifico 30/60/90gg d.f.f.m.', -1, '90', 34), -(93, 'Bonifico 30/60/90/120gg d.f.f.m.', -1, '30', 25), -(94, 'Bonifico 30/60/90/120gg d.f.f.m.', -1, '60', 25), -(95, 'Bonifico 30/60/90/120gg d.f.f.m.', -1, '90', 25), -(96, 'Bonifico 30/60/90/120gg d.f.f.m.', -1, '120', 25), -(97, 'Bonifico 30/60/90/120/150gg d.f.f.m.', -1, '30', 20), -(98, 'Bonifico 30/60/90/120/150gg d.f.f.m.', -1, '60', 20), -(99, 'Bonifico 30/60/90/120/150gg d.f.f.m.', -1, '90', 20), -(100, 'Bonifico 30/60/90/120/150gg d.f.f.m.', -1, '120', 20), -(101, 'Bonifico 30/60/90/120/150gg d.f.f.m.', -1, '150', 20), -(102, 'Bonifico 30/60/90/120/150/180gg d.f.f.m.', -1, '30', 16), -(103, 'Bonifico 30/60/90/120/150/180gg d.f.f.m.', -1, '60', 16), -(104, 'Bonifico 30/60/90/120/150/180gg d.f.f.m.', -1, '90', 16), -(105, 'Bonifico 30/60/90/120/150/180gg d.f.f.m.', -1, '120', 16), -(106, 'Bonifico 30/60/90/120/150/180gg d.f.f.m.', -1, '150', 16), -(107, 'Bonifico 30/60/90/120/150/180gg d.f.f.m.', -1, '180', 20), -(108, 'Cambiale', 0, '0', 100), -(109, 'Assegno', 0, '0', 100), -(110, 'Bancomat', 0, '0', 100), -(111, 'Contanti', 0, '0', 100), -(112, 'Visa', 0, '0', 100); - --- -------------------------------------------------------- - --- --- Struttura della tabella `co_pianodeiconti1` --- - -CREATE TABLE IF NOT EXISTS `co_pianodeiconti1` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `numero` varchar(10) NOT NULL, - `descrizione` varchar(100) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `co_pianodeiconti1` --- - -INSERT INTO `co_pianodeiconti1` (`id`, `numero`, `descrizione`) VALUES -(1, '01', 'Patrimoniale'), -(2, '02', 'Economico'); - --- -------------------------------------------------------- - --- --- Struttura della tabella `co_pianodeiconti2` --- - -CREATE TABLE IF NOT EXISTS `co_pianodeiconti2` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `numero` varchar(10) NOT NULL, - `descrizione` varchar(100) NOT NULL, - `idpianodeiconti1` int(11) NOT NULL, - `dir` varchar(15) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `co_pianodeiconti2` --- - -INSERT INTO `co_pianodeiconti2` (`id`, `numero`, `descrizione`, `idpianodeiconti1`, `dir`) VALUES -(1, '100', 'Cassa e banche', 1, ''), -(2, '110', 'Crediti clienti e crediti diversi', 1, ''), -(3, '120', 'Effetti attivi', 1, ''), -(4, '130', 'Ratei e risconti attivi', 1, ''), -(5, '200', 'Erario iva, INPS, IRPEF, INAIL, ecc', 1, ''), -(6, '220', 'Immobilizzazioni', 1, ''), -(7, '230', 'Rimanente magazzino', 1, ''), -(8, '240', 'Debiti fornitori e debiti diversi', 1, ''), -(9, '250', 'Ratei e risconti passivi', 1, ''), -(10, '300', 'Fondi ammortamento', 1, ''), -(11, '310', 'Altri fondi', 1, ''), -(12, '400', 'Capitale', 1, ''), -(14, '600', 'Costi merci c/acquisto', 2, 'uscita'), -(15, '610', 'Costi generali', 2, 'uscita'), -(16, '620', 'Costi diversi', 2, ''), -(17, '630', 'Costi del personale', 2, ''), -(18, '640', 'Costi ammortamenti', 2, ''), -(19, '650', 'Costi accantonamenti', 2, ''), -(20, '700', 'Ricavi', 2, 'entrata'), -(21, '810', 'Perdite e profitti', 2, ''), -(22, '900', 'Conti transitori', 2, ''); - --- -------------------------------------------------------- - --- --- Struttura della tabella `co_pianodeiconti3` --- - -CREATE TABLE IF NOT EXISTS `co_pianodeiconti3` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `numero` varchar(10) NOT NULL, - `descrizione` varchar(100) NOT NULL, - `idpianodeiconti2` int(11) NOT NULL, - `dir` varchar(15) NOT NULL, - `can_delete` tinyint(1) NOT NULL, - `can_edit` tinyint(1) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `co_pianodeiconti3` --- - -INSERT INTO `co_pianodeiconti3` (`id`, `numero`, `descrizione`, `idpianodeiconti2`, `dir`, `can_delete`, `can_edit`) VALUES -(1, '000010', 'Cassa', 1, '', 0, 0), -(2, '000020', 'Banca C/C', 1, '', 0, 0), -(3, '000030', 'Effetti in portafoglio', 1, '', 0, 0), -(4, '000040', 'Banca effetti all''incasso', 1, '', 0, 0), -(5, '000050', 'Titoli', 1, '', 0, 0), -(6, '000010', 'Riepilogativo clienti', 2, '', 0, 0), -(7, '000030', 'Clienti per fatture da emettere', 2, '', 0, 0), -(8, '000040', 'Crediti imposte', 2, '', 0, 0), -(9, '000050', 'Crediti diversi', 2, '', 0, 0), -(10, '000060', 'Ri.Ba in portafoglio', 2, '', 0, 0), -(11, '000080', 'Dipendenti c/stipendi', 2, '', 0, 0), -(12, '000090', 'Amministratori c/emolumenti', 2, '', 0, 0), -(13, '000010', 'Effetti allo sconto', 3, '', 0, 0), -(14, '000020', 'Effetti all''incasso', 3, '', 0, 0), -(15, '000030', 'Effetti insoluti', 3, '', 0, 0), -(16, '000010', 'Risconti attivi', 4, '', 0, 0), -(17, '000020', 'Ratei attivi', 4, '', 0, 0), -(18, '000005', 'Erario c/to iva', 5, '', 0, 0), -(19, '000010', 'Erario c/INPS', 5, '', 0, 0), -(20, '000030', 'Erario c/IRPEF', 5, '', 0, 0), -(21, '000040', 'Erario c/INAIL', 5, '', 0, 0), -(22, '000050', 'Erario c/acconto TFR', 5, '', 0, 0), -(23, '000060', 'Erario c/ritenute d''acconto', 5, '', 0, 0), -(24, '000070', 'Erario c/enasarco', 5, '', 0, 0), -(25, '000080', 'Erario c/varie', 5, '', 0, 0), -(26, '000010', 'Fabbricati', 6, '', 1, 0), -(27, '000020', 'Mobili e macchine da ufficio', 6, '', 0, 0), -(28, '000030', 'Automezzi', 6, '', 0, 0), -(29, '000040', 'Impianti e attrezzature', 6, '', 0, 0), -(30, '000060', 'Manutenzione da ammortizzare', 6, '', 0, 0), -(31, '000070', 'Costi pluriennali', 6, '', 0, 0), -(32, '000010', 'Merci c/to rimanenze materie prime', 7, '', 0, 0), -(33, '000020', 'Merci c/to rimanenze semilavorati', 7, '', 0, 0), -(34, '000010', 'Riepilogativo fornitori', 8, '', 0, 0), -(35, '000020', 'Cambiali passive', 8, '', 0, 0), -(36, '000030', 'Mutui passivi', 8, '', 0, 0), -(37, '000040', 'Debiti verso banche', 8, '', 0, 0), -(38, '000050', 'Fornitori per fatture da ricevere', 8, '', 0, 0), -(39, '000060', 'Debiti diversi', 8, '', 0, 0), -(40, '000070', 'Finanziamenti vari', 8, '', 0, 0), -(41, '000200', 'Riepilogativo fornitori contabilità semplificata', 8, '', 0, 0), -(42, '000010', 'Risconti passivi', 9, '', 0, 0), -(43, '000020', 'Ratei passivi', 9, '', 0, 0), -(44, '000010', 'Fondi ammortamento fabbricati', 10, '', 0, 0), -(45, '000020', 'Fondi ammortamento mobili e macchine da ufficio', 10, '', 0, 0), -(46, '000030', 'Fondi ammortamento automezzi', 10, '', 0, 0), -(47, '000040', 'Fondi ammortamento impianti e attrezzature', 10, '', 0, 0), -(48, '000060', 'Fondi ammortamento manutenzione da ammortizzare', 10, '', 0, 0), -(49, '000070', 'Fondi ammortamento costi pluriennali', 10, '', 0, 0), -(50, '000010', 'Fondo imposte e tasse', 11, '', 0, 0), -(51, '000020', 'Fondo TFR liquidazione personale', 11, '', 0, 0), -(52, '000010', 'Capitale sociale o netto', 12, '', 0, 0), -(53, '000020', 'Riserve', 12, '', 0, 0), -(55, '000010', 'Costi merci c/acquisto di rivendita', 14, 'uscita', 0, 0), -(56, '000020', 'Costi merci c/acquisto di produzione', 14, 'uscita', 0, 0), -(57, '000030', 'Costi merci c/acquisto intracomunitario', 14, 'uscita', 0, 0), -(58, '000040', 'Costi merci c/acquisto importazioni', 14, 'uscita', 0, 0), -(59, '000010', 'Spese telefoniche', 15, 'uscita', 1, 1), -(60, '000020', 'Spese postali', 15, 'uscita', 1, 1), -(61, '000030', 'Spese cancelleria', 15, 'uscita', 1, 1), -(62, '000040', 'Spese locomozione e carburante', 15, 'uscita', 0, 0), -(63, '000050', 'Spese software', 15, 'uscita', 1, 1), -(64, '000060', 'Spese energia elettrica', 15, 'uscita', 1, 1), -(65, '000070', 'Spese consulenze', 15, 'uscita', 1, 1), -(66, '000080', 'Spese varie', 15, 'uscita', 1, 1), -(67, '000090', 'Spese assicurazioni', 15, 'uscita', 1, 1), -(68, '000100', 'Spese bancarie', 15, 'uscita', 1, 1), -(69, '000110', 'Spese fitti passivi', 15, 'uscita', 1, 1), -(70, '000120', 'Spese ristoranti e alberghi', 15, 'uscita', 1, 1), -(71, '000130', 'Spese manutenzione e riparazione', 15, 'uscita', 1, 1), -(72, '000140', 'Spese canoni leasing', 15, 'uscita', 1, 1), -(73, '000150', 'Spese acquisto beni strumentali non ammortizzabilii', 15, 'uscita', 0, 0), -(74, '000010', 'Costi interessi passivi', 16, '', 0, 0), -(75, '000020', 'Costi abbuoni passivi', 16, '', 0, 0), -(76, '000030', 'Costi imposte e tasse', 16, '', 0, 0), -(77, '000040', 'Costi imposta IRA', 16, '', 0, 0), -(78, '000050', 'Costi minusvalenze', 16, '', 0, 0), -(79, '000060', 'Costi perdite su crediti', 16, '', 0, 0), -(80, '000070', 'Costi sopravvenienze passive', 16, '', 0, 0), -(81, '000080', 'Costi perdite da operazioni finanziarie', 16, '', 0, 0), -(82, '000010', 'Costi salari e stipendi', 17, '', 0, 0), -(83, '000020', 'Costi contributi sociali', 17, '', 0, 0), -(84, '000040', 'Costi TFR', 17, '', 0, 0), -(85, '000050', 'Costi contributi dipendenti', 17, '', 0, 0), -(86, '000060', 'Costi contributi assicurazione lavoro', 17, '', 0, 0), -(87, '000010', 'Ammortamento fabbricati', 18, '', 0, 0), -(88, '000020', 'Ammortamento mobili e macchine ufficio', 18, '', 0, 0), -(89, '000030', 'Ammortamento automezzi', 18, '', 0, 0), -(90, '000040', 'Ammortamento impianti e attrezzature', 18, '', 0, 0), -(91, '000060', 'Ammortamento manutenzioni', 18, '', 0, 0), -(92, '000070', 'Ammortamento costi pluriennali', 18, '', 0, 0), -(93, '000010', 'Accantonamento TFR', 19, '', 0, 0), -(94, '000010', 'Ricavi merci c/to vendite', 20, 'entrata', 0, 0), -(95, '000020', 'Ricavi vendita prestazione servizi', 20, 'entrata', 0, 0), -(96, '000030', 'Ricavi interessi attivi', 20, 'entrata', 0, 0), -(97, '000040', 'Ricavi fitti attivi', 20, 'entrata', 0, 0), -(98, '000050', 'Ricavi vari', 20, 'entrata', 0, 0), -(99, '000051', 'Rimborso spese marche da bollo', 20, '', 0, 0), -(100, '000060', 'Ricavi abbuoni attivi', 20, '', 0, 0), -(101, '000070', 'Ricavi sopravvenienze attive', 20, '', 0, 0), -(102, '000080', 'Ricavi plusvalenze', 20, '', 0, 0), -(103, '000020', 'Perdite e profitti', 21, '', 0, 0), -(104, '000010', 'Apertura conti patrimoniali', 21, '', 0, 0), -(105, '000900', 'Chiusura conti patrimoniali', 21, '', 0, 0), -(106, '000010', 'Iva su vendite', 22, '', 0, 0), -(107, '000020', 'Iva su acquisti', 22, '', 0, 0), -(108, '000030', 'Iva indetraibile', 22, '', 0, 0), -(109, '000200', 'Intra UE: riepilogativo fornitori', 22, '', 0, 0), -(110, '000210', 'Intra UE: transitorio iva', 22, '', 0, 0), -(111, '000220', 'Intra UE: transitorio per movimento iva', 22, '', 0, 0); - --- -------------------------------------------------------- - --- --- Struttura della tabella `co_preventivi` --- - -CREATE TABLE IF NOT EXISTS `co_preventivi` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `numero` varchar(50) NOT NULL, - `nome` varchar(100) NOT NULL, - `idagente` int(11) NOT NULL, - `data_bozza` datetime NOT NULL, - `data_accettazione` datetime NOT NULL, - `data_rifiuto` datetime NOT NULL, - `data_conclusione` datetime NOT NULL, - `data_pagamento` datetime NOT NULL, - `budget` float(12,4) NOT NULL, - `descrizione` text NOT NULL, - `idstato` tinyint(4) NOT NULL, - `validita` int(11) NOT NULL, - `tempi_consegna` varchar(255) NOT NULL, - `idanagrafica` int(11) NOT NULL, - `esclusioni` text NOT NULL, - `idreferente` int(11) NOT NULL, - `idpagamento` int(11) NOT NULL, - `idporto` int(11) NOT NULL, - `idtipointervento` varchar(25) NOT NULL, - `costo_diritto_chiamata` float(12,4) NOT NULL, - `ore_lavoro` float(12,4) NOT NULL, - `costo_orario` float(12,4) NOT NULL, - `costo_km` float(12,4) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=MyISAM; - --- -------------------------------------------------------- - --- --- Struttura della tabella `co_preventivi_interventi` --- - -CREATE TABLE IF NOT EXISTS `co_preventivi_interventi` ( - `idpreventivo` int(11) NOT NULL, - `idintervento` varchar(25) NOT NULL, - `costo_orario` float(12,4) NOT NULL, - `costo_km` float(12,4) NOT NULL, - PRIMARY KEY (`idpreventivo`,`idintervento`) -) ENGINE=MyISAM; - --- -------------------------------------------------------- - --- --- Struttura della tabella `co_righe2_contratti` --- - -CREATE TABLE IF NOT EXISTS `co_righe2_contratti` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `idcontratto` int(11) NOT NULL, - `descrizione` text NOT NULL, - `subtotale` float(12,4) NOT NULL, - `um` varchar(20) NOT NULL, - `qta` float(12,4) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `co_righe_contratti` --- - -CREATE TABLE IF NOT EXISTS `co_righe_contratti` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `idcontratto` int(11) NOT NULL, - `idintervento` varchar(25) NOT NULL, - `idtipointervento` varchar(25) NOT NULL, - `data_richiesta` datetime NOT NULL, - `richiesta` varchar(8000) NOT NULL, - `idsede` int(11) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `co_righe_documenti` --- - -CREATE TABLE IF NOT EXISTS `co_righe_documenti` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `iddocumento` int(11) NOT NULL, - `idordine` int(11) NOT NULL, - `idddt` int(11) NOT NULL, - `idintervento` varchar(25) NOT NULL, - `idarticolo` int(11) NOT NULL, - `idpreventivo` int(11) NOT NULL, - `idcontratto` int(11) NOT NULL, - `idtecnico` int(11) NOT NULL, - `idagente` int(11) NOT NULL, - `idautomezzo` int(11) NOT NULL, - `idiva` int(11) NOT NULL, - `desc_iva` varchar(255) NOT NULL, - `iva` float(12,4) NOT NULL, - `iva_indetraibile` float(12,4) NOT NULL, - `descrizione` text NOT NULL, - `subtotale` float(12,4) NOT NULL, - `sconto` float(12,4) NOT NULL, - `um` varchar(20) NOT NULL, - `qta` float(12,4) NOT NULL, - `lotto` varchar(50) NOT NULL, - `serial` varchar(50) NOT NULL, - `altro` varchar(50) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `co_righe_preventivi` --- - -CREATE TABLE IF NOT EXISTS `co_righe_preventivi` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `data_evasione` datetime NOT NULL, - `idpreventivo` int(11) NOT NULL, - `idarticolo` int(11) NOT NULL, - `idiva` int(11) NOT NULL, - `iva` float(12,4) NOT NULL, - `iva_indetraibile` float(12,4) NOT NULL, - `descrizione` text NOT NULL, - `lotto` varchar(50) NOT NULL, - `serial` varchar(50) NOT NULL, - `altro` varchar(50) NOT NULL, - `subtotale` float(12,4) NOT NULL, - `um` varchar(20) NOT NULL, - `qta` float(12,4) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `co_ritenutaacconto` --- - -CREATE TABLE IF NOT EXISTS `co_ritenutaacconto` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `descrizione` varchar(100) NOT NULL, - `percentuale` float(5,2) NOT NULL, - `indetraibile` float(5,2) NOT NULL, - `esente` tinyint(1) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `co_ritenutaacconto` --- - -INSERT INTO `co_ritenutaacconto` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`) VALUES -(1, 'Ritenuta d''acconto 20%', 20.00, 0.00, 0); - --- -------------------------------------------------------- - --- --- Struttura della tabella `co_rivalsainps` --- - -CREATE TABLE IF NOT EXISTS `co_rivalsainps` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `descrizione` varchar(100) NOT NULL, - `percentuale` float(5,2) NOT NULL, - `indetraibile` float(5,2) NOT NULL, - `esente` tinyint(1) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `co_rivalsainps` --- - -INSERT INTO `co_rivalsainps` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`) VALUES -(1, 'Rivalsa INPS 4%', 4.00, 0.00, 0); - --- -------------------------------------------------------- - --- --- Struttura della tabella `co_scadenziario` --- - -CREATE TABLE IF NOT EXISTS `co_scadenziario` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `iddocumento` int(11) NOT NULL, - `data_emissione` datetime NOT NULL, - `scadenza` datetime NOT NULL, - `da_pagare` float(12,4) DEFAULT NULL, - `pagato` float(12,4) DEFAULT NULL, - `data_pagamento` datetime NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `co_staticontratti` --- - -CREATE TABLE IF NOT EXISTS `co_staticontratti` ( - `id` tinyint(4) NOT NULL AUTO_INCREMENT, - `descrizione` varchar(100) DEFAULT NULL, - `icona` varchar(255) NOT NULL, - `completato` tinyint(1) NOT NULL DEFAULT '0', - `annullato` tinyint(1) DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `co_staticontratti` --- - -INSERT INTO `co_staticontratti` (`id`, `descrizione`, `icona`, `completato`, `annullato`) VALUES -(1, 'Bozza', 'fa fa-2x fa-file-text-o text-muted', 0, 0), -(2, 'In attesa di conferma', 'fa fa-2x fa-clock-o text-warning', 0, 0), -(3, 'Accettato', 'fa fa-2x fa-thumbs-up text-success', 0, 0), -(4, 'Rifiutato', 'fa fa-2x fa-thumbs-down text-danger', 0, 1), -(5, 'In lavorazione', 'fa fa-2x fa-gear text-warning', 1, 0), -(6, 'In attesa di pagamento', 'fa fa-2x fa-money text-primary', 0, 0), -(7, 'Pagato', 'fa fa-2x fa-check-circle text-success', 0, 0); - --- -------------------------------------------------------- - --- --- Struttura della tabella `co_statidocumento` --- - -CREATE TABLE IF NOT EXISTS `co_statidocumento` ( - `id` tinyint(4) NOT NULL AUTO_INCREMENT, - `descrizione` varchar(100) NOT NULL, - `icona` varchar(255) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `co_statidocumento` --- - -INSERT INTO `co_statidocumento` (`id`, `descrizione`, `icona`) VALUES -(1, 'Pagato', 'fa fa-2x fa-check-circle text-success'), -(2, 'Bozza', 'fa fa-2x fa-file-text-o text-muted'), -(3, 'Emessa', 'fa fa-2x fa-clock-o text-info'), -(4, 'Annullata', 'fa fa-2x fa-times text-danger'); - --- -------------------------------------------------------- - --- --- Struttura della tabella `co_statipreventivi` --- - -CREATE TABLE IF NOT EXISTS `co_statipreventivi` ( - `id` tinyint(4) NOT NULL AUTO_INCREMENT, - `descrizione` varchar(100) NOT NULL, - `icona` varchar(255) NOT NULL, - `completato` tinyint(1) NOT NULL DEFAULT '0', - `annullato` tinyint(1) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `co_statipreventivi` --- - -INSERT INTO `co_statipreventivi` (`id`, `descrizione`, `icona`, `completato`, `annullato`) VALUES -(1, 'Bozza', 'fa fa-2x fa-file-text-o text-muted', 0, 0), -(2, 'In attesa di conferma', 'fa fa-2x fa-clock-o text-warning', 0, 0), -(3, 'Accettato', 'fa fa-2x fa-thumbs-up text-success', 0, 0), -(4, 'Rifiutato', 'fa fa-2x fa-thumbs-down text-danger', 0, 1), -(5, 'In lavorazione', 'fa fa-2x fa-gear text-warning', 1, 0), -(6, 'Concluso', 'fa fa-2x fa-check text-success', 0, 0), -(7, 'Pagato', 'fa fa-2x fa-check-circle text-success', 0, 0), -(8, 'In attesa di pagamento', 'fa fa-2x fa-money text-primary', 0, 0); - --- -------------------------------------------------------- - --- --- Struttura della tabella `co_tipidocumento` --- - -CREATE TABLE IF NOT EXISTS `co_tipidocumento` ( - `id` tinyint(11) NOT NULL AUTO_INCREMENT, - `descrizione` varchar(100) NOT NULL, - `dir` enum('entrata','uscita') NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `co_tipidocumento` --- - -INSERT INTO `co_tipidocumento` (`id`, `descrizione`, `dir`) VALUES -(1, 'Fattura immediata di acquisto', 'uscita'), -(2, 'Fattura immediata di vendita', 'entrata'), -(3, 'Fattura differita di acquisto', 'uscita'), -(4, 'Fattura differita di vendita', 'entrata'), -(5, 'Fattura accompagnatoria di acquisto', 'uscita'), -(6, 'Fattura accompagnatoria di vendita', 'entrata'), -(7, 'Nota di accredito', 'uscita'), -(8, 'Nota di addebito', 'uscita'), -(9, 'Nota di accredito', 'entrata'), -(10, 'Nota di addebito', 'entrata'); - --- -------------------------------------------------------- - --- --- Struttura della tabella `dt_aspettobeni` --- - -CREATE TABLE IF NOT EXISTS `dt_aspettobeni` ( - `id` tinyint(4) NOT NULL AUTO_INCREMENT, - `descrizione` varchar(255) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `dt_aspettobeni` --- - -INSERT INTO `dt_aspettobeni` (`id`, `descrizione`) VALUES -(1, 'A vista'), -(2, 'Cartoni'), -(3, 'Sacchi'), -(4, 'Scatola'); - --- -------------------------------------------------------- - --- --- Struttura della tabella `dt_automezzi` --- - -CREATE TABLE IF NOT EXISTS `dt_automezzi` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `nome` varchar(200) NOT NULL, - `descrizione` varchar(1000) NOT NULL, - `targa` varchar(20) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `dt_automezzi_tagliandi` --- - -CREATE TABLE IF NOT EXISTS `dt_automezzi_tagliandi` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `idautomezzo` int(11) NOT NULL, - `descrizione` varchar(255) NOT NULL, - `km` int(11) NOT NULL, - `data_emissione` datetime NOT NULL, - `validita` int(11) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `dt_automezzi_tecnici` --- - -CREATE TABLE IF NOT EXISTS `dt_automezzi_tecnici` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `idautomezzo` int(11) NOT NULL, - `idtecnico` int(11) NOT NULL, - `data_inizio` datetime NOT NULL, - `data_fine` datetime NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `dt_causalet` --- - -CREATE TABLE IF NOT EXISTS `dt_causalet` ( - `id` tinyint(4) NOT NULL AUTO_INCREMENT, - `descrizione` varchar(255) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `dt_causalet` --- - -INSERT INTO `dt_causalet` (`id`, `descrizione`) VALUES -(1, 'Vendita'), -(2, 'Noleggio'), -(3, 'Reso'); - --- -------------------------------------------------------- - --- --- Struttura della tabella `dt_ddt` --- - -CREATE TABLE IF NOT EXISTS `dt_ddt` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `numero` int(11) NOT NULL, - `numero_esterno` varchar(100) NOT NULL, - `data` datetime NOT NULL, - `idagente` int(11) NOT NULL, - `idiva` int(11) NOT NULL, - `idanagrafica` int(11) NOT NULL, - `idcausalet` int(11) NOT NULL, - `idspedizione` tinyint(4) NOT NULL, - `idporto` tinyint(4) NOT NULL, - `idaspettobeni` tinyint(4) NOT NULL, - `idvettore` int(11) NOT NULL, - `idtipoddt` tinyint(4) NOT NULL, - `idstatoddt` tinyint(4) NOT NULL, - `idpagamento` int(11) NOT NULL, - `idconto` int(11) NOT NULL, - `idrivalsainps` int(11) NOT NULL, - `idritenutaacconto` int(11) NOT NULL, - `idsede` int(11) NOT NULL, - `rivalsainps` float(12,4) NOT NULL, - `iva_rivalsainps` float(12,4) NOT NULL, - `ritenutaacconto` float(12,4) NOT NULL, - `bollo` float(12,4) NOT NULL, - `n_colli` int(11) NOT NULL, - `note` varchar(255) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `dt_porto` --- - -CREATE TABLE IF NOT EXISTS `dt_porto` ( - `id` tinyint(4) NOT NULL AUTO_INCREMENT, - `descrizione` varchar(255) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `dt_porto` --- - -INSERT INTO `dt_porto` (`id`, `descrizione`) VALUES -(1, 'Franco'), -(2, 'Assegnato'); - --- -------------------------------------------------------- - --- --- Struttura della tabella `dt_righe_ddt` --- - -CREATE TABLE IF NOT EXISTS `dt_righe_ddt` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `idddt` int(11) NOT NULL, - `idordine` int(11) NOT NULL, - `idarticolo` int(11) NOT NULL, - `idiva` int(11) NOT NULL, - `iva` float(12,4) NOT NULL, - `iva_indetraibile` float(12,4) NOT NULL, - `descrizione` text NOT NULL, - `lotto` varchar(50) NOT NULL, - `serial` varchar(50) NOT NULL, - `altro` varchar(50) NOT NULL, - `subtotale` float(12,4) NOT NULL, - `sconto` float(12,4) NOT NULL, - `um` varchar(20) NOT NULL, - `qta` float(12,4) NOT NULL, - `qta_evasa` float(12,4) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `dt_spedizione` --- - -CREATE TABLE IF NOT EXISTS `dt_spedizione` ( - `id` tinyint(4) NOT NULL AUTO_INCREMENT, - `descrizione` varchar(255) NOT NULL, - `esterno` tinyint(1) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `dt_spedizione` --- - -INSERT INTO `dt_spedizione` (`id`, `descrizione`, `esterno`) VALUES -(1, 'A nostro carico', 0), -(2, 'Vettore', 1), -(3, 'A carico del cliente', 0); - --- -------------------------------------------------------- - --- --- Struttura della tabella `dt_statiddt` --- - -CREATE TABLE IF NOT EXISTS `dt_statiddt` ( - `id` tinyint(4) NOT NULL AUTO_INCREMENT, - `descrizione` varchar(100) NOT NULL, - `icona` varchar(100) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `dt_statiddt` --- - -INSERT INTO `dt_statiddt` (`id`, `descrizione`, `icona`) VALUES -(1, 'Bozza', 'fa fa-2x fa-file-text-o text-muted'), -(2, 'Evaso', 'fa fa-2x fa-clock-o text-info'), -(3, 'Pagato', 'fa fa-2x fa-check-circle text-success'); - --- -------------------------------------------------------- - --- --- Struttura della tabella `dt_tipiddt` --- - -CREATE TABLE IF NOT EXISTS `dt_tipiddt` ( - `id` tinyint(4) NOT NULL AUTO_INCREMENT, - `descrizione` varchar(100) DEFAULT NULL, - `dir` enum('entrata','uscita') DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `dt_tipiddt` --- - -INSERT INTO `dt_tipiddt` (`id`, `descrizione`, `dir`) VALUES -(1, 'Ddt di acquisto', 'uscita'), -(2, 'Ddt di vendita', 'entrata'); - --- -------------------------------------------------------- - --- --- Struttura della tabella `in_interventi` --- - -CREATE TABLE IF NOT EXISTS `in_interventi` ( - `idintervento` varchar(25) NOT NULL, - `data_richiesta` datetime NOT NULL, - `richiesta` text NOT NULL, - `descrizione` text NOT NULL, - `km` float(7,2) NOT NULL, - `idtipointervento` varchar(25) NOT NULL, - `nomefile` varchar(255) NOT NULL, - `idanagrafica` int(11) NOT NULL, - `idreferente` int(11) NOT NULL, - `idstatointervento` varchar(10) NOT NULL, - `informazioniaggiuntive` text NOT NULL, - `prezzo_ore_unitario` float(10,2) NOT NULL, - `idsede` int(11) NOT NULL, - `idautomezzo` int(11) NOT NULL, - `idclientefinale` int(11) NOT NULL, - `info_sede` varchar(255) NOT NULL, - `data_sla` date NOT NULL, - `ora_sla` time NOT NULL, - PRIMARY KEY (`idintervento`), - KEY `in_interventi_ibfk_1` (`idanagrafica`), - KEY `in_interventi_ibfk_2` (`idtipointervento`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `in_interventi_tecnici` --- - -CREATE TABLE IF NOT EXISTS `in_interventi_tecnici` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `idintervento` varchar(25) NOT NULL, - `idtecnico` int(11) NOT NULL, - `orario_inizio` datetime NOT NULL, - `orario_fine` datetime NOT NULL, - `km` float(12,4) NOT NULL, - `prezzo_ore_unitario` float(12,4) NOT NULL, - `prezzo_km_unitario` float(12,4) NOT NULL, - `prezzo_ore_consuntivo` float(12,4) NOT NULL, - `prezzo_km_consuntivo` float(12,4) NOT NULL, - `prezzo_dirittochiamata` float(12,4) NOT NULL, - `prezzo_ore_unitario_tecnico` float(12,4) NOT NULL, - `prezzo_km_unitario_tecnico` float(12,4) NOT NULL, - `prezzo_ore_consuntivo_tecnico` float(12,4) NOT NULL, - `prezzo_km_consuntivo_tecnico` float(12,4) NOT NULL, - `prezzo_dirittochiamata_tecnico` float(12,4) NOT NULL, - PRIMARY KEY (`id`), - KEY `in_interventi_tecnici_ibfk_1` (`idintervento`), - KEY `in_interventi_tecnici_ibfk_2` (`idtecnico`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `in_righe_interventi` --- - -CREATE TABLE IF NOT EXISTS `in_righe_interventi` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `descrizione` varchar(255) NOT NULL, - `qta` float(12,4) NOT NULL, - `um` varchar(25) NOT NULL, - `prezzo` float(12,4) NOT NULL, - `idintervento` varchar(25) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `in_statiintervento` --- - -CREATE TABLE IF NOT EXISTS `in_statiintervento` ( - `idstatointervento` varchar(10) NOT NULL, - `descrizione` varchar(255) NOT NULL, - `colore` varchar(7) NOT NULL DEFAULT '#FFFFFF', - `default` tinyint(1) NOT NULL, - `completato` tinyint(1) NOT NULL, - PRIMARY KEY (`idstatointervento`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `in_statiintervento` --- - -INSERT INTO `in_statiintervento` (`idstatointervento`, `descrizione`, `colore`, `default`, `completato`) VALUES -('CALL', 'Chiamata', '#96c0ff', 1, 0), -('FAT', 'Fatturato', '#55FF55', 1, 0), -('OK', 'Completato', '#a3ff82', 1, 1), -('WIP', 'In programmazione', '#ffc400', 1, 0); - --- -------------------------------------------------------- - --- --- Struttura della tabella `in_tariffe` --- - -CREATE TABLE IF NOT EXISTS `in_tariffe` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `idtecnico` int(11) NOT NULL, - `idtipointervento` varchar(25) NOT NULL, - `costo_ore` float(12,4) NOT NULL, - `costo_km` float(12,4) NOT NULL, - `costo_dirittochiamata` float(12,4) NOT NULL, - `costo_ore_tecnico` float(12,4) NOT NULL, - `costo_km_tecnico` float(12,4) NOT NULL, - `costo_dirittochiamata_tecnico` float(12,4) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `in_tipiintervento` --- - -CREATE TABLE IF NOT EXISTS `in_tipiintervento` ( - `idtipointervento` varchar(25) NOT NULL, - `descrizione` varchar(255) NOT NULL, - `costo_orario` float(12,4) NOT NULL, - `costo_km` float(12,4) NOT NULL, - `costo_diritto_chiamata` float(12,4) NOT NULL, - `costo_orario_tecnico` float(12,4) NOT NULL, - `costo_km_tecnico` float(12,4) NOT NULL, - `costo_diritto_chiamata_tecnico` float(12,4) NOT NULL, - PRIMARY KEY (`idtipointervento`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `in_tipiintervento` --- - -INSERT INTO `in_tipiintervento` (`idtipointervento`, `descrizione`, `costo_orario`, `costo_km`, `costo_diritto_chiamata`, `costo_orario_tecnico`, `costo_km_tecnico`, `costo_diritto_chiamata_tecnico`) VALUES -('GEN', 'Generico', 30.0000, 0.5000, 0.0000, 0.0000, 0.0000, 0.0000), -('ODS', 'Ordine di servizio', 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000); - --- -------------------------------------------------------- - --- --- Struttura della tabella `in_vociservizio` --- - -CREATE TABLE IF NOT EXISTS `in_vociservizio` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `descrizione` varchar(255) NOT NULL, - `categoria` varchar(255) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `in_vociservizio` --- - -INSERT INTO `in_vociservizio` (`id`, `descrizione`, `categoria`) VALUES -(1, 'Manutenzione programmata', 'Intervento generico'); - --- -------------------------------------------------------- - --- --- Struttura della tabella `mg_articoli` --- - -CREATE TABLE IF NOT EXISTS `mg_articoli` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `codice` varchar(255) NOT NULL, - `descrizione` varchar(255) NOT NULL, - `idum` tinyint(11) NOT NULL, - `categoria` varchar(255) NOT NULL, - `subcategoria` varchar(255) NOT NULL, - `immagine01` varchar(255) NOT NULL, - `note` varchar(1000) NOT NULL, - `qta` float(12,4) NOT NULL, - `threshold_qta` float(12,4) NOT NULL, - `prezzo_acquisto` float(12,4) NOT NULL, - `prezzo_vendita` float(12,4) NOT NULL, - `idiva_vendita` int(11) NOT NULL, - `gg_garanzia` int(11) NOT NULL, - `componente_filename` varchar(255) NOT NULL, - `contenuto` text NOT NULL, - `attivo` tinyint(1) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `mg_articoli_automezzi` --- - -CREATE TABLE IF NOT EXISTS `mg_articoli_automezzi` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `idarticolo` int(11) NOT NULL, - `idautomezzo` int(11) NOT NULL, - `qta` float(12,4) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `mg_articoli_interventi` --- - -CREATE TABLE IF NOT EXISTS `mg_articoli_interventi` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `idarticolo` int(11) NOT NULL, - `idintervento` varchar(25) NOT NULL, - `matricola` varchar(25) NOT NULL, - `descrizione` varchar(255) NOT NULL, - `lotto` varchar(50) NOT NULL, - `serial` varchar(50) NOT NULL, - `altro` varchar(50) NOT NULL, - `prezzo_vendita` float(12,4) NOT NULL, - `sconto` float(12,4) NOT NULL, - `idiva_vendita` float(10,2) NOT NULL, - `idautomezzo` int(11) NOT NULL, - `qta` float(10,2) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `mg_listini` --- - -CREATE TABLE IF NOT EXISTS `mg_listini` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `nome` varchar(255) NOT NULL, - `prc_guadagno` float(5,2) NOT NULL, - `note` varchar(1000) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `mg_movimenti` --- - -CREATE TABLE IF NOT EXISTS `mg_movimenti` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `idarticolo` int(11) NOT NULL, - `descrizione_articolo` varchar(255) NOT NULL, - `qta` float(12,4) NOT NULL, - `movimento` varchar(255) NOT NULL, - `data` datetime NOT NULL, - `idintervento` varchar(25) NOT NULL, - `idddt` int(11) NOT NULL, - `iddocumento` int(11) NOT NULL, - `idautomezzo` int(11) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `mg_prodotti` --- - -CREATE TABLE IF NOT EXISTS `mg_prodotti` ( - `id` bigint(20) NOT NULL AUTO_INCREMENT, - `idarticolo` int(11) NOT NULL, - `lotto` varchar(50) NOT NULL, - `serial` varchar(50) NOT NULL, - `altro` varchar(50) NOT NULL, - `data` datetime NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `mg_unitamisura` --- - -CREATE TABLE IF NOT EXISTS `mg_unitamisura` ( - `id` tinyint(4) NOT NULL AUTO_INCREMENT, - `valore` varchar(20) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `mg_unitamisura` --- - -INSERT INTO `mg_unitamisura` (`id`, `valore`) VALUES -(1, 'nr'), -(2, 'kg'), -(3, 'pz'), -(4, 'litri'), -(5, 'ore'); - --- -------------------------------------------------------- - --- --- Struttura della tabella `mk_allegati` --- - -CREATE TABLE IF NOT EXISTS `mk_allegati` ( - `idallegato` int(11) NOT NULL AUTO_INCREMENT, - `idcliente` int(11) NOT NULL, - `nome` varchar(255) NOT NULL, - PRIMARY KEY (`idallegato`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `mk_attivita` --- - -CREATE TABLE IF NOT EXISTS `mk_attivita` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `idstato` int(11) NOT NULL, - `data` date NOT NULL, - `ora_dal` time NOT NULL, - `ora_al` time NOT NULL, - `infogiorno` varchar(255) NOT NULL, - `descrizione` text NOT NULL, - `idagente` int(11) NOT NULL, - `idcliente` int(11) NOT NULL, - `idreferente` int(11) NOT NULL, - `luogo` varchar(500) NOT NULL, - `idtipo` int(11) NOT NULL, - `datanotifica` datetime NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `mk_email` --- - -CREATE TABLE IF NOT EXISTS `mk_email` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `data_invio` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `da` varchar(255) NOT NULL, - `a` varchar(500) NOT NULL, - `cc` varchar(500) NOT NULL, - `bcc` varchar(500) NOT NULL, - `oggetto` varchar(255) NOT NULL, - `idallegato` varchar(255) NOT NULL, - `confermalettura` tinyint(1) NOT NULL, - `confermarecapito` tinyint(1) NOT NULL, - `testo` text NOT NULL, - `presentazione` tinyint(1) NOT NULL, - `idcliente` int(11) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `mk_statoattivita` --- - -CREATE TABLE IF NOT EXISTS `mk_statoattivita` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `descrizione` varchar(255) NOT NULL, - `colore` varchar(7) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `mk_statoattivita` --- - -INSERT INTO `mk_statoattivita` (`id`, `descrizione`, `colore`) VALUES -(1, 'Completato', '#a3ff82'), -(2, 'In programmazione', '#ffc400'), -(3, 'Annullato', '#fa6161'); - --- -------------------------------------------------------- - --- --- Struttura della tabella `mk_tipoattivita` --- - -CREATE TABLE IF NOT EXISTS `mk_tipoattivita` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `descrizione` varchar(100) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `mk_tipoattivita` --- - -INSERT INTO `mk_tipoattivita` (`id`, `descrizione`) VALUES -(1, 'Appuntamento'), -(2, 'Chiamata'); - --- -------------------------------------------------------- - --- --- Struttura della tabella `my_impianti` --- - -CREATE TABLE IF NOT EXISTS `my_impianti` ( - `matricola` varchar(25) NOT NULL, - `nome` varchar(255) NOT NULL, - `descrizione` varchar(5000) NOT NULL, - `idanagrafica` int(11) NOT NULL, - `idsede` int(11) NOT NULL, - `data` date NOT NULL, - `idtecnico` int(11) NOT NULL, - `ubicazione` varchar(255) NOT NULL, - `scala` varchar(50) NOT NULL, - `piano` varchar(50) NOT NULL, - `occupante` varchar(255) NOT NULL, - `proprietario` varchar(255) NOT NULL, - `palazzo` varchar(255) NOT NULL, - `interno` varchar(255) NOT NULL, - `immagine` varchar(255) NOT NULL, - PRIMARY KEY (`matricola`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `my_impianti_interventi` --- - -CREATE TABLE IF NOT EXISTS `my_impianti_interventi` ( - `idintervento` varchar(25) NOT NULL, - `matricola` varchar(25) NOT NULL, - PRIMARY KEY (`idintervento`,`matricola`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `my_impianto_componenti` --- - -CREATE TABLE IF NOT EXISTS `my_impianto_componenti` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `idsostituto` int(11) NOT NULL, - `matricola` varchar(25) NOT NULL, - `idintervento` varchar(20) NOT NULL, - `nome` varchar(255) NOT NULL, - `data` datetime NOT NULL, - `data_sostituzione` datetime NOT NULL, - `filename` varchar(255) NOT NULL, - `contenuto` text NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `or_ordini` --- - -CREATE TABLE IF NOT EXISTS `or_ordini` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `numero` varchar(100) NOT NULL, - `numero_esterno` varchar(100) NOT NULL, - `data` datetime NOT NULL, - `idagente` int(11) NOT NULL, - `idanagrafica` int(11) NOT NULL, - `idsede` int(11) NOT NULL, - `idtipoordine` tinyint(4) NOT NULL, - `idstatoordine` tinyint(4) NOT NULL, - `idpagamento` int(11) NOT NULL, - `idconto` int(11) NOT NULL, - `idrivalsainps` int(11) NOT NULL, - `idritenutaacconto` int(11) NOT NULL, - `rivalsainps` float(12,4) NOT NULL, - `iva_rivalsainps` float(12,4) NOT NULL, - `ritenutaacconto` float(12,4) NOT NULL, - `bollo` float(10,2) NOT NULL, - `note` varchar(255) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `or_righe_ordini` --- - -CREATE TABLE IF NOT EXISTS `or_righe_ordini` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `data_evasione` datetime NOT NULL, - `idordine` int(11) NOT NULL, - `idarticolo` int(11) NOT NULL, - `idiva` int(11) NOT NULL, - `idagente` int(11) NOT NULL, - `iva` float(12,4) NOT NULL, - `iva_indetraibile` float(12,4) NOT NULL, - `descrizione` text NOT NULL, - `lotto` varchar(50) NOT NULL, - `serial` varchar(50) NOT NULL, - `altro` varchar(50) NOT NULL, - `subtotale` float(12,4) NOT NULL, - `sconto` float(12,4) NOT NULL, - `um` varchar(20) NOT NULL, - `qta` float(12,4) NOT NULL, - `qta_evasa` float(12,4) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `or_statiordine` --- - -CREATE TABLE IF NOT EXISTS `or_statiordine` ( - `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; - --- --- Dump dei dati per la tabella `or_statiordine` --- - -INSERT INTO `or_statiordine` (`id`, `descrizione`, `annullato`, `icona`) VALUES -(1, 'Non evaso', 0, 'fa fa-2x fa-file-text-o text-muted'), -(2, 'Evaso', 1, 'fa fa-2x fa-check-circle text-success'), -(3, 'Parzialmente evaso', 1, 'fa fa-2x fa-gear text-warning'); - --- -------------------------------------------------------- - --- --- Struttura della tabella `or_tipiordine` --- - -CREATE TABLE IF NOT EXISTS `or_tipiordine` ( - `id` tinyint(11) NOT NULL AUTO_INCREMENT, - `descrizione` varchar(100) NOT NULL, - `dir` enum('entrata','uscita') NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `or_tipiordine` --- - -INSERT INTO `or_tipiordine` (`id`, `descrizione`, `dir`) VALUES -(1, 'Ordine fornitore', 'uscita'), -(2, 'Ordine cliente', 'entrata'); - --- -------------------------------------------------------- - --- --- Struttura della tabella `zz_files` --- - -CREATE TABLE IF NOT EXISTS `zz_files` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `data` datetime NOT NULL, - `nome` varchar(255) NOT NULL, - `filename` varchar(255) NOT NULL, - `module` varchar(255) NOT NULL, - `externalid` varchar(255) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `zz_gruppi` --- - -CREATE TABLE IF NOT EXISTS `zz_gruppi` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `nome` varchar(50) NOT NULL, - `editable` tinyint(1) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `zz_gruppi` --- - -INSERT INTO `zz_gruppi` (`id`, `nome`, `editable`) VALUES -(1, 'Amministratori', 0), -(2, 'Tecnici', 0), -(3, 'Agenti', 0), -(4, 'Clienti', 0); - --- -------------------------------------------------------- - --- --- Struttura della tabella `zz_gruppi_modules` --- - -CREATE TABLE IF NOT EXISTS `zz_gruppi_modules` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `idgruppo` int(11) NOT NULL, - `idmodule` int(11) NOT NULL, - `clause` varchar(5000) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `zz_gruppi_modules` --- - -INSERT INTO `zz_gruppi_modules` (`id`, `idgruppo`, `idmodule`, `clause`) VALUES -(1, 2, 3, ' AND in_interventi.idintervento IN (SELECT idintervento FROM in_interventi_tecnici WHERE idintervento=in_interventi.idintervento AND idtecnico=|idtecnico|)'), -(2, 2, 2, ' AND an_anagrafiche.idanagrafica IN (SELECT idanagrafica FROM in_interventi_tecnici INNER JOIN in_interventi ON in_interventi_tecnici.idintervento=in_interventi.idintervento WHERE in_interventi.idanagrafica=an_anagrafiche.idanagrafica AND idtecnico=|idtecnico|)'), -(3, 3, 2, ' AND an_anagrafiche.idagente=|idagente|'), -(4, 4, 2, ' AND an_anagrafiche.idanagrafica=|idanagrafica|'), -(5, 4, 3, ' AND in_interventi.idanagrafica=|idanagrafica|'), -(6, 4, 14, ' AND co_documenti.idanagrafica=|idanagrafica|'); - --- -------------------------------------------------------- - --- --- Struttura della tabella `zz_impostazioni` --- - -CREATE TABLE IF NOT EXISTS `zz_impostazioni` ( - `idimpostazione` smallint(6) NOT NULL AUTO_INCREMENT, - `nome` varchar(255) NOT NULL, - `valore` varchar(50) NOT NULL, - `tipo` varchar(1000) NOT NULL, - `editable` tinyint(1) NOT NULL, - `sezione` varchar(100) NOT NULL, - PRIMARY KEY (`idimpostazione`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `zz_impostazioni` --- - -INSERT INTO `zz_impostazioni` (`idimpostazione`, `nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES -(1, 'Righe per pagina', '20', 'integer', 1, 'Generali'), -(2, 'Azienda predefinita', '0', 'query=SELECT an_anagrafiche.idanagrafica, ragione_sociale FROM an_anagrafiche INNER JOIN an_tipianagrafiche_anagrafiche ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE idtipoanagrafica=(SELECT idtipoanagrafica FROM an_tipianagrafiche WHERE descrizione=''Azienda'') AND deleted=0', 1, 'Generali'), -(3, 'max_idintervento', '0', 'string', 0, 'Generali'), -(5, 'Formato report', 'pdf', 'list[html,pdf]', 1, 'Generali'), -(6, 'Iva predefinita', '91', 'query=SELECT id, descrizione FROM `co_iva` ORDER BY descrizione ASC', 1, 'Fatturazione'), -(7, 'Tipo di pagamento predefinito', '20', 'query=SELECT id, descrizione FROM `co_pagamenti` ORDER BY descrizione ASC', 1, 'Fatturazione'), -(8, 'Percentuale ritenuta d''acconto', '0', 'query=SELECT id, descrizione FROM `co_ritenutaacconto` ORDER BY descrizione ASC', 1, 'Fatturazione'), -(9, 'Percentuale rivalsa INPS', '0', 'query=SELECT id, descrizione FROM `co_rivalsainps` ORDER BY descrizione ASC', 1, 'Fatturazione'), -(10, 'Importo marca da bollo', '0.00', 'string', 1, 'Fatturazione'), -(11, 'Soglia minima per l''applicazione della marca da bollo', '77.47', 'string', 1, 'Fatturazione'), -(12, 'Conto aziendale predefinito', '', 'query=SELECT id,descrizione FROM co_pianodeiconti3 WHERE idpianodeiconti2=(SELECT id FROM co_pianodeiconti2 WHERE descrizione=''Cassa e banche'')', 1, 'Fatturazione'), -(13, 'Indirizzo per le email in uscita', '', 'string', 1, 'Email'), -(14, 'Server SMTP', 'localhost', 'string', 1, 'Email'), -(15, 'Username SMTP', '', 'string', 1, 'Email'), -(16, 'Password SMTP', '', 'string', 1, 'Email'), -(17, 'Visualizza i costi sulle stampe degli interventi', '1', 'boolean', 1, 'Interventi'), -(19, 'Stampa i prezzi sui ddt', '1', 'boolean', 1, 'Ddt'), -(20, 'Stampa i prezzi sugli ordini', '1', 'boolean', 1, 'Ordini'), -(21, 'Movimenta il magazzino durante l''inserimento o eliminazione dei lotti/serial number', '1', 'boolean', 1, 'Magazzino'), -(22, 'Formato numero secondario ddt', '##', 'string', 1, 'Ddt'), -(23, 'Formato numero secondario fattura', '##', 'string', 1, 'Fatturazione'), -(24, 'Formato numero secondario ordine', '##', 'string', 1, 'Ordini'), -(25, 'Formato codice intervento', '#', 'string', 1, 'Interventi'), -(26, 'Formato codice preventivi', '#', 'string', 1, 'Preventivi'), -(27, 'Stampa i prezzi sui preventivi', '1', 'boolean', 1, 'Preventivi'), -(28, 'Mostra i prezzi al tecnico', '1', 'boolean', 1, 'Interventi'), -(29, 'Formato codice anagrafica', '########', 'string', 1, 'Anagrafiche'), -(30, 'Numero di mesi prima da cui iniziare a visualizzare gli interventi', '12', 'integer', 1, 'Interventi'), -(31, 'Formato codice contratti', '#', 'string', 1, 'Contratti'), -(32, 'Stampa i prezzi sui contratti', '1', 'boolean', 1, 'Contratti'), -(33, 'osmcloud_username', '', 'string', 0, 'CLOUD'), -(34, 'osmcloud_password', '', 'string', 0, 'CLOUD'), -(35, 'osm_installed', '1', 'string', 0, 'INSTALL'), -(36, 'Conto predefinito fatture di vendita', '', 'query=SELECT id, CONCAT_WS('' - '', numero, descrizione) AS descrizione FROM co_pianodeiconti3 WHERE dir=''entrata''', 1, 'Fatturazione'), -(37, 'Conto predefinito fatture di acquisto', '', 'query=SELECT id, CONCAT_WS('' - '', numero, descrizione) AS descrizione FROM co_pianodeiconti3 WHERE dir=''uscita''', 1, 'Fatturazione'), -(38, 'Porta SMTP', '25', 'string', 1, 'Email'), -(39, 'Destinatario', 'info@openstamanager.com', 'string', 1, 'Email'), -(40, 'Numero di backup da mantenere', '7', 'integer', 1, 'Generali'), -(41, 'Backup automatico', '0', 'boolean', 1, 'Generali'), -(42, 'Usa tabelle avanzate', '1', 'boolean', 1, 'Generali'), -(43, 'Utilizzare i tooltip sul calendario', '0', 'boolean', 1, 'Generali'), -(44, 'Visualizzare la domenica sul calendario', '1', 'boolean', 1, 'Generali'), -(45, 'Nascondere la barra sinistra di default', '0', 'boolean', 1, 'Generali'), -(46, 'Abilitare orario lavorativo', '0', 'boolean', 1, 'Generali'), -(47, 'Cifre decimali', '2', 'list[1,2,3,4]', 1, 'Generali'), -(48, 'CSS Personalizzato', '', 'textarea', 1, 'Generali'), -(49, 'Attiva aggiornamenti', '1', 'boolean', '0', 'Generali'); --- -------------------------------------------------------- - --- --- Struttura della tabella `zz_modules` --- - -CREATE TABLE IF NOT EXISTS `zz_modules` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `name2` varchar(255) NOT NULL, - `module_dir` varchar(50) NOT NULL, - `options` text NOT NULL, - `options2` text NOT NULL, - `icon` varchar(255) NOT NULL, - `version` varchar(15) NOT NULL, - `compatibility` varchar(1000) NOT NULL, - `order` int(11) NOT NULL, - `level` tinyint(4) NOT NULL, - `parent` int(11) NOT NULL, - `default` tinyint(1) NOT NULL, - `enabled` tinyint(1) NOT NULL, - `type` varchar(20) NOT NULL, - `new` tinyint(1) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `zz_modules` --- - -INSERT INTO `zz_modules` (`id`, `name`, `name2`, `module_dir`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `level`, `parent`, `default`, `enabled`, `type`, `new`) VALUES -(1, 'Dashboard', '', 'dashboard', '{ "main_query": [ { "type": "custom" } ]}', '', 'fa fa-dashboard', '2.0', '2.0', 0, 0, 0, 1, 1, 'menu', 0), -(2, 'Anagrafiche', '', 'anagrafiche', '{ "main_query": [ { "type": "table", "fields": "Ragione sociale, Tipologia, Città, Telefono, color_Rel.", "query": "SELECT `idanagrafica` AS `id`, ragione_sociale AS `Ragione sociale`, (SELECT GROUP_CONCAT(descrizione SEPARATOR '', '') FROM an_tipianagrafiche INNER JOIN an_tipianagrafiche_anagrafiche ON an_tipianagrafiche.idtipoanagrafica=an_tipianagrafiche_anagrafiche.idtipoanagrafica GROUP BY idanagrafica HAVING idanagrafica=an_anagrafiche.idanagrafica) AS `Tipologia`, citta AS `Città`, telefono AS `Telefono`, an_relazioni.colore AS `color_Rel.`, an_relazioni.descrizione AS `color_title_Rel.` FROM an_anagrafiche LEFT OUTER JOIN an_relazioni ON an_anagrafiche.idrelazione=an_relazioni.id WHERE 1=1 AND deleted=0 ORDER BY `ragione_sociale`"} ]}', '', 'fa fa-users', '2.0', '2.0', 1, 0, 0, 1, 1, 'menu', 0), -(3, 'Interventi', 'Attività', 'interventi', '{ "main_query": [ { "type": "table", "fields": "ID intervento, Ragione sociale, Data inizio, Data fine, _print_", "query": "SELECT `in_interventi`.`idanagrafica`, `in_interventi`.`idintervento` AS `id`, `in_interventi`.`idintervento` AS `ID intervento`, `ragione_sociale` AS `Ragione sociale`, MIN( DATE_FORMAT( `orario_inizio`, ''%d/%m/%Y'' ) ) AS `Data inizio`, MAX( DATE_FORMAT( `orario_fine`, ''%d/%m/%Y'' ) ) AS `Data fine`, `data_richiesta`, (SELECT `colore` FROM `in_statiintervento` WHERE `idstatointervento`=`in_interventi`.`idstatointervento`) AS `_bg_`, ''pdfgen.php?ptype=interventi&idintervento=$id$&mode=single'' AS `_print_`, `orario_inizio`, `orario_fine` FROM (`in_interventi` INNER JOIN `an_anagrafiche` ON `in_interventi`.`idanagrafica`=`an_anagrafiche`.`idanagrafica`) LEFT OUTER JOIN `in_interventi_tecnici` ON `in_interventi_tecnici`.`idintervento`=`in_interventi`.`idintervento` GROUP BY `in_interventi`.`idintervento` HAVING 1=1 AND ( ( DATE_FORMAT( `orario_inizio`, ''%Y-%m-%d'' ) >= ''|period_start|'' AND DATE_FORMAT( `orario_fine`, ''%Y-%m-%d'' ) <= ''|period_end|'' ) OR ( DATE_FORMAT( `data_richiesta`, ''%Y-%m-%d'' ) >= ''|period_start|'' AND DATE_FORMAT( `data_richiesta`, ''%Y-%m-%d'' ) <= ''|period_end|'' ) ) ORDER BY IFNULL(`orario_fine`, `data_richiesta`) DESC"} ]}', '', 'fa fa-wrench', '2.0', '2.0', 2, 0, 0, 1, 1, 'menu', 0), -(6, 'Aggiornamenti', '', 'aggiornamenti', '{ "main_query": [ { "type": "custom" } ]}', '', 'fa fa-download', '2.0', '2.0', 4, 0, 0, 1, 1, 'menu', 0), -(7, 'Backup', '', 'backup', '{ "main_query": [ { "type": "custom" } ]}', '', 'fa fa-archive', '2.0', '2.0', 5, 0, 0, 1, 1, 'menu', 0), -(8, 'Tipi di anagrafiche', '', 'tipi_anagrafiche', '{ "main_query": [ { "type": "table", "fields": "Descrizione", "query": "SELECT `idtipoanagrafica` AS `id`, `descrizione` AS `Descrizione` FROM `an_tipianagrafiche` WHERE 1=1"} ]}', '', 'fa fa-external-link', '2.0', '2.0', 0, 1, 2, 1, 0, 'menu', 0), -(9, 'Tipi di intervento', 'Tipi di attività', 'tipi_intervento', '{ "main_query": [ { "type": "table", "fields": "Codice, Descrizione, Costo orario, Costo al km, Diritto di chiamata, Costo orario tecnico, Costo al km tecnico, Diritto di chiamata tecnico", "query": "SELECT `idtipointervento` AS `id`, `idtipointervento` AS `Codice`, `descrizione` AS `Descrizione`, REPLACE( FORMAT(`costo_orario`,2), ''.'', '','' ) AS `Costo orario`, REPLACE( FORMAT(`costo_km`,2), ''.'', '','' ) AS `Costo al km`, REPLACE( FORMAT(`costo_diritto_chiamata`,2), ''.'', '','' ) AS `Diritto di chiamata`, REPLACE( FORMAT(`costo_orario_tecnico`,2), ''.'', '','' ) AS `Costo orario tecnico`, REPLACE( FORMAT(`costo_km_tecnico`,2), ''.'', '','' ) AS `Costo al km tecnico`, REPLACE( FORMAT(`costo_diritto_chiamata_tecnico`,2), ''.'', '','' ) AS `Diritto di chiamata tecnico` FROM `in_tipiintervento` WHERE 1=1"} ]}', '', 'fa fa-external-link', '2.0', '2.0', 0, 1, 3, 1, 1, 'menu', 0), -(10, 'Stati di intervento', 'Stati di attività', 'stati_intervento', '{ "main_query": [ { "type": "table", "fields": "Codice, Descrizione, color_Colore", "query": "SELECT `idstatointervento` AS `Codice`, `idstatointervento` AS `id`, `descrizione` AS `Descrizione`, `colore` AS `color_Colore` FROM `in_statiintervento` WHERE 1=1"} ]}', '', 'fa fa-external-link', '2.0', '2.0', 1, 1, 3, 1, 1, 'menu', 0), -(12, 'Contabilità', '', 'contabilita', '', '', 'fa fa-eur', '2.0', '2.0', 3, 0, 0, 1, 1, 'menu', 0), -(13, 'Preventivi', '', 'preventivi', '{ "main_query": [ { "type": "table", "fields": "Numero, Nome, Cliente, icon_Stato", "query": "SELECT `id`, `numero` AS `Numero`, `nome` AS `Nome`, (SELECT `ragione_sociale` FROM `an_anagrafiche` WHERE `idanagrafica`=`co_preventivi`.`idanagrafica`) AS `Cliente`, (SELECT `icona` FROM `co_statipreventivi` WHERE `id`=`idstato`) AS `icon_Stato`, (SELECT `descrizione` FROM `co_statipreventivi` WHERE `id`=`idstato`) AS `icon_title_Stato` FROM `co_preventivi` WHERE 1=1 AND (''|period_start|'' >= `data_bozza` AND ''|period_start|'' <= `data_conclusione`) OR (''|period_end|'' >= `data_bozza` AND ''|period_end|'' <= `data_conclusione`) OR (`data_bozza` >= ''|period_start|'' AND `data_bozza` <= ''|period_end|'') OR (`data_conclusione` >= ''|period_start|'' AND `data_conclusione` <= ''|period_end|'') OR (`data_bozza` >= ''|period_start|'' AND `data_conclusione` = ''0000-00-00'') ORDER BY `id` DESC"} ]}', '', 'fa fa-external-link', '2.0', '2.0', 0, 1, 12, 1, 1, 'menu', 0), -(14, 'Fatture di vendita', '', 'fatture', '{ "main_query": [ { "type": "table", "fields": "Numero, Data, Cliente, Totale, icon_Stato", "query": "SELECT `co_documenti`.`id`, IF(`numero_esterno`='''', `numero`, `numero_esterno`) AS `Numero`, DATE_FORMAT( `data`, ''%d/%m/%Y'' ) AS `Data`, (SELECT `ragione_sociale` FROM `an_anagrafiche` WHERE `idanagrafica`=`co_documenti`.`idanagrafica`) AS `Cliente`, REPLACE( REPLACE( REPLACE( FORMAT(((SELECT SUM(subtotale-sconto+iva) FROM co_righe_documenti WHERE iddocumento=co_documenti.id)+iva_rivalsainps+rivalsainps+bollo-ritenutaacconto), 2), '','', ''#''), ''.'', '',''), ''#'', ''.'') AS Totale, (SELECT `icona` FROM `co_statidocumento` WHERE `id`=`idstatodocumento`) AS `icon_Stato`, (SELECT `descrizione` FROM `co_statidocumento` WHERE `id`=`idstatodocumento`) AS `icon_title_Stato` FROM `co_documenti` INNER JOIN `co_tipidocumento` ON `co_documenti`.`idtipodocumento`=`co_tipidocumento`.`id` WHERE `dir`=''entrata'' AND `data` >= ''|period_start|'' AND `data` <= ''|period_end|'' ORDER BY DATE_FORMAT( `data`, ''%Y%m%d'' ) DESC"} ]}', '', 'fa fa-external-link', '2.0', '2.0', 3, 1, 12, 1, 1, 'menu', 0), -(15, 'Fatture di acquisto', '', 'fatture', '{ "main_query": [ { "type": "table", "fields": "Numero, Data, Cliente, Totale, icon_Stato", "query": "SELECT `co_documenti`.`id`, IF(`numero_esterno`='''', `numero`, `numero_esterno`) AS `Numero`, DATE_FORMAT( `data`, ''%d/%m/%Y'' ) AS `Data`, (SELECT `ragione_sociale` FROM `an_anagrafiche` WHERE `idanagrafica`=`co_documenti`.`idanagrafica`) AS `Cliente`, REPLACE( REPLACE( REPLACE( FORMAT(((SELECT SUM(subtotale-sconto+iva) FROM co_righe_documenti WHERE iddocumento=co_documenti.id)+iva_rivalsainps+rivalsainps+bollo-ritenutaacconto), 2), '','', ''#''), ''.'', '',''), ''#'', ''.'') AS Totale, (SELECT `icona` FROM `co_statidocumento` WHERE `id`=`idstatodocumento`) AS `icon_Stato`, (SELECT `descrizione` FROM `co_statidocumento` WHERE `id`=`idstatodocumento`) AS `icon_title_Stato` FROM `co_documenti` INNER JOIN `co_tipidocumento` ON `co_documenti`.`idtipodocumento`=`co_tipidocumento`.`id` WHERE `dir`=''uscita'' AND `data` >= ''|period_start|'' AND `data` <= ''|period_end|'' ORDER BY DATE_FORMAT( `data`, ''%Y%m%d'' ) DESC"} ]}', '', 'fa fa-external-link', '2.0', '2.0', 4, 1, 12, 1, 1, 'menu', 0), -(16, 'Prima nota', '', 'primanota', '{ "main_query": [ { "type": "table", "fields": "Data, Causale, Controparte, Conto dare, Conto avere, Dare, Avere", "query": "SELECT `co_movimenti`.`id` AS `id`, DATE_FORMAT(`data`, ''%d/%m/%Y'') AS `Data`, `co_movimenti`.`descrizione` AS `Causale`, (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=(SELECT idanagrafica FROM co_documenti WHERE id=iddocumento)) AS `Controparte`, GROUP_CONCAT(CASE WHEN totale>0 THEN co_pianodeiconti3.descrizione ELSE NULL END) AS `Conto dare`, GROUP_CONCAT(CASE WHEN totale<0 THEN co_pianodeiconti3.descrizione ELSE NULL END) AS `Conto avere`, FORMAT( SUM(CASE WHEN totale>0 THEN ABS(totale) ELSE 0 END), 2, ''de_DE'' ) AS Dare, FORMAT( SUM(CASE WHEN totale<0 THEN ABS(totale) ELSE 0 END), 2, ''de_DE'' ) AS Avere FROM co_movimenti INNER JOIN co_pianodeiconti3 ON co_movimenti.idconto=co_pianodeiconti3.id GROUP BY `idmastrino`, `primanota`, `co_movimenti`.`data` HAVING 1=1 AND primanota=1 AND `co_movimenti`.`data`>=''|period_start|'' AND `co_movimenti`.`data`<=''|period_end|'' ORDER BY `co_movimenti`.`data` DESC"} ]}', '', 'fa fa-external-link', '2.0', '2.0', 5, 1, 12, 1, 1, 'menu', 0), -(17, 'Partitario', '', 'partitario', '{ "main_query": [ { "type": "custom" } ]}', '', 'fa fa-external-link', '2.0', '2.0', 6, 1, 12, 1, 1, 'menu', 0), -(18, 'Scadenzario', '', 'scadenziario', '{ "main_query": [ { "type": "table", "fields": "Documento, Cliente, Tipo di pagamento, Data emissione, Data scadenza, Importo, Pagato", "query": "SELECT co_scadenziario.id AS id, ragione_sociale AS `Cliente`, co_pagamenti.descrizione AS `Tipo di pagamento`, CONCAT( co_tipidocumento.descrizione, CONCAT( '' numero '', IF(numero_esterno<>'''', numero_esterno, numero) ) ) AS `Documento`, DATE_FORMAT(data_emissione, ''%d/%m/%Y'') AS `Data emissione`, DATE_FORMAT(scadenza, ''%d/%m/%Y'') AS `Data scadenza`, REPLACE(da_pagare, ''.'', '','') AS `Importo`, REPLACE(pagato, ''.'', '','') AS `Pagato`, IF(scadenza= ''|period_start|'' AND `data` <= ''|period_end|'' ORDER BY `id` DESC"} ]}', '', 'fa fa-external-link', '2.0', '2.0', 1, 1, 12, 1, 1, 'menu', 0), -(25, 'Ordini fornitore', '', 'ordini', '{ "main_query": [ { "type": "table", "fields": "Numero, Data, Ragione sociale, icon_Stato", "query": "SELECT `or_ordini`.`id`, IF(`numero_esterno`='''', `numero`, `numero_esterno`) AS `Numero`, DATE_FORMAT( `data`, ''%d/%m/%Y'' ) AS `Data`, (SELECT `ragione_sociale` FROM `an_anagrafiche` WHERE `idanagrafica`=`or_ordini`.`idanagrafica`) AS `Ragione sociale`, (SELECT `icona` FROM `or_statiordine` WHERE `id`=`idstatoordine`) AS `icon_Stato`, (SELECT `descrizione` FROM `or_statiordine` WHERE `id`=`idstatoordine`) AS `icon_title_Stato` FROM `or_ordini` INNER JOIN `or_tipiordine` ON `or_ordini`.`idtipoordine`=`or_tipiordine`.`id` WHERE 1=1 AND `dir`=''uscita'' AND `data` >= ''|period_start|'' AND `data` <= ''|period_end|'' ORDER BY `id` DESC"} ]}', '', 'fa fa-external-link', '2.0', '2.0', 2, 1, 12, 1, 1, 'menu', 0), -(26, 'Ddt di vendita', '', 'ddt', '{ "main_query": [ { "type": "table", "fields": "Numero, Data, Cliente, icon_Stato", "query": "SELECT `dt_ddt`.`id`, IF(`numero_esterno`='''', `numero`, `numero_esterno`) AS `Numero`, DATE_FORMAT( `data`, ''%d/%m/%Y'' ) AS `Data`, (SELECT `ragione_sociale` FROM `an_anagrafiche` WHERE `idanagrafica`=`dt_ddt`.`idanagrafica`) AS `Cliente`, (SELECT `icona` FROM `dt_statiddt` WHERE `id`=`idstatoddt`) AS `icon_Stato`, (SELECT `descrizione` FROM `dt_statiddt` WHERE `id`=`idstatoddt`) AS `icon_title_Stato` FROM `dt_ddt` INNER JOIN `dt_tipiddt` ON `dt_ddt`.`idtipoddt`=`dt_tipiddt`.`id` WHERE 1=1 AND `dir`=''entrata'' AND `data` >= ''|period_start|'' AND `data` <= ''|period_end|'' ORDER BY DATE_FORMAT( `data`, ''%Y%m%d'' ) DESC"} ]}', '', 'fa fa-external-link', '2.0', '2.0', 3, 1, 20, 1, 1, 'menu', 0), -(27, 'Ddt di acquisto', '', 'ddt', '{ "main_query": [ { "type": "table", "fields": "Numero, Data, Cliente, icon_Stato", "query": "SELECT `dt_ddt`.`id`, IF(`numero_esterno`='''', `numero`, `numero_esterno`) AS `Numero`, DATE_FORMAT( `data`, ''%d/%m/%Y'' ) AS `Data`, (SELECT `ragione_sociale` FROM `an_anagrafiche` WHERE `idanagrafica`=`dt_ddt`.`idanagrafica`) AS `Cliente`, (SELECT `icona` FROM `dt_statiddt` WHERE `id`=`idstatoddt`) AS `icon_Stato`, (SELECT `descrizione` FROM `dt_statiddt` WHERE `id`=`idstatoddt`) AS `icon_title_Stato` FROM `dt_ddt` INNER JOIN `dt_tipiddt` ON `dt_ddt`.`idtipoddt`=`dt_tipiddt`.`id` WHERE 1=1 AND `dir`=''uscita'' AND `data` >= ''|period_start|'' AND `data` <= ''|period_end|'' ORDER BY DATE_FORMAT( `data`, ''%Y%m%d'' ) DESC"} ]}', '', 'fa fa-external-link', '2.0', '2.0', 4, 1, 20, 1, 1, 'menu', 0), -(28, 'Zone', '', 'zone', '{ "main_query": [ { "type": "table", "fields": "Nome, Descrizione", "query": "SELECT `id`, `nome` AS `Nome`, `descrizione` AS `Descrizione` FROM `an_zone` WHERE 1=1 ORDER BY `id`"} ]}', '', 'fa fa-external-link', '2.0', '2.0', 2, 1, 2, 1, 1, 'menu', 0), -(29, 'Tecnici e tariffe', '', 'tecnici_tariffe', '{ "main_query": [ { "type": "table", "fields": "Tipo intervento, Tecnico, Costo orario, Costo al km, Diritto di chiamata, Costo orario tecnico, Costo al km tecnico, Diritto di chiamata tecnico", "query": "SELECT `id`, (SELECT descrizione FROM in_tipiintervento WHERE idtipointervento=in_tariffe.idtipointervento) AS `Tipo intervento`, (SELECT `ragione_sociale` FROM `an_anagrafiche` WHERE `idanagrafica`=`idtecnico`) AS `Tecnico`, REPLACE( FORMAT(`costo_ore`,2), ''.'', '','' ) AS `Costo orario`, REPLACE( FORMAT(`costo_km`,2), ''.'', '','' ) AS `Costo al km`, REPLACE( FORMAT(`costo_dirittochiamata`,2), ''.'', '','' ) AS `Diritto di chiamata`, REPLACE( FORMAT(`costo_ore_tecnico`,2), ''.'', '','' ) AS `Costo orario tecnico`, REPLACE( FORMAT(`costo_km_tecnico`,2), ''.'', '','' ) AS `Costo al km tecnico`, REPLACE( FORMAT(`costo_dirittochiamata_tecnico`,2), ''.'', '','' ) AS `Diritto di chiamata tecnico` FROM `in_tariffe` UNION SELECT CONCAT(`an_anagrafiche`.`idanagrafica`,''|'',`in_tipiintervento`.`idtipointervento`) AS `id`, `in_tipiintervento`.`descrizione` AS `Tipo intervento`, `ragione_sociale` AS `Tecnico`, ''0,00'' AS `Costo orario`, ''0,00'' AS `Costo al km`, ''0,00'' AS `Diritto di chiamata`, ''0,00'' AS `Costo orario tecnico`, ''0,00'' AS `Costo al km tecnico`, ''0,00'' AS `Diritto di chiamata tecnico` FROM ((`an_anagrafiche` INNER JOIN (`an_tipianagrafiche_anagrafiche` INNER JOIN `an_tipianagrafiche` ON `an_tipianagrafiche_anagrafiche`.`idtipoanagrafica`=`an_tipianagrafiche`.`idtipoanagrafica`) ON `an_anagrafiche`.`idanagrafica`=`an_tipianagrafiche_anagrafiche`.`idanagrafica` ) LEFT OUTER JOIN `in_tipiintervento` ON 1=1) WHERE 1=1 AND `an_tipianagrafiche`.`descrizione`=''Tecnico'' AND CONCAT_WS( ''-'', `an_anagrafiche`.`idanagrafica`, `in_tipiintervento`.`idtipointervento`) NOT IN( SELECT CONCAT_WS( ''-'', `in_tariffe`.`idtecnico`, `in_tariffe`.`idtipointervento` ) FROM `in_tariffe` WHERE `idtecnico`=`an_anagrafiche`.`idanagrafica`) ORDER BY `Tipo intervento`, `Tecnico`"} ]}', '', 'fa fa-external-link', '2.0', '2.0', 3, 1, 3, 1, 1, 'menu', 0), -(30, 'MyImpianti', '', 'my_impianti', '{ "main_query": [ { "type": "table", "fields": "Matricola, Nome, Cliente, Data, Tecnico", "query": "SELECT `matricola` AS `id`, `matricola` AS `Matricola`, `nome` AS `Nome`, DATE_FORMAT( `data`, ''%d/%m/%Y'' ) AS `Data`, (SELECT `ragione_sociale` FROM `an_anagrafiche` WHERE `idanagrafica`=`my_impianti`.`idanagrafica`) AS `Cliente`, (SELECT `ragione_sociale` FROM `an_anagrafiche` WHERE `idanagrafica`=`my_impianti`.`idtecnico`) AS `Tecnico` FROM `my_impianti` WHERE 1=1 ORDER BY `matricola`"} ]}', '', 'fa fa-puzzle-piece', '0.1', '2.0', 8, 0, 0, 0, 1, 'menu', 0), -(31, 'Contratti', '', 'contratti', '{ "main_query": [ { "type": "table", "fields": "Numero, Nome, Cliente, icon_Stato", "query": "SELECT `id`, `numero` AS `Numero`, `nome` AS `Nome`, (SELECT `ragione_sociale` FROM `an_anagrafiche` WHERE `idanagrafica`=`co_contratti`.`idanagrafica`) AS `Cliente`, (SELECT `icona` FROM `co_staticontratti` WHERE `id`=`idstato`) AS `icon_Stato`, (SELECT `descrizione` FROM `co_staticontratti` WHERE `id`=`idstato`) AS `icon_title_Stato` FROM `co_contratti` WHERE 1=1 AND (''|period_start|'' >= `data_bozza` AND ''|period_start|'' <= `data_conclusione`) OR (''|period_end|'' >= `data_bozza` AND ''|period_end|'' <= `data_conclusione`) OR (`data_bozza` >= ''|period_start|'' AND `data_bozza` <= ''|period_end|'') OR (`data_conclusione` >= ''|period_start|'' AND `data_conclusione` <= ''|period_end|'') OR (`data_bozza` >= ''|period_start|'' AND `data_conclusione` = ''0000-00-00'') ORDER BY `id` DESC"} ]}', '', 'fa fa-external-link', '2.0', '2.0', 0, 1, 12, 1, 1, 'menu', 0), -(32, 'Voci di servizio', '', 'voci_servizio', '{ "main_query": [ { "type": "table", "fields": "Categoria, Descrizione", "query": "SELECT `id`, `descrizione` AS `Descrizione`, `categoria` AS `Categoria` FROM `in_vociservizio` WHERE 1=1 ORDER BY `categoria`, `descrizione`"} ]}', '', 'fa fa-external-link', '2.0', '2.0', 3, 1, 3, 1, 1, 'menu', 0); - --- -------------------------------------------------------- - --- --- Struttura della tabella `zz_modules_plugins` --- - -CREATE TABLE IF NOT EXISTS `zz_modules_plugins` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `idmodule_from` int(11) NOT NULL, - `idmodule_to` int(11) NOT NULL, - `position` varchar(50) NOT NULL, - `script` varchar(255) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `zz_modules_plugins` --- - -INSERT INTO `zz_modules_plugins` (`id`, `name`, `idmodule_from`, `idmodule_to`, `position`, `script`) VALUES -(1, 'Impianti del cliente', 30, 2, 'tab', 'my_impianti.anagrafiche.php'), -(2, 'Impianti', 30, 3, 'tab', 'my_impianti.interventi.php'), -(3, 'Referenti', 2, 2, 'tab', 'ajax_referente.php'), -(4, 'Sedi', 2, 2, 'tab', 'ajax_sedi.php'), -(7, 'Statistiche', 2, 2, 'tab', 'statistiche.php'), -(8, 'Interventi svolti', 3, 30, 'tab', 'my_impianti.interventi.php'), -(9, 'Componenti', 30, 30, 'tab', 'my_impianti.componenti.php'), -(10, 'Movimenti', 21, 21, 'tab', 'articoli.movimenti.php'), -(11, 'Lotti', 21, 21, 'tab', 'articoli.lotti.php'), -(12, 'Consuntivo', 13, 13, 'tab', 'preventivi.consuntivo.php'), -(13, 'Consuntivo', 31, 31, 'tab', 'contratti.consuntivo.php'), -(14, 'Pianificazione interventi', 31, 31, 'tab', 'contratti.pianificazioneinterventi.php'), -(15, 'Pianificazione ordini di servizio', 31, 31, 'tab', 'contratti.ordiniservizio.php'), -(16, 'Pianificazione fatturazione', 31, 31, 'tab', 'contratti.fatturaordiniservizio.php'); - --- -------------------------------------------------------- - --- --- Struttura della tabella `zz_permessi` --- - -CREATE TABLE IF NOT EXISTS `zz_permessi` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `idgruppo` int(11) NOT NULL, - `idmodule` int(11) NOT NULL, - `permessi` enum('-','r','rw') NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `zz_utenti` --- - -CREATE TABLE IF NOT EXISTS `zz_utenti` ( - `idutente` smallint(6) NOT NULL AUTO_INCREMENT, - `username` varchar(255) NOT NULL, - `password` varchar(255) NOT NULL, - `email` varchar(50) NOT NULL, - `idanagrafica` int(11) NOT NULL, - `idtipoanagrafica` int(11) NOT NULL, - `idgruppo` int(11) NOT NULL, - `enabled` tinyint(1) NOT NULL, - PRIMARY KEY (`idutente`) -) ENGINE=InnoDB; - --- -------------------------------------------------------- - --- --- Struttura della tabella `zz_widget_modules` --- - -CREATE TABLE IF NOT EXISTS `zz_widget_modules` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) DEFAULT NULL, - `type` enum('stats','chart','custom','print') DEFAULT NULL, - `id_module` int(11) NOT NULL, - `location` enum('controller_top','controller_right','editor_top','editor_right') DEFAULT NULL, - `class` varchar(50) DEFAULT NULL, - `query` text, - `bgcolor` varchar(7) DEFAULT NULL, - `icon` varchar(255) DEFAULT NULL, - `print_link` varchar(255) DEFAULT NULL, - `more_link` varchar(5000) DEFAULT NULL, - `more_link_type` enum('link','popup','javascript') DEFAULT NULL, - `php_include` varchar(255) DEFAULT NULL, - `text` text, - `enabled` tinyint(1) DEFAULT NULL, - `order` int(11) DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `zz_widget_modules` --- - -INSERT INTO `zz_widget_modules` (`id`, `name`, `type`, `id_module`, `location`, `class`, `query`, `bgcolor`, `icon`, `print_link`, `more_link`, `more_link_type`, `php_include`, `text`, `enabled`, `order`) VALUES -(1, 'Numero di clienti', 'stats', 2, 'controller_top', 'col-md-2', 'SELECT COUNT(an_anagrafiche.idanagrafica) AS dato FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE descrizione="Cliente" AND deleted=0', '#37a02d', 'fa fa-user', '', '$(''#th_Tipologia input'').val( ''Cliente'' ).trigger( ''keyup'' );', 'javascript', '', 'Clienti', 1, 0), -(2, 'Numero di tecnici', 'stats', 2, 'controller_top', 'col-md-2', 'SELECT COUNT(an_anagrafiche.idanagrafica) AS dato FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE descrizione="Tecnico" AND deleted=0', '#ff7e00', 'fa fa-cog', '', '$(''#th_Tipologia input'').val( ''Tecnico'' ).trigger( ''keyup'' );', 'javascript', '', 'Tecnici', 1, 1), -(3, 'Numero di fornitori', 'stats', 2, 'controller_top', 'col-md-2', 'SELECT COUNT(an_anagrafiche.idanagrafica) AS dato FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE descrizione="Fornitore" AND deleted=0', '#a15d2d', 'fa fa-truck', '', '$(''#th_Tipologia input'').val( ''Fornitore'' ).trigger( ''keyup'' );', 'javascript', '', 'Fornitori', 1, 3), -(4, 'Numero di agenti', 'stats', 2, 'controller_top', 'col-md-2', 'SELECT COUNT(an_anagrafiche.idanagrafica) AS dato FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE descrizione="Agente" AND deleted=0', '#2d70a1', 'fa fa-briefcase', '', '$(''#th_Tipologia input'').val( ''Agente'' ).trigger( ''keyup'' );', 'javascript', '', 'Agenti', 1, 3), -(5, 'Interventi da pianificare', 'stats', 1, 'controller_right', 'col-md-3', 'SELECT COUNT(id) AS dato FROM co_righe_contratti WHERE idcontratto IN( SELECT id FROM co_contratti WHERE idstato IN(SELECT id FROM co_staticontratti WHERE descrizione IN("Bozza", "Accettato", "In lavorazione", "In attesa di pagamento")) ) AND idintervento=""', '#ff7e00', 'fa fa-cog', '', './modules/contratti/widgets/contratti.pianificazionedashboard.interventi.php', 'popup', '', 'Interventi da pianificare', 1, 0), -(6, 'Ordini di servizio da impostare', 'stats', 1, 'controller_right', 'col-md-3', 'SELECT COUNT(id) AS dato FROM co_ordiniservizio WHERE idcontratto IN( SELECT id FROM co_contratti WHERE idstato IN(SELECT id FROM co_staticontratti WHERE descrizione IN("Bozza", "Accettato", "In lavorazione", "In attesa di pagamento")) ) AND idintervento=""', '#45a9f1', 'fa fa-gears', '', './modules/contratti/widgets/contratti.pianificazionedashboard.php', 'popup', '', 'Ordini di servizio da impostare', 1, 1), -(7, 'Scadenze', 'stats', 1, 'controller_right', 'col-md-3', 'SELECT COUNT(co_documenti.id) AS dato FROM co_scadenziario INNER JOIN (((co_documenti INNER JOIN an_anagrafiche ON co_documenti.idanagrafica=an_anagrafiche.idanagrafica) INNER JOIN co_pagamenti ON co_documenti.idpagamento=co_pagamenti.id) INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id) ON co_scadenziario.iddocumento=co_documenti.id WHERE ABS(pagato) < ABS(da_pagare) AND idstatodocumento=(SELECT id FROM co_statidocumento WHERE descrizione="Emessa") AND scadenza >= "|period_start|" AND scadenza <= "|period_end|" ORDER BY scadenza ASC', '#c62f2a', 'fa fa-money', '', './controller.php?id_module=18', 'link', '', 'Scadenze', 1, 2), -(8, 'Articoli in esaurimento', 'stats', 1, 'controller_right', 'col-md-3', 'SELECT COUNT(id) AS dato FROM mg_articoli WHERE qta < threshold_qta AND attivo=1', '#a15d2d', 'fa fa-truck', '', './modules/articoli/widgets/articoli.dashboard.php', 'popup', '', 'Articoli in esaurimento', 1, 3), -(9, 'Preventivi in lavorazione', 'stats', 1, 'controller_right', 'col-md-12', 'SELECT COUNT(id) AS dato FROM co_preventivi WHERE idstato=(SELECT id FROM co_statipreventivi WHERE descrizione="In lavorazione")', '#44aae4', 'fa fa-tasks', '', './modules/preventivi/widgets/preventivi.dashboard.php', 'popup', '', 'Preventivi in lavorazione', 1, 4), -(10, 'Contratti in scadenza', 'stats', 1, 'controller_right', 'col-md-12', 'SELECT COUNT(id) AS dato FROM co_contratti WHERE idstato IN(SELECT id FROM co_staticontratti WHERE descrizione="Accettato" OR descrizione="In lavorazione" OR descrizione="In attesa di pagamento") AND rinnovabile=1 AND NOW() > DATE_ADD( data_conclusione, INTERVAL -ABS(giorni_preavviso_rinnovo) DAY)', '#c62f2a', 'fa fa-edit', '', './modules/contratti/widgets/contratti_scadenza.dashboard.php', 'popup', '', 'Contratti in scadenza', 1, 5), -(11, 'Rate contrattuali', 'stats', 1, 'controller_right', 'col-md-12', 'SELECT COUNT(id) AS dato FROM co_ordiniservizio_pianificazionefatture WHERE idcontratto IN( SELECT id FROM co_contratti WHERE idstato IN(SELECT id FROM co_staticontratti WHERE descrizione IN("Bozza", "Accettato", "In lavorazione", "In attesa di pagamento")) ) AND co_ordiniservizio_pianificazionefatture.iddocumento=0', '#4ccc4c', 'fa fa-folder-open', '', './modules/contratti/widgets/contratti.ratecontrattuali.php', 'popup', '', 'Rate contrattuali', 1, 6), -(12, 'Stampa inventario', 'print', 21, 'controller_right', 'col-md-12', '', '#45a9f1', 'fa fa-print', '', 'if( confirm(''Stampare l\\''inventario?'') ){ window.open(''templates/pdfgen.php?ptype=magazzino_inventario&search_codice=''+$(''#th_Codice input'').val()+''&search_descrizione=''+$(''#th_Descrizione input'').val()+''&search_categoria=''+$(''#th_Categoria input'').val()+''&search_subcategoria=''+$(''#th_Subcategoria input'').val()+''&search_tipo=solo prodotti attivi''); }', 'javascript', '', 'Stampa inventario', 1, 1), -(13, 'Fatturato', 'stats', 14, 'controller_top', 'col-md-6', 'SELECT CONCAT_WS( " ", REPLACE( REPLACE( REPLACE( FORMAT( SUM((SELECT SUM(subtotale+iva-sconto) FROM co_righe_documenti WHERE iddocumento=co_documenti.id)+iva_rivalsainps+rivalsainps+bollo-ritenutaacconto), 2), ",", "#"), ".", "," ), "#", "."), "€" ) AS dato FROM co_documenti WHERE idtipodocumento IN(SELECT id FROM co_tipidocumento WHERE dir="entrata") AND data >= "|period_start|" AND data <= "|period_end|"', '#4dc347', 'fa fa-money', '', '', '', '', 'Fatturato', 1, 1), -(14, 'Acquisti', 'stats', 15, 'controller_top', 'col-md-6', 'SELECT CONCAT_WS( " ", REPLACE( REPLACE( REPLACE( FORMAT( SUM((SELECT SUM(subtotale+iva-sconto) FROM co_righe_documenti WHERE iddocumento=co_documenti.id)+iva_rivalsainps+rivalsainps+bollo-ritenutaacconto), 2), ",", "#"), ".", "," ), "#", "."), "€" ) AS dato FROM co_documenti WHERE idtipodocumento IN(SELECT id FROM co_tipidocumento WHERE dir="uscita") AND data >= "|period_start|" AND data <= "|period_end|"', '#c2464c', 'fa fa-money', '', '', '', '', 'Acquisti', 1, 1), -(15, 'Crediti da clienti', 'stats', 14, 'controller_top', 'col-md-6', 'SELECT CONCAT_WS( " ", REPLACE( REPLACE( REPLACE( FORMAT( SUM((SELECT SUM(subtotale+iva-sconto) FROM co_righe_documenti WHERE iddocumento=co_documenti.id)+iva_rivalsainps+rivalsainps+bollo-ritenutaacconto), 2), ",", "#"), ".", "," ), "#", "."), "€" ) AS dato FROM co_documenti WHERE idtipodocumento IN(SELECT id FROM co_tipidocumento WHERE dir="entrata") AND idstatodocumento=(SELECT id FROM co_statidocumento WHERE descrizione="Emessa") AND data >= "|period_start|" AND data <= "|period_end|"', '#f4af1b', 'fa fa-warning', '', '', '', '', 'Crediti da clienti', 1, 2), -(16, 'Debiti verso fornitori', 'stats', 15, 'controller_top', 'col-md-6', 'SELECT CONCAT_WS( " ", REPLACE( REPLACE( REPLACE( FORMAT( SUM((SELECT SUM(subtotale+iva-sconto) FROM co_righe_documenti WHERE iddocumento=co_documenti.id)+iva_rivalsainps+rivalsainps+bollo-ritenutaacconto), 2), ",", "#"), ".", "," ), "#", "."), "€" ) AS dato FROM co_documenti WHERE idtipodocumento IN(SELECT id FROM co_tipidocumento WHERE dir="uscita") AND idstatodocumento=(SELECT id FROM co_statidocumento WHERE descrizione="Emessa") AND data >= "|period_start|" AND data <= "|period_end|"', '#f4af1b', 'fa fa-warning', '', '', '', '', 'Debiti verso fornitori', 1, 2), -(17, 'Numero di vettori', 'stats', 2, 'controller_top', 'col-md-2', 'SELECT COUNT(an_anagrafiche.idanagrafica) AS dato FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE descrizione="Vettore" AND deleted=0', '#00C0EF', 'fa fa-truck', '', '$(''#th_Tipologia input'').val( ''Vettore'' ).trigger( ''keyup'' );', 'javascript', '', 'Vettori', 1, 4), -(18, 'Tutte le anagrafiche', 'stats', 2, 'controller_top', 'col-md-2', 'SELECT COUNT(an_anagrafiche.idanagrafica) AS dato FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE deleted=0', '#CCCCCC', 'fa fa-users', '', '$(''#th_Tipologia input'').val( '''' ).trigger( ''keyup'' );', 'javascript', '', 'Tutti', 1, 5), -(19, 'Stampa riepilogo', 'print', 3, 'controller_right', 'col-md-12', '', '#45a9f1', 'fa fa-print', '', 'if( confirm(''Stampare il riepilogo?'') ){ window.open(''templates/pdfgen.php?ptype=riepilogo_interventi&search_idintervento=''+$(''#th_ID_intervento input'').val()+''&search_ragionesociale=''+$(''#th_Ragione_sociale input'').val()+''&search_datastart=''+$(''#th_Data_inizio input'').val()+''&search_dataend=''+$(''#th_Data_fine input'').val()); }', 'javascript', '', 'Stampa riepilogo', 1, 1); - --- --- Limiti per le tabelle scaricate --- - --- --- Limiti per la tabella `an_tipianagrafiche_anagrafiche` --- -ALTER TABLE `an_tipianagrafiche_anagrafiche` - ADD CONSTRAINT `an_tipianagrafiche_anagrafiche_ibfk_1` FOREIGN KEY (`idtipoanagrafica`) REFERENCES `an_tipianagrafiche` (`idtipoanagrafica`) ON DELETE CASCADE, - ADD CONSTRAINT `an_tipianagrafiche_anagrafiche_ibfk_2` FOREIGN KEY (`idanagrafica`) REFERENCES `an_anagrafiche` (`idanagrafica`) ON DELETE CASCADE; - --- --- Limiti per la tabella `in_interventi` --- -ALTER TABLE `in_interventi` - ADD CONSTRAINT `in_interventi_ibfk_1` FOREIGN KEY (`idanagrafica`) REFERENCES `an_anagrafiche` (`idanagrafica`) ON DELETE CASCADE, - ADD CONSTRAINT `in_interventi_ibfk_2` FOREIGN KEY (`idtipointervento`) REFERENCES `in_tipiintervento` (`idtipointervento`) ON DELETE CASCADE; - --- --- Limiti per la tabella `in_interventi_tecnici` --- -ALTER TABLE `in_interventi_tecnici` - ADD CONSTRAINT `in_interventi_tecnici_ibfk_1` FOREIGN KEY (`idintervento`) REFERENCES `in_interventi` (`idintervento`) ON DELETE CASCADE, - ADD CONSTRAINT `in_interventi_tecnici_ibfk_2` FOREIGN KEY (`idtecnico`) REFERENCES `an_anagrafiche` (`idanagrafica`) ON DELETE CASCADE; diff --git a/update/2_1.php b/update/2_1.php deleted file mode 100755 index 40c23dea9..000000000 --- a/update/2_1.php +++ /dev/null @@ -1,25 +0,0 @@ -fetchArray("SELECT valore FROM zz_impostazioni WHERE nome='Percentuale rivalsa INPS'")[0]['valore']; -$ritenuta = $dbo->fetchArray("SELECT valore FROM zz_impostazioni WHERE nome='Percentuale ritenuta d''acconto'")[0]['valore']; - -$rs = $dbo->fetchArray('SELECT id FROM co_documenti'); - -for ($i = 0; $i < sizeof($rs); ++$i) { - if ($rivalsainps != '') { - $dbo->query('UPDATE co_righe_documenti SET idrivalsainps="'.$rivalsainps.'", rivalsainps=( (subtotale-sconto) /100 * 4 ) WHERE iddocumento="'.$rs[$i]['id'].'"'); - } else { - $dbo->query('UPDATE co_righe_documenti SET idrivalsainps="0", rivalsainps=0 WHERE iddocumento="'.$rs[$i]['id'].'"'); - } - - if ($ritenuta != '') { - $dbo->query('UPDATE co_righe_documenti SET idritenutaacconto="'.$ritenuta.'", ritenutaacconto=( (subtotale+rivalsainps-sconto) /100 * 20 ) WHERE iddocumento="'.$rs[$i]['id'].'"'); - } else { - $dbo->query('UPDATE co_righe_documenti SET idritenutaacconto="0", ritenutaacconto=0 WHERE iddocumento="'.$rs[$i]['id'].'"'); - } -} diff --git a/update/2_1.sql b/update/2_1.sql deleted file mode 100755 index ec96902c6..000000000 --- a/update/2_1.sql +++ /dev/null @@ -1,61 +0,0 @@ --- Cambio tipo di dati decimali da FLOAT a DECIMAL -ALTER TABLE `co_contratti` CHANGE `budget` `budget` DECIMAL(12, 4) NOT NULL, CHANGE `costo_diritto_chiamata` `costo_diritto_chiamata` DECIMAL(12, 4) NOT NULL, CHANGE `ore_lavoro` `ore_lavoro` DECIMAL(12, 4) NOT NULL, CHANGE `costo_orario` `costo_orario` DECIMAL(12, 4) NOT NULL, CHANGE `costo_km` `costo_km` DECIMAL(12, 4) NOT NULL; -ALTER TABLE `co_documenti` CHANGE `rivalsainps` `rivalsainps` DECIMAL(12, 4) NOT NULL, CHANGE `iva_rivalsainps` `iva_rivalsainps` DECIMAL(12, 4) NOT NULL, CHANGE `ritenutaacconto` `ritenutaacconto` DECIMAL(12, 4) NOT NULL, CHANGE `bollo` `bollo` DECIMAL(12, 4) NOT NULL; -ALTER TABLE `co_movimenti` CHANGE `totale` `totale` DECIMAL(12, 4) NULL DEFAULT NULL; -ALTER TABLE `co_preventivi` CHANGE `budget` `budget` DECIMAL(12, 4) NOT NULL, CHANGE `costo_diritto_chiamata` `costo_diritto_chiamata` DECIMAL(12, 4) NOT NULL, CHANGE `ore_lavoro` `ore_lavoro` DECIMAL(12, 4) NOT NULL, CHANGE `costo_orario` `costo_orario` DECIMAL(12, 4) NOT NULL, CHANGE `costo_km` `costo_km` DECIMAL(12, 4) NOT NULL; -ALTER TABLE `co_preventivi_interventi` CHANGE `costo_orario` `costo_orario` DECIMAL(12, 4) NOT NULL, CHANGE `costo_km` `costo_km` DECIMAL(12, 4) NOT NULL; -ALTER TABLE `co_righe2_contratti` CHANGE `subtotale` `subtotale` DECIMAL(12, 4) NOT NULL, CHANGE `qta` `qta` DECIMAL(12, 4) NOT NULL; -ALTER TABLE `co_righe_documenti` CHANGE `iva` `iva` DECIMAL(12, 4) NOT NULL, CHANGE `iva_indetraibile` `iva_indetraibile` DECIMAL(12, 4) NOT NULL, CHANGE `subtotale` `subtotale` DECIMAL(12, 4) NOT NULL, CHANGE `sconto` `sconto` DECIMAL(12, 4) NOT NULL, CHANGE `qta` `qta` DECIMAL(12, 4) NOT NULL; -ALTER TABLE `co_righe_preventivi` CHANGE `iva` `iva` DECIMAL(12, 4) NOT NULL, CHANGE `iva_indetraibile` `iva_indetraibile` DECIMAL(12, 4) NOT NULL, CHANGE `subtotale` `subtotale` DECIMAL(12, 4) NOT NULL, CHANGE `qta` `qta` DECIMAL(12, 4) NOT NULL; -ALTER TABLE `co_scadenziario` CHANGE `da_pagare` `da_pagare` DECIMAL(12, 4) NULL DEFAULT NULL, CHANGE `pagato` `pagato` DECIMAL(12, 4) NULL DEFAULT NULL; -ALTER TABLE `dt_ddt` CHANGE `rivalsainps` `rivalsainps` DECIMAL(12, 4) NOT NULL, CHANGE `iva_rivalsainps` `iva_rivalsainps` DECIMAL(12, 4) NOT NULL, CHANGE `ritenutaacconto` `ritenutaacconto` DECIMAL(12, 4) NOT NULL, CHANGE `bollo` `bollo` DECIMAL(12, 4) NOT NULL; -ALTER TABLE `dt_righe_ddt` CHANGE `iva` `iva` DECIMAL(12, 4) NOT NULL, CHANGE `iva_indetraibile` `iva_indetraibile` DECIMAL(12, 4) NOT NULL, CHANGE `subtotale` `subtotale` DECIMAL(12, 4) NOT NULL, CHANGE `sconto` `sconto` DECIMAL(12, 4) NOT NULL, CHANGE `qta` `qta` DECIMAL(12, 4) NOT NULL, CHANGE `qta_evasa` `qta_evasa` DECIMAL(12, 4) NOT NULL; -ALTER TABLE `in_interventi_tecnici` CHANGE `km` `km` DECIMAL(12, 4) NOT NULL, CHANGE `prezzo_ore_unitario` `prezzo_ore_unitario` DECIMAL(12, 4) NOT NULL, CHANGE `prezzo_km_unitario` `prezzo_km_unitario` DECIMAL(12, 4) NOT NULL, CHANGE `prezzo_ore_consuntivo` `prezzo_ore_consuntivo` DECIMAL(12, 4) NOT NULL, CHANGE `prezzo_km_consuntivo` `prezzo_km_consuntivo` DECIMAL(12, 4) NOT NULL, CHANGE `prezzo_dirittochiamata` `prezzo_dirittochiamata` DECIMAL(12, 4) NOT NULL, CHANGE `prezzo_ore_unitario_tecnico` `prezzo_ore_unitario_tecnico` DECIMAL(12, 4) NOT NULL, CHANGE `prezzo_km_unitario_tecnico` `prezzo_km_unitario_tecnico` DECIMAL(12, 4) NOT NULL, CHANGE `prezzo_ore_consuntivo_tecnico` `prezzo_ore_consuntivo_tecnico` DECIMAL(12, 4) NOT NULL, CHANGE `prezzo_km_consuntivo_tecnico` `prezzo_km_consuntivo_tecnico` DECIMAL(12, 4) NOT NULL, CHANGE `prezzo_dirittochiamata_tecnico` `prezzo_dirittochiamata_tecnico` DECIMAL(12, 4) NOT NULL; -ALTER TABLE `in_tariffe` CHANGE `costo_ore` `costo_ore` DECIMAL(12, 4) NOT NULL, CHANGE `costo_km` `costo_km` DECIMAL(12, 4) NOT NULL, CHANGE `costo_dirittochiamata` `costo_dirittochiamata` DECIMAL(12, 4) NOT NULL, CHANGE `costo_ore_tecnico` `costo_ore_tecnico` DECIMAL(12, 4) NOT NULL, CHANGE `costo_km_tecnico` `costo_km_tecnico` DECIMAL(12, 4) NOT NULL, CHANGE `costo_dirittochiamata_tecnico` `costo_dirittochiamata_tecnico` DECIMAL(12, 4) NOT NULL; -ALTER TABLE `in_tipiintervento` CHANGE `costo_orario` `costo_orario` DECIMAL(12, 4) NOT NULL, CHANGE `costo_km` `costo_km` DECIMAL(12, 4) NOT NULL, CHANGE `costo_diritto_chiamata` `costo_diritto_chiamata` DECIMAL(12, 4) NOT NULL, CHANGE `costo_orario_tecnico` `costo_orario_tecnico` DECIMAL(12, 4) NOT NULL, CHANGE `costo_km_tecnico` `costo_km_tecnico` DECIMAL(12, 4) NOT NULL, CHANGE `costo_diritto_chiamata_tecnico` `costo_diritto_chiamata_tecnico` DECIMAL(12, 4) NOT NULL; -ALTER TABLE `mg_articoli` CHANGE `qta` `qta` DECIMAL(12, 4) NOT NULL, CHANGE `threshold_qta` `threshold_qta` DECIMAL(12, 4) NOT NULL, CHANGE `prezzo_acquisto` `prezzo_acquisto` DECIMAL(12, 4) NOT NULL, CHANGE `prezzo_vendita` `prezzo_vendita` DECIMAL(12, 4) NOT NULL; -ALTER TABLE `mg_articoli_automezzi` CHANGE `qta` `qta` DECIMAL(12, 4) NOT NULL; -ALTER TABLE `mg_articoli_interventi` CHANGE `prezzo_vendita` `prezzo_vendita` DECIMAL(12, 4) NOT NULL, CHANGE `sconto` `sconto` DECIMAL(12, 4) NOT NULL; -ALTER TABLE `mg_movimenti` CHANGE `qta` `qta` DECIMAL(12, 4) NOT NULL; -ALTER TABLE `or_ordini` CHANGE `rivalsainps` `rivalsainps` DECIMAL(12, 4) NOT NULL, CHANGE `iva_rivalsainps` `iva_rivalsainps` DECIMAL(12, 4) NOT NULL, CHANGE `ritenutaacconto` `ritenutaacconto` DECIMAL(12, 4) NOT NULL; -ALTER TABLE `or_righe_ordini` CHANGE `iva` `iva` DECIMAL(12, 4) NOT NULL, CHANGE `iva_indetraibile` `iva_indetraibile` DECIMAL(12, 4) NOT NULL, CHANGE `subtotale` `subtotale` DECIMAL(12, 4) NOT NULL, CHANGE `sconto` `sconto` DECIMAL(12, 4) NOT NULL, CHANGE `qta` `qta` DECIMAL(12, 4) NOT NULL, CHANGE `qta_evasa` `qta_evasa` DECIMAL(12, 4) NOT NULL; -ALTER TABLE `co_iva` CHANGE `percentuale` `percentuale` DECIMAL(5,2) NOT NULL, CHANGE `indetraibile` `indetraibile` DECIMAL(5,2) NOT NULL; -ALTER TABLE `co_ritenutaacconto` CHANGE `percentuale` `percentuale` DECIMAL(5,2) NOT NULL, CHANGE `indetraibile` `indetraibile` DECIMAL(5,2) NOT NULL; -ALTER TABLE `co_rivalsainps` CHANGE `percentuale` `percentuale` DECIMAL(5,2) NOT NULL, CHANGE `indetraibile` `indetraibile` DECIMAL(5,2) NOT NULL; -ALTER TABLE `mg_articoli_interventi` CHANGE `idiva_vendita` `idiva_vendita` INT NOT NULL, CHANGE `qta` `qta` DECIMAL(10,2) NOT NULL; -ALTER TABLE `mg_listini` CHANGE `prc_guadagno` `prc_guadagno` DECIMAL(5,2) NOT NULL; -ALTER TABLE `or_ordini` CHANGE `bollo` `bollo` DECIMAL(10,2) NOT NULL; -ALTER TABLE `an_anagrafiche` CHANGE `km` `km` DECIMAL(10,2) NOT NULL; -ALTER TABLE `an_sedi` CHANGE `km` `km` DECIMAL(10,2) NOT NULL; -ALTER TABLE `co_movimenti` CHANGE `primanota` `primanota` TINYINT NOT NULL; -ALTER TABLE `in_interventi` CHANGE `km` `km` DECIMAL(7,2) NOT NULL, CHANGE `prezzo_ore_unitario` `prezzo_ore_unitario` DECIMAL(10,2) NOT NULL; - --- Aggiunta ritenuta d'acconto e rivalsa inps per ogni riga della fattura -ALTER TABLE `co_righe_documenti` ADD `ritenutaacconto` DECIMAL(12, 4) NOT NULL AFTER `sconto`, ADD `rivalsainps` DECIMAL(12, 4) NOT NULL AFTER `ritenutaacconto`; -ALTER TABLE `co_righe_documenti` ADD `idritenutaacconto` INT NOT NULL AFTER `sconto`; -ALTER TABLE `co_righe_documenti` ADD `idrivalsainps` INT NOT NULL AFTER `ritenutaacconto`; - - --- Aggiornamento modulo scadenzario -UPDATE `zz_modules` SET `module_dir` = 'scadenzario', `options` = '{ "main_query": [ { "type": "table", "fields": "Documento, Cliente, Tipo di pagamento, Data emissione, Data scadenza, Importo, Pagato", "query": "SELECT co_scadenziario.id AS id, ragione_sociale AS `Cliente`, co_pagamenti.descrizione AS `Tipo di pagamento`, CONCAT(co_tipidocumento.descrizione, CONCAT('' numero '', IF(numero_esterno<>'''', numero_esterno, numero))) AS `Documento`, DATE_FORMAT(data_emissione, ''%d/%m/%Y'') AS `Data emissione`, DATE_FORMAT(scadenza, ''%d/%m/%Y'') AS `Data scadenza`, REPLACE(REPLACE(REPLACE(FORMAT(da_pagare, 2), '','', ''#''), ''.'', '',''), ''#'', ''.'') AS `Importo`, REPLACE(REPLACE(REPLACE(FORMAT(pagato, 2), '','', ''#''), ''.'', '',''), ''#'', ''.'') AS `Pagato`, IF(scadenza= ''|period_start|'' AND `data` <= ''|period_end|'' ORDER BY DATE_FORMAT(`data`, ''%Y%m%d'') DESC"} ]}' WHERE `name`='Fatture di acquisto'; -UPDATE `zz_modules` SET `options` = '{ "main_query": [ { "type": "table", "fields": "Numero, Data, Ragione sociale, Totale, icon_Stato", "query": "SELECT `co_documenti`.`id`, IF(`numero_esterno`='''', `numero`, `numero_esterno`) AS `Numero`, DATE_FORMAT(`data`, ''%d/%m/%Y'') AS `Data`, (SELECT `ragione_sociale` FROM `an_anagrafiche` WHERE `idanagrafica`=`co_documenti`.`idanagrafica`) AS `Ragione sociale`, REPLACE(REPLACE(REPLACE(FORMAT((SELECT SUM(`subtotale`-`sconto`+`iva`+`rivalsainps`-`ritenutaacconto`) FROM `co_righe_documenti` GROUP BY `iddocumento` HAVING `iddocumento`=`co_documenti`.`id`) +`bollo` + `iva_rivalsainps`, 2), '','', ''#''), ''.'', '',''), ''#'', ''.'') AS `Totale`, (SELECT `icona` FROM `co_statidocumento` WHERE `id`=`idstatodocumento`) AS `icon_Stato`, (SELECT `descrizione` FROM `co_statidocumento` WHERE `id`=`idstatodocumento`) AS `icon_title_Stato` FROM `co_documenti` INNER JOIN `co_tipidocumento` ON `co_documenti`.`idtipodocumento`=`co_tipidocumento`.`id` WHERE 1=1 AND `dir`=''entrata'' AND `data` >= ''|period_start|'' AND `data` <= ''|period_end|'' ORDER BY DATE_FORMAT(`data`, ''%Y%m%d'') DESC"} ]}' WHERE `name`='Fatture di vendita'; - --- Rinominato "Cliente" con "Anagrafica" -UPDATE `zz_modules` SET `options` = '{ "main_query": [ { "type": "table", "fields": "Documento, Anagrafica, Tipo di pagamento, Data emissione, Data scadenza, Importo, Pagato", "query": "SELECT co_scadenziario.id AS id, ragione_sociale AS `Anagrafica`, co_pagamenti.descrizione AS `Tipo di pagamento`, CONCAT(co_tipidocumento.descrizione, CONCAT('' numero '', IF(numero_esterno<>'''', numero_esterno, numero))) AS `Documento`, DATE_FORMAT(data_emissione, ''%d/%m/%Y'') AS `Data emissione`, DATE_FORMAT(scadenza, ''%d/%m/%Y'') AS `Data scadenza`, REPLACE(REPLACE(REPLACE(FORMAT(da_pagare, 2), '','', ''#''), ''.'', '',''), ''#'', ''.'') AS `Importo`, REPLACE(REPLACE(REPLACE(FORMAT(pagato, 2), '','', ''#''), ''.'', '',''), ''#'', ''.'') AS `Pagato`, IF(scadenzafetchArray('SELECT idanagrafica, ragione_sociale, (SELECT GROUP_CONCAT(an_tipianagrafiche.descrizione) FROM an_tipianagrafiche INNER JOIN an_tipianagrafiche_anagrafiche ON an_tipianagrafiche.idtipoanagrafica=an_tipianagrafiche_anagrafiche.idtipoanagrafica WHERE idanagrafica=an_anagrafiche.idanagrafica) AS idtipianagrafica FROM an_anagrafiche WHERE idconto_cliente=0 OR idconto_fornitore=0'); - -for ($i = 0; $i < sizeof($rs); ++$i) { - if (in_array('Cliente', explode(',', $rs[$i]['idtipianagrafica']))) { - // Calcolo il codice conto più alto - $rs2 = $dbo->fetchArray("SELECT MAX( CAST(numero AS UNSIGNED) ) AS max_numero, idpianodeiconti2 FROM co_pianodeiconti3 WHERE numero=CAST(numero AS UNSIGNED) AND idpianodeiconti2=(SELECT id FROM co_pianodeiconti2 WHERE descrizione='Crediti clienti e crediti diversi')"); - $numero = str_pad($rs2[0]['max_numero'] + 1, 6, '0', STR_PAD_LEFT); - $idpianodeiconti2 = $rs2[0]['idpianodeiconti2']; - - // Creo il nuovo conto - $dbo->query('INSERT INTO co_pianodeiconti3( numero, descrizione, idpianodeiconti2, can_delete, can_edit ) VALUES( "'.$numero.'", "'.$rs[$i]['ragione_sociale'].'", "'.$idpianodeiconti2.'", 1, 1 )'); - $idconto = $dbo->lastInsertedID(); - - // Collego questo conto al cliente - $dbo->query('UPDATE an_anagrafiche SET idconto_cliente="'.$idconto.'" WHERE idanagrafica="'.$rs[$i]['idanagrafica'].'"'); - } - - if (in_array('Fornitore', explode(',', $rs[$i]['idtipianagrafica']))) { - // Calcolo il codice conto più alto - $rs2 = $dbo->fetchArray("SELECT MAX( CAST(numero AS UNSIGNED) ) AS max_numero, idpianodeiconti2 FROM co_pianodeiconti3 WHERE numero=CAST(numero AS UNSIGNED) AND idpianodeiconti2=(SELECT id FROM co_pianodeiconti2 WHERE descrizione='Debiti fornitori e debiti diversi')"); - $numero = str_pad($rs2[0]['max_numero'] + 1, 6, '0', STR_PAD_LEFT); - $idpianodeiconti2 = $rs2[0]['idpianodeiconti2']; - - // Creo il nuovo conto - $dbo->query('INSERT INTO co_pianodeiconti3( numero, descrizione, idpianodeiconti2, can_delete, can_edit ) VALUES( "'.$numero.'", "'.$rs[$i]['ragione_sociale'].'", "'.$idpianodeiconti2.'", 1, 1 )'); - $idconto = $dbo->lastInsertedID(); - - // Collego questo conto al cliente - $dbo->query('UPDATE an_anagrafiche SET idconto_fornitore="'.$idconto.'" WHERE idanagrafica="'.$rs[$i]['idanagrafica'].'"'); - } -} - -// Sposto tutti i movimenti delle fatture dal riepilogativo (clienti o fornitori) al relativo conto di ogni anagrafica -$rs = $dbo->fetchArray('SELECT co_movimenti.id, co_documenti.idanagrafica, dir FROM (co_movimenti INNER JOIN co_documenti ON co_movimenti.iddocumento=co_documenti.id) INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento WHERE NOT iddocumento=0'); - -for ($i = 0; $i < sizeof($rs); ++$i) { - if ($rs[$i]['dir'] == 'entrata') { - $query = 'UPDATE co_movimenti SET idconto=(SELECT idconto_cliente FROM an_anagrafiche WHERE idanagrafica="'.$rs[$i]['idanagrafica'].'") WHERE id="'.$rs[$i]['id']."\" AND idconto=(SELECT id FROM co_pianodeiconti3 WHERE descrizione='Riepilogativo clienti')"; - } else { - $query = 'UPDATE co_movimenti SET idconto=(SELECT idconto_fornitore FROM an_anagrafiche WHERE idanagrafica="'.$rs[$i]['idanagrafica'].'") WHERE id="'.$rs[$i]['id']."\" AND idconto=(SELECT id FROM co_pianodeiconti3 WHERE descrizione='Riepilogativo fornitori')"; - } - - $dbo->query($query); -} - -// Aggiungo il flag "Attiva aggiornamenti" se manca (nella migrazione della 2.0 non c'è) -$rs = $dbo->fetchArray("SELECT idimpostazione FROM zz_impostazioni WHERE nome='Attiva aggiornamenti'"); - -if (sizeof($rs) == 0) { - $dbo->query("INSERT INTO `zz_impostazioni` (`nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES ( 'Attiva aggiornamenti', '1', 'boolean', '0', 'Generali')"); -} - -// Spostamento ore di lavoro e diritto di chiamata dei preventivi nella tabella -$idiva = $dbo->fetchArray("SELECT valore FROM zz_impostazioni WHERE nome='Iva predefinita'")[0]['valore']; - -$rs = $dbo->fetchArray('SELECT percentuale, indetraibile FROM co_iva WHERE id="'.$idiva.'"'); -$percentuale = $rs[0]['percentuale']; -$indetraibile = $rs[0]['indetraibile']; - -$rs = $dbo->fetchArray('SELECT * FROM co_preventivi WHERE ore_lavoro > 0 OR costo_diritto_chiamata > 0'); - -for ($i = 0; $i < sizeof($rs); ++$i) { - // Ore lavoro - if ($rs[$i]['ore_lavoro'] > 0) { - $imponibile = $rs[$i]['costo_orario'] * $rs[$i]['ore_lavoro']; - - $iva = $imponibile / 100 * $percentuale; - $iva_indetraibile = $imponibile / 100 * $indetraibile; - - $dbo->query('INSERT INTO co_righe_preventivi( idpreventivo, idiva, iva, iva_indetraibile, descrizione, subtotale, sconto, um, qta ) VALUES( "'.$rs[$i]['id'].'", "'.$idiva.'", "'.$iva.'", "'.$iva_indetraibile.'", "Ore lavoro", "'.$imponibile.'", "0.00", "ore", "'.$rs[$i]['ore_lavoro'].'" )'); - } - - // Ore diritto chiamata - if ($rs[$i]['costo_diritto_chiamata'] > 0) { - $imponibile = $rs[$i]['costo_diritto_chiamata']; - - $iva = $imponibile / 100 * $percentuale; - $iva_indetraibile = $imponibile / 100 * $indetraibile; - - $dbo->query('INSERT INTO co_righe_preventivi( idpreventivo, idiva, iva, iva_indetraibile, descrizione, subtotale, sconto, um, qta ) VALUES( "'.$rs[$i]['id'].'", "'.$idiva.'", "'.$iva.'", "'.$iva_indetraibile.'", "Diritto chiamata", "'.$imponibile.'", "0.00", "", "'.$rs[$i]['costo_diritto_chiamata'].'" )'); - } -} - -// Eliminazione vecchi file -$files = [ - base_dir().'/share/themes/default/css/font-awesome.css', - base_dir().'/modules/preventivi/js/', -]; -delete($files); - -/* -* Spostamento agente di riferimento su nuova tabella an_anagrafiche_agenti -*/ -$rs = $dbo->fetchArray('SELECT idanagrafica, idagente FROM an_anagrafiche WHERE NOT idagente=0'); - -for ($i = 0; $i < sizeof($rs); ++$i) { - $dbo->query('INSERT INTO an_anagrafiche_agenti( idanagrafica, idagente ) VALUES( "'.$rs[$i]['idanagrafica'].'", "'.$rs[$i]['idagente'].'" )'); -} - -/** - * 2016-11-09 (r1509) - * Creo le associazioni fra i tipi di intervento e i contratti. - */ -$rsc = $dbo->fetchArray('SELECT id FROM co_contratti'); - -for ($c = 0; $c < sizeof($rsc); ++$c) { - $rsi = $dbo->fetchArray('SELECT * FROM in_tipiintervento WHERE (costo_orario!=0 OR costo_km!=0 OR costo_diritto_chiamata!=0)'); - - for ($i = 0; $i < sizeof($rsi); ++$i) { - $dbo->query('INSERT INTO co_contratti_tipiintervento( idcontratto, idtipointervento, costo_ore, costo_km, costo_dirittochiamata, costo_ore_tecnico, costo_km_tecnico, costo_dirittochiamata_tecnico ) VALUES( "'.$rsc[$c]['id'].'", "'.$rsi[$i]['idtipointervento'].'", "'.$rsi[$i]['costo_orario'].'", "'.$rsi[$i]['costo_km'].'", "'.$rsi[$i]['costo_diritto_chiamata'].'", "'.$rsi[$i]['costo_orario_tecnico'].'", "'.$rsi[$i]['costo_km_tecnico'].'", "'.$rsi[$i]['costo_diritto_chiamata_tecnico'].'" )'); - } -} diff --git a/update/2_2.sql b/update/2_2.sql deleted file mode 100755 index 0851c6d62..000000000 --- a/update/2_2.sql +++ /dev/null @@ -1,177 +0,0 @@ --- Aggiunta ai contratti il collegamento con il contratto precedente -ALTER TABLE `co_contratti` ADD `idcontratto_prev` INT NOT NULL; - --- Aggiunta vista dashboard (mese,settimana,giorno) -INSERT INTO `zz_impostazioni` (`idimpostazione`, `nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES (NULL, 'Vista dashboard', 'settimana', 'list[mese,settimana,giorno]', '1', 'Generali'); - --- Aggiungo nuovi valori predefiniti per le anagrafiche -ALTER TABLE `an_anagrafiche` ADD `idtipointervento_default` VARCHAR(25) NOT NULL; - --- Creo tabella my_impianti_contratti -CREATE TABLE IF NOT EXISTS `my_impianti_contratti` ( - `idcontratto` varchar(25) NOT NULL, - `matricola` varchar(25) NOT NULL -) ENGINE=InnoDB; - --- Aggiunta sesso nelle anagrafiche -ALTER TABLE `an_anagrafiche` ADD `sesso` ENUM('', 'M', 'F') NOT NULL AFTER `luogo_nascita`; - --- Aggiunta tipo anagrafica -ALTER TABLE `an_anagrafiche` ADD `tipo` ENUM('', 'Azienda', 'Privato', 'Ente pubblico') NOT NULL AFTER `ragione_sociale`; - --- Aggiunta scelta impostazioni sicurezza SMTP -INSERT INTO `zz_impostazioni` (`idimpostazione`, `nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES (NULL, 'Sicurezza SMTP', 'Nessuna', 'list[Nessuna,TLS,SSL]', '1', 'Email'); - --- nascondo opzione con indirizzo email destinatario del modulo bug -UPDATE `zz_impostazioni` SET `editable` = '0' WHERE `nome` = 'Destinatario'; - --- Aggiornamento query moduli per il nuovo sistema di caricamento via ajax -UPDATE `zz_modules` SET `options` = '{ "main_query": [ { "type": "table", "fields": "Ragione sociale, Tipologia, Città, Telefono, color_Rel.", "query": "SELECT `idanagrafica` AS `id`, ragione_sociale AS `Ragione sociale`, (SELECT GROUP_CONCAT(descrizione SEPARATOR '', '') FROM an_tipianagrafiche INNER JOIN an_tipianagrafiche_anagrafiche ON an_tipianagrafiche.idtipoanagrafica=an_tipianagrafiche_anagrafiche.idtipoanagrafica GROUP BY idanagrafica HAVING idanagrafica=an_anagrafiche.idanagrafica) AS `Tipologia`, citta AS `Città`, telefono AS `Telefono`, an_relazioni.colore AS `color_Rel.`, an_relazioni.descrizione AS `color_title_Rel.`, deleted FROM an_anagrafiche LEFT OUTER JOIN an_relazioni ON an_anagrafiche.idrelazione=an_relazioni.id HAVING 1=1 AND deleted=0 ORDER BY `ragione_sociale`"} ]}' WHERE `name` = 'Anagrafiche'; -UPDATE `zz_modules` SET `options` = '{ "main_query": [ { "type": "table", "fields": "ID, Tipo, Ragione sociale, Stato, Data inizio, Data fine, _print_", "query": "SELECT `in_interventi`.`idanagrafica`, `in_interventi`.`idintervento` AS `id`, `in_interventi`.`idintervento` AS `ID`, `ragione_sociale` AS `Ragione sociale`, DATE_FORMAT(MIN(`orario_inizio`), ''%d/%m/%Y'') AS `Data inizio`, DATE_FORMAT(MAX(`orario_fine`), ''%d/%m/%Y'') AS `Data fine`, `data_richiesta`, (SELECT `colore` FROM `in_statiintervento` WHERE `idstatointervento`=`in_interventi`.`idstatointervento`) AS `_bg_`, (SELECT `descrizione` FROM `in_statiintervento` WHERE `idstatointervento`=`in_interventi`.`idstatointervento`) AS `Stato`, (SELECT `descrizione` FROM `in_tipiintervento` WHERE `idtipointervento`=`in_interventi`.`idtipointervento`) AS `Tipo`, ''pdfgen.php?ptype=interventi&idintervento=$id$&mode=single'' AS `_print_`, `orario_inizio`, `orario_fine` FROM (`in_interventi` INNER JOIN `an_anagrafiche` ON `in_interventi`.`idanagrafica`=`an_anagrafiche`.`idanagrafica`) LEFT OUTER JOIN `in_interventi_tecnici` ON `in_interventi_tecnici`.`idintervento`=`in_interventi`.`idintervento` GROUP BY `in_interventi`.`idintervento` HAVING 1=1 AND ((DATE_FORMAT(`orario_inizio`, ''%Y-%m-%d'') >= ''|period_start|'' AND DATE_FORMAT(`orario_fine`, ''%Y-%m-%d'') <= ''|period_end|'') OR (DATE_FORMAT(`data_richiesta`, ''%Y-%m-%d'') >= ''|period_start|'' AND DATE_FORMAT(`data_richiesta`, ''%Y-%m-%d'') <= ''|period_end|'')) ORDER BY IFNULL(`orario_fine`, `data_richiesta`) DESC"} ]}' WHERE `zz_modules`.`name` = 'Interventi'; -UPDATE `zz_modules` SET `options` = '{ "main_query": [ { "type": "table", "fields": "Descrizione", "query": "SELECT `idtipoanagrafica` AS `id`, `descrizione` AS `Descrizione` FROM `an_tipianagrafiche` HAVING 1=1"} ]}' WHERE `name` = 'Tipi di anagrafiche'; -UPDATE `zz_modules` SET `options` = '{ "main_query": [ { "type": "table", "fields": "Codice, Descrizione, Costo orario, Costo al km, Diritto di chiamata, Costo orario tecnico, Costo al km tecnico, Diritto di chiamata tecnico", "query": "SELECT `idtipointervento` AS `id`, `idtipointervento` AS `Codice`, `descrizione` AS `Descrizione`, REPLACE(FORMAT(`costo_orario`,2), ''.'', '','') AS `Costo orario`, REPLACE(FORMAT(`costo_km`,2), ''.'', '','') AS `Costo al km`, REPLACE(FORMAT(`costo_diritto_chiamata`,2), ''.'', '','') AS `Diritto di chiamata`, REPLACE(FORMAT(`costo_orario_tecnico`,2), ''.'', '','') AS `Costo orario tecnico`, REPLACE(FORMAT(`costo_km_tecnico`,2), ''.'', '','') AS `Costo al km tecnico`, REPLACE(FORMAT(`costo_diritto_chiamata_tecnico`,2), ''.'', '','') AS `Diritto di chiamata tecnico` FROM `in_tipiintervento` HAVING 1=1"} ]}' WHERE `name` = 'Tipi di intervento'; -UPDATE `zz_modules` SET `options` = '{ "main_query": [ { "type": "table", "fields": "Codice, Descrizione, color_Colore", "query": "SELECT `idstatointervento` AS `Codice`, `idstatointervento` AS `id`, `descrizione` AS `Descrizione`, `colore` AS `color_Colore` FROM `in_statiintervento` HAVING 1=1"} ]}' WHERE `name` = 'Stati di intervento'; -UPDATE `zz_modules` SET `options` = '{ "main_query": [ { "type": "table", "fields": "Numero, Nome, Cliente, icon_Stato", "query": "SELECT `id`, `numero` AS `Numero`, `nome` AS `Nome`, (SELECT `ragione_sociale` FROM `an_anagrafiche` WHERE `idanagrafica`=`co_preventivi`.`idanagrafica`) AS `Cliente`, (SELECT `icona` FROM `co_statipreventivi` WHERE `id`=`idstato`) AS `icon_Stato`, (SELECT `descrizione` FROM `co_statipreventivi` WHERE `id`=`idstato`) AS `icon_title_Stato`, data_bozza, data_conclusione FROM `co_preventivi` HAVING 1=1 AND (''|period_start|'' >= `data_bozza` AND ''|period_start|'' <= `data_conclusione`) OR (''|period_end|'' >= `data_bozza` AND ''|period_end|'' <= `data_conclusione`) OR (`data_bozza` >= ''|period_start|'' AND `data_bozza` <= ''|period_end|'') OR (`data_conclusione` >= ''|period_start|'' AND `data_conclusione` <= ''|period_end|'') OR (`data_bozza` >= ''|period_start|'' AND `data_conclusione` = ''0000-00-00'') ORDER BY `id` DESC"} ]}' WHERE `name` = 'Preventivi'; -UPDATE `zz_modules` SET `options` = '{ "main_query": [ { "type": "table", "fields": "Numero, Data, Ragione sociale, Totale, icon_Stato", "query": "SELECT `co_documenti`.`id`, IF(`numero_esterno`='''', `numero`, `numero_esterno`) AS `Numero`, DATE_FORMAT(`data`, ''%d/%m/%Y'') AS `Data`, (SELECT `ragione_sociale` FROM `an_anagrafiche` WHERE `idanagrafica`=`co_documenti`.`idanagrafica`) AS `Ragione sociale`, REPLACE(REPLACE(REPLACE(FORMAT((SELECT SUM(`subtotale`-`sconto`+`iva`+`rivalsainps`-`ritenutaacconto`) FROM `co_righe_documenti` GROUP BY `iddocumento` HAVING `iddocumento`=`co_documenti`.`id`) +`bollo` + `iva_rivalsainps`, 2), '','', ''#''), ''.'', '',''), ''#'', ''.'') AS `Totale`, (SELECT `icona` FROM `co_statidocumento` WHERE `id`=`idstatodocumento`) AS `icon_Stato`, (SELECT `descrizione` FROM `co_statidocumento` WHERE `id`=`idstatodocumento`) AS `icon_title_Stato` FROM `co_documenti` INNER JOIN `co_tipidocumento` ON `co_documenti`.`idtipodocumento`=`co_tipidocumento`.`id` WHERE 1=1 AND `dir`=''entrata'' AND `data` >= ''|period_start|'' AND `data` <= ''|period_end|'' ORDER BY DATE_FORMAT(`data`, ''%Y%m%d'') DESC, CAST(IFNULL(numero_esterno, numero) AS UNSIGNED) DESC"} ]}' WHERE `name`='Fatture di vendita'; -UPDATE `zz_modules` SET `options` = '{ "main_query": [ { "type": "table", "fields": "Numero, Data, Ragione sociale, Totale, icon_Stato", "query": "SELECT `co_documenti`.`id`, IF(`numero_esterno`='''', `numero`, `numero_esterno`) AS `Numero`, DATE_FORMAT(`data`, ''%d/%m/%Y'') AS `Data`, (SELECT `ragione_sociale` FROM `an_anagrafiche` WHERE `idanagrafica`=`co_documenti`.`idanagrafica`) AS `Ragione sociale`, REPLACE(REPLACE(REPLACE(FORMAT((SELECT SUM(`subtotale`-`sconto`+`iva`+`rivalsainps`-`ritenutaacconto`) FROM `co_righe_documenti` GROUP BY `iddocumento` HAVING `iddocumento`=`co_documenti`.`id`) +`bollo` + `iva_rivalsainps`, 2), '','', ''#''), ''.'', '',''), ''#'', ''.'') AS `Totale`, (SELECT `icona` FROM `co_statidocumento` WHERE `id`=`idstatodocumento`) AS `icon_Stato`, (SELECT `descrizione` FROM `co_statidocumento` WHERE `id`=`idstatodocumento`) AS `icon_title_Stato`, `dir`, `data` AS `data1` FROM `co_documenti` INNER JOIN `co_tipidocumento` ON `co_documenti`.`idtipodocumento`=`co_tipidocumento`.`id` HAVING 1=1 AND `dir`=''uscita'' AND `data1` >= ''|period_start|'' AND `data1` <= ''|period_end|'' ORDER BY DATE_FORMAT(`data1`, ''%Y%m%d'') DESC"} ]}' WHERE `name` = 'Fatture di acquisto'; -UPDATE `zz_modules` SET `options` = '{ "main_query": [ { "type": "table", "fields": "Codice, Descrizione, Categoria, Subcategoria, Q.tà", "query": "SELECT `id`, `codice` AS `Codice`, `descrizione` AS `Descrizione`, `categoria` AS `Categoria`, `subcategoria` AS `Subcategoria`, CONCAT_WS('' '', REPLACE(FORMAT(`qta`, 2), ''.'', '',''), (SELECT `valore` FROM `mg_unitamisura` WHERE `id`=`idum`)) AS `Q.tà` FROM `mg_articoli` HAVING 1=1 ORDER BY `descrizione`"} ]}' WHERE `name` = 'Articoli'; -UPDATE `zz_modules` SET `options` = '{ "main_query": [ { "type": "table", "fields": "Codice, Descrizione, Categoria, Subcategoria, Q.tà", "query": "SELECT `id`, `codice` AS `Codice`, `descrizione` AS `Descrizione`, `categoria` AS `Categoria`, `subcategoria` AS `Subcategoria`, CONCAT_WS('' '', REPLACE(FORMAT(`qta`, 2), ''.'', '',''), (SELECT `valore` FROM `mg_unitamisura` WHERE `id`=`idum`)) AS `Q.tà` FROM `mg_articoli` HAVING 1=1 ORDER BY `descrizione`"}] }' WHERE `name` = 'Articoli'; -UPDATE `zz_modules` SET `options` = '{ "main_query": [ { "type": "table", "fields": "Nome, Percentuale guadagno o sconto,Note", "query": "SELECT `id`, `nome` AS `Nome`, `prc_guadagno` AS `Percentuale guadagno o sconto`,`note` AS `Note` FROM `mg_listini` HAVING 1=1 ORDER BY `nome`"} ]}' WHERE `name` = 'Listini'; -UPDATE `zz_modules` SET `options` = '{ "main_query": [ { "type": "table", "fields": "Targa,Nome,Descrizione", "query": "SELECT `id`, `targa` AS `Targa`, `nome` AS `Nome`,`descrizione` AS `Descrizione` FROM `dt_automezzi` HAVING 1=1 ORDER BY `targa`"} ]}' WHERE `name` = 'Automezzi'; -UPDATE `zz_modules` SET `options` = '{ "main_query": [ { "type": "table", "fields": "Numero, Data, Ragione sociale, icon_Stato", "query": "SELECT `or_ordini`.`id`, IF(`numero_esterno`='''', `numero`, `numero_esterno`) AS `Numero`, DATE_FORMAT(`data`, ''%d/%m/%Y'') AS `Data`, (SELECT `ragione_sociale` FROM `an_anagrafiche` WHERE `idanagrafica`=`or_ordini`.`idanagrafica`) AS `Ragione sociale`, (SELECT `icona` FROM `or_statiordine` WHERE `id`=`idstatoordine`) AS `icon_Stato`, (SELECT `descrizione` FROM `or_statiordine` WHERE `id`=`idstatoordine`) AS `icon_title_Stato`, `dir`, `data` AS `data1` FROM `or_ordini` INNER JOIN `or_tipiordine` ON `or_ordini`.`idtipoordine`=`or_tipiordine`.`id` HAVING 1=1 AND `dir`=''entrata'' AND `data1` >= ''|period_start|'' AND `data1` <= ''|period_end|'' ORDER BY `data1` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC"} ]}' WHERE `name` = 'Ordini cliente'; -UPDATE `zz_modules` SET `options` = '{ "main_query": [ { "type": "table", "fields": "Numero, Data, Ragione sociale, icon_Stato", "query": "SELECT `or_ordini`.`id`, IF(`numero_esterno`='''', `numero`, `numero_esterno`) AS `Numero`, DATE_FORMAT(`data`, ''%d/%m/%Y'') AS `Data`, (SELECT `ragione_sociale` FROM `an_anagrafiche` WHERE `idanagrafica`=`or_ordini`.`idanagrafica`) AS `Ragione sociale`, (SELECT `icona` FROM `or_statiordine` WHERE `id`=`idstatoordine`) AS `icon_Stato`, (SELECT `descrizione` FROM `or_statiordine` WHERE `id`=`idstatoordine`) AS `icon_title_Stato`, `dir`, `data` AS `data1` FROM `or_ordini` INNER JOIN `or_tipiordine` ON `or_ordini`.`idtipoordine`=`or_tipiordine`.`id` HAVING 1=1 AND `dir`=''uscita'' AND `data1` >= ''|period_start|'' AND `data1` <= ''|period_end|'' ORDER BY `data1` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC"} ]}' WHERE `name` = 'Ordini fornitore'; -UPDATE `zz_modules` SET `options` = '{ "main_query": [ { "type": "table", "fields": "Numero, Data, Cliente, icon_Stato", "query": "SELECT `dt_ddt`.`id`, IF(`numero_esterno`='''', `numero`, `numero_esterno`) AS `Numero`, DATE_FORMAT(`data`, ''%d/%m/%Y'') AS `Data`, (SELECT `ragione_sociale` FROM `an_anagrafiche` WHERE `idanagrafica`=`dt_ddt`.`idanagrafica`) AS `Cliente`, (SELECT `icona` FROM `dt_statiddt` WHERE `id`=`idstatoddt`) AS `icon_Stato`, (SELECT `descrizione` FROM `dt_statiddt` WHERE `id`=`idstatoddt`) AS `icon_title_Stato`, `dir`, `data` AS `data1` FROM `dt_ddt` INNER JOIN `dt_tipiddt` ON `dt_ddt`.`idtipoddt`=`dt_tipiddt`.`id` HAVING 1=1 AND `dir`=''entrata'' AND `data1` >= ''|period_start|'' AND `data1` <= ''|period_end|'' ORDER BY DATE_FORMAT(`data1`, ''%Y%m%d'') DESC, CAST(`numero_esterno` AS UNSIGNED) DESC"} ]}' WHERE `name` = 'Ddt di vendita'; -UPDATE `zz_modules` SET `options` = '{ "main_query": [ { "type": "table", "fields": "Numero, Data, Cliente, icon_Stato", "query": "SELECT `dt_ddt`.`id`, IF(`numero_esterno`='''', `numero`, `numero_esterno`) AS `Numero`, DATE_FORMAT(`data`, ''%d/%m/%Y'') AS `Data`, (SELECT `ragione_sociale` FROM `an_anagrafiche` WHERE `idanagrafica`=`dt_ddt`.`idanagrafica`) AS `Cliente`, (SELECT `icona` FROM `dt_statiddt` WHERE `id`=`idstatoddt`) AS `icon_Stato`, (SELECT `descrizione` FROM `dt_statiddt` WHERE `id`=`idstatoddt`) AS `icon_title_Stato`, `dir`, `data` AS `data1` FROM `dt_ddt` INNER JOIN `dt_tipiddt` ON `dt_ddt`.`idtipoddt`=`dt_tipiddt`.`id` HAVING 1=1 AND `dir`=''uscita'' AND `data1` >= ''|period_start|'' AND `data1` <= ''|period_end|'' ORDER BY DATE_FORMAT(`data1`, ''%Y%m%d'') DESC, CAST(`numero_esterno` AS UNSIGNED) DESC"} ]}' WHERE `name` = 'Ddt di acquisto'; -UPDATE `zz_modules` SET `options` = '{ "main_query": [ { "type": "table", "fields": "Nome, Descrizione", "query": "SELECT `id`, `nome` AS `Nome`, `descrizione` AS `Descrizione` FROM `an_zone` HAVING 1=1 ORDER BY `id`"} ]}' WHERE `name` = 'Zone'; -UPDATE `zz_modules` SET `options` = '{ "main_query": [ { "type": "table", "fields": "Tipo intervento, Tecnico, Costo orario, Costo al km, Diritto di chiamata, Costo orario tecnico, Costo al km tecnico, Diritto di chiamata tecnico", "query": "SELECT `id`, (SELECT descrizione FROM in_tipiintervento WHERE idtipointervento=in_tariffe.idtipointervento) AS `Tipo intervento`, (SELECT `ragione_sociale` FROM `an_anagrafiche` WHERE `idanagrafica`=`idtecnico`) AS `Tecnico`, REPLACE(FORMAT(`costo_ore`,2), ''.'', '','') AS `Costo orario`, REPLACE(FORMAT(`costo_km`,2), ''.'', '','') AS `Costo al km`, REPLACE(FORMAT(`costo_dirittochiamata`,2), ''.'', '','') AS `Diritto di chiamata`, REPLACE(FORMAT(`costo_ore_tecnico`,2), ''.'', '','') AS `Costo orario tecnico`, REPLACE(FORMAT(`costo_km_tecnico`,2), ''.'', '','') AS `Costo al km tecnico`, REPLACE(FORMAT(`costo_dirittochiamata_tecnico`,2), ''.'', '','') AS `Diritto di chiamata tecnico`, ''Tecnico'' AS `descrizione`, `in_tariffe`.`idtecnico`, `idtipointervento` FROM `in_tariffe` HAVING 1=1 UNION SELECT CONCAT(`an_anagrafiche`.`idanagrafica`,''|'',`in_tipiintervento`.`idtipointervento`) AS `id`, `in_tipiintervento`.`descrizione` AS `Tipo intervento`, `ragione_sociale` AS `Tecnico`, ''0,00'' AS `Costo orario`, ''0,00'' AS `Costo al km`, ''0,00'' AS `Diritto di chiamata`, ''0,00'' AS `Costo orario tecnico`, ''0,00'' AS `Costo al km tecnico`, ''0,00'' AS `Diritto di chiamata tecnico`, `an_tipianagrafiche`.`descrizione`, `an_anagrafiche`.`idanagrafica`, `in_tipiintervento`.`idtipointervento` FROM ((`an_anagrafiche` INNER JOIN (`an_tipianagrafiche_anagrafiche` INNER JOIN `an_tipianagrafiche` ON `an_tipianagrafiche_anagrafiche`.`idtipoanagrafica`=`an_tipianagrafiche`.`idtipoanagrafica`) ON `an_anagrafiche`.`idanagrafica`=`an_tipianagrafiche_anagrafiche`.`idanagrafica`) LEFT OUTER JOIN `in_tipiintervento` ON 2=2) HAVING 1=1 AND `an_tipianagrafiche`.`descrizione`=''Tecnico'' AND CONCAT_WS(''-'', `an_anagrafiche`.`idanagrafica`, `in_tipiintervento`.`idtipointervento`) NOT IN(SELECT CONCAT_WS(''-'', `in_tariffe`.`idtecnico`, `in_tariffe`.`idtipointervento`) FROM `in_tariffe` WHERE `idtecnico`=`an_anagrafiche`.`idanagrafica`) ORDER BY `Tipo intervento`, `Tecnico`"} ]} ' WHERE `name` = 'Tecnici e tariffe'; -UPDATE `zz_modules` SET `options` = '{ "main_query": [ { "type": "table", "fields": "Matricola, Nome, Cliente, Data, Tecnico", "query": "SELECT `matricola` AS `id`, `matricola` AS `Matricola`, `nome` AS `Nome`, DATE_FORMAT(`data`, ''%d/%m/%Y'') AS `Data`, (SELECT `ragione_sociale` FROM `an_anagrafiche` WHERE `idanagrafica`=`my_impianti`.`idanagrafica`) AS `Cliente`, (SELECT `ragione_sociale` FROM `an_anagrafiche` WHERE `idanagrafica`=`my_impianti`.`idtecnico`) AS `Tecnico` FROM `my_impianti` HAVING 1=1 ORDER BY `matricola`"} ]}' WHERE `name` = 'MyImpianti'; -UPDATE `zz_modules` SET `options` = '{ "main_query": [ { "type": "table", "fields": "Numero, Nome, Cliente, icon_Stato", "query": "SELECT `id`, `numero` AS `Numero`, `nome` AS `Nome`, (SELECT `ragione_sociale` FROM `an_anagrafiche` WHERE `idanagrafica`=`co_contratti`.`idanagrafica`) AS `Cliente`, (SELECT `icona` FROM `co_staticontratti` WHERE `id`=`idstato`) AS `icon_Stato`, (SELECT `descrizione` FROM `co_staticontratti` WHERE `id`=`idstato`) AS `icon_title_Stato`, `data_bozza`, `data_conclusione` FROM `co_contratti` HAVING 1=1 AND ((''|period_start|'' >= `data_bozza` AND ''|period_start|'' <= `data_conclusione`) OR (''|period_end|'' >= `data_bozza` AND ''|period_end|'' <= `data_conclusione`) OR (`data_bozza` >= ''|period_start|'' AND `data_bozza` <= ''|period_end|'') OR (`data_conclusione` >= ''|period_start|'' AND `data_conclusione` <= ''|period_end|'') OR (`data_bozza` >= ''|period_start|'' AND `data_conclusione` = ''0000-00-00'')) ORDER BY `id` DESC"} ]}' WHERE `name` = 'Contratti'; -UPDATE `zz_modules` SET `options` = '{ "main_query": [ { "type": "table", "fields": "Categoria, Descrizione", "query": "SELECT `id`, `descrizione` AS `Descrizione`, `categoria` AS `Categoria` FROM `in_vociservizio` HAVING 1=1 ORDER BY `categoria`, `descrizione`"} ]}' WHERE `name` = 'Voci di servizio'; -UPDATE `zz_modules` SET `options` = '{ "main_query": [ { "type": "table", "fields": "Documento, Anagrafica, Tipo di pagamento, Data emissione, Data scadenza, Importo, Pagato", "query": "SELECT co_scadenziario.id AS id, ragione_sociale AS `Anagrafica`, co_pagamenti.descrizione AS `Tipo di pagamento`, CONCAT(co_tipidocumento.descrizione, CONCAT('' numero '', IF(numero_esterno<>'''', numero_esterno, numero))) AS `Documento`, DATE_FORMAT(data_emissione, ''%d/%m/%Y'') AS `Data emissione`, DATE_FORMAT(scadenza, ''%d/%m/%Y'') AS `Data scadenza`, REPLACE(REPLACE(REPLACE(FORMAT(da_pagare, 2), '','', ''#''), ''.'', '',''), ''#'', ''.'') AS `Importo`, REPLACE(REPLACE(REPLACE(FORMAT(pagato, 2), '','', ''#''), ''.'', '',''), ''#'', ''.'') AS `Pagato`, IF(scadenza0', '#A15D2D', 'fa fa-money', '', '', '', '', 'Valore magazzino', '1', '1'); -INSERT INTO `zz_widget_modules` (`id`, `name`, `type`, `id_module`, `location`, `class`, `query`, `bgcolor`, `icon`, `print_link`, `more_link`, `more_link_type`, `php_include`, `text`, `enabled`, `order`) VALUES (NULL, 'Articoli in magazzino', 'stats', '21', 'controller_right', 'col-md-12', 'SELECT CONCAT_WS(" ", REPLACE(REPLACE(REPLACE(FORMAT (SUM(qta),2), ",", "#"), ".", ","), "#", "."), "unità") AS dato FROM mg_articoli WHERE qta>0', '#45A9F1', 'fa fa-check-square-o', '', '', '', '', 'Articoli in magazzino', '1', '1'); --- Controllo scadenze per contratti con data conclusione > 1970 -UPDATE `zz_widget_modules` SET `query` = 'SELECT COUNT(id) AS dato FROM co_contratti WHERE idstato IN(SELECT id FROM co_staticontratti WHERE descrizione="Accettato" OR descrizione="In lavorazione" OR descrizione="In attesa di pagamento") AND rinnovabile=1 AND NOW() > DATE_ADD(data_conclusione, INTERVAL -ABS(giorni_preavviso_rinnovo) DAY) AND YEAR(data_conclusione) > 1970' WHERE `zz_widget_modules`.`name` = 'Contratti in scadenza'; - --- Aumento dimensione campo descrizione su co_pagamenti -ALTER TABLE `co_pagamenti` CHANGE `descrizione` `descrizione` VARCHAR(255) NOT NULL; - --- Aggiunta filtro su MyImpianti per mostrare solo quelli del cliente loggato -INSERT INTO `zz_gruppi_modules` (`idgruppo`, `idmodule`, `clause`) VALUES ((SELECT `id` FROM `zz_gruppi` WHERE `nome`='Clienti'), (SELECT `id` FROM `zz_modules` WHERE `name`='MyImpianti'), 'AND my_impianti.idanagrafica=|idanagrafica|'); - --- Aggiunto plugin che mostra elenco ddt di vendita per l'anagrafica -INSERT INTO `zz_modules_plugins` (`id`, `name`, `idmodule_from`, `idmodule_to`, `position`, `script`) VALUES (NULL, 'Ddt del cliente', (SELECT `id` FROM `zz_modules` WHERE `name`='Ddt di vendita'), (SELECT `id` FROM `zz_modules` WHERE `name`='Anagrafiche'), 'tab', 'ddt.anagrafiche.php'); - --- Aggiunta nuovi campi nelle righe preventivi -ALTER TABLE `co_righe2_contratti` ADD `sconto` DECIMAL(12, 4) NOT NULL AFTER `subtotale`; -ALTER TABLE `co_righe2_contratti` ADD `idiva` INT(11) NOT NULL AFTER `sconto`; -ALTER TABLE `co_righe2_contratti` ADD `iva` DECIMAL(12, 4) NOT NULL AFTER `idiva`; -ALTER TABLE `co_righe2_contratti` ADD `iva_indetraibile` DECIMAL(12, 4) NOT NULL AFTER `iva`; - --- Aggiunto stato concluso anche ai contratti -INSERT INTO `co_staticontratti` (`id`, `descrizione`, `icona`, `completato`, `annullato`) VALUES (NULL, 'Concluso', 'fa fa-2x fa-check text-success', '0', '0'); - --- Aggiunto modulo per gestire componenti --- (SELECT `id` FROM `zz_modules` WHERE `name`='MyImpianti') -INSERT INTO `zz_modules` (`id`, `name`, `name2`, `module_dir`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `level`, `parent`, `default`, `enabled`, `type`, `new`) VALUES (NULL, 'Gestione componenti', '', 'gestione_componenti', '{ "main_query": [ { "type": "custom" } ]}', '', 'fa fa-external-link', '2.2', '2.2', '0', '1', '30', '1', '1', 'menu', '0'); -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Gestione componenti' AND `t2`.`name` = 'MyImpianti') SET `t1`.`parent` = `t2`.`id`; - --- Aggiunti campi per gestire firma rapportini -ALTER TABLE `in_interventi` ADD `firma_file` varchar(255) NOT NULL AFTER `ora_sla`; -ALTER TABLE `in_interventi` ADD `firma_data` DATETIME NOT NULL AFTER `firma_file`; -ALTER TABLE `in_interventi` ADD `firma_nome` VARCHAR(255) NOT NULL AFTER `firma_data`; - --- Aggiunto campo data_invio per salvare data e ora invio email dei rapportini -ALTER TABLE `in_interventi` ADD `data_invio` DATETIME NULL AFTER `firma_nome`; - --- Aggiunta impostazione destinatario fisso in copia -INSERT INTO `zz_impostazioni` (`nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES -('Destinatario fisso in copia (campo CC)', '', 'string', 1, 'Email'); - --- Aggiunta legame tra interventi e componenti -CREATE TABLE IF NOT EXISTS `my_componenti_interventi` ( - `id_intervento` varchar(25) NOT NULL, - `id_componente` varchar(25) NOT NULL -) ENGINE=InnoDB; - --- Aggiunto campo prc_guadagno in co_righe_preventivi -ALTER TABLE `co_righe_preventivi` ADD `prc_guadagno` DECIMAL(5,2) NOT NULL AFTER `sconto`; - --- 2016-11-09 (r1509) -CREATE TABLE IF NOT EXISTS `co_contratti_tipiintervento` ( - `idcontratto` int(11) NOT NULL, - `idtipointervento` varchar(25) NOT NULL, - `costo_ore` decimal(12,4) NOT NULL, - `costo_km` decimal(12,4) NOT NULL, - `costo_dirittochiamata` decimal(12,4) NOT NULL, - `costo_ore_tecnico` decimal(12,4) NOT NULL, - `costo_km_tecnico` decimal(12,4) NOT NULL, - `costo_dirittochiamata_tecnico` decimal(12,4) NOT NULL, - PRIMARY KEY (`idcontratto`,`idtipointervento`) -) ENGINE=InnoDB; diff --git a/update/2_3.php b/update/2_3.php deleted file mode 100755 index abdbd50bb..000000000 --- a/update/2_3.php +++ /dev/null @@ -1,42 +0,0 @@ -query("UPDATE mg_articoli SET contenuto = REPLACE(REPLACE(REPLACE(contenuto, '"', '\"'), '\n', ".prepare(PHP_EOL)."), '`', '\"')"); -$database->query("UPDATE my_impianto_componenti SET contenuto = REPLACE(REPLACE(REPLACE(contenuto, '"', '\"'), '\n', ".prepare(PHP_EOL)."), '`', '\"')"); - -// Fix per la presenza della Foreign Key in in_interventi_tecnici -$fk = $database->fetchArray('SELECT TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_SCHEMA = '.prepare($database->getDatabaseName())." AND REFERENCED_TABLE_NAME = 'in_interventi' AND CONSTRAINT_NAME = 'in_interventi_tecnici_ibfk_1'"); -if (!empty($fk)) { - $database->query('ALTER TABLE `in_interventi_tecnici` DROP FOREIGN KEY `in_interventi_tecnici_ibfk_1`'); -} - -$database->query('ALTER TABLE `in_interventi` DROP PRIMARY KEY, CHANGE `idintervento` `codice` varchar(25) NOT NULL UNIQUE, ADD PRIMARY KEY (`id`)'); -$database->query('DROP INDEX primary_key ON `in_interventi`'); -$database->query('UPDATE `in_interventi_tecnici` SET `idintervento` = (SELECT `id` FROM `in_interventi` WHERE `in_interventi`.`codice` = `in_interventi_tecnici`.`idintervento`)'); -$database->query('ALTER TABLE `in_interventi_tecnici` CHANGE `idintervento` `idintervento` varchar(25)'); -$database->query("UPDATE `in_interventi_tecnici` SET `idintervento` = NULL WHERE `idintervento` = 0 OR `idintervento` = ''"); -$database->query('ALTER TABLE `in_interventi_tecnici` CHANGE `idintervento` `idintervento` int(11), ADD FOREIGN KEY (`idintervento`) REFERENCES `in_interventi`(`id`) ON DELETE CASCADE'); - -// Fix dei timestamp delle tabelle mg_prodotti, mg_movimenti, zz_logs e zz_files -$database->query('UPDATE `mg_prodotti` SET `created_at` = `data`'); -$database->query('ALTER TABLE `mg_prodotti` DROP `data`'); - -$database->query('UPDATE `mg_movimenti` SET `created_at` = `data`'); -$database->query('ALTER TABLE `mg_movimenti` DROP `data`'); - -$database->query('UPDATE `zz_logs` SET `created_at` = `timestamp`'); -$database->query('ALTER TABLE `zz_logs` DROP `timestamp`'); - -$database->query('UPDATE `zz_files` SET `created_at` = `data`'); -$database->query('ALTER TABLE `zz_files` DROP `data`'); - -// Fix per gli idtipointervento che non si sono copiati in in_interventi_tecnici -$database->query("UPDATE `in_interventi_tecnici` SET `idtipointervento` = (SELECT `idtipointervento` FROM `in_interventi` WHERE `in_interventi`.`id` = `in_interventi_tecnici`.`idintervento`) WHERE `idtipointervento` = '' "); - -/* -* Rimozione file e cartelle deprecati [in 2.3.1 per risolvere un problema sui percorsi] -*/ diff --git a/update/2_3.sql b/update/2_3.sql deleted file mode 100755 index 74368819b..000000000 --- a/update/2_3.sql +++ /dev/null @@ -1,1085 +0,0 @@ --- Standardizzazione delle tabelle principali -ALTER TABLE `zz_utenti` RENAME `zz_users`; -ALTER TABLE `zz_impostazioni` RENAME `zz_settings`; -ALTER TABLE `zz_permessi` RENAME `zz_permissions`; -ALTER TABLE `zz_widget_modules` RENAME `zz_widgets`; -ALTER TABLE `zz_modules_plugins` RENAME `zz_plugins`; -ALTER TABLE `zz_log` RENAME `zz_logs`; -ALTER TABLE `zz_gruppi` RENAME `zz_groups`; -ALTER TABLE `zz_gruppi_modules` RENAME `zz_group_module`; - -ALTER TABLE `zz_settings` CHANGE `valore` `valore` text NOT NULL; - --- Ridenominazione dell'attributo module_dir in directory -ALTER TABLE `zz_modules` CHANGE `module_dir` `directory` varchar(50) NOT NULL, CHANGE `name2` `title` varchar(255) NOT NULL, DROP `type`, DROP `new`; -UPDATE `zz_modules` SET `name` = REPLACE(`name`, 'à', 'à'), `title` = REPLACE(`title`, 'à', 'à'); - --- Adattamento della tabella in_interventi -ALTER TABLE `in_interventi` ADD `id` int(11) NOT NULL; -CREATE INDEX primary_key ON `in_interventi` (`id`); -ALTER TABLE `in_interventi` CHANGE `id` `id` int(11) NOT NULL AUTO_INCREMENT FIRST; - -ALTER TABLE `my_impianti_interventi` DROP PRIMARY KEY; - -UPDATE `co_ordiniservizio` SET `idintervento` = (SELECT `id` FROM `in_interventi` WHERE `in_interventi`.`idintervento` = `co_ordiniservizio`.`idintervento`); -DELETE FROM `co_preventivi_interventi` WHERE idpreventivo = 0; -UPDATE `co_preventivi_interventi` SET `idintervento` = (SELECT `id` FROM `in_interventi` WHERE `in_interventi`.`idintervento` = `co_preventivi_interventi`.`idintervento`); -UPDATE `co_righe_contratti` SET `idintervento` = (SELECT `id` FROM `in_interventi` WHERE `in_interventi`.`idintervento` = `co_righe_contratti`.`idintervento`); -UPDATE `co_righe_documenti` SET `idintervento` = (SELECT `id` FROM `in_interventi` WHERE `in_interventi`.`idintervento` = `co_righe_documenti`.`idintervento`); -UPDATE `in_righe_interventi` SET `idintervento` = (SELECT `id` FROM `in_interventi` WHERE `in_interventi`.`idintervento` = `in_righe_interventi`.`idintervento`); -UPDATE `mg_movimenti` SET `idintervento` = (SELECT `id` FROM `in_interventi` WHERE `in_interventi`.`idintervento` = `mg_movimenti`.`idintervento`); -UPDATE `mg_articoli_interventi` SET `idintervento` = (SELECT `id` FROM `in_interventi` WHERE `in_interventi`.`idintervento` = `mg_articoli_interventi`.`idintervento`); -UPDATE `my_impianti_interventi` SET `idintervento` = (SELECT `id` FROM `in_interventi` WHERE `in_interventi`.`idintervento` = `my_impianti_interventi`.`idintervento`); -UPDATE `my_impianto_componenti` SET `idintervento` = (SELECT `id` FROM `in_interventi` WHERE `in_interventi`.`idintervento` = `my_impianto_componenti`.`idintervento`); -UPDATE `my_componenti_interventi` SET `id_intervento` = (SELECT `id` FROM `in_interventi` WHERE `in_interventi`.`idintervento` = `my_componenti_interventi`.`id_intervento`); - -ALTER TABLE `co_ordiniservizio` CHANGE `idintervento` `idintervento` varchar(25); -ALTER TABLE `co_preventivi_interventi` CHANGE `idintervento` `idintervento` varchar(25); -ALTER TABLE `co_righe_contratti` CHANGE `idintervento` `idintervento` varchar(25); -ALTER TABLE `co_righe_documenti` CHANGE `idintervento` `idintervento` varchar(25); -ALTER TABLE `in_righe_interventi` CHANGE `idintervento` `idintervento` varchar(25); -ALTER TABLE `mg_movimenti` CHANGE `idintervento` `idintervento` varchar(25); -ALTER TABLE `mg_articoli_interventi` CHANGE `idintervento` `idintervento` varchar(25); -ALTER TABLE `my_impianti_interventi` CHANGE `idintervento` `idintervento` varchar(25); -ALTER TABLE `my_impianto_componenti` CHANGE `idintervento` `idintervento` varchar(25); -ALTER TABLE `my_componenti_interventi` CHANGE `id_intervento` `id_intervento` varchar(25); - -UPDATE `co_ordiniservizio` SET `idintervento` = NULL WHERE `idintervento` = 0 OR `idintervento` = ''; -UPDATE `co_preventivi_interventi` SET `idintervento` = NULL WHERE `idintervento` = 0 OR `idintervento` = ''; -UPDATE `co_righe_contratti` SET `idintervento` = NULL WHERE `idintervento` = 0 OR `idintervento` = ''; -UPDATE `co_righe_documenti` SET `idintervento` = NULL WHERE `idintervento` = 0 OR `idintervento` = ''; -UPDATE `in_righe_interventi` SET `idintervento` = NULL WHERE `idintervento` = 0 OR `idintervento` = ''; -UPDATE `mg_movimenti` SET `idintervento` = NULL WHERE `idintervento` = 0 OR `idintervento` = ''; -UPDATE `mg_articoli_interventi` SET `idintervento` = NULL WHERE `idintervento` = 0 OR `idintervento` = ''; -UPDATE `my_impianti_interventi` SET `idintervento` = NULL WHERE `idintervento` = 0 OR `idintervento` = ''; -UPDATE `my_impianto_componenti` SET `idintervento` = NULL WHERE `idintervento` = 0 OR `idintervento` = ''; -UPDATE `my_componenti_interventi` SET `id_intervento` = NULL WHERE `id_intervento` = 0 OR `id_intervento` = ''; - -ALTER TABLE `co_ordiniservizio` CHANGE `idintervento` `idintervento` int(11), ADD FOREIGN KEY (`idintervento`) REFERENCES `in_interventi`(`id`) ON DELETE CASCADE; -ALTER TABLE `co_preventivi_interventi` CHANGE `idintervento` `idintervento` int(11), ADD FOREIGN KEY (`idintervento`) REFERENCES `in_interventi`(`id`) ON DELETE CASCADE; -ALTER TABLE `co_righe_contratti` CHANGE `idintervento` `idintervento` int(11), ADD FOREIGN KEY (`idintervento`) REFERENCES `in_interventi`(`id`) ON DELETE CASCADE; -ALTER TABLE `co_righe_documenti` CHANGE `idintervento` `idintervento` int(11); -ALTER TABLE `in_righe_interventi` CHANGE `idintervento` `idintervento` int(11), ADD FOREIGN KEY (`idintervento`) REFERENCES `in_interventi`(`id`) ON DELETE CASCADE; -ALTER TABLE `mg_movimenti` CHANGE `idintervento` `idintervento` int(11), ADD FOREIGN KEY (`idintervento`) REFERENCES `in_interventi`(`id`) ON DELETE CASCADE; -ALTER TABLE `mg_articoli_interventi` CHANGE `idintervento` `idintervento` int(11), ADD FOREIGN KEY (`idintervento`) REFERENCES `in_interventi`(`id`) ON DELETE CASCADE; -ALTER TABLE `my_impianti_interventi` CHANGE `idintervento` `idintervento` int(11), ADD FOREIGN KEY (`idintervento`) REFERENCES `in_interventi`(`id`) ON DELETE CASCADE; -ALTER TABLE `my_impianto_componenti` CHANGE `idintervento` `idintervento` int(11), ADD FOREIGN KEY (`idintervento`) REFERENCES `in_interventi`(`id`) ON DELETE CASCADE; -ALTER TABLE `my_componenti_interventi` CHANGE `id_intervento` `id_intervento` int(11), ADD FOREIGN KEY (`id_intervento`) REFERENCES `in_interventi`(`id`) ON DELETE CASCADE; - --- Aggiunta di chiavi esterne in my_componenti_interventi -ALTER TABLE `my_componenti_interventi` CHANGE `id_componente` `id_componente` int(11) NOT NULL, ADD FOREIGN KEY (`id_componente`) REFERENCES `my_impianto_componenti`(`id`) ON DELETE CASCADE; - --- Aggiornamento dei filtri per i gruppo di utenti -UPDATE `zz_group_module` SET `clause` = ' AND in_interventi.id IN (SELECT idintervento FROM in_interventi_tecnici WHERE idintervento=in_interventi.id AND idtecnico=|idtecnico|)' WHERE `id` = 1; -UPDATE `zz_group_module` SET `clause` = ' AND an_anagrafiche.idanagrafica IN (SELECT idanagrafica FROM in_interventi_tecnici INNER JOIN in_interventi ON in_interventi_tecnici.idintervento=in_interventi.id WHERE in_interventi.idanagrafica=an_anagrafiche.idanagrafica AND idtecnico=|idtecnico|)' WHERE `id` = 2; - --- Eliminazione tabelle inutilizzate -DROP TABLE IF EXISTS `mk_allegati`; -DROP TABLE IF EXISTS `mk_attivita`; -DROP TABLE IF EXISTS `mk_email`; -DROP TABLE IF EXISTS `mk_statoattivita`; -DROP TABLE IF EXISTS `mk_tipoattivita`; -DROP TABLE IF EXISTS `dt_automezzi_tagliandi`; -DROP TABLE IF EXISTS `co_contratti_interventi`; - --- RELEASE 2.2.1 [NON UFFICIALE] -- --- Aggiunta del campo desc_iva anche per Preventivi, Ddt e Ordini -ALTER TABLE `dt_righe_ddt` ADD `desc_iva` varchar(255) NOT NULL AFTER `idiva`; -ALTER TABLE `co_righe_preventivi` ADD `desc_iva` varchar(255) NOT NULL AFTER `idiva`; -ALTER TABLE `or_righe_ordini` ADD `desc_iva` varchar(255) NOT NULL AFTER `idiva`; -ALTER TABLE `co_righe2_contratti` ADD `desc_iva` varchar(255) NOT NULL AFTER `idiva`; - --- Fix per l'ordinamento delle righe in Preventivi, Ddt e Ordini -ALTER TABLE `co_righe_preventivi` ADD `order` tinyint(11) NOT NULL AFTER `qta`; -ALTER TABLE `dt_righe_ddt` ADD `order` tinyint(11) NOT NULL AFTER `qta_evasa`; -ALTER TABLE `or_righe_ordini` ADD `order` tinyint(11) NOT NULL AFTER `qta_evasa`; -ALTER TABLE `co_righe2_contratti` ADD `order` tinyint(11) NOT NULL AFTER `qta`; -ALTER TABLE `co_righe_documenti` CHANGE `ordine` `order` int(11) NOT NULL; - --- Aggiungo idconto anche per le righe delle fatture e allineamento (copia idconto nelle righe delle fatture, solo per i conti di entrata e uscita) -ALTER TABLE `co_righe_documenti` ADD `idconto` int(11) NOT NULL AFTER `idautomezzo`; -UPDATE `co_righe_documenti` SET `idconto` = (SELECT `idconto` FROM `co_documenti` WHERE `id` = `co_righe_documenti`.`iddocumento`); - --- 2016-12-16 --- Dicitura fissa a fondo fattura -INSERT INTO `zz_settings` (`nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES ('Dicitura fissa fattura', 'Ai sensi del D.Lgs. 196/2003 Vi informiamo che i Vs. dati saranno utilizzati esclusivamente per i fini connessi ai rapporti commerciali tra di noi in essere. Contributo CONAI assolto ove dovuto - Vi preghiamo di controllare i Vs. dati anagrafici, la P. IVA e il Cod. Fiscale. Non ci riteniamo responsabili di eventuali errori.', 'textarea', '1', 'Fatturazione'); - --- 2016-12-20 --- Aggiunto peso lordo e volume (per ddt e fatture accompagnatorie) -ALTER TABLE `mg_articoli` ADD `peso_lordo` decimal(12, 4) NOT NULL AFTER `gg_garanzia`, ADD `volume` decimal(12, 4) NOT NULL AFTER `peso_lordo`; - --- 2016-02-15 --- Aggiunta sconto percentuale e unitario su fatture e righe, ddt e righe, ordini e righe, preventivi e righe, contratti e righe -ALTER TABLE `co_documenti` ADD `sconto_globale` decimal(12, 4) NOT NULL; -ALTER TABLE `co_documenti` ADD `tipo_sconto_globale` enum('UNT', 'PRC') NOT NULL DEFAULT 'UNT'; -ALTER TABLE `co_preventivi` ADD `sconto_globale` decimal(12, 4) NOT NULL; -ALTER TABLE `co_preventivi` ADD `tipo_sconto_globale` enum('UNT', 'PRC') NOT NULL DEFAULT 'UNT'; -ALTER TABLE `co_contratti` ADD `sconto_globale` decimal(12, 4) NOT NULL; -ALTER TABLE `co_contratti` ADD `tipo_sconto_globale` enum('UNT', 'PRC') NOT NULL DEFAULT 'UNT'; -ALTER TABLE `or_ordini` ADD `sconto_globale` decimal(12, 4) NOT NULL; -ALTER TABLE `or_ordini` ADD `tipo_sconto_globale` enum('UNT', 'PRC') NOT NULL DEFAULT 'UNT'; -ALTER TABLE `dt_ddt` ADD `sconto_globale` decimal(12, 4) NOT NULL; -ALTER TABLE `dt_ddt` ADD `tipo_sconto_globale` enum('UNT', 'PRC') NOT NULL DEFAULT 'UNT'; -ALTER TABLE `in_interventi` ADD `sconto_globale` decimal(12, 4) NOT NULL; -ALTER TABLE `in_interventi` ADD `tipo_sconto_globale` enum('UNT', 'PRC') NOT NULL DEFAULT 'UNT'; - -ALTER TABLE `co_righe_documenti` ADD `sconto_unitario` decimal(12, 4) NOT NULL AFTER `sconto`; -ALTER TABLE `co_righe_documenti`ADD `tipo_sconto` enum('UNT', 'PRC') NOT NULL DEFAULT 'UNT' AFTER `sconto_unitario`; -ALTER TABLE `co_righe_documenti` ADD `sconto_globale` boolean NOT NULL DEFAULT 0 AFTER `tipo_sconto`; - -ALTER TABLE `co_righe_preventivi` ADD `sconto_unitario` decimal(12, 4) NOT NULL AFTER `sconto`; -ALTER TABLE `co_righe_preventivi` ADD `tipo_sconto` enum('UNT', 'PRC') NOT NULL DEFAULT 'UNT' AFTER `sconto_unitario`; -ALTER TABLE `co_righe_preventivi` ADD `sconto_globale` boolean NOT NULL DEFAULT 0 AFTER `tipo_sconto`; - -ALTER TABLE `co_righe2_contratti` ADD `sconto_unitario` decimal(12, 4) NOT NULL AFTER `sconto`; -ALTER TABLE `co_righe2_contratti` ADD `tipo_sconto` enum('UNT', 'PRC') NOT NULL DEFAULT 'UNT' AFTER `sconto_unitario`; -ALTER TABLE `co_righe2_contratti` ADD `sconto_globale` boolean NOT NULL DEFAULT 0 AFTER `tipo_sconto`; - -ALTER TABLE `or_righe_ordini` ADD `sconto_unitario` decimal(12, 4) NOT NULL AFTER `sconto`; -ALTER TABLE `or_righe_ordini` ADD `tipo_sconto` enum('UNT', 'PRC') NOT NULL DEFAULT 'UNT' AFTER `sconto_unitario`; -ALTER TABLE `or_righe_ordini` ADD `sconto_globale` boolean NOT NULL DEFAULT 0 AFTER `tipo_sconto`; - -ALTER TABLE `dt_righe_ddt` ADD `sconto_unitario` decimal(12, 4) NOT NULL AFTER `sconto`; -ALTER TABLE `dt_righe_ddt` ADD `tipo_sconto` enum('UNT', 'PRC') NOT NULL DEFAULT 'UNT' AFTER `sconto_unitario`; -ALTER TABLE `dt_righe_ddt` ADD `sconto_globale` boolean NOT NULL DEFAULT 0 AFTER `tipo_sconto`; - - -ALTER TABLE `in_righe_interventi` ADD `sconto` decimal(12, 4) NOT NULL, ADD `sconto_unitario` decimal(12, 4) NOT NULL AFTER `sconto`, ADD `tipo_sconto` enum('UNT', 'PRC') NOT NULL DEFAULT 'UNT' AFTER `sconto_unitario`; -ALTER TABLE `mg_articoli_interventi` ADD `sconto_unitario` decimal(12, 4) NOT NULL AFTER `sconto`, ADD `tipo_sconto` enum('UNT', 'PRC') NOT NULL DEFAULT 'UNT' AFTER `sconto_unitario`; -ALTER TABLE `in_interventi_tecnici` - ADD `sconto` decimal(12, 4) NOT NULL, ADD `sconto_unitario` decimal(12, 4) NOT NULL AFTER `sconto`, ADD `tipo_sconto` enum('UNT', 'PRC') NOT NULL DEFAULT 'UNT' AFTER `sconto_unitario`, - ADD `scontokm` decimal(12, 4) NOT NULL AFTER `tipo_sconto`, ADD `scontokm_unitario` decimal(12, 4) NOT NULL AFTER `scontokm`, ADD `tipo_scontokm` enum('UNT', 'PRC') NOT NULL DEFAULT 'UNT' AFTER `scontokm_unitario`; - --- Inizializzo a vuoto il valore per le impostazioni Percentuale ritenuta d'acconto e Percentuale rivalsa INPS -UPDATE `zz_settings` SET `valore` = '' WHERE `zz_settings`.`nome` = "Percentuale ritenuta d'acconto"; -UPDATE `zz_settings` SET `valore` = '' WHERE `zz_settings`.`nome` = "Percentuale rivalsa INPS"; - --- Aggiornamento widget credito clienti e debito fornitori leggendo da scadenzario per includere anche il parzialmente pagato -UPDATE `zz_widgets` SET `query` = 'SELECT CONCAT_WS(" ", REPLACE(REPLACE(REPLACE(FORMAT((SELECT ABS(SUM(da_pagare-pagato))), 2), ",", "#"), ".", ","), "#", "."), "€") AS dato FROM (co_scadenziario INNER JOIN co_documenti ON co_scadenziario.iddocumento=co_documenti.id) INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE dir=''entrata'' AND data_emissione >= "|period_start|" AND data_emissione <= "|period_end|"' WHERE `zz_widgets`.`name` = 'Crediti da clienti'; -UPDATE `zz_widgets` SET `query` = 'SELECT CONCAT_WS(" ", REPLACE(REPLACE(REPLACE(FORMAT((SELECT ABS(SUM(da_pagare-pagato))), 2), ",", "#"), ".", ","), "#", "."), "€") AS dato FROM (co_scadenziario INNER JOIN co_documenti ON co_scadenziario.iddocumento=co_documenti.id) INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE dir=''uscita'' AND data_emissione >= "|period_start|" AND data_emissione <= "|period_end|"' WHERE `zz_widgets`.`name` = 'Debiti verso fornitori'; - --- Aggiornamento widget fatturato e acquisti leggendo da scadenzario per includere solo le fatture emesse -UPDATE `zz_widgets` SET `query` = 'SELECT CONCAT_WS(" ", REPLACE(REPLACE(REPLACE(FORMAT((SELECT ABS(SUM(da_pagare))), 2), ",", "#"), ".", ","), "#", "."), "€") AS dato FROM (co_scadenziario INNER JOIN co_documenti ON co_scadenziario.iddocumento=co_documenti.id) INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE dir=''entrata'' AND data_emissione >= "|period_start|" AND data_emissione <= "|period_end|"' WHERE `zz_widgets`.`name` = 'Fatturato'; -UPDATE `zz_widgets` SET `query` = 'SELECT CONCAT_WS(" ", REPLACE(REPLACE(REPLACE(FORMAT((SELECT ABS(SUM(da_pagare))), 2), ",", "#"), ".", ","), "#", "."), "€") AS dato FROM (co_scadenziario INNER JOIN co_documenti ON co_scadenziario.iddocumento=co_documenti.id) INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE dir=''uscita'' AND data_emissione >= "|period_start|" AND data_emissione <= "|period_end|"' WHERE `zz_widgets`.`name` = 'Acquisti'; - --- RELEASE 2.3 -- --- Aggiunta tabelle nascoste per l'API -INSERT INTO `zz_settings` (`nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES -('Tabelle escluse per la sincronizzazione API automatica', 'zz_users,zz_permissions,zz_semaphores,zz_tokens,updates', 'string', '0', 'API'), -('Lunghezza pagine per API', '200', 'integer', '0', 'API'); - --- --- Struttura della tabella `zz_views` --- - -CREATE TABLE IF NOT EXISTS `zz_views` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_module` int(11) NOT NULL, - `name` varchar(255) NOT NULL, - `query` text DEFAULT NULL, - `order` tinyint(11) NOT NULL, - `search` tinyint(1) NOT NULL DEFAULT '1', - `slow` tinyint(1) NOT NULL DEFAULT '0', - `search_inside` varchar(255) DEFAULT NULL, - `order_by` varchar(255) DEFAULT NULL, - `enabled` tinyint(1) NOT NULL DEFAULT '1', - `summable` tinyint(1) NOT NULL DEFAULT '0', - `default` int(11) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`), - FOREIGN KEY (`id_module`) REFERENCES `zz_modules`(`id`) ON DELETE CASCADE -) ENGINE=InnoDB; - --- --- Dump dei dati per la tabella `zz_views` --- - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `enabled`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Anagrafiche'), 'id', 'an_anagrafiche.idanagrafica', 1, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Anagrafiche'), 'Ragione sociale', 'ragione_sociale', 2, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Anagrafiche'), 'Tipologia', 'GROUP_CONCAT(an_tipianagrafiche.descrizione SEPARATOR '', '')', 3, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Anagrafiche'), 'Città', 'citta', 4, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Anagrafiche'), 'Telefono', 'telefono', 5, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Anagrafiche'), 'color_Rel.', 'an_relazioni.colore', 6, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Anagrafiche'), 'color_title_Rel.', 'an_relazioni.descrizione', 7, 1, 0, 0, 1); - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `enabled`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), 'id', 'in_interventi.id', 1, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), 'Numero', 'in_interventi.codice', 2, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), 'Ragione sociale', 'ragione_sociale', 3, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), 'Data inizio', 'MIN(orario_inizio)', 4, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), 'Data fine', 'MAX(orario_fine)', 5, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), '_bg_', '(SELECT colore FROM in_statiintervento WHERE idstatointervento=in_interventi.idstatointervento)', 6, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), 'Stato', '(SELECT descrizione FROM in_statiintervento WHERE idstatointervento=in_interventi.idstatointervento)', 7, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), 'Tipo', '(SELECT descrizione FROM in_tipiintervento WHERE idtipointervento=in_interventi.idtipointervento)', 8, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), '_print_', '''pdfgen.php?ptype=interventi&idintervento=$id$&mode=single''', 9, 0, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), 'idanagrafica', 'in_interventi.idanagrafica', 10, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), 'orario_inizio', 'orario_inizio', 11, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), 'data_richiesta', 'data_richiesta', 12, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), 'orario_fine', 'orario_fine', 13, 1, 0, 0, 1); - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `enabled`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi di anagrafiche'), 'id', 'idtipoanagrafica', 1, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi di anagrafiche'), 'Descrizione', 'descrizione', 2, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi di intervento'), 'id', 'idtipointervento', 1, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi di intervento'), 'Codice', 'idtipointervento', 2, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi di intervento'), 'Descrizione', 'descrizione', 3, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi di intervento'), 'Costo orario', 'costo_orario', 4, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi di intervento'), 'Costo al km', 'costo_km', 5, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi di intervento'), 'Diritto di chiamata', 'costo_diritto_chiamata', 6, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi di intervento'), 'Costo orario tecnico', 'costo_orario_tecnico', 7, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi di intervento'), 'Costo al km tecnico', 'costo_km_tecnico', 8, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi di intervento'), 'Diritto di chiamata tecnico', 'costo_diritto_chiamata_tecnico', 9, 1, 0, 1, 1); - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `enabled`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stati di intervento'), 'id', 'idstatointervento', 1, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stati di intervento'), 'Codice', 'idstatointervento', 2, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stati di intervento'), 'Descrizione', 'descrizione', 3, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stati di intervento'), 'color_Colore', 'colore', 4, 1, 0, 1, 1); - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `enabled`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi'), 'id', 'id', 1, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi'), 'Numero', 'numero', 2, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi'), 'Nome', 'nome', 3, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi'), 'Cliente', '(SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=co_preventivi.idanagrafica)', 4, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi'), 'icon_Stato', '(SELECT icona FROM co_statipreventivi WHERE id=idstato)', 5, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi'), 'icon_title_Stato', '(SELECT descrizione FROM co_statipreventivi WHERE id=idstato)', 6, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi'), 'data_bozza', 'data_bozza', 7, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi'), 'data_conclusione', 'data_conclusione', 8, 1, 0, 0, 1); - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `enabled`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'), 'id', 'co_documenti.id', 1, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'), 'Numero', 'IF(numero_esterno='''', numero, numero_esterno)', 2, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'), 'Data', 'data', 3, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'), 'Ragione sociale', '(SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=co_documenti.idanagrafica)', 4, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'), 'Totale', '(SELECT SUM(subtotale - sconto + iva + rivalsainps - ritenutaacconto) FROM co_righe_documenti WHERE co_righe_documenti.iddocumento=co_documenti.id GROUP BY iddocumento) + bollo + iva_rivalsainps', 5, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'), 'icon_Stato', '(SELECT icona FROM co_statidocumento WHERE id=idstatodocumento)', 6, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'), 'icon_title_Stato', '(SELECT descrizione FROM co_statidocumento WHERE id=idstatodocumento)', 7, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'), 'dir', 'dir', 9, 1, 0, 0, 1); - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `enabled`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di acquisto'), 'id', 'co_documenti.id', 1, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di acquisto'), 'Numero', 'IF(numero_esterno='''', numero, numero_esterno)', 2, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di acquisto'), 'Data', 'data', 3, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di acquisto'), 'Ragione sociale', '(SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=co_documenti.idanagrafica)', 4, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di acquisto'), 'Totale', '(SELECT SUM(subtotale - sconto + iva + rivalsainps - ritenutaacconto) FROM co_righe_documenti WHERE co_righe_documenti.iddocumento=co_documenti.id GROUP BY iddocumento ) + bollo + iva_rivalsainps', 5, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di acquisto'), 'icon_Stato', '(SELECT icona FROM co_statidocumento WHERE id=idstatodocumento)', 6, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di acquisto'), 'icon_title_Stato', '(SELECT descrizione FROM co_statidocumento WHERE id=idstatodocumento)', 7, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di acquisto'), 'dir', 'dir', 9, 1, 0, 0, 1); - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `enabled`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Prima nota'), 'id', 'co_movimenti.id', 1, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Prima nota'), 'Data', 'data', 2, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Prima nota'), 'Causale', 'co_movimenti.descrizione', 3, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Prima nota'), 'Controparte', '(SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica= (SELECT idanagrafica FROM co_documenti WHERE id=iddocumento))', 4, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Prima nota'), 'Conto avere', 'GROUP_CONCAT(CASE WHEN totale>0 THEN co_pianodeiconti3.descrizione ELSE NULL END)', 5, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Prima nota'), 'Dare', 'SUM(IF(totale > 0, ABS(totale), 0))', 6, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Prima nota'), 'Avere', 'SUM(IF(totale < 0, ABS(totale), 0))', 7, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Prima nota'), 'Conto dare', 'GROUP_CONCAT(CASE WHEN totale<0 THEN co_pianodeiconti3.descrizione ELSE NULL END)', 8, 1, 0, 1, 1); - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `enabled`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Scadenzario'), 'id', 'co_scadenziario.id', 1, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Scadenzario'), 'Anagrafica', 'ragione_sociale', 2, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Scadenzario'), 'Tipo di pagamento', 'co_pagamenti.descrizione', 3, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Scadenzario'), 'Data emissione', 'CONCAT(co_tipidocumento.descrizione, CONCAT('' numero '', IF(numero_esterno<>'''', numero_esterno, numero)))', 4, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Scadenzario'), 'Data scadenza', 'scadenza', 5, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Scadenzario'), 'Importo', 'da_pagare', 6, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Scadenzario'), 'Pagato', 'pagato', 7, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Scadenzario'), '_bg_', 'IF(scadenza= `data_bozza` AND ''|period_start|'' <= `data_conclusione`) OR (''|period_end|'' >= `data_bozza` AND ''|period_end|'' <= `data_conclusione`) OR (`data_bozza` >= ''|period_start|'' AND `data_bozza` <= ''|period_end|'') OR (`data_conclusione` >= ''|period_start|'' AND `data_conclusione` <= ''|period_end|'') OR (`data_bozza` >= ''|period_start|'' AND `data_conclusione` = ''0000-00-00'')) ORDER BY `id` DESC' WHERE `name` = 'Contratti'; -UPDATE `zz_modules` SET `options` = 'custom' WHERE `name` = 'Dashboard'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `dt_ddt` INNER JOIN `dt_tipiddt` ON `dt_ddt`.`idtipoddt` = `dt_tipiddt`.`id` WHERE 1=1 AND `dir` = ''uscita'' AND `data` >= ''|period_start|'' AND `data` <= ''|period_end|'' HAVING 2=2 ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC' WHERE `name` = 'Ddt di acquisto'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `dt_ddt` INNER JOIN `dt_tipiddt` ON `dt_ddt`.`idtipoddt` = `dt_tipiddt`.`id` WHERE 1=1 AND `dir` = ''entrata'' AND `data` >= ''|period_start|'' AND `data` <= ''|period_end|'' HAVING 2=2 ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC' WHERE `name` = 'Ddt di vendita'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_documenti` INNER JOIN `co_tipidocumento` ON `co_documenti`.`idtipodocumento` = `co_tipidocumento`.`id` WHERE 1=1 AND `dir` = ''uscita'' AND `data` >= ''|period_start|'' AND `data` <= ''|period_end|'' HAVING 2=2 ORDER BY `data` DESC, CAST(IF(numero_esterno='''', numero, numero_esterno) AS UNSIGNED) DESC' WHERE `name` = 'Fatture di acquisto'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_documenti` INNER JOIN `co_tipidocumento` ON `co_documenti`.`idtipodocumento` = `co_tipidocumento`.`id` WHERE 1=1 AND `dir` = ''entrata'' AND `data` >= ''|period_start|'' AND `data` <= ''|period_end|'' HAVING 2=2 ORDER BY `data` DESC, CAST(numero_esterno AS UNSIGNED) DESC' WHERE `name` = 'Fatture di vendita'; -UPDATE `zz_modules` SET `options` = 'custom' WHERE `name` = 'Gestione componenti'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM (`in_interventi` INNER JOIN `an_anagrafiche` ON `in_interventi`.`idanagrafica` = `an_anagrafiche`.`idanagrafica`) LEFT OUTER JOIN `in_interventi_tecnici` ON `in_interventi_tecnici`.`idintervento` = `in_interventi`.`id` WHERE 1=1 GROUP BY `in_interventi`.`id` HAVING 2=2 AND ((`orario_inizio` >= ''|period_start|'' AND `orario_fine` <= ''|period_end|'') OR (`data_richiesta` >= ''|period_start|'' AND `data_richiesta` <= ''|period_end|'')) ORDER BY IFNULL(`orario_fine`, `data_richiesta`) DESC' WHERE `name` = 'Interventi'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `mg_listini` WHERE 1=1 HAVING 2=2 ORDER BY `nome`' WHERE `name` = 'Listini'; -UPDATE `zz_modules` SET `options` = '' WHERE `name` = 'Magazzino'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `my_impianti` WHERE 1=1 HAVING 2=2 ORDER BY `matricola`' WHERE `name` = 'MyImpianti'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `or_ordini` INNER JOIN `or_tipiordine` ON `or_ordini`.`idtipoordine` = `or_tipiordine`.`id` WHERE 1=1 AND `dir` = ''entrata'' AND `data` >= ''|period_start|'' AND `data` <= ''|period_end|'' HAVING 2=2 ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC' WHERE `name` = 'Ordini cliente'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `or_ordini` INNER JOIN `or_tipiordine` ON `or_ordini`.`idtipoordine` = `or_tipiordine`.`id` WHERE 1=1 AND `dir` = ''uscita'' AND `data` >= ''|period_start|'' AND `data` <= ''|period_end|'' HAVING 2=2 ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC' WHERE `name` = 'Ordini fornitore'; -UPDATE `zz_modules` SET `options` = 'custom' WHERE `name` = 'Piano dei conti'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_preventivi` WHERE 1=1 HAVING 2=2 AND ((''|period_start|'' >= `data_bozza` AND ''|period_start|'' <= `data_conclusione`) OR (''|period_end|'' >= `data_bozza` AND ''|period_end|'' <= `data_conclusione`) OR (`data_bozza` >= ''|period_start|'' AND `data_bozza` <= ''|period_end|'') OR (`data_conclusione` >= ''|period_start|'' AND `data_conclusione` <= ''|period_end|'') OR (`data_bozza` >= ''|period_start|'' AND `data_conclusione` = ''0000-00-00'')) ORDER BY `id` DESC' WHERE `name` = 'Preventivi'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_movimenti` INNER JOIN `co_pianodeiconti3` ON `co_movimenti`.`idconto` = `co_pianodeiconti3`.`id` WHERE 1=1 GROUP BY `idmastrino`, `primanota`, `co_movimenti`.`data` HAVING 2=2 AND `primanota` = 1 AND `co_movimenti`.`data`>=''|period_start|'' AND `co_movimenti`.`data`<=''|period_end|'' ORDER BY `co_movimenti`.`data` DESC' WHERE `name` = 'Prima nota'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM (`co_scadenziario` INNER JOIN (((`co_documenti` INNER JOIN `an_anagrafiche` ON `co_documenti`.`idanagrafica` = `an_anagrafiche`.`idanagrafica`) INNER JOIN `co_pagamenti` ON `co_documenti`.`idpagamento` = `co_pagamenti`.`id`) INNER JOIN `co_tipidocumento` ON `co_documenti`.`idtipodocumento` = `co_tipidocumento`.`id`) ON `co_scadenziario`.`iddocumento` = `co_documenti`.`id`) INNER JOIN `co_statidocumento` ON `co_documenti`.`idstatodocumento` = `co_statidocumento`.`id` WHERE 1=1 HAVING 2=2 AND (ABS(`pagato_reale`) < ABS(`da_pagare`) AND `co_statidocumento`.`descrizione` IN(''Emessa'',''Parzialmente pagato'')) ORDER BY `scadenza` ASC' WHERE `name` = 'Scadenzario'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `in_statiintervento` WHERE 1=1 HAVING 2=2' WHERE `name` = 'Stati di intervento'; -UPDATE `zz_modules` SET `options` = 'custom' WHERE `name` = 'Tecnici e tariffe'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `an_tipianagrafiche` WHERE 1=1 HAVING 2=2' WHERE `name` = 'Tipi di anagrafiche'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `in_tipiintervento` WHERE 1=1 HAVING 2=2' WHERE `name` = 'Tipi di intervento'; -UPDATE `zz_modules` SET `options` = '' WHERE `name` = 'Vendite'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `in_vociservizio` WHERE 1=1 HAVING 2=2 ORDER BY `categoria`, `descrizione`' WHERE `name` = 'Voci di servizio'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `an_zone` WHERE 1=1 HAVING 2=2 ORDER BY `id`' WHERE `name` = 'Zone'; - --- Aggiunta di un reset nel caso di elemento già selezionato nei filtri di Anagrafiche -UPDATE `zz_widgets` SET `more_link` = 'if($(''#th_Tipologia input'').val()!= ''Cliente''){ $(''#th_Tipologia input'').val(''Cliente'').trigger(''keyup'');} else reset(''Tipologia'');' WHERE `zz_widgets`.`name` = 'Numero di clienti'; -UPDATE `zz_widgets` SET `more_link` = 'if($(''#th_Tipologia input'').val()!= ''Tecnico''){ $(''#th_Tipologia input'').val(''Tecnico'').trigger(''keyup'');} else reset(''Tipologia'');' WHERE `zz_widgets`.`name` = 'Numero di tecnici'; -UPDATE `zz_widgets` SET `more_link` = 'if($(''#th_Tipologia input'').val()!= ''Fornitore''){ $(''#th_Tipologia input'').val(''Fornitore'').trigger(''keyup'');} else reset(''Tipologia'');' WHERE `zz_widgets`.`name` = 'Numero di fornitori'; -UPDATE `zz_widgets` SET `more_link` = 'if($(''#th_Tipologia input'').val()!= ''Agente''){$(''#th_Tipologia input'').val(''Agente'').trigger(''keyup'');} else reset(''Tipologia'');' WHERE `zz_widgets`.`name` = 'Numero di agenti'; -UPDATE `zz_widgets` SET `more_link` = 'if($(''#th_Tipologia input'').val()!= ''Vettore''){$(''#th_Tipologia input'').val(''Vettore'').trigger(''keyup'');} else reset(''Tipologia'');' WHERE `zz_widgets`.`name` = 'Numero di vettori'; -UPDATE `zz_widgets` SET `more_link` = 'reset(''Tipologia'');' WHERE `zz_widgets`.`name` = 'Tutte le anagrafiche'; - --- Aggiunta di campi per le sessioni avanzate e il timeout relativo in editor.php -INSERT INTO `zz_settings` (`nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES ('Attiva notifica di presenza utenti sul record', '1', 'boolean', 1, 'Generali'); -INSERT INTO `zz_settings` (`nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES ('Timeout notifica di presenza (minuti)', '15', 'integer', 1, 'Generali'); - --- Aggiunta tabella per le sessioni avanazate -CREATE TABLE IF NOT EXISTS `zz_semaphores` ( - `id_utente` int(11) NOT NULL, - `posizione` varchar(255) NOT NULL, - `updated` datetime -) ENGINE=InnoDB; - --- Aggiornamento zz_modules -INSERT INTO `zz_modules` (`id`, `name`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `level`, `parent`, `default`, `enabled`) VALUES (NULL, 'Strumenti', '', '', '', 'fa fa-cog', '2.3', '2.3', '1', '0', 0, '1', '1'); - -ALTER TABLE `zz_modules` DROP `level`; - -UPDATE `zz_modules` SET `options` = 'menu' WHERE `options` = ''; - -INSERT INTO `zz_modules` (`id`, `name`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Viste', 'viste', 'SELECT |select| FROM `zz_modules` WHERE 1=1 HAVING 2=2 ORDER BY `name`, `title` ASC', '', 'fa fa-eye', '2.3', '2.3', '1', 1, '1', '0'); - -INSERT INTO `zz_modules` (`id`, `name`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Utenti e permessi', 'utenti', 'SELECT |select| FROM `zz_groups` WHERE 1=1 HAVING 2=2 ORDER BY `id`, `nome` ASC', '', 'fa fa-lock', '2.3', '2.3', '1', 1, '1', '1'); - -INSERT INTO `zz_modules` (`id`, `name`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Impostazioni', 'impostazioni', 'SELECT |select| FROM `zz_settings` WHERE 1=1 AND `editable` = 1 GROUP BY `sezione` HAVING 2=2 ORDER BY `sezione`', '', 'fa fa-th-list', '2.3', '2.3', '1', 1, '1', '1'); - -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Viste' AND `t2`.`name` = 'Strumenti') SET `t1`.`parent` = `t2`.`id`; -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Utenti e permessi' AND `t2`.`name` = 'Strumenti') SET `t1`.`parent` = `t2`.`id`; -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Impostazioni' AND `t2`.`name` = 'Strumenti') SET `t1`.`parent` = `t2`.`id`; -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Aggiornamenti' AND `t2`.`name` = 'Strumenti') SET `t1`.`parent` = `t2`.`id`; -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Backup' AND `t2`.`name` = 'Strumenti') SET `t1`.`parent` = `t2`.`id`; - -UPDATE `zz_settings` SET `tipo` = 'query=SELECT `an_anagrafiche`.`idanagrafica` AS ''id'', `ragione_sociale` AS ''descrizione'' FROM `an_anagrafiche` INNER JOIN `an_tipianagrafiche_anagrafiche` ON `an_anagrafiche`.`idanagrafica` = `an_tipianagrafiche_anagrafiche`.`idanagrafica` WHERE `idtipoanagrafica` = (SELECT `idtipoanagrafica` FROM `an_tipianagrafiche` WHERE `descrizione` = ''Azienda'') AND deleted=0' WHERE `zz_settings`.`nome` = 'Azienda predefinita'; - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `enabled`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Impostazioni'), 'Nome', 'sezione', 2, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Impostazioni'), 'id', 'idimpostazione', 1, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Utenti e permessi'), 'id', 'id', 2, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Utenti e permessi'), 'Gruppo', 'nome', 1, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Viste'), 'Numero', 'id', 1, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Viste'), 'Icona', 'icon', 4, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Viste'), 'Nome', 'title', 3, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Viste'), 'id', 'id', 2, 1, 0, 0, 1); - -INSERT INTO `zz_group_view` (`id_gruppo`, `id_vista`) VALUES -((SELECT `id` FROM `zz_groups` WHERE `nome` = 'Amministratori'), (SELECT `id` FROM `zz_views` WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Impostazioni') AND `name` = 'Nome')), -((SELECT `id` FROM `zz_groups` WHERE `nome` = 'Amministratori'), (SELECT `id` FROM `zz_views` WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Impostazioni') AND `name` = 'id')), -((SELECT `id` FROM `zz_groups` WHERE `nome` = 'Amministratori'), (SELECT `id` FROM `zz_views` WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Utenti e permessi') AND `name` = 'id')), -((SELECT `id` FROM `zz_groups` WHERE `nome` = 'Amministratori'), (SELECT `id` FROM `zz_views` WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Utenti e permessi') AND `name` = 'Gruppo')), -((SELECT `id` FROM `zz_groups` WHERE `nome` = 'Amministratori'), (SELECT `id` FROM `zz_views` WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Viste') AND `name` = 'Numero')), -((SELECT `id` FROM `zz_groups` WHERE `nome` = 'Amministratori'), (SELECT `id` FROM `zz_views` WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Viste') AND `name` = 'Icona')), -((SELECT `id` FROM `zz_groups` WHERE `nome` = 'Amministratori'), (SELECT `id` FROM `zz_views` WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Viste') AND `name` = 'Nome')), -((SELECT `id` FROM `zz_groups` WHERE `nome` = 'Amministratori'), (SELECT `id` FROM `zz_views` WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Viste') AND `name` = 'id')); - --- Eliminazione impostazioni inutilizzata -DELETE FROM `zz_settings` WHERE `zz_settings`.`nome` = 'Usa tabelle avanzate'; -DELETE FROM `zz_settings` WHERE `zz_settings`.`nome` = 'Righe per pagina'; -DELETE FROM `zz_settings` WHERE `zz_settings`.`nome` = 'Formato report'; - --- Aggiunta tabelle per la gestione dei campi "minori"" -INSERT INTO `zz_modules` (`id`, `name`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Tabelle', '', '', '', 'fa fa-table', '2.3', '2.3', '1', 1, '1', '1'); -INSERT INTO `zz_modules` (`id`, `name`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'IVA', 'iva', 'SELECT |select| FROM `co_iva` WHERE 1=1 HAVING 2=2', '', 'fa fa-percent', '2.3', '2.3', '1', 1, '1', '1'); -INSERT INTO `zz_modules` (`id`, `name`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Causali', 'causali', 'SELECT |select| FROM `dt_causalet` WHERE 1=1 HAVING 2=2', '', 'fa fa-commenting-o', '2.3', '2.3', '1', 1, '1', '1'); -INSERT INTO `zz_modules` (`id`, `name`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Aspetto beni', 'beni', 'SELECT |select| FROM `dt_aspettobeni` WHERE 1=1 HAVING 2=2', '', 'fa fa-external-link', '2.3', '2.3', '1', 1, '1', '1'); -INSERT INTO `zz_modules` (`id`, `name`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Unità di misura', 'misure', 'SELECT |select| FROM `mg_unitamisura` WHERE 1=1 HAVING 2=2', '', 'fa fa-external-link', '2.3', '2.3', '1', 1, '1', '1'); -INSERT INTO `zz_modules` (`id`, `name`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Porto', 'porti', 'SELECT |select| FROM `dt_porto` WHERE 1=1 HAVING 2=2', '', 'fa fa-external-link', '2.3', '2.3', '1', 1, '1', '1'); -INSERT INTO `zz_modules` (`id`, `name`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Pagamenti', 'pagamenti', 'SELECT |select| FROM `co_pagamenti` WHERE 1=1 GROUP BY `descrizione` HAVING 2=2', '', 'fa fa-usd', '2.3', '2.3', '1', 1, '1', '1'); - -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Tabelle' AND `t2`.`name` = 'Strumenti') SET `t1`.`parent` = `t2`.`id`; -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'IVA' AND `t2`.`name` = 'Tabelle') SET `t1`.`parent` = `t2`.`id`; -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Causali' AND `t2`.`name` = 'Tabelle') SET `t1`.`parent` = `t2`.`id`; -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Aspetto beni' AND `t2`.`name` = 'Tabelle') SET `t1`.`parent` = `t2`.`id`; -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Unità di misura' AND `t2`.`name` = 'Tabelle') SET `t1`.`parent` = `t2`.`id`; -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Porto' AND `t2`.`name` = 'Tabelle') SET `t1`.`parent` = `t2`.`id`; -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Pagamenti' AND `t2`.`name` = 'Tabelle') SET `t1`.`parent` = `t2`.`id`; - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `enabled`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Pagamenti'), 'id', 'id', 3, 1, 0, 0, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Pagamenti'), 'Rate', 'COUNT(descrizione)', 2, 1, 0, 1, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Pagamenti'), 'Descrizione', 'descrizione', 1, 1, 0, 1, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Porto'), 'Descrizione', 'descrizione', 2, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Porto'), 'id', 'id', 1, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Unità di misura'), 'Valore', 'valore', 2, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Unità di misura'), 'id', 'id', 1, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Aspetto beni'), 'Descrizione', 'descrizione', 2, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Aspetto beni'), 'id', 'id', 1, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Causali'), 'Descrizione', 'descrizione', 2, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Causali'), 'id', 'id', 1, 1, 0, 0, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'IVA'), 'Indetraibile', 'indetraibile', 4, 1, 0, 1, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'IVA'), 'Percentuale', 'percentuale', 3, 1, 0, 1, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'IVA'), 'Descrizione', 'descrizione', 2, 1, 0, 1, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'IVA'), 'id', 'id', 1, 1, 0, 0, 0); - --- Modifica di an_anagrafiche per sostituire le nazioni con i corrispettivi nella tabella apposita -ALTER TABLE `an_anagrafiche` ADD `id_nazione` int(11) AFTER `nazione`, ADD FOREIGN KEY (`id_nazione`) REFERENCES `an_nazioni`(`id`); -UPDATE `an_anagrafiche` SET `id_nazione` = (SELECT `id` FROM `an_nazioni` WHERE `nome` = `nazione`); -ALTER TABLE `an_anagrafiche` DROP COLUMN `nazione`; - --- Aggiunta della colonna id negli impianti, e relative modifiche alle altre tabelle -ALTER TABLE `my_impianti` DROP PRIMARY KEY, ADD `id` int(11) PRIMARY KEY AUTO_INCREMENT FIRST; - -ALTER TABLE `co_ordiniservizio` ADD `idimpianto` int(11); -UPDATE `co_ordiniservizio` SET `idimpianto` = (SELECT `id` FROM `my_impianti` WHERE `my_impianti`.`matricola` = `co_ordiniservizio`.`matricola`); -ALTER TABLE `co_ordiniservizio` DROP COLUMN `matricola`, ADD FOREIGN KEY (`idimpianto`) REFERENCES `my_impianti`(`id`) ON DELETE CASCADE; - -ALTER TABLE `mg_articoli_interventi` ADD `idimpianto` int(11); -UPDATE `mg_articoli_interventi` SET `idimpianto` = (SELECT `id` FROM `my_impianti` WHERE `my_impianti`.`matricola` = `mg_articoli_interventi`.`matricola`); -ALTER TABLE `mg_articoli_interventi` DROP COLUMN `matricola`, ADD FOREIGN KEY (`idimpianto`) REFERENCES `my_impianti`(`id`) ON DELETE CASCADE; - -ALTER TABLE `my_impianto_componenti` ADD `idimpianto` int(11); -UPDATE `my_impianto_componenti` SET `idimpianto` = (SELECT `id` FROM `my_impianti` WHERE `my_impianti`.`matricola` = `my_impianto_componenti`.`matricola`); -ALTER TABLE `my_impianto_componenti` DROP COLUMN `matricola`, ADD FOREIGN KEY (`idimpianto`) REFERENCES `my_impianti`(`id`) ON DELETE CASCADE; - -ALTER TABLE `my_impianti_interventi` ADD `idimpianto` int(11); -UPDATE `my_impianti_interventi` SET `idimpianto` = (SELECT `id` FROM `my_impianti` WHERE `my_impianti`.`matricola` = `my_impianti_interventi`.`matricola`); -DELETE FROM `my_impianti_interventi` WHERE `idimpianto` IS NULL; -ALTER TABLE `my_impianti_interventi` DROP COLUMN `matricola`, ADD FOREIGN KEY (`idimpianto`) REFERENCES `my_impianti`(`id`) ON DELETE CASCADE; - -ALTER TABLE `my_impianti_contratti` ADD `idimpianto` int(11), ADD FOREIGN KEY (`idimpianto`) REFERENCES `my_impianti`(`id`) ON DELETE CASCADE; -UPDATE `my_impianti_contratti` SET `idimpianto` = (SELECT `id` FROM `my_impianti` WHERE `my_impianti`.`matricola` = `my_impianti_contratti`.`matricola`); -ALTER TABLE `my_impianti_contratti` DROP COLUMN `matricola`; - --- Adattamento di co_pagamenti e co_movimenti -ALTER TABLE `co_pagamenti` CHANGE `num_giorni` `num_giorni` int(11) NOT NULL; -ALTER TABLE `co_movimenti` CHANGE `iddocumento` `iddocumento` int(11) NOT NULL; - --- Aggiornamento plugins di anagrafiche -UPDATE `zz_plugins` SET `script` = 'referenti.php' WHERE `zz_plugins`.`name` = 'Referenti'; -UPDATE `zz_plugins` SET `script` = 'sedi.php' WHERE `zz_plugins`.`name` = 'Sedi'; - --- Aggiornamento dei vari campi per le Viste -UPDATE `zz_views` SET `order_by` = 'data' WHERE -(`name` = 'Data' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita')) OR -(`name` = 'Data' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di acquisto')) OR -(`name` = 'Data' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Prima nota')) OR -(`name` = 'Data' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ddt di acquisto')) OR -(`name` = 'Data' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'MyImpianti')) OR -(`name` = 'Data' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ordini cliente')) OR -(`name` = 'Data' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ddt di vendita')); - -UPDATE `zz_views` SET `order_by` = 'scadenza' WHERE (`name` = 'Data scadenza' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Scadenzario')); - -UPDATE `zz_views` SET `order_by` = 'orario_fine' WHERE (`name` = 'Orario fine' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi')); -UPDATE `zz_views` SET `order_by` = 'orario_inizio' WHERE (`name` = 'Orario inizio' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi')); - -UPDATE `zz_views` SET `search_inside` = 'color_title_Rel' WHERE (`name` = 'color_Rel.' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Anagrafiche')); - -UPDATE `zz_views` SET `search` = '0' WHERE `name` = '_print_'; - --- Aggiornamento icona di default per i moduli senza icona specifica -UPDATE `zz_modules` SET `icon`='fa fa-angle-right' WHERE `icon`='fa fa-external-link'; - --- Aggiunta di tabella e modulo per categorie -CREATE TABLE IF NOT EXISTS `mg_categorie` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `nome` varchar(255) NOT NULL, - `colore` varchar(255) NOT NULL, - `nota` varchar(1000) NOT NULL, - `parent` int(11), - PRIMARY KEY (`id`), - FOREIGN KEY (`parent`) REFERENCES `mg_categorie`(`id`) ON DELETE CASCADE -) ENGINE=InnoDB; - -INSERT INTO `mg_categorie` (`nome`) SELECT `categoria` FROM `mg_articoli` GROUP BY `categoria`; -INSERT INTO `mg_categorie` (`nome`, `parent`) SELECT `subcategoria`, `mg_categorie`.`id` FROM `mg_articoli` INNER JOIN `mg_categorie` ON `mg_categorie`.`nome` = `mg_articoli`.`categoria` GROUP BY `categoria`,`subcategoria`; -ALTER TABLE `mg_articoli` ADD `id_categoria` int(11) NOT NULL, ADD `id_sottocategoria` int(11) NOT NULL; -UPDATE `mg_articoli` JOIN `mg_categorie` ON `mg_articoli`.`categoria` = `mg_categorie`.`nome` AND `mg_categorie`.`parent` IS NULL SET `mg_articoli`.`id_categoria` = `mg_categorie`.`id`; -UPDATE `mg_articoli` JOIN `mg_categorie` ON `mg_articoli`.`subcategoria` = `mg_categorie`.`nome` AND `mg_categorie`.`parent` != 0 SET `mg_articoli`.`id_sottocategoria` = `mg_categorie`.`id`; -ALTER TABLE `mg_articoli` DROP COLUMN `categoria`, DROP COLUMN `subcategoria`; - -INSERT INTO `zz_modules` (`id`, `name`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Categorie', 'categorie', 'SELECT |select| FROM `mg_categorie` WHERE 1=1 AND `parent` IS NULL HAVING 2=2', '', 'fa fa-briefcase', '2.3', '2.3', '1', 1, '1', '1'); -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Categorie' AND `t2`.`name` = 'Tabelle') SET `t1`.`parent` = `t2`.`id`; - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `enabled`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Categorie'), 'id', 'id', 3, 1, 0, 0, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Categorie'), 'Nome', 'nome', 2, 1, 0, 1, 0); - --- Fix della ricerca per tipologia su anagrafiche -UPDATE `zz_views` SET `search_inside` = 'idanagrafica IN(SELECT idanagrafica FROM an_tipianagrafiche_anagrafiche WHERE idtipoanagrafica IN (SELECT idtipoanagrafica FROM an_tipianagrafiche WHERE descrizione LIKE |search|))' WHERE `zz_views`.`id` = 3; - --- Aggiunta della descrizione negli Articoli -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `search_inside`, `order_by`, `enabled`, `summable`, `default`) VALUES ((SELECT `id` FROM `zz_modules` WHERE `name` = 'Articoli'), 'Descrizione', 'descrizione', '1', '1', '0', '', '', '1', '0', '1'); - --- Aggiornamento delle icone -UPDATE `co_statidocumento` SET `icona` = 'fa fa-check-circle text-success' WHERE `descrizione` = 'Pagato'; -UPDATE `co_statidocumento` SET `icona` = 'fa fa-file-text-o text-muted' WHERE `descrizione` = 'Bozza'; -UPDATE `co_statidocumento` SET `icona` = 'fa fa-clock-o text-info' WHERE `descrizione` = 'Emessa'; -UPDATE `co_statidocumento` SET `icona` = 'fa fa-times text-danger' WHERE `descrizione` = 'Annullata'; -UPDATE `co_statidocumento` SET `icona` = 'fa fa-dot-circle-o text-warning' WHERE `descrizione` = 'Parzialmente pagato'; - -UPDATE `or_statiordine` SET `icona` = 'fa fa-file-text-o text-muted' WHERE `descrizione` = 'Non evaso'; -UPDATE `or_statiordine` SET `icona` = 'fa fa-check-circle text-success' WHERE `descrizione` = 'Evaso'; -UPDATE `or_statiordine` SET `icona` = 'fa fa-gear text-warning' WHERE `descrizione` = 'Parzialmente evaso'; - -UPDATE `dt_statiddt` SET `icona` = 'fa fa-file-text-o text-muted' WHERE `descrizione` = 'Bozza'; -UPDATE `dt_statiddt` SET `icona` = 'fa fa-clock-o text-info' WHERE `descrizione` = 'Evaso'; -UPDATE `dt_statiddt` SET `icona` = 'fa fa-check-circle text-success' WHERE `descrizione` = 'Pagato'; - -UPDATE `co_staticontratti` SET `icona` = 'fa fa-file-text-o text-muted' WHERE `descrizione` = 'Bozza'; -UPDATE `co_staticontratti` SET `icona` = 'fa fa-clock-o text-warning' WHERE `descrizione` = 'In attesa di conferma'; -UPDATE `co_staticontratti` SET `icona` = 'fa fa-thumbs-up text-success' WHERE `descrizione` = 'Accettato'; -UPDATE `co_staticontratti` SET `icona` = 'fa fa-thumbs-down text-danger' WHERE `descrizione` = 'Rifiutato'; -UPDATE `co_staticontratti` SET `icona` = 'fa fa-gear text-warning' WHERE `descrizione` = 'In lavorazione'; -UPDATE `co_staticontratti` SET `icona` = 'fa fa-money text-primary' WHERE `descrizione` = 'In attesa di pagamento'; -UPDATE `co_staticontratti` SET `icona` = 'fa fa-check-circle text-success' WHERE `descrizione` = 'Pagato'; -UPDATE `co_staticontratti` SET `icona` = 'fa fa-check text-success' WHERE `descrizione` = 'Concluso'; - -UPDATE `co_statipreventivi` SET `icona` = 'fa fa-file-text-o text-muted' WHERE `descrizione` = 'Bozza'; -UPDATE `co_statipreventivi` SET `icona` = 'fa fa-clock-o text-warning' WHERE `descrizione` = 'In attesa di conferma'; -UPDATE `co_statipreventivi` SET `icona` = 'fa fa-thumbs-up text-success' WHERE `descrizione` = 'Accettato'; -UPDATE `co_statipreventivi` SET `icona` = 'fa fa-thumbs-down text-danger' WHERE `descrizione` = 'Rifiutato'; -UPDATE `co_statipreventivi` SET `icona` = 'fa fa-gear text-warning' WHERE `descrizione` = 'In lavorazione'; -UPDATE `co_statipreventivi` SET `icona` = 'fa fa-check text-success' WHERE `descrizione` = 'Concluso'; -UPDATE `co_statipreventivi` SET `icona` = 'fa fa-check-circle text-success' WHERE `descrizione` = 'Pagato'; -UPDATE `co_statipreventivi` SET `icona` = 'fa fa-money text-primary' WHERE `descrizione` = 'In attesa di pagamento'; - --- Aggiunta sconto incondizionato sull'attività -ALTER TABLE `in_interventi` ADD `tipo_sconto` enum('UNT', 'PRC') NOT NULL DEFAULT 'UNT' AFTER `ora_sla`; - --- Aggiunta sconto in euro e percentuale su ore e km, e quantità ore nella riga tecnico-intervento -ALTER TABLE `in_interventi_tecnici` ADD `ore` decimal(12, 4) NOT NULL AFTER `orario_fine`; - --- Calcolo il campo ore degli interventi già inseriti -UPDATE `in_interventi_tecnici` SET `ore` = (TIMESTAMPDIFF(MINUTE, `orario_inizio`, `orario_fine`) / 60); - --- Aggiunta sconti e prezzo di acquisto su righe generiche attività -ALTER TABLE `in_righe_interventi` ADD `prezzo_acquisto` decimal(12, 4) NOT NULL AFTER `prezzo`; - --- Aggiunta sconto in percentuale, unità di misura (in copia negli articoli aggiunti negli interventi), prezzo di acquisto sugli articoli e sulle spese aggiuntive -ALTER TABLE `mg_articoli_interventi` ADD `um` varchar(20) NOT NULL AFTER `qta`, ADD `prezzo_acquisto` decimal(12, 4) NOT NULL AFTER `altro`; - --- Rinomino il prezzo finale delle righe generiche in prezzo_vendita per uniformare i campi -ALTER TABLE `in_righe_interventi` CHANGE `prezzo` `prezzo_vendita` decimal(12, 4) NOT NULL; - --- Aggiungo la tipologia di intervento alla riga del tecnico e copio le tipologie già inserite nel nuovo campo -ALTER TABLE `in_interventi_tecnici` ADD `idtipointervento` varchar(25) NOT NULL AFTER `idintervento`; --- Fix per le sessioni di lavoro dei tecnici precedenti -UPDATE `in_interventi_tecnici` SET `idtipointervento` = (SELECT `idtipointervento` FROM `in_interventi` WHERE `in_interventi_tecnici`.`idintervento` = `in_interventi`.`id`); - --- Cambiato il campo dell'unità di misura in valore effettivo, togliendo il riferimento all'id. Conversione dei precedenti id in valori -ALTER TABLE `mg_articoli` ADD `um` varchar(20) NOT NULL AFTER `idum`; -UPDATE `mg_articoli` SET `um` = (SELECT `valore` FROM `mg_unitamisura` WHERE `id` = `mg_articoli`.`idum`); -ALTER TABLE `mg_articoli` DROP `idum`; - --- Aggiunte altre possibili ritenute d'acconto e iva -INSERT INTO `co_ritenutaacconto` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`) VALUES (NULL, 'Ritenuta d''acconto 10%', '10', '0.00', '0'); -INSERT INTO `co_ritenutaacconto` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`) VALUES (NULL, 'Ritenuta d''acconto 4%', '4', '0.00', '0'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `descrizione2`, `indetraibile`, `esente`) VALUES (NULL, 'Art. 17 comma 6 DPR 633/72 22%', '22', '', '0.00', '0'); - --- Aggiunto modulo per gestire le ritenute d'acconto -INSERT INTO `zz_modules` (`id`, `name`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Ritenute acconto', 'ritenute', 'SELECT |select| FROM `co_ritenutaacconto` WHERE 1=1 HAVING 2=2', '', 'fa fa-percent', '2.3', '2.3', '1', 1, '1', '1'); - -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Ritenute acconto' AND `t2`.`name` = 'Tabelle') SET `t1`.`parent` = `t2`.`id`; - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `enabled`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Ritenute acconto'), 'Indetraibile', 'indetraibile', 4, 1, 0, 1, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Ritenute acconto'), 'Percentuale', 'percentuale', 3, 1, 0, 1, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Ritenute acconto'), 'Descrizione', 'descrizione', 2, 1, 0, 1, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Ritenute acconto'), 'id', 'id', 1, 1, 0, 0, 0); - --- Query mancanti per viste su MyImpianti -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `enabled`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'MyImpianti'), 'idanagrafica', 'idanagrafica', 1, 0, 0, 0, 1); - --- Query mancanti per viste su Fatture di vendita -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `enabled`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'), 'idanagrafica', 'idanagrafica', 1, 0, 0, 0, 1); - --- filtri dei WHERE in base al modulo e all'utente loggato anche per i widget -UPDATE `zz_widgets` SET `query` = 'SELECT CONCAT_WS(" ", REPLACE(REPLACE(REPLACE(FORMAT(SUM((SELECT SUM(subtotale+iva-sconto) FROM co_righe_documenti WHERE iddocumento=co_documenti.id)+iva_rivalsainps+rivalsainps+bollo-ritenutaacconto), 2), ",", "#"), ".", ","), "#", "."), "€") AS dato FROM co_documenti WHERE idtipodocumento IN(SELECT id FROM co_tipidocumento WHERE dir="entrata") AND data >= "|period_start|" AND data <= "|period_end|" AND 1=1' WHERE `zz_widgets`.`name` = 'Fatturato'; - -UPDATE `zz_widgets` SET `query` = 'SELECT CONCAT_WS(" ", REPLACE(REPLACE(REPLACE(FORMAT(SUM((SELECT SUM(subtotale+iva-sconto) FROM co_righe_documenti WHERE iddocumento=co_documenti.id)+iva_rivalsainps+rivalsainps+bollo-ritenutaacconto), 2), ",", "#"), ".", ","), "#", "."), "€") AS dato FROM co_documenti WHERE idtipodocumento IN(SELECT id FROM co_tipidocumento WHERE dir="entrata") AND idstatodocumento = (SELECT id FROM co_statidocumento WHERE descrizione="Emessa") AND data >= "|period_start|" AND data <= "|period_end|" AND 1=1' WHERE `zz_widgets`.`name` = 'Crediti da clienti'; - --- Aggiunta del campo per permettere la modifica delle Viste di default -INSERT INTO `zz_settings` (`nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES ('Modifica Viste di default', '0', 'boolean', 0, 'Generali'); - --- Aggiunta del campo per permettere la modifica delle prima pagina di OSM -INSERT INTO `zz_settings` (`nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES -('Prima pagina', (SELECT `id` FROM `zz_modules` WHERE `name` = 'Dashboard'), 'query=SELECT id, title AS ''descrizione'' FROM zz_modules WHERE enabled = 1 AND options != '''' AND options != ''menu'' AND options IS NOT NULL ORDER BY `order` ASC', 1, 'Generali'); - --- Aggiunta del campo idagente in Anagrafiche per la visione da parte degli agenti -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `enabled`, `default`) VALUES ((SELECT `id` FROM `zz_modules` WHERE `name` = 'Anagrafiche'), 'idagente', 'idagente', 9, 0, 0, 0, 1); - -INSERT INTO `zz_group_view` (`id_gruppo`, `id_vista`) VALUES -((SELECT `id` FROM `zz_groups` WHERE `nome` = 'Agenti'), (SELECT `id` FROM `zz_views` WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Anagrafiche') AND `name` = 'idagente')); - --- Aggiunta di chiavi esterne in zz_modules -ALTER TABLE `zz_modules` CHANGE `parent` `parent` int(11) NULL; -UPDATE `zz_modules` SET `parent` = NULL WHERE `parent` = 0; -ALTER TABLE `zz_modules` ADD FOREIGN KEY (`parent`) REFERENCES `zz_modules`(`id`) ON DELETE CASCADE; - --- Aggiunta di chiavi esterne in zz_widgets -ALTER TABLE `zz_widgets` ADD FOREIGN KEY (`id_module`) REFERENCES `zz_modules`(`id`) ON DELETE CASCADE; - --- Aggiunta di chiavi esterne in zz_group_module -ALTER TABLE `zz_group_module` ADD FOREIGN KEY (`idmodule`) REFERENCES `zz_modules`(`id`) ON DELETE CASCADE, ADD FOREIGN KEY (`idgruppo`) REFERENCES `zz_groups`(`id`) ON DELETE CASCADE; - --- Aggiunta di chiavi esterne in zz_permissions -DELETE FROM `zz_permissions` WHERE `idmodule` NOT IN (SELECT `id` FROM `zz_modules`); -ALTER TABLE `zz_permissions` ADD FOREIGN KEY (`idmodule`) REFERENCES `zz_modules`(`id`) ON DELETE CASCADE, ADD FOREIGN KEY (`idgruppo`) REFERENCES `zz_groups`(`id`) ON DELETE CASCADE; - --- Aggiunta di chiavi esterne in zz_plugins -DELETE FROM `zz_plugins` WHERE `idmodule_to` NOT IN (SELECT `id` FROM `zz_modules`); -DELETE FROM `zz_plugins` WHERE `idmodule_from` NOT IN (SELECT `id` FROM `zz_modules`); -ALTER TABLE `zz_plugins` ADD FOREIGN KEY (`idmodule_from`) REFERENCES `zz_modules`(`id`) ON DELETE CASCADE, ADD FOREIGN KEY (`idmodule_to`) REFERENCES `zz_modules`(`id`) ON DELETE CASCADE; - --- Aggiunta di chiavi esterne in zz_users -ALTER TABLE `zz_users` CHANGE `idutente` `id` int(11) NOT NULL AUTO_INCREMENT, ADD FOREIGN KEY (`idgruppo`) REFERENCES `zz_groups`(`id`) ON DELETE CASCADE; - --- Aggiunta di chiavi esterne in zz_logs -ALTER TABLE `zz_logs` DROP `password`, CHANGE `idutente` `id_utente` int(11), CHANGE `timestamp` `timestamp` datetime; -UPDATE `zz_logs` SET `id_utente` = NULL WHERE `id_utente` = 0; -DELETE FROM `zz_logs` WHERE `id_utente` IS NOT NULL AND `id_utente` NOT IN (SELECT `id` FROM `zz_users`); -ALTER TABLE `zz_logs` ADD FOREIGN KEY (`id_utente`) REFERENCES `zz_users`(`id`) ON DELETE CASCADE; - --- Aggiunta di chiavi esterne in zz_semaphores -ALTER TABLE `zz_semaphores` ADD FOREIGN KEY (`id_utente`) REFERENCES `zz_users`(`id`) ON DELETE CASCADE; - --- Aggiunta della tabella per gestire le chiavi di accesso all'API -CREATE TABLE IF NOT EXISTS `zz_tokens` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_utente` int(11) NOT NULL, - `token` varchar(255) NOT NULL, - `descrizione` varchar(255), - `enabled` boolean NOT NULL DEFAULT 1, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_utente`) REFERENCES `zz_users`(`id`) ON DELETE CASCADE -) ENGINE=InnoDB; - --- Modifica di an_sedi per sostituire le nazioni con i corrispettivi nella tabella apposita -ALTER TABLE `an_sedi` ADD `id_nazione` int(11) COMMENT 'Nazione' AFTER `nazione`, ADD FOREIGN KEY (`id_nazione`) REFERENCES `an_nazioni`(`id`); -UPDATE `an_sedi` SET `id_nazione` = `nazione` WHERE `nazione` IN (SELECT `id` FROM `an_nazioni`); -ALTER TABLE `an_sedi` DROP COLUMN `nazione`; - --- Aggiunta di chiavi esterne in my_impianto_componenti -ALTER TABLE `my_impianto_componenti` CHANGE `idsostituto` `idsostituto` int(11); -UPDATE `my_impianto_componenti` SET `idsostituto` = NULL WHERE `idsostituto` = 0; --- PRIMA DI AGGIUNGERE LA CHIAVE ESTERNA: mi assicuro che non ci siano componenti collegati a componenti non più esistenti -DELETE `t1` FROM `my_impianto_componenti` `t1` INNER JOIN `my_impianto_componenti` `t2` ON `t1`.`id` = `t2`.`id` WHERE `t1`.`idsostituto` NOT IN (`t2`.`id`); -ALTER TABLE `my_impianto_componenti` ADD FOREIGN KEY (`idsostituto`) REFERENCES `my_impianto_componenti`(`id`) ON DELETE CASCADE; - --- Adeguamento degli id di zz_files per interventi -UPDATE `zz_files` SET `externalid` = (SELECT `id` FROM `in_interventi` WHERE `in_interventi`.`idintervento` = `externalid`) WHERE module = 'interventi' ; - --- Adeguamento degli id di zz_files per impianti -UPDATE `zz_files` SET `externalid` = (SELECT `id` FROM `my_impianti` WHERE `my_impianti`.`matricola` = `externalid`) WHERE module = 'myimpianti' ; - --- Adeguamento dei contenuti di zz_files -ALTER TABLE `zz_files` CHANGE `externalid` `id_record` int(11) NOT NULL, ADD `id_module` int(11) NOT NULL AFTER `filename`, ADD `original` varchar(255) NOT NULL AFTER `filename`; - --- Adeguamento delle fatture (zz_files) -UPDATE `zz_files` SET `id_module` = (SELECT `id` FROM `zz_modules` WHERE `zz_modules`.`name` = 'Fatture di vendita') WHERE (`module`= 'fatture di vendita' OR `module`= 'fatture') AND `id_record` IN (SELECT `id` FROM `co_documenti` WHERE `idtipodocumento` IN (SELECT `id` FROM `co_tipidocumento` WHERE `dir` = 'entrata')); -UPDATE `zz_files` SET `id_module` = (SELECT `id` FROM `zz_modules` WHERE `zz_modules`.`name` = 'Fatture di acquisto') WHERE (`module`= 'fatture di acquisto' OR `module`= 'fatture') AND `id_record` IN (SELECT `id` FROM `co_documenti` WHERE `idtipodocumento` IN (SELECT `id` FROM `co_tipidocumento` WHERE `dir` = 'uscita')); - --- Adeguamento dei ddt (zz_files) -UPDATE `zz_files` SET `id_module` = (SELECT `id` FROM `zz_modules` WHERE `zz_modules`.`name` = 'Ddt di vendita') WHERE (`module`= 'ddt di vendita' OR `module`= 'ddt') AND `id_record` IN (SELECT `id` FROM `dt_ddt` WHERE `idtipoddt` IN (SELECT `id` FROM `dt_tipiddt` WHERE `dir` = 'entrata')); -UPDATE `zz_files` SET `id_module` = (SELECT `id` FROM `zz_modules` WHERE `zz_modules`.`name` = 'Ddt di acquisto') WHERE (`module`= 'ddt di acquisto' OR `module`= 'ddt') AND `id_record` IN (SELECT `id` FROM `dt_ddt` WHERE `idtipoddt` IN (SELECT `id` FROM `dt_tipiddt` WHERE `dir` = 'uscita')); - --- Adeguamento degli ordini (zz_files) -UPDATE `zz_files` SET `id_module` = (SELECT `id` FROM `zz_modules` WHERE `zz_modules`.`name` = 'Ordini cliente') WHERE (`module`= 'ordini cliente' OR `module`= 'ordini') AND `id_record` IN (SELECT `id` FROM `or_ordini` WHERE `idtipoordine` IN (SELECT `id` FROM `or_tipiordine` WHERE `dir` = 'entrata')); -UPDATE `zz_files` SET `id_module` = (SELECT `id` FROM `zz_modules` WHERE `zz_modules`.`name` = 'Ordini fornitore') WHERE (`module`= 'ordini fornitore' OR `module`= 'ordini') AND `id_record` IN (SELECT `id` FROM `or_ordini` WHERE `idtipoordine` IN (SELECT `id` FROM `or_tipiordine` WHERE `dir` = 'uscita')); - --- Adeguamento resto dei moduli (zz_files) -UPDATE `zz_files` SET `id_module` = (SELECT `id` FROM `zz_modules` WHERE `zz_modules`.`name` = `zz_files`.`module`) WHERE `id_module` = 0 OR `id_module` IS NULL; -UPDATE `zz_files` SET `id_module` = (SELECT `id` FROM `zz_modules` WHERE `zz_modules`.`directory` = `zz_files`.`module`) WHERE `id_module` = 0 OR `id_module` IS NULL; -ALTER TABLE `zz_files` DROP `module`; - --- Fix del widget 'Tutte le anagrafiche' -UPDATE `zz_widgets` SET `query` = 'SELECT COUNT(an_anagrafiche.idanagrafica) AS dato FROM an_anagrafiche WHERE deleted=0' WHERE `name` = 'Tutte le anagrafiche'; - --- Fix dei contenuti dei filtri per gruppi -UPDATE `zz_group_module` SET `clause` = IF(SUBSTRING(TRIM(`clause`), 1, 4) = 'AND ', SUBSTRING(TRIM(`clause`), 4), TRIM(`clause`)); - --- Aggiunta dei campi position e default in zz_group_module -ALTER TABLE `zz_group_module` ADD `default` boolean NOT NULL DEFAULT 0 AFTER `clause`, ADD `enabled` boolean NOT NULL DEFAULT 1 AFTER `clause`, ADD `position` enum('WHR', 'HVN') NOT NULL DEFAULT 'WHR' AFTER `clause`; -UPDATE `zz_group_module` SET `default` = 1; - --- Fix per lo spostamento di pdfgen.php -UPDATE `zz_widgets` SET `more_link` = REPLACE(TRIM(`more_link`), 'templates/pdfgen.php', 'pdfgen.php'); - --- Nuova struttura per i plugins -ALTER TABLE `zz_plugins` ADD `title` varchar(255) NOT NULL AFTER `name`, -ADD `directory` varchar(50) NOT NULL AFTER `script`, ADD `options` text AFTER `script`, ADD `options2` text AFTER `script`, ADD `version` varchar(15) NOT NULL AFTER `script`, ADD `compatibility` varchar(1000) NOT NULL AFTER `script`, ADD `order` int(11) NOT NULL AFTER `script`, ADD `default` boolean NOT NULL DEFAULT 0 AFTER `script`, ADD `enabled` boolean NOT NULL DEFAULT 1 AFTER `script`; - -UPDATE `zz_plugins` SET `name` = 'Serial' WHERE `name` = 'Lotti'; -UPDATE `zz_plugins` SET `title` = `name` WHERE `title` = ''; - --- Nuova struttura per i plugin Sedi e Referenti in Anagrafiche -UPDATE `zz_plugins` SET `script` = '', `options` = ' { "main_query": [ { "type": "table", "fields": "Nome, Indirizzo, Città, CAP, Provincia, Referente", "query": "SELECT an_sedi.id, an_sedi.nomesede AS Nome, an_sedi.indirizzo AS Indirizzo, an_sedi.citta AS Città, an_sedi.cap AS CAP, an_sedi.provincia AS Provincia, an_referenti.nome AS Referente FROM an_sedi LEFT OUTER JOIN an_referenti ON idsede = an_sedi.id WHERE 1=1 AND an_sedi.idanagrafica=|idanagrafica| HAVING 2=2 ORDER BY an_sedi.id DESC"} ]}', `directory` = 'sedi', `version` = '2.3', `compatibility` = '2.*' WHERE `name` = 'Sedi'; -UPDATE `zz_plugins` SET `script` = '', `options` = ' { "main_query": [ { "type": "table", "fields": "Nominativo, Mansione, Telefono, Indirizzo email, Sede", "query": "SELECT an_referenti.id, an_referenti.nome AS Nominativo, mansione AS Mansione, an_referenti.telefono AS Telefono, an_referenti.email AS ''Indirizzo email'', an_sedi.nomesede AS Sede FROM an_referenti LEFT OUTER JOIN an_sedi ON idsede = an_sedi.id WHERE 1=1 AND an_referenti.idanagrafica=|idanagrafica| HAVING 2=2 ORDER BY an_referenti.id DESC"} ]}', `directory` = 'referenti', `version` = '2.3', `compatibility` = '2.*' WHERE `name` = 'Referenti'; - --- Cleanup della tabella zz_settings -DELETE FROM `zz_settings` WHERE (`idimpostazione` = 33 AND `nome` = 'osmcloud_username') OR (`idimpostazione` = 34 AND `nome` = 'osmcloud_password') OR (`idimpostazione` = 3 AND `nome` = 'max_idintervento') OR (`idimpostazione` = 30 AND `nome` = 'Numero di mesi prima da cui iniziare a visualizzare gli interventi') OR (`idimpostazione` = 35 AND `nome` = 'osm_installed'); - --- Modifica degli stati dei contratti -ALTER TABLE `co_staticontratti` DROP `completato`, DROP `annullato`, ADD `fatturabile` boolean NOT NULL AFTER `icona`, ADD `pianificabile` boolean NOT NULL AFTER `icona`; - -UPDATE `co_staticontratti` SET `fatturabile` = 1 WHERE `descrizione` IN ('Pagato', 'Accettato', 'In lavorazione', 'In attesa di conferma', 'In attesa di pagamento', 'Concluso'); -UPDATE `co_staticontratti` SET `pianificabile` = 1 WHERE `descrizione` IN ('Pagato', 'Accettato', 'In lavorazione', 'In attesa di pagamento'); - --- Aggiornamento delle impostazioni riguardanti le cifre decimali -INSERT INTO `zz_settings` (`nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES ('Cifre decimali per quantità', '2', 'list[1,2,3,4]', 1, 'Generali'); -UPDATE `zz_settings` SET `nome` = 'Cifre decimali per importi' WHERE `nome` = 'Cifre decimali'; - --- Generalizzazione nella gestione dei seriali -ALTER TABLE `mg_articoli` ADD `abilita_serial` boolean NOT NULL DEFAULT '0' AFTER `um`; -ALTER TABLE `co_righe_documenti` ADD `abilita_serial` boolean NOT NULL DEFAULT '0' AFTER `um`; -ALTER TABLE `dt_righe_ddt` ADD `abilita_serial` boolean NOT NULL DEFAULT '0' AFTER `um`; -ALTER TABLE `mg_articoli_interventi` ADD `abilita_serial` boolean NOT NULL DEFAULT '0' AFTER `um`; -ALTER TABLE `or_righe_ordini` ADD `abilita_serial` boolean NOT NULL DEFAULT '0' AFTER `um`; - --- Aggiunto modulo per visualizzare i movimenti di magazzino -INSERT INTO `zz_modules` (`id`, `name`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Movimenti', '', 'SELECT |select| FROM `mg_movimenti` JOIN `mg_articoli` ON `mg_articoli`.id = `mg_movimenti`.`idarticolo` WHERE 1=1 HAVING 2=2', '', 'fa fa-angle-right', '2.3', '2.3', '1', 1, '1', '1'); - -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Movimenti' AND `t2`.`name` = 'Magazzino') SET `t1`.`parent` = `t2`.`id`; - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `enabled`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Movimenti'), 'Articolo', 'IF(mg_articoli.descrizione != '''', CONCAT(mg_articoli.codice, '' - '', mg_articoli.descrizione), mg_articoli.codice)', 2, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Movimenti'), 'Data', 'mg_movimenti.created_at', 5, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Movimenti'), 'Quantità', 'mg_movimenti.qta', 4, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Movimenti'), 'Descrizione', 'movimento', 3, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Movimenti'), 'id', 'mg_movimenti.id', 1, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Movimenti'), '_link_module_', '(SELECT `id` FROM `zz_modules` WHERE `name` = ''Articoli'')', 6, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Movimenti'), '_link_record_', 'mg_movimenti.idarticolo', 7, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Movimenti'), '_link_hash_', 'CONCAT(''tab_'', (SELECT `id` FROM `zz_plugins` WHERE `name` = ''Movimenti'' AND idmodule_to = (SELECT `id` FROM `zz_modules` WHERE `name` = ''Articoli'')))', 7, 1, 0, 0, 1); - --- Aggiunta del campo di dicitura fissa per la fatturazione -ALTER TABLE `co_iva` ADD `dicitura` varchar(255); - --- Miglioramento della gestione dei pagamenti predefiniti -ALTER TABLE `an_anagrafiche` CHANGE `idpagamento` `idpagamento_vendite` int(11), ADD `idpagamento_acquisti` int(11) AFTER `idpagamento_vendite`; -UPDATE `an_anagrafiche` SET `idpagamento_vendite` = NULL WHERE `idpagamento_vendite` = 0; -UPDATE `an_anagrafiche` SET `idpagamento_acquisti` = `idpagamento_vendite` WHERE `idpagamento_vendite` IS NOT NULL; - --- Miglioramento della gestione dei listini predefiniti -ALTER TABLE `an_anagrafiche` CHANGE `idlistino` `idlistino_vendite` int(11), ADD `idlistino_acquisti` int(11) AFTER `idlistino_vendite`; -UPDATE `an_anagrafiche` SET `idlistino_vendite` = NULL WHERE `idlistino_vendite` = 0; -UPDATE `an_anagrafiche` SET `idlistino_acquisti` = `idlistino_vendite` WHERE `idlistino_vendite` IS NOT NULL; - --- Miglioramento della gestione dell'iva predefinita -ALTER TABLE `an_anagrafiche` CHANGE `idiva` `idiva_vendite` int(11), ADD `idiva_acquisti` int(11) AFTER `idiva_vendite`; -UPDATE `an_anagrafiche` SET `idiva_vendite` = NULL WHERE `idiva_vendite` = 0; -UPDATE `an_anagrafiche` SET `idiva_acquisti` = `idiva_vendite` WHERE `idiva_vendite` IS NOT NULL; - --- Rimozione data_sla e ora_sla -ALTER TABLE `in_interventi` DROP `data_sla`, DROP `ora_sla`; - --- Fix dei widget -UPDATE `zz_widgets` SET `query` = 'SELECT COUNT(id) AS dato FROM co_righe_contratti WHERE idcontratto IN( SELECT id FROM co_contratti WHERE idstato IN (SELECT id FROM co_staticontratti WHERE pianificabile = 1)) AND idintervento IS NULL' WHERE `zz_widgets`.`name` = 'Interventi da pianificare'; - -UPDATE `zz_widgets` SET `query` = 'SELECT COUNT(id) AS dato FROM co_ordiniservizio WHERE idcontratto IN( SELECT id FROM co_contratti WHERE idstato IN(SELECT id FROM co_staticontratti WHERE pianificabile = 1)) AND idintervento IS NULL' WHERE `zz_widgets`.`name` = 'Ordini di servizio da impostare'; - --- Creazione del campo format per la tabella zz_views -ALTER TABLE `zz_views` ADD `format` boolean NOT NULL DEFAULT 0 AFTER `slow`; -UPDATE `zz_views` SET `format` = 1 WHERE -(`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Scadenzario') AND `name` = 'Importo') -OR (`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Scadenzario') AND `name` = 'Pagato') -OR (`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di acquisto') AND `name` = 'Totale') -OR (`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita') AND `name` = 'Totale') -OR (`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi di intervento') AND `name` = 'Costo orario') -OR (`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi di intervento') AND `name` = 'Costo al km') -OR (`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi di intervento') AND `name` = 'Diritto di chiamata') -OR (`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi di intervento') AND `name` = 'Costo orario tecnico') -OR (`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi di intervento') AND `name` = 'Costo al km tecnico') -OR (`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi di intervento') AND `name` = 'Diritto di chiamata tecnico') -OR (`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi') AND `name` = 'Data inizio') -OR (`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi') AND `name` = 'Data fine') -OR (`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita') AND `name` = 'Data') -OR (`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di acquisto') AND `name` = 'Data') -OR (`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Prima nota') AND `name` = 'Data') -OR (`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Scadenzario') AND `name` = 'Data scadenza') -OR (`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ddt di vendita') AND `name` = 'Data') -OR (`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ddt di acquisto') AND `name` = 'Data') -OR (`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'MyImpianti') AND `name` = 'Data') -OR (`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ordini cliente') AND `name` = 'Data') -OR (`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Movimenti') AND `name` = 'Data') -OR (`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Movimenti') AND `name` = 'Quantità') -OR (`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Prima nota') AND `name` = 'Dare') -OR (`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Prima nota') AND `name` = 'Avere'); - --- Disabilitazione dei plugin instabili -UPDATE `zz_plugins` SET `enabled` = 0 WHERE `name` = 'Pianificazione fatturazione' OR `name` = 'Pianificazione ordini di servizio'; - --- Fix del tipo di alcune impostazioni -UPDATE `zz_settings` SET `tipo` = 'decimal' WHERE `nome` = 'Soglia minima per l''applicazione della marca da bollo' OR `nome` = 'Importo marca da bollo'; -UPDATE `zz_settings` SET `valore` = '82' WHERE `nome` = 'Tipo di pagamento predefinito' AND `valore` = '20'; - --- Fix per le date in varie tabelle -ALTER TABLE `co_documenti` CHANGE `data` `data` datetime; -ALTER TABLE `or_ordini` CHANGE `data` `data` datetime; -ALTER TABLE `dt_ddt` CHANGE `data` `data` datetime; - -ALTER TABLE `co_preventivi` CHANGE `data_bozza` `data_bozza` datetime, CHANGE `data_accettazione` `data_accettazione` datetime, CHANGE `data_rifiuto` `data_rifiuto` datetime, CHANGE `data_conclusione` `data_conclusione` datetime, CHANGE `data_pagamento` `data_pagamento` datetime; -ALTER TABLE `co_contratti` CHANGE `data_bozza` `data_bozza` datetime, CHANGE `data_accettazione` `data_accettazione` datetime, CHANGE `data_rifiuto` `data_rifiuto` datetime, CHANGE `data_conclusione` `data_conclusione` datetime; - -ALTER TABLE `co_movimenti` CHANGE `data` `data` datetime, CHANGE `data_documento` `data_documento` datetime; -ALTER TABLE `co_ordiniservizio` CHANGE `data_scadenza` `data_scadenza` datetime; -ALTER TABLE `co_ordiniservizio_pianificazionefatture` CHANGE `data_scadenza` `data_scadenza` datetime; -ALTER TABLE `co_righe_contratti` CHANGE `data_richiesta` `data_richiesta` datetime; -ALTER TABLE `co_righe_preventivi` CHANGE `data_evasione` `data_evasione` datetime; -ALTER TABLE `co_scadenziario` CHANGE `data_emissione` `data_emissione` datetime, CHANGE `scadenza` `scadenza` datetime, CHANGE `data_pagamento` `data_pagamento` datetime; -ALTER TABLE `dt_automezzi_tecnici` CHANGE `data_inizio` `data_inizio` datetime, CHANGE `data_fine` `data_fine` datetime; -ALTER TABLE `my_impianto_componenti` CHANGE `data` `data` datetime, CHANGE `data_sostituzione` `data_sostituzione` datetime; -ALTER TABLE `or_righe_ordini` CHANGE `data_evasione` `data_evasione` datetime; - -UPDATE `co_documenti` SET `data` = NULL WHERE `data` = '0000-00-00 00:00:00'; -UPDATE `or_ordini` SET `data` = NULL WHERE `data` = '0000-00-00 00:00:00'; -UPDATE `dt_ddt` SET `data` = NULL WHERE `data` = '0000-00-00 00:00:00'; - -UPDATE `co_preventivi` SET `data_bozza` = NULL WHERE `data_bozza` = '0000-00-00 00:00:00'; -UPDATE `co_preventivi` SET `data_accettazione` = NULL WHERE `data_accettazione` = '0000-00-00 00:00:00'; -UPDATE `co_preventivi` SET `data_rifiuto` = NULL WHERE `data_rifiuto` = '0000-00-00 00:00:00'; -UPDATE `co_preventivi` SET `data_conclusione` = NULL WHERE `data_conclusione` = '0000-00-00 00:00:00'; -UPDATE `co_preventivi` SET `data_pagamento` = NULL WHERE `data_pagamento` = '0000-00-00 00:00:00'; -UPDATE `co_contratti` SET `data_bozza` = NULL WHERE `data_bozza` = '0000-00-00 00:00:00'; -UPDATE `co_contratti` SET `data_accettazione` = NULL WHERE `data_accettazione` = '0000-00-00 00:00:00'; -UPDATE `co_contratti` SET `data_rifiuto` = NULL WHERE `data_rifiuto` = '0000-00-00 00:00:00'; -UPDATE `co_contratti` SET `data_conclusione` = NULL WHERE `data_conclusione` = '0000-00-00 00:00:00'; - -UPDATE `co_movimenti` SET `data` = NULL WHERE `data` = '0000-00-00 00:00:00'; -UPDATE `co_movimenti` SET `data_documento` = NULL WHERE `data_documento` = '0000-00-00 00:00:00'; -UPDATE `co_ordiniservizio` SET `data_scadenza` = NULL WHERE `data_scadenza` = '0000-00-00 00:00:00'; -UPDATE `co_ordiniservizio_pianificazionefatture` SET `data_scadenza` = NULL WHERE `data_scadenza` = '0000-00-00 00:00:00'; -UPDATE `co_righe_contratti` SET `data_richiesta` = NULL WHERE `data_richiesta` = '0000-00-00 00:00:00'; -UPDATE `co_righe_preventivi` SET `data_evasione` = NULL WHERE `data_evasione` = '0000-00-00 00:00:00'; -UPDATE `co_scadenziario` SET `data_emissione` = NULL WHERE `data_emissione` = '0000-00-00 00:00:00'; -UPDATE `co_scadenziario` SET `scadenza` = NULL WHERE `scadenza` = '0000-00-00 00:00:00'; -UPDATE `co_scadenziario` SET `data_pagamento` = NULL WHERE `data_pagamento` = '0000-00-00 00:00:00'; -UPDATE `dt_automezzi_tecnici` SET `data_inizio` = NULL WHERE `data_inizio` = '0000-00-00 00:00:00'; -UPDATE `dt_automezzi_tecnici` SET `data_fine` = NULL WHERE `data_fine` = '0000-00-00 00:00:00'; -UPDATE `my_impianto_componenti` SET `data` = NULL WHERE `data` = '0000-00-00 00:00:00'; -UPDATE `my_impianto_componenti` SET `data_sostituzione` = NULL WHERE `data_sostituzione` = '0000-00-00 00:00:00'; -UPDATE `or_righe_ordini` SET `data_evasione` = NULL WHERE `data_evasione` = '0000-00-00 00:00:00'; - -ALTER TABLE `co_documenti` CHANGE `data` `data` date; -ALTER TABLE `or_ordini` CHANGE `data` `data` date; -ALTER TABLE `dt_ddt` CHANGE `data` `data` date; - -ALTER TABLE `co_preventivi` CHANGE `data_bozza` `data_bozza` date, CHANGE `data_accettazione` `data_accettazione` date, CHANGE `data_rifiuto` `data_rifiuto` date, CHANGE `data_conclusione` `data_conclusione` date, CHANGE `data_pagamento` `data_pagamento` date; -ALTER TABLE `co_contratti` CHANGE `data_bozza` `data_bozza` date, CHANGE `data_accettazione` `data_accettazione` date, CHANGE `data_rifiuto` `data_rifiuto` date, CHANGE `data_conclusione` `data_conclusione` date; - -ALTER TABLE `co_movimenti` CHANGE `data` `data` date, CHANGE `data_documento` `data_documento` date; -ALTER TABLE `co_ordiniservizio` CHANGE `data_scadenza` `data_scadenza` date; -ALTER TABLE `co_ordiniservizio_pianificazionefatture` CHANGE `data_scadenza` `data_scadenza` date; -ALTER TABLE `co_righe_contratti` CHANGE `data_richiesta` `data_richiesta` date; -ALTER TABLE `co_righe_preventivi` CHANGE `data_evasione` `data_evasione` date; -ALTER TABLE `co_scadenziario` CHANGE `data_emissione` `data_emissione` date, CHANGE `scadenza` `scadenza` date, CHANGE `data_pagamento` `data_pagamento` date; -ALTER TABLE `dt_automezzi_tecnici` CHANGE `data_inizio` `data_inizio` date, CHANGE `data_fine` `data_fine` date; -ALTER TABLE `my_impianto_componenti` CHANGE `data` `data` date, CHANGE `data_sostituzione` `data_sostituzione` date; -ALTER TABLE `or_righe_ordini` CHANGE `data_evasione` `data_evasione` date; - --- Fix di alcuni problemi con le query dei widget -UPDATE `zz_widgets` SET `query` = 'SELECT CONCAT_WS(" ", REPLACE(REPLACE(REPLACE(FORMAT(SUM(qta),2), ",", "#"), ".", ","), "#", "."), "unità") AS dato FROM mg_articoli WHERE qta>0' WHERE `name` = 'Articoli in magazzino'; -UPDATE `zz_widgets` SET `query` = 'SELECT CONCAT_WS(" ", REPLACE(REPLACE(REPLACE(FORMAT(SUM(prezzo_acquisto*qta),2), ",", "#"), ".", ","), "#", "."), "€") AS dato FROM mg_articoli WHERE qta>0' WHERE `name` = 'Valore magazzino'; - --- Fix per i serial number -ALTER TABLE `mg_prodotti` ADD `id_riga_documento` int(11), ADD FOREIGN KEY (`id_riga_documento`) REFERENCES `co_righe_documenti`(`id`) ON DELETE CASCADE, ADD `id_riga_ordine` int(11), ADD FOREIGN KEY (`id_riga_ordine`) REFERENCES `or_righe_ordini`(`id`) ON DELETE CASCADE, ADD `id_riga_ddt` int(11), ADD FOREIGN KEY (`id_riga_ddt`) REFERENCES `dt_righe_ddt`(`id`) ON DELETE CASCADE, ADD `id_riga_intervento` int(11), ADD FOREIGN KEY (`id_riga_intervento`) REFERENCES `mg_articoli_interventi`(`id`) ON DELETE CASCADE, ADD `dir` enum('entrata', 'uscita') DEFAULT 'uscita', CHANGE `idarticolo` `id_articolo` int(11), ADD FOREIGN KEY (`id_articolo`) REFERENCES `mg_articoli`(`id`) ON DELETE SET NULL, CHANGE `serial` `serial` varchar(50), CHANGE `lotto` `lotto` varchar(50), CHANGE `altro` `altro` varchar(50); - -INSERT INTO `mg_prodotti` (`id_riga_documento`, `dir`, `id_articolo`, `serial`, `lotto`, `altro`) SELECT `id`, (SELECT `dir` FROM `co_tipidocumento` JOIN `co_documenti` ON `co_tipidocumento`.`id` = `co_documenti`.`idtipodocumento` WHERE `co_documenti`.`id` = `co_righe_documenti`.`iddocumento`), IF(`idarticolo` IN (SELECT `id` FROM `mg_articoli`), `idarticolo`, NULL), `serial`, `lotto`, `altro` FROM `co_righe_documenti`; - -INSERT INTO `mg_prodotti` (`id_riga_ordine`, `dir`, `id_articolo`, `serial`, `lotto`, `altro`) SELECT `id`, (SELECT `dir` FROM `or_tipiordine` JOIN `or_ordini` ON `or_tipiordine`.`id` = `or_ordini`.`idtipoordine` WHERE `or_ordini`.`id` = `or_righe_ordini`.`idordine`), IF(`idarticolo` IN (SELECT `id` FROM `mg_articoli`), `idarticolo`, NULL), `serial`, `lotto`, `altro` FROM `or_righe_ordini`; - -INSERT INTO `mg_prodotti` (`id_riga_ddt`, `dir`, `id_articolo`, `serial`, `lotto`, `altro`) SELECT `id`, (SELECT `dir` FROM `dt_tipiddt` JOIN `dt_ddt` ON `dt_tipiddt`.`id` = `dt_ddt`.`idtipoddt` WHERE `dt_ddt`.`id` = `dt_righe_ddt`.`idddt`), IF(`idarticolo` IN (SELECT `id` FROM `mg_articoli`), `idarticolo`, NULL), `serial`, `lotto`, `altro` FROM `dt_righe_ddt`; - -INSERT INTO `mg_prodotti` (`id_riga_intervento`, `dir`, `id_articolo`, `serial`, `lotto`, `altro`) SELECT `id`, 'entrata', IF(`idarticolo` IN (SELECT `id` FROM `mg_articoli`), `idarticolo`, NULL), `serial`, `lotto`, `altro` FROM `mg_articoli_interventi`; - -UPDATE `mg_prodotti` SET `serial` = NULL WHERE `serial` = ''; -UPDATE `mg_prodotti` SET `lotto` = NULL WHERE `lotto` = ''; -UPDATE `mg_prodotti` SET `altro` = NULL WHERE `altro` = ''; - -DELETE FROM `mg_prodotti` WHERE `serial` IS NULL AND `lotto` IS NULL AND `altro` IS NULL; - -ALTER TABLE `co_righe_documenti` DROP `serial`, DROP `altro`, DROP `lotto`; -ALTER TABLE `mg_articoli_interventi` DROP `serial`, DROP `altro`, DROP `lotto`; -ALTER TABLE `dt_righe_ddt` DROP `serial`, DROP `altro`, DROP `lotto`; -ALTER TABLE `or_righe_ordini` DROP `serial`, DROP `altro`, DROP `lotto`; -ALTER TABLE `co_righe_preventivi` DROP `serial`, DROP `altro`, DROP `lotto`; - -UPDATE `mg_articoli` SET `abilita_serial` = 1 WHERE `id` IN (SELECT `id_articolo` FROM `mg_prodotti`); -UPDATE `co_righe_documenti` SET `abilita_serial` = 1 WHERE `idarticolo` IN (SELECT `id_articolo` FROM `mg_prodotti`); -UPDATE `dt_righe_ddt` SET `abilita_serial` = 1 WHERE `idarticolo` IN (SELECT `id_articolo` FROM `mg_prodotti`); -UPDATE `mg_articoli_interventi` SET `abilita_serial` = 1 WHERE `idarticolo` IN (SELECT `id_articolo` FROM `mg_prodotti`); -UPDATE `or_righe_ordini` SET `abilita_serial` = 1 WHERE `idarticolo` IN (SELECT `id_articolo` FROM `mg_prodotti`); - --- Rimozione del campo descrizione_articolo (inutilizzato) da mg_movimenti -ALTER TABLE `mg_movimenti` DROP `descrizione_articolo`; - --- Rimozione sconto/magg. per i preventivi -UPDATE `co_righe_preventivi` SET `sconto_unitario` = `prc_guadagno`, `tipo_sconto` = 'PRC', `sconto` = `prc_guadagno` * `qta` WHERE `prc_guadagno` != 0; -ALTER TABLE `co_righe_preventivi` DROP `prc_guadagno`; - --- Rimozione del campo descrizione2 da co_iva e aggiunta delle diciture fisse in fattura (per la stampa) -ALTER TABLE `co_iva` DROP `descrizione2`; -UPDATE `co_iva` SET `dicitura` = 'Senza addebito iva ex art. 74 comma 8-9 del DPR 633/72' WHERE `descrizione` = 'Esente art. 74'; -UPDATE `co_iva` SET `dicitura` = 'Operazione soggetta a reverse charge ex art. 17, comma 6, DPR 633/72' WHERE `descrizione` = 'Art. 17 comma 6 DPR 633/72' OR `descrizione` = 'Art. 17 comma 6 DPR 633/72 4%' OR `descrizione` = 'Art. 17 comma 6 DPR 633/72 10%' OR `descrizione` = 'Art. 17 comma 6 DPR 633/72 20%' OR `descrizione` = 'Art. 17 comma 6 DPR 633/72 22%'; - --- Aggiunta campi in co_pagamenti per la selezione del conto di default -ALTER TABLE `co_pagamenti` ADD `idconto_vendite` int(11), ADD `idconto_acquisti` int(11); - --- Aggiunta del modulo Stampe contabili -INSERT INTO `zz_modules` (`id`, `name`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Stampe contabili', 'stampe_contabili', 'custom', '', 'fa fa-angle-right', '2.3', '2.3', '1', NULL, '1', '1'); -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Stampe contabili' AND `t2`.`name` = 'Contabilità') SET `t1`.`parent` = `t2`.`id`; - --- Aggiunta del campo per introdurre l'help nei widget -ALTER TABLE `zz_widgets` ADD `help` varchar(255); - --- ALTER TABLE `my_componenti_interventi` ADD PRIMARY KEY (`id_intervento`, `id_componente`); --- ALTER TABLE `my_impianti_interventi` ADD PRIMARY KEY (`idintervento`, `idimpianto`); --- ALTER TABLE `co_righe_documenti`ADD FOREIGN KEY (`idintervento`) REFERENCES `in_interventi`(`id`) ON DELETE CASCADE; - --- Aggiunta delle mappe Google -INSERT INTO `zz_settings` (`nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES ('Google Maps API key', '', 'string', '1', 'Generali'); - -ALTER TABLE `an_anagrafiche` ADD `gaddress` varchar(255), ADD `lat` float(10, 6), ADD `lng` float(10, 6); -ALTER TABLE `an_sedi` ADD `gaddress` varchar(255), ADD `lat` float(10, 6), ADD `lng` float(10, 6); - --- Aggiunta del modulo Statistiche -INSERT INTO `zz_modules` (`id`, `name`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Statistiche', 'statistiche', 'custom', '', 'fa fa-bar-chart', '2.3', '2.3', '1', NULL, '1', '1'); - -UPDATE `zz_modules` `t1` INNER JOIN (SELECT MAX(`order`) AS `order` FROM `zz_modules`) `t2` ON (`t1`.`name` = 'Statistiche') SET `t1`.`order` = `t2`.`order`+1; -UPDATE `zz_modules` `t1` INNER JOIN (SELECT MAX(`order`) AS `order` FROM `zz_modules`) `t2` ON (`t1`.`name` = 'Strumenti') SET `t1`.`order` = `t2`.`order`+1; - --- Impostazione dei titoli di default -UPDATE `zz_modules` SET `title` = `name` WHERE `title` = ''; - --- Nuova struttura per i plugin Ddt del cliente e Impianti del cliente in Anagrafiche -UPDATE `zz_plugins` SET `script` = '', `options` = ' { "main_query": [ { "type": "table", "fields": "Numero, Data, Descrizione, Qtà", "query": "SELECT dt_ddt.id, (SELECT `id` FROM `zz_modules` WHERE `name` = ''Ddt di vendita'') AS _link_module_, dt_ddt.id AS _link_record_, IF(dt_ddt.numero_esterno = '''', dt_ddt.numero, dt_ddt.numero_esterno) AS Numero, DATE_FORMAT(dt_ddt.data, ''%d/%m/%Y'') AS Data, dt_righe_ddt.descrizione AS `Descrizione`, CONCAT(REPLACE(REPLACE(REPLACE(FORMAT(dt_righe_ddt.qta, 2), '','', ''#''), ''.'', '',''), ''#'', ''.''), '' '', dt_righe_ddt.um) AS `Qtà` FROM dt_ddt JOIN dt_righe_ddt ON dt_ddt.id=dt_righe_ddt.idddt WHERE dt_ddt.idanagrafica=|idanagrafica| HAVING 2=2 ORDER BY dt_ddt.id DESC"} ]}', `directory` = '', `version` = '2.3', `compatibility` = '2.*' WHERE `name` = 'Ddt del cliente'; -UPDATE `zz_plugins` SET `script` = '', `options` = ' { "main_query": [ { "type": "table", "fields": "Matricola, Nome, Data, Descrizione", "query": "SELECT id, (SELECT `id` FROM `zz_modules` WHERE `name` = ''MyImpianti'') AS _link_module_, id AS _link_record_, matricola AS Matricola, nome AS Nome, DATE_FORMAT(data, ''%d/%m/%Y'') AS Data, descrizione AS Descrizione FROM my_impianti WHERE idanagrafica=|idanagrafica| HAVING 2=2 ORDER BY id DESC"} ]}', `directory` = '', `version` = '2.3', `compatibility` = '2.*' WHERE `name` = 'Impianti del cliente'; - --- Aggiunta del supporto alla sincronizzazione interventi -ALTER TABLE `in_interventi_tecnici` ADD `uid` VARCHAR(255) NOT NULL AFTER `prezzo_dirittochiamata_tecnico`, ADD `summary` VARCHAR(255) NOT NULL AFTER `uid`; -ALTER TABLE `in_interventi` ADD `deleted` TINYINT NOT NULL DEFAULT '0' AFTER `data_invio`; - --- Fix nella conversione dei listini precedenti -UPDATE `mg_listini` SET `prc_guadagno` = - `prc_guadagno`; - --- Aggiunta pagamento di default "Bonifico bancario" -INSERT INTO `co_pagamenti` (`id`, `descrizione`, `giorno`, `num_giorni`, `prc`, `idconto_vendite`, `idconto_acquisti`) VALUES (NULL, 'Bonifico bancario', '0', '10', '100', NULL, NULL); - --- Per Dashboard e Articoli i widgets vanno in alto -UPDATE `zz_widgets` SET `location` = 'controller_top' WHERE `zz_widgets`.`id_module` = (SELECT id FROM zz_modules WHERE name = 'Dashboard') OR `zz_widgets`.`id_module` = (SELECT id FROM zz_modules WHERE name = 'Articoli'); - --- Disabilito widgets 'Ordini di servizio da impostare' e 'Rate contrattuali' -UPDATE `zz_widgets` SET `enabled` = '0' WHERE `zz_widgets`.`name` = 'Ordini di servizio da impostare' OR `zz_widgets`.`name` = 'Rate contrattuali'; - --- Aggiunta articolo su contratti -ALTER TABLE `co_righe2_contratti` ADD `idarticolo` INT NOT NULL AFTER `idcontratto`; - --- Campo per identificare le righe descrittive documenti/ddt/preventivi/contratti/ordini -ALTER TABLE `co_righe_documenti` ADD `is_descrizione` TINYINT(1) NOT NULL AFTER `idcontratto`; -ALTER TABLE `dt_righe_ddt` ADD `is_descrizione` TINYINT(1) NOT NULL AFTER `idarticolo`; -ALTER TABLE `co_righe_preventivi` ADD `is_descrizione` TINYINT(1) NOT NULL AFTER `idarticolo`; -ALTER TABLE `co_righe2_contratti` ADD `is_descrizione` TINYINT(1) NOT NULL AFTER `idarticolo`; -ALTER TABLE `or_righe_ordini` ADD `is_descrizione` TINYINT(1) NOT NULL AFTER `idarticolo`; - --- Aggiunta flag "servizio" su articolo -ALTER TABLE `mg_articoli` ADD `servizio` TINYINT(1) NOT NULL AFTER `id_sottocategoria`; - --- Aggiunto lo stato ddt "Parzialmente fatturato" e cambiato lo stato "Pagato" in "Fatturato" -UPDATE `dt_statiddt` SET `descrizione` = 'Fatturato' WHERE `dt_statiddt`.`descrizione` = 'Pagato'; -INSERT INTO `dt_statiddt` (`id`, `descrizione`, `icona`) VALUES (NULL, 'Parzialmente fatturato', 'fa fa-clock-o text-warning'); diff --git a/update/2_3_1.php b/update/2_3_1.php deleted file mode 100755 index 587ca560a..000000000 --- a/update/2_3_1.php +++ /dev/null @@ -1,128 +0,0 @@ - $value) { - $files[$key] = realpath(base_dir().'/'.$value); -} - -delete($files); - -// File .html dei moduli di default -// Per un problema sulla lunghezza massima del path su glob è necessario dividere le cartelle dei moduli di default da pulire -$dirs = [ - 'aggiornamenti', - 'anagrafiche', - 'articoli', - 'automezzi', - 'backup', - 'beni', - 'categorie', - 'causali', - 'contratti', - 'dashboard', - 'ddt', - 'fatture', - 'gestione_componenti', - 'interventi', - 'iva', - 'listini', - 'misure', - 'my_impianti', - 'opzioni', - 'ordini', - 'pagamenti', - 'partitario', - 'porti', - 'preventivi', - 'primanota', - 'scadenzario', - 'stati_intervento', - 'tecnici_tariffe', - 'tipi_anagrafiche', - 'tipi_intervento', - 'utenti', - 'viste', - 'voci_servizio', - 'zone', -]; - -$pieces = array_chunk($dirs, 5); - -foreach ($pieces as $piece) { - $files = glob(base_dir().'/modules/{'.implode(',', $piece).'}/*.html', GLOB_BRACE); - delete($files); -} - -/* -* Rimozione file e cartelle deprecati [2.3.1] -*/ - -// File e cartelle deprecate -$files = [ - 'templates/interventi/pdfgen.interventi.php', - 'templates/ddt/pdfgen.ddt.php', - 'templates/ordini/pdfgen.ordini.php', - 'templates/fatture/fattura_body.html', - 'templates/fatture/fattura.html', - 'templates/contratti/contratto_body.html', - 'templates/contratti/contratto.html', - 'templates/preventivo/preventivo_body.html', - 'templates/preventivo/preventivo.html', -]; - -foreach ($files as $key => $value) { - $files[$key] = realpath(base_dir().'/'.$value); -} - -delete($files); diff --git a/update/2_3_1.sql b/update/2_3_1.sql deleted file mode 100755 index 4aa9eb935..000000000 --- a/update/2_3_1.sql +++ /dev/null @@ -1,71 +0,0 @@ --- Rimosso il referente dalla lista sedi, per non mostrare sedi duplicate nella lista sedi -UPDATE `zz_plugins` SET `options` = ' { "main_query": [ { "type": "table", "fields": "Nome, Indirizzo, Città, CAP, Provincia", "query": "SELECT an_sedi.id, an_sedi.nomesede AS Nome, an_sedi.indirizzo AS Indirizzo, an_sedi.citta AS Città, an_sedi.cap AS CAP, an_sedi.provincia AS Provincia FROM an_sedi WHERE 1=1 AND an_sedi.idanagrafica=|idanagrafica| HAVING 2=2 ORDER BY an_sedi.id DESC"} ]}', `created_at` = NULL WHERE `zz_plugins`.`name` = 'Sedi'; - --- Aggiunta possibilità di collegare allegati anche ai plugins -ALTER TABLE `zz_files` ADD `id_plugin` int(11) AFTER `id_module`; - --- Aggiunto valore NULL a idarticolo in co_righe2_contratti --- ALTER TABLE `co_righe2_contratti` CHANGE `idarticolo` `idarticolo` int(11); --- UPDATE `co_righe2_contratti` SET `idarticolo` = NULL WHERE `idarticolo` = 0; - --- Aggiornamento ORDER BY nei moduli Fatture, DDT, Ordini, Preventivi, Contratti e Interventi -UPDATE `zz_views` SET `order_by` = 'CAST(numero_esterno AS UNSIGNED)' WHERE `name` = 'Numero' AND `id_module` IN (SELECT `id` FROM `zz_modules` WHERE `name` IN ('Fatture di vendita', 'Fatture di acquisto', 'Ordini cliente', 'Ordini fornitore', 'Ddt di vendita', 'Ddt di acquisto')); - -UPDATE `zz_views` SET `order_by` = 'CAST(in_interventi.codice AS UNSIGNED)' WHERE `name` = 'Numero' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'); - -UPDATE `zz_views` SET `order_by` = 'CAST(numero AS UNSIGNED)' WHERE `name` = 'Numero' AND `id_module` IN (SELECT `id` FROM `zz_modules` WHERE `name` IN ('Ordini Preventivi', 'Contratti')); - --- Query per ignorare i punti nella ricerca in Ragione sociale --- UPDATE `zz_views` SET `search_inside` = CONCAT('REPLACE(', `query`, ', ''.'', '''') LIKE |search|') WHERE `name` = 'Ragione sociale'; - --- Aggiornate le viste standard, separando i simboli < e > per non dare errore nell'aggiornamento -UPDATE `zz_views` SET `query` = 'IF(scadenza < NOW(), \'#ff7777\', \'\')' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Scadenzario') AND `name` = '_bg_'; -UPDATE `zz_views` SET `query` = 'CONCAT(co_tipidocumento.descrizione, CONCAT(\' numero \', IF(numero_esterno <> \'\', numero_esterno, numero)))' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Scadenzario') AND `name` = 'Data emissione'; -UPDATE `zz_views` SET `query` = 'GROUP_CONCAT(CASE WHEN totale > 0 THEN co_pianodeiconti3.descrizione ELSE NULL END)' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Prima nota') AND `name` = 'Conto avere'; -UPDATE `zz_views` SET `query` = 'GROUP_CONCAT(CASE WHEN totale < 0 THEN co_pianodeiconti3.descrizione ELSE NULL END)' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Prima nota') AND `name` = 'Conto dare'; - --- Spostamento conti di apertura e chiusura stato patrimoniale sotto lo stato patrimoniale -UPDATE `co_pianodeiconti2` SET `idpianodeiconti1`=1 WHERE `descrizione` = 'Perdite e profitti'; - --- Aggiungo 1=1 nel WHERE e 2=2 nel HAVING per il widget clienti in anagrafica -UPDATE `zz_widgets` SET `query` = 'SELECT COUNT(an_anagrafiche.idanagrafica) AS dato FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE 1=1 AND descrizione="Cliente" AND deleted=0 HAVING 2=2' WHERE `zz_widgets`.`name` = 'Numero di clienti'; - --- Aggiungo 1=1 nel WHERE e 2=2 nel HAVING per il widget tecnici in anagrafica -UPDATE `zz_widgets` SET `query` = 'SELECT COUNT(an_anagrafiche.idanagrafica) AS dato FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE 1=1 AND descrizione="Tecnico" AND deleted=0 HAVING 2=2' WHERE `zz_widgets`.`name` = 'Numero di tecnici'; - --- Aggiungo 1=1 nel WHERE e 2=2 nel HAVING per il widget fornitori in anagrafica -UPDATE `zz_widgets` SET `query` = 'SELECT COUNT(an_anagrafiche.idanagrafica) AS dato FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE 1=1 AND descrizione="Fornitore" AND deleted=0 HAVING 2=2' WHERE `zz_widgets`.`name` = 'Numero di fornitori'; - --- Aggiungo 1=1 nel WHERE e 2=2 nel HAVING per il widget agenti in anagrafica -UPDATE `zz_widgets` SET `query` = 'SELECT COUNT(an_anagrafiche.idanagrafica) AS dato FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE 1=1 AND descrizione="Agente" AND deleted=0 HAVING 2=2' WHERE `zz_widgets`.`name` = 'Numero di agenti'; - --- Aggiungo 1=1 nel WHERE e 2=2 nel HAVING per il widget vettori in anagrafica -UPDATE `zz_widgets` SET `query` = 'SELECT COUNT(an_anagrafiche.idanagrafica) AS dato FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE 1=1 AND descrizione="Vettore" AND deleted=0 HAVING 2=2' WHERE `zz_widgets`.`name` = 'Numero di vettori'; - --- Aggiungo 1=1 nel WHERE e 2=2 nel HAVING per il widget tutte le anagrafiche -UPDATE `zz_widgets` SET `query` = 'SELECT COUNT(an_anagrafiche.idanagrafica) AS dato FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE 1=1 AND deleted=0 HAVING 2=2' WHERE `zz_widgets`.`name` = 'Tutte le anagrafiche'; - --- Aggiornamento widget "Crediti da clienti" anche con totali parziali -UPDATE `zz_widgets` SET `query` = 'SELECT CONCAT_WS(" ", REPLACE(REPLACE(REPLACE(FORMAT(da_pagare-pagato, 2), ",", "#"), ".", ","), "#", "."), "€") AS dato FROM (co_scadenziario INNER JOIN co_documenti ON co_scadenziario.iddocumento=co_documenti.id) INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE co_tipidocumento.dir=\'entrata\'' WHERE `zz_widgets`.`name` = 'Crediti da clienti'; - --- Aggiornamento widget "Debiti verso fornitori" anche con totali parziali -UPDATE `zz_widgets` SET `query` = 'SELECT CONCAT_WS(" ", REPLACE(REPLACE(REPLACE(FORMAT( -(da_pagare-pagato), 2), ",", "#"), ".", ","), "#", "."), "€") AS dato FROM (co_scadenziario INNER JOIN co_documenti ON co_scadenziario.iddocumento=co_documenti.id) INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE co_tipidocumento.dir=\'uscita\'' WHERE `zz_widgets`.`name` = 'Debiti verso fornitori'; - --- Aggiungo flag deleted per gli stati intervento -ALTER TABLE `in_statiintervento` ADD `deleted` BOOLEAN NOT NULL DEFAULT FALSE AFTER `completato`; - --- Aggiorno query modulo stati intervento -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `in_statiintervento` WHERE 1=1 AND deleted = 0 HAVING 2=2' WHERE `zz_modules`.`name` = 'Stati di intervento'; - --- Aggiungo il flag can_delete ed elimino il flag `default` in quanto non serve più -ALTER TABLE `in_statiintervento` ADD `can_delete` BOOLEAN NOT NULL DEFAULT TRUE AFTER `default`; -ALTER TABLE `in_statiintervento` DROP `default`; - --- Aggiunti come eliminabili gli stati "Chiamata" e "In programmazione" -UPDATE `in_statiintervento` SET `can_delete` = 1 WHERE `idstatointervento` IN( 'CALL', 'WIP' ); - --- Aggiunti come non eliminabili ma modificabili gli stati "Fatturato" e "Completato" -UPDATE `in_statiintervento` SET `can_delete` = 0 WHERE `idstatointervento` IN( 'FAT', 'OK' ); - --- Impostazione di tutti gli eventuali altri tipi di intervento a modificabili e cancellabili -UPDATE `in_statiintervento` SET `can_delete` = 1 WHERE `idstatointervento` NOT IN( 'FAT', 'OK', 'CALL', 'WIP' ); \ No newline at end of file diff --git a/update/2_4.php b/update/2_4.php deleted file mode 100755 index d912e7947..000000000 --- a/update/2_4.php +++ /dev/null @@ -1,36 +0,0 @@ - $value) { - $files[$key] = realpath(base_dir().'/'.$value); -} - -delete($files); diff --git a/update/2_4.sql b/update/2_4.sql deleted file mode 100755 index 14ea1c4ca..000000000 --- a/update/2_4.sql +++ /dev/null @@ -1,343 +0,0 @@ --- Lo stato 'FAT' è da considerarsi completato -UPDATE `in_statiintervento` SET `completato` = '1' WHERE `in_statiintervento`.`idstatointervento` = 'FAT'; - --- Nuovi campi per iva su righe 'Materiale utilizzato' in interventi -ALTER TABLE `mg_articoli_interventi` CHANGE `idiva_vendita` `idiva` INT(11) NOT NULL; -ALTER TABLE `mg_articoli_interventi` ADD `desc_iva` VARCHAR(255) NOT NULL AFTER `idiva`, ADD `iva` DECIMAL(12,4) NOT NULL AFTER `desc_iva`; - --- Nuovi campi per iva su righe 'Altre spese' in interventi -ALTER TABLE `in_righe_interventi` ADD `idiva` INT(11) NOT NULL AFTER `prezzo_acquisto`, ADD `desc_iva` VARCHAR(255) NOT NULL AFTER `idiva`, ADD `iva` DECIMAL(12,4) NOT NULL AFTER `desc_iva`; - --- --- Struttura della tabella `zz_prints` --- - -CREATE TABLE IF NOT EXISTS `zz_prints` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_module` int(11) NOT NULL, - `is_record` BOOLEAN NOT NULL DEFAULT 1, - `name` varchar(255) NOT NULL, - `title` varchar(255) NOT NULL, - `directory` varchar(50) NOT NULL, - `previous` varchar(50) NOT NULL, - `options` text NOT NULL, - `icon` varchar(50) NOT NULL, - `version` varchar(15) NOT NULL, - `compatibility` varchar(1000) NOT NULL, - `order` int(11) NOT NULL, - `main` tinyint(1) NOT NULL, - `default` tinyint(1) NOT NULL, - `enabled` tinyint(1) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- Inserimento delle stampe di base -INSERT INTO `zz_prints` (`id_module`, `name`, `directory`, `options`, `previous`, `enabled`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'), 'Fattura di vendita', 'fatture', '', 'iddocumento', 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), 'Riepilogo interventi', 'riepilogo_interventi', '', '', 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Articoli'), 'Inventario magazzino', 'magazzino_inventario', '', '', 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Piano dei conti'), 'Mastrino', 'partitario_mastrino', '', 'idconto', 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Scadenzario'), 'Scadenzario', 'scadenzario', '', '', 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stampe contabili'), 'Registro IVA', 'registro_iva', '', '', 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stampe contabili'), 'Fatturato', 'fatturato', '', '', 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stampe contabili'), 'Spesometro', 'spesometro', '', '', 1, 1); - -UPDATE `zz_prints` SET `is_record` = 0 WHERE `name` = 'Riepilogo interventi'; - --- Inserimento delle stampe con prezzo disabilitato -INSERT INTO `zz_prints` (`id_module`, `name`, `directory`, `options`, `previous`, `enabled`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Contratti'), 'Contratto (senza costi)', 'contratti', '{"pricing":false}', 'idcontratto', 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), 'Intervento (senza costi)', 'interventi', '{"pricing":false}', 'idintervento', 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Ordini cliente'), 'Ordine cliente (senza costi)', 'ordini', '{"pricing":false}', 'idordine', 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Ordini fornitore'), 'Ordine fornitore', 'ordini', '{"pricing":false}', 'idordine', 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Ddt di vendita'), 'Ddt di vendita (senza costi)', 'ddt', '{"pricing":false}', 'idddt', 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi'), 'Preventivo (senza costi)', 'preventivi', '{"pricing":false}', 'idpreventivo', 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Contratti'), 'Consuntivo contratto (senza costi)', 'contratti_cons', '{"pricing":false}', 'idcontratto', 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi'), 'Consuntivo preventivo (senza costi)', 'preventivi_cons', '{"pricing":false}', 'idpreventivo', 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Contratti'), 'Ordine di servizio (senza costi)', 'interventi_ordiniservizio', '{"pricing":false}', 'idintervento', 1, 1); - --- Inserimento delle stampe con prezzo abilitate -INSERT INTO `zz_prints` (`id_module`, `name`, `directory`, `options`, `main`, `previous`, `enabled`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Contratti'), 'Contratto', 'contratti', '{"pricing":true}', 1, 'idcontratto', 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), 'Intervento', 'interventi', '{"pricing":true}', 1, 'idintervento', 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Ordini cliente'), 'Ordine cliente', 'ordini', '{"pricing":true}', 1, 'idordine', 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Ddt di vendita'), 'Ddt di vendita', 'ddt', '{"pricing":true}', 1, 'idddt', 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi'), 'Preventivo', 'preventivi', '{"pricing":true}', 1, 'idpreventivo', 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Contratti'), 'Consuntivo contratto', 'contratti_cons', '{"pricing":true}', 1, 'idcontratto', 1, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi'), 'Consuntivo preventivo', 'preventivi_cons', '{"pricing":true}', 1, 'idpreventivo', 1, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Contratti'), 'Ordine di servizio', 'interventi_ordiniservizio', '{"pricing":true}', 1, 'idintervento', 1, 0); - --- Impostazione dei titoli di default -UPDATE `zz_prints` SET `title` = `name` WHERE `title` = ''; - --- Impostazione delle icone di default -UPDATE `zz_prints` SET `icon` = 'fa fa-print' WHERE `icon` = ''; - --- DELETE FROM `zz_settings` WHERE `nome` = 'Stampa i prezzi sui contratti'; --- DELETE FROM `zz_settings` WHERE `nome` = 'Stampa i prezzi sui ddt'; --- DELETE FROM `zz_settings` WHERE `nome` = 'Visualizza i costi sulle stampe degli interventi'; --- DELETE FROM `zz_settings` WHERE `nome` = 'Stampa i prezzi sugli ordini'; --- DELETE FROM `zz_settings` WHERE `nome` = 'Stampa i prezzi sui preventivi'; - --- --- Struttura della tabella `zz_smtp` --- - -CREATE TABLE IF NOT EXISTS `zz_smtp` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `note` varchar(255) NOT NULL, - `server` varchar(255) NOT NULL, - `port` varchar(255) NOT NULL, - `username` varchar(255) NOT NULL, - `password` varchar(255) NOT NULL, - `from_name` varchar(255) NOT NULL, - `from_address` varchar(255) NOT NULL, - `encryption` enum('','tls','ssl') NOT NULL, - `pec` tinyint(1) NOT NULL, - `main` tinyint(1) NOT NULL, - `deleted` tinyint(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Struttura della tabella `zz_emails` --- - -CREATE TABLE IF NOT EXISTS `zz_emails` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_module` int(11) NOT NULL, - `id_smtp` int(11) NOT NULL, - `name` varchar(255) NOT NULL, - `icon` varchar(50) NOT NULL, - `subject` varchar(255) NOT NULL, - `reply_to` varchar(255) NOT NULL, - `cc` varchar(255) NOT NULL, - `bcc` varchar(255) NOT NULL, - `body` text NOT NULL, - `read_notify` tinyint(1) NOT NULL, - `main` tinyint(1) NOT NULL, - `deleted` tinyint(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Struttura della tabella `zz_emails` --- - -CREATE TABLE IF NOT EXISTS `zz_email_print` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_email` int(11) NOT NULL, - `id_print` int(11) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- Aggiunta dei moduli dedicati alla gestione delle email -INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Account email', 'Account email', 'smtp', 'SELECT |select| FROM zz_smtp WHERE 1=1 AND deleted = 0 HAVING 2=2 ORDER BY `name`', 'fa fa-user-o', '2.3', '2.3', '10', NULL, 1, 1); -INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Template email', 'Template email', 'emails', 'SELECT |select| FROM zz_emails WHERE 1=1 AND deleted = 0 HAVING 2=2 ORDER BY `name`', 'fa fa-pencil-square-o', '2.3', '2.3', '10', NULL, 1, 1); - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `enabled`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Account email'), 'id', 'id', 1, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Account email'), '#', 'id', 2, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Account email'), 'Nome account', 'name', 3, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Account email'), 'Nome visualizzato', 'from_name', 4, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Account email'), 'Email mittente', 'from_address', 5, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Template email'), 'id', 'id', 1, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Template email'), '#', 'id', 2, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Template email'), 'Nome', 'name', 3, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Template email'), 'Oggetto', 'subject', 4, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Template email'), 'Modulo', '(SELECT name FROM zz_modules WHERE id=zz_emails.id_module)', 5, 1, 0, 1, 1); - - --- Raggruppamento dei moduli per le email -INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Gestione email', 'Gestione email', '', '', '', 'fa fa-envelope', '2.3', '2.3', '1', NULL, '1', '1'); - -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Account email' AND `t2`.`name` = 'Gestione email') SET `t1`.`parent` = `t2`.`id`; -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Template email' AND `t2`.`name` = 'Gestione email') SET `t1`.`parent` = `t2`.`id`; - --- Importazione dell'account email di default -INSERT INTO `zz_smtp` (`id`, `name`, `server`, `port`, `username`, `password`, `encryption`, `main`) VALUES (NULL, 'Account email da Impostazioni', (SELECT `valore` FROM `zz_settings` WHERE `nome` = 'Server SMTP'), (SELECT `valore` FROM `zz_settings` WHERE `nome` = 'Porta SMTP'), (SELECT `valore` FROM `zz_settings` WHERE `nome` = 'Username SMTP'), (SELECT `valore` FROM `zz_settings` WHERE `nome` = 'Password SMTP'), (SELECT `valore` FROM `zz_settings` WHERE `nome` = 'Sicurezza SMTP'), 1); - -DELETE FROM `zz_settings` WHERE -(`nome` = 'Server SMTP') OR -(`nome` = 'Porta SMTP') OR -(`nome` = 'Username SMTP') OR -(`nome` = 'Password SMTP') OR -(`nome` = 'Sicurezza SMTP'); - --- SEGNENTI --- Modifico co_documenti per aggiungere riferimento al segmento -ALTER TABLE `co_documenti` ADD `id_segment` int(11) NOT NULL ; - --- Creo tabella segmenti -CREATE TABLE IF NOT EXISTS `zz_segments` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_module` int(11) NOT NULL, - `name` varchar(255) NOT NULL, - `clause` TEXT NOT NULL, - `position` enum('WHR', 'HVN') NOT NULL DEFAULT 'WHR', - `pattern` varchar(255) NOT NULL, - `note` text NOT NULL, - `predefined` BOOLEAN NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- Popolo con i segmenti di default -INSERT INTO `zz_segments` (`id`, `id_module`, `name`, `clause`, `position`, `pattern`,`note`, `predefined`) VALUES -(1, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'), 'Standard vendite', '1=1', 'WHR', IF((SELECT COUNT(id) FROM co_documenti) > 0, (SELECT `valore` FROM `zz_settings` WHERE `nome` = 'Formato numero secondario fattura'), '####/YYYY'), '', 1), -(2, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di acquisto'), 'Standard acquisti', '1=1', 'WHR', '#', '', 1); - --- Rimuovo impostazione per numero secondario fattura -DELETE FROM `zz_settings` WHERE `zz_settings`.`nome` = 'Formato numero secondario fattura'; - --- Collego le fatture esistenti al segmento di default -UPDATE `co_documenti` SET `id_segment`='1' WHERE `idtipodocumento` IN (SELECT `id` FROM `co_tipidocumento` WHERE `co_tipidocumento`.`dir`='entrata'); -UPDATE `co_documenti` SET `id_segment`='2' WHERE `idtipodocumento` IN (SELECT `id` FROM `co_tipidocumento` WHERE `co_tipidocumento`.`dir`='uscita'); - --- Innesto modulo segmenti sotto "Strumenti" -INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Segmenti', 'Segmenti', 'segmenti', '{ "main_query": [ { "type": "table", "fields": "id, Nome, Modulo, Maschera, Note, Predefinito", "query": "SELECT `id`, (IF(predefined=1, ''Sì'', ''No'')) AS `Predefinito`, `name` AS `Nome`, (SELECT name FROM zz_modules WHERE id = zz_segments.id_module) AS Modulo, `pattern` AS `Maschera`, `note` AS `Note` FROM `zz_segments` HAVING 2=2 ORDER BY name, id_module"} ]}', '', 'fa fa-database', '2.4', '2.4', 1, NULL, 1, 1); -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Segmenti' AND `t2`.`name` = 'Strumenti') SET `t1`.`parent` = `t2`.`id`; - --- Aggiorno widget Fatturato con i sezionali -UPDATE `zz_widgets` SET `query` = 'SELECT CONCAT_WS(" ", REPLACE(REPLACE(REPLACE(FORMAT(SUM((SELECT SUM(subtotale+iva-sconto) FROM co_righe_documenti WHERE iddocumento=co_documenti.id)+iva_rivalsainps+rivalsainps+bollo-ritenutaacconto), 2), ",", "#"), ".", ","), "#", "."), "€") AS dato FROM co_documenti WHERE idtipodocumento IN (SELECT id FROM co_tipidocumento WHERE dir="entrata") |segment| AND data >= "|period_start|" AND data <= "|period_end|" AND 1=1' WHERE `zz_widgets`.`name` = 'Fatturato'; - --- Aggiorno widget Acquisti con i sezionali -UPDATE `zz_widgets` SET `query` = 'SELECT CONCAT_WS(" ", REPLACE(REPLACE(REPLACE(FORMAT((SELECT ABS(SUM(da_pagare))), 2), ",", "#"), ".", ","), "#", "."), "€") AS dato FROM (co_scadenziario INNER JOIN co_documenti ON co_scadenziario.iddocumento=co_documenti.id) INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE dir=''uscita'' |segment| AND data_emissione >= "|period_start|" AND data_emissione <= "|period_end|"' WHERE `zz_widgets`.`name` = 'Acquisti'; - --- Aggiorno widget Crediti da clienti con i sezionali -UPDATE `zz_widgets` SET `query` = 'SELECT CONCAT_WS(" ", REPLACE(REPLACE(REPLACE(FORMAT(SUM((SELECT SUM(subtotale+iva-sconto) FROM co_righe_documenti WHERE iddocumento=co_documenti.id)+iva_rivalsainps+rivalsainps+bollo-ritenutaacconto), 2), ",", "#"), ".", ","), "#", "."), "€") AS dato FROM co_documenti WHERE idtipodocumento IN (SELECT id FROM co_tipidocumento WHERE dir="entrata") AND idstatodocumento = (SELECT id FROM co_statidocumento WHERE descrizione="Emessa") |segment| AND data >= "|period_start|" AND data <= "|period_end|" AND 1=1' WHERE `zz_widgets`.`name` = 'Crediti da clienti' ; - --- Aggiorno widget Debiti verso fornitori con i sezionali -UPDATE `zz_widgets` SET `query` = 'SELECT CONCAT_WS('' '', REPLACE(REPLACE(REPLACE(FORMAT((SELECT ABS(SUM(da_pagare-pagato))), 2), '','', ''#''), ''.'', '',''),''#'', ''.''), ''€'') AS dato FROM (co_scadenziario INNER JOIN co_documenti ON co_scadenziario.iddocumento=co_documenti.id) INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE co_tipidocumento.dir=''uscita'' |segment| AND data_emissione >= "|period_start|" AND data_emissione <= "|period_end|"' WHERE `zz_widgets`.`name` = 'Debiti verso fornitori'; - --- Aggiorno i moduli Fattura con i sezionali -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_documenti` INNER JOIN `co_tipidocumento` ON `co_documenti`.`idtipodocumento` = `co_tipidocumento`.`id` WHERE 1=1 AND `dir` = ''uscita'' |segment| AND `data` >= ''|period_start|'' AND `data` <= ''|period_end|'' HAVING 2=2 ORDER BY `data` DESC, CAST(IF(numero_esterno='''', numero, numero_esterno) AS UNSIGNED) DESC' WHERE `name` = 'Fatture di acquisto'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_documenti` INNER JOIN `co_tipidocumento` ON `co_documenti`.`idtipodocumento` = `co_tipidocumento`.`id` WHERE 1=1 AND `dir` = ''entrata'' |segment| AND `data` >= ''|period_start|'' AND `data` <= ''|period_end|'' HAVING 2=2 ORDER BY `data` DESC, CAST(numero_esterno AS UNSIGNED) DESC' WHERE `name` = 'Fatture di vendita'; - --- Help text per widget Fatturato -UPDATE `zz_widgets` SET `help` = 'Fatturato IVA inclusa.' WHERE `zz_widgets`.`name` = 'Fatturato'; - --- --- Struttura della tabella `zz_fields` --- - -CREATE TABLE IF NOT EXISTS `zz_fields` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_module` int(11), - `id_plugin` int(11), - `name` varchar(255) NOT NULL, - `html_name` varchar(255) NOT NULL, - `content` text NOT NULL, - `options` text, - `order` int(11) NOT NULL, - `on_add` boolean NOT NULL, - `top` boolean NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- --- Struttura della tabella `zz_fields` --- - -CREATE TABLE IF NOT EXISTS `zz_field_record` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_field` int(11) NOT NULL, - `id_record` int(11) NOT NULL, - `value` text NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- Aggiunta modulo di importazione -INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES -(NULL, 'Import', 'Import', 'import', 'custom', '', 'fa fa-file-o', '2.4', '2.4', 1, NULL, 1, 1); -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Import' AND `t2`.`name` = 'Strumenti') SET `t1`.`parent` = `t2`.`id`; - --- Aggiunta delle email per i rapportini -INSERT INTO `zz_emails` (`id`, `id_module`, `id_smtp`, `name`, `icon`, `subject`, `reply_to`, `cc`, `bcc`, `body`, `read_notify`, `main`, `deleted`) VALUES -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), 1, 'Rapportino intervento', 'fa fa-envelope', 'Invio rapportino numero {numero} del {data}', '', '', '', '

    Gentile Cliente,

    \r\n

    inviamo in allegato il rapportino numero {numero} del {data}.

    \r\n

     

    \r\n

    Distinti saluti

    \r\n', '0', '0', '0'), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi'), 1, 'Preventivo', 'fa fa-envelope', 'Invio preventivo numero {numero} del {data}', '', '', '', '

    Gentile Cliente,

    \r\n

    inviamo in allegato il preventivo numero {numero} del {data}.

    \r\n

     

    \r\n

    Distinti saluti

    \r\n', '0', '0', '0'), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Contratti'), 1, 'Contratto', 'fa fa-envelope', 'Invio contratto numero {numero} del {data}', '', '', '', '

    Gentile Cliente,

    \r\n

    inviamo in allegato il contratto numero {numero} del {data}.

    \r\n

     

    \r\n

    Distinti saluti

    \r\n', '0', '0', '0'), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ordini cliente'), 1, 'Ordine', 'fa fa-envelope', 'Invio ordine numero {numero} del {data}', '', '', '', '

    Gentile Cliente,

    \r\n

    inviamo in allegato l\'ordine numero {numero} del {data}.

    \r\n

     

    \r\n

    Distinti saluti

    \r\n', '0', '0', '0'), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ordini fornitore'), 1, 'Ordine', 'fa fa-envelope', 'Invio ordine numero {numero} del {data}', '', '', '', '

    Gentile Cliente,

    \r\n

    inviamo in allegato l\'ordine numero {numero} del {data}.

    \r\n

     

    \r\n

    Distinti saluti

    \r\n', '0', '0', '0'), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'), 1, 'Fattura', 'fa fa-envelope', 'Invio fattura numero {numero} del {data}', '', '', '', '

    Gentile Cliente,

    \r\n

    inviamo in allegato la fattura numero {numero} del {data}.

    \r\n

     

    \r\n

    Distinti saluti

    \r\n', '0', '0', '0'), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ddt di vendita'), 1, 'Ddt', 'fa fa-envelope', 'Invio ddt {numero} del {data}', '', '', '', '

    Gentile Cliente,

    \r\n

    inviamo in allegato il ddt numero {numero} del {data}.

    \r\n

     

    \r\n

    Distinti saluti

    \r\n', '0', '0', '0'); - -INSERT INTO `zz_email_print` (`id`, `id_email`, `id_print`) VALUES -(NULL, (SELECT `id` FROM `zz_emails` WHERE `name` = 'Rapportino intervento' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi')), (SELECT `id` FROM `zz_prints` WHERE `name` = 'Intervento (senza costi)')), -(NULL, (SELECT `id` FROM `zz_emails` WHERE `name` = 'Preventivo' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi')), (SELECT `id` FROM `zz_prints` WHERE `name` = 'Preventivo')), -(NULL, (SELECT `id` FROM `zz_emails` WHERE `name` = 'Contratto' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Contratti')), (SELECT `id` FROM `zz_prints` WHERE `name` = 'Contratto')), -(NULL, (SELECT `id` FROM `zz_emails` WHERE `name` = 'Ordine' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ordini cliente')), (SELECT `id` FROM `zz_prints` WHERE `name` = 'Ordine cliente')), -(NULL, (SELECT `id` FROM `zz_emails` WHERE `name` = 'Ordine' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ordini fornitore')), (SELECT `id` FROM `zz_prints` WHERE `name` = 'Ordine fornitore')), -(NULL, (SELECT `id` FROM `zz_emails` WHERE `name` = 'Fattura' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita')), (SELECT `id` FROM `zz_prints` WHERE `name` = 'Fattura di vendita')), -(NULL, (SELECT `id` FROM `zz_emails` WHERE `name` = 'Ddt' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ddt di vendita')), (SELECT `id` FROM `zz_prints` WHERE `name` = 'Ddt di vendita')); - --- Aggiunta delle email per i consuntivi rapportini -INSERT INTO `zz_emails` (`id`, `id_module`, `id_smtp`, `name`, `icon`, `subject`, `reply_to`, `cc`, `bcc`, `body`, `read_notify`, `main`, `deleted`) VALUES -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Contratti'), 1, 'Consuntivo contratto', 'fa fa-envelope', 'Invio consuntivo contratto numero {numero} del {data}', '', '', '', '

    Gentile Cliente,

    \r\n

    inviamo in allegato il rapportino numero {numero} del {data}.

    \r\n

     

    \r\n

    Distinti saluti

    \r\n', '0', '0', '0'), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi'), 1, 'Consuntivo preventivo', 'fa fa-envelope', 'Invio consuntivo del preventivo numero {numero} del {data}', '', '', '', '

    Gentile Cliente,

    \r\n

    inviamo in allegato il rapportino numero {numero} del {data}.

    \r\n

     

    \r\n

    Distinti saluti

    \r\n', '0', '0', '0'); - -INSERT INTO `zz_email_print` (`id`, `id_email`, `id_print`) VALUES -(NULL, (SELECT `id` FROM `zz_emails` WHERE `name` = 'Consuntivo contratto' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Contratti')), (SELECT `id` FROM `zz_prints` WHERE `name` = 'Consuntivo contratto')), -(NULL, (SELECT `id` FROM `zz_emails` WHERE `name` = 'Consuntivo preventivo' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi')), (SELECT `id` FROM `zz_prints` WHERE `name` = 'Consuntivo preventivo')); - --- apilayer API key (per validazione email) -INSERT INTO `zz_settings` (`idimpostazione`, `nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES (NULL, 'apilayer API key for Email', '', 'string', '1', 'Generali'); - --- apilayer API key (per validazione piva) -INSERT INTO `zz_settings` (`idimpostazione`, `nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES (NULL, 'apilayer API key for VAT number', '', 'string', '1', 'Generali'); - --- Aggiorno query modulo movimenti per ordinarli in funzione della data del movimento -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `mg_movimenti` JOIN `mg_articoli` ON `mg_articoli`.id = `mg_movimenti`.`idarticolo` WHERE 1=1 HAVING 2=2 ORDER BY `Data` DESC' WHERE `zz_modules`.`name` = 'Movimenti'; - --- Rimozione impostazioni inutilizzate -DELETE FROM `zz_settings` WHERE `zz_settings`.`nome` = 'Indirizzo per le email in uscita'; -DELETE FROM `zz_settings` WHERE `zz_settings`.`nome` = 'Destinatario'; -DELETE FROM `zz_settings` WHERE `zz_settings`.`nome` = 'Destinatario fisso in copia (campo CC)'; - --- Conversione numero co_documenti da int(11) a varchar(100) -ALTER TABLE `co_documenti` CHANGE `numero` `numero` VARCHAR(100) NOT NULL; - --- Disabilito di default filtro tecnici che altrimento vedono solo le anagrafiche per i quali hanno eseguito un intervento (issue #190) -UPDATE `zz_group_module` SET `enabled` = '0' WHERE `zz_group_module`.`id` = 2; - --- Disattivazione funzionalità in attesa di approfondire alcuni problemi di rallentamento e ottimizzazione performance -UPDATE `zz_settings` SET `valore` = '0' WHERE `nome` = 'Attiva notifica di presenza utenti sul record'; - --- Tabella co_banche -CREATE TABLE IF NOT EXISTS `co_banche` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `nome` varchar(255) NOT NULL, - `filiale` varchar(255) NOT NULL, - `iban` varchar(32) NOT NULL, - `bic` varchar(11) NOT NULL, - `id_pianodeiconti3` int(11) DEFAULT NULL, - `note` text NOT NULL, - `deleted` tinyint(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- Innesto modulo per gestione banche -INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Banche', 'Banche', 'banche', 'SELECT |select| FROM `co_banche` WHERE 1=1 AND deleted = 0 GROUP BY `nome` HAVING 2=2', '', 'fa fa-university', '2.4', '2.4', '1', NULL, '1', '1'); -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Banche' AND `t2`.`name` = 'Tabelle') SET `t1`.`parent` = `t2`.`id`; - -INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `enabled`, `summable`, `default`) VALUES -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Banche'), 'id', 'co_banche.id', 0, 0, 0, 0, 1, 0, 0), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Banche'), 'Nome', 'co_banche.nome', 0, 0, 0, 0, 1, 0, 0), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Banche'), 'Filiale', 'co_banche.filiale', 0, 0, 0, 0, 1, 0, 0), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Banche'), 'IBAN', 'co_banche.iban', 0, 0, 0, 0, 1, 0, 0); - --- Aggiungo campi in an_anagrafiche con riferimento banche -ALTER TABLE `an_anagrafiche` ADD `idbanca_vendite` INT(11) NOT NULL AFTER `idconto_cliente`, ADD `idbanca_acquisti` INT(11) NOT NULL AFTER `idbanca_vendite`; - --- Campo idbanca per fatture -ALTER TABLE `co_documenti` ADD `idbanca` INT(11) NOT NULL AFTER `idpagamento`; - --- Campo calcolo_ritenutaacconto per selezione tipo di calcolo ritenuta acconto -ALTER TABLE `co_righe_documenti` ADD `calcolo_ritenutaacconto` VARCHAR(255) NOT NULL AFTER `rivalsainps`; -INSERT INTO `zz_settings` (`idimpostazione`, `nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES (NULL, 'Metodologia calcolo ritenuta d''acconto predefinito', 'Imponibile', 'list[Imponibile,Imponibile + rivalsa inps]', 1, 'Fatturazione'); - --- Fix doppio conto iva 'Esente art. 10' & 'Esente art.10' -DELETE FROM `co_iva` WHERE `co_iva`.`descrizione` = 'Esente art. 10' AND `co_iva`.`id` NOT IN (SELECT `idiva` FROM co_righe_documenti UNION SELECT `idiva` FROM co_righe_preventivi UNION SELECT `idiva` FROM dt_righe_ddt UNION SELECT `idiva` FROM or_righe_ordini ); - --- Allineamento query widget 'Contratti in scadenza' -UPDATE `zz_widgets` SET `query` = 'SELECT COUNT(id) AS dato, DATEDIFF( data_conclusione, NOW() ) AS giorni_rimanenti FROM co_contratti WHERE idstato IN(SELECT id FROM co_staticontratti WHERE fatturabile = 1) AND NOT EXISTS (SELECT id FROM co_righe_documenti WHERE co_righe_documenti.idcontratto = co_contratti.id) AND rinnovabile=1 AND NOW() > DATE_ADD( data_conclusione, INTERVAL - ABS(giorni_preavviso_rinnovo) DAY) AND YEAR(data_conclusione) > 1970 ORDER BY giorni_rimanenti ASC' WHERE `zz_widgets`.`name` = 'Contratti in scadenza'; diff --git a/update/2_4_1.sql b/update/2_4_1.sql deleted file mode 100755 index d23be85b8..000000000 --- a/update/2_4_1.sql +++ /dev/null @@ -1,498 +0,0 @@ -ALTER TABLE `co_contratti` ADD `idsede` INT NOT NULL AFTER `idanagrafica`; - --- Imposto conto cassa per contanti e rimesse -UPDATE `co_pagamenti` SET `idconto_vendite` = (SELECT id FROM co_pianodeiconti3 WHERE descrizione = 'Cassa'), `idconto_acquisti` = (SELECT id FROM co_pianodeiconti3 WHERE descrizione = 'Cassa') WHERE `co_pagamenti`.`descrizione` = 'Contanti' OR `co_pagamenti`.`descrizione` LIKE 'Rimessa %'; - --- Imposto conto banca per tutti i bonifici e ri.ba. -UPDATE `co_pagamenti` SET `idconto_vendite` = (SELECT id FROM co_pianodeiconti3 WHERE descrizione = 'Banca C/C'), `idconto_acquisti` = (SELECT id FROM co_pianodeiconti3 WHERE descrizione = 'Banca C/C') WHERE `co_pagamenti`.`descrizione` LIKE 'Bonifico %' OR `co_pagamenti`.`descrizione` LIKE 'Ri.Ba. %'; - --- Indirizzo PEC -ALTER TABLE `an_anagrafiche` ADD `pec` VARCHAR(255) NOT NULL AFTER `email`; - --- ISO 3166-1 alpha-2 code per nazioni -ALTER TABLE `an_nazioni` ADD `iso2` VARCHAR(2) NOT NULL AFTER `nome`; - --- ISO 2 per ITALIA (https://it.wikipedia.org/wiki/ISO_3166-1_alpha-2) -UPDATE `an_nazioni` SET `iso2` = 'IT' WHERE `an_nazioni`.`nome` = 'ITALIA'; - --- Aggiunto name per i filtri -ALTER TABLE `zz_group_module` ADD `name` VARCHAR(255) NOT NULL AFTER `idmodule`; - -UPDATE `zz_group_module` SET `name` = 'Mostra interventi ai tecnici coinvolti' WHERE `zz_group_module`.`idgruppo` = (SELECT `id` FROM `zz_groups` WHERE `nome` = 'Tecnici') AND `zz_group_module`.`idmodule` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'); -UPDATE `zz_group_module` SET `name` = 'Mostra interventi ai clienti coinvolti' WHERE `zz_group_module`.`idgruppo` = (SELECT `id` FROM `zz_groups` WHERE `nome` = 'Clienti') AND `zz_group_module`.`idmodule` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'); - --- Abilito plugin Pianificazione fatturazione in contratti -UPDATE `zz_plugins` SET `enabled` = '1' WHERE `zz_plugins`.`name` = 'Pianificazione fatturazione'; - --- Abilito widget Rate contrattuali in dashboard -UPDATE `zz_widgets` SET `enabled` = '1' WHERE `zz_widgets`.`name` = 'Rate contrattuali'; - --- Help text per i plugins -ALTER TABLE `zz_plugins` ADD `help` VARCHAR(255) NOT NULL AFTER `directory`; - --- Help text per plugin Ddt del cliente -UPDATE `zz_plugins` SET `help` = 'Righe ddt del cliente. I ddt senza righe non saranno visualizzati.' WHERE `zz_plugins`.`name` = 'Ddt del cliente'; - --- Creazione tabella per modelli primanota -CREATE TABLE IF NOT EXISTS `co_movimenti_modelli` ( - `id` int(11) NOT NULL, - `idmastrino` int(11) NOT NULL, - `descrizione` text NOT NULL, - `idconto` int(11) NOT NULL -); - -ALTER TABLE `co_movimenti_modelli` ADD PRIMARY KEY (`id`); - -ALTER TABLE `co_movimenti_modelli` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; - --- Modulo modelli prima nota -INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Modelli prima nota', 'Modelli prima nota', 'modelli_primanota', 'SELECT |select| FROM `co_movimenti_modelli` WHERE 1=1 GROUP BY `idmastrino` HAVING 2=2', '', 'fa fa-angle-right', '2.4.1', '2.4.1', '1', NULL, '1', '1'); - -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Modelli prima nota' AND `t2`.`name` = 'Tabelle') SET `t1`.`parent` = `t2`.`id`; - -INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `enabled`, `summable`, `default`) VALUES (NULL, (SELECT id FROM zz_modules WHERE name='Modelli prima nota'), 'id', 'co_movimenti_modelli.id', '0', '1', '0', '0', NULL, NULL, '0', '0', '1'); -INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `enabled`, `summable`, `default`) VALUES (NULL, (SELECT id FROM zz_modules WHERE name='Modelli prima nota'), 'Causale predefinita', 'co_movimenti_modelli.descrizione', '1', '1', '0', '0', NULL, NULL, '1', '0', '1'); - --- Widget per stampa calendario -INSERT INTO `zz_widgets` (`id`, `name`, `type`, `id_module`, `location`, `class`, `query`, `bgcolor`, `icon`, `print_link`, `more_link`, `more_link_type`, `php_include`, `text`, `enabled`, `order`, `help` ) VALUES (NULL, 'Stampa calendario', 'print', '1', 'controller_top', 'col-md-12', NULL, '#4ccc4c', 'fa fa-print', '', './modules/dashboard/widgets/stampa_calendario.dashboard.php', 'popup', '', 'Stampa calendario', '1', '7', NULL); - --- Stampa calendario -INSERT INTO `zz_prints` (`id`, `id_module`, `is_record`, `name`, `title`, `directory`, `previous`, `options`, `icon`, `version`, `compatibility`, `order`, `main`, `default`, `enabled`) VALUES (NULL, '1', '1', 'Stampa calendario', 'Stampa calendario', 'dashboard', '', '', 'fa fa-print', '', '', '0', '1', '1', '1'); - --- Rimosso group by nome banche -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_banche` WHERE 1=1 AND deleted = 0 HAVING 2=2' WHERE `zz_modules`.`name` = 'Banche'; - --- impianti per pianificazione contratti -ALTER TABLE `co_righe_contratti` ADD `idimpianti` VARCHAR(255) NOT NULL AFTER `idsede`; - --- Struttura della tabella `co_righe_contratti_materiali` -CREATE TABLE IF NOT EXISTS `co_righe_contratti_materiali` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `descrizione` varchar(255) NOT NULL, - `qta` float(12,4) NOT NULL, - `um` varchar(25) NOT NULL, - `prezzo_vendita` decimal(12,4) NOT NULL, - `prezzo_acquisto` decimal(12,4) NOT NULL, - `idiva` int(11) NOT NULL, - `desc_iva` varchar(255) NOT NULL, - `iva` decimal(12,4) NOT NULL, - `id_riga_contratto` int(11) DEFAULT NULL, - `sconto` decimal(12,4) NOT NULL, - `sconto_unitario` decimal(12,4) NOT NULL, - `tipo_sconto` enum('UNT','PRC') NOT NULL DEFAULT 'UNT', - PRIMARY KEY (`id`), - KEY `id_riga_contratto` (`id_riga_contratto`) -); - --- Struttura della tabella `co_righe_contratti_articoli` -CREATE TABLE IF NOT EXISTS `co_righe_contratti_articoli` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `idarticolo` int(11) NOT NULL, - `id_riga_contratto` int(11) DEFAULT NULL, - `descrizione` varchar(255) NOT NULL, - `prezzo_acquisto` decimal(12,4) NOT NULL, - `prezzo_vendita` decimal(12,4) NOT NULL, - `sconto` decimal(12,4) NOT NULL, - `sconto_unitario` decimal(12,4) NOT NULL, - `tipo_sconto` enum('UNT','PRC') NOT NULL DEFAULT 'UNT', - `idiva` int(11) NOT NULL, - `desc_iva` varchar(255) NOT NULL, - `iva` decimal(12,4) NOT NULL, - `idautomezzo` int(11) NOT NULL, - `qta` decimal(10,2) NOT NULL, - `um` varchar(20) NOT NULL, - `abilita_serial` tinyint(1) NOT NULL DEFAULT '0', - `idimpianto` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `id_riga_contratto` (`id_riga_contratto`), - KEY `idimpianto` (`idimpianto`) -); - --- Modifica query widget per mostrare solo quelli che non sono stati rinnovati -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 HAVING 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'; - --- Aggiunto campo data su movimenti articoli -ALTER TABLE `mg_movimenti` ADD `data` DATE NOT NULL AFTER `movimento`; - --- Campo per identificare i movimenti manuali -ALTER TABLE `mg_movimenti` ADD `manuale` TINYINT(1) NOT NULL AFTER `data`; - --- Aggiunta possibilità di selezionare anche i conti in 620 Costi diversi negli acquisti -UPDATE `co_pianodeiconti2` SET `dir` = 'uscita' WHERE `co_pianodeiconti2`.`descrizione` = 'Costi diversi'; - --- Supporto al valore NULL per uid e summary in in_interventi_tecnici -ALTER TABLE `in_interventi_tecnici` CHANGE `uid` `uid` VARCHAR(255), CHANGE `summary` `summary` VARCHAR(255); -UPDATE `in_interventi_tecnici` SET `uid` = NULL WHERE `uid` = ''; -UPDATE `in_interventi_tecnici` SET `summary` = NULL WHERE `summary` = ''; -ALTER TABLE `in_interventi_tecnici` CHANGE `uid` `uid` int(11); - --- Aggiorno campo 'Data' in 'Data movimento' -UPDATE `zz_views` SET `name` = 'Data movimento', `order` = '6' WHERE `zz_views`.`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Movimenti') AND name = 'Data'; - -UPDATE `zz_views` SET `query` = 'CONCAT(mg_movimenti.qta,'' '', (SELECT um FROM mg_articoli WHERE id = mg_movimenti.idarticolo) )' WHERE `zz_views`.`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Movimenti') AND name = 'Quantità'; - --- Allineo anche il modulo movimenti con il nuovo campo data -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `enabled`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Movimenti'), 'Data', 'mg_movimenti.data', 5, 1, 0, 1, 1, 1); - --- Aggiungo colonna impianti per i contratti -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `enabled`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Contratti'), 'Impianti', '(SELECT IF(nome = '''', GROUP_CONCAT(matricola SEPARATOR ''
    ''), GROUP_CONCAT(matricola, '' - '', nome SEPARATOR ''
    '')) FROM my_impianti INNER JOIN my_impianti_contratti ON my_impianti.id = my_impianti_contratti.idimpianto WHERE my_impianti_contratti.idcontratto = co_contratti.id)', 4, 1, 0, 0, 0, 1); - --- Tempo standard per attività -ALTER TABLE `in_tipiintervento` ADD `tempo_standard` DECIMAL(10,2) NULL AFTER `costo_diritto_chiamata_tecnico`; - --- Rinomino Interventi da pianificare in Promemoria contratti da pianificare -UPDATE `zz_widgets` SET `text` = 'Promemoria contratti da pianificare' WHERE `zz_widgets`.`name` = 'Interventi da pianificare'; - --- Aggiunta impostazioni per cambio stato automatici -INSERT INTO `zz_settings` (`idimpostazione`, `nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES (NULL, 'Cambia automaticamente stato ddt fatturati', '1', 'boolean', '1', 'Ddt'); -INSERT INTO `zz_settings` (`idimpostazione`, `nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES (NULL, 'Cambia automaticamente stato ordini fatturati', '1', 'boolean', '1', 'Ordini'); - --- Flag completato per disabilitare la modifica dei campi nei ddt -ALTER TABLE `dt_statiddt` ADD `completato` TINYINT(1) NOT NULL AFTER `icona`; -UPDATE `dt_statiddt` SET `completato` = '1' WHERE `dt_statiddt`.`descrizione` IN( 'Fatturato', 'Parzialmente fatturato', 'Evaso' ); - --- Aggiungo stato parzialmente evaso -INSERT INTO `dt_statiddt` (`id`, `descrizione`, `icona`, `completato`) VALUES (NULL, 'Parzialmente evaso', 'fa fa-clock-o text-info', '1'); - --- Modifico le icone degli stati ddt -UPDATE `dt_statiddt` SET `icona` = 'fa fa-truck text-success' WHERE `dt_statiddt`.`descrizione` = 'Evaso'; -UPDATE `dt_statiddt` SET `icona` = 'fa fa-truck text-warning' WHERE `dt_statiddt`.`descrizione` = 'Parzialmente evaso'; -UPDATE `dt_statiddt` SET `icona` = 'fa fa-file-text-o text-success' WHERE `dt_statiddt`.`descrizione` = 'Fatturato'; -UPDATE `dt_statiddt` SET `icona` = 'fa fa-file-text-o text-warning' WHERE `dt_statiddt`.`descrizione` = 'Parzialmente fatturato'; - --- Modifico gli stati dell'ordine -UPDATE `or_statiordine` SET `descrizione` = 'Bozza' WHERE `or_statiordine`.`descrizione` = 'Non evaso'; - --- Modifico le icone degli stati ordini -UPDATE `or_statiordine` SET `icona` = 'fa fa-truck text-success' WHERE `or_statiordine`.`descrizione` = 'Evaso'; - --- Inserisco due nuovi stati ordine -INSERT INTO `or_statiordine` (`id`, `descrizione`, `annullato`, `icona`) VALUES -(NULL, 'Parzialmente fatturato', 0, 'fa fa-file-text-o text-warning'), -(NULL, 'Fatturato', 0, 'fa fa-file-text-o text-success'); - --- Flag completato per disabilitare la modifica dei campi negli ordini -ALTER TABLE `or_statiordine` ADD `completato` TINYINT(1) NOT NULL AFTER `icona`; -UPDATE `or_statiordine` SET `completato` = '1' WHERE `or_statiordine`.`id` IN( 2, 3, 4, 5 ); - --- Campi per note aggiuntive in ddt e ordini -ALTER TABLE `or_ordini` ADD `note_aggiuntive` TEXT NOT NULL AFTER `note`; -ALTER TABLE `dt_ddt` ADD `note_aggiuntive` TEXT NOT NULL AFTER `note`; - --- Fix id_plugin (zz_files) -UPDATE `zz_files` SET `id_plugin` = NULL WHERE `id_plugin` = 0; - --- Fix id_module (zz_files) -ALTER TABLE `zz_files` CHANGE `id_module` `id_module` INT(11) NULL; -UPDATE `zz_files` SET `id_module` = NULL WHERE `id_module` = 0; - --- Totali fatture, sommabile -UPDATE `zz_views` SET `summable` = '1' WHERE `zz_views`.`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita') AND name = 'Totale'; -UPDATE `zz_views` SET `summable` = '1' WHERE `zz_views`.`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di acquisto') AND name = 'Totale'; - --- Fix serial, lotti, altro a 0 o null -DELETE FROM `mg_prodotti` WHERE (`serial` IS NULL OR `serial`='0') AND (`lotto` IS NULL OR `lotto`='0') AND (`altro` IS NULL OR `altro`='0'); - -UPDATE `mg_articoli` SET `abilita_serial` = 1 WHERE `id` IN (SELECT `id_articolo` FROM `mg_prodotti`); -UPDATE `co_righe_documenti` SET `abilita_serial` = 1 WHERE `idarticolo` IN (SELECT `id_articolo` FROM `mg_prodotti`); -UPDATE `dt_righe_ddt` SET `abilita_serial` = 1 WHERE `idarticolo` IN (SELECT `id_articolo` FROM `mg_prodotti`); -UPDATE `mg_articoli_interventi` SET `abilita_serial` = 1 WHERE `idarticolo` IN (SELECT `id_articolo` FROM `mg_prodotti`); -UPDATE `or_righe_ordini` SET `abilita_serial` = 1 WHERE `idarticolo` IN (SELECT `id_articolo` FROM `mg_prodotti`); - -UPDATE `mg_articoli` SET `abilita_serial` = 0 WHERE `id` NOT IN (SELECT `id_articolo` FROM `mg_prodotti`); -UPDATE `co_righe_documenti` SET `abilita_serial` = 0 WHERE `idarticolo` NOT IN (SELECT `id_articolo` FROM `mg_prodotti`); -UPDATE `dt_righe_ddt` SET `abilita_serial` = 0 WHERE `idarticolo` NOT IN (SELECT `id_articolo` FROM `mg_prodotti`); -UPDATE `mg_articoli_interventi` SET `abilita_serial` = 0 WHERE `idarticolo` NOT IN (SELECT `id_articolo` FROM `mg_prodotti`); -UPDATE `or_righe_ordini` SET `abilita_serial` = 0 WHERE `idarticolo` NOT IN (SELECT `id_articolo` FROM `mg_prodotti`); - --- Aggiungo colonna idanagrafica per i preventivi (colonna necessaria per i permessi) -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `enabled`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi'), 'idanagrafica', 'co_preventivi.idanagrafica', 0, 0, 0, 0, 0, 1); - --- Fix name, title e order stampa ordine fornitore senza costi -UPDATE `zz_prints` SET `name` = 'Ordine fornitore (senza costi)', `title` = 'Ordine fornitore (senza costi)', `order` = 1 WHERE `zz_prints`.`name` = 'Ordine fornitore' AND options = '{"pricing":false}' AND `zz_prints`.`id_module` = (SELECT id FROM zz_modules WHERE name='Ordini fornitore') ; --- Stampa ordine fornitore con costi costi -INSERT INTO `zz_prints` (`id`, `id_module`, `is_record`, `name`, `title`, `directory`, `previous`, `options`, `icon`, `version`, `compatibility`, `order`, `main`, `default`, `enabled`) VALUES (NULL, (SELECT id FROM zz_modules WHERE name='Ordini fornitore'), '1', 'Ordine fornitore', 'Ordine fornitore', 'ordini', 'idordine', '{"pricing":true}', 'fa fa-print', '', '', '0', '1', '1', '1'); --- Default invio ordini al fornitore con i prezzi -UPDATE `zz_email_print` SET `id_print` = (SELECT id FROM zz_prints WHERE name = 'Ordine fornitore') WHERE `zz_email_print`.`id_email` = (SELECT id FROM zz_emails WHERE id_module = (SELECT id FROM zz_modules WHERE name='Ordini fornitore')); - --- Ordino stampa ordine cliente senza costi -UPDATE `zz_prints` SET `order` = 1 WHERE `zz_prints`.`name` = 'Ordine cliente (senza costi)' AND options = '{"pricing":false}' AND `zz_prints`.`id_module` = (SELECT id FROM zz_modules WHERE name='Ordini cliente'); - --- Rimuovo impostazioni non più utilizzate -DELETE FROM `zz_settings` WHERE `nome` = 'Stampa i prezzi sugli ordini'; -DELETE FROM `zz_settings` WHERE `nome` = 'Stampa i prezzi sui contratti'; -DELETE FROM `zz_settings` WHERE `nome` = 'Stampa i prezzi sui ddt'; -DELETE FROM `zz_settings` WHERE `nome` = 'Visualizza i costi sulle stampe degli interventi'; -DELETE FROM `zz_settings` WHERE `nome` = 'Stampa i prezzi sui preventivi'; - --- Lo stato 'In programmazione' non può essere eliminato/modificato -UPDATE `in_statiintervento` SET `can_delete` = '0' WHERE `in_statiintervento`.`idstatointervento` = 'WIP'; - --- Campi Importo e Pagato dello Scadenzario sommabili -UPDATE `zz_views` SET `summable` = '1' WHERE `zz_views`.`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Scadenzario') AND name = 'Importo'; -UPDATE `zz_views` SET `summable` = '1' WHERE `zz_views`.`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Scadenzario') AND name = 'Pagato'; - --- Collego il preventivo alla riga dell'ordine -ALTER TABLE `or_righe_ordini` ADD `idpreventivo` INT(11) NOT NULL AFTER `idarticolo`; - --- Fix foreign keys (2.4) -ALTER TABLE `zz_emails` -ADD FOREIGN KEY (`id_module`) REFERENCES `zz_modules`(`id`) ON DELETE CASCADE, -ADD FOREIGN KEY (`id_smtp`) REFERENCES `zz_smtp`(`id`) ON DELETE CASCADE; - -ALTER TABLE `zz_email_print` -ADD FOREIGN KEY (`id_email`) REFERENCES `zz_emails`(`id`) ON DELETE CASCADE, -ADD FOREIGN KEY (`id_print`) REFERENCES `zz_prints`(`id`) ON DELETE CASCADE; - -ALTER TABLE `zz_fields` -ADD FOREIGN KEY (`id_module`) REFERENCES `zz_modules`(`id`) ON DELETE CASCADE, -ADD FOREIGN KEY (`id_plugin`) REFERENCES `zz_plugins`(`id`) ON DELETE CASCADE; - -ALTER TABLE `zz_field_record` -ADD FOREIGN KEY (`id_field`) REFERENCES `zz_fields`(`id`) ON DELETE CASCADE; - -ALTER TABLE `zz_prints` -ADD FOREIGN KEY (`id_module`) REFERENCES `zz_modules`(`id`) ON DELETE CASCADE; - --- Widget per attività senza nessun tecnico assegnato -INSERT INTO `zz_widgets` (`id`, `name`, `type`, `id_module`, `location`, `class`, `query`, `bgcolor`, `icon`, `print_link`, `more_link`, `more_link_type`, `php_include`, `text`, `enabled`, `order`, `help`) VALUES (NULL, 'Attività da pianificare', 'stats', (SELECT id FROM zz_modules WHERE name = 'Dashboard'), 'controller_top', 'col-md-3', 'SELECT COUNT(id) AS dato FROM in_interventi WHERE id NOT IN (SELECT idintervento FROM in_interventi_tecnici) AND idstatointervento IN (SELECT idstatointervento FROM in_statiintervento WHERE completato = 0) ', '#6dab3c', 'fa fa-cogs', '', './modules/interventi/widgets/interventi.pianificazionedashboard.interventi.php', 'popup', '', 'Promemoria attività da pianificare', 1, '0', NULL); - --- Impostazione "Tempo di attesa ricerche" -INSERT INTO `zz_settings` (`idimpostazione`, `nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES (NULL, 'Tempo di attesa ricerche in secondi', '2', 'integer', '0', 'Generali'); - --- Rimozione IVA duplicata -DELETE FROM `co_iva` WHERE `id` = 31; -UPDATE `an_anagrafiche` SET `idiva_acquisti` = 75 WHERE `idiva_acquisti` = 31; -UPDATE `an_anagrafiche` SET `idiva_vendite` = 75 WHERE `idiva_vendite` = 31; -UPDATE `co_preventivi` SET `idiva` = 75 WHERE `idiva` = 31; -UPDATE `co_righe2_contratti` SET `idiva` = 75 WHERE `idiva` = 31; -UPDATE `co_righe_contratti_articoli` SET `idiva` = 75 WHERE `idiva` = 31; -UPDATE `co_righe_contratti_materiali` SET `idiva` = 75 WHERE `idiva` = 31; -UPDATE `co_righe_documenti` SET `idiva` = 75 WHERE `idiva` = 31; -UPDATE `co_righe_documenti` SET `idiva` = 75 WHERE `idiva` = 31; -UPDATE `dt_ddt` SET `idiva` = 75 WHERE `idiva` = 31; -UPDATE `dt_righe_ddt` SET `idiva` = 75 WHERE `idiva` = 31; -UPDATE `in_righe_interventi` SET `idiva` = 75 WHERE `idiva` = 31; -UPDATE `mg_articoli` SET `idiva_vendita` = 75 WHERE `idiva_vendita` = 31; -UPDATE `mg_articoli_interventi` SET `idiva` = 75 WHERE `idiva` = 31; -UPDATE `or_righe_ordini` SET `idiva` = 75 WHERE `idiva` = 31; - --- Rimozione idtipointervento da co_contratti -ALTER TABLE `co_contratti` DROP `idtipointervento`; - --- Ridenominazione tabelle -ALTER TABLE `co_righe_contratti` RENAME `co_contratti_promemoria`; -ALTER TABLE `co_righe2_contratti` RENAME `co_righe_contratti`; -UPDATE `zz_widgets` SET `query` = REPLACE(`query`, 'co_righe_contratti', 'co_contratti_promemoria'); -UPDATE `zz_widgets` SET `query` = REPLACE(`query`, 'co_righe2_contratti', 'co_righe_contratti'); - --- Ordine per le Impostazioni -ALTER TABLE `zz_settings` ADD `order` int(11); -UPDATE `zz_settings` SET `order` = 1 WHERE `nome` = 'Azienda predefinita'; -UPDATE `zz_settings` SET `order` = 2 WHERE `nome` = 'Nascondere la barra sinistra di default'; -UPDATE `zz_settings` SET `order` = 3 WHERE `nome` = 'Backup automatico'; -UPDATE `zz_settings` SET `order` = 4 WHERE `nome` = 'Numero di backup da mantenere'; -UPDATE `zz_settings` SET `order` = 5 WHERE `nome` = 'Vista dashboard'; -UPDATE `zz_settings` SET `order` = 6 WHERE `nome` = 'Utilizzare i tooltip sul calendario'; -UPDATE `zz_settings` SET `order` = 7 WHERE `nome` = 'Visualizzare la domenica sul calendario'; -UPDATE `zz_settings` SET `order` = 8 WHERE `nome` = 'Abilitare orario lavorativo'; -UPDATE `zz_settings` SET `order` = 9 WHERE `nome` = 'Cifre decimali per importi'; -UPDATE `zz_settings` SET `order` = 10 WHERE `nome` = 'Cifre decimali per quantità'; -UPDATE `zz_settings` SET `order` = 11 WHERE `nome` = 'Prima pagina'; -UPDATE `zz_settings` SET `order` = 12 WHERE `nome` = 'Google Maps API key'; -UPDATE `zz_settings` SET `order` = 13 WHERE `nome` = 'Attiva notifica di presenza utenti sul record'; -UPDATE `zz_settings` SET `order` = 14 WHERE `nome` = 'Timeout notifica di presenza (minuti)'; -UPDATE `zz_settings` SET `order` = 15 WHERE `nome` = 'apilayer API key for Email'; -UPDATE `zz_settings` SET `order` = 16 WHERE `nome` = 'apilayer API key for VAT number'; -UPDATE `zz_settings` SET `order` = 17 WHERE `nome` = 'CSS Personalizzato'; - --- Fix tipo del campo order -ALTER TABLE `co_righe_preventivi` CHANGE `order` `order` int(11) NOT NULL; -ALTER TABLE `dt_righe_ddt` CHANGE `order` `order` int(11) NOT NULL; -ALTER TABLE `or_righe_ordini` CHANGE `order` `order` int(11) NOT NULL; -ALTER TABLE `co_righe_contratti` CHANGE `order` `order` int(11) NOT NULL; - --- Impostazione "Logo stampe" -INSERT INTO `zz_settings` (`idimpostazione`, `nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES (NULL, 'Logo stampe', '', 'string', '0', 'Generali'); - --- Categorie zz_files -ALTER TABLE `zz_files` ADD `category` varchar(100) AFTER `original`; - --- Impostazione "Abilita esportazione Excel e PDF" -INSERT INTO `zz_settings` (`idimpostazione`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES (NULL, 'Abilita esportazione Excel e PDF', '0', 'boolean', '1', 'Generali', 18); - --- Rimozione idtipoanagrafica da zz_users -ALTER TABLE `zz_users` DROP `idtipoanagrafica`; - --- Introduzione controllo duplicazione della numerazione Fatture di vendita -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `enabled`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'), '_bg_', 'IF((SELECT COUNT(t.numero_esterno) FROM co_documenti AS t WHERE t.numero_esterno = co_documenti.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|'') > 1, ''red'', '''')', 0, 0, 0, 0, 1); - --- Aggiunto supporto a Note di accredito e addebito -ALTER TABLE `co_documenti` ADD `ref_documento` int(11) AFTER `idagente`, ADD FOREIGN KEY (`ref_documento`) REFERENCES `co_documenti`(`id`) ON DELETE CASCADE; -ALTER TABLE `co_righe_documenti` ADD `qta_evasa` decimal(12,4) NOT NULL AFTER `qta`, ADD `ref_riga_documento` int(11) AFTER `idcontratto`, ADD FOREIGN KEY (`ref_riga_documento`) REFERENCES `co_righe_documenti`(`id`) ON DELETE CASCADE; - -ALTER TABLE `co_tipidocumento` ADD `reversed` BOOLEAN NOT NULL DEFAULT FALSE AFTER `dir`; -UPDATE `co_tipidocumento` SET `reversed` = 1 WHERE `descrizione` = 'Nota di accredito'; - --- Fix id_sottocategoria in mg_articoli -ALTER TABLE `mg_articoli` CHANGE `id_sottocategoria` `id_sottocategoria` int(11); - --- Immagini articoli come allegati -ALTER TABLE `mg_articoli` CHANGE `immagine01` `immagine` varchar(255); -UPDATE `mg_articoli` SET `immagine` = NULL WHERE `immagine` = ''; -INSERT INTO `zz_files` (`id_module`, `id_record`, `nome`, `filename`, `original`) SELECT (SELECT `id` FROM `zz_modules` WHERE `name` = 'Articoli'), `id`, 'Immagine', `immagine`, `immagine` FROM `mg_articoli` WHERE `immagine` IS NOT NULL; - --- Immagini impianto come allegati -ALTER TABLE `my_impianti` CHANGE `immagine` `immagine` varchar(255); -UPDATE `my_impianti` SET `immagine` = NULL WHERE `immagine` = ''; -INSERT INTO `zz_files` (`id_module`, `id_record`, `nome`, `filename`, `original`) SELECT (SELECT `id` FROM `zz_modules` WHERE `name` = 'MyImpianti'), `id`, 'Immagine', `immagine`, `immagine` FROM `my_impianti` WHERE `immagine` IS NOT NULL; - --- Fix widgets fatturato, prendo importi dallo scadenzario -UPDATE `zz_widgets` SET `query` = 'SELECT CONCAT_WS(" ", REPLACE(REPLACE(REPLACE(FORMAT((SELECT ABS(SUM(da_pagare))), 2), ",", "#"), ".", ","), "#", "."), "€") AS dato FROM (co_scadenziario INNER JOIN co_documenti ON co_scadenziario.iddocumento=co_documenti.id) INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE co_tipidocumento.dir=''entrata'' |segment| AND data_emissione >= "|period_start|" AND data_emissione <= "|period_end|" AND 1=1' WHERE `zz_widgets`.`name` = 'Fatturato'; - -UPDATE `zz_widgets` SET `query` = 'SELECT CONCAT_WS(" ", REPLACE(REPLACE(REPLACE(FORMAT((SELECT ABS(SUM(da_pagare))), 2), ",", "#"), ".", ","), "#", "."), "€") AS dato FROM (co_scadenziario INNER JOIN co_documenti ON co_scadenziario.iddocumento=co_documenti.id) INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE co_tipidocumento.dir=''uscita'' |segment| AND data_emissione >= "|period_start|" AND data_emissione <= "|period_end|" AND 1=1', `help` = 'Fatturato IVA inclusa.' WHERE `zz_widgets`.`name` = 'Acquisti'; - --- Per i crediti / debiti considero o no il periodo temporale? -UPDATE `zz_widgets` SET `query` = 'SELECT CONCAT_WS(" ", REPLACE(REPLACE(REPLACE(FORMAT((SELECT ABS(SUM(da_pagare-pagato))), 2), ",", "#"), ".", ","), "#", "."), "€") AS dato FROM (co_scadenziario INNER JOIN co_documenti ON co_scadenziario.iddocumento=co_documenti.id) INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE co_tipidocumento.dir=''entrata'' |segment| AND 1=1', `help` = 'Crediti IVA inclusa.' WHERE `zz_widgets`.`name` = 'Crediti da clienti'; - -UPDATE `zz_widgets` SET `query` = 'SELECT CONCAT_WS('' '', REPLACE(REPLACE(REPLACE(FORMAT((SELECT ABS(SUM(da_pagare-pagato))), 2), '','', ''#''), ''.'', '',''),''#'', ''.''), ''€'') AS dato FROM (co_scadenziario INNER JOIN co_documenti ON co_scadenziario.iddocumento=co_documenti.id) INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE co_tipidocumento.dir=''uscita'' |segment| AND 1=1', `help` = 'Debiti IVA inclusa.' WHERE `zz_widgets`.`name` = 'Debiti verso fornitori'; - --- Introduzione del tipo documento nelle tabelle Fatture -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `enabled`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'), 'Tipo', 'co_tipidocumento.descrizione', 4, 1, 0, 1, 1); -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `enabled`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di acquisto'), 'Tipo', -'co_tipidocumento.descrizione', 4, 1, 0, 1, 1); - --- Aggiunta di alcuni filtri di base -INSERT INTO `zz_group_module` (`id`, `idgruppo`, `idmodule`, `name`, `clause`, `position`, `enabled`, `default`) VALUES -(NULL, (SELECT `id` FROM `zz_groups` WHERE `nome` = 'Clienti'), (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ddt di vendita'), 'Mostra ddt di vendita ai clienti coinvolti', 'dt_ddt.idanagrafica=|idanagrafica|', 'WHR', '0', '1'), -(NULL, (SELECT `id` FROM `zz_groups` WHERE `nome` = 'Clienti'), (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ordini cliente'), 'Mostra ordini cliente ai clienti coinvolti', 'or_ordini.idanagrafica=|idanagrafica|', 'WHR', '0', '1'), -(NULL, (SELECT `id` FROM `zz_groups` WHERE `nome` = 'Clienti'), (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'), 'Mostra fatture di vendita ai clienti coinvolti', 'co_documenti.idanagrafica=|idanagrafica|', 'WHR', '0', '1'); - --- Sostituzione deleted con deleted_at -ALTER TABLE `co_banche` ADD `deleted_at` timestamp NULL DEFAULT NULL; -UPDATE `co_banche` SET `deleted_at` = NOW() WHERE `deleted` = 1; -ALTER TABLE `co_banche` DROP `deleted`; - -ALTER TABLE `an_anagrafiche` ADD `deleted_at` timestamp NULL DEFAULT NULL; -UPDATE `an_anagrafiche` SET `deleted_at` = NOW() WHERE `deleted` = 1; -ALTER TABLE `an_anagrafiche` DROP `deleted`; - -ALTER TABLE `in_statiintervento` ADD `deleted_at` timestamp NULL DEFAULT NULL; -UPDATE `in_statiintervento` SET `deleted_at` = NOW() WHERE `deleted` = 1; -ALTER TABLE `in_statiintervento` DROP `deleted`; - -ALTER TABLE `zz_emails` ADD `deleted_at` timestamp NULL DEFAULT NULL; -UPDATE `zz_emails` SET `deleted_at` = NOW() WHERE `deleted` = 1; -ALTER TABLE `zz_emails` DROP `deleted`; - -ALTER TABLE `zz_smtp` ADD `deleted_at` timestamp NULL DEFAULT NULL; -UPDATE `zz_smtp` SET `deleted_at` = NOW() WHERE `deleted` = 1; -ALTER TABLE `zz_smtp` DROP `deleted`; - -ALTER TABLE `in_interventi` ADD `deleted_at` timestamp NULL DEFAULT NULL; -UPDATE `in_interventi` SET `deleted_at` = NOW() WHERE `deleted` = 1; -ALTER TABLE `in_interventi` DROP `deleted`; - -UPDATE `zz_widgets` SET `query` = REPLACE( - REPLACE( - REPLACE(`query`, 'deleted=0', '`deleted_at` IS NULL') - , 'deleted = 0', '`deleted_at` IS NULL') -, '`deleted` = 0', '`deleted_at` IS NULL'); -UPDATE `zz_modules` SET `options` = REPLACE( - REPLACE( - REPLACE(`options`, 'deleted=0', '`deleted_at` IS NULL') - , 'deleted = 0', '`deleted_at` IS NULL') -, '`deleted` = 0', '`deleted_at` IS NULL'), `options2` = REPLACE( - REPLACE( - REPLACE(`options2`, 'deleted=0', '`deleted_at` IS NULL') - , 'deleted = 0', '`deleted_at` IS NULL') -, '`deleted` = 0', '`deleted_at` IS NULL'); -UPDATE `zz_group_module` SET `clause` = REPLACE( - REPLACE( - REPLACE(`clause`, 'deleted=0', '`deleted_at` IS NULL') - , 'deleted = 0', '`deleted_at` IS NULL') -, '`deleted` = 0', '`deleted_at` IS NULL'); -UPDATE `zz_views` SET `query` = REPLACE( - REPLACE( - REPLACE(`query`, 'deleted=0', '`deleted_at` IS NULL') - , 'deleted = 0', '`deleted_at` IS NULL') -, '`deleted` = 0', '`deleted_at` IS NULL'); -UPDATE `zz_settings` SET `tipo` = REPLACE( - REPLACE( - REPLACE(`tipo`, 'deleted=0', '`deleted_at` IS NULL') - , 'deleted = 0', '`deleted_at` IS NULL') -, '`deleted` = 0', '`deleted_at` IS NULL'); - -UPDATE `zz_widgets` SET `query` = REPLACE( - REPLACE( - REPLACE(`query`, 'deleted=1', '`deleted_at` IS NOT NULL') - , 'deleted = 1', '`deleted_at` IS NOT NULL') -, '`deleted` = 1', '`deleted_at` IS NOT NULL'); -UPDATE `zz_modules` SET `options` = REPLACE( - REPLACE( - REPLACE(`options`, 'deleted=1', '`deleted_at` IS NOT NULL') - , 'deleted = 1', '`deleted_at` IS NOT NULL') -, '`deleted` = 1', '`deleted_at` IS NOT NULL'), `options2` = REPLACE( - REPLACE( - REPLACE(`options2`, 'deleted=1', '`deleted_at` IS NOT NULL') - , 'deleted = 1', '`deleted_at` IS NOT NULL') -, '`deleted` = 1', '`deleted_at` IS NOT NULL'); -UPDATE `zz_group_module` SET `clause` = REPLACE( - REPLACE( - REPLACE(`clause`, 'deleted=1', '`deleted_at` IS NOT NULL') - , 'deleted = 1', '`deleted_at` IS NOT NULL') -, '`deleted` = 1', '`deleted_at` IS NOT NULL'); -UPDATE `zz_views` SET `query` = REPLACE( - REPLACE( - REPLACE(`query`, 'deleted=1', '`deleted_at` IS NOT NULL') - , 'deleted = 1', '`deleted_at` IS NOT NULL') -, '`deleted` = 1', '`deleted_at` IS NOT NULL'); -UPDATE `zz_settings` SET `tipo` = REPLACE( - REPLACE( - REPLACE(`tipo`, 'deleted=1', '`deleted_at` IS NOT NULL') - , 'deleted = 1', '`deleted_at` IS NOT NULL') -, '`deleted` = 1', '`deleted_at` IS NOT NULL'); - --- Fix id delle Banche -UPDATE `zz_views` SET `enabled` = 0 WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Banche') AND `name` = 'id'; - --- Aggiunta campi per specificare se la riga importata è un import unico di pù righe -ALTER TABLE `co_righe_documenti` ADD `is_preventivo` TINYINT(1) NOT NULL AFTER `is_descrizione`, ADD `is_contratto` TINYINT(1) NOT NULL AFTER `is_preventivo`; - --- Aggiunta colonna 'Sede' per MyImpianti -INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `enabled`, `summable`, `default` ) VALUES -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'MyImpianti'), 'Sede', 'IF(my_impianti.idsede = 0, \'Sede legale\', (SELECT CONCAT_WS( '' - '', nomesede, citta ) AS descrizione FROM an_sedi WHERE id = my_impianti.idsede))', 4, 1, 0, 0, '', '', 0, 0, 0); - --- Aggiunta colonna 'Tempo standard' per Tipi di intervento -INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `enabled`, `summable`, `default` ) VALUES -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi di intervento'), 'Tempo standard', 'in_tipiintervento.tempo_standard', 10, 1, 0, 1, '', '', 0, 0, 0); - --- Disabilito temporaneamente le stampe degli ordini di servizio, plugins disabilitati -UPDATE `zz_prints` SET `enabled` = 0 WHERE `name` IN( 'Ordine di servizio', 'Ordine di servizio (senza costi)' ); - --- Fix colonna delle stampe -UPDATE `zz_views` SET `query` = '\'Intervento\'' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi') AND `name` = '_print_'; - --- Flag per definire i segmenti di note di accredito e di addebito -ALTER TABLE `zz_segments` ADD `predefined_accredito` TINYINT(1) NOT NULL AFTER `predefined`, ADD `predefined_addebito` TINYINT(1) NOT NULL AFTER `predefined_accredito`; - --- Fattura di vendita senza intestazione (per carta intestata) -INSERT INTO `zz_prints` (`id`, `id_module`, `is_record`, `name`, `title`, `directory`, `previous`, `options`, `icon`, `version`, `compatibility`, `order`, `main`, `default`, `enabled`) VALUES -(NULL, (SELECT id FROM zz_modules WHERE name='Fatture di vendita'), 1, 'Fattura di vendita (senza intestazione)', 'Fattura di vendita (senza intestazione)', 'fatture', 'iddocumento', '{"hide_header":true, "hide_footer":true}', 'fa fa-print', '', '', 0, 0, 1, 1); -UPDATE `zz_prints` SET `main` = '1' WHERE `name` = 'Fattura di vendita'; - --- Innesto modulo per campi personalizzati -INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Campi personalizzati', 'Campi personalizzati', 'custom_fields', 'SELECT |select| FROM `zz_fields` WHERE 1=1 HAVING 2=2', '', 'fa fa-list', '2.4.1', '2.4.1', '1', NULL, '1', '0'); -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Campi personalizzati' AND `t2`.`name` = 'Strumenti') SET `t1`.`parent` = `t2`.`id`; - -INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `enabled`, `summable`, `default`) VALUES -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Campi personalizzati'), 'id', 'id', 0, 0, 0, 0, 0, 0, 1), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Campi personalizzati'), 'Modulo', '(SELECT name FROM zz_modules WHERE zz_modules.id = zz_fields.id_module)', 0, 1, 0, 0, 1, 0, 1), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Campi personalizzati'), 'Plugin', '(SELECT name FROM zz_plugins WHERE zz_plugins.id = zz_fields.id_plugin)', 0, 1, 0, 0, 1, 0, 1), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Campi personalizzati'), 'Nome', 'name', 0, 1, 0, 0, 1, 0, 1); diff --git a/update/2_4_10.php b/update/2_4_10.php deleted file mode 100755 index 8dffaec7e..000000000 --- a/update/2_4_10.php +++ /dev/null @@ -1,159 +0,0 @@ -fetchArray('SELECT id, bollo, split_payment FROM co_documenti'); -foreach ($fatture as $fattura) { - $bollo = $fattura['bollo']; - - if (empty($bollo)) { - if (empty($fattura['split_payment'])) { - $totale = 'subtotale - sconto + iva + rivalsainps'; - } else { - $totale = 'subtotale - sconto + rivalsainps'; - } - - $righe = $database->fetchArray('SELECT ('.$totale.') AS netto FROM co_righe_documenti INNER JOIN co_iva ON co_iva.id = co_righe_documenti.idiva WHERE iddocumento = '.prepare($fattura['id'])." AND codice_natura_fe IN ('N1', 'N2', 'N3', 'N4')"); - $totale = sum(array_column($righe, 'netto')); - $importo_bollo = setting('Importo marca da bollo'); - if (abs($importo_bollo) > 0 && abs($totale) > setting("Soglia minima per l'applicazione della marca da bollo")) { - $bollo = $importo_bollo; - } - } - - $bollo = floatval($bollo); - if ($bollo > 0) { - $fatture = $database->query( - 'insert into `co_righe_documenti` (`iddocumento`, `order`, `descrizione`, `um`, `idiva`, `idconto`, `calcolo_ritenuta_acconto`, `idritenutaacconto`, `ritenuta_contributi`, `idrivalsainps`, `prezzo_unitario_acquisto`, `sconto_unitario`, `tipo_sconto`, `qta`, `data_inizio_periodo`, `data_fine_periodo`, `riferimento_amministrazione`, `tipo_cessione_prestazione`, `ritenutaacconto`, `rivalsainps`, `subtotale`, `sconto`, `iva`, `desc_iva`, `iva_indetraibile`, `created_at`) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [ - 0 => $fattura['id'], - 1 => 0, - 2 => 'Marca da bollo', - 3 => null, - 4 => '110', - 5 => '99', - 6 => null, - 7 => null, - 8 => false, - 9 => null, - 10 => 0, - 11 => 0.0, - 12 => 'PRC', - 13 => 1.0, - 14 => null, - 15 => null, - 16 => '', - 17 => '', - 18 => 0.0, - 19 => 0.0, - 20 => $bollo, - 21 => 0.0, - 22 => 0.0, - 23 => 'Escluso art. 15', - 24 => 0.0, - 25 => '2020-10-17 10:00:00', - ]); - $id_riga_bollo = $database->lastInsertedId(); - - $database->query('UPDATE co_documenti SET id_riga_bollo = '.prepare($id_riga_bollo).' WHERE id = '.prepare($fattura['id'])); - } -} - -// Fix per le relazioni tariffe-tecnici -$tecnici = $database->fetchArray("SELECT DISTINCT(an_anagrafiche.idanagrafica) AS id FROM an_anagrafiche - INNER JOIN an_tipianagrafiche ON an_anagrafiche.idanagrafica = an_anagrafiche.idanagrafica - INNER JOIN an_tipianagrafiche_anagrafiche ON an_tipianagrafiche.idtipoanagrafica = an_tipianagrafiche_anagrafiche.idtipoanagrafica -WHERE an_tipianagrafiche.descrizione = 'Tecnico'"); -foreach ($tecnici as $tecnico) { - $presenti = $database->fetchArray('SELECT idtipointervento AS id FROM in_tariffe WHERE idtecnico = '.prepare($tecnico['id'])); - - // Aggiunta associazioni costi unitari al contratto - $query = 'SELECT in_tipiintervento.*, in_tipiintervento.idtipointervento AS id FROM in_tipiintervento'; - $elenco_presenti = array_column($presenti, 'id'); - if (!empty($elenco_presenti)) { - $query .= ' WHERE idtipointervento NOT IN ('.implode(', ', $elenco_presenti).')'; - } - $tipi = $database->fetchArray($query); - - foreach ($tipi as $tipo) { - $database->insert('in_tariffe', [ - 'idtecnico' => $tecnico['id'], - 'idtipointervento' => $tipo['id'], - 'costo_ore' => $tipo['costo_orario'], - 'costo_km' => $tipo['costo_km'], - 'costo_dirittochiamata' => $tipo['costo_diritto_chiamata'], - 'costo_ore_tecnico' => $tipo['costo_orario_tecnico'], - 'costo_km_tecnico' => $tipo['costo_km_tecnico'], - 'costo_dirittochiamata_tecnico' => $tipo['costo_diritto_chiamata_tecnico'], - ]); - } -} - -// Spostamento automezzi su sedi -$automezzi = $database->fetchArray('SELECT * FROM dt_automezzi'); -foreach ($automezzi as $automezzo) { - $nomesede = []; - - (!empty($automezzo['nome'])) ? $nomesede[] = $automezzo['nome'] : null; - (!empty($automezzo['descrizione'])) ? $nomesede[] = $automezzo['descrizione'] : null; - (!empty($automezzo['targa'])) ? $nomesede[] = $automezzo['targa'] : null; - - $database->insert( - 'an_sedi', - [ - 'nomesede' => implode(' - ', $nomesede), - 'idanagrafica' => setting('Azienda predefinita'), - ] - ); - - $idsede = $database->lastInsertedId(); - - // Aggiornamento sede di partenza su - $database->update( - 'in_interventi', - [ - 'idsede_partenza' => $idsede, - ], [ - 'idautomezzo' => $automezzo['id'], - ] - ); -} - -// Aggiornamento della sede azienda nei movimenti degli interventi -$database->query('UPDATE mg_movimenti SET idsede_azienda=(SELECT idsede_partenza FROM in_interventi WHERE in_interventi.id=mg_movimenti.idintervento) WHERE idintervento IS NOT NULL'); - -// Cancellazione idautomezzo da mg_movimenti e in_interventi -$database->query('ALTER TABLE in_interventi DROP idautomezzo'); -$database->query('ALTER TABLE mg_movimenti DROP idautomezzo'); -$database->query('ALTER TABLE co_promemoria_articoli DROP idautomezzo'); -$database->query('ALTER TABLE co_righe_documenti DROP idautomezzo'); -$database->query('ALTER TABLE mg_articoli_interventi DROP idautomezzo'); - -// Eliminazione tabelle degli automezzi non più usate -$database->query('DROP TABLE mg_articoli_automezzi'); -$database->query('DROP TABLE dt_automezzi'); -$database->query('DROP TABLE dt_automezzi_tecnici'); -$database->query('DELETE FROM zz_modules WHERE name="Automezzi"'); - -//Rimuovo il codice come indice per in_interventi -$database->query('ALTER TABLE `in_interventi` DROP INDEX `codice`'); - -// File e cartelle deprecate -$files = [ - 'modules\automezzi', - 'modules\anagrafiche\plugins\statistiche.php', - 'modules\interventi\src\TipoSessione.php', - 'templates\registro_iva\body.php', - 'templates\registro_iva\header.php', - 'templates\scadenzario\scadenzario.html', - 'templates\scadenzario\scadenzario_body.html', - 'templates\scadenzario\pdfgen.scadenzario.php', -]; - -foreach ($files as $key => $value) { - $files[$key] = realpath(base_dir().'/'.$value); -} - -delete($files); diff --git a/update/2_4_10.sql b/update/2_4_10.sql deleted file mode 100755 index b55223f05..000000000 --- a/update/2_4_10.sql +++ /dev/null @@ -1,274 +0,0 @@ --- Fix colonna Totale per Fatture -UPDATE `zz_views` SET `query` = '(SELECT SUM(subtotale - sconto + iva + rivalsainps - ritenutaacconto) FROM co_righe_documenti WHERE co_righe_documenti.iddocumento=co_documenti.id GROUP BY iddocumento) + iva_rivalsainps' WHERE `zz_views`.`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita') AND name = 'Totale'; -UPDATE `zz_views` SET `query` = '(SELECT SUM(subtotale - sconto + iva + rivalsainps - ritenutaacconto) FROM co_righe_documenti WHERE co_righe_documenti.iddocumento=co_documenti.id GROUP BY iddocumento) + iva_rivalsainps' WHERE `zz_views`.`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di acquisto') AND name = 'Totale'; - --- Fix widget Contratti in scadenza per mostrare i contratti con ore in esaurimento -UPDATE `zz_widgets` SET `query` = 'SELECT COUNT(id) AS dato, - ((SELECT SUM(co_righe_contratti.qta) FROM co_righe_contratti WHERE co_righe_contratti.um=\'ore\' AND co_righe_contratti.idcontratto=co_contratti.id) - IFNULL( (SELECT SUM(in_interventi_tecnici.ore) FROM in_interventi_tecnici INNER JOIN in_interventi ON in_interventi_tecnici.idintervento=in_interventi.id WHERE in_interventi.id_contratto=co_contratti.id AND in_interventi.idstatointervento IN (SELECT in_statiintervento.idstatointervento FROM in_statiintervento WHERE in_statiintervento.completato = 1)), 0) ) AS ore_rimanenti, - DATEDIFF(data_conclusione, NOW()) AS giorni_rimanenti, - data_conclusione, - ore_preavviso_rinnovo, - giorni_preavviso_rinnovo, - (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=co_contratti.idanagrafica) AS ragione_sociale -FROM co_contratti WHERE - idstato IN (SELECT id FROM co_staticontratti WHERE is_fatturabile = 1) AND - rinnovabile = 1 AND - YEAR(data_conclusione) > 1970 AND - (SELECT id FROM co_contratti contratti WHERE contratti.idcontratto_prev = co_contratti.id) IS NULL -HAVING (ore_rimanenti < ore_preavviso_rinnovo OR DATEDIFF(data_conclusione, NOW()) < ABS(giorni_preavviso_rinnovo)) -ORDER BY giorni_rimanenti ASC, ore_rimanenti ASC' WHERE `zz_widgets`.`name` = 'Contratti in scadenza'; - --- Miglioramento hooks -ALTER TABLE `zz_hooks` ADD `enabled` boolean NOT NULL DEFAULT 1, ADD `id_module` int(11) NOT NULL; -UPDATE `zz_hooks` SET `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita') WHERE `name` = 'Ricevute'; -UPDATE `zz_hooks` SET `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di acquisto') WHERE `name` = 'Fatture'; -ALTER TABLE `zz_hooks` ADD FOREIGN KEY (`id_module`) REFERENCES `zz_modules`(`id`) ON DELETE CASCADE; - -INSERT INTO `zz_hooks` (`id`, `name`, `class`, `frequency`, `id_module`) VALUES -(NULL, 'Aggiornamenti', 'Modules\\Aggiornamenti\\UpdateHook', '7 day', (SELECT `id` FROM `zz_modules` WHERE `name` = 'Aggiornamenti')); - --- --- Aggiunta nuovi campi per tracciamento sedi --- -ALTER TABLE `mg_movimenti` ADD `idsede_azienda` INT NOT NULL AFTER `idautomezzo`, ADD `idsede_controparte` INT NOT NULL AFTER `idsede_azienda`; - --- --- Creazione plugin Giacenze --- -INSERT INTO `zz_plugins` (`id`, `name`, `title`, `idmodule_from`, `idmodule_to`, `position`, `script`, `enabled`, `default`, `order`, `compatibility`, `version`, `options2`, `options`, `directory`, `help`) VALUES (NULL, 'Giacenze', 'Giacenze', (SELECT id FROM zz_modules WHERE name='Articoli'), (SELECT id FROM zz_modules WHERE name='Articoli'), 'tab', 'articoli.giacenze.php', '1', '0', '0', '', '', NULL, NULL, '', ''); - --- Aggiornamento nomi dei campi sede per ddt -ALTER TABLE `dt_ddt` CHANGE `idsede` `idsede_partenza` INT NOT NULL; -ALTER TABLE `dt_ddt` ADD `idsede_destinazione` INT NOT NULL AFTER `idsede_partenza`; - --- Aggiornamento idsede_destinazione per i ddt di vendita -UPDATE `dt_ddt` SET `idsede_destinazione`=`idsede_partenza` WHERE `idtipoddt` IN (SELECT id FROM dt_tipiddt WHERE dir="entrata"); -UPDATE `dt_ddt` SET `idsede_partenza`=0 WHERE `idtipoddt` IN (SELECT id FROM dt_tipiddt WHERE dir="entrata"); -UPDATE `dt_ddt` SET `idsede_destinazione`=0 WHERE `idtipoddt` IN (SELECT id FROM dt_tipiddt WHERE dir="uscita"); - - -UPDATE `zz_modules` SET `options`='SELECT |select| FROM (((((((`dt_ddt` INNER JOIN `dt_tipiddt` ON `dt_ddt`.`idtipoddt` = `dt_tipiddt`.`id`) LEFT OUTER JOIN `dt_righe_ddt` ON `dt_ddt`.`id` = `dt_righe_ddt`.`idddt`) LEFT OUTER JOIN `dt_causalet` ON `dt_ddt`.`idcausalet` = `dt_causalet`.`id`) LEFT OUTER JOIN `dt_spedizione` ON `dt_ddt`.`idspedizione` = `dt_spedizione`.`id`) LEFT OUTER JOIN `an_anagrafiche` `vettori` ON `dt_ddt`.`idvettore` = `vettori`.`idanagrafica`) LEFT OUTER JOIN `an_anagrafiche` AS `destinatari` ON `dt_ddt`.`idanagrafica` = `destinatari`.`idanagrafica`) LEFT OUTER JOIN an_sedi AS sedi ON `dt_ddt`.`idsede_partenza` = `sedi`.`id`) LEFT OUTER JOIN an_sedi AS sedi_destinazione ON dt_ddt.idsede_destinazione = sedi_destinazione.id WHERE 1=1 AND `dir` = ''entrata'' |date_period(`data`)| GROUP BY dt_ddt.id HAVING 2=2 ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC,`dt_ddt`.created_at DESC' WHERE name="Ddt di vendita"; - -UPDATE `zz_modules` SET `options`='SELECT |select| FROM (((((((`dt_ddt` INNER JOIN `dt_tipiddt` ON `dt_ddt`.`idtipoddt` = `dt_tipiddt`.`id`) LEFT OUTER JOIN `dt_righe_ddt` ON `dt_ddt`.`id` = `dt_righe_ddt`.`idddt`) LEFT OUTER JOIN `dt_causalet` ON `dt_ddt`.`idcausalet` = `dt_causalet`.`id`) LEFT OUTER JOIN `dt_spedizione` ON `dt_ddt`.`idspedizione` = `dt_spedizione`.`id`) LEFT OUTER JOIN `an_anagrafiche` `vettori` ON `dt_ddt`.`idvettore` = `vettori`.`idanagrafica`) LEFT OUTER JOIN `an_anagrafiche` AS `destinatari` ON `dt_ddt`.`idanagrafica` = `destinatari`.`idanagrafica`) LEFT OUTER JOIN `an_sedi` AS sedi ON `dt_ddt`.`idsede_partenza` = sedi.`id`) LEFT OUTER JOIN an_sedi AS sedi_destinazione ON dt_ddt.idsede_destinazione = sedi_destinazione.id WHERE 1=1 AND `dir` = ''uscita'' |date_period(`data`)| GROUP BY dt_ddt.id HAVING 2=2 ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC,`dt_ddt`.created_at DESC' WHERE name="Ddt di acquisto"; - --- Aggiornamento nomi dei campi sede per co_documenti -ALTER TABLE `co_documenti` ADD `idsede_destinazione` INT NOT NULL AFTER `idsede`; -ALTER TABLE `co_documenti` CHANGE `idsede` `idsede_partenza` INT(11) NOT NULL; - --- Aggiornamento idsede su co_documenti come ddt -UPDATE `co_documenti` SET `idsede_destinazione`=`idsede_partenza` WHERE `idtipodocumento` IN (SELECT id FROM co_tipidocumento WHERE dir="entrata"); -UPDATE `co_documenti` SET `idsede_partenza`=0 WHERE `idtipodocumento` IN (SELECT id FROM co_tipidocumento WHERE dir="entrata"); -UPDATE `co_documenti` SET `idsede_destinazione`=0 WHERE `idtipodocumento` IN (SELECT id FROM co_tipidocumento WHERE dir="uscita"); - --- Rinomino idsede in in_interventi in idsede_destinazione -ALTER TABLE `in_interventi` CHANGE `idsede` `idsede_destinazione` INT(11) NOT NULL; - --- Creazione idsede_partenza in_interventi -ALTER TABLE `in_interventi` ADD `idsede_partenza` INT NOT NULL AFTER `prezzo_ore_unitario`; - --- Aggiunta sede destinazione ddt uscita -INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `visible`, `summable`, `default`) VALUES ('0', (SELECT id FROM zz_modules WHERE name='Ddt di vendita'), 'Sede destinazione', 'IF(`dt_ddt`.`idsede_destinazione`=0, \'Sede legale\',CONCAT_WS(\' - \', sedi_destinazione.nomesede,sedi_destinazione.citta))', '5', '1', '0', '0', '', '', '1', '0', '0'); - --- Aggiunta sede destinazione ddt in entrata -INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `visible`, `summable`, `default`) VALUES ('0', (SELECT id FROM zz_modules WHERE name='Ddt di acquisto'), 'Sede destinazione', 'IF(`dt_ddt`.`idsede_destinazione`=0, \'Sede legale\',CONCAT_WS(\' - \', sedi_destinazione.nomesede,sedi_destinazione.citta))', '5', '1', '0', '1', '', '', '1', '0', '0'); - --- Update sede -> sede partenza ddt in uscita -UPDATE zz_views SET query='IF(dt_ddt.idsede_partenza=0, "Sede legale",CONCAT_WS(" - ", sedi.nomesede,sedi.citta))', name='Sede partenza' WHERE id_module=(SELECT id FROM zz_modules WHERE name="Ddt di vendita") AND name= "sede"; - --- Update sede -> sede partenza ddt in entrata -UPDATE zz_views SET query='IF(`dt_ddt`.`idsede_partenza`=0, "Sede legale",CONCAT_WS(" - ", sedi.nomesede,sedi.citta))', name="Sede partenza" WHERE id_module=(SELECT id FROM zz_modules WHERE name="Ddt di acquisto") AND name= "sede"; - --- Aggiornamento idsede_destinazione sui movimenti degli articoli inseriti sulle attività -UPDATE `mg_movimenti` SET `idsede_controparte` = (SELECT `idsede_destinazione` FROM `in_interventi` WHERE `in_interventi`.`id` = `mg_movimenti`.`idintervento`) WHERE `idintervento` IS NOT NULL; - --- Aggiorno idsede_azienda e controparte per ddt -UPDATE `mg_movimenti` SET `idsede_controparte` = (SELECT `idsede_destinazione` FROM `dt_ddt` WHERE `dt_ddt`.`id` = `mg_movimenti`.`idddt`) WHERE `idddt`!=0; -UPDATE `mg_movimenti` SET `idsede_azienda` = (SELECT `idsede_partenza` FROM `dt_ddt` WHERE `dt_ddt`.`id` = `mg_movimenti`.`idddt`) WHERE `idddt`!=0; - --- Aggiorno idsede_azienda e controparte per documenti -UPDATE `mg_movimenti` SET `idsede_controparte` = (SELECT `idsede_destinazione` FROM `co_documenti` WHERE `co_documenti`.`id` = `mg_movimenti`.`iddocumento`) WHERE `iddocumento`!=0; -UPDATE `mg_movimenti` SET `idsede_azienda` = (SELECT `idsede_destinazione` FROM `co_documenti` WHERE `co_documenti`.`id` = `mg_movimenti`.`iddocumento`) WHERE `iddocumento`!=0; - --- Sistemo vista per icon_Inviata modulo Fatture di vendita -UPDATE `zz_views` SET `query` = 'IF(`email`.`name` IS NOT NULL, \'fa fa-envelope text-success\', \'\')' WHERE `zz_views`.`name` = 'icon_Inviata' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita') ; - --- Sistemo vista per icon_title_Inviata modulo Fatture di vendita -UPDATE `zz_views` SET `query` = '`email`.`name`' WHERE `zz_views`.`name` = 'icon_title_Inviata' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita') ; - --- Relazione fra utente e una o più sedi -CREATE TABLE `zz_user_sedi` ( - `id_user` int(11) NOT NULL, - `idsede` int(11) NOT NULL -) ENGINE=InnoDB; - --- Sistemo colonna Nome, Descrizione - Modelli prima nota -UPDATE `zz_views` SET `query` = 'CONCAT_WS(co_movimenti_modelli.nome, co_movimenti_modelli.descrizione)' WHERE `zz_views`.`name` = 'Nome' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Modelli prima nota'); - -UPDATE `co_movimenti_modelli` SET `nome` = `descrizione` WHERE `nome` = ''; - --- Rimuovo le interruzioni di riga per descrizioni vuote --- UPDATE `in_interventi` SET `descrizione` = REPLACE(`descrizione`, '\n', '') where `descrizione` LIKE '%\n'; - --- Aggiunto tabella co_tipi_scadenze -CREATE TABLE `co_tipi_scadenze` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `nome` varchar(255) NOT NULL, - `descrizione` varchar(255) NOT NULL, - `can_delete` tinyint(1) NOT NULL DEFAULT '1', - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - -INSERT INTO `co_tipi_scadenze` (`id`, `nome`, `descrizione`, `can_delete`) VALUES -(1, 'f24', 'F24', 0), -(2, 'generico', 'Scadenze generiche', 0); - --- Aggiunto modulo per gestire i tipi di scadenze -INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Tipi scadenze', 'Tipi scadenze', 'tipi_scadenze', 'SELECT |select| FROM `co_tipi_scadenze` WHERE 1=1 HAVING 2=2', '', 'fa fa-calendar', '2.4.10', '2.4.10', '1', (SELECT `id` FROM `zz_modules` t WHERE t.`name` = 'Tabelle'), '1', '1'); - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi scadenze'), 'Descrizione', 'descrizione', 3, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi scadenze'), 'Nome', 'nome', 2, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi scadenze'), 'id', 'id', 1, 1, 0, 0, 0); - --- Aggiungo possibilità di vedere la descrizione per le scadenze generiche -UPDATE `zz_views` SET `query` = 'IF(an_anagrafiche.ragione_sociale IS NULL, co_scadenziario.descrizione, an_anagrafiche.ragione_sociale)' WHERE `zz_views`.`name` = 'Anagrafica' AND `zz_views`.`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Scadenzario'); - --- Plugin rinnovi per Contratti -INSERT INTO `zz_plugins` (`id`, `name`, `title`, `idmodule_from`, `idmodule_to`, `position`, `script`, `enabled`, `default`, `order`, `compatibility`, `version`, `options2`, `options`, `directory`, `help`) VALUES (NULL, 'Rinnovi', 'Rinnovi', (SELECT `id` FROM `zz_modules` WHERE `name` = 'Contratti'), (SELECT `id` FROM `zz_modules` WHERE `name` = 'Contratti'), 'tab', '', 1, 0, 0, '', '', NULL, 'custom', 'rinnovi_contratti', ''); - --- Aggiornamento Tecnici e tariffe -UPDATE `zz_modules` SET `options` = ' -SELECT |select| FROM an_anagrafiche WHERE idanagrafica IN ( - SELECT idanagrafica FROM an_tipianagrafiche_anagrafiche WHERE idtipoanagrafica IN ( - SELECT idtipoanagrafica FROM an_tipianagrafiche WHERE descrizione = ''Tecnico'' - ) -) AND deleted_at IS NULL AND 1=1 HAVING 2=2 ORDER BY ragione_sociale' WHERE `name` = 'Tecnici e tariffe'; - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Tecnici e tariffe'), '_bg_', 'colore', 3, 1, 0, 0, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Tecnici e tariffe'), 'Nome', 'ragione_sociale', 2, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Tecnici e tariffe'), 'id', 'idanagrafica', 1, 1, 0, 0, 0); - --- Correzione primary key -ALTER TABLE `in_interventi` DROP FOREIGN KEY `in_interventi_ibfk_2`; -ALTER TABLE `in_tipiintervento` DROP PRIMARY KEY; -ALTER TABLE `in_tipiintervento` CHANGE `idtipointervento` `codice` VARCHAR(25) NOT NULL, ADD `idtipointervento` INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT; - -UPDATE `in_interventi` INNER JOIN `in_tipiintervento` ON `in_interventi`.`idtipointervento` = `in_tipiintervento`.`codice` SET `in_interventi`.`idtipointervento` = `in_tipiintervento`.`idtipointervento`; -ALTER TABLE `in_interventi` CHANGE `idtipointervento` `idtipointervento` INT(11) NOT NULL, ADD FOREIGN KEY (`idtipointervento`) REFERENCES `in_tipiintervento`(`idtipointervento`); - -ALTER TABLE `in_statiintervento` DROP PRIMARY KEY; -ALTER TABLE `in_statiintervento` CHANGE `idstatointervento` `codice` VARCHAR(25) NOT NULL, ADD `idstatointervento` INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT; - -UPDATE `in_interventi` INNER JOIN `in_statiintervento` ON `in_interventi`.`idstatointervento` = `in_statiintervento`.`codice` SET `in_interventi`.`idstatointervento` = `in_statiintervento`.`idstatointervento`; -UPDATE `in_interventi` SET `idstatointervento` = (SELECT `idstatointervento` FROM `in_statiintervento` LIMIT 1) WHERE `idstatointervento` NOT IN (SELECT `idstatointervento` FROM `in_statiintervento`); -ALTER TABLE `in_interventi` CHANGE `idstatointervento` `idstatointervento` INT(11) NOT NULL, ADD FOREIGN KEY (`idstatointervento`) REFERENCES `in_statiintervento`(`idstatointervento`); - -UPDATE `an_anagrafiche` INNER JOIN `in_tipiintervento` ON `an_anagrafiche`.`idtipointervento_default` = `in_tipiintervento`.`codice` SET `an_anagrafiche`.`idtipointervento_default` = `in_tipiintervento`.`idtipointervento`; -ALTER TABLE `an_anagrafiche` CHANGE `idtipointervento_default` `idtipointervento_default` varchar(25); -UPDATE `an_anagrafiche` SET `idtipointervento_default` = NULL WHERE `idtipointervento_default` NOT IN (SELECT `idtipointervento` FROM `in_tipiintervento`); -ALTER TABLE `an_anagrafiche` CHANGE `idtipointervento_default` `idtipointervento_default` INT(11), ADD FOREIGN KEY (`idtipointervento_default`) REFERENCES `in_tipiintervento`(`idtipointervento`); - -UPDATE `co_contratti_tipiintervento` INNER JOIN `in_tipiintervento` ON `co_contratti_tipiintervento`.`idtipointervento` = `in_tipiintervento`.`codice` SET `co_contratti_tipiintervento`.`idtipointervento` = `in_tipiintervento`.`idtipointervento`; -DELETE FROM `co_contratti_tipiintervento` WHERE `idtipointervento` NOT IN (SELECT `idtipointervento` FROM `in_tipiintervento`); -ALTER TABLE `co_contratti_tipiintervento` CHANGE `idtipointervento` `idtipointervento` INT(11) NOT NULL, ADD FOREIGN KEY (`idtipointervento`) REFERENCES `in_tipiintervento`(`idtipointervento`); - -UPDATE `co_preventivi` INNER JOIN `in_tipiintervento` ON `co_preventivi`.`idtipointervento` = `in_tipiintervento`.`codice` SET `co_preventivi`.`idtipointervento` = `in_tipiintervento`.`idtipointervento`; -UPDATE `co_preventivi` SET `idtipointervento` = (SELECT `idtipointervento` FROM `in_tipiintervento` LIMIT 1) WHERE `idtipointervento` NOT IN (SELECT `idtipointervento` FROM `in_tipiintervento`); -ALTER TABLE `co_preventivi` CHANGE `idtipointervento` `idtipointervento` INT(11) NOT NULL, ADD FOREIGN KEY (`idtipointervento`) REFERENCES `in_tipiintervento`(`idtipointervento`); - -UPDATE `co_promemoria` INNER JOIN `in_tipiintervento` ON `co_promemoria`.`idtipointervento` = `in_tipiintervento`.`codice` SET `co_promemoria`.`idtipointervento` = `in_tipiintervento`.`idtipointervento`; -ALTER TABLE `co_promemoria` CHANGE `idtipointervento` `idtipointervento` INT(11) NOT NULL, ADD FOREIGN KEY (`idtipointervento`) REFERENCES `in_tipiintervento`(`idtipointervento`); - -UPDATE `in_interventi_tecnici` INNER JOIN `in_tipiintervento` ON `in_interventi_tecnici`.`idtipointervento` = `in_tipiintervento`.`codice` SET `in_interventi_tecnici`.`idtipointervento` = `in_tipiintervento`.`idtipointervento`; -UPDATE `in_interventi_tecnici` SET `idtipointervento` = (SELECT `idtipointervento` FROM `in_tipiintervento` LIMIT 1) WHERE `idtipointervento` NOT IN (SELECT `idtipointervento` FROM `in_tipiintervento`); -ALTER TABLE `in_interventi_tecnici` CHANGE `idtipointervento` `idtipointervento` INT(11) NOT NULL, ADD FOREIGN KEY (`idtipointervento`) REFERENCES `in_tipiintervento`(`idtipointervento`); - -UPDATE `in_tariffe` INNER JOIN `in_tipiintervento` ON `in_tariffe`.`idtipointervento` = `in_tipiintervento`.`codice` SET `in_tariffe`.`idtipointervento` = `in_tipiintervento`.`idtipointervento`; -DELETE FROM `in_tariffe` WHERE `idtipointervento` NOT IN (SELECT `idtipointervento` FROM `in_tipiintervento`); -ALTER TABLE `in_tariffe` CHANGE `idtipointervento` `idtipointervento` INT(11) NOT NULL, ADD FOREIGN KEY (`idtipointervento`) REFERENCES `in_tipiintervento`(`idtipointervento`); - --- Ottimizzazione query Fatture -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_documenti` - INNER JOIN `an_anagrafiche` ON `co_documenti`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - INNER JOIN `co_tipidocumento` ON `co_documenti`.`idtipodocumento` = `co_tipidocumento`.`id` - INNER JOIN `co_statidocumento` ON `co_documenti`.`idstatodocumento` = `co_statidocumento`.`id` - LEFT JOIN `fe_stati_documento` ON `co_documenti`.`codice_stato_fe` = `fe_stati_documento`.`codice` - LEFT JOIN (SELECT `numero_esterno`, `id_segment` FROM `co_documenti` WHERE `co_documenti`.`idtipodocumento` IN(SELECT `id` FROM `co_tipidocumento` WHERE `dir` = ''entrata'') AND `co_documenti`.`data` >= ''2019-01-01'' AND `co_documenti`.`data` <= ''2019-12-31'' GROUP BY `id_segment`, `numero_esterno` HAVING COUNT(`numero_esterno`) > 1) dup ON `co_documenti`.`numero_esterno` = `dup`.`numero_esterno` AND `dup`.`id_segment` = `co_documenti`.`id_segment` - LEFT OUTER JOIN (SELECT `zz_emails`.`name`, `zz_operations`.`id_record` FROM `zz_operations` INNER JOIN `zz_emails` ON `zz_operations`.`id_email` = `zz_emails`.`id` INNER JOIN `zz_modules` ON `zz_operations`.`id_module` = `zz_modules`.`id` AND `zz_modules`.`name` = ''Fatture di vendita'' AND `zz_operations`.`op` = ''send-email'' LIMIT 1) AS `email` ON `email`.`id_record` = `co_documenti`.`id` -WHERE 1=1 AND `dir` = ''entrata'' |segment(co_documenti.id_segment)| AND `co_documenti`.`data` >= ''|period_start|'' AND `co_documenti`.`data` <= ''|period_end|'' -HAVING 2=2 -ORDER BY `co_documenti`.`data` DESC, CAST(`co_documenti`.`numero_esterno` AS UNSIGNED) DESC' WHERE `name` = 'Fatture di vendita'; - -UPDATE `zz_views` SET `query` = 'IF(`dup`.`numero_esterno` IS NULL, '''', ''red'')' WHERE `name` = '_bg_' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'); -UPDATE `zz_views` SET `query` = 'an_anagrafiche.idanagrafica' WHERE `name` = 'idanagrafica' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'); -UPDATE `zz_views` SET `query` = 'IF(co_documenti.numero_esterno='''', co_documenti.numero, co_documenti.numero_esterno)', `order_by` ='CAST(co_documenti.numero_esterno AS UNSIGNED)' WHERE `name` = 'Numero' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'); -UPDATE `zz_views` SET `query` = 'co_documenti.data' WHERE `name` = 'Data' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'); -UPDATE `zz_views` SET `query` = 'an_anagrafiche.ragione_sociale' WHERE `name` = 'Ragione sociale' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'); -UPDATE `zz_views` SET `query` = '(SELECT SUM(subtotale - sconto + iva + rivalsainps - ritenutaacconto) FROM co_righe_documenti WHERE co_righe_documenti.iddocumento=co_documenti.id GROUP BY iddocumento) + co_documenti.iva_rivalsainps' WHERE `name` = 'Totale' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'); -UPDATE `zz_views` SET `query` = 'co_statidocumento.icona' WHERE `name` = 'icon_Stato' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'); -UPDATE `zz_views` SET `query` = 'co_statidocumento.descrizione' WHERE `name` = 'icon_title_Stato' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'); -UPDATE `zz_views` SET `query` = '`fe_stati_documento`.`icon`' WHERE `name` = 'icon_FE' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'); -UPDATE `zz_views` SET `query` = '`fe_stati_documento`.`descrizione`' WHERE `name` = 'icon_title_FE' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'); - --- Impostazione per la lunghezza delle pagine Datatables -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES (NULL, 'Lunghezza in pagine del buffer Datatables', '10', 'decimal', 0, 'Generali', 1); - --- Miglioramento query Scadenzario -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_scadenziario` - LEFT JOIN `co_documenti` ON `co_scadenziario`.`iddocumento` = `co_documenti`.`id` - LEFT JOIN `an_anagrafiche` ON `co_documenti`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - LEFT JOIN `co_pagamenti` ON `co_documenti`.`idpagamento` = `co_pagamenti`.`id` - LEFT JOIN `co_tipidocumento` ON `co_documenti`.`idtipodocumento` = `co_tipidocumento`.`id` - LEFT JOIN `co_statidocumento` ON `co_documenti`.`idstatodocumento` = `co_statidocumento`.`id` -WHERE 1=1 AND ABS(`co_scadenziario`.`pagato`) < ABS(`co_scadenziario`.`da_pagare`) AND `co_statidocumento`.`descrizione` IN(''Emessa'',''Parzialmente pagato'') -HAVING 2=2 -ORDER BY `scadenza` ASC' WHERE `name` = 'Scadenzario'; - --- Plugin Statistiche per Articoli -INSERT INTO `zz_plugins` (`id`, `name`, `title`, `idmodule_from`, `idmodule_to`, `position`, `script`, `enabled`, `default`, `order`, `compatibility`, `version`, `options2`, `options`, `directory`, `help`) VALUES (NULL, 'Statistiche', 'Statistiche', (SELECT `id` FROM `zz_modules` WHERE `name` = 'Articoli'), (SELECT `id` FROM `zz_modules` WHERE `name` = 'Articoli'), 'tab', '', 1, 0, 0, '', '', NULL, 'custom', 'statistiche_articoli', ''); - --- Aggiunta nome file per le stampe -ALTER TABLE `zz_prints` ADD `filename` VARCHAR(255) NOT NULL AFTER `title`; -UPDATE `zz_prints` SET `filename` = 'Fattura num. {numero} del {data}' WHERE `name` = 'Fattura di vendita'; -UPDATE `zz_prints` SET `filename` = 'Fatturato' WHERE `name` = 'Fatturato'; -UPDATE `zz_prints` SET `filename` = 'DDT num. {numero} del {data}' WHERE `name` = 'Ddt di vendita (senza costi)'; -UPDATE `zz_prints` SET `filename` = 'DDT num. {numero} del {data}' WHERE `name` = 'Ddt di vendita'; -UPDATE `zz_prints` SET `filename` = 'Ordine fornitore num. {numero} del {data}' WHERE `name` = 'Ordine fornitore (senza costi)'; -UPDATE `zz_prints` SET `filename` = 'Ordine cliente num. {numero} del {data}' WHERE `name` = 'Ordine cliente (senza costi)'; -UPDATE `zz_prints` SET `filename` = 'Ordine fornitore num. {numero} del {data}' WHERE `name` = 'Ordine fornitore'; -UPDATE `zz_prints` SET `filename` = 'Ordine cliente num. {numero} del {data}' WHERE `name` = 'Ordine cliente'; -UPDATE `zz_prints` SET `filename` = 'Ordine cliente num. {numero} del {data}' WHERE `name` = 'Ordine cliente'; -UPDATE `zz_prints` SET `filename` = 'Contratto num. {numero} del {data}' WHERE `name` = 'Contratto (senza costi)'; -UPDATE `zz_prints` SET `filename` = 'Contratto num. {numero} del {data}' WHERE `name` = 'Contratto'; -UPDATE `zz_prints` SET `filename` = 'Intervento num. {numero} del {data}' WHERE `name` = 'Intervento (senza costi)'; -UPDATE `zz_prints` SET `filename` = 'Intervento num. {numero} del {data}' WHERE `name` = 'Intervento'; -UPDATE `zz_prints` SET `filename` = 'Preventivo num. {numero} del {data}' WHERE `name` = 'Preventivo (senza costi)'; -UPDATE `zz_prints` SET `filename` = 'Preventivo num. {numero} del {data}' WHERE `name` = 'Preventivo'; -UPDATE `zz_prints` SET `filename` = 'Registro IVA {tipo}' WHERE `name` = 'Registro IVA'; -UPDATE `zz_prints` SET `filename` = 'Scadenzario' WHERE `name` = 'Scadenzario'; -UPDATE `zz_prints` SET `filename` = 'Spesometro' WHERE `name` = 'Spesometro'; -UPDATE `zz_prints` SET `filename` = 'Mastrino' WHERE `name` = 'Mastrino'; -UPDATE `zz_prints` SET `filename` = 'Inventario' WHERE `name` = 'Inventario magazzino'; -UPDATE `zz_prints` SET `filename` = 'Riepilogo interventi' WHERE `name` = 'Riepilogo interventi'; -UPDATE `zz_prints` SET `filename` = 'Consuntivo contratto num. {numero} del {data}' WHERE `name` = 'Consuntivo contratto (senza costi)'; -UPDATE `zz_prints` SET `filename` = 'Consuntivo contratto num. {numero} del {data}' WHERE `name` = 'Consuntivo contratto'; -UPDATE `zz_prints` SET `filename` = 'Consuntivo preventivo num. {numero} del {data}' WHERE `name` = 'Consuntivo preventivo (senza costi)'; -UPDATE `zz_prints` SET `filename` = 'Consuntivo preventivo num. {numero} del {data}' WHERE `name` = 'Consuntivo preventivo'; -UPDATE `zz_prints` SET `filename` = 'Stampa calendario {periodo}' WHERE `name` = 'Stampa calendario'; - --- Aggiornamento Statistiche delle Anagrafiche -UPDATE `zz_plugins` SET `options` = 'custom', `directory` = 'statistiche_anagrafiche', `script` = '' WHERE `name` = 'Statistiche' AND `idmodule_from` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Anagrafiche'); - --- Fix sconti globali -UPDATE `co_righe_documenti` SET `sconto` = -`subtotale`, `sconto_unitario` = -`subtotale` WHERE `is_sconto` = 1 AND `subtotale` != 0; -UPDATE `co_righe_preventivi` SET `sconto` = -`subtotale`, `sconto_unitario` = -`subtotale` WHERE `is_sconto` = 1 AND `subtotale` != 0; -UPDATE `co_righe_contratti` SET `sconto` = -`subtotale`, `sconto_unitario` = -`subtotale` WHERE `is_sconto` = 1 AND `subtotale` != 0; -UPDATE `or_righe_ordini` SET `sconto` = -`subtotale`, `sconto_unitario` = -`subtotale` WHERE `is_sconto` = 1 AND `subtotale` != 0; -UPDATE `dt_righe_ddt` SET `sconto` = -`subtotale`, `sconto_unitario` = -`subtotale` WHERE `is_sconto` = 1 AND `subtotale` != 0; - -UPDATE `co_righe_documenti` SET `subtotale` = 0 WHERE `is_sconto` = 1 AND `subtotale` != 0; -UPDATE `co_righe_preventivi` SET `subtotale` = 0 WHERE `is_sconto` = 1 AND `subtotale` != 0; -UPDATE `co_righe_contratti` SET `subtotale` = 0 WHERE `is_sconto` = 1 AND `subtotale` != 0; -UPDATE `or_righe_ordini` SET `subtotale` = 0 WHERE `is_sconto` = 1 AND `subtotale` != 0; -UPDATE `dt_righe_ddt` SET `subtotale` = 0 WHERE `is_sconto` = 1 AND `subtotale` != 0; diff --git a/update/2_4_11.php b/update/2_4_11.php deleted file mode 100755 index 4455dce06..000000000 --- a/update/2_4_11.php +++ /dev/null @@ -1,92 +0,0 @@ -query('ALTER TABLE `zz_operations` DROP FOREIGN KEY `zz_operations_ibfk_3`'); -$logs = $database->fetchArray("SELECT * FROM `zz_operations` WHERE `op` = 'send-email'"); - -$database->query('UPDATE `zz_operations` SET `id_email` = NULL'); -foreach ($logs as $log) { - $user = User::find($log['id_utente']); - $template = Template::find($log['id_email']); - if (empty($template)) { - continue; - } - - $mail = Mail::build($user, $template, $log['id_record']); - $mail->resetPrints(); - - $options = json_decode($log['options'], true); - - foreach ($options['receivers'] as $receiver) { - $mail->addReceiver($receiver); - } - - foreach ($options['attachments'] as $upload) { - $mail->addUpload($upload); - } - - foreach ($options['prints'] as $print) { - $mail->addPrint($print); - } - - $sent_at = $log['created_at'] ?: date('Y-m-d H:i:s'); - $mail->created_at = $sent_at; - $mail->sent_at = $sent_at; - - $mail->save(); - - $database->query('UPDATE `zz_operations` SET `id_email` = '.prepare($mail->id).' WHERE `id_module` = '.prepare($log['id_module']).' AND `id_email` = '.prepare($log['id_email']).' AND `id_record` = '.prepare($log['id_record']).' AND `options` = '.prepare($log['options']).' AND `created_at` = '.prepare($log['created_at'])); -} - -$database->query('ALTER TABLE `zz_operations` ADD FOREIGN KEY (`id_email`) REFERENCES `em_emails`(`id`) ON DELETE SET NULL'); - -// Aggiunta permessi alla gestione documentale -$gruppi = $database->fetchArray('SELECT `id` FROM `zz_groups`'); -$viste = $database->fetchArray('SELECT `id` FROM `do_categorie`'); - -$array = []; -foreach ($viste as $vista) { - foreach ($gruppi as $gruppo) { - $array[] = [ - 'id_gruppo' => $gruppo['id'], - 'id_categoria' => $vista['id'], - ]; - } -} -if (!empty($array)) { - $database->insert('do_permessi', $array); -} - -// File e cartelle deprecate -$files = [ - 'src/API.php', - 'src/Mail.php', - 'modules/utenti/api', - 'modules/stato_servizi/api', - 'modules/stati_preventivo/api', - 'modules/stati_intervento/api', - 'modules/tipi_intervento/api', - 'modules/stati_contratto/api', - 'modules/articoli/api', - 'modules/anagrafiche/api', - 'modules/interventi/api/update.php', - 'modules/interventi/api/retrieve.php', - 'modules/interventi/api/delete.php', - 'modules/interventi/api/create.php', - 'modules/aggiornamenti/api', - 'plugins/exportFE/src/Connection.php', - 'modules/contratti/plugins/contratti.ordiniservizio.interventi.php ', - 'modules/contratti/plugins/contratti.ordiniservizio.php', - 'templates/contratti_cons/body.php', - 'templates/preventivi_cons/body.php', -]; - -foreach ($files as $key => $value) { - $files[$key] = realpath(base_dir().'/'.$value); -} - -delete($files); diff --git a/update/2_4_11.sql b/update/2_4_11.sql deleted file mode 100755 index 08b3c7bc5..000000000 --- a/update/2_4_11.sql +++ /dev/null @@ -1,922 +0,0 @@ -UPDATE `zz_prints` SET `filename` = 'Preventivo num. {numero} del {data}' WHERE `name` = 'Preventivo (senza totali)'; -UPDATE `zz_prints` SET `filename` = 'Fattura num. {numero} del {data}' WHERE `name` = 'Fattura di vendita (senza intestazione)'; -UPDATE `zz_prints` SET `filename` = 'Calendario' WHERE `name` = 'Stampa calendario'; - -DELETE FROM `zz_plugins` WHERE `name` = 'Pianificazione ordini di servizio'; - --- Aggiunta campo JSON per le informazioni aggiuntive FE -ALTER TABLE `co_righe_documenti` ADD `dati_aggiuntivi_fe` TEXT; -UPDATE `co_righe_documenti` SET `dati_aggiuntivi_fe` = CONCAT('{"tipo_cessione_prestazione":"', IFNULL(tipo_cessione_prestazione, ""), '","riferimento_amministrazione":"', IFNULL(riferimento_amministrazione, ""), '","data_inizio_periodo":"', IFNULL(data_inizio_periodo, ""), '","data_fine_periodo":"', IFNULL(data_fine_periodo, ""), '"}'); -ALTER TABLE `co_righe_documenti` DROP `tipo_cessione_prestazione`, DROP `riferimento_amministrazione`, DROP `data_inizio_periodo`, DROP `data_fine_periodo`; - -ALTER TABLE `co_documenti` ADD `dati_aggiuntivi_fe` TEXT; - --- Aggiunta stampe consuntivo costi per Preventivi e Contratti -INSERT INTO `zz_prints` (`id_module`, `name`, `title`, `filename`, `directory`, `options`, `icon`, `enabled`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Contratti'), 'Consuntivo contratto interno', 'Consuntivo contratto interno', 'Consuntivo interno contratto num. {numero} del {data}', 'contratti_cons', '{"dir":"uscita"}', 'fa fa-print', 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi'), 'Consuntivo preventivo interno', 'Consuntivo preventivo interno', 'Consuntivo interno preventivo num. {numero} del {data}', 'preventivi_cons', '{"dir":"uscita"}', 'fa fa-print', 1, 1); - --- Reset password per gli utenti -ALTER TABLE `zz_users` ADD `reset_token` VARCHAR(255); - -INSERT INTO `zz_emails` (`id`, `id_module`, `id_smtp`, `name`, `icon`, `subject`, `reply_to`, `cc`, `bcc`, `body`, `read_notify`) VALUES -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Utenti e permessi'), 1, 'Reset password', 'fa fa-envelope', 'Richiesta di reset password', '', '', '', '

    Gentile {username},

    \r\n

    a seguito della richiesta di reimpostazione della password del Suo account è pregato di inserire la nuova password che desidera utilizzare al seguente link:

    \r\n

    {reset_link}

    \r\n

     

    Se non sei il responsabile della richiesta in questione, contatta l''amministratore il prima possibile per richiedere un cambio di username.

    \r\n

     

    \r\n

    Distinti saluti

    \r\n', '0'); - --- Relazione tra le righe dei documenti -ALTER TABLE `co_righe_documenti` ADD `original_id` int(11), ADD `original_type` varchar(255); -ALTER TABLE `or_righe_ordini` ADD `original_id` int(11), ADD `original_type` varchar(255); -ALTER TABLE `dt_righe_ddt` ADD `original_id` int(11), ADD `original_type` varchar(255); - -ALTER TABLE `co_righe_contratti` ADD `abilita_serial` tinyint(1) NOT NULL DEFAULT '0'; -ALTER TABLE `co_righe_preventivi` ADD `abilita_serial` tinyint(1) NOT NULL DEFAULT '0'; - --- --- Fatture --- --- Collegamento Articoli -UPDATE `co_righe_documenti` INNER JOIN `or_righe_ordini` ON `co_righe_documenti`.`idordine` = `or_righe_ordini`.`idordine` AND `co_righe_documenti`.`descrizione` = `or_righe_ordini`.`descrizione` AND `co_righe_documenti`.`idarticolo` = `or_righe_ordini`.`idarticolo` SET `co_righe_documenti`.`original_id` = `or_righe_ordini`.`id`, `co_righe_documenti`.`original_type` = 'Modules\\Ordini\\Components\\Articolo' WHERE `co_righe_documenti`.`idarticolo` != 0; - -UPDATE `co_righe_documenti` INNER JOIN `dt_righe_ddt` ON `co_righe_documenti`.`idddt` = `dt_righe_ddt`.`idddt` AND `co_righe_documenti`.`descrizione` = `dt_righe_ddt`.`descrizione` AND `co_righe_documenti`.`idarticolo` = `dt_righe_ddt`.`idarticolo` SET `co_righe_documenti`.`original_id` = `dt_righe_ddt`.`id`, `co_righe_documenti`.`original_type` = 'Modules\\DDT\\Components\\Articolo' WHERE `co_righe_documenti`.`idarticolo` != 0; - -UPDATE `co_righe_documenti` INNER JOIN `co_righe_contratti` ON `co_righe_documenti`.`idcontratto` = `co_righe_contratti`.`idcontratto` AND `co_righe_documenti`.`descrizione` = `co_righe_contratti`.`descrizione` AND `co_righe_documenti`.`idarticolo` = `co_righe_contratti`.`idarticolo` SET `co_righe_documenti`.`original_id` = `co_righe_contratti`.`id`, `co_righe_documenti`.`original_type` = 'Modules\\Contratti\\Components\\Articolo' WHERE `co_righe_documenti`.`idarticolo` != 0; - -UPDATE `co_righe_documenti` INNER JOIN `co_righe_preventivi` ON `co_righe_documenti`.`idpreventivo` = `co_righe_preventivi`.`idpreventivo` AND `co_righe_documenti`.`descrizione` = `co_righe_preventivi`.`descrizione` AND `co_righe_documenti`.`idarticolo` = `co_righe_preventivi`.`idarticolo` SET `co_righe_documenti`.`original_id` = `co_righe_preventivi`.`id`, `co_righe_documenti`.`original_type` = 'Modules\\Preventivi\\Components\\Articolo' WHERE `co_righe_documenti`.`idarticolo` != 0; - --- Collegamento Sconti -UPDATE `co_righe_documenti` INNER JOIN `or_righe_ordini` ON `co_righe_documenti`.`idordine` = `or_righe_ordini`.`idordine` AND `co_righe_documenti`.`descrizione` = `or_righe_ordini`.`descrizione` AND `co_righe_documenti`.`idarticolo` = `or_righe_ordini`.`idarticolo` SET `co_righe_documenti`.`original_id` = `or_righe_ordini`.`id`, `co_righe_documenti`.`original_type` = 'Modules\\Ordini\\Components\\Sconto' WHERE `co_righe_documenti`.`is_sconto` != 0; - -UPDATE `co_righe_documenti` INNER JOIN `dt_righe_ddt` ON `co_righe_documenti`.`idddt` = `dt_righe_ddt`.`idddt` AND `co_righe_documenti`.`descrizione` = `dt_righe_ddt`.`descrizione` AND `co_righe_documenti`.`idarticolo` = `dt_righe_ddt`.`idarticolo` SET `co_righe_documenti`.`original_id` = `dt_righe_ddt`.`id`, `co_righe_documenti`.`original_type` = 'Modules\\DDT\\Components\\Sconto' WHERE `co_righe_documenti`.`is_sconto` != 0; - -UPDATE `co_righe_documenti` INNER JOIN `co_righe_contratti` ON `co_righe_documenti`.`idcontratto` = `co_righe_contratti`.`idcontratto` AND `co_righe_documenti`.`descrizione` = `co_righe_contratti`.`descrizione` AND `co_righe_documenti`.`idarticolo` = `co_righe_contratti`.`idarticolo` SET `co_righe_documenti`.`original_id` = `co_righe_contratti`.`id`, `co_righe_documenti`.`original_type` = 'Modules\\Contratti\\Components\\Sconto' WHERE `co_righe_documenti`.`is_sconto` != 0; - -UPDATE `co_righe_documenti` INNER JOIN `co_righe_preventivi` ON `co_righe_documenti`.`idpreventivo` = `co_righe_preventivi`.`idpreventivo` AND `co_righe_documenti`.`descrizione` = `co_righe_preventivi`.`descrizione` AND `co_righe_documenti`.`idarticolo` = `co_righe_preventivi`.`idarticolo` SET `co_righe_documenti`.`original_id` = `co_righe_preventivi`.`id`, `co_righe_documenti`.`original_type` = 'Modules\\Preventivi\\Components\\Sconto' WHERE `co_righe_documenti`.`is_sconto` != 0; - --- Collegamento Descrizioni -UPDATE `co_righe_documenti` INNER JOIN `or_righe_ordini` ON `co_righe_documenti`.`idordine` = `or_righe_ordini`.`idordine` AND `co_righe_documenti`.`descrizione` = `or_righe_ordini`.`descrizione` AND `co_righe_documenti`.`idarticolo` = `or_righe_ordini`.`idarticolo` SET `co_righe_documenti`.`original_id` = `or_righe_ordini`.`id`, `co_righe_documenti`.`original_type` = 'Modules\\Ordini\\Components\\Descrizione' WHERE `co_righe_documenti`.`is_descrizione` != 0; - -UPDATE `co_righe_documenti` INNER JOIN `dt_righe_ddt` ON `co_righe_documenti`.`idddt` = `dt_righe_ddt`.`idddt` AND `co_righe_documenti`.`descrizione` = `dt_righe_ddt`.`descrizione` AND `co_righe_documenti`.`idarticolo` = `dt_righe_ddt`.`idarticolo` SET `co_righe_documenti`.`original_id` = `dt_righe_ddt`.`id`, `co_righe_documenti`.`original_type` = 'Modules\\DDT\\Components\\Descrizione' WHERE `co_righe_documenti`.`is_descrizione` != 0; - -UPDATE `co_righe_documenti` INNER JOIN `co_righe_contratti` ON `co_righe_documenti`.`idcontratto` = `co_righe_contratti`.`idcontratto` AND `co_righe_documenti`.`descrizione` = `co_righe_contratti`.`descrizione` AND `co_righe_documenti`.`idarticolo` = `co_righe_contratti`.`idarticolo` SET `co_righe_documenti`.`original_id` = `co_righe_contratti`.`id`, `co_righe_documenti`.`original_type` = 'Modules\\Contratti\\Components\\Descrizione' WHERE `co_righe_documenti`.`is_descrizione` != 0; - -UPDATE `co_righe_documenti` INNER JOIN `co_righe_preventivi` ON `co_righe_documenti`.`idpreventivo` = `co_righe_preventivi`.`idpreventivo` AND `co_righe_documenti`.`descrizione` = `co_righe_preventivi`.`descrizione` AND `co_righe_documenti`.`idarticolo` = `co_righe_preventivi`.`idarticolo` SET `co_righe_documenti`.`original_id` = `co_righe_preventivi`.`id`, `co_righe_documenti`.`original_type` = 'Modules\\Preventivi\\Components\\Descrizione' WHERE `co_righe_documenti`.`is_descrizione` != 0; - --- Collegamento Righe -UPDATE `co_righe_documenti` INNER JOIN `or_righe_ordini` ON `co_righe_documenti`.`idordine` = `or_righe_ordini`.`idordine` AND `co_righe_documenti`.`descrizione` = `or_righe_ordini`.`descrizione` AND `co_righe_documenti`.`idarticolo` = `or_righe_ordini`.`idarticolo` SET `co_righe_documenti`.`original_id` = `or_righe_ordini`.`id`, `co_righe_documenti`.`original_type` = 'Modules\\Ordini\\Components\\Riga' WHERE `co_righe_documenti`.`original_id` IS NULL; - -UPDATE `co_righe_documenti` INNER JOIN `dt_righe_ddt` ON `co_righe_documenti`.`idddt` = `dt_righe_ddt`.`idddt` AND `co_righe_documenti`.`descrizione` = `dt_righe_ddt`.`descrizione` AND `co_righe_documenti`.`idarticolo` = `dt_righe_ddt`.`idarticolo` SET `co_righe_documenti`.`original_id` = `dt_righe_ddt`.`id`, `co_righe_documenti`.`original_type` = 'Modules\\DDT\\Components\\Riga' WHERE `co_righe_documenti`.`original_id` IS NULL; - -UPDATE `co_righe_documenti` INNER JOIN `co_righe_contratti` ON `co_righe_documenti`.`idcontratto` = `co_righe_contratti`.`idcontratto` AND `co_righe_documenti`.`descrizione` = `co_righe_contratti`.`descrizione` AND `co_righe_documenti`.`idarticolo` = `co_righe_contratti`.`idarticolo` SET `co_righe_documenti`.`original_id` = `co_righe_contratti`.`id`, `co_righe_documenti`.`original_type` = 'Modules\\Contratti\\Components\\Riga' WHERE `co_righe_documenti`.`original_id` IS NULL; - -UPDATE `co_righe_documenti` INNER JOIN `co_righe_preventivi` ON `co_righe_documenti`.`idpreventivo` = `co_righe_preventivi`.`idpreventivo` AND `co_righe_documenti`.`descrizione` = `co_righe_preventivi`.`descrizione` AND `co_righe_documenti`.`idarticolo` = `co_righe_preventivi`.`idarticolo` SET `co_righe_documenti`.`original_id` = `co_righe_preventivi`.`id`, `co_righe_documenti`.`original_type` = 'Modules\\Preventivi\\Components\\Riga' WHERE `co_righe_documenti`.`original_id` IS NULL; - --- --- DDT --- --- Collegamento Articoli -UPDATE `dt_righe_ddt` INNER JOIN `or_righe_ordini` ON `dt_righe_ddt`.`idordine` = `or_righe_ordini`.`idordine` AND `dt_righe_ddt`.`descrizione` = `or_righe_ordini`.`descrizione` AND `dt_righe_ddt`.`idarticolo` = `or_righe_ordini`.`idarticolo` SET `dt_righe_ddt`.`original_id` = `or_righe_ordini`.`id`, `dt_righe_ddt`.`original_type` = 'Modules\\Ordini\\Components\\Articolo' WHERE `dt_righe_ddt`.`idarticolo` != 0; - --- Collegamento Sconti -UPDATE `dt_righe_ddt` INNER JOIN `or_righe_ordini` ON `dt_righe_ddt`.`idordine` = `or_righe_ordini`.`idordine` AND `dt_righe_ddt`.`descrizione` = `or_righe_ordini`.`descrizione` AND `dt_righe_ddt`.`idarticolo` = `or_righe_ordini`.`idarticolo` SET `dt_righe_ddt`.`original_id` = `or_righe_ordini`.`id`, `dt_righe_ddt`.`original_type` = 'Modules\\Ordini\\Components\\Sconto' WHERE `dt_righe_ddt`.`is_sconto` != 0; - --- Collegamento Descrizioni -UPDATE `dt_righe_ddt` INNER JOIN `or_righe_ordini` ON `dt_righe_ddt`.`idordine` = `or_righe_ordini`.`idordine` AND `dt_righe_ddt`.`descrizione` = `or_righe_ordini`.`descrizione` AND `dt_righe_ddt`.`idarticolo` = `or_righe_ordini`.`idarticolo` SET `dt_righe_ddt`.`original_id` = `or_righe_ordini`.`id`, `dt_righe_ddt`.`original_type` = 'Modules\\Ordini\\Components\\Descrizione' WHERE `dt_righe_ddt`.`is_descrizione` != 0; - --- Collegamento Righe -UPDATE `dt_righe_ddt` INNER JOIN `or_righe_ordini` ON `dt_righe_ddt`.`idordine` = `or_righe_ordini`.`idordine` AND `dt_righe_ddt`.`descrizione` = `or_righe_ordini`.`descrizione` AND `dt_righe_ddt`.`idarticolo` = `or_righe_ordini`.`idarticolo` SET `dt_righe_ddt`.`original_id` = `or_righe_ordini`.`id`, `dt_righe_ddt`.`original_type` = 'Modules\\Ordini\\Components\\Riga' WHERE `dt_righe_ddt`.`original_id` IS NULL; - --- --- Ordini --- --- Collegamento Articoli -UPDATE `or_righe_ordini` INNER JOIN `co_righe_preventivi` ON `or_righe_ordini`.`idpreventivo` = `co_righe_preventivi`.`idpreventivo` AND `or_righe_ordini`.`descrizione` = `co_righe_preventivi`.`descrizione` AND `or_righe_ordini`.`idarticolo` = `co_righe_preventivi`.`idarticolo` SET `or_righe_ordini`.`original_id` = `co_righe_preventivi`.`id`, `or_righe_ordini`.`original_type` = 'Modules\\Preventivi\\Components\\Articolo' WHERE `or_righe_ordini`.`idarticolo` != 0; - --- Collegamento Sconti -UPDATE `or_righe_ordini` INNER JOIN `co_righe_preventivi` ON `or_righe_ordini`.`idpreventivo` = `co_righe_preventivi`.`idpreventivo` AND `or_righe_ordini`.`descrizione` = `co_righe_preventivi`.`descrizione` AND `or_righe_ordini`.`idarticolo` = `co_righe_preventivi`.`idarticolo` SET `or_righe_ordini`.`original_id` = `co_righe_preventivi`.`id`, `or_righe_ordini`.`original_type` = 'Modules\\Preventivi\\Components\\Sconto' WHERE `or_righe_ordini`.`is_sconto` != 0; - --- Collegamento Descrizioni -UPDATE `or_righe_ordini` INNER JOIN `co_righe_preventivi` ON `or_righe_ordini`.`idpreventivo` = `co_righe_preventivi`.`idpreventivo` AND `or_righe_ordini`.`descrizione` = `co_righe_preventivi`.`descrizione` AND `or_righe_ordini`.`idarticolo` = `co_righe_preventivi`.`idarticolo` SET `or_righe_ordini`.`original_id` = `co_righe_preventivi`.`id`, `or_righe_ordini`.`original_type` = 'Modules\\Preventivi\\Components\\Descrizione' WHERE `or_righe_ordini`.`is_descrizione` != 0; - --- Collegamento Righe -UPDATE `or_righe_ordini` INNER JOIN `co_righe_preventivi` ON `or_righe_ordini`.`idpreventivo` = `co_righe_preventivi`.`idpreventivo` AND `or_righe_ordini`.`descrizione` = `co_righe_preventivi`.`descrizione` AND `or_righe_ordini`.`idarticolo` = `co_righe_preventivi`.`idarticolo` SET `or_righe_ordini`.`original_id` = `co_righe_preventivi`.`id`, `or_righe_ordini`.`original_type` = 'Modules\\Preventivi\\Components\\Riga' WHERE `or_righe_ordini`.`original_id` IS NULL; - --- Aggiunta foto utente -ALTER TABLE `zz_users` ADD `image_file_id` int(11); -UPDATE `zz_modules` SET `enabled` = 1 WHERE `name` = 'Utenti e permessi'; - --- Aggiornamento sistema API -CREATE TABLE IF NOT EXISTS `zz_api_resources` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `version` varchar(15) NOT NULL, - `type` ENUM('create', 'retrieve', 'update', 'delete'), - `resource` varchar(255) NOT NULL, - `class` varchar(255) NOT NULL, - `enabled` tinyint(1) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - -DELETE FROM `zz_settings` WHERE `nome` = 'Tabelle escluse per la sincronizzazione API automatica'; - -INSERT INTO `zz_api_resources` (`id`, `version`, `type`, `resource`, `class`, `enabled`) VALUES -(NULL, 'v1', 'create', 'allegato', 'Api\\Common\\Allegato', '1'), -(NULL, 'v1', 'retrieve', 'clienti', 'Modules\\Anagrafiche\\API\\v1\\Anagrafiche', '1'), -(NULL, 'v1', 'retrieve', 'anagrafiche', 'Modules\\Anagrafiche\\API\\v1\\Anagrafiche', '1'), -(NULL, 'v1', 'create', 'anagrafica', 'Modules\\Anagrafiche\\API\\v1\\Anagrafiche', '1'), -(NULL, 'v1', 'update', 'anagrafica', 'Modules\\Anagrafiche\\API\\v1\\Anagrafiche', '1'), -(NULL, 'v1', 'delete', 'anagrafica', 'Modules\\Anagrafiche\\API\\v1\\Anagrafiche', '1'), -(NULL, 'v1', 'retrieve', 'sedi', 'Modules\\Anagrafiche\\API\\v1\\Sedi', '1'), -(NULL, 'v1', 'create', 'movimento_articolo', 'Modules\\Articoli\\API\\v1\\Movimenti', '1'), -(NULL, 'v1', 'retrieve', 'articoli', 'Modules\\Articoli\\API\\v1\\Articoli', '1'), -(NULL, 'v1', 'create', 'login', 'Modules\\Utenti\\API\\v1\\Login', '1'), -(NULL, 'v1', 'create', 'logout', 'Modules\\Utenti\\API\\v1\\Logout', '1'), -(NULL, 'v1', 'retrieve', 'folder_size', 'Modules\\StatoServizi\\API\\v1\\FolderSize', '1'), -(NULL, 'v1', 'retrieve', 'tipi_intervento', 'Modules\\TipiIntervento\\API\\v1\\TipiInterventi', '1'), -(NULL, 'v1', 'retrieve', 'stati_intervento', 'Modules\\StatiIntervento\\API\\v1\\StatiInterventi', '1'), -(NULL, 'v1', 'retrieve', 'stati_preventivo', 'Modules\\StatiPreventivo\\API\\v1\\StatiPreventivi', '1'), -(NULL, 'v1', 'retrieve', 'stati_contratto', 'Modules\\StatiContratto\\API\\v1\\StatiContratti', '1'), -(NULL, 'v1', 'retrieve', 'tipi_intervento', 'Modules\\Interventi\\API\\v1\\Interventi', '1'), -(NULL, 'v1', 'retrieve', 'interventi', 'Modules\\Interventi\\API\\v1\\Interventi', '1'), -(NULL, 'v1', 'create', 'intervento', 'Modules\\Interventi\\API\\v1\\Interventi', '1'), -(NULL, 'v1', 'update', 'intervento', 'Modules\\Interventi\\API\\v1\\Interventi', '1'), -(NULL, 'v1', 'update', 'firma_intervento', 'Modules\\Interventi\\API\\v1\\Firma', '1'), -(NULL, 'v1', 'retrieve', 'sync', 'Modules\\Interventi\\API\\v1\\Sync', '1'), -(NULL, 'v1', 'update', 'sync', 'Modules\\Interventi\\API\\v1\\Sync', '1'), -(NULL, 'v1', 'retrieve', 'sessioni_intervento', 'Modules\\Interventi\\API\\v1\\Sessioni', '1'), -(NULL, 'v1', 'create', 'sessione', 'Modules\\Interventi\\API\\v1\\Sessioni', '1'), -(NULL, 'v1', 'delete', 'sessioni_intervento', 'Modules\\Interventi\\API\\v1\\Sessioni', '1'), -(NULL, 'v1', 'retrieve', 'articoli_intervento', 'Modules\\Interventi\\API\\v1\\Articoli', '1'), -(NULL, 'v1', 'create', 'articolo_intervento', 'Modules\\Interventi\\API\\v1\\Articoli', '1'), -(NULL, 'v1', 'retrieve', 'stampa', 'Api\\Common\\Stampa', '1'); - --- Supporto alla personalizzazione dell'API remota OSMCloud -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES -(NULL, 'OSMCloud Services API Version', 'v2', 'string', 0, 'Fatturazione Elettronica', 11); -DELETE FROM `zz_settings` WHERE `nome` = 'apilayer API key for Email'; - --- Fatture pro-forma di acquisto -INSERT INTO `zz_segments` (`id`, `id_module`, `name`, `clause`, `position`, `pattern`, `is_fiscale`) VALUES (NULL, '15', 'Fatture pro-forma', '1=1', 'WHR', 'PRO-###', '0'); - --- Aggiunto codice cig e codice cup per ddt -ALTER TABLE `dt_ddt` ADD `codice_cig` VARCHAR(15), ADD `codice_cup` VARCHAR(15) AFTER `codice_cig`, ADD `id_documento_fe` VARCHAR(20) AFTER `codice_cup`,ADD `num_item` VARCHAR(15) AFTER `id_documento_fe`; - --- Fix quantità per descrizioni -UPDATE `co_righe_documenti` SET `qta` = 1 WHERE `is_descrizione` = 1; -UPDATE `dt_righe_ddt` SET `qta` = 1 WHERE `is_descrizione` = 1; -UPDATE `co_righe_preventivi` SET `qta` = 1 WHERE `is_descrizione` = 1; -UPDATE `co_righe_contratti` SET `qta` = 1 WHERE `is_descrizione` = 1; -UPDATE `or_righe_ordini` SET `qta` = 1 WHERE `is_descrizione` = 1; -UPDATE `mg_articoli_interventi` SET `qta` = 1 WHERE `is_descrizione` = 1; - --- Aggiunta generale di prezzo_unitario_acquisto -ALTER TABLE `dt_righe_ddt` ADD `prezzo_unitario_acquisto` DECIMAL(12,4) NOT NULL AFTER `descrizione`; -ALTER TABLE `or_righe_ordini` ADD `prezzo_unitario_acquisto` DECIMAL(12,4) NOT NULL AFTER `descrizione`; -ALTER TABLE `co_righe_contratti` ADD `prezzo_unitario_acquisto` DECIMAL(12,4) NOT NULL AFTER `descrizione`; - --- Fix query Scadenzario -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_scadenziario` - LEFT JOIN `co_documenti` ON `co_scadenziario`.`iddocumento` = `co_documenti`.`id` - LEFT JOIN `an_anagrafiche` ON `co_documenti`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - LEFT JOIN `co_pagamenti` ON `co_documenti`.`idpagamento` = `co_pagamenti`.`id` - LEFT JOIN `co_tipidocumento` ON `co_documenti`.`idtipodocumento` = `co_tipidocumento`.`id` - LEFT JOIN `co_statidocumento` ON `co_documenti`.`idstatodocumento` = `co_statidocumento`.`id` -WHERE 1=1 AND - (`co_scadenziario`.`scadenza` BETWEEN ''|period_start|'' AND ''|period_end|'' OR ABS(`co_scadenziario`.`pagato`) < ABS(`co_scadenziario`.`da_pagare`)) AND - (`co_statidocumento`.`descrizione` IS NULL OR `co_statidocumento`.`descrizione` IN(''Emessa'',''Parzialmente pagato'')) -HAVING 2=2 -ORDER BY `scadenza` ASC' WHERE `name` = 'Scadenzario'; - --- Aggiunte impostazione Autocomple web form -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES (NULL, 'Autocompletamento form', 'off', 'list[on,off]', '1', 'Generali', '', NULL); - --- Data concordata per le scadenza -ALTER TABLE `co_scadenziario` ADD `data_concordata` DATE; - -UPDATE `zz_views` SET `query` = 'IF(pagato = da_pagare, ''#38CD4E'', IF(data_concordata IS NOT NULL AND data_concordata > NOW(), '' #CC9837'', IF(scadenza < NOW(), ''#CC4D37'', '''')))' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Scadenzario') AND `name` = '_bg_'; - --- Sistema di note interne -CREATE TABLE IF NOT EXISTS `zz_notes` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_module` int(11), - `id_plugin` int(11), - `id_record` int(11) NOT NULL, - `id_utente` int(11) NOT NULL, - `notification_date` DATE, - `content` TEXT, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_module`) REFERENCES `zz_modules`(`id`) ON DELETE CASCADE, - FOREIGN KEY (`id_plugin`) REFERENCES `zz_plugins`(`id`) ON DELETE CASCADE, - FOREIGN KEY (`id_utente`) REFERENCES `zz_users`(`id`) ON DELETE CASCADE -) ENGINE=InnoDB; - --- Sistema di checklists -CREATE TABLE IF NOT EXISTS `zz_checks` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_module` int(11), - `id_plugin` int(11), - `id_record` int(11) NOT NULL, - `created_by` int(11) NOT NULL, - `checked_by` int(11) , - `checked_at` TIMESTAMP NULL, - `content` TEXT, - `id_parent` int(11), - `order` int(11), - PRIMARY KEY (`id`), - FOREIGN KEY (`id_module`) REFERENCES `zz_modules`(`id`) ON DELETE CASCADE, - FOREIGN KEY (`id_plugin`) REFERENCES `zz_plugins`(`id`) ON DELETE CASCADE, - FOREIGN KEY (`created_by`) REFERENCES `zz_users`(`id`) ON DELETE CASCADE, - FOREIGN KEY (`checked_by`) REFERENCES `zz_users`(`id`) ON DELETE CASCADE, - FOREIGN KEY (`id_parent`) REFERENCES `zz_checks`(`id`) ON DELETE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE IF NOT EXISTS `zz_check_user` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_utente` int(11) NOT NULL, - `id_check` int(11) NOT NULL, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_utente`) REFERENCES `zz_users`(`id`) ON DELETE CASCADE, - FOREIGN KEY (`id_check`) REFERENCES `zz_checks`(`id`) ON DELETE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE IF NOT EXISTS `zz_checklists` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255), - `id_module` int(11), - `id_plugin` int(11), - PRIMARY KEY (`id`), - FOREIGN KEY (`id_module`) REFERENCES `zz_modules`(`id`) ON DELETE CASCADE, - FOREIGN KEY (`id_plugin`) REFERENCES `zz_plugins`(`id`) ON DELETE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE IF NOT EXISTS `zz_checklist_items` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_checklist` int(11), - `content` TEXT, - `id_parent` int(11), - `order` int(11), - PRIMARY KEY (`id`), - FOREIGN KEY (`id_checklist`) REFERENCES `zz_checklists`(`id`) ON DELETE CASCADE, - FOREIGN KEY (`id_parent`) REFERENCES `zz_checklist_items`(`id`) ON DELETE CASCADE -) ENGINE=InnoDB; - --- Gestione di note e checklists -ALTER TABLE `zz_modules` ADD `use_notes` BOOLEAN DEFAULT FALSE, ADD `use_checklists` BOOLEAN DEFAULT FALSE; -UPDATE `zz_modules` SET `use_notes` = 1 WHERE `name` IN ('Anagrafiche', 'Interventi', 'Preventivi', 'Contratti', 'Fatture di vendita', 'Fatture di acquisto', 'Scadenzario', 'Ordini cliente', 'Ordini fornitore', 'Articoli', 'Ddt di vendita', 'Ddt di acquisto', 'MyImpianti'); -UPDATE `zz_modules` SET `use_checklists` = 1 WHERE `name` IN ('Interventi', 'MyImpianti'); - --- Modulo per i template delle Checklist -INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Checklists', 'Checklists', 'checklists', 'SELECT |select| FROM `zz_checklists` WHERE 1=1 HAVING 2=2', '', 'fa fa-check-square-o', '2.4.11', '2.*', '1', (SELECT `id` FROM `zz_modules` t WHERE t.`name` = 'Strumenti'), '1', '1'); - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Checklists'), 'id', 'id', 1, 0, 0, 1, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Checklists'), 'Nome', 'name', 2, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Checklists'), 'Modulo', '(SELECT name FROM zz_modules WHERE id = zz_checklists.id_module)', 5, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Checklists'), 'Plugin', '(SELECT name FROM zz_plugins WHERE id = zz_checklists.id_plugin)', 5, 1, 0, 1, 1); - --- Miglioramento gestione header e footer per le stampe -UPDATE `zz_prints` SET `options` = REPLACE(`options`, "hide_header", "hide-header"); -UPDATE `zz_prints` SET `options` = REPLACE(`options`, "hide_footer", "hide-footer"); -UPDATE `zz_prints` SET `options` = '{"last-page-footer": true}' WHERE `zz_prints`.`name` = 'Fattura di vendita'; -UPDATE `zz_prints` SET `options` = '{"hide-header": true, "hide-footer": true, "last-page-footer": true}' WHERE `zz_prints`.`name` = 'Fattura di vendita (senza intestazione)'; -UPDATE `zz_prints` SET `options` = '{"pricing": true, "last-page-footer": true}' WHERE `zz_prints`.`name` = 'Ordine cliente'; -UPDATE `zz_prints` SET `options` = '{"pricing": false, "last-page-footer": true}' WHERE `zz_prints`.`name` = 'Ordine cliente (senza costi)'; -UPDATE `zz_prints` SET `options` = '{"pricing": true, "last-page-footer": true}' WHERE `zz_prints`.`name` = 'Preventivo'; -UPDATE `zz_prints` SET `options` = '{"pricing": false, "last-page-footer": true}' WHERE `zz_prints`.`name` = 'Preventivo (senza costi)'; -UPDATE `zz_prints` SET `options` = '{"pricing": true, "last-page-footer": true}' WHERE `zz_prints`.`name` = 'Contratto'; -UPDATE `zz_prints` SET `options` = '{"pricing": false, "last-page-footer": true}' WHERE `zz_prints`.`name` = 'Contratto (senza costi)'; - --- Widget per le notifiche delle note interne -INSERT INTO `zz_widgets` (`id`, `name`, `type`, `id_module`, `location`, `class`, `query`, `bgcolor`, `icon`, `print_link`, `more_link`, `more_link_type`, `php_include`, `text`, `enabled`, `order`) VALUES (NULL, 'Note interne', 'custom', (SELECT `id` FROM `zz_modules` WHERE `name` = 'Dashboard'), 'controller_top', 'col-md-12', NULL, '#4ccc4c', 'fa fa-file-text-o ', '', './modules/dashboard/widgets/notifiche.php', 'popup', './modules/dashboard/widgets/notifiche.php', 'Notifiche interne', '1', '1'); - --- Aggiunto collegamento degli allegati al creatore -ALTER TABLE `zz_files` ADD `created_by` INT(11) AFTER `id_record`, ADD FOREIGN KEY (`created_by`) REFERENCES `zz_users`(`id`) ON DELETE SET NULL; - --- Aggiunto riferimento allo Scadenzario nella Prima Nota -ALTER TABLE `co_movimenti` ADD `id_scadenza` INT(11) AFTER `iddocumento`, ADD FOREIGN KEY (`id_scadenza`) REFERENCES `co_scadenziario`(`id`) ON DELETE CASCADE, ADD `is_insoluto` BOOLEAN NOT NULL DEFAULT FALSE AFTER `id_scadenza`; - --- Aggiornamento indirizzo email SDI -UPDATE `zz_emails` SET `cc` = 'sdi52@pec.fatturapa.it' WHERE `name` = 'PEC'; - --- Rimozione Pianificazione fatturazione -DELETE FROM `zz_plugins` WHERE `name` = 'Pianificazione fatturazione'; - --- Aggiunta deleted_at su mg_articoli -ALTER TABLE `mg_articoli` ADD `deleted_at` timestamp NULL DEFAULT NULL; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `mg_articoli` WHERE 1=1 AND `deleted_at` IS NULL HAVING 2=2 ORDER BY `descrizione`' WHERE `name` = 'Articoli'; - --- Ampliamento hooks -ALTER TABLE `zz_hooks` ADD `processing_at` TIMESTAMP NULL DEFAULT NULL, ADD `processing_token` varchar(255); -INSERT INTO `zz_hooks` (`id`, `name`, `class`, `frequency`, `id_module`) VALUES (NULL, 'Backup', 'Modules\\Backups\\BackupHook', '1 day', (SELECT `id` FROM `zz_modules` WHERE `name` = 'Backup')); - --- Miglioramento gestione email (questo RENAME genera un errore rif. tabella se mysql <= 5.5.55) -RENAME TABLE `zz_emails` TO `em_templates`; -RENAME TABLE `zz_smtps` TO `em_accounts`; -RENAME TABLE `zz_email_print` TO `em_print_template`; - -UPDATE zz_modules SET options = REPLACE(options, 'zz_emails', 'em_templates'), options2 = REPLACE(options2, 'zz_emails', 'em_templates'); -UPDATE zz_modules SET options = REPLACE(options, 'zz_smtps', 'em_accounts'), options2 = REPLACE(options2, 'zz_smtps', 'em_accounts'); -UPDATE zz_views SET query = REPLACE(query, 'zz_emails', 'em_templates'); -UPDATE zz_views SET query = REPLACE(query, 'zz_smtps', 'em_accounts'); - -CREATE TABLE IF NOT EXISTS `em_newsletters` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `id_template` int(11) NOT NULL, - `state` varchar(25) NOT NULL, - `subject` varchar(255) NOT NULL, - `content` TEXT NOT NULL, - `notes` TEXT, - `created_by` int(11) NOT NULL, - `completed_at` TIMESTAMP NULL DEFAULT NULL, - `deleted_at` TIMESTAMP NULL DEFAULT NULL, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_template`) REFERENCES `em_templates`(`id`) ON DELETE CASCADE, - FOREIGN KEY (`created_by`) REFERENCES `zz_users`(`id`) ON DELETE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE IF NOT EXISTS `em_emails` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_account` int(11) NOT NULL, - `id_template` int(11), - `id_newsletter` int(11), - `id_record` int(11), - `subject` varchar(255), - `content` TEXT, - `options` TEXT, - `sent_at` TIMESTAMP NULL DEFAULT NULL, - `failed_at` TIMESTAMP NULL DEFAULT NULL, - `processing_at` TIMESTAMP NULL DEFAULT NULL, - `created_by` int(11) NOT NULL, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_account`) REFERENCES `em_accounts`(`id`) ON DELETE CASCADE, - FOREIGN KEY (`id_template`) REFERENCES `em_templates`(`id`) ON DELETE CASCADE, - FOREIGN KEY (`id_newsletter`) REFERENCES `em_newsletters`(`id`) ON DELETE CASCADE, - FOREIGN KEY (`created_by`) REFERENCES `zz_users`(`id`) ON DELETE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE IF NOT EXISTS `em_email_receiver` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_email` int(11) NOT NULL, - `type` varchar(255) NOT NULL, - `address` varchar(255) NOT NULL, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_email`) REFERENCES `em_emails`(`id`) ON DELETE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE IF NOT EXISTS `em_email_upload` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_email` int(11) NOT NULL, - `id_file` int(11) NOT NULL, - `name` varchar(255), - PRIMARY KEY (`id`), - FOREIGN KEY (`id_email`) REFERENCES `em_emails`(`id`) ON DELETE CASCADE, - FOREIGN KEY (`id_file`) REFERENCES `zz_files`(`id`) ON DELETE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE IF NOT EXISTS `em_email_print` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_email` int(11) NOT NULL, - `id_print` int(11) NOT NULL, - `name` varchar(255), - PRIMARY KEY (`id`), - FOREIGN KEY (`id_email`) REFERENCES `em_emails`(`id`) ON DELETE CASCADE, - FOREIGN KEY (`id_print`) REFERENCES `zz_prints`(`id`) ON DELETE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE IF NOT EXISTS `em_newsletter_anagrafica` ( - `id_newsletter` int(11) NOT NULL, - `id_anagrafica` int(11) NOT NULL, - `id_email` int(11), - FOREIGN KEY (`id_newsletter`) REFERENCES `em_newsletters`(`id`) ON DELETE CASCADE, - FOREIGN KEY (`id_anagrafica`) REFERENCES `an_anagrafiche`(`idanagrafica`) ON DELETE CASCADE, - FOREIGN KEY (`id_email`) REFERENCES `em_emails`(`id`) ON DELETE CASCADE -) ENGINE=InnoDB; - --- Hook per la gestione della coda di invio -ALTER TABLE `zz_hooks` CHANGE `id_module` `id_module` INT(11) NULL; -INSERT INTO `zz_hooks` (`id`, `name`, `class`, `frequency`, `id_module`) VALUES (NULL, 'Email', 'Modules\\Emails\\EmailHook', '1 minute', NULL); - --- Modulo Newsletter -INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Newsletter', 'Newsletter', 'newsletter', 'SELECT |select| FROM `em_newsletters` WHERE 1=1 AND deleted_at IS NULL HAVING 2=2', '', 'fa fa-newspaper-o ', '2.4.11', '2.*', '1', (SELECT `id` FROM `zz_modules` t WHERE t.`name` = 'Gestione email'), '1', '1'); - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Newsletter'), 'id', 'id', 1, 0, 0, 1, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Newsletter'), 'Nome', 'name', 2, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Newsletter'), 'Template', '(SELECT name FROM em_templates WHERE id = em_newsletters.id_template)', 3, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Newsletter'), 'Completato', 'IF(completed_at IS NULL, ''No'', ''Si'')', 4, 1, 0, 1, 1); - --- Modulo Stato email -INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Stato email', 'Coda di invio', 'stato_email', 'SELECT |select| -FROM `em_emails` - LEFT JOIN `em_templates` ON `em_templates`.`id` = `em_emails`.`id_template` - INNER JOIN `zz_users` ON `zz_users`.`id` = `em_emails`.`created_by` -WHERE 1=1 AND (`em_emails`.`created_at` BETWEEN ''|period_start|'' AND ''|period_end|'' OR `em_emails`.`sent_at` IS NULL) -HAVING 2=2 -ORDER BY `em_emails`.`created_at` DESC', '', 'fa fa-spinner ', '2.4.11', '2.*', '1', (SELECT `id` FROM `zz_modules` t WHERE t.`name` = 'Gestione email'), '1', '1'); - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `default`, `visible`, `format`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stato email'), 'id', 'em_emails.id', 1, 0, 0, 1, 0, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stato email'), 'Oggetto', 'em_emails.subject', 2, 1, 0, 1, 1, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stato email'), 'Contenuto', 'em_emails.content', 3, 1, 0, 0, 1, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stato email'), 'Template', 'em_templates.name', 3, 1, 0, 1, 1, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stato email'), 'Data invio', 'em_emails.sent_at', 4, 1, 0, 1, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stato email'), 'Ultimo tentativo', 'em_emails.failed_at', 5, 1, 0, 1, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stato email'), 'Utente', 'zz_users.username', 6, 1, 0, 1, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stato email'), '_bg_', 'IF(em_emails.sent_at IS NULL, IF(em_emails.failed_at IS NULL, ''#CC9837'', ''#CC4D37''), ''#38CD4E'')', 6, 1, 0, 0, 0, 0); - -ALTER TABLE `em_templates` ADD `id_account` INT(11) NOT NULL; -UPDATE `em_templates` SET `id_account` = `id_smtp`; -ALTER TABLE `em_templates` DROP FOREIGN KEY `em_templates_ibfk_2`, DROP `id_smtp`; -ALTER TABLE `em_templates` ADD FOREIGN KEY (`id_account`) REFERENCES `em_accounts`(`id`) ON DELETE CASCADE; - -ALTER TABLE `em_print_template` ADD `id_template` INT(11) NOT NULL; -UPDATE `em_print_template` SET `id_template` = `id_email`; -ALTER TABLE `em_print_template` DROP FOREIGN KEY `em_print_template_ibfk_1`, DROP `id_email`; -ALTER TABLE `em_print_template` ADD FOREIGN KEY (`id_template`) REFERENCES `em_templates`(`id`) ON DELETE CASCADE; - -ALTER TABLE `em_accounts` ADD `timeout` INT(11) NOT NULL DEFAULT 1000; -ALTER TABLE `an_anagrafiche` ADD `enable_newsletter` BOOLEAN DEFAULT TRUE; - --- Aggiunta coda di invio per le Fatture Elettroniche -ALTER TABLE `co_documenti` ADD `hook_send` BOOLEAN DEFAULT FALSE; -INSERT INTO `zz_hooks` (`id`, `name`, `class`, `frequency`, `id_module`) VALUES (NULL, 'Fatture Elettroniche', 'Plugins\\ExportFE\\InvoiceHook', '1 minute', NULL); - -INSERT INTO `fe_stati_documento` (`codice`, `descrizione`, `icon`) VALUES -('ERR', 'Trasmissione non riuscita', 'fa fa-close'), -('QUEUE', 'In coda di elaborazione', 'fa fa-spinner'); - --- Ottimizzazione Fatture di vendita -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_documenti` - INNER JOIN `an_anagrafiche` ON `co_documenti`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - INNER JOIN `co_tipidocumento` ON `co_documenti`.`idtipodocumento` = `co_tipidocumento`.`id` - INNER JOIN `co_statidocumento` ON `co_documenti`.`idstatodocumento` = `co_statidocumento`.`id` - LEFT JOIN `fe_stati_documento` ON `co_documenti`.`codice_stato_fe` = `fe_stati_documento`.`codice` - LEFT OUTER JOIN ( - SELECT `iddocumento`, SUM(`subtotale` - `sconto` + `iva` + `rivalsainps` - `ritenutaacconto`) AS `totale` - FROM `co_righe_documenti` - GROUP BY `iddocumento` - ) AS righe ON `co_documenti`.`id` = `righe`.`iddocumento` - LEFT JOIN ( - SELECT `numero_esterno`, `id_segment` - FROM `co_documenti` - WHERE `co_documenti`.`idtipodocumento` IN(SELECT `id` FROM `co_tipidocumento` WHERE `dir` = ''entrata'') |date_period(`co_documenti`.`data`)| AND `numero_esterno` != '''' - GROUP BY `id_segment`, `numero_esterno` - HAVING COUNT(`numero_esterno`) > 1 - ) dup ON `co_documenti`.`numero_esterno` = `dup`.`numero_esterno` AND `dup`.`id_segment` = `co_documenti`.`id_segment` - LEFT OUTER JOIN ( - SELECT `zz_operations`.`id_email`, `zz_operations`.`id_record` - FROM `zz_operations` - INNER JOIN `em_emails` ON `zz_operations`.`id_email` = `em_emails`.`id` - INNER JOIN `em_templates` ON `em_emails`.`id_template` = `em_templates`.`id` - INNER JOIN `zz_modules` ON `zz_operations`.`id_module` = `zz_modules`.`id` - WHERE `zz_modules`.`name` = ''Fatture di vendita'' AND `zz_operations`.`op` = ''send-email'' - GROUP BY `zz_operations`.`id_record` - ) AS `email` ON `email`.`id_record` = `co_documenti`.`id` -WHERE 1=1 AND `dir` = ''entrata'' |segment(`co_documenti`.`id_segment`)| |date_period(`co_documenti`.`data`)| -HAVING 2=2 -ORDER BY `co_documenti`.`data` DESC, CAST(`co_documenti`.`numero_esterno` AS UNSIGNED) DESC' WHERE `name` = 'Fatture di vendita'; - -UPDATE `zz_views` SET `query` = 'righe.totale' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita') AND `name` = 'Totale'; -UPDATE `zz_views` SET `query` = 'IF(`email`.`id_email` IS NOT NULL, ''fa fa-envelope text-success'', '''')' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita') AND `name` = 'icon_Inviata'; -UPDATE `zz_views` SET `query` = 'IF(`email`.`id_email` IS NOT NULL, ''Inviata via email'', '''')' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita') AND `name` = 'icon_title_Inviata'; - --- Ottimizzazione Fatture di acquisto -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_documenti` - INNER JOIN `an_anagrafiche` ON `co_documenti`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - INNER JOIN `co_tipidocumento` ON `co_documenti`.`idtipodocumento` = `co_tipidocumento`.`id` - INNER JOIN `co_statidocumento` ON `co_documenti`.`idstatodocumento` = `co_statidocumento`.`id` - LEFT OUTER JOIN ( - SELECT `iddocumento`, SUM(`subtotale` - `sconto` + `iva` + `rivalsainps` - `ritenutaacconto`) AS `totale` - FROM `co_righe_documenti` - GROUP BY `iddocumento` - ) AS righe ON `co_documenti`.`id` = `righe`.`iddocumento` -WHERE 1=1 AND `dir` = ''uscita'' |segment(`co_documenti`.`id_segment`)| |date_period(`co_documenti`.`data`)| -HAVING 2=2 -ORDER BY `co_documenti`.`data` DESC, CAST(IF(`co_documenti`.`numero_esterno` = '''', `co_documenti`.`numero`, `co_documenti`.`numero_esterno`) AS UNSIGNED) DESC' WHERE `name` = 'Fatture di acquisto'; - -UPDATE `zz_views` SET `query` = 'righe.totale' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di acquisto') AND `name` = 'Totale'; -UPDATE `zz_views` SET `query` = 'an_anagrafiche.ragione_sociale ' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di acquisto') AND `name` = 'Ragione sociale'; -UPDATE `zz_views` SET `query` = 'co_statidocumento.icona' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di acquisto') AND `name` = 'icon_Stato'; -UPDATE `zz_views` SET `query` = 'co_statidocumento.descrizione' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di acquisto') AND `name` = 'icon_title_Stato'; - --- Ottimizzazione Contratti -UPDATE `zz_modules` SET `options` = 'SELECT |select| -FROM `co_contratti` - INNER JOIN `an_anagrafiche` ON `co_contratti`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - INNER JOIN `co_staticontratti` ON `co_contratti`.`idstato` = `co_staticontratti`.`id` - LEFT OUTER JOIN ( - SELECT `idcontratto`, SUM(`subtotale` - `sconto` + `iva`) AS `totale` - FROM `co_righe_contratti` - GROUP BY `idcontratto` - ) AS righe ON `co_contratti`.`id` = `righe`.`idcontratto` - LEFT OUTER JOIN ( - SELECT GROUP_CONCAT(CONCAT(matricola, IF(nome != '''', CONCAT('' - '', nome), '''')) SEPARATOR ''
    '') AS descrizione, my_impianti_contratti.idcontratto - FROM my_impianti - INNER JOIN my_impianti_contratti ON my_impianti.id = my_impianti_contratti.idimpianto - GROUP BY my_impianti_contratti.idcontratto - ) AS impianti ON impianti.idcontratto = co_contratti.id -WHERE 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'')| -HAVING 2=2 -ORDER BY `co_contratti`.`id` DESC' WHERE `name` = 'Contratti'; - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `format`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Contratti'), 'Totale', 'righe.totale', 5, 1, 1, 1, 1); -UPDATE `zz_views` SET `query` = 'an_anagrafiche.ragione_sociale ' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Contratti') AND `name` = 'Cliente'; -UPDATE `zz_views` SET `query` = 'co_staticontratti.icona' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Contratti') AND `name` = 'icon_Stato'; -UPDATE `zz_views` SET `query` = 'co_staticontratti.descrizione' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Contratti') AND `name` = 'icon_title_Stato'; -UPDATE `zz_views` SET `query` = '`co_contratti`.`id`' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Contratti') AND `name` = 'id'; -UPDATE `zz_views` SET `query` = '`co_contratti`.`nome`' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Contratti') AND `name` = 'Nome'; -UPDATE `zz_views` SET `query` = 'impianti.descrizione' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Contratti') AND `name` = 'Impianti'; - --- Ottimizzazione Preventivi -UPDATE `zz_modules` SET `options` = 'SELECT |select| -FROM `co_preventivi` - INNER JOIN `an_anagrafiche` ON `co_preventivi`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - INNER JOIN `co_statipreventivi` ON `co_preventivi`.`idstato` = `co_statipreventivi`.`id` - LEFT OUTER JOIN ( - SELECT `idpreventivo`, SUM(`subtotale` - `sconto` + `iva`) AS `totale` - FROM `co_righe_preventivi` - GROUP BY `idpreventivo` - ) AS righe ON `co_preventivi`.`id` = `righe`.`idpreventivo` -WHERE 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'')| -HAVING 2=2 -ORDER BY `co_preventivi`.`id` DESC' WHERE `name` = 'Preventivi'; - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `format`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi'), 'Totale', 'righe.totale', 5, 1, 1, 1, 1); -UPDATE `zz_views` SET `query` = 'an_anagrafiche.ragione_sociale ' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi') AND `name` = 'Cliente'; -UPDATE `zz_views` SET `query` = 'co_statipreventivi.icona' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi') AND `name` = 'icon_Stato'; -UPDATE `zz_views` SET `query` = 'co_statipreventivi.descrizione' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi') AND `name` = 'icon_title_Stato'; -UPDATE `zz_views` SET `query` = '`co_preventivi`.`id`' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi') AND `name` = 'id'; -UPDATE `zz_views` SET `query` = '`co_preventivi`.`nome`' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi') AND `name` = 'Nome'; - --- Ottimizzazione Ddt di acquisto -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `dt_ddt` - INNER JOIN `an_anagrafiche` ON `dt_ddt`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - INNER JOIN `dt_tipiddt` ON `dt_ddt`.`idtipoddt` = `dt_tipiddt`.`id` - LEFT OUTER JOIN `dt_causalet` ON `dt_ddt`.`idcausalet` = `dt_causalet`.`id` - LEFT OUTER JOIN `dt_spedizione` ON `dt_ddt`.`idspedizione` = `dt_spedizione`.`id` - LEFT OUTER JOIN `an_anagrafiche` `vettori` ON `dt_ddt`.`idvettore` = `vettori`.`idanagrafica` - LEFT OUTER JOIN `an_sedi` AS sedi ON `dt_ddt`.`idsede_partenza` = sedi.`id` - LEFT OUTER JOIN `an_sedi` AS `sedi_destinazione` ON `dt_ddt`.`idsede_destinazione` = `sedi_destinazione`.`id` - LEFT OUTER JOIN ( - SELECT `idddt`, SUM(`subtotale` - `sconto` + `iva`) AS `totale` - FROM `dt_righe_ddt` - GROUP BY `idddt` - ) AS righe ON `dt_ddt`.`id` = `righe`.`idddt` -WHERE 1=1 AND `dir` = ''uscita'' |date_period(`data`)| -HAVING 2=2 -ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC,`dt_ddt`.created_at DESC' WHERE `name` = 'Ddt di acquisto'; - -UPDATE `zz_views` SET `query` = 'righe.totale' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ddt di acquisto') AND `name` = 'Totale'; -UPDATE `zz_views` SET `query` = 'an_anagrafiche.ragione_sociale ' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ddt di acquisto') AND `name` = 'Ragione sociale'; - --- Ottimizzazione Ddt di vendita -UPDATE `zz_modules` SET `options` = 'SELECT |select| -FROM `dt_ddt` - INNER JOIN `an_anagrafiche` ON `dt_ddt`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - INNER JOIN `dt_tipiddt` ON `dt_ddt`.`idtipoddt` = `dt_tipiddt`.`id` - LEFT OUTER JOIN `dt_causalet` ON `dt_ddt`.`idcausalet` = `dt_causalet`.`id` - LEFT OUTER JOIN `dt_spedizione` ON `dt_ddt`.`idspedizione` = `dt_spedizione`.`id` - LEFT OUTER JOIN `an_anagrafiche` `vettori` ON `dt_ddt`.`idvettore` = `vettori`.`idanagrafica` - LEFT OUTER JOIN `an_sedi` AS sedi ON `dt_ddt`.`idsede_partenza` = sedi.`id` - LEFT OUTER JOIN `an_sedi` AS `sedi_destinazione` ON `dt_ddt`.`idsede_destinazione` = `sedi_destinazione`.`id` - LEFT OUTER JOIN ( - SELECT `idddt`, SUM(`subtotale` - `sconto` + `iva`) AS `totale` - FROM `dt_righe_ddt` - GROUP BY `idddt` - ) AS righe ON `dt_ddt`.`id` = `righe`.`idddt` -WHERE 1=1 AND `dir` = ''entrata'' |date_period(`data`)| -HAVING 2=2 -ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC,`dt_ddt`.created_at DESC' WHERE `name` = 'Ddt di vendita'; - -UPDATE `zz_views` SET `query` = 'righe.totale' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ddt di vendita') AND `name` = 'Totale'; -UPDATE `zz_views` SET `query` = 'an_anagrafiche.ragione_sociale ' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ddt di vendita') AND `name` = 'Ragione sociale'; - --- Ottimizzazione Ordini cliente -UPDATE `zz_modules` SET `options` = 'SELECT |select| -FROM `or_ordini` - INNER JOIN `an_anagrafiche` ON `or_ordini`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - INNER JOIN `or_tipiordine` ON `or_ordini`.`idtipoordine` = `or_tipiordine`.`id` - LEFT OUTER JOIN ( - SELECT `idordine`, SUM(`subtotale` - `sconto` + `iva`) AS `totale` - FROM `or_righe_ordini` - GROUP BY `idordine` - ) AS righe ON `or_ordini`.`id` = `righe`.`idordine` -WHERE 1=1 AND `dir` = ''entrata'' |date_period(`data`)| -HAVING 2=2 -ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC' WHERE `name` = 'Ordini cliente'; - -UPDATE `zz_views` SET `query` = 'righe.totale' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ordini cliente') AND `name` = 'Totale'; -UPDATE `zz_views` SET `query` = 'an_anagrafiche.ragione_sociale ' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ordini cliente') AND `name` = 'Ragione sociale'; - --- Ottimizzazione Ordini fornitore -UPDATE `zz_modules` SET `options` = 'SELECT |select| -FROM `or_ordini` - INNER JOIN `an_anagrafiche` ON `or_ordini`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - INNER JOIN `or_tipiordine` ON `or_ordini`.`idtipoordine` = `or_tipiordine`.`id` - LEFT OUTER JOIN ( - SELECT `idordine`, SUM(`subtotale` - `sconto` + `iva`) AS `totale` - FROM `or_righe_ordini` - GROUP BY `idordine` - ) AS righe ON `or_ordini`.`id` = `righe`.`idordine` -WHERE 1=1 AND `dir` = ''uscita'' |date_period(`data`)| -HAVING 2=2 -ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC' WHERE `name` = 'Ordini fornitore'; - -UPDATE `zz_views` SET `query` = 'righe.totale' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ordini fornitore') AND `name` = 'Totale'; -UPDATE `zz_views` SET `query` = 'an_anagrafiche.ragione_sociale ' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ordini fornitore') AND `name` = 'Ragione sociale'; - --- Correzioni per gli ordini -INSERT INTO `or_statiordine` (`id`, `descrizione`, `annullato`, `icona`, `completato`) VALUES -(NULL, 'In attesa di conferma', '0', 'fa fa-clock-o text-warning', '0'), -(NULL, 'Accettato', '0', 'fa fa-thumbs-up text-success', '0'); - -ALTER TABLE `or_ordini` ADD `data_cliente` DATE NULL DEFAULT NULL, ADD `numero_cliente` varchar(255) NULL DEFAULT NULL; - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `format`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Ordini cliente'), 'Numero ordine cliente', 'numero_cliente', 3, 1, 0, 1, 1); - --- Dichiarazioni d'Intento -CREATE TABLE IF NOT EXISTS `co_dichiarazioni_intento` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_anagrafica` int(11) NOT NULL, - `data` DATE NOT NULL, - `numero_protocollo` varchar(255) NOT NULL, - `numero_progressivo` varchar(255) NOT NULL, - `data_inizio` DATE NOT NULL, - `data_fine` DATE NOT NULL, - `data_protocollo` DATE NULL DEFAULT NULL, - `data_emissione` DATE NULL DEFAULT NULL, - `massimale` DECIMAL(12, 4) NOT NULL, - `totale` DECIMAL(12, 4) NOT NULL, - `deleted_at` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_anagrafica`) REFERENCES `an_anagrafiche`(`idanagrafica`) ON DELETE CASCADE -) ENGINE=InnoDB; - -ALTER TABLE `co_documenti` ADD `id_dichiarazione_intento` int(11), ADD FOREIGN KEY (`id_dichiarazione_intento`) REFERENCES `co_dichiarazioni_intento`(`id`) ON DELETE SET NULL; - -INSERT INTO `zz_plugins` (`id`, `name`, `title`, `idmodule_from`, `idmodule_to`, `position`, `script`, `enabled`, `default`, `order`, `compatibility`, `version`, `options2`, `options`, `directory`, `help`) VALUES (NULL, 'Dichiarazioni d''Intento', 'Dichiarazioni d''Intento', (SELECT id FROM zz_modules WHERE name = 'Fatture di vendita'), (SELECT id FROM zz_modules WHERE name='Anagrafiche'), 'tab', '', '1', '1', '0', '', '', NULL, '{ "main_query": [ { "type": "table", "fields": "Protocollo, Progressivo, Massimale, Totale, Data inizio, Data fine", "query": "SELECT id, numero_protocollo AS Protocollo, numero_progressivo AS Progressivo, DATE_FORMAT(data_inizio,''%d/%m/%Y'') AS ''Data inizio'', DATE_FORMAT(data_inizio,''%d/%m/%Y'') AS ''Data fine'', ROUND(massimale, 2) AS Massimale, ROUND(totale, 2) AS Totale FROM co_dichiarazioni_intento WHERE 1=1 AND deleted_at IS NULL AND id_anagrafica = |id_parent| HAVING 2=2 ORDER BY co_dichiarazioni_intento.id DESC"} ]}', 'dichiarazioni_intento', ''); - -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES -(NULL, 'Iva per lettere d''intento', '', 'query=SELECT id, descrizione FROM `co_iva` WHERE codice_natura_fe = ''N3'' AND deleted_at IS NULL ORDER BY descrizione ASC', 1, 'Fatturazione', 11); - --- Liste per le newsletter -CREATE TABLE IF NOT EXISTS `em_lists` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `description` TEXT, - `query` TEXT, - `deleted_at` TIMESTAMP NULL DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - -CREATE TABLE IF NOT EXISTS `em_list_anagrafica` ( - `id_list` int(11) NOT NULL, - `id_anagrafica` int(11) NOT NULL, - FOREIGN KEY (`id_list`) REFERENCES `em_newsletters`(`id`) ON DELETE CASCADE, - FOREIGN KEY (`id_anagrafica`) REFERENCES `an_anagrafiche`(`idanagrafica`) ON DELETE CASCADE -) ENGINE=InnoDB; - -INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Liste newsletter', 'Liste', 'liste_newsletter', 'SELECT |select| FROM `em_lists` WHERE deleted_at IS NULL AND 1=1 HAVING 2=2', '', 'fa fa-list', '2.4.11', '2.*', '1', (SELECT `id` FROM `zz_modules` t WHERE t.`name` = 'Gestione email'), '1', '0'); - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Liste newsletter'), 'id', 'id', 1, 0, 0, 1, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Liste newsletter'), 'Nome', 'name', 2, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Liste newsletter'), 'Descrizione', 'description', 3, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Liste newsletter'), 'Dinamica', 'IF(query IS NULL, ''No'', ''Si'')', 4, 1, 0, 1, 1); - -UPDATE `zz_prints` SET `is_record` = '0' WHERE `zz_prints`.`name` = 'Inventario magazzino'; - --- Gestione permessi per le categorie documentali -ALTER TABLE `zz_documenti` RENAME TO `do_documenti`; -ALTER TABLE `zz_documenti_categorie` RENAME TO `do_categorie`; - -CREATE TABLE IF NOT EXISTS `do_permessi` ( - `id_categoria` int(11) NOT NULL, - `id_gruppo` int(11) NOT NULL, - FOREIGN KEY (`id_categoria`) REFERENCES `do_categorie`(`id`) ON DELETE CASCADE, - FOREIGN KEY (`id_gruppo`) REFERENCES `zz_groups`(`id`) ON DELETE CASCADE -) ENGINE=InnoDB; - -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `do_categorie` -WHERE 1=1 AND `deleted_at` IS NULL AND - (SELECT `idgruppo` FROM `zz_users` WHERE `id` = |id_utente|) IN (SELECT `id_gruppo` FROM `do_permessi` WHERE `id_categoria` = `do_categorie`.`id`) -HAVING 2=2' WHERE `name` = 'Categorie documenti'; - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Categorie documenti'), 'id', 'id', 1, 0, 0, 1, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Categorie documenti'), 'Descrizione', 'descrizione', 2, 0, 0, 1, 1); - -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `do_documenti` -INNER JOIN `do_categorie` ON `do_categorie`.`id` = `do_documenti`.`idcategoria` -WHERE 1=1 AND `deleted_at` IS NULL AND - (SELECT `idgruppo` FROM `zz_users` WHERE `zz_users`.`id` = |id_utente|) IN (SELECT `id_gruppo` FROM `do_permessi` WHERE `id_categoria` = `do_documenti`.`idcategoria`) - |date_period(`data`)| -HAVING 2=2' WHERE `name` = 'Gestione documentale'; - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `format`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Gestione documentale'), 'id', '`do_documenti`.`id`', 1, 0, 0, 1, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Gestione documentale'), 'Categoria', '`do_categorie`.`descrizione`', 2, 0, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Gestione documentale'), 'Nome', '`do_documenti`.`nome`', 3, 0, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Gestione documentale'), 'Data', '`do_documenti`.`data`', 4, 0, 1, 1, 1); - --- Aggiornamento limite sui decimali -ALTER TABLE `co_contratti` CHANGE `budget` `budget` decimal(12, 6) NOT NULL; -ALTER TABLE `co_contratti` CHANGE `costo_diritto_chiamata` `costo_diritto_chiamata` decimal(12, 6) NOT NULL; -ALTER TABLE `co_contratti` CHANGE `ore_lavoro` `ore_lavoro` decimal(12, 6) NOT NULL; -ALTER TABLE `co_contratti` CHANGE `costo_orario` `costo_orario` decimal(12, 6) NOT NULL; -ALTER TABLE `co_contratti` CHANGE `costo_km` `costo_km` decimal(12, 6) NOT NULL; -ALTER TABLE `co_contratti_tipiintervento` CHANGE `costo_ore` `costo_ore` decimal(12, 6) NOT NULL; -ALTER TABLE `co_contratti_tipiintervento` CHANGE `costo_km` `costo_km` decimal(12, 6) NOT NULL; -ALTER TABLE `co_contratti_tipiintervento` CHANGE `costo_dirittochiamata` `costo_dirittochiamata` decimal(12, 6) NOT NULL; -ALTER TABLE `co_contratti_tipiintervento` CHANGE `costo_ore_tecnico` `costo_ore_tecnico` decimal(12, 6) NOT NULL; -ALTER TABLE `co_contratti_tipiintervento` CHANGE `costo_km_tecnico` `costo_km_tecnico` decimal(12, 6) NOT NULL; -ALTER TABLE `co_contratti_tipiintervento` CHANGE `costo_dirittochiamata_tecnico` `costo_dirittochiamata_tecnico` decimal(12, 6) NOT NULL; -ALTER TABLE `co_dichiarazioni_intento` CHANGE `massimale` `massimale` decimal(12, 6) NOT NULL; -ALTER TABLE `co_dichiarazioni_intento` CHANGE `totale` `totale` decimal(12, 6) NOT NULL; -ALTER TABLE `co_documenti` CHANGE `rivalsainps` `rivalsainps` decimal(12, 6) NOT NULL; -ALTER TABLE `co_documenti` CHANGE `iva_rivalsainps` `iva_rivalsainps` decimal(12, 6) NOT NULL; -ALTER TABLE `co_documenti` CHANGE `ritenutaacconto` `ritenutaacconto` decimal(12, 6) NOT NULL; -ALTER TABLE `co_documenti` CHANGE `bollo` `bollo` decimal(12, 6); -ALTER TABLE `co_documenti` CHANGE `ritenuta_contributi` `ritenuta_contributi` decimal(12, 6) NOT NULL; -ALTER TABLE `co_movimenti` CHANGE `totale` `totale` decimal(12, 6); -ALTER TABLE `co_preventivi` CHANGE `budget` `budget` decimal(12, 6) NOT NULL; -ALTER TABLE `co_preventivi` CHANGE `costo_diritto_chiamata` `costo_diritto_chiamata` decimal(12, 6) NOT NULL; -ALTER TABLE `co_preventivi` CHANGE `ore_lavoro` `ore_lavoro` decimal(12, 6) NOT NULL; -ALTER TABLE `co_preventivi` CHANGE `costo_orario` `costo_orario` decimal(12, 6) NOT NULL; -ALTER TABLE `co_preventivi` CHANGE `costo_km` `costo_km` decimal(12, 6) NOT NULL; -ALTER TABLE `co_promemoria_articoli` CHANGE `prezzo_acquisto` `prezzo_acquisto` decimal(12, 6) NOT NULL; -ALTER TABLE `co_promemoria_articoli` CHANGE `prezzo_vendita` `prezzo_vendita` decimal(12, 6) NOT NULL; -ALTER TABLE `co_promemoria_articoli` CHANGE `sconto` `sconto` decimal(12, 6) NOT NULL; -ALTER TABLE `co_promemoria_articoli` CHANGE `sconto_unitario` `sconto_unitario` decimal(12, 6) NOT NULL; -ALTER TABLE `co_promemoria_articoli` CHANGE `iva` `iva` decimal(12, 6) NOT NULL; -ALTER TABLE `co_promemoria_righe` CHANGE `prezzo_vendita` `prezzo_vendita` decimal(12, 6) NOT NULL; -ALTER TABLE `co_promemoria_righe` CHANGE `prezzo_acquisto` `prezzo_acquisto` decimal(12, 6) NOT NULL; -ALTER TABLE `co_promemoria_righe` CHANGE `iva` `iva` decimal(12, 6) NOT NULL; -ALTER TABLE `co_promemoria_righe` CHANGE `sconto` `sconto` decimal(12, 6) NOT NULL; -ALTER TABLE `co_promemoria_righe` CHANGE `sconto_unitario` `sconto_unitario` decimal(12, 6) NOT NULL; -ALTER TABLE `co_righe_contratti` CHANGE `prezzo_unitario_acquisto` `prezzo_unitario_acquisto` decimal(12, 6) NOT NULL; -ALTER TABLE `co_righe_contratti` CHANGE `subtotale` `subtotale` decimal(12, 6) NOT NULL; -ALTER TABLE `co_righe_contratti` CHANGE `sconto` `sconto` decimal(12, 6) NOT NULL; -ALTER TABLE `co_righe_contratti` CHANGE `sconto_unitario` `sconto_unitario` decimal(12, 6) NOT NULL; -ALTER TABLE `co_righe_contratti` CHANGE `iva` `iva` decimal(12, 6) NOT NULL; -ALTER TABLE `co_righe_contratti` CHANGE `iva_indetraibile` `iva_indetraibile` decimal(12, 6) NOT NULL; -ALTER TABLE `co_righe_contratti` CHANGE `qta` `qta` decimal(12, 6) NOT NULL; -ALTER TABLE `co_righe_contratti` CHANGE `qta_evasa` `qta_evasa` decimal(12, 6) NOT NULL; -ALTER TABLE `co_righe_documenti` CHANGE `iva` `iva` decimal(12, 6) NOT NULL; -ALTER TABLE `co_righe_documenti` CHANGE `iva_indetraibile` `iva_indetraibile` decimal(12, 6) NOT NULL; -ALTER TABLE `co_righe_documenti` CHANGE `prezzo_unitario_acquisto` `prezzo_unitario_acquisto` decimal(12, 6) NOT NULL; -ALTER TABLE `co_righe_documenti` CHANGE `subtotale` `subtotale` decimal(12, 6) NOT NULL; -ALTER TABLE `co_righe_documenti` CHANGE `sconto` `sconto` decimal(12, 6) NOT NULL; -ALTER TABLE `co_righe_documenti` CHANGE `sconto_unitario` `sconto_unitario` decimal(12, 6) NOT NULL; -ALTER TABLE `co_righe_documenti` CHANGE `ritenutaacconto` `ritenutaacconto` decimal(12, 6) NOT NULL; -ALTER TABLE `co_righe_documenti` CHANGE `rivalsainps` `rivalsainps` decimal(12, 6) NOT NULL; -ALTER TABLE `co_righe_documenti` CHANGE `qta` `qta` decimal(12, 6) NOT NULL; -ALTER TABLE `co_righe_documenti` CHANGE `qta_evasa` `qta_evasa` decimal(12, 6) NOT NULL; -ALTER TABLE `co_righe_preventivi` CHANGE `iva` `iva` decimal(12, 6) NOT NULL; -ALTER TABLE `co_righe_preventivi` CHANGE `iva_indetraibile` `iva_indetraibile` decimal(12, 6) NOT NULL; -ALTER TABLE `co_righe_preventivi` CHANGE `prezzo_unitario_acquisto` `prezzo_unitario_acquisto` decimal(12, 6) NOT NULL; -ALTER TABLE `co_righe_preventivi` CHANGE `subtotale` `subtotale` decimal(12, 6) NOT NULL; -ALTER TABLE `co_righe_preventivi` CHANGE `sconto` `sconto` decimal(12, 6) NOT NULL; -ALTER TABLE `co_righe_preventivi` CHANGE `sconto_unitario` `sconto_unitario` decimal(12, 6) NOT NULL; -ALTER TABLE `co_righe_preventivi` CHANGE `qta` `qta` decimal(12, 6) NOT NULL; -ALTER TABLE `co_righe_preventivi` CHANGE `qta_evasa` `qta_evasa` decimal(12, 6) NOT NULL; -ALTER TABLE `co_scadenziario` CHANGE `da_pagare` `da_pagare` decimal(12, 6); -ALTER TABLE `co_scadenziario` CHANGE `pagato` `pagato` decimal(12, 6); -ALTER TABLE `dt_ddt` CHANGE `rivalsainps` `rivalsainps` decimal(12, 6) NOT NULL; -ALTER TABLE `dt_ddt` CHANGE `iva_rivalsainps` `iva_rivalsainps` decimal(12, 6) NOT NULL; -ALTER TABLE `dt_ddt` CHANGE `ritenutaacconto` `ritenutaacconto` decimal(12, 6) NOT NULL; -ALTER TABLE `dt_ddt` CHANGE `bollo` `bollo` decimal(12, 6) NOT NULL; -ALTER TABLE `dt_righe_ddt` CHANGE `iva` `iva` decimal(12, 6) NOT NULL; -ALTER TABLE `dt_righe_ddt` CHANGE `iva_indetraibile` `iva_indetraibile` decimal(12, 6) NOT NULL; -ALTER TABLE `dt_righe_ddt` CHANGE `prezzo_unitario_acquisto` `prezzo_unitario_acquisto` decimal(12, 6) NOT NULL; -ALTER TABLE `dt_righe_ddt` CHANGE `subtotale` `subtotale` decimal(12, 6) NOT NULL; -ALTER TABLE `dt_righe_ddt` CHANGE `sconto` `sconto` decimal(12, 6) NOT NULL; -ALTER TABLE `dt_righe_ddt` CHANGE `sconto_unitario` `sconto_unitario` decimal(12, 6) NOT NULL; -ALTER TABLE `dt_righe_ddt` CHANGE `qta` `qta` decimal(12, 6) NOT NULL; -ALTER TABLE `dt_righe_ddt` CHANGE `qta_evasa` `qta_evasa` decimal(12, 6) NOT NULL; -ALTER TABLE `in_interventi_tecnici` CHANGE `ore` `ore` decimal(12, 6) NOT NULL; -ALTER TABLE `in_interventi_tecnici` CHANGE `km` `km` decimal(12, 6) NOT NULL; -ALTER TABLE `in_interventi_tecnici` CHANGE `prezzo_ore_unitario` `prezzo_ore_unitario` decimal(12, 6) NOT NULL; -ALTER TABLE `in_interventi_tecnici` CHANGE `prezzo_km_unitario` `prezzo_km_unitario` decimal(12, 6) NOT NULL; -ALTER TABLE `in_interventi_tecnici` CHANGE `prezzo_ore_consuntivo` `prezzo_ore_consuntivo` decimal(12, 6) NOT NULL; -ALTER TABLE `in_interventi_tecnici` CHANGE `prezzo_km_consuntivo` `prezzo_km_consuntivo` decimal(12, 6) NOT NULL; -ALTER TABLE `in_interventi_tecnici` CHANGE `prezzo_dirittochiamata` `prezzo_dirittochiamata` decimal(12, 6) NOT NULL; -ALTER TABLE `in_interventi_tecnici` CHANGE `prezzo_ore_unitario_tecnico` `prezzo_ore_unitario_tecnico` decimal(12, 6) NOT NULL; -ALTER TABLE `in_interventi_tecnici` CHANGE `prezzo_km_unitario_tecnico` `prezzo_km_unitario_tecnico` decimal(12, 6) NOT NULL; -ALTER TABLE `in_interventi_tecnici` CHANGE `prezzo_ore_consuntivo_tecnico` `prezzo_ore_consuntivo_tecnico` decimal(12, 6) NOT NULL; -ALTER TABLE `in_interventi_tecnici` CHANGE `prezzo_km_consuntivo_tecnico` `prezzo_km_consuntivo_tecnico` decimal(12, 6) NOT NULL; -ALTER TABLE `in_interventi_tecnici` CHANGE `prezzo_dirittochiamata_tecnico` `prezzo_dirittochiamata_tecnico` decimal(12, 6) NOT NULL; -ALTER TABLE `in_interventi_tecnici` CHANGE `sconto` `sconto` decimal(12, 6) NOT NULL; -ALTER TABLE `in_interventi_tecnici` CHANGE `sconto_unitario` `sconto_unitario` decimal(12, 6) NOT NULL; -ALTER TABLE `in_interventi_tecnici` CHANGE `scontokm` `scontokm` decimal(12, 6) NOT NULL; -ALTER TABLE `in_interventi_tecnici` CHANGE `scontokm_unitario` `scontokm_unitario` decimal(12, 6) NOT NULL; -ALTER TABLE `in_righe_interventi` CHANGE `prezzo_vendita` `prezzo_vendita` decimal(12, 6) NOT NULL; -ALTER TABLE `in_righe_interventi` CHANGE `prezzo_acquisto` `prezzo_acquisto` decimal(12, 6) NOT NULL; -ALTER TABLE `in_righe_interventi` CHANGE `iva` `iva` decimal(12, 6) NOT NULL; -ALTER TABLE `in_righe_interventi` CHANGE `sconto` `sconto` decimal(12, 6) NOT NULL; -ALTER TABLE `in_righe_interventi` CHANGE `sconto_unitario` `sconto_unitario` decimal(12, 6) NOT NULL; -ALTER TABLE `in_tariffe` CHANGE `costo_ore` `costo_ore` decimal(12, 6) NOT NULL; -ALTER TABLE `in_tariffe` CHANGE `costo_km` `costo_km` decimal(12, 6) NOT NULL; -ALTER TABLE `in_tariffe` CHANGE `costo_dirittochiamata` `costo_dirittochiamata` decimal(12, 6) NOT NULL; -ALTER TABLE `in_tariffe` CHANGE `costo_ore_tecnico` `costo_ore_tecnico` decimal(12, 6) NOT NULL; -ALTER TABLE `in_tariffe` CHANGE `costo_km_tecnico` `costo_km_tecnico` decimal(12, 6) NOT NULL; -ALTER TABLE `in_tariffe` CHANGE `costo_dirittochiamata_tecnico` `costo_dirittochiamata_tecnico` decimal(12, 6) NOT NULL; -ALTER TABLE `in_tipiintervento` CHANGE `costo_orario` `costo_orario` decimal(12, 6) NOT NULL; -ALTER TABLE `in_tipiintervento` CHANGE `costo_km` `costo_km` decimal(12, 6) NOT NULL; -ALTER TABLE `in_tipiintervento` CHANGE `costo_diritto_chiamata` `costo_diritto_chiamata` decimal(12, 6) NOT NULL; -ALTER TABLE `in_tipiintervento` CHANGE `costo_orario_tecnico` `costo_orario_tecnico` decimal(12, 6) NOT NULL; -ALTER TABLE `in_tipiintervento` CHANGE `costo_km_tecnico` `costo_km_tecnico` decimal(12, 6) NOT NULL; -ALTER TABLE `in_tipiintervento` CHANGE `costo_diritto_chiamata_tecnico` `costo_diritto_chiamata_tecnico` decimal(12, 6) NOT NULL; -ALTER TABLE `mg_articoli` CHANGE `qta` `qta` decimal(12, 6) NOT NULL; -ALTER TABLE `mg_articoli` CHANGE `threshold_qta` `threshold_qta` decimal(12, 6) NOT NULL; -ALTER TABLE `mg_articoli` CHANGE `prezzo_acquisto` `prezzo_acquisto` decimal(12, 6) NOT NULL; -ALTER TABLE `mg_articoli` CHANGE `prezzo_vendita` `prezzo_vendita` decimal(12, 6) NOT NULL; -ALTER TABLE `mg_articoli` CHANGE `peso_lordo` `peso_lordo` decimal(12, 6) NOT NULL; -ALTER TABLE `mg_articoli` CHANGE `volume` `volume` decimal(12, 6) NOT NULL; -ALTER TABLE `mg_articoli_interventi` CHANGE `prezzo_acquisto` `prezzo_acquisto` decimal(12, 6) NOT NULL; -ALTER TABLE `mg_articoli_interventi` CHANGE `prezzo_vendita` `prezzo_vendita` decimal(12, 6) NOT NULL; -ALTER TABLE `mg_articoli_interventi` CHANGE `sconto` `sconto` decimal(12, 6) NOT NULL; -ALTER TABLE `mg_articoli_interventi` CHANGE `sconto_unitario` `sconto_unitario` decimal(12, 6) NOT NULL; -ALTER TABLE `mg_articoli_interventi` CHANGE `iva` `iva` decimal(12, 6) NOT NULL; -ALTER TABLE `mg_movimenti` CHANGE `qta` `qta` decimal(12, 6) NOT NULL; -ALTER TABLE `or_ordini` CHANGE `rivalsainps` `rivalsainps` decimal(12, 6) NOT NULL; -ALTER TABLE `or_ordini` CHANGE `iva_rivalsainps` `iva_rivalsainps` decimal(12, 6) NOT NULL; -ALTER TABLE `or_ordini` CHANGE `ritenutaacconto` `ritenutaacconto` decimal(12, 6) NOT NULL; -ALTER TABLE `or_righe_ordini` CHANGE `iva` `iva` decimal(12, 6) NOT NULL; -ALTER TABLE `or_righe_ordini` CHANGE `iva_indetraibile` `iva_indetraibile` decimal(12, 6) NOT NULL; -ALTER TABLE `or_righe_ordini` CHANGE `prezzo_unitario_acquisto` `prezzo_unitario_acquisto` decimal(12, 6) NOT NULL; -ALTER TABLE `or_righe_ordini` CHANGE `subtotale` `subtotale` decimal(12, 6) NOT NULL; -ALTER TABLE `or_righe_ordini` CHANGE `sconto` `sconto` decimal(12, 6) NOT NULL; -ALTER TABLE `or_righe_ordini` CHANGE `sconto_unitario` `sconto_unitario` decimal(12, 6) NOT NULL; -ALTER TABLE `or_righe_ordini` CHANGE `qta` `qta` decimal(12, 6) NOT NULL; -ALTER TABLE `or_righe_ordini` CHANGE `qta_evasa` `qta_evasa` decimal(12, 6) NOT NULL; - -UPDATE `zz_settings` SET `tipo` = 'list[1,2,3,4,5]' WHERE `nome` = 'Cifre decimali per importi'; -UPDATE `zz_settings` SET `tipo` = 'list[1,2,3,4,5]' WHERE `nome` = 'Cifre decimali per quantità'; - --- Aggiunta percentuale combinata in listini -ALTER TABLE `mg_listini` ADD `prc_combinato` VARCHAR(255); - --- Aggiunto supporto ai tentativi di invio email -ALTER TABLE `em_emails` ADD `attempt` INT(11) NOT NULL DEFAULT 0; - --- Fix calcolo totale contratti in scadenza -UPDATE `zz_widgets` SET `query` = 'SELECT COUNT(id) AS dato, - DATEDIFF(data_conclusione, NOW()) AS giorni_rimanenti, - data_conclusione, - ore_preavviso_rinnovo, - giorni_preavviso_rinnovo, - (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=co_contratti.idanagrafica) AS ragione_sociale -FROM co_contratti WHERE - idstato IN (SELECT id FROM co_staticontratti WHERE is_fatturabile = 1) AND - rinnovabile = 1 AND - YEAR(data_conclusione) > 1970 AND - (SELECT id FROM co_contratti contratti WHERE contratti.idcontratto_prev = co_contratti.id) IS NULL -AND (IFNULL( ((SELECT SUM(co_righe_contratti.qta) FROM co_righe_contratti WHERE co_righe_contratti.um=\'ore\' AND co_righe_contratti.idcontratto=co_contratti.id) - IFNULL( (SELECT SUM(in_interventi_tecnici.ore) FROM in_interventi_tecnici INNER JOIN in_interventi ON in_interventi_tecnici.idintervento=in_interventi.id WHERE in_interventi.id_contratto=co_contratti.id AND in_interventi.idstatointervento IN (SELECT in_statiintervento.idstatointervento FROM in_statiintervento WHERE in_statiintervento.completato = 1)), 0) ), 0 ) < ore_preavviso_rinnovo OR DATEDIFF(data_conclusione, NOW()) < ABS(giorni_preavviso_rinnovo)) -ORDER BY giorni_rimanenti ASC, IFNULL( ((SELECT SUM(co_righe_contratti.qta) FROM co_righe_contratti WHERE co_righe_contratti.um=\'ore\' AND co_righe_contratti.idcontratto=co_contratti.id) - IFNULL( (SELECT SUM(in_interventi_tecnici.ore) FROM in_interventi_tecnici INNER JOIN in_interventi ON in_interventi_tecnici.idintervento=in_interventi.id WHERE in_interventi.id_contratto=co_contratti.id AND in_interventi.idstatointervento IN (SELECT in_statiintervento.idstatointervento FROM in_statiintervento WHERE in_statiintervento.completato = 1)), 0) ), 0 ) ASC' WHERE `zz_widgets`.`name` = 'Contratti in scadenza'; - --- Aggiunta campo barcode per gli articoli -ALTER TABLE `mg_articoli` ADD `barcode` VARCHAR(255); - --- Aggiunta campo fornitore per gli articoli -ALTER TABLE `mg_articoli` ADD `id_fornitore` INT(11) NULL DEFAULT NULL; - --- Aggiunta vista prezzo vendita e prezzo acquisto per gli articoli -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `summable`, `visible`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Articoli'), 'Fornitore', '(SELECT `ragione_sociale` FROM `an_anagrafiche` WHERE `idanagrafica` = `id_fornitore`)', 6, 1, 0, 0, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Articoli'), 'Prezzo di acquisto', 'prezzo_acquisto', 6, 1, 0, 1, 1, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Articoli'), 'Prezzo di vendita', 'prezzo_vendita', 6, 1, 0, 1, 1, 0, 1); - --- Aggiunta flag can_delete per stati preventivi e contratti -ALTER TABLE `co_statipreventivi` ADD `can_delete` BOOLEAN NOT NULL DEFAULT TRUE; -ALTER TABLE `co_staticontratti` ADD `can_delete` BOOLEAN NOT NULL DEFAULT TRUE; - --- Imposto gli stati Bozza, In lavorazione e Concluso non eliminabili per stati preventivi e contratti -UPDATE `co_statipreventivi` SET `can_delete` = '0' WHERE `co_statipreventivi`.`descrizione` = 'Bozza'; -UPDATE `co_statipreventivi` SET `can_delete` = '0' WHERE `co_statipreventivi`.`descrizione` = 'In lavorazione'; - -UPDATE `co_staticontratti` SET `can_delete` = '0' WHERE `co_staticontratti`.`descrizione` = 'Bozza'; -UPDATE `co_staticontratti` SET `can_delete` = '0' WHERE `co_staticontratti`.`descrizione` = 'In lavorazione'; -UPDATE `co_staticontratti` SET `can_delete` = '0' WHERE `co_staticontratti`.`descrizione` = 'Concluso'; -UPDATE `co_staticontratti` SET `can_delete` = '0' WHERE `co_staticontratti`.`descrizione` = 'Fatturato'; -UPDATE `co_staticontratti` SET `can_delete` = '0' WHERE `co_staticontratti`.`descrizione` = 'Parzialmente fatturato'; - -ALTER TABLE `an_sedi` ADD `note` TEXT NULL DEFAULT NULL AFTER `idzona`; - -UPDATE `zz_views` SET `query` = 'codice' WHERE `zz_views`.`name` = 'Codice' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Stati di intervento'); -UPDATE `zz_views` SET `query` = 'codice' WHERE `zz_views`.`name` = 'Codice' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi di intervento'); -UPDATE `zz_modules` SET `icon` = 'fa fa-angle-right' WHERE `zz_modules`.`name` = 'Categorie documenti'; - -UPDATE `zz_widgets` SET `query` = 'SELECT CONCAT_WS(" ", REPLACE(REPLACE(REPLACE(FORMAT(SUM(prezzo_acquisto*qta),2), ",", "#"), ".", ","), "#", "."), "€") AS dato FROM mg_articoli WHERE qta>0 AND deleted_at IS NULL' WHERE `zz_widgets`.`name` = 'Valore magazzino'; -UPDATE `zz_widgets` SET `query` = 'SELECT CONCAT_WS(" ", REPLACE(REPLACE(REPLACE(FORMAT(SUM(qta),2), ",", "#"), ".", ","), "#", "."), "unità") AS dato FROM mg_articoli WHERE qta>0 AND deleted_at IS NULL' WHERE `zz_widgets`.`name` = 'Articoli in magazzino'; - --- Fix accesso alla stampa dell'Inventario magazzino -UPDATE `zz_prints` SET `is_record` = '0' WHERE `zz_prints`.`name` = 'Inventario magazzino'; - -UPDATE `in_statiintervento` SET `can_delete` = '0', `in_statiintervento`.`codice` = 'TODO' WHERE `in_statiintervento`.`codice` = 'DAP'; - --- Fix possibili problemi per data_registrazione e data_competenza -UPDATE `co_documenti` SET `data_registrazione` = NULL WHERE `data_registrazione` = '0000-00-00'; -UPDATE `co_documenti` SET `data_registrazione` = `data` WHERE `data_registrazione` IS NULL AND idtipodocumento IN (SELECT id FROM co_tipidocumento WHERE dir = 'uscita'); -UPDATE `co_documenti` SET `data_competenza` = `data_registrazione` WHERE `data_competenza` = '0000-00-00' OR `data_competenza` IS NULL; diff --git a/update/2_4_12.sql b/update/2_4_12.sql deleted file mode 100755 index b76c57dd7..000000000 --- a/update/2_4_12.sql +++ /dev/null @@ -1,50 +0,0 @@ -UPDATE `co_documenti` SET `data_competenza` = `data` WHERE `data_competenza` = '0000-00-00' OR `data_competenza` IS NULL; - --- In caso di pagamenti anticipati dei clienti. Queste fatture non sono differenziate dalle altre, se non per la descrizione nel corpo fattura, che fa, appunto, riferimento all'anticipo ricevuto. --- Nelle specifiche della fattura elettronica si parla di un tipo documento TD02 Acconto/anticipo su fattura. -INSERT INTO `co_tipidocumento` (`id`, `descrizione`, `dir`, `reversed`, `codice_tipo_documento_fe`) VALUES (NULL, 'Acconto/anticipo su fattura', 'entrata', '0', 'TD02'); - -INSERT INTO `dt_causalet` (`id`, `descrizione`, `predefined`) VALUES (NULL, 'Conto lavorazione', '0'), (NULL, 'Conto visione','0') , (NULL, 'Omaggio','0'); - -UPDATE `zz_widgets` SET `name` = 'Attività nello stato da programmare', `text` = 'Attività nello stato da programmare' WHERE `zz_widgets`.`name` = 'Attività in programmazione'; - -UPDATE `in_statiintervento` SET `descrizione` = 'Programmato' WHERE `in_statiintervento`.`descrizione` = 'In Programmazione' AND `in_statiintervento`.`codice` = 'WIP'; - --- Uniformo le date scadenza non settate correttamente -UPDATE `in_interventi` SET `data_scadenza` = NULL WHERE `data_scadenza` = '0000-00-00 00:00:00'; - --- Permetti inserimento sessioni anche per altri tecnici -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES (NULL, 'Permetti inserimento sessioni degli altri tecnici', '0', 'boolean', '1', 'Interventi', NULL, "Permette al tecnico l\'inserimento delle sessioni di lavoro anche per gli altri tecnici."); - --- Aggiunta cartella per il modulo "Movimenti" -UPDATE `zz_modules` SET `directory` = 'movimenti' WHERE `name` = 'Movimenti'; - --- Fix nomenclatura stampe (da "senza costi" a "senza prezzi") -UPDATE `zz_prints` SET `title` = 'Intervento (senza prezzi)' WHERE `name` = 'Intervento (senza costi)'; -UPDATE `zz_prints` SET `title` = 'Preventivo (senza prezzi)' WHERE `name` = 'Preventivo (senza costi)'; -UPDATE `zz_prints` SET `title` = 'Consuntivo preventivo (senza prezzi)' WHERE `name` = 'Consuntivo preventivo (senza costi)'; -UPDATE `zz_prints` SET `title` = 'Contratto (senza prezzi)' WHERE `name` = 'Contratto (senza costi)'; -UPDATE `zz_prints` SET `title` = 'Consuntivo contratto (senza prezzi)' WHERE `name` = 'Consuntivo contratto (senza costi)'; -UPDATE `zz_prints` SET `title` = 'Ordine cliente (senza prezzi)' WHERE `name` = 'Ordine cliente (senza costi)'; -UPDATE `zz_prints` SET `title` = 'Ordine fornitore (senza prezzi)' WHERE `name` = 'Ordine fornitore (senza costi)'; -UPDATE `zz_prints` SET `title` = 'Ddt di vendita (senza prezzi)' WHERE `name` = 'Ddt di vendita (senza costi)'; - --- Aggiunta campo "Ubicazione" per gli articoli -ALTER TABLE `mg_articoli` ADD `ubicazione` VARCHAR(255) NOT NULL AFTER `threshold_qta`; - --- Aggiunta flag per apertura e chiusura bilancio automatici -ALTER TABLE `co_movimenti` ADD `is_apertura` BOOLEAN NOT NULL DEFAULT FALSE AFTER `is_insoluto`, ADD `is_chiusura` BOOLEAN NOT NULL DEFAULT FALSE AFTER `is_apertura`; - -ALTER TABLE `co_pianodeiconti3` DROP `can_delete`, DROP `can_edit`; - -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES -(NULL, 'Conto per Riepilogativo fornitori', (SELECT id FROM co_pianodeiconti3 WHERE descrizione = 'Riepilogativo fornitori'), 'query=SELECT `id`, CONCAT_WS('' - '', `numero`, `descrizione`) AS descrizione FROM `co_pianodeiconti3` ORDER BY `descrizione` ASC', 1, 'Piano dei Conti', 1), -(NULL, 'Conto per Riepilogativo clienti', (SELECT id FROM co_pianodeiconti3 WHERE descrizione = 'Riepilogativo clienti'), 'query=SELECT `id`, CONCAT_WS('' - '', `numero`, `descrizione`) AS descrizione FROM `co_pianodeiconti3` ORDER BY `descrizione` ASC', 1, 'Piano dei Conti', 1), -(NULL, 'Conto per Iva indetraibile', (SELECT id FROM co_pianodeiconti3 WHERE descrizione = 'Iva indetraibile'), 'query=SELECT `id`, CONCAT_WS('' - '', `numero`, `descrizione`) AS descrizione FROM `co_pianodeiconti3` ORDER BY `descrizione` ASC', 1, 'Piano dei Conti', 1), -(NULL, 'Conto per Iva su vendite', (SELECT id FROM co_pianodeiconti3 WHERE descrizione = 'Iva su vendite'), 'query=SELECT `id`, CONCAT_WS('' - '', `numero`, `descrizione`) AS descrizione FROM `co_pianodeiconti3` ORDER BY `descrizione` ASC', 1, 'Piano dei Conti', 1), -(NULL, 'Conto per Iva su acquisti', (SELECT id FROM co_pianodeiconti3 WHERE descrizione = 'Iva su acquisti'), 'query=SELECT `id`, CONCAT_WS('' - '', `numero`, `descrizione`) AS descrizione FROM `co_pianodeiconti3` ORDER BY `descrizione` ASC', 1, 'Piano dei Conti', 1), -(NULL, 'Conto per Erario c/ritenute d''acconto', (SELECT id FROM co_pianodeiconti3 WHERE descrizione = 'Erario c/ritenute d''acconto'), 'query=SELECT `id`, CONCAT_WS('' - '', `numero`, `descrizione`) AS descrizione FROM `co_pianodeiconti3` ORDER BY `descrizione` ASC', 1, 'Piano dei Conti', 1), -(NULL, 'Conto per Erario c/INPS', (SELECT id FROM co_pianodeiconti3 WHERE descrizione = 'Erario c/INPS'), 'query=SELECT `id`, CONCAT_WS('' - '', `numero`, `descrizione`) AS descrizione FROM `co_pianodeiconti3` ORDER BY `descrizione` ASC', 1, 'Piano dei Conti', 1), -(NULL, 'Conto per Erario c/enasarco', (SELECT id FROM co_pianodeiconti3 WHERE descrizione = 'Erario c/enasarco'), 'query=SELECT `id`, CONCAT_WS('' - '', `numero`, `descrizione`) AS descrizione FROM `co_pianodeiconti3` ORDER BY `descrizione` ASC', 1, 'Piano dei Conti', 1), -(NULL, 'Conto per Apertura conti patrimoniali', (SELECT id FROM co_pianodeiconti3 WHERE descrizione = 'Apertura conti patrimoniali'), 'query=SELECT `id`, CONCAT_WS('' - '', `numero`, `descrizione`) AS descrizione FROM `co_pianodeiconti3` ORDER BY `descrizione` ASC', 1, 'Piano dei Conti', 1), -(NULL, 'Conto per Chiusura conti patrimoniali', (SELECT id FROM co_pianodeiconti3 WHERE descrizione = 'Chiusura conti patrimoniali'), 'query=SELECT `id`, CONCAT_WS('' - '', `numero`, `descrizione`) AS descrizione FROM `co_pianodeiconti3` ORDER BY `descrizione` ASC', 1, 'Piano dei Conti', 1); diff --git a/update/2_4_13.php b/update/2_4_13.php deleted file mode 100755 index 53f459b6c..000000000 --- a/update/2_4_13.php +++ /dev/null @@ -1,59 +0,0 @@ - $value) { - $files[$key] = realpath(base_dir().'\\'.$value); -} - -delete($files); diff --git a/update/2_4_13.sql b/update/2_4_13.sql deleted file mode 100755 index b1af48f8f..000000000 --- a/update/2_4_13.sql +++ /dev/null @@ -1,260 +0,0 @@ --- Aggiornamento vista contratti con totale imponibile -UPDATE `zz_modules` SET `options` = 'SELECT |select| -FROM `co_contratti` - INNER JOIN `an_anagrafiche` ON `co_contratti`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - INNER JOIN `co_staticontratti` ON `co_contratti`.`idstato` = `co_staticontratti`.`id` - LEFT OUTER JOIN ( - SELECT `idcontratto`, SUM(`subtotale` - `sconto`) AS `totale` - FROM `co_righe_contratti` - GROUP BY `idcontratto` - ) AS righe ON `co_contratti`.`id` = `righe`.`idcontratto` - LEFT OUTER JOIN ( - SELECT GROUP_CONCAT(CONCAT(matricola, IF(nome != '''', CONCAT('' - '', nome), '''')) SEPARATOR ''
    '') AS descrizione, my_impianti_contratti.idcontratto - FROM my_impianti - INNER JOIN my_impianti_contratti ON my_impianti.id = my_impianti_contratti.idimpianto - GROUP BY my_impianti_contratti.idcontratto - ) AS impianti ON impianti.idcontratto = co_contratti.id -WHERE 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'')| -HAVING 2=2 -ORDER BY `co_contratti`.`id` DESC' WHERE `name` = 'Contratti'; - - --- Aggiornamento vista preventivi con totale imponibile -UPDATE `zz_modules` SET `options` = 'SELECT |select| -FROM `co_preventivi` - INNER JOIN `an_anagrafiche` ON `co_preventivi`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - INNER JOIN `co_statipreventivi` ON `co_preventivi`.`idstato` = `co_statipreventivi`.`id` - LEFT OUTER JOIN ( - SELECT `idpreventivo`, SUM(`subtotale` - `sconto`) AS `totale` - FROM `co_righe_preventivi` - GROUP BY `idpreventivo` - ) AS righe ON `co_preventivi`.`id` = `righe`.`idpreventivo` -WHERE 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'')| -HAVING 2=2 -ORDER BY `co_preventivi`.`id` DESC' WHERE `name` = 'Preventivi'; - - --- Aggiornamento Ddt di acquisto con totale imponibile -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `dt_ddt` - INNER JOIN `an_anagrafiche` ON `dt_ddt`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - INNER JOIN `dt_tipiddt` ON `dt_ddt`.`idtipoddt` = `dt_tipiddt`.`id` - LEFT OUTER JOIN `dt_causalet` ON `dt_ddt`.`idcausalet` = `dt_causalet`.`id` - LEFT OUTER JOIN `dt_spedizione` ON `dt_ddt`.`idspedizione` = `dt_spedizione`.`id` - LEFT OUTER JOIN `an_anagrafiche` `vettori` ON `dt_ddt`.`idvettore` = `vettori`.`idanagrafica` - LEFT OUTER JOIN `an_sedi` AS sedi ON `dt_ddt`.`idsede_partenza` = sedi.`id` - LEFT OUTER JOIN `an_sedi` AS `sedi_destinazione` ON `dt_ddt`.`idsede_destinazione` = `sedi_destinazione`.`id` - LEFT OUTER JOIN ( - SELECT `idddt`, SUM(`subtotale` - `sconto`) AS `totale` - FROM `dt_righe_ddt` - GROUP BY `idddt` - ) AS righe ON `dt_ddt`.`id` = `righe`.`idddt` -WHERE 1=1 AND `dir` = ''uscita'' |date_period(`data`)| -HAVING 2=2 -ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC,`dt_ddt`.created_at DESC' WHERE `name` = 'Ddt di acquisto'; - - --- Aggiornamento Ddt di vendita con totale imponibile -UPDATE `zz_modules` SET `options` = 'SELECT |select| -FROM `dt_ddt` - INNER JOIN `an_anagrafiche` ON `dt_ddt`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - INNER JOIN `dt_tipiddt` ON `dt_ddt`.`idtipoddt` = `dt_tipiddt`.`id` - LEFT OUTER JOIN `dt_causalet` ON `dt_ddt`.`idcausalet` = `dt_causalet`.`id` - LEFT OUTER JOIN `dt_spedizione` ON `dt_ddt`.`idspedizione` = `dt_spedizione`.`id` - LEFT OUTER JOIN `an_anagrafiche` `vettori` ON `dt_ddt`.`idvettore` = `vettori`.`idanagrafica` - LEFT OUTER JOIN `an_sedi` AS sedi ON `dt_ddt`.`idsede_partenza` = sedi.`id` - LEFT OUTER JOIN `an_sedi` AS `sedi_destinazione` ON `dt_ddt`.`idsede_destinazione` = `sedi_destinazione`.`id` - LEFT OUTER JOIN ( - SELECT `idddt`, SUM(`subtotale` - `sconto`) AS `totale` - FROM `dt_righe_ddt` - GROUP BY `idddt` - ) AS righe ON `dt_ddt`.`id` = `righe`.`idddt` -WHERE 1=1 AND `dir` = ''entrata'' |date_period(`data`)| -HAVING 2=2 -ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC,`dt_ddt`.created_at DESC' WHERE `name` = 'Ddt di vendita'; - - --- Aggiornamento Ordini cliente con totale imponibile -UPDATE `zz_modules` SET `options` = 'SELECT |select| -FROM `or_ordini` - INNER JOIN `an_anagrafiche` ON `or_ordini`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - INNER JOIN `or_tipiordine` ON `or_ordini`.`idtipoordine` = `or_tipiordine`.`id` - LEFT OUTER JOIN ( - SELECT `idordine`, SUM(`subtotale` - `sconto`) AS `totale` - FROM `or_righe_ordini` - GROUP BY `idordine` - ) AS righe ON `or_ordini`.`id` = `righe`.`idordine` -WHERE 1=1 AND `dir` = ''entrata'' |date_period(`data`)| -HAVING 2=2 -ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC' WHERE `name` = 'Ordini cliente'; - - --- Aggiornamento Ordini fornitore con totale imponibile -UPDATE `zz_modules` SET `options` = 'SELECT |select| -FROM `or_ordini` - INNER JOIN `an_anagrafiche` ON `or_ordini`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - INNER JOIN `or_tipiordine` ON `or_ordini`.`idtipoordine` = `or_tipiordine`.`id` - LEFT OUTER JOIN ( - SELECT `idordine`, SUM(`subtotale` - `sconto`) AS `totale` - FROM `or_righe_ordini` - GROUP BY `idordine` - ) AS righe ON `or_ordini`.`id` = `righe`.`idordine` -WHERE 1=1 AND `dir` = ''uscita'' |date_period(`data`)| -HAVING 2=2 -ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC' WHERE `name` = 'Ordini fornitore'; - --- Fix data registrazione e data competenza non settate -UPDATE `co_documenti` SET `data_registrazione` = `data` WHERE `data_registrazione` IS NULL; -UPDATE `co_documenti` SET `data_competenza` = `data_registrazione` WHERE `data_competenza` IS NULL; - --- Data ora trasporto per ddt -ALTER TABLE `dt_ddt` ADD `data_ora_trasporto` DATETIME NULL DEFAULT NULL AFTER `data`; - --- Corretto widget contratti in scadenza -UPDATE `zz_widgets` SET `query` = 'SELECT COUNT(id) AS dato, - ((SELECT SUM(co_righe_contratti.qta) FROM co_righe_contratti WHERE co_righe_contratti.um=\'ore\' AND co_righe_contratti.idcontratto=co_contratti.id) - IFNULL( (SELECT SUM(in_interventi_tecnici.ore) FROM in_interventi_tecnici INNER JOIN in_interventi ON in_interventi_tecnici.idintervento=in_interventi.id WHERE in_interventi.id_contratto=co_contratti.id AND in_interventi.idstatointervento IN (SELECT in_statiintervento.idstatointervento FROM in_statiintervento WHERE in_statiintervento.completato = 1)), 0) ) AS ore_rimanenti, - data_conclusione, ore_preavviso_rinnovo, giorni_preavviso_rinnovo - FROM co_contratti WHERE idstato IN (SELECT id FROM co_staticontratti WHERE is_fatturabile = 1) AND rinnovabile = 1 AND YEAR(data_conclusione) > 1970 AND (SELECT id FROM co_contratti contratti WHERE contratti.idcontratto_prev = co_contratti.id) IS NULL - HAVING (ore_rimanenti < ore_preavviso_rinnovo OR DATEDIFF(data_conclusione, NOW()) < ABS(giorni_preavviso_rinnovo))' WHERE `zz_widgets`.`name` = 'Contratti in scadenza'; - --- Impostazione "Filigrana stampe" -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES (NULL, 'Filigrana stampe', '', 'string', '0', 'Generali'); - --- Per elenco coda di invio aggiungo colonna Modulo (legata al template) e Destinatario -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `default`, `visible`, `format`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stato email'), 'Modulo', '(SELECT zz_modules.title FROM zz_modules WHERE zz_modules.id = em_templates.id_module)', 3, 1, 0, 1, 1, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stato email'), 'Destinatari', '(SELECT GROUP_CONCAT(address SEPARATOR "
    ") FROM em_email_receiver WHERE em_email_receiver.id_email = em_emails.id)', 1, 1, 0, 1, 1, 0); - --- Modulo Relazioni -INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Relazioni', 'Relazioni', 'relazioni_anagrafiche', 'SELECT |select| -FROM `an_relazioni` -WHERE 1=1 -HAVING 2=2 -ORDER BY `an_relazioni`.`created_at` DESC', '', 'fa fa-angle-right ', '2.4.13', '2.*', '1', (SELECT `id` FROM `zz_modules` t WHERE t.`name` = 'Anagrafiche'), '1', '1'); - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `default`, `visible`, `format`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Relazioni'), 'id', 'an_relazioni.id', 1, 0, 0, 1, 0, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Relazioni'), 'Descrizione', 'an_relazioni.descrizione', 2, 1, 0, 1, 1, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Relazioni'), 'Colore', 'an_relazioni.colore', 3, 1, 0, 1, 1, 0); - --- Ripristino modulo pianificazione fatturazione -INSERT INTO `zz_plugins` (`id`, `name`, `title`, `idmodule_from`, `idmodule_to`, `position`, `script`, `enabled`, `default`, `order`, `compatibility`, `version`, `options2`, `options`, `directory`, `help`) VALUES -(NULL, 'Pianificazione fatturazione', 'Pianificazione fatturazione', (SELECT `id` FROM `zz_modules` WHERE `name` = 'Contratti'), (SELECT `id` FROM `zz_modules` WHERE `name` = 'Contratti'), 'tab', 'contratti.fatturaordiniservizio.php', 1, 0, 0, '', '', NULL, NULL, '', ''); - --- Aggiunta campo note nello scadenzario -- -ALTER TABLE `co_scadenziario` ADD `note` VARCHAR(255) DEFAULT NULL AFTER `data_pagamento`; - --- Aggiunta note in vista scadenzario -- -INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `visible`, `summable`, `default`) VALUES (NULL, (SELECT `zz_modules`.`id` FROM `zz_modules` WHERE `zz_modules`.`name`='Scadenzario' ), 'Note', 'co_scadenziario.note', '5', '1', '0', '0', '', '', '0', '0', '0'); - -UPDATE `zz_settings` SET `nome` = 'Ora inizio sul calendario' WHERE `zz_settings`.`nome` = 'Inizio orario lavorativo'; -UPDATE `zz_settings` SET `nome` = 'Ora fine sul calendario' WHERE `zz_settings`.`nome` = 'Fine orario lavorativo'; -UPDATE `zz_settings` SET `nome` = 'Formato codice attività' WHERE `zz_settings`.`nome` = 'Formato codice intervento'; - --- Inizio orario lavorativo -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `help`) VALUES (NULL, 'Inizio orario lavorativo', '08:00:00', 'time', '1', 'Interventi', 'Inizio dell''orario lavorativo standard.'); - --- Fine orario lavorativo -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `help`) VALUES (NULL, 'Fine orario lavorativo', '18:00:00', 'time', '1', 'Interventi', 'Fine dell''orario lavorativo standard.'); - --- Giorni lavorativi -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`,`help`) VALUES (NULL, 'Giorni lavorativi', 'Lunedì,Martedì,Mercoledì,Giovedì,Venerdì', 'multiple[Lunedì,Martedì,Mercoledì,Giovedì,Venerdì,Sabato,Domenica]', '1', 'Interventi', ''); - -ALTER TABLE `zz_settings` CHANGE `help` `help` TEXT; - -UPDATE `zz_settings` SET `help` = '

    Impostare la maschera senza indicare l''anno per evitare il reset del contatore.

    • ####: Numero progressivo del documento, con zeri non significativi per raggiungere il numero desiderato di caratteri
    • YYYY: Anno corrente a 4 cifre
    • yy: Anno corrente a 2 cifre
    ' WHERE `zz_settings`.`nome` = 'Formato codice preventivi'; - --- Fix nome hook Aggiornamenti -UPDATE `zz_hooks` SET `name` = 'Aggiornamenti' WHERE `class` = 'Modules\\Aggiornamenti\\UpdateHook'; - --- Colonne aggiuntive articoli -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `mg_articoli` LEFT OUTER JOIN an_anagrafiche ON mg_articoli.id_fornitore=an_anagrafiche.idanagrafica LEFT OUTER JOIN co_iva ON mg_articoli.idiva_vendita=co_iva.id LEFT OUTER JOIN (SELECT SUM(qta-qta_evasa) AS qta_impegnata, idarticolo FROM or_righe_ordini INNER JOIN or_ordini ON or_righe_ordini.idordine=or_ordini.id WHERE idstatoordine IN(SELECT id FROM or_statiordine WHERE completato=0) GROUP BY idarticolo) a ON a.idarticolo=mg_articoli.id WHERE 1=1 AND (`mg_articoli`.`deleted_at`) IS NULL HAVING 2=2 ORDER BY `descrizione`' WHERE `zz_modules`.`name` = 'Articoli'; - -UPDATE `zz_views` SET `query` = 'mg_articoli.codice' WHERE `zz_views`.`name` = 'Codice' AND `zz_views`.`id_module` = (SELECT id FROM zz_modules WHERE `name`='Articoli'); -UPDATE `zz_views` SET `query` = 'mg_articoli.id' WHERE `zz_views`.`name` = 'id' AND `zz_views`.`id_module` = (SELECT id FROM zz_modules WHERE `name`='Articoli'); -UPDATE `zz_views` SET `query` = 'mg_articoli.descrizione' WHERE `zz_views`.`name` = 'Descrizione' AND `zz_views`.`id_module` = (SELECT id FROM zz_modules WHERE `name`='Articoli'); - -INSERT INTO `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`='Articoli'), 'Prezzo vendita ivato', 'IF( co_iva.percentuale IS NOT NULL, (mg_articoli.prezzo_vendita + mg_articoli.prezzo_vendita * co_iva.percentuale / 100), mg_articoli.prezzo_vendita + mg_articoli.prezzo_vendita*(SELECT co_iva.percentuale FROM co_iva INNER JOIN zz_settings ON co_iva.id=zz_settings.valore AND nome=\'Iva predefinita\')/100 )', 8, 1, 0, 1, '', '', 0, 0, 1), -(NULL, (SELECT id FROM zz_modules WHERE `name`='Articoli'), 'Q.tà impegnata', 'IFNULL(a.qta_impegnata, 0)', 10, 1, 0, 1, '', '', 0, 0, 1), -(NULL, (SELECT id FROM zz_modules WHERE `name`='Articoli'), 'Q.tà disponibile', 'qta-IFNULL(a.qta_impegnata, 0)', 11, 1, 0, 1, '', '', 0, 0, 1); - -UPDATE `zz_views` SET `order` = '9' WHERE `zz_views`.`name` = 'Q.tà' AND `zz_views`.`id_module` = (SELECT id FROM zz_modules WHERE `name`='Articoli'); - -UPDATE `zz_views` SET `visible` = '1' WHERE `zz_views`.`name` = 'Fornitore' AND `zz_views`.`id_module` = (SELECT id FROM zz_modules WHERE `name`='Articoli'); -UPDATE `zz_views` SET `visible` = '1' WHERE `zz_views`.`name` = 'Prezzo di acquisto' AND `zz_views`.`id_module` = (SELECT id FROM zz_modules WHERE `name`='Articoli'); -UPDATE `zz_views` SET `visible` = '1' WHERE `zz_views`.`name` = 'Prezzo di vendita' AND `zz_views`.`id_module` = (SELECT id FROM zz_modules WHERE `name`='Articoli'); - -INSERT INTO `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`='Articoli'), 'Barcode', 'mg_articoli.barcode', '2', '1', '0', '0', '', '', '1', '0', '1'); - --- Aggiunto help per maschera codice attività -UPDATE `zz_settings` SET `help` = '

    Impostare la maschera senza indicare l''anno per evitare il reset del contatore.

    • ####: Numero progressivo dell''attività, con zeri non significativi per raggiungere il numero desiderato di caratteri
    • YYYY: Anno corrente a 4 cifre
    • yy: Anno corrente a 2 cifre
    ' WHERE `zz_settings`.`nome` = 'Formato codice attività'; - --- Rimosso stato completato dallo stato ordine Parzialmente evaso -UPDATE `or_statiordine` SET `completato` = '0' WHERE `or_statiordine`.`descrizione` = 'Parzialmente evaso'; - --- Fatture di vendita perfezionato campo totale -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_documenti` - INNER JOIN `an_anagrafiche` ON `co_documenti`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - INNER JOIN `co_tipidocumento` ON `co_documenti`.`idtipodocumento` = `co_tipidocumento`.`id` - INNER JOIN `co_statidocumento` ON `co_documenti`.`idstatodocumento` = `co_statidocumento`.`id` - LEFT JOIN `fe_stati_documento` ON `co_documenti`.`codice_stato_fe` = `fe_stati_documento`.`codice` - LEFT OUTER JOIN ( - SELECT `iddocumento`, SUM(`subtotale` - `sconto`) AS `imponibile`, - SUM(`subtotale` - `sconto` + `iva` ) AS `totale` - FROM `co_righe_documenti` - GROUP BY `iddocumento` - ) AS righe ON `co_documenti`.`id` = `righe`.`iddocumento` - LEFT JOIN ( - SELECT `numero_esterno`, `id_segment` - FROM `co_documenti` - WHERE `co_documenti`.`idtipodocumento` IN(SELECT `id` FROM `co_tipidocumento` WHERE `dir` = ''entrata'') |date_period(`co_documenti`.`data`)| AND `numero_esterno` != '''' - GROUP BY `id_segment`, `numero_esterno` - HAVING COUNT(`numero_esterno`) > 1 - ) dup ON `co_documenti`.`numero_esterno` = `dup`.`numero_esterno` AND `dup`.`id_segment` = `co_documenti`.`id_segment` - LEFT OUTER JOIN ( - SELECT `zz_operations`.`id_email`, `zz_operations`.`id_record` - FROM `zz_operations` - INNER JOIN `em_emails` ON `zz_operations`.`id_email` = `em_emails`.`id` - INNER JOIN `em_templates` ON `em_emails`.`id_template` = `em_templates`.`id` - INNER JOIN `zz_modules` ON `zz_operations`.`id_module` = `zz_modules`.`id` - WHERE `zz_modules`.`name` = ''Fatture di vendita'' AND `zz_operations`.`op` = ''send-email'' - GROUP BY `zz_operations`.`id_record` - ) AS `email` ON `email`.`id_record` = `co_documenti`.`id` -WHERE 1=1 AND `dir` = ''entrata'' |segment(`co_documenti`.`id_segment`)| |date_period(`co_documenti`.`data`)| -HAVING 2=2 -ORDER BY `co_documenti`.`data` DESC, CAST(`co_documenti`.`numero_esterno` AS UNSIGNED) DESC' WHERE `name` = 'Fatture di vendita'; - -INSERT INTO `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`='Fatture di vendita'), 'Imponibile', 'righe.imponibile', '5', '1', '0', '1', '', '', '1', '1', '1'); - -UPDATE `zz_views` SET `order` = '6' WHERE `zz_views`.`id_module` = (SELECT id FROM zz_modules WHERE `name`='Fatture di vendita') AND `zz_views`.`name` = 'Totale'; - --- Fatture di acquisto perfezionato campo totale -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_documenti` - INNER JOIN `an_anagrafiche` ON `co_documenti`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - INNER JOIN `co_tipidocumento` ON `co_documenti`.`idtipodocumento` = `co_tipidocumento`.`id` - INNER JOIN `co_statidocumento` ON `co_documenti`.`idstatodocumento` = `co_statidocumento`.`id` - LEFT OUTER JOIN ( - SELECT `iddocumento`, SUM(`subtotale` - `sconto`) AS `imponibile`, - SUM(`subtotale` - `sconto` + `iva`) AS `totale` - FROM `co_righe_documenti` - GROUP BY `iddocumento` - ) AS righe ON `co_documenti`.`id` = `righe`.`iddocumento` -WHERE 1=1 AND `dir` = ''uscita'' |segment(`co_documenti`.`id_segment`)| |date_period(`co_documenti`.`data`)| -HAVING 2=2 -ORDER BY `co_documenti`.`data` DESC, CAST(IF(`co_documenti`.`numero_esterno` = '''', `co_documenti`.`numero`, `co_documenti`.`numero_esterno`) AS UNSIGNED) DESC' WHERE `name` = 'Fatture di acquisto'; - -INSERT INTO `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`='Fatture di acquisto'), 'Imponibile', 'righe.imponibile', '5', '1', '0', '1', '', '', '1', '1', '1'); - -UPDATE `zz_views` SET `order` = '6' WHERE `zz_views`.`id_module` = (SELECT id FROM zz_modules WHERE `name`='Fatture di acquisto') AND `zz_views`.`name` = 'Totale'; - --- Widget Fatturato fatture di vendita -UPDATE `zz_widgets` SET `query` = 'SELECT CONCAT_WS('' '', REPLACE(REPLACE(REPLACE(FORMAT((SELECT SUM(subtotale-sconto)), 2), '','', ''#''), ''.'', '',''), ''#'', ''.''), ''€'') AS dato FROM (co_righe_documenti INNER JOIN co_documenti ON co_righe_documenti.iddocumento=co_documenti.id) INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE co_tipidocumento.dir=''entrata'' |segment| AND data >= ''|period_start|'' AND data <= ''|period_end|'' AND 1=1' WHERE `zz_widgets`.`name` = 'Fatturato'; - --- Widget Acquisti fatture di acquisto -UPDATE `zz_widgets` SET `query` = 'SELECT CONCAT_WS('' '', REPLACE(REPLACE(REPLACE(FORMAT((SELECT SUM(subtotale-sconto)), 2), '','', ''#''), ''.'', '',''), ''#'', ''.''), ''€'') AS dato FROM (co_righe_documenti INNER JOIN co_documenti ON co_righe_documenti.iddocumento=co_documenti.id) INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE co_tipidocumento.dir=''uscita'' |segment| AND data >= ''|period_start|'' AND data <= ''|period_end|'' AND 1=1' WHERE `zz_widgets`.`name` = 'Acquisti'; - -UPDATE `zz_widgets` SET `help` = 'Crediti iva inclusa accumulati con i clienti durante tutti gli anni di attività.' WHERE `zz_widgets`.`name` = 'Crediti da clienti'; -UPDATE `zz_widgets` SET `help` = 'Debiti iva inclusa accumulati con i fornitori durante tutti gli anni di attività.' WHERE `zz_widgets`.`name` = 'Debiti verso fornitori'; - --- Fix relazione su modulo liste -ALTER TABLE `em_list_anagrafica` DROP FOREIGN KEY `em_list_anagrafica_ibfk_1`; ALTER TABLE `em_list_anagrafica` ADD CONSTRAINT `em_list_anagrafica_ibfk_1` FOREIGN KEY (`id_list`) REFERENCES `em_lists`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT; diff --git a/update/2_4_14.php b/update/2_4_14.php deleted file mode 100755 index 10259507c..000000000 --- a/update/2_4_14.php +++ /dev/null @@ -1,32 +0,0 @@ - $value) { - $files[$key] = realpath(base_dir().'/'.$value); -} - -delete($files); - -// Calcolo nuovo campo "numero_revision" per ciascun preventivo -$preventivi = $dbo->fetchArray('SELECT * FROM co_preventivi ORDER BY id ASC'); - -foreach ($preventivi as $preventivo) { - // Calcolo il numero preventivo in modo sequenziale in base alla creazione - $revisioni = $dbo->fetchArray('SELECT id FROM co_preventivi WHERE master_revision = '.prepare($preventivo['id']).' AND id > '.prepare($preventivo['id']).' ORDER BY id ASC'); - - $numero_revision = 1; - - foreach ($revisioni as $revisione) { - $dbo->query('UPDATE co_preventivi SET numero_revision='.prepare($numero_revision++).' WHERE id='.$revisione['id']); - } -} diff --git a/update/2_4_14.sql b/update/2_4_14.sql deleted file mode 100755 index 0bac2d356..000000000 --- a/update/2_4_14.sql +++ /dev/null @@ -1,625 +0,0 @@ --- Eliminazione impostazione non utilizzata -DELETE FROM `zz_settings` WHERE `zz_settings`.`nome` = 'Modifica Viste di default'; - -UPDATE `zz_settings` SET `sezione` = 'Backup' WHERE `zz_settings`.`nome` = 'Numero di backup da mantenere'; -UPDATE `zz_settings` SET `sezione` = 'Backup' WHERE `zz_settings`.`nome` = 'Backup automatico'; - -UPDATE `zz_settings` SET `sezione` = 'Aggiornamenti' WHERE `zz_settings`.`nome` = 'Attiva aggiornamenti'; -UPDATE `zz_settings` SET `sezione` = 'API' WHERE `zz_settings`.`nome` = 'apilayer API key for VAT number'; -UPDATE `zz_settings` SET `sezione` = 'API' WHERE `zz_settings`.`nome` = 'Google Maps API key'; - --- Abilita la possibilità di ripristinare backup da archivi esterni al gestionale -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `created_at`, `order`, `help`) VALUES (NULL, 'Permetti il ripristino di backup da file esterni', '1', 'boolean', '0', 'Backup', CURRENT_TIMESTAMP, NULL, 'Abilita la possibilità di ripristinare backup da archivi esterni al gestionale.'); - - -UPDATE `zz_settings` SET `help` = 'Esegue automaticamente un backup completo del gestionale al primo accesso della giornata.' WHERE `zz_settings`.`nome` = 'Backup automatico'; - --- Aggiungo come completatato lo stato "Accettato" e "Parzialmente evaso" dell'ordine -UPDATE `or_statiordine` SET `completato` = '1' WHERE `or_statiordine`.`descrizione` = 'Accettato' OR `or_statiordine`.`descrizione` = 'Parzialmente evaso'; - --- Aumento dimensione campo qta -ALTER TABLE `co_righe_preventivi` CHANGE `qta` `qta` decimal(15, 6) NOT NULL; -ALTER TABLE `co_righe_contratti` CHANGE `qta` `qta` decimal(15, 6) NOT NULL; -ALTER TABLE `co_righe_documenti` CHANGE `qta` `qta` decimal(15, 6) NOT NULL; -ALTER TABLE `dt_righe_ddt` CHANGE `qta` `qta` decimal(15, 6) NOT NULL; -ALTER TABLE `mg_articoli` CHANGE `qta` `qta` decimal(15, 6) NOT NULL; -ALTER TABLE `mg_movimenti` CHANGE `qta` `qta` decimal(15, 6) NOT NULL; -ALTER TABLE `or_righe_ordini` CHANGE `qta` `qta` decimal(15, 6) NOT NULL; -ALTER TABLE `or_righe_ordini` CHANGE `qta_evasa` `qta_evasa` decimal(15, 6) NOT NULL; -ALTER TABLE `dt_righe_ddt` CHANGE `qta_evasa` `qta_evasa` decimal(15, 6) NOT NULL; -ALTER TABLE `co_righe_preventivi` CHANGE `qta_evasa` `qta_evasa` decimal(15, 6) NOT NULL; -ALTER TABLE `co_righe_documenti` CHANGE `qta_evasa` `qta_evasa` decimal(15, 6) NOT NULL; -ALTER TABLE `co_righe_contratti` CHANGE `qta_evasa` `qta_evasa` decimal(15, 6) NOT NULL; -ALTER TABLE `mg_articoli` CHANGE `threshold_qta` `threshold_qta` decimal(15, 6) NOT NULL; - -INSERT INTO `zz_prints` (`id`, `id_module`, `is_record`, `name`, `title`, `filename`, `directory`, `previous`, `options`, `icon`, `version`, `compatibility`, `order`, `predefined`, `default`, `enabled`) VALUES -(NULL, (SELECT id FROM zz_modules WHERE `name`='Preventivi'), 1, 'Preventivo (solo totale)', 'Preventivo (solo totale)', 'Preventivo num. {numero} del {data}', 'preventivi', 'idpreventivo', '{\"pricing\":false, \"show_only_total\":true}', 'fa fa-print', '', '', 0, 0, 1, 1); - --- Unificazione righe e articoli interventi -ALTER TABLE `in_righe_interventi` ADD `abilita_serial` boolean NOT NULL DEFAULT '0' AFTER `um`; -ALTER TABLE `in_righe_interventi` ADD `idimpianto` int(11); -ALTER TABLE `in_righe_interventi` ADD `old_id` int(11); - --- Agli articoli utilizzati negli interventi che fanno riferimento ad articoli eliminati assegno l'articolo fittizio DELETED -INSERT INTO `mg_articoli` (`id`, `codice`, `descrizione`, `um`, `abilita_serial`, `immagine`, `note`, `qta`, `threshold_qta`, `ubicazione`, `prezzo_acquisto`, `prezzo_vendita`, `idiva_vendita`, `gg_garanzia`, `peso_lordo`, `volume`, `componente_filename`, `contenuto`, `attivo`, `created_at`, `id_categoria`, `id_sottocategoria`, `servizio`, `idconto_vendita`, `idconto_acquisto`, `deleted_at`, `barcode`, `id_fornitore`) VALUES (NULL, 'DELETED', 'ARTICOLO RIMOSSO', '', '0', NULL, '', '0', '0', '', '0', '0', '0', '0', '0', '0', '', '', '0', CURRENT_TIMESTAMP, 0, NULL, '1', NULL, NULL, NULL, NULL, NULL); - -UPDATE `mg_articoli_interventi` SET `idarticolo` = (SELECT `id` FROM `mg_articoli` WHERE `codice` = 'DELETED' ) WHERE `idarticolo` NOT IN (SELECT `id` FROM `mg_articoli`); - -INSERT INTO `in_righe_interventi` (`old_id`, `idarticolo`, `idintervento`, `is_descrizione`, `is_sconto`, `descrizione`, `prezzo_acquisto`, `prezzo_vendita`, `sconto`, `sconto_unitario`, `tipo_sconto`, `idiva`, `desc_iva`, `iva`, `qta`, `um`, `abilita_serial`, `idimpianto`) SELECT `id`, `idarticolo`, `idintervento`, `is_descrizione`, `is_sconto`, `descrizione`, `prezzo_acquisto`, `prezzo_vendita`, `sconto`, `sconto_unitario`, `tipo_sconto`, `idiva`, `desc_iva`, `iva`, `qta`, `um`, `abilita_serial`, `idimpianto` FROM `mg_articoli_interventi`; - -ALTER TABLE `co_promemoria_righe` ADD `abilita_serial` boolean NOT NULL DEFAULT '0' AFTER `um`, ADD `idimpianto` int(11), ADD `idarticolo` int(11), ADD FOREIGN KEY (`idarticolo`) REFERENCES `mg_articoli`(`id`) ON DELETE SET NULL, CHANGE `um` `um` varchar(25); -ALTER TABLE `co_promemoria_righe` ADD `is_descrizione` TINYINT(1) DEFAULT FALSE NOT NULL, ADD `is_sconto` BOOLEAN DEFAULT FALSE NOT NULL AFTER `is_descrizione`; - -INSERT INTO `co_promemoria_righe` (`idarticolo`, `id_promemoria`, `descrizione`, `prezzo_acquisto`, `prezzo_vendita`, `sconto`, `sconto_unitario`, `tipo_sconto`, `idiva`, `desc_iva`, `iva`, `qta`, `um`, `abilita_serial`, `idimpianto`) SELECT `idarticolo`, `id_promemoria`, `descrizione`, `prezzo_acquisto`, `prezzo_vendita`, `sconto`, `sconto_unitario`, `tipo_sconto`, `idiva`, `desc_iva`, `iva`, `qta`, `um`, `abilita_serial`, `idimpianto` FROM `co_promemoria_articoli`; - -ALTER TABLE `co_righe_documenti` CHANGE `prezzo_unitario_acquisto` `costo_unitario` decimal(15,6) NOT NULL AFTER `qta`, - ADD `prezzo_unitario` decimal(15,6) NOT NULL AFTER `costo_unitario`, - ADD `iva_unitaria` decimal(15,6) NOT NULL AFTER `prezzo_unitario`, - ADD `prezzo_unitario_ivato` decimal(15,6) NOT NULL AFTER `iva_unitaria`, - ADD `sconto_percentuale` decimal(15,6) NOT NULL AFTER `sconto_unitario`, - ADD `sconto_iva_unitario` decimal(15,6) NOT NULL AFTER `sconto_unitario`, - ADD `sconto_unitario_ivato` decimal(15,6) NOT NULL AFTER `sconto_iva_unitario`; -ALTER TABLE `co_righe_preventivi` CHANGE `prezzo_unitario_acquisto` `costo_unitario` decimal(15,6) NOT NULL AFTER `qta`, - ADD `prezzo_unitario` decimal(15,6) NOT NULL AFTER `costo_unitario`, - ADD `iva_unitaria` decimal(15,6) NOT NULL AFTER `prezzo_unitario`, - ADD `prezzo_unitario_ivato` decimal(15,6) NOT NULL AFTER `iva_unitaria`, - ADD `sconto_percentuale` decimal(15,6) NOT NULL AFTER `sconto_unitario`, - ADD `sconto_iva_unitario` decimal(15,6) NOT NULL AFTER `sconto_unitario`, - ADD `sconto_unitario_ivato` decimal(15,6) NOT NULL AFTER `sconto_iva_unitario`; -ALTER TABLE `co_righe_contratti` CHANGE `prezzo_unitario_acquisto` `costo_unitario` decimal(15,6) NOT NULL AFTER `qta`, - ADD `prezzo_unitario` decimal(15,6) NOT NULL AFTER `costo_unitario`, - ADD `iva_unitaria` decimal(15,6) NOT NULL AFTER `prezzo_unitario`, - ADD `prezzo_unitario_ivato` decimal(15,6) NOT NULL AFTER `iva_unitaria`, - ADD `sconto_percentuale` decimal(15,6) NOT NULL AFTER `sconto_unitario`, - ADD `sconto_iva_unitario` decimal(15,6) NOT NULL AFTER `sconto_unitario`, - ADD `sconto_unitario_ivato` decimal(15,6) NOT NULL AFTER `sconto_iva_unitario`; -ALTER TABLE `dt_righe_ddt` CHANGE `prezzo_unitario_acquisto` `costo_unitario` decimal(15,6) NOT NULL AFTER `qta`, - ADD `prezzo_unitario` decimal(15,6) NOT NULL AFTER `costo_unitario`, - ADD `iva_unitaria` decimal(15,6) NOT NULL AFTER `prezzo_unitario`, - ADD `prezzo_unitario_ivato` decimal(15,6) NOT NULL AFTER `iva_unitaria`, - ADD `sconto_percentuale` decimal(15,6) NOT NULL AFTER `sconto_unitario`, - ADD `sconto_iva_unitario` decimal(15,6) NOT NULL AFTER `sconto_unitario`, - ADD `sconto_unitario_ivato` decimal(15,6) NOT NULL AFTER `sconto_iva_unitario`; -ALTER TABLE `or_righe_ordini` CHANGE `prezzo_unitario_acquisto` `costo_unitario` decimal(15,6) NOT NULL AFTER `qta`, - ADD `prezzo_unitario` decimal(15,6) NOT NULL AFTER `costo_unitario`, - ADD `iva_unitaria` decimal(15,6) NOT NULL AFTER `prezzo_unitario`, - ADD `prezzo_unitario_ivato` decimal(15,6) NOT NULL AFTER `iva_unitaria`, - ADD `sconto_percentuale` decimal(15,6) NOT NULL AFTER `sconto_unitario`, - ADD `sconto_iva_unitario` decimal(15,6) NOT NULL AFTER `sconto_percentuale`, - ADD `sconto_unitario_ivato` decimal(15,6) NOT NULL AFTER `sconto_iva_unitario`; -ALTER TABLE `in_righe_interventi` CHANGE `prezzo_acquisto` `costo_unitario` decimal(15,6) NOT NULL AFTER `qta`, - CHANGE `prezzo_vendita` `prezzo_unitario` decimal(15,6) NOT NULL AFTER `costo_unitario`, - ADD `iva_unitaria` decimal(15,6) NOT NULL AFTER `prezzo_unitario`, - ADD `prezzo_unitario_ivato` decimal(15,6) NOT NULL AFTER `iva_unitaria`, - ADD `sconto_percentuale` decimal(15,6) NOT NULL AFTER `sconto_unitario`, - ADD `sconto_iva_unitario` decimal(15,6) NOT NULL AFTER `sconto_unitario`, - ADD `sconto_unitario_ivato` decimal(15,6) NOT NULL AFTER `sconto_iva_unitario`; -ALTER TABLE `co_promemoria_righe` CHANGE `prezzo_acquisto` `costo_unitario` decimal(15,6) NOT NULL AFTER `qta`, - CHANGE `prezzo_vendita` `prezzo_unitario` decimal(15,6) NOT NULL AFTER `costo_unitario`, - ADD `iva_unitaria` decimal(15,6) NOT NULL AFTER `prezzo_unitario`, - ADD `prezzo_unitario_ivato` decimal(15,6) NOT NULL AFTER `iva_unitaria`, - ADD `sconto_percentuale` decimal(15,6) NOT NULL AFTER `sconto_unitario`, - ADD `sconto_iva_unitario` decimal(15,6) NOT NULL AFTER `sconto_unitario`, - ADD `sconto_unitario_ivato` decimal(15,6) NOT NULL AFTER `sconto_iva_unitario`; - -UPDATE `co_righe_documenti` SET `qta` = IF(`qta` = 0, 1, `qta`), - `prezzo_unitario` = `subtotale` / `qta`, - `iva_unitaria` = `iva` / `qta`, - `prezzo_unitario_ivato` = `prezzo_unitario` + `iva`, - `sconto_percentuale` = IF(`tipo_sconto` = 'PRC', `sconto_unitario`, 0), - `sconto_unitario` = IF(`tipo_sconto` = 'PRC', `sconto` / `qta`, `sconto_unitario`), - `sconto_unitario_ivato` = `sconto_unitario`; -UPDATE `co_righe_preventivi` SET `qta` = IF(`qta` = 0, 1, `qta`), - `prezzo_unitario` = `subtotale` / `qta`, - `iva_unitaria` = `iva` / `qta`, - `prezzo_unitario_ivato` = `prezzo_unitario` + `iva_unitaria`, - `sconto_percentuale` = IF(`tipo_sconto` = 'PRC', `sconto_unitario`, 0), - `sconto_unitario` = IF(`tipo_sconto` = 'PRC', `sconto` / `qta`, `sconto_unitario`), - `sconto_unitario_ivato` = `sconto_unitario`; -UPDATE `co_righe_contratti` SET `qta` = IF(`qta` = 0, 1, `qta`), - `prezzo_unitario` = `subtotale` / `qta`, - `iva_unitaria` = `iva` / `qta`, - `prezzo_unitario_ivato` = `prezzo_unitario` + `iva`, - `sconto_percentuale` = IF(`tipo_sconto` = 'PRC', `sconto_unitario`, 0), - `sconto_unitario` = IF(`tipo_sconto` = 'PRC', `sconto` / `qta`, `sconto_unitario`), - `sconto_unitario_ivato` = `sconto_unitario`; -UPDATE `dt_righe_ddt` SET `qta` = IF(`qta` = 0, 1, `qta`), - `prezzo_unitario` = `subtotale` / `qta`, - `iva_unitaria` = `iva` / `qta`, - `prezzo_unitario_ivato` = `prezzo_unitario` + `iva_unitaria`, - `sconto_percentuale` = IF(`tipo_sconto` = 'PRC', `sconto_unitario`, 0), - `sconto_unitario` = IF(`tipo_sconto` = 'PRC', `sconto` / `qta`, `sconto_unitario`), - `sconto_unitario_ivato` = `sconto_unitario`; -UPDATE `or_righe_ordini` SET `qta` = IF(`qta` = 0, 1, `qta`), - `prezzo_unitario` = `subtotale` / `qta`, - `iva_unitaria` = `iva` / `qta`, - `prezzo_unitario_ivato` = `prezzo_unitario` + `iva_unitaria`, - `sconto_percentuale` = IF(`tipo_sconto` = 'PRC', `sconto_unitario`, 0), - `sconto_unitario` = IF(`tipo_sconto` = 'PRC', `sconto` / `qta`, `sconto_unitario`), - `sconto_unitario_ivato` = `sconto_unitario`; -UPDATE `in_righe_interventi` SET `qta` = IF(`qta` = 0, 1, `qta`), - `iva_unitaria` = `iva` / `qta`, - `prezzo_unitario_ivato` = `prezzo_unitario` + `iva_unitaria`, - `sconto_percentuale` = IF(`tipo_sconto` = 'PRC', `sconto_unitario`, 0), - `sconto_unitario` = IF(`tipo_sconto` = 'PRC', `sconto` / `qta`, `sconto_unitario`), - `sconto_unitario_ivato` = `sconto_unitario`; -UPDATE `co_promemoria_righe` SET `qta` = IF(`qta` = 0, 1, `qta`), - `iva_unitaria` = `iva` / `qta`, - `prezzo_unitario_ivato` = `prezzo_unitario` + `iva_unitaria`, - `sconto_percentuale` = IF(`tipo_sconto` = 'PRC', `sconto_unitario`, 0), - `sconto_unitario` = IF(`tipo_sconto` = 'PRC', `sconto` / `qta`, `sconto_unitario`), - `sconto_unitario_ivato` = `sconto_unitario`; - -ALTER TABLE `co_promemoria_righe` RENAME TO `co_righe_promemoria`; - -SET FOREIGN_KEY_CHECKS=0; -DROP TABLE `mg_articoli_interventi`; -DROP TABLE `co_promemoria_articoli`; -SET FOREIGN_KEY_CHECKS=1; - -ALTER TABLE `co_righe_promemoria` ADD `original_id` int(11), ADD `original_type` varchar(255); -ALTER TABLE `in_righe_interventi` ADD `original_id` int(11), ADD `original_type` varchar(255); - --- Aggiunta supporto a prezzi ivati -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `created_at`, `order`, `help`) VALUES (NULL, 'Utilizza prezzi di vendita comprensivi di IVA', '0', 'boolean', '1', 'Fatturazione', CURRENT_TIMESTAMP, NULL, 'Abilita la gestione con importi ivati per i prezzi di vendita.'); - --- Fix plugin "Pianificazione fatturazione" -UPDATE `zz_plugins` SET `options` = 'custom', `script` = '', `directory` = 'pianificazione_fatturazione' WHERE `name` = 'Pianificazione fatturazione'; -DROP TABLE `co_ordiniservizio_vociservizio`; -ALTER TABLE `co_ordiniservizio_pianificazionefatture` RENAME TO `co_fatturazione_contratti`; - -UPDATE `zz_widgets` SET `query` = 'SELECT COUNT(id) AS dato FROM co_fatturazione_contratti WHERE idcontratto IN( SELECT id FROM co_contratti WHERE idstato IN(SELECT id FROM co_staticontratti WHERE descrizione IN("Bozza", "Accettato", "In lavorazione", "In attesa di pagamento")) ) AND co_fatturazione_contratti.iddocumento=0' WHERE `name` = 'Rate contrattuali'; - --- Introduzione segmento scadenzario completo (su periodo temporale) il quale contempla tutte le scadenze (anche quelle chiuse) -INSERT INTO `zz_segments` (`id`, `id_module`, `name`, `clause`, `position`, `pattern`, `note`, `predefined`, `predefined_accredito`, `predefined_addebito`, `is_fiscale`) VALUES -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Scadenzario'), 'Scadenziaro completo', '(`co_scadenziario`.`scadenza` BETWEEN ''|period_start|'' AND ''|period_end|'' )', 'WHR', '####', '', 0, 0, 0, 0); - --- Attiva scrociatoie da tastiera -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES (NULL, 'Attiva scorciatoie da tastiera', '1', 'boolean', '1', 'Generali', NULL, NULL); - --- Correzione conteggi magazzino -- -UPDATE `zz_widgets` SET `query` = 'SELECT CONCAT_WS(\" \", REPLACE(REPLACE(REPLACE(FORMAT(SUM(prezzo_acquisto*qta),2), \",\", \"#\"), \".\", \",\"), \"#\", \".\"), \"€\") AS dato FROM mg_articoli WHERE qta>0 AND deleted_at IS NULL AND servizio=0 AND attivo=1' WHERE `zz_widgets`.`name` = 'Valore magazzino'; -UPDATE `zz_widgets` SET `query` = 'SELECT CONCAT_WS(\" \", REPLACE(REPLACE(REPLACE(FORMAT(SUM(qta),2), \",\", \"#\"), \".\", \",\"), \"#\", \".\"), \"unità\") AS dato FROM mg_articoli WHERE qta>0 AND deleted_at IS NULL AND servizio=0 AND attivo=1' WHERE `zz_widgets`.`name` = 'Articoli in magazzino'; - --- Disattivazione totali prezzi articoli -UPDATE `zz_views` SET `summable` = '0' WHERE `zz_views`.`id_module` = (SELECT `zz_modules`.`id` FROM `zz_modules` WHERE `zz_modules`.`name`='Articoli') AND `zz_views`.`name`='Prezzo di acquisto'; -UPDATE `zz_views` SET `summable` = '0' WHERE `zz_views`.`id_module` = (SELECT `zz_modules`.`id` FROM `zz_modules` WHERE `zz_modules`.`name`='Articoli') AND `zz_views`.`name`='Prezzo di vendita'; -UPDATE `zz_views` SET `summable` = '0' WHERE `zz_views`.`id_module` = (SELECT `zz_modules`.`id` FROM `zz_modules` WHERE `zz_modules`.`name`='Articoli') AND `zz_views`.`name`='Prezzo vendita ivato'; - --- Introduzione modulo Stampe -INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Stampe', 'Stampe', 'stampe', 'SELECT |select| FROM `zz_prints` WHERE 1=1 HAVING 2=2', '', 'fa fa-print', '2.4.14', '2.4.14', '1', (SELECT `id` FROM `zz_modules` t WHERE t.`name` = 'Strumenti'), '1', '0'); - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stampe'), 'Nome del file', 'filename', 3, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stampe'), 'Titolo', 'title', 2, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stampe'), 'id', 'id', 1, 1, 0, 0, 0); - --- Fix widget Attività confermate -UPDATE `zz_widgets` SET `query` = 'SELECT COUNT(id) AS dato FROM in_interventi WHERE in_interventi.idstatointervento = (SELECT in_statiintervento.idstatointervento FROM in_statiintervento WHERE in_statiintervento.codice=''WIP'') ORDER BY in_interventi.data_richiesta ASC' WHERE `name` = 'Attività confermate'; - --- Permetto valore null per id_categoria articoli -ALTER TABLE `mg_articoli` CHANGE `id_categoria` `id_categoria` INT(11) NULL; - --- Correzione totali per le Viste - --- Fatture di vendita -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_documenti` - LEFT JOIN `an_anagrafiche` ON `co_documenti`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - LEFT JOIN `co_tipidocumento` ON `co_documenti`.`idtipodocumento` = `co_tipidocumento`.`id` - LEFT JOIN `co_statidocumento` ON `co_documenti`.`idstatodocumento` = `co_statidocumento`.`id` - LEFT JOIN `fe_stati_documento` ON `co_documenti`.`codice_stato_fe` = `fe_stati_documento`.`codice` - LEFT JOIN ( - SELECT `iddocumento`, - SUM(`subtotale` - `sconto`) AS `totale_imponibile`, - SUM(`subtotale` - `sconto` + `iva`) AS `totale` - FROM `co_righe_documenti` - GROUP BY `iddocumento` - ) AS righe ON `co_documenti`.`id` = `righe`.`iddocumento` - LEFT JOIN ( - SELECT `numero_esterno`, `id_segment` - FROM `co_documenti` - WHERE `co_documenti`.`idtipodocumento` IN(SELECT `id` FROM `co_tipidocumento` WHERE `dir` = ''entrata'') |date_period(`co_documenti`.`data`)| AND `numero_esterno` != '''' - GROUP BY `id_segment`, `numero_esterno` - HAVING COUNT(`numero_esterno`) > 1 - ) dup ON `co_documenti`.`numero_esterno` = `dup`.`numero_esterno` AND `dup`.`id_segment` = `co_documenti`.`id_segment` - LEFT JOIN ( - SELECT `zz_operations`.`id_email`, `zz_operations`.`id_record` - FROM `zz_operations` - INNER JOIN `em_emails` ON `zz_operations`.`id_email` = `em_emails`.`id` - INNER JOIN `em_templates` ON `em_emails`.`id_template` = `em_templates`.`id` - INNER JOIN `zz_modules` ON `zz_operations`.`id_module` = `zz_modules`.`id` - WHERE `zz_modules`.`name` = ''Fatture di vendita'' AND `zz_operations`.`op` = ''send-email'' - GROUP BY `zz_operations`.`id_record` - ) AS `email` ON `email`.`id_record` = `co_documenti`.`id` -WHERE 1=1 AND `dir` = ''entrata'' |segment(`co_documenti`.`id_segment`)| |date_period(`co_documenti`.`data`)| -HAVING 2=2 -ORDER BY `co_documenti`.`data` DESC, CAST(`co_documenti`.`numero_esterno` AS UNSIGNED) DESC' WHERE `name` = 'Fatture di vendita'; - -UPDATE `zz_views` SET `query` = 'righe.totale_imponibile' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita') AND `name` = 'Totale'; -DELETE FROM `zz_views` WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita') AND `name` = 'Imponibile'; -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `format`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'), 'Totale ivato', 'righe.totale', 9, 1, 1, 1, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'), 'Netto a pagare', 'righe.totale + rivalsainps + iva_rivalsainps - ritenutaacconto', 10, 1, 1, 1, 1); - --- Fatture di acquisto -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_documenti` - LEFT JOIN `an_anagrafiche` ON `co_documenti`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - LEFT JOIN `co_tipidocumento` ON `co_documenti`.`idtipodocumento` = `co_tipidocumento`.`id` - LEFT JOIN `co_statidocumento` ON `co_documenti`.`idstatodocumento` = `co_statidocumento`.`id` - LEFT JOIN ( - SELECT `iddocumento`, - SUM(`subtotale` - `sconto`) AS `totale_imponibile`, - SUM(`subtotale` - `sconto` + `iva`) AS `totale` - FROM `co_righe_documenti` - GROUP BY `iddocumento` - ) AS righe ON `co_documenti`.`id` = `righe`.`iddocumento` -WHERE 1=1 AND `dir` = ''uscita'' |segment(`co_documenti`.`id_segment`)| |date_period(`co_documenti`.`data`)| -HAVING 2=2 -ORDER BY `co_documenti`.`data` DESC, CAST(IF(`co_documenti`.`numero_esterno` = '''', `co_documenti`.`numero`, `co_documenti`.`numero_esterno`) AS UNSIGNED) DESC' WHERE `name` = 'Fatture di acquisto'; - -UPDATE `zz_views` SET `query` = 'righe.totale_imponibile' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di acquisto') AND `name` = 'Totale'; -DELETE FROM `zz_views` WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di acquisto') AND `name` = 'Imponibile'; -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `format`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di acquisto'), 'Totale ivato', 'righe.totale', 6, 1, 1, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di acquisto'), 'Netto a pagare', 'righe.totale + rivalsainps + iva_rivalsainps - ritenutaacconto', 7, 1, 1, 1, 1); - --- Contratti -UPDATE `zz_modules` SET `options` = 'SELECT |select| -FROM `co_contratti` - LEFT JOIN `an_anagrafiche` ON `co_contratti`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - LEFT JOIN `co_staticontratti` ON `co_contratti`.`idstato` = `co_staticontratti`.`id` - LEFT JOIN ( - SELECT `idcontratto`, - SUM(`subtotale` - `sconto`) AS `totale_imponibile`, - SUM(`subtotale` - `sconto` + `iva`) AS `totale` - FROM `co_righe_contratti` - GROUP BY `idcontratto` - ) AS righe ON `co_contratti`.`id` = `righe`.`idcontratto` - LEFT JOIN ( - SELECT GROUP_CONCAT(CONCAT(matricola, IF(nome != '''', CONCAT('' - '', nome), '''')) SEPARATOR ''
    '') AS descrizione, my_impianti_contratti.idcontratto - FROM my_impianti - INNER JOIN my_impianti_contratti ON my_impianti.id = my_impianti_contratti.idimpianto - GROUP BY my_impianti_contratti.idcontratto - ) AS impianti ON impianti.idcontratto = co_contratti.id -WHERE 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'')| -HAVING 2=2 -ORDER BY `co_contratti`.`id` DESC' WHERE `name` = 'Contratti'; - -UPDATE `zz_views` SET `query` = 'righe.totale_imponibile' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Contratti') AND `name` = 'Totale'; -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `format`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Contratti'), 'Totale ivato', 'righe.totale', 5, 1, 1, 1, 0); - --- Preventivi -UPDATE `zz_modules` SET `options` = 'SELECT |select| -FROM `co_preventivi` - LEFT JOIN `an_anagrafiche` ON `co_preventivi`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - LEFT JOIN `co_statipreventivi` ON `co_preventivi`.`idstato` = `co_statipreventivi`.`id` - LEFT JOIN ( - SELECT `idpreventivo`, - SUM(`subtotale` - `sconto`) AS `totale_imponibile`, - SUM(`subtotale` - `sconto` + `iva`) AS `totale` - FROM `co_righe_preventivi` - GROUP BY `idpreventivo` - ) AS righe ON `co_preventivi`.`id` = `righe`.`idpreventivo` -WHERE 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 -HAVING 2=2 -ORDER BY `co_preventivi`.`id` DESC' WHERE `name` = 'Preventivi'; - -UPDATE `zz_views` SET `query` = 'righe.totale_imponibile' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi') AND `name` = 'Totale'; -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `format`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi'), 'Totale ivato', 'righe.totale', 5, 1, 1, 1, 0); - --- Ddt di acquisto -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `dt_ddt` - LEFT JOIN `an_anagrafiche` ON `dt_ddt`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - LEFT JOIN `dt_tipiddt` ON `dt_ddt`.`idtipoddt` = `dt_tipiddt`.`id` - LEFT JOIN `dt_causalet` ON `dt_ddt`.`idcausalet` = `dt_causalet`.`id` - LEFT JOIN `dt_spedizione` ON `dt_ddt`.`idspedizione` = `dt_spedizione`.`id` - LEFT JOIN `an_anagrafiche` `vettori` ON `dt_ddt`.`idvettore` = `vettori`.`idanagrafica` - LEFT JOIN `an_sedi` AS sedi ON `dt_ddt`.`idsede_partenza` = sedi.`id` - LEFT JOIN `an_sedi` AS `sedi_destinazione` ON `dt_ddt`.`idsede_destinazione` = `sedi_destinazione`.`id` - LEFT JOIN ( - SELECT `idddt`, - SUM(`subtotale` - `sconto`) AS `totale_imponibile`, - SUM(`subtotale` - `sconto` + `iva`) AS `totale` - FROM `dt_righe_ddt` - GROUP BY `idddt` - ) AS righe ON `dt_ddt`.`id` = `righe`.`idddt` -WHERE 1=1 AND `dir` = ''uscita'' |date_period(`data`)| -HAVING 2=2 -ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC,`dt_ddt`.created_at DESC' WHERE `name` = 'Ddt di acquisto'; - -UPDATE `zz_views` SET `query` = 'righe.totale_imponibile' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ddt di acquisto') AND `name` = 'Totale'; -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `format`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Ddt di acquisto'), 'Totale ivato', 'righe.totale', 9, 1, 1, 1, 0); - --- Ddt di vendita -UPDATE `zz_modules` SET `options` = 'SELECT |select| -FROM `dt_ddt` - LEFT JOIN `an_anagrafiche` ON `dt_ddt`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - LEFT JOIN `dt_tipiddt` ON `dt_ddt`.`idtipoddt` = `dt_tipiddt`.`id` - LEFT JOIN `dt_causalet` ON `dt_ddt`.`idcausalet` = `dt_causalet`.`id` - LEFT JOIN `dt_spedizione` ON `dt_ddt`.`idspedizione` = `dt_spedizione`.`id` - LEFT JOIN `an_anagrafiche` `vettori` ON `dt_ddt`.`idvettore` = `vettori`.`idanagrafica` - LEFT JOIN `an_sedi` AS sedi ON `dt_ddt`.`idsede_partenza` = sedi.`id` - LEFT JOIN `an_sedi` AS `sedi_destinazione` ON `dt_ddt`.`idsede_destinazione` = `sedi_destinazione`.`id` - LEFT JOIN ( - SELECT `idddt`, - SUM(`subtotale` - `sconto`) AS `totale_imponibile`, - SUM(`subtotale` - `sconto` + `iva`) AS `totale` - FROM `dt_righe_ddt` - GROUP BY `idddt` - ) AS righe ON `dt_ddt`.`id` = `righe`.`idddt` -WHERE 1=1 AND `dir` = ''entrata'' |date_period(`data`)| -HAVING 2=2 -ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC,`dt_ddt`.created_at DESC' WHERE `name` = 'Ddt di vendita'; - -UPDATE `zz_views` SET `query` = 'righe.totale_imponibile' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ddt di vendita') AND `name` = 'Totale'; -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `format`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Ddt di vendita'), 'Totale ivato', 'righe.totale', 9, 1, 1, 1, 0); - --- Ordini cliente -UPDATE `zz_modules` SET `options` = 'SELECT |select| -FROM `or_ordini` - LEFT JOIN `an_anagrafiche` ON `or_ordini`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - LEFT JOIN `or_tipiordine` ON `or_ordini`.`idtipoordine` = `or_tipiordine`.`id` - LEFT JOIN ( - SELECT `idordine`, - SUM(`subtotale` - `sconto`) AS `totale_imponibile`, - SUM(`subtotale` - `sconto` + `iva`) AS `totale` - FROM `or_righe_ordini` - GROUP BY `idordine` - ) AS righe ON `or_ordini`.`id` = `righe`.`idordine` -WHERE 1=1 AND `dir` = ''entrata'' |date_period(`data`)| -HAVING 2=2 -ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC' WHERE `name` = 'Ordini cliente'; - -UPDATE `zz_views` SET `query` = 'righe.totale_imponibile' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ordini cliente') AND `name` = 'Totale'; -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `format`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Ordini cliente'), 'Totale ivato', 'righe.totale', 5, 1, 1, 1, 0); - --- Ordini fornitore -UPDATE `zz_modules` SET `options` = 'SELECT |select| -FROM `or_ordini` - LEFT JOIN `an_anagrafiche` ON `or_ordini`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - LEFT JOIN `or_tipiordine` ON `or_ordini`.`idtipoordine` = `or_tipiordine`.`id` - LEFT JOIN ( - SELECT `idordine`, - SUM(`subtotale` - `sconto`) AS `totale_imponibile`, - SUM(`subtotale` - `sconto` + `iva`) AS `totale` - FROM `or_righe_ordini` - GROUP BY `idordine` - ) AS righe ON `or_ordini`.`id` = `righe`.`idordine` -WHERE 1=1 AND `dir` = ''uscita'' |date_period(`data`)| -HAVING 2=2 -ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC' WHERE `name` = 'Ordini fornitore'; - -UPDATE `zz_views` SET `query` = 'righe.totale_imponibile' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ordini fornitore') AND `name` = 'Totale'; -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `format`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Ordini fornitore'), 'Totale ivato', 'righe.totale', 5, 1, 1, 1, 0); - --- Aggiunta gestione dinamica dei movimenti degli Articoli -ALTER TABLE `mg_movimenti` ADD `reference_id` int(11), ADD `reference_type` varchar(255); -UPDATE `mg_movimenti` SET `reference_id` = `iddocumento`, `reference_type` = 'Modules\\Fatture\\Fattura' WHERE `iddocumento` IS NOT NULL AND `iddocumento` != 0; -UPDATE `mg_movimenti` SET `reference_id` = `idintervento`, `reference_type` = 'Modules\\Interventi\\Intervento' WHERE `idintervento` IS NOT NULL AND `idintervento` != 0; -UPDATE `mg_movimenti` SET `reference_id` = `idddt`, `reference_type` = 'Modules\\DDT\\DDT' WHERE `idddt` IS NOT NULL AND `idddt` != 0; - --- Descrizioni movimenti predefinite per l'aggiunta dal modulo Movimenti -CREATE TABLE IF NOT EXISTS `mg_causali_movimenti` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `nome` varchar(255) NOT NULL, - `descrizione` varchar(255) NOT NULL, - `movimento_carico` BOOLEAN DEFAULT TRUE, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - -INSERT INTO `mg_causali_movimenti` (`id`, `nome`, `descrizione`, `movimento_carico`) VALUES -(NULL, 'Carico', 'Carico manuale', '1'), -(NULL, 'Scarico', 'Scarico manuale', '0'); - --- Introduzione modulo Movimenti predefiniti -INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Causali movimenti', 'Causali movimenti', 'causali_movimenti', 'SELECT |select| FROM `mg_causali_movimenti` WHERE 1=1 HAVING 2=2', '', 'fa fa-truck', '2.4.14', '2.4.14', '1', (SELECT `id` FROM `zz_modules` t WHERE t.`name` = 'Tabelle'), '1', '1'); - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Causali movimenti'), 'Movimento di carico', 'IF(movimento_carico, ''Si'', ''No'')', 4, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Causali movimenti'), 'Descrizione', 'descrizione', 3, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Causali movimenti'), 'Nome', 'nome', 2, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Causali movimenti'), 'id', 'id', 1, 1, 0, 0, 0); - --- Miglioramento della cache interna -CREATE TABLE IF NOT EXISTS `zz_cache` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` VARCHAR(255) NOT NULL, - `content` TEXT NOT NULL, - `valid_time` VARCHAR(255), - `expire_at` timestamp NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - -INSERT INTO `zz_cache` (`id`, `name`, `content`, `valid_time`, `expire_at`) VALUES -(NULL, 'Ricevute Elettroniche', '', '1 day', NULL), -(NULL, 'Ricevute Elettroniche importate', '', '1 day', NULL), -(NULL, 'Fatture Elettroniche', '', '1 day', NULL), -(NULL, 'Ultima versione di OpenSTAManager disponibile', '', '7 day', NULL); - -DROP TABLE IF EXISTS `zz_hook_cache`; -ALTER TABLE `zz_hooks` DROP `frequency`; - --- Fix nome hook Aggiornamenti -UPDATE `zz_hooks` SET `name` = 'Aggiornamenti' WHERE `class` = 'Modules\\Aggiornamenti\\UpdateHook'; - --- Aggiunta stampa Barcode -INSERT INTO `zz_prints` (`id_module`, `name`, `title`, `filename`, `directory`, `icon`, `options`, `predefined`, `previous`, `enabled`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Articoli'), 'Barcode', 'Barcode', 'Barcode', 'barcode', 'fa fa-print', '{"width": 54, "height": 20, "format": [64, 55]}', 1, '', 1, 1); - --- Disabilito modulo voci di servizio INUTILIZZATO -UPDATE `zz_modules` SET `enabled` = '0' WHERE `zz_modules`.`name` = 'Voci di servizio'; - -ALTER TABLE `in_statiintervento` CHANGE `completato` `is_completato` TINYINT(1) NOT NULL; - --- Aggiunto flag per stabilire se un intervento è fatturabile -ALTER TABLE `in_statiintervento` ADD `is_fatturabile` TINYINT(1) NOT NULL AFTER `is_completato`; - -UPDATE `in_statiintervento` SET `is_fatturabile` = '1' WHERE `in_statiintervento`.`codice` = 'OK'; - -UPDATE `zz_widgets` SET `query` = 'SELECT COUNT(id) AS dato, - ((SELECT SUM(co_righe_contratti.qta) FROM co_righe_contratti WHERE co_righe_contratti.um=\'ore\' AND co_righe_contratti.idcontratto=co_contratti.id) - IFNULL( (SELECT SUM(in_interventi_tecnici.ore) FROM in_interventi_tecnici INNER JOIN in_interventi ON in_interventi_tecnici.idintervento=in_interventi.id WHERE in_interventi.id_contratto=co_contratti.id AND in_interventi.idstatointervento IN (SELECT in_statiintervento.idstatointervento FROM in_statiintervento WHERE in_statiintervento.is_completato = 1)), 0) ) AS ore_rimanenti, - data_conclusione, ore_preavviso_rinnovo, giorni_preavviso_rinnovo - FROM co_contratti WHERE idstato IN (SELECT id FROM co_staticontratti WHERE is_fatturabile = 1) AND rinnovabile = 1 AND YEAR(data_conclusione) > 1970 AND (SELECT id FROM co_contratti contratti WHERE contratti.idcontratto_prev = co_contratti.id) IS NULL - HAVING (ore_rimanenti < ore_preavviso_rinnovo OR DATEDIFF(data_conclusione, NOW()) < ABS(giorni_preavviso_rinnovo))' WHERE `zz_widgets`.`name` = 'Contratti in scadenza'; - - -UPDATE `zz_widgets` SET `query` = 'SELECT COUNT(id) AS dato FROM in_interventi WHERE id NOT IN (SELECT idintervento FROM in_interventi_tecnici) AND idstatointervento IN (SELECT idstatointervento FROM in_statiintervento WHERE is_completato = 0) ' WHERE `zz_widgets`.`name` = 'Attività da pianificare'; - - --- Lista con indirizzi email validi per ogni anagrafica caricata a sistema -INSERT INTO `em_lists` (`id`, `name`, `description`, `query`, `deleted_at`) VALUES -(NULL, 'Tutte le anagrafiche', 'Indirizzi email validi per ogni anagrafica caricata a sistema', 'SELECT idanagrafica AS id FROM an_anagrafiche WHERE email != \'\'', NULL); - --- Correzioni minori su widget -UPDATE `zz_widgets` SET `more_link` = './modules/interventi/widgets/interventi_da_programmare.php' WHERE `name` = 'Attività nello stato da programmare'; -UPDATE `zz_widgets` SET `more_link` = './modules/interventi/widgets/interventi_da_pianificare.php' WHERE `name` = 'Attività da pianificare'; - --- Cambio formato quantità in vista, per migliorare l'eventuale esportazione csv -UPDATE `zz_views` SET `query` = 'qta', `format` = 1 WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Articoli') AND `name` = 'Q.tà'; - --- Aggiornamento API -INSERT INTO `zz_api_resources` (`id`, `version`, `type`, `resource`, `class`, `enabled`) VALUES -(NULL, 'v1', 'retrieve', 'impianti', 'Modules\\Impianti\\API\\v1\\Impianti', '1'), -(NULL, 'v1', 'retrieve', 'impianti_intervento', 'Modules\\Interventi\\API\\v1\\Impianti', '1'), -(NULL, 'v1', 'create', 'impianti_intervento', 'Modules\\Interventi\\API\\v1\\Impianti', '1'), -(NULL, 'v1', 'retrieve', 'rapportino', 'Modules\\Interventi\\API\\v1\\Rapportino', '1'), -(NULL, 'v1', 'create', 'rapportino', 'Modules\\Interventi\\API\\v1\\Rapportino', '1'); - --- Aggiunta vincolo a pianificazione rate contratti -DELETE FROM `co_fatturazione_contratti` WHERE `idcontratto` NOT IN(SELECT `id` FROM `co_contratti`); -ALTER TABLE `co_fatturazione_contratti` ADD CONSTRAINT `fk_contratti_fatturazione` FOREIGN KEY (`idcontratto`) REFERENCES `co_contratti`(`id`) ON DELETE CASCADE; - --- Aggiunta flag per gestione revisioni per stato -ALTER TABLE `co_statipreventivi` ADD `is_revisionabile` BOOLEAN NOT NULL AFTER `is_pianificabile`; - --- Impostazione flag revisionabile per i preventivi non completati o rifiutati -UPDATE `co_statipreventivi` SET `is_revisionabile` = 1 WHERE `is_completato` = 0 OR `descrizione` = 'Rifiutato'; - --- Spostamento moduli "Stati preventivi" e "Stati contratti" sotto "Tabelle" -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Stati dei preventivi' AND `t2`.`name` = 'Tabelle') SET `t1`.`parent` = `t2`.`id`; -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Stati dei contratti' AND `t2`.`name` = 'Tabelle') SET `t1`.`parent` = `t2`.`id`; - --- Aggiunta campo per salvare il numero di revisione del preventivo -ALTER TABLE `co_preventivi` ADD `numero_revision` INT NOT NULL AFTER `default_revision`; - --- Riordinamento campi Fatture di vendita -UPDATE `zz_views` SET `order` = '11' WHERE `zz_views`.`name` = 'icon_Stato' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'); - --- Aggiornamento stampa inventario -UPDATE `zz_widgets` SET `more_link` = './modules/articoli/widgets/stampa_inventario.php', `more_link_type` = 'popup' WHERE `zz_widgets`.`name` = 'Stampa inventario'; - --- Ottimizzazione query articoli -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `mg_articoli` LEFT OUTER JOIN an_anagrafiche ON mg_articoli.id_fornitore=an_anagrafiche.idanagrafica LEFT OUTER JOIN co_iva ON mg_articoli.idiva_vendita=co_iva.id LEFT OUTER JOIN (SELECT SUM(qta-qta_evasa) AS qta_impegnata, idarticolo FROM or_righe_ordini INNER JOIN or_ordini ON or_righe_ordini.idordine=or_ordini.id WHERE idstatoordine IN(SELECT id FROM or_statiordine WHERE completato=0) GROUP BY idarticolo) a ON a.idarticolo=mg_articoli.id LEFT JOIN mg_categorie ON mg_articoli.id_categoria=mg_categorie.id LEFT JOIN mg_categorie AS sottocategorie ON mg_articoli.id_sottocategoria=sottocategorie.id WHERE 1=1 AND (`mg_articoli`.`deleted_at`) IS NULL HAVING 2=2 ORDER BY `descrizione`' WHERE `zz_modules`.`name` = 'Articoli'; - -UPDATE `zz_views` SET `query` = 'mg_categorie.nome' WHERE `zz_views`.`name` = 'Categoria' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Articoli'); -UPDATE `zz_views` SET `query` = 'sottocategorie.nome' WHERE `zz_views`.`name` = 'Sottocategoria' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Articoli'); -UPDATE `zz_views` SET `query` = 'an_anagrafiche.ragione_sociale' WHERE `zz_views`.`name` = 'Fornitore' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Articoli'); - --- Fix id ambigui modulo articoli -UPDATE `zz_views` SET `query` = 'mg_articoli.id' WHERE `query` = 'id' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Articoli'); -UPDATE `zz_views` SET `query` = 'mg_articoli.codice' WHERE `query` = 'codice' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Articoli'); -UPDATE `zz_views` SET `query` = 'mg_articoli.descrizione' WHERE `query` = 'descrizione' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Articoli'); -UPDATE `zz_views` SET `query` = 'mg_articoli.note' WHERE `query` = 'note' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Articoli'); - --- Ottimizzazione query attività -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM (`in_interventi` INNER JOIN `an_anagrafiche` ON `in_interventi`.`idanagrafica` = `an_anagrafiche`.`idanagrafica`) LEFT JOIN `in_interventi_tecnici` ON `in_interventi_tecnici`.`idintervento` = `in_interventi`.`id` LEFT JOIN `in_statiintervento` ON `in_interventi`.`idstatointervento`=`in_statiintervento`.`idstatointervento` LEFT JOIN (SELECT an_sedi.id, CONCAT(an_sedi.nomesede,\'
    \',an_sedi.telefono,\'
    \',an_sedi.cellulare,\'
    \',an_sedi.citta,\' - \', an_sedi.indirizzo) AS info FROM an_sedi) AS sede_destinazione ON sede_destinazione.id = in_interventi.idsede_destinazione WHERE 1=1 |date_period(`orario_inizio`,`data_richiesta`)| GROUP BY `in_interventi`.`id` HAVING 2=2 ORDER BY IFNULL(`orario_fine`, `data_richiesta`) DESC' WHERE `name` = 'Interventi'; - -UPDATE `zz_views` SET `query` = 'in_statiintervento.descrizione' WHERE `zz_views`.`name` = 'Stato' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'); -UPDATE `zz_views` SET `query` = 'in_interventi.descrizione' WHERE `zz_views`.`name` = 'Descrizione' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'); - --- Aggiunta colonna Rif. sede per attività (se diversa dalla sede legale) -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `format`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), 'Sede', 'sede_destinazione.info', 4, 1, 0, 0, 1); - --- Aggiornamento widget Rate contrattuali -UPDATE `zz_widgets` SET `more_link` = './plugins/pianificazione_fatturazione/widgets/rate_contrattuali.php' WHERE `zz_widgets`.`name` = 'Rate contrattuali'; - --- Aggiornamento widget Promemoria contratti da pianificare -UPDATE `zz_widgets` SET `name` = 'Promemoria contratti da pianificare' WHERE `zz_widgets`.`name` = 'Interventi da pianificare'; -UPDATE `zz_widgets` SET `more_link` = './plugins/pianificazione_interventi/widgets/promemoria_da_pianificare.php' WHERE `zz_widgets`.`name` = 'Promemoria contratti da pianificare'; - --- Rimozione completa co_ordiniservizio -DROP TABLE IF EXISTS `co_ordiniservizio`; -DROP TABLE IF EXISTS `co_ordiniservizio_vociservizio`; -DELETE FROM `zz_widgets` WHERE `name` = 'Ordini di servizio da impostare'; - --- --- Aggiornamento FE in base alla normativa del 28/02/2020 --- -ALTER TABLE `fe_natura` CHANGE `codice` `codice` VARCHAR(5) NOT NULL; - --- Nuove nature IVA -INSERT INTO `fe_natura` (`codice`, `descrizione`) VALUES -('N2.1', 'non soggette ad IVA ai sensi degli artt. Da 7 a 7-septies del DPR 633/72'), -('N2.2', 'non soggette - altri casi'), -('N3.1', 'non imponibili - esportazioni'), -('N3.2', 'non imponibili - cessioni intracomunitarie'), -('N3.3', 'non imponibili - cessioni verso San Marino'), -('N3.4', 'non imponibili - operazioni assimilate alle cessioni all\'esportazione'), -('N3.5', 'non imponibili - a seguito di dichiarazioni d\'intento'), -('N3.6', 'non imponibili - altre operazioni che non concorrono alla formazione del plafond'), -('N6.1', 'inversione contabile - cessione di rottami e altri materiali di recupero'), -('N6.2', 'inversione contabile - cessione di oro e argento pure'), -('N6.3', 'inversione contabile - subappalto nel settore edile'), -('N6.4', 'inversione contabile - cessione di fabbricati'), -('N6.5', 'inversione contabile - cessione di telefoni cellulari'), -('N6.6', 'inversione contabile - cessione di prodotti elettronici'), -('N6.7', 'inversione contabile - prestazioni comparto edile e settori connessi'), -('N6.8', 'inversione contabile - operazioni settore energetico'), -('N6.9', 'inversione contabile - altri casi'); - --- Nuove aliquote di default collegate alle nuove nature IVA -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `esente`, `codice_natura_fe`, `esigibilita`, `default`) VALUES -(NULL, 'Non soggetta ad IVA ai sensi degli artt. Da 7 a 7-septies del DPR 633/72', '0', '1', 'N2.1', 'I', '1'), -(NULL, 'Non soggetta - altri casi', '0', '1', 'N2.2', 'I', '1'), -(NULL, 'Non imponibile - esportazioni', '0', '1', 'N3.1', 'I', '1'), -(NULL, 'Non imponibile - cessioni intracomunitarie', '0', '1', 'N3.2', 'I', '1'), -(NULL, 'Non imponibile - cessioni verso San Marino', '0', '1', 'N3.3', 'I', '1'), -(NULL, 'Non imponibile - operazioni assimilate alle cessioni all\'esportazione', '0', '1', 'N3.4', 'I', '1'), -(NULL, 'Non imponibile - a seguito di dichiarazioni d\'intento', '0', '1', 'N3.5', 'I', '1'), -(NULL, 'Non imponibile - altre operazioni che non concorrono alla formazione del plafond', '0', '1', 'N3.6', 'I', '1'), -(NULL, 'Inversione contabile - cessione di rottami e altri materiali di recupero', '0', '1', 'N6.1', 'I', '1'), -(NULL, 'Inversione contabile - cessione di oro e argento pure', '0', '1', 'N6.2', 'I', '1'), -(NULL, 'Inversione contabile - subappalto nel settore edile', '0', '1', 'N6.3', 'I', '1'), -(NULL, 'Inversione contabile - cessione di fabbricati', '0', '1', 'N6.4', 'I', '1'), -(NULL, 'Inversione contabile - cessione di telefoni cellulari', '0', '1', 'N6.5', 'I', '1'), -(NULL, 'Inversione contabile - cessione di prodotti elettronici', '0', '1', 'N6.6', 'I', '1'), -(NULL, 'Inversione contabile - prestazioni comparto edile e settori connessi', '0', '1', 'N6.7', 'I', '1'), -(NULL, 'Inversione contabile - operazioni settore energetico', '0', '1', 'N6.8', 'I', '1'), -(NULL, 'Inversione contabile - altri casi', '0', '1', 'N6.9', 'I', '1'); - --- Nuovi tipi di documento -INSERT INTO `fe_tipi_documento` (`codice`, `descrizione`) VALUES -('TD16', 'Integrazione fattura reverse charge interno'), -('TD17', 'Integrazione/autofattura per acquisto servizi dall\'estero'), -('TD18', 'Integrazione per acquisto di beni intracomunitari'), -('TD19', 'Integrazione/autofattura per acquisto di beni ex art.17 c.2 DPR 633/72'), -('TD20', 'Autofattura per regolarizzazione e integrazione delle fatture (art.6 c.8 d.lgs. 471/97 o art.46 c.5 D.L. 331/93)'), -('TD21', 'Autofattura per splafonamento'), -('TD22', 'Estrazione beni da deposito IVA'), -('TD23', 'Estrazione beni da deposito IVA con versamento dell\'IVA'), -('TD24', 'Fattura differita di cui all\'art.21, comma 4, lett. a)'), -('TD25', 'Fattura differita di cui all\'art.21, comma 4, terzo periodo lett. b)'), -('TD26', 'Cessione di beni ammortizzabili e per passaggi interni (ex art.36 DPR 633/72)'), -('TD27', 'Fattura per autoconsumo o per cessioni gratuite senza rivalsa'); - -INSERT INTO `co_tipidocumento` (`id`, `descrizione`, `dir`, `reversed`, `codice_tipo_documento_fe`) VALUES -(NULL, 'Integrazione fattura reverse charge interno', 'entrata', '0', 'TD16'), -(NULL, 'Integrazione/autofattura per acquisto servizi dall\'estero', 'entrata', '0', 'TD17'), -(NULL, 'Integrazione per acquisto di beni intracomunitari', 'entrata', '0', 'TD18'), -(NULL, 'Integrazione/autofattura per acquisto di beni ex art.17 c.2 DPR 633/72', 'entrata', '0', 'TD19'), -(NULL, 'Autofattura per regolarizzazione e integrazione delle fatture (art.6 c.8 d.lgs. 471/97 o art.46 c.5 D.L. 331/93)', 'entrata', '0', 'TD20'), -(NULL, 'Autofattura per splafonamento', 'entrata', '0', 'TD21'), -(NULL, 'Estrazione beni da deposito IVA', 'entrata', '0', 'TD22'), -(NULL, 'Estrazione beni da deposito IVA con versamento dell\'IVA', 'entrata', '0', 'TD23'), -(NULL, 'Cessione di beni ammortizzabili e per passaggi interni (ex art.36 DPR 633/72)', 'entrata', '0', 'TD26'), -(NULL, 'Fattura per autoconsumo o per cessioni gratuite senza rivalsa', 'entrata', '0', 'TD27'); - --- Aggiornamento tipo documento FE per fatture differite -UPDATE `co_tipidocumento` SET `codice_tipo_documento_fe` = 'TD24' WHERE `descrizione` IN('Fattura differita di acquisto', 'Fattura differita di vendita'); diff --git a/update/2_4_15.sql b/update/2_4_15.sql deleted file mode 100644 index 465513f81..000000000 --- a/update/2_4_15.sql +++ /dev/null @@ -1,33 +0,0 @@ --- Aggiunta del campo per permettere la modifica delle Viste di default -INSERT INTO `zz_settings` (`nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES ('Modifica Viste di default', '0', 'boolean', 0, 'Generali'); - --- Retrofix -UPDATE `mg_articoli` SET `id_categoria` = NULL WHERE `codice` = 'DELETED'; - --- Ottimizzazione query attività -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM (`in_interventi` INNER JOIN `an_anagrafiche` ON `in_interventi`.`idanagrafica` = `an_anagrafiche`.`idanagrafica`) LEFT JOIN `in_interventi_tecnici` ON `in_interventi_tecnici`.`idintervento` = `in_interventi`.`id` LEFT JOIN `in_statiintervento` ON `in_interventi`.`idstatointervento`=`in_statiintervento`.`idstatointervento` LEFT JOIN (SELECT an_sedi.id, CONCAT(an_sedi.nomesede,\'
    \',an_sedi.telefono,\'
    \',an_sedi.cellulare,\'
    \',an_sedi.citta,\' - \', an_sedi.indirizzo) AS info FROM an_sedi) AS sede_destinazione ON sede_destinazione.id = in_interventi.idsede_destinazione LEFT JOIN (SELECT co_righe_documenti.idintervento, CONCAT(\'Fatt. \', co_documenti.numero_esterno,\' del \', DATE_FORMAT(co_documenti.data, \'%d/%m/%Y\')) AS info FROM co_documenti INNER JOIN co_righe_documenti ON co_documenti.id = co_righe_documenti.iddocumento) AS fattura ON fattura.idintervento = in_interventi.id WHERE 1=1 |date_period(`orario_inizio`,`data_richiesta`)| GROUP BY `in_interventi`.`id` HAVING 2=2 ORDER BY IFNULL(`orario_fine`, `data_richiesta`) DESC' WHERE `name` = 'Interventi'; - --- Aggiunta colonna Rif. fattura per attività -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `format`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), 'Rif. fattura', 'fattura.info', 17, 1, 0, 0, 1); - --- Aggiunta indice per idintervento in co_righe_documenti -ALTER TABLE `co_righe_documenti` ADD INDEX(`idintervento`); - --- Ore preavviso rinnovo con decimali per frazioni ore -ALTER TABLE `co_contratti` CHANGE `ore_preavviso_rinnovo` `ore_preavviso_rinnovo` DECIMAL(15,6) NULL DEFAULT NULL; - --- Canale aggiornamenti stable/pre-release -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES (NULL, 'Abilita canale pre-release per aggiornamenti', '1', 'boolean', '1', 'Generali', NULL, "Consente di recuperare dal canale di pre-release gli aggiornamenti NON stabili del gestionale."); - --- Per gli articoli con id_categoria e id_sottocategoria a 0 imposto il valore NULL (permesso dalla 2.4.14) -UPDATE `mg_articoli` SET `id_categoria` = NULL WHERE `mg_articoli`.`id_categoria` = 0; -UPDATE `mg_articoli` SET `id_sottocategoria` = NULL WHERE `mg_articoli`.`id_sottocategoria` = 0; - --- Allineamento title stampe -UPDATE `zz_prints` SET `title` = 'Ddt in uscita (senza prezzi)' WHERE `zz_prints`.`name` = 'Ddt di vendita (senza costi)'; -UPDATE `zz_prints` SET `title` = 'Ddt in uscita' WHERE `zz_prints`.`name` = 'Ddt di vendita'; - --- Rimozione stampe ordini di servizio a database -DELETE FROM `zz_prints` WHERE `zz_prints`.`name` = 'Ordine di servizio (senza costi)'; -DELETE FROM `zz_prints` WHERE `zz_prints`.`name` = 'Ordine di servizio'; diff --git a/update/2_4_16.sql b/update/2_4_16.sql deleted file mode 100644 index 0fb33214e..000000000 --- a/update/2_4_16.sql +++ /dev/null @@ -1,164 +0,0 @@ -UPDATE `zz_views` SET `search` = 1 WHERE `zz_views`.`name` = 'Descrizione' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Categorie documenti'); -UPDATE `zz_views` SET `search` = 1 WHERE `zz_views`.`name` IN ('Categoria', 'Nome', 'Data') AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Gestione documentale'); - --- Aggiunta rivalsa inps e relativa iva per il calcolo del totale ivato del documento -UPDATE `zz_views` SET `query` = 'righe.totale + `co_documenti`.`rivalsainps` + `co_documenti`.`iva_rivalsainps`' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita') AND `name` = 'Totale ivato'; - -UPDATE `zz_views` SET `query` = 'righe.totale + `co_documenti`.`rivalsainps` + `co_documenti`.`iva_rivalsainps`' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di acquisto') AND `name` = 'Totale ivato'; - --- Aggiunta campi righe contratti -- -ALTER TABLE `co_righe_contratti` ADD `original_id` INT(11) NULL DEFAULT NULL AFTER `abilita_serial` , ADD `original_type` VARCHAR(255) NULL DEFAULT NULL AFTER `original_id`; - -UPDATE `fe_stati_documento` SET `icon` = 'fa fa-paper-plane-o text-success' WHERE `fe_stati_documento`.`codice` = 'MC'; - -UPDATE `fe_stati_documento` SET `icon` = 'fa fa-check-circle text-warning' WHERE `fe_stati_documento`.`codice` = 'NE'; - --- modifica vista tecnici attività -- -UPDATE `zz_views` SET `query` = 'GROUP_CONCAT(DISTINCT((SELECT DISTINCT(ragione_sociale) FROM an_anagrafiche WHERE idanagrafica = in_interventi_tecnici.idtecnico)))' WHERE `zz_views`.`id_module` = (SELECT `zz_modules`.`id` FROM `zz_modules` WHERE `zz_modules`.`name` = 'Interventi') AND `zz_views`.`name` = 'Tecnici'; - --- fix valore data_ora_trasporto -UPDATE `dt_ddt` SET `data_ora_trasporto` = NULL WHERE `dt_ddt`.`id` = '0000-00-00 00:00:00'; - --- fix widget Contratti in scadenza -UPDATE `zz_widgets` SET `query` = 'SELECT COUNT(dati.id) AS dato FROM(SELECT id, ((SELECT SUM(co_righe_contratti.qta) FROM co_righe_contratti WHERE co_righe_contratti.um=''ore'' AND co_righe_contratti.idcontratto=co_contratti.id) - IFNULL( (SELECT SUM(in_interventi_tecnici.ore) FROM in_interventi_tecnici INNER JOIN in_interventi ON in_interventi_tecnici.idintervento=in_interventi.id WHERE in_interventi.id_contratto=co_contratti.id AND in_interventi.idstatointervento IN (SELECT in_statiintervento.idstatointervento FROM in_statiintervento WHERE in_statiintervento.is_completato = 1)), 0) ) AS ore_rimanenti, DATEDIFF(data_conclusione, NOW()) AS giorni_rimanenti, data_conclusione, ore_preavviso_rinnovo, giorni_preavviso_rinnovo, (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=co_contratti.idanagrafica) AS ragione_sociale FROM co_contratti WHERE idstato IN (SELECT id FROM co_staticontratti WHERE is_fatturabile = 1) AND rinnovabile = 1 AND YEAR(data_conclusione) > 1970 AND (SELECT id FROM co_contratti contratti WHERE contratti.idcontratto_prev = co_contratti.id) IS NULL HAVING (ore_rimanenti < ore_preavviso_rinnovo OR DATEDIFF(data_conclusione, NOW()) < ABS(giorni_preavviso_rinnovo)) ORDER BY giorni_rimanenti ASC, ore_rimanenti ASC) dati' WHERE `zz_widgets`.`name` = 'Contratti in scadenza'; - --- Segmento Attività/Promemoria per attività. -INSERT INTO `zz_segments` (`id`, `id_module`, `name`, `clause`, `position`, `pattern`, `note`, `predefined`, `predefined_accredito`, `predefined_addebito`, `is_fiscale`) VALUES -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), 'Tutti', '1=1', 'WHR', '####', '', 1, 0, 0, 0), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), 'Attività', 'orario_inizio BETWEEN ''|period_start|'' AND ''|period_end|'' OR orario_fine BETWEEN ''|period_start|'' AND ''|period_end|''', 'WHR', '####', '', 0, 0, 0, 0), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), 'Promemoria', '((in_interventi_tecnici.orario_inizio=''0000-00-00 00:00:00'' AND in_interventi_tecnici.orario_fine=''0000-00-00 00:00:00'') OR in_interventi_tecnici.id IS NULL)', 'WHR', '####', '', 0, 0, 0, 0); - --- Aggiunta dei template predefiniti che non possono essere rinominati o eliminati -UPDATE `em_templates` SET `predefined` = '1' WHERE `em_templates`.`name` = 'Notifica intervento'; -UPDATE `em_templates` SET `predefined` = '1' WHERE `em_templates`.`name` = 'Notifica rimozione intervento'; -UPDATE `em_templates` SET `predefined` = '1' WHERE `em_templates`.`name` = 'Reset password'; -UPDATE `em_templates` SET `predefined` = '1' WHERE `em_templates`.`name` = 'Rapportino intervento'; - -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES (NULL, 'Notifica al tecnico l''assegnazione all''attività', '0', 'boolean', '1', 'Interventi', NULL, 'Notifica via email al tecnico le nuove sessioni di lavoro che gli sono state assegnate (l''indirizzo email deve essere specificato nella sua anagrafica)'); - -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES (NULL, 'Notifica al tecnico la rimozione dall''attività', '0', 'boolean', '1', 'Interventi', NULL, 'Notifica via email al tecnico la rimozione dalle sessioni di lavoro che gli erano state assegnate (l''indirizzo email deve essere specificato nella sua anagrafica)'); - -UPDATE `zz_settings` SET `sezione` = 'Fatturazione Elettronica' WHERE `zz_settings`.`nome` = 'Riferimento dei documenti in Fattura Elettronica'; - --- Fix campo iva con prezzi fino a 6 decimali -ALTER TABLE `co_righe_documenti` CHANGE `iva_unitaria` `iva_unitaria` DECIMAL(17,8) NOT NULL; -ALTER TABLE `co_righe_preventivi` CHANGE `iva_unitaria` `iva_unitaria` DECIMAL(17,8) NOT NULL; -ALTER TABLE `co_righe_contratti` CHANGE `iva_unitaria` `iva_unitaria` DECIMAL(17,8) NOT NULL; -ALTER TABLE `dt_righe_ddt` CHANGE `iva_unitaria` `iva_unitaria` DECIMAL(17,8) NOT NULL; -ALTER TABLE `or_righe_ordini` CHANGE `iva_unitaria` `iva_unitaria` DECIMAL(17,8) NOT NULL; -ALTER TABLE `in_righe_interventi` CHANGE `iva_unitaria` `iva_unitaria` DECIMAL(17,8) NOT NULL; - --- Aggiunta stato ordine "Annullato" -INSERT INTO `or_statiordine` (`id`, `descrizione`, `annullato`, `icona`, `completato`) VALUES (NULL, 'Annullato', '0', 'fa fa-thumbs-down text-danger', '1'); - --- Aggiunta dei riferimenti n-n tra righe di documenti diversi -CREATE TABLE IF NOT EXISTS `co_riferimenti_righe` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `source_type` varchar(255) NOT NULL, - `source_id` int(11) NOT NULL, - `target_type` varchar(255) NOT NULL, - `target_id` int(11) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- Aggiunta relazione tra articoli e fornitori -CREATE TABLE IF NOT EXISTS `mg_fornitore_articolo` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_articolo` int(11) NOT NULL, - `id_fornitore` int(11) NOT NULL, - `codice_fornitore` varchar(255) NOT NULL, - `descrizione` varchar(255) NOT NULL, - `prezzo_acquisto` decimal(15, 6) NOT NULL, - `qta_minima` decimal(15, 6) NOT NULL, - `giorni_consegna` int(11) NOT NULL, - `deleted_at` TIMESTAMP NULL DEFAULT NULL, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_articolo`) REFERENCES `mg_articoli`(`id`) ON DELETE CASCADE, - FOREIGN KEY (`id_fornitore`) REFERENCES `an_anagrafiche`(`idanagrafica`) ON DELETE CASCADE -) ENGINE=InnoDB; - -INSERT INTO `zz_plugins` (`id`, `name`, `title`, `idmodule_from`, `idmodule_to`, `position`, `directory`, `options`) VALUES -(NULL, 'Fornitori Articolo', 'Fornitori', (SELECT `id` FROM `zz_modules` WHERE `name`='Articoli'), (SELECT `id` FROM `zz_modules` WHERE `name`='Articoli'), 'tab', 'fornitori_articolo', 'custom'); - -ALTER TABLE `or_righe_ordini` ADD `id_dettaglio_fornitore` int(11) NULL DEFAULT NULL, - ADD FOREIGN KEY (`id_dettaglio_fornitore`) REFERENCES `mg_fornitore_articolo`(`id`) ON DELETE SET NULL; -ALTER TABLE `dt_righe_ddt` ADD `id_dettaglio_fornitore` int(11) NULL DEFAULT NULL, -ADD FOREIGN KEY (`id_dettaglio_fornitore`) REFERENCES `mg_fornitore_articolo`(`id`) ON DELETE SET NULL; -ALTER TABLE `co_righe_preventivi` ADD `id_dettaglio_fornitore` int(11) NULL DEFAULT NULL, - ADD FOREIGN KEY (`id_dettaglio_fornitore`) REFERENCES `mg_fornitore_articolo`(`id`) ON DELETE SET NULL; -ALTER TABLE `co_righe_contratti` ADD `id_dettaglio_fornitore` int(11) NULL DEFAULT NULL, - ADD FOREIGN KEY (`id_dettaglio_fornitore`) REFERENCES `mg_fornitore_articolo`(`id`) ON DELETE SET NULL; -ALTER TABLE `co_righe_documenti` ADD `id_dettaglio_fornitore` int(11) NULL DEFAULT NULL, - ADD FOREIGN KEY (`id_dettaglio_fornitore`) REFERENCES `mg_fornitore_articolo`(`id`) ON DELETE SET NULL; -ALTER TABLE `in_righe_interventi` ADD `id_dettaglio_fornitore` int(11) NULL DEFAULT NULL, - ADD FOREIGN KEY (`id_dettaglio_fornitore`) REFERENCES `mg_fornitore_articolo`(`id`) ON DELETE SET NULL; -ALTER TABLE `co_righe_promemoria` ADD `id_dettaglio_fornitore` int(11) NULL DEFAULT NULL, - ADD FOREIGN KEY (`id_dettaglio_fornitore`) REFERENCES `mg_fornitore_articolo`(`id`) ON DELETE SET NULL; - --- Aggiunta campo prezzo_vendita_ivato per gli Articoli -ALTER TABLE `mg_articoli` ADD `prezzo_vendita_ivato` decimal(15,6) NOT NULL AFTER `prezzo_vendita`; -UPDATE `mg_articoli` SET `prezzo_vendita_ivato` = `prezzo_vendita`; - --- Aggiornamento ID per gli articoli degli Interventi -ALTER TABLE `mg_prodotti` DROP FOREIGN KEY `mg_prodotti_ibfk_4`; -UPDATE `mg_prodotti` SET `mg_prodotti`.`id_riga_intervento` = NULL WHERE `mg_prodotti`.`id_riga_intervento` NOT IN (SELECT `old_id` FROM `in_righe_interventi`); -UPDATE `mg_prodotti` SET `mg_prodotti`.`id_riga_intervento` = (SELECT `id` FROM `in_righe_interventi` WHERE `mg_prodotti`.`id_riga_intervento` = `in_righe_interventi`.`old_id`); -ALTER TABLE `mg_prodotti` ADD FOREIGN KEY (`id_riga_intervento`) REFERENCES `in_righe_interventi`(`id`) ON DELETE CASCADE; - --- Periodi di validità (Contratti e Preventivi) -ALTER TABLE `co_contratti` ADD COLUMN `tipo_validita` ENUM('days', 'months', 'years') NULL DEFAULT NULL AFTER `validita`; -ALTER TABLE `co_preventivi` ADD COLUMN `tipo_validita` ENUM('days', 'months', 'years') NULL DEFAULT NULL AFTER `validita`; - --- Aggiunta campi Peso e Volume in DDT e Fatture accompagnatorie -ALTER TABLE `dt_ddt` ADD COLUMN `peso` decimal(12, 4) AFTER `n_colli`, ADD COLUMN `volume` decimal(12, 4) AFTER `peso`; -ALTER TABLE `co_documenti` ADD COLUMN `peso` decimal(12, 4) AFTER `n_colli`, ADD COLUMN `volume` decimal(12, 4) AFTER `peso`; - --- Aggiunta data di connessione agli account SMTP -ALTER TABLE `em_accounts` ADD `connected_at` TIMESTAMP NULL DEFAULT NULL AFTER `timeout`; -UPDATE `em_accounts` SET `connected_at` = NOW(); - --- Aggiunta del flag is_importabile sulle causali per permettere/bloccare l'importazione dei DDT -ALTER TABLE `dt_causalet` ADD `is_importabile` BOOLEAN DEFAULT TRUE AFTER `descrizione`; - --- Impostazione "Totali delle tabelle ristretti alla selezione" -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES (NULL, 'Totali delle tabelle ristretti alla selezione', '0', 'boolean', '1', 'Generali', 119); - --- Ottimizzazione caricamento lista fatture -ALTER TABLE `co_righe_documenti` ADD INDEX(`iddocumento`); - --- Aggiunta colonna data negli ordini -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `format`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Ordini fornitore'), 'Data', 'or_ordini.data', 3, 1, 0, 0, 1); - --- Plugin storico attività scheda Anagrafiche -INSERT INTO `zz_plugins` (`id`, `name`, `title`, `idmodule_from`, `idmodule_to`, `position`, `script`, `enabled`, `default`, `order`, `compatibility`, `version`, `options2`, `options`, `directory`, `help`) VALUES (NULL, 'Storico attività', 'Storico attività', (SELECT id FROM zz_modules WHERE name = 'Interventi'), (SELECT id FROM zz_modules WHERE name='Anagrafiche'), 'tab', '', '1', '1', '0', '2.*', '0.1', NULL, '{ "main_query": [ { "type": "table", "fields": "Numero, Data inizio, Data fine, Tipo", "query": "SELECT in_interventi.id, in_interventi.codice AS Numero, DATE_FORMAT(MAX(orario_inizio),''%d/%m/%Y'') AS ''Data inizio'', DATE_FORMAT(MAX(orario_fine),''%d/%m/%Y'') AS ''Data fine'', (SELECT descrizione FROM in_tipiintervento WHERE idtipointervento=in_interventi.idtipointervento) AS ''Tipo'', (SELECT `id` FROM `zz_modules` WHERE `name` = ''Interventi'') AS _link_module_, in_interventi.id AS _link_record_ FROM in_interventi LEFT JOIN `in_interventi_tecnici` ON `in_interventi_tecnici`.`idintervento` = `in_interventi`.`id` LEFT JOIN `in_statiintervento` ON `in_interventi`.`idstatointervento`=`in_statiintervento`.`idstatointervento` WHERE 1=1 AND in_interventi.deleted_at IS NULL AND idanagrafica = |id_parent| HAVING 2=2 ORDER BY in_interventi.id DESC"} ]}', '', ''); - --- Fix prezzo_unitario_ivato e sconto_iva_unitario per i documenti -UPDATE `co_righe_contratti` SET `prezzo_unitario_ivato` = `prezzo_unitario` + `iva_unitaria`; -UPDATE `co_righe_documenti` SET `prezzo_unitario_ivato` = `prezzo_unitario` + `iva_unitaria`; - -UPDATE `co_righe_documenti` INNER JOIN `co_iva` ON `co_iva`.`id` = `co_righe_documenti`.`idiva` SET - `sconto_iva_unitario` = (`co_iva`.`percentuale` * `sconto_unitario` / 100), - `sconto_unitario_ivato` = `sconto_unitario` + `sconto_iva_unitario`; -UPDATE `co_righe_preventivi` INNER JOIN `co_iva` ON `co_iva`.`id` = `co_righe_preventivi`.`idiva` SET - `sconto_iva_unitario` = (`co_iva`.`percentuale` * `sconto_unitario` / 100), - `sconto_unitario_ivato` = `sconto_unitario` + `sconto_iva_unitario`; -UPDATE `co_righe_contratti` INNER JOIN `co_iva` ON `co_iva`.`id` = `co_righe_contratti`.`idiva` SET - `sconto_iva_unitario` = (`co_iva`.`percentuale` * `sconto_unitario` / 100), - `sconto_unitario_ivato` = `sconto_unitario` + `sconto_iva_unitario`; -UPDATE `dt_righe_ddt` INNER JOIN `co_iva` ON `co_iva`.`id` = `dt_righe_ddt`.`idiva` SET - `sconto_iva_unitario` = (`co_iva`.`percentuale` * `sconto_unitario` / 100), - `sconto_unitario_ivato` = `sconto_unitario` + `sconto_iva_unitario`; -UPDATE `or_righe_ordini` INNER JOIN `co_iva` ON `co_iva`.`id` = `or_righe_ordini`.`idiva` SET - `sconto_iva_unitario` = (`co_iva`.`percentuale` * `sconto_unitario` / 100), - `sconto_unitario_ivato` = `sconto_unitario` + `sconto_iva_unitario`; -UPDATE `in_righe_interventi` INNER JOIN `co_iva` ON `co_iva`.`id` = `in_righe_interventi`.`idiva` SET - `sconto_iva_unitario` = (`co_iva`.`percentuale` * `sconto_unitario` / 100), - `sconto_unitario_ivato` = `sconto_unitario` + `sconto_iva_unitario`; -UPDATE `co_righe_promemoria` INNER JOIN `co_iva` ON `co_iva`.`id` = `co_righe_promemoria`.`idiva` SET - `sconto_iva_unitario` = (`co_iva`.`percentuale` * `sconto_unitario` / 100), - `sconto_unitario_ivato` = `sconto_unitario` + `sconto_iva_unitario`; - --- Fix namespace classi Stampa e Allegato per API -UPDATE `zz_api_resources` SET `class` = 'API\\Common\\Stampa' WHERE `class` = 'Api\\Common\\Stampa'; -UPDATE `zz_api_resources` SET `class` = 'API\\Common\\Allegato' WHERE `class` = 'Api\\Common\\Allegato'; diff --git a/update/2_4_17.sql b/update/2_4_17.sql deleted file mode 100644 index 975e54c63..000000000 --- a/update/2_4_17.sql +++ /dev/null @@ -1,240 +0,0 @@ --- Aggiunta data competenza nel filtro temporale per le fatture di acquisto -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_documenti` - LEFT JOIN `an_anagrafiche` ON `co_documenti`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - LEFT JOIN `co_tipidocumento` ON `co_documenti`.`idtipodocumento` = `co_tipidocumento`.`id` - LEFT JOIN `co_statidocumento` ON `co_documenti`.`idstatodocumento` = `co_statidocumento`.`id` - LEFT JOIN ( - SELECT `iddocumento`, - SUM(`subtotale` - `sconto`) AS `totale_imponibile`, - SUM(`subtotale` - `sconto` + `iva`) AS `totale` - FROM `co_righe_documenti` - GROUP BY `iddocumento` - ) AS righe ON `co_documenti`.`id` = `righe`.`iddocumento` -WHERE 1=1 AND `dir` = \'uscita\' |segment(`co_documenti`.`id_segment`)||date_period(custom, \'|period_start|\' <= `co_documenti`.`data` AND \'|period_end|\' >= `co_documenti`.`data`, \'|period_start|\' <= `co_documenti`.`data_competenza` AND \'|period_end|\' >= `co_documenti`.`data_competenza` )| -HAVING 2=2 -ORDER BY `co_documenti`.`data` DESC, CAST(IF(`co_documenti`.`numero` = \'\', `co_documenti`.`numero_esterno`, `co_documenti`.`numero`) AS UNSIGNED) DESC' WHERE `name` = 'Fatture di acquisto'; - --- Allineo per i movimenti relativi alle fatture di vendita, la data del movimento con la data del documento -UPDATE `co_movimenti` SET `co_movimenti`.`data` = `co_movimenti`.`data_documento` WHERE `iddocumento` IN (SELECT `co_documenti`.`id` FROM `co_documenti` INNER JOIN `co_tipidocumento` ON `co_documenti`.`idtipodocumento` = `co_tipidocumento`.`id` WHERE `co_tipidocumento`.`dir` = 'entrata' ) AND `primanota` = 0; - --- Allineo per le fatture di vendita, la data_competenza con data emissione del documento -UPDATE `co_documenti` SET `co_documenti`.`data_competenza` = `co_documenti`.`data` WHERE `co_documenti`.`idtipodocumento` IN (SELECT `co_tipidocumento`.`id` FROM `co_tipidocumento` WHERE `co_tipidocumento`.`dir` = 'entrata'); - --- Elimino data_documento per co_documenti -ALTER TABLE `co_movimenti` DROP `data_documento`; - --- Allineamento idarticolo nelle tabelle delle righe -ALTER TABLE `co_righe_documenti` CHANGE `idarticolo` `idarticolo` INT(11) NULL; -UPDATE `co_righe_documenti` SET `idarticolo` = NULL WHERE `idarticolo` = 0; - -ALTER TABLE `co_righe_preventivi` CHANGE `idarticolo` `idarticolo` INT(11) NULL; -UPDATE `co_righe_preventivi` SET `idarticolo` = NULL WHERE `idarticolo` = 0; - -ALTER TABLE `co_righe_contratti` CHANGE `idarticolo` `idarticolo` INT(11) NULL; -UPDATE `co_righe_contratti` SET `idarticolo` = NULL WHERE `idarticolo` = 0; - -ALTER TABLE `dt_righe_ddt` CHANGE `idarticolo` `idarticolo` INT(11) NULL; -UPDATE `dt_righe_ddt` SET `idarticolo` = NULL WHERE `idarticolo` = 0; - -ALTER TABLE `or_righe_ordini` CHANGE `idarticolo` `idarticolo` INT(11) NULL; -UPDATE `or_righe_ordini` SET `idarticolo` = NULL WHERE `idarticolo` = 0; - -ALTER TABLE `or_righe_ordini` CHANGE `idarticolo` `idarticolo` INT(11) NULL; -UPDATE `or_righe_ordini` SET `idarticolo` = NULL WHERE `idarticolo` = 0; - -ALTER TABLE `co_righe_promemoria` CHANGE `idarticolo` `idarticolo` INT(11) NULL; -UPDATE `co_righe_promemoria` SET `idarticolo` = NULL WHERE `idarticolo` = 0; - --- Fix link del plugin "Ddt del cliente" -UPDATE `zz_plugins` SET `options` = '{ "main_query": [ { "type": "table", "fields": "Numero, Data, Descrizione, Qtà", "query": "SELECT dt_ddt.id, IF(dt_tipiddt.dir = \'entrata\', (SELECT `id` FROM `zz_modules` WHERE `name` = \'Ddt di vendita\'), (SELECT `id` FROM `zz_modules` WHERE `name` = \'Ddt di acquisto\')) AS _link_module_, dt_ddt.id AS _link_record_, IF(dt_ddt.numero_esterno = \'\', dt_ddt.numero, dt_ddt.numero_esterno) AS Numero, DATE_FORMAT(dt_ddt.data, \'%d/%m/%Y\') AS Data, dt_righe_ddt.descrizione AS `Descrizione`, REPLACE(REPLACE(REPLACE(FORMAT(dt_righe_ddt.qta, 2), \',\', \'#\'), \'.\', \',\'), \'#\', \'.\') AS `Qtà` FROM dt_ddt LEFT JOIN dt_righe_ddt ON dt_ddt.id=dt_righe_ddt.idddt JOIN dt_tipiddt ON dt_ddt.idtipoddt = dt_tipiddt.id WHERE dt_ddt.idanagrafica=|id_parent| GROUP BY dt_ddt.id HAVING 2=2 ORDER BY dt_ddt.id DESC"} ]}' WHERE `zz_plugins`.`name` = 'Ddt del cliente'; - --- Aggiunta risorse API dedicate all'applicazione -DELETE FROM `zz_api_resources` WHERE `version` = 'app-v1'; -INSERT INTO `zz_api_resources` (`id`, `version`, `type`, `resource`, `class`, `enabled`) VALUES --- Login -(NULL, 'app-v1', 'create', 'login', 'API\\App\\v1\\Login', '1'), --- Clienti -(NULL, 'app-v1', 'retrieve', 'clienti', 'API\\App\\v1\\Clienti', '1'), -(NULL, 'app-v1', 'retrieve', 'clienti-cleanup', 'API\\App\\v1\\Clienti', '1'), -(NULL, 'app-v1', 'retrieve', 'cliente', 'API\\App\\v1\\Clienti', '1'), --- Tecnici -(NULL, 'app-v1', 'retrieve', 'tecnici', 'API\\App\\v1\\Tecnici', '1'), -(NULL, 'app-v1', 'retrieve', 'tecnici-cleanup', 'API\\App\\v1\\Tecnici', '1'), -(NULL, 'app-v1', 'retrieve', 'tecnico', 'API\\App\\v1\\Tecnici', '1'), --- Sedi -(NULL, 'app-v1', 'retrieve', 'sedi', 'API\\App\\v1\\Sedi', '1'), -(NULL, 'app-v1', 'retrieve', 'sedi-cleanup', 'API\\App\\v1\\Sedi', '1'), -(NULL, 'app-v1', 'retrieve', 'sede', 'API\\App\\v1\\Sedi', '1'), --- Referenti -(NULL, 'app-v1', 'retrieve', 'referenti', 'API\\App\\v1\\Referenti', '1'), -(NULL, 'app-v1', 'retrieve', 'referenti-cleanup', 'API\\App\\v1\\Referenti', '1'), -(NULL, 'app-v1', 'retrieve', 'referente', 'API\\App\\v1\\Referenti', '1'), --- Impianti -(NULL, 'app-v1', 'retrieve', 'impianti', 'API\\App\\v1\\Impianti', '1'), -(NULL, 'app-v1', 'retrieve', 'impianti-cleanup', 'API\\App\\v1\\Impianti', '1'), -(NULL, 'app-v1', 'retrieve', 'impianto', 'API\\App\\v1\\Impianti', '1'), --- Stati degli interventi -(NULL, 'app-v1', 'retrieve', 'stati-intervento', 'API\\App\\v1\\StatiIntervento', '1'), -(NULL, 'app-v1', 'retrieve', 'stati-intervento-cleanup', 'API\\App\\v1\\StatiIntervento', '1'), -(NULL, 'app-v1', 'retrieve', 'stato-intervento', 'API\\App\\v1\\StatiIntervento', '1'), --- Tipi degli interventi -(NULL, 'app-v1', 'retrieve', 'tipi-intervento', 'API\\App\\v1\\TipiIntervento', '1'), -(NULL, 'app-v1', 'retrieve', 'tipi-intervento-cleanup', 'API\\App\\v1\\TipiIntervento', '1'), -(NULL, 'app-v1', 'retrieve', 'tipo-intervento', 'API\\App\\v1\\TipiIntervento', '1'), --- Articoli -(NULL, 'app-v1', 'retrieve', 'articoli', 'API\\App\\v1\\Articoli', '1'), -(NULL, 'app-v1', 'retrieve', 'articoli-cleanup', 'API\\App\\v1\\Articoli', '1'), -(NULL, 'app-v1', 'retrieve', 'articolo', 'API\\App\\v1\\Articoli', '1'), --- Interventi -(NULL, 'app-v1', 'retrieve', 'interventi', 'API\\App\\v1\\Interventi', '1'), -(NULL, 'app-v1', 'retrieve', 'interventi-cleanup', 'API\\App\\v1\\Interventi', '1'), -(NULL, 'app-v1', 'retrieve', 'intervento', 'API\\App\\v1\\Interventi', '1'), -(NULL, 'app-v1', 'create', 'intervento', 'API\\App\\v1\\Interventi', '1'), -(NULL, 'app-v1', 'update', 'intervento', 'API\\App\\v1\\Interventi', '1'), -(NULL, 'app-v1', 'delete', 'intervento', 'API\\App\\v1\\Interventi', '1'), --- Sessioni degli interventi -(NULL, 'app-v1', 'retrieve', 'sessioni', 'API\\App\\v1\\SessioniInterventi', '1'), -(NULL, 'app-v1', 'retrieve', 'sessioni-cleanup', 'API\\App\\v1\\SessioniInterventi', '1'), -(NULL, 'app-v1', 'retrieve', 'sessione', 'API\\App\\v1\\SessioniInterventi', '1'), -(NULL, 'app-v1', 'delete', 'sessione', 'API\\App\\v1\\SessioniInterventi', '1'), -(NULL, 'app-v1', 'create', 'sessione', 'API\\App\\v1\\SessioniInterventi', '1'), -(NULL, 'app-v1', 'update', 'sessione', 'API\\App\\v1\\SessioniInterventi', '1'), --- Righe degli interventi -(NULL, 'app-v1', 'retrieve', 'righe-interventi', 'API\\App\\v1\\RigheInterventi', '1'), -(NULL, 'app-v1', 'retrieve', 'righe-interventi-cleanup', 'API\\App\\v1\\RigheInterventi', '1'), -(NULL, 'app-v1', 'retrieve', 'riga-intervento', 'API\\App\\v1\\RigheInterventi', '1'), -(NULL, 'app-v1', 'create', 'riga-intervento', 'API\\App\\v1\\RigheInterventi', '1'), -(NULL, 'app-v1', 'update', 'riga-intervento', 'API\\App\\v1\\RigheInterventi', '1'), -(NULL, 'app-v1', 'delete', 'riga-intervento', 'API\\App\\v1\\RigheInterventi', '1'), --- Aliquote IVA -(NULL, 'app-v1', 'retrieve', 'aliquote-iva', 'API\\App\\v1\\AliquoteIva', '1'), -(NULL, 'app-v1', 'retrieve', 'aliquote-iva-cleanup', 'API\\App\\v1\\AliquoteIva', '1'), -(NULL, 'app-v1', 'retrieve', 'aliquota-iva', 'API\\App\\v1\\AliquoteIva', '1'), --- Impostazioni (non modificabili) -(NULL, 'app-v1', 'retrieve', 'impostazioni', 'API\\App\\v1\\Impostazioni', '1'), -(NULL, 'app-v1', 'retrieve', 'impostazioni-cleanup', 'API\\App\\v1\\Impostazioni', '1'), -(NULL, 'app-v1', 'retrieve', 'impostazione', 'API\\App\\v1\\Impostazioni', '1'), --- Contratti -(NULL, 'app-v1', 'retrieve', 'contratti', 'API\\App\\v1\\Contratti', '1'), -(NULL, 'app-v1', 'retrieve', 'contratti-cleanup', 'API\\App\\v1\\Contratti', '1'), -(NULL, 'app-v1', 'retrieve', 'contratto', 'API\\App\\v1\\Contratti', '1'), --- Preventivi -(NULL, 'app-v1', 'retrieve', 'preventivi', 'API\\App\\v1\\Preventivi', '1'), -(NULL, 'app-v1', 'retrieve', 'preventivi-cleanup', 'API\\App\\v1\\Preventivi', '1'), -(NULL, 'app-v1', 'retrieve', 'preventivo', 'API\\App\\v1\\Preventivi', '1'), --- Tariffe dei tecnici -(NULL, 'app-v1', 'retrieve', 'tariffe-tecnici', 'API\\App\\v1\\TariffeTecnici', '1'), -(NULL, 'app-v1', 'retrieve', 'tariffe-tecnici-cleanup', 'API\\App\\v1\\TariffeTecnici', '1'), -(NULL, 'app-v1', 'retrieve', 'tariffa-tecnico', 'API\\App\\v1\\TariffeTecnici', '1'), --- Tariffe relative ai contratti -(NULL, 'app-v1', 'retrieve', 'tariffe-contratti', 'API\\App\\v1\\TariffeContratti', '1'), -(NULL, 'app-v1', 'retrieve', 'tariffe-contratti-cleanup', 'API\\App\\v1\\TariffeContratti', '1'), -(NULL, 'app-v1', 'retrieve', 'tariffa-contratto', 'API\\App\\v1\\TariffeContratti', '1'), --- Allegati -(NULL, 'app-v1', 'retrieve', 'allegati-interventi', 'API\\App\\v1\\AllegatiInterventi', '1'), -(NULL, 'app-v1', 'retrieve', 'allegati-interventi-cleanup', 'API\\App\\v1\\AllegatiInterventi', '1'), -(NULL, 'app-v1', 'retrieve', 'allegato-intervento', 'API\\App\\v1\\AllegatiInterventi', '1'), -(NULL, 'app-v1', 'create', 'allegato-intervento', 'API\\App\\v1\\AllegatiInterventi', '1'), --- Email di rapportino intervento -(NULL, 'app-v1', 'retrieve', 'email-rapportino', 'API\\App\\v1\\RapportinoIntervento', '1'), -(NULL, 'app-v1', 'create', 'email-rapportino', 'API\\App\\v1\\RapportinoIntervento', '1'); - --- Impostazioni relative all'applicazione -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES -(NULL, 'Google Maps API key per Tecnici', '', 'string', '1', 'Applicazione', 1, ''), -(NULL, 'Mostra prezzi', '1', 'boolean', '1', 'Applicazione', 2, ''), -(NULL, 'Sincronizza solo i Clienti per cui il Tecnico ha lavorato in passato', '1', 'boolean', '1', 'Applicazione', 3, ''), -(NULL, 'Mesi per lo storico delle Attività', '6', 'integer', '1', 'Applicazione', 3, ''); - --- Impostazioni relative gli stati delle Attività -UPDATE `zz_settings` SET `sezione` = 'Attività' WHERE `sezione` = 'Interventi'; -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES -(NULL, 'Stato dell''attività alla chiusura', (SELECT idstatointervento AS id FROM in_statiintervento WHERE codice = 'OK'), 'query=SELECT idstatointervento AS id, descrizione AS text FROM in_statiintervento WHERE is_completato = 1', '1', 'Attività', 1, 'Stato in cui spostare l''attitivà a seguito della chiusura'), -(NULL, 'Stato dell''attività dopo la firma', (SELECT idstatointervento AS id FROM in_statiintervento WHERE codice = 'OK'), 'query=SELECT idstatointervento AS id, descrizione AS text FROM in_statiintervento WHERE is_completato = 1', '1', 'Attività', 2, 'Stato in cui spostare l''attitivà dopo la firma del cliente'); - --- Aggiunta risorsa per il download degli allegati -INSERT INTO `zz_api_resources` (`id`, `version`, `type`, `resource`, `class`, `enabled`) VALUES (NULL, 'v1', 'retrieve', 'allegato', 'API\\Common\\Allegato', '1'); - --- Modifica di MyImpianti in Impianti -UPDATE `zz_modules` SET `name` = 'Impianti', `title` = IF(`title` = 'MyImpianti', 'Impianti', `title`), `directory` = 'impianti' WHERE `zz_modules`.`name` = 'MyImpianti'; - --- Rimozione stato di Interventi "Chiamata" se inutilizzato -DELETE FROM `in_statiintervento` WHERE `codice` = 'CALL' AND `descrizione` = 'Chiamata' AND - NOT EXISTS(SELECT `idstatointervento` FROM `in_interventi` WHERE `in_interventi`.`idstatointervento` = `in_statiintervento`.`idstatointervento`) ; - --- Rimozione aliquote iva non usate -UPDATE `co_iva` SET deleted_at = NOW() WHERE `descrizione` LIKE 'Scorporo%'; - --- Modifica mg_causali_movimenti -ALTER TABLE `mg_causali_movimenti` ADD `tipo_movimento` ENUM('carico', 'scarico', 'spostamento') NOT NULL DEFAULT 'spostamento'; -UPDATE `mg_causali_movimenti` SET `tipo_movimento` = 'carico' WHERE `movimento_carico` = 1; -UPDATE `mg_causali_movimenti` SET `tipo_movimento` = 'scarico' WHERE `movimento_carico` = 0; -ALTER TABLE `mg_causali_movimenti` DROP `movimento_carico`; - -INSERT INTO `mg_causali_movimenti` (`id`, `nome`, `descrizione`, `tipo_movimento`) VALUES -(NULL, 'Spostamento', 'Spostamento manuale', 'spostamento'); - --- Aggiunta tabella in_interventi_tecnici_assegnati per la gestione dei tecnici assegnati alle attività -CREATE TABLE IF NOT EXISTS `in_interventi_tecnici_assegnati` ( - `id_intervento` int(11) NOT NULL, - `id_tecnico` int(11) NOT NULL, - FOREIGN KEY (`id_intervento`) REFERENCES `in_interventi`(`id`) ON DELETE CASCADE, - FOREIGN KEY (`id_tecnico`) REFERENCES `an_anagrafiche`(`idanagrafica`) ON DELETE CASCADE -) ENGINE=InnoDB; - --- Fix contenuti delle date (NULL al posto di 0000-00-00) -ALTER TABLE `mg_movimenti` CHANGE `data` `data` date; -ALTER TABLE `my_impianti` CHANGE `data` `data` date; -ALTER TABLE `an_anagrafiche` CHANGE `data_nascita` `data_nascita` date; -ALTER TABLE `in_interventi` CHANGE `data_richiesta` `data_richiesta` DATETIME; -ALTER TABLE `in_interventi` CHANGE `firma_data` `firma_data` DATETIME; - --- SET sql_mode = ''; -UPDATE `mg_movimenti` SET `data` = NULL WHERE `data` = '0000-00-00' OR `data` = '0000-00-00 00:00:00'; -UPDATE `my_impianti` SET `data` = NULL WHERE `data` = '0000-00-00' OR `data` = '0000-00-00 00:00:00'; -UPDATE `an_anagrafiche` SET `data_nascita` = NULL WHERE `data_nascita` = '0000-00-00' OR `data_nascita` = '0000-00-00 00:00:00'; -UPDATE `in_interventi` SET `data_richiesta` = NULL WHERE `data_richiesta` = '0000-00-00' OR `data_richiesta` = '0000-00-00 00:00:00'; -UPDATE `in_interventi` SET `firma_data` = NULL WHERE `firma_data` = '0000-00-00' OR `firma_data` = '0000-00-00 00:00:00'; -UPDATE `updates` SET `id` = NULL WHERE `id` = '0000-00-00' OR `id` = '0000-00-00 00:00:00'; -UPDATE `in_interventi_tecnici` SET `orario_fine` = NULL WHERE `orario_fine` = '0000-00-00' OR `orario_fine` = '0000-00-00 00:00:00'; -UPDATE `in_interventi_tecnici` SET `orario_inizio` = NULL WHERE `orario_inizio` = '0000-00-00' OR `orario_inizio` = '0000-00-00 00:00:00'; -UPDATE `or_ordini` SET `data` = NULL WHERE `data` = '0000-00-00' OR `data` = '0000-00-00 00:00:00'; -UPDATE `co_documenti` SET `data` = NULL WHERE `data` = '0000-00-00' OR `data` = '0000-00-00 00:00:00'; -UPDATE `do_documenti` SET `data` = NULL WHERE `data` = '0000-00-00' OR `data` = '0000-00-00 00:00:00'; -UPDATE `co_movimenti` SET `data` = NULL WHERE `data` = '0000-00-00' OR `data` = '0000-00-00 00:00:00'; -UPDATE `my_impianto_componenti` SET `data` = NULL WHERE `data` = '0000-00-00' OR `data` = '0000-00-00 00:00:00'; -UPDATE `dt_ddt` SET `data` = NULL WHERE `data` = '0000-00-00' OR `data` = '0000-00-00 00:00:00'; -UPDATE `co_preventivi` SET `data_accettazione` = NULL WHERE `data_accettazione` = '0000-00-00' OR `data_accettazione` = '0000-00-00 00:00:00'; -UPDATE `co_contratti` SET `data_accettazione` = NULL WHERE `data_accettazione` = '0000-00-00' OR `data_accettazione` = '0000-00-00 00:00:00'; -UPDATE `co_contratti` SET `data_bozza` = NULL WHERE `data_bozza` = '0000-00-00' OR `data_bozza` = '0000-00-00 00:00:00'; -UPDATE `co_preventivi` SET `data_bozza` = NULL WHERE `data_bozza` = '0000-00-00' OR `data_bozza` = '0000-00-00 00:00:00'; -UPDATE `co_preventivi` SET `data_conclusione` = NULL WHERE `data_conclusione` = '0000-00-00' OR `data_conclusione` = '0000-00-00 00:00:00'; -UPDATE `co_contratti` SET `data_conclusione` = NULL WHERE `data_conclusione` = '0000-00-00' OR `data_conclusione` = '0000-00-00 00:00:00'; -UPDATE `co_scadenziario` SET `data_emissione` = NULL WHERE `data_emissione` = '0000-00-00' OR `data_emissione` = '0000-00-00 00:00:00'; -UPDATE `or_righe_ordini` SET `data_evasione` = NULL WHERE `data_evasione` = '0000-00-00' OR `data_evasione` = '0000-00-00 00:00:00'; -UPDATE `in_interventi` SET `data_invio` = NULL WHERE `data_invio` = '0000-00-00' OR `data_invio` = '0000-00-00 00:00:00'; -UPDATE `co_preventivi` SET `data_pagamento` = NULL WHERE `data_pagamento` = '0000-00-00' OR `data_pagamento` = '0000-00-00 00:00:00'; -UPDATE `co_scadenziario` SET `data_pagamento` = NULL WHERE `data_pagamento` = '0000-00-00' OR `data_pagamento` = '0000-00-00 00:00:00'; -UPDATE `co_promemoria` SET `data_richiesta` = NULL WHERE `data_richiesta` = '0000-00-00' OR `data_richiesta` = '0000-00-00 00:00:00'; -UPDATE `co_preventivi` SET `data_rifiuto` = NULL WHERE `data_rifiuto` = '0000-00-00' OR `data_rifiuto` = '0000-00-00 00:00:00'; -UPDATE `co_contratti` SET `data_rifiuto` = NULL WHERE `data_rifiuto` = '0000-00-00' OR `data_rifiuto` = '0000-00-00 00:00:00'; -UPDATE `my_impianto_componenti` SET `data_sostituzione` = NULL WHERE `data_sostituzione` = '0000-00-00' OR `data_sostituzione` = '0000-00-00 00:00:00'; - --- Impostazioni per i tecnici assegnati delle Attività -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES -(NULL, 'Mostra promemoria attività ai soli Tecnici assegnati', '1', 'boolean', '1', 'Attività', 14), -(NULL, 'Espandi automaticamente la sezione "Dettagli aggiuntivi"', '0', 'boolean', '1', 'Attività', 15); - --- Modifica per introdurre il totale reddito per i Movimenti, sulla base del Conto relativo -ALTER TABLE `co_movimenti` ADD `totale_reddito` decimal(12, 6) NOT NULL DEFAULT 0; -ALTER TABLE `co_pianodeiconti3` ADD `percentuale_deducibile` decimal(5,2) NOT NULL DEFAULT 0; -UPDATE `co_movimenti` SET `totale_reddito` = `totale`; -UPDATE `co_pianodeiconti3` SET `percentuale_deducibile` = 100; - --- Evita di caricare impostazioni doppie --- Disabilitato per problemi con versioni di MySQL < 5.7 --- ALTER TABLE `zz_settings` ADD UNIQUE(`nome`); - --- Evita di caricare username doppi --- Disabilitato per problemi con versioni di MySQL < 5.7 --- ALTER TABLE `zz_users` ADD UNIQUE(`username`); diff --git a/update/2_4_17_1.php b/update/2_4_17_1.php deleted file mode 100644 index 53c473877..000000000 --- a/update/2_4_17_1.php +++ /dev/null @@ -1,6 +0,0 @@ - $value) { - $files[$key] = realpath(base_dir().'/'.$value); -} - -delete($files); - -/* Porting modifica UNIQUE con riduzione dei campi per versioni di MySQL < 5.7 */ -// Riduzione lunghezza campo nome zz_settings per problema compatibilità mysql 5.6 con UNIQUE -$impostazioni = $database->fetchArray('SELECT `nome`, COUNT(`nome`) AS numero_duplicati FROM `zz_settings` GROUP BY `nome` HAVING COUNT(`nome`) > 1'); -foreach ($impostazioni as $impostazione) { - $limit = intval($impostazione['numero_duplicati']) - 1; - - $database->query('DELETE FROM `zz_settings` WHERE `nome` = '.prepare($impostazione['nome']).' LIMIT '.$limit); -} - -// Rimozione dell'indice precedente -try { - $database->query('ALTER TABLE `zz_settings` DROP INDEX `nome`'); -} catch (\PDOException $e) { -} -$database->query('ALTER TABLE `zz_settings` CHANGE `nome` `nome` VARCHAR(150) NOT NULL'); -$database->query('ALTER TABLE `zz_settings` ADD UNIQUE(`nome`)'); - -// Riduzione lunghezza campo username zz_users per problema compatibilità mysql 5.6 con UNIQUE -// Rimozione dell'indice precedente -try { - $database->query('ALTER TABLE `zz_users` DROP INDEX `username`'); -} catch (\PDOException $e) { -} -$database->query('ALTER TABLE `zz_users` CHANGE `username` `username` VARCHAR(150) NOT NULL'); -$database->query('ALTER TABLE `zz_users` ADD UNIQUE(`username`)'); diff --git a/update/2_4_18.sql b/update/2_4_18.sql deleted file mode 100644 index 679f92c3c..000000000 --- a/update/2_4_18.sql +++ /dev/null @@ -1,330 +0,0 @@ --- Miglioramento della cache interna -CREATE TABLE IF NOT EXISTS `zz_tasks` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` VARCHAR(255) NOT NULL, - `class` TEXT NOT NULL, - `expression` VARCHAR(255) NOT NULL, - `next_execution_at` timestamp NULL, - `last_executed_at` timestamp NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - -CREATE TABLE IF NOT EXISTS `zz_tasks_logs` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_task` int(11), - `level` VARCHAR(255) NOT NULL, - `message` TEXT NOT NULL, - `context` TEXT NOT NULL, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_task`) REFERENCES `zz_tasks`(`id`) -) ENGINE=InnoDB; - -INSERT INTO `zz_cache` (`id`, `name`, `content`, `valid_time`, `expire_at`) VALUES -(NULL, 'Ultima esecuzione del cron', '', '1 month', NULL), -(NULL, 'ID del cron', '', '1 month', NULL), -(NULL, 'Cron in esecuzione', '', '1 month', NULL), -(NULL, 'Disabilita cron', '', '1 month', NULL); - -INSERT INTO `zz_tasks` (`id`, `name`, `class`, `expression`, `last_executed_at`) VALUES -(NULL, 'Backup automatico', 'Modules\\Backups\\BackupTask', '0 1 * * *', NULL), -(NULL, 'Importazione automatica Ricevute FE', 'Plugins\\ReceiptFE\\ReceiptTask', '0 */24 * * *', NULL); - -DELETE FROM `zz_hooks` WHERE `class` = 'Modules\\Backups\\BackupHook'; - --- Modifica dei Listini in Piani di sconto/magg. -UPDATE `zz_modules` SET `title` = 'Piani di sconto/magg.' WHERE `name` = 'Listini'; - --- Aggiunto supporto ai prezzi per Articoli specifici per Anagrafica e range di quantità -CREATE TABLE IF NOT EXISTS `mg_prezzi_articoli` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_articolo` int(11) NOT NULL, - `id_anagrafica` int(11), - `minimo` DECIMAL(15,6), - `massimo` DECIMAL(15,6), - `prezzo_unitario` DECIMAL(15,6) NOT NULL, - `prezzo_unitario_ivato` DECIMAL(15,6) NOT NULL, - `dir` VARCHAR(255) NOT NULL, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_articolo`) REFERENCES `mg_articoli`(`id`), - FOREIGN KEY (`id_anagrafica`) REFERENCES `an_anagrafiche`(`idanagrafica`) -) ENGINE=InnoDB; - -UPDATE `zz_plugins` SET `directory` = 'dettagli_articolo', `name`= 'Dettagli articolo', `title`= 'Dettagli' WHERE `name` = 'Fornitori Articolo'; - --- Modulo Giacenze sedi -INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`, `use_notes`, `use_checklists`) VALUES (NULL, 'Giacenze sedi', 'Giacenze sedi', 'giacenze_sedi', 'SELECT |select| FROM `mg_articoli` - LEFT OUTER JOIN an_anagrafiche ON mg_articoli.id_fornitore = an_anagrafiche.idanagrafica - LEFT OUTER JOIN co_iva ON mg_articoli.idiva_vendita = co_iva.id - LEFT OUTER JOIN ( - SELECT SUM(qta - qta_evasa) AS qta_impegnata, idarticolo FROM or_righe_ordini - INNER JOIN or_ordini ON or_righe_ordini.idordine = or_ordini.id - WHERE idstatoordine IN (SELECT id FROM or_statiordine WHERE completato = 0) - GROUP BY idarticolo - ) ordini ON ordini.idarticolo = mg_articoli.id -WHERE 1=1 AND `mg_articoli`.`deleted_at` IS NULL HAVING 2=2 AND `Q.tà` > 0 ORDER BY `descrizione`', '', 'fa fa-angle-right', '2.4.18', '2.4.18', '5', (SELECT id FROM zz_modules t WHERE t.name = 'Magazzino'), '1', '1', '1', '0'); - -INSERT INTO `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` = 'Giacenze sedi'), '_link_module_', (SELECT `id` FROM `zz_modules` WHERE `name` = 'Articoli'), '1', '1', '0', '0', NULL, NULL, '0', '0', '1'), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Giacenze sedi'), 'id', 'mg_articoli.id', '1', '1', '0', '0', NULL, NULL, '0', '0', '1'), - (NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Giacenze sedi'), 'Codice', 'mg_articoli.codice', '2', '1', '0', '0', NULL, NULL, '1', '0', '1'), - (NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Giacenze sedi'), 'Categoria', '(SELECT `nome` FROM `mg_categorie` WHERE `id` = `id_categoria`)', '4', '1', '0', '0', NULL, NULL, '1', '0', '1'), - (NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Giacenze sedi'), 'Sottocategoria', '(SELECT `nome` FROM `mg_categorie` WHERE `id` = `id_sottocategoria`)', '5', '1', '0', '0', NULL, NULL, '1', '0', '1'), - (NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Giacenze sedi'), 'Q.tà', '(SELECT SUM(IF(mg_movimenti.idsede_azienda = |giacenze_sedi_idsede|, mg_movimenti.qta, IF(mg_movimenti.idsede_controparte = |giacenze_sedi_idsede|, -mg_movimenti.qta, 0))) FROM mg_movimenti LEFT JOIN an_sedi ON an_sedi.id = mg_movimenti.idsede_azienda WHERE mg_movimenti.idarticolo=mg_articoli.id AND idsede_azienda=|giacenze_sedi_idsede| GROUP BY idsede_azienda)', '9', '1', '0', '0', NULL, NULL, '1', '0', '1'), - (NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Giacenze sedi'), 'Descrizione', 'mg_articoli.descrizione', '1', '1', '0', '0', '', '', '1', '0', '1'), - (NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Giacenze sedi'), 'Fornitore', '(SELECT `ragione_sociale` FROM `an_anagrafiche` WHERE `idanagrafica` = `id_fornitore`)', '6', '1', '0', '0', NULL, NULL, '1', '0', '1'), - (NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Giacenze sedi'), 'Prezzo di acquisto', 'prezzo_acquisto', '6', '1', '0', '1', NULL, NULL, '1', '1', '1'), - (NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Giacenze sedi'), 'Prezzo di vendita', 'prezzo_vendita', '6', '1', '0', '1', NULL, NULL, '1', '1', '1'), - (NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Giacenze sedi'), 'Prezzo vendita ivato', 'IF( co_iva.percentuale IS NOT NULL, (mg_articoli.prezzo_vendita + mg_articoli.prezzo_vendita * co_iva.percentuale / 100), mg_articoli.prezzo_vendita + mg_articoli.prezzo_vendita*(SELECT co_iva.percentuale FROM co_iva INNER JOIN zz_settings ON co_iva.id=zz_settings.valore AND nome=''Iva predefinita'')/100 )', '8', '1', '0', '1', '', '', '0', '0', '1'), - (NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Giacenze sedi'), 'Barcode', 'mg_articoli.barcode', '2', '1', '0', '0', '', '', '1', '0', '1'); - --- Aggiunta risorse API dedicate alle task in cron -INSERT INTO `zz_api_resources` (`id`, `version`, `type`, `resource`, `class`, `enabled`) VALUES -(NULL, 'v1', 'retrieve', 'cron-logs', 'API\\Common\\Task', '1'), -(NULL, 'v1', 'create', 'cron-restart', 'API\\Common\\Task', '1'); - --- Fix visualizzazione modulo Causali movimenti -UPDATE `zz_views` SET `query` = 'CONCAT(UCASE(LEFT(tipo_movimento, 1)), SUBSTRING(tipo_movimento, 2))', `name` = 'Tipo' WHERE `zz_views`.`name` = 'Movimento di carico' AND id_module = (SELECT id FROM zz_modules WHERE name = 'Causali movimenti'); - --- Aggiornamento versione API services -UPDATE `zz_settings` SET `valore` = 'v3' WHERE `nome` = 'OSMCloud Services API Version'; - --- Aggiornamento margini stampa barbcode -UPDATE `zz_prints` SET `options` = '{"width": 54, "height": 20, "format": [64, 55], "margins": {"top": 5,"bottom": 0,"left": 0,"right": 0}}' WHERE `zz_prints`.`name` = 'Barcode'; --- Aggiunto collegamento con allegato per impostare la ricevuta principale -ALTER TABLE `co_documenti` ADD `id_ricevuta_principale` INT(11); -UPDATE `co_documenti` SET `co_documenti`.`id_ricevuta_principale` = ( - SELECT `zz_files`.`id` FROM `zz_files` WHERE `zz_files`.`id_module` = ( - SELECT `zz_modules`.`id` FROM `zz_modules` WHERE `zz_modules`.`name` = 'Fatture di vendita' - ) AND `zz_files`.`id_record` = `co_documenti`.`id` - AND `zz_files`.`name` LIKE 'Ricevuta%' - ORDER BY `zz_files`.`created_at` - LIMIT 1 -); - --- Aggiunta riferimenti testuali su descrizione righe per Fatture -UPDATE `co_righe_documenti` - INNER JOIN `co_righe_contratti` ON `co_righe_documenti`.`original_id` = `co_righe_contratti`.`id` - INNER JOIN `co_contratti` ON `co_contratti`.`id` = `co_righe_contratti`.`idcontratto` -SET `co_righe_documenti`.`descrizione` = CONCAT(`co_righe_documenti`.`descrizione`, '\nRif. contratto num. ', `co_contratti`.`numero`, ' del ', DATE_FORMAT(`co_contratti`.`data_bozza`, '%d/%m/%Y')) -WHERE `co_righe_documenti`.`original_type` LIKE '%Contratti%'; -UPDATE `co_righe_documenti` - INNER JOIN `co_righe_preventivi` ON `co_righe_documenti`.`original_id` = `co_righe_preventivi`.`id` - INNER JOIN `co_preventivi` ON `co_preventivi`.`id` = `co_righe_preventivi`.`idpreventivo` -SET `co_righe_documenti`.`descrizione` = CONCAT(`co_righe_documenti`.`descrizione`, '\nRif. preventivo num. ', `co_preventivi`.`numero`, ' del ', DATE_FORMAT(`co_preventivi`.`data_bozza`, '%d/%m/%Y')) -WHERE `co_righe_documenti`.`original_type` LIKE '%Preventivi%'; -UPDATE `co_righe_documenti` - INNER JOIN `or_righe_ordini` ON `co_righe_documenti`.`original_id` = `or_righe_ordini`.`id` - INNER JOIN `or_ordini` ON `or_ordini`.`id` = `or_righe_ordini`.`idordine` - INNER JOIN `or_tipiordine` ON `or_tipiordine`.`id` = `or_ordini`.`idtipoordine` -SET `co_righe_documenti`.`descrizione` = CONCAT(`co_righe_documenti`.`descrizione`, '\nRif. ordine num. ', IF(`or_ordini`.`numero_esterno`!='', `or_ordini`.`numero_esterno`, `or_ordini`.`numero`), ' del ', DATE_FORMAT(`or_ordini`.`data`, '%d/%m/%Y')) -WHERE `co_righe_documenti`.`original_type` LIKE '%Ordini%'; -UPDATE `co_righe_documenti` - INNER JOIN `dt_righe_ddt` ON `co_righe_documenti`.`original_id` = `dt_righe_ddt`.`id` - INNER JOIN `dt_ddt` ON `dt_ddt`.`id` = `dt_righe_ddt`.`idddt` - INNER JOIN `dt_tipiddt` ON `dt_tipiddt`.`id` = `dt_ddt`.`idtipoddt` -SET `co_righe_documenti`.`descrizione` = CONCAT(`co_righe_documenti`.`descrizione`, '\nRif. ', LOWER(`dt_tipiddt`.`descrizione`), ' num. ', `dt_ddt`.`numero`, ' del ', DATE_FORMAT(`dt_ddt`.`data`, '%d/%m/%Y')) -WHERE `co_righe_documenti`.`original_type` LIKE '%DDT%'; -UPDATE `co_righe_documenti` - INNER JOIN `in_righe_interventi` ON `co_righe_documenti`.`original_id` = `in_righe_interventi`.`id` - INNER JOIN `in_interventi` ON `in_interventi`.`id` = `in_righe_interventi`.`idintervento` -SET `co_righe_documenti`.`descrizione` = CONCAT(`co_righe_documenti`.`descrizione`, '\nRif. attività num. ', `in_interventi`.`codice`, ' del ', DATE_FORMAT(`in_interventi`.`data_richiesta`, '%d/%m/%Y')) -WHERE `co_righe_documenti`.`original_type` LIKE '%Interventi%'; - --- Aggiunta riferimenti testuali su descrizione righe per Ordini -UPDATE `or_righe_ordini` - INNER JOIN `co_righe_contratti` ON `or_righe_ordini`.`original_id` = `co_righe_contratti`.`id` - INNER JOIN `co_contratti` ON `co_contratti`.`id` = `co_righe_contratti`.`idcontratto` -SET `or_righe_ordini`.`descrizione` = CONCAT(`or_righe_ordini`.`descrizione`, '\nRif. contratto num. ', `co_contratti`.`numero`, ' del ', DATE_FORMAT(`co_contratti`.`data_bozza`, '%d/%m/%Y')) -WHERE `or_righe_ordini`.`original_type` LIKE '%Contratti%'; -UPDATE `or_righe_ordini` - INNER JOIN `co_righe_preventivi` ON `or_righe_ordini`.`original_id` = `co_righe_preventivi`.`id` - INNER JOIN `co_preventivi` ON `co_preventivi`.`id` = `co_righe_preventivi`.`idpreventivo` -SET `or_righe_ordini`.`descrizione` = CONCAT(`or_righe_ordini`.`descrizione`, '\nRif. preventivo num. ', `co_preventivi`.`numero`, ' del ', DATE_FORMAT(`co_preventivi`.`data_bozza`, '%d/%m/%Y')) -WHERE `or_righe_ordini`.`original_type` LIKE '%Preventivi%'; -UPDATE `or_righe_ordini` - INNER JOIN `dt_righe_ddt` ON `or_righe_ordini`.`original_id` = `dt_righe_ddt`.`id` - INNER JOIN `dt_ddt` ON `dt_ddt`.`id` = `dt_righe_ddt`.`idddt` - INNER JOIN `dt_tipiddt` ON `dt_tipiddt`.`id` = `dt_ddt`.`idtipoddt` -SET `or_righe_ordini`.`descrizione` = CONCAT(`or_righe_ordini`.`descrizione`, '\nRif. ', LOWER(`dt_tipiddt`.`descrizione`), ' num. ', `dt_ddt`.`numero`, ' del ', DATE_FORMAT(`dt_ddt`.`data`, '%d/%m/%Y')) -WHERE `or_righe_ordini`.`original_type` LIKE '%DDT%'; -UPDATE `or_righe_ordini` - INNER JOIN `in_righe_interventi` ON `or_righe_ordini`.`original_id` = `in_righe_interventi`.`id` - INNER JOIN `in_interventi` ON `in_interventi`.`id` = `in_righe_interventi`.`idintervento` -SET `or_righe_ordini`.`descrizione` = CONCAT(`or_righe_ordini`.`descrizione`, '\nRif. attività num. ', `in_interventi`.`codice`, ' del ', DATE_FORMAT(`in_interventi`.`data_richiesta`, '%d/%m/%Y')) -WHERE `or_righe_ordini`.`original_type` LIKE '%Interventi%'; - --- Aggiunta riferimenti testuali su descrizione righe per DDT -UPDATE `dt_righe_ddt` - INNER JOIN `co_righe_contratti` ON `dt_righe_ddt`.`original_id` = `co_righe_contratti`.`id` - INNER JOIN `co_contratti` ON `co_contratti`.`id` = `co_righe_contratti`.`idcontratto` -SET `dt_righe_ddt`.`descrizione` = CONCAT(`dt_righe_ddt`.`descrizione`, '\nRif. contratto num. ', `co_contratti`.`numero`, ' del ', DATE_FORMAT(`co_contratti`.`data_bozza`, '%d/%m/%Y')) -WHERE `dt_righe_ddt`.`original_type` LIKE '%Contratti%'; -UPDATE `dt_righe_ddt` - INNER JOIN `co_righe_preventivi` ON `dt_righe_ddt`.`original_id` = `co_righe_preventivi`.`id` - INNER JOIN `co_preventivi` ON `co_preventivi`.`id` = `co_righe_preventivi`.`idpreventivo` -SET `dt_righe_ddt`.`descrizione` = CONCAT(`dt_righe_ddt`.`descrizione`, '\nRif. preventivo num. ', `co_preventivi`.`numero`, ' del ', DATE_FORMAT(`co_preventivi`.`data_bozza`, '%d/%m/%Y')) -WHERE `dt_righe_ddt`.`original_type` LIKE '%Preventivi%'; -UPDATE `dt_righe_ddt` - INNER JOIN `or_righe_ordini` ON `dt_righe_ddt`.`original_id` = `or_righe_ordini`.`id` - INNER JOIN `or_ordini` ON `or_ordini`.`id` = `or_righe_ordini`.`idordine` - INNER JOIN `or_tipiordine` ON `or_tipiordine`.`id` = `or_ordini`.`idtipoordine` -SET `dt_righe_ddt`.`descrizione` = CONCAT(`dt_righe_ddt`.`descrizione`, '\nRif. ordine num. ', IF(`or_ordini`.`numero_esterno`!='', `or_ordini`.`numero_esterno`, `or_ordini`.`numero`), ' del ', DATE_FORMAT(`or_ordini`.`data`, '%d/%m/%Y')) -WHERE `dt_righe_ddt`.`original_type` LIKE '%Ordini%'; -UPDATE `dt_righe_ddt` - INNER JOIN `in_righe_interventi` ON `dt_righe_ddt`.`original_id` = `in_righe_interventi`.`id` - INNER JOIN `in_interventi` ON `in_interventi`.`id` = `in_righe_interventi`.`idintervento` -SET `dt_righe_ddt`.`descrizione` = CONCAT(`dt_righe_ddt`.`descrizione`, '\nRif. attività num. ', `in_interventi`.`codice`, ' del ', DATE_FORMAT(`in_interventi`.`data_richiesta`, '%d/%m/%Y')) -WHERE `dt_righe_ddt`.`original_type` LIKE '%Interventi%'; - --- Aggiunta campi per i riferimenti in Preventivi -ALTER TABLE `co_righe_preventivi` ADD `original_id` int(11), ADD `original_type` varchar(255); - --- Fix qtà impegnata: aggiunto filtro per ricerca solo su ordini cliente e non tutti gli ordini -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `mg_articoli` LEFT JOIN an_anagrafiche ON mg_articoli.id_fornitore=an_anagrafiche.idanagrafica LEFT JOIN co_iva ON mg_articoli.idiva_vendita=co_iva.id LEFT JOIN (SELECT SUM(qta-qta_evasa) AS qta_impegnata, idarticolo FROM or_righe_ordini INNER JOIN or_ordini ON or_righe_ordini.idordine=or_ordini.id INNER JOIN or_tipiordine ON or_ordini.idtipoordine=or_tipiordine.id WHERE idstatoordine IN(SELECT id FROM or_statiordine WHERE completato=0) AND or_tipiordine.dir=''entrata'' GROUP BY idarticolo) a ON a.idarticolo=mg_articoli.id LEFT JOIN mg_categorie ON mg_articoli.id_categoria=mg_categorie.id LEFT JOIN mg_categorie AS sottocategorie ON mg_articoli.id_sottocategoria=sottocategorie.id WHERE 1=1 AND (`mg_articoli`.`deleted_at`) IS NULL HAVING 2=2 ORDER BY `mg_articoli`.`descrizione`' WHERE `zz_modules`.`name` = 'Articoli'; - --- Fix query per plugin Impianti del cliente -UPDATE `zz_plugins` SET `options` = ' { "main_query": [ { "type": "table", "fields": "Matricola, Nome, Data, Descrizione", "query": "SELECT id, (SELECT `id` FROM `zz_modules` WHERE `name` = ''Impianti'') AS _link_module_, id AS _link_record_, matricola AS Matricola, nome AS Nome, DATE_FORMAT(data, ''%d/%m/%Y'') AS Data, descrizione AS Descrizione FROM my_impianti WHERE idanagrafica=|id_parent| HAVING 2=2 ORDER BY id DESC"} ]}' WHERE `zz_plugins`.`name` = 'Impianti del cliente'; - --- Fix per plugin Storico attività -UPDATE `zz_plugins` SET `options` = '{"main_query": [{"type": "table", "fields": "Numero, Data inizio, Data fine, Tipo", "query": "SELECT in_interventi.id, in_interventi.codice AS Numero, DATE_FORMAT(MAX(orario_inizio),''%d/%m/%Y'') AS ''Data inizio'', DATE_FORMAT(MAX(orario_fine),''%d/%m/%Y'') AS ''Data fine'', (SELECT descrizione FROM in_tipiintervento WHERE idtipointervento=in_interventi.idtipointervento) AS ''Tipo'', (SELECT `id` FROM `zz_modules` WHERE `name` = ''Interventi'') AS _link_module_, in_interventi.id AS _link_record_ FROM in_interventi LEFT JOIN `in_interventi_tecnici` ON `in_interventi_tecnici`.`idintervento` = `in_interventi`.`id` LEFT JOIN `in_statiintervento` ON `in_interventi`.`idstatointervento`=`in_statiintervento`.`idstatointervento` WHERE 1=1 AND in_interventi.deleted_at IS NULL AND idanagrafica = |id_parent| GROUP BY `in_interventi`.`id` HAVING 2=2 ORDER BY in_interventi.id DESC"}]}' WHERE `name` = 'Storico attività'; - --- Aggiornamento del modulo Banche per il supporto completo alle Anagrafiche -ALTER TABLE `co_banche` ADD `id_anagrafica` INT(11) NOT NULL, CHANGE `note` `note` TEXT, CHANGE `filiale` `filiale` varchar(255), ADD `predefined` BOOLEAN NOT NULL DEFAULT FALSE, ADD `creditor_id` varchar(255), ADD `codice_sia` varchar(5); -UPDATE `co_banche` SET `id_anagrafica` = (SELECT `valore` FROM `zz_settings` WHERE `nome` = 'Azienda predefinita'); -ALTER TABLE `co_banche` ADD FOREIGN KEY (`id_anagrafica`) REFERENCES `an_anagrafiche`(`idanagrafica`) ON DELETE CASCADE; - --- Collegamento sulla base dei campi aggiuntivi per le Anagrafiche -UPDATE `co_banche` SET `co_banche`.`id_anagrafica` = (SELECT valore FROM zz_settings WHERE nome = 'Azienda predefinita'); - --- Aggiornamento ID relativo sulle Anagrafiche -ALTER TABLE `an_anagrafiche` CHANGE `idbanca_acquisti` `idbanca_acquisti` INT(11), - CHANGE `idbanca_vendite` `idbanca_vendite` INT(11); -UPDATE `an_anagrafiche` SET `idbanca_acquisti` = NULL WHERE `idbanca_vendite` = 0; -UPDATE `an_anagrafiche` SET `idbanca_vendite` = NULL WHERE `idbanca_vendite` = 0; - -INSERT INTO `co_banche` (`id_anagrafica`, `nome`, `iban`, `bic`, `filiale`, `predefined`) SELECT idanagrafica, IF(appoggiobancario != '', appoggiobancario, CONCAT('Banca predefinita di ', ragione_sociale)), codiceiban, bic, filiale, 1 FROM an_anagrafiche WHERE codiceiban IS NOT NULL AND codiceiban != ''; - -UPDATE `an_anagrafiche` SET `idbanca_acquisti` = (SELECT `id` FROM `co_banche` WHERE `co_banche`.`id_anagrafica` = `an_anagrafiche`.`idanagrafica` LIMIT 1) WHERE `idbanca_acquisti` IS NULL; -UPDATE `an_anagrafiche` SET `idbanca_vendite` = (SELECT `id` FROM `co_banche` WHERE `co_banche`.`id_anagrafica` = `an_anagrafiche`.`idanagrafica` LIMIT 1) WHERE `idbanca_vendite` IS NULL; - --- Aggiornamento tabella principale per Banche -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_banche` INNER JOIN an_anagrafiche ON `an_anagrafiche`.`idanagrafica` = `co_banche`.`id_anagrafica` WHERE 1=1 AND `co_banche`.`deleted_at` IS NULL AND `an_anagrafiche`.`deleted_at` IS NULL HAVING 2=2' WHERE `name` = 'Banche'; -INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `visible`, `summable`, `default`) VALUES -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Banche'), 'Anagrafica', 'an_anagrafiche.ragione_sociale', 0, 1, 0, 0, 1, 0, 1), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Banche'), 'Predefinito', 'IF(`co_banche`.`predefined`, ''Si'', ''No'')', 6, 1, 0, 0, 1, 0, 1); - --- Campo id_banca_controparte e id_banca_azienda per i Documenti -ALTER TABLE `co_documenti` ADD `id_banca_controparte` INT(11) AFTER `idpagamento`; -ALTER TABLE `co_preventivi` ADD `id_banca_controparte` INT(11) AFTER `idpagamento`; -ALTER TABLE `co_contratti` ADD `id_banca_controparte` INT(11) AFTER `idpagamento`; -ALTER TABLE `dt_ddt` ADD `id_banca_controparte` INT(11) AFTER `idpagamento`; -ALTER TABLE `or_ordini` ADD `id_banca_controparte` INT(11) NOT NULL AFTER `idpagamento`; - -ALTER TABLE `co_documenti` CHANGE `idbanca` `id_banca_azienda` INT(11) AFTER `idpagamento`; -ALTER TABLE `co_preventivi` ADD `id_banca_azienda` INT(11) AFTER `idpagamento`; -ALTER TABLE `co_contratti` ADD `id_banca_azienda` INT(11) AFTER `idpagamento`; -ALTER TABLE `dt_ddt` ADD `id_banca_azienda` INT(11) AFTER `idpagamento`; -ALTER TABLE `or_ordini` ADD `id_banca_azienda` INT(11) AFTER `idpagamento`; - -UPDATE `co_documenti` SET `id_banca_azienda` = NULL WHERE `id_banca_azienda` = 0; - --- Aggiunta unità di misura secondaria per le stampe documenti di vendita -ALTER TABLE `mg_articoli` ADD `um_secondaria` varchar(255), ADD `fattore_um_secondaria` DECIMAL(15, 6); - --- Aggiunta impostazione per impegnare o meno automaticamente le quantità negli ordini clienti -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES (NULL, 'Conferma automaticamente le quantità negli ordini cliente', '1', 'boolean', '1', 'Ordini', NULL, NULL); - -ALTER TABLE `or_righe_ordini` ADD `confermato` BOOLEAN NOT NULL AFTER `id_dettaglio_fornitore`; -UPDATE `or_righe_ordini` SET `confermato` = 1; - -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `mg_articoli` LEFT JOIN an_anagrafiche ON mg_articoli.id_fornitore=an_anagrafiche.idanagrafica LEFT JOIN co_iva ON mg_articoli.idiva_vendita=co_iva.id LEFT JOIN (SELECT SUM(qta-qta_evasa) AS qta_impegnata, idarticolo FROM or_righe_ordini INNER JOIN or_ordini ON or_righe_ordini.idordine=or_ordini.id INNER JOIN or_tipiordine ON or_ordini.idtipoordine=or_tipiordine.id WHERE idstatoordine IN(SELECT id FROM or_statiordine WHERE completato=0) AND or_tipiordine.dir=''entrata'' AND or_righe_ordini.confermato = 1 GROUP BY idarticolo) a ON a.idarticolo=mg_articoli.id LEFT JOIN mg_categorie ON mg_articoli.id_categoria=mg_categorie.id LEFT JOIN mg_categorie AS sottocategorie ON mg_articoli.id_sottocategoria=sottocategorie.id WHERE 1=1 AND (`mg_articoli`.`deleted_at`) IS NULL HAVING 2=2 ORDER BY `mg_articoli`.`descrizione`' WHERE `zz_modules`.`name` = 'Articoli'; - --- Aggiunta impostazione per impegnare o meno automaticamente le quantità negli ordini fornitori -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES (NULL, 'Conferma automaticamente le quantità negli ordini fornitore', '1', 'boolean', '1', 'Ordini', NULL, NULL); - --- Aggiunte note prima nota -ALTER TABLE `co_movimenti` ADD `note` TEXT AFTER `descrizione`; - --- Aggiunta risorse API dedicate alle Stampe in binary formato -INSERT INTO `zz_api_resources` (`id`, `version`, `type`, `resource`, `class`, `enabled`) VALUES -(NULL, 'v1', 'retrieve', 'stampa-binary', 'API\\Common\\Stampa', '1'); - --- Fix tracciato 1.2.1 FE (che potrà essere utilizzata a partire dal 01/10/2020 e sarà obbligatoria dal 01/01/2021) -INSERT INTO `fe_causali_pagamento_ritenuta` (`codice`, `descrizione`) VALUES ('M2', 'Prestazioni di lavoro autonomo non esercitate abitualmente per le quali sussiste l’obbligo di iscrizione alla Gestione Separata ENPAPI'); - -INSERT INTO `fe_causali_pagamento_ritenuta` (`codice`, `descrizione`) VALUES ('M1', 'Redditi derivanti dall’assunzione di obblighi di fare, di non fare o permettere'); - -INSERT INTO `fe_causali_pagamento_ritenuta` (`codice`, `descrizione`) VALUES ('L1', 'Redditi derivanti dall’utilizzazione economica di opere dell’ingegno, di brevetti industriali e di processi, che sono percepiti da soggetti che abbiano acquistato a titolo oneroso i diritti alla loro utilizzazione'); - -INSERT INTO `fe_causali_pagamento_ritenuta` (`codice`, `descrizione`) VALUES ('O1', 'Redditi derivanti dall’assunzione di obblighi di fare, di non fare o permettere, per le quali non sussiste l’obbligo di iscrizione alla gestione separata (Circ. INPS n. 104/2001)'); - -INSERT INTO `fe_causali_pagamento_ritenuta` (`codice`, `descrizione`) VALUES ('V1', 'Redditi derivanti da attività commerciali non esercitate abitualmente (ad esempio, provvigioni corrisposte per prestazioni occasionali ad agente o rappresentante di commercio, mediatore, procacciatore d’affari)'); - -INSERT INTO `fe_causali_pagamento_ritenuta` (`codice`, `descrizione`) VALUES ('V2', 'Redditi derivanti dalle prestazioni non esercitate abitualmente rese dagli incaricati alla vendita diretta a domicilio'); - -UPDATE `fe_causali_pagamento_ritenuta` SET `codice` = 'ZO' WHERE `fe_causali_pagamento_ritenuta`.`codice` = 'Z'; - -UPDATE `zz_settings` SET `valore` = 'ZO' WHERE `zz_settings`.`nome` = 'Causale ritenuta d''acconto' AND `zz_settings`.`valore` = 'Z'; - --- Disattivazione aliquote IVA con NATURA non più supportata dal tracciato 1.2.1 FE --- andrà doverosamente specificato il sotto codice (esempio N3.1, N3.2 etc) -UPDATE `co_iva` SET `deleted_at` = now() WHERE `co_iva`.`codice_natura_fe` IN ('N2','N3','N6'); - --- Introduzione tabella di supporto per nodo tracciato 1.2.1 FE -CREATE TABLE IF NOT EXISTS `fe_tipi_ritenuta` ( - `codice` varchar(4) NOT NULL, - `descrizione` varchar(255) NOT NULL, - PRIMARY KEY (`codice`) -) ENGINE=InnoDB; - -INSERT INTO `fe_tipi_ritenuta` (`codice`, `descrizione`) VALUES -('RT01', 'Ritenuta persone fisiche'), -('RT02', 'Ritenuta persone giuridiche'), -('RT03', 'Contributo INPS'), -('RT04', 'Contributo ENASARCO'), -('RT05', 'Contributo ENPAM'), -('RT06', 'Altro contributo previdenziale'); - --- Impostazione percentuale deducibile di default al 100% -ALTER TABLE `co_pianodeiconti3` CHANGE `percentuale_deducibile` `percentuale_deducibile` DECIMAL(5,2) NOT NULL DEFAULT '100'; - -ALTER TABLE `fe_stati_documento` ADD `is_generabile` BOOLEAN DEFAULT FALSE, - ADD `is_inviabile` BOOLEAN DEFAULT FALSE, - ADD `tipo` varchar(255) NOT NULL; - -UPDATE `fe_stati_documento` SET `is_generabile` = '1', `is_inviabile` = '1' WHERE `codice` = 'ERVAL'; -UPDATE `fe_stati_documento` SET `is_generabile` = '1', `is_inviabile` = '1' WHERE `codice` = 'ERR'; -UPDATE `fe_stati_documento` SET `is_generabile` = '1', `is_inviabile` = '1' WHERE `codice` = 'GEN'; -UPDATE `fe_stati_documento` SET `is_generabile` = '1' WHERE `codice` = 'NS'; -UPDATE `fe_stati_documento` SET `is_generabile` = '1' WHERE `codice` = 'EC02'; - -UPDATE `fe_stati_documento` SET `tipo` = 'danger'; -UPDATE `fe_stati_documento` SET `tipo` = 'warning' WHERE `codice` IN ('ERVAL', 'WAIT', 'NE'); -UPDATE `fe_stati_documento` SET `tipo` = 'success' WHERE `codice` IN ('EC01', 'RC'); -UPDATE `fe_stati_documento` SET `tipo` = 'info' WHERE `codice` IN ('GEN', 'MC'); - --- Aggiunta stampa liquidazione IVA -INSERT INTO `zz_prints` (`id`, `id_module`, `is_record`, `name`, `title`, `filename`, `directory`, `previous`, `options`, `icon`, `version`, `compatibility`, `order`, `predefined`, `default`, `enabled`) VALUES (NULL,(SELECT id FROM zz_modules WHERE name='Stampe contabili'), '1', 'Liquidazione IVA', 'Liquidazione IVA', 'Liquidazione IVA', 'liquidazione_iva', '', '', 'fa fa-print', '', '', '0', '0', '1', '1'); - --- Aggiunta impostazione per Liquidazione IVA -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES (NULL, 'Liquidazione iva', 'Mensile', 'list[Mensile,Trimestrale]', '1', 'Fatturazione', '16', NULL); - --- Aggiornamento causali DDT in caso di assenza -UPDATE `dt_ddt` SET `idcausalet` = (SELECT `id` FROM `dt_causalet` WHERE `predefined` = 1 LIMIT 1) WHERE EXISTS(SELECT `id` FROM `dt_causalet` WHERE `predefined` = 1) AND (idcausalet = 0 OR idcausalet IS NULL); -UPDATE `dt_ddt` SET `idcausalet` = (SELECT `id` FROM `dt_causalet` WHERE `descrizione` = 'Vendita' LIMIT 1) WHERE EXISTS(SELECT `id` FROM `dt_causalet` WHERE `descrizione` = 'Vendita') AND (idcausalet = 0 OR idcausalet IS NULL); -UPDATE `dt_ddt` SET `idcausalet` = (SELECT `id` FROM `dt_causalet`) WHERE EXISTS(SELECT `id` FROM `dt_causalet`) AND (idcausalet = 0 OR idcausalet IS NULL); - --- Aggiornamento del modulo Impostazioni -UPDATE `zz_modules` SET `options` = 'custom' WHERE `name` = 'Impostazioni'; - --- Fix logica query Scadenzario -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_scadenziario`\r\n LEFT JOIN `co_documenti` ON `co_scadenziario`.`iddocumento` = `co_documenti`.`id`\r\n LEFT JOIN `an_anagrafiche` ON `co_documenti`.`idanagrafica` = `an_anagrafiche`.`idanagrafica`\r\n LEFT JOIN `co_pagamenti` ON `co_documenti`.`idpagamento` = `co_pagamenti`.`id`\r\n LEFT JOIN `co_tipidocumento` ON `co_documenti`.`idtipodocumento` = `co_tipidocumento`.`id`\r\n LEFT JOIN `co_statidocumento` ON `co_documenti`.`idstatodocumento` = `co_statidocumento`.`id`\r\nWHERE 1=1 AND\r\n (`co_scadenziario`.`scadenza` BETWEEN \'|period_start|\' AND \'|period_end|\' OR ABS(`co_scadenziario`.`pagato`) < ABS(`co_scadenziario`.`da_pagare`)) AND\r\n (`co_statidocumento`.`descrizione` IS NULL OR `co_statidocumento`.`descrizione` IN(\'Emessa\',\'Parzialmente pagato\',\'Pagato\'))\r\nHAVING 2=2\r\nORDER BY `scadenza` ASC' WHERE `zz_modules`.`name` = 'Scadenzario'; - --- Elimino token disabilitati -DELETE FROM `zz_tokens` WHERE `zz_tokens`.`enabled` = 0; - --- Aggiunto colonna sconto per le coppie anagrafica articolo -ALTER TABLE `mg_prezzi_articoli` ADD `sconto_percentuale` DECIMAL(15,6) NOT NULL AFTER `massimo`; - --- Aggiunta impostazione per mostrare o nascondere barra plugin -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES (NULL, 'Nascondere la barra dei plugin di default', '0', 'boolean', '1', 'Generali', '2', NULL); diff --git a/update/2_4_19.sql b/update/2_4_19.sql deleted file mode 100644 index 4e72ce3e8..000000000 --- a/update/2_4_19.sql +++ /dev/null @@ -1,60 +0,0 @@ --- Aggiunta impostazione conto anticipi -INSERT INTO `co_pianodeiconti3` (`id`, `numero`, `descrizione`, `idpianodeiconti2`, `dir`, `percentuale_deducibile`) VALUES (NULL, '000011', 'Anticipo fornitori', '8', '', '100.00'); - -INSERT INTO `co_pianodeiconti3` (`id`, `numero`, `descrizione`, `idpianodeiconti2`, `dir`, `percentuale_deducibile`) VALUES (NULL, '000011', 'Anticipo clienti', '2', '', '100.00'); - -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES (NULL, 'Conto anticipo clienti', (SELECT `id` FROM `co_pianodeiconti3` WHERE `descrizione`='Anticipo clienti'), 'query=SELECT id, CONCAT_WS('' - '', numero, descrizione) AS descrizione FROM co_pianodeiconti3', '1', 'Fatturazione', NULL, NULL); - -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES (NULL, 'Conto anticipo fornitori', (SELECT `id` FROM `co_pianodeiconti3` WHERE `descrizione`='Anticipo fornitori'), 'query=SELECT id, CONCAT_WS('' - '', numero, descrizione) AS descrizione FROM co_pianodeiconti3', '1', 'Fatturazione', NULL, NULL); - --- Allineamento tipo di campo con NULL se non valorizzato -ALTER TABLE `co_movimenti` CHANGE `idanagrafica` `id_anagrafica` INT(11) NULL; - --- Rimozione valori a 0 -UPDATE `co_movimenti` SET `id_anagrafica` = NULL WHERE `id_anagrafica` = 0; - --- Spostamento conti transitori su stato patrimoniale -UPDATE `co_pianodeiconti2` SET `idpianodeiconti1` = 1 WHERE `descrizione` = 'Conti transitori'; - --- Aggiunta quantità multipla -ALTER TABLE `mg_articoli` ADD `qta_multipla` DECIMAL(15,6) NOT NULL DEFAULT '0' AFTER `threshold_qta`; - --- Correzione riferimenti Articoli Interventi per Fatture -UPDATE `co_righe_documenti` SET `co_righe_documenti`.`original_id` = (SELECT `id` FROM `in_righe_interventi` WHERE `co_righe_documenti`.`original_id` = `in_righe_interventi`.`old_id`) WHERE `co_righe_documenti`.`original_type` = 'Modules\\Interventi\\Components\\Articolo'; - --- --- Aggiornamento dati Interventi per Fatture --- --- Collegamento Articoli -UPDATE `co_righe_documenti` INNER JOIN `in_righe_interventi` ON `co_righe_documenti`.`idintervento` = `in_righe_interventi`.`idintervento` AND `co_righe_documenti`.`descrizione` = `in_righe_interventi`.`descrizione` AND `co_righe_documenti`.`idarticolo` = `in_righe_interventi`.`idarticolo` SET `co_righe_documenti`.`original_id` = `in_righe_interventi`.`id`, `co_righe_documenti`.`original_type` = 'Modules\\Interventi\\Components\\Articolo' WHERE `co_righe_documenti`.`idarticolo` != 0 AND `co_righe_documenti`.`original_type` IS NULL; - --- Collegamento Sconti -UPDATE `co_righe_documenti` INNER JOIN `in_righe_interventi` ON `co_righe_documenti`.`idintervento` = `in_righe_interventi`.`idintervento` AND `co_righe_documenti`.`descrizione` = `in_righe_interventi`.`descrizione` AND `co_righe_documenti`.`idarticolo` = `in_righe_interventi`.`idarticolo` SET `co_righe_documenti`.`original_id` = `in_righe_interventi`.`id`, `co_righe_documenti`.`original_type` = 'Modules\\Interventi\\Components\\Sconto' WHERE `co_righe_documenti`.`is_sconto` != 0 AND `co_righe_documenti`.`original_type` IS NULL; - --- Collegamento Descrizioni -UPDATE `co_righe_documenti` INNER JOIN `in_righe_interventi` ON `co_righe_documenti`.`idintervento` = `in_righe_interventi`.`idintervento` AND `co_righe_documenti`.`descrizione` = `in_righe_interventi`.`descrizione` AND `co_righe_documenti`.`idarticolo` = `in_righe_interventi`.`idarticolo` SET `co_righe_documenti`.`original_id` = `in_righe_interventi`.`id`, `co_righe_documenti`.`original_type` = 'Modules\\Interventi\\Components\\Descrizione' WHERE `co_righe_documenti`.`is_descrizione` != 0 AND `co_righe_documenti`.`original_type` IS NULL; - --- Collegamento Righe -UPDATE `co_righe_documenti` INNER JOIN `in_righe_interventi` ON `co_righe_documenti`.`idintervento` = `in_righe_interventi`.`idintervento` AND `co_righe_documenti`.`descrizione` = `in_righe_interventi`.`descrizione` AND `co_righe_documenti`.`idarticolo` = `in_righe_interventi`.`idarticolo` SET `co_righe_documenti`.`original_id` = `in_righe_interventi`.`id`, `co_righe_documenti`.`original_type` = 'Modules\\Interventi\\Components\\Riga' WHERE `co_righe_documenti`.`original_id` IS NULL AND `co_righe_documenti`.`original_type` IS NULL; - --- Aggiunta colonna qta_evasa per Interventi -ALTER TABLE `in_righe_interventi` ADD `qta_evasa` decimal(15, 6) NOT NULL AFTER `qta`; - --- Allineo campo qta_evasa (appena aggiunto) con la qta delle righe interventi inseriti in fattura -UPDATE `in_righe_interventi` SET `in_righe_interventi`.`qta_evasa` = `in_righe_interventi`.`qta` WHERE `in_righe_interventi`.`idintervento` IN ( - SELECT DISTINCT( `idintervento`) FROM `co_righe_documenti` WHERE `idintervento` IS NOT NULL -); - --- Aggiornamento date vuote su movimenti -UPDATE `mg_movimenti` SET `data`=`created_at` WHERE `data` IS NULL; - --- Aggiunta colonna "Sede" nei movimenti -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `mg_movimenti` JOIN `mg_articoli` ON `mg_articoli`.id = `mg_movimenti`.`idarticolo` LEFT JOIN `an_sedi` ON `mg_movimenti`.`idsede_azienda` = `an_sedi`.`id` WHERE 1=1 HAVING 2=2 ORDER BY mg_movimenti.data DESC, mg_movimenti.created_at DESC' WHERE `name` = 'Movimenti'; - -INSERT INTO `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` = 'Movimenti'), 'Sede', 'IF( mg_movimenti.idsede_azienda=0, ''Sede legale'', an_sedi.nomesede )', '4', '1', '0', '0', NULL, NULL, '1', '0', '1'); - -UPDATE `zz_views` INNER JOIN `zz_modules` ON `zz_views`.`id_module`=`zz_modules`.`id` SET `zz_views`.`summable` = 1 WHERE `zz_modules`.`name` = 'Movimenti' AND `zz_views`.`name` = 'Quantità'; - -INSERT INTO `zz_group_view` (`id_gruppo`, `id_vista`) ( - SELECT `zz_groups`.`id`, `zz_views`.`id` FROM `zz_groups`, `zz_views` INNER JOIN `zz_modules` ON `zz_views`.`id_module` = `zz_modules`.`id` WHERE `zz_modules`.`name` = 'Movimenti' AND `zz_views`.`name` = 'Sede' -); diff --git a/update/2_4_2.php b/update/2_4_2.php deleted file mode 100755 index 3b70cd569..000000000 --- a/update/2_4_2.php +++ /dev/null @@ -1,45 +0,0 @@ -fetchArray('SELECT * FROM mg_movimenti'); - -foreach ($movimenti as $movimento) { - $documento = null; - - if (!empty($movimento['idintervento'])) { - $documento = $dbo->fetchOne('SELECT IFNULL(MAX(orario_fine), data_richiesta) AS data FROM in_interventi LEFT JOIN in_interventi_tecnici ON in_interventi.id=in_interventi_tecnici.idintervento WHERE in_interventi.id='.prepare($movimento['idintervento'])); - } elseif (!empty($movimento['idddt'])) { - $documento = $dbo->fetchOne('SELECT data FROM dt_ddt WHERE id='.prepare($movimento['idddt'])); - } elseif (!empty($movimento['iddocumento'])) { - $documento = $dbo->fetchOne('SELECT data FROM co_documenti WHERE id='.prepare($movimento['iddocumento'])); - } - - if (!empty($documento['data'])) { - $dbo->update('mg_movimenti', [ - 'data' => $documento['data'], - ], [ - 'id' => $movimento['id'], - ]); - } -} - -$dbo->query("UPDATE mg_movimenti SET data = created_at WHERE data = '0000-00-00'"); - -// Fix Partite IVA -/* -foreach ($it as $key => $value) { - $dbo->query("UPDATE `an_anagrafiche` SET `piva` = SUBSTRING(`piva`, 2) WHERE `piva` LIKE '".$key."%'"); -}*/ - -// File e cartelle deprecate -$files = [ - 'docs', - 'couscous.yml', -]; - -foreach ($files as $key => $value) { - $files[$key] = realpath(base_dir().'/'.$value); -} - -delete($files); diff --git a/update/2_4_2.sql b/update/2_4_2.sql deleted file mode 100755 index aba69d829..000000000 --- a/update/2_4_2.sql +++ /dev/null @@ -1,656 +0,0 @@ --- Gestione documentale -CREATE TABLE IF NOT EXISTS `zz_documenti_categorie` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `descrizione` varchar(255) NOT NULL, - `deleted_at` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - -CREATE TABLE IF NOT EXISTS `zz_documenti` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `idcategoria` int(11) NOT NULL, - `nome` varchar(255) NOT NULL, - `data` date DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - -INSERT INTO `zz_documenti_categorie` (`id`, `descrizione`) VALUES -(NULL, 'Documenti società'), -(NULL, 'Contratti assunzione personale'); - --- Innesto modulo gestione documentale -INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Gestione documentale', 'Gestione documentale', 'gestione_documentale', '{ "main_query": [ { "type": "table", "fields": "Categoria, Nome, Data", "query": "SELECT id,(SELECT descrizione FROM zz_documenti_categorie WHERE zz_documenti_categorie.id = idcategoria) AS Categoria, zz_documenti.nome AS Nome, DATE_FORMAT( zz_documenti.`data`, ''%d/%m/%Y'' ) AS `Data` FROM zz_documenti WHERE `data` >= ''|period_start|'' AND `data` <= ''|period_end|'' HAVING 1=1"} ]}', '', 'fa fa-file-text-o', '2.4', '2.4', '1', NULL, '1', '1'); - --- Innesto modulo categorie documenti -INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Categorie documenti', 'Categorie documenti', 'categorie_documenti', '{ "main_query": [ { "type": "table", "fields": "Descrizione", "query": "SELECT zz_documenti_categorie.`descrizione`as Descrizione, zz_documenti_categorie.`id`as id FROM zz_documenti_categorie WHERE deleted_at IS NULL HAVING 1=1"} ]}', '', 'fa fa-file-text-o', '2.4', '2.4', '1', NULL, '1', '1'); -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Categorie documenti' AND `t2`.`name` = 'Gestione documentale') SET `t1`.`parent` = `t2`.`id`; - --- Fatturazione elettronica -ALTER TABLE `an_nazioni` ADD `name` VARCHAR(255); -ALTER TABLE `co_documenti` ADD `codice_xml` VARCHAR(255); - -INSERT INTO `zz_settings` (`idimpostazione`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES -(NULL, 'Allega stampa per fattura verso Privati', '0', 'boolean', 1, 'Fatturazione Elettronica', 8), -(NULL, 'Allega stampa per fattura verso Aziende', '0', 'boolean', 1, 'Fatturazione Elettronica', 9), -(NULL, 'Allega stampa per fattura verso PA', '0', 'boolean', 1, 'Fatturazione Elettronica', 10); - -CREATE TABLE IF NOT EXISTS `fe_regime_fiscale` ( - `codice` varchar(4) NOT NULL, - `descrizione` varchar(255) NOT NULL, - PRIMARY KEY (`codice`) -) ENGINE=InnoDB; - -INSERT INTO `fe_regime_fiscale` (`codice`, `descrizione`) VALUES -('RF01','Ordinario'), -('RF02','Contribuenti minimi (art.1, c.96-117, L. 244/07)'), -('RF04','Agricoltura e attività connesse e pesca (artt.34 e 34-bis, DPR 633/72)'), -('RF05','Vendita sali e tabacchi (art.74, c.1, DPR. 633/72)'), -('RF06','Commercio fiammiferi (art.74, c.1, DPR 633/72)'), -('RF07','Editoria (art.74, c.1, DPR 633/72)'), -('RF08','Gestione servizi telefonia pubblica (art.74, c.1, DPR 633/72)'), -('RF09','Rivendita documenti di trasporto pubblico e di sosta (art.74, c.1, DPR 633/72)'), -('RF10','Intrattenimenti, giochi e altre attività di cui alla tariffa allegata al DPR 640/72 (art.74, c.6, DPR 633/72)'), -('RF11','Agenzie viaggi e turismo (art.74-ter, DPR 633/72)'), -('RF12','Agriturismo (art.5, c.2, L. 413/91)'), -('RF13','Vendite a domicilio (art.25-bis, c.6, DPR 600/73)'), -('RF14','Rivendita beni usati, oggetti d’arte, d’antiquariato o da collezione (art.36, DL 41/95)'), -('RF15','Agenzie di vendite all’asta di oggetti d’arte, antiquariato o da collezione (art.40-bis, DL 41/95)'), -('RF16','IVA per cassa P.A. (art.6, c.5, DPR 633/72)'), -('RF17','IVA per cassa (art. 32-bis, DL 83/2012)'), -('RF18','Altro'), -('RF19','Regime forfettario (art.1, c.54-89, L. 190/2014)'); - -INSERT INTO `zz_settings` (`idimpostazione`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES (NULL, 'Regime Fiscale', '', 'query=SELECT codice AS id, descrizione FROM fe_regime_fiscale', 1, 'Fatturazione Elettronica', 1); - -CREATE TABLE IF NOT EXISTS `fe_tipo_cassa` ( - `codice` varchar(4) NOT NULL, - `descrizione` varchar(255) NOT NULL, - PRIMARY KEY (`codice`) -) ENGINE=InnoDB; - -INSERT INTO `fe_tipo_cassa` (`codice`, `descrizione`) VALUES -('TC01','Cassa nazionale previdenza e assistenza avvocati e procuratori legali'), -('TC02','Cassa previdenza dottori commercialisti'), -('TC03','Cassa previdenza e assistenza geometri'), -('TC04','Cassa nazionale previdenza e assistenza ingegneri e architetti liberi professionisti'), -('TC05','Cassa nazionale del notariato'), -('TC06','Cassa nazionale previdenza e assistenza ragionieri e periti commerciali'), -('TC07','Ente nazionale assistenza agenti e rappresentanti di commercio (ENASARCO)'), -('TC08','Ente nazionale previdenza e assistenza consulenti del lavoro (ENPACL)'), -('TC09','Ente nazionale previdenza e assistenza medici (ENPAM)'), -('TC10','Ente nazionale previdenza e assistenza farmacisti (ENPAF)'), -('TC11','Ente nazionale previdenza e assistenza veterinari (ENPAV)'), -('TC12','Ente nazionale previdenza e assistenza impiegati dell agricoltura (ENPAIA)'), -('TC13','Fondo previdenza impiegati imprese di spedizione e agenzie marittime'), -('TC14','Istituto nazionale previdenza giornalisti italiani (INPGI)'), -('TC15','Opera nazionale assistenza orfani sanitari italiani (ONAOSI)'), -('TC16','Cassa autonoma assistenza integrativa giornalisti italiani (CASAGIT)'), -('TC17','Ente previdenza periti industriali e periti industriali laureati (EPPI)'), -('TC18','Ente previdenza e assistenza pluricategoriale (EPAP)'), -('TC19','Ente nazionale previdenza e assistenza biologi (ENPAB)'), -('TC20','Ente nazionale previdenza e assistenza professione infermieristica (ENPAPI)'), -('TC21','Ente nazionale previdenza e assistenza psicologi (ENPAP)'), -('TC22','INPS'); - -INSERT INTO `zz_settings` (`idimpostazione`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES (NULL, 'Tipo Cassa', '', 'query=SELECT codice AS id, descrizione FROM fe_tipo_cassa', 1, 'Fatturazione Elettronica', 2); - -CREATE TABLE IF NOT EXISTS `fe_modalita_pagamento` ( - `codice` varchar(4) NOT NULL, - `descrizione` varchar(255) NOT NULL, - PRIMARY KEY (`codice`) -) ENGINE=InnoDB; - -INSERT INTO `fe_modalita_pagamento` (`codice`, `descrizione`) VALUES -('MP01','Contanti'), -('MP02','Assegno'), -('MP03','Assegno circolare'), -('MP04','Contanti presso Tesoreria'), -('MP05','Bonifico'), -('MP06','Vaglia cambiario'), -('MP07','Bollettino bancario'), -('MP08','Carta di pagamento'), -('MP09','RID'), -('MP10','RID utenze'), -('MP11','RID veloce'), -('MP12','RIBA'), -('MP13','MAV'), -('MP14','Quietanza erario'), -('MP15','Giroconto su conti di contabilità speciale'), -('MP16','Domiciliazione bancaria'), -('MP17','Domiciliazione postale'), -('MP18','Bollettino di c/c postale'), -('MP19','SEPA Direct Debit'), -('MP20','SEPA Direct Debit CORE'), -('MP21','SEPA Direct Debit B2B'), -('MP22','Trattenuta su somme già riscosse'); - -ALTER TABLE `co_pagamenti` ADD `codice_modalita_pagamento_fe` varchar(4); -UPDATE `co_pagamenti` SET `codice_modalita_pagamento_fe` = 'MP01' WHERE `descrizione` IN ('Rimessa diretta', 'Rimessa diretta a 30gg', 'Rimessa diretta 30gg fisso al 15', 'Contanti'); -UPDATE `co_pagamenti` SET `codice_modalita_pagamento_fe` = 'MP02' WHERE `descrizione` IN ('Assegno'); -UPDATE `co_pagamenti` SET `codice_modalita_pagamento_fe` = 'MP05' WHERE `descrizione` IN ('Bonifico 30gg d.f.', 'Bonifico 60gg d.f.', 'Bonifico 90gg d.f.', 'Bonifico 120gg d.f.', 'Bonifico 150gg d.f.', 'Bonifico 180gg d.f.', 'Bonifico 30/60gg d.f.', 'Bonifico 30/60gg d.f.', 'Bonifico 30/60/90gg d.f.', 'Bonifico 30/60/90gg d.f.', 'Bonifico 30/60/90gg d.f.', 'Bonifico 30/60/90/120gg d.f.', 'Bonifico 30/60/90/120gg d.f.', 'Bonifico 30/60/90/120gg d.f.', 'Bonifico 30/60/90/120gg d.f.', 'Bonifico 30/60/90/120/150gg d.f.', 'Bonifico 30/60/90/120/150gg d.f.', 'Bonifico 30/60/90/120/150gg d.f.', 'Bonifico 30/60/90/120/150gg d.f.', 'Bonifico 30/60/90/120/150gg d.f.', 'Bonifico 30/60/90/120/150/180gg d.f.', 'Bonifico 30/60/90/120/150/180gg d.f.', 'Bonifico 30/60/90/120/150/180gg d.f.', 'Bonifico 30/60/90/120/150/180gg d.f.', 'Bonifico 30/60/90/120/150/180gg d.f.', 'Bonifico 30/60/90/120/150/180gg d.f.', 'Bonifico 30gg d.f.f.m.', 'Bonifico 60gg d.f.f.m.', 'Bonifico 90gg d.f.f.m.', 'Bonifico 120gg d.f.f.m.', 'Bonifico 150gg d.f.f.m.', 'Bonifico 180gg d.f.f.m.', 'Bonifico 30/60gg d.f.f.m.', 'Bonifico 30/60gg d.f.f.m.', 'Bonifico 30/60/90gg d.f.f.m.', 'Bonifico 30/60/90gg d.f.f.m.', 'Bonifico 30/60/90gg d.f.f.m.', 'Bonifico 30/60/90/120gg d.f.f.m.', 'Bonifico 30/60/90/120gg d.f.f.m.', 'Bonifico 30/60/90/120gg d.f.f.m.', 'Bonifico 30/60/90/120gg d.f.f.m.', 'Bonifico 30/60/90/120/150gg d.f.f.m.', 'Bonifico 30/60/90/120/150gg d.f.f.m.', 'Bonifico 30/60/90/120/150gg d.f.f.m.', 'Bonifico 30/60/90/120/150gg d.f.f.m.', 'Bonifico 30/60/90/120/150gg d.f.f.m.', 'Bonifico 30/60/90/120/150/180gg d.f.f.m.', 'Bonifico 30/60/90/120/150/180gg d.f.f.m.', 'Bonifico 30/60/90/120/150/180gg d.f.f.m.', 'Bonifico 30/60/90/120/150/180gg d.f.f.m.', 'Bonifico 30/60/90/120/150/180gg d.f.f.m.', 'Bonifico 30/60/90/120/150/180gg d.f.f.m.', 'Bonifico bancario'); -UPDATE `co_pagamenti` SET `codice_modalita_pagamento_fe` = 'MP06' WHERE `descrizione` IN ('Cambiale'); -UPDATE `co_pagamenti` SET `codice_modalita_pagamento_fe` = 'MP08' WHERE `descrizione` IN ('Bancomat', 'Visa'); -UPDATE `co_pagamenti` SET `codice_modalita_pagamento_fe` = 'MP12' WHERE `descrizione` IN ('Ri.Ba. 30gg d.f.', 'Ri.Ba. 60gg d.f.', 'Ri.Ba. 90gg d.f.', 'Ri.Ba. 120gg d.f.', 'Ri.Ba. 150gg d.f.', 'Ri.Ba. 180gg d.f.', 'Ri.Ba. 30/60gg d.f.', 'Ri.Ba. 30/60gg d.f.', 'Ri.Ba. 30/60/90gg d.f.', 'Ri.Ba. 30/60/90gg d.f.', 'Ri.Ba. 30/60/90gg d.f.', 'Ri.Ba. 30/60/90/120gg d.f.', 'Ri.Ba. 30/60/90/120gg d.f.', 'Ri.Ba. 30/60/90/120gg d.f.', 'Ri.Ba. 30/60/90/120gg d.f.', 'Ri.Ba. 30/60/90/120/150gg d.f.', 'Ri.Ba. 30/60/90/120/150gg d.f.', 'Ri.Ba. 30/60/90/120/150gg d.f.', 'Ri.Ba. 30/60/90/120/150gg d.f.', 'Ri.Ba. 30/60/90/120/150gg d.f.', 'Ri.Ba. 30/60/90/120/150/180gg d.f.', 'Ri.Ba. 30/60/90/120/150/180gg d.f.', 'Ri.Ba. 30/60/90/120/150/180gg d.f.', 'Ri.Ba. 30/60/90/120/150/180gg d.f.', 'Ri.Ba. 30/60/90/120/150/180gg d.f.', 'Ri.Ba. 30/60/90/120/150/180gg d.f.', 'Ri.Ba. 30gg d.f.f.m.', 'Ri.Ba. 60gg d.f.f.m.', 'Ri.Ba. 90gg d.f.f.m.', 'Ri.Ba. 120gg d.f.f.m.', 'Ri.Ba. 150gg d.f.f.m.', 'Ri.Ba. 180gg d.f.f.m.', 'Ri.Ba. 30/60gg d.f.f.m.', 'Ri.Ba. 30/60gg d.f.f.m.', 'Ri.Ba. 30/60/90gg d.f.f.m.', 'Ri.Ba. 30/60/90gg d.f.f.m.', 'Ri.Ba. 30/60/90gg d.f.f.m.', 'Ri.Ba. 30/60/90/120gg d.f.f.m.', 'Ri.Ba. 30/60/90/120gg d.f.f.m.', 'Ri.Ba. 30/60/90/120gg d.f.f.m.', 'Ri.Ba. 30/60/90/120gg d.f.f.m.', 'Ri.Ba. 30/60/90/120/150gg d.f.f.m.', 'Ri.Ba. 30/60/90/120/150gg d.f.f.m.', 'Ri.Ba. 30/60/90/120/150gg d.f.f.m.', 'Ri.Ba. 30/60/90/120/150gg d.f.f.m.', 'Ri.Ba. 30/60/90/120/150gg d.f.f.m.', 'Ri.Ba. 30/60/90/120/150/180gg d.f.f.m.', 'Ri.Ba. 30/60/90/120/150/180gg d.f.f.m.', 'Ri.Ba. 30/60/90/120/150/180gg d.f.f.m.', 'Ri.Ba. 30/60/90/120/150/180gg d.f.f.m.', 'Ri.Ba. 30/60/90/120/150/180gg d.f.f.m.', 'Ri.Ba. 30/60/90/120/150/180gg d.f.f.m.'); -ALTER TABLE `co_pagamenti` ADD FOREIGN KEY (`codice_modalita_pagamento_fe`) REFERENCES `fe_modalita_pagamento`(`codice`) ON DELETE CASCADE; - -CREATE TABLE IF NOT EXISTS `fe_tipi_documento` ( - `codice` varchar(4) NOT NULL, - `descrizione` varchar(255) NOT NULL, - PRIMARY KEY (`codice`) -) ENGINE=InnoDB; - -INSERT INTO `fe_tipi_documento` (`codice`, `descrizione`) VALUES -('TD01','Fattura'), -('TD02','Acconto/anticipo su fattura'), -('TD03','Acconto/anticipo su parcella'), -('TD04','Nota di credito'), -('TD05','Nota di debito'), -('TD06','Parcella'); - -ALTER TABLE `co_tipidocumento` ADD `codice_tipo_documento_fe` varchar(4) NOT NULL; -UPDATE `co_tipidocumento` SET `codice_tipo_documento_fe` = 'TD01' WHERE `descrizione` IN ('Fattura immediata di acquisto', 'Fattura immediata di vendita', 'Fattura differita di acquisto', 'Fattura differita di vendita', 'Fattura accompagnatoria di acquisto', 'Fattura accompagnatoria di vendita'); -UPDATE `co_tipidocumento` SET `codice_tipo_documento_fe` = 'TD04', `descrizione` = 'Nota di credito' WHERE `descrizione` = 'Nota di accredito'; -UPDATE `co_tipidocumento` SET `codice_tipo_documento_fe` = 'TD05', `descrizione` = 'Nota di debito' WHERE `descrizione` = 'Nota di addebito'; -ALTER TABLE `co_tipidocumento` ADD FOREIGN KEY (`codice_tipo_documento_fe`) REFERENCES `fe_tipi_documento`(`codice`) ON DELETE CASCADE; - -CREATE TABLE IF NOT EXISTS `fe_natura` ( - `codice` varchar(2) NOT NULL, - `descrizione` text NOT NULL, - PRIMARY KEY (`codice`) -) ENGINE=InnoDB; - -INSERT INTO `fe_natura` (`codice`, `descrizione`) VALUES -('N1','Escluse ex art. 15'), -('N2','Non soggette'), -('N3','Non imponibili'), -('N4','Esenti'), -('N5','Regime del margine / IVA non esposta in fattura'), -('N6','Inversione contabile (per le operazioni in reverse charge ovvero nei casi di autofatturazione per acquisti extra UE di servizi ovvero per importazioni di beni nei soli casi previsti)'), -('N7','IVA assolta in altro stato UE (vendite a distanza ex art. 40 c. 3 e 4 e art. 41 c. 1 lett. b, DL 331/93; prestazione di servizi di telecomunicazioni, tele-radiodiffusione ed elettronici ex art. 7-sexies lett. f, g, art. 74-sexies DPR 633/72)'); - -ALTER TABLE `co_iva` ADD `codice_natura_fe` varchar(4), ADD `deleted_at` timestamp NULL DEFAULT NULL, ADD `codice` int(11), ADD `esigibilita` enum('I', 'D', 'S') NOT NULL DEFAULT 'I', ADD `default` boolean NOT NULL DEFAULT 0, ADD FOREIGN KEY (`codice_natura_fe`) REFERENCES `fe_natura`(`codice`) ON DELETE CASCADE; -UPDATE `co_iva` SET `deleted_at` = NOW(); - -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_iva` WHERE 1=1 AND deleted_at IS NULL HAVING 2=2' WHERE `name` = 'IVA'; - -INSERT INTO `co_iva` (`descrizione`, `percentuale`, `indetraibile`, `esente`, `codice_natura_fe`, `codice`, `default`) VALUES -("Fuori campo IVA", 0, 0, 1, "N2", 300, 1), -("Es.art27DL98/11", 0, 0, 1, "N2", 301, 1), -("Escluso art. 2", 0, 0, 1, "N2", 302, 1), -("Escluso art. 3", 0, 0, 1, "N2", 303, 1), -("Escluso art. 4", 0, 0, 1, "N2", 304, 1), -("Escluso art. 5", 0, 0, 1, "N2", 305, 1), -("Esc.art7tr noUE", 0, 0, 1, "N2", 306, 1), -("Escl.art7ter UE", 0, 0, 1, "N6", 307, 1), -("Es. art.10 n.18", 0, 0, 1, "N4", 308, 1), -("Es.art.10 n.1/9", 0, 0, 1, "N4", 309, 1), -("Esente art. 10", 0, 0, 1, "N4", 310, 1), -("Art8,1/a triang", 0, 0, 1, "N3", 311, 1), -("N.I.art.8,2 ITA", 0, 0, 1, "N3", 312, 1), -("N.I.art.8,2 UE", 0, 0, 1, "N3", 313, 1), -("N.I. art. 9 c.1", 0, 0, 1, "N3", 314, 1), -("Escluso art. 15", 0, 0, 1, "N1", 315, 1), -("Art.17,6 let.a-", 0, 0, 1, "N6", 316, 1), -("N.I. art.74 ter", 0, 0, 1, "N5", 317, 1), -("N.I.art.14 L.49", 0, 0, 1, "N3", 318, 1), -("Es.art.10 n.27q", 0, 0, 1, "N4", 319, 1), -("N.I.a.8,2 no-UE", 0, 0, 1, "N3", 320, 1), -("Es. art.10 n.11", 0, 0, 1, "N4", 321, 1), -("N.I. art. 8 bis", 0, 0, 1, "N3", 322, 1), -("N.I. art.8,1 b", 0, 0, 1, "N3", 323, 1), -("N.I. art.8,1 c", 0, 0, 1, "N3", 324, 1), -("N.I. art.8,1 a", 0, 0, 1, "N3", 325, 1), -("N.V.escl.art.26", 0, 0, 1, "N2", 326, 1), -("N.I. altri acq.", 0, 0, 1, "N3", 327, 1), -("Op. non sog.ter", 0, 0, 1, "N2", 328, 1), -("N.I. art. 9 c.2", 0, 0, 1, "N3", 329, 1), -("Esc.art7quatrUE", 0, 0, 1, "N6", 330, 1), -("Esc.art7qtrNOUE", 0, 0, 1, "N2", 331, 1), -("Esc.art7quinqUE", 0, 0, 1, "N6", 332, 1), -("Esc.art7qnqNOUE", 0, 0, 1, "N2", 333, 1), -("Art.36-bis", 0, 0, 1, "N2", 334, 1), -("Art.17 comma 3", 0, 0, 1, "N2", 335, 1), -("DL41/95 art.36", 0, 0, 1, "N5", 336, 1), -("Es.art.19c3abis", 0, 0, 1, "N4", 337, 1), -("N.I. art.38 q.", 0, 0, 1, "N3", 338, 1), -("Escl.art.7nodet", 0, 0, 1, "N2", 339, 1), -("Esc.art.7spt/sx", 0, 0, 1, "N2", 340, 1), -("DL331/93 art.41", 0, 0, 1, "N3", 341, 1), -("DL331art42,40c2", 0, 0, 1, "N3", 342, 1), -("N.I.art.8,1 b2", 0, 0, 1, "N3", 343, 1), -("Escl.art.7bisUE", 0, 0, 1, "N6", 344, 1), -("DL331 a.50b,4-g", 0, 0, 1, "N3", 350, 1), -("DL331 a.50b,4-f", 0, 0, 1, "N3", 351, 1), -("Cess. dep. IVA", 0, 0, 1, "N2", 352, 1), -("N.I.Acq.dep.IVA", 0, 0, 1, "N2", 353, 1), -("Es.art1 L190/14", 0, 0, 1, "N2", 354, 1), -("Ces.gratuiteExp", 0, 0, 1, "N3", 355, 1), -("DL331/93 a.58,1", 0, 0, 1, "N3", 358, 1), -("Esc.legge67/88", 0, 0, 1, "N2", 367, 1), -("Imp.n.s. art.68", 0, 0, 1, "N3", 368, 1), -("Art.74 ter c. 8", 0, 0, 1, "N6", 369, 1), -("Escl.art.7bis", 0, 0, 1, "N2", 370, 1), -("N.I.art.71 V-SM", 0, 0, 1, "N3", 371, 1), -("N.I. art. 72", 0, 0, 1, "N3", 372, 1), -("N.I.art.74c.1-2", 0, 0, 1, "N2", 374, 1), -("Art. 74 c. 7-8", 0, 0, 1, "N6", 375, 1), -("Art. 17 c. 5", 0, 0, 1, "N6", 376, 1), -("Art.17,6 lett.a", 0, 0, 1, "N6", 377, 1), -("Art.74 ter c. 8", 0, 0, 1, "N3", 378, 1), -("Art.17,6 lett.b", 0, 0, 1, "N6", 379, 1), -("Art.17,6 lett.c", 0, 0, 1, "N6", 380, 1), -("Art.17,6 let.a3", 0, 0, 1, "N6", 381, 1), -("Art.17,6,lett.d", 0, 0, 1, "N6", 382, 1), -("Aliq. Iva 2%", 2, 0, 0, NULL, 2, 1), -("Aliq. Iva 4%", 4, 0, 0, NULL, 4, 1), -("Aliq. Iva 5%", 5, 0, 0, NULL, 5, 1), -("Aliq. Iva 7%", 7, 0, 0, NULL, 7, 1), -("Aliq. Iva 8%", 8, 0, 0, NULL, 8, 1), -("Aliq. Iva 10%", 10, 0, 0, NULL, 10, 1), -("Aliq. Iva 12,3%", 12.3, 0, 0, NULL, 13, 1), -("Aliq. Iva 20%", 20, 0, 0, NULL, 20, 1), -("Aliq. Iva 21%", 21, 0, 0, NULL, 21, 1), -("Aliq. Iva 22%", 22, 0, 0, NULL, 22, 1), -("Aliq. Iva 7,3%", 7.3, 0, 0, NULL, 73, 1), -("Aliq. Iva 7,5%", 7.5, 0, 0, NULL, 75, 1), -("Aliq. Iva 7,65%", 7.65, 0, 0, NULL, 76, 1), -("Aliq. Iva 7,7%", 7.7, 0, 0, NULL, 77, 1), -("Aliq. Iva 7,95%", 7.95, 0, 0, NULL, 79, 1), -("Aliq. Iva 8,3%", 8.3, 0, 0, NULL, 83, 1), -("Aliq. Iva 8,5%", 8.5, 0, 0, NULL, 85, 1), -("Aliq. Iva 8,8%", 8.8, 0, 0, NULL, 88, 1), -("Scorporo 2%", 2, 0, 0, NULL, 102, 1), -("Scorporo 4%", 4, 0, 0, NULL, 104, 1), -("Scorporo 5%", 5, 0, 0, NULL, 105, 1), -("Scorporo 7%", 7, 0, 0, NULL, 107, 1), -("Scorporo 8%", 8, 0, 0, NULL, 108, 1), -("Scorporo 10%", 10, 0, 0, NULL, 110, 1), -("Scorporo 12,3%", 12.3, 0, 0, NULL, 113, 1), -("Scorporo 20%", 20, 0, 0, NULL, 120, 1), -("Scorporo 21%", 21, 0, 0, NULL, 121, 1), -("Scorporo 22%", 22, 0, 0, NULL, 122, 1), -("Scorporo 7,3%", 7.3, 0, 0, NULL, 173, 1), -("Scorporo 7,5%", 7.5, 0, 0, NULL, 175, 1), -("Scorporo 7,65%", 7.65, 0, 0, NULL, 176, 1), -("Scorporo 7,7%", 7.7, 0, 0, NULL, 177, 1), -("Scorporo 7,95%", 7.95, 0, 0, NULL, 179, 1), -("Scorporo 8,3%", 8.3, 0, 0, NULL, 183, 1), -("Scorporo 8,5%", 8.5, 0, 0, NULL, 185, 1), -("Scorporo 8,8%", 8.8, 0, 0, NULL, 188, 1), -("Corr. Ventilati", 0, 0, 0, NULL, 200, 1), -("Iva Vent. 2%", 2, 0, 0, NULL, 202, 1), -("Iva Vent. 4%", 4, 0, 0, NULL, 204, 1), -("Iva Vent. 5%", 5, 0, 0, NULL, 205, 1), -("Iva Vent. 7%", 7, 0, 0, NULL, 207, 1), -("Iva Vent. 8%", 8, 0, 0, NULL, 208, 1), -("Iva Vent. 10%", 10, 0, 0, NULL, 210, 1), -("Iva Vent. 12,3%", 12.3, 0, 0, NULL, 213, 1), -("Iva Vent. 20%", 20, 0, 0, NULL, 220, 1), -("Iva Vent. 21%", 21, 0, 0, NULL, 221, 1), -("Iva Vent. 22%", 22, 0, 0, NULL, 222, 1), -("Iva Vent. 7,3%", 7.3, 0, 0, NULL, 273, 1), -("Iva Vent. 7,5%", 7.5, 0, 0, NULL, 275, 1), -("Iva Vent. 7,65%", 7.65, 0, 0, NULL, 276, 1), -("Iva Vent. 7,7%", 7.7, 0, 0, NULL, 277, 1), -("Iva Vent. 7,95%", 7.95, 0, 0, NULL, 279, 1), -("Iva Vent. 8,3%", 8.3, 0, 0, NULL, 283, 1), -("Iva Vent. 8,5%", 8.5, 0, 0, NULL, 285, 1), -("Iva Vent. 8,8%", 8.8, 0, 0, NULL, 288, 1), -("Iva Tot. Indetr 2%", 2, 100, 0, NULL, 602, 1), -("Iva Tot. Indetr 4%", 4, 100, 0, NULL, 604, 1), -("Iva Tot. Indetr 5%", 5, 100, 0, NULL, 605, 1), -("Iva Tot. Indetr 7%", 7, 100, 0, NULL, 607, 1), -("Iva Tot. Indetr 8%", 8, 100, 0, NULL, 608, 1), -("Iva Tot. Indetr 10%", 10, 100, 0, NULL, 610, 1), -("Iva Tot. Indetr 12,3%", 12.3, 100, 0, NULL, 613, 1), -("Iva Tot. Indetr 20%", 20, 100, 0, NULL, 620, 1), -("Iva Tot. Indetr 21%", 21, 100, 0, NULL, 621, 1), -("Iva Tot. Indetr 22%", 22, 100, 0, NULL, 622, 1), -("Iva Tot. Indetr 7,3%", 7.3, 100, 0, NULL, 673, 1), -("Iva Tot. Indetr 7,5%", 7.5, 100, 0, NULL, 675, 1), -("Iva Tot. Indetr 7,65%", 7.65, 100, 0, NULL, 676, 1), -("Iva Tot. Indetr 7,7%", 7.7, 100, 0, NULL, 677, 1), -("Iva Tot. Indetr 7,95%", 7.95, 100, 0, NULL, 679, 1), -("Iva Tot. Indetr 8,3%", 8.3, 100, 0, NULL, 683, 1), -("Iva Tot. Indetr 8,5%", 8.5, 100, 0, NULL, 685, 1), -("Iva Tot. Indetr 8,8%", 8.8, 100, 0, NULL, 688, 1), -("Iva Agric. 2%", 2, 0, 0, NULL, 802, 1), -("Iva Agric. 4%", 4, 0, 0, NULL, 804, 1), -("Iva Agric. 5%", 5, 0, 0, NULL, 805, 1), -("Iva Agric. 7%", 7, 0, 0, NULL, 807, 1), -("Iva Agric. 8%", 8, 0, 0, NULL, 808, 1), -("Iva Agric. 10%", 10, 0, 0, NULL, 810, 1), -("Iva Agric. 12,3", 12.3, 0, 0, NULL, 813, 1), -("Iva Agric. 20%", 20, 0, 0, NULL, 820, 1), -("Iva Agric. 21%", 21, 0, 0, NULL, 821, 1), -("Iva Agric. 22%", 22, 0, 0, NULL, 822, 1), -("Iva Agric. 7,3%", 7.3, 0, 0, NULL, 873, 1), -("Iva Agric. 7,5%", 7.5, 0, 0, NULL, 875, 1), -("Iva Agric. 7,65", 7.65, 0, 0, NULL, 876, 1), -("Iva Agric. 7,7%", 7.7, 0, 0, NULL, 877, 1), -("Iva Agric. 7,95", 7.95, 0, 0, NULL, 879, 1), -("Iva Agric. 8,3%", 8.3, 0, 0, NULL, 883, 1), -("Iva Agric. 8,5%", 8.5, 0, 0, NULL, 885, 1), -("Iva Agric. 8,8%", 8.8, 0, 0, NULL, 888, 1); - -CREATE TABLE IF NOT EXISTS `fe_causali_pagamento_ritenuta` ( - `codice` varchar(4) NOT NULL, - `descrizione` varchar(1000) NOT NULL, - PRIMARY KEY (`codice`) -) ENGINE=InnoDB; - -INSERT INTO `fe_causali_pagamento_ritenuta` (`codice`, `descrizione`) VALUES -('A', 'Prestazioni di lavoro autonomo rientranti nell''esercizio di arte o professione abituale'), -('B', 'Utilizzazione economica, da parte dell''autore o dell''inventore, di opere dell''ingegno, di brevetti industriali e di processi, formule o informazioni relativi a esperienze acquisite in campo industriale, commerciale o scientifico'), -('C', 'Utili derivanti da contratti di associazione in partecipazione e da contratti di cointeressenza, quando l''apporto è costituito esclusivamente dalla prestazione di lavoro'), -('D', 'Utili spettanti ai soci promotori e ai soci fondatori delle società di capitali'), -('E', 'Levata di protesti cambiari da parte dei segretari comunali'), -('G', 'Indennità corrisposte per la cessazione di attività sportiva professionale'), -('H', 'Indennità corrisposte per la cessazione dei rapporti di agenzia delle persone fisiche e delle società di persone, con esclusione delle somme maturate entro il 31.12.2003, già imputate per competenza e tassate come reddito d''impresa'), -('I', 'Indennità corrisposte per la cessazione da funzioni notarili'), -('L', 'Utilizzazione economica, da parte di soggetto diverso dall''autore o dall''inventore, di opere dell''ingegno, di brevetti industriali e di processi, formule e informazioni relative a esperienze acquisite in campo industriale, commerciale o scientifico'), -('M', 'Prestazioni di lavoro autonomo non esercitate abitualmente, obblighi di fare, di non fare o permettere'), -('N', 'Indennità di trasferta, rimborso forfetario di spese, premi e compensi erogati nell''esercizio diretto di attività sportive dilettantistiche e in relazione a rapporti di collaborazione coordinata e continuativa di carattere amministrativo-gestionale, di natura non profe -ssionale, resi a favore di società e associazioni sportive dilettantistiche e di cori, bande e filodrammatiche da parte del diretto -re e dei collaboratori tecnici'), -('O', 'Prestazioni di lavoro autonomo non esercitate abitualmente, obblighi di fare, di non fare o permettere, per le quali non sussiste l''obbligo di iscrizione alla gestione separata (Circ. Inps 104/2001)'), -('P', 'Compensi corrisposti a soggetti non residenti privi di stabile organizzazione per l''uso o la concessione in uso di attrezzature industriali, commerciali o scientifiche che si trovano nel territorio dello Stato ovvero a società svizzere o stabili organizzazioni di soci -età svizzere che possiedono i requisiti di cui all''art. 15, c. 2 dell’Accordo tra la Comunità Europea e la Confederazione svizzera del 26.10 -.2004 (pubblicato in G.U.C.E. 29.12.2004, n. 385/30)'), -('Q', 'Provvigioni corrisposte ad agente o rappresentante di commercio monomandatario'), -('R', 'Provvigioni corrisposte ad agente o rappresentante di commercio plurimandatario'), -('S', 'Provvigioni corrisposte a commissionario'), -('T', 'Provvigioni corrisposte a mediatore'), -('U', 'Provvigioni corrisposte a procacciatore di affari'), -('V', 'Provvigioni corrisposte a incaricato per le vendite a domicilio e provvigioni corrisposte a incaricato per la vendita porta a porta e per la vendita ambulante di giornali quotidiani e periodici (L. 25.02.1987, n. 67)'), -('W', 'Corrispettivi erogati nel 2013 per prestazioni relative a contratti d''appalto cui si sono resi applicabili le disposizioni contenute nell''art. 25-ter D.P.R. 600/1973'), -('X', 'Canoni corrisposti nel 2004 da società o enti residenti, ovvero da stabili organizzazioni di società estere di cui all''art. 26-quater, c. 1, lett. a) e b) D.P.R. 600/1973, a società o stabili organizzazioni di società, situate in altro Stato membro dell''Unione Europea in presenza dei relativi requisiti richiesti, per i quali è stato effettuato nel 2006 il rimborso della ritenuta ai sensi dell''art. 4 D. Lgs. 143/2005'), -('Y', 'Canoni corrisposti dal 1.01.2005 al 26.07.2005 da soggetti di cui al punto precedente'), -('Z', 'Titolo diverso dai precedenti'); - -INSERT INTO `zz_settings` (`idimpostazione`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES (NULL, 'Causale ritenuta d''acconto', '', 'query=SELECT codice AS id, descrizione FROM fe_causali_pagamento_ritenuta', 1, 'Fatturazione Elettronica', 3); - -INSERT INTO `zz_settings` (`idimpostazione`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES (NULL, 'Authorization ID Indice PA', '', 'string', 1, 'Fatturazione Elettronica', 4); - -ALTER TABLE `an_anagrafiche` ADD `codice_destinatario` varchar(7); - --- Plugin Fatturazione Elettronica -INSERT INTO `zz_plugins` (`id`, `name`, `title`, `idmodule_from`, `idmodule_to`, `position`, `directory`, `options`) VALUES -(NULL, 'Fatturazione Elettronica', 'Fatturazione Elettronica', (SELECT `id` FROM `zz_modules` WHERE `name`='Fatture di vendita'), (SELECT `id` FROM `zz_modules` WHERE `name`='Fatture di vendita'), 'tab', 'exportPA', 'custom'), -(NULL, 'Fatturazione Elettronica', 'Fatturazione Elettronica', (SELECT `id` FROM `zz_modules` WHERE `name`='Fatture di vendita'), (SELECT `id` FROM `zz_modules` WHERE `name`='Fatture di acquisto'), 'tab_main', 'importPA', 'custom'); - -UPDATE `zz_emails` SET `main` = 1 WHERE `name` = 'Fattura' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'); - --- Aggiornamento zz_settings -ALTER TABLE `zz_settings` CHANGE `idimpostazione` `id` int(11) NOT NULL AUTO_INCREMENT; -UPDATE `zz_views` SET `query` = REPLACE(`query`, 'idimpostazione', 'id'); - --- Aggiunta conti in Articoli -ALTER TABLE `mg_articoli` ADD `idconto_vendita` int(11), ADD `idconto_acquisto` int(11); - --- Aggiunta log per invio email -CREATE TABLE IF NOT EXISTS `zz_operations` ( - `id_module` int(11), - `id_plugin` int(11), - `id_email` int(11), - `id_record` int(11), - `id_utente` int(11) NOT NULL, - `op` varchar(255) NOT NULL, - `options` text, - FOREIGN KEY (`id_module`) REFERENCES `zz_modules`(`id`) ON DELETE CASCADE, - FOREIGN KEY (`id_plugin`) REFERENCES `zz_plugins`(`id`) ON DELETE CASCADE, - FOREIGN KEY (`id_email`) REFERENCES `zz_emails`(`id`) ON DELETE CASCADE, - FOREIGN KEY (`id_utente`) REFERENCES `zz_users`(`id`) ON DELETE CASCADE -) ENGINE=InnoDB; - -ALTER TABLE `zz_smtp` RENAME `zz_smtps`; - --- Aggiorno tabella zz_smtp in zz_smtps per il modulo Account email -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM zz_smtps WHERE 1=1 AND deleted_at IS NULL HAVING 2=2 ORDER BY `name`' WHERE `zz_modules`.`name` = 'Account email'; - --- Ridenominazione enabled in visible su zz_views -ALTER TABLE `zz_views` CHANGE `enabled` `visible` BOOLEAN NOT NULL DEFAULT 1; - --- Rimozione permessi negati (comportamento di default) -DELETE FROM `zz_permissions` WHERE `permessi` = '-'; - --- Ridenominazione plugin "Pianificazione interventi" -UPDATE `zz_plugins` SET `title` = 'Pianificazione attività' WHERE `name` = 'Pianificazione interventi'; - --- Fix plugin "Pianificazione interventi" -UPDATE `zz_plugins` SET `options` = 'custom', `script` = '', `directory` = 'pianificazione_interventi' WHERE `name` = 'Pianificazione interventi'; - --- Ridenominazione tabelle per i promemoria -ALTER TABLE `co_contratti_promemoria` RENAME `co_promemoria`; -ALTER TABLE `co_righe_contratti_materiali` RENAME `co_promemoria_righe`; -ALTER TABLE `co_righe_contratti_articoli` RENAME `co_promemoria_articoli`; -ALTER TABLE `co_promemoria_righe` CHANGE `id_riga_contratto` `id_promemoria` int(11) NOT NULL; -ALTER TABLE `co_promemoria_articoli` CHANGE `id_riga_contratto` `id_promemoria` int(11) NOT NULL; -UPDATE `zz_widgets` SET `query` = REPLACE(`query`, 'co_contratti_promemoria', 'co_promemoria'); - --- Fix nome in zz_files -ALTER TABLE `zz_files` CHANGE `nome` `name` varchar(255) NOT NULL; -UPDATE `zz_files` SET `id_module` = NULL WHERE `id_plugin` IS NOT NULL; - --- Adeguamento variabili di filtraggio -UPDATE `zz_modules` SET `options` = REPLACE(`options`, '|idanagrafica|', '|id_anagrafica|'), `options2` = REPLACE(`options2`, '|idanagrafica|', '|id_anagrafica|'); -UPDATE `zz_plugins` SET `options` = REPLACE(`options`, '|idanagrafica|', '|id_anagrafica|'), `options2` = REPLACE(`options2`, '|idanagrafica|', '|id_anagrafica|'); -UPDATE `zz_widgets` SET `query` = REPLACE(`query`, '|idanagrafica|', '|id_anagrafica|'); -UPDATE `zz_group_module` SET `clause` = REPLACE(`clause`, '|idanagrafica|', '|id_anagrafica|'); - -UPDATE `zz_modules` SET `options` = REPLACE(`options`, '|idtecnico|', '|id_anagrafica|'), `options2` = REPLACE(`options2`, '|idtecnico|', '|id_anagrafica|'); -UPDATE `zz_plugins` SET `options` = REPLACE(`options`, '|idtecnico|', '|id_anagrafica|'), `options2` = REPLACE(`options2`, '|idtecnico|', '|id_anagrafica|'); -UPDATE `zz_widgets` SET `query` = REPLACE(`query`, '|idtecnico|', '|id_anagrafica|'); -UPDATE `zz_group_module` SET `clause` = REPLACE(`clause`, '|idtecnico|', '|id_anagrafica|'); - -UPDATE `zz_modules` SET `options` = REPLACE(`options`, '|idagente|', '|id_anagrafica|'), `options2` = REPLACE(`options2`, '|idagente|', '|id_anagrafica|'); -UPDATE `zz_plugins` SET `options` = REPLACE(`options`, '|idagente|', '|id_anagrafica|'), `options2` = REPLACE(`options2`, '|idagente|', '|id_anagrafica|'); -UPDATE `zz_widgets` SET `query` = REPLACE(`query`, '|idagente|', '|id_anagrafica|'); -UPDATE `zz_group_module` SET `clause` = REPLACE(`clause`, '|idagente|', '|id_anagrafica|'); - --- Adeguamento variabili di filtraggio per i plugin Sedi e Referenti in Anagrafiche -UPDATE `zz_plugins` SET `script` = '', `options` = ' { "main_query": [ { "type": "table", "fields": "Nome, Indirizzo, Città, CAP, Provincia, Referente", "query": "SELECT an_sedi.id, an_sedi.nomesede AS Nome, an_sedi.indirizzo AS Indirizzo, an_sedi.citta AS Città, an_sedi.cap AS CAP, an_sedi.provincia AS Provincia, an_referenti.nome AS Referente FROM an_sedi LEFT OUTER JOIN an_referenti ON idsede = an_sedi.id WHERE 1=1 AND an_sedi.idanagrafica=|id_parent| HAVING 2=2 ORDER BY an_sedi.id DESC"} ]}', `directory` = 'sedi', `version` = '2.3', `compatibility` = '2.*' WHERE `name` = 'Sedi'; -UPDATE `zz_plugins` SET `script` = '', `options` = ' { "main_query": [ { "type": "table", "fields": "Nominativo, Mansione, Telefono, Indirizzo email, Sede", "query": "SELECT an_referenti.id, an_referenti.nome AS Nominativo, mansione AS Mansione, an_referenti.telefono AS Telefono, an_referenti.email AS ''Indirizzo email'', IF(idsede = 0, ''Sede legale'', an_sedi.nomesede) AS Sede FROM an_referenti LEFT OUTER JOIN an_sedi ON idsede = an_sedi.id WHERE 1=1 AND an_referenti.idanagrafica=|id_parent| HAVING 2=2 ORDER BY an_referenti.id DESC"} ]}', `directory` = 'referenti', `version` = '2.3', `compatibility` = '2.*' WHERE `name` = 'Referenti'; - -UPDATE `an_referenti` SET `idsede` = 0 WHERE `idsede` = -1; - --- Rimozione co_preventivi_interventi -ALTER TABLE `in_interventi` ADD `id_preventivo` int(11), ADD FOREIGN KEY (`id_preventivo`) REFERENCES `co_preventivi`(`id`) ON DELETE CASCADE, ADD `id_contratto` int(11), ADD FOREIGN KEY (`id_contratto`) REFERENCES `co_contratti`(`id`) ON DELETE CASCADE; -UPDATE `in_interventi` SET `id_preventivo` = (SELECT `idpreventivo` FROM `co_preventivi_interventi` WHERE `co_preventivi_interventi`.`idintervento` = `in_interventi`.`id` LIMIT 1); -DROP TABLE `co_preventivi_interventi`; - --- Aggiunto input CKEditor automatico -UPDATE `zz_settings` SET `tipo` = 'ckeditor' WHERE `nome` = 'Dicitura fissa fattura'; - --- Miglioramento dell'impostazione "Orario lavorativo" -UPDATE `zz_settings` SET `sezione` = 'Dashboard' WHERE `nome` IN ('Vista dashboard', 'Visualizzare la domenica sul calendario', 'Utilizzare i tooltip sul calendario'); -DELETE FROM `zz_settings` WHERE `nome` = 'Abilitare orario lavorativo'; -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES -(NULL, 'Inizio orario lavorativo', '00:00:00', 'time', 1, 'Dashboard', 1), -(NULL, 'Fine orario lavorativo', '23:59:00', 'time', 1, 'Dashboard', 2); - --- Notifiche negli stati interventi -ALTER TABLE `in_statiintervento` ADD `notifica` boolean NOT NULL DEFAULT 0, ADD `id_email` int(11), ADD `destinatari` varchar(255); -ALTER TABLE `in_statiintervento` ADD FOREIGN KEY (`id_email`) REFERENCES `zz_emails`(`id`) ON DELETE CASCADE; - --- Email di notifica -INSERT INTO `zz_emails` (`id`, `id_module`, `id_smtp`, `name`, `icon`, `subject`, `reply_to`, `cc`, `bcc`, `body`, `read_notify`, `main`) VALUES -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), 1, 'Notifica intervento', 'fa fa-envelope', 'Notifica intervento numero {numero} del {data}', '', '', '', '

    Gentile Tecnico,

    \r\n

    un nuovo intervento {numero} in {data} è stato aggiunto.

    \r\n

     

    \r\n

    Distinti saluti

    \r\n', '0', '0'), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), 1, 'Notifica rimozione intervento', 'fa fa-envelope', 'Notifica intervento numero {numero} del {data}', '', '', '', '

    Gentile Tecnico,

    \r\n

    sei stato rimosso dall''intervento {numero} in {data}.

    \r\n

     

    \r\n

    Distinti saluti

    \r\n', '0', '0'), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), 1, 'Stato intervento', 'fa fa-envelope', 'Intervento numero {numero} del {data}: {stato}.', '', '', '', '

    Gentile Utente,

    \r\n

    l''intervento {numero} in {data} è stato spostato nello stato {stato}.

    ', '0', '0'); - -INSERT INTO `zz_email_print` (`id`, `id_email`, `id_print`) VALUES -(NULL, (SELECT `id` FROM `zz_emails` WHERE `name` = 'Stato intervento' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi')), (SELECT `id` FROM `zz_prints` WHERE `name` = 'Intervento')); - -UPDATE `zz_emails` SET `main` = 1 WHERE `name` = 'Rapportino intervento' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'); -UPDATE `in_statiintervento` SET `id_email` = (SELECT `id` FROM `zz_emails` WHERE `name` = 'Stato intervento' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi')); - --- Ritenuta d'acconto predefinita per anagrafica -ALTER TABLE `an_anagrafiche` ADD `id_ritenuta_acconto_vendite` INT(11) NULL DEFAULT NULL AFTER `idiva_acquisti`; -ALTER TABLE `an_anagrafiche` ADD `id_ritenuta_acconto_acquisti` INT(11) NULL DEFAULT NULL AFTER `id_ritenuta_acconto_vendite`; - --- Correzione partite ive e codici fiscali -UPDATE `an_anagrafiche` SET `piva` = REPLACE(`piva`, ' ', ''), `codice_fiscale` = REPLACE(`codice_fiscale`, ' ', ''); - --- Aggiunta impostazione -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES (NULL, 'Stampa per anteprima e firma', (SELECT id FROM zz_prints WHERE main = 1 AND id_module = (SELECT id FROM zz_modules WHERE name = 'Interventi')), 'query=SELECT id, title AS descrizione FROM zz_prints WHERE id_module = (SELECT id FROM zz_modules WHERE name = ''Interventi'') AND is_record = 1', 1, 'Interventi', 3); - --- Fix nomi campi predefined -ALTER TABLE `zz_smtps` CHANGE `main` `predefined` boolean NOT NULL DEFAULT 0; -ALTER TABLE `zz_prints` CHANGE `main` `predefined` boolean NOT NULL DEFAULT 0; -ALTER TABLE `zz_emails` CHANGE `main` `predefined` boolean NOT NULL DEFAULT 0; -ALTER TABLE `dt_porto` ADD `predefined` boolean NOT NULL DEFAULT 0; -ALTER TABLE `dt_causalet` ADD `predefined` boolean NOT NULL DEFAULT 0; -ALTER TABLE `dt_spedizione` ADD `predefined` boolean NOT NULL DEFAULT 0; - --- Aggiunta tabelle per la gestione dei tipi spedizione -INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Tipi di spedizione', 'Tipi di spedizione', 'spedizioni', 'SELECT |select| FROM `dt_spedizione` WHERE 1=1 HAVING 2=2', '', 'fa fa-angle-right', '2.4.2', '2.4.2', '1', NULL, '1', '1'); - -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Tipi di spedizione' AND `t2`.`name` = 'Tabelle') SET `t1`.`parent` = `t2`.`id`; - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `visible`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi di spedizione'), 'Descrizione', 'descrizione', 2, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi di spedizione'), 'id', 'id', 1, 1, 0, 0, 1); - --- Aggiunto flag fiscale nei sezionali -ALTER TABLE `zz_segments` ADD `is_fiscale` boolean NOT NULL DEFAULT 1; - -INSERT INTO `zz_segments` (`id_module`, `name`, `clause`, `position`, `pattern`,`note`, `predefined`, `is_fiscale`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'), 'Fatture pro-forma', '1=1', 'WHR', 'PRO-###', '', 0, 0); - --- Fix campi di ricerca -UPDATE `zz_modules` SET `options` = "SELECT |select| FROM `zz_segments` WHERE 1=1 HAVING 2=2 ORDER BY name, id_module" WHERE `name` = 'Segmenti'; -INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `visible`, `summable`, `default`) VALUES -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Segmenti'), 'id', 'id', 0, 0, 0, 0, 0, 0, 1), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Segmenti'), 'Nome', 'name', 1, 1, 0, 0, 1, 0, 1), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Segmenti'), 'Modulo', '(SELECT name FROM zz_modules WHERE zz_modules.id = zz_segments.id_module)', 2, 1, 0, 0, 1, 0, 1), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Segmenti'), 'Maschera', 'pattern', 3, 1, 0, 0, 1, 0, 1), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Segmenti'), 'Note', 'note', 4, 1, 0, 0, 1, 0, 1), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Segmenti'), 'Predefinito', 'IF(predefined=1, ''Sì'', ''No'')', 5, 1, 0, 0, 1, 0, 1); - -UPDATE `zz_views` SET `search` = 1 WHERE `name` = 'Nome' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Banche'); -UPDATE `zz_views` SET `search` = 1 WHERE `name` = 'Filiale' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Banche'); -UPDATE `zz_views` SET `search` = 1 WHERE `name` = 'IBAN' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Banche'); - --- Fix Date emissione nello Scadenzario -UPDATE `zz_views` SET `query` = 'data_emissione', `format` = '1' WHERE `zz_views`.`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Scadenzario') AND name = 'Data emissione'; - --- Normalizzazione default e predefined -ALTER TABLE `zz_views` CHANGE `default` `default` boolean NOT NULL DEFAULT 0; -ALTER TABLE `zz_prints` CHANGE `default` `default` boolean NOT NULL DEFAULT 0; -ALTER TABLE `an_tipianagrafiche` CHANGE `default` `default` boolean NOT NULL DEFAULT 0; -ALTER TABLE `an_zone` CHANGE `default` `default` boolean NOT NULL DEFAULT 0; -ALTER TABLE `zz_modules` CHANGE `default` `default` boolean NOT NULL DEFAULT 0; - -ALTER TABLE `zz_segments` CHANGE `predefined` `predefined` boolean NOT NULL DEFAULT 0; - --- Fix colore per fatture senza numero esterno -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|'') > 1, ''red'', '''')' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita') AND `name` = '_bg_'; - --- Campi per la gestione revisioni -ALTER TABLE `co_preventivi` ADD `master_revision` INT NOT NULL AFTER `tipo_sconto_globale`, ADD `default_revision` TINYINT(1) NOT NULL AFTER `master_revision`; - --- Plugin revisioni -INSERT INTO `zz_plugins` (`id`, `name`, `title`, `idmodule_from`, `idmodule_to`, `position`, `script`, `enabled`, `default`, `order`, `compatibility`, `version`, `options2`, `options`, `directory`, `help`) VALUES (NULL, 'Revisioni', 'Revisioni', (SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi'), (SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi'), 'tab', '', 1, 0, 0, '', '', NULL, 'custom', 'revisioni', ''); - --- Modifica modulo preventivi per revisioni -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_preventivi` WHERE 1=1 AND default_revision=1 HAVING 2=2 AND ((\'|period_start|\' >= `data_bozza` AND \'|period_start|\' <= `data_conclusione`) OR (\'|period_end|\' >= `data_bozza` AND \'|period_end|\' <= `data_conclusione`) OR (`data_bozza` >= \'|period_start|\' AND `data_bozza` <= \'|period_end|\') OR (`data_conclusione` >= \'|period_start|\' AND `data_conclusione` <= \'|period_end|\') OR (`data_bozza` >= \'|period_start|\' AND `data_conclusione` = \'0000-00-00\')) ORDER BY `id` DESC' WHERE `zz_modules`.`name` = 'Preventivi'; - --- Mi assicuro che non ci siano righe del preventivo collegate a preventivi non più esistenti -DELETE FROM co_righe_preventivi WHERE idpreventivo NOT IN (SELECT id FROM co_preventivi); - --- Chiave secondaria per le righe del preventivo -ALTER TABLE `co_righe_preventivi` ADD FOREIGN KEY (`idpreventivo`) REFERENCES `co_preventivi`(`id`) ON DELETE CASCADE; - --- Tabella categorie -CREATE TABLE IF NOT EXISTS `my_impianti_categorie` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `nome` varchar(255) NOT NULL, - `colore` varchar(255) NOT NULL, - `nota` varchar(1000) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- Categoria impianto -ALTER TABLE `my_impianti` ADD `id_categoria` INT(11) AFTER `idanagrafica`, ADD FOREIGN KEY (`id_categoria`) REFERENCES `my_impianti_categorie`(`id`) ON DELETE SET NULL; - --- Rinominato Categorie in Categorie articoli -UPDATE `zz_modules` SET `name` = 'Categorie articoli', `title` = 'Categorie articoli', `directory` = 'categorie_articoli' WHERE `zz_modules`.`name` = 'Categorie'; - --- Modulo Categorie impianti -INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Categorie impianti', 'Categorie impianti', 'categorie_impianti', 'SELECT |select| FROM `my_impianti_categorie` WHERE 1=1 HAVING 2=2', '', 'fa fa-angle-right', '2.4.2', '2.4.2', '1', NULL, '1', '1'); -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Categorie impianti' AND `t2`.`name` = 'MyImpianti') SET `t1`.`parent` = `t2`.`id`; - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `visible`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Categorie impianti'), 'id', 'id', 1, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Categorie impianti'), 'Nome', 'nome', 2, 1, 0, 1, 1); - --- Per i preventivi già in essere imposto master_revision = id e default_revision = 1 -UPDATE `co_preventivi` SET `master_revision` = `id`, `default_revision` = 1; - --- Colonna natura iva e codice iva -INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `visible`, `summable`, `default`) VALUES -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'IVA'), 'Natura', 'codice_natura_fe', 2, 1, 0, 0, 1, 0, 1), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'IVA'), 'Codice', 'codice', 1, 1, 0, 0, 1, 0, 1); - --- Colonna codice modalità pagamento -INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `visible`, `summable`, `default`) VALUES -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Pagamenti'), 'Codice pagamento', 'CONCAT(codice_modalita_pagamento_fe, '' - '', (SELECT descrizione FROM fe_modalita_pagamento WHERE codice = codice_modalita_pagamento_fe) )', 2, 1, 0, 0, 1, 0, 1); - --- Fix plugin "Impianti del cliente" -UPDATE `zz_plugins` SET `options` = ' { "main_query": [ { "type": "table", "fields": "Matricola, Nome, Data, Descrizione", "query": "SELECT id, (SELECT `id` FROM `zz_modules` WHERE `name` = \'MyImpianti\') AS _link_module_, id AS _link_record_, matricola AS Matricola, nome AS Nome, DATE_FORMAT(data, \'%d/%m/%Y\') AS Data, descrizione AS Descrizione FROM my_impianti WHERE idanagrafica=|id_parent| HAVING 2=2 ORDER BY id DESC"} ]}' WHERE `zz_plugins`.`name` = 'Impianti del cliente'; - --- Fix plugin "Ddt del cliente" -UPDATE `zz_plugins` SET `options` = ' { "main_query": [ { "type": "table", "fields": "Numero, Data, Descrizione, Qtà", "query": "SELECT dt_ddt.id, (SELECT `id` FROM `zz_modules` WHERE `name` = \'Ddt di vendita\') AS _link_module_, dt_ddt.id AS _link_record_, IF(dt_ddt.numero_esterno = \'\', dt_ddt.numero, dt_ddt.numero_esterno) AS Numero, DATE_FORMAT(dt_ddt.data, \'%d/%m/%Y\') AS Data, dt_righe_ddt.descrizione AS `Descrizione`, REPLACE(REPLACE(REPLACE(FORMAT(dt_righe_ddt.qta, 2), \',\', \'#\'), \'.\', \',\'), \'#\', \'.\') AS `Qtà` FROM dt_ddt LEFT JOIN dt_righe_ddt ON dt_ddt.id=dt_righe_ddt.idddt WHERE dt_ddt.idanagrafica=|id_parent| GROUP BY dt_ddt.id HAVING 2=2 ORDER BY dt_ddt.id DESC"} ]}' WHERE `zz_plugins`.`name` = 'Ddt del cliente'; - --- Aggiunto codice cig e codice cup per contratti e interventi -ALTER TABLE `co_contratti` ADD `codice_cig` VARCHAR(15) AFTER `tipo_sconto_globale`, ADD `codice_cup` VARCHAR(15) AFTER `codice_cig`, ADD `id_documento_fe` VARCHAR(20) AFTER `codice_cup`; -ALTER TABLE `in_interventi` ADD `codice_cig` VARCHAR(15) AFTER `tipo_sconto_globale`, ADD `codice_cup` VARCHAR(15) AFTER `codice_cig`, ADD `id_documento_fe` VARCHAR(20) AFTER `codice_cup`; - --- Aggiunta data e ora generazione fattura elettronica -ALTER TABLE `co_documenti` ADD `xml_generated_at` TIMESTAMP NULL AFTER `codice_xml`; - --- Colonna nella vista fatture per indicare se è stato generato o meno il file xml -INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `visible`, `summable`, `default`) VALUES -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'), 'icon_FE', 'IF(xml_generated_at IS NOT NULL, \'fa fa-file-code-o text-success\', \'\')', 10, 1, 0, 0, 1, 0, 0), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'), 'icon_title_FE', 'IF(xml_generated_at IS NOT NULL, \'Generata\', \'\')', 10, 1, 0, 0, 0, 0, 0); - --- Colonna nella vista fatture per indicare se è stata inviata o meno la mail -INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `visible`, `summable`, `default`) VALUES -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'), 'icon_Inviata', 'IF((SELECT GROUP_CONCAT(DISTINCT`name` SEPARATOR \'\\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` = \'Fatture di vendita\') AND op = \'send-email\' AND id_record = co_documenti.id GROUP BY id_email) IS NOT NULL, \'fa fa-envelope text-success\', \'\')', 11, 1, 0, 0, 1, 0, 0), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'), 'icon_title_Inviata', '(SELECT GROUP_CONCAT(DISTINCT`name` SEPARATOR \'\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` = \'Fatture di vendita\') AND op = \'send-email\' AND id_record = co_documenti.id GROUP BY id_email)', 12, 1, 0, 0, 0, 0, 0); - - --- Colonna codice destinatario -INSERT INTO `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` = 'Anagrafiche'), 'Codice destinatario', 'codice_destinatario', 4, 1, 0, 0, NULL, NULL, 0, 0, 0); - --- Aggiungo descrizione per filtri -UPDATE `zz_group_module` SET `name` = 'Mostra agli agenti solo le anagrafiche di cui sono agenti' WHERE `zz_group_module`.`idgruppo` = (SELECT `id` FROM `zz_groups` WHERE `nome` = 'Agenti') AND `zz_group_module`.`idmodule` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Anagrafiche'); - -UPDATE `zz_group_module` SET `name` = 'Mostra ai tecnici solo le anagrafiche in cui sono coinvolti con delle attività' WHERE `zz_group_module`.`idgruppo` = (SELECT `id` FROM `zz_groups` WHERE `nome` = 'Tecnici') AND `zz_group_module`.`idmodule` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Anagrafiche'); - -UPDATE `zz_group_module` SET `name` = 'Mostra ai clienti solo la propria anagrafica' WHERE `zz_group_module`.`idgruppo` = (SELECT `id` FROM `zz_groups` WHERE `nome` = 'Clienti') AND `zz_group_module`.`idmodule` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Anagrafiche'); - -UPDATE `zz_group_module` SET `name` = 'Mostra ai clienti solo le proprie fatture' WHERE `zz_group_module`.`idgruppo` = (SELECT `id` FROM `zz_groups` WHERE `nome` = 'Clienti') AND `zz_group_module`.`idmodule` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'); - -UPDATE `zz_group_module` SET `name` = 'Mostra ai clienti solo le proprie fatture' WHERE `zz_group_module`.`idgruppo` = (SELECT `id` FROM `zz_groups` WHERE `nome` = 'Clienti') AND `zz_group_module`.`idmodule` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'); - -UPDATE `zz_group_module` SET `name` = 'Mostra agli agenti solo la prima nota delle anagrafiche di cui sono agenti' WHERE `zz_group_module`.`idgruppo` = (SELECT `id` FROM `zz_groups` WHERE `nome` = 'Agenti') AND `zz_group_module`.`idmodule` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Prima nota'); - -UPDATE `zz_group_module` SET `name` = 'Mostra ai clienti solo i propri impianti' WHERE `zz_group_module`.`idgruppo` = (SELECT `id` FROM `zz_groups` WHERE `nome` = 'Clienti') AND `zz_group_module`.`idmodule` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'MyImpianti'); - - --- Importazione dell'account email PEC -INSERT INTO `zz_smtps` (`id`, `name`, `note`, `server`, `port`, `username`, `password`, `from_name`, `from_address`, `encryption`, `pec`, `predefined`) VALUES (NULL, 'PEC aziendale', '', '', '', '', '', '', '', '', '1', '0'); - -INSERT INTO `zz_emails` (`id`, `id_module`, `id_smtp`, `name`, `icon`, `subject`, `reply_to`, `cc`, `bcc`, `body`, `read_notify`, `predefined`) VALUES (NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'), (SELECT `id` FROM `zz_smtps` WHERE `pec` = 1 LIMIT 0,1), 'PEC', 'fa fa-file', 'Invio fattura numero {numero} del {data}', '', 'sdi01@pec.fatturapa.it', '', '

    Gentile Cliente,

    \r\n

    inviamo in allegato la fattura numero {numero} del {data}.

    \r\n

     

    \r\n

    Distinti saluti

    \r\n', '0', '0'); - -INSERT INTO `zz_email_print` (`id`, `id_email`, `id_print`) VALUES (NULL, (SELECT `id` FROM `zz_emails` WHERE `name` = 'PEC' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita')), (SELECT `id` FROM `zz_prints` WHERE `name` = 'Fattura di vendita')); - --- Ridenominazione "Ddt di vendita" in "Ddt in uscita" -UPDATE `zz_modules` SET `title`='Ddt in uscita' WHERE `name`='Ddt di vendita'; -UPDATE `dt_tipiddt` SET `descrizione`='Ddt in uscita' WHERE `descrizione`='Ddt di vendita'; - --- Ridenominazione "Ddt di acquisto" in "Ddt in ingresso" -UPDATE `zz_modules` SET `title`='Ddt in entrata' WHERE `name`='Ddt di acquisto'; -UPDATE `dt_tipiddt` SET `descrizione`='Ddt in entrata' WHERE `descrizione`='Ddt di acquisto'; diff --git a/update/2_4_20.php b/update/2_4_20.php deleted file mode 100644 index 0a3855525..000000000 --- a/update/2_4_20.php +++ /dev/null @@ -1,119 +0,0 @@ - $value) { - $files[$key] = realpath(base_dir().'/'.$value); -} - -delete($files); - -/** - * Procedura per aggiustare alcuni campi di sconto ivato nei documenti prima della fattura - * in quanto veniva calcolato lo sconto ivato erroneamente. - */ - -// TODO: aggiornare procedura con query SQL esplicite invece che con i metodi che possono cambiare nel tempo -// Fix sconti contratti -$righe = $dbo->fetchArray('SELECT id, idiva, sconto_percentuale, sconto_unitario, tipo_sconto, prezzo_unitario FROM co_righe_contratti WHERE sconto_percentuale != 0 AND tipo_sconto="PRC"'); - -foreach ($righe as $riga) { - if (empty($riga['idarticolo'])) { - $this_riga = RigaContratto::find($riga['id']); - } else { - $this_riga = ArticoloContratto::find($riga['id']); - } - - if ($this_riga !== null) { - $this_riga->setPrezzoUnitario($riga['prezzo_unitario'], $riga['idiva']); - - if ($riga['tipo_sconto'] == 'PRC') { - $this_riga->setSconto($riga['sconto_percentuale'], $riga['tipo_sconto']); - } else { - $this_riga->setSconto($riga['sconto_unitario'], $riga['tipo_sconto']); - } - - $this_riga->save(); - } -} - -// Fix sconti preventivi -$righe = $dbo->fetchArray('SELECT id, idiva, sconto_percentuale, sconto_unitario, tipo_sconto, prezzo_unitario FROM co_righe_preventivi WHERE sconto_percentuale != 0 AND tipo_sconto="PRC"'); - -foreach ($righe as $riga) { - if (empty($riga['idarticolo'])) { - $this_riga = RigaPreventivo::find($riga['id']); - } else { - $this_riga = ArticoloPreventivo::find($riga['id']); - } - - if ($this_riga !== null) { - $this_riga->setPrezzoUnitario($riga['prezzo_unitario'], $riga['idiva']); - - if ($riga['tipo_sconto'] == 'PRC') { - $this_riga->setSconto($riga['sconto_percentuale'], $riga['tipo_sconto']); - } else { - $this_riga->setSconto($riga['sconto_unitario'], $riga['tipo_sconto']); - } - - $this_riga->save(); - } -} - -// Fix sconti ordini -$righe = $dbo->fetchArray('SELECT id, idiva, sconto_percentuale, sconto_unitario, tipo_sconto, prezzo_unitario FROM or_righe_ordini WHERE sconto_percentuale != 0 AND tipo_sconto="PRC"'); - -foreach ($righe as $riga) { - if (empty($riga['idarticolo'])) { - $this_riga = RigaOrdine::find($riga['id']); - } else { - $this_riga = ArticoloOrdine::find($riga['id']); - } - - if ($this_riga !== null) { - $this_riga->setPrezzoUnitario($riga['prezzo_unitario'], $riga['idiva']); - - if ($riga['tipo_sconto'] == 'PRC') { - $this_riga->setSconto($riga['sconto_percentuale'], $riga['tipo_sconto']); - } else { - $this_riga->setSconto($riga['sconto_unitario'], $riga['tipo_sconto']); - } - - $this_riga->save(); - } -} - -// Fix sconti ddt -$righe = $dbo->fetchArray('SELECT id, idiva, sconto_percentuale, sconto_unitario, tipo_sconto, prezzo_unitario FROM dt_righe_ddt WHERE sconto_percentuale != 0 AND tipo_sconto="PRC"'); - -foreach ($righe as $riga) { - if (empty($riga['idarticolo'])) { - $this_riga = RigaDDT::find($riga['id']); - } else { - $this_riga = ArticoloDDT::find($riga['id']); - } - - if ($this_riga !== null) { - $this_riga->setPrezzoUnitario($riga['prezzo_unitario'], $riga['idiva']); - - if ($riga['tipo_sconto'] == 'PRC') { - $this_riga->setSconto($riga['sconto_percentuale'], $riga['tipo_sconto']); - } else { - $this_riga->setSconto($riga['sconto_unitario'], $riga['tipo_sconto']); - } - - $this_riga->save(); - } -} diff --git a/update/2_4_20.sql b/update/2_4_20.sql deleted file mode 100644 index 58c413e74..000000000 --- a/update/2_4_20.sql +++ /dev/null @@ -1,234 +0,0 @@ -UPDATE `zz_modules` SET `name` = 'Piani di sconto/magg.' WHERE `name` = 'Listini'; - --- Creazione modulo Listini -INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Listini', 'Listini', 'listini', 'SELECT |select| -FROM mg_prezzi_articoli - INNER JOIN an_anagrafiche ON an_anagrafiche.idanagrafica = mg_prezzi_articoli.id_anagrafica - INNER JOIN mg_articoli ON mg_articoli.id = mg_prezzi_articoli.id_articolo -WHERE 1=1 AND mg_articoli.deleted_at IS NULL AND an_anagrafiche.deleted_at IS NULL -ORDER BY an_anagrafiche.ragione_sociale', '', 'fa fa-file-text-o', '2.4', '2.4', '1', NULL, '1', '1'); -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Listini' AND `t2`.`name` = 'Magazzino') SET `t1`.`parent` = `t2`.`id`; - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Listini'), 'id', 'mg_prezzi_articoli.id', 1, 1, 0, 1, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Listini'), 'Minimo', 'mg_prezzi_articoli.minimo', 4, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Listini'), 'Massimo', 'mg_prezzi_articoli.massimo', 5, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Listini'), 'Prezzo unitario', 'mg_prezzi_articoli.prezzo_unitario', 6, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Listini'), 'Sconto percentuale', 'mg_prezzi_articoli.sconto_percentuale', 7, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Listini'), 'Articolo', 'CONCAT(mg_articoli.codice, '' - '', mg_articoli.descrizione)', 2, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Listini'), 'Ragione sociale', 'an_anagrafiche.ragione_sociale', 3, 1, 0, 1, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Listini'), '_link_module_', '(SELECT id FROM zz_modules WHERE name = ''Articoli'')', 1, 1, 0, 1, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Listini'), '_link_record_', 'mg_articoli.id', 1, 1, 0, 1, 0); - --- Aggiunta impstazione per alert occupazione tecnici -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES (NULL, 'Alert occupazione tecnici', '1', 'boolean', '1', 'Attività'); - --- Aggiunta supporto riferimento_amministrazione per Anagrafiche -ALTER TABLE `an_anagrafiche` ADD `riferimento_amministrazione` VARCHAR(255) AFTER `codicerea`; - --- Fix dimensioni campi descrittivi -ALTER TABLE `co_contratti` CHANGE `descrizione` `descrizione` TEXT NULL; -ALTER TABLE `co_contratti` CHANGE `esclusioni` `esclusioni` TEXT NULL; -ALTER TABLE `co_documenti` CHANGE `note` `note` TEXT NULL; -ALTER TABLE `co_documenti` CHANGE `note_aggiuntive` `note_aggiuntive` TEXT NULL; -ALTER TABLE `co_movimenti` CHANGE `descrizione` `descrizione` TEXT NULL; -ALTER TABLE `co_preventivi` CHANGE `descrizione` `descrizione` TEXT NULL; -ALTER TABLE `co_preventivi` CHANGE `esclusioni` `esclusioni` TEXT NULL; -ALTER TABLE `co_righe_contratti` CHANGE `descrizione` `descrizione` TEXT NULL; -ALTER TABLE `co_righe_documenti` CHANGE `descrizione` `descrizione` TEXT NULL; -ALTER TABLE `co_righe_preventivi` CHANGE `descrizione` `descrizione` TEXT NULL; -ALTER TABLE `dt_righe_ddt` CHANGE `descrizione` `descrizione` TEXT NULL; -ALTER TABLE `in_interventi` CHANGE `richiesta` `richiesta` TEXT NULL; -ALTER TABLE `in_interventi` CHANGE `descrizione` `descrizione` TEXT NULL; -ALTER TABLE `in_interventi` CHANGE `informazioniaggiuntive` `informazioniaggiuntive` TEXT NULL; -ALTER TABLE `mg_articoli` CHANGE `contenuto` `contenuto` TEXT NULL; -ALTER TABLE `my_impianto_componenti` CHANGE `contenuto` `contenuto` TEXT NULL; -ALTER TABLE `or_righe_ordini` CHANGE `descrizione` `descrizione` TEXT NULL; -ALTER TABLE `zz_modules` CHANGE `options` `options` TEXT NULL; -ALTER TABLE `zz_modules` CHANGE `options2` `options2` TEXT NULL; -ALTER TABLE `zz_widgets` CHANGE `query` `query` TEXT NULL; -ALTER TABLE `zz_widgets` CHANGE `text` `text` TEXT NULL; - -ALTER TABLE `zz_views` CHANGE `format` `format` TINYINT(1) NOT NULL DEFAULT '0'; - - --- Aggiunto HAVING 2=2 nel modulo listini -UPDATE `zz_modules` SET `options` = 'SELECT |select| -FROM mg_prezzi_articoli - INNER JOIN an_anagrafiche ON an_anagrafiche.idanagrafica = mg_prezzi_articoli.id_anagrafica - INNER JOIN mg_articoli ON mg_articoli.id = mg_prezzi_articoli.id_articolo -WHERE 1=1 AND mg_articoli.deleted_at IS NULL AND an_anagrafiche.deleted_at IS NULL -HAVING 2=2 -ORDER BY an_anagrafiche.ragione_sociale' WHERE `zz_modules`.`name` = 'Listini'; - --- Aggiunti segmenti nel modulo listini -INSERT INTO `zz_segments` (`id_module`, `name`, `clause`, `position`, `pattern`, `note`, `predefined`, `predefined_accredito`, `predefined_addebito`, `is_fiscale`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Listini'), 'Tutti', '1=1', 'WHR', '####', '', 1, 0, 0, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Listini'), 'Fornitori', 'mg_prezzi_articoli.dir=\"uscita\"', 'WHR', '####', '', 0, 0, 0, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Listini'), 'Clienti', 'mg_prezzi_articoli.dir=\"entrata\"', 'WHR', '####', '', 0, 0, 0, 0); - --- Aggiunto formattabile nel modulo listini ai campi numerici -UPDATE `zz_views` SET `format` = '1' WHERE `name` = 'Prezzo unitario'; -UPDATE `zz_views` SET `format` = '1' WHERE `name` = 'Sconto percentuale'; -UPDATE `zz_views` SET `format` = '1' WHERE `name` = 'Minimo'; -UPDATE `zz_views` SET `format` = '1' WHERE `name` = 'Massimo'; - - --- Sostituito icona Listini con ">" -UPDATE `zz_modules` SET `icon` = 'fa fa-angle-right' WHERE `zz_modules`.`name` = 'Listini'; - --- Modificato nome plugin dettagli in Prezzi specifici -UPDATE `zz_plugins` SET `name` = 'Prezzi specifici articolo', `title` = 'Prezzi specifici' WHERE `zz_plugins`.`name` = 'Dettagli articolo'; - --- Impostazione soft quota -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES (NULL, 'Soft quota', '', 'integer', '0', 'Generali', NULL, 'Soft quota in GB'); - --- Relativo hook per il calcolo dello spazio utilizzato -INSERT INTO `zz_hooks` (`id`, `name`, `class`, `enabled`, `id_module`, `processing_at`, `processing_token`) VALUES (NULL, 'Spazio', 'Modules\\StatoServizi\\SpaceHook', '1', (SELECT `id` FROM `zz_modules` WHERE `name`='Stato dei servizi'), NULL, NULL); - -INSERT INTO `zz_cache` (`id`, `name`, `content`, `valid_time`, `expire_at`) VALUES -(NULL, 'Spazio utilizzato', '', '60 minute', NOW()); - --- Introduzione hook per informazioni su Services -INSERT INTO `zz_hooks` (`id`, `name`, `class`, `enabled`, `id_module`, `processing_at`, `processing_token`) VALUES (NULL, 'Informazioni su Services', 'Modules\\StatoServizi\\ServicesHook', '1', (SELECT `id` FROM `zz_modules` WHERE `name`='Stato dei servizi'), NULL, NULL); - -INSERT INTO `zz_cache` (`id`, `name`, `content`, `valid_time`, `expire_at`) VALUES -(NULL, 'Informazioni su Services', '', '7 days', NOW()), -(NULL, 'Informazioni su spazio FE', '', '7 days', NOW()); - --- Aggiunta colonna Tecnici assegnati in Attività -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `in_interventi` -INNER JOIN `an_anagrafiche` ON `in_interventi`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` -LEFT JOIN `in_interventi_tecnici` ON `in_interventi_tecnici`.`idintervento` = `in_interventi`.`id` -LEFT JOIN `in_interventi_tecnici_assegnati` ON `in_interventi_tecnici_assegnati`.`id_intervento` = `in_interventi`.`id` -LEFT JOIN `in_statiintervento` ON `in_interventi`.`idstatointervento`=`in_statiintervento`.`idstatointervento` -LEFT JOIN ( - SELECT an_sedi.id, CONCAT(an_sedi.nomesede, ''
    '',an_sedi.telefono, ''
    '',an_sedi.cellulare,''
    '',an_sedi.citta, '' - '', an_sedi.indirizzo) AS info FROM an_sedi -) AS sede_destinazione ON sede_destinazione.id = in_interventi.idsede_destinazione -LEFT JOIN ( - SELECT co_righe_documenti.idintervento, CONCAT(''Fatt. '', co_documenti.numero_esterno, '' del '', DATE_FORMAT(co_documenti.data, ''%d/%m/%Y'')) AS info FROM co_documenti INNER JOIN co_righe_documenti ON co_documenti.id = co_righe_documenti.iddocumento -) AS fattura ON fattura.idintervento = in_interventi.id -WHERE 1=1 |date_period(`orario_inizio`,`data_richiesta`)| -GROUP BY `in_interventi`.`id` -HAVING 2=2 -ORDER BY IFNULL(`orario_fine`, `data_richiesta`) DESC' WHERE `name` = 'Interventi'; -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `format`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), 'Tecnici assegnati', 'GROUP_CONCAT((SELECT DISTINCT(ragione_sociale) FROM an_anagrafiche WHERE idanagrafica = in_interventi_tecnici_assegnati.id_tecnico) SEPARATOR '', '')', 14, 1, 0, 1, 1); - -UPDATE `zz_views` SET `default` = 1 WHERE `zz_views`.`id_module` = (SELECT `zz_modules`.`id` FROM `zz_modules` WHERE `zz_modules`.`name` = 'Interventi') AND (`zz_views`.`name` = 'Tecnici' OR `zz_views`.`name` = 'Rif. fattura'); - --- Modifica directory Piani di sconto/magg. -UPDATE `zz_modules` SET `directory` = 'piano_sconto' WHERE `zz_modules`.`name` = 'Piani di sconto/magg.'; - --- Aggiunto flag rinnovo automatico in contratti -ALTER TABLE `co_contratti` ADD `rinnovo_automatico` TINYINT(1) NOT NULL DEFAULT '0' AFTER `rinnovabile`; - --- Aggiunto segmento per attività NON completate -INSERT INTO `zz_segments` (`id`, `id_module`, `name`, `clause`, `position`, `pattern`, `note`, `predefined`, `predefined_accredito`, `predefined_addebito`, `is_fiscale`) VALUES (NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), 'Non completate', 'in_interventi.idstatointervento NOT IN(SELECT in_statiintervento.idstatointervento FROM in_statiintervento WHERE is_completato=1)', 'WHR', '####', '', '0', '0', '0', '0'); - --- Aggiunto segmenti Ri.Ba. Clienti/Fornitori su Scadenzario -DELETE FROM `zz_segments` WHERE name='Scadenzario Ri.Ba.'; - -INSERT INTO `zz_segments` (`id_module`, `name`, `clause`, `position`, `pattern`, `note`, `predefined`, `predefined_accredito`, `predefined_addebito`, `is_fiscale`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Scadenzario'), 'Scadenzario Ri.Ba. Clienti', 'co_pagamenti.riba=1 AND co_tipidocumento.dir=\"entrata\"', 'WHR', '####', '', 0, 0, 0, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Scadenzario'), 'Scadenzario Ri.Ba. Fornitori', 'co_pagamenti.riba=1 AND co_tipidocumento.dir=\"uscita\"', 'WHR', '####', '', 0, 0, 0, 0); - --- Aggiunta impostazione per disabilitare articoli con quantità <= 0 -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES (NULL, 'Permetti selezione articoli con quantità minore o uguale a zero in Documenti di Vendita', '0', 'boolean', '1', 'Generali', '20', NULL); - --- Correzione per visualizzazione campi 'Dare' e 'Avere' -UPDATE `zz_views` SET `summable` = 1 WHERE `name` IN ('Dare', 'Avere') AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Prima Nota'); - --- Fix query dichiarazione d'intento -UPDATE `zz_plugins` SET `options` = '{ \"main_query\": [ { \"type\": \"table\", \"fields\": \"Protocollo, Progressivo, Massimale, Totale, Data inizio, Data fine\", \"query\": \"SELECT id, numero_protocollo AS Protocollo, numero_progressivo AS Progressivo, DATE_FORMAT(data_inizio,\'%d/%m/%Y\') AS \'Data inizio\', DATE_FORMAT(data_fine,\'%d/%m/%Y\') AS \'Data fine\', ROUND(massimale, 2) AS Massimale, ROUND(totale, 2) AS Totale FROM co_dichiarazioni_intento WHERE 1=1 AND deleted_at IS NULL AND id_anagrafica = |id_parent| HAVING 2=2 ORDER BY co_dichiarazioni_intento.id DESC\"} ]}' WHERE `zz_plugins`.`name` = "Dichiarazioni d\'Intento"; - --- Aggiunto colonne categoria e sottocategoria su listini -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM mg_prezzi_articoli - INNER JOIN an_anagrafiche ON an_anagrafiche.idanagrafica = mg_prezzi_articoli.id_anagrafica - INNER JOIN mg_articoli ON mg_articoli.id = mg_prezzi_articoli.id_articolo - INNER JOIN mg_categorie AS categoria ON mg_articoli.id_categoria=categoria.id - INNER JOIN mg_categorie AS sottocategoria ON mg_articoli.id_sottocategoria=sottocategoria.id -WHERE 1=1 AND mg_articoli.deleted_at IS NULL AND an_anagrafiche.deleted_at IS NULL -HAVING 2=2 -ORDER BY an_anagrafiche.ragione_sociale' WHERE `name` = 'Listini'; - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `visible`, `summable`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Listini'), 'Sottocategoria', 'sottocategoria.nome', 5, 1, 0, 0, '', '', 1, 0, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Listini'), 'Categoria', 'categoria.nome', 4, 1, 0, 0, '', '', 1, 0, 0); - -INSERT INTO `zz_group_view` (`id_gruppo`, `id_vista`) ( -SELECT `zz_groups`.`id`, `zz_views`.`id` FROM `zz_groups`, `zz_views` INNER JOIN `zz_modules` ON `zz_views`.`id_module` = `zz_modules`.`id` WHERE `zz_modules`.`name` = 'Listini' AND `zz_views`.`name` = 'Categoria' -); -INSERT INTO `zz_group_view` (`id_gruppo`, `id_vista`) ( -SELECT `zz_groups`.`id`, `zz_views`.`id` FROM `zz_groups`, `zz_views` INNER JOIN `zz_modules` ON `zz_views`.`id_module` = `zz_modules`.`id` WHERE `zz_modules`.`name` = 'Listini' AND `zz_views`.`name` = 'Sottocategoria' -); - --- Aggiornamento natura iva per aliquote eliminate -UPDATE `co_iva` SET `codice_natura_fe` = 'N2.2' WHERE `codice_natura_fe` = 'N2'; -UPDATE `co_iva` SET `codice_natura_fe` = 'N3.6' WHERE `codice_natura_fe` = 'N3'; -UPDATE `co_iva` SET `codice_natura_fe` = 'N6.9' WHERE `codice_natura_fe` = 'N6'; - --- Aumento testo descrizione per righe attività (da 255 caratteri) -ALTER TABLE `in_righe_interventi` CHANGE `descrizione` `descrizione` TEXT NULL; - -ALTER TABLE `co_tipidocumento` CHANGE `descrizione` `descrizione` VARCHAR(125) NOT NULL; - --- Aggiunta tipologia documento TD 25 -INSERT INTO `co_tipidocumento` (`id`, `descrizione`, `dir`, `reversed`, `codice_tipo_documento_fe`) VALUES -(NULL, "Fattura differita di cui all'art.21, comma 4, terzo periodo lett. b (Dropshipping)", 'entrata', '0', 'TD25'), -(NULL, "Fattura differita di cui all'art.21, comma 4, terzo periodo lett. b (Dropshipping)", 'uscita', '0', 'TD25'); - --- Metodi di pagamento speculari per fatture di acquisto -INSERT INTO `co_tipidocumento` (`id`, `descrizione`, `dir`, `reversed`, `codice_tipo_documento_fe`) VALUES -(NULL, 'Acconto/anticipo su fattura', 'uscita', '0', 'TD02'), -(NULL, 'Integrazione fattura reverse charge interno', 'uscita', '0', 'TD16'), -(NULL, "Integrazione/autofattura per acquisto servizi dall\'estero", 'uscita', '0', 'TD17'), -(NULL, 'Integrazione per acquisto di beni intracomunitari', 'uscita', '0', 'TD18'), -(NULL, 'Integrazione/autofattura per acquisto di beni ex art.17 c.2 DPR 633/72', 'uscita', '0', 'TD19'), -(NULL, 'Autofattura per regolarizzazione e integrazione delle fatture (art.6 c.8 d.lgs. 471/97 o art.46 c.5 D.L. 331/93)', 'uscita', '0', 'TD20'), -(NULL, 'Autofattura per splafonamento', 'uscita', '0', 'TD21'), -(NULL, 'Estrazione beni da deposito IVA', 'uscita', '0', 'TD22'), -(NULL, "Estrazione beni da deposito IVA con versamento dell\'IVA", 'uscita', '0', 'TD23'), -(NULL, 'Cessione di beni ammortizzabili e per passaggi interni (ex art.36 DPR 633/72)', 'uscita', '0', 'TD26'), -(NULL, 'Fattura per autoconsumo o per cessioni gratuite senza rivalsa', 'uscita', '0', 'TD27'); - --- Setto 10 tentativi per email create più di una settimana fa che non sono state mai processate e non hanno ricevuto ne invio o fallimento -UPDATE `em_emails` SET `attempt` = '10', `em_emails`.`failed_at` = NOW() WHERE `em_emails`.`attempt` = 0 AND `em_emails`.`failed_at` IS NULL AND `em_emails`.`sent_at` IS NULL AND `em_emails`.`processing_at` IS NULL AND `em_emails`.`created_at` <= DATE_SUB(NOW(), INTERVAL 7 DAY); - --- Aggiunto deleted_at per tipi di documento -ALTER TABLE `co_tipidocumento` ADD `deleted_at` DATETIME NULL DEFAULT NULL AFTER `codice_tipo_documento_fe`; --- Aggiunti campi predefined, enabled, help per tipi di documento -ALTER TABLE `co_tipidocumento` ADD `predefined` TINYINT NOT NULL DEFAULT '0' AFTER `codice_tipo_documento_fe`; -ALTER TABLE `co_tipidocumento` ADD `enabled` TINYINT NOT NULL DEFAULT '1' AFTER `predefined`; -ALTER TABLE `co_tipidocumento` ADD `help` VARCHAR(255) NULL AFTER `enabled`; -UPDATE `co_tipidocumento` SET `predefined` = '1' WHERE `co_tipidocumento`.`descrizione` = 'Fattura immediata di vendita'; -UPDATE `co_tipidocumento` SET `predefined` = '1' WHERE `co_tipidocumento`.`descrizione` = 'Fattura immediata di acquisto'; - -UPDATE `co_tipidocumento` SET `help` = 'Fattura emessa entro le ore 24 del giorno di effettuazione dell’operazione.' WHERE `co_tipidocumento`.`descrizione` = 'Fattura immediata di acquisto'; -UPDATE `co_tipidocumento` SET `help` = 'Fattura emessa entro le ore 24 del giorno di effettuazione dell’operazione.' WHERE `co_tipidocumento`.`descrizione` = 'Fattura immediata di vendita'; -UPDATE `co_tipidocumento` SET `help` = "Fattura emessa entro il giorno 15 del mese successivo a quello di effettuazione dell'operazione (art. 21 comma 4 lett. a) del D.P.R. 633/1972)." WHERE `co_tipidocumento`.`descrizione` = 'Fattura differita di acquisto'; -UPDATE `co_tipidocumento` SET `help` = "Fattura emessa entro il giorno 15 del mese successivo a quello di effettuazione dell'operazione (art. 21 comma 4 lett. a) del D.P.R. 633/1972)." WHERE `co_tipidocumento`.`descrizione` = 'Fattura differita di vendita'; - --- Innesto nuovo modulo Tipi documento -INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`, `use_notes`, `use_checklists`) VALUES (NULL, 'Tipi documento', 'Tipi documento', 'tipi_documento', 'SELECT |select| FROM `co_tipidocumento` WHERE 1=1 AND deleted_at IS NULL HAVING 2=2', '', 'fa fa-angle-right', '2.4.20', '2.4.20', '1', (SELECT `id` FROM `zz_modules` t WHERE t.`name` = 'Tabelle'), '1', '1', '0', '0'); - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi documento'), 'Attivo', 'co_tipidocumento.enabled', 7, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi documento'), 'Predefinito', 'co_tipidocumento.predefined', 6, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi documento'), 'Codice FE', 'co_tipidocumento.codice_tipo_documento_fe', 5, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi documento'), 'Reversed', 'co_tipidocumento.reversed', 4, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi documento'), 'Direzione', 'co_tipidocumento.dir', 3, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi documento'), 'Descrizione', 'co_tipidocumento.descrizione', 2, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi documento'), 'id', 'co_tipidocumento.id', 1, 1, 0, 0, 0); - --- Aggiornate descrizioni aliquote IVA con codice natura 6.() -UPDATE `co_iva` SET `descrizione`='Art. 74 co. 8 del DPR 633/72 - Cessione di rottami e di altri materiali di recupero' WHERE `descrizione`='Inversione contabile - cessione di rottami e altri materiali di recupero'; -UPDATE `co_iva` SET `descrizione`='Art. 17 co. 5 del DPR 633/72 - Cessione di oro e argento puro' WHERE `descrizione`='Inversione contabile - cessione di oro e argento pure'; -UPDATE `co_iva` SET `descrizione`='Art. 17 co. 6 lett. a) del DPR 633/72 - Subappalto nel settore edile' WHERE `descrizione`='Inversione contabile - subappalto nel settore edile'; -UPDATE `co_iva` SET `descrizione`='Art. 17 co. 6 lett. a-bis) del DPR 633/72 - Cessione di fabbricati' WHERE `descrizione`='Inversione contabile - cessione di fabbricati'; -UPDATE `co_iva` SET `descrizione`='Art. 17 co. 6 lett. b) del DPR 633/72 - Cessione di telefoni cellulari' WHERE `descrizione`='Inversione contabile - cessione di telefoni cellulari'; -UPDATE `co_iva` SET `descrizione`='Art. 17 co. 6 lett. c) del DPR 633/72 - Cessione di prodotti elettronici' WHERE `descrizione`='Inversione contabile - cessione di prodotti elettronici'; -UPDATE `co_iva` SET `descrizione`='Art. 17 co. 6 lett. a-ter) del DPR 633/72 - Prestazioni del comparto edile e settori connessi' WHERE `descrizione`='Inversione contabile - prestazioni comparto edile e settori connessi'; -UPDATE `co_iva` SET `descrizione`='Art. 17 co. 6 lett. d-bis) del DPR 633/72 - Operazioni del settore energetico' WHERE `descrizione`='Inversione contabile - operazioni settore energetico'; - -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Art. 17 co. 6 lett. d-ter) del DPR 633/72 - Operazioni del settore energetico', '0.00', '0.00', '1', NULL, 'N6.8', NULL, NULL, 'I', '1'); diff --git a/update/2_4_21.sql b/update/2_4_21.sql deleted file mode 100644 index 38cd8c27e..000000000 --- a/update/2_4_21.sql +++ /dev/null @@ -1,93 +0,0 @@ --- Aggiunta fattura.info query preventivi -UPDATE - `zz_modules` -SET - `options` = 'SELECT |select|\r\nFROM `co_preventivi`\r\n LEFT JOIN `an_anagrafiche` ON `co_preventivi`.`idanagrafica` = `an_anagrafiche`.`idanagrafica`\r\n LEFT JOIN `co_statipreventivi` ON `co_preventivi`.`idstato` = `co_statipreventivi`.`id`\r\n LEFT JOIN (\r\n SELECT `idpreventivo`,\r\n SUM(`subtotale` - `sconto`) AS `totale_imponibile`,\r\n SUM(`subtotale` - `sconto` + `iva`) AS `totale`\r\n FROM `co_righe_preventivi`\r\n GROUP BY `idpreventivo`\r\n ) AS righe ON `co_preventivi`.`id` = `righe`.`idpreventivo`\r\n -LEFT JOIN (SELECT co_righe_documenti.idpreventivo, CONCAT(\'Fatt. \', co_documenti.numero_esterno,\' del \', DATE_FORMAT(co_documenti.data, \'%d/%m/%Y\')) AS info FROM co_documenti INNER JOIN co_righe_documenti ON co_documenti.id = co_righe_documenti.iddocumento) AS fattura ON fattura.idpreventivo = co_preventivi.id -WHERE 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\r\nGROUP BY `co_preventivi`.`id`\r\nHAVING 2=2\r\nORDER BY `co_preventivi`.`id` DESC ' -WHERE - `zz_modules`.`name` = 'Preventivi'; - --- Aggiunta colonna Rif. fattura per preventivi -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `format`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi'), 'Rif. fattura', 'fattura.info', 9, 1, 0, 0, 1); - --- Modifico impostazione "Lunghezza in pagine del buffer Datatables" per renderla modificabile dall'utente -UPDATE `zz_settings` SET `editable` = '1', `tipo` = 'list[5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100]', `help` = 'Attenzione, a valori più elevati corrispondono performance peggiori' WHERE `zz_settings`.`nome` = 'Lunghezza in pagine del buffer Datatables'; - --- Impostazioni per decidere eventuali date predefinite per l'inizio o la fine del calendario (impostate al login) -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES (NULL, 'Inizio periodo calendario', '', 'date', '1', 'Generali', '23', NULL); -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES (NULL, 'Fine periodo calendario', '', 'date', '1', 'Generali', '23', NULL); - --- Ottimizzazione calcolo quantità su modulo "Giacenze sedi" -UPDATE `zz_modules` SET `options`='SELECT |select| FROM `mg_articoli` - LEFT OUTER JOIN an_anagrafiche ON mg_articoli.id_fornitore = an_anagrafiche.idanagrafica - LEFT OUTER JOIN co_iva ON mg_articoli.idiva_vendita = co_iva.id - LEFT OUTER JOIN ( - SELECT SUM(qta - qta_evasa) AS qta_impegnata, idarticolo FROM or_righe_ordini - INNER JOIN or_ordini ON or_righe_ordini.idordine = or_ordini.id - WHERE idstatoordine IN (SELECT id FROM or_statiordine WHERE completato = 0) - GROUP BY idarticolo - ) ordini ON ordini.idarticolo = mg_articoli.id - LEFT OUTER JOIN (SELECT `idarticolo`, `idsede_azienda`, SUM(`qta`) AS `qta` FROM `mg_movimenti` WHERE `idsede_azienda` = |giacenze_sedi_idsede| GROUP BY `idarticolo`, `idsede_azienda`) movimenti ON `mg_articoli`.`id` = `movimenti`.`idarticolo` -WHERE 1=1 AND `mg_articoli`.`deleted_at` IS NULL HAVING 2=2 AND `Q.tà` > 0 ORDER BY `descrizione`' WHERE `name` = 'Giacenze sedi'; -UPDATE `zz_views` SET `query`='movimenti.qta', `format`=1 WHERE `id_module`=(SELECT `id` FROM `zz_modules` WHERE `name`='Giacenze sedi') AND `name`='Q.tà'; - --- Fix widget rate contrattuali -UPDATE `zz_widgets` SET `query` = 'SELECT COUNT(id) AS dato FROM co_fatturazione_contratti WHERE idcontratto IN( SELECT id FROM co_contratti WHERE co_contratti.idstato IN (SELECT id FROM co_staticontratti WHERE is_fatturabile = 1)) AND co_fatturazione_contratti.iddocumento=0' WHERE `zz_widgets`.`name` = 'Rate contrattuali'; - --- Divisione delle colonne modulo modelli prima nota -UPDATE `zz_views` SET `query` = 'co_movimenti_modelli.nome' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name`='Modelli prima nota') AND `name` LIKE 'Nome'; -INSERT INTO `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`='Modelli prima nota'), 'Causale', 'co_movimenti_modelli.descrizione', '2', '1', '0', '0', NULL, NULL, '1', '0', '1'); - --- Aggiunto flag peso e volume manuale in fatture e ddt -ALTER TABLE `dt_ddt` ADD `peso_manuale` TINYINT(1) NOT NULL AFTER `volume`; -ALTER TABLE `dt_ddt` ADD `volume_manuale` TINYINT(1) NOT NULL AFTER `peso_manuale`; -ALTER TABLE `co_documenti` ADD `peso_manuale` TINYINT(1) NOT NULL AFTER `volume`; -ALTER TABLE `co_documenti` ADD `volume_manuale` TINYINT(1) NOT NULL AFTER `peso_manuale`; - --- Fix fornitore predefinito articoli -INSERT INTO `mg_prezzi_articoli`( - `id_articolo`, - `id_anagrafica`, - `prezzo_unitario`, - `prezzo_unitario_ivato`, - `dir`, - `sconto_percentuale` -)( - SELECT - `mg_articoli`.`id`, - `mg_articoli`.`id_fornitore`, - `mg_articoli`.`prezzo_acquisto`, - `mg_articoli`.`prezzo_acquisto` + `mg_articoli`.`prezzo_acquisto` * IFNULL( - `co_iva`.`percentuale`, - `iva_default`.`percentuale` - ) / 100, - 'uscita', - 0 - FROM - `mg_articoli` - LEFT JOIN `co_iva` ON `mg_articoli`.`idiva_vendita` = `co_iva`.`id` - LEFT JOIN( - SELECT - `valore` AS `idiva` - FROM - `zz_settings` - WHERE - `nome` = 'Iva predefinita' - ) AS `impostazioni` -ON - 1 = 1 -LEFT JOIN `co_iva` AS `iva_default` -ON - `iva_default`.`id` = `impostazioni`.`idiva` -WHERE - `id_fornitore` NOT IN( - SELECT - `id_anagrafica` - FROM - `mg_prezzi_articoli` AS `prezzi_specifica` - WHERE - `id_articolo` = `mg_articoli`.`id` -) AND `id_fornitore` IN (SELECT `idanagrafica` FROM `an_anagrafiche`) -); \ No newline at end of file diff --git a/update/2_4_22.php b/update/2_4_22.php deleted file mode 100644 index 87db5bf0f..000000000 --- a/update/2_4_22.php +++ /dev/null @@ -1,15 +0,0 @@ - $campo) { - $documenti = $dbo->fetchArray('SELECT '.$campo.' FROM '.$tabella.' GROUP BY '.$campo); - foreach ($documenti as $documento) { - reorderRows($tabella, $campo, $documento); - } -} diff --git a/update/2_4_22.sql b/update/2_4_22.sql deleted file mode 100644 index 2fb4fbbd1..000000000 --- a/update/2_4_22.sql +++ /dev/null @@ -1,319 +0,0 @@ --- Rimozione campo formattabile su "Causale" e "Sede destinazione" dei Ddt -UPDATE `zz_views` INNER JOIN `zz_modules` ON `zz_views`.`id_module` = `zz_modules`.`id` SET `zz_views`.`format` = 0 WHERE `zz_views`.`name` IN('Causale', 'Sede partenza') AND `zz_modules`.`name` IN('Ddt di vendita', 'Ddt di acquisto'); - --- Aggiunta colonna reversed -ALTER TABLE `dt_causalet` ADD `reversed` TINYINT(1) NOT NULL AFTER `is_importabile`; -UPDATE `dt_causalet` SET `reversed`=1 WHERE `descrizione`='Reso'; - --- Ottimizzazione per ricerca articoli da ajax select -ALTER TABLE `mg_movimenti` ADD INDEX(`idarticolo`); - --- Aggiunta possibilità di scegliere uno stato dopo la firma anche se non ha il flag completato -UPDATE `zz_settings` SET `tipo`='query=SELECT idstatointervento AS id, descrizione AS text FROM in_statiintervento' WHERE `nome`='Stato dell''attività dopo la firma'; - --- Aggiunto filtro N3.% nella scelta aliquota per le dichiarazioni d'intento -UPDATE `zz_settings` SET `tipo` = 'query=SELECT id, descrizione FROM `co_iva` WHERE codice_natura_fe LIKE ''N3.%'' AND deleted_at IS NULL ORDER BY descrizione ASC' WHERE `zz_settings`.`nome` = 'Iva per lettere d''intento'; - - --- Aggiunte descrizioni aliquote IVA con codice natura 2.1 -UPDATE `co_iva` SET `descrizione`='Art.7 bis DPR 633/1972 (cessione di beni extra-UE)' WHERE `descrizione`='Non soggetta ad IVA ai sensi degli artt. Da 7 a 7-septies del DPR 633/72' AND `codice_natura_fe`='N2.1'; -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Art.7 ter DPR 633/1972 prestazione servizi UE (vendite)', '0.00', '0.00', '1', NULL, 'N2.1', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Art.7 ter DPR 633/1972 prestazione servizi extra-UE', '0.00', '0.00', '1', NULL, 'N2.1', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Art.7 quater DPR 633/1972 prestazione servizi UE (vendite)', '0.00', '0.00', '1', NULL, 'N2.1', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Art.7 quater DPR 633/1972 prestazione servizi extra-UE', '0.00', '0.00', '1', NULL, 'N2.1', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Art.7 quinquies DPR 633/1972 (prestazione servizi)', '0.00', '0.00', '1', NULL, 'N2.1', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Art.7 sexies, septies DPR 633/1972 (prestazione servizi)', '0.00', '0.00', '1', NULL, 'N2.1', NULL, NULL, 'I', '1'); - --- Aggiunte descrizioni aliquote IVA con codice natura 2.2 -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Fuori campo Iva art. 2 DPR 633/1972', '0.00', '0.00', '1', NULL, 'N2.2', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Fuori campo Iva art. 3 DPR 633/1972', '0.00', '0.00', '1', NULL, 'N2.2', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Fuori campo Iva art. 4 DPR 633/1972', '0.00', '0.00', '1', NULL, 'N2.2', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Fuori campo Iva art. 5 DPR 633/1972', '0.00', '0.00', '1', NULL, 'N2.2', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Art. 38 c.5 DL 331/1993', '0.00', '0.00', '1', NULL, 'N2.2', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Art.17 c.3 DPR 633/1972', '0.00', '0.00', '1', NULL, 'N2.2', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Art.19 c.3 lett. b DPR 633/1972', '0.00', '0.00', '1', NULL, 'N2.2', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Art. 50 bis c.4 DL 331/1993', '0.00', '0.00', '1', NULL, 'N2.2', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Art.74 cc.1 e 2 DPR 633/1972', '0.00', '0.00', '1', NULL, 'N2.2', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Art.19 c.3 lett. e DPR 633/1972', '0.00', '0.00', '1', NULL, 'N2.2', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Art.13 DPR 633/1972', '0.00', '0.00', '1', NULL, 'N2.2', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Art. 27 c.1 e 2 DL 98/2011 (contribuenti minimi)', '0.00', '0.00', '1', NULL, 'N2.2', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Art.1 c.54-89 L. 190/2014 e succ. modifiche (regime forfettario)', '0.00', '0.00', '1', NULL, 'N2.2', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Art.26 c.3 DPR 633/1972', '0.00', '0.00', '1', NULL, 'N2.2', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'DM 9/4/1993', '0.00', '0.00', '1', NULL, 'N2.2', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Art.26 bis L.196/1997', '0.00', '0.00', '1', NULL, 'N2.2', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Art.8 c.35 L. 67/1988', '0.00', '0.00', '1', NULL, 'N2.2', NULL, NULL, 'I', '1'); - --- Aggiunte descrizioni aliquote IVA con codice natura 3.() -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Art.8 c.1 lett.a DPR 633/1972', '0.00', '0.00', '1', NULL, 'N3.1', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Art.8 c.1 lett.b DPR 633/1972', '0.00', '0.00', '1', NULL, 'N3.1', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Non imp. art. 8 c.1 lett. b-bis DPR 633/1972', '0.00', '0.00', '1', NULL, 'N3.1', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Non imp. art.9 c.2 DPR 633/1972', '0.00', '0.00', '1', NULL, 'N3.1', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Non imp.art.72 c.1 DPR 633/1972', '0.00', '0.00', '1', NULL, 'N3.1', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Non imp. art.50 bis c.4 lett. g DL 331/93', '0.00', '0.00', '1', NULL, 'N3.1', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Non imp. art.14 legge n. 49/1987', '0.00', '0.00', '1', NULL, 'N3.1', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Non imp. art.50 bis c.4 lett. f DL 331/93', '0.00', '0.00', '1', NULL, 'N3.2', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Non imp. art.41 DL 331/93', '0.00', '0.00', '1', NULL, 'N3.2', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Non imp. art.58 c.1 DL 331/93', '0.00', '0.00', '1', NULL, 'N3.2', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Art. 8 bis DPR 633/1972', '0.00', '0.00', '1', NULL, 'N3.4', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Non imp. art. 8 bis c.2 DPR 633/1972', '0.00', '0.00', '1', NULL, 'N3.4', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Non imp. art. 8 c.1 lett. c DPR 633/1972', '0.00', '0.00', '1', NULL, 'N3.5', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Art.9 c.1 DPR 633/1972', '0.00', '0.00', '1', NULL, 'N3.6', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Non imp. art.72 DPR 633/1972', '0.00', '0.00', '1', NULL, 'N3.6', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Art. 71 DPR 633/1972', '0.00', '0.00', '1', NULL, 'N3.6', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Art. 2 c. 2, n. 4 DPR 633/1972', '0.00', '0.00', '1', NULL, 'N3.6', NULL, NULL, 'I', '1'); -INSERT INTO `co_iva` (`id`, `descrizione`, `percentuale`, `indetraibile`, `esente`, `dicitura`, `codice_natura_fe`, `deleted_at`, `codice`, `esigibilita`, `default`) VALUES (NULL, 'Non imp. art.38 quater c.1 DPR 633/1972', '0.00', '0.00', '1', NULL, 'N3.6', NULL, NULL, 'I', '1'); - --- Aggiunto ckeditor Condizioni generali di fornitura in impostazioni preventivi -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES (NULL, 'Condizioni generali di fornitura', '', 'ckeditor', '1', 'Preventivi', NULL, NULL); - --- Aggiunta colonna condizioni_fornitura in co_preventivi -ALTER TABLE `co_preventivi` ADD `condizioni_fornitura` TEXT NOT NULL AFTER `numero_revision`; - --- Aggiunta colonna totale in modelli prima nota -ALTER TABLE `co_movimenti_modelli` ADD `totale` DECIMAL(15,6) NOT NULL AFTER `idconto`; - --- Aggiunto colonna garanzie in co_preventivi -ALTER TABLE `co_preventivi` ADD `garanzia` TEXT NOT NULL AFTER `condizioni_fornitura`; - --- Modificata lunghezza campo Partita iva -ALTER TABLE `an_anagrafiche` CHANGE `piva` `piva` VARCHAR(16) NOT NULL; - --- Aggiunta stampa bilancio -INSERT INTO `zz_prints` (`id`, `id_module`, `is_record`, `name`, `title`, `filename`, `directory`, `previous`, `options`, `icon`, `version`, `compatibility`, `order`, `predefined`, `default`, `enabled`) VALUES (NULL, (SELECT `id` FROM `zz_modules` WHERE name='Piano dei conti'), '1', 'Bilancio', 'Bilancio', 'Bilancio', 'bilancio', '', '', 'fa fa-print', '', '', '0', '0', '1', '1'); - --- Aggiunta flag notifica cliente e tecnici in in_statiintervento -ALTER TABLE `in_statiintervento` ADD `notifica_cliente` TINYINT NOT NULL AFTER `notifica`, ADD `notifica_tecnici` TINYINT NOT NULL AFTER `notifica_cliente`; - --- Api creazione anagrafica da app -INSERT INTO `zz_api_resources` (`id`, `version`, `type`, `resource`, `class`, `enabled`) VALUES (NULL, 'app-v1', 'create', 'cliente', 'API\\App\\v1\\Clienti', '1'), (NULL, 'app-v1', 'update', 'cliente', 'API\\App\\v1\\Clienti', '1'), (NULL, 'app-v1', 'delete', 'cliente', 'API\\App\\v1\\Clienti', '1'); - --- Aggiunto flag per il pagamento della ritenuta nelle fatture passive -ALTER TABLE `co_documenti` ADD `is_ritenuta_pagata` BOOLEAN NOT NULL AFTER `id_ricevuta_principale`; - --- Modificato options modulo scadenzario -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_scadenziario` -LEFT JOIN `co_documenti` ON `co_scadenziario`.`iddocumento` = `co_documenti`.`id` -LEFT JOIN `an_anagrafiche` ON `co_documenti`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` -LEFT JOIN `co_pagamenti` ON `co_documenti`.`idpagamento` = `co_pagamenti`.`id` -LEFT JOIN `co_tipidocumento` ON `co_documenti`.`idtipodocumento` = `co_tipidocumento`.`id` -LEFT JOIN `co_statidocumento` ON `co_documenti`.`idstatodocumento` = `co_statidocumento`.`id` -WHERE 1=1 AND -(`co_statidocumento`.`descrizione` IS NULL OR `co_statidocumento`.`descrizione` IN(''Emessa'',''Parzialmente pagato'',''Pagato'')) -HAVING 2=2 -ORDER BY `scadenza` ASC' WHERE `zz_modules`.`name`='Scadenzario'; - --- Modificato nome segmento -UPDATE `zz_segments` SET `name` = 'Scadenzario completo per periodo' WHERE `zz_segments`.`name` = 'Scadenzario completo'; - --- Fix stampe predefinite Preventivi e Contratti -UPDATE `zz_prints` SET `predefined` = '0' WHERE `zz_prints`.`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Preventivi') AND `zz_prints`.`name` = 'Consuntivo preventivo'; -UPDATE `zz_prints` SET `predefined` = '0' WHERE `zz_prints`.`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Contratti') AND `zz_prints`.`name` = 'Consuntivo contratto'; -UPDATE `zz_prints` SET `predefined` = '0' WHERE `zz_prints`.`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Contratti') AND `zz_prints`.`name` = 'Ordine di servizio'; - --- Eliminata colonna idsede_controparte e rinominata idsede_azienda in idsede -ALTER TABLE `mg_movimenti` CHANGE `idsede_azienda` `idsede` INT(11) NOT NULL; -ALTER TABLE `mg_movimenti` DROP `idsede_controparte`; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `mg_movimenti` JOIN `mg_articoli` ON `mg_articoli`.id = `mg_movimenti`.`idarticolo` LEFT JOIN `an_sedi` ON `mg_movimenti`.`idsede` = `an_sedi`.`id` WHERE 1=1 HAVING 2=2 ORDER BY mg_movimenti.data DESC, mg_movimenti.created_at DESC' WHERE `zz_modules`.`name` = 'Movimenti'; -UPDATE `zz_views` SET `query` = 'IF( mg_movimenti.idsede=0, ''Sede legale'', an_sedi.nomesede )' WHERE `zz_views`.`name` = 'Sede' 'Movimenti' AND `zz_views`.`id_module`= (SELECT `id` FROM `zz_modules` WHERE `name`='Movimenti'); -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `mg_articoli` -LEFT OUTER JOIN an_anagrafiche ON mg_articoli.id_fornitore = an_anagrafiche.idanagrafica -LEFT OUTER JOIN co_iva ON mg_articoli.idiva_vendita = co_iva.id -LEFT OUTER JOIN ( -SELECT SUM(qta - qta_evasa) AS qta_impegnata, idarticolo FROM or_righe_ordini -INNER JOIN or_ordini ON or_righe_ordini.idordine = or_ordini.id -WHERE idstatoordine IN (SELECT id FROM or_statiordine WHERE completato = 0) -GROUP BY idarticolo -) ordini ON ordini.idarticolo = mg_articoli.id -LEFT OUTER JOIN (SELECT `idarticolo`, `idsede`, SUM(`qta`) AS `qta` FROM `mg_movimenti` WHERE `idsede` = |giacenze_sedi_idsede| GROUP BY `idarticolo`, `idsede`) movimenti ON `mg_articoli`.`id` = `movimenti`.`idarticolo` -WHERE 1=1 AND `mg_articoli`.`deleted_at` IS NULL HAVING 2=2 AND `Q.tà` > 0 ORDER BY `descrizione`' WHERE `zz_modules`.`name` = 'Giacenze sedi'; - --- Rimozione campo idsede_azienda -UPDATE `zz_views` INNER JOIN `zz_modules` ON `zz_views`.`id_module` = `zz_modules`.`id` SET `zz_views`.`query` = 'IF( mg_movimenti.idsede=0, ''Sede legale'', an_sedi.nomesede )' WHERE `zz_views`.`name` = 'Sede' AND `zz_modules`.`name` = 'Movimenti'; - --- Aggiunto metodo di pagamento PagoPA -INSERT INTO `fe_modalita_pagamento` (`codice`, `descrizione`) VALUES -('MP23','PagoPA'); - -INSERT INTO `co_pagamenti` (`id`, `descrizione`, `giorno`, `num_giorni`, `prc`, `codice_modalita_pagamento_fe`) VALUES -(NULL, 'PagoPA', '0', '1', '100', 'MP23'); - --- Aggiunti referenti ai documenti -ALTER TABLE `or_ordini` ADD `idreferente` INT NULL DEFAULT NULL AFTER `idanagrafica`; -ALTER TABLE `co_documenti` ADD `idreferente` INT NULL DEFAULT NULL AFTER `idanagrafica`; -ALTER TABLE `dt_ddt` ADD `idreferente` INT NULL DEFAULT NULL AFTER `idanagrafica`; - --- Colorazione riga fatture di acquisto con stesso numero e fornitore -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_documenti` -LEFT JOIN `an_anagrafiche` ON `co_documenti`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` -LEFT JOIN `co_tipidocumento` ON `co_documenti`.`idtipodocumento` = `co_tipidocumento`.`id` -LEFT JOIN `co_statidocumento` ON `co_documenti`.`idstatodocumento` = `co_statidocumento`.`id` -LEFT JOIN ( - SELECT `iddocumento`, - SUM(`subtotale` - `sconto`) AS `totale_imponibile`, - SUM(`subtotale` - `sconto` + `iva`) AS `totale` - FROM `co_righe_documenti` - GROUP BY `iddocumento` -) AS righe ON `co_documenti`.`id` = `righe`.`iddocumento` -LEFT JOIN ( - SELECT COUNT(`d`.`id`) AS `conteggio`, - IF(`d`.`numero_esterno`='''', `d`.`numero`, `d`.`numero_esterno`) AS `numero_documento` - FROM `co_documenti` AS `d` - LEFT JOIN `co_tipidocumento` AS `d_tipo` ON `d`.`idtipodocumento` = `d_tipo`.`id` - WHERE 1=1 - AND `d_tipo`.`dir` = ''uscita'' - AND (''|period_start|'' <= `d`.`data` AND ''|period_end|'' >= `d`.`data` OR ''|period_start|'' <= `d`.`data_competenza` AND ''|period_end|'' >= `d`.`data_competenza`) - GROUP BY `numero_documento`, `d`.`idanagrafica` -) AS `d` ON `d`.`numero_documento` = IF(`co_documenti`.`numero_esterno`='''', `co_documenti`.`numero`, `co_documenti`.`numero_esterno`) -WHERE 1=1 AND `dir` = ''uscita'' |segment(`co_documenti`.`id_segment`)||date_period(custom, ''|period_start|'' <= `co_documenti`.`data` AND ''|period_end|'' >= `co_documenti`.`data`, ''|period_start|'' <= `co_documenti`.`data_competenza` AND ''|period_end|'' >= `co_documenti`.`data_competenza` )| -HAVING 2=2 -ORDER BY `co_documenti`.`data` DESC, CAST(IF(`co_documenti`.`numero` = '''', `co_documenti`.`numero_esterno`, `co_documenti`.`numero`) AS UNSIGNED) DESC' WHERE `zz_modules`.`name`='Fatture di acquisto'; - - -INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `visible`, `summable`, `default`) VALUES (NULL, (SELECT `zz_modules`.`id` FROM `zz_modules` WHERE `zz_modules`.`name`='Fatture di acquisto'), '_bg_', 'IF(`d`.`conteggio`>1, ''red'', '''')', '1', '0', '0', '0', '', '', '0', '0', '1'); - -INSERT INTO `zz_group_view` (`id_gruppo`, `id_vista`) (SELECT `zz_groups`.`id`, `zz_views`.`id` FROM `zz_groups`, `zz_views` INNER JOIN `zz_modules` ON `zz_views`.`id_module` = `zz_modules`.`id` WHERE `zz_modules`.`name` = 'Fatture di acquisto' AND `zz_views`.`name` = '_bg_'); - - -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES (NULL, 'Descrizione fattura pianificata', 'Canone {rata} del contratto numero {numero}', 'text', '1', 'Fatturazione'); - -ALTER TABLE `co_righe_contratti` ADD `idpianificazione` INT NULL DEFAULT NULL AFTER `idarticolo`; -INSERT INTO `zz_prints` (`id`, `id_module`, `is_record`, `name`, `title`, `filename`, `directory`, `previous`, `options`, `icon`, `version`, `compatibility`, `order`, `predefined`, `default`, `enabled`) VALUES (NULL, (SELECT `id` FROM `zz_modules` WHERE `name`='Fatture di vendita'), '1', 'Fattura elettronica di vendita', 'Fattura elettronica di vendita', 'Fattura elettronica {numero} del {data}', 'fatture_elettroniche', 'iddocumento', '{\"hide-header\": true, \"hide-footer\": true}', 'fa fa-print', '', '', '0', '1', '1', '1'); - -INSERT INTO `zz_prints` (`id`, `id_module`, `is_record`, `name`, `title`, `filename`, `directory`, `previous`, `options`, `icon`, `version`, `compatibility`, `order`, `predefined`, `default`, `enabled`) VALUES (NULL, (SELECT `id` FROM `zz_modules` WHERE `name`='Fatture di acquisto'), '1', 'Fattura elettronica di acquisto', 'Fattura elettronica di acquisto', 'Fattura elettronica {numero} del {data}', 'fatture_elettroniche', 'iddocumento', '{\"hide-header\": true, \"hide-footer\": true}', 'fa fa-print', '', '', '0', '1', '1', '1'); - -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES -(NULL, 'Numero massimo di tentativi', '10', 'integer', 1, 'Newsletter', 1, 'Numero massimo di tentativi da effettuare per cercare di inviare una mail'); - --- Aggiunta colonna codice commessa convenzione -ALTER TABLE `or_ordini` ADD `codice_commessa` VARCHAR(100) NULL AFTER `updated_at`; - --- Copiato in or_ordini id_documento_fe in numero_cliente dove è presente -UPDATE `or_ordini` SET `numero_cliente`= `id_documento_fe` WHERE `id_documento_fe`!='' AND `id_documento_fe` IS NOT NULL; - --- Fix nome file con il tipo documento di vendita -UPDATE `zz_prints` SET `filename` = '{tipo_documento} num. {numero} del {data}' WHERE `zz_prints`.`name` = 'Fattura di vendita'; - --- Risorsa API per sincronizzazione rapida di un singolo intervento -INSERT INTO `zz_api_resources` (`id`, `version`, `type`, `resource`, `class`, `enabled`) VALUES -(NULL, 'app-v1', 'update', 'intervento-flash', 'API\\App\\v1\\Flash\\Intervento', '1'); - --- Colonna categoria impianto -INSERT INTO `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='Impianti'), 'Categoria', '(SELECT nome FROM my_impianti_categorie WHERE my_impianti_categorie.id=id_categoria)', 6, 1, 0, 0, '', '', 1, 0, 1); - --- --- Struttura della tabella `zz_imports` --- - -CREATE TABLE IF NOT EXISTS `zz_imports` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_module` int(11) NOT NULL, - `name` varchar(255) NOT NULL, - `class` varchar(255) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - -ALTER TABLE `zz_imports` - ADD FOREIGN KEY (`id_module`) REFERENCES `zz_modules`(`id`) ON DELETE CASCADE; - --- Importazioni di base -INSERT INTO `zz_imports` (`id_module`, `name`, `class`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Anagrafiche'), 'Anagrafiche', 'Modules\\Anagrafiche\\Import\\CSV'), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Articoli'), 'Articoli', 'Modules\\Articoli\\Import\\CSV'); - --- Introduzione hook per Notifiche su Ricevute FE -INSERT INTO `zz_hooks` (`id`, `name`, `class`, `enabled`, `id_module`, `processing_at`, `processing_token`) VALUES (NULL, 'Notifiche su Ricevute FE', 'Plugins\\ReceiptFE\\NotificheRicevuteHook', '1', (SELECT `id` FROM `zz_modules` WHERE `name`='Fatture di vendita'), NULL, NULL); - --- Aggiornamento query Articoli per aggiunta quantità ordinata -UPDATE `zz_modules` SET `options` = 'SELECT |select| -FROM `mg_articoli` - LEFT JOIN an_anagrafiche ON mg_articoli.id_fornitore = an_anagrafiche.idanagrafica - LEFT JOIN co_iva ON mg_articoli.idiva_vendita = co_iva.id - LEFT JOIN ( - SELECT SUM(or_righe_ordini.qta - or_righe_ordini.qta_evasa) AS qta_impegnata, or_righe_ordini.idarticolo - FROM or_righe_ordini - INNER JOIN or_ordini ON or_righe_ordini.idordine = or_ordini.id - INNER JOIN or_tipiordine ON or_ordini.idtipoordine = or_tipiordine.id - WHERE idstatoordine IN(SELECT id FROM or_statiordine WHERE completato = 0) - AND or_tipiordine.dir = ''entrata'' - AND or_righe_ordini.confermato = 1 - GROUP BY idarticolo - ) a ON a.idarticolo = mg_articoli.id - LEFT JOIN ( - SELECT SUM(or_righe_ordini.qta) AS qta_ordinata, or_righe_ordini.idarticolo - FROM or_righe_ordini - INNER JOIN or_ordini ON or_righe_ordini.idordine = or_ordini.id - INNER JOIN or_tipiordine ON or_ordini.idtipoordine = or_tipiordine.id - WHERE idstatoordine IN(SELECT id FROM or_statiordine WHERE completato = 1) - AND or_tipiordine.dir = ''uscita'' - AND or_righe_ordini.confermato = 1 - GROUP BY idarticolo - ) ordini_fornitore ON ordini_fornitore.idarticolo = mg_articoli.id - LEFT JOIN mg_categorie ON mg_articoli.id_categoria = mg_categorie.id - LEFT JOIN mg_categorie AS sottocategorie ON mg_articoli.id_sottocategoria = sottocategorie.id -WHERE 1=1 AND (`mg_articoli`.`deleted_at`) IS NULL -HAVING 2=2 -ORDER BY `mg_articoli`.`descrizione`' WHERE `zz_modules`.`name`='Articoli'; - -INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `visible`, `summable`, `default`) VALUES (NULL, (SELECT `zz_modules`.`id` FROM `zz_modules` WHERE `zz_modules`.`name`='Articoli'), 'Q.tà ordinata', 'ordini_fornitore.qta_ordinata', '10', '1', '0', '1', '', '', '1', '0', '1'); - --- Aggiunta sconto finale in Fatture --- Nota: lo sconto finale è limitato alla Fattura, e non può derivare da ulteriori documenti -ALTER TABLE `co_documenti` ADD `sconto_finale` DECIMAL(17,8) NOT NULL, - ADD `sconto_finale_percentuale` DECIMAL(17,8) NOT NULL; - --- Fix quantità positiva per Note di credito -UPDATE `co_righe_documenti` SET `qta` = ABS(`qta`), `qta_evasa` = ABS(`qta_evasa`), `subtotale` = ABS(`subtotale`), `iva` = ABS(`iva`), `ritenutaacconto` = ABS(`ritenutaacconto`), `rivalsainps` = ABS(`rivalsainps`); - -UPDATE `co_documenti` SET `ritenutaacconto` = ABS(`ritenutaacconto`), `rivalsainps` = ABS(`rivalsainps`), `ritenuta_contributi` = ABS(`ritenuta_contributi`); - --- Correzione widget con utilizzo interno delle quantità negative per Note -UPDATE `zz_widgets` SET `query` = 'SELECT - CONCAT_WS('' '', REPLACE(REPLACE(REPLACE(FORMAT(( - SELECT SUM( - (subtotale - sconto) * IF(co_tipidocumento.reversed, -1, 1) - ) - ), 2), '','', ''#''), ''.'', '',''), ''#'', ''.''), ''€'') AS dato -FROM co_righe_documenti - INNER JOIN co_documenti ON co_righe_documenti.iddocumento = co_documenti.id - INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento = co_tipidocumento.id -WHERE co_tipidocumento.dir=''entrata'' |segment| AND data >= ''|period_start|'' AND data <= ''|period_end|'' AND 1=1' WHERE `zz_widgets`.`name`='Fatturato'; - -UPDATE `zz_widgets` SET `query` = 'SELECT - CONCAT_WS('' '', REPLACE(REPLACE(REPLACE(FORMAT(( - SELECT SUM( - (subtotale - sconto) * IF(co_tipidocumento.reversed, -1, 1) - ) - ), 2), '','', ''#''), ''.'', '',''), ''#'', ''.''), ''€'') AS dato -FROM co_righe_documenti - INNER JOIN co_documenti ON co_righe_documenti.iddocumento = co_documenti.id - INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento = co_tipidocumento.id -WHERE co_tipidocumento.dir=''uscita'' |segment| AND data >= ''|period_start|'' AND data <= ''|period_end|'' AND 1=1' WHERE `zz_widgets`.`name`='Acquisti'; - - --- Correzione campi del Totale per le tabelle principali di Fatture -UPDATE `zz_views` SET `query` = 'righe.totale_imponibile * IF(co_tipidocumento.reversed, -1, 1)' WHERE `name` = 'Totale' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `zz_modules`.`name` = 'Fatture di vendita'); -UPDATE `zz_views` SET `query` = 'righe.totale_imponibile * IF(co_tipidocumento.reversed, -1, 1)' WHERE `name` = 'Totale' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `zz_modules`.`name` = 'Fatture di acquisto'); - -UPDATE `zz_views` SET `query` = '(righe.totale + `co_documenti`.`rivalsainps` + `co_documenti`.`iva_rivalsainps`) * IF(co_tipidocumento.reversed, -1, 1)' WHERE `name` = 'Totale ivato' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `zz_modules`.`name` = 'Fatture di vendita'); -UPDATE `zz_views` SET `query` = '(righe.totale + `co_documenti`.`rivalsainps` + `co_documenti`.`iva_rivalsainps`) * IF(co_tipidocumento.reversed, -1, 1)' WHERE `name` = 'Totale ivato' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `zz_modules`.`name` = 'Fatture di acquisto'); - -UPDATE `zz_views` SET `query` = '(righe.totale + `co_documenti`.`rivalsainps` + `co_documenti`.`iva_rivalsainps` - `co_documenti`.`ritenutaacconto`) * IF(co_tipidocumento.reversed, -1, 1)' WHERE `name` = 'Netto a pagare' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `zz_modules`.`name` = 'Fatture di vendita'); -UPDATE `zz_views` SET `query` = '(righe.totale + `co_documenti`.`rivalsainps` + `co_documenti`.`iva_rivalsainps` - `co_documenti`.`ritenutaacconto`) * IF(co_tipidocumento.reversed, -1, 1)' WHERE `name` = 'Netto a pagare' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `zz_modules`.`name` = 'Fatture di acquisto'); - --- Fix campi Conto dare e Conto avere del modulo Prima nota -UPDATE `zz_views` SET `order` = 5, `name`='Conto avere_new' WHERE `name`='Conto dare'; -UPDATE `zz_views` SET `order` = 8, `name`='Conto dare' WHERE `name`='Conto avere'; -UPDATE `zz_views` SET `name`='Conto avere' WHERE `name`='Conto avere_new'; - --- Aggiunta campo per scelta ordine in intervento -ALTER TABLE `in_interventi` ADD `id_ordine` INT(11) AFTER `id_contratto`; -ALTER TABLE `in_interventi` ADD FOREIGN KEY (`id_ordine`) REFERENCES `or_ordini`(`id`) ON DELETE CASCADE; - --- Aggiunta plugin consuntivo per ordini -INSERT INTO `zz_plugins` (`id`, `name`, `title`, `idmodule_from`, `idmodule_to`, `position`, `script`, `enabled`, `default`, `order`, `compatibility`, `version`, `options2`, `options`, `directory`, `help`) VALUES -(NULL, 'Consuntivo', 'Consuntivo', (SELECT `id` FROM `zz_modules` WHERE name='Ordini cliente'), (SELECT `id` FROM `zz_modules` WHERE name='Ordini cliente'), 'tab', 'ordini.consuntivo.php', 1, 0, 0, '', '', NULL, NULL, '', ''); - --- Stampa consuntivo ordini -INSERT INTO `zz_prints` (`id`, `id_module`, `is_record`, `name`, `title`, `filename`, `directory`, `previous`, `options`, `icon`, `version`, `compatibility`, `order`, `predefined`, `default`, `enabled`) VALUES -(NULL, (SELECT `id` FROM `zz_modules` WHERE name='Ordini cliente'), 1, 'Consuntivo ordine', 'Consuntivo ordine', 'Consuntivo ordine num. {numero} del {data}', 'ordini_cons', 'idordine', '{\"pricing\":true}', 'fa fa-print', '', '', 0, 0, 1, 1); diff --git a/update/2_4_23.php b/update/2_4_23.php deleted file mode 100644 index 85d6038dc..000000000 --- a/update/2_4_23.php +++ /dev/null @@ -1,26 +0,0 @@ -', '2020-08-01') - ->whereHas('stato', function ($query) { - return $query->whereNotIn('descrizione', ['Bozza', 'Annullata']); - }) - ->get(); - -foreach ($fatture as $fattura) { - $gestore = new GestoreMovimenti($fattura); - $gestore->registra(); -} - -// Completamento automatico informazioni IBAN per banche -$banche = Banca::all(); -foreach ($banche as $banca) { - try { - $banca->save(); - } catch (Exception $e) { - } -} diff --git a/update/2_4_23.sql b/update/2_4_23.sql deleted file mode 100644 index d9c089a8c..000000000 --- a/update/2_4_23.sql +++ /dev/null @@ -1,207 +0,0 @@ --- Aggiornamento Netto a pagare per considerare lo Sconto finale -UPDATE `zz_views` SET `query` = '(righe.totale + `co_documenti`.`rivalsainps` + `co_documenti`.`iva_rivalsainps` - `co_documenti`.`ritenutaacconto` - `co_documenti`.`sconto_finale`) * (1 - `co_documenti`.`sconto_finale_percentuale` / 100) * IF(co_tipidocumento.reversed, -1, 1)' WHERE `name` = 'Netto a pagare' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `zz_modules`.`name` = 'Fatture di vendita'); -UPDATE `zz_views` SET `query` = '(righe.totale + `co_documenti`.`rivalsainps` + `co_documenti`.`iva_rivalsainps` - `co_documenti`.`ritenutaacconto` - `co_documenti`.`sconto_finale`) * (1 - `co_documenti`.`sconto_finale_percentuale` / 100) * IF(co_tipidocumento.reversed, -1, 1)' WHERE `name` = 'Netto a pagare' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `zz_modules`.`name` = 'Fatture di acquisto'); - --- Fix aggiornamento query Articoli per aggiunta quantità ordinata -UPDATE `zz_modules` SET `options` = 'SELECT |select| -FROM `mg_articoli` - LEFT JOIN an_anagrafiche ON mg_articoli.id_fornitore = an_anagrafiche.idanagrafica - LEFT JOIN co_iva ON mg_articoli.idiva_vendita = co_iva.id - LEFT JOIN ( - SELECT SUM(or_righe_ordini.qta - or_righe_ordini.qta_evasa) AS qta_impegnata, or_righe_ordini.idarticolo - FROM or_righe_ordini - INNER JOIN or_ordini ON or_righe_ordini.idordine = or_ordini.id - INNER JOIN or_tipiordine ON or_ordini.idtipoordine = or_tipiordine.id - WHERE idstatoordine IN(SELECT id FROM or_statiordine WHERE completato = 1) - AND or_tipiordine.dir = ''entrata'' - AND or_righe_ordini.confermato = 1 - GROUP BY idarticolo - ) a ON a.idarticolo = mg_articoli.id - LEFT JOIN ( - SELECT SUM(or_righe_ordini.qta) AS qta_ordinata, or_righe_ordini.idarticolo - FROM or_righe_ordini - INNER JOIN or_ordini ON or_righe_ordini.idordine = or_ordini.id - INNER JOIN or_tipiordine ON or_ordini.idtipoordine = or_tipiordine.id - WHERE idstatoordine IN(SELECT id FROM or_statiordine WHERE completato = 1) - AND or_tipiordine.dir = ''uscita'' - AND or_righe_ordini.confermato = 1 - GROUP BY idarticolo - ) ordini_fornitore ON ordini_fornitore.idarticolo = mg_articoli.id - LEFT JOIN mg_categorie ON mg_articoli.id_categoria = mg_categorie.id - LEFT JOIN mg_categorie AS sottocategorie ON mg_articoli.id_sottocategoria = sottocategorie.id -WHERE 1=1 AND `mg_articoli`.`deleted_at` IS NULL -HAVING 2=2 -ORDER BY `mg_articoli`.`descrizione`' WHERE `zz_modules`.`name`='Articoli'; - --- Rimozione flag inutilizzato -ALTER TABLE `or_statiordine` DROP `annullato`; - --- Aggiunta flag "impegnato" sugli stati ordine -ALTER TABLE `or_statiordine` ADD `impegnato` BOOLEAN NOT NULL DEFAULT FALSE AFTER `icona`; -UPDATE `or_statiordine` SET `impegnato` = 1 WHERE `descrizione` IN('Evaso', 'Parzialmente evaso', 'Accettato', 'Parzialmente fatturato', 'Fatturato'); - --- Aggiornamento calcolo quantità impegnate ed evase -UPDATE `zz_modules` SET `options` = 'SELECT |select|\nFROM `mg_articoli`\n LEFT JOIN an_anagrafiche ON mg_articoli.id_fornitore = an_anagrafiche.idanagrafica\n LEFT JOIN co_iva ON mg_articoli.idiva_vendita = co_iva.id\n LEFT JOIN (\n SELECT SUM(or_righe_ordini.qta - or_righe_ordini.qta_evasa) AS qta_impegnata, or_righe_ordini.idarticolo\n FROM or_righe_ordini\n INNER JOIN or_ordini ON or_righe_ordini.idordine = or_ordini.id\n INNER JOIN or_tipiordine ON or_ordini.idtipoordine = or_tipiordine.id\n INNER JOIN or_statiordine ON or_ordini.idstatoordine = or_statiordine.id\n WHERE\n or_tipiordine.dir = \'entrata\'\n AND or_righe_ordini.confermato = 1\n AND or_statiordine.impegnato = 1\n GROUP BY idarticolo\n ) a ON a.idarticolo = mg_articoli.id\n LEFT JOIN (\n SELECT SUM(or_righe_ordini.qta-or_righe_ordini.qta_evasa) AS qta_ordinata, or_righe_ordini.idarticolo\n FROM or_righe_ordini\n INNER JOIN or_ordini ON or_righe_ordini.idordine = or_ordini.id\n INNER JOIN or_tipiordine ON or_ordini.idtipoordine = or_tipiordine.id\n INNER JOIN or_statiordine ON or_ordini.idstatoordine = or_statiordine.id\n WHERE\n or_tipiordine.dir = \'uscita\'\n AND or_righe_ordini.confermato = 1\n AND or_statiordine.impegnato = 1\n GROUP BY idarticolo\n ) ordini_fornitore ON ordini_fornitore.idarticolo = mg_articoli.id\n LEFT JOIN mg_categorie ON mg_articoli.id_categoria = mg_categorie.id\n LEFT JOIN mg_categorie AS sottocategorie ON mg_articoli.id_sottocategoria = sottocategorie.id\nWHERE 1=1 AND (`mg_articoli`.`deleted_at`) IS NULL\nHAVING 2=2\nORDER BY `mg_articoli`.`descrizione`' WHERE `zz_modules`.`name` = 'Articoli'; - --- Fix query widgets Fatturato e Acquisti -UPDATE `zz_widgets` SET `query` = 'SELECT\n CONCAT_WS(\' \', REPLACE(REPLACE(REPLACE(FORMAT((\n SELECT SUM(\n (co_righe_documenti.subtotale - co_righe_documenti.sconto) * IF(co_tipidocumento.reversed, -1, 1)\n )\n ), 2), \',\', \'#\'), \'.\', \',\'), \'#\', \'.\'), \'€\') AS dato\nFROM co_righe_documenti\n INNER JOIN co_documenti ON co_righe_documenti.iddocumento = co_documenti.id\n INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento = co_tipidocumento.id\nWHERE co_tipidocumento.dir=\'entrata\' |segment| AND data >= \'|period_start|\' AND data <= \'|period_end|\' AND 1=1' WHERE `zz_widgets`.`name` = 'Fatturato'; -UPDATE `zz_widgets` SET `query` = 'SELECT\n CONCAT_WS(\' \', REPLACE(REPLACE(REPLACE(FORMAT((\n SELECT SUM(\n (co_righe_documenti.subtotale - co_righe_documenti.sconto) * IF(co_tipidocumento.reversed, -1, 1)\n )\n ), 2), \',\', \'#\'), \'.\', \',\'), \'#\', \'.\'), \'€\') AS dato\nFROM co_righe_documenti\n INNER JOIN co_documenti ON co_righe_documenti.iddocumento = co_documenti.id\n INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento = co_tipidocumento.id\nWHERE co_tipidocumento.dir=\'uscita\' |segment| AND data >= \'|period_start|\' AND data <= \'|period_end|\' AND 1=1' WHERE `zz_widgets`.`name` = 'Acquisti'; - --- Aggiunta risorse API per creazione e modifica Articoli -INSERT INTO `zz_api_resources` (`id`, `version`, `type`, `resource`, `class`, `enabled`) VALUES -(NULL, 'v1', 'create', 'articolo', 'Modules\\Articoli\\API\\v1\\Articoli', '1'), -(NULL, 'v1', 'update', 'articolo', 'Modules\\Articoli\\API\\v1\\Articoli', '1'); - --- Fix visualizzazione attività in dashboard -UPDATE `zz_segments` SET `clause` = '(orario_inizio BETWEEN \'|period_start|\' AND \'|period_end|\' OR orario_fine BETWEEN \'|period_start|\' AND \'|period_end|\')' WHERE `zz_segments`.`name` = 'Attività'; - --- Aumentato limite per campo note in scheda anagrafica -ALTER TABLE `an_anagrafiche` CHANGE `note` `note` TEXT NOT NULL; - --- Aggiunta risorsa APi per revisione applicazione -INSERT INTO `zz_api_resources` (`id`, `version`, `type`, `resource`, `class`, `enabled`) VALUES -(NULL, 'app-v1', 'retrieve', 'revisione', 'API\\App\\v1\\Revisione', '1'); - --- Fix query listini -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM mg_prezzi_articoli INNER JOIN an_anagrafiche ON an_anagrafiche.idanagrafica = mg_prezzi_articoli.id_anagrafica INNER JOIN mg_articoli ON mg_articoli.id = mg_prezzi_articoli.id_articolo LEFT JOIN mg_categorie AS categoria ON mg_articoli.id_categoria=categoria.id LEFT JOIN mg_categorie AS sottocategoria ON mg_articoli.id_sottocategoria=sottocategoria.id WHERE 1=1 AND mg_articoli.deleted_at IS NULL AND an_anagrafiche.deleted_at IS NULL HAVING 2=2 ORDER BY an_anagrafiche.ragione_sociale' WHERE `zz_modules`.`name` = 'Listini'; - --- Cambiato title al plugin prezzi specifici -UPDATE `zz_plugins` SET `title` = 'Prezzi di listino' WHERE `zz_plugins`.`name` = 'Prezzi specifici articolo'; - --- Impostati stati fatturabili in ddt e ordini -ALTER TABLE `or_statiordine` ADD `is_fatturabile` TINYINT(1) NOT NULL AFTER `completato`; -ALTER TABLE `dt_statiddt` ADD `is_fatturabile` TINYINT(1) NOT NULL AFTER `completato`; - -UPDATE `or_statiordine` SET `is_fatturabile` = '1' WHERE `or_statiordine`.`descrizione` = 'Evaso'; -UPDATE `or_statiordine` SET `is_fatturabile` = '1' WHERE `or_statiordine`.`descrizione` = 'Parzialmente evaso'; -UPDATE `or_statiordine` SET `is_fatturabile` = '1' WHERE `or_statiordine`.`descrizione` = 'Parzialmente fatturato'; -UPDATE `or_statiordine` SET `is_fatturabile` = '1' WHERE `or_statiordine`.`descrizione` = 'Accettato'; -UPDATE `dt_statiddt` SET `is_fatturabile` = '1' WHERE `dt_statiddt`.`descrizione` = 'Evaso'; -UPDATE `dt_statiddt` SET `is_fatturabile` = '1' WHERE `dt_statiddt`.`descrizione` = 'Parzialmente evaso'; -UPDATE `dt_statiddt` SET `is_fatturabile` = '1' WHERE `dt_statiddt`.`descrizione` = 'Parzialmente fatturato'; - --- Aggiunta colonna um in Movimenti di magazzino -UPDATE `zz_views` SET `query` = 'mg_movimenti.qta' WHERE `zz_views`.`name` = 'Quantità'; -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `visible`, `summable`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE name='Movimenti'), 'Um', 'mg_articoli.um', 5, 1, 0, 0, '', '', 0, 0, 0); -INSERT INTO `zz_group_view` (`id_gruppo`, `id_vista`) ( -SELECT `zz_groups`.`id`, `zz_views`.`id` FROM `zz_groups`, `zz_views` INNER JOIN `zz_modules` ON `zz_views`.`id_module` = `zz_modules`.`id` WHERE `zz_modules`.`name` = 'Movimenti' AND `zz_views`.`name` = 'Um' -); --- Fix campo iva per Sconti di versioni precedenti -UPDATE `co_righe_documenti` SET `iva` = ABS(`iva`) * IF(`sconto` > 0, -1, 1) WHERE `is_sconto` = 1; -UPDATE `co_righe_preventivi` SET `iva` = ABS(`iva`) * IF(`sconto` > 0, -1, 1) WHERE `is_sconto` = 1; -UPDATE `co_righe_contratti` SET `iva` = ABS(`iva`) * IF(`sconto` > 0, -1, 1) WHERE `is_sconto` = 1; -UPDATE `dt_righe_ddt` SET `iva` = ABS(`iva`) * IF(`sconto` > 0, -1, 1) WHERE `is_sconto` = 1; -UPDATE `or_righe_ordini` SET `iva` = ABS(`iva`) * IF(`sconto` > 0, -1, 1) WHERE `is_sconto` = 1; -UPDATE `co_righe_promemoria` SET `iva` = ABS(`iva`) * IF(`sconto` > 0, -1, 1) WHERE `is_sconto` = 1; -UPDATE `in_righe_interventi` SET `iva` = ABS(`iva`) * IF(`sconto` > 0, -1, 1) WHERE `is_sconto` = 1; - --- Aumentato il campo descrizione in articoli da varchar a text -ALTER TABLE `mg_articoli` CHANGE `descrizione` `descrizione` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL; - --- Set a NULL le date dei contratti vuote -UPDATE `co_contratti` SET `data_bozza`=NULL WHERE `data_bozza`=0000-00-00; -UPDATE `co_contratti` SET `data_accettazione`=NULL WHERE `data_accettazione`=0000-00-00; -UPDATE `co_contratti` SET `data_rifiuto`=NULL WHERE `data_rifiuto`=0000-00-00; -UPDATE `co_contratti` SET `data_conclusione`=NULL WHERE `data_conclusione`=0000-00-00; - --- Aggiunto sconto finale in preventivi -ALTER TABLE `co_preventivi` ADD `sconto_finale` DECIMAL(17,8) NOT NULL AFTER `garanzia`, ADD `sconto_finale_percentuale` DECIMAL(17,8) NOT NULL AFTER `sconto_finale`; - --- Aggiunto sconto finale in ordini -ALTER TABLE `or_ordini` ADD `sconto_finale` DECIMAL(17,8) NOT NULL AFTER `numero_cliente`, ADD `sconto_finale_percentuale` DECIMAL(17,8) NOT NULL AFTER `sconto_finale`; - --- Aggiunto sconto finale in ddt -ALTER TABLE `dt_ddt` ADD `sconto_finale` DECIMAL(17,8) NOT NULL AFTER `num_item`, ADD `sconto_finale_percentuale` DECIMAL(17,8) NOT NULL AFTER `sconto_finale`; - --- Aggiunto sconto finale in contratti -ALTER TABLE `co_contratti` ADD `sconto_finale` DECIMAL(17,8) NOT NULL AFTER `num_item`, ADD `sconto_finale_percentuale` DECIMAL(17,8) NOT NULL AFTER `sconto_finale`; - --- Set a NULL le date dei preventivi vuote -UPDATE `co_preventivi` SET `data_bozza`=NULL WHERE `data_bozza`=0000-00-00; -UPDATE `co_preventivi` SET `data_accettazione`=NULL WHERE `data_accettazione`=0000-00-00; -UPDATE `co_preventivi` SET `data_rifiuto`=NULL WHERE `data_rifiuto`=0000-00-00; -UPDATE `co_preventivi` SET `data_conclusione`=NULL WHERE `data_conclusione`=0000-00-00; - --- Aggiunto filtro in attività per vedere interventi assegnati -INSERT INTO `zz_group_module` ( `idgruppo`, `idmodule`, `name`, `clause`, `position`, `enabled`, `default`) VALUES ((SELECT `id` FROM `zz_groups` WHERE `nome`='Tecnici'), (SELECT `id` FROM `zz_modules` WHERE name='Interventi'), 'Mostra interventi ai tecnici assegnati', 'in_interventi.id IN (SELECT id_intervento FROM in_interventi_tecnici_assegnati WHERE id_intervento=in_interventi.id AND id_tecnico=|id_anagrafica|)', 'WHR', 0, 1); - --- Aggiunta colonna Prev. evasione in Ordini -INSERT INTO `zz_views` ( `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `visible`, `summable`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE name='Ordini fornitore'), 'icon_Prev. evasione', 'IF(righe.`qta_da_evadere` > 0,IF((righe_da_evadere.data_evasione>now() OR righe_da_evadere.data_evasione IS NULL), \'fa fa-clock-o text-info\', \'fa fa-warning text-danger\'), \'fa fa-check text-success\')', 8, 1, 0, 0, '', '', 0, 0, 0), -((SELECT `id` FROM `zz_modules` WHERE name='Ordini fornitore'), 'icon_title_Prev. evasione', 'IF(righe.`qta_da_evadere` > 0,IF((righe_da_evadere.data_evasione>now() OR righe_da_evadere.data_evasione IS NULL), \'In orario\', \'In ritardo\'), \'Consegnato\')', 9, 1, 0, 0, '', '', 0, 0, 0); - -INSERT INTO `zz_views` ( `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `visible`, `summable`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE name='Ordini cliente'), 'icon_Prev. evasione', 'IF(righe.`qta_da_evadere` > 0,IF((righe_da_evadere.data_evasione>now() OR righe_da_evadere.data_evasione IS NULL), \'fa fa-clock-o text-info\', \'fa fa-warning text-danger\'), \'fa fa-check text-success\')', 8, 1, 0, 0, '', '', 0, 0, 0), -((SELECT `id` FROM `zz_modules` WHERE name='Ordini cliente'), 'icon_title_Prev. evasione', 'IF(righe.`qta_da_evadere` > 0,IF((righe_da_evadere.data_evasione>now() OR righe_da_evadere.data_evasione IS NULL), \'In orario\', \'In ritardo\'), \'Consegnato\')', 9, 1, 0, 0, '', '', 0, 0, 0); - -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`\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|\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`\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'; - -INSERT INTO `zz_group_view` (`id_gruppo`, `id_vista`) ( -SELECT `zz_groups`.`id`, `zz_views`.`id` FROM `zz_groups`, `zz_views` INNER JOIN `zz_modules` ON `zz_views`.`id_module` = `zz_modules`.`id` WHERE `zz_modules`.`name`='Ordini fornitore' AND (`zz_views`.`name` = 'icon_title_Prev. evasione' OR `zz_views`.`name` = 'icon_Prev. evasione') -); - -INSERT INTO `zz_group_view` (`id_gruppo`, `id_vista`) ( -SELECT `zz_groups`.`id`, `zz_views`.`id` FROM `zz_groups`, `zz_views` INNER JOIN `zz_modules` ON `zz_views`.`id_module` = `zz_modules`.`id` WHERE `zz_modules`.`name`='Ordini cliente' AND (`zz_views`.`name` = 'icon_title_Prev. evasione' OR `zz_views`.`name` = 'icon_Prev. evasione') -); - --- Aggiunto campo ora evasione in ordini -ALTER TABLE `or_righe_ordini` ADD `ora_evasione` TIME NULL AFTER `data_evasione`; - --- Aggiunta indice sull'id preventivo per velocizzare il caricamento del rif. numero fattura in vista preventivi -ALTER TABLE `co_righe_documenti` ADD INDEX(`idpreventivo`); - --- Aggiunta stampa dettaglio anagrafica -INSERT INTO `zz_prints` (`id_module`, `is_record`, `name`, `title`, `filename`, `directory`, `previous`, `options`, `icon`, `version`, `compatibility`, `order`, `predefined`, `default`, `enabled`) VALUES ((SELECT `zz_modules`.`id` FROM `zz_modules` WHERE `zz_modules`.`name`='Anagrafiche'), '1', 'Dettaglio anagrafica', 'Dettaglio anagrafica', 'Anagrafica {codice} - {ragione_sociale}', 'anagrafiche', 'idanagrafica', '', 'fa fa-print', '', '', '0', '1', '1', '1'); - --- Aggiunta stampa dati aziendali -INSERT INTO `zz_prints` (`id_module`, `is_record`, `name`, `title`, `filename`, `directory`, `previous`, `options`, `icon`, `version`, `compatibility`, `order`, `predefined`, `default`, `enabled`) VALUES ((SELECT `zz_modules`.`id` FROM `zz_modules` WHERE `zz_modules`.`name`='Anagrafiche'), '1', 'Dati aziendali', 'Dati aziendali', 'Dati aziendali {ragione_sociale}', 'azienda', 'idanagrafica', '', 'fa fa-print', '', '', '0', '0', '0', '1'); - --- Correzione per segmenti con pagamenti RiBa per Scadenzario -UPDATE `zz_segments` SET `clause` = REPLACE(`clause`, 'co_pagamenti.riba=1', 'co_pagamenti.codice_modalita_pagamento_fe= ''MP12'''); -ALTER TABLE `co_pagamenti` DROP `riba`; - --- Aggiunto filtro in contratti per i clienti -INSERT INTO `zz_group_module` (`idgruppo`, `idmodule`, `name`, `clause`, `position`, `enabled`, `default`) VALUES(4, 31, 'Mostra i contratti ai clienti coivolti', 'co_contratti.idanagrafica=|id_anagrafica|', 'WHR', 1, 1); - --- Fix widget crediti clienti -UPDATE `zz_widgets` SET `query` = 'SELECT \n CONCAT_WS(\' \', REPLACE(REPLACE(REPLACE(FORMAT((\n SELECT SUM(da_pagare-pagato)), 2), \',\', \'#\'), \'.\', \',\'),\'#\', \'.\'), \'€\') AS dato FROM (co_scadenziario INNER JOIN co_documenti ON co_scadenziario.iddocumento=co_documenti.id) INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE co_tipidocumento.dir=\'entrata\' AND co_documenti.idstatodocumento!=1 |segment| AND 1=1' WHERE `zz_widgets`.`name` = 'Crediti da clienti'; - --- Aggiunto campo descrizione revisione in preventivi -ALTER TABLE `co_preventivi` ADD `descrizione_revision` VARCHAR(255) NOT NULL AFTER `default_revision`; -UPDATE `zz_prints` SET `filename` = 'Preventivo num. {numero} del {data} rev {revisione}' WHERE `zz_prints`.`name` = 'Preventivo'; - --- Aggiunti campi per componenti IBAN -ALTER TABLE `co_banche` ADD `branch_code` VARCHAR(20) NULL, - ADD `bank_code` VARCHAR(20) NULL, - ADD `account_number` VARCHAR(20) NULL, - ADD `check_digits` VARCHAR(20) NULL, - ADD `national_check_digits` VARCHAR(20) NULL, - ADD `id_nazione` INT(11) NULL, - ADD FOREIGN KEY (`id_nazione`) REFERENCES `an_nazioni`(`id`); - --- Fix gestione documentale -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `do_documenti`\r\nINNER JOIN `do_categorie` ON `do_categorie`.`id` = `do_documenti`.`idcategoria`\r\nWHERE 1=1 AND `deleted_at` IS NULL AND\r\n (SELECT `idgruppo` FROM `zz_users` WHERE `zz_users`.`id` = |id_utente|) IN (SELECT `id_gruppo` FROM `do_permessi` WHERE `id_categoria` = `do_documenti`.`idcategoria`)\r\n |date_period(`data`)| OR data IS NULL\r\nHAVING 2=2' WHERE `zz_modules`.`name` = 'Gestione documentale'; - --- Messaggio Verifica numero intervento -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES -(NULL, 'Verifica numero intervento', '1', 'boolean', 1, 'Attività', 1, 'Visualizza il messaggio che verifica la continuità dei numeri per le attività'); - --- Allineamento colore icona EC02 -UPDATE `fe_stati_documento` SET `icon` = 'fa fa-times text-danger' WHERE `fe_stati_documento`.`codice` = 'EC02'; - --- Impostata aliquota iva per dichiarazone d'intento se non presente -UPDATE `zz_settings` SET `valore` = IF(`valore` ='', (SELECT `id` FROM `co_iva` WHERE `descrizione`='Non imp. art. 8 c.1 lett. c DPR 633/1972'), `valore`) WHERE `nome`="Iva per lettere d'intento"; - --- Fix query Fatture di acquisto -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_documenti`\nLEFT JOIN `an_anagrafiche` ON `co_documenti`.`idanagrafica` = `an_anagrafiche`.`idanagrafica`\nLEFT JOIN `co_tipidocumento` ON `co_documenti`.`idtipodocumento` = `co_tipidocumento`.`id`\nLEFT JOIN `co_statidocumento` ON `co_documenti`.`idstatodocumento` = `co_statidocumento`.`id`\nLEFT JOIN (\n SELECT `iddocumento`,\n SUM(`subtotale` - `sconto`) AS `totale_imponibile`,\n SUM(`subtotale` - `sconto` + `iva`) AS `totale`\n FROM `co_righe_documenti`\n GROUP BY `iddocumento`\n) AS righe ON `co_documenti`.`id` = `righe`.`iddocumento`\nLEFT JOIN (\n SELECT COUNT(`d`.`id`) AS `conteggio`,\n IF(`d`.`numero_esterno`=\'\', `d`.`numero`, `d`.`numero_esterno`) AS `numero_documento`,\n `d`.`idanagrafica` AS `anagrafica`\n FROM `co_documenti` AS `d`\n LEFT JOIN `co_tipidocumento` AS `d_tipo` ON `d`.`idtipodocumento` = `d_tipo`.`id`\n WHERE 1=1\n AND `d_tipo`.`dir` = \'uscita\'\n AND (\'|period_start|\' <= `d`.`data` AND \'|period_end|\' >= `d`.`data` OR \'|period_start|\' <= `d`.`data_competenza` AND \'|period_end|\' >= `d`.`data_competenza`)\n GROUP BY `numero_documento`, `d`.`idanagrafica`\n) AS `d` ON (`d`.`numero_documento` = IF(`co_documenti`.`numero_esterno`=\'\', `co_documenti`.`numero`, `co_documenti`.`numero_esterno`) AND `d`.`anagrafica`=`co_documenti`.`idanagrafica`)\nWHERE 1=1 AND `dir` = \'uscita\' |segment(`co_documenti`.`id_segment`)||date_period(custom, \'|period_start|\' <= `co_documenti`.`data` AND \'|period_end|\' >= `co_documenti`.`data`, \'|period_start|\' <= `co_documenti`.`data_competenza` AND \'|period_end|\' >= `co_documenti`.`data_competenza` )|\nHAVING 2=2\nORDER BY `co_documenti`.`data` DESC, CAST(IF(`co_documenti`.`numero` = \'\', `co_documenti`.`numero_esterno`, `co_documenti`.`numero`) AS UNSIGNED) DESC' WHERE `zz_modules`.`name` = 'Fatture di acquisto'; - --- Ripristino Fattura di vendita come stampa predefinita -UPDATE `zz_prints` SET `predefined` = '0' WHERE `zz_prints`.`name` = 'Fattura elettronica di vendita'; - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stampe'), 'Modulo', '(SELECT name FROM zz_modules WHERE zz_modules.id= zz_prints.id_module)', 4, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stampe'), 'Predefinita', 'zz_prints.predefined', 5, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stampe'), 'Ordine', 'zz_prints.order', 6, 1, 0, 0, 1); \ No newline at end of file diff --git a/update/2_4_24.sql b/update/2_4_24.sql deleted file mode 100644 index f92d79a8d..000000000 --- a/update/2_4_24.sql +++ /dev/null @@ -1,180 +0,0 @@ --- Colonna n. protocollo per fatture di acquisto -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `visible`, `summable`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE name='Fatture di acquisto'), 'N. Prot.', 'co_documenti.numero', 1, 1, 0, 0, '', '', 0, 0, 0); - --- Formattazione colonna data modulo Ordini fornitore -UPDATE `zz_views` SET `format`=1 WHERE `zz_views`.`name`='Data' AND `zz_views`.`id_module`=(SELECT `id` FROM `zz_modules` WHERE name='Ordini fornitore'); - --- Colonna stato per newsletter -INSERT INTO `zz_views` ( `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `visible`, `summable`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE name='Newsletter'), 'Stato', 'IF(em_newsletters.state = ''DEV'', ''Bozza'', IF(em_newsletters.state = ''WAIT'', ''Invio in corso'', ''Completata''))', 4, 1, 0, 0, '', '', 1, 0, 0); - --- Colonna destinatari per newsletter -INSERT INTO `zz_views` ( `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `visible`, `summable`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE name='Newsletter'), 'Destinatari', '(SELECT COUNT(*) FROM `em_newsletter_anagrafica` WHERE `em_newsletter_anagrafica`.`id_newsletter` = `em_newsletters`.`id`)', 5, 1, 0, 0, '', '', 1, 0, 0); - --- Aggiorno colonna completato per newsletter -UPDATE `zz_views` SET `query` = 'IF(completed_at IS NULL, ''No'', CONCAT(''Sì '', ''('', DATE_FORMAT(completed_at, ''%d/%m/%Y %H:%i:%s'' ), '')''))', `order` = 6 WHERE `zz_views`.`id_module` = (SELECT `id` FROM `zz_modules` WHERE name='Newsletter') AND `name` = 'Completato'; - --- Visualizza informazioni aggiuntive sul calendario -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES (NULL, 'Visualizza informazioni aggiuntive sul calendario', '0', 'boolean', '1', 'Dashboard', '1', 'Visualizza sul calendario il box Tutto il giorno dove possono essere presenti informazioni aggiuntve'); - --- Rinominate stampe ordini fornitore -UPDATE `zz_prints` SET `title` = 'Richiesta di offerta (RdO)' WHERE `zz_prints`.`name` = 'Ordine fornitore (senza costi)'; -UPDATE `zz_prints` SET `title` = 'Richiesta di acquisto (RdA)' WHERE `zz_prints`.`name` = 'Ordine fornitore'; - --- Aggiunta impostazione formato ore in stampa intervento -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `created_at`, `updated_at`, `order`, `help`) VALUES (NULL, 'Formato ore in stampa', 'Decimale', 'list[Decimale,Sessantesimi]', '1', 'Attività', NOW(), NOW(), '1', ''); - --- Aggiunta plugin allegati dell'anagrafica -INSERT INTO `zz_plugins` (`name`, `title`, `idmodule_from`, `idmodule_to`, `position`, `script`, `enabled`, `default`, `order`, `compatibility`, `version`, `options2`, `options`, `directory`, `help`) VALUES ('Allegati', 'Allegati', (SELECT `zz_modules`.`id` FROM `zz_modules` WHERE `zz_modules`.`name`='Anagrafiche'), (SELECT `zz_modules`.`id` FROM `zz_modules` WHERE `zz_modules`.`name`='Anagrafiche'), 'tab', 'allegati.php', '1', '0', '0', '', '', NULL, NULL, '', ''); - --- Aggiunta idsede nelle righe dell'intervento -ALTER TABLE `in_righe_interventi` ADD `idsede_partenza` INT NOT NULL AFTER `id_dettaglio_fornitore`; - - --- Aggiunto nuovo plugin Componenti e disabilitato quello precedente -UPDATE `zz_plugins` SET `name`='Componenti ini', `title`='Componenti ini' WHERE `name`='Componenti'; -UPDATE `zz_plugins` SET `enabled`=0 WHERE `name`='Componenti ini'; - -INSERT INTO `zz_plugins` ( `name`, `title`, `idmodule_from`, `idmodule_to`, `position`, `script`, `enabled`, `default`, `order`, `compatibility`, `version`, `options2`, `options`, `directory`, `help`, `created_at`, `updated_at`) VALUES ('Componenti', 'Componenti', (SELECT `id` FROM `zz_modules` WHERE name='Impianti'), (SELECT `id` FROM `zz_modules` WHERE name='Impianti'), 'tab', '', '1', '0', '0', '', '', NULL, 'custom', 'componenti', '', NOW(), NOW()); - -CREATE TABLE `my_componenti_articoli` ( `id` INT NOT NULL AUTO_INCREMENT, `id_impianto` INT NOT NULL , `id_articolo` INT NOT NULL , `pre_id_articolo` INT NOT NULL, `note` TEXT NOT NULL , `data_registrazione` DATE NULL , `data_installazione` DATE NULL , `data_disinstallazione` DATE NULL , `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , `updated_at` TIMESTAMP on update CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`)); - --- Aggiunta vista referente in modulo attività -INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `visible`, `summable`, `default`) VALUES (NULL, (SELECT `zz_modules`.`id` FROM `zz_modules` WHERE `zz_modules`.`name`='Interventi' ), 'Referente', '(SELECT an_referenti.nome FROM an_referenti WHERE an_referenti.id=in_interventi.idreferente)', '7', '1', '0', '0', '', '', '1', '0', '0'); - --- Aggiunta vista scaduto in scadenzario -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `visible`, `summable`, `default`) VALUES -((SELECT `zz_modules`.`id` FROM `zz_modules` WHERE `zz_modules`.`name`='Scadenzario' ), 'Scaduto', 'IF(pagato = da_pagare, ''NO'', IF(data_concordata IS NOT NULL AND data_concordata > NOW(), ''NO'', IF(scadenza < NOW(), ''SÌ'', ''NO'')))', 14, 1, 0, 0, '', '', 1, 0, 0); - -INSERT INTO `zz_group_view` (`id_gruppo`, `id_vista`) (SELECT `zz_groups`.`id`, `zz_views`.`id` FROM `zz_groups`, `zz_views` INNER JOIN `zz_modules` ON `zz_views`.`id_module` = `zz_modules`.`id` WHERE `zz_modules`.`name` = 'Scadenzario' AND `zz_views`.`name` = 'Scaduto'); - --- Aggiunta vista "N. utenti" per il modulo "Utenti e permessi" -INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `visible`, `summable`, `default`) VALUES -(NULL, (SELECT `zz_modules`.`id` FROM `zz_modules` WHERE `zz_modules`.`name`='Utenti e permessi'), 'N. utenti', '(SELECT COUNT(`id`) FROM `zz_users` WHERE `idgruppo` = `zz_groups`.`id`)', 3, 1, 0, 0, '', '', 1, 0, 0); - --- Aggiunto campo confermato, data e ora evasione in righe preventivi -ALTER TABLE `co_righe_preventivi` ADD `data_evasione` DATE NULL DEFAULT NULL AFTER `id`, ADD `ora_evasione` TIME NULL DEFAULT NULL AFTER `data_evasione`; -ALTER TABLE `co_righe_preventivi` ADD `confermato` BOOLEAN NOT NULL AFTER `id_dettaglio_fornitore`; -UPDATE `co_righe_preventivi` SET `confermato` = 1; - --- Aggiunta impostazione per impegnare o meno automaticamente le quantità nei preventivi -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES (NULL, 'Conferma automaticamente le quantità nei preventivi', '1', 'boolean', '1', 'Preventivi', NULL, NULL); --- Aggiunta vista "Esigibilità" per il modulo "IVA" -INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `visible`, `summable`, `default`) VALUES -(NULL, (SELECT `zz_modules`.`id` FROM `zz_modules` WHERE `zz_modules`.`name`='IVA'), 'Esigibilità', 'IF(esigibilita=''I'', ''IVA ad esigibilità immediata'', IF(esigibilita=''D'', ''IVA ad esigibilità differita'', ''Scissione dei pagamenti''))', 5, 1, 0, 0, '', '', 1, 0, 0); - --- Gestione righe da documenti esterni -INSERT INTO `zz_settings` (`nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES ('Permetti il superamento della soglia quantità dei documenti di origine', '0', 'boolean', '1', 'Generali', '20', NULL); - --- Aggiunta colonna Rif. fattura negli ordini -INSERT INTO `zz_views` ( `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `visible`, `summable`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE name='Ordini cliente'), 'Rif. fattura', 'fattura.info', 11, 1, 0, 0, '', '', 1, 0, 0), -((SELECT `id` FROM `zz_modules` WHERE name='Ordini fornitore'), 'Rif. fattura', 'fattura.info', 8, 1, 0, 0, '', '', 1, 0, 0); - -UPDATE `zz_modules` SET `options` = 'SELECT |select| -FROM `or_ordini` - LEFT JOIN `an_anagrafiche` ON `or_ordini`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - LEFT JOIN `or_tipiordine` ON `or_ordini`.`idtipoordine` = `or_tipiordine`.`id` - LEFT JOIN ( - SELECT `idordine`, - SUM(`qta` - `qta_evasa`) AS `qta_da_evadere`, - SUM(`subtotale` - `sconto`) AS `totale_imponibile`, - SUM(`subtotale` - `sconto` + `iva`) AS `totale` - FROM `or_righe_ordini` - GROUP BY `idordine` - ) AS righe ON `or_ordini`.`id` = `righe`.`idordine` - LEFT JOIN ( - SELECT `idordine`, - MIN(`data_evasione`) AS `data_evasione` - FROM `or_righe_ordini` - WHERE (`qta` - `qta_evasa`)>0 - GROUP BY `idordine` - ) AS `righe_da_evadere` ON `righe`.`idordine`=`righe_da_evadere`.`idordine` - LEFT JOIN ( - SELECT GROUP_CONCAT(DISTINCT co_documenti.numero_esterno SEPARATOR \", \") AS info, co_righe_documenti.idordine FROM co_documenti INNER JOIN co_righe_documenti ON co_documenti.id = co_righe_documenti.iddocumento GROUP BY idordine -) AS fattura ON fattura.idordine = or_ordini.id -WHERE 1=1 AND `dir` = ''entrata'' |date_period(`data`)| -HAVING 2=2 -ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC' WHERE `zz_modules`.`name` = 'Ordini cliente'; - -UPDATE `zz_modules` SET `options` = 'SELECT |select| -FROM `or_ordini` - LEFT JOIN `an_anagrafiche` ON `or_ordini`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` - LEFT JOIN `or_tipiordine` ON `or_ordini`.`idtipoordine` = `or_tipiordine`.`id` - LEFT JOIN ( - SELECT `idordine`, - SUM(`qta` - `qta_evasa`) AS `qta_da_evadere`, - SUM(`subtotale` - `sconto`) AS `totale_imponibile`, - SUM(`subtotale` - `sconto` + `iva`) AS `totale` - FROM `or_righe_ordini` - GROUP BY `idordine` - ) AS righe ON `or_ordini`.`id` = `righe`.`idordine` - LEFT JOIN ( - SELECT `idordine`, - MIN(`data_evasione`) AS `data_evasione` - FROM `or_righe_ordini` - WHERE (`qta` - `qta_evasa`)>0 - GROUP BY `idordine` - ) AS `righe_da_evadere` ON `righe`.`idordine`=`righe_da_evadere`.`idordine` - LEFT JOIN ( - SELECT GROUP_CONCAT(DISTINCT co_documenti.numero_esterno SEPARATOR \", \") AS info, co_righe_documenti.idordine FROM co_documenti INNER JOIN co_righe_documenti ON co_documenti.id = co_righe_documenti.iddocumento GROUP BY idordine -) AS fattura ON fattura.idordine = or_ordini.id -WHERE 1=1 AND `dir` = ''uscita'' |date_period(`data`)| -HAVING 2=2 -ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC' WHERE `zz_modules`.`name` = 'Ordini fornitore'; - -INSERT INTO `zz_api_resources` (`id`, `version`, `type`, `resource`, `class`, `enabled`) VALUES -(NULL, 'app-v1', 'retrieve', 'sedi-azienda', 'API\\App\\v1\\SediAzienda', '1'), -(NULL, 'app-v1', 'retrieve', 'sedi-azienda-cleanup', 'API\\App\\v1\\SediAzienda', '1'), -(NULL, 'app-v1', 'retrieve', 'sede-azienda', 'API\\App\\v1\\SediAzienda', '1'), -(NULL, 'app-v1', 'retrieve', 'movimenti-manuali', 'API\\App\\v1\\MovimentiManuali', '1'), -(NULL, 'app-v1', 'retrieve', 'movimenti-manuali-cleanup', 'API\\App\\v1\\MovimentiManuali', '1'), -(NULL, 'app-v1', 'create', 'movimento-manuale', 'API\\App\\v1\\MovimentiManuali', '1'), -(NULL, 'app-v1', 'retrieve', 'controllo-clienti', 'API\\App\\v1\\ControlloClienti', '1'), -(NULL, 'app-v1', 'retrieve', 'segnalazione-bug', 'API\\App\\v1\\SegnalazioneBug', '1'), -(NULL, 'app-v1', 'create', 'segnalazione-bug', 'API\\App\\v1\\SegnalazioneBug', '1'); - --- Aggiunto collegamento tra DDT in direzioni opposte per gestione movimentazioni interne tra sedi -ALTER TABLE `dt_ddt` ADD `id_ddt_trasporto_interno` INT(11) NULL, ADD FOREIGN KEY (`id_ddt_trasporto_interno`) REFERENCES `dt_ddt`(`id`) ON DELETE CASCADE; - --- Aggiunto ragruppamento referenti per sede -UPDATE `zz_plugins` SET `options` = ' { \"main_query\": [ { \"type\": \"table\", \"fields\": \"Nome, Indirizzo, Città, CAP, Provincia, Referente\", \"query\": \"SELECT an_sedi.id, an_sedi.nomesede AS Nome, an_sedi.indirizzo AS Indirizzo, an_sedi.citta AS Città, an_sedi.cap AS CAP, an_sedi.provincia AS Provincia, GROUP_CONCAT(an_referenti.nome SEPARATOR \\\", \\\") AS Referente FROM an_sedi LEFT OUTER JOIN an_referenti ON idsede = an_sedi.id WHERE 1=1 AND an_sedi.idanagrafica=|id_parent| GROUP BY an_sedi.id HAVING 2=2 ORDER BY an_sedi.id DESC\"} ]}' WHERE `zz_plugins`.`name` = 'Sedi'; -UPDATE `zz_group_module` SET `clause` = 'in_interventi.id IN (SELECT idintervento FROM in_interventi_tecnici WHERE idintervento=in_interventi.id AND idtecnico=|id_anagrafica| UNION SELECT id_intervento FROM in_interventi_tecnici_assegnati WHERE id_intervento=in_interventi.id AND id_tecnico=|id_anagrafica|)' WHERE `zz_group_module`.`name` = 'Mostra interventi ai tecnici coinvolti'; - --- Aggiunto supporto autenticazione OAuth 2 -ALTER TABLE `em_accounts` ADD `provider` varchar(255), - ADD `client_id` TEXT, - ADD `client_secret` TEXT, - ADD `oauth2_state` TEXT, - ADD `access_token` TEXT, - ADD `refresh_token` TEXT; - --- Aggiornamento plugin Listini per Articoli -UPDATE `zz_plugins` SET `name` = 'Listino Clienti', `title` = 'Listino clienti', `directory` = 'listino_clienti' WHERE `zz_plugins`.`name` = 'Prezzi specifici articolo'; -INSERT INTO `zz_plugins` (`id`, `name`, `title`, `idmodule_from`, `idmodule_to`, `position`, `directory`, `options`) VALUES -(NULL, 'Listino Fornitori', 'Listino fornitori', (SELECT `id` FROM `zz_modules` WHERE `name`='Articoli'), (SELECT `id` FROM `zz_modules` WHERE `name`='Articoli'), 'tab', 'listino_fornitori', 'custom'), -(NULL, 'Piani di sconto/maggiorazione', 'Piani di sconto/magg.', (SELECT `id` FROM `zz_modules` WHERE `name`='Articoli'), (SELECT `id` FROM `zz_modules` WHERE `name`='Articoli'), 'tab', 'piani_sconto_maggiorazione', 'custom'); - -UPDATE `zz_modules` SET `name` = 'Piani di sconto/maggiorazione' WHERE `name` = 'Piani di sconto/magg.'; - --- Aggiunta riferimento documenti -ALTER TABLE `co_righe_promemoria` ADD `original_document_type` varchar(255) AFTER `original_type`, ADD `original_document_id` int(11) AFTER `original_type`; -ALTER TABLE `in_righe_interventi` ADD `original_document_type` varchar(255) AFTER `original_type`, ADD `original_document_id` int(11) AFTER `original_type`; -ALTER TABLE `co_righe_contratti` ADD `original_document_type` varchar(255) AFTER `original_type`, ADD `original_document_id` int(11) AFTER `original_type`; -ALTER TABLE `co_righe_preventivi` ADD `original_document_type` varchar(255) AFTER `original_type`, ADD `original_document_id` int(11) AFTER `original_type`; -ALTER TABLE `co_righe_documenti` ADD `original_document_type` varchar(255) AFTER `original_type`, ADD `original_document_id` int(11) AFTER `original_type`; -ALTER TABLE `or_righe_ordini` ADD `original_document_type` varchar(255) AFTER `original_type`, ADD `original_document_id` int(11) AFTER `original_type`; -ALTER TABLE `dt_righe_ddt` ADD `original_document_type` varchar(255) AFTER `original_type`, ADD `original_document_id` int(11) AFTER `original_type`; - -UPDATE `co_righe_documenti` SET `original_document_id` = `idcontratto`, `original_document_type` = 'Modules\\Contratti\\Contratto' WHERE `idcontratto` != 0; -UPDATE `co_righe_documenti` SET `original_document_id` = `idpreventivo`, `original_document_type` = 'Modules\\Preventivi\\Preventivo' WHERE `idpreventivo` != 0; -UPDATE `co_righe_documenti` SET `original_document_id` = `idintervento`, `original_document_type` = 'Modules\\Interventi\\Intervento' WHERE `idintervento` IS NOT NULL; -UPDATE `co_righe_documenti` SET `original_document_id` = `idordine`, `original_document_type` = 'Modules\\Ordini\\Ordine' WHERE `idordine` != 0; -UPDATE `co_righe_documenti` SET `original_document_id` = `idintervento`, `original_document_type` = 'Modules\\DDT\\DDT' WHERE `idddt` != 0; -UPDATE `co_righe_documenti` INNER JOIN `co_righe_documenti` AS origine ON `origine`.`id` = `co_righe_documenti`.`ref_riga_documento` SET `co_righe_documenti`.`original_document_id` = `origine`.`iddocumento`, `co_righe_documenti`.`original_document_type` = 'Modules\\Fatture\\Fattura' WHERE `co_righe_documenti`.`ref_riga_documento` IS NOT NULL; - -UPDATE `dt_righe_ddt` SET `original_document_id` = `idordine`, `original_document_type` = 'Modules\\Ordini\\Ordine' WHERE `idordine` != 0; - -UPDATE `or_righe_ordini` SET `original_document_id` = `idpreventivo`, `original_document_type` = 'Modules\\Preventivi\\Preventivo' WHERE `idpreventivo` != 0; diff --git a/update/2_4_25.sql b/update/2_4_25.sql deleted file mode 100644 index bd5d2cb70..000000000 --- a/update/2_4_25.sql +++ /dev/null @@ -1,2 +0,0 @@ --- Aggiornato widget Contratti in scadenza (sostituito fatturabile con pianificabile) -UPDATE `zz_widgets` SET `query` = 'SELECT COUNT(dati.id) AS dato FROM(SELECT id, ((SELECT SUM(co_righe_contratti.qta) FROM co_righe_contratti WHERE co_righe_contratti.um=\'ore\' AND co_righe_contratti.idcontratto=co_contratti.id) - IFNULL( (SELECT SUM(in_interventi_tecnici.ore) FROM in_interventi_tecnici INNER JOIN in_interventi ON in_interventi_tecnici.idintervento=in_interventi.id WHERE in_interventi.id_contratto=co_contratti.id AND in_interventi.idstatointervento IN (SELECT in_statiintervento.idstatointervento FROM in_statiintervento WHERE in_statiintervento.is_completato = 1)), 0) ) AS ore_rimanenti, DATEDIFF(data_conclusione, NOW()) AS giorni_rimanenti, data_conclusione, ore_preavviso_rinnovo, giorni_preavviso_rinnovo, (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=co_contratti.idanagrafica) AS ragione_sociale FROM co_contratti WHERE idstato IN (SELECT id FROM co_staticontratti WHERE is_pianificabile = 1) AND rinnovabile = 1 AND YEAR(data_conclusione) > 1970 AND (SELECT id FROM co_contratti contratti WHERE contratti.idcontratto_prev = co_contratti.id) IS NULL HAVING (ore_rimanenti < ore_preavviso_rinnovo OR DATEDIFF(data_conclusione, NOW()) < ABS(giorni_preavviso_rinnovo)) ORDER BY giorni_rimanenti ASC, ore_rimanenti ASC) dati' WHERE `zz_widgets`.`name` = 'Contratti in scadenza'; \ No newline at end of file diff --git a/update/2_4_3.php b/update/2_4_3.php deleted file mode 100755 index d61e4f793..000000000 --- a/update/2_4_3.php +++ /dev/null @@ -1,631 +0,0 @@ - 'Afghanistan', - 'AL' => 'Albania', - 'DZ' => 'Algeria', - 'UM' => 'Altre isole americane del Pacifico', - 'AD' => 'Andorra', - 'AO' => 'Angola', - 'AI' => 'Anguilla', - 'AQ' => 'Antartide', - 'AG' => 'Antigua e Barbuda', - 'SA' => 'Arabia Saudita', - 'AR' => 'Argentina', - 'AM' => 'Armenia', - 'AW' => 'Aruba', - 'AU' => 'Australia', - 'AT' => 'Austria', - 'AZ' => 'Azerbaigian', - 'BS' => 'Bahamas', - 'BH' => 'Bahrein', - 'BD' => 'Bangladesh', - 'BB' => 'Barbados', - 'BE' => 'Belgio', - 'BZ' => 'Belize', - 'BJ' => 'Benin', - 'BM' => 'Bermuda', - 'BT' => 'Bhutan', - 'BY' => 'Bielorussia', - 'BO' => 'Bolivia', - 'BA' => 'Bosnia ed Erzegovina', - 'BW' => 'Botswana', - 'BR' => 'Brasile', - 'BN' => 'Brunei', - 'BG' => 'Bulgaria', - 'BF' => 'Burkina Faso', - 'BI' => 'Burundi', - 'KH' => 'Cambogia', - 'CM' => 'Camerun', - 'CA' => 'Canada', - 'CV' => 'Capo Verde', - 'BQ' => 'Caraibi olandesi', - 'CZ' => 'Repubblica ceca', - 'EA' => 'Ceuta e Melilla', - 'TD' => 'Ciad', - 'CL' => 'Cile', - 'CN' => 'Cina', - 'CY' => 'Cipro', - 'VA' => 'Città del Vaticano', - 'CO' => 'Colombia', - 'KM' => 'Comore', - 'CD' => 'Congo - Kinshasa', - 'CG' => 'Congo-Brazzaville', - 'KP' => 'Corea del Nord', - 'KR' => 'Corea del Sud', - 'CI' => 'Costa d’Avorio', - 'CR' => 'Costa Rica', - 'HR' => 'Croazia', - 'CU' => 'Cuba', - 'CW' => 'Curaçao', - 'DK' => 'Danimarca', - 'DG' => 'Diego Garcia', - 'DM' => 'Dominica', - 'EC' => 'Ecuador', - 'EG' => 'Egitto', - 'SV' => 'El Salvador', - 'AE' => 'Emirati Arabi Uniti', - 'ER' => 'Eritrea', - 'EE' => 'Estonia', - 'ET' => 'Etiopia', - 'EZ' => 'Eurozone', - 'FJ' => 'Figi', - 'PH' => 'Filippine', - 'FI' => 'Finlandia', - 'FR' => 'Francia', - 'GA' => 'Gabon', - 'GM' => 'Gambia', - 'GE' => 'Georgia', - 'GS' => 'Georgia del Sud e Sandwich australi', - 'DE' => 'Germania', - 'GH' => 'Ghana', - 'JM' => 'Giamaica', - 'JP' => 'Giappone', - 'GI' => 'Gibilterra', - 'DJ' => 'Gibuti', - 'JO' => 'Giordania', - 'GR' => 'Grecia', - 'GD' => 'Grenada', - 'GL' => 'Groenlandia', - 'GP' => 'Guadalupa', - 'GU' => 'Guam', - 'GT' => 'Guatemala', - 'GG' => 'Guernsey', - 'GN' => 'Guinea', - 'GQ' => 'Guinea Equatoriale', - 'GW' => 'Guinea-Bissau', - 'GY' => 'Guyana', - 'GF' => 'Guyana francese', - 'HT' => 'Haiti', - 'HN' => 'Honduras', - 'IN' => 'India', - 'ID' => 'Indonesia', - 'IR' => 'Iran', - 'IQ' => 'Iraq', - 'IE' => 'Irlanda', - 'IS' => 'Islanda', - 'AC' => 'Isola Ascensione', - 'CX' => 'Isola Christmas', - 'IM' => 'Isola di Man', - 'NF' => 'Isola Norfolk', - 'AX' => 'Isole Åland', - 'IC' => 'Isole Canarie', - 'KY' => 'Isole Cayman', - 'CC' => 'Isole Cocos (Keeling)', - 'CK' => 'Isole Cook', - 'FO' => 'Isole Fær Øer', - 'FK' => 'Isole Falkland', - 'MP' => 'Isole Marianne settentrionali', - 'MH' => 'Isole Marshall', - 'PN' => 'Isole Pitcairn', - 'SB' => 'Isole Salomone', - 'TC' => 'Isole Turks e Caicos', - 'VI' => 'Isole Vergini Americane', - 'VG' => 'Isole Vergini Britanniche', - 'IL' => 'Israele', - 'IT' => 'Italia', - 'JE' => 'Jersey', - 'KZ' => 'Kazakistan', - 'KE' => 'Kenya', - 'KG' => 'Kirghizistan', - 'KI' => 'Kiribati', - 'XK' => 'Kosovo', - 'KW' => 'Kuwait', - 'LA' => 'Laos', - 'LS' => 'Lesotho', - 'LV' => 'Lettonia', - 'LB' => 'Libano', - 'LR' => 'Liberia', - 'LY' => 'Libia', - 'LI' => 'Liechtenstein', - 'LT' => 'Lituania', - 'LU' => 'Lussemburgo', - 'MG' => 'Madagascar', - 'MW' => 'Malawi', - 'MY' => 'Malesia', - 'MV' => 'Maldive', - 'ML' => 'Mali', - 'MT' => 'Malta', - 'MA' => 'Marocco', - 'MQ' => 'Martinica', - 'MR' => 'Mauritania', - 'MU' => 'Mauritius', - 'YT' => 'Mayotte', - 'MX' => 'Messico', - 'FM' => 'Micronesia', - 'MD' => 'Moldavia', - 'MC' => 'Monaco', - 'MN' => 'Mongolia', - 'ME' => 'Montenegro', - 'MS' => 'Montserrat', - 'MZ' => 'Mozambico', - 'MM' => 'Myanmar (Birmania)', - 'NA' => 'Namibia', - 'NR' => 'Nauru', - 'UN' => 'nazioni unite', - 'NP' => 'Nepal', - 'NI' => 'Nicaragua', - 'NE' => 'Niger', - 'NG' => 'Nigeria', - 'NU' => 'Niue', - 'NO' => 'Norvegia', - 'NC' => 'Nuova Caledonia', - 'NZ' => 'Nuova Zelanda', - 'OM' => 'Oman', - 'NL' => 'Paesi Bassi', - 'PK' => 'Pakistan', - 'PW' => 'Palau', - 'PA' => 'Panamá', - 'PG' => 'Papua Nuova Guinea', - 'PY' => 'Paraguay', - 'PE' => 'Perù', - 'PF' => 'Polinesia francese', - 'PL' => 'Polonia', - 'PT' => 'Portogallo', - 'PR' => 'Portorico', - 'QA' => 'Qatar', - 'HK' => 'RAS di Hong Kong', - 'MO' => 'RAS di Macao', - 'GB' => 'Regno Unito', - 'CF' => 'Repubblica Centrafricana', - 'MK' => 'Repubblica di Macedonia', - 'DO' => 'Repubblica Dominicana', - 'RE' => 'Riunione', - 'RO' => 'Romania', - 'RW' => 'Ruanda', - 'RU' => 'Russia', - 'EH' => 'Sahara occidentale', - 'KN' => 'Saint Kitts e Nevis', - 'LC' => 'Saint Lucia', - 'MF' => 'Saint Martin', - 'PM' => 'Saint Pierre e Miquelon', - 'VC' => 'Saint Vincent e Grenadines', - 'BL' => 'Saint-Barthélemy', - 'WS' => 'Samoa', - 'AS' => 'Samoa americane', - 'SM' => 'San Marino', - 'SH' => 'Sant’Elena', - 'ST' => 'São Tomé e Príncipe', - 'SN' => 'Senegal', - 'RS' => 'Serbia', - 'SC' => 'Seychelles', - 'SL' => 'Sierra Leone', - 'SG' => 'Singapore', - 'SX' => 'Sint Maarten', - 'SY' => 'Siria', - 'SK' => 'Slovacchia', - 'SI' => 'Slovenia', - 'SO' => 'Somalia', - 'ES' => 'Spagna', - 'LK' => 'Sri Lanka', - 'US' => 'Stati Uniti', - 'SS' => 'Sud Sudan', - 'ZA' => 'Sudafrica', - 'SD' => 'Sudan', - 'SR' => 'Suriname', - 'SJ' => 'Svalbard e Jan Mayen', - 'SE' => 'Svezia', - 'CH' => 'Svizzera', - 'SZ' => 'Swaziland', - 'TJ' => 'Tagikistan', - 'TW' => 'Taiwan', - 'TZ' => 'Tanzania', - 'TF' => 'Terre australi francesi', - 'PS' => 'Territori palestinesi', - 'IO' => 'Territorio britannico dell’Oceano Indiano', - 'TH' => 'Thailandia', - 'TL' => 'Timor Est', - 'TG' => 'Togo', - 'TK' => 'Tokelau', - 'TO' => 'Tonga', - 'TT' => 'Trinidad e Tobago', - 'TA' => 'Tristan da Cunha', - 'TN' => 'Tunisia', - 'TR' => 'Turchia', - 'TM' => 'Turkmenistan', - 'TV' => 'Tuvalu', - 'UA' => 'Ucraina', - 'UG' => 'Uganda', - 'HU' => 'Ungheria', - 'UY' => 'Uruguay', - 'UZ' => 'Uzbekistan', - 'VU' => 'Vanuatu', - 'VE' => 'Venezuela', - 'VN' => 'Vietnam', - 'WF' => 'Wallis e Futuna', - 'YE' => 'Yemen', - 'ZM' => 'Zambia', - 'ZW' => 'Zimbabwe', - 'AN' => 'Antille olandesi', -]; - -$en = [ - 'AF' => 'Afghanistan', - 'AX' => 'Åland Islands', - 'AL' => 'Albania', - 'DZ' => 'Algeria', - 'AS' => 'American Samoa', - 'AD' => 'Andorra', - 'AO' => 'Angola', - 'AI' => 'Anguilla', - 'AQ' => 'Antarctica', - 'AG' => 'Antigua & Barbuda', - 'AR' => 'Argentina', - 'AM' => 'Armenia', - 'AW' => 'Aruba', - 'AC' => 'Ascension Island', - 'AU' => 'Australia', - 'AT' => 'Austria', - 'AZ' => 'Azerbaijan', - 'BS' => 'Bahamas', - 'BH' => 'Bahrain', - 'BD' => 'Bangladesh', - 'BB' => 'Barbados', - 'BY' => 'Belarus', - 'BE' => 'Belgium', - 'BZ' => 'Belize', - 'BJ' => 'Benin', - 'BM' => 'Bermuda', - 'BT' => 'Bhutan', - 'BO' => 'Bolivia', - 'BA' => 'Bosnia & Herzegovina', - 'BW' => 'Botswana', - 'BR' => 'Brazil', - 'IO' => 'British Indian Ocean Territory', - 'VG' => 'British Virgin Islands', - 'BN' => 'Brunei', - 'BG' => 'Bulgaria', - 'BF' => 'Burkina Faso', - 'BI' => 'Burundi', - 'KH' => 'Cambodia', - 'CM' => 'Cameroon', - 'CA' => 'Canada', - 'IC' => 'Canary Islands', - 'CV' => 'Cape Verde', - 'BQ' => 'Caribbean Netherlands', - 'KY' => 'Cayman Islands', - 'CF' => 'Central African Republic', - 'EA' => 'Ceuta & Melilla', - 'TD' => 'Chad', - 'CL' => 'Chile', - 'CN' => 'China', - 'CX' => 'Christmas Island', - 'CC' => 'Cocos (Keeling) Islands', - 'CO' => 'Colombia', - 'KM' => 'Comoros', - 'CG' => 'Repubblica del Congo', - 'CD' => 'Repubblica Democratica del Congo', - 'CK' => 'Cook Islands', - 'CR' => 'Costa Rica', - 'CI' => 'Côte d’Ivoire', - 'HR' => 'Croatia', - 'CU' => 'Cuba', - 'CW' => 'Curaçao', - 'CY' => 'Cyprus', - 'CZ' => 'Czechia', - 'DK' => 'Denmark', - 'DG' => 'Diego Garcia', - 'DJ' => 'Djibouti', - 'DM' => 'Dominica', - 'DO' => 'Dominican Republic', - 'EC' => 'Ecuador', - 'EG' => 'Egypt', - 'SV' => 'El Salvador', - 'GQ' => 'Equatorial Guinea', - 'ER' => 'Eritrea', - 'EE' => 'Estonia', - 'ET' => 'Ethiopia', - 'EZ' => 'Eurozone', - 'FK' => 'Falkland Islands', - 'FO' => 'Faroe Islands', - 'FJ' => 'Fiji', - 'FI' => 'Finland', - 'FR' => 'France', - 'GF' => 'French Guiana', - 'PF' => 'French Polynesia', - 'TF' => 'French Southern Territories', - 'GA' => 'Gabon', - 'GM' => 'Gambia', - 'GE' => 'Georgia', - 'DE' => 'Germany', - 'GH' => 'Ghana', - 'GI' => 'Gibraltar', - 'GR' => 'Greece', - 'GL' => 'Greenland', - 'GD' => 'Grenada', - 'GP' => 'Guadeloupe', - 'GU' => 'Guam', - 'GT' => 'Guatemala', - 'GG' => 'Guernsey', - 'GN' => 'Guinea', - 'GW' => 'Guinea-Bissau', - 'GY' => 'Guyana', - 'HT' => 'Haiti', - 'HN' => 'Honduras', - 'HK' => 'Hong Kong SAR China', - 'HU' => 'Hungary', - 'IS' => 'Iceland', - 'IN' => 'India', - 'ID' => 'Indonesia', - 'IR' => 'Iran', - 'IQ' => 'Iraq', - 'IE' => 'Ireland', - 'IM' => 'Isle of Man', - 'IL' => 'Israel', - 'IT' => 'Italy', - 'JM' => 'Jamaica', - 'JP' => 'Japan', - 'JE' => 'Jersey', - 'JO' => 'Jordan', - 'KZ' => 'Kazakhstan', - 'KE' => 'Kenya', - 'KI' => 'Kiribati', - 'XK' => 'Kosovo', - 'KW' => 'Kuwait', - 'KG' => 'Kyrgyzstan', - 'LA' => 'Laos', - 'LV' => 'Latvia', - 'LB' => 'Lebanon', - 'LS' => 'Lesotho', - 'LR' => 'Liberia', - 'LY' => 'Libya', - 'LI' => 'Liechtenstein', - 'LT' => 'Lithuania', - 'LU' => 'Luxembourg', - 'MO' => 'Macau SAR China', - 'MK' => 'Macedonia', - 'MG' => 'Madagascar', - 'MW' => 'Malawi', - 'MY' => 'Malaysia', - 'MV' => 'Maldives', - 'ML' => 'Mali', - 'MT' => 'Malta', - 'MH' => 'Marshall Islands', - 'MQ' => 'Martinique', - 'MR' => 'Mauritania', - 'MU' => 'Mauritius', - 'YT' => 'Mayotte', - 'MX' => 'Mexico', - 'FM' => 'Micronesia', - 'MD' => 'Moldova', - 'MC' => 'Monaco', - 'MN' => 'Mongolia', - 'ME' => 'Montenegro', - 'MS' => 'Montserrat', - 'MA' => 'Morocco', - 'MZ' => 'Mozambique', - 'MM' => 'Myanmar (Burma)', - 'NA' => 'Namibia', - 'NR' => 'Nauru', - 'NP' => 'Nepal', - 'NL' => 'Netherlands', - 'NC' => 'New Caledonia', - 'NZ' => 'New Zealand', - 'NI' => 'Nicaragua', - 'NE' => 'Niger', - 'NG' => 'Nigeria', - 'NU' => 'Niue', - 'NF' => 'Norfolk Island', - 'KP' => 'North Korea', - 'MP' => 'Northern Mariana Islands', - 'NO' => 'Norway', - 'OM' => 'Oman', - 'PK' => 'Pakistan', - 'PW' => 'Palau', - 'PS' => 'Palestinian Territories', - 'PA' => 'Panama', - 'PG' => 'Papua New Guinea', - 'PY' => 'Paraguay', - 'PE' => 'Peru', - 'PH' => 'Philippines', - 'PN' => 'Pitcairn Islands', - 'PL' => 'Poland', - 'PT' => 'Portugal', - 'PR' => 'Puerto Rico', - 'QA' => 'Qatar', - 'RE' => 'Réunion', - 'RO' => 'Romania', - 'RU' => 'Russia', - 'RW' => 'Rwanda', - 'WS' => 'Samoa', - 'SM' => 'San Marino', - 'ST' => 'São Tomé & Príncipe', - 'SA' => 'Saudi Arabia', - 'SN' => 'Senegal', - 'RS' => 'Serbia', - 'SC' => 'Seychelles', - 'SL' => 'Sierra Leone', - 'SG' => 'Singapore', - 'SX' => 'Sint Maarten', - 'SK' => 'Slovakia', - 'SI' => 'Slovenia', - 'SB' => 'Solomon Islands', - 'SO' => 'Somalia', - 'ZA' => 'South Africa', - 'GS' => 'South Georgia & South Sandwich Islands', - 'KR' => 'South Korea', - 'SS' => 'South Sudan', - 'ES' => 'Spain', - 'LK' => 'Sri Lanka', - 'BL' => 'St. Barthélemy', - 'SH' => 'St. Helena', - 'KN' => 'St. Kitts & Nevis', - 'LC' => 'St. Lucia', - 'MF' => 'St. Martin', - 'PM' => 'St. Pierre & Miquelon', - 'VC' => 'St. Vincent & Grenadines', - 'SD' => 'Sudan', - 'SR' => 'Suriname', - 'SJ' => 'Svalbard & Jan Mayen', - 'SZ' => 'Swaziland', - 'SE' => 'Sweden', - 'CH' => 'Switzerland', - 'SY' => 'Syria', - 'TW' => 'Taiwan', - 'TJ' => 'Tajikistan', - 'TZ' => 'Tanzania', - 'TH' => 'Thailand', - 'TL' => 'Timor-Leste', - 'TG' => 'Togo', - 'TK' => 'Tokelau', - 'TO' => 'Tonga', - 'TT' => 'Trinidad & Tobago', - 'TA' => 'Tristan da Cunha', - 'TN' => 'Tunisia', - 'TR' => 'Turkey', - 'TM' => 'Turkmenistan', - 'TC' => 'Turks & Caicos Islands', - 'TV' => 'Tuvalu', - 'UM' => 'U.S. Outlying Islands', - 'VI' => 'U.S. Virgin Islands', - 'UG' => 'Uganda', - 'UA' => 'Ukraine', - 'AE' => 'United Arab Emirates', - 'GB' => 'United Kingdom', - 'UN' => 'United Nations', - 'US' => 'United States', - 'UY' => 'Uruguay', - 'UZ' => 'Uzbekistan', - 'VU' => 'Vanuatu', - 'VA' => 'Vatican City', - 'VE' => 'Venezuela', - 'VN' => 'Vietnam', - 'WF' => 'Wallis & Futuna', - 'EH' => 'Western Sahara', - 'YE' => 'Yemen', - 'ZM' => 'Zambia', - 'ZW' => 'Zimbabwe', - 'AN' => 'Netherlands Antilles', -]; - -// Fix dei valori preimpostati -$database->update('an_nazioni', [ - 'nome' => 'Antigua e Barbuda', -], ['nome' => 'ANTIGUA AND BARBUDA']); - -$database->update('an_nazioni', [ - 'nome' => 'Azerbaijan', -], ['nome' => 'AZERBAIJAN REPUBLIC']); - -$database->update('an_nazioni', [ - 'nome' => 'Bosnia & Herzegovina', -], ['nome' => 'BOSNIA AND HERZEGOVINA']); - -$database->update('an_nazioni', [ - 'nome' => 'China', -], ['nome' => 'CHINA WORLDWIDE']); - -$database->update('an_nazioni', [ - 'nome' => 'Repubblica Democratica del Congo', -], ['nome' => 'DEMOCRATIC REPUBLIC OF THE CONGO']); - -$database->update('an_nazioni', [ - 'nome' => 'Micronesia', -], ['nome' => 'FEDERATED STATES OF MICRONESIA']); - -$database->update('an_nazioni', [ - 'nome' => 'Gabon', -], ['nome' => 'GABON REPUBLIC']); - -$database->update('an_nazioni', [ - 'nome' => 'Guinea-Bissau', -], ['nome' => 'GUINEA BISSAU']); - -$database->update('an_nazioni', [ - 'nome' => 'RAS di Hong Kong', -], ['nome' => 'HONG KONG']); - -$database->update('an_nazioni', [ - 'nome' => 'Paesi Bassi', -], ['nome' => 'OLANDA']); - -$database->update('an_nazioni', [ - 'nome' => 'Norway', -], ['nome' => 'NORWEGIA']); - -$database->update('an_nazioni', [ - 'nome' => 'Saint Vincent e Grenadines', -], ['nome' => 'SAINT VINCENT AND THE GRENADINES']); - -$database->update('an_nazioni', [ - 'nome' => 'South Africa', -], ['nome' => 'SUD AFRICA']); - -$database->update('an_nazioni', [ - 'nome' => 'Corea del Sud', -], ['nome' => 'SUD KOREA']); - -$database->update('an_nazioni', [ - 'nome' => 'Saint Kitts e Nevis', -], ['nome' => 'ST. KITTS AND NEVIS']); - -$database->update('an_nazioni', [ - 'nome' => 'St. Pierre & Miquelon', -], ['nome' => 'ST. PIERRE AND MIQUELON']); - -$database->update('an_nazioni', [ - 'nome' => 'Svalbard e Jan Mayen', -], ['nome' => 'SVALBARD AND JAN MAYEN ISLANDS']); - -$database->update('an_nazioni', [ - 'nome' => 'Isole Turks e Caicos', -], ['nome' => 'TURKS AND CAICOS ISLANDS']); - -$database->update('an_nazioni', [ - 'nome' => 'Wallis & Futuna', -], ['nome' => 'WALLIS AND FUTUNA ISLANDS']); - -// Aggiornamenti e inserimenti -foreach ($it as $key => $value) { - $italian = $value; - $english = $en[$key]; - - if ($database->fetchNum('SELECT id FROM an_nazioni WHERE nome IN('.prepare($italian).', '.prepare($english).')') != 0) { - $database->update('an_nazioni', [ - 'iso2' => $key, - 'nome' => $italian, - 'name' => $english, - ], [ - 'nome' => $english, - ]); - - $database->update('an_nazioni', [ - 'iso2' => $key, - 'nome' => $italian, - 'name' => $english, - ], [ - 'nome' => $italian, - ]); - } else { - $database->insert('an_nazioni', [ - 'iso2' => $key, - 'nome' => $italian, - 'name' => $english, - ]); - } -} diff --git a/update/2_4_3.sql b/update/2_4_3.sql deleted file mode 100755 index d84b1c047..000000000 --- a/update/2_4_3.sql +++ /dev/null @@ -1,63 +0,0 @@ --- Fix nome colonna 'Cliente' ddt vendita e acquisto -UPDATE `zz_views` SET `name` = 'Ragione sociale' WHERE `zz_views`.`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ddt di vendita') AND name = 'Cliente'; -UPDATE `zz_views` SET `name` = 'Ragione sociale' WHERE `zz_views`.`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Ddt di acquisto') AND name = 'Cliente'; - --- Rinomino colonna Rel. in Relazione -UPDATE `zz_views` SET `name` = 'color_Relazione', `search_inside` = 'color_title_Relazione' WHERE `zz_views`.`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Anagrafiche') AND name = 'color_Rel.'; -UPDATE `zz_views` SET `name` = 'color_title_Relazione' WHERE `zz_views`.`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Anagrafiche') AND name = 'color_title_Rel.'; - --- Rinomino colonna Tipologia in Tipo -UPDATE `zz_views` SET `name` = 'Tipo' WHERE `zz_views`.`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Anagrafiche') AND name = 'Tipologia'; - --- Nuova colonna Tipologia -INSERT INTO `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` = 'Anagrafiche'), 'Tipologia', 'tipo', 3, 1, 0, 0, NULL, NULL, 1, 0, 0); - --- Fix dei widget con nuova colonna Tipo -UPDATE `zz_widgets` SET `more_link` = 'if($(\'#th_Tipo input\').val()!= \'Tecnico\'){ $(\'#th_Tipo input\').val(\'Tecnico\').trigger(\'keyup\');} else reset(\'Tipo\');' WHERE `zz_widgets`.`name` = 'Numero di tecnici'; - -UPDATE `zz_widgets` SET `more_link` = 'if($(\'#th_Tipo input\').val()!= \'Cliente\'){ $(\'#th_Tipo input\').val(\'Cliente\').trigger(\'keyup\');} else reset(\'Tipo\');' WHERE `zz_widgets`.`name` = 'Numero di clienti'; - -UPDATE `zz_widgets` SET `more_link` = 'if($(\'#th_Tipo input\').val()!= \'Fornitore\'){ $(\'#th_Tipo input\').val(\'Fornitore\').trigger(\'keyup\');} else reset(\'Tipo\');' WHERE `zz_widgets`.`name` = 'Numero di fornitori'; - -UPDATE `zz_widgets` SET `more_link` = 'if($(\'#th_Tipo input\').val()!= \'Agente\'){ $(\'#th_Tipo input\').val(\'Agente\').trigger(\'keyup\');} else reset(\'Tipo\');' WHERE `zz_widgets`.`name` = 'Numero di agenti'; - -UPDATE `zz_widgets` SET `more_link` = 'if($(\'#th_Tipo input\').val()!= \'Vettore\'){ $(\'#th_Tipo input\').val(\'Vettore\').trigger(\'keyup\');} else reset(\'Tipo\');' WHERE `zz_widgets`.`name` = 'Numero di vettori'; - -UPDATE `zz_widgets` SET `more_link` = 'reset(\'Tipo\');' WHERE `zz_widgets`.`name` = 'Tutte le anagrafiche'; - --- Fix del campo codice_xml -ALTER TABLE `co_documenti` CHANGE `codice_xml` `progressivo_invio` VARCHAR(255); - --- Aggiunto codice cig e codice cup per fatture e ordini -ALTER TABLE `or_ordini` ADD `codice_cig` VARCHAR(15) AFTER `tipo_sconto_globale`, ADD `codice_cup` VARCHAR(15) AFTER `codice_cig`, ADD `id_documento_fe` VARCHAR(20) AFTER `codice_cup`; -ALTER TABLE `co_righe_documenti` ADD `data_inizio_periodo` date, ADD `data_fine_periodo` date, ADD `riferimento_amministrazione` VARCHAR(20), ADD `tipo_cessione_prestazione` enum('SC', 'PR', 'AB', 'AC') DEFAULT NULL; - -ALTER TABLE `co_documenti` ADD `tipo_resa` VARCHAR(3); - --- Colonna nome impianto -INSERT INTO `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` = 'MyImpianti'), 'Nome', 'nome', 2, 1, 0, 0, NULL, NULL, 1, 0, 1); - --- Colonna causale predefinita -INSERT INTO `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` = 'Causali'), 'Predefinita', 'IF(predefined, ''Sì'', ''No'')', 2, 1, 0, 0, NULL, NULL, 0, 0, 0); - --- Colonna porto predefinita -INSERT INTO `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` = 'Porto'), 'Predefinita', 'IF(predefined, ''Sì'', ''No'')', 2, 1, 0, 0, NULL, NULL, 0, 0, 0); - --- Nascondo colonna id inutile per porto -UPDATE `zz_views` SET `visible` = '0' WHERE `zz_views`.`name` = 'id' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Porto') ; - --- Colonna tipi di spedizione predefinita -INSERT INTO `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` = 'Tipi di spedizione'), 'Predefinita', 'IF(predefined, ''Sì'', ''No'')', 2, 1, 0, 0, NULL, NULL, 0, 0, 0); - --- Fix plugin -UPDATE `zz_plugins` SET `directory` = 'exportFE' WHERE `idmodule_to` = (SELECT `id` FROM `zz_modules` WHERE `name`='Fatture di vendita') AND `name` = 'Fatturazione Elettronica'; -UPDATE `zz_plugins` SET `directory` = 'importFE' WHERE `idmodule_to` = (SELECT `id` FROM `zz_modules` WHERE `name`='Fatture di acquisto') AND `name` = 'Fatturazione Elettronica'; - --- Check colonna Totale per fatture di vendita -UPDATE `zz_views` SET `query` = '(SELECT SUM(subtotale - sconto + iva + rivalsainps - ritenutaacconto) FROM co_righe_documenti WHERE co_righe_documenti.iddocumento=co_documenti.id GROUP BY iddocumento) + bollo + iva_rivalsainps' WHERE `zz_views`.`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita') AND name = 'Totale'; - --- Check colonna Totale per fatture di acquisto -UPDATE `zz_views` SET `query` = '(SELECT SUM(subtotale - sconto + iva + rivalsainps - ritenutaacconto) FROM co_righe_documenti WHERE co_righe_documenti.iddocumento=co_documenti.id GROUP BY iddocumento) + bollo + iva_rivalsainps' WHERE `zz_views`.`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di acquisto') AND name = 'Totale'; - --- Codice destinatario sedi -ALTER TABLE `an_sedi` ADD `codice_destinatario` varchar(7); diff --git a/update/2_4_4.php b/update/2_4_4.php deleted file mode 100755 index 3ab28580e..000000000 --- a/update/2_4_4.php +++ /dev/null @@ -1,12 +0,0 @@ - $value) { - $files[$key] = realpath(base_dir().'/'.$value); -} - -delete($files); diff --git a/update/2_4_4.sql b/update/2_4_4.sql deleted file mode 100755 index 31e5804ba..000000000 --- a/update/2_4_4.sql +++ /dev/null @@ -1,29 +0,0 @@ --- Stati di invio del documento -CREATE TABLE IF NOT EXISTS `fe_stati_documento` ( - `codice` varchar(5) NOT NULL, - `descrizione` varchar(255) NOT NULL, - `icon` varchar(255) NOT NULL, - PRIMARY KEY (`codice`) -) ENGINE=InnoDB; - -INSERT INTO `fe_stati_documento` (`codice`, `descrizione`, `icon`) VALUES -('GEN', 'Generata', 'fa fa-file-code-o text-success'), -('WAIT', 'In attesa', 'fa fa-clock-o text-warning'), -('SENT', 'Inviata', 'fa fa-paper-plane-o text-info'), -('ACK', 'Accettata', 'fa fa-paper-check text-success'), -('REF', 'Rifiuta', 'fa fa-times text-error'); - -ALTER TABLE `co_documenti` ADD `codice_stato_fe` varchar(5), ADD FOREIGN KEY (`codice_stato_fe`) REFERENCES `fe_stati_documento`(`codice`) ON DELETE SET NULL; -UPDATE `co_documenti` SET `codice_stato_fe` = 'GEN' WHERE `xml_generated_at` IS NOT NULL; -ALTER TABLE `co_documenti` DROP `xml_generated_at`; - -UPDATE `zz_views` SET `query` = '(SELECT `icon` FROM `fe_stati_documento` WHERE `codice` = `codice_stato_fe`)' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita') AND `name` = 'icon_FE'; -UPDATE `zz_views` SET `query` = '(SELECT `descrizione` FROM `fe_stati_documento` WHERE `codice` = `codice_stato_fe`)' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita') AND `name` = 'icon_title_FE'; - -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES -(NULL, 'OSMCloud Services API Token', '', 'string', 1, 'Fatturazione Elettronica', 11); - --- Allineo valore Iva predefinita secondo nuovi codici tabella co_iva -UPDATE `zz_settings` SET `valore` = (SELECT id FROM `co_iva` WHERE `codice` = 22 LIMIT 0,1) WHERE `nome` = 'Iva predefinita' AND `valore` = 91; - -UPDATE `zz_modules` SET `directory` = 'backups' WHERE `name` = 'Backup'; diff --git a/update/2_4_5.sql b/update/2_4_5.sql deleted file mode 100755 index 78171cbcd..000000000 --- a/update/2_4_5.sql +++ /dev/null @@ -1,80 +0,0 @@ -INSERT INTO `zz_plugins` (`id`, `name`, `title`, `idmodule_from`, `idmodule_to`, `position`, `directory`, `options`) VALUES -(NULL, 'Ricevute FE', 'Ricevute FE', (SELECT `id` FROM `zz_modules` WHERE `name`='Fatture di vendita'), (SELECT `id` FROM `zz_modules` WHERE `name`='Fatture di vendita'), 'tab_main', 'receiptFE', 'custom'); - -UPDATE `fe_stati_documento` SET `icon` = 'fa fa-check text-success' WHERE `codice` = 'ACK'; - --- Introduzione del flag split payment -ALTER TABLE `an_anagrafiche` ADD `split_payment` BOOLEAN NOT NULL DEFAULT FALSE AFTER `codice_destinatario`; - --- Prezzo di acquisto in Fatture di vendita e Preventivi -ALTER TABLE `co_righe_documenti` ADD `prezzo_unitario_acquisto` DECIMAL(12,4) NOT NULL AFTER `descrizione`; -ALTER TABLE `co_righe_preventivi` ADD `prezzo_unitario_acquisto` DECIMAL(12,4) NOT NULL AFTER `descrizione`; - --- Uniformati codici con standard SDI e aggiunta 2 stati mancanti -UPDATE `fe_stati_documento` SET `codice`='EC01' WHERE `codice`='ACK'; -UPDATE `fe_stati_documento` SET `codice`='EC02', `descrizione`='Rifiutata' WHERE `codice`='REF'; -UPDATE `fe_stati_documento` SET `codice`='RC', `descrizione`='Consegnata' WHERE `codice`='SENT'; -INSERT INTO `fe_stati_documento`( `codice`, `descrizione`, `icon` ) VALUES -( 'MC', 'Mancata consegna', 'fa fa-exclamation-circle text-danger' ), -( 'DT', 'Decorrenza termini', 'fa fa-calendar-times-o text-danger' ), -( 'NS', 'Scartata', 'fa fa-times text-danger' ); - --- ssl_no_verify -ALTER TABLE `zz_smtps` ADD `ssl_no_verify` BOOLEAN NOT NULL DEFAULT FALSE AFTER `encryption`; - --- Introduzione del flag split payment per documenti -ALTER TABLE `co_documenti` ADD `split_payment` BOOLEAN NOT NULL DEFAULT FALSE AFTER `bollo`; - --- Fix campo calcolo_ritenutaacconto -UPDATE `co_righe_documenti` SET `calcolo_ritenutaacconto` = 'IMP' WHERE `calcolo_ritenutaacconto` = 'Imponibile' OR `calcolo_ritenutaacconto` = ''; -UPDATE `co_righe_documenti` SET `calcolo_ritenutaacconto` = 'IMP+RIV' WHERE `calcolo_ritenutaacconto` = 'Imponibile + rivalsa inps'; -ALTER TABLE `co_righe_documenti` CHANGE `calcolo_ritenutaacconto` `calcolo_ritenuta_acconto` ENUM('IMP', 'IMP+RIV') DEFAULT 'IMP'; -UPDATE `zz_settings` SET `tipo` = 'query=SELECT ''IMP'' AS id, ''Imponibile'' AS descrizione UNION SELECT ''IMP+RIV'' AS id, ''Imponibile + rivalsa inps'' AS descrizione', `valore` = REPLACE(REPLACE(`valore`, 'Imponibile + rivalsa inps', 'IMP+RIV'), 'Imponibile', 'IMP') WHERE `nome` = 'Metodologia calcolo ritenuta d''acconto predefinito'; - --- Fix per province caricate a gestionale in minuscolo -UPDATE `an_anagrafiche` SET `provincia` = UPPER(provincia); -UPDATE `an_sedi` SET `provincia` = UPPER(provincia); - --- Colonna Codice Modalità (Pagamenti) -INSERT INTO `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` = 'Pagamenti'), 'Codice Modalità', 'codice_modalita_pagamento_fe', 2, 1, 0, 0, NULL, NULL, 1, 0, 0); - --- Impostazione "Anagrafica del terzo intermediario" -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES (NULL, 'Terzo intermediario', '', 'query=SELECT `an_anagrafiche`.`idanagrafica` AS ''id'', `ragione_sociale` AS ''descrizione'' FROM `an_anagrafiche` INNER JOIN `an_tipianagrafiche_anagrafiche` ON `an_anagrafiche`.`idanagrafica` = `an_tipianagrafiche_anagrafiche`.`idanagrafica` WHERE `idtipoanagrafica` = (SELECT `idtipoanagrafica` FROM `an_tipianagrafiche` WHERE `descrizione` = ''Fornitore'') AND `deleted_at` IS NULL', '1', 'Fatturazione Elettronica'); - --- Aggiungo campi nome e cognome -ALTER TABLE `an_anagrafiche` CHANGE `nome_cognome` `nome` VARCHAR(255) NOT NULL; -ALTER TABLE `an_anagrafiche` ADD `cognome` VARCHAR(255) NOT NULL AFTER `nome`; - --- Colonna Rif. fattura (Prima nota) -INSERT INTO `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` = 'Prima nota'), 'Rif. fattura', '(SELECT numero_esterno FROM co_documenti WHERE id = iddocumento)', 2, 1, 0, 0, NULL, NULL, 1, 0, 0); - --- Aumento decimali percentuali delle rate pagamenti a 2 -ALTER TABLE `co_pagamenti` CHANGE `prc` `prc` DECIMAL(5,2) NOT NULL; - --- Ordino gestione documentale per data, nome -UPDATE `zz_modules` SET `options` = '{ "main_query": [ { "type": "table", "fields": "Categoria, Nome, Data", "query": "SELECT id,(SELECT descrizione FROM zz_documenti_categorie WHERE zz_documenti_categorie.id = idcategoria) AS Categoria, zz_documenti.nome AS Nome, DATE_FORMAT( zz_documenti.`data`, ''%d/%m/%Y'' ) AS `Data` FROM zz_documenti WHERE `data` >= ''|period_start|'' AND `data` <= ''|period_end|'' HAVING 1=1 ORDER BY data, nome"} ]}' WHERE `zz_modules`.`name` = 'Gestione documentale'; - --- Ordino Ddt anche per created_at (nel caso di stessa data e che il cast del numero esterno non sia efficace) -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `dt_ddt` INNER JOIN `dt_tipiddt` ON `dt_ddt`.`idtipoddt` = `dt_tipiddt`.`id` WHERE 1=1 AND `dir` = ''entrata'' AND `data` >= ''|period_start|'' AND `data` <= ''|period_end|'' HAVING 2=2 ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC,`dt_ddt`.created_at DESC' WHERE `zz_modules`.`name` = 'Ddt di vendita'; - -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `dt_ddt` INNER JOIN `dt_tipiddt` ON `dt_ddt`.`idtipoddt` = `dt_tipiddt`.`id` WHERE 1=1 AND `dir` = ''uscita'' AND `data` >= ''|period_start|'' AND `data` <= ''|period_end|'' HAVING 2=2 ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC, `dt_ddt`.created_at DESC' WHERE `zz_modules`.`id` = 'Ddt di acquisto'; - --- Aggiunti pagamenti mancanti Assegno circolare,Contanti presso Tesoreria, Vaglia cambiario, Bollettino bancario, RID, RID utenze, RID veloce, MAV, Quietanza erario, Giroconto su conti di contabilità speciale, Domiciliazione bancaria, Domiciliazione postale, Bollettino di c/c postale, SEPA Direct Debit, SEPA Direct Debit CORE, SEPA Direct Debit B2B, Trattenuta su somme già riscosse -INSERT INTO `co_pagamenti` (`id`, `descrizione`, `giorno`, `num_giorni`, `prc`, `codice_modalita_pagamento_fe`) VALUES -(NULL, 'Assegno circolare', '0', '1', '100', 'MP03'), -(NULL, 'Contanti presso Tesoreria', '0', '1', '100', 'MP04'), -(NULL, 'Vaglia cambiario', '0', '1', '100', 'MP06'), -(NULL, 'Bollettino bancario', '0', '1', '100', 'MP07'), -(NULL, 'RID', '0', '1', '100', 'MP09'), -(NULL, 'RID utenze', '0', '1', '100', 'MP10'), -(NULL, 'RID veloce', '0', '1', '100', 'MP11'), -(NULL, 'MAV', '0', '1', '100', 'MP13'), -(NULL, 'Quietanza erario', '0', '1', '100', 'MP14'), -(NULL, 'Giroconto su conti di contabilità speciale', '0', '1', '100', 'MP15'), -(NULL, 'Domiciliazione bancaria', '0', '1', '100', 'MP16'), -(NULL, 'Domiciliazione postale', '0', '1', '100', 'MP17'), -(NULL, 'Bollettino di c/c postale', '0', '1', '100', 'MP18'), -(NULL, 'SEPA Direct Debit', '0', '1', '100', 'MP19'), -(NULL, 'SEPA Direct Debit CORE', '0', '1', '100', 'MP20'), -(NULL, 'SEPA Direct Debit B2B', '0', '1', '100', 'MP21'), -(NULL, 'Trattenuta su somme già riscosse', '0', '1', '100', 'MP22'); diff --git a/update/2_4_6.php b/update/2_4_6.php deleted file mode 100755 index c3f69c0b7..000000000 --- a/update/2_4_6.php +++ /dev/null @@ -1,12 +0,0 @@ - $value) { - $files[$key] = realpath(base_dir().'/'.$value); -} - -delete($files); diff --git a/update/2_4_6.sql b/update/2_4_6.sql deleted file mode 100755 index 263caf3a8..000000000 --- a/update/2_4_6.sql +++ /dev/null @@ -1,97 +0,0 @@ --- Aggiunto campo ritenuta per ENASARCO, ENPALS -ALTER TABLE `co_documenti` ADD `id_ritenuta_contributi` INT(11) NOT NULL AFTER `bollo`; -ALTER TABLE `co_documenti` ADD `ritenuta_contributi` DECIMAL(12,4) NOT NULL AFTER `id_ritenuta_contributi`; - --- Colonna tecnici per interventi -INSERT INTO `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 per tipi di spedizione fuorvianti (esiste già il campo "Porto" per stabilire di chi è a carico la spedizione) -UPDATE `dt_spedizione` SET `descrizione` = 'Ritiro in magazzino' WHERE `dt_spedizione`.`descrizione` = 'A carico del cliente'; -UPDATE `dt_spedizione` SET `descrizione` = 'Espressa' WHERE `dt_spedizione`.`descrizione` = 'A nostro carico'; - --- Rinomino tabella gestione rivalse -RENAME TABLE co_rivalsainps TO co_rivalse; - --- 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'; - --- Fix Metodologia calcolo ritenuta -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\'acconto predefinito'; - --- Aggiunto modulo per gestire le rivalse -INSERT INTO `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', (SELECT id FROM zz_modules t WHERE t.name = 'Tabelle'), '1', '1'); - --- Colonne per modulo 'Rivalse' -INSERT INTO `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` = 'Rivalse'), 'id', 'id', 1, 1, 0, 0, NULL, NULL, 0, 0, 1), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Rivalse'), 'Descrizione', 'descrizione', 2, 1, 0, 0, NULL, NULL, 1, 0, 1), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Rivalse'), 'Percentuale', 'percentuale', 3, 1, 0, 0, NULL, NULL, 1, 0, 1), -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Rivalse'), 'Indetraibile', 'indetraibile', 4, 1, 0, 0, NULL, NULL, 1, 0, 1); - --- Aggiunto campo help per impostazioni -ALTER TABLE `zz_settings` ADD `help` VARCHAR(255) NOT NULL AFTER `order`; - --- Aggiunto help per impostazione tipo cassa -UPDATE `zz_settings` SET `help` = 'Definisce il tipo della rivalsa' WHERE `zz_settings`.`nome` = 'Tipo Cassa'; - --- Aggiorno indirizzo a cui inviare le FE -UPDATE `zz_emails` SET `cc` = 'sdi24@pec.fatturapa.it' WHERE `zz_emails`.`name` = 'PEC' AND `zz_emails`.`cc` = 'sdi01@pec.fatturapa.it'; - --- Aggiunto id documento codice cig e codice cup per preventivi -ALTER TABLE `co_preventivi` ADD `codice_cig` VARCHAR(15) AFTER `master_revision`, ADD `codice_cup` VARCHAR(15) AFTER `codice_cig`, ADD `id_documento_fe` VARCHAR(20) AFTER `codice_cup`; - --- Migliorata visualizzazione impostazione -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'; - --- Aggiunto stato WAIT, fattura elettronica in elaborazione -UPDATE `fe_stati_documento` SET `descrizione`='In elaborazione' WHERE `codice`='WAIT'; - --- Inserito stato errore interno OSM -INSERT INTO `fe_stati_documento`( `codice`, `descrizione`, `icon` ) VALUES( 'ERVAL', 'Errore di validazione', 'fa fa-edit text-danger' ); -ALTER TABLE `co_documenti` ADD `data_stato_fe` TIMESTAMP, ADD `descrizione_ricevuta_fe` TEXT; - --- Rimozione iva eliminata -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'; - --- Flag fattura per conto terzi -ALTER TABLE `co_documenti` ADD `is_fattura_conto_terzi` BOOLEAN NOT NULL DEFAULT FALSE AFTER `split_payment`; - --- Migliorata visualizzazione impostazione -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'; - --- Tabella co_ritenuta_contributi (ENASARCO, ECC..) -CREATE TABLE IF NOT EXISTS `co_ritenuta_contributi` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `descrizione` varchar(100) NOT NULL, - `percentuale` decimal(5,2) NOT NULL, - `percentuale_imponibile` decimal(5,2) NOT NULL, - PRIMARY KEY (`id`) -); - --- Fix icon_Inviata Fatture di vendita per errore subquery -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` = \'Fatture di vendita\') 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' AND id_module = (SELECT id FROM zz_modules WHERE name = '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` = \'Fatture di vendita\') AND op = \'send-email\' AND id_record = co_documenti.id ORDER BY zz_operations.created_at DESC LIMIT 1) IS NOT NULL, \'fa fa-envelope text-success\', \'\') ' WHERE `zz_views`.`name` = 'icon_Inviata' AND id_module = (SELECT id FROM zz_modules WHERE name = 'Fatture di vendita'); - --- Limitato all'anno in corso il controllo per i numeri duplicati nelle fatture -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_' AND id_module = (SELECT id FROM zz_modules WHERE name = 'Fatture di vendita'); - --- Fornitore terzo intermediario abilitato all'invio della fattura elettronica -UPDATE `zz_settings` SET `help` = 'Fornitore, mio intermediario abilitato all\'invio della fattura elettronica (es. Aruba, Teamsystem ecc...)' WHERE `zz_settings`.`nome` = 'Terzo intermediario'; - --- Aggiunta percentuale_imponibile su cui applicare il calcolo della ritenuta -ALTER TABLE `co_ritenutaacconto` ADD `percentuale_imponibile` DECIMAL(5,2) NOT NULL AFTER `esente`; - --- Aggiunto modulo per gestire la seconda ritenuta (ENASARCO, ECC..) -INSERT INTO `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` t WHERE t.`name` = 'Tabelle'), '1', '1'); - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `default`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Ritenute contributi'), 'Percentuale imponibile', 'percentuale_imponibile', 4, 1, 0, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Ritenute contributi'), 'Percentuale', 'percentuale', 3, 1, 0, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Ritenute contributi'), 'Descrizione', 'descrizione', 2, 1, 0, 0), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Ritenute contributi'), 'id', 'id', 1, 1, 0, 0); - -UPDATE `zz_views` SET `query` = 'percentuale_imponibile', `name` = 'Percentuale imponibile' WHERE `zz_views`.`name` = 'Indetraibile' AND id_module = (SELECT id FROM zz_modules WHERE name = 'Ritenute acconto'); diff --git a/update/2_4_7.php b/update/2_4_7.php deleted file mode 100755 index 81ac5e6c5..000000000 --- a/update/2_4_7.php +++ /dev/null @@ -1,22 +0,0 @@ - $value) { - $files[$key] = realpath(base_dir().'/'.$value); -} - -delete($files); diff --git a/update/2_4_7.sql b/update/2_4_7.sql deleted file mode 100755 index 7172d8670..000000000 --- a/update/2_4_7.sql +++ /dev/null @@ -1,35 +0,0 @@ -UPDATE `in_interventi` SET `id_contratto` = (SELECT `idcontratto` FROM `co_promemoria` WHERE `idintervento` = `in_interventi`.`id` LIMIT 1); - -ALTER TABLE `co_righe_contratti` ADD `qta_evasa` DECIMAL(12, 4) NOT NULL; -ALTER TABLE `co_righe_preventivi` ADD `qta_evasa` DECIMAL(12, 4) NOT NULL; - --- Inserisco due nuovi stati preventivi -UPDATE `co_statipreventivi` SET `descrizione` = 'Fatturato', `completato` = 1, `annullato` = 0, `icona` = 'fa fa-file-text-o text-success' WHERE `descrizione` = 'In attesa di pagamento'; -INSERT INTO `co_statipreventivi` (`id`, `descrizione`, `completato`, `annullato`, `icona`) VALUES -(NULL, 'Parzialmente fatturato', 0, 0, 'fa fa-file-text-o text-warning'); - -ALTER TABLE `co_statipreventivi` ADD `fatturabile` BOOLEAN NOT NULL DEFAULT FALSE; -UPDATE `co_statipreventivi` SET `fatturabile` = 1 WHERE `descrizione` IN('Parzialmente fatturato', 'Concluso', 'Pagato', 'In lavorazione', 'Accettato', 'In attesa di conferma'); - --- Inserisco due nuovi stati contratti -UPDATE `co_staticontratti` SET `descrizione` = 'Fatturato', `pianificabile` = 0, `fatturabile` = 0, `icona` = 'fa fa-file-text-o text-success' WHERE `descrizione` = 'In attesa di pagamento'; -INSERT INTO `co_staticontratti` (`id`, `descrizione`, `pianificabile`, `fatturabile`, `icona`) VALUES -(NULL, 'Parzialmente fatturato', 0, 1, 'fa fa-file-text-o text-warning'); - -UPDATE `zz_widgets` SET `query` = REPLACE(`query`, 'In attesa di pagamento', 'Fatturato'); - --- Fix ritenuta contributi -ALTER TABLE `co_documenti` CHANGE `id_ritenuta_contributi` `id_ritenuta_contributi` INT(11); -UPDATE `co_documenti` SET `id_ritenuta_contributi` = NULL WHERE `id_ritenuta_contributi` = 0; -ALTER TABLE `co_documenti` ADD FOREIGN KEY (`id_ritenuta_contributi`) REFERENCES `co_ritenuta_contributi`(`id`) ON DELETE SET NULL; -ALTER TABLE `co_righe_documenti` ADD `ritenuta_contributi` BOOLEAN NOT NULL DEFAULT FALSE; - -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES (NULL, 'Ritenuta contributi', '', 'query=SELECT * FROM co_ritenuta_contributi', 1, 'Fatturazione', 12); - --- Fix ricerca documentali -UPDATE `zz_modules` SET `options` = '{ "main_query": [ { "type": "table", "fields": "Descrizione", "query": "SELECT zz_documenti_categorie.`descrizione`as Descrizione, zz_documenti_categorie.`id`as id FROM zz_documenti_categorie WHERE deleted_at IS NULL AND 1=1 HAVING 2=2"} ]}' WHERE `name` = 'Categorie documenti'; -UPDATE `zz_modules` SET `options` = '{ "main_query": [ { "type": "table", "fields": "Categoria, Nome, Data", "query": "SELECT id,(SELECT descrizione FROM zz_documenti_categorie WHERE zz_documenti_categorie.id = idcategoria) AS Categoria, zz_documenti.nome AS Nome, DATE_FORMAT( zz_documenti.`data`, ''%d/%m/%Y'' ) AS `Data` FROM zz_documenti WHERE `data` >= ''|period_start|'' AND `data` <= ''|period_end|'' AND 1=1 HAVING 2=2"} ]}' WHERE `name` = 'Gestione documentale'; - --- Sollecito di pagamento -INSERT INTO `zz_emails` (`id`, `id_module`, `id_smtp`, `name`, `icon`, `subject`, `reply_to`, `cc`, `bcc`, `body`, `read_notify`, `predefined`) VALUES -(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Scadenzario'), 1, 'Sollecito di pagamento', 'fa fa-envelope', 'Sollecito di pagamento fattura {numero}', '', '', '', '

    Spett.le {ragione_sociale},

    \r\n\r\n

    da un riscontro contabile, ci risulta che la fattura numero {numero} a Voi intestata, equivalente ad un ammontare di Euro {totale}, è scaduta in data {data_scadenza}.

    \r\n\r\n

    La sollecitiamo pertanto di provvedere quanto prima a regolarizzare la sua situazione contabile. A tal proposito, il pagamento potrà essere effettuato tramite {pagamento}.

    \r\n\r\n

    Se ha già provveduto al pagamento, ritenga nulla la presente.

    \r\n\r\n

     

    \r\n\r\n

    La ringraziamo e le porgiamo i nostri saluti.

    \r\n', '0', '1'); diff --git a/update/2_4_8.sql b/update/2_4_8.sql deleted file mode 100755 index 5d80990a2..000000000 --- a/update/2_4_8.sql +++ /dev/null @@ -1,15 +0,0 @@ --- Fix problema username vuoti in zz_logs -ALTER TABLE `zz_logs` CHANGE `username` `username` varchar(255); - --- Aggiunta tipologia di documento Parcella -INSERT INTO `co_tipidocumento` (`id`, `descrizione`, `dir`, `reversed`, `codice_tipo_documento_fe`) VALUES (NULL, 'Parcella', 'entrata', '0', 'TD06'); -INSERT INTO `co_tipidocumento` (`id`, `descrizione`, `dir`, `reversed`, `codice_tipo_documento_fe`) VALUES (NULL, 'Parcella', 'uscita', '0', 'TD06'); - --- Aggiunto codice cig e codice cup per contratti e interventi -ALTER TABLE `co_contratti` ADD `num_item` VARCHAR(15) AFTER `id_documento_fe`; -ALTER TABLE `in_interventi` ADD `num_item` VARCHAR(15) AFTER `id_documento_fe`; -ALTER TABLE `or_ordini` ADD `num_item` VARCHAR(15) AFTER `id_documento_fe`; -ALTER TABLE `co_preventivi` ADD `num_item` VARCHAR(15) AFTER `id_documento_fe`; - --- Aggiunta data scadenza attività -ALTER TABLE `in_interventi` ADD `data_scadenza` DATETIME AFTER `data_invio`; diff --git a/update/2_4_9.php b/update/2_4_9.php deleted file mode 100755 index a6a74031a..000000000 --- a/update/2_4_9.php +++ /dev/null @@ -1,227 +0,0 @@ -fetchArray('SELECT descrizione, percentuale, indetraibile FROM co_iva WHERE id='.prepare($idiva)); - - $tecnici = $dbo->fetchArray('SELECT - - COALESCE(SUM( - ROUND(prezzo_ore_unitario_tecnico*ore, '.$decimals.') - ), 0) AS manodopera_costo, - COALESCE(SUM( - ROUND(prezzo_ore_unitario*ore, '.$decimals.') - ), 0) AS manodopera_addebito, - COALESCE(SUM( - ROUND(prezzo_ore_unitario*ore, '.$decimals.') - ROUND(sconto, '.$decimals.') - ), 0) AS manodopera_scontato, - - - COALESCE(SUM( - ROUND(prezzo_dirittochiamata_tecnico, '.$decimals.') - ), 0) AS dirittochiamata_costo, - COALESCE(SUM( - ROUND(prezzo_dirittochiamata, '.$decimals.') - ), 0) AS dirittochiamata_addebito, - COALESCE(SUM( - ROUND(prezzo_dirittochiamata, '.$decimals.') - ), 0) AS dirittochiamata_scontato, - - COALESCE(SUM( - ROUND(prezzo_km_consuntivo_tecnico, '.$decimals.') - ), 0) AS viaggio_costo, - COALESCE(SUM( - ROUND(prezzo_km_consuntivo, '.$decimals.') - ), 0) viaggio_addebito, - COALESCE(SUM( - ROUND(prezzo_km_consuntivo, '.$decimals.') - ROUND(scontokm, '.$decimals.') - ), 0) AS viaggio_scontato - - FROM in_interventi_tecnici WHERE idintervento='.prepare($id_intervento)); - - $articoli = $dbo->fetchArray('SELECT - COALESCE(SUM( - ROUND(prezzo_acquisto, '.$decimals.') * ROUND(qta, '.$decimals.') - ), 0) AS ricambi_costo, - COALESCE(SUM( - ROUND(prezzo_vendita, '.$decimals.') * ROUND(qta, '.$decimals.') - ), 0) AS ricambi_addebito, - COALESCE(SUM( - ROUND(prezzo_vendita, '.$decimals.') * ROUND(qta, '.$decimals.') - ROUND(sconto, '.$decimals.') - ), 0) AS ricambi_scontato, - ROUND( - (SELECT percentuale FROM co_iva WHERE co_iva.id=mg_articoli_interventi.idiva), '.$decimals.' - ) AS ricambi_iva - - FROM mg_articoli_interventi WHERE idintervento='.prepare($id_intervento)); - - $altro = $dbo->fetchArray('SELECT - COALESCE(SUM( - ROUND(prezzo_acquisto, '.$decimals.') * ROUND(qta, '.$decimals.') - ), 0) AS altro_costo, - COALESCE(SUM( - ROUND(prezzo_vendita, '.$decimals.') * ROUND(qta, '.$decimals.') - ), 0) AS altro_addebito, - COALESCE(SUM( - ROUND(prezzo_vendita, '.$decimals.') * ROUND(qta, '.$decimals.') - ROUND(sconto, '.$decimals.') - ), 0) AS altro_scontato, - ROUND( - (SELECT percentuale FROM co_iva WHERE co_iva.id=in_righe_interventi.idiva), '.$decimals.' - ) AS altro_iva - - FROM in_righe_interventi WHERE idintervento='.prepare($id_intervento)); - - $result = array_merge($tecnici[0], $articoli[0], $altro[0]); - - $result['totale_costo'] = sum([ - $result['manodopera_costo'], - $result['dirittochiamata_costo'], - $result['viaggio_costo'], - $result['ricambi_costo'], - $result['altro_costo'], - ]); - - $result['totale_addebito'] = sum([ - $result['manodopera_addebito'], - $result['dirittochiamata_addebito'], - $result['viaggio_addebito'], - $result['ricambi_addebito'], - $result['altro_addebito'], - ]); - - $result['totale_scontato'] = sum([ - $result['manodopera_scontato'], - $result['dirittochiamata_scontato'], - $result['viaggio_scontato'], - $result['ricambi_scontato'], - $result['altro_scontato'], - ]); - - $result['iva_costo'] = sum([ - $result['manodopera_costo'] * $rs_iva[0]['percentuale'] / 100, - $result['dirittochiamata_costo'] * $rs_iva[0]['percentuale'] / 100, - $result['viaggio_costo'] * $rs_iva[0]['percentuale'] / 100, - $result['ricambi_costo'] * $result['ricambi_iva'] / 100, - $result['altro_costo'] * $result['altro_iva'] / 100, - ]); - - $result['iva_addebito'] = sum([ - $result['manodopera_addebito'] * $rs_iva[0]['percentuale'] / 100, - $result['dirittochiamata_addebito'] * $rs_iva[0]['percentuale'] / 100, - $result['viaggio_addebito'] * $rs_iva[0]['percentuale'] / 100, - $result['ricambi_addebito'] * $result['ricambi_iva'] / 100, - $result['altro_addebito'] * $result['altro_iva'] / 100, - ]); - - $result['iva_totale'] = sum([ - $result['manodopera_scontato'] * $rs_iva[0]['percentuale'] / 100, - $result['dirittochiamata_scontato'] * $rs_iva[0]['percentuale'] / 100, - $result['viaggio_scontato'] * $rs_iva[0]['percentuale'] / 100, - $result['ricambi_scontato'] * $result['ricambi_iva'] / 100, - $result['altro_scontato'] * $result['altro_iva'] / 100, - ]); - - $result['totaleivato_costo'] = sum([ - $result['manodopera_costo'] + ($result['manodopera_costo'] * $rs_iva[0]['percentuale'] / 100), - $result['dirittochiamata_costo'] + ($result['dirittochiamata_costo'] * $rs_iva[0]['percentuale'] / 100), - $result['viaggio_costo'] + ($result['viaggio_costo'] * $rs_iva[0]['percentuale'] / 100), - $result['ricambi_costo'] + ($result['ricambi_costo'] * $result['ricambi_iva'] / 100), - $result['altro_costo'] + ($result['altro_costo'] * $result['altro_iva'] / 100), - ]); - - $result['totaleivato_addebito'] = sum([ - $result['manodopera_addebito'] + ($result['manodopera_addebito'] * $rs_iva[0]['percentuale'] / 100), - $result['dirittochiamata_addebito'] + ($result['dirittochiamata_addebito'] * $rs_iva[0]['percentuale'] / 100), - $result['viaggio_addebito'] + ($result['viaggio_addebito'] * $rs_iva[0]['percentuale'] / 100), - $result['ricambi_addebito'] + ($result['ricambi_addebito'] * $result['ricambi_iva'] / 100), - $result['altro_addebito'] + ($result['altro_addebito'] * $result['altro_iva'] / 100), - ]); - - $result['totale'] = sum([ - $result['manodopera_scontato'] + ($result['manodopera_scontato'] * $rs_iva[0]['percentuale'] / 100), - $result['dirittochiamata_scontato'] + ($result['dirittochiamata_scontato'] * $rs_iva[0]['percentuale'] / 100), - $result['viaggio_scontato'] + ($result['viaggio_scontato'] * $rs_iva[0]['percentuale'] / 100), - $result['ricambi_scontato'] + ($result['ricambi_scontato'] * $result['ricambi_iva'] / 100), - $result['altro_scontato'] + ($result['altro_scontato'] * $result['altro_iva'] / 100), - ]); - - // Calcolo dello sconto incondizionato - $sconto = $dbo->fetchArray('SELECT sconto_globale, tipo_sconto_globale FROM in_interventi WHERE id='.prepare($id_intervento))[0]; - $result['sconto_globale'] = ($sconto['tipo_sconto_globale'] == 'PRC') ? $result['totale_scontato'] * $sconto['sconto_globale'] / 100 : $sconto['sconto_globale']; - $result['sconto_globale'] = round($result['sconto_globale'], $decimals); - - $result['totale_scontato'] = sum($result['totale_scontato'], -$result['sconto_globale']); - $result['iva_totale'] = sum($result['iva_totale'], -($result['sconto_globale'] * $rs_iva[0]['percentuale'] / 100)); - $result['totale'] = sum($result['totale'], -($result['sconto_globale'] + ($result['sconto_globale'] * $rs_iva[0]['percentuale'] / 100))); - - return $result; -} - -// Aggiornamento sconti incodizionati per Interventi -$id_iva = setting('Iva predefinita'); -$iva = $dbo->fetchOne('SELECT * FROM co_iva WHERE id='.prepare($id_iva)); - -$interventi = $dbo->fetchArray('SELECT * FROM in_interventi WHERE sconto_globale != 0 AND sconto_globale != NULL'); -foreach ($interventi as $intervento) { - $costi = get_costi_intervento_fix($intervento['id']); - $sconto_globale = $costi['sconto_globale']; - - if ($intervento['tipo_sconto_globale'] == 'PRC') { - $descrizione = $sconto_globale >= 0 ? tr('Sconto percentuale') : tr('Maggiorazione percentuale'); - $descrizione .= ' '.Translator::numberToLocale($intervento['sconto_globale']).'%'; - } else { - $descrizione = $sconto_globale >= 0 ? tr('Sconto unitario') : tr('Maggiorazione unitaria'); - } - - $valore_iva = $sconto_globale * $iva['percentuale'] / 100; - - $dbo->insert('in_righe_interventi', [ - 'idintervento' => $intervento['id'], - 'descrizione' => $descrizione, - 'qta' => 1, - 'sconto' => $sconto_globale, - 'sconto_unitario' => $sconto_globale, - 'tipo_sconto' => 'UNT', - 'is_sconto' => 1, - 'idiva' => $id_iva['id'], - 'desc_iva' => $iva['descrizione'], - 'iva' => $valore_iva, - ]); -} - -$dbo->query('ALTER TABLE `in_interventi` DROP `sconto_globale`, DROP `tipo_sconto_globale`, DROP `tipo_sconto`'); - -// File e cartelle deprecate -$files = [ - 'plugins/xml/AT_v1.0.xml', - 'plugins/xml/DT_v1.0.xml', - 'plugins/xml/EC_v1.0.xml', - 'plugins/xml/MC_v1.0.xml', - 'plugins/xml/MT_v1.0.xml', - 'plugins/xml/NE_v1.0.xml', - 'plugins/xml/NS_v1.0.xml', - 'plugins/xml/RC_v1.0.xml', - 'plugins/xml/SE_v1.0.xml', - 'plugins/exportFE/view.php', - 'plugins/exportFE/src/stylesheet-1.2.1.xsl', -]; - -foreach ($files as $key => $value) { - $files[$key] = realpath(base_dir().'/'.$value); -} - -delete($files); - -// Calcolo la descrizione per il nuovo campo descrizione in scadenzario -$rs = $dbo->fetchArray('SELECT * FROM co_scadenziario'); - -for ($i = 0; $i < sizeof($rs); ++$i) { - $dbo->query("UPDATE co_scadenziario SET descrizione=(SELECT CONCAT(co_tipidocumento.descrizione, CONCAT(' numero ', IF(numero_esterno!='', numero_esterno, numero))) FROM co_documenti INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE co_documenti.id='".$rs[$i]['iddocumento']."') WHERE co_scadenziario.id='".$rs[$i]['id']."'"); -} diff --git a/update/2_4_9.sql b/update/2_4_9.sql deleted file mode 100755 index 2f42829a7..000000000 --- a/update/2_4_9.sql +++ /dev/null @@ -1,379 +0,0 @@ --- Escluso Art.74 ter D.P.R. 633/72 -INSERT INTO `co_iva` (`descrizione`, `percentuale`, `indetraibile`, `esente`, `codice_natura_fe`, `codice`, `default`) VALUES -("Escluso Art.74 ter D.P.R. 633/72", 0, 0, 1, "N4", NULL, 1); - --- Aggiungo vista "Conto" per Fatture di acquisto (opzionale) -INSERT INTO `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` = 'Fatture di acquisto') , 'Conto', '(SELECT GROUP_CONCAT(DISTINCT(co_pianodeiconti3.descrizione)) FROM co_righe_documenti INNER JOIN co_pianodeiconti3 ON co_pianodeiconti3.id = co_righe_documenti.idconto WHERE co_righe_documenti.iddocumento = co_documenti.id)', 10, 1, 0, 0, '', '', 0, 0, 1); - --- Stato FE (Notifica esito) -INSERT INTO `fe_stati_documento` (`codice`, `descrizione`, `icon`) VALUES ('NE', 'Notifica esito', 'fa fa-check text-warning'); - --- Aggiunta data di registrazione, utile per le fatture di acquisto -ALTER TABLE `co_documenti` ADD `data_registrazione` DATE NULL AFTER `data`, ADD `data_competenza` DATE NULL AFTER `data`; - --- Importo marca da bollo a 2 (https://www.fiscoetasse.com/approfondimenti/12090-applicazione-della-marca-da-bollo-sulle-fatture.html) -UPDATE `zz_settings` SET `valore` = '2' WHERE `zz_settings`.`nome` = 'Importo marca da bollo'; - --- Stampa preventivo (senza totali) -INSERT INTO `zz_prints` (`id`, `id_module`, `is_record`, `name`, `title`, `directory`, `previous`, `options`, `icon`, `version`, `compatibility`, `order`, `predefined`, `default`, `enabled`) VALUES -(NULL, (SELECT id FROM zz_modules WHERE name='Preventivi'), 1, 'Preventivo (senza totali)', 'Preventivo (senza totali)', 'preventivi', 'idpreventivo', '{"pricing":true, "hide_total":true}', 'fa fa-print', '', '', 0, 0, 1, 1); - --- Dimensione dei file caricati -ALTER TABLE `zz_files` ADD `size` INT(11) NULL AFTER `category`; - --- Elimino data_evasione da co_righe_preventivi -ALTER TABLE `co_righe_preventivi` DROP `data_evasione`; - --- Allineo qta evase per le righe dei preventivi inseriti in una fattura -UPDATE `co_righe_preventivi` INNER JOIN `co_righe_documenti` ON `co_righe_documenti`.`idpreventivo` = `co_righe_preventivi`.`idpreventivo` SET `co_righe_preventivi`.`qta_evasa` = `co_righe_documenti`.`qta`; - --- Allineo qta evase per le righe dei contratti inseriti in una fattura -UPDATE `co_righe_contratti` INNER JOIN `co_righe_documenti` ON `co_righe_documenti`.`idcontratto` = `co_righe_contratti`.`idcontratto` SET `co_righe_contratti`.`qta_evasa` = `co_righe_documenti`.`qta`; - --- Standardizzazione stati preventivi e contratti -ALTER TABLE `co_staticontratti` ADD `is_completato` BOOLEAN NOT NULL DEFAULT FALSE AFTER `pianificabile`; - -ALTER TABLE `co_statipreventivi` CHANGE `completato` `is_completato` BOOLEAN NOT NULL DEFAULT FALSE; -ALTER TABLE `co_statipreventivi` CHANGE `fatturabile` `is_fatturabile` BOOLEAN NOT NULL DEFAULT FALSE; -ALTER TABLE `co_statipreventivi` ADD `is_pianificabile` BOOLEAN NOT NULL DEFAULT FALSE AFTER `is_fatturabile`; -ALTER TABLE `co_statipreventivi` DROP `annullato`; - -ALTER TABLE `co_staticontratti` CHANGE `pianificabile` `is_pianificabile` BOOLEAN NOT NULL DEFAULT FALSE; -ALTER TABLE `co_staticontratti` CHANGE `fatturabile` `is_fatturabile` BOOLEAN NOT NULL DEFAULT FALSE; - --- Fix degli stati predefiniti preventivi e contratti -UPDATE `co_staticontratti` SET `is_completato` = 0, `is_pianificabile` = 0, `is_fatturabile` = 0 WHERE `descrizione` = 'Bozza'; -UPDATE `co_staticontratti` SET `is_completato` = 0, `is_pianificabile` = 0, `is_fatturabile` = 0 WHERE `descrizione` = 'In attesa di conferma'; -UPDATE `co_staticontratti` SET `is_completato` = 1, `is_pianificabile` = 0, `is_fatturabile` = 1 WHERE `descrizione` = 'Accettato'; -UPDATE `co_staticontratti` SET `is_completato` = 1, `is_pianificabile` = 0, `is_fatturabile` = 0 WHERE `descrizione` = 'Rifiutato'; -UPDATE `co_staticontratti` SET `is_completato` = 1, `is_pianificabile` = 1, `is_fatturabile` = 1 WHERE `descrizione` = 'In lavorazione'; -UPDATE `co_staticontratti` SET `is_completato` = 1, `is_pianificabile` = 1, `is_fatturabile` = 0 WHERE `descrizione` = 'Fatturato'; -UPDATE `co_staticontratti` SET `is_completato` = 1, `is_pianificabile` = 1, `is_fatturabile` = 0 WHERE `descrizione` = 'Pagato'; -UPDATE `co_staticontratti` SET `is_completato` = 1, `is_pianificabile` = 0, `is_fatturabile` = 1 WHERE `descrizione` = 'Concluso'; -UPDATE `co_staticontratti` SET `is_completato` = 1, `is_pianificabile` = 1, `is_fatturabile` = 1 WHERE `descrizione` = 'Parzialmente fatturato'; - -UPDATE `co_statipreventivi` SET `is_completato` = 0, `is_pianificabile` = 0, `is_fatturabile` = 0 WHERE `descrizione` = 'Bozza'; -UPDATE `co_statipreventivi` SET `is_completato` = 0, `is_pianificabile` = 0, `is_fatturabile` = 0 WHERE `descrizione` = 'In attesa di conferma'; -UPDATE `co_statipreventivi` SET `is_completato` = 1, `is_pianificabile` = 0, `is_fatturabile` = 1 WHERE `descrizione` = 'Accettato'; -UPDATE `co_statipreventivi` SET `is_completato` = 1, `is_pianificabile` = 0, `is_fatturabile` = 0 WHERE `descrizione` = 'Rifiutato'; -UPDATE `co_statipreventivi` SET `is_completato` = 1, `is_pianificabile` = 1, `is_fatturabile` = 1 WHERE `descrizione` = 'In lavorazione'; -UPDATE `co_statipreventivi` SET `is_completato` = 1, `is_pianificabile` = 1, `is_fatturabile` = 0 WHERE `descrizione` = 'Fatturato'; -UPDATE `co_statipreventivi` SET `is_completato` = 1, `is_pianificabile` = 1, `is_fatturabile` = 0 WHERE `descrizione` = 'Pagato'; -UPDATE `co_statipreventivi` SET `is_completato` = 1, `is_pianificabile` = 0, `is_fatturabile` = 1 WHERE `descrizione` = 'Concluso'; -UPDATE `co_statipreventivi` SET `is_completato` = 1, `is_pianificabile` = 1, `is_fatturabile` = 1 WHERE `descrizione` = 'Parzialmente fatturato'; - -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 is_fatturabile = 1) AND rinnovabile=1 AND ( ( (SELECT SUM(co_righe_contratti.qta) FROM co_righe_contratti WHERE co_righe_contratti.um=\'ore\' AND co_righe_contratti.idcontratto=co_contratti.id) - IFNULL( (SELECT SUM(in_interventi_tecnici.ore) FROM in_interventi_tecnici INNER JOIN in_interventi ON in_interventi_tecnici.idintervento=in_interventi.id WHERE in_interventi.id_contratto=co_contratti.id AND in_interventi.idstatointervento IN (SELECT in_statiintervento.idstatointervento FROM in_statiintervento WHERE in_statiintervento.completato = 1)), 0) ) < co_contratti.ore_preavviso_rinnovo OR NOW() > DATE_ADD( data_conclusione, INTERVAL - ABS(giorni_preavviso_rinnovo) DAY) ) AND YEAR(data_conclusione) > 1970 HAVING 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'; - -UPDATE `zz_widgets` SET `query` = 'SELECT COUNT(id) AS dato FROM co_ordiniservizio WHERE idcontratto IN( SELECT id FROM co_contratti WHERE idstato IN(SELECT id FROM co_staticontratti WHERE is_pianificabile = 1)) AND idintervento IS NULL' WHERE `zz_widgets`.`name` = 'Ordini di servizio da impostare'; -UPDATE `zz_widgets` SET `query` = 'SELECT COUNT(id) AS dato FROM co_promemoria WHERE idcontratto IN( SELECT id FROM co_contratti WHERE idstato IN (SELECT id FROM co_staticontratti WHERE is_pianificabile = 1)) AND idintervento IS NULL' WHERE `zz_widgets`.`name` = 'Interventi da pianificare'; - --- Fix filtri per data -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_documenti` INNER JOIN `co_tipidocumento` ON `co_documenti`.`idtipodocumento` = `co_tipidocumento`.`id` WHERE 1=1 AND `dir` = ''uscita'' |segment| |date_period(`data`)| HAVING 2=2 ORDER BY `data` DESC, CAST(IF(numero_esterno='''', numero, numero_esterno) AS UNSIGNED) DESC' WHERE `zz_modules`.`name` = 'Fatture di acquisto'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM co_documenti INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento = co_tipidocumento.id WHERE 1=1 AND dir = ''entrata'' |segment| |date_period(`data`)| HAVING 2=2 ORDER BY data DESC, CAST(numero_esterno AS UNSIGNED) DESC' WHERE `zz_modules`.`name` = 'Fatture di vendita'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM (`in_interventi` INNER JOIN `an_anagrafiche` ON `in_interventi`.`idanagrafica` = `an_anagrafiche`.`idanagrafica`) LEFT OUTER JOIN `in_interventi_tecnici` ON `in_interventi_tecnici`.`idintervento` = `in_interventi`.`id` WHERE 1=1 |date_period(`orario_inizio`,`data_richiesta`)| GROUP BY `in_interventi`.`id` HAVING 2=2 ORDER BY IFNULL(`orario_fine`, `data_richiesta`) DESC' WHERE `zz_modules`.`name` = 'Interventi'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_preventivi` WHERE 1=1 AND default_revision=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'')| HAVING 2=2 ORDER BY `id` DESC' WHERE `zz_modules`.`name` = 'Preventivi'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_contratti` WHERE 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'')| HAVING 2=2 ORDER BY `id` DESC' WHERE `zz_modules`.`name` = 'Contratti'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_movimenti` INNER JOIN `co_pianodeiconti3` ON `co_movimenti`.`idconto` = `co_pianodeiconti3`.`id` WHERE 1=1 AND `primanota` = 1 |date_period(`co_movimenti`.`data`)| GROUP BY `idmastrino`, `primanota`, `co_movimenti`.`data` HAVING 2=2 ORDER BY `co_movimenti`.`data` DESC' WHERE `zz_modules`.`name` = 'Prima nota'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `or_ordini` INNER JOIN `or_tipiordine` ON `or_ordini`.`idtipoordine` = `or_tipiordine`.`id` WHERE 1=1 AND `dir` = ''entrata'' |date_period(`data`)| HAVING 2=2 ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC' WHERE `zz_modules`.`name` = 'Ordini cliente'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `or_ordini` INNER JOIN `or_tipiordine` ON `or_ordini`.`idtipoordine` = `or_tipiordine`.`id` WHERE 1=1 AND `dir` = ''uscita'' |date_period(`data`)| HAVING 2=2 ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC' WHERE `zz_modules`.`name` = 'Ordini fornitore'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `dt_ddt` INNER JOIN `dt_tipiddt` ON `dt_ddt`.`idtipoddt` = `dt_tipiddt`.`id` WHERE 1=1 AND `dir` = ''entrata'' |date_period(`data`)| HAVING 2=2 ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC,`dt_ddt`.created_at DESC' WHERE `zz_modules`.`name` = 'Ddt di vendita'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `dt_ddt` INNER JOIN `dt_tipiddt` ON `dt_ddt`.`idtipoddt` = `dt_tipiddt`.`id` WHERE 1=1 AND `dir` = ''uscita'' |date_period(`data`)| HAVING 2=2 ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC' WHERE `zz_modules`.`name` = 'Ddt di acquisto'; - -UPDATE `zz_views` SET `query` = 'co_movimenti.idmastrino' WHERE `name` = 'id' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Prima nota'); - --- Stato FE (Attestazione di avvenuta trasmissione della fattura con impossibilità di recapito, estensione ricevuta .zip) -INSERT INTO `fe_stati_documento` (`codice`, `descrizione`, `icon`) VALUES ('AT', 'Attestazione trasmissione', 'fa fa-check text-warning'); - --- Aggiungo deleted_at per co_statipreventivi e co_staticontratti -ALTER TABLE `co_statipreventivi` ADD `deleted_at` DATETIME NULL; -ALTER TABLE `co_staticontratti` ADD `deleted_at` DATETIME NULL; - --- Aggiunto modulo per gestire gli stati dei preventivi -INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Stati dei preventivi', 'Stati dei preventivi','stati_preventivo', 'SELECT |select| FROM `co_statipreventivi` WHERE 1=1 AND deleted_at IS NULL HAVING 2=2', '', 'fa fa-angle-right', '2.4.9', '2.4.9', '1', (SELECT `id` FROM `zz_modules` t WHERE t.`name` = 'Preventivi'), '1', '1'); - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stati dei preventivi'), 'Fatturabile', 'IF(is_fatturabile, ''Sì'', ''No'')', 6, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stati dei preventivi'), 'Completato', 'IF(is_completato, ''Sì'', ''No'')', 5, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stati dei preventivi'), 'Pianificabile', 'IF(is_pianificabile, ''Sì'', ''No'')', 4, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stati dei preventivi'), 'Icona', 'icona', 3, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stati dei preventivi'), 'Descrizione', 'descrizione', 2, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stati dei preventivi'), 'id', 'id', 1, 0, 0, 1, 0); - --- Aggiunto modulo per gestire gli stati dei contratti -INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Stati dei contratti', 'Stati dei contratti','stati_contratto', 'SELECT |select| FROM `co_staticontratti` WHERE 1=1 AND deleted_at IS NULL HAVING 2=2', '', 'fa fa-angle-right', '2.4.9', '2.4.9', '1', (SELECT `id` FROM `zz_modules` t WHERE t.`name` = 'Contratti'), '1', '1'); - -INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `default`, `visible`) VALUES -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stati dei contratti'), 'Fatturabile', 'IF(is_fatturabile, ''Sì'', ''No'')', 6, 1, 0, 0 ,1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stati dei contratti'), 'Completato', 'IF(is_completato, ''Sì'', ''No'')', 5, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stati dei contratti'), 'Pianificabile', 'IF(is_pianificabile, ''Sì'', ''No'')', 4, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stati dei contratti'), 'Icona', 'icona', 3, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stati dei contratti'), 'Descrizione', 'descrizione', 2, 1, 0, 0, 1), -((SELECT `id` FROM `zz_modules` WHERE `name` = 'Stati dei contratti'), 'id', 'id', 1, 0, 0, 1, 0); - --- Aggiornamento sconti incondizionati -ALTER TABLE `co_documenti` DROP `sconto_globale`, DROP `tipo_sconto_globale`; -ALTER TABLE `co_preventivi` DROP `sconto_globale`, DROP `tipo_sconto_globale`; -ALTER TABLE `co_contratti` DROP `sconto_globale`, DROP `tipo_sconto_globale`; -ALTER TABLE `or_ordini` DROP `sconto_globale`, DROP `tipo_sconto_globale`; -ALTER TABLE `dt_ddt` DROP `sconto_globale`, DROP `tipo_sconto_globale`; - -ALTER TABLE `co_righe_documenti` ADD `is_sconto` BOOLEAN DEFAULT FALSE NOT NULL AFTER `is_descrizione`; -UPDATE `co_righe_documenti` SET `sconto` = `sconto_globale`, `sconto_unitario` = `sconto_globale`, `tipo_sconto` = 'UNT', `is_sconto` = 1 WHERE `sconto_globale` != 0; -ALTER TABLE `co_righe_documenti` DROP `sconto_globale`; - -ALTER TABLE `co_righe_preventivi` ADD `is_sconto` BOOLEAN DEFAULT FALSE NOT NULL AFTER `is_descrizione`; -UPDATE `co_righe_preventivi` SET `sconto` = `sconto_globale`, `sconto_unitario` = `sconto_globale`, `tipo_sconto` = 'UNT', `is_sconto` = 1 WHERE `sconto_globale` != 0; -ALTER TABLE `co_righe_preventivi` DROP `sconto_globale`; - -ALTER TABLE `co_righe_contratti` ADD `is_sconto` BOOLEAN DEFAULT FALSE NOT NULL AFTER `is_descrizione`; -UPDATE `co_righe_contratti` SET `sconto` = `sconto_globale`, `sconto_unitario` = `sconto_globale`, `tipo_sconto` = 'UNT', `is_sconto` = 1 WHERE `sconto_globale` != 0; -ALTER TABLE `co_righe_contratti` DROP `sconto_globale`; - -ALTER TABLE `or_righe_ordini` ADD `is_sconto` BOOLEAN DEFAULT FALSE NOT NULL AFTER `is_descrizione`; -UPDATE `or_righe_ordini` SET `sconto` = `sconto_globale`, `sconto_unitario` = `sconto_globale`, `tipo_sconto` = 'UNT', `is_sconto` = 1 WHERE `sconto_globale` != 0; -ALTER TABLE `or_righe_ordini` DROP `sconto_globale`; - -ALTER TABLE `dt_righe_ddt` ADD `is_sconto` BOOLEAN DEFAULT FALSE NOT NULL AFTER `is_descrizione`; -UPDATE `dt_righe_ddt` SET `sconto` = `sconto_globale`, `sconto_unitario` = `sconto_globale`, `tipo_sconto` = 'UNT', `is_sconto` = 1 WHERE `sconto_globale` != 0; -ALTER TABLE `dt_righe_ddt` DROP `sconto_globale`; - --- Fix per la tabella in_righe_interventi -ALTER TABLE `in_righe_interventi` ADD `is_descrizione` TINYINT(1) NOT NULL AFTER `idintervento`, ADD `idarticolo` INT(11) AFTER `idintervento`, ADD FOREIGN KEY (`idarticolo`) REFERENCES `mg_articoli`(`id`), ADD `is_sconto` BOOLEAN DEFAULT FALSE NOT NULL AFTER `is_descrizione`; -ALTER TABLE `mg_articoli_interventi` ADD `is_descrizione` TINYINT(1) NOT NULL AFTER `idintervento`, ADD `is_sconto` BOOLEAN DEFAULT FALSE NOT NULL AFTER `is_descrizione`; - --- Rimozione campi inutilizzati co_ritenutaacconto -ALTER TABLE `co_ritenutaacconto` DROP `esente`, DROP `indetraibile`; -UPDATE `co_ritenutaacconto` SET `percentuale_imponibile` = 100; - --- Aggiornamento widget "Debiti verso fornitori" -UPDATE `zz_widgets` SET `query` = 'SELECT CONCAT_WS('' '', REPLACE(REPLACE(REPLACE(FORMAT((SELECT ABS(SUM(da_pagare-pagato))), 2), '','', ''#''), ''.'', '',''),''#'', ''.''), ''€'') AS dato FROM (co_scadenziario INNER JOIN co_documenti ON co_scadenziario.iddocumento=co_documenti.id) INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE co_tipidocumento.dir=''uscita'' AND co_documenti.idstatodocumento!=1 |segment| AND 1=1' WHERE `zz_widgets`.`name` = 'Debiti verso fornitori'; - --- Aggiunta idsede anche preventivi (completamento 2.4.1) -ALTER TABLE `co_preventivi` ADD `idsede` INT NOT NULL AFTER `idanagrafica`; - --- Aggiunta flag riba per tipi di pagamento Ri.Ba. -ALTER TABLE `co_pagamenti` ADD `riba` TINYINT(1) NOT NULL DEFAULT '0' AFTER `codice_modalita_pagamento_fe`; -UPDATE `co_pagamenti` SET `riba` = 1 WHERE `descrizione` LIKE 'Ri.Ba.%'; - --- Creazione nuovo conto per anticipi Ri.Ba. -INSERT INTO `co_pianodeiconti3` (`id`, `numero`, `descrizione`, `idpianodeiconti2`, `dir`, `can_delete`, `can_edit`) VALUES (NULL, '000021', 'Banca C/C (conto anticipi)', '1', '', '0', '0'); - --- Aggiunta colonna nome per i modelli primanota -ALTER TABLE `co_movimenti_modelli` ADD `nome` VARCHAR(255) NOT NULL AFTER `idmastrino`; - -UPDATE `zz_views` SET `name` = 'Nome', `query` = 'co_movimenti_modelli.nome' WHERE `zz_views`.`id_module` = (SELECT id FROM zz_modules WHERE name='Modelli prima nota') AND `zz_views`.`name`='Causale predefinita'; -UPDATE `zz_views` SET `query` = 'co_movimenti_modelli.idmastrino' WHERE `zz_views`.`id_module` = (SELECT id FROM zz_modules WHERE name='Modelli prima nota') AND `zz_views`.`name`='id'; - --- Modelli primanota default -INSERT INTO `co_movimenti_modelli` (`id`, `idmastrino`, `nome`, `descrizione`, `idconto`) VALUES -(NULL, 1, 'Anticipo fattura', 'Anticipo fattura num. {numero} del {data}', -1), -(NULL, 1, 'Anticipo fattura', 'Anticipo fattura num. {numero} del {data}', (SELECT id FROM co_pianodeiconti3 WHERE descrizione = 'Banca C/C (conto anticipi)')), -(NULL, 1, 'Anticipo fattura', 'Anticipo fattura num. {numero} del {data}', (SELECT id FROM co_pianodeiconti3 WHERE descrizione = 'Spese bancarie')), -(NULL, 2, 'Accredito anticipo', 'Accredito anticipo fattura num. {numero} del {data}', (SELECT id FROM co_pianodeiconti3 WHERE descrizione = 'Banca C/C (conto anticipi)')), -(NULL, 2, 'Accredito anticipo', 'Accredito anticipo fattura num. {numero} del {data}', (SELECT id FROM co_pianodeiconti3 WHERE descrizione = 'Banca C/C')); - --- Segmenti per modulo scadenzario -INSERT INTO `zz_segments` (`id`, `id_module`, `name`, `clause`, `position`, `pattern`, `note`, `predefined`, `predefined_accredito`, `predefined_addebito`, `is_fiscale`) VALUES -(NULL, (SELECT id FROM zz_modules WHERE name='Scadenzario'), 'Scadenzario totale', '1=1', 'WHR', '####', '', 1, 0, 0, 1), -(NULL, (SELECT id FROM zz_modules WHERE name='Scadenzario'), 'Scadenzario clienti', '((SELECT dir FROM co_tipidocumento WHERE co_tipidocumento.id=co_documenti.idtipodocumento)=''entrata'')', 'WHR', '####', '', 0, 0, 0, 0), -(NULL, (SELECT id FROM zz_modules WHERE name='Scadenzario'), 'Scadenzario fornitori', '((SELECT dir FROM co_tipidocumento WHERE co_tipidocumento.id=co_documenti.idtipodocumento)=''uscita'')', 'WHR', '####', '', 0, 0, 0, 0), -(NULL, (SELECT id FROM zz_modules WHERE name='Scadenzario'), 'Scadenzario Ri.Ba.', 'co_pagamenti.riba=1', 'WHR', '####', '', 0, 0, 0, 0); - --- Fix vari -ALTER TABLE `co_righe_documenti` CHANGE `um` `um` VARCHAR(20) NULL; -UPDATE `co_righe_documenti` SET `um` = NULL WHERE `um` = ''; -ALTER TABLE `co_righe_documenti` CHANGE `idritenutaacconto` `idritenutaacconto` INT(11) NULL, CHANGE `idrivalsainps` `idrivalsainps` INT(11) NULL; -UPDATE `co_righe_documenti` SET `idritenutaacconto` = NULL WHERE `idritenutaacconto` = 0; -UPDATE `co_righe_documenti` SET `idrivalsainps` = NULL WHERE `idrivalsainps` = 0; - -ALTER TABLE `co_righe_preventivi` CHANGE `um` `um` VARCHAR(20) NULL; -UPDATE `co_righe_preventivi` SET `um` = NULL WHERE `um` = ''; - -ALTER TABLE `co_righe_contratti` CHANGE `um` `um` VARCHAR(20) NULL; -UPDATE `co_righe_contratti` SET `um` = NULL WHERE `um` = ''; - -ALTER TABLE `or_righe_ordini` CHANGE `um` `um` VARCHAR(20) NULL; -UPDATE `or_righe_ordini` SET `um` = NULL WHERE `um` = ''; - -ALTER TABLE `dt_righe_ddt` CHANGE `um` `um` VARCHAR(20) NULL; -UPDATE `dt_righe_ddt` SET `um` = NULL WHERE `um` = ''; - -ALTER TABLE `in_righe_interventi` CHANGE `um` `um` VARCHAR(20) NULL; -UPDATE `in_righe_interventi` SET `um` = NULL WHERE `um` = ''; - -ALTER TABLE `mg_articoli_interventi` CHANGE `um` `um` VARCHAR(20) NULL; -UPDATE `mg_articoli_interventi` SET `um` = NULL WHERE `um` = ''; - --- Supporto a valute differenti -CREATE TABLE IF NOT EXISTS `zz_currencies` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `title` varchar(255) NOT NULL, - `symbol` varchar(255) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - -INSERT INTO `zz_currencies` (`id`, `name`, `title`, `symbol`) VALUES -(NULL, 'Euro', 'Euro', '€'), -(NULL, 'Sterlina', 'Sterlina', '£'); - -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES (NULL, 'Valuta', '', 'query=SELECT id AS id, CONCAT(title, '' - '', symbol) AS text FROM zz_currencies', 1, 'Generali', 12); - --- Aggiornamento dicitura Tipo Cassa -UPDATE `zz_settings` SET `nome` = 'Tipo Cassa Previdenziale' WHERE `zz_settings`.`nome` = 'Tipo Cassa'; - --- Aggiunta campo "Rif. fattura" nello scadenzario -INSERT INTO `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='Scadenzario'), 'Rif. Fattura', 'IF( numero_esterno!="", numero_esterno, numero )', '2', '1', '0', '0', NULL, NULL, '1', '0', '1'); - -UPDATE `zz_views` SET `order`=`order`+1 WHERE `id_module`=(SELECT `id` FROM `zz_modules` WHERE `name`='Scadenzario') AND `order` > 1 AND `name` != 'Rif. Fattura'; - --- Aggiornamento widget "Crediti da clienti" -UPDATE `zz_widgets` SET `query` = 'SELECT CONCAT_WS('' '', REPLACE(REPLACE(REPLACE(FORMAT((SELECT ABS(SUM(da_pagare-pagato))), 2), '','', ''#''), ''.'', '',''),''#'', ''.''), ''€'') AS dato FROM (co_scadenziario INNER JOIN co_documenti ON co_scadenziario.iddocumento=co_documenti.id) INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE co_tipidocumento.dir=''entrata'' AND co_documenti.idstatodocumento!=1 |segment| AND 1=1' WHERE `zz_widgets`.`name` = 'Crediti da clienti'; - -UPDATE `fe_stati_documento` SET `icon`='fa fa-paper-plane-o text-info' WHERE `codice`='MC'; -UPDATE `fe_stati_documento` SET `icon`='fa fa-inbox text-success' WHERE `codice`='RC'; -UPDATE `fe_stati_documento` SET `icon`='fa fa-file-code-o text-info' WHERE `codice`='GEN'; - --- Impostazioni per i riferimenti ai documenti -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES (NULL, 'Riferimento dei documenti nelle stampe', '1', 'boolean', 1, 'Generali', 13); -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES (NULL, 'Riferimento dei documenti in Fattura Elettronica', '1', 'boolean', 1, 'Generali', 14); - --- Supporto alla personalizzazione dell'API remota OSMCloud -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES -(NULL, 'OSMCloud Services API URL', 'https://services.osmcloud.it/api/', 'string', 0, 'Fatturazione Elettronica', 11); - --- Miglioramento gestione marca da bollo -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES -(NULL, 'Addebita marca da bollo al cliente', 1, 'boolean', 1, 'Fatturazione', 13), -(NULL, 'Iva da applicare su marca da bollo', (SELECT id FROM `co_iva` WHERE `deleted_at` IS NULL AND `descrizione` = 'Escluso art. 15' ORDER BY descrizione ASC), 'query=SELECT id, id, IF(codice_natura_fe IS NULL, IF(codice IS NULL, descrizione, CONCAT(codice, " - ", descrizione)), CONCAT( IF(codice IS NULL, descrizione, CONCAT(codice, " - ", descrizione)), " (", codice_natura_fe, ")" )) AS descrizione FROM `co_iva` WHERE `deleted_at` IS NULL ORDER BY descrizione ASC', 1, 'Fatturazione', 14), -(NULL, 'Descrizione addebito bollo', 'Marca da bollo', 'string', 1, 'Fatturazione', 15), -(NULL, 'Conto predefinito per la marca da bollo', (SELECT id FROM co_pianodeiconti3 WHERE idpianodeiconti2=(SELECT id FROM co_pianodeiconti2 WHERE descrizione='Ricavi') AND descrizione = 'Rimborso spese marche da bollo'), 'query=SELECT id, descrizione FROM co_pianodeiconti3 WHERE idpianodeiconti2=(SELECT id FROM co_pianodeiconti2 WHERE descrizione=''Ricavi'')', 1, 'Fatturazione', 16); - -ALTER TABLE `zz_settings` CHANGE `help` `help` varchar(255); -UPDATE `zz_settings` SET `help` = NULL WHERE `help` = ''; - -ALTER TABLE `co_documenti` CHANGE `bollo` `bollo` decimal(12,4), CHANGE `data_stato_fe` `data_stato_fe` TIMESTAMP NULL, ADD `addebita_bollo` BOOLEAN NOT NULL DEFAULT TRUE, ADD `id_riga_bollo` int(11), ADD FOREIGN KEY (`id_riga_bollo`) REFERENCES `co_righe_documenti`(`id`) ON DELETE SET NULL; -UPDATE `co_documenti` SET `bollo` = NULL WHERE `idstatodocumento` = (SELECT `id` FROM `co_statidocumento` WHERE `descrizione` = 'Bozza'); -UPDATE `co_documenti` SET `data_registrazione` = NULL WHERE `data_registrazione` = '0000-00-00'; -UPDATE `co_documenti` SET `data_registrazione` = `data` WHERE `data_registrazione` IS NULL AND idtipodocumento IN (SELECT id FROM co_tipidocumento WHERE dir = 'uscita'); -UPDATE `co_documenti` SET `data_competenza` = `data_registrazione`; -UPDATE `co_documenti` SET `data_stato_fe` = NULL WHERE `data_stato_fe` = '0000-00-00 00:00:00'; - --- Rimozione tasto di stampa scadenzario totale da dentro la scadenza -UPDATE `zz_prints` SET `is_record` = 0 WHERE `name` = 'Scadenzario'; - --- Aggiunta descrizione nello scadenzario, per scadenze generiche -ALTER TABLE co_scadenziario ADD `descrizione` TEXT NOT NULL AFTER `tipo`; -INSERT INTO `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`='Scadenzario'), 'Descrizione scadenza', 'co_scadenziario.descrizione', 1, 1, 0, 0, '', '', 1, 0, 1); - --- Aggiunta segmento per scadenze generiche e F24 -INSERT INTO `zz_segments` (`id`, `id_module`, `name`, `clause`, `position`, `pattern`, `note`, `predefined`, `predefined_accredito`, `predefined_addebito`, `is_fiscale`) VALUES (NULL, (SELECT id FROM zz_modules WHERE `name`='Scadenzario'), 'Scadenzario generico', 'co_scadenziario.tipo="generico"', 'WHR', '####', '', 0, 0, 0, 0), (NULL, (SELECT id FROM zz_modules WHERE `name`='Scadenzario'), 'Scadenzario F24', 'co_scadenziario.tipo="f24"', 'WHR', '####', '', 0, 0, 0, 0); - --- Aggiornamento modulo Scadenzario per adattamento a scadenze multiple -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM (`co_scadenziario` LEFT JOIN (((`co_documenti` LEFT JOIN `an_anagrafiche` ON `co_documenti`.`idanagrafica` = `an_anagrafiche`.`idanagrafica`) LEFT JOIN `co_pagamenti` ON `co_documenti`.`idpagamento` = `co_pagamenti`.`id`) LEFT JOIN `co_tipidocumento` ON `co_documenti`.`idtipodocumento` = `co_tipidocumento`.`id`) ON `co_scadenziario`.`iddocumento` = `co_documenti`.`id`) LEFT JOIN `co_statidocumento` ON `co_documenti`.`idstatodocumento` = `co_statidocumento`.`id` WHERE 1=1 HAVING 2=2 AND IF(`co_statidocumento`.`descrizione` IS NOT NULL, `co_statidocumento`.`descrizione` IN(''Emessa'',''Parzialmente pagato''), 3=3) ORDER BY `scadenza` ASC' WHERE `zz_modules`.`name` = 'Scadenzario'; - -UPDATE `zz_segments` SET `clause` = '((SELECT dir FROM co_tipidocumento WHERE co_tipidocumento.id=co_documenti.idtipodocumento)=''entrata'') AND ABS(`co_scadenziario`.`pagato`) < ABS(`co_scadenziario`.`da_pagare`)' WHERE `zz_segments`.`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Scadenzario') AND `zz_segments`.`name` = 'Scadenzario clienti'; -UPDATE `zz_segments` SET `clause` = '((SELECT dir FROM co_tipidocumento WHERE co_tipidocumento.id=co_documenti.idtipodocumento)=''uscita'') AND ABS(`co_scadenziario`.`pagato`) < ABS(`co_scadenziario`.`da_pagare`)' WHERE `zz_segments`.`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Scadenzario') AND `zz_segments`.`name` = 'Scadenzario fornitori'; -UPDATE `zz_segments` SET `clause` = 'ABS(`co_scadenziario`.`pagato`) < ABS(`co_scadenziario`.`da_pagare`)' WHERE `zz_segments`.`id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Scadenzario') AND `zz_segments`.`name` = 'Scadenzario totale'; - --- Aggiornamento cambio colore scadenze -UPDATE `zz_views` SET `query` = 'IF( pagato=da_pagare, ''#38CD4E'', IF(scadenza < NOW(), ''#cc4d37'', '''') )' WHERE `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Scadenzario') AND `name` = '_bg_'; - --- Aggiunta campo con totale da pagare -INSERT INTO `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`='Scadenzario'), 'Saldo', 'da_pagare-pagato', 13, 1, 1, 1, '', '', 1, 1, 1); - --- Aggiunta vista ore rimanenti nei contratti -INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `visible`, `summable`, `default`) VALUES (NULL, (SELECT `zz_modules`.`id` FROM `zz_modules` WHERE `zz_modules`.`name`="Contratti"), 'Ore rimanenti', '( (SELECT SUM(co_righe_contratti.qta) FROM co_righe_contratti WHERE co_righe_contratti.um=''ore'' AND co_righe_contratti.idcontratto=co_contratti.id) - IFNULL( (SELECT SUM(in_interventi_tecnici.ore) FROM in_interventi_tecnici INNER JOIN in_interventi ON in_interventi_tecnici.idintervento=in_interventi.id WHERE in_interventi.id_contratto=co_contratti.id ), 0) )', '5', '1', '0', '1', '', '', '0', '0', '0'); - --- Inserimento stato intervento da programmare -INSERT INTO `in_statiintervento` (`idstatointervento`, `descrizione`, `colore`, `can_delete`, `completato`, `created_at`, `notifica`, `id_email`, `destinatari`) VALUES ('DAP', 'Da programmare', '#2deded', '1', '0', NULL, '0', NULL, NULL); - --- Widget attività in programmazione -INSERT INTO `zz_widgets` (`id`, `name`, `type`, `id_module`, `location`, `class`, `query`, `bgcolor`, `icon`, `print_link`, `more_link`, `more_link_type`, `php_include`, `text`, `enabled`, `order`, `help`) VALUES (NULL, 'Attività in programmazione', 'stats', '1', 'controller_top', 'col-md-12', 'SELECT COUNT(id) AS dato FROM in_interventi WHERE in_interventi.idstatointervento = (SELECT in_statiintervento.idstatointervento FROM in_statiintervento WHERE in_statiintervento.descrizione=\'Da programmare\') ORDER BY in_interventi.data_richiesta ASC', '#2deded', 'fa fa-hourglass-half', '', './modules/interventi/widgets/interventi_da_pianificare.php', 'popup', '', 'Attività in programmazione', '1', '8', NULL); - --- Widget attività ancora da programmare -INSERT INTO `zz_widgets` (`id`, `name`, `type`, `id_module`, `location`, `class`, `query`, `bgcolor`, `icon`, `print_link`, `more_link`, `more_link_type`, `php_include`, `text`, `enabled`, `order`, `help`) VALUES (NULL, 'Attività confermate', 'stats', '1', 'controller_top', 'col-md-12', 'SELECT COUNT(id) AS dato FROM in_interventi WHERE in_interventi.idstatointervento = (SELECT in_statiintervento.idstatointervento FROM in_statiintervento WHERE in_statiintervento.descrizione=\'In programmazione\') ORDER BY in_interventi.data_richiesta ASC', '#f2bd00', 'fa fa-hourglass-half', '', './modules/interventi/widgets/interventi_confermati.php', 'popup', '', 'Attività confermate', '1', '8', NULL); - --- Aggiunta ore rimanenti nel contratto per preavviso rinnovo -ALTER TABLE `co_contratti` ADD `ore_preavviso_rinnovo` INT(11) NULL AFTER `giorni_preavviso_rinnovo`; - --- Moduli Stato dei servizi -INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Stato dei servizi', 'Stato dei servizi', 'stato_servizi', 'custom', '', 'fa fa-clock-o', '2.4.9', '2.4.9', '1', NULL, '1', '1'); -UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Stato dei servizi' AND `t2`.`name` = 'Strumenti') SET `t1`.`parent` = `t2`.`id`; - --- Widget spazio utilizzato -INSERT INTO `zz_widgets` (`id`, `name`, `type`, `id_module`, `location`, `class`, `query`, `bgcolor`, `icon`, `print_link`, `more_link`, `more_link_type`, `php_include`, `text`, `enabled`, `order`, `help`) VALUES (NULL, 'Spazio utilizzato', 'chart', (SELECT id FROM zz_modules WHERE name = 'Stato dei servizi'), 'controller_right', 'col-md-12', NULL, '#4ccc4c', 'fa fa-hdd-o', '', '', NULL, './modules/stato_servizi/widgets/spazio_utilizzato.php', 'Spazio utilizzato', '1', '1', NULL); - --- Aggiunta vista con data conclusione e flag rinnovabile nei contratti -INSERT INTO `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` = 'Contratti'), 'Rinnovabile', 'IF(`co_contratti`.`rinnovabile`=1, \'SI\', \'NO\')', '6', '1', '0', '1', '', '', '0', '0', '0'), (NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Contratti'), 'Data conclusione', 'IF(data_conclusione=0, \'\', data_conclusione)', '7', '1', '0', '1', '', '', '0', '0', '0'); - --- Aggiunta visualizzazione importo totale negli ordini -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM ((`or_ordini` INNER JOIN `or_tipiordine` ON `or_ordini`.`idtipoordine` = `or_tipiordine`.`id`) INNER JOIN `an_anagrafiche` ON `or_ordini`.`idanagrafica` = `an_anagrafiche`.`idanagrafica`) LEFT OUTER JOIN `or_righe_ordini` ON `or_ordini`.`id` = `or_righe_ordini`.`idordine` WHERE 1=1 AND `dir` = \'entrata\' |date_period(`data`)| GROUP BY or_ordini.id HAVING 2=2 ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC' WHERE `zz_modules`.`name` = 'Ordini cliente'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM ((`or_ordini` INNER JOIN `or_tipiordine` ON `or_ordini`.`idtipoordine` = `or_tipiordine`.`id`) INNER JOIN `an_anagrafiche` ON `or_ordini`.`idanagrafica` = `an_anagrafiche`.`idanagrafica`) LEFT OUTER JOIN `or_righe_ordini` ON `or_ordini`.`id` = `or_righe_ordini`.`idordine` WHERE 1=1 AND `dir` = \'uscita\' |date_period(`data`)| GROUP BY or_ordini.id HAVING 2=2 ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC' WHERE `zz_modules`.`name` = 'Ordini fornitore'; - -INSERT INTO `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` = 'Ordini cliente'), 'Totale', 'SUM(`subtotale` - `sconto`)', '5', '1', '0', '1', '', '', '1', '1', '0'); -INSERT INTO `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` = 'Ordini fornitore'), 'Totale', 'SUM(`subtotale` - `sconto`)', '5', '1', '0', '1', '', '', '1', '1', '0'); - -UPDATE `zz_views` SET `query` = '`an_anagrafiche`.`ragione_sociale`' WHERE `id_module` IN (SELECT `id` FROM `zz_modules` WHERE `name` IN('Ordini cliente', 'Ordini fornitore')) AND `name` = 'Ragione sociale'; - --- Riordinamento campi degli ordini cliente e fornitore -UPDATE `zz_views` SET `order` = 3 WHERE `id_module` IN (SELECT `id` FROM `zz_modules` WHERE `name` IN('Ordini cliente', 'Ordini fornitore')) AND `name` = 'Data'; -UPDATE `zz_views` SET `order` = 4 WHERE `id_module` IN (SELECT `id` FROM `zz_modules` WHERE `name` IN('Ordini cliente', 'Ordini fornitore')) AND `name` = 'Ragione sociale'; -UPDATE `zz_views` SET `order` = 6 WHERE `id_module` IN (SELECT `id` FROM `zz_modules` WHERE `name` IN('Ordini cliente', 'Ordini fornitore')) AND `name` = 'icon_Stato'; -UPDATE `zz_views` SET `order` = 7 WHERE `id_module` IN (SELECT `id` FROM `zz_modules` WHERE `name` IN('Ordini cliente', 'Ordini fornitore')) AND `name` = 'icon_title_Stato'; - --- Aggiunta visualizzazione nuovi campi utili nei ddt -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM ((((((`dt_ddt` INNER JOIN `dt_tipiddt` ON `dt_ddt`.`idtipoddt` = `dt_tipiddt`.`id`) LEFT OUTER JOIN `dt_righe_ddt` ON `dt_ddt`.`id` = `dt_righe_ddt`.`idddt`) LEFT OUTER JOIN `dt_causalet` ON `dt_ddt`.`idcausalet` = `dt_causalet`.`id`) LEFT OUTER JOIN `dt_spedizione` ON `dt_ddt`.`idspedizione` = `dt_spedizione`.`id`) LEFT OUTER JOIN `an_anagrafiche` `vettori` ON `dt_ddt`.`idvettore` = `vettori`.`idanagrafica`) LEFT OUTER JOIN `an_anagrafiche` AS `destinatari` ON `dt_ddt`.`idanagrafica` = `destinatari`.`idanagrafica`) LEFT OUTER JOIN `an_sedi` ON `dt_ddt`.`idsede` = `an_sedi`.`id` WHERE 1=1 AND `dir` = \'entrata\' |date_period(`data`)| GROUP BY dt_ddt.id HAVING 2=2 ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC,`dt_ddt`.created_at DESC' WHERE `zz_modules`.`name` = 'Ddt di vendita'; -UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM ((((((`dt_ddt` INNER JOIN `dt_tipiddt` ON `dt_ddt`.`idtipoddt` = `dt_tipiddt`.`id`) LEFT OUTER JOIN `dt_righe_ddt` ON `dt_ddt`.`id` = `dt_righe_ddt`.`idddt`) LEFT OUTER JOIN `dt_causalet` ON `dt_ddt`.`idcausalet` = `dt_causalet`.`id`) LEFT OUTER JOIN `dt_spedizione` ON `dt_ddt`.`idspedizione` = `dt_spedizione`.`id`) LEFT OUTER JOIN `an_anagrafiche` `vettori` ON `dt_ddt`.`idvettore` = `vettori`.`idanagrafica`) LEFT OUTER JOIN `an_anagrafiche` AS `destinatari` ON `dt_ddt`.`idanagrafica` = `destinatari`.`idanagrafica`) LEFT OUTER JOIN `an_sedi` ON `dt_ddt`.`idsede` = `an_sedi`.`id` WHERE 1=1 AND `dir` = \'uscita\' |date_period(`data`)| GROUP BY dt_ddt.id HAVING 2=2 ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC,`dt_ddt`.created_at DESC' WHERE `zz_modules`.`name` = 'Ddt di acquisto'; - -INSERT INTO `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` = 'Ddt di vendita'), 'Sede', 'IF(`dt_ddt`.`idsede`=0, \'Sede legale\', `an_sedi`.`nomesede`)', '5', '1', '0', '1', '', '', '1', '0', '0'); -INSERT INTO `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` = 'Ddt di vendita'), 'Causale', '`dt_causalet`.`descrizione`', '6', '1', '0', '1', '', '', '1', '0', '0'); -INSERT INTO `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` = 'Ddt di vendita'), 'Tipo spedizione', '`dt_spedizione`.`descrizione`', '7', '1', '0', '1', '', '', '1', '0', '0'); -INSERT INTO `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` = 'Ddt di vendita'), 'Vettore', '`vettori`.`ragione_sociale`', '8', '1', '0', '1', '', '', '1', '0', '0'); -INSERT INTO `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` = 'Ddt di vendita'), 'Totale', 'SUM(`subtotale` - `sconto`)', '9', '1', '0', '1', '', '', '1', '1', '0'); - -INSERT INTO `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` = 'Ddt di acquisto'), 'Sede', 'IF(`dt_ddt`.`idsede`=0, \'Sede legale\', `an_sedi`.`nomesede`)', '5', '1', '0', '1', '', '', '1', '0', '0'); -INSERT INTO `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` = 'Ddt di acquisto'), 'Causale', '`dt_causalet`.`descrizione`', '6', '1', '0', '1', '', '', '1', '0', '0'); -INSERT INTO `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` = 'Ddt di acquisto'), 'Tipo spedizione', '`dt_spedizione`.`descrizione`', '7', '1', '0', '1', '', '', '1', '0', '0'); -INSERT INTO `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` = 'Ddt di acquisto'), 'Vettore', '`vettori`.`ragione_sociale`', '8', '1', '0', '1', '', '', '1', '0', '0'); -INSERT INTO `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` = 'Ddt di acquisto'), 'Totale', 'SUM(`subtotale` - `sconto`)', '9', '1', '0', '1', '', '', '1', '1', '0'); - -UPDATE `zz_views` SET `query` = '`destinatari`.`ragione_sociale`' WHERE `id_module` IN (SELECT `id` FROM `zz_modules` WHERE `name` IN('Ddt di vendita', 'Ddt di acquisto')) AND `name` = 'Ragione sociale'; - --- Riordinamento campi dei ddt in ingresso e uscita -UPDATE `zz_views` SET `order` = 10 WHERE `id_module` IN (SELECT `id` FROM `zz_modules` WHERE `name` IN('Ddt di vendita', 'Ddt di acquisto')) AND `name` = 'icon_Stato'; -UPDATE `zz_views` SET `order` = 11 WHERE `id_module` IN (SELECT `id` FROM `zz_modules` WHERE `name` IN('Ddt di vendita', 'Ddt di acquisto')) AND `name` = 'icon_title_Stato'; -UPDATE `zz_views` SET `order` = 12 WHERE `id_module` IN (SELECT `id` FROM `zz_modules` WHERE `name` IN('Ddt di vendita', 'Ddt di acquisto')) AND `name` = 'dir'; - --- Aggiornamento widget "Fatturato" (iva esclusa) -UPDATE `zz_widgets` SET `query` = 'SELECT CONCAT_WS('' '', REPLACE(REPLACE(REPLACE(FORMAT((SELECT SUM(subtotale-sconto-co_righe_documenti.ritenutaacconto)), 2), '','', ''#''), ''.'', '',''), ''#'', ''.''), ''€'') AS dato FROM (co_righe_documenti INNER JOIN co_documenti ON co_righe_documenti.iddocumento=co_documenti.id) INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE co_tipidocumento.dir=''entrata'' |segment| AND data >= ''|period_start|'' AND data <= ''|period_end|'' AND 1=1', `help` = 'Fatturato IVA esclusa.' WHERE `zz_widgets`.`name` = 'Fatturato'; - --- Aggiornamento widget "Acquisti" (iva esclusa) -UPDATE `zz_widgets` SET `query` = 'SELECT CONCAT_WS('' '', REPLACE(REPLACE(REPLACE(FORMAT((SELECT SUM(subtotale-sconto-co_righe_documenti.ritenutaacconto)), 2), '','', ''#''), ''.'', '',''), ''#'', ''.''), ''€'') AS dato FROM (co_righe_documenti INNER JOIN co_documenti ON co_righe_documenti.iddocumento=co_documenti.id) INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE co_tipidocumento.dir=''uscita'' |segment| AND data >= ''|period_start|'' AND data <= ''|period_end|'' AND 1=1', `help` = 'Fatturato IVA esclusa.' WHERE `zz_widgets`.`name` = 'Acquisti'; - --- Sistema Hook -CREATE TABLE IF NOT EXISTS `zz_hooks` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `class` varchar(255) NOT NULL, - `frequency` varchar(255) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - -CREATE TABLE IF NOT EXISTS `zz_hook_cache` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `hook_id` int(11) NOT NULL, - `results` TEXT NOT NULL, - PRIMARY KEY (`id`), - FOREIGN KEY (`hook_id`) REFERENCES `zz_hooks`(`id`) -) ENGINE=InnoDB; - -INSERT INTO `zz_hooks` (`id`, `name`, `class`, `frequency`) VALUES -(NULL, 'Ricevute', 'Plugins\\ReceiptFE\\ReceiptHook', '1 day'), -(NULL, 'Fatture', 'Plugins\\ImportFE\\InvoiceHook', '1 day'); - --- Aggiunte variabili di sistema per stampa riepilogo interventi -INSERT INTO `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'), 'richiesta', 'richiesta', '14', '1', '0', '0', '', '', '0', '0', '1'); - -INSERT INTO `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'), 'descrizione', 'descrizione', '15', '1', '0', '0', '', '', '0', '0', '1'); diff --git a/update/api.php b/update/api.php deleted file mode 100755 index 37496fb95..000000000 --- a/update/api.php +++ /dev/null @@ -1,28 +0,0 @@ -tableExists($table)) { - $query = 'SHOW COLUMNS FROM `'.$table.'` IN `'.$database->getDatabaseName()."` WHERE Field='|field|'"; - - $created_at = $database->fetchArray(str_replace('|field|', 'created_at', $query)); - if (empty($created_at)) { - $database->query('ALTER TABLE `'.$table.'` ADD `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP'); - } - - if (Response::isCompatible()) { - $updated_at = $database->fetchArray(str_replace('|field|', 'updated_at', $query)); - if (empty($updated_at)) { - $database->query('ALTER TABLE `'.$table.'` ADD `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'); - } - } - } -} diff --git a/update/create_updates.sql b/update/create_updates.sql deleted file mode 100755 index b024fe863..000000000 --- a/update/create_updates.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE `updates` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `directory` varchar(255), - `version` varchar(255) NOT NULL, - `sql` boolean NOT NULL, - `script` boolean NOT NULL, - `done` int(11), - PRIMARY KEY (`id`) -) ENGINE=InnoDB; diff --git a/update/structure.php b/update/structure.php deleted file mode 100644 index 7d5224812..000000000 --- a/update/structure.php +++ /dev/null @@ -1,11 +0,0 @@ -. - */ - -// Rimozione delle limitazioni sull'esecuzione -set_time_limit(0); -ignore_user_abort(true); - -$skip_permissions = true; -include_once __DIR__.'/../../core.php'; - -$backup = null; // Cartella di backup specifica -$file = null; // File di backup del database - -// Ricerca dell'ultimo backup (idealmente versione 2.4.16) -if (empty($file) && empty($backup)) { - $backups = Backup::getList(); - $backups = array_reverse($backups); -} - -if (empty($file)) { - $count = count($backups); - for ($i = 0; $i < $count; ++$i) { - $backup = $backups[$i]; - - // Individuazione del database nel backup - if (string_ends_with($backup, '.zip')) { - $zip = new ZipArchive(); - $zip->open($backup); - - $version = $zip->getFromName('VERSION'); - if ($version == '2.4.17') { - continue; - } - - $contents = $zip->getFromName('database.sql'); - - // File temporaneo - $file = DIRECTORY_SEPARATOR. - trim(sys_get_temp_dir(), DIRECTORY_SEPARATOR). - DIRECTORY_SEPARATOR. - ltrim('database.sql', DIRECTORY_SEPARATOR); - - file_put_contents($file, $contents); - - register_shutdown_function(function () use ($file) { - unlink($file); - }); - } else { - $version = file_get_contents($backup.'/VERSION'); - if ($version == '2.4.17') { - continue; - } - - $file = $backup.'/database.sql'; - } - } -} - -if (empty($file)) { - echo 'Impossibile procedere'; - - return; -} - -// Lettura delle query -$queries = readSQLFile($file, ';'); -$count = count($queries); - -// Individuazione del dump di co_movimenti -$query = null; -for ($i = 0; $i < $count; ++$i) { - if (string_starts_with($queries[$i], 'INSERT INTO `co_movimenti`')) { - $query = $queries[$i]; - } -} - -if (empty($query)) { - echo 'Impossibile procedere'; - - return; -} - -// Lettura dei contenuti -$values = explode('VALUES', $query, 2)[1]; -$values = explode('),', $values); - -// Generazione delle query per il recupero delle date per la Prima Nota -$results = []; -foreach ($values as $row) { - $row = substr(trim($row), 1); - - $campi = explode(',', $row); - $id = $campi[0]; - $data = $campi[2]; - $is_primanota = $campi[12]; - - if (!empty($is_primanota)) { - $results[] = 'UPDATE `co_movimenti` SET `data` = '.$data.' WHERE `id` = '.prepare($id).';'; - } -} - -echo implode("\n", $results); diff --git a/view.php b/view.php deleted file mode 100755 index 74dd8d008..000000000 --- a/view.php +++ /dev/null @@ -1,104 +0,0 @@ -. - */ - -include_once __DIR__.'/core.php'; - -$file_id = filter('file_id'); - -$file = Models\Upload::find($file_id); - -if (empty($file)) { - return; -} - -$link = base_path().'/'.$file->filepath; - -// Force download of the file -if (get('download') == '1') { - header('Content-Type: application/octet-stream'); - header('Content-Transfer-Encoding: Binary'); - header('Content-disposition: attachment; filename="'.basename($file->original_name).'"'); - readfile(base_dir().'/'.$file->filepath); - //download(base_dir().'/'.$file->filepath, basename($file->original_name)); - exit(); -} - -if ($file->isFatturaElettronica()) { - $content = file_get_contents(base_dir().'/'.$file->filepath); - - // Individuazione stylesheet - $default_stylesheet = 'asso-invoice'; - - $name = basename($file->original_name); - $filename = explode('.', $name)[0]; - $pieces = explode('_', $filename); - $stylesheet = $pieces[2]; - - $stylesheet = base_dir().'/plugins/xml/'.$stylesheet.'.xsl'; - $stylesheet = file_exists($stylesheet) ? $stylesheet : base_dir().'/plugins/xml/'.$default_stylesheet.'.xsl'; - - // XML - $xml = new DOMDocument(); - $xml->loadXML($content); - - // XSL - $xsl = new DOMDocument(); - $xsl->load($stylesheet); - - // XSLT - $xslt = new XSLTProcessor(); - $xslt->importStylesheet($xsl); - - echo ' -'; - - echo $xslt->transformToXML($xml); -} else { - echo ' -'; - - if ($file->isImage()) { - echo ' - '; - } else { - if ($file->isPDF()) { - $src = \Prints::getPDFLink($file->filepath); - } - - echo ' - '; - } -} diff --git a/webpack.mix.js b/webpack.mix.js new file mode 100644 index 000000000..2a22dc120 --- /dev/null +++ b/webpack.mix.js @@ -0,0 +1,17 @@ +const mix = require('laravel-mix'); + +/* + |-------------------------------------------------------------------------- + | Mix Asset Management + |-------------------------------------------------------------------------- + | + | Mix provides a clean, fluent API for defining some Webpack build steps + | for your Laravel applications. By default, we are compiling the CSS + | file for the application as well as bundling up all the JS files. + | + */ + +mix.js('resources/js/app.js', 'public/js') + .postCss('resources/css/app.css', 'public/css', [ + // + ]);