A free open source IT asset/license management system
feat: create hema labels template
Florian Vaneste0c30a8407613
diff --git a/app/Models/Labels/Sheets/Hema/_14130046.php b/app/Models/Labels/Sheets/Hema/_14130046.phpnew file mode 100644index 0000000000..2d50e121e1--- /dev/null+++ b/app/Models/Labels/Sheets/Hema/_14130046.php@@ -0,0 +1,213 @@+<?php++namespace App\Models\Labels\Sheets\Hema;++use App\Models\Labels\RectangleSheet;++/**+ * HEMA 14130046 — sheet of 10 labels (2 columns x 5 rows), each 38 x 19 mm.+ *+ * Layout: a square QR code on the left occupying nearly the full label height+ * (with a 2 mm margin all around), and the title/fields on the right.+ *+ * Geometry was measured from the manufacturer's template PDF:+ * page 80 x 119 mm+ * margins left/right 1 mm, top/bottom 4 mm+ * gutters 2 mm between columns, 4 mm between rows+ * label 38 x 19 mm+ */+class _14130046 extends RectangleSheet+{+ /* Sheet geometry (mm) */+ private const PAGE_WIDTH = 80.0;++ private const PAGE_HEIGHT = 119.0;++ private const PAGE_MARGIN_TOP = 4.0;++ private const PAGE_MARGIN_LEFT = 1.0;++ private const LABEL_WIDTH = 38.0;++ private const LABEL_HEIGHT = 19.0;++ private const COLUMN_SPACING = 2.0;++ private const ROW_SPACING = 4.0;++ /* Content layout (mm) */+ private const CONTENT_MARGIN = 2.0;++ private const QR_GUTTER = 2.0;++ private const TITLE_SIZE = 2.6;++ private const TITLE_MARGIN = 0.6;++ private const FIELD_SIZE = 2.4;++ private const FIELD_MARGIN = 0.5;++ public function getUnit()+ {+ return 'mm';+ }++ public function getPageWidth()+ {+ return self::PAGE_WIDTH;+ }++ public function getPageHeight()+ {+ return self::PAGE_HEIGHT;+ }++ public function getPageMarginTop()+ {+ return self::PAGE_MARGIN_TOP;+ }++ public function getPageMarginBottom()+ {+ return self::PAGE_MARGIN_TOP;+ }++ public function getPageMarginLeft()+ {+ return self::PAGE_MARGIN_LEFT;+ }++ public function getPageMarginRight()+ {+ return self::PAGE_MARGIN_LEFT;+ }++ public function getColumns()+ {+ return 2;+ }++ public function getRows()+ {+ return 5;+ }++ public function getLabelColumnSpacing()+ {+ return self::COLUMN_SPACING;+ }++ public function getLabelRowSpacing()+ {+ return self::ROW_SPACING;+ }++ public function getLabelWidth()+ {+ return self::LABEL_WIDTH;+ }++ public function getLabelHeight()+ {+ return self::LABEL_HEIGHT;+ }++ public function getLabelBorder()+ {+ return 0;+ }++ public function getLabelMarginTop()+ {+ return 0;+ }++ public function getLabelMarginBottom()+ {+ return 0;+ }++ public function getLabelMarginLeft()+ {+ return 0;+ }++ public function getLabelMarginRight()+ {+ return 0;+ }++ public function getSupportAssetTag()+ {+ return false;+ }++ public function getSupport1DBarcode()+ {+ return false;+ }++ public function getSupport2DBarcode()+ {+ return true;+ }++ public function getSupportFields()+ {+ return 4;+ }++ public function getSupportLogo()+ {+ return false;+ }++ public function getSupportTitle()+ {+ return true;+ }++ public function preparePDF($pdf) {}++ public function write($pdf, $record)+ {+ // The QR code is a square occupying (nearly) the full label height,+ // with a CONTENT_MARGIN margin all around it, pinned to the left.+ $qrSize = $this->getLabelHeight() - (2 * self::CONTENT_MARGIN);+ $qrX = self::CONTENT_MARGIN;+ $qrY = self::CONTENT_MARGIN;++ if ($record->get('barcode2d')) {+ static::write2DBarcode(+ $pdf, $record->get('barcode2d')->content, $record->get('barcode2d')->type,+ $qrX, $qrY, $qrSize, $qrSize+ );+ }++ // Fields sit to the right of the QR code.+ $textX = $qrX + $qrSize + self::QR_GUTTER;+ $textW = $this->getLabelWidth() - self::CONTENT_MARGIN - $textX;+ $textY = self::CONTENT_MARGIN;++ if ($record->get('title')) {+ static::writeText(+ $pdf, $record->get('title'),+ $textX, $textY,+ 'freesans', 'b', self::TITLE_SIZE, 'L',+ $textW, self::TITLE_SIZE, true, 0+ );+ $textY += self::TITLE_SIZE + self::TITLE_MARGIN;+ }++ foreach ($record->get('fields') as $field) {+ static::writeText(+ $pdf, (($field['label']) ? $field['label'].' ' : '').$field['value'],+ $textX, $textY,+ 'freesans', '', self::FIELD_SIZE, 'L',+ $textW, self::FIELD_SIZE, true, 0+ );+ $textY += self::FIELD_SIZE + self::FIELD_MARGIN;+ }+ }+}diff --git a/app/Models/Labels/Sheets/Hema/_38310012.php b/app/Models/Labels/Sheets/Hema/_38310012.phpnew file mode 100644index 0000000000..4bee64b24f--- /dev/null+++ b/app/Models/Labels/Sheets/Hema/_38310012.php@@ -0,0 +1,213 @@+<?php++namespace App\Models\Labels\Sheets\Hema;++use App\Models\Labels\RectangleSheet;++/**+ * HEMA 38310012 — A4 sheet of 21 labels (3 columns x 7 rows), each 63.5 x 38.1 mm.+ *+ * Layout: a square QR code on the left occupying nearly the full label height+ * (with a 2 mm margin all around), and the title/fields on the right.+ *+ * Geometry (mm):+ * page 210 x 297 mm (A4 portrait)+ * margins left/right 6 mm, top/bottom 13 mm+ * gutters 3 mm between columns, 0 mm between rows+ * label 63.5 x 38.1 mm+ */+class _38310012 extends RectangleSheet+{+ /* Sheet geometry (mm) */+ private const PAGE_WIDTH = 210.0;++ private const PAGE_HEIGHT = 297.0;++ private const PAGE_MARGIN_TOP = 13.0;++ private const PAGE_MARGIN_LEFT = 6.0;++ private const LABEL_WIDTH = 63.5;++ private const LABEL_HEIGHT = 38.1;++ private const COLUMN_SPACING = 3.0;++ private const ROW_SPACING = 0.0;++ /* Content layout (mm) */+ private const CONTENT_MARGIN = 2.0;++ private const QR_GUTTER = 3.0;++ private const TITLE_SIZE = 3.6;++ private const TITLE_MARGIN = 1.0;++ private const FIELD_SIZE = 3.0;++ private const FIELD_MARGIN = 0.8;++ public function getUnit()+ {+ return 'mm';+ }++ public function getPageWidth()+ {+ return self::PAGE_WIDTH;+ }++ public function getPageHeight()+ {+ return self::PAGE_HEIGHT;+ }++ public function getPageMarginTop()+ {+ return self::PAGE_MARGIN_TOP;+ }++ public function getPageMarginBottom()+ {+ return self::PAGE_MARGIN_TOP;+ }++ public function getPageMarginLeft()+ {+ return self::PAGE_MARGIN_LEFT;+ }++ public function getPageMarginRight()+ {+ return self::PAGE_MARGIN_LEFT;+ }++ public function getColumns()+ {+ return 3;+ }++ public function getRows()+ {+ return 7;+ }++ public function getLabelColumnSpacing()+ {+ return self::COLUMN_SPACING;+ }++ public function getLabelRowSpacing()+ {+ return self::ROW_SPACING;+ }++ public function getLabelWidth()+ {+ return self::LABEL_WIDTH;+ }++ public function getLabelHeight()+ {+ return self::LABEL_HEIGHT;+ }++ public function getLabelBorder()+ {+ return 0;+ }++ public function getLabelMarginTop()+ {+ return 0;+ }++ public function getLabelMarginBottom()+ {+ return 0;+ }++ public function getLabelMarginLeft()+ {+ return 0;+ }++ public function getLabelMarginRight()+ {+ return 0;+ }++ public function getSupportAssetTag()+ {+ return false;+ }++ public function getSupport1DBarcode()+ {+ return false;+ }++ public function getSupport2DBarcode()+ {+ return true;+ }++ public function getSupportFields()+ {+ return 5;+ }++ public function getSupportLogo()+ {+ return false;+ }++ public function getSupportTitle()+ {+ return true;+ }++ public function preparePDF($pdf) {}++ public function write($pdf, $record)+ {+ // The QR code is a square occupying (nearly) the full label height,+ // with a CONTENT_MARGIN margin all around it, pinned to the left.+ $qrSize = $this->getLabelHeight() - (2 * self::CONTENT_MARGIN);+ $qrX = self::CONTENT_MARGIN;+ $qrY = self::CONTENT_MARGIN;++ if ($record->get('barcode2d')) {+ static::write2DBarcode(+ $pdf, $record->get('barcode2d')->content, $record->get('barcode2d')->type,+ $qrX, $qrY, $qrSize, $qrSize+ );+ }++ // Fields sit to the right of the QR code.+ $textX = $qrX + $qrSize + self::QR_GUTTER;+ $textW = $this->getLabelWidth() - self::CONTENT_MARGIN - $textX;+ $textY = self::CONTENT_MARGIN;++ if ($record->get('title')) {+ static::writeText(+ $pdf, $record->get('title'),+ $textX, $textY,+ 'freesans', 'b', self::TITLE_SIZE, 'L',+ $textW, self::TITLE_SIZE, true, 0+ );+ $textY += self::TITLE_SIZE + self::TITLE_MARGIN;+ }++ foreach ($record->get('fields') as $field) {+ static::writeText(+ $pdf, (($field['label']) ? $field['label'].' ' : '').$field['value'],+ $textX, $textY,+ 'freesans', '', self::FIELD_SIZE, 'L',+ $textW, self::FIELD_SIZE, true, 0+ );+ $textY += self::FIELD_SIZE + self::FIELD_MARGIN;+ }+ }+}