Dodanie paginacji oraz poprawienie widoków większości tabel

This commit is contained in:
czup 2020-01-29 01:57:19 +01:00
parent 406605de39
commit c69bdaf053
14 changed files with 288 additions and 160 deletions

View File

@ -12,7 +12,7 @@ class EquipmentController extends Controller
if(auth()->user() != null && auth()->user()->fireStationID != null ){ if(auth()->user() != null && auth()->user()->fireStationID != null ){
$equipment = DB::table('equipment')->where("fireStationID", '=', auth()->user()->fireStationID) $equipment = DB::table('equipment')->where("fireStationID", '=', auth()->user()->fireStationID)
->whereNull('deleted_at')->get(); ->whereNull('deleted_at')->paginate(10);
return view("equipment", ["equipment" => $equipment]); return view("equipment", ["equipment" => $equipment]);
} else{ } else{
return view('equipment'); return view('equipment');
@ -90,6 +90,8 @@ class EquipmentController extends Controller
{ {
equipment::where('id',$id)->delete(); equipment::where('id',$id)->delete();
return redirect()->to('/sprzet'); return response()->json([
'success' => 'Record deleted successfully!'
]);
} }
} }

View File

@ -20,7 +20,7 @@ class fireFightersController extends Controller
->leftJoin('ranks', 'users.degreeID', '=', 'ranks.id') ->leftJoin('ranks', 'users.degreeID', '=', 'ranks.id')
->leftJoin('unitFunctions', 'users.functionID', '=', 'unitFunctions.id') ->leftJoin('unitFunctions', 'users.functionID', '=', 'unitFunctions.id')
->select('users.id','users.name', 'users.surname', 'users.PESEL', 'users.email', 'users.statusID', 'ranks.rank', 'unitFunctions.unitFunction') ->select('users.id','users.name', 'users.surname', 'users.PESEL', 'users.email', 'users.statusID', 'ranks.rank', 'unitFunctions.unitFunction')
->get(); ->paginate(10);
return view("fireFighters", ["users" => $users]); return view("fireFighters", ["users" => $users]);
} else{ } else{
return view('fireFighters'); return view('fireFighters');

View File

@ -16,7 +16,8 @@ class trainingsController extends Controller
if(auth()->user() != null && auth()->user()->fireStationID != null ){ if(auth()->user() != null && auth()->user()->fireStationID != null ){
$trainings = DB::table('trainings')->where("fireStationID", '=', auth()->user()->fireStationID) $trainings = DB::table('trainings')->where("fireStationID", '=', auth()->user()->fireStationID)
->whereNull('deleted_at')->get(); ->whereNull('deleted_at')
->paginate(10);
$fireFighters = array(); $fireFighters = array();
foreach($trainings as $training) { foreach($trainings as $training) {
@ -66,7 +67,7 @@ class trainingsController extends Controller
$join->where('trainingsFirefighters.trainingID', '=', $id); $join->where('trainingsFirefighters.trainingID', '=', $id);
}) })
->select('trainingsFirefighters.*', 'users.name', 'users.surname', 'users.id as userID') ->select('trainingsFirefighters.*', 'users.name', 'users.surname', 'users.id as userID')
->get(); ->paginate(10);
$training = DB::table('trainings')->where("id", '=', $id) $training = DB::table('trainings')->where("id", '=', $id)
->whereNull('deleted_at')->first(); ->whereNull('deleted_at')->first();
@ -158,9 +159,11 @@ class trainingsController extends Controller
public function destroy($id) public function destroy($id)
{ {
trainings::where('id',$id)->delete(); trainings::find($id)->delete($id);
return redirect()->to('/szkolenia'); return response()->json([
'success' => 'Record deleted successfully!'
]);
} }
public function trainingsRename(Request $request){ public function trainingsRename(Request $request){

View File

@ -15,27 +15,32 @@
@else @else
@if(count($awardedDecorations) > 0) @if(count($awardedDecorations) > 0)
<p align='center'> <p align='center'>
<table class='firefighterViewTable'> <table class='table'>
<tr class='table-header'> <thead>
<th colspan="2" scope="colgroup" style="text-align:center">{{ $firefighter->name }} {{ $firefighter->surname }} - odznaczenia</th> <tr>
</tr> <th colspan="3" scope="colgroup" style="text-align:center">{{ $firefighter->name }} {{ $firefighter->surname }} - odznaczenia</th>
<tr class='table-header'>
<td>Odznaczenie</td>
<td>Data przyznania</td>
@foreach($awardedDecorations as $awardedDecoration)
<tr>
<form action="{{ route('decorations.destroy', $awardedDecoration->decorationsFirefightersID)}}" method="post">
<td id="decorationName{{ $awardedDecoration->decorationsFirefightersID }}">{{ $awardedDecoration->decorationName }}</td>
<td id="dateOfAward{{ $awardedDecoration->decorationsFirefightersID }}">{{ $awardedDecoration->dateOfAward }}</td>
<td>
{{ csrf_field() }}
@method('DELETE')
<button class="btn btn-danger" type="submit">Usuń</button>
</td>
</form>
</tr> </tr>
@endforeach
</table> </thead>
<tbody>
<th>Odznaczenie</th>
<th>Data przyznania</th>
<th>Operacja</th>
@foreach($awardedDecorations as $awardedDecoration)
<tr>
<form action="{{ route('decorations.destroy', $awardedDecoration->decorationsFirefightersID)}}" method="post">
<td id="decorationName{{ $awardedDecoration->decorationsFirefightersID }}">{{ $awardedDecoration->decorationName }}</td>
<td id="dateOfAward{{ $awardedDecoration->decorationsFirefightersID }}">{{ $awardedDecoration->dateOfAward }}</td>
<td>
{{ csrf_field() }}
@method('DELETE')
<button class="btn btn-danger" type="submit">Usuń</button>
</td>
</form>
</tr>
@endforeach
</tbody>
</table>
</p> </p>
@else @else
{{ $firefighter->name }} {{ $firefighter->surname }} nie posiada żadnych odznaczeń. {{ $firefighter->name }} {{ $firefighter->surname }} nie posiada żadnych odznaczeń.

View File

@ -1,5 +1,6 @@
@extends('layout.app') @extends('layout.app')
<meta name="csrf-token" content="{{ csrf_token() }}">
@section('left-menu') @section('left-menu')
@parent @parent
<ul> <ul>
@ -10,6 +11,7 @@
@stop @stop
@section('center-area') @section('center-area')
<meta name="csrf-token" content="{{ csrf_token() }}">
@parent @parent
@if( auth()->check()) @if( auth()->check())
@ -17,26 +19,38 @@
Jednostka nie istnieje Jednostka nie istnieje
@else @else
<p align='center'> <p align='center'>
<table class='firefighterViewTable'> <table class="table">
<tr class='table-header'> <thead>
<td>Nazwa</td> <tr>
<td>Ilość</td> <th>#</th>
<td>Param. charakterystyczny</td> <th>Nazwa</th>
<th>Ilość</th>
<th>Param. charakterystyczny</th>
<th>Operacja</th>
</tr>
</thead>
@php
$i=1;
@endphp
@foreach($equipment as $item) @foreach($equipment as $item)
<tr> <tr>
<form action="{{ route('equipment.destroy', $item->id)}}" method="post"> <th>{{$i}}</th>
<td id="name{{ $item->id }}">{{ $item->name }}</td> <td id="name{{ $item->id }}">{{ $item->name }}</td>
<td id="amount{{ $item->id }}">{{ $item->amount }}</td> <td id="amount{{ $item->id }}">{{ $item->amount }}</td>
<td id="parameter{{ $item->id }}">{{ $item->parameter }}</td> <td id="parameter{{ $item->id }}">{{ $item->parameter }}</td>
<td><a href="{{ URL::asset('sprzet/edit/'.$item->id) }}"><input type="button" onclick="" value="Edytuj"> </a></td>
<td> <td>
{{ csrf_field() }} <a href="{{ URL::asset('sprzet/edit/'.$item->id) }}" class="btn btn-secondary" role="button">Edytuj</a>
@method('DELETE') <button class="btn btn-danger" type="submit" id="{{$item->id}}" onclick="deleteButton('{{$item->id}}')">Usuń</button>
<button class="btn btn-danger" type="submit">Usuń</button> </td>
</form></td>
</tr> </tr>
@php
$i++;
@endphp
@endforeach @endforeach
</table> </table>
{{ $equipment->links() }}
</p> </p>
@endif @endif
@ -45,3 +59,39 @@
@endif @endif
@stop @stop
<script>
function deleteButton(itemID){
swal.fire({
title: "Czy chcesz usunąć sprzęt?",
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: "sprzet/"+itemID,
type: 'DELETE',
data: {
"id": itemID,
},
success: function (){
console.log("it Works");
location.reload();
}
});
}
})
}
</script>

View File

@ -19,8 +19,8 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="amount">Ilość:</label> <label for="amount">Ilość:</label>
<input type="text" class="form-control" id="amount" name="amount" value="{{ old('amount') }}"> <input type="text" class="form-control" id="amount" name="amount" value="{{ old('amount') }}">
</div> </div>
<div class="form-group"> <div class="form-group">

View File

@ -66,42 +66,56 @@
Jednostka nie istnieje Jednostka nie istnieje
@else @else
<table class='firefighterViewTable'> <table class='table'>
<tr class='table-header'> <thead>
<td>Imie</td>
<td>Nazwisko</td>
<td>PESEL</td>
<td>E-mail</td>
<td>Funkcja</td>
<td>Stopień</td>
<td>Status</td>
</tr>
@foreach($users as $user)
<tr> <tr>
<td id="userName{{ $user->id }}">{{ $user->name }}</td> <th>#</th>
<td id="userSurname{{ $user->id }}">{{ $user->surname }}</td> <th>Imie</th>
<td id="userPESEL{{ $user->id }}">{{ $user->PESEL }}</td> <th>Nazwisko</th>
<td id="userEmail{{ $user->id }}">{{ $user->email }}</td> <th>PESEL</th>
<td id="userFunction{{ $user->id }}"> {{$user->unitFunction}} </td> <th>E-mail</th>
<td id="userDegree{{ $user->id }}"> {{$user->rank}}</td> <th>Funkcja</th>
<td id="userStatus{{ $user->id }}">@if( $user->statusID == 0) Czynny @else Wyłączony @endif</td> <th>Stopień</th>
<td><a href="{{ URL::asset('strazacy/edit/'.$user->id) }}"><input type="button" onclick="" value="Edytuj"> </a></td> <th>Status</th>
<td><a href="{{ URL::asset('strazacy/odznaczenia/'.$user->id) }}"><input type="button" onclick="" value="Odznaczenia"> </a></td> <th>Operacje</th>
</tr> </tr>
{{-- <tr>--}} </thead>
{{-- <form id="editForm{{$user->id}}" method="POST" action="/strazacy">--}}
{{-- {{ csrf_field() }}--}}
{{-- <div class="form-group">--}}
{{-- <label for="name">Imię:</label>--}}
{{-- <input type="text" class="form-control" id="name" name="name" value="{{ old('name') }} ">--}}
{{-- </div>--}}
{{-- </form>--}}
{{-- </tr>--}}
@endforeach
</table>"
<tbody>
@php
$i = 1;
@endphp
@foreach($users as $user)
<tr>
<th>{{$i}}</th>
<td id="userName{{ $user->id }}">{{ $user->name }}</td>
<td id="userSurname{{ $user->id }}">{{ $user->surname }}</td>
<td id="userPESEL{{ $user->id }}">{{ $user->PESEL }}</td>
<td id="userEmail{{ $user->id }}">{{ $user->email }}</td>
<td id="userFunction{{ $user->id }}"> {{$user->unitFunction}} </td>
<td id="userDegree{{ $user->id }}"> {{$user->rank}}</td>
<td id="userStatus{{ $user->id }}">@if( $user->statusID == 0) Czynny @else Wyłączony @endif</td>
<td>
<a href="{{ URL::asset('strazacy/edit/'.$user->id) }}" class="btn btn-secondary" role="button">Edytuj</a>
<a href="{{ URL::asset('strazacy/odznaczenia/'.$user->id) }}" class="btn btn-success" role="button">Odznaczenia</a>
</td>
</tr>
{{-- <tr>--}}
{{-- <form id="editForm{{$user->id}}" method="POST" action="/strazacy">--}}
{{-- {{ csrf_field() }}--}}
{{-- <div class="form-group">--}}
{{-- <label for="name">Imię:</label>--}}
{{-- <input type="text" class="form-control" id="name" name="name" value="{{ old('name') }} ">--}}
{{-- </div>--}}
{{-- </form>--}}
{{-- </tr>--}}
@php
$i++;
@endphp
@endforeach
</tbody>
</table>
{{ $users->links() }}
@endif @endif
@else @else
Brak autoryzacji Brak autoryzacji
@ -112,4 +126,3 @@

View File

@ -25,11 +25,11 @@
<th>Rodzaj zagrożenia</th> <th>Rodzaj zagrożenia</th>
<th>Dowódca</th> <th>Dowódca</th>
<th>Operacja</th> <th>Operacja</th>
<th>Szczegóły</th> <th>Szczegóły</th> <tbody>
</tr>
</tr>
</thead> </thead>
<tbody>
@php @php
$i=1; $i=1;
@endphp @endphp
@ -42,11 +42,11 @@
<td id="operationDangerType{{ $operation->id }}">{{ $operation->dangerType }}</td> <td id="operationDangerType{{ $operation->id }}">{{ $operation->dangerType }}</td>
<td id="operationCommander{{ $operation->id }}">{{$operation->name}} {{$operation->surname}}</td> <td id="operationCommander{{ $operation->id }}">{{$operation->name}} {{$operation->surname}}</td>
<td> <td>
<a href="{{ URL::asset('wyjazdy/edit/'.$operation->id) }}"><input type="button" onclick="" value="Edytuj"> </a> <a href="{{ URL::asset('wyjazdy/edit/'.$operation->id) }}" class="btn btn-secondary" role="button">Edytuj</a>
<button class="btn btn-danger btn-delete" type="submit" id="{{$operation->id}}" onclick="deleteButton('{{$operation->id}}')">Usuń</button> <button class="btn btn-danger" type="submit" id="{{$operation->id}}" onclick="deleteButton('{{$operation->id}}')">Usuń</button>
</td> </td>
<td> <td>
<input type="button" onclick="showMoreInformation('{{$operation->id}}')" id="more{{$operation->id}}" value="Więcej"> <button class="btn btn-info" type="button" id="more{{$operation->id}}" onclick="showMoreInformation('{{$operation->id}}')">Więcej</button>
</td> </td>
</tr> </tr>
<tr id="moreInformation{{$operation->id}}" style="visibility:collapse;"> <tr id="moreInformation{{$operation->id}}" style="visibility:collapse;">

View File

@ -23,7 +23,7 @@
<div class="form-group"> <div class="form-group">
<label for="location">Miejsce akcji:</label> <label for="location">Miejsce akcji:</label>
<input type="text" class="form-control" id="operationLocation" name="operationLocation" value="{{ $operation->location}}"> <input type="text" class="form-control is-valid" id="operationLocation" name="operationLocation" value="{{ $operation->location}}">
</div> </div>
<div class="form-group"> <div class="form-group">
@ -33,7 +33,7 @@
<div class="form-group"> <div class="form-group">
<label for="location">Rodzaj zagrożenia:</label> <label for="location">Rodzaj zagrożenia:</label>
<input type="text" class="form-control" id="operationDangerType" name="operationDangerType" value="{{ $operation->dangerType }}"> <input type="text" class="form-control is-valid" id="operationDangerType" name="operationDangerType" value="{{ $operation->dangerType }}">
</div> </div>
<div class="form-group"> <div class="form-group">

View File

@ -15,8 +15,8 @@
@stop @stop
@section('center-area') @section('center-area')
<meta name="csrf-token" content="{{ csrf_token() }}">
@parent @parent
@if( auth()->check()) @if( auth()->check())
@if( auth()->user()->fireStationID == NULL) @if( auth()->user()->fireStationID == NULL)
Jednostka nie istnieje Jednostka nie istnieje
@ -34,55 +34,68 @@
</div> </div>
@include('inc.formerrors') @include('inc.formerrors')
</form> </form>
<table class='firefighterViewTable'> <table class='table'>
<tr class='table-header'> <tr class='table-header'>
<td>Nazwa Szkolenia</td> <thead>
<td>Ilość z ukończonym</td> <th>#</th>
<td>Akcje</td> <th>Nazwa Szkolenia</th>
@foreach($trainings as $training) <th>Ilość z ukończonym</th>
<tr id="{{$training->id}}"> <th>Operacja</th>
<th>Szczegóły</th>
</thead>
<td id="name{{ $training->id }}">{{ $training->trainingName }}</td> <tbody>
<td id="amount{{ $training->id }}">5</td> @php
<td><input type="button" onclick="showMoreInformation('{{$training->id}}')" id="more{{$training->id}}" value="Więcej"> $i=1;
<button class="btn btn-info" type="submit" onclick="renameTraining('{{$training->id}}')" id="{{$training->id}}">Zmień nazwę</button> @endphp
<a href="{{ URL::asset('szkolenia/addTrainingsFireFighters/'.$training->id) }}"><input type="button" onclick="" value="Zarządzaj"></a> @foreach($trainings as $training)
</td> <tr id="{{$training->id}}">
<th>{{$i}}</th>
<td id="name{{ $training->id }}">{{ $training->trainingName }}</td>
<td id="amount{{ $training->id }}">5</td>
<td> <td>
<form action="{{ route('trainings.destroy', $training->id)}}" method="post"> <button class="btn btn-success " type="submit" onclick="renameTraining('{{$training->id}}')" id="{{$training->id}}">Zmień nazwę</button>
{{ csrf_field() }} <a href="{{ URL::asset('szkolenia/addTrainingsFireFighters/'.$training->id) }}" class="btn btn-secondary" role="button">Zarządzaj</a>
@method('DELETE') <button class="btn btn-danger" type="submit" id="{{$training->id}}" onclick="deleteButton('{{$training->id}}')">Usuń</button>
<button class="btn btn-danger" type="submit">Usuń</button> </td>
</form> <td>
</td> <button class="btn btn-info" onclick="showMoreInformation('{{$training->id}}')" id="more{{$training->id}}">Więcej</button>
</td>
</tr> </tr>
<tr id="moreInformation{{$training->id}}" style="visibility:collapse;" bgcolor="#C0C0C0"> <tr id="moreInformation{{$training->id}}" style="visibility:collapse;" >
<td colspan="3"> <td colspan="5">
<table> <table class="table table-dark">
<thead>
<thead> <tr>
<td>Imię i Nazwisko</td> <th>Imię i Nazwisko</th>
<td>Ważne od:</td> <th>Ważne od:</th>
<td>Ważne do:</td> <th>Ważne do:</th>
</thead>
<tbody>
@foreach($fireFighters[$training->id] as $fireFighter)
@if($fireFighter->dateOfComplete != null and $fireFighter->dateOfExpiry != null)
<tr id="{{$fireFighter->userID}}">
<td>{{$fireFighter->name}} {{$fireFighter->surname}}</td>
<td>{{$fireFighter->dateOfComplete}}</td>
<td>{{$fireFighter->dateOfExpiry}}</td>
</tr> </tr>
@endif </thead>
@endforeach
</tbody> <tbody>
</table> @foreach($fireFighters[$training->id] as $fireFighter)
</td> @if($fireFighter->dateOfComplete != null and $fireFighter->dateOfExpiry != null)
</tr> <tr id="{{$fireFighter->userID}}">
@endforeach <td>{{$fireFighter->name}} {{$fireFighter->surname}}</td>
<td>{{$fireFighter->dateOfComplete}}</td>
<td>{{$fireFighter->dateOfExpiry}}</td>
</tr>
@endif
@endforeach
</tbody>
</table>
</td>
</tr>
@php
$i++;
@endphp
@endforeach
</tbody>
</table> </table>
{{ $trainings->links() }}
</p> </p>
@endif @endif
@ -141,4 +154,36 @@
} }
) )
} }
function deleteButton(trainingID){
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: "szkolenia/"+trainingID,
type: 'DELETE',
data: {
"id": trainingID,
},
success: function (){
console.log("it Works");
location.reload();
}
});
}
})
}
</script> </script>

View File

@ -22,13 +22,13 @@
Jednostka nie istnieje Jednostka nie istnieje
@else @else
<center><h1>{{$training->trainingName}}</h1></center> <center><h1>{{$training->trainingName}}</h1></center>
<table id="editableTable" class='table table-bordered'> <table id="editableTable" class='table'>
<thead> <thead>
<td>Imię i Nazwisko</td> <th>Imię i Nazwisko</th>
<td>Ważne od:</td> <th>Ważne od:</th>
<td>Ważne do:</td> <th>Ważne do:</th>
<td>Akcje</td> <th>Akcje</th>
</thead> </thead>
<tbody> <tbody>
@ -37,12 +37,16 @@
<td>{{$fireFighter->name}} {{$fireFighter->surname}}</td> <td>{{$fireFighter->name}} {{$fireFighter->surname}}</td>
<td>{{$fireFighter->dateOfComplete}}</td> <td>{{$fireFighter->dateOfComplete}}</td>
<td>{{$fireFighter->dateOfExpiry}}</td> <td>{{$fireFighter->dateOfExpiry}}</td>
<td><button class="btn btn-warning" type="submit" style="display:none" id="{{$fireFighter->userID}}" onclick="cancelButton('{{$fireFighter->userID}}', '{{$fireFighter->dateOfComplete}}', '{{$fireFighter->dateOfExpiry}}')">Anuluj</button> <button class="btn btn-success" type="submit" style="display:none" id="{{$fireFighter->userID}}" onclick="updateButton('{{$fireFighter->userID}}', '{{$fireFighter->dateOfComplete}}', '{{$fireFighter->dateOfExpiry}}')">Zapisz</button> <button class="btn btn-info" type="submit" id="{{$fireFighter->userID}}" onclick="editButton('{{$fireFighter->userID}}')">Edytuj</button> <button class="btn btn-danger btn-delete" type="submit" id="{{$fireFighter->userID}}" onclick="deleteButton('{{$fireFighter->userID}}')">Usuń</button></td> <td>
<button class="btn btn-warning" type="submit" style="display:none" id="{{$fireFighter->userID}}" onclick="cancelButton('{{$fireFighter->userID}}', '{{$fireFighter->dateOfComplete}}', '{{$fireFighter->dateOfExpiry}}')">Anuluj</button>
<button class="btn btn-success" type="submit" style="display:none" id="{{$fireFighter->userID}}" onclick="updateButton('{{$fireFighter->userID}}', '{{$fireFighter->dateOfComplete}}', '{{$fireFighter->dateOfExpiry}}')">Zapisz</button>
<button class="btn btn-secondary" type="submit" id="{{$fireFighter->userID}}" onclick="editButton('{{$fireFighter->userID}}')">Edytuj</button>
<button class="btn btn-danger btn-delete" type="submit" id="{{$fireFighter->userID}}" onclick="deleteButton('{{$fireFighter->userID}}')">Usuń</button></td>
</tr> </tr>
@endforeach @endforeach
</tbody> </tbody>
</table> </table>
{{ $fireFighters->links() }}
@endif @endif
@else @else
@ -54,21 +58,21 @@
<script type="text/javascript"> <script type="text/javascript">
function editButton(firefighterID){ function editButton(firefighterID){
$('.btn-info', '#'+firefighterID).css('display', 'none'); $('.btn-secondary', '#'+firefighterID).css('display', 'none');
$('.btn-warning', '#'+firefighterID).css('display', 'inline'); $('.btn-warning', '#'+firefighterID).css('display', 'inline');
$('.btn-success', '#'+firefighterID).css('display', 'inline'); $('.btn-success', '#'+firefighterID).css('display', 'inline');
$('.btn-info', '#'+firefighterID).parents("tr").find("td:eq(1)").html('<input type="date" name="dateOfComplete">'); $('.btn-secondary', '#'+firefighterID).parents("tr").find("td:eq(1)").html('<input type="date" name="dateOfComplete">');
$('.btn-info', '#'+firefighterID).parents("tr").find("td:eq(2)").html('<input type="date" name="dateOfExpiry">'); $('.btn-secondary', '#'+firefighterID).parents("tr").find("td:eq(2)").html('<input type="date" name="dateOfExpiry">');
} }
function cancelButton(firefighterID, dateOfComplete, dateOfExpiry){ function cancelButton(firefighterID, dateOfComplete, dateOfExpiry){
$('.btn-info', '#'+firefighterID).css('display', 'inline'); $('.btn-secondary', '#'+firefighterID).css('display', 'inline');
$('.btn-warning', '#'+firefighterID).css('display', 'none'); $('.btn-warning', '#'+firefighterID).css('display', 'none');
$('.btn-success', '#'+firefighterID).css('display', 'none'); $('.btn-success', '#'+firefighterID).css('display', 'none');
$('.btn-info', '#'+firefighterID).parents("tr").find("td:eq(1)").html(dateOfComplete); $('.btn-secondary', '#'+firefighterID).parents("tr").find("td:eq(1)").html(dateOfComplete);
$('.btn-info', '#'+firefighterID).parents("tr").find("td:eq(2)").html(dateOfExpiry); $('.btn-secondary', '#'+firefighterID).parents("tr").find("td:eq(2)").html(dateOfExpiry);
} }
function updateButton(firefighterID, dateOfComplete, dateOfExpiry){ function updateButton(firefighterID, dateOfComplete, dateOfExpiry){
@ -89,10 +93,10 @@
'dateOfExpiry': $('input[name=dateOfExpiry]').val() 'dateOfExpiry': $('input[name=dateOfExpiry]').val()
}, },
success: function(data) { success: function(data) {
$('.btn-info', '#'+firefighterID).parents("tr").find("td:eq(1)").html($('input[name=dateOfComplete]').val()); $('.btn-secondary', '#'+firefighterID).parents("tr").find("td:eq(1)").html($('input[name=dateOfComplete]').val());
$('.btn-info', '#'+firefighterID).parents("tr").find("td:eq(2)").html($('input[name=dateOfExpiry]').val()); $('.btn-secondary', '#'+firefighterID).parents("tr").find("td:eq(2)").html($('input[name=dateOfExpiry]').val());
$('.btn-info', '#'+firefighterID).css('display', 'inline'); $('.btn-secondary', '#'+firefighterID).css('display', 'inline');
$('.btn-warning', '#'+firefighterID).css('display', 'none'); $('.btn-warning', '#'+firefighterID).css('display', 'none');
$('.btn-success', '#'+firefighterID).css('display', 'none'); $('.btn-success', '#'+firefighterID).css('display', 'none');
console.log('sukces') console.log('sukces')
@ -151,8 +155,13 @@
'trainingID': '{{$training->id}}', 'trainingID': '{{$training->id}}',
}, },
success: function(data) { success: function(data) {
$('.btn-info', '#'+firefighterID).parents("tr").find("td:eq(1)").html(''); $('.btn-secondary', '#'+firefighterID).parents("tr").find("td:eq(1)").html('');
$('.btn-info', '#'+firefighterID).parents("tr").find("td:eq(2)").html(''); $('.btn-secondary', '#'+firefighterID).parents("tr").find("td:eq(2)").html('');
$('.btn-secondary', '#'+firefighterID).css('display', 'inline');
$('.btn-warning', '#'+firefighterID).css('display', 'none');
$('.btn-success', '#'+firefighterID).css('display', 'none');
} }
}); });
} }

View File

@ -82,7 +82,7 @@ Route::post('/sprzet', 'EquipmentController@store');
Route::get('/sprzet/edit/{id}', 'EquipmentController@editForm'); Route::get('/sprzet/edit/{id}', 'EquipmentController@editForm');
Route::post('/sprzet/edit', 'EquipmentController@update'); Route::post('/sprzet/edit', 'EquipmentController@update');
Route::resource('equipment', 'EquipmentController'); Route::resource('equipment', 'EquipmentController');
Route::delete('sprzet/{id}', 'EquipmentController@destroy')->name('EquipmentController.destroy');
Route::get('/szkolenia', 'trainingsController@create'); Route::get('/szkolenia', 'trainingsController@create');
Route::post('/szkolenia', 'trainingsController@store'); Route::post('/szkolenia', 'trainingsController@store');
@ -90,6 +90,7 @@ Route::post('/szkolenia/rename', 'trainingsController@trainingsRename');
Route::get('/szkolenia/addTrainingsFireFighters/{id}', 'trainingsController@addTrainingsFireFighters'); Route::get('/szkolenia/addTrainingsFireFighters/{id}', 'trainingsController@addTrainingsFireFighters');
Route::post('/szkolenia/addTrainingsFireFighters/', 'trainingsController@ajaxRequest'); Route::post('/szkolenia/addTrainingsFireFighters/', 'trainingsController@ajaxRequest');
Route::post('/szkolenia/addTrainingsFireFighters/delete', 'trainingsController@deleteFireFighterTrainings'); Route::post('/szkolenia/addTrainingsFireFighters/delete', 'trainingsController@deleteFireFighterTrainings');
Route::delete('szkolenia/{id}', 'trainingsController@destroy')->name('trainingsController.destroy');
Route::resource('trainings', 'trainingsController'); Route::resource('trainings', 'trainingsController');
Route::get('/userprofile', 'userProfileController@create'); Route::get('/userprofile', 'userProfileController@create');