|
|
@@ -1,33 +1,30 @@
|
|
|
<?php
|
|
|
-
|
|
|
namespace App\Http\Livewire;
|
|
|
-
|
|
|
use App\Http\Livewire\Traits\HasAccertatore;
|
|
|
+use App\Http\Livewire\Traits\HasNote;
|
|
|
use App\Http\Livewire\Traits\HasParteCoinvolta;
|
|
|
use App\Http\Livewire\Traits\HasPolizza;
|
|
|
+use App\Http\Livewire\Traits\HasAllegato;
|
|
|
+use App\Http\Livewire\Traits\HasRichieste;
|
|
|
use Livewire\Component;
|
|
|
-
|
|
|
use Livewire\WithPagination;
|
|
|
-
|
|
|
use Livewire\WithFileUploads;
|
|
|
-
|
|
|
use Barryvdh\DomPDF\Facade\Pdf;
|
|
|
use App\Models\ReportDataPartiCoinvolte;
|
|
|
use App\Models\ReportDataVeicoli;
|
|
|
use App\Models\Vehicle;
|
|
|
-
|
|
|
use \Illuminate\Support\Facades\DB;
|
|
|
use \Illuminate\Support\Facades\Log;
|
|
|
-
|
|
|
-
|
|
|
-class Report extends Component
|
|
|
-{
|
|
|
+class Report extends Component{
|
|
|
|
|
|
use WithPagination;
|
|
|
use WithFileUploads;
|
|
|
use HasParteCoinvolta;
|
|
|
use HasPolizza;
|
|
|
use HasAccertatore;
|
|
|
+ use HasAllegato;
|
|
|
+ use HasRichieste;
|
|
|
+ use HasNote;
|
|
|
protected $paginationTheme = 'bootstrap';
|
|
|
public $title = 'Verbali';
|
|
|
public $loadPatente;
|
|
|
@@ -415,25 +412,6 @@ class Report extends Component
|
|
|
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;
|
|
|
public $segnalazione_pervenuta_da;
|
|
|
public $segnaletica_verticale_1;
|
|
|
public $segnaletica_verticale_2;
|
|
|
@@ -451,20 +429,6 @@ class Report extends Component
|
|
|
public $loadAnagrafica;
|
|
|
public $currentInfortunato;
|
|
|
public $cds_2;
|
|
|
- public $allegati = [];
|
|
|
-
|
|
|
- public function updatedAllegati()
|
|
|
- {
|
|
|
- foreach ($this->allegati as $allegato)
|
|
|
- {
|
|
|
- $name = $allegato->getClientOriginalName();
|
|
|
- $allegato->storeAs('public', $name);
|
|
|
- $this->allegatiFiles[] = $name;
|
|
|
- }
|
|
|
- $this->emit('attachments', implode("|", $this->allegatiFiles));
|
|
|
- $this->allegati = [];
|
|
|
- }
|
|
|
-
|
|
|
protected $rules = [
|
|
|
//'name' => 'required'
|
|
|
];
|
|
|
@@ -1507,162 +1471,12 @@ class Report extends Component
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- 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 closeAndResetModal(){
|
|
|
logger('closeAndResetModal called');
|
|
|
$this->resetVeicoloData();
|
|
|
$this->emit('close-modal-parte-comune');
|
|
|
|
|
|
}
|
|
|
-
|
|
|
- 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 editAnagraficaParte($progressive) {
|
|
|
$parte_comune = ReportDataPartiCoinvolte::where('report_id', $this->dataId)->where('progressive', $progressive)->first();
|
|
|
if ($parte_comune != null)
|
|
|
@@ -2649,17 +2463,6 @@ class Report extends Component
|
|
|
}
|
|
|
return "";
|
|
|
}
|
|
|
-
|
|
|
- public function getAllegatoType($type)
|
|
|
- {
|
|
|
- if ($type > 0)
|
|
|
- {
|
|
|
- $ret = \App\Models\AllegatiGalleryType::findOrFail($type);
|
|
|
- return $ret->name;
|
|
|
- }
|
|
|
- return "";
|
|
|
- }
|
|
|
-
|
|
|
public function getVeicolo($veicolo)
|
|
|
{
|
|
|
if ($veicolo > 0)
|