A free open source IT asset/license management system
adds tag alignment option
Godfrey Mca6b33d5ca4b
diff --git a/app/Models/Labels/CustomLabels/CustomSheetLabel.php b/app/Models/Labels/CustomLabels/CustomSheetLabel.phpindex 0201b30e7a..3e4013a080 100644--- a/app/Models/Labels/CustomLabels/CustomSheetLabel.php+++ b/app/Models/Labels/CustomLabels/CustomSheetLabel.php@@ -53,6 +53,8 @@ abstract class CustomSheetLabel extends CustomLabelprotected float $labelMargin = 1.5;protected float $fieldMargin = 2.0;+ protected string $tagAlignment = 'L';+public function getUnit(){return $this->unit;@@ -198,6 +200,11 @@ abstract class CustomSheetLabel extends CustomLabelreturn $this->tagSize;}+ public function getTagAlignment(): string+ {+ return $this->tagAlignment;+ }+public function getTitleSize(): float{return $this->titleSize;@@ -244,6 +251,7 @@ abstract class CustomSheetLabel extends CustomLabelreturn ['barcode_size' => $this->getBarcodeSize(),'barcode_margin' => $this->getBarcodeMargin(),+ 'tag_alignment' => $this->getTagAlignment(),'barcode_2d_size' => $this->get2DBarcodeSize(),'logo_max_width' => $this->getLogoMaxWidth(),'logo_margin' => $this->getLogoMargin(),@@ -388,6 +396,7 @@ abstract class CustomSheetLabel extends CustomLabel$this->logoMargin = isset($content['logo_margin']) ? (float)$content['logo_margin'] : $this->logoMargin;$this->tagSize = isset($content['tag_font_size']) ? (float)$content['tag_font_size'] : $this->tagSize;+ $this->tagAlignment = isset($content['tag_alignment']) ? (string)$content['tag_alignment'] : $this->tagAlignment;$this->titleSize = isset($content['title_font_size']) ? (float)$content['title_font_size'] : $this->titleSize;$this->labelSize = isset($content['field_label_font_size']) ? (float)$content['field_label_font_size'] : $this->labelSize;$this->fieldSize = isset($content['field_value_font_size']) ? (float)$content['field_value_font_size'] : $this->fieldSize;@@ -406,6 +415,9 @@ abstract class CustomSheetLabel extends CustomLabel$usableWidth = $pa->w;$usableHeight = $pa->h;$bottomLimit = $pa->y2;+ $barcodeX = null;+ $barcodeY = null;+ $barcodeSize = null;if ($record->has('barcode1d') && $this->getSupport1DBarcode()) {$barcodeSize = $this->getBarcodeSize();@@ -452,10 +464,11 @@ abstract class CustomSheetLabel extends CustomLabel$textX = $currentX;$textY = $currentY;+ $tagAlign = $this->getTagAlignment();+if ($record->has('barcode2d') && $this->getSupport2DBarcode()) {$barcodeSize = $this->get2DBarcodeSize();$barcodeMargin = $this->getBarcodeMargin();- $tagSize = $this->getTagSize();$barcodeX = $currentX;$barcodeY = $currentY;@@ -470,31 +483,44 @@ abstract class CustomSheetLabel extends CustomLabel$barcodeSize);- if ($record->has('tag') && $this->getSupportAssetTag()) {- $tagY = $barcodeY + $barcodeSize + $barcodeMargin;-- static::writeText(- $pdf,- $record->get('tag'),- $barcodeX,- $tagY,- 'freemono',- 'B',- $tagSize,- 'L',- $barcodeSize,- $tagSize,- true,- 0,- 0.3- );- }-$textX = $barcodeX + $barcodeSize + $barcodeMargin;$usableWidth = max(0, ($pa->x1 + $pa->w) - $textX);$textY = $barcodeY;}+ if ($record->has('tag') && $this->getSupportAssetTag()) {+ $tagSize = $this->getTagSize();+ $barcodeMargin = $this->getBarcodeMargin();++ if ($barcodeX !== null && $barcodeY !== null && $barcodeSize !== null) {+ // normal case: put tag under 2D barcode+ $tagX = $barcodeX;+ $tagY = $barcodeY + $barcodeSize + $barcodeMargin;+ $tagWidth = $barcodeSize;+ } else {+ // fallback: no 2D barcode, still show tag+ $tagX = $currentX;+ $tagY = $currentY;+ $tagWidth = $usableWidth;+ }++ static::writeText(+ $pdf,+ $record->get('tag'),+ $tagX,+ $tagY,+ 'freemono',+ 'B',+ $tagSize,+ $tagAlign,+ $tagWidth,+ $tagSize,+ true,+ 0,+ 0.3+ );+ }+$title = null;if ($record->has('title') && $this->getSupportTitle()) {$title = $record->get('title');diff --git a/app/Models/Labels/Label.php b/app/Models/Labels/Label.phpindex 377f966fbc..210a0f965c 100644--- a/app/Models/Labels/Label.php+++ b/app/Models/Labels/Label.php@@ -783,6 +783,7 @@ abstract class Label'barcode_size' => $this->getBarcodeSize(),'barcode_margin' => $this->getBarcodeMargin(),'barcode_2d_size' => $this->get2DBarcodeSize(),+ 'tag_alignment' => $this->getTagAlignment(),'logo_max_width' => $this->getLogoMaxWidth(),'logo_margin' => $this->getLogoMargin(),'tag_font_size' => $this->getTagSize(),diff --git a/resources/views/settings/label-edit.blade.php b/resources/views/settings/label-edit.blade.phpindex 5577423c47..5892f4f36a 100644--- a/resources/views/settings/label-edit.blade.php+++ b/resources/views/settings/label-edit.blade.php@@ -231,8 +231,20 @@<div class="form-group"><label class="col-md-5 control-label">{{ $key }}</label><div class="col-md-7">- <input type="number" step="0.001" name="content[{{ $key }}]"- value="{{ $value }}" class="form-control">+ @if($key === 'tag_alignment')+ <select name="content[{{ $key }}]" class="form-control">+ <option value="L" {{ $value === 'L' ? 'selected' : '' }}>Left+ </option>+ <option value="C" {{ $value === 'C' ? 'selected' : '' }}>+ Center+ </option>+ <option value="R" {{ $value === 'R' ? 'selected' : '' }}>Right+ </option>+ </select>+ @else+ <input type="number" step="0.001" name="content[{{ $key }}]"+ value="{{ $value }}" class="form-control">+ @endif</div></div>@endforeach