diff --git a/app/Models/Labels/DefaultLabel.php b/app/Models/Labels/DefaultLabel.php index df8aff0072..94f043ccd5 100644 --- a/app/Models/Labels/DefaultLabel.php +++ b/app/Models/Labels/DefaultLabel.php @@ -38,23 +38,24 @@ class DefaultLabel extends RectangleSheet private int $rows; - public function __construct() { + public function __construct() + { $settings = Setting::getSettings(); $this->textSize = Helper::convertUnit($settings->labels_fontsize, 'pt', 'in'); - $this->labelWidth = $settings->labels_width; + $this->labelWidth = $settings->labels_width; $this->labelHeight = $settings->labels_height; $this->labelSpacingH = $settings->labels_display_sgutter; $this->labelSpacingV = $settings->labels_display_bgutter; - $this->pageMarginTop = $settings->labels_pmargin_top; + $this->pageMarginTop = $settings->labels_pmargin_top; $this->pageMarginBottom = $settings->labels_pmargin_bottom; - $this->pageMarginLeft = $settings->labels_pmargin_left; - $this->pageMarginRight = $settings->labels_pmargin_right; + $this->pageMarginLeft = $settings->labels_pmargin_left; + $this->pageMarginRight = $settings->labels_pmargin_right; - $this->pageWidth = $settings->labels_pagewidth; + $this->pageWidth = $settings->labels_pagewidth; $this->pageHeight = $settings->labels_pageheight; $usableWidth = $this->pageWidth - $this->pageMarginLeft - $this->pageMarginRight; @@ -74,41 +75,132 @@ class DefaultLabel extends RectangleSheet } - public function getUnit() { return 'in'; } + public function getUnit() + { + return 'in'; + } - public function getPageWidth() { return $this->pageWidth; } - public function getPageHeight() { return $this->pageHeight; } + public function getPageWidth() + { + return $this->pageWidth; + } - public function getPageMarginTop() { return $this->pageMarginTop; } - public function getPageMarginBottom() { return $this->pageMarginBottom; } - public function getPageMarginLeft() { return $this->pageMarginLeft; } - public function getPageMarginRight() { return $this->pageMarginRight; } + public function getPageHeight() + { + return $this->pageHeight; + } - public function getColumns() { return $this->columns; } - public function getRows() { return $this->rows; } - public function getLabelBorder() { return 0; } + public function getPageMarginTop() + { + return $this->pageMarginTop; + } - public function getLabelWidth() { return $this->labelWidth; } - public function getLabelHeight() { return $this->labelHeight; } + public function getPageMarginBottom() + { + return $this->pageMarginBottom; + } - public function getLabelMarginTop() { return 0; } - public function getLabelMarginBottom() { return 0; } - public function getLabelMarginLeft() { return 0; } - public function getLabelMarginRight() { return 0; } + public function getPageMarginLeft() + { + return $this->pageMarginLeft; + } - public function getLabelColumnSpacing() { return $this->labelSpacingH; } - public function getLabelRowSpacing() { return $this->labelSpacingV; } + public function getPageMarginRight() + { + return $this->pageMarginRight; + } - public function getSupportAssetTag() { return false; } - public function getSupport1DBarcode() { return true; } - public function getSupport2DBarcode() { return true; } - public function getSupportFields() { return 4; } - public function getSupportTitle() { return true; } - public function getSupportLogo() { return true; } + public function getColumns() + { + return $this->columns; + } - public function preparePDF($pdf) {} + public function getRows() + { + return $this->rows; + } - public function write($pdf, $record) { + public function getLabelBorder() + { + return 0; + } + + public function getLabelWidth() + { + return $this->labelWidth; + } + + public function getLabelHeight() + { + return $this->labelHeight; + } + + public function getLabelMarginTop() + { + return 0; + } + + public function getLabelMarginBottom() + { + return 0; + } + + public function getLabelMarginLeft() + { + return 0; + } + + public function getLabelMarginRight() + { + return 0; + } + + 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; + } + + public function getSupportTitle() + { + return true; + } + + public function getSupportLogo() + { + return true; + } + + public function preparePDF($pdf) + { + } + + public function write($pdf, $record) + { $asset = $record->get('asset'); $settings = Setting::getSettings(); @@ -164,7 +256,7 @@ class DefaultLabel extends RectangleSheet $fieldsDone = 0; if ($settings->labels_display_name && $fieldsDone < $this->getSupportFields()) { - foreach ($record->get('fields') as $field){ + foreach ($record->get('fields') as $field) { static::writeText( $pdf, $field['label'][0] . ': ' . $field['value'], $textX1, $textY, @@ -172,63 +264,10 @@ class DefaultLabel extends RectangleSheet $textW, $this->textSize, true, 0 ); - $textY += $this->textSize + self::TEXT_MARGIN; - $fieldsDone++; - } + $textY += $this->textSize + self::TEXT_MARGIN; + $fieldsDone++; + } } -// if ($settings->labels_display_company_name && $fieldsDone < $this->getSupportFields()) { -// if ($asset->company) { -// static::writeText( -// $pdf, 'C: '.$asset->company->name, -// $textX1, $textY, -// 'freesans', '', $this->textSize, 'L', -// $textW, $this->textSize, -// true, 0 -// ); -// $textY += $this->textSize + self::TEXT_MARGIN; -// $fieldsDone++; -// } -// } -// if ($settings->labels_display_tag && $fieldsDone < $this->getSupportFields()) { -// if ($asset->asset_tag) { -// static::writeText( -// $pdf, 'T: '.$asset->asset_tag, -// $textX1, $textY, -// 'freesans', '', $this->textSize, 'L', -// $textW, $this->textSize, -// true, 0 -// ); -// $textY += $this->textSize + self::TEXT_MARGIN; -// $fieldsDone++; -// } -// } -// if ($settings->labels_display_serial && $fieldsDone < $this->getSupportFields()) { -// if ($asset->serial) { -// static::writeText( -// $pdf, 'S: '.$asset->serial, -// $textX1, $textY, -// 'freesans', '', $this->textSize, 'L', -// $textW, $this->textSize, -// true, 0 -// ); -// $textY += $this->textSize + self::TEXT_MARGIN; -// $fieldsDone++; -// } -// } -// if ($settings->labels_display_model && $fieldsDone < $this->getSupportFields()) { -// if ($asset->model) { -// static::writeText( -// $pdf, 'M: '.$asset->model->name, -// $textX1, $textY, -// 'freesans', '', $this->textSize, 'L', -// $textW, $this->textSize, -// true, 0 -// ); -// $textY += $this->textSize + self::TEXT_MARGIN; -// $fieldsDone++; -// } -// } - } }