eOSP2/app/Http/Controllers/documentOverlayController.php

157 lines
5.2 KiB
PHP
Raw Normal View History

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-11 20:56:21 +02:00
public function wniosekNadaniePDF($userData, $decoration, $fireStation){
2020-03-25 00:20:45 +01:00
// initiate FPDI
$pdf = new Fpdi();
// 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
$pdf->SetFont('times');
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-11 20:56:21 +02:00
$pdf->Cell(20,10, $decoration, 0, 0, 'C');
2020-06-13 00:02:05 +02:00
#Imie
$pdf->SetXY(35, 74);
//$pdf->Write(0, $decoration);
2020-07-11 20:56:21 +02:00
$pdf->Cell(20,10, $userData->name, 0, 0, 'C');
2020-06-13 00:02:05 +02:00
#Nazwisko
$pdf->SetXY(95, 74);
//$pdf->Write(0, $decoration);
2020-07-11 20:56:21 +02:00
$pdf->Cell(20,10, $userData->surname, 0, 0, 'C');
2020-06-13 00:02:05 +02:00
#Data Urodzenia
$pdf->SetXY(35, 93);
//$pdf->Write(0, $decoration);
2020-07-11 20:56:21 +02:00
$pdf->Cell(20,10, Helpers::peselBirthdayDate($userData->PESEL), 0, 0, 'C');
2020-06-13 00:02:05 +02:00
#Funkcja
$pdf->SetXY(124, 113);
2020-07-11 20:56:21 +02:00
$pdf->Cell(20,10, $userData->unitFunction, 0, 0, 'C');
2020-06-13 00:02:05 +02:00
#Funkcja
$pdf->SetXY(35, 113);
2020-07-11 20:56:21 +02:00
$pdf->Cell(20,10, $fireStation->postOffice, 0, 0, 'C');
2020-03-25 00:20:45 +01:00
}
}
$pdf->Output();
}
2020-07-11 20:56:21 +02:00
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();
}
2020-03-25 00:20:45 +01:00
}