|
|
@@ -3,9 +3,12 @@ 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\HasPedoni;
|
|
|
use App\Http\Livewire\Traits\HasPolizza;
|
|
|
use App\Http\Livewire\Traits\HasAllegato;
|
|
|
use App\Http\Livewire\Traits\HasRichieste;
|
|
|
+use App\Http\Livewire\Traits\HasProprietari;
|
|
|
+
|
|
|
use Livewire\Component;
|
|
|
use Livewire\WithPagination;
|
|
|
use Livewire\WithFileUploads;
|
|
|
@@ -25,6 +28,8 @@ class Report extends Component{
|
|
|
use HasAllegato;
|
|
|
use HasRichieste;
|
|
|
use HasNote;
|
|
|
+ use HasPedoni;
|
|
|
+ use HasProprietari;
|
|
|
protected $paginationTheme = 'bootstrap';
|
|
|
public $title = 'Verbali';
|
|
|
public $loadPatente;
|
|
|
@@ -268,18 +273,13 @@ class Report extends Component{
|
|
|
public $vei_peso_complessivo;
|
|
|
public $vei_destinazione_uso;
|
|
|
public $vei_state;
|
|
|
- public $currentProprietario;
|
|
|
- public $currentCoproprietario;
|
|
|
public $currentConducente;
|
|
|
- public $currentPolizza;
|
|
|
public $currentPasseggero;
|
|
|
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;
|
|
|
@@ -396,19 +396,10 @@ class Report extends Component{
|
|
|
public $data_testi_oculari_stato_2;
|
|
|
public $data_testi_oculari_3;
|
|
|
public $data_testi_oculari_stato_3;
|
|
|
- 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;
|
|
|
@@ -847,25 +838,6 @@ class Report extends Component{
|
|
|
$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 hydrate(){
|
|
|
$this->emit('load-select');
|
|
|
$this->emit('load-check');
|
|
|
@@ -1505,56 +1477,17 @@ class Report extends Component{
|
|
|
|
|
|
}
|
|
|
|
|
|
- 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);
|
|
|
@@ -1680,7 +1613,7 @@ class Report extends Component{
|
|
|
public function editVeicolo($veicolo)
|
|
|
{
|
|
|
$this->resetVeicolo();
|
|
|
- $vei = \App\Models\Vehicle::where('id', $veicolo)->first();
|
|
|
+ $vei = Vehicle::where('id', $veicolo)->first();
|
|
|
if ($vei != null){
|
|
|
$this->currentVeicolo = $veicolo;
|
|
|
$this->vei_tipo_id = $vei->tipo_id;
|
|
|
@@ -1706,11 +1639,11 @@ class Report extends Component{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function editVeicoloData($progressive)
|
|
|
- {
|
|
|
+ public function editVeicoloData($progressive){
|
|
|
$this->resetVeicoloData();
|
|
|
$this->currentProgressive = $progressive;
|
|
|
- $data = \App\Models\ReportDataVeicoli::where('progressive', $progressive)->where('report_id', $this->dataId)->first();
|
|
|
+ $data = ReportDataVeicoli::where('progressive', $progressive)->where('report_id', $this->dataId)->first();
|
|
|
+
|
|
|
if ($data != null){
|
|
|
$this->currentVeicolo = $data->veicolo;
|
|
|
$this->data_chilometri_percorsi = $data->chilometri_percorsi;
|
|
|
@@ -1800,7 +1733,7 @@ class Report extends Component{
|
|
|
$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();
|
|
|
+ $an = ReportDataPartiCoinvolte::where('report_id', $this->dataId)->where('progressive', $progressive)->first();
|
|
|
$this->data_conducenti = $an->anagrafica;
|
|
|
}
|
|
|
}
|
|
|
@@ -1826,7 +1759,6 @@ class Report extends Component{
|
|
|
$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){
|
|
|
@@ -1851,7 +1783,6 @@ class Report extends Component{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // Infortunati
|
|
|
$infortunati = \App\Models\ReportDataInfortunati::where('progressive', $progressive)->where('report_id', $this->dataId)->get();
|
|
|
foreach($infortunati as $idx => $i){
|
|
|
if($idx == 0)
|
|
|
@@ -1903,39 +1834,6 @@ class Report extends Component{
|
|
|
|
|
|
}
|
|
|
|
|
|
- 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');
|
|
|
- }
|
|
|
-
|
|
|
public function anagraficaSave()
|
|
|
{
|
|
|
|
|
|
@@ -2131,9 +2029,8 @@ class Report extends Component{
|
|
|
'vei_destinazione_uso.required' => 'Il campo "Destinazione d\'uso" è obbligatorio.',
|
|
|
]);
|
|
|
|
|
|
- if ($this->currentVeicolo > 0)
|
|
|
- {
|
|
|
- \App\Models\Vehicle::whereId($this->currentVeicolo)->update([
|
|
|
+ if ($this->currentVeicolo > 0){
|
|
|
+ Vehicle::whereId($this->currentVeicolo)->update([
|
|
|
'tipo_id' => $this->vei_tipo_id,
|
|
|
'marca_id' => $this->vei_marca_id,
|
|
|
'marca_altro' => $this->vei_marca_altro,
|
|
|
@@ -2154,9 +2051,7 @@ class Report extends Component{
|
|
|
'peso_complessivo' => $this->vei_peso_complessivo,
|
|
|
'destinazione_uso' => $this->vei_destinazione_uso
|
|
|
]);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ }else{
|
|
|
$veicolo = \App\Models\Vehicle::create([
|
|
|
'tipo_id' => $this->vei_tipo_id,
|
|
|
'marca_id' => $this->vei_marca_id,
|
|
|
@@ -2184,39 +2079,6 @@ class Report extends Component{
|
|
|
$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 anagraficaDataParteComuneSave(){
|
|
|
|
|
|
ReportDataVeicoli::where('progressive', $this->currentProgressive)->where('report_id', $this->dataId)->delete();
|
|
|
@@ -2441,8 +2303,7 @@ class Report extends Component{
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
- public function getStradario($stradario)
|
|
|
- {
|
|
|
+ public function getStradario($stradario){
|
|
|
if ($stradario > 0)
|
|
|
{
|
|
|
$ret = \App\Models\Stradario::findOrFail($stradario);
|
|
|
@@ -2451,8 +2312,7 @@ class Report extends Component{
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
- public function getAnagrafica($anagrafica)
|
|
|
- {
|
|
|
+ public function getAnagrafica($anagrafica){
|
|
|
if ($anagrafica > 0)
|
|
|
{
|
|
|
$ret = \App\Models\Anagrafica::findOrFail($anagrafica);
|
|
|
@@ -2463,8 +2323,7 @@ class Report extends Component{
|
|
|
}
|
|
|
return "";
|
|
|
}
|
|
|
- public function getVeicolo($veicolo)
|
|
|
- {
|
|
|
+ public function getVeicolo($veicolo){
|
|
|
if ($veicolo > 0)
|
|
|
{
|
|
|
$ret = Vehicle::findOrFail($veicolo);
|
|
|
@@ -2473,8 +2332,7 @@ class Report extends Component{
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
- public function getByTarga()
|
|
|
- {
|
|
|
+ public function getByTarga(){
|
|
|
|
|
|
if ($this->vei_targa != '')
|
|
|
{
|
|
|
@@ -2632,11 +2490,10 @@ class Report extends Component{
|
|
|
|
|
|
}
|
|
|
|
|
|
- public function print($id)
|
|
|
- {
|
|
|
+ public function print($id){
|
|
|
|
|
|
$record = \App\Models\Report::findOrFail($id);
|
|
|
- $parti_coinvolte = \App\Models\ReportDataPartiCoinvolte::where('report_id', $id)->get();
|
|
|
+ $parti_coinvolte = ReportDataPartiCoinvolte::where('report_id', $id)->get();
|
|
|
|
|
|
$datiVeicolo = array();
|
|
|
$datiInfortunati = array();
|
|
|
@@ -2647,7 +2504,7 @@ class Report extends Component{
|
|
|
$datiCintureSicurezza = array();
|
|
|
foreach($parti_coinvolte as $pr)
|
|
|
{
|
|
|
- $datiVeicolo[$pr->progressive] = \App\Models\ReportDataVeicoli::where('progressive', $pr->progressive)->where('report_id', $id)->first();
|
|
|
+ $datiVeicolo[$pr->progressive] = 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();
|