1
0
forked from s421507/eOSP2

Dodanie możliwości edycji nowych danych strażaka przez prezesa i naczelnika jednostki

This commit is contained in:
Krzysztof Strzelecki 2020-07-20 15:20:35 +02:00
parent c7dfa83343
commit 9c2e7dbc5f
2 changed files with 108 additions and 7 deletions

View File

@ -34,11 +34,9 @@ class fireFightersController 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
$fireStation = fireStation::find(auth()->user()->fireStationID); $fireStation = fireStation::find(auth()->user()->fireStationID);
if($fireStation-> creatorID == auth()->user()->id){ //if do usunięcia w pzyszłości
$ranks = DB::table('ranks')->pluck("rank","id"); $ranks = DB::table('ranks')->pluck("rank","id");
$unitFunctions = DB::table('unitFunctions')->pluck("unitFunction","id"); $unitFunctions = DB::table('unitFunctions')->pluck("unitFunction","id");
return view('fireFightersAdd',compact('ranks'), compact('unitFunctions')); return view('fireFightersAdd',compact('ranks'), compact('unitFunctions'));
} else return fireFightersController::create(); // ???
} else return redirect()->to('/strazacy'); } else return redirect()->to('/strazacy');
} }
@ -46,7 +44,6 @@ class fireFightersController extends Controller
if(auth()->user() != null && auth()->user()->accessLevel() == 50 ){ //prezes,naczelnik if(auth()->user() != null && auth()->user()->accessLevel() == 50 ){ //prezes,naczelnik
$userFireStation = auth()->user()->fireStationID; $userFireStation = auth()->user()->fireStationID;
$fireFighterFireStation = DB::table('users')->where("id", $id)->value('fireStationID'); $fireFighterFireStation = DB::table('users')->where("id", $id)->value('fireStationID');
$fireStationCreatorId = DB::table('fireStations')->where("id", $userFireStation)->value('creatorID');
$fireFighter = DB::table('users')->where("id", $id)->first(); $fireFighter = DB::table('users')->where("id", $id)->first();
return view('fireFightersEdit', ["fireFighter" => $fireFighter]); return view('fireFightersEdit', ["fireFighter" => $fireFighter]);
@ -113,6 +110,19 @@ class fireFightersController extends Controller
'surname' =>'required|min:2|max:45|regex:/^[A-Za-zżźćńółęąśŻŹĆĄŚĘŁÓŃ\040\x27-]+$/', 'surname' =>'required|min:2|max:45|regex:/^[A-Za-zżźćńółęąśŻŹĆĄŚĘŁÓŃ\040\x27-]+$/',
'PESEL' => new Pesel, 'PESEL' => new Pesel,
'phoneNumber' => 'required|digits:9', 'phoneNumber' => 'required|digits:9',
'secondName' => 'max:45',
'fathersName' => 'max:45',
'mothersName' => 'max:45',
'homePhoneNumber' => 'max:20',
'address' => 'max:45',
'apartment'=> 'max:45',
'placeOfBirth'=> 'max:45',
'IDSeries'=> 'max:3',
'IDNumber'=> 'max:6',
'identityCardNumber'=> 'max:20',
'driversLicense'=> 'max:20',
'education'=> 'max:45',
'profession'=> 'max:45',
], ],
[ [
'required' => ':attribute jest wymagany(e).', 'required' => ':attribute jest wymagany(e).',
@ -131,6 +141,22 @@ class fireFightersController extends Controller
$fireFighter-> surname = $request->surname; $fireFighter-> surname = $request->surname;
$fireFighter-> PESEL = $request->PESEL; $fireFighter-> PESEL = $request->PESEL;
$fireFighter-> phoneNumber = $request->phoneNumber; $fireFighter-> phoneNumber = $request->phoneNumber;
$fireFighter-> changingID = auth()->user()-> id;
$fireFighter-> secondName = $request->secondName;
$fireFighter-> fathersName = $request->fathersName;
$fireFighter-> mothersName = $request->mothersName;
$fireFighter-> homePhoneNumber = $request->homePhoneNumber;
$fireFighter-> address = $request->address;
$fireFighter-> apartment = $request->apartment;
$fireFighter-> placeOfBirth = $request->placeOfBirth;
$fireFighter-> joiningOSPDate = $request->joiningOSPDate;
$fireFighter-> IDSeries = $request->IDSeries;
$fireFighter-> IDNumber = $request->IDNumber;
$fireFighter-> IDValidUntil = $request->IDValidUntil;
$fireFighter-> identityCardNumber = $request->identityCardNumber;
$fireFighter-> driversLicense= $request->driversLicense;
$fireFighter-> education = $request->education;
$fireFighter-> profession = $request->profession;
$fireFighter->save(); $fireFighter->save();
return fireFightersController::create(); return fireFightersController::create();

View File

@ -24,16 +24,91 @@
<input type="text" class="form-control" id="surname" name="surname" value="{{ $fireFighter->surname }}"> <input type="text" class="form-control" id="surname" name="surname" value="{{ $fireFighter->surname }}">
</div> </div>
<div class="form-group">
<label for="parameter">Drugie imię:</label>
<input type="text" class="form-control" id="secondName" name="secondName" value="{{ $fireFighter->secondName }}">
</div>
<div class="form-group">
<label for="parameter">Imię ojca:</label>
<input type="text" class="form-control" id="fathersName" name="fathersName" value="{{ $fireFighter->fathersName }}">
</div>
<div class="form-group">
<label for="parameter">Imię matki:</label>
<input type="text" class="form-control" id="mothersName" name="mothersName" value="{{ $fireFighter->mothersName }}">
</div>
<div class="form-group"> <div class="form-group">
<label for="name">Pesel:</label> <label for="name">Pesel:</label>
<input type="text" class="form-control" id="PESEL" name="PESEL" value="{{ $fireFighter->PESEL }}"> <input type="text" class="form-control" id="PESEL" name="PESEL" value="{{ $fireFighter->PESEL }}">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="name">Numer telefonu:</label> <label for="name">Numer telefonu komórkowego:</label>
<input type="text" class="form-control" id="phoneNumber" name="phoneNumber" value="{{ $fireFighter->phoneNumber }}"> <input type="text" class="form-control" id="phoneNumber" name="phoneNumber" value="{{ $fireFighter->phoneNumber }}">
</div> </div>
<div class="form-group">
<label for="parameter">Telefon domowy:</label>
<input type="text" class="form-control" id="homePhoneNumber" name="homePhoneNumber" value="{{ $fireFighter->homePhoneNumber }}">
</div>
<div class="form-group">
<label for="parameter">Adres zamieszkania:</label>
<input type="text" class="form-control" id="address" name="address" value="{{ $fireFighter->address }}">
</div>
<div class="form-group">
<label for="parameter">Numer domu:</label>
<input type="text" class="form-control" id="apartment" name="apartment" value="{{ $fireFighter->apartment }}">
</div>
<div class="form-group">
<label for="parameter">Miejsce urodzenia:</label>
<input type="text" class="form-control" id="placeOfBirth" name="placeOfBirth" value="{{ $fireFighter->placeOfBirth }}">
</div>
<div class="form-group">
<label for="parameter">Data wstąpienia do OSP:</label>
<input type="date" class="form-control" id="joiningOSPDate" name="joiningOSPDate" value="{{ $fireFighter->joiningOSPDate }}">
</div>
<div class="form-group">
<label for="parameter">Seria dowodu osobistego:</label>
<input type="text" class="form-control" id="IDSeries" name="IDSeries" value="{{ $fireFighter->IDSeries }}">
</div>
<div class="form-group">
<label for="parameter">Numer dowodu osobistego:</label>
<input type="text" class="form-control" id="IDNumber" name="IDNumber" value="{{ $fireFighter->IDNumber }}">
</div>
<div class="form-group">
<label for="parameter">Dowód osobisty ważny do:</label>
<input type="date" class="form-control" id="IDValidUntil" name="IDValidUntil" value="{{ $fireFighter->IDValidUntil }}">
</div>
<div class="form-group">
<label for="parameter">Numer legitymacji członkowskiej:</label>
<input type="text" class="form-control" id="identityCardNumber" name="identityCardNumber" value="{{ $fireFighter->identityCardNumber }}">
</div>
<div class="form-group">
<label for="parameter">Prawo jazdy (kategorie):</label>
<input type="text" class="form-control" id="driversLicense" name="driversLicense" value="{{ $fireFighter->driversLicense }}">
</div>
<div class="form-group">
<label for="parameter">Wykształcenie:</label>
<input type="text" class="form-control" id="education" name="education" value="{{ $fireFighter->education }}">
</div>
<div class="form-group">
<label for="parameter">Zawód wyuczony:</label>
<input type="text" class="form-control" id="profession" name="profession" value="{{ $fireFighter->profession }}">
</div>
<div class="form-group"> <div class="form-group">
<button style="cursor:pointer" type="submit" class="btn btn-primary">Zapisz</button> <button style="cursor:pointer" type="submit" class="btn btn-primary">Zapisz</button>