56 lines
1.6 KiB
PHP
56 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Service\Pdf;
|
|
|
|
use App\Entity\Disposition;
|
|
|
|
class ContractRenderer extends AbstractPdfRenderer
|
|
{
|
|
public function render(Disposition $disposition): Pdf
|
|
{
|
|
$teamer = $disposition->getTeamer();
|
|
|
|
$pdf = new Pdf();
|
|
|
|
$pdf->SetAuthor($teamer->getFullName(), true);
|
|
$pdf->SetCreator($teamer->getFullName(), true);
|
|
|
|
// Load template
|
|
$pdfTemplate = sprintf('%s/assets/pdf/contract.pdf', $this->config['project_dir']);
|
|
$numberOfPages = $pdf->appendPdf($pdfTemplate);
|
|
$pdf->setPage(1);
|
|
|
|
$pdf->SetFont('Arial', '', 10);
|
|
|
|
$assignment = $disposition->getAssignment();
|
|
$destination = $assignment->getDestination();
|
|
|
|
// Current date
|
|
$date = (new \DateTimeImmutable())->format('d.m.Y');
|
|
$pdf->Text(164,43, $pdf->encodeString($date));
|
|
|
|
// Name
|
|
$pdf->Text(45,67.75, $pdf->encodeString($teamer));
|
|
|
|
// Address
|
|
$pdf->Text(45,77.75, $pdf->encodeString($teamer->getAddress()));
|
|
|
|
// Jobprofile
|
|
$pdf->Text(21,104.5, $pdf->encodeString($assignment->getJobProfile()->getName()));
|
|
|
|
// Period
|
|
$dateFrom = $assignment->getEffectivePeriod()->start->format('d.m.Y');
|
|
$dateTo = $assignment->getEffectivePeriod()->end->format('d.m.Y');
|
|
$period = sprintf('%s - %s', $dateFrom, $dateTo);
|
|
$pdf->Text(57,113, $period);
|
|
|
|
// Destination
|
|
$pdf->Text(57,121.5, $pdf->encodeString(sprintf('%s, %s', $destination->getProduct(), $destination->getHotel())));
|
|
|
|
// Set pointer to last page to include all
|
|
$pdf->setPage($numberOfPages);
|
|
|
|
return $pdf;
|
|
}
|
|
}
|