chore: code cleanup

This commit is contained in:
Björn Fromme
2025-08-21 14:20:43 +02:00
parent c4e28818e0
commit e36009008c
273 changed files with 547 additions and 531 deletions
+6 -6
View File
@@ -27,25 +27,25 @@ class ContractRenderer extends AbstractPdfRenderer
// Current date
$date = (new \DateTimeImmutable())->format('d.m.Y');
$pdf->Text(164,43, $pdf->encodeString($date));
$pdf->Text(164, 43, $pdf->encodeString($date));
// Name
$pdf->Text(45,67.75, $pdf->encodeString($teamer));
$pdf->Text(45, 67.75, $pdf->encodeString($teamer));
// Address
$pdf->Text(45,77.75, $pdf->encodeString($teamer->getAddress()));
$pdf->Text(45, 77.75, $pdf->encodeString($teamer->getAddress()));
// Jobprofile
$pdf->Text(21,104.5, $pdf->encodeString($assignment->getJobProfile()->getName()));
$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);
$pdf->Text(57, 113, $period);
// Destination
$pdf->Text(57,121.5, $pdf->encodeString(sprintf('%s, %s', $destination->getProduct(), $destination->getHotel())));
$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);
+3 -3
View File
@@ -39,19 +39,19 @@ class InvoiceApprover extends AbstractPdfRenderer
// Cost unit job profile
if (null !== $costUnit = $assignment->getJobProfile()->getCostUnit()) {
$pdf->SetFont('Arial', '', 11);
$pdf->Text(20,20, $pdf->encodeString('Kostenstelle 1: '.$costUnit));
$pdf->Text(20, 20, $pdf->encodeString('Kostenstelle 1: '.$costUnit));
}
// Cost unit destination/hotel
if (null !== $costUnit = $assignment->getDestination()->getCostUnit()) {
$pdf->SetFont('Arial', '', 11);
$pdf->Text(20,25, $pdf->encodeString('Kostenstelle 2: '.$costUnit));
$pdf->Text(20, 25, $pdf->encodeString('Kostenstelle 2: '.$costUnit));
}
// Approval
$pdf->SetFont('Arial', '', 11);
$pdf->SetTextColor(0, 128, 0);
$pdf->Text(20,30, $pdf->encodeString('geprüft: '.$invoice->getApprovedBy()));
$pdf->Text(20, 30, $pdf->encodeString('geprüft: '.$invoice->getApprovedBy()));
$this->createBackup($filepath);
+9 -11
View File
@@ -3,7 +3,6 @@
namespace App\Service\Pdf;
use App\Entity\Disposition;
use App\Entity\Upload;
class InvoiceRenderer extends AbstractPdfRenderer
{
@@ -26,33 +25,32 @@ class InvoiceRenderer extends AbstractPdfRenderer
$assignment = $disposition->getAssignment();
// Name
$pdf->Text(135,28.5, $pdf->encodeString($teamer->getFullName()));
$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()));
$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() ?? '-'));
$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->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() ?? '-'));
$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));
$pdf->Text(38, 264, $pdf->encodeString($date));
return $pdf;
}
+13 -13
View File
@@ -85,7 +85,7 @@ class Pdf extends Fpdi
* maintaining its aspect ratio. An optional title can be added at the top.
*
* @param string $sourceFile Path to the image file to display
* @param string $pageTitle Optional title text to display at the top of the page
* @param string $pageTitle Optional title text to display at the top of the page
*/
public function appendImage(string $sourceFile, string $pageTitle = ''): void
{
@@ -113,18 +113,18 @@ class Pdf extends Fpdi
* while maintaining aspect ratio, then positions it in the center. Handles
* image loading errors gracefully by displaying an error message.
*
* @param string $imgPath Path to the image file
* @param int $x X-coordinate of the container's top-left corner
* @param int $y Y-coordinate of the container's top-left corner
* @param int $containerWidth Width of the container area
* @param int $containerHeight Height of the container area
* @param string $imgPath Path to the image file
* @param int $x X-coordinate of the container's top-left corner
* @param int $y Y-coordinate of the container's top-left corner
* @param int $containerWidth Width of the container area
* @param int $containerHeight Height of the container area
*/
public function centerImage(
string $imgPath,
int $x = 0,
int $y = 0,
int $containerWidth = self::A4_WIDTH,
int $containerHeight = self::A4_HEIGHT
int $containerHeight = self::A4_HEIGHT,
): void {
[$width, $height] = $this->resizeToFit($imgPath, $containerWidth, $containerHeight);
@@ -151,7 +151,7 @@ class Pdf extends Fpdi
*/
protected function pixelsToMm($val): int
{
return (int) (round($val * $this::MM_IN_INCH / self::DPI));
return (int) round($val * $this::MM_IN_INCH / self::DPI);
}
/**
@@ -163,7 +163,7 @@ class Pdf extends Fpdi
*/
protected function mmToPixels($val): int
{
return (int) (round($this::DPI * $val / $this::MM_IN_INCH));
return (int) round($this::DPI * $val / $this::MM_IN_INCH);
}
/**
@@ -173,16 +173,16 @@ class Pdf extends Fpdi
* size that fits within the maximum width and height while preserving the
* aspect ratio. Returns dimensions in millimeters for PDF placement.
*
* @param string $imgPath Path to the image file
* @param int $maxWidth Maximum allowed width in millimeters
* @param int $maxHeight Maximum allowed height in millimeters
* @param string $imgPath Path to the image file
* @param int $maxWidth Maximum allowed width in millimeters
* @param int $maxHeight Maximum allowed height in millimeters
*
* @return array Array containing [width, height] in millimeters
*/
protected function resizeToFit(
string $imgPath,
int $maxWidth = self::A4_WIDTH,
int $maxHeight = self::A4_HEIGHT
int $maxHeight = self::A4_HEIGHT,
): array {
[$width, $height] = getimagesize($imgPath);
$widthScale = $this->mmToPixels($maxWidth) / $width;
+2 -2
View File
@@ -39,7 +39,7 @@ class Sanitizer
if (null === $targetFilepath) {
$parts = pathinfo($inputFilepath);
$targetFilepath = sprintf('%s/%s.%s', $parts['dirname'], $parts['filename'], $parts['extension']);
$targetFilepath = sprintf('%s/%s.%s', $parts['dirname'], $parts['filename'], $parts['extension']);
}
if ('pdf' !== pathinfo($inputFilepath, PATHINFO_EXTENSION)) {
@@ -61,7 +61,7 @@ class Sanitizer
$filesystem->remove($inputFilepath);
$inputFilepath = $pdfFilepath;
$targetFilepath.= '.pdf';
$targetFilepath .= '.pdf';
}
$command = [