Skip to content

A free open source IT asset/license management system

apply helper to L4736_A

Godfrey Md62f10cb469d
diff --git a/app/Models/Labels/Sheets/Avery/L4736_A.php b/app/Models/Labels/Sheets/Avery/L4736_A.php
index de9c14e737..052edb585f 100644
--- a/app/Models/Labels/Sheets/Avery/L4736_A.php
+++ b/app/Models/Labels/Sheets/Avery/L4736_A.php
@@ -3,6 +3,8 @@
namespace App\Models\Labels\Sheets\Avery;
+use App\Helpers\Helper;
+
class L4736_A extends L4736
{
private const BARCODE_MARGIN = 1.80;
@@ -96,38 +98,38 @@ class L4736_A extends L4736
$usableWidth -= $barcodeSize + self::BARCODE_MARGIN;
}
$fields = $record->get('fields');
- $fieldCount = count($fields);
-
- $perFieldHeight = (self::LABEL_SIZE + self::LABEL_MARGIN)
- + (self::FIELD_SIZE + self::FIELD_MARGIN);
- $baseHeight = $fieldCount * $perFieldHeight;
- $scale = 1.0;
- if ($baseHeight > $usableHeight && $baseHeight > 0) {
- $scale = $usableHeight / $baseHeight;
- }
+ $field_layout = Helper::labelFieldLayoutScaling(
+ pdf: $pdf,
+ fields: $fields,
+ currentX: $currentX,
+ usableWidth: $usableWidth,
+ usableHeight: $usableHeight,
+ baseLabelSize: self::LABEL_SIZE,
+ baseFieldSize: self::FIELD_SIZE,
+ baseFieldMargin: self::FIELD_MARGIN,
+ baseLabelPadding: 1.5,
+ baseGap: 1.5,
+ maxScale: 1.8,
+ labelFont: 'freesans',
+ );
- $labelSize = self::LABEL_SIZE * $scale;
- $labelMargin = self::LABEL_MARGIN * $scale;
- $fieldSize = self::FIELD_SIZE * $scale;
- $fieldMargin = self::FIELD_MARGIN * $scale;
foreach ($fields as $field) {
static::writeText(
$pdf, $field['label'],
$currentX, $currentY,
- 'freesans', '', $labelSize, 'L',
- $usableWidth, $labelSize, true, 0
+ 'freesans', '', $field_layout['labelSize'], 'L',
+ $field_layout['labelWidth'], $field_layout['rowAdvance'], true, 0
);
- $currentY += $labelSize + $labelMargin;
static::writeText(
$pdf, $field['value'],
- $currentX, $currentY,
- 'freemono', 'B', $fieldSize, 'L',
- $usableWidth, $fieldSize, true, 0, 0.01
+ $field_layout['valueX'], $currentY,
+ 'freemono', 'B', $field_layout['fieldSize'], 'L',
+ $field_layout['valueWidth'], $field_layout['rowAdvance'], true, 0, 0.01
);
- $currentY += $fieldSize + $fieldMargin;
+ $currentY += $field_layout['rowAdvance'];
}
}