Skip to content

A free open source IT asset/license management system

add labelEditor extraction methods for 3490_A

Godfrey M968abd2b90b9
diff --git a/app/Models/Labels/Label.php b/app/Models/Labels/Label.php
index 13069be46a..74a6ced3dc 100644
--- a/app/Models/Labels/Label.php
+++ b/app/Models/Labels/Label.php
@@ -725,4 +725,68 @@ abstract class Label
}
);
}
+
+ public function toEditorConfig(): array
+ {
+ return [
+ 'name' => $this->getName(),
+ 'unit' => $this->getUnit(),
+ 'dimensions' => $this->getDimensionsEditorConfig(),
+ 'printable_area' => $this->getPrintableAreaEditorConfig(),
+ 'supports' => $this->getSupportsEditorConfig(),
+ 'content' => $this->getContentEditorConfig(),
+ 'meta' => $this->getMetaEditorConfig(),
+ ];
+ }
+
+ protected function getDimensionsEditorConfig(): array
+ {
+ return [
+ 'width' => $this->getWidth(),
+ 'height' => $this->getHeight(),
+ 'margin_top' => $this->getMarginTop(),
+ 'margin_right' => $this->getMarginRight(),
+ 'margin_bottom' => $this->getMarginBottom(),
+ 'margin_left' => $this->getMarginLeft(),
+ ];
+ }
+
+ protected function getPrintableAreaEditorConfig(): array
+ {
+ $pa = $this->getPrintableArea();
+
+ return [
+ 'x1' => $pa->x1,
+ 'y1' => $pa->y1,
+ 'x2' => $pa->x2,
+ 'y2' => $pa->y2,
+ 'width' => $pa->w,
+ 'height' => $pa->h,
+ ];
+ }
+
+ protected function getSupportsEditorConfig(): array
+ {
+ return [
+ 'asset_tag' => $this->getSupportAssetTag(),
+ 'barcode_1d' => $this->getSupport1DBarcode(),
+ 'barcode_2d' => $this->getSupport2DBarcode(),
+ 'fields' => $this->getSupportFields(),
+ 'logo' => $this->getSupportLogo(),
+ 'title' => $this->getSupportTitle(),
+ ];
+ }
+
+ protected function getContentEditorConfig(): array
+ {
+ return [];
+ }
+
+ protected function getMetaEditorConfig(): array
+ {
+ return [
+ 'orientation' => $this->getOrientation(),
+ 'rotation' => $this->getRotation(),
+ ];
+ }
}
diff --git a/app/Models/Labels/RectangleSheet.php b/app/Models/Labels/RectangleSheet.php
index e5dd0cb8fd..73c52e5adf 100644
--- a/app/Models/Labels/RectangleSheet.php
+++ b/app/Models/Labels/RectangleSheet.php
@@ -47,4 +47,21 @@ abstract class RectangleSheet extends Sheet
return [$x, $y];
}
+
+ public function toEditorConfig(): array
+ {
+ return array_merge(parent::toEditorConfig(), [
+ 'grid' => $this->getGridEditorConfig(),
+ ]);
+ }
+
+ protected function getGridEditorConfig(): array
+ {
+ return [
+ 'columns' => $this->getColumns(),
+ 'rows' => $this->getRows(),
+ 'column_spacing' => $this->getLabelColumnSpacing(),
+ 'row_spacing' => $this->getLabelRowSpacing(),
+ ];
+ }
}
diff --git a/app/Models/Labels/Sheet.php b/app/Models/Labels/Sheet.php
index 8fe30de388..10595bfbaf 100644
--- a/app/Models/Labels/Sheet.php
+++ b/app/Models/Labels/Sheet.php
@@ -232,4 +232,62 @@ abstract class Sheet extends Label
{
$this->indexOffset = $offset;
}
+
+ public function toEditorConfig(): array
+ {
+ return array_merge(parent::toEditorConfig(), [
+ 'page' => $this->getPageEditorConfig(),
+ 'label' => $this->getLabelEditorConfig(),
+ 'label_printable_area' => $this->getLabelPrintableAreaEditorConfig(),
+ 'sheet' => $this->getSheetEditorConfig(),
+ ]);
+ }
+
+ protected function getPageEditorConfig(): array
+ {
+ return [
+ 'width' => $this->getPageWidth(),
+ 'height' => $this->getPageHeight(),
+ 'margin_top' => $this->getPageMarginTop(),
+ 'margin_right' => $this->getPageMarginRight(),
+ 'margin_bottom' => $this->getPageMarginBottom(),
+ 'margin_left' => $this->getPageMarginLeft(),
+ ];
+ }
+
+ protected function getLabelEditorConfig(): array
+ {
+ return [
+ 'width' => $this->getLabelWidth(),
+ 'height' => $this->getLabelHeight(),
+ 'border' => $this->getLabelBorder(),
+ 'padding_top' => $this->getLabelMarginTop(),
+ 'padding_right' => $this->getLabelMarginRight(),
+ 'padding_bottom' => $this->getLabelMarginBottom(),
+ 'padding_left' => $this->getLabelMarginLeft(),
+ ];
+ }
+
+ protected function getLabelPrintableAreaEditorConfig(): array
+ {
+ $pa = $this->getLabelPrintableArea();
+
+ return [
+ 'x1' => $pa->x1,
+ 'y1' => $pa->y1,
+ 'x2' => $pa->x2,
+ 'y2' => $pa->y2,
+ 'width' => $pa->w,
+ 'height' => $pa->h,
+ ];
+ }
+
+ protected function getSheetEditorConfig(): array
+ {
+ return [
+ 'labels_per_page' => $this->getLabelsPerPage(),
+ 'index_offset' => $this->getLabelIndexOffset(),
+ 'label_orientation' => $this->getLabelOrientation(),
+ ];
+ }
}
diff --git a/app/Models/Labels/Sheets/Avery/_3490_A.php b/app/Models/Labels/Sheets/Avery/_3490_A.php
index 9ac77f87da..13e0946536 100644
--- a/app/Models/Labels/Sheets/Avery/_3490_A.php
+++ b/app/Models/Labels/Sheets/Avery/_3490_A.php
@@ -20,6 +20,46 @@ class _3490_A extends _3490
private const FIELD_MARGIN = 0.012;
+ public function getBarcodeMargin()
+ {
+ return self::BARCODE_MARGIN;
+ }
+
+ public function getTagSize()
+ {
+ return self::TAG_SIZE;
+ }
+
+ public function getTitleSize()
+ {
+ return self::TITLE_SIZE;
+ }
+
+ public function getTitleMargin()
+ {
+ return self::TITLE_MARGIN;
+ }
+
+ public function getLabelSize()
+ {
+ return self::LABEL_SIZE;
+ }
+
+ public function getLabelMargin()
+ {
+ return self::LABEL_MARGIN;
+ }
+
+ public function getFieldSize()
+ {
+ return self::FIELD_SIZE;
+ }
+
+ public function getFieldMargin()
+ {
+ return self::FIELD_MARGIN;
+ }
+
public function getUnit()
{
return 'in';
@@ -75,6 +115,32 @@ class _3490_A extends _3490
return true;
}
+ protected function getContentEditorConfig(): array
+ {
+ return [
+ 'barcode_margin' => $this->getBarcodeMargin(),
+ 'tag_font_size' => $this->getTagSize(),
+ 'title_font_size' => $this->getTitleSize(),
+ 'title_margin' => $this->getTitleMargin(),
+ 'field_label_font_size' => $this->getLabelSize(),
+ 'field_label_margin' => $this->getLabelMargin(),
+ 'field_value_font_size' => $this->getFieldSize(),
+ 'field_value_margin' => $this->getFieldMargin(),
+ ];
+ }
+
+ protected function getSupportsEditorConfig(): array
+ {
+ return [
+ 'asset_tag' => $this->getSupportAssetTag(),
+ 'barcode_1d' => $this->getSupport1DBarcode(),
+ 'barcode_2d' => $this->getSupport2DBarcode(),
+ 'fields' => $this->getSupportFields(),
+ 'logo' => $this->getSupportLogo(),
+ 'title' => $this->getSupportTitle(),
+ ];
+ }
+
public function preparePDF($pdf) {}
public function write($pdf, $record)
diff --git a/routes/web.php b/routes/web.php
index 4488f7a7bf..0d3653b918 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -33,6 +33,7 @@ use App\Livewire\Importer;
use App\Models\ReportTemplate;
use Illuminate\Support\Facades\Route;
use Tabuna\Breadcrumbs\Trail;
+use App\Models\Labels\Sheets\Avery\_3490_A;
Route::group(['middleware' => 'auth'], function () {
/*
@@ -569,7 +570,11 @@ Route::group(['prefix' => 'reports', 'middleware' => ['auth']], function () {
Route::delete('/{reportTemplate}', [ReportTemplatesController::class, 'destroy'])
->name('report-templates.destroy');
});
+ Route::get('/debug/label', function () {
+ $label = new _3490_A();
+ dd($label->toEditorConfig());
+ });
Route::get(