1
0
forked from s421507/eOSP2

Edytowanie strazakow

This commit is contained in:
czup 2019-10-05 22:29:46 +02:00
parent 8334215767
commit d454710e87
5 changed files with 126 additions and 16 deletions

View File

@ -14,8 +14,8 @@ class fireFightersController extends Controller
public function create(){ public function create(){
if(auth()->user() != null && auth()->user()->fireStationID != null ){ if(auth()->user() != null && auth()->user()->fireStationID != null ){
// $users = DB::table('Users')->where("fireStationID", auth()->user()->fireStationID); // $users = user::where("fireStationID", auth()->user()->fireStationID)->get();
$users = user::where("fireStationID", auth()->user()->fireStationID); $users = DB::table('users')->where("fireStationID", '=', auth()->user()->fireStationID)->get();
return view("fireFighters", ["users" => $users]); return view("fireFighters", ["users" => $users]);
} else{ } else{
return view('fireFighters'); return view('fireFighters');
@ -32,6 +32,20 @@ class fireFightersController extends Controller
} else return view("unit"); } else return view("unit");
} }
public function editForm($id){
if(auth()->user() != null && auth()->user()->fireStationID != null ){
$userFireStation = auth()->user()->fireStationID;
$fireFighterFireStation = DB::table('users')->where("id", $id)->value('fireStationID');
if($userFireStation == $fireFighterFireStation) {
return view('fireFightersEdit');
} else{
return "Brak dostepu";
}
}else{
return view('unit');
}
}
public function store(){ public function store(){
$this->validate(request(), [ $this->validate(request(), [
@ -73,8 +87,6 @@ class fireFightersController extends Controller
return view('fireFighters'); return view('fireFighters');
} }
public function editFireFighter(){
}
} }

View File

@ -11,6 +11,49 @@
</ul> </ul>
@stop @stop
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
<script type="text/javascript">
{{--$(document).ready(function () {--}}
{{-- $('.editbtn').click(function () {--}}
{{-- var currentTD = $(this).parents('tr').find('td');--}}
{{-- if ($(this).html() == 'Edytuj') {--}}
{{-- $.each(currentTD, function () {--}}
{{-- getElementById("userName{{ $user->id }}".prop('contenteditable', true);--}}
{{-- });--}}
{{-- } else {--}}
{{-- $.each(currentTD, function () {--}}
{{-- $(this).prop('contenteditable', false)--}}
{{-- });--}}
{{-- }--}}
{{-- $(this).html($(this).html() == 'Edytuj' ? 'Zapisz' : 'Edytuj')--}}
{{-- });--}}
{{--});--}}
function editUser(id){
document.getElementById("userName"+id).contentEditable = "true";
document.getElementById("userSurname"+id).contentEditable = "true";
document.getElementById("userPESEL"+id).contentEditable = "true";
document.getElementById("userFunction"+id).contentEditable = "true";
document.getElementById("userDegree"+id).contentEditable = "true";
document.getElementById("userName"+id).style.backgroundColor = "#e6e6e6";
document.getElementById("userSurname"+id).style.backgroundColor = "#e6e6e6";
document.getElementById("userPESEL"+id).style.backgroundColor = "#e6e6e6";
document.getElementById("userFunction"+id).style.backgroundColor = "#e6e6e6";
document.getElementById("userDegree"+id).style.backgroundColor = "#e6e6e6";
}
</script>
</head>
@section('center-area') @section('center-area')
@parent @parent
@if( auth()->check()) @if( auth()->check())
@ -20,7 +63,8 @@
<table class='firefighterViewTable'> <table class='firefighterViewTable'>
<tr class='table-header'> <tr class='table-header'>
<td>Imie i nazwisko</td> <td>Imie</td>
<td>Nazwisko</td>
<td>PESEL</td> <td>PESEL</td>
<td>E-mail</td> <td>E-mail</td>
<td>Funkcja</td> <td>Funkcja</td>
@ -28,16 +72,19 @@
<td>Status</td> <td>Status</td>
</tr> </tr>
<tr> @foreach($users as $user)
@foreach($users as $user) <tr>
<td>{{ $user->name }} surname</td> <td id="userName{{ $user->id }}">{{ $user->name }}</td>
<td>???????????</td> <td id="userSurname{{ $user->id }}">{{ $user->surname }}</td>
<td>przykladowymail@domena.com</td> <td id="userPESEL{{ $user->id }}">{{ $user->PESEL }}</td>
<td>Zast. Naczelnika</td> <td id="userEmail{{ $user->id }}">{{ $user->email }}</td>
<td>Dowódca</td> <td id="userFunction{{ $user->id }}">Zast. Naczelnika</td>
<td>Czynny</td> <td id="userDegree{{ $user->id }}">Dowódca</td>
@endforeach <td id="userStatus{{ $user->id }}">@if( $user->statusID == 0) Czynny @else Wyłączony @endif</td>
</tr>" {{-- <td><a href="{{ URL::asset('strazacy/edit/'.$user->id) }}">Edytuj<input type="button" onclick="add({{$user->id}})" value="Edytuj"> </a></td>--}}
<td><button class="editbtn" onclick="editUser({{$user->id}})">Edytuj</button></td>
</tr>
@endforeach
</table>" </table>"
@endif @endif
@ -47,3 +94,7 @@
@stop @stop

View File

@ -1 +1,44 @@
<?php @extends('layout.app')
@section('left-menu')
@parent
<ul>
<a href="/strazacy/add"><li>Dodaj<img src="img/left_menu_icon/add.png"></li></a>
<li>Edytuj<img src="img/left_menu_icon/edit.png"></li>
<li>Wyklucz<img src="img/left_menu_icon/delete.png"></li>
<li>Zawieś<img src="img/left_menu_icon/suspended.png"></li>
<li>Więcej<img src="img/left_menu_icon/more.png"></li>
</ul>
@stop
@section('center-area')
@parent
<form method="POST" action="/strazacy/edit">
{{ 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>
<div class="form-group">
<label for="name">Nazwisko:</label>
<input type="text" class="form-control" id="surname" name="surname" value="{{ old('surname') }}">
</div>
<div class="form-group">
<label for="name">Pesel:</label>
<input type="text" class="form-control" id="PESEL" name="PESEL" value="{{ old('PESEL') }}">
</div>
<div class="form-group">
<label for="name">Numer telefonu:</label>
<input type="text" class="form-control" id="phoneNumber" name="phoneNumber" value="{{ old('phoneNumber') }}">
</div>
<div class="form-group">
<button style="cursor:pointer" type="submit" class="btn btn-primary">Edytuj</button>
</div>
@include('inc.formerrors')
</form>
@stop

View File

@ -5,6 +5,7 @@
<title>E-OSP</title> <title>E-OSP</title>
<link rel="stylesheet" href="{{ asset('css/theme.css') }}"> <link rel="stylesheet" href="{{ asset('css/theme.css') }}">
<meta charset="UTF-8"> <meta charset="UTF-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
</head> </head>
<body> <body>
@if( auth()->check() ) @if( auth()->check() )

View File

@ -47,6 +47,8 @@ Route::get('/logout', 'SessionsController@destroy');
Route::get('/strazacy', 'fireFightersController@create'); Route::get('/strazacy', 'fireFightersController@create');
Route::get('/strazacy/add', 'fireFightersController@addForm'); Route::get('/strazacy/add', 'fireFightersController@addForm');
Route::post('/strazacy', 'fireFightersController@store'); Route::post('/strazacy', 'fireFightersController@store');
Route::get('/strazacy/edit/{id}', 'fireFightersController@editForm');
//Route::post('/strazacy/edit', '');
Route::get('/jednostka', 'fireStationController@create'); Route::get('/jednostka', 'fireStationController@create');
Route::post('/jednostka', 'fireStationController@store'); Route::post('/jednostka', 'fireStationController@store');
@ -54,6 +56,7 @@ Route::post('/jednostka', 'fireStationController@store');
Route::get('/jednostka/getcounties/{id}','DataController@getCounties'); Route::get('/jednostka/getcounties/{id}','DataController@getCounties');
Route::get('/jednostka/getcommunities/{id}','DataController@getCommunities'); Route::get('/jednostka/getcommunities/{id}','DataController@getCommunities');
//Auth::routes(); //Auth::routes();
// //
//Route::get('/home', 'HomeController@index')->name('home'); //Route::get('/home', 'HomeController@index')->name('home');