eOSP2/resources/views/vehicles.blade.php

140 lines
5.8 KiB
PHP
Raw Normal View History

2019-07-11 23:55:51 +02:00
@extends('layout.app')
<meta name="csrf-token" content="{{ csrf_token() }}">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
2019-07-11 23:55:51 +02:00
@section('left-menu')
@parent
@if( auth()->check() )
@if( auth()->user()->fireStationID != NULL)
@if(auth()->user()->accessLevel() == 50)
2019-07-11 23:55:51 +02:00
<ul>
2019-11-17 17:08:02 +01:00
<a href="/pojazdy/add"><li>Dodaj<img src="img/left_menu_icon/add.png"></li></a>
2020-02-01 06:24:15 +01:00
@if(auth()->user()->accessLevel() == 50)
<form id="myForm" action="{{ route('vehicles.pdfALL') }}" method="post" style="display:inline;">
{{ csrf_field() }}
<input type="hidden" class="form-control" name="fireStationID" value="{{auth()->user()->fireStationID}}">
<li onclick="myForm.submit();">Drukuj pojazdy</li>
</form>
@endif
2019-07-11 23:55:51 +02:00
</ul>
@endif
@endif
@endif
2019-07-11 23:55:51 +02:00
@stop
@section('center-area')
<meta name="csrf-token" content="{{ csrf_token() }}">
2019-07-11 23:55:51 +02:00
@parent
2019-11-17 17:08:02 +01:00
@if( auth()->check())
@if( auth()->user()->fireStationID == NULL)
Jednostka nie istnieje
@else
2019-07-11 23:55:51 +02:00
<table class='table'>
<thead>
<tr>
<th>#</th>
<th>Typ Pojazdu</th>
<th>Marka</th>
<th>Nr rej.</th>
<th>Kryptonim</th>
<th>Rok Produkcji</th>
<th>Rodzaj napędu</th>
<th>Przegląd</th>
<th>OC</th>
@if(auth()->user()->accessLevel() == 50)
<th>Operacja</th>
@endif
</tr>
</thead>
2019-11-17 17:08:02 +01:00
@php
$lp=0 // liczba porządkowa
@endphp
2019-11-17 17:08:02 +01:00
@foreach($vehicles as $vehicle)
@php
$lp = $lp + 1
@endphp
2019-11-17 17:08:02 +01:00
<tr>
<td>{{ $lp }}</td>
<td id="name{{ $vehicle->id }}">{{ $vehicle->name }}</td>
<td id="brand{{ $vehicle->id }}">{{ $vehicle->brand }}</td>
<td id="registrationNumber{{ $vehicle->id }}">{{ $vehicle->registrationNumber }}</td>
<td id="codename{{ $vehicle->id }}">{{ $vehicle->codename }}</td>
<td id="productionYear{{ $vehicle->id }}">{{ $vehicle->productionYear }}</td>
<td id="driveType{{ $vehicle->id }}">{{ $vehicle->driveType }}</td>
<td id="examExpirationDate{{ $vehicle->id }}">{{ $vehicle->examExpirationDate }}</td>
<td id="insuranceExpirationDate{{ $vehicle->id }}">{{ $vehicle->insuranceExpirationDate }}</td>
@if(auth()->user()->accessLevel() == 50)
<td style="display:inline;">
<a href="{{ URL::asset('pojazdy/edit/'.$vehicle->id) }}" class="btn btn-secondary" role="button">Edytuj</a>
<button class="btn btn-danger" type="submit" id="{{$vehicle->id}}" onclick="deleteButton('{{$vehicle->id}}')">Usuń</button>
@if ($vehicle->status == 1)
<form method="POST" action="/pojazdy/deactivate" style="display:inline;">
{{ csrf_field() }}
<input type="hidden" class="form-control" name="vehicleID" value="{{ $vehicle->id }}">
<button style="cursor:pointer" type="submit" class="btn btn-primary">Zawieś</button>
</form>
@elseif ($vehicle->status == 0)
<form method="POST" action="/pojazdy/activate" style="display:inline;" >
{{ csrf_field() }}
<input type="hidden" class="form-control" name="vehicleID" value="{{ $vehicle->id }}">
<button style="cursor:pointer" type="submit" class="btn btn-primary">Przywróć do służby</button>
</form>
2019-12-28 19:01:42 +01:00
@endif
2020-02-01 06:24:15 +01:00
<form action="{{ route('vehicles.pdfSingle') }}" method="post" style="display:inline;">
{{ csrf_field() }}
<input type="hidden" class="form-control" name="vehicleID" value="{{$vehicle->id}}">
<button class="btn btn-dark" type="submit">Drukuj pojazd</button>
</form>
</td>
@endif
2019-11-17 17:08:02 +01:00
</tr>
@endforeach
</table>
{{ $vehicles->links() }}
2019-11-17 17:08:02 +01:00
@endif
@else
Brak autoryzacji
@endif
2019-07-11 23:55:51 +02:00
@stop
<script>
function deleteButton(vehicleID){
swal.fire({
title: "Czy chcesz usunąć pojazd?",
width: 'auto',
confirmButtonText: 'Tak',
cancelButtonText: 'Nie',
showCancelButton: true,
}).then((result) => {
if(result.value){
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
url: "pojazdy/"+vehicleID,
type: 'DELETE',
data: {
"id": vehicleID,
},
success: function (){
console.log("it Works");
location.reload();
}
});
}
})
}
2020-02-01 06:24:15 +01:00
</script>