Skip to content

A free open source IT asset/license management system

fix up 11354 label, and readd 1d barcode to 2112283

Godfrey Ma19282710be8
diff --git a/app/Models/Labels/Tapes/Dymo/LabelWriter_11354.php b/app/Models/Labels/Tapes/Dymo/LabelWriter_11354.php
index 81d6e88452..60c311e2b7 100644
--- a/app/Models/Labels/Tapes/Dymo/LabelWriter_11354.php
+++ b/app/Models/Labels/Tapes/Dymo/LabelWriter_11354.php
@@ -12,6 +12,8 @@ class LabelWriter_11354 extends LabelWriter
private const TITLE_MARGIN = 0.50;
private const FIELD_SIZE = 2.80;
private const FIELD_MARGIN = 0.15;
+ private const LABEL_SIZE = 2.8;
+ private const LABEL_MARGIN = 0.6;
public function getUnit()
{
@@ -102,22 +104,47 @@ class LabelWriter_11354 extends LabelWriter
$currentY += self::TITLE_SIZE + self::TITLE_MARGIN;
}
- foreach ($record->get('fields') as $field) {
+ $fields = $record->get('fields');
+ // Below rescales the size of the field box to fit, it feels like it could/should be abstracted one class above
+ // to be usable on other labels but im unsure of how to implement that, since it uses a lot of private
+ // constants.
+
+ // Figure out how tall the label fields wants to be
+ $fieldCount = count($fields);
+ $perFieldHeight = (self::LABEL_SIZE + self::LABEL_MARGIN)
+ + (self::FIELD_SIZE + self::FIELD_MARGIN);
+ $usableHeight = $pa->h
+ - self::TAG_SIZE
+ - self::BARCODE_MARGIN;
+
+ $baseHeight = $fieldCount * $perFieldHeight;
+ // If it doesn't fit in the available height, scale everything down
+ $scale = 1.0;
+ if ($baseHeight > $usableHeight && $baseHeight > 0) {
+ $scale = $usableHeight / $baseHeight;
+ }
+
+ $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', '', self::TITLE_SIZE, 'L',
- $usableWidth, self::TITLE_SIZE, true, 0
+ 'freesans', '', $labelSize, 'L',
+ $usableWidth, $labelSize, true, 0
);
- $currentY += self::TITLE_SIZE + self::TITLE_MARGIN;
+ $currentY += $labelSize + $labelMargin;
static::writeText(
$pdf, $field['value'],
$currentX, $currentY,
- 'freemono', 'B', self::FIELD_SIZE, 'L',
- $usableWidth, self::FIELD_SIZE, true, 0, 0.5
+ 'freemono', 'B', $fieldSize, 'L',
+ $usableWidth, $fieldSize, true, 0, 0.01
);
- $currentY += self::FIELD_SIZE + self::FIELD_MARGIN;
+ $currentY += $fieldSize + $fieldMargin;
}
}
diff --git a/app/Models/Labels/Tapes/Dymo/LabelWriter_2112283.php b/app/Models/Labels/Tapes/Dymo/LabelWriter_2112283.php
index 99d7ae0947..54d002998e 100644
--- a/app/Models/Labels/Tapes/Dymo/LabelWriter_2112283.php
+++ b/app/Models/Labels/Tapes/Dymo/LabelWriter_2112283.php
@@ -133,6 +133,12 @@ class LabelWriter_2112283 extends LabelWriter
);
$currentY += $fieldSize + $fieldMargin;
}
+ if ($record->has('barcode1d')) {
+ static::write1DBarcode(
+ $pdf, $record->get('barcode1d')->content, $record->get('barcode1d')->type,
+ $currentX, $barcodeSize + self::BARCODE_MARGIN, $usableWidth - self::TAG_SIZE, self::TAG_SIZE
+ );
+ }
}
}