A free open source IT asset/license management system
adds a stacked view and getters for Continuous_53mm_A
Godfrey M75de698a20c5
diff --git a/app/Models/Labels/CustomLabels/Concerns/RenderCustomLabelContent.php b/app/Models/Labels/CustomLabels/Concerns/RenderCustomLabelContent.phpindex 786a349c4d..1806a1ba68 100644--- a/app/Models/Labels/CustomLabels/Concerns/RenderCustomLabelContent.php+++ b/app/Models/Labels/CustomLabels/Concerns/RenderCustomLabelContent.php@@ -229,6 +229,56 @@ trait RenderCustomLabelContent}}+ protected function renderVerticalStackedTextBlock($pdf, $record, array $layout): void+ {+ if (empty($layout['fields'])) {+ return;+ }++ $y = $layout['fields']['start_y'];++ foreach ($layout['fields']['fields'] as $field) {+ $label = $field['label'] ?? '';+ $value = $field['value'] ?? '';++ if ($label !== '') {+ static::writeText(+ $pdf,+ $label,+ $layout['text']['x1'],+ $y,+ 'freesans',+ '',+ $layout['fields']['label_size'],+ 'L',+ $layout['text']['w'],+ $layout['fields']['label_size'],+ true,+ 0+ );++ $y += $layout['fields']['label_size'] + $this->getLabelMargin();+ }++ static::writeText(+ $pdf,+ $value,+ $layout['text']['x1'],+ $y,+ 'freemono',+ 'B',+ $layout['fields']['field_size'],+ 'L',+ $layout['text']['w'],+ $layout['fields']['field_size'],+ true,+ 0,+ 0.01+ );++ $y += $layout['fields']['field_size'] + $this->getFieldMargin();+ }+ }protected function resolveTextBox(array $body, array $boxes): array{$leftEdge = $body['x1'];diff --git a/app/Models/Labels/CustomLabels/CustomTapeLabel.php b/app/Models/Labels/CustomLabels/CustomTapeLabel.phpindex 0349b38460..419125ae6f 100644--- a/app/Models/Labels/CustomLabels/CustomTapeLabel.php+++ b/app/Models/Labels/CustomLabels/CustomTapeLabel.php@@ -65,6 +65,7 @@ abstract class CustomTapeLabel extends Labelprotected string $barcode1DVAlign = 'T';protected string $barcode1DPlacement = 'full_width';protected string $barcode2D_h_align = 'L';+ protected ?string $barcode2DPlacement = null;protected string $barcode2D_v_align = 'T';protected int $rotation = 0;@@ -223,6 +224,11 @@ abstract class CustomTapeLabel extends Labelreturn $this->barcode2DSize;}+ public function getBarcode2DPlacement(): ?string+ {+ return $this->barcode2DPlacement;+ }+public function getTagOffsetX(): float{return $this->tagOffsetX;@@ -327,6 +333,7 @@ abstract class CustomTapeLabel extends Label'barcode_2d_size' => $this->get2DBarcodeSize(),'barcode2D_h_align' => $this->getBarcode2DHAlign(),'barcode2D_v_align' => $this->getBarcode2DVAlign(),+ 'barcode2D_placement' => $this->getBarcode2DPlacement(),'text_size_mod' => $this->getTextSizeMod(), // needs to be combined with field size'text_area_offset_y' => $this->getTextAreaOffsetY(),'tag_font_size' => $this->getTagSize(),@@ -414,6 +421,7 @@ abstract class CustomTapeLabel extends Label'barcode1D_placement' => 'barcode1DPlacement','barcode_2d_size' => 'barcode2DSize','barcode_2d_margin' => 'barcode2DMargin',+ 'barcode2D_placement' => 'barcode2DPlacement','logo_max_height' => 'logoMaxHeight','text_size_mod' => 'textSizeMod',@@ -513,6 +521,7 @@ abstract class CustomTapeLabel extends Label$this->barcode2DSize = isset($content['barcode_2d_size']) ? (float)$content['barcode_2d_size'] : $this->barcode2DSize;$this->barcode2DVAlign = isset($content['barcode2D_v_align']) ? (string)$content['barcode2D_v_align'] : $this->barcode2DVAlign;$this->barcode2DMargin = isset($content['barcode_2d_margin']) ? (float)($content['barcode_2d_margin']) : $this->barcode2DMargin;+ $this->barcode2DPlacement = isset($content['barcode2D_placement']) ? (string)$content['barcode2D_placement'] : $this->barcode2DPlacement;$this->logoMaxHeight = isset($content['logo_max_height']) ? (float)($content['logo_max_height']) : $this->logoMaxHeight;@@ -555,7 +564,6 @@ abstract class CustomTapeLabel extends Label$this->renderLogo($pdf, $record, $layout);$this->render2DBarcode($pdf, $record, $layout);$this->renderTag($pdf, $record, $layout);-$this->renderTextBlock($pdf, $record, $layout);}@@ -635,7 +643,23 @@ abstract class CustomTapeLabel extends Label| Resolve positioned elements|--------------------------------------------------------------------------*/- if ($this->getLogoPlacement() === 'text_column') {+ if ($this->getBarcode2DPlacement() === 'stacked') {+ $barcode2dBox = $this->resolve2DBarcodeBox($record, $layout['body'], null);++ $barcode2dBox['x'] = $layout['body']['x1']+ + (($layout['body']['w'] - $barcode2dBox['w']) / 2);++ $layout['barcode2d'] = $barcode2dBox;++ if ($barcode2dBox) {+ $layout['body']['y1'] = $barcode2dBox['y'] + $barcode2dBox['h'] + $this->getBarcode2DMargin();+ $layout['body']['h'] = max(0, $layout['body']['y2'] - $layout['body']['y1']);+ }++ $layout['text'] = $layout['body'];+ $layout['logo'] = null;+ $layout['tag'] = null;+ } elseif ($this->getLogoPlacement() === 'text_column') {$barcode2dBox = $this->resolve2DBarcodeBox($record, $layout['body'], null);$tagBox = $this->resolveTagBox($record, $layout['body'], $barcode2dBox, null);@@ -831,6 +855,11 @@ abstract class CustomTapeLabel extends Labelprotected function renderTextBlock($pdf, $record, array $layout): void{+ if ($this->getTextRenderMode() === 'vertical_stack') {+ $this->renderVerticalStackedTextBlock($pdf, $record, $layout);+ return;+ }+if ($this->getTextRenderMode() === 'block') {$this->renderStackedTextBlock($pdf, $record, $layout);return;diff --git a/app/Models/Labels/Tapes/Generic/Continuous_53mm_A.php b/app/Models/Labels/Tapes/Generic/Continuous_53mm_A.phpindex 9926df1268..1df243d96e 100644--- a/app/Models/Labels/Tapes/Generic/Continuous_53mm_A.php+++ b/app/Models/Labels/Tapes/Generic/Continuous_53mm_A.php@@ -16,7 +16,7 @@ class Continuous_53mm_A extends Continuous_53mmpublic function getSupport1DBarcode(){- return true;+ return false;}public function getSupport2DBarcode()@@ -39,6 +39,64 @@ class Continuous_53mm_A extends Continuous_53mmreturn true;}+ public function getBarcodeMargin(): float+ {+ return $this->barcodeMargin;+ }++ public function getTitleSize(): float+ {+ return $this->titleSize;+ }++ public function getTitleMargin(): float+ {+ return $this->titleMargin;+ }++ public function getLabelSize(): float+ {+ return $this->labelSize;+ }++ public function getLabelMargin(): float+ {+ return $this->labelMargin;+ }++ public function getFieldSize(): float+ {+ return $this->fieldSize;+ }++ public function getFieldMargin(): float+ {+ return $this->fieldMargin;+ }++ protected function getContentEditorConfig(): array+ {+ return [+ 'barcode_2d_size' => 44.0,+ 'barcode2D_h_align' => 'C',+ 'barcode2D_v_align' => 'T',+ 'barcode2D_placement' => 'stacked',++ 'barcode_margin' => $this->barcodeMargin,++ 'title_font_size' => $this->titleSize,+ 'title_margin' => $this->titleMargin,++ 'field_label_font_size' => $this->labelSize,+ 'field_label_margin' => $this->labelMargin,++ 'field_value_font_size' => $this->fieldSize,+ 'field_value_margin' => $this->fieldMargin,++ 'text_render_mode' => 'vertical_stack',+ ];+ }+public function preparePDF($pdf){$pdf->SetAutoPageBreak(false);