A free open source IT asset/license management system
add getters for tze18mm and fixed layout for tapes and preview select
Godfrey M83a80edc89e4
diff --git a/app/Http/Controllers/LabelsController.php b/app/Http/Controllers/LabelsController.phpindex e535b0bf82..1e936cff25 100755--- a/app/Http/Controllers/LabelsController.php+++ b/app/Http/Controllers/LabelsController.php@@ -390,15 +390,25 @@ class LabelsController extends Controller? new DefaultLabel: Label::find($labelName);+ $isTape = str_starts_with($labelName, 'Tapes\\');+$editorConfig = [- 'page' => $request->input('page', []),- 'grid' => $request->input('grid', []),- 'label' => $request->input('label', []),'content' => $request->input('content', []),'supports' => $request->input('supports', []),];- $template = new PreviewSheetLabel;+ if ($isTape) {+ $editorConfig['tape'] = $request->input('tape', []);+ $template = new PreviewTapeLabel;+ } else {+ $editorConfig['page'] = $request->input('page', []);+ $editorConfig['grid'] = $request->input('grid', []);+ $editorConfig['label'] = $request->input('label', []);+ $template = new PreviewSheetLabel;+ }++ $template->seedFromTemplate($baseTemplate);+ $template->applyEditorConfig($editorConfig);if (method_exists($template, 'seedFromTemplate')) {$template->seedFromTemplate($baseTemplate);diff --git a/app/Models/Labels/CustomLabels/Concerns/RenderCustomLabelContent.php b/app/Models/Labels/CustomLabels/Concerns/RenderCustomLabelContent.phpnew file mode 100644index 0000000000..90adee3826--- /dev/null+++ b/app/Models/Labels/CustomLabels/Concerns/RenderCustomLabelContent.php@@ -0,0 +1,398 @@+<?php++namespace App\Models\Labels\CustomLabels\Concerns;++trait RenderCustomLabelContent+{+ protected function boxesOverlap(?array $a, ?array $b): bool+ {+ if (!$a || !$b) {+ return false;+ }++ return !(+ $b['x'] >= $a['x'] + $a['w'] ||+ $a['x'] >= $b['x'] + $b['w'] ||+ $b['y'] >= $a['y'] + $a['h'] ||+ $a['y'] >= $b['y'] + $b['h']+ );+ }++ protected function clampBox(array $box, array $container): array+ {+ $box['w'] = min(max(0, $box['w']), $container['w']);+ $box['h'] = min(max(0, $box['h']), $container['h']);++ $box['x'] = max($container['x1'], min($box['x'], $container['x2'] - $box['w']));+ $box['y'] = max($container['y1'], min($box['y'], $container['y2'] - $box['h']));++ return $box;+ }++ protected function anchorBox(array $container, float $w, float $h, string $hAlign, string $vAlign): array+ {+ $w = min($w, $container['w']);+ $h = min($h, $container['h']);++ $x = match (strtoupper($hAlign)) {+ 'R' => $container['x2'] - $w,+ 'C' => $container['x1'] + (($container['w'] - $w) / 2),+ default => $container['x1'],+ };++ $y = match (strtoupper($vAlign)) {+ 'B' => $container['y2'] - $h,+ 'C' => $container['y1'] + (($container['h'] - $h) / 2),+ default => $container['y1'],+ };++ return $this->clampBox([+ 'x' => $x,+ 'y' => $y,+ 'w' => $w,+ 'h' => $h,+ ], $container);+ }++ protected function render1DBarcode($pdf, $record, array $layout): void+ {+ if (+ empty($layout['barcode1d']) ||+ !$record->has('barcode1d') ||+ !$this->getSupport1DBarcode()+ ) {+ return;+ }++ static::write1DBarcode(+ $pdf,+ $record->get('barcode1d')->content,+ $record->get('barcode1d')->type,+ $layout['barcode1d']['x'],+ $layout['barcode1d']['y'],+ $layout['barcode1d']['w'],+ $layout['barcode1d']['h']+ );+ }++ protected function renderLogo($pdf, $record, array $layout): void+ {+ if (+ empty($layout['logo']) ||+ !$record->has('logo') ||+ !$this->getSupportLogo()+ ) {+ return;+ }++ static::writeImage(+ $pdf,+ $record->get('logo'),+ $layout['logo']['x'],+ $layout['logo']['y'],+ $layout['logo']['w'],+ $layout['logo']['h'],+ $this->getLogoHAlign(),+ $this->getLogoVAlign(),+ 300,+ true,+ false,+ 0+ );+ }++ protected function render2DBarcode($pdf, $record, array $layout): void+ {+ if (+ empty($layout['barcode2d']) ||+ !$record->has('barcode2d') ||+ !$this->getSupport2DBarcode()+ ) {+ return;+ }++ static::write2DBarcode(+ $pdf,+ $record->get('barcode2d')->content,+ $record->get('barcode2d')->type,+ $layout['barcode2d']['x'],+ $layout['barcode2d']['y'],+ $layout['barcode2d']['w'],+ $layout['barcode2d']['h']+ );+ }++ protected function renderTag($pdf, $record, array $layout): void+ {+ if (+ empty($layout['tag']) ||+ !$record->has('tag') ||+ !$this->getSupportAssetTag()+ ) {+ return;+ }++ static::writeText(+ $pdf,+ $record->get('tag'),+ $layout['tag']['x'],+ $layout['tag']['y'],+ 'freemono',+ 'B',+ $layout['tag']['font_size'] ?? $this->getTagSize(),+ $this->getTagAlignment(),+ $layout['tag']['w'],+ $layout['tag']['h'],+ true,+ 0,+ $layout['tag']['spacing'] ?? 0.3+ );+ }++ protected function renderTextBlock($pdf, $record, array $layout): void+ {+ if (!empty($layout['title'])) {+ static::writeText(+ $pdf,+ $record->get('title'),+ $layout['title']['x'],+ $layout['title']['y'],+ 'freesans',+ '',+ $layout['title']['font_size'],+ 'L',+ $layout['title']['w'],+ $layout['title']['h'],+ true,+ 0+ );+ }++ if (empty($layout['fields'])) {+ return;+ }++ $y = $layout['fields']['start_y'];++ foreach ($layout['fields']['fields'] as $field) {+ if ($y + $layout['fields']['row_advance'] > $layout['fields']['bottom_limit']) {+ break;+ }++ $label = $field['label'] ?? '';+ $value = $field['value'] ?? '';++ if (is_string($label) && trim($label) !== '') {+ $label = rtrim($label, ':') . ':';+ }++ if ($label !== '') {+ static::writeText(+ $pdf,+ $label,+ $layout['fields']['start_x'],+ $y,+ 'freesans',+ '',+ $layout['fields']['label_size'],+ 'L',+ $layout['fields']['label_width'],+ $layout['fields']['label_size'],+ true,+ 0+ );+ }++ if ($layout['fields']['value_width'] > 0) {+ static::writeText(+ $pdf,+ $value,+ $layout['fields']['value_x'],+ $y,+ 'freemono',+ 'B',+ $layout['fields']['field_size'],+ 'L',+ $layout['fields']['value_width'],+ $layout['fields']['field_size'],+ true,+ 0+ );+ }++ $y += $layout['fields']['row_advance'];+ }+ }++ protected function resolveTextBox(array $body, array $boxes): array+ {+ $leftEdge = $body['x1'];+ $rightEdge = $body['x2'];+ $topEdge = $body['y1'];+ $bottomEdge = $body['y2'];++ foreach ($boxes as $box) {+ if (!$box) {+ continue;+ }++ $isLeftAnchored = abs($box['x'] - $body['x1']) < 0.01;+ $isRightAnchored = abs(($box['x'] + $box['w']) - $body['x2']) < 0.01;+ $isTopAnchored = abs($box['y'] - $body['y1']) < 0.01;+ $isBottomAnchored = abs(($box['y'] + $box['h']) - $body['y2']) < 0.01;++ if ($isLeftAnchored) {+ $leftEdge = max($leftEdge, $box['x'] + $box['w'] + $this->getLogoMargin());+ }++ if ($isRightAnchored) {+ $rightEdge = min($rightEdge, $box['x'] - $this->getLogoMargin());+ }++ if ($isTopAnchored && $box['w'] > ($body['w'] * 0.6)) {+ $topEdge = max($topEdge, $box['y'] + $box['h'] + $this->getTitleMargin());+ }++ if ($isBottomAnchored && $box['w'] > ($body['w'] * 0.6)) {+ $bottomEdge = min($bottomEdge, $box['y'] - $this->getFieldMargin());+ }+ }++ if ($rightEdge < $leftEdge) {+ $rightEdge = $leftEdge;+ }++ if ($bottomEdge < $topEdge) {+ $bottomEdge = $topEdge;+ }++ return [+ 'x1' => $leftEdge,+ 'y1' => $topEdge,+ 'x2' => $rightEdge,+ 'y2' => $bottomEdge,+ 'w' => max(0, $rightEdge - $leftEdge),+ 'h' => max(0, $bottomEdge - $topEdge),+ ];+ }++ protected function resolveLogoBox($record, array $body): ?array+ {+ if (!$record->has('logo') || !$this->getSupportLogo()) {+ return null;+ }++ $width = min($this->getLogoMaxWidth(), $body['w']);++ return $this->anchorBox(+ $body,+ $width,+ $body['h'],+ $this->getLogoHAlign(),+ $this->getLogoVAlign()+ );+ }++ protected function resolve2DBarcodeBox($record, array $body, ?array $logoBox = null): ?array+ {+ if (!$record->has('barcode2d') || !$this->getSupport2DBarcode()) {+ return null;+ }++ $size = $this->calculate2DBarcodeSize($record, $body);+ $size = min($size, $body['w'], $body['h']);++ $box = $this->anchorBox(+ $body,+ $size,+ $size,+ $this->getBarcode2DHAlign(),+ $this->getBarcode2DVAlign()+ );++ if ($this->boxesOverlap($box, $logoBox)) {+ $altHAlign = strtoupper($this->getBarcode2DHAlign()) === 'R' ? 'L' : 'R';++ $altBox = $this->anchorBox(+ $body,+ $size,+ $size,+ $altHAlign,+ $this->getBarcode2DVAlign()+ );++ if (!$this->boxesOverlap($altBox, $logoBox)) {+ $box = $altBox;+ }+ }++ return $box;+ }++ protected function resolveTagBox($record, array $body, ?array $barcode2dBox = null, ?array $logoBox = null): ?array+ {+ if (!$record->has('tag') || !$this->getSupportAssetTag()) {+ return null;+ }++ $tagHeight = max(0, $this->getTagSize());++ if (+ $barcode2dBox &&+ strtoupper($this->getTagAlignment()) === strtoupper($this->getBarcode2DHAlign())+ ) {+ $box = [+ 'x' => $barcode2dBox['x'],+ 'y' => $barcode2dBox['y'] + $barcode2dBox['h'],+ 'w' => $barcode2dBox['w'],+ 'h' => $tagHeight,+ ];++ $box['x'] += $this->getTagOffsetX();+ $box['y'] += $this->getTagOffsetY();++ return $this->clampBox($box, $body);+ }++ $tagWidth = $this->calculateTagWidth($record, $body, $barcode2dBox);+ $tagAlign = strtoupper($this->getTagAlignment());++ $x = $tagAlign === 'R'+ ? $body['x2'] - $tagWidth+ : $body['x1'];++ $box = [+ 'x' => $x,+ 'y' => $body['y2'] - $tagHeight,+ 'w' => $tagWidth,+ 'h' => $tagHeight,+ ];++ $box['x'] += $this->getTagOffsetX();+ $box['y'] += $this->getTagOffsetY();++ return $this->clampBox($box, $body);+ }++ protected function calculate2DBarcodeSize($record, array $container): float+ {+ return min(+ $this->get2DBarcodeSize(),+ $container['w'],+ $container['h']+ );+ }++ protected function calculateTagWidth($record, array $body, ?array $barcode2dBox = null): float+ {+ if (+ method_exists($this, 'getTagPositionMode') &&+ $barcode2dBox &&+ $this->getTagPositionMode() === 'under_barcode'+ ) {+ return $barcode2dBox['w'];+ }++ return min($body['w'] * 0.35, $body['w']);+ }+}\ No newline at end of filediff --git a/app/Models/Labels/CustomLabels/CustomSheetLabel.php b/app/Models/Labels/CustomLabels/CustomSheetLabel.phpindex c5a1c2c5da..16dd16981d 100644--- a/app/Models/Labels/CustomLabels/CustomSheetLabel.php+++ b/app/Models/Labels/CustomLabels/CustomSheetLabel.php@@ -3,10 +3,12 @@namespace App\Models\Labels\CustomLabels;use App\Helpers\Helper;+use App\Models\Labels\CustomLabels\Concerns\RenderCustomLabelContent;use App\Models\Labels\RectangleSheet;abstract class CustomSheetLabel extends RectangleSheet{+ use RenderCustomLabelContent;protected array $editorConfig = [];protected string $unit = 'mm';@@ -837,384 +839,4 @@ abstract class CustomSheetLabel extends RectangleSheetreturn $layout;}-- protected function boxesOverlap(?array $a, ?array $b): bool- {- if (! $a || ! $b) {- return false;- }-- return ! (- $b['x'] >= $a['x'] + $a['w'] ||- $a['x'] >= $b['x'] + $b['w'] ||- $b['y'] >= $a['y'] + $a['h'] ||- $a['y'] >= $b['y'] + $b['h']- );- }-- protected function clampBox(array $box, array $container): array- {- $box['w'] = min(max(0, $box['w']), $container['w']);- $box['h'] = min(max(0, $box['h']), $container['h']);-- $box['x'] = max($container['x1'], min($box['x'], $container['x2'] - $box['w']));- $box['y'] = max($container['y1'], min($box['y'], $container['y2'] - $box['h']));-- return $box;- }-- protected function anchorBox(array $container, float $w, float $h, string $hAlign, string $vAlign): array- {- $w = min($w, $container['w']);- $h = min($h, $container['h']);-- $x = match (strtoupper($hAlign)) {- 'R' => $container['x2'] - $w,- 'C' => $container['x1'] + (($container['w'] - $w) / 2),- default => $container['x1'],- };-- $y = match (strtoupper($vAlign)) {- 'B' => $container['y2'] - $h,- 'C' => $container['y1'] + (($container['h'] - $h) / 2),- default => $container['y1'],- };-- return $this->clampBox([- 'x' => $x,- 'y' => $y,- 'w' => $w,- 'h' => $h,- ], $container);- }-- protected function resolveLogoBox($record, array $body): ?array- {- if (! $record->has('logo') || ! $this->getSupportLogo()) {- return null;- }-- $width = min($this->getLogoMaxWidth(), $body['w']);-- return $this->anchorBox(- $body,- $width,- $body['h'],- $this->getLogoHAlign(),- $this->getLogoVAlign()- );- }-- protected function resolve2DBarcodeBox($record, array $body, ?array $logoBox = null): ?array- {- if (! $record->has('barcode2d') || ! $this->getSupport2DBarcode()) {- return null;- }-- $size = $this->calculate2DBarcodeSize($record, $body);- $size = min($size, $body['w'], $body['h']);-- $box = $this->anchorBox(- $body,- $size,- $size,- $this->getBarcode2DHAlign(),- $this->getBarcode2DVAlign()- );-- if ($this->boxesOverlap($box, $logoBox)) {- $altHAlign = strtoupper($this->getBarcode2DHAlign()) === 'R' ? 'L' : 'R';-- $altBox = $this->anchorBox(- $body,- $size,- $size,- $altHAlign,- $this->getBarcode2DVAlign()- );-- if (! $this->boxesOverlap($altBox, $logoBox)) {- $box = $altBox;- }- }-- return $box;- }-- protected function resolveTagBox($record, array $body, ?array $barcode2dBox = null, ?array $logoBox = null): ?array- {- if (! $record->has('tag') || ! $this->getSupportAssetTag()) {- return null;- }-- $tagHeight = max(0, $this->getTagSize());-- // If tag and barcode share the same horizontal side, anchor tag to barcode region- if (- $barcode2dBox &&- strtoupper($this->getTagAlignment()) === strtoupper($this->getBarcode2DHAlign())- ) {- $box = [- 'x' => $barcode2dBox['x'],- 'y' => $barcode2dBox['y'] + $barcode2dBox['h'],- 'w' => $barcode2dBox['w'],- 'h' => $tagHeight,- ];-- $box['x'] += $this->getTagOffsetX();- $box['y'] += $this->getTagOffsetY();-- return $this->clampBox($box, $body);- }-- $tagWidth = $this->calculateTagWidth($record, $body, $barcode2dBox);- $tagAlign = strtoupper($this->getTagAlignment());-- if ($tagAlign === 'R') {- $x = $body['x2'] - $tagWidth;- } else {- $x = $body['x1'];- }-- $box = [- 'x' => $x,- 'y' => $body['y2'] - $tagHeight,- 'w' => $tagWidth,- 'h' => $tagHeight,- ];-- $box['x'] += $this->getTagOffsetX();- $box['y'] += $this->getTagOffsetY();-- return $this->clampBox($box, $body);- }-- protected function render1DBarcode($pdf, $record, array $layout): void- {- if (! $layout['barcode1d'] || ! $record->has('barcode1d')) {- return;- }-- static::write1DBarcode(- $pdf,- $record->get('barcode1d')->content,- $record->get('barcode1d')->type,- $layout['barcode1d']['x'],- $layout['barcode1d']['y'],- $layout['barcode1d']['w'],- $layout['barcode1d']['h']- );- }-- protected function renderLogo($pdf, $record, array $layout): void- {- if (! $layout['logo'] || ! $record->has('logo') || ! $this->getSupportLogo()) {- return;- }-- static::writeImage(- $pdf,- $record->get('logo'),- $layout['logo']['x'],- $layout['logo']['y'],- $layout['logo']['w'],- $layout['logo']['h'],- $this->getLogoHAlign(),- $this->getLogoVAlign(),- 300,- true,- false,- 0- );- }-- protected function render2DBarcode($pdf, $record, array $layout): void- {- if (! $layout['barcode2d'] || ! $record->has('barcode2d') || ! $this->getSupport2DBarcode()) {- return;- }-- static::write2DBarcode(- $pdf,- $record->get('barcode2d')->content,- $record->get('barcode2d')->type,- $layout['barcode2d']['x'],- $layout['barcode2d']['y'],- $layout['barcode2d']['w'],- $layout['barcode2d']['h']- );- }-- protected function renderTag($pdf, $record, array $layout): void- {- if (! $layout['tag'] || ! $record->has('tag') || ! $this->getSupportAssetTag()) {- return;- }-- static::writeText(- $pdf,- $record->get('tag'),- $layout['tag']['x'],- $layout['tag']['y'],- 'freemono',- 'B',- $this->getTagSize(),- $this->getTagAlignment(),- $layout['tag']['w'],- $layout['tag']['h'],- true,- 0,- 0.3- );- }-- protected function renderTextBlock($pdf, $record, array $layout): void- {- if ($layout['title']) {- static::writeText(- $pdf,- $record->get('title'),- $layout['title']['x'],- $layout['title']['y'],- 'freesans',- '',- $layout['title']['font_size'],- 'L',- $layout['title']['w'],- $layout['title']['h'],- true,- 0- );- }-- if (! $layout['fields']) {- return;- }-- $y = $layout['fields']['start_y'];-- foreach ($layout['fields']['fields'] as $field) {- if ($y + $layout['fields']['row_advance'] > $layout['fields']['bottom_limit']) {- break;- }-- $label = $field['label'] ?? '';- $value = $field['value'] ?? '';-- if (is_string($label) && trim($label) !== '') {- $label = rtrim($label, ':').':';- }-- if ($label !== '') {- static::writeText(- $pdf,- $label,- $layout['fields']['start_x'],- $y,- 'freesans',- '',- $layout['fields']['label_size'],- 'L',- $layout['fields']['label_width'],- $layout['fields']['label_size'],- true,- 0- );- }-- if ($layout['fields']['value_width'] > 0) {- static::writeText(- $pdf,- $value,- $layout['fields']['value_x'],- $y,- 'freemono',- 'B',- $layout['fields']['field_size'],- 'L',- $layout['fields']['value_width'],- $layout['fields']['field_size'],- true,- 0- );- }-- $y += $layout['fields']['row_advance'];- }- }-- protected function resolveTextBox(array $body, array $boxes): array- {- $x1 = $body['x1'];- $y1 = $body['y1'];- $x2 = $body['x2'];- $y2 = $body['y2'];-- $leftEdge = $x1;- $rightEdge = $x2;- $topEdge = $y1;- $bottomEdge = $y2;-- foreach ($boxes as $box) {- if (! $box) {- continue;- }-- $isLeftAnchored = abs($box['x'] - $body['x1']) < 0.01;- $isRightAnchored = abs(($box['x'] + $box['w']) - $body['x2']) < 0.01;- $isTopAnchored = abs($box['y'] - $body['y1']) < 0.01;- $isBottomAnchored = abs(($box['y'] + $box['h']) - $body['y2']) < 0.01;-- if ($isLeftAnchored) {- $leftEdge = max($leftEdge, $box['x'] + $box['w'] + $this->getLogoMargin());- }-- if ($isRightAnchored) {- $rightEdge = min($rightEdge, $box['x'] - $this->getLogoMargin());- }-- if ($isTopAnchored && $box['w'] > ($body['w'] * 0.6)) {- $topEdge = max($topEdge, $box['y'] + $box['h'] + $this->getTitleMargin());- }-- if ($isBottomAnchored && $box['w'] > ($body['w'] * 0.6)) {- $bottomEdge = min($bottomEdge, $box['y'] - $this->getFieldMargin());- }- }-- if ($rightEdge < $leftEdge) {- $rightEdge = $leftEdge;- }-- if ($bottomEdge < $topEdge) {- $bottomEdge = $topEdge;- }-- return [- 'x1' => $leftEdge,- 'y1' => $topEdge,- 'x2' => $rightEdge,- 'y2' => $bottomEdge,- 'w' => max(0, $rightEdge - $leftEdge),- 'h' => max(0, $bottomEdge - $topEdge),- ];- }-- protected function calculate2DBarcodeSize($record, array $container): float- {- return min(- $this->get2DBarcodeSize(),- $container['w'],- $container['h']- );- }-- protected function calculateTagWidth($record, array $body, ?array $barcode2dBox = null): float- {- if ($barcode2dBox && $this->getTagPositionMode() === 'under_barcode') {- return $barcode2dBox['w'];- }-- return min($body['w'] * 0.35, $body['w']);- }}diff --git a/app/Models/Labels/CustomLabels/CustomTapeLabel.php b/app/Models/Labels/CustomLabels/CustomTapeLabel.phpindex 9bebea98b8..ddb648f514 100644--- a/app/Models/Labels/CustomLabels/CustomTapeLabel.php+++ b/app/Models/Labels/CustomLabels/CustomTapeLabel.php@@ -2,10 +2,13 @@namespace App\Models\Labels\CustomLabels;+use App\Models\Labels\CustomLabels\Concerns\RenderCustomLabelContent;use App\Models\Labels\Label;+use App\Helpers\Helper;abstract class CustomTapeLabel extends Label{+ use RenderCustomLabelContent;protected array $editorConfig = [];protected string $unit = 'mm';@@ -32,6 +35,27 @@ abstract class CustomTapeLabel extends Labelprotected float $fieldSize = 5.5;protected string $tagAlignment = 'L';protected string $fieldAlignment = 'R';+ protected float $logoMaxWidth = 12.0;+ protected float $logoMargin = 2.0;+ protected string $logoHAlign = 'L';+ protected string $logoVAlign = 'T';++ protected float $barcode2DSize = 10.0;+ protected string $barcode2DHAlign = 'L';+ protected string $barcode2DVAlign = 'T';+ protected float $tagOffsetX = 0.0;+ protected float $tagOffsetY = 0.0;+ protected string $tagPositionMode = 'free';++ protected float $titleSize = 8.0;+ protected float $titleMargin = 1.0;+ protected float $titleOffsetX = 0.0;++ protected float $labelSize = 5.0;+ protected float $labelMargin = 1.0;+ protected float $fieldMargin = 1.0;+ protected ?float $textAreaWidth = null;+ protected ?float $textAreaHeight = null;public function getUnit(){@@ -133,6 +157,96 @@ abstract class CustomTapeLabel extends Labelreturn $this->fieldAlignment;}+ public function getLogoMaxWidth(): float+ {+ return $this->logoMaxWidth;+ }++ public function getLogoMargin(): float+ {+ return $this->logoMargin;+ }++ public function getLogoHAlign(): string+ {+ return $this->logoHAlign;+ }++ public function getLogoVAlign(): string+ {+ return $this->logoVAlign;+ }++ public function get2DBarcodeSize(): float+ {+ return $this->barcode2DSize;+ }++ public function getBarcode2DHAlign(): string+ {+ return $this->barcode2DHAlign;+ }++ public function getBarcode2DVAlign(): string+ {+ return $this->barcode2DVAlign;+ }++ public function getTagOffsetX(): float+ {+ return $this->tagOffsetX;+ }++ public function getTagOffsetY(): float+ {+ return $this->tagOffsetY;+ }++ public function getTagPositionMode(): string+ {+ return $this->tagPositionMode;+ }++ public function getTitleSize(): float+ {+ return $this->titleSize;+ }++ public function getTitleMargin(): float+ {+ return $this->titleMargin;+ }++ public function getTitleOffsetX(): float+ {+ return $this->titleOffsetX;+ }++ public function getLabelSize(): float+ {+ return $this->labelSize;+ }++ public function getLabelMargin(): float+ {+ return $this->labelMargin;+ }++ public function getFieldMargin(): float+ {+ return $this->fieldMargin;+ }++ public function getTextAreaWidth(): ?float+ {+ return $this->textAreaWidth;+ }++ public function getTextAreaHeight(): ?float+ {+ return $this->textAreaHeight;+ }+public function preparePDF($pdf){$pdf->SetMargins(0, 0, 0);@@ -229,6 +343,7 @@ abstract class CustomTapeLabel extends Label$contentMap = ['barcode_size' => 'barcodeSize','barcode_margin' => 'barcodeMargin',+ 'text_size_mod' => 'textSizeMod','tag_font_size' => 'tagSize','field_value_font_size' => 'fieldSize','tag_alignment' => 'tagAlignment',@@ -288,63 +403,134 @@ abstract class CustomTapeLabel extends Label{$pa = $this->getPrintableArea();+ $layout = $this->buildLayout($pdf, $record, $pa);++ $this->render1DBarcode($pdf, $record, $layout);+ $this->renderTapeTag($pdf, $record, $layout);+ $this->renderTapeField($pdf, $record, $layout);+ }++ protected function buildLayout($pdf, $record, $pa): array+ {+ $layout = [+ 'printable' => [+ 'x1' => $pa->x1,+ 'y1' => $pa->y1,+ 'x2' => $pa->x2,+ 'y2' => $pa->y2,+ 'w' => $pa->w,+ 'h' => $pa->h,+ ],+ 'body' => [+ 'x1' => $pa->x1,+ 'y1' => $pa->y1,+ 'x2' => $pa->x2,+ 'y2' => $pa->y2,+ 'w' => $pa->w,+ 'h' => $pa->h,+ ],+ 'barcode1d' => null,+ 'barcode2d' => null,+ 'logo' => null,+ 'tag' => null,+ 'field' => null,+ 'text' => null,+ 'title' => null,+ 'fields' => null,+ ];+ $barcodeHeight = 0;+ $barcodeMargin = 0;+if ($record->has('barcode1d') && $this->getSupport1DBarcode()) {- static::write1DBarcode(- $pdf,- $record->get('barcode1d')->content,- $record->get('barcode1d')->type,- $pa->x1,- $pa->y1,- $pa->w,- $this->getBarcodeSize()- );+ $barcodeHeight = min(max(0, $this->getBarcodeSize()), $pa->h);+ $barcodeMargin = max(0, $this->getBarcodeMargin());++ $layout['barcode1d'] = [+ 'x' => $pa->x1,+ 'y' => $pa->y1,+ 'w' => $pa->w,+ 'h' => $barcodeHeight,+ ];}- $currentY = $pa->y1 + $this->getBarcodeSize() + $this->getBarcodeMargin();- $usableHeight = max(0, $pa->h - $this->getBarcodeSize() - $this->getBarcodeMargin());+ $currentY = $pa->y1 + $barcodeHeight + $barcodeMargin;+ $usableHeight = max(0, $pa->h - $barcodeHeight - $barcodeMargin);$fontSize = $usableHeight + $this->getTextSizeMod();$tagWidth = $pa->w / 3;$fieldWidth = $pa->w - $tagWidth;- if ($record->has('tag') && $this->getSupportAssetTag()) {- static::writeText(- $pdf,- $record->get('tag'),- $pa->x1,- $currentY,- 'freemono',- 'B',- $fontSize,- $this->getTagAlignment(),- $tagWidth,- $usableHeight,- true,- 0,- 0- );+ $layout['tag'] = [+ 'x' => $pa->x1,+ 'y' => $currentY,+ 'w' => $tagWidth,+ 'h' => $usableHeight,+ 'font_size' => $fontSize,+ 'align' => $this->getTagAlignment(),+ 'spacing' => 0,+ ];++ $layout['field'] = [+ 'x' => $pa->x1 + $tagWidth,+ 'y' => $currentY,+ 'w' => $fieldWidth,+ 'h' => $usableHeight,+ 'font_size' => $fontSize,+ 'align' => $this->getFieldAlignment(),+ 'spacing' => 0,+ ];++ return $layout;+ }++ protected function renderTapeTag($pdf, $record, array $layout): void+ {+ if (empty($layout['tag']) || !$record->has('tag') || !$this->getSupportAssetTag()) {+ return;}+ static::writeText(+ $pdf,+ $record->get('tag'),+ $layout['tag']['x'],+ $layout['tag']['y'],+ 'freemono',+ 'B',+ $layout['tag']['font_size'],+ $layout['tag']['align'],+ $layout['tag']['w'],+ $layout['tag']['h'],+ true,+ 0,+ $layout['tag']['spacing']+ );+ }++ protected function renderTapeField($pdf, $record, array $layout): void+ {if (- $record->has('fields') &&- $this->getSupportFields() >= 1 &&- $record->get('fields')->count() >= 1+ empty($layout['field']) ||+ !$record->has('fields') ||+ $record->get('fields')->count() < 1 ||+ $this->getSupportFields() < 1) {- static::writeText(- $pdf,- $record->get('fields')->values()->get(0)['value'],- $pa->x1 + $tagWidth,- $currentY,- 'freemono',- 'B',- $fontSize,- $this->getFieldAlignment(),- $fieldWidth,- $usableHeight,- true,- 0,- 0- );+ return;}++ static::writeText(+ $pdf,+ $record->get('fields')->values()->get(0)['value'],+ $layout['field']['x'],+ $layout['field']['y'],+ 'freemono',+ 'B',+ $layout['field']['font_size'],+ $layout['field']['align'],+ $layout['field']['w'],+ $layout['field']['h'],+ true,+ 0,+ $layout['field']['spacing']+ );}}\ No newline at end of filediff --git a/app/Models/Labels/Tapes/Brother/TZe_18mm_A.php b/app/Models/Labels/Tapes/Brother/TZe_18mm_A.phpindex a2ef750a4d..927dfd05e5 100644--- a/app/Models/Labels/Tapes/Brother/TZe_18mm_A.php+++ b/app/Models/Labels/Tapes/Brother/TZe_18mm_A.php@@ -10,6 +10,20 @@ class TZe_18mm_A extends TZe_18mmprivate const TEXT_SIZE_MOD = 1.00;+ public function getBarcodeSize(): float+ {+ return self::BARCODE_SIZE;+ }++ public function getBarcodeMargin(): float+ {+ return self::BARCODE_MARGIN;+ }++ public function getTextSizeMod(): float+ {+ return self::TEXT_SIZE_MOD;+ }public function getUnit(){return 'mm';@@ -50,6 +64,15 @@ class TZe_18mm_A extends TZe_18mmreturn false;}+ protected function getContentEditorConfig(): array+ {+ return [+ 'barcode_size' => $this->getBarcodeSize(),+ 'barcode_margin' => $this->getBarcodeMargin(),+ 'text_size_mod' => $this->getTextSizeMod(),+ ];+ }+public function preparePDF($pdf) {}public function write($pdf, $record)