diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 217a262..d710b9c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,20 +2,10 @@ - - - - - - - - - - - - - + + + @@ -286,16 +281,10 @@ - - - - - - @@ -304,7 +293,6 @@ - @@ -313,18 +301,13 @@ - + - - - - + + + - - - - - + \ No newline at end of file diff --git a/app/Http/Controllers/documentApplicationController.php b/app/Http/Controllers/documentApplicationController.php index 6b5f3dc..d7623e5 100644 --- a/app/Http/Controllers/documentApplicationController.php +++ b/app/Http/Controllers/documentApplicationController.php @@ -11,7 +11,11 @@ class documentApplicationController extends Controller if(auth()->user() != null && auth()->user()->fireStationID != null ){ $fireFighters = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID )->get(); - return view("documentApplicationForm", ["fireFighters" => $fireFighters]); + $decoration = DB::table('decorations')->pluck('decorationName', 'id'); + return view("documentApplicationForm") + ->with(compact('decoration')) + ->with(compact('fireFighters')); + } else{ return view('home'); } @@ -22,7 +26,16 @@ class documentApplicationController extends Controller if(auth()->user() != null && auth()->user()->fireStationID != null ) { $request = request(); $test = new documentOverlayController(); - $test->testPdf($request->fireFighterID); + + $userData = DB::table('users')->where("users.id", '=', $request->fireFighterID) + ->leftJoin('ranks', 'users.degreeID', '=', 'ranks.id') + ->leftJoin('unitFunctions', 'users.functionID', '=', 'unitFunctions.id') + ->select('users.id','users.name', 'users.surname', 'users.PESEL', 'users.fireStationID','users.phoneNumber', 'users.email', 'ranks.rank', 'unitFunctions.unitFunction', 'users.number') + ->first(); + + $fireStation = DB::table('firestations')->where("id", '=', $userData->fireStationID)->first(); + + $test->testPdf($userData, $request->decoration, $fireStation); } } } diff --git a/app/Http/Controllers/documentOverlayController.php b/app/Http/Controllers/documentOverlayController.php index 4ef5eef..3f38d0a 100644 --- a/app/Http/Controllers/documentOverlayController.php +++ b/app/Http/Controllers/documentOverlayController.php @@ -9,7 +9,38 @@ use setasign\Fpdi\Fpdi; class documentOverlayController extends Controller { // - public function testPdf($fireFighterID){ + + + public function peselBirthDay($pesel){ + $pesel = (String) $pesel; + $output = $pesel[2]; + $output = (int)$output; + if( $output == 0 || $output == 1){ + $year = '19'."".(String)$pesel[0]."".(String)$pesel[1]; + }elseif( $output == 2 || $output == 3){ + $year = '20'."".(String)$pesel[0]."".(String)$pesel[1]; + }elseif( $output == 4 || $output == 5){ + $year = '21'."".(String)$pesel[0]."".(String)$pesel[1]; + }elseif( $output == 6 || $output == 7){ + $year = '22'."".(String)$pesel[0]."".(String)$pesel[1]; + }elseif( $output == 8 || $output == 9){ + $year = '18'."".(String)$pesel[0]."".(String)$pesel[1]; + } + + if($output % 2 == 0 ){ + $month = '0'."".(String)$pesel[3]; + }else{ + $month = '1'."".(String)$pesel[3]; + } + + $day = (String)$pesel[4]."".(String)$pesel[5]; + + return $day.".".$month.".".$year; + } + + + + public function testPdf($userData, $decoration, $fireStation){ // initiate FPDI $pdf = new Fpdi(); // set the source file @@ -32,12 +63,43 @@ class documentOverlayController extends Controller if($pageNo == 1){ $str = iconv('UTF-8', 'cp1250', 'zazółcić gęślą jaźń'); - $xyz = iconv('UTF-8', 'cp1250', $fireFighterID); +// $xyz = iconv('UTF-8', 'cp1250', $fireFighterID); + $dec = iconv('UTF-8', 'cp1250', $decoration); // now write some text above the imported page $pdf->SetFont('times'); - $pdf->SetTextColor(255, 0, 0); + $pdf->SetTextColor(128, 128, 128); + + #Pieczęć $pdf->SetXY(30, 30); - $pdf->Write(0, $xyz); +// $pdf->Write(0, $decoration); + + #Nazwa odznaczenia + $pdf->SetXY(120, 50); + //$pdf->Write(0, $decoration); + $pdf->Cell(20,10, $decoration, 1, 0, 'C'); + + #Imie + $pdf->SetXY(35, 74); + //$pdf->Write(0, $decoration); + $pdf->Cell(20,10, $userData->name, 1, 0, 'C'); + + #Nazwisko + $pdf->SetXY(95, 74); + //$pdf->Write(0, $decoration); + $pdf->Cell(20,10, $userData->surname, 1, 0, 'C'); + + #Data Urodzenia + $pdf->SetXY(35, 93); + //$pdf->Write(0, $decoration); + $pdf->Cell(20,10, $this->peselBirthDay($userData->PESEL), 1, 0, 'C'); + + #Funkcja + $pdf->SetXY(124, 113); + $pdf->Cell(20,10, $userData->unitFunction, 1, 0, 'C'); + + #Funkcja + $pdf->SetXY(35, 113); + $pdf->Cell(20,10, $fireStation->postOffice, 1, 0, 'C'); } } diff --git a/resources/views/documentApplicationForm.blade.php b/resources/views/documentApplicationForm.blade.php index 77427c3..361cb99 100644 --- a/resources/views/documentApplicationForm.blade.php +++ b/resources/views/documentApplicationForm.blade.php @@ -20,6 +20,20 @@ +
+ + +
+