60 lines
1.7 KiB
PHP
60 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Service\Pdf;
|
|
|
|
use App\Entity\Disposition;
|
|
use App\Entity\Upload;
|
|
|
|
class InvoiceRenderer 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/invoice.pdf', $this->config['project_dir']);
|
|
$pdf->appendPdf($pdfTemplate);
|
|
$pdf->setPage(1);
|
|
|
|
$pdf->SetFont('Arial', '', 10);
|
|
|
|
$assignment = $disposition->getAssignment();
|
|
|
|
// Name
|
|
$pdf->Text(135,28.5, $pdf->encodeString($teamer->getFullName()));
|
|
|
|
// Address
|
|
$address = $teamer->getAddress();
|
|
$pdf->Text(135,39, $pdf->encodeString($address->getStreet()));
|
|
$pdf->Text(135,51, $pdf->encodeString($address->getPostCode(). ' '.$address->getCity()));
|
|
|
|
// Tax ID
|
|
$pdf->Text(144,62, $pdf->encodeString($teamer->getTaxId()));
|
|
|
|
// Invoice number
|
|
$pdf->SetFont('Arial', '', 12);
|
|
$number = $assignment->getEffectivePeriod()->start->format('d/m/Y');
|
|
$pdf->Text(85,116, $number);
|
|
|
|
$pdf->SetFont('Arial', '', 10);
|
|
|
|
// Bank account
|
|
$bankAccount = $teamer->getBankAccount();
|
|
$pdf->Text(36,233.5, $pdf->encodeString($bankAccount->getIban()));
|
|
$pdf->Text(36,241, $pdf->encodeString($bankAccount->getBic()));
|
|
$pdf->Text(36,248.5, $pdf->encodeString($bankAccount->getBank()));
|
|
|
|
|
|
// Current date
|
|
$date = (new \DateTimeImmutable())->format('d.m.Y');
|
|
$pdf->Text(38,264, $pdf->encodeString($date));
|
|
|
|
return $pdf;
|
|
}
|
|
}
|