eOSP2/app/Http/Controllers/documentOverlayController.php

170 lines
6.0 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
{
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
#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
#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-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');
$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();
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
$pdf->SetXY(84, 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
# 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);
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();
exit;
2020-07-11 20:56:21 +02:00
}
2020-03-25 00:20:45 +01:00
}