Bläddra i källkod

full project init

FabioFratini 1 år sedan
förälder
incheckning
9caa0eba7c
100 ändrade filer med 9853 tillägg och 0 borttagningar
  1. BIN
      .DS_Store
  2. 18 0
      .editorconfig
  3. 72 0
      .env dev
  4. 59 0
      .env.example
  5. 11 0
      .gitattributes
  6. 19 0
      .gitignore
  7. BIN
      app/.DS_Store
  8. 27 0
      app/Console/Kernel.php
  9. 30 0
      app/Exceptions/Handler.php
  10. 23 0
      app/Helpers/DateHelper.php
  11. 10 0
      app/Helpers/PoliziaUtils.php
  12. BIN
      app/Http/.DS_Store
  13. 12 0
      app/Http/Controllers/Controller.php
  14. 68 0
      app/Http/Kernel.php
  15. BIN
      app/Http/Livewire/.DS_Store
  16. 112 0
      app/Http/Livewire/AccertatoreGrado.php
  17. 103 0
      app/Http/Livewire/AllegatiGalleryType.php
  18. 317 0
      app/Http/Livewire/Anagrafica.php
  19. 112 0
      app/Http/Livewire/AusilioAltriEnti.php
  20. 112 0
      app/Http/Livewire/Compagnia.php
  21. 112 0
      app/Http/Livewire/CondizioneStrada.php
  22. 116 0
      app/Http/Livewire/CondizioniAtmosferiche.php
  23. 116 0
      app/Http/Livewire/CondizioniLuce.php
  24. 15 0
      app/Http/Livewire/Dashboard.php
  25. 112 0
      app/Http/Livewire/EffettoDanno.php
  26. 112 0
      app/Http/Livewire/EntitaDanno.php
  27. 112 0
      app/Http/Livewire/FondoStradale.php
  28. 762 0
      app/Http/Livewire/Istat.php
  29. 112 0
      app/Http/Livewire/MarcaVeicolo.php
  30. 112 0
      app/Http/Livewire/MaterialeRecuperato.php
  31. 127 0
      app/Http/Livewire/ModelloVeicolo.php
  32. 112 0
      app/Http/Livewire/NomenclaturaStrada.php
  33. 112 0
      app/Http/Livewire/ParteMacchina.php
  34. 116 0
      app/Http/Livewire/ParticolaritaStrada.php
  35. 116 0
      app/Http/Livewire/PavimentazioneStrada.php
  36. 3444 0
      app/Http/Livewire/Report.php
  37. 112 0
      app/Http/Livewire/Rilievi.php
  38. 112 0
      app/Http/Livewire/SegnalazioneOrizzontale.php
  39. 116 0
      app/Http/Livewire/SegnalazionePervenutaDa.php
  40. 112 0
      app/Http/Livewire/SegnalazioneVerticale.php
  41. 120 0
      app/Http/Livewire/Stradario.php
  42. 112 0
      app/Http/Livewire/TipoDanno.php
  43. 112 0
      app/Http/Livewire/TipoSegnalazione.php
  44. 116 0
      app/Http/Livewire/TipoStrada.php
  45. 112 0
      app/Http/Livewire/TipoUrto.php
  46. 112 0
      app/Http/Livewire/TipoVeicolo.php
  47. 157 0
      app/Http/Livewire/User.php
  48. 17 0
      app/Http/Middleware/Authenticate.php
  49. 17 0
      app/Http/Middleware/EncryptCookies.php
  50. 17 0
      app/Http/Middleware/PreventRequestsDuringMaintenance.php
  51. 30 0
      app/Http/Middleware/RedirectIfAuthenticated.php
  52. 19 0
      app/Http/Middleware/TrimStrings.php
  53. 20 0
      app/Http/Middleware/TrustHosts.php
  54. 28 0
      app/Http/Middleware/TrustProxies.php
  55. 22 0
      app/Http/Middleware/ValidateSignature.php
  56. 17 0
      app/Http/Middleware/VerifyCsrfToken.php
  57. 19 0
      app/Models/AccertatoreGrado.php
  58. 20 0
      app/Models/AllegatiGalleryType.php
  59. 107 0
      app/Models/Anagrafica.php
  60. 19 0
      app/Models/AusilioAltriEnti.php
  61. 19 0
      app/Models/Compagnia.php
  62. 19 0
      app/Models/CondizioneStrada.php
  63. 20 0
      app/Models/CondizioniAtmosferiche.php
  64. 20 0
      app/Models/CondizioniLuce.php
  65. 19 0
      app/Models/EffettoDanno.php
  66. 19 0
      app/Models/EntitaDanno.php
  67. 19 0
      app/Models/FondoStradale.php
  68. 31 0
      app/Models/LocationCountry.php
  69. 22 0
      app/Models/LocationProvince.php
  70. 20 0
      app/Models/LocationRegion.php
  71. 30 0
      app/Models/LocationTown.php
  72. 20 0
      app/Models/MarcaModelloVeicolo.php
  73. 19 0
      app/Models/MarcaVeicolo.php
  74. 19 0
      app/Models/MaterialeRecuperato.php
  75. 43 0
      app/Models/ModelloVeicolo.php
  76. 19 0
      app/Models/NomenclaturaStrada.php
  77. 19 0
      app/Models/ParteMacchina.php
  78. 20 0
      app/Models/ParticolaritaStrada.php
  79. 20 0
      app/Models/PavimentazioneStrada.php
  80. 41 0
      app/Models/Polizza.php
  81. 300 0
      app/Models/Report.php
  82. 33 0
      app/Models/ReportAllegatiGallery.php
  83. 25 0
      app/Models/ReportAusilioAltriEnti.php
  84. 25 0
      app/Models/ReportCondizioniLuce.php
  85. 26 0
      app/Models/ReportDataCintureSicurezza.php
  86. 27 0
      app/Models/ReportDataInfortunati.php
  87. 39 0
      app/Models/ReportDataPartiCoinvolte.php
  88. 30 0
      app/Models/ReportDataPasseggeri.php
  89. 54 0
      app/Models/ReportDataPedoni.php
  90. 29 0
      app/Models/ReportDataTestimoniOculari.php
  91. 24 0
      app/Models/ReportDataUsoDelCasco.php
  92. 24 0
      app/Models/ReportDataUsoDelCascoOmologazione.php
  93. 128 0
      app/Models/ReportDataVeicoli.php
  94. 25 0
      app/Models/ReportMaterialeRecuperato.php
  95. 22 0
      app/Models/ReportProtocolloNote.php
  96. 26 0
      app/Models/ReportRichiesta.php
  97. 25 0
      app/Models/ReportSegnalazionePervenutaDa.php
  98. 25 0
      app/Models/ReportSegnaleticaOrizzontale1.php
  99. 25 0
      app/Models/ReportSegnaleticaOrizzontale2.php
  100. 25 0
      app/Models/ReportSegnaleticaOrizzontale3.php

BIN
.DS_Store


+ 18 - 0
.editorconfig

@@ -0,0 +1,18 @@
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+indent_size = 4
+indent_style = space
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.md]
+trim_trailing_whitespace = false
+
+[*.{yml,yaml}]
+indent_size = 2
+
+[docker-compose.yml]
+indent_size = 4

+ 72 - 0
.env dev

@@ -0,0 +1,72 @@
+APP_NAME=Polizia
+APP_ENV=local
+APP_KEY=base64:1YsMWZ+cIDVa5NIePkjsXVheT9rbykHDs/CnGPUQdqU=
+APP_DEBUG=true
+APP_URL=http://frascati.dev.webmagistri.biz
+
+LOG_CHANNEL=stack
+LOG_DEPRECATIONS_CHANNEL=null
+LOG_LEVEL=debug
+
+DB_CONNECTION=mysql
+DB_HOST=127.0.0.1
+DB_PORT=3306
+DB_DATABASE=polizia_online
+DB_USERNAME=admin
+DB_PASSWORD=admin
+
+BROADCAST_DRIVER=log
+CACHE_DRIVER=file
+FILESYSTEM_DISK=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=mailpit
+MAIL_PORT=1025
+MAIL_USERNAME=null
+MAIL_PASSWORD=null
+MAIL_ENCRYPTION=null
+MAIL_FROM_ADDRESS="hello@example.com"
+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_HOST=
+PUSHER_PORT=443
+PUSHER_SCHEME=https
+PUSHER_APP_CLUSTER=mt1
+
+VITE_APP_NAME="${APP_NAME}"
+VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
+VITE_PUSHER_HOST="${PUSHER_HOST}"
+VITE_PUSHER_PORT="${PUSHER_PORT}"
+VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
+VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
+
+#MCTC_URL=https://e-servizicoll.dtt.ilportaledellautomobilista.it/Info-ws-sh/services
+MCTC_URL=https://www.ilportaledellautomobilista.it/Info-ws/services
+#MCTC_USER=PRFR000191
+#MCTC_PASSWORD=TEST.001
+#MCTC_USER=CMRM001301
+#MCTC_PASSWORD=2PMPM*71
+#MCTC_USER=CMLT001801
+#MCTC_PASSWORD=Giuse24?
+MCTC_USER=CMRM001301
+MCTC_PASSWORD=2PMPM*86
+
+STORAGE_PATH=app/public/

+ 59 - 0
.env.example

@@ -0,0 +1,59 @@
+APP_NAME=Laravel
+APP_ENV=local
+APP_KEY=
+APP_DEBUG=true
+APP_URL=http://localhost
+
+LOG_CHANNEL=stack
+LOG_DEPRECATIONS_CHANNEL=null
+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_DISK=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=mailpit
+MAIL_PORT=1025
+MAIL_USERNAME=null
+MAIL_PASSWORD=null
+MAIL_ENCRYPTION=null
+MAIL_FROM_ADDRESS="hello@example.com"
+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_HOST=
+PUSHER_PORT=443
+PUSHER_SCHEME=https
+PUSHER_APP_CLUSTER=mt1
+
+VITE_APP_NAME="${APP_NAME}"
+VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
+VITE_PUSHER_HOST="${PUSHER_HOST}"
+VITE_PUSHER_PORT="${PUSHER_PORT}"
+VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
+VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

+ 11 - 0
.gitattributes

@@ -0,0 +1,11 @@
+* text=auto eol=lf
+
+*.blade.php diff=html
+*.css diff=css
+*.html diff=html
+*.md diff=markdown
+*.php diff=php
+
+/.github export-ignore
+CHANGELOG.md export-ignore
+.styleci.yml export-ignore

+ 19 - 0
.gitignore

@@ -0,0 +1,19 @@
+/.phpunit.cache
+/node_modules
+/public/build
+/public/hot
+/public/storage
+/storage/*.key
+/vendor
+.env
+.env.backup
+.env.production
+.phpunit.result.cache
+Homestead.json
+Homestead.yaml
+auth.json
+npm-debug.log
+yarn-error.log
+/.fleet
+/.idea
+/.vscode

BIN
app/.DS_Store


+ 27 - 0
app/Console/Kernel.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace App\Console;
+
+use Illuminate\Console\Scheduling\Schedule;
+use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
+
+class Kernel extends ConsoleKernel
+{
+    /**
+     * Define the application's command schedule.
+     */
+    protected function schedule(Schedule $schedule): void
+    {
+        // $schedule->command('inspire')->hourly();
+    }
+
+    /**
+     * Register the commands for the application.
+     */
+    protected function commands(): void
+    {
+        $this->load(__DIR__.'/Commands');
+
+        require base_path('routes/console.php');
+    }
+}

+ 30 - 0
app/Exceptions/Handler.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Exceptions;
+
+use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
+use Throwable;
+
+class Handler extends ExceptionHandler
+{
+    /**
+     * The list of the inputs that are never flashed to the session on validation exceptions.
+     *
+     * @var array<int, string>
+     */
+    protected $dontFlash = [
+        'current_password',
+        'password',
+        'password_confirmation',
+    ];
+
+    /**
+     * Register the exception handling callbacks for the application.
+     */
+    public function register(): void
+    {
+        $this->reportable(function (Throwable $e) {
+            //
+        });
+    }
+}

+ 23 - 0
app/Helpers/DateHelper.php

@@ -0,0 +1,23 @@
+<?php
+namespace App\Helpers;
+
+class DateHelper
+{
+    public static function filterDate($date)
+    {
+        return (bool)strtotime($date);
+    }
+
+    public static function calculateAge($birthDate, $currentDate)
+    {
+        $birth = new \DateTime($birthDate);
+        $current = new \DateTime($currentDate);
+        return $current->diff($birth)->y ?: 1; // Return 1 if age is 0
+    }
+
+
+    public static function formatDate($date) {
+        if (!$date) return '';
+        return date('d/m/Y', strtotime($date));
+    }
+}

+ 10 - 0
app/Helpers/PoliziaUtils.php

@@ -0,0 +1,10 @@
+<?php
+namespace App\Helpers;
+
+class PoliziaUtils
+{
+    public static function numberToLetter($number) {
+        return chr(65 + $number);
+    }
+
+}

BIN
app/Http/.DS_Store


+ 12 - 0
app/Http/Controllers/Controller.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
+use Illuminate\Foundation\Validation\ValidatesRequests;
+use Illuminate\Routing\Controller as BaseController;
+
+class Controller extends BaseController
+{
+    use AuthorizesRequests, ValidatesRequests;
+}

+ 68 - 0
app/Http/Kernel.php

@@ -0,0 +1,68 @@
+<?php
+
+namespace App\Http;
+
+use Illuminate\Foundation\Http\Kernel as HttpKernel;
+
+class Kernel extends HttpKernel
+{
+    /**
+     * The application's global HTTP middleware stack.
+     *
+     * These middleware are run during every request to your application.
+     *
+     * @var array<int, class-string|string>
+     */
+    protected $middleware = [
+        // \App\Http\Middleware\TrustHosts::class,
+        \App\Http\Middleware\TrustProxies::class,
+        \Illuminate\Http\Middleware\HandleCors::class,
+        \App\Http\Middleware\PreventRequestsDuringMaintenance::class,
+        \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
+        \App\Http\Middleware\TrimStrings::class,
+        \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
+    ];
+
+    /**
+     * The application's route middleware groups.
+     *
+     * @var array<string, array<int, class-string|string>>
+     */
+    protected $middlewareGroups = [
+        'web' => [
+            \App\Http\Middleware\EncryptCookies::class,
+            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
+            \Illuminate\Session\Middleware\StartSession::class,
+            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
+            \App\Http\Middleware\VerifyCsrfToken::class,
+            \Illuminate\Routing\Middleware\SubstituteBindings::class,
+        ],
+
+        'api' => [
+            // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
+            \Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
+            \Illuminate\Routing\Middleware\SubstituteBindings::class,
+        ],
+    ];
+
+    /**
+     * The application's middleware aliases.
+     *
+     * Aliases may be used instead of class names to conveniently assign middleware to routes and groups.
+     *
+     * @var array<string, class-string|string>
+     */
+    protected $middlewareAliases = [
+        'auth' => \App\Http\Middleware\Authenticate::class,
+        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
+        'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
+        'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
+        'can' => \Illuminate\Auth\Middleware\Authorize::class,
+        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
+        'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
+        'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class,
+        'signed' => \App\Http\Middleware\ValidateSignature::class,
+        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
+        'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
+    ];
+}

BIN
app/Http/Livewire/.DS_Store


+ 112 - 0
app/Http/Livewire/AccertatoreGrado.php

@@ -0,0 +1,112 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+use Livewire\WithPagination;
+
+class AccertatoreGrado extends Component
+{
+
+    use WithPagination;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $title = 'Accertatore grado';
+
+    public $search, $name, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public function resetFields(){
+        $this->name = '';
+    }
+
+    public function updatingSearch()
+    {
+        $this->resetPage();
+    }
+
+    public function render()
+    {
+        $rows = \App\Models\AccertatoreGrado::where('name', 'like', '%'.$this->search.'%')->orderBy('name')->paginate(10);
+        return view('livewire.accertatore-grado', ['records' => $rows]);
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\AccertatoreGrado::create([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $record = \App\Models\AccertatoreGrado::findOrFail($id);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+                $this->name = $record->name;
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\AccertatoreGrado::whereId($this->dataId)->update([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('success','Errore');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\AccertatoreGrado::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+}

+ 103 - 0
app/Http/Livewire/AllegatiGalleryType.php

@@ -0,0 +1,103 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+class AllegatiGalleryType extends Component
+{
+
+    public $records, $name, $file_type, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public function resetFields(){
+        $this->name = '';
+        $this->file_type = 0;
+    }
+
+    public function render()
+    {
+        $this->records = \App\Models\AllegatiGalleryType::get();
+        return view('livewire.allegati-gallery-type');
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\AllegatiGalleryType::create([
+                'name' => $this->name,
+                'file_type' => $this->file_type,
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $record = \App\Models\AllegatiGalleryType::findOrFail($id);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+                $this->name = $record->name;
+                $this->file_type = $record->file_type;
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\AllegatiGalleryType::whereId($this->dataId)->update([
+                'name' => $this->name,
+                'file_type' => $this->file_type,
+            ]);
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('success','Errore');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\AllegatiGalleryType::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+}

+ 317 - 0
app/Http/Livewire/Anagrafica.php

@@ -0,0 +1,317 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+use Livewire\WithPagination;
+
+class Anagrafica extends Component
+{
+    use WithPagination;
+
+    public $type;
+    public $firstname;
+    public $lastname;
+    public $gender;
+    public $birth_date;
+    public $birth_town_id;
+    public $birth_prov_id;
+    public $residenza_town_id;
+    public $residenza_prov_id;
+    public $residenza_address;
+    public $residenza_cap;
+    public $mobile;
+    public $sedicente;
+    public $documento_tipo;
+    public $documento_patente_cat;
+    public $documento_tipo_altro;
+    public $documento_numero;
+    public $documento_rilasciato_da;
+    public $documento_rilasciato_da_altro;
+    public $foreign_country;
+    public $documento_rilasciato_da_di_foreign_localita;
+    public $documento_rilasciato_da_di_foreign_country;
+    public $documento_rilasciato_da_prov_id;
+    public $documento_rilasciato_da_town_id;
+    public $documento_rilasciato_il;
+    public $documento_scadenza_il;
+    public $state;
+    public $created;
+    public $created_by;
+    public $updated;
+    public $updated_by;
+    public $locked;
+    public $locked_by;
+    public $nazionalita;
+    public $nazione_straniera;
+    public $localita_straniera;
+    public $rag_soc;
+    public $vat;
+    public $sede_legale_address;
+    public $sede_legale_town_id;
+    public $sede_legale_prov_id;
+    public $sede_legale_cap;
+    public $sede_legale_state;
+    public $phone;
+
+    public $recordId; // Used for editing/updating a record
+    public $updateMode = false;
+
+    public $anag_foreign_birth_country;
+    public $anag_foreign_birth_city;
+    public $anag_foreign_residence_country;
+    public $anag_foreign_residence_city;
+
+    protected $rules = [
+        'type' => 'required|string|max:255',
+        'firstname' => 'required|string|max:255',
+        'lastname' => 'required|string|max:255',
+        // Add other validation rules as needed
+    ];
+
+    public function render()
+    {
+        return view('livewire.anagrafica-crud', [
+            'anagraficas' => Anagrafica::paginate(10)
+        ]);
+    }
+
+    public function resetInputFields()
+    {
+        $this->type = '';
+        $this->firstname = '';
+        $this->lastname = '';
+        $this->gender = '';
+        $this->birth_date = '';
+        $this->birth_town_id = '';
+        $this->birth_prov_id = '';
+        $this->residenza_town_id = '';
+        $this->residenza_prov_id = '';
+        $this->residenza_address = '';
+        $this->residenza_cap = '';
+        $this->mobile = '';
+        $this->sedicente = '';
+        $this->documento_tipo = '';
+        $this->documento_patente_cat = '';
+        $this->documento_tipo_altro = '';
+        $this->documento_numero = '';
+        $this->documento_rilasciato_da = '';
+        $this->documento_rilasciato_da_altro = '';
+        $this->foreign_country = '';
+        $this->documento_rilasciato_da_di_foreign_localita = '';
+        $this->documento_rilasciato_da_di_foreign_country = '';
+        $this->documento_rilasciato_da_prov_id = '';
+        $this->documento_rilasciato_da_town_id = '';
+        $this->documento_rilasciato_il = '';
+        $this->documento_scadenza_il = '';
+        $this->state = '';
+        $this->created = '';
+        $this->created_by = '';
+        $this->updated = '';
+        $this->updated_by = '';
+        $this->locked = '';
+        $this->locked_by = '';
+        $this->nazionalita = '';
+        $this->nazione_straniera = '';
+        $this->localita_straniera = '';
+        $this->rag_soc = '';
+        $this->vat = '';
+        $this->sede_legale_address = '';
+        $this->sede_legale_town_id = '';
+        $this->sede_legale_prov_id = '';
+        $this->sede_legale_cap = '';
+        $this->sede_legale_state = '';
+        $this->phone = '';
+
+        $this->anag_foreign_birth_country = '';
+        $this->anag_foreign_birth_city = '';
+        $this->anag_foreign_residence_country = '';
+        $this->anag_foreign_residence_city = '';
+    }
+
+    public function store()
+    {
+        $this->validate();
+        Anagrafica::create([
+            'type' => $this->type,
+            'firstname' => $this->firstname,
+            'lastname' => $this->lastname,
+            'gender' => $this->gender,
+            'birth_date' => $this->birth_date,
+            'birth_town_id' => $this->birth_town_id,
+            'birth_prov_id' => $this->birth_prov_id,
+            'residenza_town_id' => $this->residenza_town_id,
+            'residenza_prov_id' => $this->residenza_prov_id,
+            'residenza_address' => $this->residenza_address,
+            'residenza_cap' => $this->residenza_cap,
+            'mobile' => $this->mobile,
+            'sedicente' => $this->sedicente,
+            'documento_tipo' => $this->documento_tipo,
+            'documento_patente_cat' => $this->documento_patente_cat,
+            'documento_tipo_altro' => $this->documento_tipo_altro,
+            'documento_numero' => $this->documento_numero,
+            'documento_rilasciato_da' => $this->documento_rilasciato_da,
+            'documento_rilasciato_da_altro' => $this->documento_rilasciato_da_altro,
+            'foreign_country' => $this->foreign_country,
+            'documento_rilasciato_da_di_foreign_localita' => $this->documento_rilasciato_da_di_foreign_localita,
+            'documento_rilasciato_da_di_foreign_country' => $this->documento_rilasciato_da_di_foreign_country,
+            'documento_rilasciato_da_prov_id' => $this->documento_rilasciato_da_prov_id,
+            'documento_rilasciato_da_town_id' => $this->documento_rilasciato_da_town_id,
+            'documento_rilasciato_il' => $this->documento_rilasciato_il,
+            'documento_scadenza_il' => $this->documento_scadenza_il,
+            'state' => $this->state,
+            'created' => $this->created,
+            'created_by' => $this->created_by,
+            'updated' => $this->updated,
+            'updated_by' => $this->updated_by,
+            'locked' => $this->locked,
+            'locked_by' => $this->locked_by,
+            'nazionalita' => $this->nazionalita,
+            'nazione_straniera' => $this->nazione_straniera,
+            'localita_straniera' => $this->localita_straniera,
+            'rag_soc' => $this->rag_soc,
+            'vat' => $this->vat,
+            'sede_legale_address' => $this->sede_legale_address,
+            'sede_legale_town_id' => $this->sede_legale_town_id,
+            'sede_legale_prov_id' => $this->sede_legale_prov_id,
+            'sede_legale_cap' => $this->sede_legale_cap,
+            'sede_legale_state' => $this->sede_legale_state,
+            'phone' => $this->phone,
+            'anag_foreign_birth_country' => $this->anag_foreign_birth_country,
+            'anag_foreign_birth_city' => $this->anag_foreign_birth_city,
+            'anag_foreign_residence_country' => $this->anag_foreign_residence_country,
+            'anag_foreign_residence_city' => $this->anag_foreign_residence_city,
+        ]);
+
+        session()->flash('message', 'Record Created Successfully.');
+        $this->resetInputFields();
+    }
+
+    public function edit($id)
+    {
+        $record = Anagrafica::findOrFail($id);
+
+        $this->recordId = $id;
+        $this->type = $record->type;
+        $this->firstname = $record->firstname;
+        $this->lastname = $record->lastname;
+        $this->gender = $record->gender;
+        $this->birth_date = $record->birth_date;
+        $this->birth_town_id = $record->birth_town_id;
+        $this->birth_prov_id = $record->birth_prov_id;
+        $this->residenza_town_id = $record->residenza_town_id;
+        $this->residenza_prov_id = $record->residenza_prov_id;
+        $this->residenza_address = $record->residenza_address;
+        $this->residenza_cap = $record->residenza_cap;
+        $this->mobile = $record->mobile;
+        $this->sedicente = $record->sedicente;
+        $this->documento_tipo = $record->documento_tipo;
+        $this->documento_patente_cat = $record->documento_patente_cat;
+        $this->documento_tipo_altro = $record->documento_tipo_altro;
+        $this->documento_numero = $record->documento_numero;
+        $this->documento_rilasciato_da = $record->documento_rilasciato_da;
+        $this->documento_rilasciato_da_altro = $record->documento_rilasciato_da_altro;
+        $this->foreign_country = $record->foreign_country;
+        $this->documento_rilasciato_da_di_foreign_localita = $record->documento_rilasciato_da_di_foreign_localita;
+        $this->documento_rilasciato_da_di_foreign_country = $record->documento_rilasciato_da_di_foreign_country;
+        $this->documento_rilasciato_da_prov_id = $record->documento_rilasciato_da_prov_id;
+        $this->documento_rilasciato_da_town_id = $record->documento_rilasciato_da_town_id;
+        $this->documento_rilasciato_il = $record->documento_rilasciato_il;
+        $this->documento_scadenza_il = $record->documento_scadenza_il;
+        $this->state = $record->state;
+        $this->created = $record->created;
+        $this->created_by = $record->created_by;
+        $this->updated = $record->updated;
+        $this->updated_by = $record->updated_by;
+        $this->locked = $record->locked;
+        $this->locked_by = $record->locked_by;
+        $this->nazionalita = $record->nazionalita;
+        $this->nazione_straniera = $record->nazione_straniera;
+        $this->localita_straniera = $record->localita_straniera;
+        $this->rag_soc = $record->rag_soc;
+        $this->vat = $record->vat;
+        $this->sede_legale_address = $record->sede_legale_address;
+        $this->sede_legale_town_id = $record->sede_legale_town_id;
+        $this->sede_legale_prov_id = $record->sede_legale_prov_id;
+        $this->sede_legale_cap = $record->sede_legale_cap;
+        $this->sede_legale_state = $record->sede_legale_state;
+        $this->phone = $record->phone;
+
+        $this->anag_foreign_birth_country = $record->anag_foreign_birth_country;
+        $this->anag_foreign_birth_city = $record->anag_foreign_birth_city;
+        $this->anag_foreign_residence_country = $record->anag_foreign_residence_country;
+        $this->anag_foreign_residence_city = $record->anag_foreign_residence_city;
+
+        $this->updateMode = true;
+    }
+
+    public function update()
+    {
+        $this->validate();
+
+        if ($this->recordId) {
+            $record = Anagrafica::find($this->recordId);
+            $record->update([
+                'type' => $this->type,
+                'firstname' => $this->firstname,
+                'lastname' => $this->lastname,
+                'gender' => $this->gender,
+                'birth_date' => $this->birth_date,
+                'birth_town_id' => $this->birth_town_id,
+                'birth_prov_id' => $this->birth_prov_id,
+                'residenza_town_id' => $this->residenza_town_id,
+                'residenza_prov_id' => $this->residenza_prov_id,
+                'residenza_address' => $this->residenza_address,
+                'residenza_cap' => $this->residenza_cap,
+                'mobile' => $this->mobile,
+                'sedicente' => $this->sedicente,
+                'documento_tipo' => $this->documento_tipo,
+                'documento_patente_cat' => $this->documento_patente_cat,
+                'documento_tipo_altro' => $this->documento_tipo_altro,
+                'documento_numero' => $this->documento_numero,
+                'documento_rilasciato_da' => $this->documento_rilasciato_da,
+                'documento_rilasciato_da_altro' => $this->documento_rilasciato_da_altro,
+                'foreign_country' => $this->foreign_country,
+                'documento_rilasciato_da_di_foreign_localita' => $this->documento_rilasciato_da_di_foreign_localita,
+                'documento_rilasciato_da_di_foreign_country' => $this->documento_rilasciato_da_di_foreign_country,
+                'documento_rilasciato_da_prov_id' => $this->documento_rilasciato_da_prov_id,
+                'documento_rilasciato_da_town_id' => $this->documento_rilasciato_da_town_id,
+                'documento_rilasciato_il' => $this->documento_rilasciato_il,
+                'documento_scadenza_il' => $this->documento_scadenza_il,
+                'state' => $this->state,
+                'created' => $this->created,
+                'created_by' => $this->created_by,
+                'updated' => $this->updated,
+                'updated_by' => $this->updated_by,
+                'locked' => $this->locked,
+                'locked_by' => $this->locked_by,
+                'nazionalita' => $this->nazionalita,
+                'nazione_straniera' => $this->nazione_straniera,
+                'localita_straniera' => $this->localita_straniera,
+                'rag_soc' => $this->rag_soc,
+                'vat' => $this->vat,
+                'sede_legale_address' => $this->sede_legale_address,
+                'sede_legale_town_id' => $this->sede_legale_town_id,
+                'sede_legale_prov_id' => $this->sede_legale_prov_id,
+                'sede_legale_cap' => $this->sede_legale_cap,
+                'sede_legale_state' => $this->sede_legale_state,
+                'phone' => $this->phone,
+                'anag_foreign_birth_country' => $this->anag_foreign_birth_country,
+                'anag_foreign_birth_city' => $this->anag_foreign_birth_city,
+                'anag_foreign_residence_country' => $this->anag_foreign_residence_country,
+                'anag_foreign_residence_city' => $this->anag_foreign_residence_city,
+            ]);
+
+            $this->updateMode = false;
+            session()->flash('message', 'Record Updated Successfully.');
+            $this->resetInputFields();
+        }
+    }
+
+
+    public function delete($id)
+    {
+        Anagrafica::find($id)->delete();
+        session()->flash('message', 'Record Deleted Successfully.');
+    }
+}

+ 112 - 0
app/Http/Livewire/AusilioAltriEnti.php

@@ -0,0 +1,112 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+use Livewire\WithPagination;
+
+class AusilioAltriEnti extends Component
+{
+
+    use WithPagination;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $search, $name, $dataId, $update = false, $add = false;
+
+    public $title = 'Ausilio altri enti';
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public function resetFields(){
+        $this->name = '';
+    }
+
+    public function updatingSearch()
+    {
+        $this->resetPage();
+    }
+
+    public function render()
+    {
+        $rows = \App\Models\AusilioAltriEnti::where('name', 'like', '%'.$this->search.'%')->orderBy('name')->paginate(10);
+        return view('livewire.ausilio-altri-enti', ['records' => $rows]);
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\AusilioAltriEnti::create([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $record = \App\Models\AusilioAltriEnti::findOrFail($id);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+                $this->name = $record->name;
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\AusilioAltriEnti::whereId($this->dataId)->update([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('success','Errore');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\AusilioAltriEnti::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+}

+ 112 - 0
app/Http/Livewire/Compagnia.php

@@ -0,0 +1,112 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+use Livewire\WithPagination;
+
+class Compagnia extends Component
+{
+
+    use WithPagination;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $title = 'Assicurazioni';
+
+    public $search, $name, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public function resetFields(){
+        $this->name = '';
+    }
+
+    public function updatingSearch()
+    {
+        $this->resetPage();
+    }
+
+    public function render()
+    {
+        $rows = \App\Models\Compagnia::where('name', 'like', '%'.$this->search.'%')->orderBy('name')->paginate(10);
+        return view('livewire.compagnia', ['records' => $rows]);
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\Compagnia::create([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $record = \App\Models\Compagnia::findOrFail($id);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+                $this->name = $record->name;
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\Compagnia::whereId($this->dataId)->update([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('success','Errore');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\Compagnia::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+}

+ 112 - 0
app/Http/Livewire/CondizioneStrada.php

@@ -0,0 +1,112 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+use Livewire\WithPagination;
+
+class CondizioneStrada extends Component
+{
+
+    use WithPagination;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $title = 'Condizione strada';
+
+    public $search, $name, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public function resetFields(){
+        $this->name = '';
+    }
+
+    public function updatingSearch()
+    {
+        $this->resetPage();
+    }
+
+    public function render()
+    {
+        $rows = \App\Models\CondizioneStrada::where('name', 'like', '%'.$this->search.'%')->orderBy('name')->paginate(10);
+        return view('livewire.condizione-strada', ['records' => $rows]);
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\CondizioneStrada::create([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $record = \App\Models\CondizioneStrada::findOrFail($id);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+                $this->name = $record->name;
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\CondizioneStrada::whereId($this->dataId)->update([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('success','Errore');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\CondizioneStrada::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+}

+ 116 - 0
app/Http/Livewire/CondizioniAtmosferiche.php

@@ -0,0 +1,116 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+use Livewire\WithPagination;
+
+class CondizioniAtmosferiche extends Component
+{
+
+    use WithPagination;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $title = 'Condizioni atmosferiche';
+
+    public $search, $name, $para_agg, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public function resetFields(){
+        $this->name = '';
+        $this->para_agg = '';
+    }
+
+    public function updatingSearch()
+    {
+        $this->resetPage();
+    }
+
+    public function render()
+    {
+        $rows = \App\Models\CondizioniAtmosferiche::where('name', 'like', '%'.$this->search.'%')->orderBy('name')->paginate(10);
+        return view('livewire.condizioni-atmosferiche', ['records' => $rows]);
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\CondizioniAtmosferiche::create([
+                'name' => $this->name,
+                'para_agg' => $this->para_agg,
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $record = \App\Models\CondizioniAtmosferiche::findOrFail($id);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+                $this->name = $record->name;
+                $this->para_agg = $record->PARA_AGG;
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\CondizioniAtmosferiche::whereId($this->dataId)->update([
+                'name' => $this->name,
+                'para_agg' => $this->para_agg,
+            ]);
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('success','Errore');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\CondizioniAtmosferiche::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+}

+ 116 - 0
app/Http/Livewire/CondizioniLuce.php

@@ -0,0 +1,116 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+use Livewire\WithPagination;
+
+class CondizioniLuce extends Component
+{
+
+    use WithPagination;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $title = 'Condizioni luce';
+
+    public $search, $name, $para_agg, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public function resetFields(){
+        $this->name = '';
+        $this->para_agg = '';
+    }
+
+    public function updatingSearch()
+    {
+        $this->resetPage();
+    }
+
+    public function render()
+    {
+        $rows = \App\Models\CondizioniLuce::where('name', 'like', '%'.$this->search.'%')->orderBy('name')->paginate(10);
+        return view('livewire.condizioni-luce', ['records' => $rows]);
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\CondizioniLuce::create([
+                'name' => $this->name,
+                'para_agg' => $this->para_agg,
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $record = \App\Models\CondizioniLuce::findOrFail($id);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+                $this->name = $record->name;
+                $this->para_agg = $record->PARA_AGG;
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\CondizioniLuce::whereId($this->dataId)->update([
+                'name' => $this->name,
+                'para_agg' => $this->para_agg,
+            ]);
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('success','Errore');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\CondizioniLuce::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+}

+ 15 - 0
app/Http/Livewire/Dashboard.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+class Dashboard extends Component
+{
+
+    public function render()
+    {
+        return view('livewire.dashboard');
+    }
+
+}

+ 112 - 0
app/Http/Livewire/EffettoDanno.php

@@ -0,0 +1,112 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+use Livewire\WithPagination;
+
+class EffettoDanno extends Component
+{
+
+    use WithPagination;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $title = 'Effetto del danno';
+
+    public $search, $name, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public function resetFields(){
+        $this->name = '';
+    }
+
+    public function updatingSearch()
+    {
+        $this->resetPage();
+    }
+
+    public function render()
+    {
+        $rows = \App\Models\EffettoDanno::where('name', 'like', '%'.$this->search.'%')->orderBy('name')->paginate(10);
+        return view('livewire.effetto-danno', ['records' => $rows]);
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\EffettoDanno::create([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $record = \App\Models\EffettoDanno::findOrFail($id);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+                $this->name = $record->name;
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\EffettoDanno::whereId($this->dataId)->update([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('success','Errore');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\EffettoDanno::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+}

+ 112 - 0
app/Http/Livewire/EntitaDanno.php

@@ -0,0 +1,112 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+use Livewire\WithPagination;
+
+class EntitaDanno extends Component
+{
+
+    use WithPagination;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $title = 'Entita del danno';
+
+    public $search, $name, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public function resetFields(){
+        $this->name = '';
+    }
+
+    public function updatingSearch()
+    {
+        $this->resetPage();
+    }
+
+    public function render()
+    {
+        $rows = \App\Models\EntitaDanno::where('name', 'like', '%'.$this->search.'%')->orderBy('name')->paginate(10);
+        return view('livewire.entita-danno', ['records' => $rows]);
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\EntitaDanno::create([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $record = \App\Models\EntitaDanno::findOrFail($id);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+                $this->name = $record->name;
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\EntitaDanno::whereId($this->dataId)->update([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('success','Errore');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\EntitaDanno::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+}

+ 112 - 0
app/Http/Livewire/FondoStradale.php

@@ -0,0 +1,112 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+use Livewire\WithPagination;
+
+class FondoStradale extends Component
+{
+
+    use WithPagination;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $title = 'Fondo stradale';
+
+    public $search, $name, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public function resetFields(){
+        $this->name = '';
+    }
+
+    public function updatingSearch()
+    {
+        $this->resetPage();
+    }
+
+    public function render()
+    {
+        $rows = \App\Models\FondoStradale::where('name', 'like', '%'.$this->search.'%')->orderBy('name')->paginate(10);
+        return view('livewire.fondo-stradale', ['records' => $rows]);
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\FondoStradale::create([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $record = \App\Models\FondoStradale::findOrFail($id);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+                $this->name = $record->name;
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\FondoStradale::whereId($this->dataId)->update([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('success','Errore');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\FondoStradale::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+}

+ 762 - 0
app/Http/Livewire/Istat.php

@@ -0,0 +1,762 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use App\Helpers\DateHelper;
+use App\Models\Anagrafica;
+use App\Models\ReportDataPedoni;
+use Livewire\Component;
+
+class Istat 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 = 'ISTAT';
+
+    public $from = '2023-11-01', $to;
+
+    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.istat');
+    }
+
+    public function export()
+    {
+
+        $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')
+            /*->where(function ($query) {
+                $query->where('fcf_reports_reports.verificatosi_in_data', '>=', $this->from)
+                ->where('fcf_reports_reports.verificatosi_in_data', '<=', $this->to);
+            })*/
+            ->orderBy('fcf_reports_reports.verificatosi_in_data')
+        ->get();
+
+        $txt = array();
+
+        foreach($items as $item)
+        {
+
+            $report = \App\Models\Report::findOrFail($item->id);
+
+            $item_data = '';
+
+            //1-10
+            $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;
+            }
+
+            $item_data .= date('y', strtotime($item->verificatosi_in_data));
+            $item_data .= date('m', strtotime($item->verificatosi_in_data));
+            $item_data .= str_pad($prov_code,3,'0',STR_PAD_LEFT);
+            $item_data .= str_pad($town_code,3,'0',STR_PAD_LEFT);
+            $item_data .= str_repeat(' ',4);
+            $item_data .= date('d', strtotime($item->verificatosi_in_data));
+            $item_data .= str_repeat(' ',2);
+            $item_data .= '4';
+            $item_data .= str_repeat(' ',5);
+            $item_data .= ' ';
+
+            //11-20
+            if($item->localizzazione_incidente == Istat::LOCALIZZAZIONE_INCIDENTE_IN)
+            {
+                switch($item->nomenclatura_strada) {
+                    case 2: $loc = 2; break;
+                    case 3: $loc = 0; break;
+                    case 4: $loc = 3; break;
+                    default: $loc = 1;
+                }
+            }
+            elseif($item->localizzazione_incidente == Istat::LOCALIZZAZIONE_INCIDENTE_OUT)
+            {
+                switch($item->nomenclatura_strada) {
+                    case 2: $loc = 5; break;
+                    case 3: $loc = 9; break;
+                    case 4: $loc = 6; break;
+                    default: $loc = 4;
+                }
+            }
+            else $loc = ' ';
+
+            $tipo_strada = ' ';
+            $types_saved = \App\Models\ReportTipoStrada::where('report_id', $report->id)->select('tipo_strada_id')->get()->toArray();
+            // $types_saved = $report->getReportTipoStrada();
+            if($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;
+            }
+
+            $pav = ' ';
+            if($item->pavimentazione)
+                switch($item->pavimentazione)
+                {
+                    case 5:
+                    case 6:
+                        $pav = 3; break;
+                    default:
+                        if(!$item->condizione_strada || $item->condizione_strada == 1) $pav = 1;
+                        else $pav = 2;
+                }
+
+            $int = ' ';
+            switch($item->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;
+            }
+
+            $fon = ' ';
+            if($item->fondo_stradale)
+                switch($item->fondo_stradale)
+                {
+                    case 1: $fon = 1; break;
+                    case 2: $fon = 2; break;
+                    case 3: $fon = 4; break;
+                    case 4: $fon = 5; break;
+                    case 5: $fon = 3; break;
+                }
+
+            $seg = ' ';
+            if($item->segnaletica)
+                switch($item->segnaletica)
+                {
+                    case Istat::SEGNALETICA_ASSENTE: $seg = 1; break;
+                    case Istat::SEGNALETICA_VERTICALE: $seg = 2; break;
+                    case Istat::SEGNALETICA_ORIZZONTALE: $seg = 3; break;
+                    case Istat::SEGNALETICA_VERTICALE_ORIZZONTALE: $seg = 4; break;
+                    case Istat::SEGNALETICA_TEMPORANEA_CANTIERE: $seg = 5; break;
+                }
+
+
+            $met = ' ';
+            if($item->condizioni_atmosferiche)
+                switch($item->condizioni_atmosferiche)
+                {
+                    case 1: $met = 1; break;
+                    case 2: $met = 2; break;
+                    case 3: $met = 3; break;
+                    case 4: $met = 2; break;
+                    case 5: $met = 7; break;
+                    case 6: $met = 1; break;
+                    case 7: $met = 4; break;
+                    case 8: $met = 5; break;
+                    case 9: $met = 6; break;
+                }
+
+
+            $item_data .= $loc;
+            $item_data .= str_pad($item->nomenclatura_strada_numero,3,' ',STR_PAD_RIGHT);
+            $item_data .= str_repeat(' ',3);
+            $item_data .= str_repeat(' ',2);
+            $item_data .= $tipo_strada;
+            $item_data .= $pav;
+            $item_data .= $int;
+            $item_data .= $fon;
+            $item_data .= $seg;
+            $item_data .= $met;
+
+            //21-30
+            $tipo_urto = str_repeat(' ',2);
+            $types_saved = \App\Models\ReportTipoUrto::where('report_id', $report->id)->select('tipo_urto_id')->get()->toArray();
+            // $types_saved = $report->getReportTipoUrto();
+            if($types_saved)
+            {
+                if(in_array(1,$types_saved))
+                    $tipo_urto = '01';
+                elseif(in_array(2,$types_saved))
+                    $tipo_urto = '02';
+                elseif(in_array(3,$types_saved) || in_array(26,$types_saved) || in_array(27,$types_saved))
+                    $tipo_urto = '04';
+                elseif(in_array(5,$types_saved))
+                    $tipo_urto = '03';
+                elseif(in_array(7,$types_saved) || in_array(12,$types_saved))
+                    $tipo_urto = '05';
+                elseif(in_array(4,$types_saved) || in_array(21,$types_saved))
+                    $tipo_urto = '07';
+                elseif(in_array(8,$types_saved))
+                    $tipo_urto = '06';
+                elseif(in_array(6,$types_saved) || in_array(19,$types_saved) || in_array(14,$types_saved))
+                    $tipo_urto = '08';
+                elseif(in_array(9,$types_saved) || in_array(18,$types_saved))
+                    $tipo_urto = '10';
+                elseif(in_array(25,$types_saved) || in_array(22,$types_saved) || in_array(13,$types_saved))
+                    $tipo_urto = '12';
+            }
+
+            $item_data .= $tipo_urto;
+
+            $v_data = array(
+                'tipo' => '',
+                'circostanze' => '',
+                'veicolo' => '',
+                'conducente_passeggeri' => '',
+                'pedoni' => '',
+                'cittadinanza_conducente' => ''
+            );
+
+            $deceduti_24h = array();
+            $deceduti_30gg = array();
+            $feriti = array();
+
+            $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;
+                $stato_psico_fisico = str_repeat(' ',2);
+
+                if($data_veicolo)
+                {
+                    if ($data_veicolo["veicoli"] > 0)
+                    {
+                        $veicolo = \App\Models\Vehicle::findOrFail($data_veicolo["veicoli"]); //(ArrayHelper::getValue($data_veicolo, 'veicoli', 0));
+                        $v_tipo = str_repeat(' ',2);
+                        switch($veicolo->tipo_id)
+                        {
+                            case 1:
+                                switch($veicolo->destinazione_uso)
+                                {
+                                    case \App\Models\Vehicle::DESTINAZIONE_USO_PRIVATO: $v_tipo = '01'; break;
+                                    case \App\Models\Vehicle::DESTINAZIONE_USO_PUBBLICO: $v_tipo = '03'; break;
+                                    case \App\Models\Vehicle::DESTINAZIONE_USO_SOCCORSO_POLIZIA: $v_tipo = '04'; break;
+                                    default: $v_tipo = '01'; break;
+                                }
+                                break;
+                            case 17: $v_tipo = '02'; break;
+                            case 7:
+                                if($veicolo->destinazione_uso == \App\Models\Vehicle::DESTINAZIONE_USO_SERVIZO_PUBBLICO_DI_LINEA)
+                                    $v_tipo = '05';
+                                else
+                                    $v_tipo = '06';
+                                break;
+                            case 16: $v_tipo = '08'; break;
+                            case 14:
+                            case 20: $v_tipo = '09'; break;
+                            case 18: $v_tipo = '10'; break;
+                            case 8:  $v_tipo = '13'; break;
+                            case 6:  $v_tipo = '14'; break;
+                            case 3:  $v_tipo = '15'; break;
+                            case 5:  $v_tipo = '17'; break;
+                            case 19: $v_tipo = '18'; break;
+                            case 4:  $v_tipo = '21'; break;
+                        }
+
+                        $v_data['tipo'] .= $v_tipo;
+
+                        $v_data['veicolo'] .= $veicolo->foreign_country ?
+                            str_repeat(' ',8) :
+                            str_pad(substr($veicolo->targa,0,8),8,' ',STR_PAD_RIGHT);
+
+                        $v_data['veicolo'] .= $veicolo->foreign_country ?
+                            str_pad($veicolo->getCartaCircolazioneRilasciataDaDiValueAttribute(),3,' ',STR_PAD_RIGHT) :
+                            str_repeat(' ',3);
+
+                        $time = strtotime($veicolo->carta_circolazione_rilasciata_il);
+                        $v_data['veicolo'] .= str_pad($time && $time > 0 ? date('y',$time) : '',2,' ',STR_PAD_RIGHT);
+                        $v_data['veicolo'] .= str_repeat(' ',5);
+                    }
+                    if($data_veicolo["alcool_test"] && $data_veicolo["alcool_test_esito"] == Istat::ESITO_POSITIVO)
+                        $stato_psico_fisico = '90';
+                    elseif($data_veicolo["drug_test"] && $data_veicolo["drug_test_esito"] == Istat::ESITO_POSITIVO)
+                        $stato_psico_fisico = '94';
+
+                    $conducente = \App\Models\Anagrafica::findOrFail($data_veicolo["conducenti"]);
+
+                    $eta_conducente = '00';
+                    if($conducente->birth_date != '' && $report->verificatosi_in_data != '')
+                    {
+                        $eta_conducente = 0;// * * * DateHelper::calculateAge($conducente->birth_date,$report->verificatosi_in_data);
+                        if($eta_conducente > 100 || $eta_conducente < 0) $eta_conducente = 0;
+                        $eta_conducente = str_pad($eta_conducente,2,'0',STR_PAD_LEFT);
+                    }
+                    $v_data['conducente_passeggeri'] .= $eta_conducente;
+                    $v_data['conducente_passeggeri'] .= $conducente->gender == 'F' ? '2' : '1';
+
+                    $details = array(
+                        'firstname' => $conducente->firstname,
+                        'lastname' => $conducente->lastname,
+                        'ospedale' => $data_veicolo["infortunato_ospedale"],
+                    );
+
+                    switch($data_veicolo["infortunato"])
+                    {
+                        case Istat::INFORTUNATO_DECEDUTO_30GG: $infortunato = 4; $deceduti_30gg[] = $details;  break;
+                        case Istat::INFORTUNATO_DECEDUTO_24H:  $infortunato = 3; $deceduti_24h[] = $details;   break;
+                        case Istat::INFORTUNATO_FERITO:        $infortunato = 2; $feriti[] = $details;         break;
+                        default: $infortunato = 1; break;
+                    }
+
+                    $v_data['conducente_passeggeri'] .= $infortunato;
+
+                    switch($data_veicolo["conducente_patente_categoria"])
+                    {
+                        case Istat::PATENTE_CATEGORIA_AM:  $patente = '0'; break;
+                        case Istat::PATENTE_CATEGORIA_A1:
+                        case Istat::PATENTE_CATEGORIA_A1B:
+                        case Istat::PATENTE_CATEGORIA_A2:
+                        case Istat::PATENTE_CATEGORIA_A:   $patente = '1'; break;
+                        case Istat::PATENTE_CATEGORIA_AB:
+                        case Istat::PATENTE_CATEGORIA_B1:
+                        case Istat::PATENTE_CATEGORIA_B:   $patente = '2'; break;
+                        case Istat::PATENTE_CATEGORIA_C1:
+                        case Istat::PATENTE_CATEGORIA_C:   $patente = '3'; break;
+                        case Istat::PATENTE_CATEGORIA_D1:  $patente = '4'; break;
+                        case Istat::PATENTE_CATEGORIA_BE:
+                        case Istat::PATENTE_CATEGORIA_C1E:
+                        case Istat::PATENTE_CATEGORIA_CE:
+                        case Istat::PATENTE_CATEGORIA_D1E:
+                        case Istat::PATENTE_CATEGORIA_DE:
+                        case Istat::PATENTE_CATEGORIA_E:   $patente = '5'; break;
+                        default:                            $patente = '9'; break;
+                    }
+
+                    $v_data['conducente_passeggeri'] .= $patente;
+
+                    $patente_rilasciata_il = $data_veicolo["conducente_patente_rilasciata_il"];
+                    $v_data['conducente_passeggeri'] .= $patente_rilasciata_il ? date('y',strtotime($patente_rilasciata_il)) :  str_repeat(' ',2);
+                    $v_data['conducente_passeggeri'] .= str_repeat(' ',4);
+
+                    $datiPasseggeri = \App\Models\ReportDataPasseggeri::where('progressive', $i)->where('report_id', $report->id)->get()->toArray();
+                    for ($j = 0; $j < 4; $j++)
+                    {
+
+                        $passeggero_data = str_repeat(' ',4);
+                        if(isset($datiPasseggeri[$j]))
+                        {
+
+                            $passeggero = $datiPasseggeri[$j]["passeggero"];
+
+
+                            if($passeggero)
+                            {
+                                $passeggero_infortunato = $datiPasseggeri[$j]["infortunato"];
+                                if($passeggero_infortunato != Istat::INFORTUNATO_INCOLUME)
+                                {
+
+                                    $passeggero_anagrafica = \App\Models\Anagrafica::findOrFail($passeggero);
+
+                                    $eta_passeggero = '00';
+                                    if($passeggero_anagrafica->birth_date && $report->verificatosi_in_data)
+                                    {
+                                        $eta_passeggero = 0; // * * *DateHelper::calculateAge($passeggero_anagrafica->birth_date,$report->verificatosi_in_data);
+                                        if($eta_passeggero == 0) $eta_passeggero = 1;
+                                        elseif($eta_passeggero > 100 || $eta_passeggero < 0) $eta_passeggero = 0;
+                                        $eta_passeggero = str_pad($eta_passeggero,2,'0',STR_PAD_LEFT);
+                                    }
+
+                                    $passeggero_data = sprintf('%s%s%s',
+                                        $passeggero_infortunato == Istat::INFORTUNATO_FERITO ? '2' : '1',
+                                        $eta_passeggero,
+                                        $passeggero_anagrafica->gender == 'F' ? '4' : '3'
+                                    );
+
+                                    $details = array(
+                                        'firstname' => $passeggero_anagrafica->firstname,
+                                        'lastname' => $passeggero_anagrafica->lastname,
+                                        'ospedale' => $datiPasseggeri[$j]["infortunato_ospedale"]
+                                    );
+
+                                    switch($passeggero_infortunato)
+                                    {
+                                        case Istat::INFORTUNATO_DECEDUTO_30GG: $deceduti_30gg[] = $details;  break;
+                                        case Istat::INFORTUNATO_DECEDUTO_24H:  $deceduti_24h[] = $details;   break;
+                                        case Istat::INFORTUNATO_FERITO:        $feriti[] = $details;         break;
+                                    }
+                                }
+                            }
+                        }
+
+                        $v_data['conducente_passeggeri'] .= $passeggero_data;
+                    }
+
+                    $v_data['conducente_passeggeri'] .= str_repeat(' ',8);
+
+                    $v_data['cittadinanza_conducente'] .= $conducente->nazionalita == 0 ? '1' : '2';
+                    $country_id = 106;
+                    if($conducente->nazionalita != 0)
+                        $country_id = $conducente->nazione_straniera;
+                    if(!$country_id) $v_data['cittadinanza_conducente'] .= str_repeat(' ',33);
+                    else
+                    {
+                        $country = \App\Models\LocationCountry::findOrFail($country_id);
+                        $v_data['cittadinanza_conducente'] .= str_pad($country->istat_code,3,' ',STR_PAD_RIGHT);
+                        $v_data['cittadinanza_conducente'] .= str_pad(preg_replace('[^A-Z ]', '', strtoupper($country->name)),30,' ',STR_PAD_RIGHT);
+                    }
+
+
+
+                }
+                else
+                {
+                    $v_data['tipo'] .= str_repeat(' ',2);
+                    $v_data['veicolo'] .= str_repeat(' ',18);
+                    $v_data['conducente_passeggeri'] .= str_repeat(' ',35);
+                    $v_data['pedoni'] .= str_repeat(' ',24);
+                    $v_data['cittadinanza_conducente'] .= str_repeat(' ',34);
+                }
+
+                if($i < 2)
+                {
+                    $v_data['circostanze'] .= '00';
+                    $v_data['circostanze'] .= str_repeat(' ',2);
+                    $v_data['circostanze'] .= $stato_psico_fisico;
+                }
+
+
+            }
+            $p_data = '';
+
+            $datiPedoni = \App\Models\ReportDataPedoni::where('report_id', $report->id)->get()->toArray();
+            for($j = 0; $j < 4; $j++)
+            {
+
+                $pedone_data = str_repeat(' ',6);
+
+                if (isset($datiPedoni[$j]))
+                {
+                    $pedone = $datiPedoni[$j]["pedoni"];
+
+                    if($pedone)
+                    {
+                        $pedone_infortunato = $infortunato;
+                        if($pedone_infortunato != Istat::INFORTUNATO_INCOLUME)
+                        {
+                            $pedone_anagrafica = new Anagrafica([$pedone]);
+
+                            $eta_pedone = '00';
+                            if(DateHelper::filterDate($pedone_anagrafica->get('birth_date')) && DateHelper::filterDate($report->get('verificatosi_in_data')))
+                            {
+                                $eta_pedone = DateHelper::calculateAge($pedone_anagrafica->get('birth_date'),$report->get('verificatosi_in_data'));
+                                if($eta_pedone == 0) $eta_pedone = 1;
+                                elseif($eta_pedone > 100 || $eta_pedone < 0) $eta_pedone = 0;
+                                $eta_pedone = str_pad($eta_pedone,2,'0',STR_PAD_LEFT);
+                            }
+
+                            if($pedone_infortunato == Istat::INFORTUNATO_FERITO)
+                                $pedone_data = sprintf('%s%s%s',
+                                    str_repeat(' ',3),
+                                    $pedone_anagrafica->get('gender') == 'F' ? '4' : '3',
+                                    $eta_pedone
+                                );
+                            else
+                                $pedone_data = sprintf('%s%s%s',
+                                    $pedone_anagrafica->get('gender') == 'F' ? '2' : '1',
+                                    $eta_pedone,
+                                    str_repeat(' ',3)
+                                );
+
+                            $details = array(
+                                'firstname' => $pedone_anagrafica->get('firstname'),
+                                'lastname' => $pedone_anagrafica->get('lastname'),
+                                'ospedale' => ReportDataPedoni::where('report_id', $report->id)
+                                ->where('progressive', $j)
+                                ->value('infortunato_ospedale')
+                            );
+
+                            switch($pedone_infortunato)
+                            {
+                                case Istat::INFORTUNATO_DECEDUTO_30GG: $deceduti_30gg[] = $details;  break;
+                                case Istat::INFORTUNATO_DECEDUTO_24H:  $deceduti_24h[] = $details;   break;
+                                case Istat::INFORTUNATO_FERITO:        $feriti[] = $details;         break;
+                            }
+                        }
+                    }
+                }
+
+                $p_data .= $pedone_data;
+            }
+
+
+            $item_data .= $v_data['tipo'];
+            $item_data .= str_repeat(' ',24);
+            $item_data .= $v_data['circostanze'];
+            $item_data .= $v_data['veicolo'];
+            $item_data .= $v_data['conducente_passeggeri'];
+            $item_data .= $p_data;
+            $item_data .= str_repeat(' ',10);
+            $item_data .= str_pad(count($deceduti_24h),2,'0',STR_PAD_LEFT);
+            $item_data .= str_pad(count($deceduti_30gg),2,'0',STR_PAD_LEFT);
+            $item_data .= str_pad(count($feriti),2,'0',STR_PAD_LEFT);
+            $item_data .= str_repeat(' ',9);
+
+            /*
+
+            $location_description = Helper::getStradarioAddressById($report->get('localita_due'));
+            if($report->get('intersezione_con'))
+                $location_description .= ' ' . sprintf(__('ISTAT_INTERSEZIONE_CON', 'reports'),Helper::getStradarioAddressById($report->get('intersezione_con')));
+
+            if($report->get('prossimita_civico'))
+                $location_description .= ' ' . sprintf(__('ISTAT_PROSSIMITA_CIVICO', 'reports'),$report->get('prossimita_civico'));
+
+            if($report->get('prossimita_chilometro'))
+                $location_description .= ' ' . sprintf(__('ISTAT_PROSSIMITA_CHILOMETRO', 'reports'),$report->get('prossimita_chilometro'));
+
+            $item_data .= str_pad(substr(preg_replace('[^A-Za-z-0-9 ]','',strtoupper($location_description)),0,57),57,' ');
+
+            $item_data .= str_repeat(' ',100);
+
+            $deceduti = array_merge($deceduti_24h, $deceduti_30gg);
+            for($i = 0; $i < 4; $i++)
+            {
+                $deceduto = ArrayHelper::getValue($deceduti, $i);
+
+                $deceduto_data = str_repeat(' ',60);
+                if($deceduto) $deceduto_data = sprintf('%s%s',
+                        str_pad(substr($deceduto['firstname'],0,30),30,' '),
+                        str_pad(substr($deceduto['lastname'],0,30),30,' ')
+                    );
+
+                $item_data .= $deceduto_data;
+            }
+
+            for($i = 0; $i < 8; $i++)
+            {
+                $ferito = ArrayHelper::getValue($feriti, $i);
+
+                $ferito_data = str_repeat(' ',90);
+                if($ferito) $ferito_data = sprintf('%s%s%s',
+                    str_pad(substr($ferito['firstname'],0,30),30,' '),
+                    str_pad(substr($ferito['lastname'],0,30),30,' '),
+                    str_pad(substr($ferito['ospedale'],0,30),30,' ')
+                );
+
+                $item_data .= $ferito_data;
+            }
+
+            $item_data .= str_repeat(' ',10);
+            $item_data .= str_repeat(' ',102);
+            $item_data .= str_repeat(' ',8);
+
+            $ora = $report->get('verificatosi_in_data_ora');
+            $ora = $ora === '' ? '25' : str_pad(substr($ora,0,2),2,'0',STR_PAD_LEFT);
+            $item_data .= $ora;
+
+            $minuti = (int) $report->get('verificatosi_in_data_minuti');
+            if($ora == '25') $minuti = '  ';
+            $item_data .= str_pad(substr($minuti,0,2),2,'0',STR_PAD_LEFT);
+
+            $item_data .= str_repeat(' ',30);
+            $item_data .= str_repeat('0',7);
+            $item_data .= str_repeat(' ',15);
+            $item_data .= str_repeat(' ',4);
+            $item_data .= str_repeat(' ',100);
+
+            $item_data .= str_pad(substr(LocationHelper::getTown($report->get('localita_uno'))->title,0,40),40,' ');
+
+            $item_data .= str_repeat(' ',40);
+            $item_data .= str_repeat(' ',10);
+
+            $item_data .= $v_data['cittadinanza_conducente'];
+            */
+
+            $txt[] = $item_data;
+        }
+
+        $txt_data = implode("\n", $txt);
+
+        return response()->streamDownload(function () use($txt_data) {
+            echo  $txt_data;
+        }, 'istat_' . $this->from . "_" . $this->to . '.txt');
+
+        /*$txt_filename = sprintf(__('ISTAT_TXT_FILENAME', $mainframe->getOption()),
+            $model->getState('filter_date_from'),
+            $model->getState('filter_date_to')
+            );*/
+        // return view('livewire.istat');
+
+
+
+    }
+
+}

+ 112 - 0
app/Http/Livewire/MarcaVeicolo.php

@@ -0,0 +1,112 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+use Livewire\WithPagination;
+
+class MarcaVeicolo extends Component
+{
+
+    use WithPagination;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $title = 'Marche veicolo';
+
+    public $search,  $name, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public function resetFields(){
+        $this->name = '';
+    }
+
+    public function updatingSearch()
+    {
+        $this->resetPage();
+    }
+
+    public function render()
+    {
+        $rows = \App\Models\MarcaVeicolo::where('name', 'like', '%'.$this->search.'%')->orderBy('name')->paginate(10);
+        return view('livewire.marca-veicolo', ['records' => $rows]);
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\MarcaVeicolo::create([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $record = \App\Models\MarcaVeicolo::findOrFail($id);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+                $this->name = $record->name;
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\MarcaVeicolo::whereId($this->dataId)->update([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('success','Errore');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\MarcaVeicolo::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+}

+ 112 - 0
app/Http/Livewire/MaterialeRecuperato.php

@@ -0,0 +1,112 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+use Livewire\WithPagination;
+
+class MaterialeRecuperato extends Component
+{
+
+    use WithPagination;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $title = 'Materiale recuperato';
+
+    public $search, $name, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public function resetFields(){
+        $this->name = '';
+    }
+
+    public function updatingSearch()
+    {
+        $this->resetPage();
+    }
+
+    public function render()
+    {
+        $rows = \App\Models\MaterialeRecuperato::where('name', 'like', '%'.$this->search.'%')->orderBy('name')->paginate(10);
+        return view('livewire.materiale-recuperato', ['records' => $rows]);
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\MaterialeRecuperato::create([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $record = \App\Models\MaterialeRecuperato::findOrFail($id);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+                $this->name = $record->name;
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\MaterialeRecuperato::whereId($this->dataId)->update([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('success','Errore');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\MaterialeRecuperato::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+}

+ 127 - 0
app/Http/Livewire/ModelloVeicolo.php

@@ -0,0 +1,127 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+use Livewire\WithPagination;
+
+class ModelloVeicolo extends Component
+{
+
+    use WithPagination;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $title = 'Modello veicolo';
+
+    public $marche = [];
+
+    public $search, $search_marca_id, $name, $marca_id, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public function resetFields(){
+        $this->name = '';
+        $this->marca_id = null;
+    }
+
+    public function updatingSearch()
+    {
+        $this->resetPage();
+    }
+
+    public function render()
+    {
+        $this->marche = \App\Models\MarcaVeicolo::orderBy('name')->get();
+        $rows = \App\Models\ModelloVeicolo::where('name', 'like', '%'.$this->search.'%');
+        $rows = $rows->orderBy('name')->paginate(10);
+        return view('livewire.modello-veicolo', ['records' => $rows]);
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            $m = \App\Models\ModelloVeicolo::create([
+                'name' => $this->name
+            ]);
+            \App\Models\MarcaModelloVeicolo::create([
+                'marca_id' => $this->marca_id,
+                'modello_id' => $m->id
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $record = \App\Models\ModelloVeicolo::findOrFail($id);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+                $this->name = $record->name;
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+                $this->marca_id = \App\Models\MarcaModelloVeicolo::where('modello_id', $this->dataId)->first()->marca_id;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\ModelloVeicolo::whereId($this->dataId)->update([
+                'name' => $this->name
+            ]);
+            \App\Models\MarcaModelloVeicolo::where('modello_id', $this->dataId)->delete();
+            \App\Models\MarcaModelloVeicolo::create([
+                'marca_id' => $this->marca_id,
+                'modello_id' => $this->dataId
+            ]);
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('success','Errore');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\ModelloVeicolo::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+}

+ 112 - 0
app/Http/Livewire/NomenclaturaStrada.php

@@ -0,0 +1,112 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+use Livewire\WithPagination;
+
+class NomenclaturaStrada extends Component
+{
+
+    use WithPagination;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $title = 'Nomenclatura strada';
+
+    public $search, $name, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public function resetFields(){
+        $this->name = '';
+    }
+
+    public function updatingSearch()
+    {
+        $this->resetPage();
+    }
+
+    public function render()
+    {
+        $rows = \App\Models\NomenclaturaStrada::where('name', 'like', '%'.$this->search.'%')->orderBy('name')->paginate(10);
+        return view('livewire.nomenclatura-strada', ['records' => $rows]);
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\NomenclaturaStrada::create([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $record = \App\Models\NomenclaturaStrada::findOrFail($id);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+                $this->name = $record->name;
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\NomenclaturaStrada::whereId($this->dataId)->update([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('success','Errore');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\NomenclaturaStrada::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+}

+ 112 - 0
app/Http/Livewire/ParteMacchina.php

@@ -0,0 +1,112 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+use Livewire\WithPagination;
+
+class ParteMacchina extends Component
+{
+
+    use WithPagination;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $title = 'Localizzazione del danno';
+
+    public $search, $name, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public function resetFields(){
+        $this->name = '';
+    }
+
+    public function updatingSearch()
+    {
+        $this->resetPage();
+    }
+
+    public function render()
+    {
+        $rows = \App\Models\ParteMacchina::where('name', 'like', '%'.$this->search.'%')->orderBy('name')->paginate(10);
+        return view('livewire.parte-macchina', ['records' => $rows]);
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\ParteMacchina::create([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $record = \App\Models\ParteMacchina::findOrFail($id);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+                $this->name = $record->name;
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\ParteMacchina::whereId($this->dataId)->update([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('success','Errore');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\ParteMacchina::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+}

+ 116 - 0
app/Http/Livewire/ParticolaritaStrada.php

@@ -0,0 +1,116 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+use Livewire\WithPagination;
+
+class ParticolaritaStrada extends Component
+{
+
+    use WithPagination;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $title = 'Particolarità strada';
+
+    public $search, $name, $para_agg, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public function resetFields(){
+        $this->name = '';
+        $this->para_agg = '';
+    }
+
+    public function updatingSearch()
+    {
+        $this->resetPage();
+    }
+
+    public function render()
+    {
+        $rows = \App\Models\ParticolaritaStrada::where('name', 'like', '%'.$this->search.'%')->orderBy('name')->paginate(10);
+        return view('livewire.particolarita-strada', ['records' => $rows]);
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\ParticolaritaStrada::create([
+                'name' => $this->name,
+                'para_agg' => $this->para_agg,
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $record = \App\Models\ParticolaritaStrada::findOrFail($id);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+                $this->name = $record->name;
+                $this->para_agg = $record->PARA_AGG;
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\ParticolaritaStrada::whereId($this->dataId)->update([
+                'name' => $this->name,
+                'para_agg' => $this->para_agg,
+            ]);
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('success','Errore');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\ParticolaritaStrada::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+}

+ 116 - 0
app/Http/Livewire/PavimentazioneStrada.php

@@ -0,0 +1,116 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+use Livewire\WithPagination;
+
+class PavimentazioneStrada extends Component
+{
+
+    use WithPagination;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $title = 'Pavimentazione strada';
+
+    public $search, $name, $para_agg, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public function resetFields(){
+        $this->name = '';
+        $this->para_agg = '';
+    }
+
+    public function updatingSearch()
+    {
+        $this->resetPage();
+    }
+
+    public function render()
+    {
+        $rows = \App\Models\PavimentazioneStrada::where('name', 'like', '%'.$this->search.'%')->orderBy('name')->paginate(10);
+        return view('livewire.pavimentazione-strada', ['records' => $rows]);
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\PavimentazioneStrada::create([
+                'name' => $this->name,
+                'para_agg' => $this->para_agg,
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $record = \App\Models\PavimentazioneStrada::findOrFail($id);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+                $this->name = $record->name;
+                $this->para_agg = $record->PARA_AGG;
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\PavimentazioneStrada::whereId($this->dataId)->update([
+                'name' => $this->name,
+                'para_agg' => $this->para_agg,
+            ]);
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('success','Errore');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\PavimentazioneStrada::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+}

+ 3444 - 0
app/Http/Livewire/Report.php

@@ -0,0 +1,3444 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+use Livewire\WithPagination;
+
+use Livewire\WithFileUploads;
+
+use Barryvdh\DomPDF\Facade\Pdf;
+
+class Report extends Component
+{
+
+    use WithPagination;
+
+    use WithFileUploads;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $title = 'Verbali';
+
+    public $loadPatente;
+    public $loadTarga;
+
+    public $segnaletiche = array(
+        array('id' => 1, 'name' => 'Segnaletica assente'),
+        array('id' => 2, 'name' => 'Segnaletica verticale'),
+        array('id' => 3, 'name' => 'Segnaletica orizzontale'),
+        array('id' => 4, 'name' => 'Segnaletica verticale e orizzontale'),
+        array('id' => 5, 'name' => 'Segnaletica temporanea di cantiere'),
+    );
+
+    public $linee = array(
+        array('id' => 4, 'name' => 'Assente'),
+        array('id' => 1, 'name' => 'Continua'),
+        array('id' => 2, 'name' => 'Tratteggiata'),
+        array('id' => 3, 'name' => 'Tratteggiata in corrispondenza di'),
+        array('id' => 5, 'name' => 'Singola'),
+        array('id' => 6, 'name' => 'Doppia'),
+    );
+
+    public $div_segnaletica_verticale_2 = false;
+    public $div_segnaletica_verticale_3 = false;
+    public $div_segnaletica_verticale_4 = false;
+
+    public $div_segnaletica_orizzontale_2 = false;
+    public $div_segnaletica_orizzontale_3 = false;
+    public $div_segnaletica_orizzontale_4 = false;
+
+    public $search, $dataId, $update = false, $add = false;
+
+    public $name,
+        $validated,
+        $necessita_nulla_osta,
+        $data_nulla_osta,
+        $protocollo_num,
+        $protocollo_ord,
+        $protocollo_anno,
+        $verificatosi_in_data,
+        $verificatosi_in_data_ora,
+        $verificatosi_in_data_minuti,
+        $utg,
+        $utg_data,
+        $utg_protocollo,
+        $ag,
+        $ag_data,
+        $ag_protocollo,
+        $incidente_con_danni_a_cose,
+        $incidente_con_feriti,
+        $incidente_con_feriti_lesioni_lievi,
+        $incidente_con_feriti_lesioni_gravi,
+        $incidente_mortale,
+        $localita_uno,
+        $localita_due,
+        $intersezione_con,
+        $prossimita_civico,
+        $prossimita_palo_luce,
+        $prossimita_chilometro,
+        $note_aggiuntive;
+
+    public $accertatore_1,
+    $grado_accertatore_1,
+    $accertatore_2,
+    $grado_accertatore_2,
+    $accertatore_3,
+    $grado_accertatore_3,
+    $accertatore_4,
+    $grado_accertatore_4,
+    $accertatore_5,
+    $grado_accertatore_5;
+
+    public $rilievi_id;
+
+    public $tipo_segnalazione;
+
+    public $parti_coinvolte;
+
+    public $segnalazione_data,
+        $segnalazione_ora,
+        $segnalazione_minuti,
+        $segnalazione_altro,
+        $ausilio_altri_enti_motivo,
+        $ausilio_altri_enti_ora_intervento,
+        $ausilio_altri_enti_minuti_intervento,
+        $ditta_intervenuta,
+        $ripristino_ora_chiamata,
+        $ripristino_minuti_chiamata,
+        $ripristino_ora_arrivo,
+        $ripristino_minuti_arrivo,
+        $danni_cose_diverse_da_veicoli;
+
+    public $sinistro_ora,
+        $sinistro_minuti,
+        $localizzazione_incidente,
+        $localizzazione_incidente_altro,
+        $condizioni_atmosferiche,
+        $condizioni_atmosferiche_altro,
+        $nomenclatura_strada,
+        $nomenclatura_strada_numero,
+        $nomenclatura_strada_altro,
+        $pavimentazione,
+        $pavimentazione_altro,
+        $condizione_strada,
+        $condizione_strada_altro,
+        $fondo_stradale,
+        $fondo_stradale_specifica,
+        $visibilita,
+        $visibilita_specifica,
+        $particolarita_strada,
+        $particolarita_strada_specifica,
+        $tipo_strada,
+        $tipo_strada_altro,
+        $traffico;
+
+    public $segnaletica,
+        $segnaletica_verticale_1_via,
+        $segnaletica_verticale_1_altro,
+        $segnaletica_verticale_1_limite_velocita,
+        $segnaletica_verticale_1_direzione,
+        $segnaletica_verticale_1_pannello_integrativo,
+        $segnaletica_verticale_2_via,
+        $segnaletica_verticale_2_altro,
+        $segnaletica_verticale_2_limite_velocita,
+        $segnaletica_verticale_2_direzione,
+        $segnaletica_verticale_2_pannello_integrativo,
+        $segnaletica_verticale_3_via,
+        $segnaletica_verticale_3_altro,
+        $segnaletica_verticale_3_limite_velocita,
+        $segnaletica_verticale_3_direzione,
+        $segnaletica_verticale_3_pannello_integrativo,
+        $segnaletica_verticale_4_via,
+        $segnaletica_verticale_4_altro,
+        $segnaletica_verticale_4_limite_velocita,
+        $segnaletica_verticale_4_direzione,
+        $segnaletica_verticale_4_pannello_integrativo,
+        $segnaletica_orizzontale_1_via,
+        $segnaletica_orizzontale_1_linea_margine,
+        $segnaletica_orizzontale_1_linea_margine_specifica,
+        $segnaletica_orizzontale_1_linea_mezzeria,
+        $segnaletica_orizzontale_1_linea_mezzeria_specifica,
+        $segnaletica_orizzontale_1_altro,
+        $segnaletica_orizzontale_1_direzione,
+        $segnaletica_orizzontale_2_via,
+        $segnaletica_orizzontale_2_linea_margine,
+        $segnaletica_orizzontale_2_linea_margine_specifica,
+        $segnaletica_orizzontale_2_linea_mezzeria,
+        $segnaletica_orizzontale_2_linea_mezzeria_specifica,
+        $segnaletica_orizzontale_2_altro,
+        $segnaletica_orizzontale_2_direzione,
+        $segnaletica_orizzontale_3_via,
+        $segnaletica_orizzontale_3_linea_margine,
+        $segnaletica_orizzontale_3_linea_margine_specifica,
+        $segnaletica_orizzontale_3_linea_mezzeria,
+        $segnaletica_orizzontale_3_linea_mezzeria_specifica,
+        $segnaletica_orizzontale_3_altro,
+        $segnaletica_orizzontale_3_direzione,
+        $segnaletica_orizzontale_4_via,
+        $segnaletica_orizzontale_4_linea_margine,
+        $segnaletica_orizzontale_4_linea_margine_specifica,
+        $segnaletica_orizzontale_4_linea_mezzeria,
+        $segnaletica_orizzontale_4_linea_mezzeria_specifica,
+        $segnaletica_orizzontale_4_altro,
+        $segnaletica_orizzontale_4_direzione;
+
+    public $provinces = [];
+
+    public $tipo_urto = [];
+
+    // Dati
+    // public $localita = array();
+    // public $stradario = array();
+    public $rilievi = array();
+    public $tipi_danno = array();
+    public $parti_macchina = array();
+    public $entita_danni = array();
+    public $effetto_danni = array();
+    public $tipi_urto = array();
+    public $tipi_segnalazioni = array();
+    public $pervenute_da = array();
+    public $altri_enti = array();
+    public $materiali = array();
+    public $nomenclature = array();
+    public $condizioni_atmosferiche_array = array();
+    public $condizioni_luce_array = array();
+    public $pavimentazioni = array();
+    public $condizioni_strada = array();
+    public $fondi_stradali = array();
+    public $particolarita_strade = array();
+    public $tipi_strade = array();
+    public $grado_accertatore = array();
+    // public $veicoli = array();
+    // public $anagrafiche = array();
+    public $tipi_veicolo = array();
+    public $marche = array();
+    public $modelli = array();
+    public $polizze = array();
+    public $allegatiType = array();
+
+    // Anagrafica
+    public $currentAnagrafica;
+    public $anag_type;
+    public $anag_firstname;
+    public $anag_lastname;
+    public $anag_gender;
+    public $anag_birth_date;
+    public $anag_birth_town_id;
+    public $anag_birth_prov_id;
+    public $anag_residenza_town_id;
+    public $anag_residenza_prov_id;
+    public $anag_residenza_address;
+    public $anag_residenza_cap;
+    public $anag_mobile;
+    public $anag_sedicente;
+    public $anag_documento_tipo;
+    public $anag_documento_patente_cat;
+    public $anag_documento_tipo_altro;
+    public $anag_documento_numero;
+    public $anag_documento_rilasciato_da;
+    public $anag_documento_rilasciato_da_altro;
+    public $anag_foreign_country;
+    public $anag_documento_rilasciato_da_di_foreign_localita;
+    public $anag_documento_rilasciato_da_di_foreign_country;
+    public $anag_documento_rilasciato_da_prov_id;
+    public $anag_documento_rilasciato_da_town_id;
+    public $anag_documento_rilasciato_il;
+    public $anag_documento_scadenza_il;
+    public $anag_state;
+    public $anag_nazionalita;
+    public $anag_nazione_straniera;
+    public $anag_localita_straniera;
+    public $anag_rag_soc;
+    public $anag_vat;
+    public $anag_sede_legale_town_id;
+    public $anag_sede_legale_prov_id;
+    public $anag_sede_legale_address;
+    public $anag_sede_legale_cap;
+    public $anag_phone;
+    public $anag_foreign_birth_country;
+    public $anag_foreign_birth_city;
+    public $anag_foreign_residence_country;
+    public $anag_foreign_residence_city;
+
+
+    // Veicolo
+    public $currentVeicolo;
+    public $vei_tipo_id;
+    public $vei_marca_id;
+    public $vei_marca_altro;
+    public $vei_modello_id;
+    public $vei_modello_altro;
+    public $vei_colore;
+    public $vei_targa;
+    public $vei_carta_circolazione;
+    public $vei_carta_circolazione_rilasciata_da;
+    public $vei_carta_circolazione_rilasciata_da_altro;
+    public $vei_foreign_country;
+    public $vei_carta_circolazione_rilasciata_da_di_foreign_country;
+    public $vei_carta_circolazione_rilasciata_da_di_foreign_localita;
+    public $vei_carta_circolazione_rilasciata_da_di;
+    public $vei_carta_circolazione_rilasciata_il;
+    public $vei_data_ultima_revisione;
+    public $vei_cilindrata;
+    public $vei_peso_complessivo;
+    public $vei_destinazione_uso;
+    public $vei_state;
+
+    public $currentProprietario;
+    public $currentCoproprietario;
+    public $currentConducente;
+
+    // Data vaicoli
+    public $currentTeste;
+    public $currentProgressive;
+    public $data_chilometri_percorsi;
+    public $data_stato_veicolo;
+    public $data_polizze;
+    public $data_proprietari;
+    public $data_coproprietari;
+    public $data_conducente_uguale_proprietario;
+    public $data_conducenti;
+    public $data_infortunato;
+    public $data_infortunato_ospedale;
+    public $data_patente_al_seguito;
+    public $data_generalizzato;
+    public $data_generalizzato_altrove;
+    public $data_posizione_statica_finale;
+    public $data_danni_visibili_riportati;
+    public $data_danni_visibili_pre_esistenti;
+    public $data_destinazione_veicolo;
+    public $data_destinazione_veicolo_affidato_a;
+    public $data_destinazione_veicolo_sequestro_num_art;
+    public $data_destinazione_veicolo_amministrativo_num;
+    public $data_destinazione_veicolo_amministrativo_num_art_violato;
+    public $data_destinazione_veicolo_amministrativo_cds;
+    public $data_circostanze_presunte_incidente;
+    public $data_stato_pneumatici;
+    public $data_marca_pneumatici;
+    public $data_misura_pneumatici;
+    public $data_dispositivi_ottici;
+    public $data_tergicristalli;
+    public $data_segnale_pericolo;
+    public $data_abs;
+    public $data_gps;
+    public $data_marcia_inserita;
+    public $data_cristallo;
+    public $data_cristallo_posizione;
+    public $data_specchio_retrovisore;
+    public $data_specchio_lat_dx;
+    public $data_specchio_lat_sx;
+    public $data_attivazione_airbag;
+    public $data_airbag_posizione;
+    public $data_alcool_test;
+    public $data_alcool_test_esito;
+    public $data_drug_test;
+    public $data_drug_test_esito;
+    public $data_sistema_ritenuta_minori;
+    public $data_sistema_ritenuta_minori_omologazione;
+    public $data_verbale_violazione_numero_1;
+    public $data_articolo_violato_1;
+    public $data_cds_1;
+    public $data_verbale_violazione_numero_2;
+    public $data_articolo_violato_2;
+    public $data_cds_2;
+    public $data_verbale_violazione_numero_3;
+    public $data_articolo_violato_3;
+    public $data_cds_3;
+    public $data_conducente_patente_numero;
+    public $data_conducente_patente_categoria;
+    public $data_conducente_patente_rilasciata_da;
+    public $data_conducente_patente_rilasciata_da_altro;
+    public $data_conducente_patente_rilasciata_il;
+    public $data_conducente_patente_scadenza;
+    public $data_conducente_patente_prescrizioni;
+    public $data_conducente_patente_limitazioni_art_117_1;
+    public $data_conducente_patente_limitazioni_art_117_2;
+    public $data_conducente_patente_abilitazione;
+    public $data_conducente_patente_abilitazione_numero;
+    public $data_conducente_patente_abilitazione_rilasciata_da;
+    public $data_conducente_patente_abilitazione_rilasciata_il;
+    public $data_conducente_documento;
+    public $data_conducente_documento_numero;
+    public $data_conducente_sedicente;
+
+    public $data_tipo_danno;
+    public $data_entita_danno;
+    public $data_effetto_danno;
+    public $data_parte_macchina;
+
+    public $data_tipo_danno_2;
+    public $data_entita_danno_2;
+    public $data_effetto_danno_2;
+    public $data_parte_macchina_2;
+
+    public $data_tipo_danno_3;
+    public $data_entita_danno_3;
+    public $data_effetto_danno_3;
+    public $data_parte_macchina_3;
+    public $data_tipo_danno_4;
+    public $data_entita_danno_4;
+    public $data_effetto_danno_4;
+    public $data_parte_macchina_4;
+
+    public $data_cinture_conducente;
+    public $data_cinture_passeggeri_0;
+    public $data_cinture_passeggeri_1;
+    public $data_cinture_passeggeri_2;
+    public $data_cinture_passeggeri_3;
+
+    public $data_casco_conducente;
+    public $data_casco_passeggero;
+    public $data_casco_omologazione_conducente;
+    public $data_casco_omologazione_passeggero;
+
+    public $data_passeggero_0;
+    public $data_infortunato_0;
+    public $data_infortunato_ospedale_0;
+
+    public $data_passeggero_1;
+    public $data_infortunato_1;
+    public $data_infortunato_ospedale_1;
+
+    public $data_passeggero_2;
+    public $data_infortunato_2;
+    public $data_infortunato_ospedale_2;
+
+    public $data_passeggero_3;
+    public $data_infortunato_3;
+    public $data_infortunato_ospedale_3;
+
+    public $data_infortunato_extra_0;
+    public $data_infortunato_extra_1;
+    public $data_infortunato_extra_2;
+    public $data_infortunato_extra_3;
+
+    public $data_testi_oculari_0;
+    public $data_testi_oculari_stato_0;
+    public $data_testi_oculari_1;
+    public $data_testi_oculari_stato_1;
+    public $data_testi_oculari_2;
+    public $data_testi_oculari_stato_2;
+    public $data_testi_oculari_3;
+    public $data_testi_oculari_stato_3;
+
+    // Pedoni
+
+    public $currentPedone;
+    public $generalizzato;
+    public $generalizzato_altrove;
+    public $infortunato;
+    public $infortunato_ospedale;
+    public $pedone_posizione;
+    public $pedone_posizione_desc;
+    public $pedone_referto;
+    public $pedone_prognosi;
+    public $pedone_pioggia;
+    public $pedone_ombrello;
+    public $pedone_notte;
+    public $pedone_abiti_scuri;
+    public $verbale_violazione_numero;
+    public $articolo_violato;
+    public $cds;
+
+    public $noteText;
+    public $notes;
+
+    public $richiestaId;
+    public $richiestaAnagrafica;
+    public $richiestaData;
+    public $richiestaConsegna;
+    public $richiestaText;
+    public $richieste;
+
+    public $allegatoId;
+    public $allegatoType;
+    public $allegatoGallery;
+    public $allegatoName;
+    public $allegatoVisible;
+    public $allegatoFiles;
+    public $allegatiFiles;
+    public $allegatiImmagini;
+    public $allegatiDocumenti;
+
+    // Accertatore
+    public $currentAccertatore;
+    public $currentAccertatoreNumero;
+    public $accertatore_nome;
+    public $accertatore_cognome;
+    public $accertatore_grado;
+    public $accertatore_username;
+    public $accertatore_email;
+    public $accertatore_password;
+    public $accertatore_password_conferma;
+
+    public $allegati = [];
+
+    public function updatedAllegati()
+    {
+        foreach ($this->allegati as $allegato)
+        {
+            $name = $allegato->getClientOriginalName(); //  . '.'.$allegato->extension();
+            $allegato->storeAs('public', $name);
+            $this->allegatiFiles[] = $name;
+        }
+        $this->emit('attachments', implode("|", $this->allegatiFiles));
+        $this->allegati = [];
+    }
+
+    protected $rules = [
+        //'name' => 'required'
+    ];
+
+    protected $messages = [
+        'localita_uno.required' => 'Il campo località è obbligatorio ai fini della validazione del verbale',
+        'localita_due.required' => 'Il campo indirizzo è obbligatorio ai fini della validazione del verbale',
+        'verificatosi_in_data.required' => 'Il campo verificatosi in data è obbligatorio ai fini della validazione del verbale',
+        'verificatosi_in_data_ora.required' => 'Il campo verificatosi alle ore è obbligatorio ai fini della validazione del verbale',
+        'verificatosi_in_data_minuti.required' => 'Il campo verificatosi alle ore/minuti è obbligatorio ai fini della validazione del verbale',
+        'rilievi_id.required' => 'Il campo tipo di rilievo è obbligatorio per la validazione del verbale',
+        'segnalazione_data.required' => 'Il campo segnalazione data è obbligatorio ai fini della validazione del verbale',
+        'segnalazione_ora.required' => 'Il campo ora segnalazione è obbligatorio ai fini della validazione del verbale',
+        'segnalazione_minuti.required' => 'Il campo minuti segnalazione è obbligatorio ai fini della validazione del verbale',
+        'sinistro_ora.required' => 'Il campo ora sinistro è obbligatorio ai fini della validazione del verbale',
+        'sinistro_minuti.required' => 'Il campo minuti intervento è obbligatorio ai fini della validazione del verbale',
+        'localizzazione_incidente.required' => 'Il campo localizzazione incidente strada è obbligatorio ai fini della validazione del verbale',
+        'nomenclatura_strada.required' => 'Il campo nomenclatura strada è obbligatorio ai fini della validazione del verbale',
+        'condizioni_atmosferiche.required' => 'Il campo condizioni atmosferiche è obbligatorio ai fini della validazione del verbale',
+        'pavimentazione.required' => 'Il campo pavimentazione è obbligatorio ai fini della validazione del verbale',
+        'condizione_strada.required' => 'Il campo condizione strada è obbligatorio ai fini della validazione del verbale',
+        'fondo_stradale.required' => 'Il campo fondo stradale è obbligatorio ai fini della validazione del verbale',
+        'visibilita.required' => 'Il campo visibilita è obbligatorio ai fini della validazione del verbale',
+        'particolarita_strada.required' => 'Il campo particolarità strada è obbligatorio ai fini della validazione del verbale',
+    ];
+
+    public function resetFields(){
+        $this->name = '';
+        $this->validated = false;
+        $this->necessita_nulla_osta = false;
+        $this->data_nulla_osta = $this->dateToNull();
+        $this->protocollo_num = '';
+        $this->protocollo_ord = '';
+        $this->protocollo_anno = '';
+        $this->verificatosi_in_data = null;
+        $this->verificatosi_in_data_ora = '';
+        $this->verificatosi_in_data_minuti = '';
+        $this->utg = false;
+        $this->utg_data = null;
+        $this->utg_protocollo = '';
+        $this->ag = false;
+        $this->ag_data = null;
+        $this->ag_protocollo = '';
+        $this->incidente_con_danni_a_cose = false;
+        $this->incidente_con_feriti = false;
+        $this->incidente_con_feriti_lesioni_lievi = false;
+        $this->incidente_con_feriti_lesioni_gravi = false;
+        $this->incidente_mortale = false;
+        $this->localita_uno = '';
+        $this->localita_due = '';
+        $this->intersezione_con = '';
+        $this->prossimita_civico = '';
+        $this->prossimita_palo_luce = '';
+        $this->prossimita_chilometro = '';
+        $this->note_aggiuntive = '';
+
+        $this->accertatore_1 = '';
+        $this->grado_accertatore_1 = '';
+        $this->accertatore_2 = '';
+        $this->grado_accertatore_2 = '';
+        $this->accertatore_3 = '';
+        $this->grado_accertatore_3 = '';
+        $this->accertatore_4 = '';
+        $this->grado_accertatore_4 = '';
+        $this->accertatore_5 = '';
+        $this->grado_accertatore_5 = '';
+
+        $this->parti_coinvolte = [];
+
+        $this->rilievi_id = null;
+        $this->tipo_urto = [];
+
+        $this->tipo_segnalazione = [];
+        $this->segnalazione_pervenuta_da = [];
+        $this->ausilio_altri_enti = [];
+        $this->segnalazione_data = null;
+        $this->segnalazione_ora = '';
+        $this->segnalazione_minuti = '';
+        $this->segnalazione_altro = '';
+        $this->ausilio_altri_enti_motivo = '';
+        $this->ausilio_altri_enti_ora_intervento = '';
+        $this->ausilio_altri_enti_minuti_intervento = '';
+        $this->ditta_intervenuta = '';
+        $this->ripristino_ora_chiamata = '';
+        $this->ripristino_minuti_chiamata = '';
+        $this->ripristino_ora_arrivo = '';
+        $this->ripristino_minuti_arrivo = '';
+        $this->materiale_recuperato = [];
+        $this->danni_cose_diverse_da_veicoli = '';
+
+        $this->condizioni_luce = [];
+        $this->tipo_strada = [];
+        $this->sinistro_ora = '';
+        $this->sinistro_minuti = '';
+        $this->localizzazione_incidente = '';
+        $this->localizzazione_incidente_altro = '';
+        $this->condizioni_atmosferiche = '';
+        $this->condizioni_atmosferiche_altro = '';
+        $this->nomenclatura_strada = '';
+        $this->nomenclatura_strada_numero = '';
+        $this->nomenclatura_strada_altro = '';
+        $this->pavimentazione = '';
+        $this->pavimentazione_altro = '';
+        $this->condizione_strada = '';
+        $this->condizione_strada_altro = '';
+        $this->fondo_stradale = '';
+        $this->fondo_stradale_specifica = '';
+        $this->visibilita = '';
+        $this->visibilita_specifica = '';
+        $this->particolarita_strada = '';
+        $this->particolarita_strada_specifica = '';
+        // $this->tipo_strada = '';
+        $this->tipo_strada_altro = '';
+        $this->traffico = '';
+
+        $this->segnaletica_verticale_1 = [];
+        $this->segnaletica_verticale_2 = [];
+        $this->segnaletica_verticale_3 = [];
+        $this->segnaletica_verticale_4 = [];
+
+        $this->segnaletica_orizzontale_1 = [];
+        $this->segnaletica_orizzontale_2 = [];
+        $this->segnaletica_orizzontale_3 = [];
+        $this->segnaletica_orizzontale_4 = [];
+
+        $this->segnaletica = '';
+        $this->segnaletica_verticale_1_via = '';
+        $this->segnaletica_verticale_1_altro = '';
+        $this->segnaletica_verticale_1_limite_velocita = '';
+        $this->segnaletica_verticale_1_direzione = '';
+        $this->segnaletica_verticale_1_pannello_integrativo = '';
+        $this->segnaletica_verticale_2_via = '';
+        $this->segnaletica_verticale_2_altro = '';
+        $this->segnaletica_verticale_2_limite_velocita = '';
+        $this->segnaletica_verticale_2_direzione = '';
+        $this->segnaletica_verticale_2_pannello_integrativo = '';
+        $this->segnaletica_verticale_3_via = '';
+        $this->segnaletica_verticale_3_altro = '';
+        $this->segnaletica_verticale_3_limite_velocita = '';
+        $this->segnaletica_verticale_3_direzione = '';
+        $this->segnaletica_verticale_3_pannello_integrativo = '';
+        $this->segnaletica_verticale_4_via = '';
+        $this->segnaletica_verticale_4_altro = '';
+        $this->segnaletica_verticale_4_limite_velocita = '';
+        $this->segnaletica_verticale_4_direzione = '';
+        $this->segnaletica_verticale_4_pannello_integrativo = '';
+        $this->segnaletica_orizzontale_1_via = '';
+        $this->segnaletica_orizzontale_1_linea_margine = '';
+        $this->segnaletica_orizzontale_1_linea_margine_specifica = '';
+        $this->segnaletica_orizzontale_1_linea_mezzeria = '';
+        $this->segnaletica_orizzontale_1_linea_mezzeria_specifica = '';
+        $this->segnaletica_orizzontale_1_altro = '';
+        $this->segnaletica_orizzontale_1_direzione = '';
+        $this->segnaletica_orizzontale_2_via = '';
+        $this->segnaletica_orizzontale_2_linea_margine = '';
+        $this->segnaletica_orizzontale_2_linea_margine_specifica = '';
+        $this->segnaletica_orizzontale_2_linea_mezzeria = '';
+        $this->segnaletica_orizzontale_2_linea_mezzeria_specifica = '';
+        $this->segnaletica_orizzontale_2_altro;
+        $this->segnaletica_orizzontale_2_direzione;
+        $this->segnaletica_orizzontale_3_via = '';
+        $this->segnaletica_orizzontale_3_linea_margine = '';
+        $this->segnaletica_orizzontale_3_linea_margine_specifica = '';
+        $this->segnaletica_orizzontale_3_linea_mezzeria = '';
+        $this->segnaletica_orizzontale_3_linea_mezzeria_specifica = '';
+        $this->segnaletica_orizzontale_3_altro;
+        $this->segnaletica_orizzontale_3_direzione;
+        $this->segnaletica_orizzontale_4_via = '';
+        $this->segnaletica_orizzontale_4_linea_margine = '';
+        $this->segnaletica_orizzontale_4_linea_margine_specifica = '';
+        $this->segnaletica_orizzontale_4_linea_mezzeria = '';
+        $this->segnaletica_orizzontale_4_linea_mezzeria_specifica = '';
+        $this->segnaletica_orizzontale_4_altro;
+        $this->segnaletica_orizzontale_4_direzione;
+
+        $this->noteText = '';
+        $this->notes = [];
+
+        $this->richiestaId = 0;
+        $this->richiestaAnagrafica = null;
+        $this->richiestaData = null;
+        $this->richiestaConsegna = null;
+        $this->richiestaText = '';
+        $this->richieste = [];
+
+        $this->allegatoId = 0;
+        $this->allegatoType = 0;
+        $this->allegatoGallery = 0;
+        $this->allegatoName = '';
+        $this->allegatoVisible = false;
+        $this->allegatoFiles = '';
+        $this->allegatiFiles = [];
+        $this->allegatiImmagini = [];
+        $this->allegatiDocumenti = [];
+
+        $this->data_testi_oculari_0 = 0;
+        $this->data_testi_oculari_stato_0 = 0;
+        $this->data_testi_oculari_1 = 0;
+        $this->data_testi_oculari_stato_1 = 0;
+        $this->data_testi_oculari_2 = 0;
+        $this->data_testi_oculari_stato_2 = 0;
+        $this->data_testi_oculari_3 = 0;
+        $this->data_testi_oculari_stato_3 = 0;
+
+        $this->div_segnaletica_verticale_2 = false;
+        $this->div_segnaletica_verticale_3 = false;
+        $this->div_segnaletica_verticale_4 = false;
+
+        $this->div_segnaletica_orizzontale_2 = false;
+        $this->div_segnaletica_orizzontale_3 = false;
+        $this->div_segnaletica_orizzontale_4 = false;
+
+        $this->emit('load-select');
+    }
+
+    public function showSegnaleticaVerticale()
+    {
+        if (!$this->div_segnaletica_verticale_2)
+        {
+            $this->div_segnaletica_verticale_2 = true;
+        }
+        else
+        {
+            if (!$this->div_segnaletica_verticale_3)
+            {
+                $this->div_segnaletica_verticale_3 = true;
+            }
+            else
+            {
+                if (!$this->div_segnaletica_verticale_4)
+                {
+                    $this->div_segnaletica_verticale_4 = true;
+                }
+            }
+        }
+    }
+
+    public function showSegnaleticaOrizzontale()
+    {
+        if (!$this->div_segnaletica_orizzontale_2)
+        {
+            $this->div_segnaletica_orizzontale_2 = true;
+        }
+        else
+        {
+            if (!$this->div_segnaletica_orizzontale_3)
+            {
+                $this->div_segnaletica_orizzontale_3 = true;
+            }
+            else
+            {
+                if (!$this->div_segnaletica_orizzontale_4)
+                {
+                    $this->div_segnaletica_orizzontale_4 = true;
+                }
+            }
+        }
+    }
+
+    public function resetAnagrafica()
+    {
+        $this->loadAnagrafica = '';
+        $this->currentAnagrafica = 0;
+        $this->currentPasseggero = 0;
+        $this->currentInfortunato = 0;
+        $this->currentProprietario = 0;
+        $this->currentCoproprietario = 0;
+        $this->currentConducente = 0;
+        $this->currentTeste = 0;
+        //$this->currentProgressive = -1;
+        $this->anag_type = 0;
+        $this->anag_firstname = '';
+        $this->anag_lastname = '';
+        $this->anag_gender = '';
+        $this->anag_birth_date = null;
+        $this->anag_birth_town_id = null;
+        $this->anag_birth_prov_id = null;
+        $this->anag_residenza_town_id = null;
+        $this->anag_residenza_prov_id = null;
+        $this->anag_residenza_address = '';
+        $this->anag_residenza_cap = '';
+        $this->anag_mobile = '';
+        $this->anag_sedicente;
+        $this->anag_documento_tipo = '';
+        $this->anag_documento_patente_cat = '';
+        $this->anag_documento_tipo_altro = '';
+        $this->anag_documento_numero = '';
+        $this->anag_documento_rilasciato_da = '';
+        $this->anag_documento_rilasciato_da_altro = '';
+        $this->anag_foreign_country = null;
+        $this->anag_documento_rilasciato_da_di_foreign_localita = null;
+        $this->anag_documento_rilasciato_da_di_foreign_country = null;
+        $this->anag_documento_rilasciato_da_prov_id = null;
+        $this->anag_documento_rilasciato_da_town_id = null;
+        $this->anag_documento_rilasciato_il = '';
+        $this->anag_documento_scadenza_il = '';
+        $this->anag_state = '';
+        $this->anag_nazionalita = '';
+        $this->anag_nazione_straniera = '';
+        $this->anag_localita_straniera = '';
+        $this->anag_rag_soc = '';
+        $this->anag_vat = '';
+        $this->anag_sede_legale_town_id = null;
+        $this->anag_sede_legale_prov_id = null;
+        $this->anag_sede_legale_address = '';
+        $this->anag_sede_legale_cap = '';
+        $this->anag_phone = '';
+    }
+
+    public function resetVeicolo()
+    {
+        $this->loadTarga = '';
+        $this->currentVeicolo = 0;
+        $this->currentProgressive = -1;
+        $this->vei_tipo_id = null;
+        $this->vei_marca_id = null;
+        $this->vei_marca_altro = '';
+        $this->vei_modello_id = null;
+        $this->vei_modello_altro = '';
+        $this->vei_colore = '';
+        $this->vei_targa = '';
+        $this->vei_carta_circolazione = '';
+        $this->vei_carta_circolazione_rilasciata_da = '';
+        $this->vei_carta_circolazione_rilasciata_da_altro = '';
+        $this->vei_foreign_country = null;
+        $this->vei_carta_circolazione_rilasciata_da_di_foreign_country = null;
+        $this->vei_carta_circolazione_rilasciata_da_di_foreign_localita = null;
+        $this->vei_carta_circolazione_rilasciata_da_di = '';
+        $this->vei_carta_circolazione_rilasciata_il = null;
+        $this->vei_data_ultima_revisione = null;
+        $this->vei_cilindrata = '';
+        $this->vei_peso_complessivo = '';
+        $this->vei_destinazione_uso = '';
+        $this->vei_state = '';
+    }
+
+    public function resetVeicoloData()
+    {
+
+        $this->currentVeicolo = 0;
+        $this->currentProgressive = -1;
+        $this->data_chilometri_percorsi = 0;
+        $this->data_stato_veicolo = null;
+        $this->data_polizze = null;
+        $this->data_proprietari = null;
+        $this->data_coproprietari = null;
+        $this->data_conducente_uguale_proprietario = true;
+        $this->data_conducenti = null;
+        $this->data_infortunato = null;
+        $this->data_infortunato_ospedale = '';
+        $this->data_patente_al_seguito = null;
+        $this->data_generalizzato = null;
+        $this->data_generalizzato_altrove = '';
+        $this->data_posizione_statica_finale = null;
+        $this->data_danni_visibili_riportati = '';
+        $this->data_danni_visibili_pre_esistenti = '';
+        $this->data_destinazione_veicolo = null;
+        $this->data_destinazione_veicolo_affidato_a = '';
+        $this->data_destinazione_veicolo_sequestro_num_art = '';
+        $this->data_destinazione_veicolo_amministrativo_num = '';
+        $this->data_destinazione_veicolo_amministrativo_num_art_violato = '';
+        $this->data_destinazione_veicolo_amministrativo_cds = '';
+        $this->data_circostanze_presunte_incidente = '';
+        $this->data_stato_pneumatici = null;
+        $this->data_marca_pneumatici = '';
+        $this->data_misura_pneumatici = '';
+        $this->data_dispositivi_ottici = null;
+        $this->data_tergicristalli = null;
+        $this->data_segnale_pericolo = null;
+        $this->data_abs = null;
+        $this->data_gps = null;
+        $this->data_marcia_inserita = null;
+        $this->data_cristallo = null;
+        $this->data_cristallo_posizione = '';
+        $this->data_specchio_retrovisore = null;
+        $this->data_specchio_lat_dx = null;
+        $this->data_specchio_lat_sx = null;
+        $this->data_attivazione_airbag = null;
+        $this->data_airbag_posizione = '';
+        $this->data_alcool_test = null;
+        $this->data_alcool_test_esito = null;
+        $this->data_drug_test = null;
+        $this->data_drug_test_esito = null;
+        $this->data_sistema_ritenuta_minori = null;
+        $this->data_sistema_ritenuta_minori_omologazione = '';
+        $this->data_verbale_violazione_numero_1 = '';
+        $this->data_articolo_violato_1 = '';
+        $this->data_cds_1 = '';
+        $this->data_verbale_violazione_numero_2 = '';
+        $this->data_articolo_violato_2 = '';
+        $this->cds_2 = '';
+        $this->data_verbale_violazione_numero_3 = '';
+        $this->data_articolo_violato_3 = '';
+        $this->data_cds_3 = '';
+        $this->data_conducente_patente_numero = '';
+        $this->data_conducente_patente_categoria = '';
+        $this->data_conducente_patente_rilasciata_da = null;
+        $this->data_conducente_patente_rilasciata_da_altro = '';
+        $this->data_conducente_patente_rilasciata_il = null;
+        $this->data_conducente_patente_scadenza = null;
+        $this->data_conducente_patente_prescrizioni = null;
+        $this->data_conducente_patente_limitazioni_art_117_1 = '';
+        $this->data_conducente_patente_limitazioni_art_117_2 = '';
+        $this->data_conducente_patente_abilitazione = null;
+        $this->data_conducente_patente_abilitazione_numero = '';
+        $this->data_conducente_patente_abilitazione_rilasciata_da = null;
+        $this->data_conducente_patente_abilitazione_rilasciata_il = null;
+        $this->data_conducente_documento = null;
+        $this->data_conducente_documento_numero = '';
+        $this->data_conducente_sedicente = null;
+        $this->data_tipo_danno = null;
+        $this->data_entita_danno = null;
+        $this->data_effetto_danno = null;
+        $this->data_parte_macchina = null;
+        $this->data_tipo_danno_2 = null;
+        $this->data_entita_danno_2 = null;
+        $this->data_effetto_danno_2 = null;
+        $this->data_parte_macchina_2 = null;
+        $this->data_tipo_danno_3 = null;
+        $this->data_entita_danno_3 = null;
+        $this->data_effetto_danno_3 = null;
+        $this->data_parte_macchina_3 = null;
+        $this->data_tipo_danno_4 = null;
+        $this->data_entita_danno_4 = null;
+        $this->data_effetto_danno_4 = null;
+        $this->data_parte_macchina_4 = null;
+
+        $this->data_cinture_conducente = '';
+        $this->data_cinture_passeggeri_0 = '';
+        $this->data_cinture_passeggeri_1 = '';
+        $this->data_cinture_passeggeri_2 = '';
+        $this->data_cinture_passeggeri_3 = '';
+
+        $this->data_casco_conducente = '';
+        $this->data_casco_passeggero = '';
+        $this->data_casco_omologazione_conducente = '';
+        $this->data_casco_omologazione_passeggero = '';
+
+        $this->data_passeggero_0 = 0;
+        $this->data_infortunato_0 = 0;
+        $this->data_infortunato_ospedale_0 = '';
+
+        $this->data_passeggero_1 = 0;
+        $this->data_infortunato_1 = 0;
+        $this->data_infortunato_ospedale_1 = '';
+
+        $this->data_passeggero_2 = 0;
+        $this->data_infortunato_2 = 0;
+        $this->data_infortunato_ospedale_2 = '';
+
+        $this->data_passeggero_3 = 0;
+        $this->data_infortunato_3 = 0;
+        $this->data_infortunato_ospedale_3 = '';
+
+        $this->data_infortunato_extra_0 = 0;
+        $this->data_infortunato_extra_1 = 0;
+        $this->data_infortunato_extra_2 = 0;
+        $this->data_infortunato_extra_3 = 0;
+
+    }
+
+    public function resetPedoniData()
+    {
+
+        $this->currentPedone = 0;
+        $this->generalizzato = '';
+        $this->generalizzato_altrove = '';
+        $this->infortunato = '';
+        $this->infortunato_ospedale = '';
+        $this->pedone_posizione = '';
+        $this->pedone_posizione_desc = '';
+        $this->pedone_referto = '';
+        $this->pedone_prognosi = '';
+        $this->pedone_pioggia = '';
+        $this->pedone_ombrello = '';
+        $this->pedone_notte = '';
+        $this->pedone_abiti_scuri = '';
+        $this->verbale_violazione_numero = '';
+        $this->articolo_violato = '';
+        $this->cds = '';
+
+    }
+
+    public function resetAccertatore()
+    {
+        $this->currentAccertatore = 0;
+        $this->currentAccertatoreNumero = 0;
+        $this->accertatore_nome = '';
+        $this->accertatore_cognome = '';
+        $this->accertatore_grado = 0;
+        $this->accertatore_username = '';
+        $this->accertatore_email = '';
+        $this->accertatore_password = '';
+        $this->accertatore_password_conferma = '';
+    }
+
+    public function hydrate()
+    {
+        $this->emit('load-select');
+        $this->emit('load-check');
+    }
+
+    public function updatingSearch()
+    {
+        $this->resetPage();
+    }
+
+    public function mount()
+    {
+        // $this->localita = \App\Models\LocationTown::orderBy('title')->get();
+        // $this->stradario = \App\Models\Stradario::orderBy('descrizione')->get();
+        $this->provinces = \App\Models\LocationProvince::orderBy('title')->get();
+        $this->rilievi = \App\Models\Rilievi::orderBy('name')->get();
+        $this->tipi_urto = \App\Models\TipoUrto::orderBy('name')->get();
+        $this->tipi_danno = \App\Models\TipoDanno::orderBy('name')->get();
+        $this->entita_danni = \App\Models\EntitaDanno::orderBy('name')->get();
+        $this->effetto_danni = \App\Models\EffettoDanno::orderBy('name')->get();
+        $this->parti_macchina = \App\Models\ParteMacchina::orderBy('name')->get();
+        $this->tipi_veicolo = \App\Models\TipoVeicolo::orderBy('name')->get();
+        $this->marche = \App\Models\MarcaVeicolo::orderBy('name')->get();
+        $this->modelli = \App\Models\ModelloVeicolo::orderBy('name')->get();
+        $this->tipi_segnalazioni = \App\Models\TipoSegnalazione::orderBy('name')->get();
+        $this->pervenute_da = \App\Models\SegnalazionePervenutaDa::orderBy('name')->get();
+        $this->altri_enti = \App\Models\AusilioAltriEnti::orderBy('name')->get();
+        $this->materiali = \App\Models\MaterialeRecuperato::orderBy('name')->get();
+        $this->nomenclature = \App\Models\NomenclaturaStrada::orderBy('name')->get();
+        $this->condizioni_atmosferiche_array = \App\Models\CondizioniAtmosferiche::orderBy('name')->get();
+        $this->condizioni_luce_array = \App\Models\CondizioniLuce::orderBy('name')->get();
+        $this->pavimentazioni = \App\Models\PavimentazioneStrada::orderBy('name')->get();
+        $this->condizioni_strada = \App\Models\CondizioneStrada::orderBy('name')->get();
+        $this->fondi_stradali = \App\Models\FondoStradale::orderBy('name')->get();
+        $this->particolarita_strade = \App\Models\ParticolaritaStrada::orderBy('name')->get();
+        $this->tipi_strade = \App\Models\TipoStrada::orderBy('name')->get();
+        $this->grado_accertatore = \App\Models\AccertatoreGrado::orderBy('name')->get();
+        $this->segnaletica_verticale = \App\Models\SegnalazioneVerticale::orderBy('name')->get();
+        $this->segnaletica_orizzontale = \App\Models\SegnalazioneOrizzontale::orderBy('name')->get();
+        // $this->anagrafiche = \App\Models\Anagrafica::orderBy('lastname')->orderBy('firstname')->get();
+        // $this->veicoli = \App\Models\Vehicle::with('marca')->with('modello')->get()->sortBy('marca.name',SORT_REGULAR,false);
+        $this->allegatiType = \App\Models\AllegatiGalleryType::orderBy('name')->get();
+
+        // $this->polizze = array();
+    }
+
+    public function render()
+    {
+        $rows = \App\Models\Report::query()
+            ->leftJoin('fcf_reports_stradario', 'fcf_reports_reports.localita_due', '=', 'fcf_reports_stradario.id')
+            ->where(function($query) {
+                $query->where('fcf_reports_reports.name', 'like', '%'.$this->search.'%')
+                      ->orWhere('fcf_reports_stradario.descrizione', 'like', '%'.$this->search.'%');
+            })
+            ->select('fcf_reports_reports.*')
+            ->orderBy('protocollo_anno', 'DESC')
+            ->orderBy('protocollo_num', 'DESC')
+            ->paginate(10);
+
+        return view('livewire.report', ['records' => $rows]);
+    }
+    public function add()
+    {
+        $this->resetFields();
+        try {
+
+            $this->protocollo_num = \DB::table('fcf_reports_reports')->where('protocollo_anno', date('Y'))->max('protocollo_num') + 1;
+            $this->protocollo_anno = date('Y');
+            $this->name = $this->protocollo_num . "/" . $this->protocollo_anno;
+            $record = \App\Models\Report::create([
+                'name' => $this->name,
+                'protocollo_num' => $this->protocollo_num,
+                'protocollo_anno' => $this->protocollo_anno,
+                'validated' => $this->validated,
+                'necessita_nulla_osta' => $this->necessita_nulla_osta,
+                'data_nulla_osta' => $this->data_nulla_osta,
+
+            ]);
+            session()->flash('success','Record creato');
+            $this->edit($record->id);
+        } catch (\Exception $ex) {
+            //$this->add = true;
+        //$this->update = true;
+            session()->flash('error','Errore in fase di salvataggio (' . $ex->getMessage() . ')');
+        }
+
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\Report::create([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio');
+        }
+    }
+
+    public function edit($idReport){
+        $this->resetFields();
+        try {
+            $record = \App\Models\Report::findOrFail($idReport);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+
+                // Generale
+                $this->name = $record->name;
+                $this->validated = $record->validated;
+                $this->necessita_nulla_osta = $record->necessita_nulla_osta;
+                $this->data_nulla_osta = $record->data_nulla_osta;
+                $this->protocollo_num = $record->protocollo_num;
+                $this->protocollo_ord = $record->protocollo_ord;
+                $this->protocollo_anno = $record->protocollo_anno;
+                $this->verificatosi_in_data = $record->verificatosi_in_data;
+                $this->verificatosi_in_data_ora = $record->verificatosi_in_data_ora;
+                $this->verificatosi_in_data_minuti = $record->verificatosi_in_data_minuti;
+                $this->utg = $record->utg;
+                $this->utg_data = $record->utg_data;
+                $this->utg_protocollo = $record->utg_protocollo;
+                $this->ag = $record->ag;
+                $this->ag_data = $record->ag_data;
+                $this->ag_protocollo = $record->ag_protocollo;
+                $this->incidente_con_danni_a_cose = $record->incidente_con_danni_a_cose;
+                $this->incidente_con_feriti = $record->incidente_con_feriti;
+                $this->incidente_con_feriti_lesioni_lievi = $record->incidente_con_feriti_lesioni_lievi;
+                $this->incidente_con_feriti_lesioni_gravi = $record->incidente_con_feriti_lesioni_gravi;
+                $this->incidente_mortale = $record->incidente_mortale;
+                $this->localita_uno = $record->localita_uno;
+                $this->localita_due = $record->localita_due;
+                $this->intersezione_con = $record->intersezione_con;
+                $this->prossimita_civico = $record->prossimita_civico;
+                $this->prossimita_palo_luce = $record->prossimita_palo_luce;
+                $this->prossimita_chilometro = $record->prossimita_chilometro;
+                $this->note_aggiuntive = $record->note_aggiuntive;
+
+                $this->accertatore_1 = $record->accertatore_1;
+                $this->grado_accertatore_1 = $record->grado_accertatore_1;
+                $this->accertatore_2 = $record->accertatore_2;
+                $this->grado_accertatore_2 = $record->grado_accertatore_2;
+                $this->accertatore_3 = $record->accertatore_3;
+                $this->grado_accertatore_3 = $record->grado_accertatore_3;
+                $this->accertatore_4 = $record->accertatore_4;
+                $this->grado_accertatore_4 = $record->grado_accertatore_4;
+                $this->accertatore_5 = $record->accertatore_5;
+                $this->grado_accertatore_5 = $record->grado_accertatore_5;
+
+                $this->parti_coinvolte = \App\Models\ReportDataPartiCoinvolte::where('report_id', $idReport)->get();
+
+                $this->tipo_urto = \App\Models\ReportTipoUrto::where('report_id', $idReport)->pluck('tipo_urto_id');
+
+                $this->rilievi_id = $record->rilievi_id;
+
+                $this->segnalazione_data = $record->segnalazione_data;
+                $this->segnalazione_ora = $record->segnalazione_ora;
+                $this->segnalazione_minuti = $record->segnalazione_minuti;
+                $this->segnalazione_altro = $record->segnalazione_altro;
+                $this->ausilio_altri_enti_motivo = $record->ausilio_altri_enti_motivo;
+                $this->ausilio_altri_enti_ora_intervento = $record->ausilio_altri_enti_ora_intervento;
+                $this->ausilio_altri_enti_minuti_intervento = $record->ausilio_altri_enti_minuti_intervento;
+                $this->ditta_intervenuta = $record->ditta_intervenuta;
+                $this->ripristino_ora_chiamata = $record->ripristino_ora_chiamata;
+                $this->ripristino_minuti_chiamata = $record->ripristino_minuti_chiamata;
+                $this->ripristino_ora_arrivo = $record->ripristino_ora_arrivo;
+                $this->ripristino_minuti_arrivo = $record->ripristino_minuti_arrivo;
+                $this->danni_cose_diverse_da_veicoli = $record->danni_cose_diverse_da_veicoli;
+
+                $this->tipo_segnalazione = \App\Models\ReportTipoSegnalazione::where('report_id', $idReport)->pluck('tipo_segnalazione_id');
+                $this->segnalazione_pervenuta_da = \App\Models\ReportSegnalazionePervenutaDa::where('report_id', $idReport)->pluck('segnalazione_pervenuta_da_id');
+
+                $this->materiale_recuperato = \App\Models\ReportMaterialeRecuperato::where('report_id', $idReport)->pluck('materiale_recuperato_id');
+                $this->ausilio_altri_enti = \App\Models\ReportAusilioAltriEnti::where('report_id', $idReport)->pluck('ausilio_altri_enti_id');
+
+                $this->condizioni_luce = \App\Models\ReportCondizioniLuce::where('report_id', $idReport)->pluck('condizioni_luce_id');
+                $this->tipo_strada = \App\Models\ReportTipoStrada::where('report_id', $idReport)->pluck('tipo_strada_id');
+
+                $this->sinistro_ora = $record->sinistro_ora;
+                $this->sinistro_minuti = $record->sinistro_minuti;
+                $this->localizzazione_incidente = $record->localizzazione_incidente;
+                $this->localizzazione_incidente_altro = $record->localizzazione_incidente_altro;
+                $this->condizioni_atmosferiche = $record->condizioni_atmosferiche;
+                $this->condizioni_atmosferiche_altro = $record->condizioni_atmosferiche_altro;
+                $this->nomenclatura_strada = $record->nomenclatura_strada;
+                $this->nomenclatura_strada_numero = $record->nomenclatura_strada_numero;
+                $this->nomenclatura_strada_altro = $record->nomenclatura_strada_altro;
+                $this->pavimentazione = $record->pavimentazione;
+                $this->pavimentazione_altro = $record->pavimentazione_altro;
+                $this->condizione_strada = $record->condizione_strada;
+                $this->condizione_strada_altro = $record->condizione_strada_altro;
+                $this->fondo_stradale = $record->fondo_stradale;
+                $this->fondo_stradale_specifica = $record->fondo_stradale_specifica;
+                $this->visibilita = $record->visibilita;
+                $this->visibilita_specifica = $record->visibilita_specifica;
+                $this->particolarita_strada = $record->particolarita_strada;
+                $this->particolarita_strada_specifica = $record->particolarita_strada_specifica;
+                // $this->tipo_strada = $record->tipo_strada;
+                $this->tipo_strada_altro = $record->tipo_strada_altro;
+                $this->traffico = $record->traffico;
+
+                $this->segnaletica_verticale_1 = \App\Models\ReportSegnaleticaVerticale1::where('report_id', $idReport)->pluck('segnaletica_verticale_id');
+                $this->segnaletica_verticale_2 = \App\Models\ReportSegnaleticaVerticale2::where('report_id', $idReport)->pluck('segnaletica_verticale_id');
+                $this->segnaletica_verticale_3 = \App\Models\ReportSegnaleticaVerticale3::where('report_id', $idReport)->pluck('segnaletica_verticale_id');
+                $this->segnaletica_verticale_4 = \App\Models\ReportSegnaleticaVerticale4::where('report_id', $idReport)->pluck('segnaletica_verticale_id');
+
+                $this->segnaletica_orizzontale_1 = \App\Models\ReportSegnaleticaOrizzontale1::where('report_id', $idReport)->pluck('segnaletica_orizzontale_id');
+                $this->segnaletica_orizzontale_2 = \App\Models\ReportSegnaleticaOrizzontale2::where('report_id', $idReport)->pluck('segnaletica_orizzontale_id');
+                $this->segnaletica_orizzontale_3 = \App\Models\ReportSegnaleticaOrizzontale3::where('report_id', $idReport)->pluck('segnaletica_orizzontale_id');
+                $this->segnaletica_orizzontale_4 = \App\Models\ReportSegnaleticaOrizzontale4::where('report_id', $idReport)->pluck('segnaletica_orizzontale_id');
+
+                $this->segnaletica = $record->segnaletica;
+                $this->segnaletica_verticale_1_via = $record->segnaletica_verticale_1_via;
+                $this->segnaletica_verticale_1_altro = $record->segnaletica_verticale_1_altro;
+                $this->segnaletica_verticale_1_limite_velocita = $record->segnaletica_verticale_1_limite_velocita;
+                $this->segnaletica_verticale_1_direzione = $record->segnaletica_verticale_1_direzione;
+                $this->segnaletica_verticale_1_pannello_integrativo = $record->segnaletica_verticale_1_pannello_integrativo;
+                $this->segnaletica_verticale_2_via = $record->segnaletica_verticale_2_via;
+                $this->div_segnaletica_verticale_2 = $record->segnaletica_verticale_2_via != "";
+                $this->segnaletica_verticale_2_altro = $record->segnaletica_verticale_2_altro;
+                $this->segnaletica_verticale_2_limite_velocita = $record->segnaletica_verticale_2_limite_velocita;
+                $this->segnaletica_verticale_2_direzione = $record->segnaletica_verticale_2_direzione;
+                $this->segnaletica_verticale_2_pannello_integrativo = $record->segnaletica_verticale_2_pannello_integrativo;
+                $this->segnaletica_verticale_3_via = $record->segnaletica_verticale_3_via;
+                $this->div_segnaletica_verticale_3 = $record->segnaletica_verticale_3_via != "";
+                $this->segnaletica_verticale_3_altro = $record->segnaletica_verticale_3_altro;
+                $this->segnaletica_verticale_3_limite_velocita = $record->segnaletica_verticale_3_limite_velocita;
+                $this->segnaletica_verticale_3_direzione = $record->segnaletica_verticale_3_direzione;
+                $this->segnaletica_verticale_3_pannello_integrativo = $record->segnaletica_verticale_3_pannello_integrativo;
+                $this->segnaletica_verticale_4_via = $record->segnaletica_verticale_4_via;
+                $this->div_segnaletica_verticale_4 = $record->segnaletica_verticale_4_via != "";
+                $this->segnaletica_verticale_4_altro = $record->segnaletica_verticale_4_altro;
+                $this->segnaletica_verticale_4_limite_velocita = $record->segnaletica_verticale_4_limite_velocita;
+                $this->segnaletica_verticale_4_direzione = $record->segnaletica_verticale_4_direzione;
+                $this->segnaletica_verticale_4_pannello_integrativo = $record->segnaletica_verticale_4_pannello_integrativo;
+                $this->segnaletica_orizzontale_1_via = $record->segnaletica_orizzontale_1_via;
+                $this->segnaletica_orizzontale_1_linea_margine = $record->segnaletica_orizzontale_1_linea_margine;
+                $this->segnaletica_orizzontale_1_linea_margine_specifica = $record->segnaletica_orizzontale_1_linea_margine_specifica;
+                $this->segnaletica_orizzontale_1_linea_mezzeria = $record->segnaletica_orizzontale_1_linea_mezzeria;
+                $this->segnaletica_orizzontale_1_linea_mezzeria_specifica = $record->segnaletica_orizzontale_1_linea_mezzeria_specifica;
+                $this->segnaletica_orizzontale_1_altro = $record->segnaletica_orizzontale_1_altro;
+                $this->segnaletica_orizzontale_1_direzione = $record->segnaletica_orizzontale_1_direzione;
+                $this->segnaletica_orizzontale_2_via = $record->segnaletica_orizzontale_2_via;
+                $this->div_segnaletica_orizzontale_2 = $record->segnaletica_orizzontale_2_via != "";
+                $this->segnaletica_orizzontale_2_linea_margine = $record->segnaletica_orizzontale_2_linea_margine;
+                $this->segnaletica_orizzontale_2_linea_margine_specifica = $record->segnaletica_orizzontale_2_linea_margine_specifica;
+                $this->segnaletica_orizzontale_2_linea_mezzeria = $record->segnaletica_orizzontale_2_linea_mezzeria;
+                $this->segnaletica_orizzontale_2_linea_mezzeria_specifica = $record->segnaletica_orizzontale_2_linea_mezzeria_specifica;
+                $this->segnaletica_orizzontale_2_altro = $record->segnaletica_orizzontale_2_altro;
+                $this->segnaletica_orizzontale_2_direzione = $record->segnaletica_orizzontale_2_direzione;
+                $this->segnaletica_orizzontale_3_via = $record->segnaletica_orizzontale_3_via;
+                $this->div_segnaletica_orizzontale_3 = $record->segnaletica_orizzontale_3_via != "";
+                $this->segnaletica_orizzontale_3_linea_margine = $record->segnaletica_orizzontale_3_linea_margine;
+                $this->segnaletica_orizzontale_3_linea_margine_specifica = $record->segnaletica_orizzontale_3_linea_margine_specifica;
+                $this->segnaletica_orizzontale_3_linea_mezzeria = $record->segnaletica_orizzontale_3_linea_mezzeria;
+                $this->segnaletica_orizzontale_3_linea_mezzeria_specifica = $record->segnaletica_orizzontale_3_linea_mezzeria_specifica;
+                $this->segnaletica_orizzontale_3_altro = $record->segnaletica_orizzontale_3_altro;
+                $this->segnaletica_orizzontale_3_direzione = $record->segnaletica_orizzontale_3_direzione;
+                $this->segnaletica_orizzontale_4_via = $record->segnaletica_orizzontale_4_via;
+                $this->div_segnaletica_orizzontale_4 = $record->segnaletica_orizzontale_4_via != "";
+                $this->segnaletica_orizzontale_4_linea_margine = $record->segnaletica_orizzontale_4_linea_margine;
+                $this->segnaletica_orizzontale_4_linea_margine_specifica = $record->segnaletica_orizzontale_4_linea_margine_specifica;
+                $this->segnaletica_orizzontale_4_linea_mezzeria = $record->segnaletica_orizzontale_4_linea_mezzeria;
+                $this->segnaletica_orizzontale_4_linea_mezzeria_specifica = $record->segnaletica_orizzontale_4_linea_mezzeria_specifica;
+                $this->segnaletica_orizzontale_4_altro = $record->segnaletica_orizzontale_4_altro;
+                $this->segnaletica_orizzontale_4_direzione = $record->segnaletica_orizzontale_4_direzione;
+
+                $this->notes = \App\Models\ReportProtocolloNote::where('report_id', $idReport)->get();
+
+                $this->richieste = \App\Models\ReportRichiesta::where('report_id', $idReport)->get();
+
+                $this->allegatiImmagini = \App\Models\ReportAllegatiGallery::where('report_id', $idReport)->where('file_type', 0)->orderBy('name')->get();
+                $this->allegatiDocumenti = \App\Models\ReportAllegatiGallery::where('report_id', $idReport)->where('file_type', 1)->orderBy('name')->get();
+
+                // Testi oculari
+                $testi_oculari = \App\Models\ReportDataTestimoniOculari::where('report_id', $idReport)->get();
+                foreach($testi_oculari as $idx => $i)
+                {
+                    if($idx == 0)
+                    {
+                        $this->data_testi_oculari_0 = $i->testi_oculari;
+                        $this->data_testi_oculari_stato_0 = $i->stato_testi_oculari;
+                    }
+                    if($idx == 1)
+                    {
+                        $this->data_testi_oculari_1 = $i->testi_oculari;
+                        $this->data_testi_oculari_stato_1 = $i->stato_testi_oculari;
+                    }
+                    if($idx == 2)
+                    {
+                        $this->data_testi_oculari_2 = $i->testi_oculari;
+                        $this->data_testi_oculari_stato_2 = $i->stato_testi_oculari;
+                    }
+                    if($idx == 3)
+                    {
+                        $this->data_testi_oculari_3 = $i->testi_oculari;
+                        $this->data_testi_oculari_stato_3 = $i->stato_testi_oculari;
+                    }
+                }
+
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore (' . $ex->getMessage() . ')');
+        }
+        $this->emit('load-check', "");
+    }
+
+    public function update($validate = false)
+    {
+
+        if ($validate)
+        {
+            $rulesValidate = [
+                'localita_uno' => 'required',
+                'localita_due' => 'required',
+                'verificatosi_in_data' => 'required',
+                'verificatosi_in_data_ora' => 'required',
+                'verificatosi_in_data_minuti' => 'required',
+                'rilievi_id' => 'required',
+                'segnalazione_data' => 'required',
+                'segnalazione_ora' => 'required',
+                'segnalazione_minuti' => 'required',
+                'sinistro_ora' => 'required',
+                'sinistro_minuti' => 'required',
+                'localizzazione_incidente' => 'required',
+                'nomenclatura_strada' => 'required',
+                'condizioni_atmosferiche' => 'required',
+                'pavimentazione' => 'required',
+                'condizione_strada' => 'required',
+                'fondo_stradale' => 'required',
+                'visibilita' => 'required',
+                'particolarita_strada' => 'required',
+            ];
+
+            $this->validate($rulesValidate);
+        }
+        try {
+            \App\Models\Report::whereId($this->dataId)->update([
+                'name' => '0'.$this->protocollo_num . "/" . $this->protocollo_anno,
+                'necessita_nulla_osta' => $this->necessita_nulla_osta,
+                'data_nulla_osta' => $this->data_nulla_osta,
+                'protocollo_num' => $this->protocollo_num,
+                'protocollo_ord' => $this->protocollo_ord,
+                'protocollo_anno' => $this->protocollo_anno,
+                'verificatosi_in_data' => $this->verificatosi_in_data,
+                'verificatosi_in_data_ora' => $this->verificatosi_in_data_ora,
+                'verificatosi_in_data_minuti' => $this->verificatosi_in_data_minuti,
+                'utg' => $this->utg,
+                'utg_data' => $this->utg_data,
+                'utg_protocollo' => $this->utg_protocollo,
+                'ag' => $this->ag,
+                'ag_data' => $this->ag_data,
+                'ag_protocollo' => $this->ag_protocollo,
+                'incidente_con_danni_a_cose' => $this->incidente_con_danni_a_cose,
+                'incidente_con_feriti' => $this->incidente_con_feriti,
+                'incidente_con_feriti_lesioni_lievi' => $this->incidente_con_feriti_lesioni_lievi,
+                'incidente_con_feriti_lesioni_gravi' => $this->incidente_con_feriti_lesioni_gravi,
+                'incidente_mortale' => $this->incidente_mortale,
+                'localita_uno' => $this->localita_uno,
+                'localita_due' => $this->localita_due,
+                'intersezione_con' => $this->intersezione_con,
+                'prossimita_civico' => $this->prossimita_civico,
+                'prossimita_palo_luce' => $this->prossimita_palo_luce,
+                'prossimita_chilometro' => $this->prossimita_chilometro,
+                'note_aggiuntive' => $this->note_aggiuntive,
+                'accertatore_1' => $this->accertatore_1,
+                'grado_accertatore_1' => $this->grado_accertatore_1,
+                'accertatore_2' => $this->accertatore_2,
+                'grado_accertatore_2' => $this->grado_accertatore_2,
+                'accertatore_3' => $this->accertatore_3,
+                'grado_accertatore_3' => $this->grado_accertatore_3,
+                'accertatore_4' => $this->accertatore_4,
+                'grado_accertatore_4' => $this->grado_accertatore_4,
+                'accertatore_5' => $this->accertatore_5,
+                'grado_accertatore_5' => $this->grado_accertatore_5,
+                'rilievi_id' => $this->rilievi_id,
+                'segnalazione_data' => $this->segnalazione_data,
+                'segnalazione_ora' => $this->segnalazione_ora,
+                'segnalazione_minuti' => $this->segnalazione_minuti,
+                'segnalazione_altro' => $this->segnalazione_altro,
+                'ausilio_altri_enti_motivo' => $this->ausilio_altri_enti_motivo,
+                'ausilio_altri_enti_ora_intervento' => $this->ausilio_altri_enti_ora_intervento,
+                'ausilio_altri_enti_minuti_intervento' => $this->ausilio_altri_enti_minuti_intervento,
+                'ditta_intervenuta' => $this->ditta_intervenuta,
+                'ripristino_ora_chiamata' => $this->ripristino_ora_chiamata,
+                'ripristino_minuti_chiamata' => $this->ripristino_minuti_chiamata,
+                'ripristino_ora_arrivo' => $this->ripristino_ora_arrivo,
+                'ripristino_minuti_arrivo' => $this->ripristino_minuti_arrivo,
+                'danni_cose_diverse_da_veicoli' => $this->danni_cose_diverse_da_veicoli,
+                'sinistro_ora' => $this->sinistro_ora,
+                'sinistro_minuti' => $this->sinistro_minuti,
+                'localizzazione_incidente' => $this->localizzazione_incidente,
+                'localizzazione_incidente_altro' => $this->localizzazione_incidente_altro,
+                'condizioni_atmosferiche' => $this->condizioni_atmosferiche,
+                'condizioni_atmosferiche_altro' => $this->condizioni_atmosferiche_altro,
+                'nomenclatura_strada' => $this->nomenclatura_strada,
+                'nomenclatura_strada_numero' => $this->nomenclatura_strada_numero,
+                'nomenclatura_strada_altro' => $this->nomenclatura_strada_altro,
+                'pavimentazione' => $this->pavimentazione,
+                'pavimentazione_altro' => $this->pavimentazione_altro,
+                'condizione_strada' => $this->condizione_strada,
+                'condizione_strada_altro' => $this->condizione_strada_altro,
+                'fondo_stradale' => $this->fondo_stradale,
+                'fondo_stradale_specifica' => $this->fondo_stradale_specifica,
+                'visibilita' => $this->visibilita,
+                'visibilita_specifica' => $this->visibilita_specifica,
+                'particolarita_strada' => $this->particolarita_strada,
+                'particolarita_strada_specifica' => $this->particolarita_strada_specifica,
+                // 'tipo_strada' => $this->tipo_strada,
+                'tipo_strada_altro' => $this->tipo_strada_altro,
+                'traffico' => $this->traffico,
+                'segnaletica' => $this->segnaletica,
+                'segnaletica_verticale_1_via' => $this->segnaletica_verticale_1_via,
+                'segnaletica_verticale_1_altro' => $this->segnaletica_verticale_1_altro,
+                'segnaletica_verticale_1_limite_velocita' => $this->segnaletica_verticale_1_limite_velocita,
+                'segnaletica_verticale_1_direzione' => $this->segnaletica_verticale_1_direzione,
+                'segnaletica_verticale_1_pannello_integrativo' => $this->segnaletica_verticale_1_pannello_integrativo,
+                'segnaletica_verticale_2_via' => $this->segnaletica_verticale_2_via,
+                'segnaletica_verticale_2_altro' => $this->segnaletica_verticale_2_altro,
+                'segnaletica_verticale_2_limite_velocita' => $this->segnaletica_verticale_2_limite_velocita,
+                'segnaletica_verticale_2_direzione' => $this->segnaletica_verticale_2_direzione,
+                'segnaletica_verticale_2_pannello_integrativo' => $this->segnaletica_verticale_2_pannello_integrativo,
+                'segnaletica_verticale_3_via' => $this->segnaletica_verticale_3_via,
+                'segnaletica_verticale_3_altro' => $this->segnaletica_verticale_3_altro,
+                'segnaletica_verticale_3_limite_velocita' => $this->segnaletica_verticale_3_limite_velocita,
+                'segnaletica_verticale_3_direzione' => $this->segnaletica_verticale_3_direzione,
+                'segnaletica_verticale_3_pannello_integrativo' => $this->segnaletica_verticale_3_pannello_integrativo,
+                'segnaletica_verticale_4_via' => $this->segnaletica_verticale_4_via,
+                'segnaletica_verticale_4_altro' => $this->segnaletica_verticale_4_altro,
+                'segnaletica_verticale_4_limite_velocita' => $this->segnaletica_verticale_4_limite_velocita,
+                'segnaletica_verticale_4_direzione' => $this->segnaletica_verticale_4_direzione,
+                'segnaletica_verticale_4_pannello_integrativo' => $this->segnaletica_verticale_4_pannello_integrativo,
+                'segnaletica_orizzontale_1_via' => $this->segnaletica_orizzontale_1_via,
+                'segnaletica_orizzontale_1_linea_margine' => $this->segnaletica_orizzontale_1_linea_margine,
+                'segnaletica_orizzontale_1_linea_margine_specifica' => $this->segnaletica_orizzontale_1_linea_margine_specifica,
+                'segnaletica_orizzontale_1_linea_mezzeria' => $this->segnaletica_orizzontale_1_linea_mezzeria,
+                'segnaletica_orizzontale_1_linea_mezzeria_specifica' => $this->segnaletica_orizzontale_1_linea_mezzeria_specifica,
+                'segnaletica_orizzontale_1_altro' => $this->segnaletica_orizzontale_1_altro,
+                'segnaletica_orizzontale_1_direzione' => $this->segnaletica_orizzontale_1_direzione,
+                'segnaletica_orizzontale_2_via' => $this->segnaletica_orizzontale_2_via,
+                'segnaletica_orizzontale_2_linea_margine' => $this->segnaletica_orizzontale_2_linea_margine,
+                'segnaletica_orizzontale_2_linea_margine_specifica' => $this->segnaletica_orizzontale_2_linea_margine_specifica,
+                'segnaletica_orizzontale_2_linea_mezzeria' => $this->segnaletica_orizzontale_2_linea_mezzeria,
+                'segnaletica_orizzontale_2_linea_mezzeria_specifica' => $this->segnaletica_orizzontale_2_linea_mezzeria_specifica,
+                'segnaletica_orizzontale_2_altro' => $this->segnaletica_orizzontale_2_altro,
+                'segnaletica_orizzontale_2_direzione' => $this->segnaletica_orizzontale_2_direzione,
+                'segnaletica_orizzontale_3_via' => $this->segnaletica_orizzontale_3_via,
+                'segnaletica_orizzontale_3_linea_margine' => $this->segnaletica_orizzontale_3_linea_margine,
+                'segnaletica_orizzontale_3_linea_margine_specifica' => $this->segnaletica_orizzontale_3_linea_margine_specifica,
+                'segnaletica_orizzontale_3_linea_mezzeria' => $this->segnaletica_orizzontale_3_linea_mezzeria,
+                'segnaletica_orizzontale_3_linea_mezzeria_specifica' => $this->segnaletica_orizzontale_3_linea_mezzeria_specifica,
+                'segnaletica_orizzontale_3_altro' => $this->segnaletica_orizzontale_3_altro,
+                'segnaletica_orizzontale_3_direzione' => $this->segnaletica_orizzontale_3_direzione,
+                'segnaletica_orizzontale_4_via' => $this->segnaletica_orizzontale_4_via,
+                'segnaletica_orizzontale_4_linea_margine' => $this->segnaletica_orizzontale_4_linea_margine,
+                'segnaletica_orizzontale_4_linea_margine_specifica' => $this->segnaletica_orizzontale_4_linea_margine_specifica,
+                'segnaletica_orizzontale_4_linea_mezzeria' => $this->segnaletica_orizzontale_4_linea_mezzeria,
+                'segnaletica_orizzontale_4_linea_mezzeria_specifica' => $this->segnaletica_orizzontale_4_linea_mezzeria_specifica,
+                'segnaletica_orizzontale_4_altro' => $this->segnaletica_orizzontale_4_altro,
+                'segnaletica_orizzontale_4_direzione' => $this->segnaletica_orizzontale_4_direzione,
+                'validated' => $validate
+            ]);
+
+            \App\Models\ReportTipoUrto::where('report_id', $this->dataId)->delete();
+            foreach($this->tipo_urto as $x)
+            {
+                \App\Models\ReportTipoUrto::create([
+                    'report_id' => $this->dataId,
+                    'tipo_urto_id' => $x
+                ]);
+            }
+
+            \App\Models\ReportTipoSegnalazione::where('report_id', $this->dataId)->delete();
+            foreach($this->tipo_segnalazione as $x)
+            {
+                \App\Models\ReportTipoSegnalazione::create([
+                    'report_id' => $this->dataId,
+                    'tipo_segnalazione_id' => $x
+                ]);
+            }
+
+            \App\Models\ReportSegnalazionePervenutaDa::where('report_id', $this->dataId)->delete();
+            foreach($this->segnalazione_pervenuta_da as $x)
+            {
+                \App\Models\ReportSegnalazionePervenutaDa::create([
+                    'report_id' => $this->dataId,
+                    'segnalazione_pervenuta_da_id' => $x
+                ]);
+            }
+
+            \App\Models\ReportMaterialeRecuperato::where('report_id', $this->dataId)->delete();
+            foreach($this->materiale_recuperato as $x)
+            {
+                \App\Models\ReportMaterialeRecuperato::create([
+                    'report_id' => $this->dataId,
+                    'materiale_recuperato_id' => $x
+                ]);
+            }
+
+            \App\Models\ReportAusilioAltriEnti::where('report_id', $this->dataId)->delete();
+            foreach($this->ausilio_altri_enti as $x)
+            {
+                \App\Models\ReportAusilioAltriEnti::create([
+                    'report_id' => $this->dataId,
+                    'ausilio_altri_enti_id' => $x
+                ]);
+            }
+
+            \App\Models\ReportCondizioniLuce::where('report_id', $this->dataId)->delete();
+            foreach($this->condizioni_luce as $x)
+            {
+                \App\Models\ReportCondizioniLuce::create([
+                    'report_id' => $this->dataId,
+                    'condizioni_luce_id' => $x
+                ]);
+            }
+
+            \App\Models\ReportTipoStrada::where('report_id', $this->dataId)->delete();
+            foreach($this->tipo_strada as $x)
+            {
+                \App\Models\ReportTipoStrada::create([
+                    'report_id' => $this->dataId,
+                    'tipo_strada_id' => $x
+                ]);
+            }
+
+            \App\Models\ReportSegnaleticaVerticale1::where('report_id', $this->dataId)->delete();
+            foreach($this->segnaletica_verticale_1 as $x)
+            {
+                \App\Models\ReportSegnaleticaVerticale1::create([
+                    'report_id' => $this->dataId,
+                    'segnaletica_verticale_id' => $x
+                ]);
+            }
+
+            \App\Models\ReportSegnaleticaVerticale2::where('report_id', $this->dataId)->delete();
+            foreach($this->segnaletica_verticale_2 as $x)
+            {
+                \App\Models\ReportSegnaleticaVerticale2::create([
+                    'report_id' => $this->dataId,
+                    'segnaletica_verticale_id' => $x
+                ]);
+            }
+
+            \App\Models\ReportSegnaleticaVerticale3::where('report_id', $this->dataId)->delete();
+            foreach($this->segnaletica_verticale_3 as $x)
+            {
+                \App\Models\ReportSegnaleticaVerticale3::create([
+                    'report_id' => $this->dataId,
+                    'segnaletica_verticale_id' => $x
+                ]);
+            }
+
+            \App\Models\ReportSegnaleticaVerticale4::where('report_id', $this->dataId)->delete();
+            foreach($this->segnaletica_verticale_4 as $x)
+            {
+                \App\Models\ReportSegnaleticaVerticale4::create([
+                    'report_id' => $this->dataId,
+                    'segnaletica_verticale_id' => $x
+                ]);
+            }
+
+            \App\Models\ReportSegnaleticaOrizzontale1::where('report_id', $this->dataId)->delete();
+            foreach($this->segnaletica_orizzontale_1 as $x)
+            {
+                \App\Models\ReportSegnaleticaOrizzontale1::create([
+                    'report_id' => $this->dataId,
+                    'segnaletica_orizzontale_id' => $x
+                ]);
+            }
+
+            \App\Models\ReportSegnaleticaOrizzontale2::where('report_id', $this->dataId)->delete();
+            foreach($this->segnaletica_orizzontale_2 as $x)
+            {
+                \App\Models\ReportSegnaleticaOrizzontale2::create([
+                    'report_id' => $this->dataId,
+                    'segnaletica_orizzontale_id' => $x
+                ]);
+            }
+
+            \App\Models\ReportSegnaleticaOrizzontale3::where('report_id', $this->dataId)->delete();
+            foreach($this->segnaletica_orizzontale_3 as $x)
+            {
+                \App\Models\ReportSegnaleticaOrizzontale3::create([
+                    'report_id' => $this->dataId,
+                    'segnaletica_orizzontale_id' => $x
+                ]);
+            }
+
+            \App\Models\ReportSegnaleticaOrizzontale4::where('report_id', $this->dataId)->delete();
+            foreach($this->segnaletica_orizzontale_4 as $x)
+            {
+                \App\Models\ReportSegnaleticaOrizzontale4::create([
+                    'report_id' => $this->dataId,
+                    'segnaletica_orizzontale_id' => $x
+                ]);
+            }
+
+            \App\Models\ReportDataTestimoniOculari::where('report_id', $this->dataId)->delete();
+            try {
+                \App\Models\ReportDataTestimoniOculari::create([
+                    'progressive' => 0,
+                    'report_id' => $this->dataId,
+                    'testi_oculari' => $this->data_testi_oculari_0,
+                    'stato_testi_oculari' => $this->data_testi_oculari_stato_0
+                ]);
+                \App\Models\ReportDataTestimoniOculari::create([
+                    'progressive' => 1,
+                    'report_id' => $this->dataId,
+                    'testi_oculari' => $this->data_testi_oculari_1,
+                    'stato_testi_oculari' => $this->data_testi_oculari_stato_1
+                ]);
+                \App\Models\ReportDataTestimoniOculari::create([
+                    'progressive' => 2,
+                    'report_id' => $this->dataId,
+                    'testi_oculari' => $this->data_testi_oculari_2,
+                    'stato_testi_oculari' => $this->data_testi_oculari_stato_2
+                ]);
+                \App\Models\ReportDataTestimoniOculari::create([
+                    'progressive' => 3,
+                    'report_id' => $this->dataId,
+                    'testi_oculari' => $this->data_testi_oculari_3,
+                    'stato_testi_oculari' => $this->data_testi_oculari_stato_3
+                ]);
+            } catch (\Exception $ex) {
+                session()->flash('error','Errore in fase di salvataggio (' . $ex->getMessage() . ')');
+            }
+
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore (' . $ex->getMessage() . ')');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+        $this->resetAnagrafica();
+        $this->resetVeicolo();
+        $this->resetVeicoloData();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\Report::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+
+    public function addNote()
+    {
+        \App\Models\ReportProtocolloNote::create([
+            'report_id' => $this->dataId,
+            'text' => $this->noteText,
+            'created' => date("Y-m-d H:i:s"),
+            'created_by' => 0 // * * *
+        ]);
+        $this->noteText = '';
+        $this->notes = \App\Models\ReportProtocolloNote::where('report_id', $this->dataId)->get();
+    }
+
+    public function removeNote($id)
+    {
+        \App\Models\ReportProtocolloNote::findOrFail($id)->delete();
+        $this->notes = \App\Models\ReportProtocolloNote::where('report_id', $this->dataId)->get();
+    }
+
+    public function saveRichiesta()
+    {
+
+        $rules = [
+            'richiestaAnagrafica' => 'required|min:1',
+            'richiestaData' => 'required|date',
+            'richiestaConsegna' => 'required|date',
+        ];
+
+        $messages = [
+            'richiestaData.required' => 'Il campo data richiesta è obbligatorio.',
+            'richiestaData.date' => 'Il campo data richiesta deve essere una data valida.',
+            'richiestaConsegna.required' => 'Il campo data consegna è obbligatorio.',
+            'richiestaConsegna.date' => 'Il campo data consegna deve essere una data valida.',
+        ];
+
+        $this->validate($rules);
+
+        if ($this->richiestaId > 0)
+        {
+            \App\Models\ReportRichiesta::where('id', $this->richiestaId)->update([
+                'anagrafica_id' => $this->richiestaAnagrafica,
+                'data_richiesta' => $this->richiestaData,
+                'consegna_richiesta' => $this->richiestaConsegna,
+                'description' => $this->richiestaText,
+                'state' => 0
+            ]);
+        }
+        else
+        {
+            \App\Models\ReportRichiesta::create([
+                'report_id' => $this->dataId,
+                'anagrafica_id' => $this->richiestaAnagrafica,
+                'data_richiesta' => $this->richiestaData,
+                'consegna_richiesta' => $this->richiestaConsegna,
+                'description' => $this->richiestaText,
+                'state' => 0,
+                'created' => date("Y-m-d H:i:s"),
+                'created_by' => 0 // * * *
+            ]);
+        }
+
+        $this->richiestaId = 0;
+        $this->richiestaAnagrafica = 0;
+        $this->richiestaData = null;
+        $this->richiestaConsegna = null;
+        $this->richiestaText = '';
+
+        $this->richieste = \App\Models\ReportRichiesta::where('report_id', $this->dataId)->get();
+    }
+
+    public function editRichiesta($id)
+    {
+
+        $r = \App\Models\ReportRichiesta::where('id', $id)->first();
+        if ($r != null)
+        {
+            $this->richiestaId = $id;
+            $this->richiestaAnagrafica = $r->anagrafica_id;
+            $this->richiestaData = $r->data_richiesta;
+            $this->richiestaConsegna = $r->consegna_richiesta;
+            $this->richiestaText = $r->description;
+        }
+
+    }
+
+    public function removeRichiesta($id)
+    {
+        \App\Models\ReportRichiesta::findOrFail($id)->delete();
+        $this->richieste = \App\Models\ReportRichiesta::where('report_id', $this->dataId)->get();
+    }
+
+    public function addAllegato($type)
+    {
+        $this->allegatoId = 0;
+        $this->allegatoType = $type;
+        $this->allegatoGallery = 0;
+        $this->allegatoName = '';
+        $this->allegatoVisible = false;
+        $this->allegatoFiles = '';
+        $this->allegatiFiles = [];
+        $this->emit('attachments', "");
+    }
+
+    public function saveAllegato()
+    {
+
+        $files = implode("|", $this->allegatiFiles);
+
+        if ($this->allegatoId > 0)
+        {
+            \App\Models\ReportAllegatiGallery::where('id', $this->allegatoId)->update([
+                'file_type' => $this->allegatoType,
+                'gallery_type' => $this->allegatoGallery,
+                'name' => $this->allegatoName,
+                'is_visible' => $this->allegatoVisible,
+                'files' => $files,
+                'state' => 0
+            ]);
+        }
+        else
+        {
+            \App\Models\ReportAllegatiGallery::create([
+                'report_id' => $this->dataId,
+                'file_type' => $this->allegatoType,
+                'gallery_type' => $this->allegatoGallery,
+                'name' => $this->allegatoName,
+                'is_visible' => $this->allegatoVisible,
+                'files' => $files,
+                'state' => 0,
+                'created' => date("Y-m-d H:i:s"),
+                'created_by' => 0 // * * *
+            ]);
+        }
+
+        $this->allegatoId = 0;
+        $this->allegatoGallery = 0;
+        $this->allegatoName = '';
+        $this->allegatoVisible = false;
+        $this->allegatoFiles = '';
+        $this->allegatiFiles = [];
+
+        if ($this->allegatoType == 0)
+            $this->allegatiImmagini = \App\Models\ReportAllegatiGallery::where('report_id',  $this->dataId)->where('file_type', 0)->orderBy('name')->get();
+        else
+            $this->allegatiDocumenti = \App\Models\ReportAllegatiGallery::where('report_id',  $this->dataId)->where('file_type', 1)->orderBy('name')->get();
+
+        $this->allegatoType = 0;
+
+        $this->emit('close-modal');
+
+    }
+
+    public function editAllegato($id)
+    {
+        $this->emit('attachments', "");
+        $a = \App\Models\ReportAllegatiGallery::where('id', $id)->first();
+        if ($a != null)
+        {
+            $this->allegatoId = $id;
+            $this->allegatoType = $a->file_type;
+            $this->allegatoGallery = $a->gallery_type;
+            $this->allegatoName = $a->name;
+            $this->allegatoFiles = $a->files;
+            $this->allegatiFiles = explode("|", $this->allegatoFiles);
+            $this->emit('attachments', $this->allegatoFiles);
+        }
+
+    }
+
+    public function removeAllegato($id)
+    {
+        \App\Models\ReportAllegatiGallery::findOrFail($id)->delete();
+        $this->allegatiImmagini = \App\Models\ReportAllegatiGallery::where('report_id',  $this->dataId)->where('file_type', 0)->orderBy('name')->get();
+        $this->allegatiDocumenti = \App\Models\ReportAllegatiGallery::where('report_id',  $this->dataId)->where('file_type', 1)->orderBy('name')->get();
+    }
+
+    public function addParteCoinvolta($type = 'pedone')
+    {
+        $count = \App\Models\ReportDataPartiCoinvolte::where('report_id', $this->dataId)->count();
+        $progressive = $count == 0 ? 0 : $count;
+
+        \App\Models\ReportDataPartiCoinvolte::create([
+            'report_id' => $this->dataId,
+            'progressive' => $progressive,
+            'progressive_type' => $progressive,
+            'conducente_o_pedone' => $type === 'veicolo' ? 2 : 1
+        ]);
+
+        $this->parti_coinvolte = \App\Models\ReportDataPartiCoinvolte::where('report_id', $this->dataId)->get();
+    }
+
+    public function changeAnagType($type)
+    {
+        $this->anag_type = $type;
+    }
+
+    public function updateConducentePedoneParteCoinvolta($conducente_o_pedone, $progressive)
+    {
+        \App\Models\ReportDataPartiCoinvolte::where('report_id', $this->dataId)->where('progressive', $progressive)->update([
+            'conducente_o_pedone' => $conducente_o_pedone
+        ]);
+        $this->parti_coinvolte = \App\Models\ReportDataPartiCoinvolte::where('report_id', $this->dataId)->get();
+
+    }
+
+    public function updateAnagraficaParteCoinvolta($anagrafica, $progressive)
+    {
+        \App\Models\ReportDataPartiCoinvolte::where('report_id', $this->dataId)->where('progressive', $progressive)->update([
+            'anagrafica' => $anagrafica
+        ]);
+        $this->parti_coinvolte = \App\Models\ReportDataPartiCoinvolte::where('report_id', $this->dataId)->get();
+
+    }
+
+    public function removeAnagraficaParteCoinvolta($progressive)
+    {
+        \App\Models\ReportDataPartiCoinvolte::where('report_id', $this->dataId)->where('progressive', $progressive)->update([
+            'anagrafica' => 0
+        ]);
+        $this->parti_coinvolte = \App\Models\ReportDataPartiCoinvolte::where('report_id', $this->dataId)->get();
+    }
+
+    public function updateVeicoloParteCoinvolta($veicolo, $progressive)
+    {
+        \App\Models\ReportDataPartiCoinvolte::where('report_id', $this->dataId)->where('progressive', $progressive)->update([
+            'veicolo' => $veicolo
+        ]);
+        $this->parti_coinvolte = \App\Models\ReportDataPartiCoinvolte::where('report_id', $this->dataId)->get();
+
+    }
+
+    public function removeVeicoloParteCoinvolta($progressive)
+    {
+        \App\Models\ReportDataPartiCoinvolte::where('report_id', $this->dataId)->where('progressive', $progressive)->update([
+            'veicolo' => 0
+        ]);
+        $this->parti_coinvolte = \App\Models\ReportDataPartiCoinvolte::where('report_id', $this->dataId)->get();
+    }
+
+    public function removeParteCoinvolta($progressive)
+    {
+        \App\Models\ReportDataPartiCoinvolte::where('report_id', $this->dataId)->where('progressive', $progressive)->delete();
+        $this->parti_coinvolte = \App\Models\ReportDataPartiCoinvolte::where('report_id', $this->dataId)->get();
+    }
+
+    public function editAnagraficaParte($progressive)
+    {
+
+        $parte_comune = \App\Models\ReportDataPartiCoinvolte::where('report_id', $this->dataId)->where('progressive', $progressive)->first();
+        if ($parte_comune != null)
+        {
+            $this->editAnagrafica($parte_comune->anagrafica);
+            $this->emit('load-anagrafica-modal');
+        }
+
+    }
+
+    public function addAnagrafica($progressive)
+    {
+
+        $this->resetAnagrafica();
+        $this->currentProgressive = $progressive;
+        $this->emit('load-anagrafica-modal');
+
+    }
+
+    public function addTesteOculare($x)
+    {
+
+        $this->resetAnagrafica();
+        $this->currentTeste = $x;
+        $this->emit('load-anagrafica-modal');
+
+    }
+
+    public function addConducente()
+    {
+
+        $this->resetAnagrafica();
+        $this->currentConducente = 99;
+        $this->emit('load-anagrafica-modal');
+
+    }
+
+    public function addProprietario()
+    {
+
+        $this->resetAnagrafica();
+        $this->currentProprietario = 99;
+        $this->emit('load-anagrafica-modal');
+
+    }
+
+    public function addCoproprietario()
+    {
+
+        $this->resetAnagrafica();
+        $this->currentCoproprietario = 99;
+        $this->emit('load-anagrafica-modal');
+
+    }
+
+    public function addPasseggero($x)
+    {
+
+        $this->resetAnagrafica();
+        $this->currentPasseggero = $x;
+        $this->emit('load-anagrafica-modal');
+
+    }
+
+    public function removeProprietario()
+    {
+        $this->data_proprietari = 0;
+        $this->emit('add-default-value', $this->data_proprietari, '', 'data_proprietari');
+    }
+
+    public function removeCoproprietario()
+    {
+        $this->data_coproprietari = 0;
+        $this->emit('add-default-value', $this->data_coproprietari, '', 'data_coproprietari');
+    }
+
+    public function removeConducente()
+    {
+        $this->data_conducenti = 0;
+        $this->emit('add-default-value', $this->data_conducenti, '', 'data_conducenti');
+    }
+
+    public function editProprietario()
+    {
+
+        $this->currentProprietario = $this->data_proprietari;
+        $this->editAnagrafica($this->data_proprietari);
+        $this->emit('load-anagrafica-modal');
+
+    }
+
+    public function editCoproprietario()
+    {
+
+        $this->currentCoproprietario = $this->data_coproprietari;
+        $this->editAnagrafica($this->data_coproprietari);
+        $this->emit('load-anagrafica-modal');
+
+    }
+
+    public function editConducente()
+    {
+
+        $this->currentConducente = $this->data_conducenti;
+        $this->editAnagrafica($this->data_conducenti);
+        $this->emit('load-anagrafica-modal');
+
+    }
+
+    public function editPasseggero($x)
+    {
+        $this->currentPasseggero = $x;
+        if ($x == 1)
+        {
+            $this->editAnagrafica($this->data_passeggero_0);
+            $this->emit('load-anagrafica-modal');
+        }
+        if ($x == 2)
+        {
+            $this->editAnagrafica($this->data_passeggero_1);
+            $this->emit('load-anagrafica-modal');
+        }
+
+        if ($x == 3)
+        {
+            $this->editAnagrafica($this->data_passeggero_2);
+            $this->emit('load-anagrafica-modal');
+        }
+        if ($x == 4)
+        {
+            $this->editAnagrafica($this->data_passeggero_3s);
+            $this->emit('load-anagrafica-modal');
+        }
+
+    }
+
+    public function removePasseggero($x)
+    {
+        if ($x == 1)
+        {
+            $this->data_passeggero_0 = 0;
+            $this->emit('add-default-value', $this->data_passeggero_0, '', 'data_passeggero_0');
+        }
+        if ($x == 2)
+        {
+            $this->data_passeggero_1 = 0;
+            $this->emit('add-default-value', $this->data_passeggero_1, '', 'data_passeggero_1');
+        }
+
+        if ($x == 3)
+        {
+            $this->data_passeggero_2 = 0;
+            $this->emit('add-default-value', $this->data_passeggero_2, '', 'data_passeggero_2');
+        }
+        if ($x == 4)
+        {
+            $this->data_passeggero_3 = 0;
+            $this->emit('add-default-value', $this->data_passeggero_3, '', 'data_passeggero_3');
+        }
+
+    }
+
+    public function addInfortunato($x)
+    {
+
+        $this->resetAnagrafica();
+        $this->currentInfortunato = $x;
+        $this->emit('load-anagrafica-modal');
+
+    }
+
+    public function editAnagrafica($anagrafica)
+    {
+
+        $this->resetAnagrafica();
+
+        $anag = \App\Models\Anagrafica::where('id', $anagrafica)->first();
+        if ($anag != null)
+        {
+            $this->currentAnagrafica = $anagrafica;
+            $this->anag_type = $anag->type;
+            $this->anag_firstname = $anag->firstname;
+            $this->anag_lastname = $anag->lastname;
+            $this->anag_gender = $anag->gender;
+            $this->anag_birth_date = $anag->birth_date;
+            $this->anag_birth_town_id = $anag->birth_town_id;
+            $this->anag_birth_prov_id = $anag->birth_prov_id;
+            $this->anag_residenza_town_id = $anag->residenza_town_id;
+            $this->anag_residenza_prov_id = $anag->residenza_prov_id;
+            $this->anag_residenza_address = $anag->residenza_address;
+            $this->anag_residenza_cap = $anag->residenza_cap;
+            $this->anag_mobile = $anag->mobile;
+            $this->anag_sedicente = $anag->sedicente;
+            $this->anag_documento_tipo = $anag->documento_tipo;
+            $this->anag_documento_patente_cat = $anag->documento_patente_cat;
+            $this->anag_documento_tipo_altro = $anag->documento_tipo_altro;
+            $this->anag_documento_numero = $anag->documento_numero;
+            $this->anag_documento_rilasciato_da = $anag->documento_rilasciato_da;
+            $this->anag_documento_rilasciato_da_altro = $anag->documento_rilasciato_da_altro;
+            $this->anag_foreign_country = $anag->foreign_country;
+            $this->anag_documento_rilasciato_da_di_foreign_localita = $anag->documento_rilasciato_da_di_foreign_localita;
+            $this->anag_documento_rilasciato_da_di_foreign_country = $anag->documento_rilasciato_da_di_foreign_country;
+            $this->anag_documento_rilasciato_da_prov_id = $anag->documento_rilasciato_da_prov_id;
+            $this->anag_documento_rilasciato_da_town_id = $anag->documento_rilasciato_da_town_id;
+            $this->anag_documento_rilasciato_il = $anag->documento_rilasciato_il;
+            $this->anag_documento_scadenza_il = $anag->documento_scadenza_il;
+            $this->anag_state = $anag->state;
+            $this->anag_nazionalita = $anag->nazionalita;
+            $this->anag_nazione_straniera = $anag->nazione_straniera;
+            $this->anag_localita_straniera = $anag->localita_straniera;
+            $this->anag_rag_soc = $anag->rag_soc;
+            $this->anag_vat = $anag->vat;
+            $this->anag_sede_legale_town_id = $anag->sede_legale_town_id;
+            $this->anag_sede_legale_prov_id = $anag->sede_legale_prov_id;
+            $this->anag_sede_legale_address = $anag->sede_legale_address;
+            $this->anag_sede_legale_cap = $anag->sede_legale_cap;
+            $this->anag_phone = $anag->phone;
+
+            $this->anag_foreign_birth_country = $anag->anag_foreign_birth_country;
+            $this->anag_foreign_birth_city = $anag->anag_foreign_birth_city;
+            $this->anag_foreign_residence_country = $anag->anag_foreign_residence_country;
+            $this->anag_foreign_residence_city = $anag->anag_foreign_residence_city;
+        }
+
+        $this->emit('load-anagrafica-modal');
+
+        $this->emit('change-visualization', $this->anag_type);
+
+        if ($this->anag_birth_town_id > 0)
+            $this->emit('add-default-value', $this->anag_birth_town_id, $this->getLocalita($this->anag_birth_town_id), 'anag_birth_town_id');
+        if ($this->anag_residenza_town_id > 0)
+            $this->emit('add-default-value', $this->anag_residenza_town_id, $this->getLocalita($this->anag_residenza_town_id), 'anag_residenza_town_id');
+        if ($this->anag_documento_rilasciato_da_di_foreign_localita > 0)
+            $this->emit('add-default-value', $this->anag_documento_rilasciato_da_di_foreign_localita, $this->getLocalita($this->anag_documento_rilasciato_da_di_foreign_localita), 'anag_documento_rilasciato_da_di_foreign_localita');
+        if ($this->vei_carta_circolazione_rilasciata_da_di_foreign_localita > 0)
+            $this->emit('add-default-value', $this->vei_carta_circolazione_rilasciata_da_di_foreign_localita, $this->getLocalita($this->vei_carta_circolazione_rilasciata_da_di_foreign_localita), 'vei_carta_circolazione_rilasciata_da_di_foreign_localita');
+        if ($this->anag_sede_legale_town_id > 0)
+            $this->emit('add-default-value', $this->anag_sede_legale_town_id, $this->getLocalita($this->anag_sede_legale_town_id), 'anag_sede_legale_town_id');
+    }
+
+    public function addVeicolo($progressive)
+    {
+
+        $this->resetVeicolo();
+        $this->currentProgressive = $progressive;
+
+    }
+
+    public function editVeicolo($veicolo)
+    {
+
+        $this->resetVeicolo();
+
+        $vei = \App\Models\Vehicle::where('id', $veicolo)->first();
+        if ($vei != null)
+        {
+            $this->currentVeicolo = $veicolo;
+            $this->vei_tipo_id = $vei->tipo_id;
+            $this->vei_marca_id = $vei->marca_id;
+            $this->vei_marca_altro = $vei->marca_altro;
+            $this->vei_modello_id = $vei->modello_id;
+            $this->vei_modello_altro = $vei->modello_altro;
+            $this->vei_colore = $vei->colore;
+            $this->vei_targa = $vei->targa;
+            $this->vei_carta_circolazione = $vei->carta_circolazione;
+            $this->vei_carta_circolazione_rilasciata_da = $vei->carta_circolazione_rilasciata_da;
+            $this->vei_carta_circolazione_rilasciata_da_altro = $vei->carta_circolazione_rilasciata_da_altro;
+            $this->vei_foreign_country = $vei->foreign_country;
+            $this->vei_carta_circolazione_rilasciata_da_di_foreign_country = $vei->carta_circolazione_rilasciata_da_di_foreign_country;
+            $this->vei_carta_circolazione_rilasciata_da_di_foreign_localita = $vei->carta_circolazione_rilasciata_da_di_foreign_localita;
+            $this->vei_carta_circolazione_rilasciata_da_di = $vei->carta_circolazione_rilasciata_da_di;
+            $this->vei_carta_circolazione_rilasciata_il = $vei->carta_circolazione_rilasciata_il;
+            $this->vei_data_ultima_revisione = $vei->data_ultima_revisione;
+            $this->vei_cilindrata = $vei->cilindrata;
+            $this->vei_peso_complessivo = $vei->peso_complessivo;
+            $this->vei_destinazione_uso = $vei->destinazione_uso;
+            $this->vei_state = $vei->state;
+
+        }
+    }
+
+    public function editVeicoloData($progressive)
+    {
+
+        $this->resetVeicoloData();
+
+        $this->currentProgressive = $progressive;
+
+        $data = \App\Models\ReportDataVeicoli::where('progressive', $progressive)->where('report_id', $this->dataId)->first();
+        if ($data != null)
+        {
+
+            $this->currentVeicolo = $data->veicolo;
+
+            $this->data_chilometri_percorsi = $data->chilometri_percorsi;
+            $this->data_stato_veicolo = $data->stato_veicolo;
+            $this->data_polizze = $data->polizze;
+            $this->data_proprietari = $data->proprietari;
+            $this->data_coproprietari = $data->coproprietari;
+            $this->data_conducente_uguale_proprietario = $data->conducente_uguale_proprietario;
+            $this->data_conducenti = $data->conducenti;
+            $this->data_infortunato = $data->infortunato;
+            $this->data_infortunato_ospedale = $data->infortunato_ospedale;
+            $this->data_patente_al_seguito = $data->patente_al_seguito;
+            $this->data_generalizzato = $data->generalizzato;
+            $this->data_generalizzato_altrove = $data->generalizzato_altrove;
+            $this->data_posizione_statica_finale = $data->posizione_statica_finale;
+            $this->data_danni_visibili_riportati = $data->danni_visibili_riportati;
+            $this->data_danni_visibili_pre_esistenti = $data->danni_visibili_pre_esistenti;
+            $this->data_destinazione_veicolo = $data->destinazione_veicolo;
+            $this->data_destinazione_veicolo_affidato_a = $data->destinazione_veicolo_affidato_a;
+            $this->data_destinazione_veicolo_sequestro_num_art = $data->destinazione_veicolo_sequestro_num_art;
+            $this->data_destinazione_veicolo_amministrativo_num = $data->destinazione_veicolo_amministrativo_num;
+            $this->data_destinazione_veicolo_amministrativo_num_art_violato = $data->destinazione_veicolo_amministrativo_num_art_violato;
+            $this->data_destinazione_veicolo_amministrativo_cds = $data->destinazione_veicolo_amministrativo_cds;
+            $this->data_circostanze_presunte_incidente = $data->circostanze_presunte_incidente;
+            $this->data_stato_pneumatici = $data->stato_pneumatici;
+            $this->data_marca_pneumatici = $data->marca_pneumatici;
+            $this->data_misura_pneumatici = $data->misura_pneumatici;
+            $this->data_dispositivi_ottici = $data->dispositivi_ottici;
+            $this->data_tergicristalli = $data->tergicristalli;
+            $this->data_segnale_pericolo = $data->segnale_pericolo;
+            $this->data_abs = $data->abs;
+            $this->data_gps = $data->gps;
+            $this->data_marcia_inserita = $data->marcia_inserita;
+            $this->data_cristallo = $data->cristallo;
+            $this->data_cristallo_posizione = $data->cristallo_posizione;
+            $this->data_specchio_retrovisore = $data->specchio_retrovisore;
+            $this->data_specchio_lat_dx = $data->specchio_lat_dx;
+            $this->data_specchio_lat_sx = $data->specchio_lat_sx;
+            $this->data_attivazione_airbag = $data->attivazione_airbag;
+            $this->data_airbag_posizione = $data->airbag_posizione;
+            $this->data_alcool_test = $data->alcool_test;
+            $this->data_alcool_test_esito = $data->alcool_test_esito;
+            $this->data_drug_test = $data->drug_test;
+            $this->data_drug_test_esito = $data->drug_test_esito;
+            $this->data_sistema_ritenuta_minori = $data->sistema_ritenuta_minori;
+            $this->data_sistema_ritenuta_minori_omologazione = $data->sistema_ritenuta_minori_omologazione;
+            $this->data_verbale_violazione_numero_1 = $data->verbale_violazione_numero_1;
+            $this->data_articolo_violato_1 = $data->articolo_violato_1;
+            $this->data_cds_1 = $data->cds_1;
+            $this->data_verbale_violazione_numero_2 = $data->verbale_violazione_numero_2;
+            $this->data_articolo_violato_2 = $data->articolo_violato_2;
+            $this->data_cds_2 = $data->cds_2;
+            $this->data_verbale_violazione_numero_3 = $data->verbale_violazione_numero_3;
+            $this->data_articolo_violato_3 = $data->articolo_violato_3;
+            $this->data_cds_3 = $data->cds_3;
+            $this->data_conducente_patente_numero = $data->conducente_patente_numero;
+            $this->data_conducente_patente_categoria = $data->conducente_patente_categoria;
+            $this->data_conducente_patente_rilasciata_da = $data->conducente_patente_rilasciata_da;
+            $this->data_conducente_patente_rilasciata_da_altro = $data->conducente_patente_rilasciata_da_altro;
+            $this->data_conducente_patente_rilasciata_il = $data->conducente_patente_rilasciata_il;
+            $this->data_conducente_patente_scadenza = $data->conducente_patente_scadenza;
+            $this->data_conducente_patente_prescrizioni = $data->conducente_patente_prescrizioni;
+            $this->data_conducente_patente_limitazioni_art_117_1 = $data->conducente_patente_limitazioni_art_117_1;
+            $this->data_conducente_patente_limitazioni_art_117_2 = $data->conducente_patente_limitazioni_art_117_2;
+            $this->data_conducente_patente_abilitazione = $data->conducente_patente_abilitazione;
+            $this->data_conducente_patente_abilitazione_numero = $data->conducente_patente_abilitazione_numero;
+            $this->data_conducente_patente_abilitazione_rilasciata_da = $data->conducente_patente_abilitazione_rilasciata_da;
+            $this->data_conducente_patente_abilitazione_rilasciata_il = $data->conducente_patente_abilitazione_rilasciata_il;
+            $this->data_conducente_documento = $data->conducente_documento;
+            $this->data_conducente_documento_numero = $data->conducente_documento_numero;
+            $this->data_conducente_sedicente = $data->conducente_sedicente;
+            $this->data_tipo_danno = $data->tipo_danno;
+            $this->data_entita_danno = $data->entita_danno;
+            $this->data_effetto_danno = $data->effetto_danno;
+            $this->data_parte_macchina = $data->parte_macchina;
+
+            $this->data_tipo_danno_2 = $data->tipo_danno_2;
+            $this->data_entita_danno_2 = $data->entita_danno_2;
+            $this->data_effetto_danno_2 = $data->effetto_danno_2;
+            $this->data_parte_macchina_2 = $data->parte_macchina_2;
+
+            $this->data_tipo_danno_3 = $data->tipo_danno_3;
+            $this->data_entita_danno_3 = $data->entita_danno_3;
+            $this->data_effetto_danno_3 = $data->effetto_danno_3;
+            $this->data_parte_macchina_3 = $data->parte_macchina_3;
+
+            $this->data_tipo_danno_4 = $data->tipo_danno_4;
+            $this->data_entita_danno_4 = $data->entita_danno_4;
+            $this->data_effetto_danno_4 = $data->effetto_danno_4;
+            $this->data_parte_macchina_4 = $data->parte_macchina_4;
+        }
+        else
+        {
+            if ($this->data_conducenti == "" || $this->data_conducenti == 0)
+            {
+                $an = \App\Models\ReportDataPartiCoinvolte::where('report_id', $this->dataId)->where('progressive', $progressive)->first();
+                $this->data_conducenti = $an->anagrafica;
+            }
+        }
+
+        $cinture = \App\Models\ReportDataCintureSicurezza::where('progressive', $progressive)->where('report_id', $this->dataId)->first();
+        if ($cinture != null)
+        {
+            $this->data_cinture_conducente = $cinture->conducente;
+            $this->data_cinture_passeggeri_0 = $cinture->passeggeri_0;
+            $this->data_cinture_passeggeri_1 = $cinture->passeggeri_1;
+            $this->data_cinture_passeggeri_2 = $cinture->passeggeri_2;
+            $this->data_cinture_passeggeri_3 = $cinture->passeggeri_3;
+        }
+
+        $casco = \App\Models\ReportDataUsoDelCasco::where('progressive', $progressive)->where('report_id', $this->dataId)->first();
+        if ($casco != null)
+        {
+            $this->data_casco_conducente = $casco->conducente;
+            $this->data_casco_passeggero = $casco->passeggeri;
+        }
+
+        $omologazione = \App\Models\ReportDataUsoDelCascoOmologazione::where('progressive', $progressive)->where('report_id', $this->dataId)->first();
+        if ($omologazione != null)
+        {
+            $this->data_casco_omologazione_conducente = $omologazione->conducente;
+            $this->data_casco_omologazione_passeggero = $omologazione->passeggeri;
+        }
+
+        // Passeggeri
+        $passeggeri = \App\Models\ReportDataPasseggeri::where('progressive', $progressive)->where('report_id', $this->dataId)->get();
+        foreach($passeggeri as $idx => $pa)
+        {
+            if($idx == 0)
+            {
+                $this->data_passeggero_0 = $pa->passeggero;
+                $this->data_infortunato_0 = $pa->infortunato;
+                $this->data_infortunato_ospedale_0 = $pa->infortunato_ospedale;
+            }
+            if($idx == 1)
+            {
+                $this->data_passeggero_1 = $pa->passeggero;
+                $this->data_infortunato_1 = $pa->infortunato;
+                $this->data_infortunato_ospedale_1 = $pa->infortunato_ospedale;
+            }
+            if($idx == 2)
+            {
+                $this->data_passeggero_2 = $pa->passeggero;
+                $this->data_infortunato_2 = $pa->infortunato;
+                $this->data_infortunato_ospedale_2 = $pa->infortunato_ospedale;
+            }
+            if($idx == 3)
+            {
+                $this->data_passeggero_3 = $pa->passeggero;
+                $this->data_infortunato_3 = $pa->infortunato;
+                $this->data_infortunato_ospedale_3 = $pa->infortunato_ospedale;
+            }
+        }
+
+        // Infortunati
+        $infortunati = \App\Models\ReportDataInfortunati::where('progressive', $progressive)->where('report_id', $this->dataId)->get();
+        foreach($infortunati as $idx => $i)
+        {
+            if($idx == 0)
+                $this->data_infortunato_extra_0 = $i->infortunato;
+            if($idx == 1)
+                $this->data_infortunato_extra_1 = $i->infortunato;
+            if($idx == 2)
+                $this->data_infortunato_extra_2 = $i->infortunato;
+            if($idx == 3)
+                $this->data_infortunato_extra_3 = $i->infortunato;
+        }
+
+        $this->emit('load-select-modal');
+
+        if ($this->data_polizze > 0)
+            $this->emit('add-default-value', $this->data_polizze, $this->getPolizza($this->data_polizze), 'data_polizze');
+        if ($this->data_proprietari > 0)
+            $this->emit('add-default-value', $this->data_proprietari, $this->getAnagrafica($this->data_proprietari), 'data_proprietari');
+        if ($this->data_coproprietari > 0)
+            $this->emit('add-default-value', $this->data_coproprietari, $this->getAnagrafica($this->data_coproprietari), 'data_coproprietari');
+        if ($this->data_passeggero_0 > 0)
+            $this->emit('add-default-value', $this->data_passeggero_0, $this->getAnagrafica($this->data_passeggero_0), 'data_passeggero_0');
+        if ($this->data_passeggero_1 > 0)
+            $this->emit('add-default-value', $this->data_passeggero_1, $this->getAnagrafica($this->data_passeggero_1), 'data_passeggero_1');
+        if ($this->data_passeggero_2 > 0)
+            $this->emit('add-default-value', $this->data_passeggero_2, $this->getAnagrafica($this->data_passeggero_2), 'data_passeggero_2');
+        if ($this->data_passeggero_3 > 0)
+            $this->emit('add-default-value', $this->data_passeggero_3, $this->getAnagrafica($this->data_passeggero_3), 'data_passeggero_3');
+
+        if ($this->data_infortunato_extra_0 > 0)
+            $this->emit('add-default-value', $this->data_infortunato_extra_0, $this->getAnagrafica($this->data_infortunato_extra_0), 'data_infortunato_extra_0');
+        if ($this->data_infortunato_extra_1 > 0)
+            $this->emit('add-default-value', $this->data_infortunato_extra_1, $this->getAnagrafica($this->data_infortunato_extra_1), 'data_infortunato_extra_1');
+        if ($this->data_infortunato_extra_2 > 0)
+            $this->emit('add-default-value', $this->data_infortunato_extra_2, $this->getAnagrafica($this->data_infortunato_extra_2), 'data_infortunato_extra_2');
+        if ($this->data_infortunato_extra_3 > 0)
+            $this->emit('add-default-value', $this->data_infortunato_extra_3, $this->getAnagrafica($this->data_infortunato_extra_3), 'data_infortunato_extra_3');
+
+        if ($this->data_conducenti > 0)
+            $this->emit('add-default-value', $this->data_conducenti, $this->getAnagrafica($this->data_conducenti), 'data_conducenti');
+
+    }
+
+    public function editPedoneData($progressive)
+    {
+
+        $this->resetPedoniData();
+
+        $this->currentProgressive = $progressive;
+
+        $x = \App\Models\ReportDataPartiCoinvolte::where('report_id', $this->dataId)->where('progressive', $progressive)->first();
+
+        $this->currentPedone = $x->anagrafica;
+
+        $data = \App\Models\ReportDataPedoni::where('progressive', $progressive)->where('report_id', $this->dataId)->first();
+        if ($data != null)
+        {
+            $this->generalizzato = $data->generalizzato;
+            $this->generalizzato_altrove = $data->generalizzato_altrove;
+            $this->infortunato = $data->infortunato;
+            $this->infortunato_ospedale = $data->infortunato_ospedale;
+            $this->pedone_posizione = $data->pedone_posizione;
+            $this->pedone_posizione_desc = $data->pedone_posizione_desc;
+            $this->pedone_referto = $data->pedone_referto;
+            $this->pedone_prognosi = $data->pedone_prognosi;
+            $this->pedone_pioggia = $data->pedone_pioggia;
+            $this->pedone_ombrello = $data->pedone_ombrello;
+            $this->pedone_notte = $data->pedone_notte;
+            $this->pedone_abiti_scuri = $data->pedone_abiti_scuri;
+            $this->verbale_violazione_numero = $data->verbale_violazione_numero;
+            $this->articolo_violato = $data->articolo_violato;
+            $this->cds = $data->cds;
+
+        }
+
+        if ($this->currentPedone > 0)
+        {
+            $this->emit('load-pedone', $this->getAnagrafica($this->currentPedone));
+        }
+
+        $this->emit('load-select-pedone');
+
+        /*$this->emit('load-select-modal');
+
+        if ($this->data_polizze > 0)
+            $this->emit('add-default-value', $this->data_polizze, $this->getPolizza($this->data_polizze), 'data_polizze');
+        if ($this->data_proprietari > 0)
+            $this->emit('add-default-value', $this->data_proprietari, $this->getAnagrafica($this->data_proprietari), 'data_proprietari');
+        if ($this->data_conducenti > 0)
+            $this->emit('add-default-value', $this->data_conducenti, $this->getAnagrafica($this->data_conducenti), 'data_conducenti');*/
+
+    }
+
+    public function anagraficaSave()
+    {
+
+        if ($this->currentAnagrafica > 0)
+        {
+            \App\Models\Anagrafica::whereId($this->currentAnagrafica)->update([
+                'type' => $this->anag_type,
+                'firstname' => $this->anag_firstname,
+                'lastname' => $this->anag_lastname,
+                'gender' => $this->anag_gender,
+                'birth_date' => $this->anag_birth_date,
+                'birth_town_id' => $this->anag_birth_town_id,
+                'birth_prov_id' => $this->anag_birth_prov_id,
+                'residenza_town_id' => $this->anag_residenza_town_id,
+                'residenza_prov_id' => $this->anag_residenza_prov_id,
+                'residenza_address' => $this->anag_residenza_address,
+                'residenza_cap' => $this->anag_residenza_cap,
+                'mobile' => $this->anag_mobile,
+                'sedicente' => $this->anag_sedicente,
+                'documento_tipo' => $this->anag_documento_tipo,
+                'documento_patente_cat' => $this->anag_documento_patente_cat,
+                'documento_tipo_altro' => $this->anag_documento_tipo_altro,
+                'documento_numero' => $this->anag_documento_numero,
+                'documento_rilasciato_da' => $this->anag_documento_rilasciato_da,
+                'documento_rilasciato_da_altro' => $this->anag_documento_rilasciato_da_altro,
+                'foreign_country' => $this->anag_foreign_country,
+                'documento_rilasciato_da_di_foreign_localita' => $this->anag_documento_rilasciato_da_di_foreign_localita,
+                'documento_rilasciato_da_di_foreign_country' => $this->anag_documento_rilasciato_da_di_foreign_country,
+                'documento_rilasciato_da_prov_id' => $this->anag_documento_rilasciato_da_prov_id,
+                'documento_rilasciato_da_town_id' => $this->anag_documento_rilasciato_da_town_id,
+                'documento_rilasciato_il' => $this->anag_documento_rilasciato_il,
+                'documento_scadenza_il' => $this->anag_documento_scadenza_il,
+                'state' => $this->anag_state,
+                'nazionalita' => $this->anag_nazionalita,
+                'nazione_straniera' => $this->anag_nazione_straniera,
+                'localita_straniera' => $this->anag_localita_straniera,
+                'rag_soc' => $this->anag_rag_soc,
+                'vat' => $this->anag_vat,
+                'sede_legale_town_id' => $this->anag_sede_legale_town_id,
+                'sede_legale_prov_id' => $this->anag_sede_legale_prov_id,
+                'sede_legale_address' => $this->anag_sede_legale_address,
+                'sede_legale_cap' => $this->anag_sede_legale_cap,
+                'phone' => $this->anag_phone,
+                'anag_foreign_birth_country' => $this->anag_foreign_birth_country,
+                'anag_foreign_birth_city' => $this->anag_foreign_birth_city,
+                'anag_foreign_residence_country' => $this->anag_foreign_residence_country,
+                'anag_foreign_residence_city' => $this->anag_foreign_residence_city
+            ]);
+
+            /*
+            if ($this->currentProprietario > 0)
+            {
+                $this->emit('add-default-value', $this->data_proprietari, $this->getAnagrafica($this->data_proprietari), 'data_proprietari');
+            }
+            if ($this->currentPasseggero > 0)
+            {
+                $set = true;
+                if ($this->currentPasseggero == 1)
+                {
+                    $this->data_passeggero_0 = $anagrafica->id;
+                    $this->emit('add-default-value', $this->data_passeggero_0, $this->getAnagrafica($this->data_passeggero_0), 'data_passeggero_0');
+                }
+                if ($this->currentPasseggero == 2)
+                {
+                    $this->data_passeggero_1 = $anagrafica->id;
+                    $this->emit('add-default-value', $this->data_passeggero_1, $this->getAnagrafica($this->data_passeggero_1), 'data_passeggero_1');
+                }
+                if ($this->currentPasseggero == 3)
+                {
+                    $this->data_passeggero_2 = $anagrafica->id;
+                    $this->emit('add-default-value', $this->data_passeggero_2, $this->getAnagrafica($this->data_passeggero_2), 'data_passeggero_2');
+                }
+                if ($this->currentPasseggero == 4)
+                {
+                    $this->data_passeggero_3 = $anagrafica->id;
+                    $this->emit('add-default-value', $this->data_passeggero_3, $this->getAnagrafica($this->data_passeggero_3), 'data_passeggero_3');
+                }
+            }
+
+            if ($this->currentInfortunato > 0)
+            {
+                $set = true;
+                if ($this->currentInfortunato == 1)
+                {
+                    $this->data_infortunato_extra_0 = $anagrafica->id;
+                    $this->emit('add-default-value', $this->data_infortunato_extra_0, $this->getAnagrafica($this->data_infortunato_extra_0), 'data_infortunato_extra_0');
+                }
+                if ($this->currentInfortunato == 2)
+                {
+                    $this->data_infortunato_extra_1 = $anagrafica->id;
+                    $this->emit('add-default-value', $this->data_infortunato_extra_1, $this->getAnagrafica($this->data_infortunato_extra_1), 'data_infortunato_extra_1');
+                }
+                if ($this->currentInfortunato == 3)
+                {
+                    $this->data_infortunato_extra_2 = $anagrafica->id;
+                    $this->emit('add-default-value', $this->data_infortunato_extra_2, $this->getAnagrafica($this->data_infortunato_extra_2), 'data_infortunato_extra_2');
+                }
+                if ($this->currentInfortunato == 4)
+                {
+                    $this->data_infortunato_extra_3 = $anagrafica->id;
+                    $this->emit('add-default-value', $this->data_infortunato_extra_3, $this->getAnagrafica($this->data_infortunato_extra_3), 'data_infortunato_extra_3');
+                }
+            }
+
+
+            if ($this->currentConducente > 0)
+            {
+                //$this->emit('load-select-modal');
+                $this->emit('set-default-value', $this->data_conducenti, $this->getAnagrafica($this->data_conducenti), 'data_conducenti');
+            }*/
+
+        }
+        else
+        {
+            $anagrafica = \App\Models\Anagrafica::create([
+                'type' => $this->anag_type,
+                'firstname' => $this->anag_firstname,
+                'lastname' => $this->anag_lastname,
+                'gender' => $this->anag_gender,
+                'birth_date' => $this->anag_birth_date,
+                'birth_town_id' => $this->anag_birth_town_id,
+                'birth_prov_id' => $this->anag_birth_prov_id,
+                'residenza_town_id' => $this->anag_residenza_town_id,
+                'residenza_prov_id' => $this->anag_residenza_prov_id,
+                'residenza_address' => $this->anag_residenza_address,
+                'residenza_cap' => $this->anag_residenza_cap,
+                'mobile' => $this->anag_mobile,
+                'sedicente' => $this->anag_sedicente,
+                'documento_tipo' => $this->anag_documento_tipo,
+                'documento_patente_cat' => $this->anag_documento_patente_cat,
+                'documento_tipo_altro' => $this->anag_documento_tipo_altro,
+                'documento_numero' => $this->anag_documento_numero,
+                'documento_rilasciato_da' => $this->anag_documento_rilasciato_da,
+                'documento_rilasciato_da_altro' => $this->anag_documento_rilasciato_da_altro,
+                'foreign_country' => $this->anag_foreign_country,
+                'documento_rilasciato_da_di_foreign_localita' => $this->anag_documento_rilasciato_da_di_foreign_localita,
+                'documento_rilasciato_da_di_foreign_country' => $this->anag_documento_rilasciato_da_di_foreign_country,
+                'documento_rilasciato_da_prov_id' => $this->anag_documento_rilasciato_da_prov_id,
+                'documento_rilasciato_da_town_id' => $this->anag_documento_rilasciato_da_town_id,
+                'documento_rilasciato_il' => $this->anag_documento_rilasciato_il,
+                'documento_scadenza_il' => $this->anag_documento_scadenza_il,
+                'state' => $this->anag_state,
+                'nazionalita' => $this->anag_nazionalita,
+                'nazione_straniera' => $this->anag_nazione_straniera,
+                'localita_straniera' => $this->anag_localita_straniera,
+                'rag_soc' => $this->anag_rag_soc,
+                'vat' => $this->anag_vat,
+                'sede_legale_town_id' => $this->anag_sede_legale_town_id,
+                'sede_legale_prov_id' => $this->anag_sede_legale_prov_id,
+                'sede_legale_address' => $this->anag_sede_legale_address,
+                'sede_legale_cap' => $this->anag_sede_legale_cap,
+                'phone' => $this->anag_phone
+            ]);
+
+            $set = false;
+
+            if ($this->currentTeste > 0)
+            {
+                $set = true;
+                if ($this->currentTeste == 1)
+                    $this->data_testi_oculari_0 = $anagrafica->id;
+                if ($this->currentTeste == 2)
+                    $this->data_testi_oculari_1 = $anagrafica->id;
+                if ($this->currentTeste == 3)
+                    $this->data_testi_oculari_2 = $anagrafica->id;
+                if ($this->currentTeste == 4)
+                    $this->data_testi_oculari_3 = $anagrafica->id;
+            }
+            if ($this->currentProprietario > 0)
+            {
+                $set = true;
+                $this->data_proprietari = $anagrafica->id;
+                $this->emit('add-default-value', $this->data_proprietari, $this->getAnagrafica($this->data_proprietari), 'data_proprietari');
+            }
+            if ($this->currentCoproprietario > 0)
+            {
+                $set = true;
+                $this->data_coproprietari = $anagrafica->id;
+                $this->emit('add-default-value', $this->data_coproprietari, $this->getAnagrafica($this->data_coproprietari), 'data_coproprietari');
+            }
+            if ($this->currentPasseggero > 0)
+            {
+                $set = true;
+                if ($this->currentPasseggero == 1)
+                {
+                    $this->data_passeggero_0 = $anagrafica->id;
+                    $this->emit('add-default-value', $this->data_passeggero_0, $this->getAnagrafica($this->data_passeggero_0), 'data_passeggero_0');
+                }
+                if ($this->currentPasseggero == 2)
+                {
+                    $this->data_passeggero_1 = $anagrafica->id;
+                    $this->emit('add-default-value', $this->data_passeggero_1, $this->getAnagrafica($this->data_passeggero_1), 'data_passeggero_1');
+                }
+                if ($this->currentPasseggero == 3)
+                {
+                    $this->data_passeggero_2 = $anagrafica->id;
+                    $this->emit('add-default-value', $this->data_passeggero_2, $this->getAnagrafica($this->data_passeggero_2), 'data_passeggero_2');
+                }
+                if ($this->currentPasseggero == 4)
+                {
+                    $this->data_passeggero_3 = $anagrafica->id;
+                    $this->emit('add-default-value', $this->data_passeggero_3, $this->getAnagrafica($this->data_passeggero_3), 'data_passeggero_3');
+                }
+            }
+
+            if ($this->currentInfortunato > 0)
+            {
+                $set = true;
+                if ($this->currentInfortunato == 1)
+                {
+                    $this->data_infortunato_extra_0 = $anagrafica->id;
+                    $this->emit('add-default-value', $this->data_infortunato_extra_0, $this->getAnagrafica($this->data_infortunato_extra_0), 'data_infortunato_extra_0');
+                }
+                if ($this->currentInfortunato == 2)
+                {
+                    $this->data_infortunato_extra_1 = $anagrafica->id;
+                    $this->emit('add-default-value', $this->data_infortunato_extra_1, $this->getAnagrafica($this->data_infortunato_extra_1), 'data_infortunato_extra_1');
+                }
+                if ($this->currentInfortunato == 3)
+                {
+                    $this->data_infortunato_extra_2 = $anagrafica->id;
+                    $this->emit('add-default-value', $this->data_infortunato_extra_2, $this->getAnagrafica($this->data_infortunato_extra_2), 'data_infortunato_extra_2');
+                }
+                if ($this->currentInfortunato == 4)
+                {
+                    $this->data_infortunato_extra_3 = $anagrafica->id;
+                    $this->emit('add-default-value', $this->data_infortunato_extra_3, $this->getAnagrafica($this->data_infortunato_extra_3), 'data_infortunato_extra_3');
+                }
+            }
+
+
+            if ($this->currentConducente > 0)
+            {
+                $set = true;
+                $this->data_conducenti = $anagrafica->id;
+                $this->emit('add-default-value', $this->data_conducenti, $this->getAnagrafica($this->data_conducenti), 'data_conducenti');
+            }
+
+            if ($this->currentProgressive > -1 && !$set)
+                $this->updateAnagraficaParteCoinvolta($anagrafica->id, $this->currentProgressive);
+
+        }
+
+        $this->resetAnagrafica();
+        $this->emit('close-modal');
+
+    }
+
+    public function accertatoreSave()
+    {
+
+        if ($this->currentAccertatore > 0)
+        {
+            \App\Models\User::whereId($this->currentAccertatore)->update([
+                'firstname' => $this->accertatore_nome,
+                'lastname' => $this->accertatore_cognome,
+                'username' => $this->accertatore_username,
+                'email' => $this->accertatore_email,
+                'password' => $this->accertatore_password,
+            ]);
+        }
+        else
+        {
+            $accertatore = \App\Models\User::create([
+                'firstname' => $this->accertatore_nome,
+                'lastname' => $this->accertatore_cognome,
+                'username' => $this->accertatore_username,
+                'email' => $this->accertatore_email,
+                'password' => bcrypt($this->accertatore_password),
+            ]);
+
+            if ($this->currentAccertatoreNumero == 1)
+                $this->accertatore_1 = $accertatore->id;
+            if ($this->currentAccertatoreNumero == 2)
+                $this->accertatore_2 = $accertatore->id;
+            if ($this->currentAccertatoreNumero == 3)
+                $this->accertatore_3 = $accertatore->id;
+            if ($this->currentAccertatoreNumero == 4)
+                $this->accertatore_4 = $accertatore->id;
+            if ($this->currentAccertatoreNumero == 5)
+                $this->accertatore_5 = $accertatore->id;
+
+        }
+
+        $this->resetAccertatore();
+        $this->emit('close-modal');
+
+    }
+
+    public function veicoloSave()
+    {
+        $this->validate([
+            'vei_tipo_id' => 'required',
+            'vei_marca_id' => 'required',
+            'vei_modello_id' => 'required',
+            'vei_carta_circolazione_rilasciata_da' => 'required',
+            'vei_foreign_country' => 'required',
+            'vei_carta_circolazione_rilasciata_da_di' => 'required',
+            'vei_destinazione_uso' => 'required',
+        ], [
+            'vei_tipo_id.required' => 'Il campo "Tipo di veicolo" è obbligatorio.',
+            'vei_marca_id.required' => 'Il campo "Marca" è obbligatorio.',
+            'vei_modello_id.required' => 'Il campo "Modello" è obbligatorio.',
+            'vei_carta_circolazione_rilasciata_da.required' => 'Il campo "Rilasciata da" è obbligatorio.',
+            'vei_foreign_country.required' => 'Il campo "Paese di rilascio" è obbligatorio.',
+            'vei_carta_circolazione_rilasciata_da_di.required' => 'Il campo "Località di rilascio" è obbligatorio.',
+            'vei_destinazione_uso.required' => 'Il campo "Destinazione d\'uso" è obbligatorio.',
+        ]);
+
+        if ($this->currentVeicolo > 0)
+        {
+            \App\Models\Vehicle::whereId($this->currentVeicolo)->update([
+                'tipo_id' => $this->vei_tipo_id,
+                'marca_id' => $this->vei_marca_id,
+                'marca_altro' => $this->vei_marca_altro,
+                'modello_id' => $this->vei_modello_id,
+                'modello_altro' => $this->vei_modello_altro,
+                'colore' => $this->vei_colore,
+                'targa' => $this->vei_targa,
+                'carta_circolazione' => $this->vei_carta_circolazione,
+                'carta_circolazione_rilasciata_da' => $this->vei_carta_circolazione_rilasciata_da,
+                'carta_circolazione_rilasciata_da_altro' => $this->vei_carta_circolazione_rilasciata_da_altro,
+                'foreign_country' => $this->vei_foreign_country,
+                'carta_circolazione_rilasciata_da_di_foreign_country' => $this->vei_carta_circolazione_rilasciata_da_di_foreign_country,
+                'carta_circolazione_rilasciata_da_di_foreign_localita' => $this->vei_carta_circolazione_rilasciata_da_di_foreign_localita,
+                'carta_circolazione_rilasciata_da_di' => $this->vei_carta_circolazione_rilasciata_da_di,
+                'carta_circolazione_rilasciata_il' => $this->vei_carta_circolazione_rilasciata_il,
+                'data_ultima_revisione' => $this->vei_data_ultima_revisione,
+                'cilindrata' => $this->vei_cilindrata,
+                'peso_complessivo' => $this->vei_peso_complessivo,
+                'destinazione_uso' => $this->vei_destinazione_uso
+            ]);
+        }
+        else
+        {
+            $veicolo = \App\Models\Vehicle::create([
+                'tipo_id' => $this->vei_tipo_id,
+                'marca_id' => $this->vei_marca_id,
+                'marca_altro' => $this->vei_marca_altro,
+                'modello_id' => $this->vei_modello_id,
+                'modello_altro' => $this->vei_modello_altro,
+                'colore' => $this->vei_colore,
+                'targa' => $this->vei_targa,
+                'carta_circolazione' => $this->vei_carta_circolazione,
+                'carta_circolazione_rilasciata_da' => $this->vei_carta_circolazione_rilasciata_da,
+                'carta_circolazione_rilasciata_da_altro' => $this->vei_carta_circolazione_rilasciata_da_altro,
+                'foreign_country' => $this->vei_foreign_country,
+                'carta_circolazione_rilasciata_da_di_foreign_country' => $this->vei_carta_circolazione_rilasciata_da_di_foreign_country,
+                'carta_circolazione_rilasciata_da_di_foreign_localita' => $this->vei_carta_circolazione_rilasciata_da_di_foreign_localita,
+                'carta_circolazione_rilasciata_da_di' => $this->vei_carta_circolazione_rilasciata_da_di,
+                'carta_circolazione_rilasciata_il' => $this->vei_carta_circolazione_rilasciata_il,
+                'data_ultima_revisione' => $this->vei_data_ultima_revisione,
+                'cilindrata' => $this->vei_cilindrata,
+                'peso_complessivo' => $this->vei_peso_complessivo,
+                'destinazione_uso' => $this->vei_destinazione_uso
+            ]);
+            $this->updateVeicoloParteCoinvolta($veicolo->id, $this->currentProgressive);
+        }
+        $this->resetVeicolo();
+        $this->emit('close-modal');
+
+    }
+
+    public function pedoneSave()
+    {
+
+        \App\Models\ReportDataPedoni::where('progressive', $this->currentProgressive)->where('report_id', $this->dataId)->delete();
+        try
+        {
+            $pedone = \App\Models\ReportDataPedoni::create([
+                'progressive' => $this->currentProgressive,
+                'report_id' => $this->dataId,
+                'pedoni' => $this->currentPedone,
+                'generalizzato' => $this->generalizzato,
+                'generalizzato_altrove' => $this->generalizzato_altrove,
+                'infortunato' => $this->infortunato,
+                'infortunato_ospedale' => $this->infortunato_ospedale,
+                'pedone_posizione' => $this->pedone_posizione,
+                'pedone_posizione_desc' => $this->pedone_posizione_desc,
+                'pedone_referto' => $this->pedone_referto,
+                'pedone_prognosi' => $this->pedone_prognosi,
+                'pedone_pioggia' => $this->pedone_pioggia,
+                'pedone_ombrello' => $this->pedone_ombrello,
+                'pedone_notte' => $this->pedone_notte,
+                'pedone_abiti_scuri' => $this->pedone_abiti_scuri,
+                'verbale_violazione_numero' => $this->verbale_violazione_numero,
+                'articolo_violato' => $this->articolo_violato,
+                'cds' => $this->cds
+            ]);
+
+            session()->flash('success','Record salvato');
+
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio (' . $ex->getMessage() . ')');
+        }
+
+        $this->resetPedoniData();
+        $this->emit('close-modal');
+
+    }
+
+    public function addAccertatore($numero)
+    {
+
+        $this->resetAccertatore();
+        $this->currenAccertatoreNumero = $numero;
+        // $this->emit('load-anagrafica-modal');
+
+    }
+
+    public function editAccertatore($utente)
+    {
+
+        $this->resetAccertatore();
+
+        $acc = \App\Models\User::where('id', $utente)->first();
+        if ($acc != null)
+        {
+            $this->currentAccertatore = $utente;
+            $this->accertatore_nome = $acc->firstname;
+            $this->accertatore_cognome = $acc->lastname;
+            // $this->accertatore_grado = 0;
+            $this->accertatore_username = $acc->username;
+            $this->accertatore_email = $acc->email;
+            $this->accertatore_password = '';
+            $this->accertatore_password_conferma = '';
+        }
+
+    }
+
+    public function anagraficaDataParteComuneSave()
+    {
+
+        // Elimino i vecchi record
+
+        \App\Models\ReportDataVeicoli::where('progressive', $this->currentProgressive)->where('report_id', $this->dataId)->delete();
+        \App\Models\ReportDataInfortunati::where('progressive', $this->currentProgressive)->where('report_id', $this->dataId)->delete();
+        \App\Models\ReportDataPasseggeri::where('progressive', $this->currentProgressive)->where('report_id', $this->dataId)->delete();
+        \App\Models\ReportDataUsoDelCascoOmologazione::where('progressive', $this->currentProgressive)->where('report_id', $this->dataId)->delete();
+        \App\Models\ReportDataUsoDelCasco::where('progressive', $this->currentProgressive)->where('report_id', $this->dataId)->delete();
+        \App\Models\ReportDataCintureSicurezza::where('progressive', $this->currentProgressive)->where('report_id', $this->dataId)->delete();
+
+        try {
+            \App\Models\ReportDataVeicoli::create([
+                'progressive' => $this->currentProgressive,
+                'report_id' => $this->dataId,
+                'veicolo' => $this->currentVeicolo,
+                'chilometri_percorsi' => $this->data_chilometri_percorsi,
+                'stato_veicolo' => $this->data_stato_veicolo,
+                'polizze' => $this->data_polizze,
+                'proprietari' => $this->data_proprietari,
+                'coproprietari' => $this->data_coproprietari,
+                'conducente_uguale_proprietario' => $this->data_conducente_uguale_proprietario,
+                'conducenti' => $this->data_conducenti,
+                'infortunato' => $this->data_infortunato,
+                'infortunato_ospedale' => $this->data_infortunato_ospedale,
+                'patente_al_seguito' => $this->data_patente_al_seguito,
+                'generalizzato' => $this->data_generalizzato,
+                'generalizzato_altrove' => $this->data_generalizzato_altrove,
+                'posizione_statica_finale' => $this->data_posizione_statica_finale,
+                'danni_visibili_riportati' => $this->data_danni_visibili_riportati,
+                'danni_visibili_pre_esistenti' => $this->data_danni_visibili_pre_esistenti,
+                'destinazione_veicolo' => $this->data_destinazione_veicolo,
+                'destinazione_veicolo_affidato_a' => $this->data_destinazione_veicolo_affidato_a,
+                'destinazione_veicolo_sequestro_num_art' => $this->data_destinazione_veicolo_sequestro_num_art,
+                'destinazione_veicolo_amministrativo_num' => $this->data_destinazione_veicolo_amministrativo_num,
+                'destinazione_veicolo_amministrativo_num_art_violato' => $this->data_destinazione_veicolo_amministrativo_num_art_violato,
+                'destinazione_veicolo_amministrativo_cds' => $this->data_destinazione_veicolo_amministrativo_cds,
+                'circostanze_presunte_incidente' => $this->data_circostanze_presunte_incidente,
+                'stato_pneumatici' => $this->data_stato_pneumatici,
+                'marca_pneumatici' => $this->data_marca_pneumatici,
+                'misura_pneumatici' => $this->data_misura_pneumatici,
+                'dispositivi_ottici' => $this->data_dispositivi_ottici,
+                'tergicristalli' => $this->data_tergicristalli,
+                'segnale_pericolo' => $this->data_segnale_pericolo,
+                'abs' => $this->data_abs,
+                'gps' => $this->data_gps,
+                'marcia_inserita' => $this->data_marcia_inserita,
+                'cristallo' => $this->data_cristallo,
+                'cristallo_posizione' => $this->data_cristallo_posizione,
+                'specchio_retrovisore' => $this->data_specchio_retrovisore,
+                'specchio_lat_dx' => $this->data_specchio_lat_dx,
+                'specchio_lat_sx' => $this->data_specchio_lat_sx,
+                'attivazione_airbag' => $this->data_attivazione_airbag,
+                'airbag_posizione' => $this->data_airbag_posizione,
+                'alcool_test' => $this->data_alcool_test,
+                'alcool_test_esito' => $this->data_alcool_test_esito,
+                'drug_test' => $this->data_drug_test,
+                'drug_test_esito' => $this->data_drug_test_esito,
+                'sistema_ritenuta_minori' => $this->data_sistema_ritenuta_minori,
+                'sistema_ritenuta_minori_omologazione' => $this->data_sistema_ritenuta_minori_omologazione,
+                'verbale_violazione_numero_1' => $this->data_verbale_violazione_numero_1,
+                'articolo_violato_1' => $this->data_articolo_violato_1,
+                'cds_1' => $this->data_cds_1,
+                'verbale_violazione_numero_2' => $this->data_verbale_violazione_numero_2,
+                'articolo_violato_2' => $this->data_articolo_violato_2,
+                'cds_2' => $this->data_cds_2,
+                'verbale_violazione_numero_3' => $this->data_verbale_violazione_numero_3,
+                'articolo_violato_3' => $this->data_articolo_violato_3,
+                'cds_3' => $this->data_cds_3,
+                'conducente_patente_numero' => $this->data_conducente_patente_numero,
+                'conducente_patente_categoria' => $this->data_conducente_patente_categoria,
+                'conducente_patente_rilasciata_da' => $this->data_conducente_patente_rilasciata_da,
+                'conducente_patente_rilasciata_da_altro' => $this->data_conducente_patente_rilasciata_da_altro,
+                'conducente_patente_rilasciata_il' => $this->data_conducente_patente_rilasciata_il,
+                'conducente_patente_scadenza' => $this->data_conducente_patente_scadenza,
+                'conducente_patente_prescrizioni' => $this->data_conducente_patente_prescrizioni,
+                'conducente_patente_limitazioni_art_117_1' => $this->data_conducente_patente_limitazioni_art_117_1,
+                'conducente_patente_limitazioni_art_117_2' => $this->data_conducente_patente_limitazioni_art_117_2,
+                'conducente_patente_abilitazione' => $this->data_conducente_patente_abilitazione,
+                'conducente_patente_abilitazione_numero' => $this->data_conducente_patente_abilitazione_numero,
+                'conducente_patente_abilitazione_rilasciata_da' => $this->data_conducente_patente_abilitazione_rilasciata_da,
+                'conducente_patente_abilitazione_rilasciata_il' => $this->data_conducente_patente_abilitazione_rilasciata_il,
+                'conducente_documento' => $this->data_conducente_documento,
+                'conducente_documento_numero' => $this->data_conducente_documento_numero,
+                'conducente_sedicente' => $this->data_conducente_sedicente,
+                'tipo_danno' => $this->data_tipo_danno > 0 ? $this->data_tipo_danno : null,
+                'entita_danno' => $this->data_entita_danno > 0 ? $this->data_entita_danno : null,
+                'effetto_danno' => $this->data_effetto_danno > 0 ? $this->data_effetto_danno : null,
+                'parte_macchina' => $this->data_parte_macchina > 0 ? $this->data_parte_macchina : null,
+                'tipo_danno_2' => $this->data_tipo_danno_2 > 0 ? $this->data_tipo_danno_2 : null,
+                'entita_danno_2' => $this->data_entita_danno_2 > 0 ? $this->data_entita_danno_2 : null,
+                'effetto_danno_2' => $this->data_effetto_danno_2 > 0 ? $this->data_effetto_danno_2 : null,
+                'parte_macchina_2' => $this->data_parte_macchina_2 > 0 ? $this->data_parte_macchina_2 : null,
+                'tipo_danno_3' => $this->data_tipo_danno_3 > 0 ? $this->data_tipo_danno_3 : null,
+                'entita_danno_3' => $this->data_entita_danno_3 > 0 ? $this->data_entita_danno_3 : null,
+                'effetto_danno_3' => $this->data_effetto_danno_3 > 0 ? $this->data_effetto_danno_3 : null,
+                'parte_macchina_3' => $this->data_parte_macchina_3 > 0 ? $this->data_parte_macchina_3 : null,
+                'tipo_danno_4' => $this->data_tipo_danno_4 > 0 ? $this->data_tipo_danno_4 : null,
+                'entita_danno_4' => $this->data_entita_danno_4 > 0 ? $this->data_entita_danno_4 : null,
+                'effetto_danno_4' => $this->data_effetto_danno_4 > 0 ? $this->data_effetto_danno_4 : null,
+                'parte_macchina_4' => $this->data_parte_macchina_4 > 0 ? $this->data_parte_macchina_4 : null
+            ]);
+            session()->flash('success','Record creato');
+
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio (' . $ex->getMessage() . ')');
+        }
+
+        try {
+            \App\Models\ReportDataCintureSicurezza::create([
+                'progressive' => $this->currentProgressive,
+                'report_id' => $this->dataId,
+                'conducente' => $this->data_cinture_conducente,
+                'passeggeri_0' => $this->data_cinture_passeggeri_0,
+                'passeggeri_1' => $this->data_cinture_passeggeri_1,
+                'passeggeri_2' => $this->data_cinture_passeggeri_2,
+                'passeggeri_3' => $this->data_cinture_passeggeri_3
+            ]);
+            // session()->flash('success','Record creato');
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio (' . $ex->getMessage() . ')');
+        }
+
+        try {
+            \App\Models\ReportDataUsoDelCasco::create([
+                'progressive' => $this->currentProgressive,
+                'report_id' => $this->dataId,
+                'conducente' => $this->data_casco_conducente,
+                'passeggeri' => $this->data_casco_passeggero
+            ]);
+            // session()->flash('success','Record creato');
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio (' . $ex->getMessage() . ')');
+        }
+
+        try {
+            \App\Models\ReportDataUsoDelCascoOmologazione::create([
+                'progressive' => $this->currentProgressive,
+                'report_id' => $this->dataId,
+                'conducente' => $this->data_casco_omologazione_conducente,
+                'passeggeri' => $this->data_casco_omologazione_passeggero
+            ]);
+            // session()->flash('success','Record creato');
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio (' . $ex->getMessage() . ')');
+        }
+
+        try {
+            \App\Models\ReportDataPasseggeri::create([
+                'progressive' => $this->currentProgressive,
+                'report_id' => $this->dataId,
+                'passeggero' => $this->data_passeggero_0,
+                'infortunato' => $this->data_infortunato_0,
+                'infortunato_ospedale' => $this->data_infortunato_ospedale_0
+            ]);
+            \App\Models\ReportDataPasseggeri::create([
+                'progressive' => $this->currentProgressive,
+                'report_id' => $this->dataId,
+                'passeggero' => $this->data_passeggero_1,
+                'infortunato' => $this->data_infortunato_1,
+                'infortunato_ospedale' => $this->data_infortunato_ospedale_1
+            ]);
+            \App\Models\ReportDataPasseggeri::create([
+                'progressive' => $this->currentProgressive,
+                'report_id' => $this->dataId,
+                'passeggero' => $this->data_passeggero_2,
+                'infortunato' => $this->data_infortunato_2,
+                'infortunato_ospedale' => $this->data_infortunato_ospedale_2
+            ]);
+            \App\Models\ReportDataPasseggeri::create([
+                'progressive' => $this->currentProgressive,
+                'report_id' => $this->dataId,
+                'passeggero' => $this->data_passeggero_3,
+                'infortunato' => $this->data_infortunato_3,
+                'infortunato_ospedale' => $this->data_infortunato_ospedale_3
+            ]);
+            // session()->flash('success','Record creato');
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio (' . $ex->getMessage() . ')');
+        }
+
+
+        try {
+            \App\Models\ReportDataInfortunati::create([
+                'progressive' => $this->currentProgressive,
+                'report_id' => $this->dataId,
+                'infortunato' => $this->data_infortunato_extra_0
+            ]);
+            \App\Models\ReportDataInfortunati::create([
+                'progressive' => $this->currentProgressive,
+                'report_id' => $this->dataId,
+                'infortunato' => $this->data_infortunato_extra_1
+            ]);
+            \App\Models\ReportDataInfortunati::create([
+                'progressive' => $this->currentProgressive,
+                'report_id' => $this->dataId,
+                'infortunato' => $this->data_infortunato_extra_2
+            ]);
+            \App\Models\ReportDataInfortunati::create([
+                'progressive' => $this->currentProgressive,
+                'report_id' => $this->dataId,
+                'infortunato' => $this->data_infortunato_extra_3
+            ]);
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio (' . $ex->getMessage() . ')');
+        }
+
+        $this->resetVeicoloData();
+        $this->emit('close-modal-parte-comune');
+
+    }
+
+    public function dateToNull()
+    {
+        return "0000-00-00";
+    }
+
+    public function getLocalita($localita)
+    {
+        if ($localita > 0)
+        {
+            $ret = \App\Models\LocationTown::where('id', $localita)->first();
+            if ($ret)
+                return $ret->title;
+            else
+                return "";
+        }
+        return "";
+    }
+
+    public function getStradario($stradario)
+    {
+        if ($stradario > 0)
+        {
+            $ret = \App\Models\Stradario::findOrFail($stradario);
+            return $ret->TOPONIMO . " " . $ret->DESCRIZIONE;
+        }
+        return "";
+    }
+
+    public function getAnagrafica($anagrafica)
+    {
+        if ($anagrafica > 0)
+        {
+            $ret = \App\Models\Anagrafica::findOrFail($anagrafica);
+            if($ret->type == 0)
+            return $ret->lastname . " " . $ret->firstname;
+            else
+            return $ret->rag_soc;
+        }
+        return "";
+    }
+
+    public function getAllegatoType($type)
+    {
+        if ($type > 0)
+        {
+            $ret = \App\Models\AllegatiGalleryType::findOrFail($type);
+            return $ret->name;
+        }
+        return "";
+    }
+
+    public function getAccertatore($accertatore)
+    {
+        if ($accertatore > 0)
+        {
+            $ret = \DB::table('fcf_users')->where('id', $accertatore)->first();
+            return @$ret->lastname . " " . @$ret->firstname;
+        }
+        return "";
+    }
+
+    public function getVeicolo($veicolo)
+    {
+        if ($veicolo > 0)
+        {
+            $ret = \App\Models\Vehicle::findOrFail($veicolo);
+            return ($ret->marca ? $ret->marca->name : '') . " " . ($ret->modello ? $ret->modello->name : '') . " " . $ret->targa;
+        }
+        return "";
+    }
+
+    public function getPolizza($polizza)
+    {
+        if ($polizza > 0)
+        {
+            $ret = \App\Models\Polizza::with('compagnia')->with('anagrafica')->findOrFail($polizza);
+            return $ret->agenzia . " " . ($ret->compagnia ? $ret->compagnia->name : '') . " " . ($ret->anagrafica ? ($ret->anagrafica->lastname . " " . $ret->anagrafica->firstname) : '');
+        }
+        return "";
+    }
+
+    public function getByTarga()
+    {
+
+        if ($this->vei_targa != '')
+        {
+
+            $targa = $this->vei_targa;
+
+            try
+            {
+
+                $wd = "dettaglioAutoveicoloBase";
+
+                $wd = "datiCartaCircolazioneAutoveicoloProprietario";
+
+                $url = env('MCTC_URL', 'https://e-servizicoll.dtt.ilportaledellautomobilista.it/Info-ws-sh/services');
+                $client = new \SoapClient($url . '/' . $wd . '/' . $wd . '.wsdl', array(
+                    'stream_context' => stream_context_create(array(
+                        'ssl' => array(
+                            'verify_peer' => false,
+                            'verify_peer_name' => false,
+                            'allow_self_signed' => true
+                        )
+                        )),
+                        'trace'=>1
+                ));
+
+                $utente = env('MCTC_USER', '');
+                $password = env('MCTC_PASSWORD', '');
+
+                $xml = '<wsse:Security
+                xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
+                SOAP-ENV:mustUnderstand="1">
+                <wsse:UsernameToken
+                    xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
+                    wsu:Id="XWSSGID-1253605895203984534550">
+                    <wsse:Username>' . $utente . '</wsse:Username>
+                    <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">' . $password . '</wsse:Password>
+                </wsse:UsernameToken>
+                </wsse:Security>';
+
+                $header = new \SoapHeader('http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd',
+                            'Security',
+                            new \SoapVar($xml, XSD_ANYXML),
+                            true
+                        );
+                $client->__setSoapHeaders($header);
+
+                $classe = "dettaglioAutoveicoloBase";
+
+                $classe = "dettaglioCartaCircolazioneProprietarioAutoveicolo";
+
+                try
+                {
+                    $this->loadTarga = "OK";
+                    // Run the function
+                    $obj = $client->__soapCall($classe, array(
+                        $classe . "Request" => array(
+                            "login" => array(
+
+                            ),
+                            //"dettaglioAutoveicoloBaseInput" => array(
+                                "targa" => array("numeroTarga" => $targa),
+                            //),
+                            "pdf" => false
+                        )
+                    ));
+
+                    \Log::debug(print_r($obj, true));
+
+                    $this->vei_data_ultima_revisione = @$obj->DatiUltimaRevisione->dataUltimaRevisione;
+
+                    $this->vei_carta_circolazione = @$obj->DatiAmministrativiVeicolo[0]->NumeroCartaCircolazione;
+
+                    $this->vei_carta_circolazione_rilasciata_il = @$obj->DatiAmministrativiVeicolo[0]->DataEmissioneDocumento;
+
+                    //$this->vei_data_ultima_revisione = @$obj->DatiUltimaRevisione->dataUltimaRevisione;
+
+                    $this->vei_cilindrata = @$obj->DatiTecniciVeicolo->CilindrataInCentimetriCubi;
+
+                    $this->vei_peso_complessivo = @$obj->DatiTecniciVeicolo->TaraInKG;
+
+                }
+                catch(\SoapFault $fault)
+                {
+                    $this->loadTarga = $fault->getMessage();
+                    // <xmp> tag displays xml output in html
+                    //echo 'Request : <br/><xmp>',
+                    //$client->__getLastRequest(),
+                    //'</xmp><br/><br/> Error Message : <br/>',
+                    //$fault->getMessage();
+                }
+            }
+            catch(Exception $ex)
+            {
+            }
+
+            $this->emit('hideLoading', 'btTarga');
+
+        }
+
+    }
+
+    public function getByPatente()
+    {
+
+        if ($this->anag_documento_numero != '')
+        {
+
+            // $this->emit('showLoading', 'btPatente');
+
+            $patente = $this->anag_documento_numero;
+
+            try{
+
+                $wd = "dettaglioPatenteBase";
+
+                $url = env('MCTC_URL', 'https://e-servizicoll.dtt.ilportaledellautomobilista.it/Info-ws-sh/services');
+                $client = new \SoapClient($url . '/' . $wd . '/' . $wd . '.wsdl', array(
+                    'stream_context' => stream_context_create(array(
+                        'ssl' => array(
+                            'verify_peer' => false,
+                            'verify_peer_name' => false,
+                            'allow_self_signed' => true
+                        )
+                        )),
+                        'trace'=>1
+                ));
+
+                $utente = env('MCTC_USER', '');
+                $password = env('MCTC_PASSWORD', '');
+
+                $xml = '<wsse:Security
+                xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
+                SOAP-ENV:mustUnderstand="1">
+                <wsse:UsernameToken
+                    xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
+                    wsu:Id="XWSSGID-1253605895203984534550">
+                    <wsse:Username>' . $utente . '</wsse:Username>
+                    <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">' . $password . '</wsse:Password>
+                </wsse:UsernameToken>
+                </wsse:Security>';
+
+                $header = new \SoapHeader('http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd',
+                            'Security',
+                            new \SoapVar($xml, XSD_ANYXML),
+                            true
+                        );
+                $client->__setSoapHeaders($header);
+
+                $classe = "dettaglioPatente";
+
+                // $classe = "dettaglioCartaCircolazioneProprietarioAutoveicolo";
+                try{
+                    $obj = $client->__soapCall($classe, array(
+                        $classe . "Request" => array(
+                            "login" => array(
+
+                            ),
+                            "ambitoPatenteBase" => array(
+                                "patente" => array("numeroPatente" => $patente),
+                            ),
+                            "pdf" => false,
+                            "pdfAnteprimaPatente" => false
+                        )
+                    ));
+
+                    \Log::debug(print_r($obj, true));
+
+                    $this->anag_firstname = @$obj->dettaglioPatenteBaseOutput->anagrafica->nome;
+
+                    $this->anag_lastname = @$obj->dettaglioPatenteBaseOutput->anagrafica->cognome;
+
+                    $this->anag_birth_date = @$obj->dettaglioPatenteBaseOutput->anagrafica->dataNascita;
+
+                    // $output["comuneNascita"] = @$obj->dettaglioPatenteBaseOutput->anagrafica->luogoNascita->luogoItaliano->descrizioneComune;
+
+                    // $output["codiceFiscale"] = @$obj->dettaglioPatenteBaseOutput->anagrafica->codiceFiscale;
+
+                    $this->anag_residenza_address = @$obj->dettaglioPatenteBaseOutput->datiResidenza->indirizzoResidenza;
+
+                    // $output["comuneResidenza"] = @$obj->dettaglioPatenteBaseOutput->datiResidenza->comuneResidenza;
+
+                    // $output["luogoNascita"] = @$obj->dettaglioPatenteBaseOutput->anagrafica->luogoNascita->luogoItaliano->descrizioneComune;
+
+                    // $output["provinciaResidenza"] = @$obj->dettaglioPatenteBaseOutput->datiResidenza->provinciaResidenza;
+
+                    $this->anag_documento_scadenza_il = @$obj->dettaglioPatenteBaseOutput->datiPatente->dataScadenza;
+
+                    $this->anag_documento_rilasciato_il = @$obj->dettaglioPatenteBaseOutput->datiPatente->dataEmissione;
+
+                }
+                catch(\SoapFault $fault)
+                {
+                    // <xmp> tag displays xml output in html
+                    echo 'Request : <br/><xmp>',
+                    $client->__getLastRequest(),
+                    '</xmp><br/><br/> Error Message : <br/>',
+                    $fault->getMessage();
+                }
+            }
+            catch(\SoapFault $ex)
+            {
+            }
+
+            $this->emit('hideLoading', 'btPatente');
+
+        }
+
+    }
+
+    public function print($id)
+    {
+
+        $record = \App\Models\Report::findOrFail($id);
+        $parti_coinvolte = \App\Models\ReportDataPartiCoinvolte::where('report_id', $id)->get();
+
+        $datiVeicolo = array();
+        $datiInfortunati = array();
+        $datiPasseggeri = array();
+        $datiPedoni = array();
+        $datiCascoOmologazione = array();
+        $datiCasco = array();
+        $datiCintureSicurezza = array();
+        foreach($parti_coinvolte as $pr)
+        {
+            $datiVeicolo[$pr->progressive] = \App\Models\ReportDataVeicoli::where('progressive', $pr->progressive)->where('report_id', $id)->first();
+            $datiPedoni[$pr->progressive] = \App\Models\ReportDataPedoni::where('progressive', $pr->progressive)->where('report_id', $id)->get();
+            $datiInfortunati[$pr->progressive] = \App\Models\ReportDataInfortunati::where('progressive', $this->currentProgressive)->where('report_id', $id)->get();
+            $datiPasseggeri[$pr->progressive] = \App\Models\ReportDataPasseggeri::where('progressive', $this->currentProgressive)->where('report_id', $id)->get();
+            $datiCascoOmologazione[$pr->progressive] = \App\Models\ReportDataUsoDelCascoOmologazione::where('progressive', $this->currentProgressive)->where('report_id', $id)->get();
+            $datiCasco[$pr->progressive] = \App\Models\ReportDataUsoDelCasco::where('progressive', $this->currentProgressive)->where('report_id', $id)->get();
+            $datiCintureSicurezza[$pr->progressive] = \App\Models\ReportDataCintureSicurezza::where('progressive', $this->currentProgressive)->where('report_id', $id)->get();
+        }
+
+        $testi_oculari = \App\Models\ReportDataTestimoniOculari::where('report_id', $id)->get();
+        $tipo_urto = \App\Models\ReportTipoUrto::where('report_id', $id)->get();
+        $tipo_segnalazione = \App\Models\ReportTipoSegnalazione::where('report_id', $id)->get();
+        $segnalazione_pervenuta_da = \App\Models\ReportSegnalazionePervenutaDa::where('report_id', $id)->get();
+        $ausilio_altri_enti = \App\Models\ReportAusilioAltriEnti::where('report_id', $id)->get();
+        $materiale_recuperato = \App\Models\ReportMaterialeRecuperato::where('report_id', $id)->get();
+        $condizioni_luce = \App\Models\ReportCondizioniLuce::where('report_id', $id)->get();
+        $tipo_strada = \App\Models\ReportTipoStrada::where('report_id', $id)->get();
+        $segnaletica_verticale_1 = \App\Models\ReportSegnaleticaVerticale1::where('report_id', $id)->get();
+        $segnaletica_verticale_2 = \App\Models\ReportSegnaleticaVerticale2::where('report_id', $id)->get();
+        $segnaletica_verticale_3 = \App\Models\ReportSegnaleticaVerticale3::where('report_id', $id)->get();
+        $segnaletica_verticale_4 = \App\Models\ReportSegnaleticaVerticale4::where('report_id', $id)->get();
+        $segnaletica_orizzontale_1 = \App\Models\ReportSegnaleticaOrizzontale1::where('report_id', $id)->get();
+        $segnaletica_orizzontale_2 = \App\Models\ReportSegnaleticaOrizzontale2::where('report_id', $id)->get();
+        $segnaletica_orizzontale_3 = \App\Models\ReportSegnaleticaOrizzontale3::where('report_id', $id)->get();
+        $segnaletica_orizzontale_4 = \App\Models\ReportSegnaleticaOrizzontale4::where('report_id', $id)->get();
+        $allegati = \App\Models\ReportAllegatiGallery::where('report_id', $id)->get();
+        $data = array('record' => $record, 'parti_coinvolte' => $parti_coinvolte, 'tipo_urto' => $tipo_urto,
+                        'tipo_segnalazione' => $tipo_segnalazione, 'segnalazione_pervenuta_da' => $segnalazione_pervenuta_da,
+                        'ausilio_altri_enti' => $ausilio_altri_enti,
+                        'materiale_recuperato' => $materiale_recuperato,
+                        'condizioni_luce' => $condizioni_luce, 'tipo_strada' => $tipo_strada,
+                        'segnaletica_orizzontale_1' => $segnaletica_orizzontale_1, 'segnaletica_orizzontale_2' => $segnaletica_orizzontale_2,
+                        'segnaletica_orizzontale_3' => $segnaletica_orizzontale_3, 'segnaletica_orizzontale_4' => $segnaletica_orizzontale_4,
+                        'segnaletica_verticale_1' => $segnaletica_verticale_1, 'segnaletica_verticale_2' => $segnaletica_verticale_2,
+                        'segnaletica_verticale_3' => $segnaletica_verticale_3, 'segnaletica_verticale_4' => $segnaletica_verticale_4,
+                        'datiPedoni' => $datiPedoni,
+                        'datiVeicolo' => $datiVeicolo, 'datiInfortunati' => $datiInfortunati, 'datiPasseggeri' => $datiPasseggeri,
+                        'datiCascoOmologazione' => $datiCascoOmologazione,
+                     'datiCasco' => $datiCasco, 'datiCintureSicurezza' => $datiCintureSicurezza, 'testi_oculari' => $testi_oculari,'allegati' => $allegati);
+
+        $pdf = Pdf::loadView('pdf.verbale', array('data' => $data));
+        $pdf->render();
+        $pageCount = $pdf->getDomPDF()->getCanvas()->get_page_count();
+        $data['total_pages'] = $pageCount;
+        $pdf = Pdf::loadView('pdf.verbale', array('data' => $data));
+        $pdfName = "verbale_" . $record->protocollo_num . '_' . $record->protocollo_anno . ".pdf";
+        $pdfContent = $pdf->output();
+        return $pdf->stream($pdfName, $pdfContent);
+
+    }
+
+    public function updated($property, $value){
+        if ($property === 'verificatosi_in_data' && !preg_match('/^\d{4}-\d{2}-\d{2}$/', $value)) {
+            $this->verificatosi_in_data = null;
+            $this->addError('verificatosi_in_data', 'Il campo Verificatosi in data deve essere aggiornato solo dal selettore.');
+        }
+    }
+
+}

+ 112 - 0
app/Http/Livewire/Rilievi.php

@@ -0,0 +1,112 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+use Livewire\WithPagination;
+
+class Rilievi extends Component
+{
+
+    use WithPagination;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $title = 'Rilievi';
+
+    public $search, $name, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public function resetFields(){
+        $this->name = '';
+    }
+
+    public function updatingSearch()
+    {
+        $this->resetPage();
+    }
+
+    public function render()
+    {
+        $rows = \App\Models\Rilievi::where('name', 'like', '%'.$this->search.'%')->orderBy('name')->paginate(10);
+        return view('livewire.rilievi', ['records' => $rows]);
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\Rilievi::create([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $record = \App\Models\Rilievi::findOrFail($id);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+                $this->name = $record->name;
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\Rilievi::whereId($this->dataId)->update([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('success','Errore');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\Rilievi::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+}

+ 112 - 0
app/Http/Livewire/SegnalazioneOrizzontale.php

@@ -0,0 +1,112 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+use Livewire\WithPagination;
+
+class SegnalazioneOrizzontale extends Component
+{
+
+    use WithPagination;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $title = 'Segnalazione orizzontale';
+
+    public $search, $name, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public function resetFields(){
+        $this->name = '';
+    }
+
+    public function updatingSearch()
+    {
+        $this->resetPage();
+    }
+
+    public function render()
+    {
+        $rows = \App\Models\SegnalazioneOrizzontale::where('name', 'like', '%'.$this->search.'%')->orderBy('name')->paginate(10);
+        return view('livewire.segnalazione-orizzontale', ['records' => $rows]);
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\SegnalazioneOrizzontale::create([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $record = \App\Models\SegnalazioneOrizzontale::findOrFail($id);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+                $this->name = $record->name;
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\SegnalazioneOrizzontale::whereId($this->dataId)->update([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('success','Errore');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\SegnalazioneOrizzontale::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+}

+ 116 - 0
app/Http/Livewire/SegnalazionePervenutaDa.php

@@ -0,0 +1,116 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+use Livewire\WithPagination;
+
+class SegnalazionePervenutaDa extends Component
+{
+
+    use WithPagination;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $title = 'Segnalazione pervenuta da';
+
+    public $search, $name, $para_agg, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public function resetFields(){
+        $this->name = '';
+        $this->para_agg = '';
+    }
+
+    public function updatingSearch()
+    {
+        $this->resetPage();
+    }
+
+    public function render()
+    {
+        $rows = \App\Models\SegnalazionePervenutaDa::where('name', 'like', '%'.$this->search.'%')->orderBy('name')->paginate(10);
+        return view('livewire.segnalazione-pervenuta-da', ['records' => $rows]);
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\SegnalazionePervenutaDa::create([
+                'name' => $this->name,
+                'para_agg' => $this->para_agg,
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $record = \App\Models\SegnalazionePervenutaDa::findOrFail($id);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+                $this->name = $record->name;
+                $this->para_agg = $record->PARA_AGG;
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\SegnalazionePervenutaDa::whereId($this->dataId)->update([
+                'name' => $this->name,
+                'para_agg' => $this->para_agg,
+            ]);
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('success','Errore');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\SegnalazionePervenutaDa::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+}

+ 112 - 0
app/Http/Livewire/SegnalazioneVerticale.php

@@ -0,0 +1,112 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+use Livewire\WithPagination;
+
+class SegnalazioneVerticale extends Component
+{
+
+    use WithPagination;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $title = 'Segnalazione verticale';
+
+    public $search, $name, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public function resetFields(){
+        $this->name = '';
+    }
+
+    public function updatingSearch()
+    {
+        $this->resetPage();
+    }
+
+    public function render()
+    {
+        $rows = \App\Models\SegnalazioneVerticale::where('name', 'like', '%'.$this->search.'%')->orderBy('name')->paginate(10);
+        return view('livewire.segnalazione-verticale', ['records' => $rows]);
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\SegnalazioneVerticale::create([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $record = \App\Models\SegnalazioneVerticale::findOrFail($id);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+                $this->name = $record->name;
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\SegnalazioneVerticale::whereId($this->dataId)->update([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('success','Errore');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\SegnalazioneVerticale::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+}

+ 120 - 0
app/Http/Livewire/Stradario.php

@@ -0,0 +1,120 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+use Livewire\WithPagination;
+
+class Stradario extends Component
+{
+
+    use WithPagination;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $title = 'Stradario';
+
+    public $search, $codicetoponimo, $toponimo, $descrizione, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'descrizione' => 'required'
+    ];
+
+    protected $messages = [
+        'descrizione.required' => 'Il nome è obbligatorio'
+    ];
+
+    public function resetFields(){
+        $this->descrizione = '';
+        $this->codicetoponimo = 0;
+        $this->toponimo = '';
+    }
+
+    public function updatingSearch()
+    {
+        $this->resetPage();
+    }
+
+    public function render()
+    {
+        $rows = \App\Models\Stradario::where('descrizione', 'like', '%'.$this->search.'%')->orderBy('descrizione')->paginate(10);
+        return view('livewire.stradario', ['records' => $rows]);
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\Stradario::create([
+                'descrizione' => $this->descrizione,
+                'codicetoponimo' => $this->codicetoponimo,
+                'toponimo' => $this->toponimo,
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $record = \App\Models\Stradario::findOrFail($id);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+                $this->descrizione = $record->DESCRIZIONE;
+                $this->codicetoponimo = $record->CODICETOPONIMO;
+                $this->toponimo = $record->TOPONIMO;
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\Stradario::whereId($this->dataId)->update([
+                'descrizione' => $this->descrizione,
+                'codicetoponimo' => $this->codicetoponimo,
+                'toponimo' => $this->toponimo,
+            ]);
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('success','Errore');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\Stradario::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+}

+ 112 - 0
app/Http/Livewire/TipoDanno.php

@@ -0,0 +1,112 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+use Livewire\WithPagination;
+
+class TipoDanno extends Component
+{
+
+    use WithPagination;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $title = 'Tipo di danno';
+
+    public $search, $name, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public function resetFields(){
+        $this->name = '';
+    }
+
+    public function updatingSearch()
+    {
+        $this->resetPage();
+    }
+
+    public function render()
+    {
+        $rows = \App\Models\TipoDanno::where('name', 'like', '%'.$this->search.'%')->orderBy('name')->paginate(10);
+        return view('livewire.tipo-danno', ['records' => $rows]);
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\TipoDanno::create([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $record = \App\Models\TipoDanno::findOrFail($id);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+                $this->name = $record->name;
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\TipoDanno::whereId($this->dataId)->update([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('success','Errore');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\TipoDanno::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+}

+ 112 - 0
app/Http/Livewire/TipoSegnalazione.php

@@ -0,0 +1,112 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+use Livewire\WithPagination;
+
+class TipoSegnalazione extends Component
+{
+
+    use WithPagination;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $title = 'Tipo di segnalazione';
+
+    public $search, $name, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public function resetFields(){
+        $this->name = '';
+    }
+
+    public function updatingSearch()
+    {
+        $this->resetPage();
+    }
+
+    public function render()
+    {
+        $rows = \App\Models\TipoSegnalazione::where('name', 'like', '%'.$this->search.'%')->orderBy('name')->paginate(10);
+        return view('livewire.tipo-segnalazione', ['records' => $rows]);
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\TipoSegnalazione::create([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $record = \App\Models\TipoSegnalazione::findOrFail($id);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+                $this->name = $record->name;
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\TipoSegnalazione::whereId($this->dataId)->update([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('success','Errore');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\TipoSegnalazione::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+}

+ 116 - 0
app/Http/Livewire/TipoStrada.php

@@ -0,0 +1,116 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+use Livewire\WithPagination;
+
+class TipoStrada extends Component
+{
+
+    use WithPagination;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $title = 'Tipo di strada';
+
+    public $search, $name, $para_agg, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public function resetFields(){
+        $this->name = '';
+        $this->para_agg = '';
+    }
+
+    public function updatingSearch()
+    {
+        $this->resetPage();
+    }
+
+    public function render()
+    {
+        $rows = \App\Models\TipoStrada::where('name', 'like', '%'.$this->search.'%')->orderBy('name')->paginate(10);
+        return view('livewire.tipo-strada', ['records' => $rows]);
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\TipoStrada::create([
+                'name' => $this->name,
+                'para_agg' => $this->para_agg,
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $record = \App\Models\TipoStrada::findOrFail($id);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+                $this->name = $record->name;
+                $this->para_agg = $record->para_agg;
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\TipoStrada::whereId($this->dataId)->update([
+                'name' => $this->name,
+                'para_agg' => $this->para_agg,
+            ]);
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('success','Errore');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\TipoStrada::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+}

+ 112 - 0
app/Http/Livewire/TipoUrto.php

@@ -0,0 +1,112 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+use Livewire\WithPagination;
+
+class TipoUrto extends Component
+{
+
+    use WithPagination;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $title = 'Tipo di urto';
+
+    public $search, $name, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public function resetFields(){
+        $this->name = '';
+    }
+
+    public function updatingSearch()
+    {
+        $this->resetPage();
+    }
+
+    public function render()
+    {
+        $rows = \App\Models\TipoUrto::where('name', 'like', '%'.$this->search.'%')->orderBy('name')->paginate(10);
+        return view('livewire.tipo-urto', ['records' => $rows]);
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\TipoUrto::create([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $record = \App\Models\TipoUrto::findOrFail($id);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+                $this->name = $record->name;
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\TipoUrto::whereId($this->dataId)->update([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('success','Errore');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\TipoUrto::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+}

+ 112 - 0
app/Http/Livewire/TipoVeicolo.php

@@ -0,0 +1,112 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+use Livewire\WithPagination;
+
+class TipoVeicolo extends Component
+{
+
+    use WithPagination;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $title = 'Tipo di veicolo';
+
+    public $search, $name, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public function resetFields(){
+        $this->name = '';
+    }
+
+    public function updatingSearch()
+    {
+        $this->resetPage();
+    }
+
+    public function render()
+    {
+        $rows = \App\Models\TipoVeicolo::where('name', 'like', '%'.$this->search.'%')->orderBy('name')->paginate(10);
+        return view('livewire.tipo-veicolo', ['records' => $rows]);
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\TipoVeicolo::create([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $record = \App\Models\TipoVeicolo::findOrFail($id);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+                $this->name = $record->name;
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\TipoVeicolo::whereId($this->dataId)->update([
+                'name' => $this->name
+            ]);
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('success','Errore');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\TipoVeicolo::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+}

+ 157 - 0
app/Http/Livewire/User.php

@@ -0,0 +1,157 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+use Livewire\WithPagination;
+
+use Hash;
+use Illuminate\Support\Facades\Hash as FacadesHash;
+
+class User extends Component
+{
+
+    use WithPagination;
+
+    protected $paginationTheme = 'bootstrap';
+
+    public $title = 'Utenti';
+
+    public $groups = [];
+
+    public $search, $firstname, $lastname, $username, $email, $group_id, $password, $old_password, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'firstname' => 'required',
+        'lastname' => 'required',
+        'username' => 'required',
+        'email' => 'required'
+    ];
+
+    protected $messages = [
+        'firstname.required' => 'Il nome è obbligatorio',
+        'lastname.required' => 'Il cognome è obbligatorio',
+        'username.required' => 'Lo username è obbligatorio',
+        'email.required' => 'Il nome è obbligatorio',
+    ];
+
+    public function resetFields(){
+        $this->firstname = '';
+        $this->lastname = '';
+        $this->username = '';
+        $this->email = '';
+        $this->password = '';
+        $this->old_password = '';
+        $this->group_id = null;
+    }
+
+    public function updatingSearch()
+    {
+        $this->resetPage();
+    }
+
+    public function render()
+    {
+        $this->groups = \App\Models\UserGroup::orderBy('name')->get();
+        $rows = \App\Models\User::where('firstname', 'like', '%'.$this->search.'%')->orWhere('lastname', 'like', '%'.$this->search.'%')->orderBy('firstname')->paginate(10);
+        return view('livewire.users', ['records' => $rows]);
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            $u = \App\Models\User::create([
+                'firstname' => $this->firstname,
+                'lastname' => $this->lastname,
+                'username' => $this->username,
+                'email' => $this->email,
+                'password' => FacadesHash::make($this->password),
+            ]);
+            \App\Models\UserUserGroup::create([
+                'group_id' => $this->group_id,
+                'user_id' => $u->id
+            ]);
+            session()->flash('success','Record creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore in fase di salvataggio' . $ex->getMessage());
+        }
+    }
+
+    public function edit($id){
+        try {
+            $record = \App\Models\User::findOrFail($id);
+            if( !$record) {
+                session()->flash('error','Record non trovato');
+            } else {
+                $this->firstname = $record->firstname;
+                $this->lastname = $record->lastname;
+                $this->username = $record->username;
+                $this->email = $record->email;
+                $this->old_password = $record->password;
+                $this->dataId = $record->id;
+                $this->update = true;
+                $this->add = false;
+                $this->group_id = \App\Models\UserUserGroup::where('user_id', $this->dataId)->first()->group_id;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            $updateData = [
+                'firstname' => $this->firstname,
+                'lastname' => $this->lastname,
+                'username' => $this->username,
+                'email' => $this->email,
+            ];
+
+            if ($this->password !== '') {
+                $updateData['password'] = FacadesHash::make($this->password);
+            }
+
+            \App\Models\User::whereId($this->dataId)->update($updateData);
+            \App\Models\UserUserGroup::where('user_id', $this->dataId)->delete();
+            \App\Models\UserUserGroup::create([
+                'group_id' => $this->group_id,
+                'user_id' => $this->dataId
+            ]);
+            session()->flash('success','Record aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore ' . $ex->getMessage());
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\User::find($id)->delete();
+            session()->flash('success',"Record eliminato");
+        }catch(\Exception $e){
+            session()->flash('error',"Errore");
+        }
+    }
+}

+ 17 - 0
app/Http/Middleware/Authenticate.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Illuminate\Auth\Middleware\Authenticate as Middleware;
+use Illuminate\Http\Request;
+
+class Authenticate extends Middleware
+{
+    /**
+     * Get the path the user should be redirected to when they are not authenticated.
+     */
+    protected function redirectTo(Request $request): ?string
+    {
+        return $request->expectsJson() ? null : route('login');
+    }
+}

+ 17 - 0
app/Http/Middleware/EncryptCookies.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
+
+class EncryptCookies extends Middleware
+{
+    /**
+     * The names of the cookies that should not be encrypted.
+     *
+     * @var array<int, string>
+     */
+    protected $except = [
+        //
+    ];
+}

+ 17 - 0
app/Http/Middleware/PreventRequestsDuringMaintenance.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
+
+class PreventRequestsDuringMaintenance extends Middleware
+{
+    /**
+     * The URIs that should be reachable while maintenance mode is enabled.
+     *
+     * @var array<int, string>
+     */
+    protected $except = [
+        //
+    ];
+}

+ 30 - 0
app/Http/Middleware/RedirectIfAuthenticated.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use App\Providers\RouteServiceProvider;
+use Closure;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Auth;
+use Symfony\Component\HttpFoundation\Response;
+
+class RedirectIfAuthenticated
+{
+    /**
+     * Handle an incoming request.
+     *
+     * @param  \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response)  $next
+     */
+    public function handle(Request $request, Closure $next, string ...$guards): Response
+    {
+        $guards = empty($guards) ? [null] : $guards;
+
+        foreach ($guards as $guard) {
+            if (Auth::guard($guard)->check()) {
+                return redirect(RouteServiceProvider::HOME);
+            }
+        }
+
+        return $next($request);
+    }
+}

+ 19 - 0
app/Http/Middleware/TrimStrings.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
+
+class TrimStrings extends Middleware
+{
+    /**
+     * The names of the attributes that should not be trimmed.
+     *
+     * @var array<int, string>
+     */
+    protected $except = [
+        'current_password',
+        'password',
+        'password_confirmation',
+    ];
+}

+ 20 - 0
app/Http/Middleware/TrustHosts.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Illuminate\Http\Middleware\TrustHosts as Middleware;
+
+class TrustHosts extends Middleware
+{
+    /**
+     * Get the host patterns that should be trusted.
+     *
+     * @return array<int, string|null>
+     */
+    public function hosts(): array
+    {
+        return [
+            $this->allSubdomainsOfApplicationUrl(),
+        ];
+    }
+}

+ 28 - 0
app/Http/Middleware/TrustProxies.php

@@ -0,0 +1,28 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Illuminate\Http\Middleware\TrustProxies as Middleware;
+use Illuminate\Http\Request;
+
+class TrustProxies extends Middleware
+{
+    /**
+     * The trusted proxies for this application.
+     *
+     * @var array<int, string>|string|null
+     */
+    protected $proxies;
+
+    /**
+     * The headers that should be used to detect proxies.
+     *
+     * @var int
+     */
+    protected $headers =
+        Request::HEADER_X_FORWARDED_FOR |
+        Request::HEADER_X_FORWARDED_HOST |
+        Request::HEADER_X_FORWARDED_PORT |
+        Request::HEADER_X_FORWARDED_PROTO |
+        Request::HEADER_X_FORWARDED_AWS_ELB;
+}

+ 22 - 0
app/Http/Middleware/ValidateSignature.php

@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Illuminate\Routing\Middleware\ValidateSignature as Middleware;
+
+class ValidateSignature extends Middleware
+{
+    /**
+     * The names of the query string parameters that should be ignored.
+     *
+     * @var array<int, string>
+     */
+    protected $except = [
+        // 'fbclid',
+        // 'utm_campaign',
+        // 'utm_content',
+        // 'utm_medium',
+        // 'utm_source',
+        // 'utm_term',
+    ];
+}

+ 17 - 0
app/Http/Middleware/VerifyCsrfToken.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
+
+class VerifyCsrfToken extends Middleware
+{
+    /**
+     * The URIs that should be excluded from CSRF verification.
+     *
+     * @var array<int, string>
+     */
+    protected $except = [
+        //
+    ];
+}

+ 19 - 0
app/Models/AccertatoreGrado.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class AccertatoreGrado extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_accertatori_grado';
+
+    protected $fillable = [
+        'name'
+    ];
+
+}

+ 20 - 0
app/Models/AllegatiGalleryType.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class AllegatiGalleryType extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_allegati_gallery_types';
+
+    protected $fillable = [
+        'name',
+        'file_type'
+    ];
+
+}

+ 107 - 0
app/Models/Anagrafica.php

@@ -0,0 +1,107 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class Anagrafica extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_anagraficas';
+
+    protected $fillable = [
+        'type',
+        'firstname',
+        'lastname',
+        'gender',
+        'birth_date',
+        'birth_town_id',
+        'birth_prov_id',
+        'residenza_town_id',
+        'residenza_prov_id',
+        'residenza_address',
+        'residenza_cap',
+        'mobile',
+        'sedicente',
+        'documento_tipo',
+        'documento_patente_cat',
+        'documento_tipo_altro',
+        'documento_numero',
+        'documento_rilasciato_da',
+        'documento_rilasciato_da_altro',
+        'foreign_country',
+        'documento_rilasciato_da_di_foreign_localita',
+        'documento_rilasciato_da_di_foreign_country',
+        'documento_rilasciato_da_prov_id',
+        'documento_rilasciato_da_town_id',
+        'documento_rilasciato_il',
+        'documento_scadenza_il',
+        'state',
+        'created' ,
+        'created_by',
+        'updated' ,
+        'updated_by',
+        'locked' ,
+        'locked_by',
+        'nazionalita',
+        'nazione_straniera',
+        'localita_straniera',
+        'rag_soc',
+        'vat',
+        'sede_legale_address',
+        'sede_legale_town_id',
+        'sede_legale_prov_id',
+        'sede_legale_cap',
+        'sede_legale_state',
+        'phone',
+        'anag_foreign_birth_country',
+        'anag_foreign_birth_city',
+        'anag_foreign_residence_country',
+        'anag_foreign_residence_city'
+    ];
+
+    public function birth_town_id_value()
+    {
+        return $this->belongsTo(\App\Models\LocationTown::class, 'birth_town_id');
+    }
+
+    public function residenza_town_id_value()
+    {
+        return $this->belongsTo(\App\Models\LocationTown::class, 'residenza_town_id');
+    }
+
+    public function documento_rilasciato_da_town_id_value()
+    {
+        return $this->belongsTo(\App\Models\LocationTown::class, 'documento_rilasciato_da_town_id');
+    }
+
+    public function documento_rilasciato_da_di_foreign_country_value()
+    {
+        return $this->belongsTo(\App\Models\LocationCountry::class, 'documento_rilasciato_da_di_foreign_country');
+    }
+
+    public function foreign_birth_country_value()
+    {
+        return $this->belongsTo(\App\Models\LocationCountry::class, 'anag_foreign_birth_country');
+    }
+
+    public function foreign_residence_country_value()
+    {
+        return $this->belongsTo(\App\Models\LocationCountry::class, 'anag_foreign_residence_country');
+    }
+
+    public function sede_legale_town_id_value()
+    {
+        return $this->belongsTo(\App\Models\LocationTown::class, 'sede_legale_town_id');
+    }
+
+    public function get($key)
+    {
+        return $this->getAttribute($key);
+    }
+
+
+}

+ 19 - 0
app/Models/AusilioAltriEnti.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class AusilioAltriEnti extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_ausilio_altri_enti';
+
+    protected $fillable = [
+        'name'
+    ];
+
+}

+ 19 - 0
app/Models/Compagnia.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class Compagnia extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_compagnie';
+
+    protected $fillable = [
+        'name'
+    ];
+
+}

+ 19 - 0
app/Models/CondizioneStrada.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class CondizioneStrada extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_condizione_strada';
+
+    protected $fillable = [
+        'name'
+    ];
+
+}

+ 20 - 0
app/Models/CondizioniAtmosferiche.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class CondizioniAtmosferiche extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_condizioni_atmosferiche';
+
+    protected $fillable = [
+        'name',
+        'para_agg'
+    ];
+
+}

+ 20 - 0
app/Models/CondizioniLuce.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class CondizioniLuce extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_condizioni_luce';
+
+    protected $fillable = [
+        'name',
+        'para_agg'
+    ];
+
+}

+ 19 - 0
app/Models/EffettoDanno.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class EffettoDanno extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_effetto_danno';
+
+    protected $fillable = [
+        'name'
+    ];
+
+}

+ 19 - 0
app/Models/EntitaDanno.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class EntitaDanno extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_entita_danno';
+
+    protected $fillable = [
+        'name'
+    ];
+
+}

+ 19 - 0
app/Models/FondoStradale.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class FondoStradale extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_fondo_stradale';
+
+    protected $fillable = [
+        'name'
+    ];
+
+}

+ 31 - 0
app/Models/LocationCountry.php

@@ -0,0 +1,31 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class LocationCountry extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_location_countries';
+
+    protected $fillable = [
+        'code',
+        'istat_code',
+        'name'
+    ];
+
+    public function birthLocations()
+    {
+        return $this->hasMany(Anagrafica::class, 'anag_foreign_birth_country');
+    }
+
+    public function residenceLocations()
+    {
+        return $this->hasMany(Anagrafica::class, 'anag_foreign_residence_country');
+    }
+
+}

+ 22 - 0
app/Models/LocationProvince.php

@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class LocationProvince extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_location_provs';
+
+    protected $fillable = [
+        'code',
+        'istat_code',
+        'title',
+        'regione_id'
+    ];
+
+}

+ 20 - 0
app/Models/LocationRegion.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class LocationRegion extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_location_regions';
+
+    protected $fillable = [
+        'istat_code',
+        'title'
+    ];
+
+}

+ 30 - 0
app/Models/LocationTown.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class LocationTown extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_location_towns';
+
+    protected $fillable = [
+        'istat_code',
+        'title',
+        'prov',
+        'region',
+        'prefix',
+        'zipcode',
+        'district_tax_code'
+    ];
+
+}
+
+
+
+
+

+ 20 - 0
app/Models/MarcaModelloVeicolo.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class MarcaModelloVeicolo extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_marche_veicolo_modelli_veicolo';
+
+    protected $fillable = [
+        'marca_id',
+        'modello_id'
+    ];
+
+}

+ 19 - 0
app/Models/MarcaVeicolo.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class MarcaVeicolo extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_marca_veicolo';
+
+    protected $fillable = [
+        'name'
+    ];
+
+}

+ 19 - 0
app/Models/MaterialeRecuperato.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class MaterialeRecuperato extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_materiale_recuperato';
+
+    protected $fillable = [
+        'name'
+    ];
+
+}

+ 43 - 0
app/Models/ModelloVeicolo.php

@@ -0,0 +1,43 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class ModelloVeicolo extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_modello_veicolo';
+
+    protected $fillable = [
+        'name'
+    ];
+
+    public function marca()
+    {
+        $rel = \App\Models\MarcaModelloVeicolo::where('modello_id', $this->id)->first();
+        if ($rel)
+        {
+            if ($rel->marca_id > 0)
+            {
+                try
+                {
+                    return \App\Models\MarcaVeicolo::where('id', $rel->marca_id)->first() ? \App\Models\MarcaVeicolo::where('id', $rel->marca_id)->first()->name : "";
+                }
+                catch (Exception $ex)
+                {
+                    return "";
+                }
+            }
+            else
+                return "";
+        }
+        else
+            return "";
+    }
+
+
+}

+ 19 - 0
app/Models/NomenclaturaStrada.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class NomenclaturaStrada extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_nomenclatura_strada';
+
+    protected $fillable = [
+        'name'
+    ];
+
+}

+ 19 - 0
app/Models/ParteMacchina.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class ParteMacchina extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_parte_macchina';
+
+    protected $fillable = [
+        'name'
+    ];
+
+}

+ 20 - 0
app/Models/ParticolaritaStrada.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class ParticolaritaStrada extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_particolarita_strada';
+
+    protected $fillable = [
+        'name',
+        'para_agg'
+    ];
+
+}

+ 20 - 0
app/Models/PavimentazioneStrada.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class PavimentazioneStrada extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_pavimentazione_strada';
+
+    protected $fillable = [
+        'name',
+        'para_agg'
+    ];
+
+}

+ 41 - 0
app/Models/Polizza.php

@@ -0,0 +1,41 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class Polizza extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_polizzas';
+
+    protected $fillable = [
+        'compagnia_id',
+        'agenzia',
+        'polizza_num',
+        'valida_dal',
+        'valida_al' ,
+        'anagrafica_id',
+        'state',
+        'created',
+        'created_by',
+        'updated',
+        'updated_by',
+        'locked' ,
+        'locked_by',
+    ];
+
+    public function compagnia()
+    {
+        return $this->belongsTo(\App\Models\Compagnia::class, 'compagnia_id', 'id');
+    }
+
+    public function anagrafica()
+    {
+        return $this->belongsTo(\App\Models\Anagrafica::class, 'anagrafica_id', 'id');
+    }
+
+}

+ 300 - 0
app/Models/Report.php

@@ -0,0 +1,300 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class Report extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_reports';
+
+    protected $fillable = [
+        'name',
+        'validated' ,
+        'necessita_nulla_osta' ,
+        'data_nulla_osta' ,
+        'protocollo_num' ,
+        'protocollo_ord' ,
+        'protocollo_anno' ,
+        'verificatosi_in_data' ,
+        'verificatosi_in_data_ora' ,
+        'verificatosi_in_data_minuti' ,
+        'utg' ,
+        'utg_data' ,
+        'utg_protocollo',
+        'ag' ,
+        'ag_data' ,
+        'ag_protocollo',
+        'incidente_con_danni_a_cose' ,
+        'incidente_con_feriti' ,
+        'incidente_con_feriti_lesioni_lievi' ,
+        'incidente_con_feriti_lesioni_gravi' ,
+        'incidente_mortale' ,
+        'localita_uno' ,
+        'localita_due' ,
+        'intersezione_con' ,
+        'prossimita_civico',
+        'prossimita_palo_luce',
+        'prossimita_chilometro',
+        'note_aggiuntive' ,
+        'accertatore_1' ,
+        'grado_accertatore_1' ,
+        'accertatore_2' ,
+        'grado_accertatore_2' ,
+        'accertatore_3' ,
+        'grado_accertatore_3' ,
+        'accertatore_4' ,
+        'grado_accertatore_4' ,
+        'accertatore_5' ,
+        'grado_accertatore_5' ,
+        'rilievi_id' ,
+        'parti_coinvolte_1_nome' ,
+        'parti_coinvolte_2_nome' ,
+        'parti_coinvolte_3_nome' ,
+        'parti_coinvolte_1_veicolo' ,
+        'parti_coinvolte_2_veicolo' ,
+        'parti_coinvolte_3_veicolo' ,
+        'tipo_urto_altro' ,
+        'segnalazione_data' ,
+        'segnalazione_ora',
+        'segnalazione_minuti',
+        'segnalazione_altro',
+        'ausilio_altri_enti_motivo',
+        'ausilio_altri_enti_ora_intervento',
+        'ausilio_altri_enti_minuti_intervento',
+        'ditta_intervenuta' ,
+        'ripristino_ora_chiamata' ,
+        'ripristino_minuti_chiamata' ,
+        'ripristino_ora_arrivo' ,
+        'ripristino_minuti_arrivo' ,
+        'danni_cose_diverse_da_veicoli',
+        'sinistro_ora' ,
+        'sinistro_minuti' ,
+        'localizzazione_incidente' ,
+        'localizzazione_incidente_altro',
+        'condizioni_atmosferiche' ,
+        'condizioni_atmosferiche_altro' ,
+        'nomenclatura_strada' ,
+        'nomenclatura_strada_numero' ,
+        'nomenclatura_strada_altro' ,
+        'pavimentazione' ,
+        'pavimentazione_altro' ,
+        'condizione_strada' ,
+        'condizione_strada_altro' ,
+        'fondo_stradale' ,
+        'fondo_stradale_specifica' ,
+        'visibilita' ,
+        'visibilita_specifica' ,
+        'particolarita_strada' ,
+        'particolarita_strada_specifica' ,
+        'tipo_strada' ,
+        'tipo_strada_altro' ,
+        'traffico' ,
+        'segnaletica' ,
+        'segnaletica_verticale_1_via' ,
+        'segnaletica_verticale_1_altro' ,
+        'segnaletica_verticale_1_limite_velocita' ,
+        'segnaletica_verticale_1_limite_direzione' ,
+        'segnaletica_verticale_1_pannello_integrativo' ,
+        'segnaletica_verticale_2_via' ,
+        'segnaletica_verticale_2_altro' ,
+        'segnaletica_verticale_2_limite_velocita' ,
+        'segnaletica_verticale_2_limite_direzione' ,
+        'segnaletica_verticale_2_pannello_integrativo' ,
+        'segnaletica_verticale_3_via' ,
+        'segnaletica_verticale_3_altro' ,
+        'segnaletica_verticale_3_limite_velocita' ,
+        'segnaletica_verticale_3_limite_direzione' ,
+        'segnaletica_verticale_3_pannello_integrativo' ,
+        'segnaletica_verticale_4_via' ,
+        'segnaletica_verticale_4_altro' ,
+        'segnaletica_verticale_4_limite_velocita' ,
+        'segnaletica_verticale_4_limite_direzione' ,
+        'segnaletica_verticale_4_pannello_integrativo' ,
+        'segnaletica_orizzontale_1_via' ,
+        'segnaletica_orizzontale_1_linea_margine' ,
+        'segnaletica_orizzontale_1_linea_margine_specifica' ,
+        'segnaletica_orizzontale_1_linea_mezzeria' ,
+        'segnaletica_orizzontale_1_linea_mezzeria_specifica' ,
+        'segnaletica_orizzontale_1_altro' ,
+        'segnaletica_orizzontale_1_direzione' ,
+        'segnaletica_orizzontale_2_via' ,
+        'segnaletica_orizzontale_2_linea_margine' ,
+        'segnaletica_orizzontale_2_linea_margine_specifica' ,
+        'segnaletica_orizzontale_2_linea_mezzeria' ,
+        'segnaletica_orizzontale_2_linea_mezzeria_specifica' ,
+        'segnaletica_orizzontale_2_altro' ,
+        'segnaletica_orizzontale_2_direzione' ,
+        'segnaletica_orizzontale_3_via' ,
+        'segnaletica_orizzontale_3_linea_margine' ,
+        'segnaletica_orizzontale_3_linea_margine_specifica' ,
+        'segnaletica_orizzontale_3_linea_mezzeria' ,
+        'segnaletica_orizzontale_3_linea_mezzeria_specifica' ,
+        'segnaletica_orizzontale_3_altro' ,
+        'segnaletica_orizzontale_3_direzione' ,
+        'segnaletica_orizzontale_4_via' ,
+        'segnaletica_orizzontale_4_linea_margine' ,
+        'segnaletica_orizzontale_4_linea_margine_specifica' ,
+        'segnaletica_orizzontale_4_linea_mezzeria' ,
+        'segnaletica_orizzontale_4_linea_mezzeria_specifica' ,
+        'segnaletica_orizzontale_4_altro' ,
+        'segnaletica_orizzontale_4_direzione' ,
+        'state' ,
+        'created',
+        'created_by' ,
+        'updated',
+        'updated_by' ,
+        'locked' ,
+        'locked_by' ,
+    ];
+
+    public function localita()
+    {
+        return $this->belongsTo(\App\Models\LocationTown::class, 'localita_uno');
+    }
+
+    public function indirizzo()
+    {
+        return $this->belongsTo(\App\Models\Stradario::class, 'localita_due');
+    }
+
+    public function rilievo()
+    {
+        return $this->belongsTo(\App\Models\Rilievi::class, 'rilievi_id');
+    }
+
+    public function nomenclatura()
+    {
+        return $this->belongsTo(\App\Models\NomenclaturaStrada::class, 'nomenclatura_strada');
+    }
+
+    public function condizioneatmosferiche()
+    {
+        return $this->belongsTo(\App\Models\CondizioniAtmosferiche::class, 'condizioni_atmosferiche');
+    }
+
+    public function pavimentazione_value()
+    {
+        return $this->belongsTo(\App\Models\PavimentazioneStrada::class, 'pavimentazione');
+    }
+
+    public function condizione_strada_value()
+    {
+        return $this->belongsTo(\App\Models\CondizioneStrada::class, 'condizione_strada');
+    }
+
+    public function fondo_stradale_value()
+    {
+        return $this->belongsTo(\App\Models\FondoStradale::class, 'fondo_stradale');
+    }
+
+    public function particolarita_strada_value()
+    {
+        return $this->belongsTo(\App\Models\ParticolaritaStrada::class, 'particolarita_strada');
+    }
+
+    public function segnaletica_verticale_1_via_value()
+    {
+        return $this->belongsTo(\App\Models\Stradario::class, 'segnaletica_verticale_1_via');
+    }
+
+    public function segnaletica_verticale_2_via_value()
+    {
+        return $this->belongsTo(\App\Models\Stradario::class, 'segnaletica_verticale_2_via');
+    }
+
+    public function segnaletica_verticale_3_via_value()
+    {
+        return $this->belongsTo(\App\Models\Stradario::class, 'segnaletica_verticale_3_via');
+    }
+
+    public function segnaletica_verticale_4_via_value()
+    {
+        return $this->belongsTo(\App\Models\Stradario::class, 'segnaletica_verticale_4_via');
+    }
+
+    public function segnaletica_orizzontale_1_via_value()
+    {
+        return $this->belongsTo(\App\Models\Stradario::class, 'segnaletica_orizzontale_1_via');
+    }
+
+    public function segnaletica_orizzontale_2_via_value()
+    {
+        return $this->belongsTo(\App\Models\Stradario::class, 'segnaletica_orizzontale_2_via');
+    }
+
+    public function segnaletica_orizzontale_3_via_value()
+    {
+        return $this->belongsTo(\App\Models\Stradario::class, 'segnaletica_orizzontale_3_via');
+    }
+
+    public function segnaletica_orizzontale_4_via_value()
+    {
+        return $this->belongsTo(\App\Models\Stradario::class, 'segnaletica_orizzontale_4_via');
+    }
+
+    public function accertatore_1_value()
+    {
+        return $this->belongsTo(\App\Models\User::class, 'accertatore_1');
+    }
+
+    public function grado_accertatore_1_value()
+    {
+        return $this->belongsTo(\App\Models\AccertatoreGrado::class, 'grado_accertatore_1');
+    }
+
+    public function accertatore_2_value()
+    {
+        return $this->belongsTo(\App\Models\User::class, 'accertatore_2');
+    }
+
+    public function grado_accertatore_2_value()
+    {
+        return $this->belongsTo(\App\Models\AccertatoreGrado::class, 'grado_accertatore_2');
+    }
+
+    public function accertatore_3_value()
+    {
+        return $this->belongsTo(\App\Models\User::class, 'accertatore_3');
+    }
+
+    public function grado_accertatore_3_value()
+    {
+        return $this->belongsTo(\App\Models\AccertatoreGrado::class, 'grado_accertatore_3');
+    }
+
+    public function accertatore_4_value()
+    {
+        return $this->belongsTo(\App\Models\User::class, 'accertatore_4');
+    }
+
+    public function grado_accertatore_4_value()
+    {
+        return $this->belongsTo(\App\Models\AccertatoreGrado::class, 'grado_accertatore_4');
+    }
+
+    public function accertatore_5_value()
+    {
+        return $this->belongsTo(\App\Models\User::class, 'accertatore_5');
+    }
+
+    public function grado_accertatore_5_value()
+    {
+        return $this->belongsTo(\App\Models\AccertatoreGrado::class, 'grado_accertatore_5');
+    }
+
+    public function reportDataPedoni()
+    {
+        return $this->belongsTo(\App\Models\ReportDataPedoni::class, 'report_id');
+    }
+
+    public function allegati()
+    {
+        return $this->hasMany(ReportAllegatiGallery::class);
+    }
+
+}

+ 33 - 0
app/Models/ReportAllegatiGallery.php

@@ -0,0 +1,33 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class ReportAllegatiGallery extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_allegati_galleries';
+
+    protected $fillable = [
+        'report_id' ,
+        'file_type' ,
+        'gallery_type',
+        'name' ,
+        'files',
+        'token' ,
+        'is_visible',
+        'state' ,
+        'created',
+        'created_by',
+    ];
+
+    public function report()
+    {
+        return $this->belongsTo(Report::class);
+    }
+
+}

+ 25 - 0
app/Models/ReportAusilioAltriEnti.php

@@ -0,0 +1,25 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class ReportAusilioAltriEnti extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_reports_ausilio_altri_enti';
+
+    protected $fillable = [
+        'report_id',
+        'ausilio_altri_enti_id'
+    ];
+
+    public function ausilio_altri_enti()
+    {
+        return $this->belongsTo(\App\Models\AusilioAltriEnti::class, 'ausilio_altri_enti_id');
+    }
+
+}

+ 25 - 0
app/Models/ReportCondizioniLuce.php

@@ -0,0 +1,25 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class ReportCondizioniLuce extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_reports_condizioni_luce';
+
+    protected $fillable = [
+        'report_id',
+        'condizioni_luce_id'
+    ];
+
+    public function condizioni_luce()
+    {
+        return $this->belongsTo(\App\Models\CondizioniLuce::class, 'condizioni_luce_id');
+    }
+
+}

+ 26 - 0
app/Models/ReportDataCintureSicurezza.php

@@ -0,0 +1,26 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class ReportDataCintureSicurezza extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+//protected $primaryKey = 'progressive';
+    protected $table = 'fcf_reports_report_data_cinture_sicurezza';
+
+    protected $fillable = [
+        'report_id',
+        'progressive',
+        'conducente',
+        'passeggeri_0',
+        'passeggeri_1',
+        'passeggeri_2',
+        'passeggeri_3'
+    ];
+
+}

+ 27 - 0
app/Models/ReportDataInfortunati.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class ReportDataInfortunati extends Model
+{
+    use HasFactory;
+
+    public $timestamps = false;
+    //protected $primaryKey = 'progressive';
+    protected $table = 'fcf_reports_report_data_infortunati';
+
+    protected $fillable = [
+        'report_id',
+        'progressive',
+        'infortunato'
+    ];
+
+    public function infortunato_value()
+    {
+        return $this->belongsTo(\App\Models\Anagrafica::class, 'infortunato');
+    }
+
+}

+ 39 - 0
app/Models/ReportDataPartiCoinvolte.php

@@ -0,0 +1,39 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class ReportDataPartiCoinvolte extends Model
+{
+    use HasFactory;
+
+    public $timestamps = false;
+
+    //protected $primaryKey = ['report_id', 'progressive'];
+
+    //public $incrementing = false;
+
+    protected $table = 'fcf_reports_report_data_parti_coinvolte';
+
+    protected $fillable = [
+        'report_id',
+        'progressive',
+        'conducente_o_pedone',
+        'progressive_type' ,
+        'anagrafica' ,
+        'veicolo'
+    ];
+
+    public function veicolo_data()
+    {
+        return $this->belongsTo(\App\Models\Vehicle::class, 'veicolo');
+    }
+
+    public function anagrafica_data()
+    {
+        return $this->belongsTo(\App\Models\Anagrafica::class, 'anagrafica');
+    }
+
+}

+ 30 - 0
app/Models/ReportDataPasseggeri.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class ReportDataPasseggeri extends Model
+{
+    use HasFactory;
+
+    //protected $primaryKey = 'progressive';
+    public $timestamps = false;
+    protected $table = 'fcf_reports_report_data_passeggeri';
+
+    protected $fillable = [
+        'report_id',
+        'progressive',
+        'passeggero',
+        'infortunato',
+        'infortunato_ospedale'
+
+    ];
+
+    public function passeggero_value()
+    {
+        return $this->belongsTo(\App\Models\Anagrafica::class, 'passeggero');
+    }
+
+}

+ 54 - 0
app/Models/ReportDataPedoni.php

@@ -0,0 +1,54 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class ReportDataPedoni extends Model
+{
+    use HasFactory;
+
+    //protected $primaryKey = 'progressive';
+    public $timestamps = false;
+    protected $table = 'fcf_reports_report_data_pedoni';
+
+    protected $fillable = [
+        'report_id',
+        'progressive',
+        'pedoni' ,
+        'generalizzato' ,
+        'generalizzato_altrove',
+        'infortunato' ,
+        'infortunato_ospedale',
+        'pedone_posizione' ,
+        'pedone_posizione_desc' ,
+        'pedone_referto',
+        'pedone_prognosi',
+        'pedone_pioggia' ,
+        'pedone_ombrello' ,
+        'pedone_notte' ,
+        'pedone_abiti_scuri' ,
+        'verbale_violazione_numero',
+        'articolo_violato',
+        'cds'
+
+    ];
+
+    public function pedone()
+    {
+        return $this->belongsTo(\App\Models\Anagrafica::class, 'passeggero');
+    }
+
+    public function dataPedoni()
+    {
+        return $this->belongsTo(Report::class, 'report_id', 'id');
+    }
+
+    public function getDataPedoni($progressive, $attribute)
+    {
+        $pedone = $this->dataPedoni()->where('progressive', $progressive)->first();
+        return $pedone ? $pedone->$attribute : null;
+    }
+
+}

+ 29 - 0
app/Models/ReportDataTestimoniOculari.php

@@ -0,0 +1,29 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class ReportDataTestimoniOculari extends Model
+{
+    use HasFactory;
+
+    //protected $primaryKey = 'progressive';
+    public $timestamps = false;
+    protected $table = 'fcf_reports_report_data_testi_oculari';
+
+    protected $fillable = [
+        'report_id',
+        'progressive',
+        'testi_oculari' ,
+        'stato_testi_oculari'
+
+    ];
+
+    public function teste()
+    {
+        return $this->belongsTo(\App\Models\Anagrafica::class, 'testi_oculari');
+    }
+
+}

+ 24 - 0
app/Models/ReportDataUsoDelCasco.php

@@ -0,0 +1,24 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class ReportDataUsoDelCasco extends Model
+{
+    use HasFactory;
+
+    //protected $primaryKey = 'progressive';
+public $timestamps = false;
+    protected $table = 'fcf_reports_report_data_uso_del_casco';
+
+    protected $fillable = [
+        'report_id',
+        'progressive',
+        'conducente' ,
+        'passeggeri'
+
+    ];
+
+}

+ 24 - 0
app/Models/ReportDataUsoDelCascoOmologazione.php

@@ -0,0 +1,24 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class ReportDataUsoDelCascoOmologazione extends Model
+{
+    use HasFactory;
+
+    //protected $primaryKey = 'progressive';
+public $timestamps = false;
+    protected $table = 'fcf_reports_report_data_uso_del_casco_omologazione';
+
+    protected $fillable = [
+        'report_id',
+        'progressive',
+        'conducente' ,
+        'passeggeri'
+
+    ];
+
+}

+ 128 - 0
app/Models/ReportDataVeicoli.php

@@ -0,0 +1,128 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class ReportDataVeicoli extends Model
+{
+    use HasFactory;
+
+    public $timestamps = false;
+
+    //protected $primaryKey = 'progressive';
+    protected $table = 'fcf_reports_report_data_veicoli';
+
+    protected $fillable = [
+        'report_id',
+        'progressive' ,
+        'veicoli',
+        'chilometri_percorsi' ,
+        'stato_veicolo',
+        'polizze',
+        'proprietari',
+        'coproprietari',
+        'conducente_uguale_proprietario',
+        'conducenti',
+        'infortunato',
+        'infortunato_ospedale',
+        'patente_al_seguito',
+        'generalizzato',
+        'generalizzato_altrove',
+        'posizione_statica_finale',
+        'danni_visibili_riportati' ,
+        'danni_visibili_pre_esistenti' ,
+        'destinazione_veicolo',
+        'destinazione_veicolo_affidato_a',
+        'destinazione_veicolo_sequestro_num_art',
+        'destinazione_veicolo_amministrativo_num',
+        'destinazione_veicolo_amministrativo_num_art_violato',
+        'destinazione_veicolo_amministrativo_cds',
+        'circostanze_presunte_incidente',
+        'stato_pneumatici',
+        'marca_pneumatici' ,
+        'misura_pneumatici' ,
+        'dispositivi_ottici',
+        'tergicristalli',
+        'segnale_pericolo',
+        'abs',
+        'gps',
+        'marcia_inserita',
+        'cristallo',
+        'cristallo_posizione',
+        'specchio_retrovisore',
+        'specchio_lat_dx',
+        'specchio_lat_sx',
+        'attivazione_airbag',
+        'airbag_posizione',
+        'alcool_test',
+        'alcool_test_esito',
+        'drug_test',
+        'drug_test_esito',
+        'sistema_ritenuta_minori',
+        'sistema_ritenuta_minori_omologazione',
+        'verbale_violazione_numero_1',
+        'articolo_violato_1',
+        'cds_1',
+        'verbale_violazione_numero_2' ,
+        'articolo_violato_2' ,
+        'cds_2' ,
+        'verbale_violazione_numero_3' ,
+        'articolo_violato_3' ,
+        'cds_3' ,
+        'conducente_patente_numero' ,
+        'conducente_patente_categoria' ,
+        'conducente_patente_rilasciata_da',
+        'conducente_patente_rilasciata_da_altro' ,
+        'conducente_patente_rilasciata_il',
+        'conducente_patente_scadenza',
+        'conducente_patente_prescrizioni',
+        'conducente_patente_limitazioni_art_117_1' ,
+        'conducente_patente_limitazioni_art_117_2' ,
+        'conducente_patente_abilitazione',
+        'conducente_patente_abilitazione_numero' ,
+        'conducente_patente_abilitazione_rilasciata_da',
+        'conducente_patente_abilitazione_rilasciata_il',
+        'conducente_documento',
+        'conducente_documento_numero' ,
+        'conducente_sedicente',
+        'tipo_danno',
+        'entita_danno',
+        'effetto_danno',
+        'parte_macchina',
+        'tipo_danno_2',
+        'entita_danno_2',
+        'effetto_danno_2',
+        'parte_macchina_2',
+        'tipo_danno_3',
+        'entita_danno_3',
+        'effetto_danno_3',
+        'parte_macchina_3',
+        'tipo_danno_4',
+        'entita_danno_4',
+        'effetto_danno_4',
+        'parte_macchina_4'
+    ];
+
+    public function proprietario()
+    {
+        return $this->belongsTo(\App\Models\Anagrafica::class, 'proprietari');
+    }
+
+    public function coproprietario()
+    {
+        return $this->belongsTo(\App\Models\Anagrafica::class, 'coproprietari');
+    }
+
+    public function conducente()
+    {
+        return $this->belongsTo(\App\Models\Anagrafica::class, 'conducenti');
+    }
+
+    public function polizza()
+    {
+        return $this->belongsTo(\App\Models\Polizza::class, 'polizze');
+    }
+
+}

+ 25 - 0
app/Models/ReportMaterialeRecuperato.php

@@ -0,0 +1,25 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class ReportMaterialeRecuperato extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_reports_materiale_recuperato';
+
+    protected $fillable = [
+        'report_id',
+        'materiale_recuperato_id'
+    ];
+
+    public function materiale_recuperato()
+    {
+        return $this->belongsTo(\App\Models\MaterialeRecuperato::class, 'materiale_recuperato_id');
+    }
+
+}

+ 22 - 0
app/Models/ReportProtocolloNote.php

@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class ReportProtocolloNote extends Model
+{
+    use HasFactory;
+
+    public $timestamps = false;
+    protected $table = 'fcf_reports_reports_protocollo_notes';
+
+    protected $fillable = [
+        'report_id',
+        'text' ,
+        'created',
+        'created_by',
+    ];
+
+}

+ 26 - 0
app/Models/ReportRichiesta.php

@@ -0,0 +1,26 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class ReportRichiesta extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_richieste';
+
+    protected $fillable = [
+        'report_id',
+        'anagrafica_id',
+        'data_richiesta',
+        'consegna_richiesta',
+        'description',
+        'state' ,
+        'created',
+        'created_by'
+    ];
+
+}

+ 25 - 0
app/Models/ReportSegnalazionePervenutaDa.php

@@ -0,0 +1,25 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class ReportSegnalazionePervenutaDa extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_reports_segnalazione_pervenuta_da';
+
+    protected $fillable = [
+        'report_id',
+        'segnalazione_pervenuta_da_id'
+    ];
+
+    public function segnalazione_pervenuta_da()
+    {
+        return $this->belongsTo(\App\Models\SegnalazionePervenutaDa::class, 'segnalazione_pervenuta_da_id');
+    }
+
+}

+ 25 - 0
app/Models/ReportSegnaleticaOrizzontale1.php

@@ -0,0 +1,25 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class ReportSegnaleticaOrizzontale1 extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_reports_segnaletica_orizzontale_1';
+
+    protected $fillable = [
+        'report_id',
+        'segnaletica_orizzontale_id'
+    ];
+
+    public function segnaletica_orizzontale()
+    {
+        return $this->belongsTo(\App\Models\SegnalazioneOrizzontale::class, 'segnaletica_orizzontale_id');
+    }
+
+}

+ 25 - 0
app/Models/ReportSegnaleticaOrizzontale2.php

@@ -0,0 +1,25 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class ReportSegnaleticaOrizzontale2 extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_reports_segnaletica_orizzontale_2';
+
+    protected $fillable = [
+        'report_id',
+        'segnaletica_orizzontale_id'
+    ];
+
+    public function segnaletica_orizzontale()
+    {
+        return $this->belongsTo(\App\Models\SegnalazioneOrizzontale::class, 'segnaletica_orizzontale_id');
+    }
+
+}

+ 25 - 0
app/Models/ReportSegnaleticaOrizzontale3.php

@@ -0,0 +1,25 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class ReportSegnaleticaOrizzontale3 extends Model
+{
+    use HasFactory;
+
+public $timestamps = false;
+    protected $table = 'fcf_reports_reports_segnaletica_orizzontale_3';
+
+    protected $fillable = [
+        'report_id',
+        'segnaletica_orizzontale_id'
+    ];
+
+    public function segnaletica_orizzontale()
+    {
+        return $this->belongsTo(\App\Models\SegnalazioneOrizzontale::class, 'segnaletica_orizzontale_id');
+    }
+
+}

Vissa filer visades inte eftersom för många filer har ändrats