Skip to content

A free open source IT asset/license management system

Add Asset Tag as separate supported feature

Cram424bb40adfce82
diff --git a/app/Http/Transformers/LabelsTransformer.php b/app/Http/Transformers/LabelsTransformer.php
index f575f91d6c..8e0e8ca44e 100644
--- a/app/Http/Transformers/LabelsTransformer.php
+++ b/app/Http/Transformers/LabelsTransformer.php
@@ -34,6 +34,7 @@ class LabelsTransformer
'margin_left' => $label->getMarginLeft(),
'margin_right' => $label->getMarginRight(),
+ 'support_asset_tag' => $label->getSupportAssetTag(),
'support_1d_barcode' => $label->getSupport1DBarcode(),
'support_2d_barcode' => $label->getSupport2DBarcode(),
'support_fields' => $label->getSupportFields(),
diff --git a/app/Models/Labels/DefaultLabel.php b/app/Models/Labels/DefaultLabel.php
index 103e3181e0..e43519325a 100644
--- a/app/Models/Labels/DefaultLabel.php
+++ b/app/Models/Labels/DefaultLabel.php
@@ -90,6 +90,7 @@ class DefaultLabel extends RectangleSheet
public function getLabelColumnSpacing() { return $this->labelSpacingH; }
public function getLabelRowSpacing() { return $this->labelSpacingV; }
+ public function getSupportAssetTag() { return false; }
public function getSupport1DBarcode() { return true; }
public function getSupport2DBarcode() { return true; }
public function getSupportFields() { return 4; }
diff --git a/app/Models/Labels/Label.php b/app/Models/Labels/Label.php
index 2480441631..2ac37abe11 100644
--- a/app/Models/Labels/Label.php
+++ b/app/Models/Labels/Label.php
@@ -65,6 +65,13 @@ abstract class Label
*/
public abstract function getMarginRight();
+ /**
+ * Returns whether the template supports an asset tag.
+ *
+ * @return bool
+ */
+ public abstract function getSupportAssetTag();
+
/**
* Returns whether the template supports a 1D barcode.
*
diff --git a/app/Models/Labels/Sheets/Avery/L7162_A.php b/app/Models/Labels/Sheets/Avery/L7162_A.php
new file mode 100644
index 0000000000..c6d10cc5f7
--- /dev/null
+++ b/app/Models/Labels/Sheets/Avery/L7162_A.php
@@ -0,0 +1,100 @@
+<?php
+
+namespace App\Models\Labels\Sheets\Avery;
+
+
+class L7162_A extends L7162
+{
+ private const BARCODE_MARGIN = 1.60;
+ private const TAG_SIZE = 4.60;
+ private const TITLE_SIZE = 4.20;
+ private const TITLE_MARGIN = 1.40;
+ private const LABEL_SIZE = 2.20;
+ private const LABEL_MARGIN = - 0.50;
+ private const FIELD_SIZE = 4.60;
+ private const FIELD_MARGIN = 0.30;
+
+ public function getUnit() { return 'mm'; }
+
+ public function getLabelMarginTop() { return 1.0; }
+ public function getLabelMarginBottom() { return 1.0; }
+ public function getLabelMarginLeft() { return 1.0; }
+ public function getLabelMarginRight() { return 1.0; }
+
+ public function getSupportAssetTag() { return true; }
+ 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) {
+ $pa = $this->getLabelPrintableArea();
+
+ $usableWidth = $pa->w;
+ $usableHeight = $pa->h;
+ $currentX = $pa->x1;
+ $currentY = $pa->y1;
+ $titleShiftX = 0;
+
+ $barcodeSize = $pa->h - self::TAG_SIZE;
+
+ if ($record->has('barcode2d')) {
+ static::writeText(
+ $pdf, $record->get('tag'),
+ $pa->x1, $pa->y2 - self::TAG_SIZE,
+ 'freemono', 'b', self::TAG_SIZE, 'C',
+ $barcodeSize, self::TAG_SIZE, true, 0
+ );
+ static::write2DBarcode(
+ $pdf, $record->get('barcode2d')->content, $record->get('barcode2d')->type,
+ $pa->x1, $pa->y1,
+ $barcodeSize, $barcodeSize
+ );
+ $currentX += $barcodeSize + self::BARCODE_MARGIN;
+ $usableWidth -= $barcodeSize + self::BARCODE_MARGIN;
+ } else {
+ static::writeText(
+ $pdf, $record->get('tag'),
+ $pa->x1, $pa->y1,
+ 'freemono', 'b', self::TITLE_SIZE, 'L',
+ $barcodeSize, self::TITLE_SIZE, true, 0
+ );
+ $titleShiftX = $barcodeSize;
+ }
+
+ if ($record->has('title')) {
+ static::writeText(
+ $pdf, $record->get('title'),
+ $currentX + $titleShiftX, $currentY,
+ 'freesans', '', self::TITLE_SIZE, 'L',
+ $usableWidth, self::TITLE_SIZE, true, 0
+ );
+ $currentY += self::TITLE_SIZE + self::TITLE_MARGIN;
+ }
+
+ foreach ($record->get('fields') as $label => $value) {
+ static::writeText(
+ $pdf, $label,
+ $currentX, $currentY,
+ 'freesans', '', self::LABEL_SIZE, 'L',
+ $usableWidth, self::LABEL_SIZE, true, 0
+ );
+ $currentY += self::LABEL_SIZE + self::LABEL_MARGIN;
+
+ static::writeText(
+ $pdf, $value,
+ $currentX, $currentY,
+ 'freemono', 'B', self::FIELD_SIZE, 'L',
+ $usableWidth, self::FIELD_SIZE, true, 0, 0.3
+ );
+ $currentY += self::FIELD_SIZE + self::FIELD_MARGIN;
+ }
+
+ }
+}
+
+
+?>
\ No newline at end of file
diff --git a/app/Models/Labels/Sheets/Avery/L7162_B.php b/app/Models/Labels/Sheets/Avery/L7162_B.php
new file mode 100644
index 0000000000..8aea715e00
--- /dev/null
+++ b/app/Models/Labels/Sheets/Avery/L7162_B.php
@@ -0,0 +1,103 @@
+<?php
+
+namespace App\Models\Labels\Sheets\Avery;
+
+
+class L7162_B extends L7162
+{
+ private const BARCODE_SIZE = 6.00;
+ private const BARCODE_MARGIN = 1.40;
+ private const TAG_SIZE = 3.20;
+ private const LOGO_MAX_WIDTH = 25.00;
+ private const LOGO_MARGIN = 2.20;
+ private const TITLE_SIZE = 4.20;
+ private const TITLE_MARGIN = 1.20;
+ private const LABEL_SIZE = 2.20;
+ private const LABEL_MARGIN = - 0.50;
+ private const FIELD_SIZE = 4.20;
+ private const FIELD_MARGIN = 0.30;
+
+ public function getUnit() { return 'mm'; }
+
+ public function getLabelMarginTop() { return 1.0; }
+ public function getLabelMarginBottom() { return 0; }
+ public function getLabelMarginLeft() { return 1.0; }
+ public function getLabelMarginRight() { return 1.0; }
+
+ public function getSupportAssetTag() { return true; }
+ public function getSupport1DBarcode() { return true; }
+ public function getSupport2DBarcode() { return false; }
+ public function getSupportFields() { return 3; }
+ public function getSupportLogo() { return true; }
+ public function getSupportTitle() { return true; }
+
+ public function preparePDF($pdf) {}
+
+ public function write($pdf, $record) {
+ $pa = $this->getLabelPrintableArea();
+
+ $usableWidth = $pa->w;
+ $usableHeight = $pa->h;
+ $currentX = $pa->x1;
+ $currentY = $pa->y1;
+
+ if ($record->has('barcode1d')) {
+ static::write1DBarcode(
+ $pdf, $record->get('barcode1d')->content, $record->get('barcode1d')->type,
+ $pa->x1, $pa->y2 - self::BARCODE_SIZE,
+ $usableWidth, self::BARCODE_SIZE
+ );
+ $usableHeight -= self::BARCODE_SIZE + self::BARCODE_MARGIN;
+ }
+
+ if ($record->has('logo')) {
+ $logoSize = static::writeImage(
+ $pdf, $record->get('logo'),
+ $pa->x1, $pa->y1,
+ self::LOGO_MAX_WIDTH, $usableHeight,
+ 'L', 'T', 300, true, false, 0.1
+ );
+ $currentX += $logoSize[0] + self::LOGO_MARGIN;
+ $usableWidth -= $logoSize[0] + self::LOGO_MARGIN;
+ }
+
+ if ($record->has('title')) {
+ static::writeText(
+ $pdf, $record->get('title'),
+ $currentX, $currentY,
+ 'freesans', '', self::TITLE_SIZE, 'L',
+ $usableWidth, self::TITLE_SIZE, true, 0
+ );
+ $currentY += self::TITLE_SIZE + self::TITLE_MARGIN;
+ }
+
+ foreach ($record->get('fields') as $label => $value) {
+ static::writeText(
+ $pdf, $label,
+ $currentX, $currentY,
+ 'freesans', '', self::LABEL_SIZE, 'L',
+ $usableWidth, self::LABEL_SIZE, true, 0
+ );
+ $currentY += self::LABEL_SIZE + self::LABEL_MARGIN;
+
+ static::writeText(
+ $pdf, $value,
+ $currentX, $currentY,
+ 'freemono', 'B', self::FIELD_SIZE, 'L',
+ $usableWidth, self::FIELD_SIZE, true, 0, 0.3
+ );
+ $currentY += self::FIELD_SIZE + self::FIELD_MARGIN;
+ }
+
+ static::writeText(
+ $pdf, $record->get('tag'),
+ $currentX, $pa->y2 - self::BARCODE_SIZE - self::BARCODE_MARGIN - self::TAG_SIZE,
+ 'freemono', 'b', self::TAG_SIZE, 'R',
+ $usableWidth, self::TAG_SIZE, true, 0, 0.3
+ );
+
+ }
+}
+
+
+?>
\ No newline at end of file
diff --git a/app/Models/Labels/Sheets/Avery/L7162_Example.php b/app/Models/Labels/Sheets/Avery/L7162_Example.php
deleted file mode 100644
index 10d1a4f9e2..0000000000
--- a/app/Models/Labels/Sheets/Avery/L7162_Example.php
+++ /dev/null
@@ -1,91 +0,0 @@
-<?php
-
-namespace App\Models\Labels\Sheets\Avery;
-
-
-class L7162_Example extends L7162
-{
- private const BARCODE1D_SIZE = 6.0;
- private const LOGO_MAX_WIDTH = 25.0;
- private const LOGO_MARGIN = 1.4;
- private const TITLE_SIZE = 4.0;
- private const TITLE_MARGIN = 1.6;
- private const LABEL_SIZE = 2.2;
- private const LABEL_MARGIN = -0.5;
- private const FIELD_SIZE = 4.8;
- private const FIELD_MARGIN = 0.3;
-
- public function getUnit() { return 'mm'; }
-
- public function getLabelMarginTop() { return 1.0; }
- public function getLabelMarginBottom() { return 0; }
- public function getLabelMarginLeft() { return 1.0; }
- public function getLabelMarginRight() { return 1.0; }
-
- public function getSupport1DBarcode() { return true; }
- public function getSupport2DBarcode() { return false; }
- public function getSupportFields() { return 3; }
- public function getSupportLogo() { return true; }
- public function getSupportTitle() { return true; }
-
- public function preparePDF($pdf) {}
-
- public function write($pdf, $record) {
- $pa = $this->getLabelPrintableArea();
-
- $x = $pa->x1;
- $y = $pa->y1;
- $w = $pa->w;
-
- static::write1DBarcode(
- $pdf, $record->get('barcode1d')->content, $record->get('barcode1d')->type,
- $pa->x1, $pa->y2 - self::BARCODE1D_SIZE,
- $pa->w, self::BARCODE1D_SIZE
- );
-
- if ($record->get('logo')) {
- $logoMaxHeight = $pa->h - self::BARCODE1D_SIZE - self::LOGO_MARGIN;
- $logoSize = static::writeImage(
- $pdf, $record->get('logo'),
- $x, $y,
- self::LOGO_MAX_WIDTH, $logoMaxHeight,
- 'L', 'T', 300,
- true, false, 0
- );
- $x += $logoSize[0] + self::LOGO_MARGIN;
- $w -= ($logoSize[0] + self::LOGO_MARGIN);
- }
-
- if ($record->get('title')) {
- static::writeText(
- $pdf, $record->get('title'),
- $x, $y,
- 'freesans', '', self::TITLE_SIZE, 'L',
- $w, self::TITLE_SIZE, true, 0
- );
- $y += self::TITLE_SIZE + self::TITLE_MARGIN;
- }
-
- foreach ($record->get('fields') as $label => $value) {
- static::writeText(
- $pdf, $label,
- $x, $y,
- 'freesans', '', self::LABEL_SIZE, 'L',
- $w, self::LABEL_SIZE, true, 0
- );
- $y += self::LABEL_SIZE + self::LABEL_MARGIN;
-
- static::writeText(
- $pdf, $value,
- $x, $y,
- 'freemono', 'B', self::FIELD_SIZE, 'L',
- $w, self::FIELD_SIZE, true, 0, 0.3
- );
- $y += self::FIELD_SIZE + self::FIELD_MARGIN;
- }
-
- }
-}
-
-
-?>
\ No newline at end of file
diff --git a/app/Models/Labels/Sheets/Avery/L7162_Example_QR.php b/app/Models/Labels/Sheets/Avery/L7162_Example_QR.php
deleted file mode 100644
index 54c886e6e4..0000000000
--- a/app/Models/Labels/Sheets/Avery/L7162_Example_QR.php
+++ /dev/null
@@ -1,77 +0,0 @@
-<?php
-
-namespace App\Models\Labels\Sheets\Avery;
-
-
-class L7162_Example_QR extends L7162
-{
- private const BARCODE1D_SIZE = 6.0;
- private const BARCODE2D_MARGIN = 1.4;
- private const TITLE_SIZE = 4.0;
- private const TITLE_MARGIN = 1.6;
- private const LABEL_SIZE = 2.2;
- private const LABEL_MARGIN = - 0.5;
- private const FIELD_SIZE = 4.8;
- private const FIELD_MARGIN = 0.3;
-
- public function getUnit() { return 'mm'; }
-
- public function getLabelMarginTop() { return 1.0; }
- public function getLabelMarginBottom() { return 1.0; }
- public function getLabelMarginLeft() { return 1.0; }
- public function getLabelMarginRight() { return 1.0; }
-
- 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) {
- $pa = $this->getLabelPrintableArea();
-
- static::write2DBarcode(
- $pdf, $record->get('barcode2d')->content, $record->get('barcode2d')->type,
- $pa->x1, $pa->y1,
- $pa->h, $pa->h
- );
-
- $x = $pa->x1 + $pa->h + self::BARCODE2D_MARGIN;
- $y = $pa->y1;
- $w = $pa->w - $pa->h - self::BARCODE2D_MARGIN;
-
- if ($record->get('title')) {
- static::writeText(
- $pdf, $record->get('title'),
- $x, $y,
- 'freesans', '', self::TITLE_SIZE, 'L',
- $w, self::TITLE_SIZE, true, 0
- );
- $y += self::TITLE_SIZE + self::TITLE_MARGIN;
- }
-
- foreach ($record->get('fields') as $label => $value) {
- static::writeText(
- $pdf, $label,
- $x, $y,
- 'freesans', '', self::LABEL_SIZE, 'L',
- $w, self::LABEL_SIZE, true, 0
- );
- $y += self::LABEL_SIZE + self::LABEL_MARGIN;
-
- static::writeText(
- $pdf, $value,
- $x, $y,
- 'freemono', 'B', self::FIELD_SIZE, 'L',
- $w, self::FIELD_SIZE, true, 0, 0.3
- );
- $y += self::FIELD_SIZE + self::FIELD_MARGIN;
- }
-
- }
-}
-
-
-?>
\ No newline at end of file
diff --git a/app/Models/Labels/Tapes/Brother/TZe_12mm_A.php b/app/Models/Labels/Tapes/Brother/TZe_12mm_A.php
index 060ab3cb83..dbac6b9a71 100644
--- a/app/Models/Labels/Tapes/Brother/TZe_12mm_A.php
+++ b/app/Models/Labels/Tapes/Brother/TZe_12mm_A.php
@@ -10,6 +10,7 @@ class TZe_12mm_A extends TZe_12mm
public function getUnit() { return 'mm'; }
public function getWidth() { return 50.0; }
+ public function getSupportAssetTag() { return false; }
public function getSupport1DBarcode() { return true; }
public function getSupport2DBarcode() { return false; }
public function getSupportFields() { return 2; }
diff --git a/app/Models/Labels/Tapes/Brother/TZe_24mm_A.php b/app/Models/Labels/Tapes/Brother/TZe_24mm_A.php
index babfb5d408..26618c1640 100644
--- a/app/Models/Labels/Tapes/Brother/TZe_24mm_A.php
+++ b/app/Models/Labels/Tapes/Brother/TZe_24mm_A.php
@@ -14,6 +14,7 @@ class TZe_24mm_A extends TZe_24mm
public function getUnit() { return 'mm'; }
public function getWidth() { return 65.0; }
+ public function getSupportAssetTag() { return false; }
public function getSupport1DBarcode() { return false; }
public function getSupport2DBarcode() { return true; }
public function getSupportFields() { return 3; }
diff --git a/app/Presenters/LabelPresenter.php b/app/Presenters/LabelPresenter.php
index 387118432a..5ff95d2c4d 100644
--- a/app/Presenters/LabelPresenter.php
+++ b/app/Presenters/LabelPresenter.php
@@ -48,6 +48,14 @@ class LabelPresenter extends Presenter
'switchable' => true,
'title' => trans('admin/labels/table.support_fields'),
'visible' => true
+ ], [
+ 'field' => 'support_asset_tag',
+ 'searchable' => false,
+ 'sortable' => true,
+ 'switchable' => true,
+ 'title' => trans('admin/labels/table.support_asset_tag'),
+ 'visible' => true,
+ 'formatter' => 'trueFalseFormatter'
], [
'field' => 'support_1d_barcode',
'searchable' => false,
diff --git a/resources/lang/en/admin/labels/table.php b/resources/lang/en/admin/labels/table.php
index bc0ab7a977..87dee4bad0 100644
--- a/resources/lang/en/admin/labels/table.php
+++ b/resources/lang/en/admin/labels/table.php
@@ -4,6 +4,7 @@ return [
'labels_per_page' => 'Labels',
'support_fields' => 'Fields',
+ 'support_asset_tag' => 'Tag',
'support_1d_barcode' => '1D',
'support_2d_barcode' => '2D',
'support_logo' => 'Logo',