Edytowanie strazakow
This commit is contained in:
parent
8334215767
commit
d454710e87
@ -14,8 +14,8 @@ class fireFightersController extends Controller
|
||||
public function create(){
|
||||
|
||||
if(auth()->user() != null && auth()->user()->fireStationID != null ){
|
||||
// $users = DB::table('Users')->where("fireStationID", auth()->user()->fireStationID);
|
||||
$users = user::where("fireStationID", auth()->user()->fireStationID);
|
||||
// $users = user::where("fireStationID", auth()->user()->fireStationID)->get();
|
||||
$users = DB::table('users')->where("fireStationID", '=', auth()->user()->fireStationID)->get();
|
||||
return view("fireFighters", ["users" => $users]);
|
||||
} else{
|
||||
return view('fireFighters');
|
||||
@ -32,6 +32,20 @@ class fireFightersController extends Controller
|
||||
} 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(){
|
||||
$this->validate(request(), [
|
||||
|
||||
@ -73,8 +87,6 @@ class fireFightersController extends Controller
|
||||
return view('fireFighters');
|
||||
}
|
||||
|
||||
public function editFireFighter(){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,49 @@
|
||||
</ul>
|
||||
@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')
|
||||
@parent
|
||||
@if( auth()->check())
|
||||
@ -20,7 +63,8 @@
|
||||
|
||||
<table class='firefighterViewTable'>
|
||||
<tr class='table-header'>
|
||||
<td>Imie i nazwisko</td>
|
||||
<td>Imie</td>
|
||||
<td>Nazwisko</td>
|
||||
<td>PESEL</td>
|
||||
<td>E-mail</td>
|
||||
<td>Funkcja</td>
|
||||
@ -28,16 +72,19 @@
|
||||
<td>Status</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@foreach($users as $user)
|
||||
<td>{{ $user->name }} surname</td>
|
||||
<td>???????????</td>
|
||||
<td>przykladowymail@domena.com</td>
|
||||
<td>Zast. Naczelnika</td>
|
||||
<td>Dowódca</td>
|
||||
<td>Czynny</td>
|
||||
@endforeach
|
||||
</tr>"
|
||||
@foreach($users as $user)
|
||||
<tr>
|
||||
<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 }}">Zast. Naczelnika</td>
|
||||
<td id="userDegree{{ $user->id }}">Dowódca</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) }}">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>"
|
||||
|
||||
@endif
|
||||
@ -47,3 +94,7 @@
|
||||
|
||||
|
||||
@stop
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -5,6 +5,7 @@
|
||||
<title>E-OSP</title>
|
||||
<link rel="stylesheet" href="{{ asset('css/theme.css') }}">
|
||||
<meta charset="UTF-8">
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
@if( auth()->check() )
|
||||
|
@ -47,6 +47,8 @@ Route::get('/logout', 'SessionsController@destroy');
|
||||
Route::get('/strazacy', 'fireFightersController@create');
|
||||
Route::get('/strazacy/add', 'fireFightersController@addForm');
|
||||
Route::post('/strazacy', 'fireFightersController@store');
|
||||
Route::get('/strazacy/edit/{id}', 'fireFightersController@editForm');
|
||||
//Route::post('/strazacy/edit', '');
|
||||
|
||||
Route::get('/jednostka', 'fireStationController@create');
|
||||
Route::post('/jednostka', 'fireStationController@store');
|
||||
@ -54,6 +56,7 @@ Route::post('/jednostka', 'fireStationController@store');
|
||||
Route::get('/jednostka/getcounties/{id}','DataController@getCounties');
|
||||
Route::get('/jednostka/getcommunities/{id}','DataController@getCommunities');
|
||||
|
||||
|
||||
//Auth::routes();
|
||||
//
|
||||
//Route::get('/home', 'HomeController@index')->name('home');
|
||||
|
Loading…
Reference in New Issue
Block a user