forked from s421507/eOSP2
pojazdy, odznaczenia - żądanie potwiedzenie usunięcia
This commit is contained in:
parent
91e58e2187
commit
2c025bb535
@ -67,6 +67,8 @@ class DecorationsController extends Controller
|
||||
{
|
||||
decorationsFirefighters::where('id',$id)->delete();
|
||||
|
||||
return back();
|
||||
return response()->json([
|
||||
'success' => 'Record deleted successfully!'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -175,7 +175,9 @@ class VehiclesController extends Controller
|
||||
public function destroy($id)
|
||||
{
|
||||
vehicle::where('id',$id)->delete();
|
||||
return redirect()->to('/pojazdy');
|
||||
return response()->json([
|
||||
'success' => 'Record deleted successfully!'
|
||||
]);
|
||||
}
|
||||
|
||||
public function activate()
|
||||
|
@ -1,5 +1,7 @@
|
||||
@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>
|
||||
@ -7,6 +9,7 @@
|
||||
</ul>
|
||||
@stop
|
||||
@section('center-area')
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
@parent
|
||||
|
||||
@if( auth()->check())
|
||||
@ -28,15 +31,11 @@
|
||||
<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>
|
||||
<button class="btn btn-danger" type="submit" id="{{$awardedDecoration->decorationsFirefightersID}}" onclick="deleteButton('{{$awardedDecoration->decorationsFirefightersID}}')">Usuń</button>
|
||||
</td>
|
||||
</form>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
@ -77,3 +76,38 @@
|
||||
@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>
|
@ -1,6 +1,7 @@
|
||||
@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>
|
||||
|
@ -1,5 +1,7 @@
|
||||
@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>
|
||||
@ -8,6 +10,7 @@
|
||||
@stop
|
||||
|
||||
@section('center-area')
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
@parent
|
||||
@if( auth()->check())
|
||||
@if( auth()->user()->fireStationID == NULL)
|
||||
@ -39,7 +42,6 @@
|
||||
@endphp
|
||||
|
||||
<tr>
|
||||
<form action="{{ route('vehicles.destroy', $vehicle->id)}}" method="post">
|
||||
<td>{{ $lp }}</td>
|
||||
<td id="name{{ $vehicle->id }}">{{ $vehicle->name }}</td>
|
||||
<td id="brand{{ $vehicle->id }}">{{ $vehicle->brand }}</td>
|
||||
@ -51,10 +53,7 @@
|
||||
<td id="insuranceExpirationDate{{ $vehicle->id }}">{{ $vehicle->insuranceExpirationDate }}</td>
|
||||
<td style="display:inline;">
|
||||
<a href="{{ URL::asset('pojazdy/edit/'.$vehicle->id) }}" class="btn btn-secondary" role="button">Edytuj</a>
|
||||
{{ csrf_field() }}
|
||||
@method('DELETE')
|
||||
<button class="btn btn-danger" type="submit">Usuń</button>
|
||||
</form>
|
||||
<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() }}
|
||||
@ -79,3 +78,39 @@
|
||||
Brak autoryzacji
|
||||
@endif
|
||||
@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();
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
</script>
|
@ -58,6 +58,7 @@ Route::post('/strazacy/edit', 'fireFightersController@update');
|
||||
Route::get('/strazacy/odznaczenia/{id}', 'DecorationsController@create');
|
||||
Route::post('/strazacy/odznaczenia/{id}', 'DecorationsController@store');
|
||||
Route::resource('decorations', 'DecorationsController');
|
||||
Route::delete('/strazacy/odznaczenia/delete/{id}', 'DecorationsController@destroy')->name('DecorationsController.destroy');
|
||||
|
||||
Route::get('/jednostka', 'fireStationController@create');
|
||||
Route::post('/jednostka', 'fireStationController@store');
|
||||
@ -75,6 +76,7 @@ Route::post('/pojazdy/edit', 'VehiclesController@update');
|
||||
Route::resource('vehicles', 'VehiclesController');
|
||||
Route::post('pojazdy/activate', 'VehiclesController@activate');
|
||||
Route::post('pojazdy/deactivate', 'VehiclesController@deactivate');
|
||||
Route::delete('pojazdy/{id}', 'VehiclesController@destroy')->name('VehiclesController.destroy');
|
||||
|
||||
Route::get('/sprzet', 'EquipmentController@create');
|
||||
Route::get('/sprzet/add', 'EquipmentController@addForm');
|
||||
|
Loading…
Reference in New Issue
Block a user