diff --git a/app/Http/Controllers/DecorationsController.php b/app/Http/Controllers/DecorationsController.php index fb4ece1..6e79290 100644 --- a/app/Http/Controllers/DecorationsController.php +++ b/app/Http/Controllers/DecorationsController.php @@ -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'); } } @@ -67,6 +67,8 @@ class DecorationsController extends Controller { decorationsFirefighters::where('id',$id)->delete(); - return back(); + return response()->json([ + 'success' => 'Record deleted successfully!' + ]); } } diff --git a/app/Http/Controllers/EquipmentController.php b/app/Http/Controllers/EquipmentController.php index d95868b..69d5cb1 100644 --- a/app/Http/Controllers/EquipmentController.php +++ b/app/Http/Controllers/EquipmentController.php @@ -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,19 +37,24 @@ class EquipmentController extends Controller return view('equipmentEdit', ["equipment" => $equipment]); } else - return view("login"); + return redirect()->to('/sprzet'); } public function store(){ $this->validate(request(), [ - 'name' => 'required', - 'amount' => 'required|numeric', + 'name' => 'required|max:45', + 'amount' => 'required|numeric|digits_between:1,10', + 'parameter' => 'max:45|nullable', ], [ 'required' => ':attribute jest wymagany(a).', + 'name.required' => 'nazwa jest wymagany(a).', + 'name.max' => 'nazwa musi mieć nie więcej niż :max znaków.', + 'max' => ':attribute musi mieć nie więcej niż :max znaków.', 'numeric' => ':attribute powinna zawierać tylko cyfry.', + 'digits_between' => ':attribute jest za duży(a)' ]); @@ -67,12 +72,17 @@ class EquipmentController extends Controller public function update(){ $this->validate(request(), [ - 'name' => 'required', - 'amount' => 'required|numeric', + 'name' => 'required|max:45', + 'amount' => 'required|numeric|digits_between:1,10', + 'parameter' => 'max:45|nullable', ], [ 'required' => ':attribute jest wymagany(a).', - 'numeric' => ':attribute powinna zawierać tylko cyfry.' + 'name.required' => 'nazwa jest wymagany(a).', + 'name.max' => 'nazwa musi mieć nie więcej niż :max znaków.', + 'max' => ':attribute musi mieć nie więcej niż :max znaków.', + 'numeric' => ':attribute powinna zawierać tylko cyfry.', + 'digits_between' => ':attribute jest za duży(a)' ]); diff --git a/app/Http/Controllers/RegistrationController.php b/app/Http/Controllers/RegistrationController.php index f1ddd62..0402efc 100644 --- a/app/Http/Controllers/RegistrationController.php +++ b/app/Http/Controllers/RegistrationController.php @@ -8,7 +8,6 @@ use App\User; use Mail; use App\Rules\Pesel; -/* 'phoneNumber' => 'required|regex:/^([0-9\s\-\+\(\)]*)$/|min:9' */ class RegistrationController extends Controller { public function create() @@ -20,19 +19,18 @@ class RegistrationController extends Controller { $this->validate(request(), [ - 'name' => 'required|alpha|min:3|max:45', - 'surname' => 'required|alpha|min:3|max:45', + 'name' => 'required|min:2|max:45|regex:/^[\p{L}\040\x27-]+$/', + 'surname' => 'required|min:2|max:45|regex:/^[\p{L}\040\x27-]+$/', 'PESEL' => new Pesel, 'phoneNumber' => 'required|digits:9', 'email' => 'required|email|unique:users', - 'password' => 'required|confirmed|min:6', + 'password' => 'required|confirmed|min:6|max:45', ], [ 'required' => ':attribute jest wymagany(e).', 'min' => ':attribute musi mieć przynajmniej :min znaki.', 'max' => ':attribute musi mieć nie więcej niż :max znaków.', - 'alpha' => ':attribute może zawierać tylko litery.', - 'alpha_num' => ':attribute może zawierać tylko litery i cyfry.', + 'regex' => ':attribute może zawierać tylko litery, spacje, myślniki i apostrofy', 'digits' => ':attribute musi składać się z :digits cyfr.', 'unique' =>':attribute jest już zajęty.', 'confirmed' =>':attribute się nie zgadza.', diff --git a/app/Http/Controllers/SessionsController.php b/app/Http/Controllers/SessionsController.php index 5d25142..e04c395 100644 --- a/app/Http/Controllers/SessionsController.php +++ b/app/Http/Controllers/SessionsController.php @@ -15,9 +15,16 @@ class SessionsController extends Controller { if (auth()->attempt(request(['email', 'password'])) == false) { return back()->withErrors([ - 'message' => 'The email or password is incorrect, please try again' + 'message' => 'Podany adres email lub hasło jest nieprawidłowe, proszę spróbować ponownie.' ]); } + elseif(auth()->user()->statusID == 1) + { + auth()->logout(); + return back()->withErrors([ + 'message' => 'Twoje konto zostało zawieszone.' + ]); + } return redirect()->to('/jednostka'); } diff --git a/app/Http/Controllers/VehiclesController.php b/app/Http/Controllers/VehiclesController.php index 3ed083d..fe6f52d 100644 --- a/app/Http/Controllers/VehiclesController.php +++ b/app/Http/Controllers/VehiclesController.php @@ -31,46 +31,60 @@ 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(){ $this->validate(request(), [ - 'name' => 'required', - 'codename' => 'required', + 'vehicleName' => 'required|max:45', + 'codename' => 'required|max:45', + 'brand' => 'max:45', + 'registrationNumber' => 'max:15', 'productionYear' => 'digits:4|nullable', - 'foamAgent' => 'numeric|nullable', - 'enginePower' => 'numeric|nullable', - 'crewNumber' => 'numeric|nullable', - 'mass' => 'numeric|nullable', - 'chassisPoductionYear' => 'numeric|nullable', + 'driveType' => 'max:45', + 'chassisType' => 'max:45', + 'bodyProducer' => 'max:45', + 'crewNumber' => 'numeric|nullable|digits_between:1,2', + 'foamAgent' => 'numeric|nullable|digits_between:1,10', + 'enginePower' => 'numeric|nullable|digits_between:1,10', + 'mass' => 'numeric|nullable|digits_between:1,10', + 'chassisNumber' => 'max:45', + 'engineNumber' => 'max:45', + 'fuelType' => 'max:45', + 'chassisPoductionYear' => 'digits:4|nullable', + 'fireEnginePumpDescription' => 'max:250', ], [ + + 'name' => 'nazwa', 'required' => ':attribute jest wymagany(e).', - 'numeric' => ':attribute zawiera tylko cyfry.', + 'numeric' => ':attribute może zawierać tylko cyfry.', 'digits' => ':attribute musi składać się z :digits cyfr.', + 'max' => ':attribute musi mieć nie więcej niż :max znaków.', + 'digits_between' => ':attribute jest za duży(a)' + ]); $request = request(); $vehicle = vehicle::create([ 'fireStationID' => auth()->user()->fireStationID, - 'name' => $request-> name, + 'name' => $request-> vehicleName, 'codename' => $request-> codename, 'brand' => $request-> brand, 'registrationNumber' => $request-> registrationNumber, @@ -100,25 +114,39 @@ class VehiclesController extends Controller public function update(){ $this->validate(request(), [ - 'name' => 'required', - 'codename' => 'required', + 'vehicleName' => 'required|max:45', + 'codename' => 'required|max:45', + 'brand' => 'max:45', + 'registrationNumber' => 'max:15', 'productionYear' => 'digits:4|nullable', - 'foamAgent' => 'numeric|nullable', - 'enginePower' => 'numeric|nullable', - 'crewNumber' => 'numeric|nullable', - 'mass' => 'numeric|nullable', - 'chassisPoductionYear' => 'numeric|nullable', + 'driveType' => 'max:45', + 'chassisType' => 'max:45', + 'bodyProducer' => 'max:45', + 'crewNumber' => 'numeric|nullable|digits_between:1,2', + 'foamAgent' => 'numeric|nullable|digits_between:1,10', + 'enginePower' => 'numeric|nullable|digits_between:1,10', + 'mass' => 'numeric|nullable|digits_between:1,10', + 'chassisNumber' => 'max:45', + 'engineNumber' => 'max:45', + 'fuelType' => 'max:45', + 'chassisPoductionYear' => 'digits:4|nullable', + 'fireEnginePumpDescription' => 'max:250', ], [ + + 'name' => 'nazwa', 'required' => ':attribute jest wymagany(e).', - 'numeric' => ':attribute zawiera tylko cyfry.', + 'numeric' => ':attribute może zawierać tylko cyfry.', 'digits' => ':attribute musi składać się z :digits cyfr.', + 'max' => ':attribute musi mieć nie więcej niż :max znaków.', + 'digits_between' => ':attribute jest za duży(a)' + ]); $request = request(); $vehicle = vehicle::find( $request->vehicleID); - $vehicle-> name = $request-> name; + $vehicle-> name = $request-> vehicleName; $vehicle-> codename = $request-> codename; $vehicle-> brand = $request-> brand; $vehicle-> registrationNumber = $request-> registrationNumber; @@ -147,7 +175,9 @@ class VehiclesController extends Controller public function destroy($id) { vehicle::where('id',$id)->delete(); - return redirect()->to('/pojazdy'); + return response()->json([ + 'success' => 'Record deleted successfully!' + ]); } public function activate() diff --git a/app/Http/Controllers/fireFightersController.php b/app/Http/Controllers/fireFightersController.php index c4db7c3..5395ac7 100644 --- a/app/Http/Controllers/fireFightersController.php +++ b/app/Http/Controllers/fireFightersController.php @@ -15,55 +15,55 @@ class fireFightersController extends Controller { public function create(){ - if(auth()->user() != null && auth()->user()->fireStationID != null ){ + if(auth()->user() != null && auth()->user()->accessLevel() >= 20) //prezes,naczelnik,sekretarz + { // $users = user::where("fireStationID", auth()->user()->fireStationID)->get(); // $users = DB::table('users')->where("fireStationID", '=', auth()->user()->fireStationID)->get(); $users = DB::table('users')->where("fireStationID", '=', auth()->user()->fireStationID) ->leftJoin('ranks', 'users.degreeID', '=', 'ranks.id') ->leftJoin('unitFunctions', 'users.functionID', '=', 'unitFunctions.id') ->select('users.id','users.name', 'users.surname', 'users.PESEL', 'users.email', 'users.statusID', 'ranks.rank', 'unitFunctions.unitFunction') - ->paginate(10); + ->paginate(10); return view("fireFighters", ["users" => $users]); - } else{ - return view('fireFighters'); + } else { + return redirect()->to('/userprofile'); } } public function addForm(){ - if(auth()->user() != null && auth()->user()->fireStationID != null ){ + if(auth()->user() != null && auth()->user()->accessLevel() == 50 ){ //prezes,naczelnik $fireStation = fireStation::find(auth()->user()->fireStationID); - if($fireStation-> creatorID == auth()->user()->id){ - //return view('fireFightersAdd'); + if($fireStation-> creatorID == auth()->user()->id){ //if do usunięcia w pzyszłości $ranks = DB::table('ranks')->pluck("rank","id"); $unitFunctions = DB::table('unitFunctions')->pluck("unitFunction","id"); return view('fireFightersAdd',compact('ranks'), compact('unitFunctions')); - } else return fireFightersController::create(); - } else return view("unit"); + } else return fireFightersController::create(); // ??? + } else return redirect()->to('/strazacy'); } public function editForm($id){ - if(auth()->user() != null && auth()->user()->fireStationID != null ){ + if(auth()->user() != null && auth()->user()->accessLevel() == 50 ){ //prezes,naczelnik $userFireStation = auth()->user()->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(); - if($userFireStation == $fireFighterFireStation && auth()->user()->id == $fireStationCreatorId) { + if($userFireStation == $fireFighterFireStation && auth()->user()->id == $fireStationCreatorId) { // if do usunięcia w pzyszłości return view('fireFightersEdit', ["fireFighter" => $fireFighter]); } else{ return "Brak dostepu"; } }else{ - return view('unit'); + return redirect()->to('/strazacy'); } } public function store(){ $this->validate(request(), [ - 'name' => 'required|alpha|min:3|max:45', - 'surname' => 'required|alpha|min:3|max:45', + 'name' =>'required|min:2|max:45|regex:/^[\p{L}\040\x27-]+$/', + 'surname' =>'required|min:2|max:45|regex:/^[\p{L}\040\x27-]+$/', 'PESEL' => new Pesel, 'phoneNumber' => 'required|digits:9', 'email' => 'required|email|unique:users', @@ -74,8 +74,7 @@ class fireFightersController extends Controller 'required' => ':attribute jest wymagany(e).', 'min' => ':attribute musi mieć przynajmniej :min znaki.', 'max' => ':attribute musi mieć nie więcej niż :max znaków.', - 'alpha' => ':attribute może zawierać tylko litery.', - 'alpha_num' => ':attribute może zawierać tylko litery i cyfry.', + 'regex' => ':attribute może zawierać tylko litery, spacje, myślniki i apostrofy', 'digits' => ':attribute musi składać się z :digits cyfr.', 'unique' =>':attribute jest już zajęty.', 'confirmed' =>':attribute się nie zgadza.', @@ -112,8 +111,8 @@ class fireFightersController extends Controller public function update(){ $this->validate(request(), [ - 'name' => 'required|alpha|min:3|max:45', - 'surname' => 'required|alpha|min:3|max:45', + 'name' =>'required|min:2|max:45|regex:/^[\p{L}\040\x27-]+$/', + 'surname' =>'required|min:2|max:45|regex:/^[\p{L}\040\x27-]+$/', 'PESEL' => new Pesel, 'phoneNumber' => 'required|digits:9', ], @@ -121,8 +120,7 @@ class fireFightersController extends Controller 'required' => ':attribute jest wymagany(e).', 'min' => ':attribute musi mieć przynajmniej :min znaki.', 'max' => ':attribute musi mieć nie więcej niż :max znaków.', - 'alpha' => ':attribute może zawierać tylko litery.', - 'alpha_num' => ':attribute może zawierać tylko litery i cyfry.', + 'regex' => ':attribute może zawierać tylko litery, spacje, myślniki i apostrofy', 'digits' => ':attribute musi składać się z :digits cyfr.', 'unique' =>':attribute jest już zajęty.', 'confirmed' =>':attribute się nie zgadza.', @@ -140,6 +138,7 @@ class fireFightersController extends Controller return fireFightersController::create(); } + public function createSingleFireFighterPDF(){ if (auth()->user() != null && auth()->user()->fireStationID != null) { $request = request(); @@ -156,5 +155,23 @@ class fireFightersController extends Controller } } + public function activate() + { + $request = request(); + $user = User::find( $request-> userID); + $user-> statusID = 0; + $user->save(); + return redirect()->to('/strazacy'); + } + + public function deactivate() + { + $request = request(); + $user = User::find( $request-> userID); + $user-> statusID = 1; + $user->save(); + return redirect()->to('/strazacy'); + } + } diff --git a/app/Http/Controllers/fireStationController.php b/app/Http/Controllers/fireStationController.php index b236533..e33fc70 100644 --- a/app/Http/Controllers/fireStationController.php +++ b/app/Http/Controllers/fireStationController.php @@ -26,7 +26,7 @@ class fireStationController extends Controller public function editForm() { - if(auth()->user() != null && auth()->user()->fireStationID != null ) + if(auth()->user() != null && auth()->user()->accessLevel() == 50) //prezes/naczelnik { $id = auth()->user()->fireStationID; $fireStation = DB::table('fireStations')->where("id", $id)->first(); @@ -34,7 +34,7 @@ class fireStationController extends Controller return view('fireStationEdit', ["fireStation" => $fireStation], compact('voivodeships')); } else - return "Brak dostępu"; + return redirect()->to('/jednostka'); } public function store() diff --git a/app/Http/Controllers/operationsController.php b/app/Http/Controllers/operationsController.php index 8a06d3a..30f7175 100644 --- a/app/Http/Controllers/operationsController.php +++ b/app/Http/Controllers/operationsController.php @@ -60,7 +60,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], @@ -69,13 +69,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([ @@ -120,17 +120,17 @@ class operationsController extends Controller // return "Brak dostepu"; // } } else{ - return view('unit'); + return redirect()->to('/wyjazdy'); } } public function store(){ $this->validate(request(),[ 'operationDate' => 'required', - 'operationLocation' => 'required', - 'operationTarget' => 'required', - 'operationDangerType' => 'required', - 'operationDescription' => 'required', + 'operationLocation' => 'required|max:100', + 'operationTarget' => 'required|max:100', + 'operationDangerType' => 'required|max:100', + 'operationDescription' => 'required|max:250', 'operationLeader' => 'required', 'operationDriver.*' => 'required', 'operationVehicle.*' => 'required', @@ -138,7 +138,8 @@ class operationsController extends Controller 'transport.*' => 'required', ], [ - 'required' => ':attribute jest wymagany(e)' + 'required' => ':attribute jest wymagany(e)', + 'max' => ':attribute musi mieć nie więcej niż :max znaków.' ]); // @@ -197,10 +198,10 @@ class operationsController extends Controller public function update(){ $this->validate(request(),[ 'operationDate' => 'required', - 'operationLocation' => 'required', - 'operationTarget' => 'required', - 'operationDangerType' => 'required', - 'operationDescription' => 'required', + 'operationLocation' => 'required|max:100', + 'operationTarget' => 'required|max:100', + 'operationDangerType' => 'required|max:100', + 'operationDescription' => 'required|max:250', 'operationLeader' => 'required', 'operationDriver.*' => 'required', 'operationVehicle.*' => 'required', @@ -209,7 +210,7 @@ class operationsController extends Controller ], [ 'required' => ':attribute jest wymagany(e)', - 'operationTarget.required' => 'Cel jest wyma gany' + 'max' => ':attribute musi mieć nie więcej niż :max znaków.' ]); diff --git a/app/Http/Controllers/resetPasswordController.php b/app/Http/Controllers/resetPasswordController.php index c4b8d53..7cbfed4 100644 --- a/app/Http/Controllers/resetPasswordController.php +++ b/app/Http/Controllers/resetPasswordController.php @@ -34,9 +34,7 @@ class resetPasswordController extends Controller if($user){ $password = str_random(10); User::where('email', '=', $request->email) - ->update(['password' => Hash::make($password)]); // this will also update the record - //$user->password = $password; - //$user->save(); + ->update(['password' => Hash::make($password)]); Mail::send('emails.passwordReset', compact('password'), function($message) { $message->to(Input::get('email'))->subject('Zmiana hasła'); }); diff --git a/app/Http/Controllers/trainingsController.php b/app/Http/Controllers/trainingsController.php index 1d90a81..5f7ccbd 100644 --- a/app/Http/Controllers/trainingsController.php +++ b/app/Http/Controllers/trainingsController.php @@ -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,16 +32,17 @@ class trainingsController extends Controller } return View::make("trainings")->with(compact( "trainings", "fireFighters")); } else{ - return view('trainings'); + return redirect()->to('/strazacy'); } } public function store(){ $this->validate(request(), [ - 'name' => 'required', + 'name' => 'required|max:45', ], [ - 'required' => ':attribute jest wymagany(a).', + 'required' => 'Nazwa jest wymagana.', + 'max' => 'Nazwa musi mieć nie więcej niż :max znaków.', ]); @@ -60,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'); @@ -73,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'); } } diff --git a/app/Http/Controllers/userProfileController.php b/app/Http/Controllers/userProfileController.php index 3e0c01e..567beee 100644 --- a/app/Http/Controllers/userProfileController.php +++ b/app/Http/Controllers/userProfileController.php @@ -39,8 +39,8 @@ class userProfileController extends Controller public function update(){ $this->validate(request(), [ - 'name' => 'required|alpha|min:3|max:45', - 'surname' => 'required|alpha|min:3|max:45', + 'name' =>'required|min:2|max:45|regex:/^[\p{L}\040\x27-]+$/', + 'surname' =>'required|min:2|max:45|regex:/^[\p{L}\040\x27-]+$/', 'PESEL' => new Pesel, 'phoneNumber' => 'required|digits:9', 'email' => 'required|email|unique:users,email,'.auth()->user()->id, //wymagaj unikalnego adresu email ale pozwól na zachowanie starego adresu @@ -49,8 +49,7 @@ class userProfileController extends Controller 'required' => ':attribute jest wymagany(e).', 'min' => ':attribute musi mieć przynajmniej :min znaki.', 'max' => ':attribute musi mieć nie więcej niż :max znaków.', - 'alpha' => ':attribute może zawierać tylko litery.', - 'alpha_num' => ':attribute może zawierać tylko litery i cyfry.', + 'regex' => ':attribute może zawierać tylko litery, spacje, myślniki i apostrofy', 'digits' => ':attribute musi składać się z :digits cyfr.', 'unique' =>':attribute jest już zajęty.', 'confirmed' =>':attribute się nie zgadza.', diff --git a/app/User.php b/app/User.php index 9bf1995..2b62596 100644 --- a/app/User.php +++ b/app/User.php @@ -43,4 +43,20 @@ class User extends Authenticatable { $this->attributes['password'] = bcrypt($password); } + + public function accessLevel() + { + if (auth()->user() != null && auth()->user()->fireStationID != null) + if ($this->functionID == 1 or $this->functionID == 5) //prezes lub naczelnik + return 50; + elseif ($this->functionID == 3) //skarbnik + return 30; + elseif($this->functionID == 4) //sekretarz + return 20; + else + return 0; //brak specjalnych uprawnień + else + return -1; //jednostka nie istnieje + + } } diff --git a/database/migrations/2019_12_28_165307_add_softDelete_to_vehicles_table.php b/database/migrations/2019_12_28_165307_add_softDelete_to_vehicles_table.php deleted file mode 100644 index 63837d4..0000000 --- a/database/migrations/2019_12_28_165307_add_softDelete_to_vehicles_table.php +++ /dev/null @@ -1,33 +0,0 @@ -softDeletes(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('vehicles', function (Blueprint $table) { - // - }); - } -} diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index 291a037..f11cea9 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -2913,5 +2913,19 @@ class DatabaseSeeder extends Seeder DB::table('gminy')->insert([ 'id' => '1326101', 'wojewodztwo_id' => '1320000', 'powiat_id' => '1326100', 'name' => 'm. Koszalin' ]); DB::table('gminy')->insert([ 'id' => '1326201', 'wojewodztwo_id' => '1320000', 'powiat_id' => '1326200', 'name' => 'm. Szczecin' ]); DB::table('gminy')->insert([ 'id' => '1326301', 'wojewodztwo_id' => '1320000', 'powiat_id' => '1326300', 'name' => 'm. Świnoujście' ]); + //jednostki + DB::table('fireStations')->insert(['id'=>'1100','name'=>'Kębłowo','number'=>'1100','voivodeship'=>'wielkopolskie','county'=>'wolsztyński','community'=>'gm. Wolsztyn','postOffice'=>'Kębłowo','zipCode'=>'64223','address'=>'ul. Nowa 8a','latitude'=>'52.0485042','longitude'=>'16.1052983','KRS'=>'0000232331','NIP'=>'9231571641','phoneNumber'=>'501234567','email'=>'straz@keblowo.pl','deleted'=>'0','creatorID'=>'1101','changingID'=>'1101','remember_token'=>NULL,'created_at'=>now(),'updated_at'=>now()]); + DB::table('fireStations')->insert(['id'=>'1200','name'=>'Obra','number'=>'1200','voivodeship'=>'wielkopolskie','county'=>'wolsztyński','community'=>'gm. Wolsztyn','postOffice'=>'Obra','zipCode'=>'64211','address'=>'ul. Cmentarna 5a','latitude'=>'52.0768963','longitude'=>'16.0427013','KRS'=>'0000096776','NIP'=>'9231571629','phoneNumber'=>'501234567','email'=>'osp.obra@wp.pl','deleted'=>'0','creatorID'=>'1201','changingID'=>'1201','remember_token'=>NULL,'created_at'=>now(),'updated_at'=>now()]); + //użytkownicy + DB::table('users')->insert(['id'=>'1101','password'=>'$2y$10$hSeo4pAvQLmV8KzQWoOEXuMEiN7dqOb4jEU80g.xsUS6W5.sh5I4m','name'=>'Szymon','surname'=>'Tomys','PESEL'=>'74073147926','phoneNumber'=>'501234567','email'=>'szymon.tomys@eosp.projektstudencki.pl','fireStationID'=>'1100','functionID'=>'1','degreeID'=>'1','number'=>'ABC123','statusID'=>'0','deleted'=>'0','creatorID'=>NULL,'changingID'=>NULL,'confirmed'=>'0','confirmation_code'=>NULL,'email_verified_at'=>NULL,'remember_token'=>NULL,'created_at'=>now(),'updated_at'=>now()]); + DB::table('users')->insert(['id'=>'1102','password'=>'$2y$10$hSeo4pAvQLmV8KzQWoOEXuMEiN7dqOb4jEU80g.xsUS6W5.sh5I4m','name'=>'Hanna Nowacka','surname'=>'','PESEL'=>'74073147926','phoneNumber'=>'501234567','email'=>'hanna.nowacka@eosp.projektstudencki.pl','fireStationID'=>'1100','functionID'=>'2','degreeID'=>'2','number'=>'ABC123','statusID'=>'0','deleted'=>'0','creatorID'=>NULL,'changingID'=>NULL,'confirmed'=>'0','confirmation_code'=>NULL,'email_verified_at'=>NULL,'remember_token'=>NULL,'created_at'=>now(),'updated_at'=>now()]); + DB::table('users')->insert(['id'=>'1103','password'=>'$2y$10$hSeo4pAvQLmV8KzQWoOEXuMEiN7dqOb4jEU80g.xsUS6W5.sh5I4m','name'=>'Dominik Klupsz','surname'=>'','PESEL'=>'74073147926','phoneNumber'=>'501234567','email'=>'dominik.klupsz@eosp.projektstudencki.pl','fireStationID'=>'1100','functionID'=>'3','degreeID'=>'3','number'=>'ABC123','statusID'=>'0','deleted'=>'0','creatorID'=>NULL,'changingID'=>NULL,'confirmed'=>'0','confirmation_code'=>NULL,'email_verified_at'=>NULL,'remember_token'=>NULL,'created_at'=>now(),'updated_at'=>now()]); + DB::table('users')->insert(['id'=>'1104','password'=>'$2y$10$hSeo4pAvQLmV8KzQWoOEXuMEiN7dqOb4jEU80g.xsUS6W5.sh5I4m','name'=>'Kamila Prządka','surname'=>'','PESEL'=>'74073147926','phoneNumber'=>'501234567','email'=>'kamila.przadka@eosp.projektstudencki.pl','fireStationID'=>'1100','functionID'=>'4','degreeID'=>'4','number'=>'ABC123','statusID'=>'0','deleted'=>'0','creatorID'=>NULL,'changingID'=>NULL,'confirmed'=>'0','confirmation_code'=>NULL,'email_verified_at'=>NULL,'remember_token'=>NULL,'created_at'=>now(),'updated_at'=>now()]); + DB::table('users')->insert(['id'=>'1105','password'=>'$2y$10$hSeo4pAvQLmV8KzQWoOEXuMEiN7dqOb4jEU80g.xsUS6W5.sh5I4m','name'=>'Rafał Smerdka','surname'=>'','PESEL'=>'74073147926','phoneNumber'=>'501234567','email'=>'rafal.smerdka@eosp.projektstudencki.pl','fireStationID'=>'1100','functionID'=>'5','degreeID'=>'5','number'=>'ABC123','statusID'=>'0','deleted'=>'0','creatorID'=>NULL,'changingID'=>NULL,'confirmed'=>'0','confirmation_code'=>NULL,'email_verified_at'=>NULL,'remember_token'=>NULL,'created_at'=>now(),'updated_at'=>now()]); + DB::table('users')->insert(['id'=>'1201','password'=>'$2y$10$hSeo4pAvQLmV8KzQWoOEXuMEiN7dqOb4jEU80g.xsUS6W5.sh5I4m','name'=>'Damian Kotlarski','surname'=>'','PESEL'=>'74073147926','phoneNumber'=>'501234567','email'=>'damian.kotlarski@eosp.projektstudencki.pl','fireStationID'=>'1200','functionID'=>'1','degreeID'=>'1','number'=>'ABC123','statusID'=>'0','deleted'=>'0','creatorID'=>NULL,'changingID'=>NULL,'confirmed'=>'0','confirmation_code'=>NULL,'email_verified_at'=>NULL,'remember_token'=>NULL,'created_at'=>now(),'updated_at'=>now()]); + DB::table('users')->insert(['id'=>'1202','password'=>'$2y$10$hSeo4pAvQLmV8KzQWoOEXuMEiN7dqOb4jEU80g.xsUS6W5.sh5I4m','name'=>'Artur Orwat','surname'=>'','PESEL'=>'74073147926','phoneNumber'=>'501234567','email'=>'artur.orwat@eosp.projektstudencki.pl','fireStationID'=>'1200','functionID'=>'2','degreeID'=>'2','number'=>'ABC123','statusID'=>'0','deleted'=>'0','creatorID'=>NULL,'changingID'=>NULL,'confirmed'=>'0','confirmation_code'=>NULL,'email_verified_at'=>NULL,'remember_token'=>NULL,'created_at'=>now(),'updated_at'=>now()]); + DB::table('users')->insert(['id'=>'1203','password'=>'$2y$10$hSeo4pAvQLmV8KzQWoOEXuMEiN7dqOb4jEU80g.xsUS6W5.sh5I4m','name'=>'Michał Rogozinski','surname'=>'','PESEL'=>'74073147926','phoneNumber'=>'501234567','email'=>'michal.rogozinski@eosp.projektstudencki.pl','fireStationID'=>'1200','functionID'=>'3','degreeID'=>'3','number'=>'ABC123','statusID'=>'0','deleted'=>'0','creatorID'=>NULL,'changingID'=>NULL,'confirmed'=>'0','confirmation_code'=>NULL,'email_verified_at'=>NULL,'remember_token'=>NULL,'created_at'=>now(),'updated_at'=>now()]); + DB::table('users')->insert(['id'=>'1204','password'=>'$2y$10$hSeo4pAvQLmV8KzQWoOEXuMEiN7dqOb4jEU80g.xsUS6W5.sh5I4m','name'=>'Lidia Kaczmarek','surname'=>'','PESEL'=>'74073147926','phoneNumber'=>'501234567','email'=>'lidia.kaczmarek@eosp.projektstudencki.pl','fireStationID'=>'1200','functionID'=>'4','degreeID'=>'4','number'=>'ABC123','statusID'=>'0','deleted'=>'0','creatorID'=>NULL,'changingID'=>NULL,'confirmed'=>'0','confirmation_code'=>NULL,'email_verified_at'=>NULL,'remember_token'=>NULL,'created_at'=>now(),'updated_at'=>now()]); + DB::table('users')->insert(['id'=>'1205','password'=>'$2y$10$hSeo4pAvQLmV8KzQWoOEXuMEiN7dqOb4jEU80g.xsUS6W5.sh5I4m','name'=>'Michał Nowak','surname'=>'','PESEL'=>'74073147926','phoneNumber'=>'501234567','email'=>'michal.nowak@eosp.projektstudencki.pl','fireStationID'=>'1200','functionID'=>'5','degreeID'=>'5','number'=>'ABC123','statusID'=>'0','deleted'=>'0','creatorID'=>NULL,'changingID'=>NULL,'confirmed'=>'0','confirmation_code'=>NULL,'email_verified_at'=>NULL,'remember_token'=>NULL,'created_at'=>now(),'updated_at'=>now()]); } } diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php index 4315724..ac50647 100644 --- a/resources/lang/en/validation.php +++ b/resources/lang/en/validation.php @@ -163,9 +163,32 @@ return [ 'latitude' => 'szerokość geograficzna', 'amount' => 'ilość', 'decoration' => 'odznaczenie', - 'dateOfAward' => 'data przyznania' + 'dateOfAward' => 'data przyznania', + 'brand' => 'marka', + 'vehicleName' => 'nazwa pojazdu', + 'registrationNumber' => 'numer rejestracyjny', + 'productionYear' => 'rok produkcji', + 'driveType' => 'układ napędowy', + 'chassisType' => 'typ podwozia', + 'bodyProducer' => 'producent nadwozia', + 'crewNumber' => 'ilość osób w załodze', + 'mass' => 'masa', + 'chassisNumber' => 'numer podwozia', + 'engineNumber' => 'numer silnika', + 'fuelType' => 'rodzaj paliwa', + 'chassisPoductionYear' => 'rok produkcji podwozia', + 'fireEnginePumpDescription' => 'opis autopompy', + 'operationDate' =>'data wyjazdu', + 'operationLocation' =>'miejsce akcji', + 'operationTarget' =>'cel wyjazdu', + 'operationDangerType' =>'rodzaj zagrożenia', + 'operationDescription' =>'opis akcji', + 'operationLeader' =>'dowodzący', + 'operationDriver.*' =>'kierowca', + 'operationVehicle.*' =>'pojazd', + 'parameter' =>'parametr charakterystyczny', + ], - ]; diff --git a/resources/views/decorations.blade.php b/resources/views/decorations.blade.php index 2b553d2..a5a1448 100644 --- a/resources/views/decorations.blade.php +++ b/resources/views/decorations.blade.php @@ -1,5 +1,7 @@ @extends('layout.app') + + @section('left-menu') @parent @stop @section('center-area') + @parent @if( auth()->check()) @@ -28,15 +31,11 @@ Operacja @foreach($awardedDecorations as $awardedDecoration) -
{{ $awardedDecoration->decorationName }} {{ $awardedDecoration->dateOfAward }} - {{ csrf_field() }} - @method('DELETE') - + -
@endforeach @@ -54,7 +53,11 @@ @@ -73,3 +76,38 @@ @endif @stop + + \ No newline at end of file diff --git a/resources/views/depot.blade.php b/resources/views/depot.blade.php index 7b28e75..089aa75 100644 --- a/resources/views/depot.blade.php +++ b/resources/views/depot.blade.php @@ -4,16 +4,12 @@ @parent @stop @section('center-area') @parent Strona w budowie -

Zawarte będą tutaj informacje o umundurowaniu oraz sprzęcie jaki jest na wyposażeniu strażnicy oraz informacje gdzie umundurowanie się znajduje(druhowie mundury koszarowe oraz galowe mają w w domach, informacja ta pozwoli na sprawdzenie np jakie są braki w umundurowaniu).

- +

Zawarte są tutaj informacje o sprzęcie jaki jest na wyposażeniu strażnicy. W przyszłej wersji eOSP do strażnicy dodane zostaną informacje o posiadanym umundurowaniu oraz gdzie umundurowanie się znajduje(druhowie mundury koszarowe oraz galowe miewają w domach, informacja ta pozwoli na sprawdzenie np jakie są braki w umundurowaniu).

@stop diff --git a/resources/views/equipment.blade.php b/resources/views/equipment.blade.php index 758b9ff..0f18619 100644 --- a/resources/views/equipment.blade.php +++ b/resources/views/equipment.blade.php @@ -1,13 +1,18 @@ @extends('layout.app') + @section('left-menu') @parent + @if( auth()->check() ) + @if( auth()->user()->fireStationID != NULL) + @if(auth()->user()->accessLevel() == 50) + @endif + @endif + @endif @stop @section('center-area') @@ -26,7 +31,9 @@ Nazwa Ilość Param. charakterystyczny + @if(auth()->user()->accessLevel() == 50) Operacja + @endif @@ -39,10 +46,12 @@ {{ $item->name }} {{ $item->amount }} {{ $item->parameter }} + @if(auth()->user()->accessLevel() == 50) Edytuj + @endif @php diff --git a/resources/views/equipmentAdd.blade.php b/resources/views/equipmentAdd.blade.php index b49ad36..e2cadd3 100644 --- a/resources/views/equipmentAdd.blade.php +++ b/resources/views/equipmentAdd.blade.php @@ -3,9 +3,7 @@ @section('left-menu') @parent @stop @@ -29,7 +27,7 @@
- +
@include('inc.formerrors') diff --git a/resources/views/equipmentEdit.blade.php b/resources/views/equipmentEdit.blade.php index 18657d4..85bbd25 100644 --- a/resources/views/equipmentEdit.blade.php +++ b/resources/views/equipmentEdit.blade.php @@ -4,8 +4,7 @@ @parent @stop @@ -31,7 +30,7 @@
- +
@include('inc.formerrors') diff --git a/resources/views/fireFighters.blade.php b/resources/views/fireFighters.blade.php index 44df12b..a91409d 100644 --- a/resources/views/fireFighters.blade.php +++ b/resources/views/fireFighters.blade.php @@ -2,12 +2,16 @@ @section('left-menu') @parent + @if( auth()->check() ) + @if( auth()->user()->fireStationID != NULL) + @if(auth()->user()->accessLevel() == 50) + @endif + @endif + @endif @stop @@ -70,14 +74,16 @@ # - Imie + Imię Nazwisko PESEL E-mail Funkcja Stopień Status - Operacje + @if(auth()->user()->accessLevel() == 50) + Operacja + @endif @@ -95,25 +101,36 @@ {{$user->unitFunction}} {{$user->rank}} @if( $user->statusID == 0) Czynny @else Wyłączony @endif + @if(auth()->user()->accessLevel() == 50) Edytuj Odznaczenia +
{{ csrf_field() }}
+ + @if( auth()->user()->id != $user->id) + @if ($user->statusID == 0) +
+ {{ csrf_field() }} + + +
+ @elseif ($user->statusID == 1) +
+ {{ csrf_field() }} + + +
+ @endif + @endif + + @endif - {{-- --}} - {{--
--}} - {{-- {{ csrf_field() }}--}} - {{--
--}} - {{-- --}} - {{-- --}} - {{--
--}} - {{--
--}} - {{-- --}} @php $i++; @endphp diff --git a/resources/views/fireFightersAdd.blade.php b/resources/views/fireFightersAdd.blade.php index 6450962..08a0185 100644 --- a/resources/views/fireFightersAdd.blade.php +++ b/resources/views/fireFightersAdd.blade.php @@ -3,11 +3,8 @@ @section('left-menu') @parent @stop @@ -62,7 +59,7 @@
- +
@include('inc.formerrors') diff --git a/resources/views/fireFightersEdit.blade.php b/resources/views/fireFightersEdit.blade.php index 66a2815..f919d03 100644 --- a/resources/views/fireFightersEdit.blade.php +++ b/resources/views/fireFightersEdit.blade.php @@ -3,11 +3,8 @@ @section('left-menu') @parent @stop @@ -39,7 +36,7 @@
- +
@include('inc.formerrors') diff --git a/resources/views/fireStationEdit.blade.php b/resources/views/fireStationEdit.blade.php index 67f48ac..a50b992 100644 --- a/resources/views/fireStationEdit.blade.php +++ b/resources/views/fireStationEdit.blade.php @@ -95,7 +95,7 @@
- +
@include('inc.formerrors') diff --git a/resources/views/inc/addFireStation.blade.php b/resources/views/inc/addFireStation.blade.php index 1d04f60..39fc31e 100644 --- a/resources/views/inc/addFireStation.blade.php +++ b/resources/views/inc/addFireStation.blade.php @@ -94,7 +94,7 @@
- +
@include('inc.formerrors') diff --git a/resources/views/login.blade.php b/resources/views/login.blade.php index 8e1301d..281d3a4 100644 --- a/resources/views/login.blade.php +++ b/resources/views/login.blade.php @@ -11,6 +11,9 @@ @endif + @if( auth()->check()) + Jesteś już zalogowany. + @else

Zaloguj się

@@ -21,7 +24,7 @@
- +
@@ -32,5 +35,5 @@
Nie pamiętam hasła - + @endif @endsection diff --git a/resources/views/operation.blade.php b/resources/views/operation.blade.php index f05bdca..c04c257 100644 --- a/resources/views/operation.blade.php +++ b/resources/views/operation.blade.php @@ -3,9 +3,16 @@ @section('left-menu') - @parent