forked from s421507/eOSP2
Możliwośc zmiany nazwy szkoleń/badań
This commit is contained in:
parent
6a1804f158
commit
d25c6c6b02
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\equipment;
|
||||||
use App\trainings;
|
use App\trainings;
|
||||||
use App\trainingsFirefighters;
|
use App\trainingsFirefighters;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@ -34,6 +35,24 @@ class trainingsController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function store(){
|
||||||
|
$this->validate(request(), [
|
||||||
|
'name' => 'required',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'required' => ':attribute jest wymagany(a).',
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
$request = request();
|
||||||
|
$equipment = trainings::create([
|
||||||
|
'fireStationID' => auth()->user()->fireStationID,
|
||||||
|
'trainingName' => $request-> name,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect()->to('/szkolenia');
|
||||||
|
}
|
||||||
|
|
||||||
public function addForm(){
|
public function addForm(){
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -143,4 +162,14 @@ class trainingsController extends Controller
|
|||||||
|
|
||||||
return redirect()->to('/szkolenia');
|
return redirect()->to('/szkolenia');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function trainingsRename(Request $request){
|
||||||
|
$validator = Validator::make($request->all(), [
|
||||||
|
'trainingID' => 'required',
|
||||||
|
'trainingName' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
trainings::where('id', '=', $request->trainingID)
|
||||||
|
->update(['trainingName' => $request->trainingName]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
@extends('layout.app')
|
@extends('layout.app')
|
||||||
|
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
|
<title>Add Edit Delete Table Row Example using JQuery - ItSolutionStuff.com</title>
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" />
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@9"></script>
|
||||||
|
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||||
|
|
||||||
@section('left-menu')
|
@section('left-menu')
|
||||||
@parent
|
@parent
|
||||||
<ul>
|
<ul>
|
||||||
@ -36,17 +41,22 @@
|
|||||||
<td>Ilość z ukończonym</td>
|
<td>Ilość z ukończonym</td>
|
||||||
<td>Akcje</td>
|
<td>Akcje</td>
|
||||||
@foreach($trainings as $training)
|
@foreach($trainings as $training)
|
||||||
<tr>
|
<tr id="{{$training->id}}">
|
||||||
<form action="{{ route('trainings.destroy', $training->id)}}" method="post">
|
|
||||||
<td id="name{{ $training->id }}">{{ $training->trainingName }}</td>
|
<td id="name{{ $training->id }}">{{ $training->trainingName }}</td>
|
||||||
<td id="amount{{ $training->id }}">5</td>
|
<td id="amount{{ $training->id }}">5</td>
|
||||||
<td><input type="button" onclick="showMoreInformation('{{$training->id}}')" id="more{{$training->id}}" value="Więcej">
|
<td><input type="button" onclick="showMoreInformation('{{$training->id}}')" id="more{{$training->id}}" value="Więcej">
|
||||||
|
<button class="btn btn-info" type="submit" onclick="renameTraining('{{$training->id}}')" id="{{$training->id}}">Zmień nazwę</button>
|
||||||
<a href="{{ URL::asset('szkolenia/addTrainingsFireFighters/'.$training->id) }}"><input type="button" onclick="" value="Zarządzaj"></a>
|
<a href="{{ URL::asset('szkolenia/addTrainingsFireFighters/'.$training->id) }}"><input type="button" onclick="" value="Zarządzaj"></a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<form action="{{ route('trainings.destroy', $training->id)}}" method="post">
|
||||||
{{ csrf_field() }}
|
{{ csrf_field() }}
|
||||||
@method('DELETE')
|
@method('DELETE')
|
||||||
<button class="btn btn-danger" type="submit">Usuń</button>
|
<button class="btn btn-danger" type="submit">Usuń</button>
|
||||||
</td>
|
|
||||||
</form>
|
</form>
|
||||||
|
</td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr id="moreInformation{{$training->id}}" style="visibility:collapse;" bgcolor="#C0C0C0">
|
<tr id="moreInformation{{$training->id}}" style="visibility:collapse;" bgcolor="#C0C0C0">
|
||||||
<td colspan="3">
|
<td colspan="3">
|
||||||
@ -94,4 +104,42 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renameTraining(trainingID){
|
||||||
|
swal.fire({
|
||||||
|
title: "Podaj nową nazwę",
|
||||||
|
width: 'auto',
|
||||||
|
input: 'text',
|
||||||
|
confirmButtonText: 'Tak',
|
||||||
|
cancelButtonText: 'Anuluj',
|
||||||
|
showCancelButton: true,
|
||||||
|
inputValidator: (value) => {
|
||||||
|
if (!value) {
|
||||||
|
return 'To pole nie może zostać puste'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).then((result) => {
|
||||||
|
if(result.value){
|
||||||
|
$.ajaxSetup({
|
||||||
|
headers: {
|
||||||
|
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: 'post',
|
||||||
|
url: '/szkolenia/rename',
|
||||||
|
data: {
|
||||||
|
'trainingID': trainingID,
|
||||||
|
'trainingName': result.value,
|
||||||
|
},
|
||||||
|
success: function(data) {
|
||||||
|
$('.btn-info', '#'+trainingID).parents("tr").find("td:eq(0)").html(result.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -129,6 +129,7 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function deleteButton(firefighterID){
|
function deleteButton(firefighterID){
|
||||||
swal.fire({
|
swal.fire({
|
||||||
title: "Czy chcesz wyczyścić?",
|
title: "Czy chcesz wyczyścić?",
|
||||||
@ -162,8 +163,3 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,6 +83,7 @@ Route::resource('equipment', 'EquipmentController');
|
|||||||
|
|
||||||
Route::get('/szkolenia', 'trainingsController@create');
|
Route::get('/szkolenia', 'trainingsController@create');
|
||||||
Route::post('/szkolenia', 'trainingsController@store');
|
Route::post('/szkolenia', 'trainingsController@store');
|
||||||
|
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');
|
||||||
|
Loading…
Reference in New Issue
Block a user