1
0
forked from s421507/eOSP2

pojazdy, odznaczenia - żądanie potwiedzenie usunięcia

This commit is contained in:
Krzysztof Strzelecki 2020-01-31 16:45:01 +01:00
parent 91e58e2187
commit 2c025bb535
6 changed files with 88 additions and 12 deletions

View File

@ -67,6 +67,8 @@ class DecorationsController extends Controller
{ {
decorationsFirefighters::where('id',$id)->delete(); decorationsFirefighters::where('id',$id)->delete();
return back(); return response()->json([
'success' => 'Record deleted successfully!'
]);
} }
} }

View File

@ -175,7 +175,9 @@ class VehiclesController extends Controller
public function destroy($id) public function destroy($id)
{ {
vehicle::where('id',$id)->delete(); vehicle::where('id',$id)->delete();
return redirect()->to('/pojazdy'); return response()->json([
'success' => 'Record deleted successfully!'
]);
} }
public function activate() public function activate()

View File

@ -1,5 +1,7 @@
@extends('layout.app') @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') @section('left-menu')
@parent @parent
<ul> <ul>
@ -7,6 +9,7 @@
</ul> </ul>
@stop @stop
@section('center-area') @section('center-area')
<meta name="csrf-token" content="{{ csrf_token() }}">
@parent @parent
@if( auth()->check()) @if( auth()->check())
@ -28,15 +31,11 @@
<th>Operacja</th> <th>Operacja</th>
@foreach($awardedDecorations as $awardedDecoration) @foreach($awardedDecorations as $awardedDecoration)
<tr> <tr>
<form action="{{ route('decorations.destroy', $awardedDecoration->decorationsFirefightersID)}}" method="post">
<td id="decorationName{{ $awardedDecoration->decorationsFirefightersID }}">{{ $awardedDecoration->decorationName }}</td> <td id="decorationName{{ $awardedDecoration->decorationsFirefightersID }}">{{ $awardedDecoration->decorationName }}</td>
<td id="dateOfAward{{ $awardedDecoration->decorationsFirefightersID }}">{{ $awardedDecoration->dateOfAward }}</td> <td id="dateOfAward{{ $awardedDecoration->decorationsFirefightersID }}">{{ $awardedDecoration->dateOfAward }}</td>
<td> <td>
{{ csrf_field() }} <button class="btn btn-danger" type="submit" id="{{$awardedDecoration->decorationsFirefightersID}}" onclick="deleteButton('{{$awardedDecoration->decorationsFirefightersID}}')">Usuń</button>
@method('DELETE')
<button class="btn btn-danger" type="submit">Usuń</button>
</td> </td>
</form>
</tr> </tr>
@endforeach @endforeach
</tbody> </tbody>
@ -77,3 +76,38 @@
@endif @endif
@stop @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>

View File

@ -1,6 +1,7 @@
@extends('layout.app') @extends('layout.app')
<meta name="csrf-token" content="{{ csrf_token() }}"> <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') @section('left-menu')
@parent @parent
<ul> <ul>

View File

@ -1,5 +1,7 @@
@extends('layout.app') @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') @section('left-menu')
@parent @parent
<ul> <ul>
@ -8,6 +10,7 @@
@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)
@ -39,7 +42,6 @@
@endphp @endphp
<tr> <tr>
<form action="{{ route('vehicles.destroy', $vehicle->id)}}" method="post">
<td>{{ $lp }}</td> <td>{{ $lp }}</td>
<td id="name{{ $vehicle->id }}">{{ $vehicle->name }}</td> <td id="name{{ $vehicle->id }}">{{ $vehicle->name }}</td>
<td id="brand{{ $vehicle->id }}">{{ $vehicle->brand }}</td> <td id="brand{{ $vehicle->id }}">{{ $vehicle->brand }}</td>
@ -51,10 +53,7 @@
<td id="insuranceExpirationDate{{ $vehicle->id }}">{{ $vehicle->insuranceExpirationDate }}</td> <td id="insuranceExpirationDate{{ $vehicle->id }}">{{ $vehicle->insuranceExpirationDate }}</td>
<td style="display:inline;"> <td style="display:inline;">
<a href="{{ URL::asset('pojazdy/edit/'.$vehicle->id) }}" class="btn btn-secondary" role="button">Edytuj</a> <a href="{{ URL::asset('pojazdy/edit/'.$vehicle->id) }}" class="btn btn-secondary" role="button">Edytuj</a>
{{ csrf_field() }} <button class="btn btn-danger" type="submit" id="{{$vehicle->id}}" onclick="deleteButton('{{$vehicle->id}}')">Usuń</button>
@method('DELETE')
<button class="btn btn-danger" type="submit">Usuń</button>
</form>
@if ($vehicle->status == 1) @if ($vehicle->status == 1)
<form method="POST" action="/pojazdy/deactivate" style="display:inline;"> <form method="POST" action="/pojazdy/deactivate" style="display:inline;">
{{ csrf_field() }} {{ csrf_field() }}
@ -79,3 +78,39 @@
Brak autoryzacji Brak autoryzacji
@endif @endif
@stop @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>

View File

@ -58,6 +58,7 @@ Route::post('/strazacy/edit', 'fireFightersController@update');
Route::get('/strazacy/odznaczenia/{id}', 'DecorationsController@create'); Route::get('/strazacy/odznaczenia/{id}', 'DecorationsController@create');
Route::post('/strazacy/odznaczenia/{id}', 'DecorationsController@store'); Route::post('/strazacy/odznaczenia/{id}', 'DecorationsController@store');
Route::resource('decorations', 'DecorationsController'); Route::resource('decorations', 'DecorationsController');
Route::delete('/strazacy/odznaczenia/delete/{id}', 'DecorationsController@destroy')->name('DecorationsController.destroy');
Route::get('/jednostka', 'fireStationController@create'); Route::get('/jednostka', 'fireStationController@create');
Route::post('/jednostka', 'fireStationController@store'); Route::post('/jednostka', 'fireStationController@store');
@ -75,6 +76,7 @@ Route::post('/pojazdy/edit', 'VehiclesController@update');
Route::resource('vehicles', 'VehiclesController'); Route::resource('vehicles', 'VehiclesController');
Route::post('pojazdy/activate', 'VehiclesController@activate'); Route::post('pojazdy/activate', 'VehiclesController@activate');
Route::post('pojazdy/deactivate', 'VehiclesController@deactivate'); Route::post('pojazdy/deactivate', 'VehiclesController@deactivate');
Route::delete('pojazdy/{id}', 'VehiclesController@destroy')->name('VehiclesController.destroy');
Route::get('/sprzet', 'EquipmentController@create'); Route::get('/sprzet', 'EquipmentController@create');
Route::get('/sprzet/add', 'EquipmentController@addForm'); Route::get('/sprzet/add', 'EquipmentController@addForm');