Kaynağa Gözat

File prefettura

Luca Parisio 3 ay önce
ebeveyn
işleme
37b08b6468

+ 1 - 1
app/Http/Livewire/Istat.php

@@ -550,7 +550,7 @@ class Istat extends Component
                                     $v_data['tipo'] .= $v_tipo;
 
                                     $v_data['veicolo'] .= $veicolo->foreign_country ?
-                                        str_repeat(' ', 8) :
+                                        str_repeat(' ', 7) :
                                         str_pad(substr($veicolo->targa, 0, 8), 8, ' ', STR_PAD_RIGHT);
 
                                     $v_data['veicolo'] .= $veicolo->foreign_country ?

+ 550 - 0
app/Http/Livewire/Prefettura.php

@@ -0,0 +1,550 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use App\Helpers\DateHelper;
+use App\Models\Anagrafica;
+use App\Models\ReportDataPedoni;
+use Illuminate\Support\Facades\Log;
+use Livewire\Component;
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
+use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
+
+class Prefettura extends Component
+{
+
+    const LOCALIZZAZIONE_INCIDENTE_IN = 1;
+    const LOCALIZZAZIONE_INCIDENTE_OUT = 2;
+
+    const VISIBILITA_BUONA = 1;
+    const VISIBILITA_LIMITATA = 2;
+
+    const FONDO_STRADALE_SPECIFICA_OPTION_VALUE = 5;
+    const PARTICOLARITA_STRADA_SPECIFICA_OPTION_VALUE = 5;
+
+    const TRAFFICO_NORMALE = 1;
+    const TRAFFICO_SCARSO = 2;
+    const TRAFFICO_INTENSO = 3;
+
+    const TIPO_STRADA_ALTRO_OPTION_VALUE = 8;
+
+    const SEGNALETICA_ASSENTE = 1;
+    const SEGNALETICA_VERTICALE = 2;
+    const SEGNALETICA_ORIZZONTALE = 3;
+    const SEGNALETICA_VERTICALE_ORIZZONTALE = 4;
+    const SEGNALETICA_TEMPORANEA_CANTIERE = 5;
+
+    const SEGNALETICA_VERTICALE_LIMITE_VELOCITA_OPTION_VALUE = 21;
+    const SEGNALETICA_VERTICALE_PANNELLO_INTEGRATIVO_OPTION_VALUE = 22;
+    const SEGNALETICA_VERTICALE_ALTRO_OPTION_VALUE = 23;
+
+
+    const LINEA_CONTINUA = 1;
+    const LINEA_TRATTEGGIATA = 2;
+    const LINEA_TRATTEGGIATA_IN_CORRISPONDENZA = 3;
+    const SEGNALETICA_ORIZZONTALE_LINEA_ASSENTE = 4;
+
+    const MAX_PARTI_COINVOLTE = 10;
+    const MAX_VEHICLES = 4;
+    const MAX_PASSEGGERI = 4;
+    const MAX_INFORTUNATI = 4;
+    const MAX_PEDONI = 4;
+    const MAX_TESTI_OCULARI = 4;
+
+    const STATO_VEICOLO_MARCIA = 1;
+    const STATO_VEICOLO_SOSTA = 2;
+    const STATO_VEICOLO_NON_PRESENTE = 3;
+
+    const POSIZIONE_STATICA_FINALE_DOCUMENTAZIONE_FOTOGRAFICA = 1;
+    const POSIZIONE_STATICA_FINALE_RILIEVO_PLANIMETRICO = 2;
+    const POSIZIONE_STATICA_FINALE_SCHIZZO_VISTA_NO_SCALA = 3;
+    const POSIZIONE_STATICA_FINALE_GIA_RIMOSSO = 4;
+
+    const DESTINAZIONE_VEICOLO_RIMOSSO_SENSI_ART_2028_CC = 1;
+    const DESTINAZIONE_VEICOLO_SEQUESTRO_ART_354_CPP = 2;
+    const DESTINAZIONE_VEICOLO_SEQUESTRO_ART_321_CPP = 3;
+    const DESTINAZIONE_VEICOLO_SEQUESTRO = 4;
+    const DESTINAZIONE_VEICOLO_SEQUESTRO_AMMINISTRATIVO = 5;
+    const DESTINAZIONE_VEICOLO_FERMO_AMMINISTRATIVO = 6;
+    const DESTINAZIONE_VEICOLO_RITIRATO_DAL_CONDUCENTE = 7;
+
+    const STATO_PNEUMATICI_REGOLAMENTARE = 1;
+    const STATO_PNEUMATICI_BUONO = 2;
+    const STATO_PNEUMATICI_SUFFICIENTE = 3;
+    const STATO_PNEUMATICI_INSUFFICIENTE = 4;
+    const STATO_PNEUMATICI_NON_RILEVATO = 5;
+
+    const STATO_PRESENTE = 1;
+    const STATO_NON_PRESENTE = 2;
+    const STATO_FUNZIONANTE = 1;
+    const STATO_NON_FUNZIONANTE = 2;
+    const STATO_NON_RILEVATO = 3;
+
+    const YES = 1;
+    const NO = 0;
+
+    const SI_RISERVA = 3;
+
+    const PATENTE_AL_SEGUITO_NON_PREVISTA = 3;
+
+    const CONDUCENTE_GENERALIZZATO_LUOGO = 1;
+    const CONDUCENTE_GENERALIZZATO_OSPEDALE = 2;
+    const CONDUCENTE_GENERALIZZATO_ALTRO = 3;
+
+    const INFORTUNATO_INCOLUME = 0;
+    const INFORTUNATO_FERITO = 1;
+    const INFORTUNATO_DECEDUTO_24H = 2;
+    const INFORTUNATO_DECEDUTO_30GG = 3;
+
+    const MARCIA_OPTION_N = 0;
+    const MARCIA_OPTION_1 = 1;
+    const MARCIA_OPTION_2 = 2;
+    const MARCIA_OPTION_3 = 3;
+    const MARCIA_OPTION_4 = 4;
+    const MARCIA_OPTION_5 = 5;
+    const MARCIA_OPTION_6 = 6;
+    const MARCIA_OPTION_R = 7;
+    const MARCIA_NON_RILEVATA = 8;
+    const MARCIA_OPTION_AUTO = 9;
+
+    const CRISTALLO_OPTION_INTERNO = 1;
+    const CRISTALLO_OPTION_ESTERNO = 2;
+    const CRISTALLO_OPTION_ALTRO = 3;
+
+    const ESITO_NEGATIVO = 1;
+    const ESITO_POSITIVO = 2;
+
+    const DOCUMENTO_CI = 1;
+    const DOCUMENTO_PAT = 2;
+    const DOCUMENTO_PP = 3;
+    const DOCUMENTO_ALTRO = 4;
+
+    const PEDONE_PRESENTE_E_POSIZIONE = 1;
+    const PEDONE_SOCCORSO_E_PRESSO = 2;
+
+    const TESTE_PRESENTE_MOMENTO_RILIEVO = 1;
+    const TESTE_NON_PRESENTE_MOMENTO_RILIEVO = 2;
+    const TESTE_DICHIARA_LUOGO_INCIDENTE = 3;
+    const TESTE_DICHIARA_PRONTO_SOCCORSO = 4;
+    const TESTE_DICHIARA_PROSEGUO_TEMPO = 5;
+
+    const PATENTE_CATEGORIA_AM = 'AM';
+    const PATENTE_CATEGORIA_A1 = 'A1';
+    const PATENTE_CATEGORIA_A1B = 'A1B';
+    const PATENTE_CATEGORIA_A2 = 'A2';
+    const PATENTE_CATEGORIA_A = 'A';
+    const PATENTE_CATEGORIA_AB = 'AB';
+    const PATENTE_CATEGORIA_B1 = 'B1';
+    const PATENTE_CATEGORIA_B = 'B';
+    const PATENTE_CATEGORIA_BE = 'BE';
+    const PATENTE_CATEGORIA_C1 = 'C1';
+    const PATENTE_CATEGORIA_C1E = 'C1E';
+    const PATENTE_CATEGORIA_C = 'C';
+    const PATENTE_CATEGORIA_CE = 'CE';
+    const PATENTE_CATEGORIA_D1 = 'D1';
+    const PATENTE_CATEGORIA_D1E = 'D1E';
+    const PATENTE_CATEGORIA_DE = 'DE';
+    const PATENTE_CATEGORIA_E = 'E';
+
+    const PATENTE_ABILITAZIONI_CQC = 1;
+    const PATENTE_ABILITAZIONI_CAP = 2;
+    const PATENTE_ABILITAZIONI_CFC = 3;
+
+    const DOCUMENTO_RILASCIATO_COMUNE = 1;
+    const DOCUMENTO_RILASCIATO_MOTORIZZAZIONE_CIVILE = 2;
+    const DOCUMENTO_RILASCIATO_ALTRO = 3;
+    const DOCUMENTO_RILASCIATO_MCTC = 4;
+    const DOCUMENTO_RILASCIATO_MIT = 5;
+    const DOCUMENTO_RILASCIATO_UCO = 6;
+    const DOCUMENTO_RILASCIATO_PREFETTURA = 7;
+
+    const PATENTE_PRESCRIZIONI_OBBLIGO_LENTI = 1;
+    const PATENTE_PRESCRIZIONI_APPARECCHIO_ACUSTICO = 2;
+    const PATENTE_PRESCRIZIONI_LIMITAZIONI_ART_117 = 3;
+
+    const PROTOCOLLO_NUM_LENGTH = 3;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $title = 'Prefettura';
+
+    public $from, $to;
+
+    public function mount()
+    {
+        // Initialize $from with today's date in Y-m-d format
+        $this->from = now()->format('Y-m-d');
+    }
+
+    protected $rules = [
+        'from' => 'required',
+        'to' => 'required',
+    ];
+
+    protected $messages = [
+        'from.required' => 'La data inizio è obbligatoria',
+        'to.required' => 'La data fine è obbligatoria',
+    ];
+
+    public function resetFields()
+    {
+        $this->from = '';
+        $this->to = '';
+    }
+
+    public function render()
+    {
+        return view('livewire.prefettura');
+    }
+
+    public function export()
+    {
+        Log::info('Export file prefettura');
+        Log::info('From: ' . $this->from);
+        Log::info('To: ' . $this->to);
+        try {
+            $items =  \DB::table('fcf_reports_reports')
+                ->leftjoin('fcf_users', 'fcf_reports_reports.created_by', '=', 'fcf_users.id')
+                ->selectRaw('fcf_reports_reports.*, CONCAT(fcf_users.firstname," ",fcf_users.lastname) AS display_name')
+                ->where(function ($query) {
+                    $query->where('fcf_reports_reports.incidente_con_feriti', '1')
+                        ->orWhere('fcf_reports_reports.incidente_mortale', '=', '1');
+                })
+                ->where('fcf_reports_reports.verificatosi_in_data', '>=', $this->from != '' ? $this->from : '2000-01-01')
+                ->where('fcf_reports_reports.verificatosi_in_data', '<=', $this->to != '' ? $this->to : '2050-01-01')
+                ->orderBy('fcf_reports_reports.verificatosi_in_data')
+                ->get();
+
+            Log::info('Items: ' . count($items));
+
+            $spreadsheet = new Spreadsheet();
+            $activeWorksheet = $spreadsheet->getActiveSheet();
+
+            $activeWorksheet->setCellValue('A1', "IDIncidenti");
+            $activeWorksheet->setCellValue('B1', "Data");
+            $activeWorksheet->setCellValue('C1', "Ora");
+            $activeWorksheet->setCellValue('D1', "IDProv");
+            $activeWorksheet->setCellValue('E1', "IDCom");
+            $activeWorksheet->setCellValue('F1', "IDTipoIncidente");
+            $activeWorksheet->setCellValue('G1', "IDTipoStrada");
+            $activeWorksheet->setCellValue('H1', "CentroAbitato");
+            $activeWorksheet->setCellValue('I1', "IDPolizia");
+            $activeWorksheet->setCellValue('J1', "IDCaratteristiche");
+            $activeWorksheet->setCellValue('K1', "CantiereStradale");
+            $activeWorksheet->setCellValue('L1', "N_Autovettura");
+            $activeWorksheet->setCellValue('M1', "N_Autocarro fino 3,5t");
+            $activeWorksheet->setCellValue('N1', "N_Autocarro > 3,5t");
+            $activeWorksheet->setCellValue('O1', "N_Autotreno");
+            $activeWorksheet->setCellValue('P1', "N_Autoarticolato");
+            $activeWorksheet->setCellValue('Q1', "N_Autobus");
+            $activeWorksheet->setCellValue('R1', "N_Tram");
+            $activeWorksheet->setCellValue('S1', "N_Treno");
+            $activeWorksheet->setCellValue('T1', "N_Motociclo");
+            $activeWorksheet->setCellValue('U1', "N_Ciclomotore");
+            $activeWorksheet->setCellValue('V1', "N_Velocipede");
+            $activeWorksheet->setCellValue('W1', "N_Bicicletta a pedala assistita");
+            $activeWorksheet->setCellValue('X1', "N_Monopattini elettrici");
+            $activeWorksheet->setCellValue('Y1', "N_Altri dispositivi micromobilita'");
+            $activeWorksheet->setCellValue('Z1', "N_AltrIVeicoli");
+            $activeWorksheet->setCellValue('AA1', "Trasportanti merci pericolose");
+            $activeWorksheet->setCellValue('AB1', "N_Pedoni");
+            $activeWorksheet->setCellValue('AC1', "N_Deceduti");
+            $activeWorksheet->setCellValue('AD1', "N_Feriti");
+            $activeWorksheet->setCellValue('AE1', "Numero Nome Strada");
+            $activeWorksheet->setCellValue('AF1', "KM");
+            $activeWorksheet->setCellValue('AG1', "Metri");
+            $activeWorksheet->setCellValue('AH1', "Carreggiata");
+            $activeWorksheet->setCellValue('AI1', "Omissione");
+            $activeWorksheet->setCellValue('AJ1', "Contromano");
+            $activeWorksheet->setCellValue('AK1', "DettaglioPersone");
+            $activeWorksheet->setCellValue('AL1', "idPositivita");
+            $activeWorksheet->setCellValue('AM1', "ArtCds");
+            $activeWorksheet->setCellValue('AN1', "Coordinata X");
+            $activeWorksheet->setCellValue('AO1', "Coordinata Y");
+               
+
+            $activeWorksheet->getStyle('A1:AO1')->getFont()->setBold(true);
+
+            // Character counting variables
+            $charCounts = [];
+            $sectionCounts = [];
+            $idx = 2;
+            foreach ($items as $item) {
+
+                try {
+                    Log::info('Item: ' . $item->id);
+                    $report = \App\Models\Report::findOrFail($item->id);
+
+                    //$activeWorksheet->setCellValue('A' . $idx, str_pad($report->protocollo_num, 3, '0', STR_PAD_LEFT) . "/" . date('Y', strtotime($item->verificatosi_in_data)));
+                    $activeWorksheet->setCellValue('A' . $idx, $item->id);
+                    $activeWorksheet->setCellValue('B' . $idx, date('d/m/Y', strtotime($item->verificatosi_in_data)));
+                    $activeWorksheet->setCellValue('C' . $idx, $item->verificatosi_in_data_ora . ":" . $item->verificatosi_in_data_minuti);
+                    $town_code = $prov_code = '000';
+                    $town = \App\Models\LocationTown::findOrFail($item->localita_uno);
+                    if ($town) {
+                        if ($town->istat_code) $town_code = $town->istat_code;
+                        $prov = \App\Models\LocationProvince::where('code', $town->prov)->first();
+                        if ($prov && $prov->istat_code) $prov_code = $prov->istat_code;
+                    }
+                    $activeWorksheet->setCellValue('D' . $idx, $prov_code);
+                    $activeWorksheet->setCellValue('E' . $idx, $town_code);
+                    $activeWorksheet->setCellValue('F' . $idx, "???");
+                    $tipo_strada = ' ';
+                    $types_saved = \App\Models\ReportTipoStrada::where('report_id', $report->id)
+                        ->pluck('tipo_strada_id')
+                        ->toArray();
+
+                    if (!empty($types_saved)) {
+                        if (in_array(3, $types_saved) && in_array(1, $types_saved))
+                            $tipo_strada = 1;
+                        elseif (in_array(3, $types_saved) && (in_array(11, $types_saved) || in_array(2, $types_saved)))
+                            $tipo_strada = 2;
+                        elseif (in_array(4, $types_saved))
+                            $tipo_strada = 3;
+                    }
+                    $activeWorksheet->setCellValue('G' . $idx, $tipo_strada);
+
+                    if ($report->localizzazione_incidente == Prefettura::LOCALIZZAZIONE_INCIDENTE_IN) {
+                        switch ($report->nomenclatura_strada) {
+                            case 2:
+                                $loc = 2;
+                                break;
+                            case 3:
+                                $loc = 0;
+                                break;
+                            case 4:
+                                $loc = 3;
+                                break;
+                            default:
+                                $loc = 1;
+                        }
+                    } elseif ($report->localizzazione_incidente == Prefettura::LOCALIZZAZIONE_INCIDENTE_OUT) {
+                        switch ($report->nomenclatura_strada) {
+                            case 2:
+                                $loc = 5;
+                                break;
+                            case 3:
+                                $loc = 9;
+                                break;
+                            case 4:
+                                $loc = 6;
+                                break;
+                            default:
+                                $loc = 4;
+                        }
+                    } else $loc = ' ';
+                    
+                    $activeWorksheet->setCellValue('H' . $idx, $loc);
+
+                    $int = ' ';
+                    switch ($report->particolarita_strada) {
+                        case 1:
+                            $int = '07';
+                            break;
+                        case 2:
+                            $int = '01';
+                            break;
+                        case 3:
+                            $int = '08';
+                            break;
+                        case 4:
+                            $int = '02';
+                            break;
+                        case 5:
+                            $int = '10';
+                            break;
+                        case 6:
+                        case 10:
+                            $int = '09';
+                            break;
+                        case 7:
+                            $int = '06';
+                            break;
+                        case 12:
+                            $int = '04';
+                            break;
+                    }
+                    
+                    $activeWorksheet->setCellValue('I' . $idx, $int);
+                    $activeWorksheet->setCellValue('J' . $idx, $report->condizione_strada == 2 ? "S" : "N");
+                    $activeWorksheet->setCellValue('K' . $idx, "N");
+
+                    $deceduti = 0;
+                    $feriti = 0;
+                    $pedoni = 0;
+
+                    $autovetture = 0;
+                    $autotreno = 0;
+                    $autoarticolato = 0;
+                    $autobus = 0;
+                    $tram = 0;
+                    $treno = 0;
+                    $motociclo = 0;
+                    $ciclomotore = 0;
+                    $velocipede = 0;
+                    $bicicletta = 0;
+                    $monopattino = 0;
+                    $altri_micro = 0;
+                    $altri = 0;
+
+                    $data_veicoli = \App\Models\ReportDataVeicoli::where('report_id', $report->id)->get()->toArray();
+
+                    for ($i = 0; $i < 3; $i++) {
+                        $data_veicolo = isset($data_veicoli[$i]) ? $data_veicoli[$i] : false;
+                        if ($data_veicolo) 
+                        {
+                            if ($data_veicolo["veicoli"] > 0) 
+                            {
+                                $veicolo = \App\Models\Vehicle::findOrFail($data_veicolo["veicoli"]);
+                                switch ($veicolo->tipo_id) {
+                                    case \App\Models\Vehicle::AUTOVETTURA:
+                                        $autovetture += 1;
+                                        break;
+                                    case \App\Models\Vehicle::CICLO_MOTORE:
+                                        $ciclomotore += 1;
+                                        break;
+                                    case \App\Models\Vehicle::QUADRICICLO:
+                                        $altri += 1;
+                                        break;
+                                    case \App\Models\Vehicle::MOTOCICLO:
+                                        $motociclo += 1;
+                                        break;
+                                    case \App\Models\Vehicle::VELOCIPEDE:
+                                        $velocipede += 1;
+                                        break;
+                                    case \App\Models\Vehicle::AUTOBUS:
+                                        $autobus += 1;
+                                        break;
+                                    case \App\Models\Vehicle::TRATTORE_SEMIRIMORCHIO:
+                                        $altri += 1;
+                                        break;
+                                    case \App\Models\Vehicle::AUTOTURISMO:
+                                        $autobus += 1;
+                                        break;
+                                    case \App\Models\Vehicle::RIMORCHIO:
+                                        $altri += 1;
+                                        break;
+                                    case \App\Models\Vehicle::AUTOCARRO:
+                                        $altri += 1;
+                                        break;
+                                    case \App\Models\Vehicle::AUTOVETTURA_CON_RIMORCHIO:
+                                        $autovetture += 1;
+                                        break;
+                                    case \App\Models\Vehicle::AUTOSNODATO_O_AUTOARTICOLATO:
+                                        $autotreno += 1;
+                                        break;
+                                    case \App\Models\Vehicle::MOTOCARRO_O_MOTOFURGONE:
+                                        $motociclo += 1;
+                                        break;
+                                    case \App\Models\Vehicle::AUTOTRENO_CON_RIMORCHIO:
+                                        $autotreno += 1;
+                                        break;
+                                }
+                                                                
+                            }
+                            switch ($data_veicolo["infortunato"]) {
+                                case Prefettura::INFORTUNATO_DECEDUTO_30GG:
+                                    $deceduti += 1;
+                                    break;
+                                case Prefettura::INFORTUNATO_DECEDUTO_24H:
+                                    $deceduti += 1;
+                                    break;
+                                case Prefettura::INFORTUNATO_FERITO:
+                                    $feriti += 1;
+                                    break;
+                            }
+                        }
+                    }
+
+                    $datiPedoni = ReportDataPedoni::where('report_id', $report->id)->get()->toArray();
+                    for ($j = 0; $j < 4; $j++) {
+
+                        $pedone_data = str_repeat(' ', 6);
+
+                        if (isset($datiPedoni[$j])) {
+                            $pedoni += 1;
+                        }
+                    }
+
+                    $activeWorksheet->setCellValue('L' . $idx, $autovetture);
+                    $activeWorksheet->setCellValue('M' . $idx, "0");
+                    $activeWorksheet->setCellValue('N' . $idx, "0");
+                    $activeWorksheet->setCellValue('O' . $idx, $autotreno);
+                    $activeWorksheet->setCellValue('P' . $idx, $autoarticolato);
+                    $activeWorksheet->setCellValue('Q' . $idx, $autobus);
+                    $activeWorksheet->setCellValue('R' . $idx, $tram);
+                    $activeWorksheet->setCellValue('S' . $idx, $treno);
+                    $activeWorksheet->setCellValue('T' . $idx, $motociclo);
+                    $activeWorksheet->setCellValue('U' . $idx, $ciclomotore);
+                    $activeWorksheet->setCellValue('V' . $idx, $velocipede);
+                    $activeWorksheet->setCellValue('W' . $idx, $bicicletta);
+                    $activeWorksheet->setCellValue('X' . $idx, $monopattino);
+                    $activeWorksheet->setCellValue('Y' . $idx, $altri_micro);
+                    $activeWorksheet->setCellValue('Z' . $idx, $altri);
+
+                    $activeWorksheet->setCellValue('AA' . $idx, "???");
+
+                    $activeWorksheet->setCellValue('AB' . $idx, $pedoni);
+                    $activeWorksheet->setCellValue('AC' . $idx, $deceduti);
+                    $activeWorksheet->setCellValue('AD' . $idx, $feriti);
+
+                    $stradario_due = \App\Models\Stradario::find($report->localita_due);
+                    $location_description = $stradario_due ?
+                        (($stradario_due['TOPONIMO'] ?? '') . ' ' . ($stradario_due['DESCRIZIONE'] ?? '')) :
+                        '';
+
+                    $activeWorksheet->setCellValue('AE' . $idx, $location_description);
+
+                    $km = '';
+                    $metri = '';
+                    if ($report->prossimita_chilometro != '')
+                    {
+                        try
+                        {
+                            list($km, $metri) = explode("+", $report->prossimita_chilometro);
+                        } catch (\Exception $ex) {
+                    
+                        }
+                        try
+                        {
+                            list($km, $metri) = explode(".", $report->prossimita_chilometro);
+                        } catch (\Exception $ex) {
+                    
+                        }
+                        try
+                        {
+                            list($km, $metri) = explode(",", $report->prossimita_chilometro);
+                        } catch (\Exception $ex) {
+                    
+                        }
+                    }
+
+                    $activeWorksheet->setCellValue('AF' . $idx, $km);
+                    $activeWorksheet->setCellValue('AG' . $idx, $metri);
+                    $activeWorksheet->setCellValue('AH' . $idx, "");
+                    $activeWorksheet->setCellValue('AI' . $idx, "");
+                    $activeWorksheet->setCellValue('AJ' . $idx, "");
+                    $activeWorksheet->setCellValue('AK' . $idx, "???");
+                    $activeWorksheet->setCellValue('AL' . $idx, "???");
+                    $activeWorksheet->setCellValue('AM' . $idx, $report->cds);
+                    $activeWorksheet->setCellValue('AN' . $idx, $item->latitude);
+                    $activeWorksheet->setCellValue('AO' . $idx, $item->longitude);
+
+                    $idx += 1;
+
+                } catch (\Exception $e) {
+                    Log::error('Error for item ' . $item->id . ': ' . $e->getMessage());                    
+                }
+                
+            }
+
+            $writer = new Xlsx($spreadsheet);
+            $writer->save($path = storage_path('prefettura' . date("YmdHis") . '.xlsx'));
+            return response()->download($path)->deleteFileAfterSend();
+            
+        } catch (\Exception $e) {
+            Log::error('Fatal error in export: ' . $e->getMessage());
+            return response()->json(['error' => 'Export failed: ' . $e->getMessage()], 500);
+        }
+    }
+}

+ 13 - 4
app/Http/Livewire/Traits/HasAnagrafica.php

@@ -51,6 +51,8 @@ trait HasAnagrafica{
     public $anag_foreign_residence_city;
     public $anag_residenza_tipo;
 
+    public $forceSet = true;
+
     public function editAnagrafica($anagrafica)
     {
         $this->resetAnagrafica();
@@ -302,9 +304,14 @@ trait HasAnagrafica{
                 $this->emit('add-default-value', $this->data_conducenti, $this->getAnagrafica($this->data_conducenti), 'data_conducenti');
             }
 
-            if ($this->currentProgressive > -1 && !$set){
+            if ($this->currentProgressive > -1 && !$set && $this->forceSet){
                 $this->updateAnagraficaParteCoinvolta($anagrafica->id, $this->currentProgressive);
             }
+            else
+            {
+                if (!$this->forceSet)
+                    $this->emit('add-default-value', $anagrafica->id, $this->getAnagrafica($anagrafica->id), 'richiestaAnagrafica');
+            }
 
         }
         $this->resetAnagrafica();
@@ -549,8 +556,9 @@ trait HasAnagrafica{
         }
     }
 
-    public function addAnagrafica($progressive) {
+    public function addAnagrafica($progressive, $forceSet = true) {
         $this->resetAnagrafica();
+        $this->forceSet = $forceSet;
         $this->currentProgressive = $progressive;
         $this->emit('load-anagrafica-modal');
     }
@@ -560,9 +568,9 @@ trait HasAnagrafica{
         {
             $ret = \App\Models\Anagrafica::findOrFail($anagrafica);
             if($ret->type == 0)
-            return $ret->lastname . " " . $ret->firstname;
+                return $ret->lastname . " " . $ret->firstname;
             else
-            return $ret->rag_soc;
+                return $ret->rag_soc;
         }
         return "";
     }
@@ -615,5 +623,6 @@ trait HasAnagrafica{
         $this->anag_sede_legale_cap = '';
         $this->anag_phone = '';
         $this->anag_residenza_tipo = '';
+        $this->forceSet = true;
     }
 }

+ 15 - 0
app/Models/Vehicle.php

@@ -24,6 +24,21 @@ class Vehicle extends Model
     const DESTINAZIONE_USO_PUBBLICO = 8;
     const DESTINAZIONE_USO_SOCCORSO_POLIZIA = 9;
 
+    const AUTOVETTURA = 1;
+    const CICLO_MOTORE = 3;
+    const QUADRICICLO = 4;
+    const MOTOCICLO = 5;
+    const VELOCIPEDE = 6;
+    const AUTOBUS = 7;
+    const TRATTORE_SEMIRIMORCHIO = 8;
+    const AUTOTURISMO = 10;
+    const RIMORCHIO = 14;
+    const AUTOCARRO = 16;
+    const AUTOVETTURA_CON_RIMORCHIO = 17;
+    const AUTOSNODATO_O_AUTOARTICOLATO = 18;
+    const MOTOCARRO_O_MOTOFURGONE = 19;
+    const AUTOTRENO_CON_RIMORCHIO = 20;
+
     use HasFactory;
 
     public $timestamps = false;

+ 2 - 1
composer.json

@@ -11,7 +11,8 @@
         "laravel/framework": "^10.10",
         "laravel/sanctum": "^3.2",
         "laravel/tinker": "^2.8",
-        "livewire/livewire": "^2.12"
+        "livewire/livewire": "^2.12",
+        "phpoffice/phpspreadsheet": "^5.1"
     },
     "require-dev": {
         "fakerphp/faker": "^1.9.1",

+ 374 - 4
composer.lock

@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "6028c7a30294b8ee4597779e5541615d",
+    "content-hash": "85dbbecbedf4b87cf959752691111ba4",
     "packages": [
         {
             "name": "barryvdh/laravel-dompdf",
@@ -138,6 +138,85 @@
             ],
             "time": "2023-01-15T23:15:59+00:00"
         },
+        {
+            "name": "composer/pcre",
+            "version": "3.3.2",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/composer/pcre.git",
+                "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e",
+                "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e",
+                "shasum": ""
+            },
+            "require": {
+                "php": "^7.4 || ^8.0"
+            },
+            "conflict": {
+                "phpstan/phpstan": "<1.11.10"
+            },
+            "require-dev": {
+                "phpstan/phpstan": "^1.12 || ^2",
+                "phpstan/phpstan-strict-rules": "^1 || ^2",
+                "phpunit/phpunit": "^8 || ^9"
+            },
+            "type": "library",
+            "extra": {
+                "phpstan": {
+                    "includes": [
+                        "extension.neon"
+                    ]
+                },
+                "branch-alias": {
+                    "dev-main": "3.x-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Composer\\Pcre\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Jordi Boggiano",
+                    "email": "j.boggiano@seld.be",
+                    "homepage": "http://seld.be"
+                }
+            ],
+            "description": "PCRE wrapping library that offers type-safe preg_* replacements.",
+            "keywords": [
+                "PCRE",
+                "preg",
+                "regex",
+                "regular expression"
+            ],
+            "support": {
+                "issues": "https://github.com/composer/pcre/issues",
+                "source": "https://github.com/composer/pcre/tree/3.3.2"
+            },
+            "funding": [
+                {
+                    "url": "https://packagist.com",
+                    "type": "custom"
+                },
+                {
+                    "url": "https://github.com/composer",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/composer/composer",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2024-11-12T16:29:46+00:00"
+        },
         {
             "name": "dflydev/dot-access-data",
             "version": "v3.0.2",
@@ -2020,6 +2099,191 @@
             ],
             "time": "2023-08-11T04:02:34+00:00"
         },
+        {
+            "name": "maennchen/zipstream-php",
+            "version": "3.2.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/maennchen/ZipStream-PHP.git",
+                "reference": "9712d8fa4cdf9240380b01eb4be55ad8dcf71416"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/9712d8fa4cdf9240380b01eb4be55ad8dcf71416",
+                "reference": "9712d8fa4cdf9240380b01eb4be55ad8dcf71416",
+                "shasum": ""
+            },
+            "require": {
+                "ext-mbstring": "*",
+                "ext-zlib": "*",
+                "php-64bit": "^8.3"
+            },
+            "require-dev": {
+                "brianium/paratest": "^7.7",
+                "ext-zip": "*",
+                "friendsofphp/php-cs-fixer": "^3.16",
+                "guzzlehttp/guzzle": "^7.5",
+                "mikey179/vfsstream": "^1.6",
+                "php-coveralls/php-coveralls": "^2.5",
+                "phpunit/phpunit": "^12.0",
+                "vimeo/psalm": "^6.0"
+            },
+            "suggest": {
+                "guzzlehttp/psr7": "^2.4",
+                "psr/http-message": "^2.0"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "ZipStream\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Paul Duncan",
+                    "email": "pabs@pablotron.org"
+                },
+                {
+                    "name": "Jonatan Männchen",
+                    "email": "jonatan@maennchen.ch"
+                },
+                {
+                    "name": "Jesse Donat",
+                    "email": "donatj@gmail.com"
+                },
+                {
+                    "name": "András Kolesár",
+                    "email": "kolesar@kolesar.hu"
+                }
+            ],
+            "description": "ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.",
+            "keywords": [
+                "stream",
+                "zip"
+            ],
+            "support": {
+                "issues": "https://github.com/maennchen/ZipStream-PHP/issues",
+                "source": "https://github.com/maennchen/ZipStream-PHP/tree/3.2.0"
+            },
+            "funding": [
+                {
+                    "url": "https://github.com/maennchen",
+                    "type": "github"
+                }
+            ],
+            "time": "2025-07-17T11:15:13+00:00"
+        },
+        {
+            "name": "markbaker/complex",
+            "version": "3.0.2",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/MarkBaker/PHPComplex.git",
+                "reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/95c56caa1cf5c766ad6d65b6344b807c1e8405b9",
+                "reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9",
+                "shasum": ""
+            },
+            "require": {
+                "php": "^7.2 || ^8.0"
+            },
+            "require-dev": {
+                "dealerdirect/phpcodesniffer-composer-installer": "dev-master",
+                "phpcompatibility/php-compatibility": "^9.3",
+                "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
+                "squizlabs/php_codesniffer": "^3.7"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Complex\\": "classes/src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Mark Baker",
+                    "email": "mark@lange.demon.co.uk"
+                }
+            ],
+            "description": "PHP Class for working with complex numbers",
+            "homepage": "https://github.com/MarkBaker/PHPComplex",
+            "keywords": [
+                "complex",
+                "mathematics"
+            ],
+            "support": {
+                "issues": "https://github.com/MarkBaker/PHPComplex/issues",
+                "source": "https://github.com/MarkBaker/PHPComplex/tree/3.0.2"
+            },
+            "time": "2022-12-06T16:21:08+00:00"
+        },
+        {
+            "name": "markbaker/matrix",
+            "version": "3.0.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/MarkBaker/PHPMatrix.git",
+                "reference": "728434227fe21be27ff6d86621a1b13107a2562c"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/728434227fe21be27ff6d86621a1b13107a2562c",
+                "reference": "728434227fe21be27ff6d86621a1b13107a2562c",
+                "shasum": ""
+            },
+            "require": {
+                "php": "^7.1 || ^8.0"
+            },
+            "require-dev": {
+                "dealerdirect/phpcodesniffer-composer-installer": "dev-master",
+                "phpcompatibility/php-compatibility": "^9.3",
+                "phpdocumentor/phpdocumentor": "2.*",
+                "phploc/phploc": "^4.0",
+                "phpmd/phpmd": "2.*",
+                "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
+                "sebastian/phpcpd": "^4.0",
+                "squizlabs/php_codesniffer": "^3.7"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Matrix\\": "classes/src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Mark Baker",
+                    "email": "mark@demon-angel.eu"
+                }
+            ],
+            "description": "PHP Class for working with matrices",
+            "homepage": "https://github.com/MarkBaker/PHPMatrix",
+            "keywords": [
+                "mathematics",
+                "matrix",
+                "vector"
+            ],
+            "support": {
+                "issues": "https://github.com/MarkBaker/PHPMatrix/issues",
+                "source": "https://github.com/MarkBaker/PHPMatrix/tree/3.0.1"
+            },
+            "time": "2022-12-02T22:17:43+00:00"
+        },
         {
             "name": "masterminds/html5",
             "version": "2.8.1",
@@ -2671,6 +2935,112 @@
             },
             "time": "2022-09-06T12:16:56+00:00"
         },
+        {
+            "name": "phpoffice/phpspreadsheet",
+            "version": "5.1.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
+                "reference": "fd26e45a814e94ae2aad0df757d9d1739c4bf2e0"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/fd26e45a814e94ae2aad0df757d9d1739c4bf2e0",
+                "reference": "fd26e45a814e94ae2aad0df757d9d1739c4bf2e0",
+                "shasum": ""
+            },
+            "require": {
+                "composer/pcre": "^1||^2||^3",
+                "ext-ctype": "*",
+                "ext-dom": "*",
+                "ext-fileinfo": "*",
+                "ext-gd": "*",
+                "ext-iconv": "*",
+                "ext-libxml": "*",
+                "ext-mbstring": "*",
+                "ext-simplexml": "*",
+                "ext-xml": "*",
+                "ext-xmlreader": "*",
+                "ext-xmlwriter": "*",
+                "ext-zip": "*",
+                "ext-zlib": "*",
+                "maennchen/zipstream-php": "^2.1 || ^3.0",
+                "markbaker/complex": "^3.0",
+                "markbaker/matrix": "^3.0",
+                "php": "^8.1",
+                "psr/http-client": "^1.0",
+                "psr/http-factory": "^1.0",
+                "psr/simple-cache": "^1.0 || ^2.0 || ^3.0"
+            },
+            "require-dev": {
+                "dealerdirect/phpcodesniffer-composer-installer": "dev-main",
+                "dompdf/dompdf": "^2.0 || ^3.0",
+                "friendsofphp/php-cs-fixer": "^3.2",
+                "mitoteam/jpgraph": "^10.3",
+                "mpdf/mpdf": "^8.1.1",
+                "phpcompatibility/php-compatibility": "^9.3",
+                "phpstan/phpstan": "^1.1 || ^2.0",
+                "phpstan/phpstan-deprecation-rules": "^1.0 || ^2.0",
+                "phpstan/phpstan-phpunit": "^1.0 || ^2.0",
+                "phpunit/phpunit": "^10.5",
+                "squizlabs/php_codesniffer": "^3.7",
+                "tecnickcom/tcpdf": "^6.5"
+            },
+            "suggest": {
+                "dompdf/dompdf": "Option for rendering PDF with PDF Writer",
+                "ext-intl": "PHP Internationalization Functions",
+                "mitoteam/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers",
+                "mpdf/mpdf": "Option for rendering PDF with PDF Writer",
+                "tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Maarten Balliauw",
+                    "homepage": "https://blog.maartenballiauw.be"
+                },
+                {
+                    "name": "Mark Baker",
+                    "homepage": "https://markbakeruk.net"
+                },
+                {
+                    "name": "Franck Lefevre",
+                    "homepage": "https://rootslabs.net"
+                },
+                {
+                    "name": "Erik Tilt"
+                },
+                {
+                    "name": "Adrien Crivelli"
+                }
+            ],
+            "description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine",
+            "homepage": "https://github.com/PHPOffice/PhpSpreadsheet",
+            "keywords": [
+                "OpenXML",
+                "excel",
+                "gnumeric",
+                "ods",
+                "php",
+                "spreadsheet",
+                "xls",
+                "xlsx"
+            ],
+            "support": {
+                "issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues",
+                "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/5.1.0"
+            },
+            "time": "2025-09-04T05:34:49+00:00"
+        },
         {
             "name": "phpoption/phpoption",
             "version": "1.9.1",
@@ -8416,12 +8786,12 @@
     ],
     "aliases": [],
     "minimum-stability": "stable",
-    "stability-flags": [],
+    "stability-flags": {},
     "prefer-stable": true,
     "prefer-lowest": false,
     "platform": {
         "php": "^8.1"
     },
-    "platform-dev": [],
-    "plugin-api-version": "2.3.0"
+    "platform-dev": {},
+    "plugin-api-version": "2.6.0"
 }

+ 4 - 4
resources/views/components/report/modifica/header.blade.php

@@ -2,16 +2,16 @@
     <div class="card-tools row" style="margin-right: -25px;">
         <div class="col d-flex align-items-center">
             @if (!$this->validated)
-                <button type="submit" class="btn btn-primary" wire:click.prevent="update(true)">Valida&nbsp;verbale</button>
+                <button type="button" class="btn btn-primary" wire:click.prevent="update(true)">Valida&nbsp;verbale</button>
             @elseif($this->isAdmin)
-            <button type="submit" class="btn btn-primary" wire:click.prevent="invalidateVerbale()">Revoca&nbsp;validazione</button>
+            <button type="button" class="btn btn-primary" wire:click.prevent="invalidateVerbale()">Revoca&nbsp;validazione</button>
             @else
                 <span class="text-center w-100">VALIDATO</span>
             @endif
         </div>
         <div class="col">
-            <button type="submit" class="btn btn-block btn-success float-right" wire:click.prevent="update(false, true)" onclick="printReport({{$this->dataId}})">Stampa</button>            
-            <button type="submit" class="btn btn-block btn-success float-right" wire:click.prevent="update(false, true)" onclick="printPartiCoinvolte({{$this->dataId}})">Parti coinvolte</button>            
+            <button type="button" class="btn btn-block btn-success float-right" wire:click.prevent="update(false, true)" onclick="printReport({{$this->dataId}})">Stampa</button>            
+            <button type="button" class="btn btn-block btn-success float-right" wire:click.prevent="update(false, true)" onclick="printPartiCoinvolte({{$this->dataId}})">Parti coinvolte</button>            
         </div>
     </div>
 </div>

+ 13 - 6
resources/views/components/report/protocollo/richieste.blade.php

@@ -45,12 +45,19 @@
             <div class="col-sm-4">
                 <div class="form-group">
                     <label>Richiedente</label>
-                    <select
-                        class="form-control richiestaAnagrafica @error('richiestaAnagrafica') is-invalid @enderror"
-                        style="width:100%">
-                        <option value="{{ $richiestaAnagrafica }}">
-                            {{ $this->getAnagrafica($richiestaAnagrafica) }}
-                    </select>
+                    <div class="row">
+                        <div class="col-10">
+                            <select
+                                class="form-control richiestaAnagrafica @error('richiestaAnagrafica') is-invalid @enderror"
+                                style="width:100%">
+                                <option value="{{ $richiestaAnagrafica }}">
+                                    {{ $this->getAnagrafica($richiestaAnagrafica) }}
+                            </select>
+                        </div>
+                        <div class="col-2">
+                            <a class="btn btn-primary" wire:click.prevent="addAnagrafica(0, false)" data-toggle="modal" data-target="#anagraficaParte">+&nbsp;</a>
+                        </div>
+                    </div>
                 </div>
             </div>
             <div class="col-sm-4">

+ 10 - 0
resources/views/components/verbale/intestazione/index_pc.blade.php

@@ -0,0 +1,10 @@
+<table width="100%">
+    <tr>
+        <td style='width:70%'>
+            Protocollo n.{{ str_pad( @$data['record']->protocollo_num , 3, '0', STR_PAD_LEFT) }}/ {{ @$data['record']->protocollo_anno }}
+        </td>
+        <td class="pt-0 mt-0" style='width:30%;'>
+            <h5>Comm. coor. Francesco Marozza</h3>
+        </td>
+    </tr>
+</table>

+ 7 - 0
resources/views/layouts/app.blade.php

@@ -96,6 +96,13 @@
               </p>
             </a>
           </li>
+          <li class="nav-item">
+            <a href="/prefettura" class="nav-link">
+              <i class="nav-icon fas fa-copy"></i>
+              <p>Prefettura
+              </p>
+            </a>
+          </li>
           <li class="nav-item">
             <a href="#" class="nav-link">
               <i class="nav-icon fas fa-table"></i>

+ 48 - 0
resources/views/livewire/prefettura.blade.php

@@ -0,0 +1,48 @@
+<div class="m-3">
+
+    <div class="row mb-3">
+        <div class="col-6">
+            <h2>{{$title}}</h2>
+        </div>
+    </div>
+
+    <div class="card card-primary">
+
+        <form>
+
+            <div class="card-header">
+                <h3 class="card-title"><b>Seleziona un intervallo di date per esportare il file della prefettura relativo ai
+                        sinistri del periodo.</b></h3>
+            </div>
+
+            <div class="card-body">
+                <div class="form-group">
+                    <div class="row">
+                        <div class="col-md-6">
+                            <label for="name">Dal</label>
+                            <input class="form-control @error('from') is-invalid @enderror" type="date" id="from"
+                                placeholder="Dal" wire:model="from">
+                            @error('from')
+                                <div class="invalid-feedback">{{ $message }}</div>
+                            @enderror
+                        </div>
+                        <div class="col-md-6">
+                            <label for="name">Al</label>
+                            <input class="form-control @error('to') is-invalid @enderror" type="date" id="to"
+                                placeholder="Dal" wire:model="to">
+                            @error('to')
+                                <div class="invalid-feedback">{{ $message }}</div>
+                            @enderror
+                        </div>
+                    </div>
+                </div>
+            </div>
+
+            <div class="card-footer">
+                <button type="submit" class="btn btn-primary" wire:click.prevent="export()">Esporta</button>
+                <button type="submit" class="btn btn-default" wire:click.prevent="cancel()">Annulla</button>
+            </div>
+        </form>
+    </div>
+
+</div>

+ 8 - 5
resources/views/pdf/parti_coinvolte.blade.php

@@ -74,7 +74,7 @@
 </style>
 
 <body>
-    <x-verbale.intestazione.index :data="$data" />
+    <x-verbale.intestazione.index_pc :data="$data" />
 
     <x-verbale.header.header :data="$data" />
 
@@ -101,7 +101,12 @@
         $vehicleNumber = 0;
     @endphp
 
-    @foreach ($vehicles as $parte)
+    @foreach ($vehicles as $idx => $parte)
+
+        @if($idx > 0)
+            <div class="page-break"></div>
+        @endif
+
         @php
             $datiVeicolo = $data['datiVeicolo'][$parte->progressive];
             $datiPasseggeri = App\Models\ReportDataPasseggeri::with('passeggero_value')
@@ -116,8 +121,6 @@
 
         @endphp
 
-        <div class="page-break"></div>
-
         <table width="100%">
             <tr>
                 <td width="100%" valign="top" align="center" style="border:none!important">
@@ -137,7 +140,7 @@
             <x-verbale.veicolo.assicurazione :datiVeicolo="$datiVeicolo" />
         @endif
 
-        <div class="page-break"></div>
+        
 
     @endforeach
 

+ 1 - 0
routes/web.php

@@ -118,6 +118,7 @@ Route::group(['middleware' => 'auth'],function(){
 
     Route::get('/reports', \App\Http\Livewire\Report::class);
     Route::get('/istat', \App\Http\Livewire\Istat::class);
+    Route::get('/prefettura', \App\Http\Livewire\Prefettura::class);
 
     Route::get('/print', Report::class);