diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index d710b9c..3acd8b8 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -3,9 +3,14 @@
+
+
-
+
+
+
+
@@ -166,7 +171,7 @@
-
+
@@ -175,10 +180,6 @@
-
-
-
-
@@ -186,6 +187,10 @@
+
+
+
+
@@ -257,7 +262,12 @@
-
+
+
+
+
+
+
@@ -265,49 +275,25 @@
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/app/Common/Helpers.php b/app/Common/Helpers.php
index b3d9bbc..ece701a 100644
--- a/app/Common/Helpers.php
+++ b/app/Common/Helpers.php
@@ -1 +1,62 @@
user() != null && auth()->user()->fireStationID != null ){
$fireFighters = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID )->get();
$decoration = DB::table('decorations')->pluck('decorationName', 'id');
- return view("documentApplicationForm")
+ return view("wniosekNadanieForm")
->with(compact('decoration'))
->with(compact('fireFighters'));
@@ -22,7 +22,18 @@ class documentApplicationController extends Controller
}
- public function printPDF(){
+ public function createKartaEwidencyjnaForm(){
+ if(auth()->user() != null && auth()->user()->fireStationID != null ){
+ $fireFighters = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID )->get();
+ $decoration = DB::table('decorations')->pluck('decorationName', 'id');
+ return view("kartaEwidencyjnaForm")
+ ->with(compact('fireFighters'));
+ }else{
+ return view('home');
+ }
+ }
+
+ public function printWniosekNadaniePDF(){
if(auth()->user() != null && auth()->user()->fireStationID != null ) {
$request = request();
$test = new documentOverlayController();
@@ -35,7 +46,29 @@ class documentApplicationController extends Controller
$fireStation = DB::table('firestations')->where("id", '=', $userData->fireStationID)->first();
- $test->testPdf($userData, $request->decoration, $fireStation);
+ $test->wniosekNadaniePDF($userData, $request->decoration, $fireStation);
+ }
+ }
+
+
+ public function printKartaEwidencyjnaPDF(){
+ if(auth()->user() != null && auth()->user()->fireStationID != null ) {
+ $request = request();
+ $test = new documentOverlayController();
+
+ $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();
+
+ $userTrainings = DB::table('trainingsfirefighters')->where("trainingsfirefighters.firefighterID", '=', $request->fireFighterID)
+ ->leftJoin('trainings', 'trainingsfirefighters.trainingID', '=', 'trainings.id')
+ ->get();
+
+ $fireStation = DB::table('firestations')->where("id", '=', $userData->fireStationID)->first();
+
+ $test->kartaEwidencyjnaPDF($userData, $fireStation, $userTrainings);
}
}
}
diff --git a/app/Http/Controllers/documentOverlayController.php b/app/Http/Controllers/documentOverlayController.php
index 3f38d0a..cd4e5b1 100644
--- a/app/Http/Controllers/documentOverlayController.php
+++ b/app/Http/Controllers/documentOverlayController.php
@@ -6,41 +6,11 @@ use Codedge\Fpdf\Fpdf\Fpdf;
use Illuminate\Http\Request;
use setasign\Fpdi\Fpdi;
+use App\Common\Helpers;
+
class documentOverlayController extends Controller
{
- //
-
-
- 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){
+ public function wniosekNadaniePDF($userData, $decoration, $fireStation){
// initiate FPDI
$pdf = new Fpdi();
// set the source file
@@ -76,30 +46,31 @@ class documentOverlayController extends Controller
#Nazwa odznaczenia
$pdf->SetXY(120, 50);
//$pdf->Write(0, $decoration);
- $pdf->Cell(20,10, $decoration, 1, 0, 'C');
+ $pdf->Cell(20,10, $decoration, 0, 0, 'C');
#Imie
$pdf->SetXY(35, 74);
//$pdf->Write(0, $decoration);
- $pdf->Cell(20,10, $userData->name, 1, 0, 'C');
+ $pdf->Cell(20,10, $userData->name, 0, 0, 'C');
#Nazwisko
$pdf->SetXY(95, 74);
//$pdf->Write(0, $decoration);
- $pdf->Cell(20,10, $userData->surname, 1, 0, 'C');
+ $pdf->Cell(20,10, $userData->surname, 0, 0, 'C');
#Data Urodzenia
$pdf->SetXY(35, 93);
//$pdf->Write(0, $decoration);
- $pdf->Cell(20,10, $this->peselBirthDay($userData->PESEL), 1, 0, 'C');
+ $pdf->Cell(20,10, Helpers::peselBirthdayDate($userData->PESEL), 0, 0, 'C');
+
#Funkcja
$pdf->SetXY(124, 113);
- $pdf->Cell(20,10, $userData->unitFunction, 1, 0, 'C');
+ $pdf->Cell(20,10, $userData->unitFunction, 0, 0, 'C');
#Funkcja
$pdf->SetXY(35, 113);
- $pdf->Cell(20,10, $fireStation->postOffice, 1, 0, 'C');
+ $pdf->Cell(20,10, $fireStation->postOffice, 0, 0, 'C');
}
}
@@ -109,4 +80,77 @@ class documentOverlayController extends Controller
}
+
+ public function kartaEwidencyjnaPDF($userData, $fireStation, $userTrainings){
+ // initiate FPDI
+ $pdf = new Fpdi();
+ // set the source file
+ $pageCount = $pdf->setSourceFile("../app/Http/Controllers/documentTemplates/b.pdf");
+ // import page 1
+
+ for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
+ // import a page
+ $templateId = $pdf->importPage($pageNo);
+ // get the size of the imported page
+ $size = $pdf->getTemplateSize($templateId);
+
+ // create a page (landscape or portrait depending on the imported page size)
+ if ($size[0] > $size[1]) {
+ $pdf->AddPage('L', array($size[0], $size[1]));
+ } else {
+ $pdf->AddPage('P', array($size[0], $size[1]));
+ }
+ $pdf->useTemplate($templateId);
+
+
+ if($pageNo == 1) {
+ $pdf->SetFont('times');
+ $pdf->SetTextColor(128, 128, 128);
+
+ # Imie i nazwisko
+ $pdf->SetXY(84, 31.5);
+ $pdf->Cell(0, 10, $userData->surname . ' ' . $userData->name, 0, 0, 'l');
+
+ # PESEL
+ $peselArray = str_split($userData->PESEL);
+ $x = 116;
+ foreach ($peselArray as $char) {
+ $pdf->SetXY($x, 62.5);
+ $pdf->Cell(0, 10, $char, 0, 0, 'l');
+ $x = $x + 7.35;
+ }
+
+ # Numer Telefonu
+ $pdf->SetXY(102, 103);
+ $pdf->Cell(0, 10, $userData->phoneNumber, 0, 0, 'l');
+
+ # Data urodzenia
+ $birthdayArray = Helpers::peselBirthdayDateARRAY($userData->PESEL);
+ #Day
+ $pdf->SetXY(16, 62.5);
+ $pdf->Cell(0, 10, $birthdayArray[0], 0, 0, 'l');
+ #Month
+ $pdf->SetXY(26.5, 62.5);
+ $pdf->Cell(0, 10, $birthdayArray[1], 0, 0, 'l');
+ #Month
+ $pdf->SetXY(37.5, 62.5);
+ $pdf->Cell(0, 10, $birthdayArray[2], 0, 0, 'l');
+
+ $y = 182;
+ $lp = 1;
+ foreach($userTrainings as $userTraining){
+ $pdf->SetXY(20, $y);
+ $pdf->Cell(0, 10, $lp, 0, 0, 'l');
+ $pdf->SetXY(26, $y);
+ $pdf->Cell(0, 10, $userTraining->trainingName, 0, 0, 'l');
+ $pdf->SetXY(162, $y);
+ $pdf->Cell(0, 10, $userTraining->dateOfComplete, 0, 0, 'l');
+ $y = $y + 5.5;
+ $lp = $lp + 1;
+ }
+ }
+ }
+
+ $pdf->Output();
+ }
}
diff --git a/app/Http/Controllers/documentTemplates/b.pdf b/app/Http/Controllers/documentTemplates/b.pdf
new file mode 100644
index 0000000..7b71fe8
Binary files /dev/null and b/app/Http/Controllers/documentTemplates/b.pdf differ
diff --git a/app/Http/Controllers/wniosek_o_nadanie_odznaczenia.pdf b/app/Http/Controllers/wniosek_o_nadanie_odznaczenia.pdf
deleted file mode 100644
index d959408..0000000
Binary files a/app/Http/Controllers/wniosek_o_nadanie_odznaczenia.pdf and /dev/null differ
diff --git a/resources/views/documents.blade.php b/resources/views/documents.blade.php
index bb53c33..7898c8c 100644
--- a/resources/views/documents.blade.php
+++ b/resources/views/documents.blade.php
@@ -24,10 +24,15 @@
-
+
+
@endif
@endif
@stop
diff --git a/resources/views/kartaEwidencyjnaForm.blade.php b/resources/views/kartaEwidencyjnaForm.blade.php
index b3d9bbc..d74a805 100644
--- a/resources/views/kartaEwidencyjnaForm.blade.php
+++ b/resources/views/kartaEwidencyjnaForm.blade.php
@@ -1 +1,34 @@
-check())
+ @if( auth()->user()->fireStationID == NULL)
+ Jednostka nie istnieje
+ @else
+
+ @endif
+ @else
+ Brak autoryzacji
+ @endif
+
+@stop
diff --git a/routes/web.php b/routes/web.php
index d8d4a56..b1daed3 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -133,6 +133,8 @@ Route::post('/pdf/strazacy', 'pdfController@createViewFireFighters');
Route::get('/forgottenPassword', 'resetPasswordController@create');
Route::post('/forgottenPassword', 'resetPasswordController@reset');
-Route::get('/pdf/test', 'documentOverlayController@testPdf');
-Route::post('/dokumentacja/wniosek', 'documentApplicationController@create');
-Route::post('/dokumentacja/wniosek/pdf', 'documentApplicationController@printPDF');
+Route::post('/dokumentacja/wniosek_o_nadanie', 'documentApplicationController@createWniosekNadanieForm');
+Route::post('/dokumentacja/wniosek_o_nadanie/pdf', 'documentApplicationController@printWniosekNadaniePDF');
+
+Route::post('/dokumentacja/karta_ewidencyjna', 'documentApplicationController@createKartaEwidencyjnaForm');
+Route::post('/dokumentacja/karta_ewidencyjna/pdf', 'documentApplicationController@printKartaEwidencyjnaPDF');