113 lines
4.6 KiB
PHP
113 lines
4.6 KiB
PHP
@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>
|
|
@section('left-menu')
|
|
@parent
|
|
<ul>
|
|
<a href="/strazacy"><li>Powrót<img src="/img/left_menu_icon/edit.png"></li></a>
|
|
</ul>
|
|
@stop
|
|
@section('center-area')
|
|
<meta name="csrf-token" content="{{ csrf_token() }}">
|
|
@parent
|
|
|
|
@if( auth()->check())
|
|
@if( auth()->user()->fireStationID == NULL)
|
|
Jednostka nie istnieje
|
|
@else
|
|
@if(count($awardedDecorations) > 0)
|
|
<p align='center'>
|
|
<table class='table'>
|
|
<thead>
|
|
<tr>
|
|
<th colspan="3" scope="colgroup" style="text-align:center">{{ $firefighter->name }} {{ $firefighter->surname }} - odznaczenia</th>
|
|
</tr>
|
|
|
|
</thead>
|
|
<tbody>
|
|
<th>Odznaczenie</th>
|
|
<th>Data przyznania</th>
|
|
<th>Operacja</th>
|
|
@foreach($awardedDecorations as $awardedDecoration)
|
|
<tr>
|
|
<td id="decorationName{{ $awardedDecoration->decorationsFirefightersID }}">{{ $awardedDecoration->decorationName }}</td>
|
|
<td id="dateOfAward{{ $awardedDecoration->decorationsFirefightersID }}">{{ $awardedDecoration->dateOfAward }}</td>
|
|
<td>
|
|
<button class="btn btn-danger" type="submit" id="{{$awardedDecoration->decorationsFirefightersID}}" onclick="deleteButton('{{$awardedDecoration->decorationsFirefightersID}}')">Usuń</button>
|
|
</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</p>
|
|
@else
|
|
{{ $firefighter->name }} {{ $firefighter->surname }} nie posiada żadnych odznaczeń.
|
|
@endif
|
|
|
|
<form method="POST" action="/strazacy/odznaczenia/.$firefighter->id">
|
|
{{ csrf_field() }}
|
|
<input type="hidden" class="form-control" name="firefighterID" value="{{ $firefighter->id }}">
|
|
<div class="form-group">
|
|
<label for="decoration">Wybierz odznaczenie:</label>
|
|
<select name="decoration" class="form-control" style="width:300px">
|
|
<option value="">--- Wybierz odznaczenie ---</option>
|
|
@foreach ($decoration as $key => $value)
|
|
@if(Illuminate\Support\Facades\Input::old('decoration') == $key)
|
|
<option value="{{ $key }}" selected >{{ $value }}</option>
|
|
@else
|
|
<option value="{{ $key }}">{{ $value }}</option>
|
|
@endif
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="dateOfAward">Data przyznania:</label>
|
|
<input type="date" class="form-control" style="width:300px" id="dateOfAward" name="dateOfAward" value="{{ old('dateOfAward') }}">
|
|
</div>
|
|
<div class="form-group">
|
|
<button style="cursor:pointer" type="submit" class="btn btn-primary">Przyznaj odznaczenie</button>
|
|
</div>
|
|
@include('inc.formerrors')
|
|
</form>
|
|
@endif
|
|
@else
|
|
Brak autoryzacji
|
|
@endif
|
|
|
|
@stop
|
|
|
|
<script>
|
|
|
|
function deleteButton(decorationID){
|
|
swal.fire({
|
|
title: "Czy chcesz usunąć odznaczenie?",
|
|
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: "delete/"+decorationID,
|
|
type: 'DELETE',
|
|
data: {
|
|
"id": decorationID,
|
|
},
|
|
success: function (){
|
|
console.log("it Works");
|
|
location.reload();
|
|
}
|
|
});
|
|
}
|
|
})
|
|
|
|
}
|
|
</script> |