2020-03-25 00:20:45 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use Codedge\Fpdf\Fpdf\Fpdf;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use setasign\Fpdi\Fpdi;
|
|
|
|
|
2020-07-11 20:56:21 +02:00
|
|
|
use App\Common\Helpers;
|
|
|
|
|
2020-03-25 00:20:45 +01:00
|
|
|
class documentOverlayController extends Controller
|
|
|
|
{
|
2020-07-15 05:34:02 +02:00
|
|
|
public function wniosekNadaniePDF($userData, $decoration, $fireStation, $awardedDecorations){
|
2020-03-25 00:20:45 +01:00
|
|
|
// initiate FPDI
|
|
|
|
$pdf = new Fpdi();
|
2020-07-15 23:58:07 +02:00
|
|
|
$pdf->fontpath = "../app/Common/fonts/";
|
|
|
|
$pdf->AddFont('arialpl', '', 'arialpl.php');
|
|
|
|
#$pdf->AddFont('arialpl', 'B', 'arialplb.php');
|
2020-03-25 00:20:45 +01:00
|
|
|
// set the source file
|
|
|
|
$pageCount = $pdf->setSourceFile("../app/Http/Controllers/documentTemplates/a.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){
|
|
|
|
$str = iconv('UTF-8', 'cp1250', 'zazółcić gęślą jaźń');
|
2020-06-13 00:02:05 +02:00
|
|
|
// $xyz = iconv('UTF-8', 'cp1250', $fireFighterID);
|
|
|
|
$dec = iconv('UTF-8', 'cp1250', $decoration);
|
2020-03-25 00:20:45 +01:00
|
|
|
// now write some text above the imported page
|
2020-07-15 23:58:07 +02:00
|
|
|
$pdf->SetFont('arialpl');
|
2020-06-13 00:02:05 +02:00
|
|
|
$pdf->SetTextColor(128, 128, 128);
|
|
|
|
|
|
|
|
#Pieczęć
|
2020-03-25 00:20:45 +01:00
|
|
|
$pdf->SetXY(30, 30);
|
2020-06-13 00:02:05 +02:00
|
|
|
// $pdf->Write(0, $decoration);
|
|
|
|
|
|
|
|
#Nazwa odznaczenia
|
|
|
|
$pdf->SetXY(120, 50);
|
|
|
|
//$pdf->Write(0, $decoration);
|
2020-07-15 23:58:07 +02:00
|
|
|
$pdf->Cell(20,10, Helpers::textConvert($decoration), 0, 0, 'C');
|
2020-06-13 00:02:05 +02:00
|
|
|
|
|
|
|
#Imie
|
|
|
|
$pdf->SetXY(35, 74);
|
|
|
|
//$pdf->Write(0, $decoration);
|
2020-07-15 23:58:07 +02:00
|
|
|
$pdf->Cell(20,10, Helpers::textConvert($userData->name), 0, 0, 'C');
|
2020-06-13 00:02:05 +02:00
|
|
|
|
2020-07-20 18:07:27 +02:00
|
|
|
|
2020-06-13 00:02:05 +02:00
|
|
|
#Nazwisko
|
|
|
|
$pdf->SetXY(95, 74);
|
|
|
|
//$pdf->Write(0, $decoration);
|
2020-07-15 23:58:07 +02:00
|
|
|
$pdf->Cell(20,10, Helpers::textConvert($userData->surname), 0, 0, 'C');
|
2020-06-13 00:02:05 +02:00
|
|
|
|
2020-07-20 18:07:27 +02:00
|
|
|
#Imie Ojca
|
|
|
|
$pdf->SetXY(153.5, 74);
|
|
|
|
//$pdf->Write(0, $decoration);
|
|
|
|
$pdf->Cell(20,10, Helpers::textConvert($userData->fathersName), 0, 0, 'C');
|
|
|
|
|
2020-06-13 00:02:05 +02:00
|
|
|
#Data Urodzenia
|
|
|
|
$pdf->SetXY(35, 93);
|
|
|
|
//$pdf->Write(0, $decoration);
|
2020-07-15 23:58:07 +02:00
|
|
|
$pdf->Cell(20,10, Helpers::textConvert(Helpers::peselBirthdayDate($userData->PESEL)), 0, 0, 'C');
|
2020-07-11 20:56:21 +02:00
|
|
|
|
2020-07-20 18:07:27 +02:00
|
|
|
#Data Urodzenia
|
|
|
|
$pdf->SetXY(124, 93);
|
|
|
|
//$pdf->Write(0, $decoration);
|
|
|
|
$pdf->Cell(20,10, Helpers::textConvert($userData->address.' '.$userData->apartment), 0, 0, 'C');
|
|
|
|
|
2020-06-13 00:02:05 +02:00
|
|
|
|
|
|
|
#Funkcja
|
|
|
|
$pdf->SetXY(124, 113);
|
2020-07-15 23:58:07 +02:00
|
|
|
$pdf->Cell(20,10, Helpers::textConvert($userData->unitFunction), 0, 0, 'C');
|
2020-06-13 00:02:05 +02:00
|
|
|
|
|
|
|
#Funkcja
|
|
|
|
$pdf->SetXY(35, 113);
|
2020-07-15 23:58:07 +02:00
|
|
|
$pdf->Cell(20,10, Helpers::textConvert($fireStation->postOffice), 0, 0, 'C');
|
2020-07-15 05:34:02 +02:00
|
|
|
|
|
|
|
$txt = "";
|
|
|
|
foreach($awardedDecorations as $awardedDecoration){
|
|
|
|
$txt = $txt." ".$awardedDecoration->decorationName."\n";
|
|
|
|
}
|
|
|
|
$pdf->SetXY(18, 132);
|
2020-07-15 23:58:07 +02:00
|
|
|
$pdf->MultiCell(86,4, Helpers::textConvert($txt), 0, 'l', 0);
|
2020-03-25 00:20:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$pdf->Output();
|
2020-07-20 11:42:06 +02:00
|
|
|
exit;
|
2020-03-25 00:20:45 +01:00
|
|
|
|
|
|
|
}
|
2020-07-11 20:56:21 +02:00
|
|
|
|
|
|
|
public function kartaEwidencyjnaPDF($userData, $fireStation, $userTrainings){
|
|
|
|
// initiate FPDI
|
|
|
|
$pdf = new Fpdi();
|
2020-07-15 23:58:07 +02:00
|
|
|
$pdf->fontpath = "../app/Common/fonts/";
|
|
|
|
$pdf->AddFont('arialpl', '', 'arialpl.php');
|
2020-07-11 20:56:21 +02:00
|
|
|
// 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) {
|
2020-07-15 23:58:07 +02:00
|
|
|
$pdf->SetFont('arialpl');
|
2020-07-11 20:56:21 +02:00
|
|
|
$pdf->SetTextColor(128, 128, 128);
|
|
|
|
|
|
|
|
# Imie i nazwisko
|
2020-07-20 18:07:27 +02:00
|
|
|
$pdf->SetXY(85.5, 31.5);
|
2020-07-15 23:58:07 +02:00
|
|
|
$pdf->Cell(0, 10, Helpers::textConvert($userData->surname . ' ' . $userData->name), 0, 0, 'l');
|
2020-07-11 20:56:21 +02:00
|
|
|
|
2020-07-20 18:07:27 +02:00
|
|
|
# Drugie Imie
|
|
|
|
$pdf->SetXY(85.5, 39.0);
|
|
|
|
$pdf->Cell(0, 10, Helpers::textConvert($userData->secondName), 0, 0, 'l');
|
|
|
|
|
|
|
|
# Imie Ojca
|
|
|
|
$pdf->SetXY(85.5, 46.5);
|
|
|
|
$pdf->Cell(0, 10, Helpers::textConvert($userData->fathersName), 0, 0, 'l');
|
|
|
|
|
|
|
|
# Imie Mama
|
|
|
|
$pdf->SetXY(137.5, 46.5);
|
|
|
|
$pdf->Cell(0, 10, Helpers::textConvert($userData->mothersName), 0, 0, 'l');
|
|
|
|
|
2020-07-11 20:56:21 +02:00
|
|
|
# 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
|
2020-07-20 18:07:27 +02:00
|
|
|
$pdf->SetXY(102, 102.5);
|
2020-07-11 20:56:21 +02:00
|
|
|
$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');
|
|
|
|
|
2020-07-20 18:07:27 +02:00
|
|
|
|
|
|
|
# Miejsce Urodzenia
|
|
|
|
$pdf->SetXY(54, 62.5);
|
|
|
|
$pdf->Cell(0, 10, Helpers::textConvert($userData->placeOfBirth), 0, 0, 'l');
|
|
|
|
|
|
|
|
# Data wstąpienia do OSP
|
|
|
|
$pdf->SetXY(16, 84.5);
|
|
|
|
$pdf->Cell(0, 10, Helpers::textConvert($userData->joiningOSPDate), 0, 0, 'l');
|
|
|
|
|
|
|
|
# Kategorie prawa jazdy
|
|
|
|
$pdf->SetXY(55, 84.5);
|
|
|
|
$pdf->Cell(0, 10, Helpers::textConvert($userData->driversLicense), 0, 0, 'l');
|
|
|
|
|
|
|
|
|
|
|
|
# Adres zamieszkania
|
|
|
|
$pdf->SetXY(48, 95.5);
|
|
|
|
$pdf->Cell(0, 10, Helpers::textConvert($userData->address), 0, 0, 'l');
|
|
|
|
|
|
|
|
# Numer mieszkania
|
|
|
|
$pdf->SetXY(136, 95.5);
|
|
|
|
$pdf->Cell(0, 10, Helpers::textConvert($userData->apartment), 0, 0, 'l');
|
|
|
|
|
|
|
|
# Numer telefonu
|
|
|
|
$pdf->SetXY(37, 102.5);
|
|
|
|
$pdf->Cell(0, 10, Helpers::textConvert($userData->homePhoneNumber), 0, 0, 'l');
|
|
|
|
|
|
|
|
# Numer identyfikacji członskowkiej
|
|
|
|
$pdf->SetXY(158, 102.5);
|
|
|
|
$pdf->Cell(0, 10, Helpers::textConvert($userData->identityCardNumber), 0, 0, 'l');
|
|
|
|
|
|
|
|
|
|
|
|
# Wykształcenie
|
|
|
|
$pdf->SetXY(39, 112.5);
|
|
|
|
$pdf->Cell(0, 10, Helpers::textConvert($userData->education), 0, 0, 'l');
|
|
|
|
|
|
|
|
# Zawód wyuczony
|
|
|
|
$pdf->SetXY(123, 112.5);
|
|
|
|
$pdf->Cell(0, 10, Helpers::textConvert($userData->profession), 0, 0, 'l');
|
|
|
|
|
|
|
|
# Seria i numer dowodu osobistego oraz data
|
|
|
|
$seria_x = 96.3;
|
|
|
|
$seria = $userData->IDSeries;
|
|
|
|
for ($i=0; $i<3; $i++) {
|
|
|
|
$pdf->SetXY($seria_x, 81.3);
|
|
|
|
$pdf->Cell(0, 10, Helpers::textConvert($seria[$i]), 0, 0, 'l');
|
|
|
|
$seria_x = $seria_x + 6.65;
|
|
|
|
}
|
|
|
|
|
|
|
|
$numer_x = 123.4;
|
|
|
|
$numer = $userData->IDNumber;
|
|
|
|
for ($i=0; $i<6; $i++) {
|
|
|
|
$pdf->SetXY($numer_x, 81.3);
|
|
|
|
$pdf->Cell(0, 10, Helpers::textConvert($numer[$i]), 0, 0, 'l');
|
|
|
|
$numer_x = $numer_x + 6.65;
|
|
|
|
}
|
|
|
|
|
|
|
|
$pdf->SetXY(169.8, 81.3);
|
|
|
|
$pdf->Cell(0, 10, Helpers::textConvert($userData->IDValidUntil), 0, 0, 'l');
|
|
|
|
|
|
|
|
|
2020-07-11 20:56:21 +02:00
|
|
|
$y = 182;
|
|
|
|
$lp = 1;
|
|
|
|
foreach($userTrainings as $userTraining){
|
|
|
|
$pdf->SetXY(20, $y);
|
|
|
|
$pdf->Cell(0, 10, $lp, 0, 0, 'l');
|
|
|
|
$pdf->SetXY(26, $y);
|
2020-07-15 23:58:07 +02:00
|
|
|
$pdf->Cell(0, 10, Helpers::textConvert($userTraining->trainingName), 0, 0, 'l');
|
2020-07-11 20:56:21 +02:00
|
|
|
$pdf->SetXY(162, $y);
|
2020-07-15 23:58:07 +02:00
|
|
|
$pdf->Cell(0, 10, Helpers::textConvert($userTraining->dateOfComplete), 0, 0, 'l');
|
2020-07-11 20:56:21 +02:00
|
|
|
$y = $y + 5.5;
|
|
|
|
$lp = $lp + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$pdf->Output();
|
2020-07-20 11:42:06 +02:00
|
|
|
exit;
|
2020-07-11 20:56:21 +02:00
|
|
|
}
|
2020-03-25 00:20:45 +01:00
|
|
|
}
|