dokończenie poziomów dostępu i przekierowań

This commit is contained in:
Krzysztof Strzelecki 2020-02-01 01:01:26 +01:00
parent 079343fe1d
commit 0713cd5a68
8 changed files with 50 additions and 19 deletions

View File

@ -21,7 +21,7 @@ function formatDate($date)
class DecorationsController extends Controller
{
public function create($id){
if(auth()->user() != null && auth()->user()->fireStationID != null ){
if(auth()->user() != null && auth()->user()->accessLevel() == 50 ){ //prezes,naczelnik
$awardedDecorations = DB::table('decorationsFirefighters')->where("decorationsFirefighters.firefighterID", '=', $id)
->whereNull('decorationsFirefighters.deleted_at')
->leftJoin('decorations', 'decorationsFirefighters.decorationID', '=', 'decorations.id')
@ -39,7 +39,7 @@ class DecorationsController extends Controller
->with(compact('decoration'));
} else{
return "Brak dostepu";
return redirect()->to('/strazacy');
}
}

View File

@ -21,15 +21,15 @@ class EquipmentController extends Controller
}
public function addForm(){
if(auth()->user() != null && auth()->user()->fireStationID != null ){
if(auth()->user() != null && auth()->user()->accessLevel() == 50 ){ //prezes,naczelnik
return view('equipmentAdd');
} else return view("login");
} else return redirect()->to('/sprzet');
}
public function editForm($id)
{
if(auth()->user() != null && auth()->user()->fireStationID != null )
if(auth()->user() != null && auth()->user()->accessLevel() == 50 ) //prezes,naczelnik
{
$equipment = DB::table('equipment')->where("id", $id)->first();
@ -37,7 +37,7 @@ class EquipmentController extends Controller
return view('equipmentEdit', ["equipment" => $equipment]);
}
else
return view("login");
return redirect()->to('/sprzet');
}

View File

@ -31,21 +31,21 @@ class VehiclesController extends Controller
}
public function addForm(){
if(auth()->user() != null && auth()->user()->fireStationID != null ){
if(auth()->user() != null && auth()->user()->accessLevel() == 50 ){ //prezes,naczelnik
return view('vehiclesAdd');
} else return view("login");
} else return redirect()->to('/pojazdy');
}
public function editForm($id)
{
if(auth()->user() != null && auth()->user()->fireStationID != null )
if(auth()->user() != null && auth()->user()->accessLevel() == 50 ) //prezes,naczelnik
{
$vehicle = DB::table('vehicles')->where("id", $id)->first();
return view('vehiclesEdit', ["vehicle" => $vehicle]);
}
else
return "Brak dostepu";
redirect()->to('/pojazdy');
}
public function store(){

View File

@ -58,7 +58,7 @@ class operationsController extends Controller
}
public function addForm(){
if(auth()->user() != null && auth()->user()->fireStationID != null ){
if(auth()->user() != null && auth()->user()->accessLevel() == 50 ){ //prezes,naczelnik
$fireFighters = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID )->get();
$vehicles = DB::table('vehicles')->where([
["fireStationID", '=', auth()->user()->fireStationID],
@ -67,13 +67,13 @@ class operationsController extends Controller
])
->get();
return view("operationAdd", ["fireFighters" => $fireFighters], ["vehicles" => $vehicles]);
} else return view("unit");
} else return redirect()->to('/wyjazdy');
}
public function editForm($id){
if(auth()->user() != null && auth()->user()->fireStationID != null ){
if(auth()->user() != null && auth()->user()->accessLevel() == 50 ){ //prezes,naczelnik
// $fireFighters = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID )->get();
$vehicles = DB::table('vehicles')->where([
@ -118,7 +118,7 @@ class operationsController extends Controller
// return "Brak dostepu";
// }
} else{
return view('unit');
return redirect()->to('/wyjazdy');
}
}

View File

@ -14,7 +14,7 @@ class trainingsController extends Controller
{
public function create(){
if(auth()->user() != null && auth()->user()->fireStationID != null ){
if(auth()->user() != null && auth()->user()->accessLevel() == 50 ){ //prezes,naczelnik
$trainings = DB::table('trainings')->where("fireStationID", '=', auth()->user()->fireStationID)
->whereNull('deleted_at')
->paginate(10);
@ -32,7 +32,7 @@ class trainingsController extends Controller
}
return View::make("trainings")->with(compact( "trainings", "fireFighters"));
} else{
return view('trainings');
return redirect()->to('/strazacy');
}
}
@ -61,7 +61,7 @@ class trainingsController extends Controller
public function addTrainingsFireFighters($id){
if(auth()->user() != null && auth()->user()->fireStationID != null ){
if(auth()->user() != null && auth()->user()->accessLevel() == 50 ){ //prezes,naczelnik
$fireFighters = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID )
->leftJoin('trainingsFirefighters', function ($join) use($id){
$join->on('users.id', '=', 'trainingsFirefighters.firefighterID');
@ -74,7 +74,7 @@ class trainingsController extends Controller
->whereNull('deleted_at')->first();
return View::make("trainingsAddFireFighters")->with(compact( "training", "fireFighters"));
} else{
return view('trainings');
return redirect()->to('/strazacy');
}
}

View File

@ -4,9 +4,15 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
@section('left-menu')
@parent
@if( auth()->check() )
@if( auth()->user()->fireStationID != NULL)
@if(auth()->user()->accessLevel() == 50)
<ul>
<a href="sprzet/add"><li>Dodaj<img src="/img/left_menu_icon/add.png"></li></a>
</ul>
@endif
@endif
@endif
@stop
@section('center-area')
@ -25,7 +31,9 @@
<th>Nazwa</th>
<th>Ilość</th>
<th>Param. charakterystyczny</th>
@if(auth()->user()->accessLevel() == 50)
<th>Operacja</th>
@endif
</tr>
</thead>
@ -38,10 +46,12 @@
<td id="name{{ $item->id }}">{{ $item->name }}</td>
<td id="amount{{ $item->id }}">{{ $item->amount }}</td>
<td id="parameter{{ $item->id }}">{{ $item->parameter }}</td>
@if(auth()->user()->accessLevel() == 50)
<td>
<a href="{{ URL::asset('sprzet/edit/'.$item->id) }}" class="btn btn-secondary" role="button">Edytuj</a>
<button class="btn btn-danger" type="submit" id="{{$item->id}}" onclick="deleteButton('{{$item->id}}')">Usuń</button>
</td>
@endif
</tr>
@php

View File

@ -3,9 +3,16 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
@section('left-menu')
@parent<ul>
@parent
@if( auth()->check() )
@if( auth()->user()->fireStationID != NULL)
@if(auth()->user()->accessLevel() == 50)
<ul>
<a href="/wyjazdy/add"><li>Dodaj<img src="/img/left_menu_icon/add.png"></li></a>
</ul>
@endif
@endif
@endif
@stop
@section('center-area')
@ -24,7 +31,9 @@
<th>Cel</th>
<th>Rodzaj zagrożenia</th>
<th>Dowódca</th>
@if(auth()->user()->accessLevel() == 50)
<th>Operacja</th>
@endif
<th>Szczegóły</th> <tbody>
</tr>
@ -41,10 +50,12 @@
<td id="operationTarget{{ $operation->id }}">{{ $operation->target }}</td>
<td id="operationDangerType{{ $operation->id }}">{{ $operation->dangerType }}</td>
<td id="operationCommander{{ $operation->id }}">{{$operation->name}} {{$operation->surname}}</td>
@if(auth()->user()->accessLevel() == 50)
<td>
<a href="{{ URL::asset('wyjazdy/edit/'.$operation->id) }}" class="btn btn-secondary" role="button">Edytuj</a>
<button class="btn btn-danger" type="submit" id="{{$operation->id}}" onclick="deleteButton('{{$operation->id}}')">Usuń</button>
</td>
@endif
<td>
<button class="btn btn-info" type="button" id="more{{$operation->id}}" onclick="showMoreInformation('{{$operation->id}}')">Więcej</button>
</td>

View File

@ -4,9 +4,15 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
@section('left-menu')
@parent
@if( auth()->check() )
@if( auth()->user()->fireStationID != NULL)
@if(auth()->user()->accessLevel() == 50)
<ul>
<a href="/pojazdy/add"><li>Dodaj<img src="img/left_menu_icon/add.png"></li></a>
</ul>
@endif
@endif
@endif
@stop
@section('center-area')
@ -29,7 +35,9 @@
<th>Rodzaj napędu</th>
<th>Przegląd</th>
<th>OC</th>
@if(auth()->user()->accessLevel() == 50)
<th>Operacja</th>
@endif
</tr>
</thead>
@ -51,6 +59,7 @@
<td id="driveType{{ $vehicle->id }}">{{ $vehicle->driveType }}</td>
<td id="examExpirationDate{{ $vehicle->id }}">{{ $vehicle->examExpirationDate }}</td>
<td id="insuranceExpirationDate{{ $vehicle->id }}">{{ $vehicle->insuranceExpirationDate }}</td>
@if(auth()->user()->accessLevel() == 50)
<td style="display:inline;">
<a href="{{ URL::asset('pojazdy/edit/'.$vehicle->id) }}" class="btn btn-secondary" role="button">Edytuj</a>
<button class="btn btn-danger" type="submit" id="{{$vehicle->id}}" onclick="deleteButton('{{$vehicle->id}}')">Usuń</button>
@ -69,6 +78,7 @@
@endif
</td>
@endif
</tr>
@endforeach
</table>