Feat: Implement contract generation and up-/downloading
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service\Pdf;
|
||||
|
||||
use App\Entity\Disposition;
|
||||
|
||||
class ContractRenderer extends AbstractPdfRenderer
|
||||
{
|
||||
public function render(Disposition $disposition): Pdf
|
||||
{
|
||||
$pdf = new Pdf();
|
||||
|
||||
$pdf->SetAuthor('Continentale', true);
|
||||
$pdf->SetCreator('Continentale', 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);
|
||||
|
||||
$teamer = $disposition->getTeamer();
|
||||
$assignment = $disposition->getAssignment();
|
||||
$destination = $assignment->getDestination();
|
||||
|
||||
// Current date
|
||||
$date = (new \DateTimeImmutable())->format('d.m.Y');
|
||||
$pdf->Text(164,43, utf8_decode($date));
|
||||
|
||||
// Name
|
||||
$pdf->Text(45,67.75, utf8_decode($teamer));
|
||||
|
||||
// Address
|
||||
$pdf->Text(45,77.75, utf8_decode($teamer->getAddress()));
|
||||
|
||||
// Jobprofile
|
||||
$pdf->Text(21,104.5, utf8_decode($assignment->getJobProfile()->getName()));
|
||||
|
||||
// Period
|
||||
$dateFrom = $assignment->getTotalPeriod()->start->format('d.m.Y');
|
||||
$dateTo = $assignment->getTotalPeriod()->end->format('d.m.Y');
|
||||
$period = sprintf('%s - %s', $dateFrom, $dateTo);
|
||||
$pdf->Text(57,113, $period);
|
||||
|
||||
// Destination
|
||||
$pdf->Text(57,121.5, utf8_decode(sprintf('%s, %s', $destination->getProduct(), $destination->getHotel())));
|
||||
|
||||
// Set pointer to last page to include all
|
||||
$pdf->setPage($numberOfPages);
|
||||
|
||||
return $pdf;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user