Wyjazdy - zawężenie list strażaków do tych, którzy mają stosowne szkolenia
This commit is contained in:
parent
32486d50b0
commit
1b0c7bc916
@ -16,9 +16,15 @@ use Illuminate\Support\Facades\View;
|
|||||||
|
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
const basicTrainingID = 1; //szkolenie podstawowe
|
||||||
|
const leaderTrainingID = 2; //szkolenie dowódcy
|
||||||
|
const driverTrainingID = 3; //szkolenie kierowcy-mechanika
|
||||||
|
|
||||||
class operationsController extends Controller
|
class operationsController extends Controller
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
public function create(){
|
public function create(){
|
||||||
if(auth()->user() != null && auth()->user()->fireStationID != null ){
|
if(auth()->user() != null && auth()->user()->fireStationID != null ){
|
||||||
$operations = DB::table('operations')->where('operations.fireStationID', "=", auth()->user()->fireStationID)
|
$operations = DB::table('operations')->where('operations.fireStationID', "=", auth()->user()->fireStationID)
|
||||||
@ -61,14 +67,34 @@ class operationsController extends Controller
|
|||||||
|
|
||||||
public function addForm(){
|
public function addForm(){
|
||||||
if(auth()->user() != null && auth()->user()->accessLevel() == 50 ){ //prezes,naczelnik
|
if(auth()->user() != null && auth()->user()->accessLevel() == 50 ){ //prezes,naczelnik
|
||||||
$fireFighters = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID )->get();
|
$fireFighters = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID )
|
||||||
|
->leftJoin('trainingsFirefighters', 'trainingsFirefighters.firefighterID', '=', 'users.id')
|
||||||
|
->where('trainingsFirefighters.trainingID', '=', basicTrainingID)
|
||||||
|
->select('users.*')
|
||||||
|
->get();
|
||||||
|
$leaders = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID )
|
||||||
|
->leftJoin('trainingsFirefighters', 'trainingsFirefighters.firefighterID', '=', 'users.id')
|
||||||
|
->where('trainingsFirefighters.trainingID', '=', leaderTrainingID)
|
||||||
|
->select('users.*')
|
||||||
|
->get();
|
||||||
|
$drivers = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID )
|
||||||
|
->leftJoin('trainingsFirefighters', 'trainingsFirefighters.firefighterID', '=', 'users.id')
|
||||||
|
->where('trainingsFirefighters.trainingID', '=', driverTrainingID)
|
||||||
|
->select('users.*')
|
||||||
|
->get();
|
||||||
$vehicles = DB::table('vehicles')->where([
|
$vehicles = DB::table('vehicles')->where([
|
||||||
["fireStationID", '=', auth()->user()->fireStationID],
|
["fireStationID", '=', auth()->user()->fireStationID],
|
||||||
["vehicles.status", "=", 1],
|
["vehicles.status", "=", 1],
|
||||||
["vehicles.deleted_at", "=", null],
|
["vehicles.deleted_at", "=", null],
|
||||||
])
|
])
|
||||||
->get();
|
->get();
|
||||||
return view("operationAdd", ["fireFighters" => $fireFighters], ["vehicles" => $vehicles]);
|
//return view("operationAdd", ["fireFighters" => $fireFighters], ["vehicles" => $vehicles]);
|
||||||
|
return view("operationAdd")
|
||||||
|
->with(compact('fireFighters'))
|
||||||
|
->with(compact('leaders'))
|
||||||
|
->with(compact('drivers'))
|
||||||
|
->with(compact('vehicles'));
|
||||||
|
|
||||||
} else return redirect()->to('/wyjazdy');
|
} else return redirect()->to('/wyjazdy');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +106,7 @@ class operationsController extends Controller
|
|||||||
// $fireFighters = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID )->get();
|
// $fireFighters = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID )->get();
|
||||||
$vehicles = DB::table('vehicles')->where([
|
$vehicles = DB::table('vehicles')->where([
|
||||||
["fireStationID", '=', auth()->user()->fireStationID],
|
["fireStationID", '=', auth()->user()->fireStationID],
|
||||||
["vehicles.deleted_at", "=", null]
|
//["vehicles.status", "=", 1],
|
||||||
])
|
])
|
||||||
->get();
|
->get();
|
||||||
$operation = DB::table('operations')->where('operations.id', '=', $id)->first();
|
$operation = DB::table('operations')->where('operations.id', '=', $id)->first();
|
||||||
@ -90,6 +116,26 @@ class operationsController extends Controller
|
|||||||
// ->select('operations.id', 'operations.operationDate', 'operations.location', 'operations.target', 'operations.dangerType', 'operations.description', 'operations.commanderID', 'operations.fireStationID', 'users.id', 'users.name', 'users.surname')
|
// ->select('operations.id', 'operations.operationDate', 'operations.location', 'operations.target', 'operations.dangerType', 'operations.description', 'operations.commanderID', 'operations.fireStationID', 'users.id', 'users.name', 'users.surname')
|
||||||
// ->get();
|
// ->get();
|
||||||
$fireFighters = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID )
|
$fireFighters = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID )
|
||||||
|
->leftJoin('trainingsFirefighters', 'trainingsFirefighters.firefighterID', '=', 'users.id')
|
||||||
|
->where('trainingsFirefighters.trainingID', '=', basicTrainingID)
|
||||||
|
->leftJoin('operationsMembers', function ($join) use($id){
|
||||||
|
$join->on('users.id', '=', 'operationsMembers.memberID');
|
||||||
|
$join->where('operationsMembers.operationID', '=', $id);
|
||||||
|
})
|
||||||
|
->select('users.*', 'operationsMembers.memberID', 'operationsMembers.privateTransport')
|
||||||
|
->get();
|
||||||
|
$drivers = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID )
|
||||||
|
->leftJoin('trainingsFirefighters', 'trainingsFirefighters.firefighterID', '=', 'users.id')
|
||||||
|
->where('trainingsFirefighters.trainingID', '=', driverTrainingID)
|
||||||
|
->leftJoin('operationsMembers', function ($join) use($id){
|
||||||
|
$join->on('users.id', '=', 'operationsMembers.memberID');
|
||||||
|
$join->where('operationsMembers.operationID', '=', $id);
|
||||||
|
})
|
||||||
|
->select('users.*', 'operationsMembers.memberID', 'operationsMembers.privateTransport')
|
||||||
|
->get();
|
||||||
|
$leaders = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID )
|
||||||
|
->leftJoin('trainingsFirefighters', 'trainingsFirefighters.firefighterID', '=', 'users.id')
|
||||||
|
->where('trainingsFirefighters.trainingID', '=', leaderTrainingID)
|
||||||
->leftJoin('operationsMembers', function ($join) use($id){
|
->leftJoin('operationsMembers', function ($join) use($id){
|
||||||
$join->on('users.id', '=', 'operationsMembers.memberID');
|
$join->on('users.id', '=', 'operationsMembers.memberID');
|
||||||
$join->where('operationsMembers.operationID', '=', $id);
|
$join->where('operationsMembers.operationID', '=', $id);
|
||||||
@ -115,7 +161,7 @@ class operationsController extends Controller
|
|||||||
|
|
||||||
// if($userFireStation == $fireFighterFireStation && auth()->user()->id == $fireStationCreatorId) {
|
// if($userFireStation == $fireFighterFireStation && auth()->user()->id == $fireStationCreatorId) {
|
||||||
// return view('operationEdit', ["operation" => $operation], ["fireFighters" => $fireFighters], ["operationMembers" => $operationMembers] );
|
// return view('operationEdit', ["operation" => $operation], ["fireFighters" => $fireFighters], ["operationMembers" => $operationMembers] );
|
||||||
return View::make('/operationEdit')->with(compact('fireFighters','operation', 'operationMembers', 'vehicles', 'operationsTrucks'));
|
return View::make('/operationEdit')->with(compact('fireFighters', 'drivers', 'leaders', 'operation', 'operationMembers', 'vehicles', 'operationsTrucks'));
|
||||||
// } else{
|
// } else{
|
||||||
// return "Brak dostepu";
|
// return "Brak dostepu";
|
||||||
// }
|
// }
|
||||||
@ -166,13 +212,15 @@ class operationsController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Add members
|
// Add members
|
||||||
$attendance = $request-> attendance;
|
$attendance = $request-> attendance;
|
||||||
$transport = $request-> transport;
|
$transport = $request-> transport;
|
||||||
|
|
||||||
// Count of firefighters (need for length of array)
|
// Count of firefighters (need for length of array)
|
||||||
$fireFightersCount = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID )->count();
|
$fireFightersCount = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID )
|
||||||
|
->leftJoin('trainingsFirefighters', 'trainingsFirefighters.firefighterID', '=', 'users.id')
|
||||||
|
->where('trainingsFirefighters.trainingID', '=', basicTrainingID)
|
||||||
|
->count();
|
||||||
for($count = 0; $count < $fireFightersCount; $count++){
|
for($count = 0; $count < $fireFightersCount; $count++){
|
||||||
|
|
||||||
// Check privateTransport checklist
|
// Check privateTransport checklist
|
||||||
@ -267,7 +315,7 @@ class operationsController extends Controller
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return operationsController::create();
|
return redirect()->to('/wyjazdy');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function destroy($id)
|
public function destroy($id)
|
||||||
|
@ -43,11 +43,11 @@
|
|||||||
<label for="location">Dowodzący:</label>
|
<label for="location">Dowodzący:</label>
|
||||||
<select name="operationLeader" class="form-control">
|
<select name="operationLeader" class="form-control">
|
||||||
<option value="">--- Wybierz dowódcę ---</option>
|
<option value="">--- Wybierz dowódcę ---</option>
|
||||||
@foreach ($fireFighters as $fireFighter)
|
@foreach ($leaders as $leader)
|
||||||
@if(Illuminate\Support\Facades\Input::old('operationLeader') == $fireFighter->id)
|
@if(Illuminate\Support\Facades\Input::old('operationLeader') == $leader->id)
|
||||||
<option value="{{$fireFighter->id}}" selected>{{ $fireFighter->name }} {{$fireFighter->surname }}</option>
|
<option value="{{$leader->id}}" selected>{{ $leader->name }} {{$leader->surname }}</option>
|
||||||
@else
|
@else
|
||||||
<option value="{{$fireFighter->id}}">{{ $fireFighter->name }} {{$fireFighter->surname }}</option>
|
<option value="{{$leader->id}}">{{ $leader->name }} {{$leader->surname }}</option>
|
||||||
@endif
|
@endif
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
@ -119,8 +119,8 @@
|
|||||||
html += '<label for="location">Kierowca:</label>';
|
html += '<label for="location">Kierowca:</label>';
|
||||||
html += '<select name="operationDriver[]" class="form-control">';
|
html += '<select name="operationDriver[]" class="form-control">';
|
||||||
html += '<option value="">--- Wybierz kierowcę ---</option>';
|
html += '<option value="">--- Wybierz kierowcę ---</option>';
|
||||||
html += '@foreach ($fireFighters as $fireFighter)';
|
html += '@foreach ($drivers as $driver)';
|
||||||
html += '<option value="{{$fireFighter->id}}">{{ $fireFighter->name }} {{$fireFighter->surname }}</option>';
|
html += '<option value="{{$driver->id}}">{{ $driver->name }} {{$driver->surname }}</option>';
|
||||||
html += '@endforeach';
|
html += '@endforeach';
|
||||||
html += '</select>';
|
html += '</select>';
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
|
@ -47,8 +47,8 @@
|
|||||||
<label for="location">Dowodzący:</label>
|
<label for="location">Dowodzący:</label>
|
||||||
<select name="operationLeader" class="form-control">
|
<select name="operationLeader" class="form-control">
|
||||||
<option value="">--- Wybierz dowódcę ---</option>
|
<option value="">--- Wybierz dowódcę ---</option>
|
||||||
@foreach ($fireFighters as $fireFighter)
|
@foreach ($leaders as $leader)
|
||||||
<option value="{{$fireFighter->id}}" {{$fireFighter->id == $operation->commanderID ? 'selected' : ''}}>{{ $fireFighter->name }} {{$fireFighter->surname }}</option>
|
<option value="{{$leader->id}}" {{$leader->id == $operation->commanderID ? 'selected' : ''}}>{{ $leader->name }} {{$leader->surname }}</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@ -63,8 +63,8 @@
|
|||||||
<label for="location">Kierowca:</label>
|
<label for="location">Kierowca:</label>
|
||||||
<select name="operationDriver[]" class="form-control">
|
<select name="operationDriver[]" class="form-control">
|
||||||
<option value="">--- Wybierz kierowcę ---</option>
|
<option value="">--- Wybierz kierowcę ---</option>
|
||||||
@foreach ($fireFighters as $fireFighter)
|
@foreach ($drivers as $driver)
|
||||||
<option {{$fireFighter->id == $operationTruck->driverID ? 'selected' : ''}} value="{{$fireFighter->id}}">{{ $fireFighter->name }} {{$fireFighter->surname }}</option>
|
<option {{$driver->id == $operationTruck->driverID ? 'selected' : ''}} value="{{$driver->id}}">{{ $driver->name }} {{$driver->surname }}</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@ -73,7 +73,13 @@
|
|||||||
<select name="operationVehicle[]" class="form-control">
|
<select name="operationVehicle[]" class="form-control">
|
||||||
<option value="">--- Wybierz pojazd ---</option>
|
<option value="">--- Wybierz pojazd ---</option>
|
||||||
@foreach ($vehicles as $vehicle)
|
@foreach ($vehicles as $vehicle)
|
||||||
<option {{$vehicle->id == $operationTruck->truckID ? 'selected' : ''}} value="{{$vehicle->id}}">{{ $vehicle->name }} {{$vehicle->codename }} {{$vehicle->registrationNumber }}</option>
|
<option {{$vehicle->id == $operationTruck->truckID ? 'selected' : ''}} value="{{$vehicle->id}}">{{ $vehicle->name }} {{$vehicle->codename }} {{$vehicle->registrationNumber }}
|
||||||
|
@if ($vehicle->deleted_at)
|
||||||
|
(USUNIĘTY {{$vehicle->deleted_at }})
|
||||||
|
@elseif ($vehicle->status == 0)
|
||||||
|
(zawieszony)
|
||||||
|
@endif
|
||||||
|
</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user