feat: render additional info to teamer invoice
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service\Pdf;
|
||||
|
||||
use App\Entity\Disposition;
|
||||
use App\Entity\Upload;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
|
||||
class InvoiceApprover extends AbstractPdfRenderer
|
||||
{
|
||||
public function render(Disposition $disposition): Pdf
|
||||
{
|
||||
$teamer = $disposition->getTeamer();
|
||||
$invoice = $disposition->getDocumentByType(Upload::TYPE_INVOICE);
|
||||
$originalPdfFilename = $invoice->getFilename();
|
||||
|
||||
$pdf = new Pdf();
|
||||
|
||||
$pdf->SetAuthor($teamer->getFullName(), true);
|
||||
$pdf->SetCreator($teamer->getFullName(), true);
|
||||
|
||||
// Load template
|
||||
$filepath = sprintf('%s/uploads/invoice/%s', $this->config['project_dir'], $originalPdfFilename);
|
||||
$pdf->appendPdf($filepath);
|
||||
$pdf->setPage(1);
|
||||
|
||||
$pdf->SetFont('Arial', '', 11);
|
||||
$pdf->SetTextColor(0, 128, 0);
|
||||
$pdf->Text(116.5,84, utf8_decode('geprüft: '.$invoice->getApprovedBy()));
|
||||
|
||||
$this->createBackup($filepath);
|
||||
|
||||
$pdf->Output('F', $filepath);
|
||||
|
||||
return $pdf;
|
||||
}
|
||||
|
||||
private function createBackup(string $source): void
|
||||
{
|
||||
$filesystem = new Filesystem();
|
||||
|
||||
if (!$filesystem->exists($source)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$path = pathinfo($source, PATHINFO_DIRNAME);
|
||||
$filename = pathinfo($source, PATHINFO_FILENAME);
|
||||
$extension = pathinfo($source, PATHINFO_EXTENSION);
|
||||
|
||||
$target = sprintf('%s/%s.bak.%s', $path, $filename, $extension);
|
||||
|
||||
$filesystem->copy($source, $target);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Service\Pdf;
|
||||
|
||||
use App\Entity\Disposition;
|
||||
use App\Entity\Upload;
|
||||
|
||||
class InvoiceRenderer extends AbstractPdfRenderer
|
||||
{
|
||||
@@ -35,6 +36,18 @@ class InvoiceRenderer extends AbstractPdfRenderer
|
||||
// Tax ID
|
||||
$pdf->Text(144,62, utf8_decode($teamer->getTaxId()));
|
||||
|
||||
// Cost unit
|
||||
if (null !== $costUnit = $assignment->getDestination()->getCostUnit()) {
|
||||
$pdf->SetFont('Arial', '', 11);
|
||||
$pdf->Text(116.5,74, utf8_decode('Kostenstelle: '.$costUnit));
|
||||
}
|
||||
|
||||
// Cost center
|
||||
if (null !== $costCenter = $assignment->getCostCenter()) {
|
||||
$pdf->SetFont('Arial', '', 11);
|
||||
$pdf->Text(116.5,79, utf8_decode('Kostenträger: '.$costCenter));
|
||||
}
|
||||
|
||||
// Invoice number
|
||||
$pdf->SetFont('Arial', '', 12);
|
||||
$number = $assignment->getEffectivePeriod()->start->format('d/m/Y');
|
||||
|
||||
Reference in New Issue
Block a user