forked from s421507/eOSP2
253 lines
9.3 KiB
PHP
253 lines
9.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Codedge\Fpdf\Fpdf\Fpdf;
|
|
use Illuminate\Http\Request;
|
|
use setasign\Fpdi\Fpdi;
|
|
|
|
use App\Common\Helpers;
|
|
|
|
class documentOverlayController extends Controller
|
|
{
|
|
public function wniosekNadaniePDF($userData, $decoration, $fireStation, $awardedDecorations){
|
|
// initiate FPDI
|
|
$pdf = new Fpdi();
|
|
$pdf->fontpath = "../app/Common/fonts/";
|
|
$pdf->AddFont('arialpl', '', 'arialpl.php');
|
|
#$pdf->AddFont('arialpl', 'B', 'arialplb.php');
|
|
// 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źń');
|
|
// $xyz = iconv('UTF-8', 'cp1250', $fireFighterID);
|
|
$dec = iconv('UTF-8', 'cp1250', $decoration);
|
|
// now write some text above the imported page
|
|
$pdf->SetFont('arialpl');
|
|
$pdf->SetTextColor(128, 128, 128);
|
|
|
|
#Pieczęć
|
|
$pdf->SetXY(30, 30);
|
|
// $pdf->Write(0, $decoration);
|
|
|
|
#Nazwa odznaczenia
|
|
$pdf->SetXY(120, 50);
|
|
//$pdf->Write(0, $decoration);
|
|
$pdf->Cell(20,10, Helpers::textConvert($decoration), 0, 0, 'C');
|
|
|
|
#Imie
|
|
$pdf->SetXY(35, 74);
|
|
//$pdf->Write(0, $decoration);
|
|
$pdf->Cell(20,10, Helpers::textConvert($userData->name), 0, 0, 'C');
|
|
|
|
|
|
#Nazwisko
|
|
$pdf->SetXY(95, 74);
|
|
//$pdf->Write(0, $decoration);
|
|
$pdf->Cell(20,10, Helpers::textConvert($userData->surname), 0, 0, 'C');
|
|
|
|
#Imie Ojca
|
|
$pdf->SetXY(153.5, 74);
|
|
//$pdf->Write(0, $decoration);
|
|
$pdf->Cell(20,10, Helpers::textConvert($userData->fathersName), 0, 0, 'C');
|
|
|
|
#Data Urodzenia
|
|
$pdf->SetXY(35, 93);
|
|
//$pdf->Write(0, $decoration);
|
|
$pdf->Cell(20,10, Helpers::textConvert(Helpers::peselBirthdayDate($userData->PESEL)), 0, 0, 'C');
|
|
|
|
#Data Urodzenia
|
|
$pdf->SetXY(124, 93);
|
|
//$pdf->Write(0, $decoration);
|
|
$pdf->Cell(20,10, Helpers::textConvert($userData->address.' '.$userData->apartment), 0, 0, 'C');
|
|
|
|
|
|
#Funkcja
|
|
$pdf->SetXY(124, 113);
|
|
$pdf->Cell(20,10, Helpers::textConvert($userData->unitFunction), 0, 0, 'C');
|
|
|
|
#Funkcja
|
|
$pdf->SetXY(35, 113);
|
|
$pdf->Cell(20,10, Helpers::textConvert($fireStation->postOffice), 0, 0, 'C');
|
|
|
|
$txt = "";
|
|
foreach($awardedDecorations as $awardedDecoration){
|
|
$txt = $txt." ".$awardedDecoration->decorationName." (".substr($awardedDecoration->dateOfAward,0,4).")\n";
|
|
}
|
|
$pdf->SetXY(18, 132);
|
|
$pdf->MultiCell(86,4, Helpers::textConvert($txt), 0, 'l', 0);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$pdf->Output();
|
|
exit;
|
|
|
|
}
|
|
|
|
public function kartaEwidencyjnaPDF($userData, $fireStation, $userTrainings){
|
|
// initiate FPDI
|
|
$pdf = new Fpdi();
|
|
$pdf->fontpath = "../app/Common/fonts/";
|
|
$pdf->AddFont('arialpl', '', 'arialpl.php');
|
|
// 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('arialpl');
|
|
$pdf->SetTextColor(128, 128, 128);
|
|
|
|
# Imie i nazwisko
|
|
$pdf->SetXY(85.5, 31.5);
|
|
$pdf->Cell(0, 10, Helpers::textConvert($userData->surname . ' ' . $userData->name), 0, 0, 'l');
|
|
|
|
# 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');
|
|
|
|
# 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, 102.5);
|
|
$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');
|
|
|
|
|
|
# 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');
|
|
|
|
|
|
$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, Helpers::textConvert($userTraining->trainingName), 0, 0, 'l');
|
|
$pdf->SetXY(162, $y);
|
|
$pdf->Cell(0, 10, Helpers::textConvert($userTraining->dateOfComplete), 0, 0, 'l');
|
|
$y = $y + 5.5;
|
|
$lp = $lp + 1;
|
|
}
|
|
}
|
|
}
|
|
|
|
$pdf->Output();
|
|
exit;
|
|
}
|
|
}
|