eOSP2/resources/views/operation.blade.php
2020-02-01 02:33:06 +01:00

202 lines
8.4 KiB
PHP

@extends('layout.app')
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
@section('left-menu')
@parent
@if( auth()->check() )
@if( auth()->user()->fireStationID != NULL)
@if(auth()->user()->accessLevel() == 50)
<ul>
<a href="/wyjazdy/add"><li>Dodaj<img src="/img/left_menu_icon/add.png"></li></a>
</ul>
@endif
@endif
@endif
@stop
@section('center-area')
<meta name="csrf-token" content="{{ csrf_token() }}">
@parent
@if( auth()->check())
@if( auth()->user()->fireStationID == NULL)
Jednostka nie istnieje
@else
<form action="{{ route('operations.allPDF') }}" method="post" style="display:inline;">
{{ csrf_field() }}
<input type="hidden" class="form-control" name="fireStationID" value="{{auth()->user()->fireStationID}}">
<button class="btn btn-dark" type="submit">Drukuj wszystkie</button>
</form>
<br>
<table class='table'>
<thead>
<tr>
<th>#</th>
<th>Data</th>
<th>Miejsce</th>
<th>Cel</th>
<th>Rodzaj zagrożenia</th>
<th>Dowódca</th>
@if(auth()->user()->accessLevel() == 50)
<th>Operacja</th>
<th>Szczegóły</th>
@endif
<th>Szczegóły</th>
</tr>
</thead>
@php
$i=1;
@endphp
@foreach($operations as $operation)
<tr>
<th>{{$i}}</th>
<td id="operationDate{{ $operation->id }}">{{ $operation->operationDate }}</td>
<td id="operationLocation{{ $operation->id }}">{{ $operation->location }}</td>
<td id="operationTarget{{ $operation->id }}">{{ $operation->target }}</td>
<td id="operationDangerType{{ $operation->id }}">{{ $operation->dangerType }}</td>
<td id="operationCommander{{ $operation->id }}">{{$operation->name}} {{$operation->surname}}</td>
@if(auth()->user()->accessLevel() == 50)
<td>
<a href="{{ URL::asset('wyjazdy/edit/'.$operation->id) }}" class="btn btn-secondary" role="button">Edytuj</a>
<button class="btn btn-danger" type="submit" id="{{$operation->id}}" onclick="deleteButton('{{$operation->id}}')">Usuń</button>
<form action="{{ route('operations.singlePDF') }}" method="post" style="display:inline;">
{{ csrf_field() }}
<input type="hidden" class="form-control" name="operationID" value="{{$operation->id}}">
<button class="btn btn-dark" type="submit">Drukuj</button>
</form>
</td>
@endif
<td>
<button class="btn btn-info" type="button" id="more{{$operation->id}}" onclick="showMoreInformation('{{$operation->id}}')">Więcej</button>
</td>
</tr>
<tr id="moreInformation{{$operation->id}}" style="visibility:collapse;">
{{-- bgcolor="#C0C0C0"--}}
<td colspan="8">
<center>
<table class="table table-dark">
<thead>
<tr>
<th colspan="8"><center>Opis Akcji</center></th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="8">{{$operation->description}}</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<th><center>Pojazdy</center></th>
<th><center>Kierowcy</center></th>
</tr>
@foreach($trucks[$operation->id] as $truck)
@if($truck->truckID != null)
<tr>
<td>{{$truck->name}} {{$truck->codename }} {{$truck->brand}} {{$truck->registrationNumber}}</td>
<td colspan="8">{{$truck->driverName }} {{ $truck->driverSurname}}</td>
</tr>
@endif
@endforeach
<tr>
<td></td>
<td></td>
</tr>
<tr>
<th><center>Członkowie Akcji</center></th>
<th><center>Transport Własny</center></th>
</tr>
@foreach($fireFighters[$operation->id] as $fireFighter)
@if($fireFighter->memberID != null)
<tr>
<td>{{$fireFighter->name}} {{$fireFighter->surname }}</td>
<td>{{($fireFighter->privateTransport == 1) ? "Tak" : "Nie"}}</td>
</tr>
@endif
@endforeach
<tr>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</center>
</td>
</tr>
@php
$i++;
@endphp
@endforeach
</tbody>
</table>
{{ $operations->links() }}
@endif
@else
Brak autoryzacji
@endif
@stop
<script>
function showMoreInformation(operationID){
if( $('#more'+operationID).val() == "Więcej"){
$('#more'+operationID).val("Ukryj");
$("#moreInformation"+operationID).css('visibility', 'visible');
} else{
$('#more'+operationID).val("Więcej");
$("#moreInformation"+operationID).css('visibility', 'collapse');
}
}
function deleteButton(operationID){
swal.fire({
title: "Czy chcesz usunąć wyjazd?",
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: "wyjazdy/"+operationID,
type: 'DELETE',
data: {
"id": operationID,
},
success: function (){
console.log("it Works");
location.reload();
}
});
}
})
}
</script>