From c62758c5b5252682f9e4e3c5f5af7044b59d5e43 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Thu, 22 Feb 2024 11:36:39 -0800 Subject: [PATCH 01/13] adds custom field select to default label view --- app/Http/Controllers/LabelsController.php | 2 +- app/Models/Labels/DefaultLabel.php | 109 +++++++++++----------- app/View/Label.php | 1 + resources/views/settings/labels.blade.php | 2 +- 4 files changed, 59 insertions(+), 55 deletions(-) diff --git a/app/Http/Controllers/LabelsController.php b/app/Http/Controllers/LabelsController.php index bb08d2cd45..b4f24f74a5 100755 --- a/app/Http/Controllers/LabelsController.php +++ b/app/Http/Controllers/LabelsController.php @@ -27,7 +27,7 @@ class LabelsController extends Controller public function show(string $labelName) { $labelName = str_replace('/', '\\', $labelName); - $template = Label::find($labelName); + $template = Label::find($labelName);// $exampleAsset = new Asset(); diff --git a/app/Models/Labels/DefaultLabel.php b/app/Models/Labels/DefaultLabel.php index f06c4582f9..745b5c272f 100644 --- a/app/Models/Labels/DefaultLabel.php +++ b/app/Models/Labels/DefaultLabel.php @@ -162,62 +162,12 @@ class DefaultLabel extends RectangleSheet // Fields $fieldsDone = 0; + if ($settings->labels_display_name && $fieldsDone < $this->getSupportFields()) { + foreach($record->get('fields') as $field) if ($asset->name) { static::writeText( - $pdf, 'N: '.$asset->name, - $textX1, $textY, - 'freesans', '', $this->textSize, 'L', - $textW, $this->textSize, - true, 0 - ); - $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, + $pdf, $field['label'][0].': '.$field['value'], $textX1, $textY, 'freesans', '', $this->textSize, 'L', $textW, $this->textSize, @@ -227,8 +177,61 @@ class DefaultLabel extends RectangleSheet $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++; +// } +// } } + } ?> \ No newline at end of file diff --git a/app/View/Label.php b/app/View/Label.php index fd6b172550..d74d1b3e5d 100644 --- a/app/View/Label.php +++ b/app/View/Label.php @@ -37,6 +37,7 @@ class Label implements View { $settings = $this->data->get('settings'); $assets = $this->data->get('assets'); + dd($this->data); $offset = $this->data->get('offset'); $template = $this->data->get('template'); diff --git a/resources/views/settings/labels.blade.php b/resources/views/settings/labels.blade.php index a6edd29154..814768d603 100644 --- a/resources/views/settings/labels.blade.php +++ b/resources/views/settings/labels.blade.php @@ -235,7 +235,7 @@ {{ Form::hidden('label2_fields', old('label2_fields', $setting->label2_fields)) }} @endif - @if ($setting->label2_enable && ($setting->label2_template != 'DefaultLabel')) + @if ($setting->label2_enable) {{ Form::hidden('labels_per_page', old('labels_per_page', $setting->labels_per_page)) }} {{ Form::hidden('labels_fontsize', old('labels_fontsize', $setting->labels_fontsize)) }} From c0215baca5e93a9c706aea8ccf9569ed3a11c40b Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Thu, 22 Feb 2024 11:41:04 -0800 Subject: [PATCH 02/13] minor changes --- app/Http/Controllers/LabelsController.php | 2 +- app/View/Label.php | 1 - resources/views/settings/labels.blade.php | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/LabelsController.php b/app/Http/Controllers/LabelsController.php index b4f24f74a5..bb08d2cd45 100755 --- a/app/Http/Controllers/LabelsController.php +++ b/app/Http/Controllers/LabelsController.php @@ -27,7 +27,7 @@ class LabelsController extends Controller public function show(string $labelName) { $labelName = str_replace('/', '\\', $labelName); - $template = Label::find($labelName);// + $template = Label::find($labelName); $exampleAsset = new Asset(); diff --git a/app/View/Label.php b/app/View/Label.php index d74d1b3e5d..fd6b172550 100644 --- a/app/View/Label.php +++ b/app/View/Label.php @@ -37,7 +37,6 @@ class Label implements View { $settings = $this->data->get('settings'); $assets = $this->data->get('assets'); - dd($this->data); $offset = $this->data->get('offset'); $template = $this->data->get('template'); diff --git a/resources/views/settings/labels.blade.php b/resources/views/settings/labels.blade.php index 814768d603..a6edd29154 100644 --- a/resources/views/settings/labels.blade.php +++ b/resources/views/settings/labels.blade.php @@ -235,7 +235,7 @@ {{ Form::hidden('label2_fields', old('label2_fields', $setting->label2_fields)) }} @endif - @if ($setting->label2_enable) + @if ($setting->label2_enable && ($setting->label2_template != 'DefaultLabel')) {{ Form::hidden('labels_per_page', old('labels_per_page', $setting->labels_per_page)) }} {{ Form::hidden('labels_fontsize', old('labels_fontsize', $setting->labels_fontsize)) }} From b7850ab8392b9de27a239d4dc16c71fd944ed18f Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Thu, 22 Feb 2024 12:08:04 -0800 Subject: [PATCH 03/13] puts textY outside of the forloop --- app/Models/Labels/DefaultLabel.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/Models/Labels/DefaultLabel.php b/app/Models/Labels/DefaultLabel.php index 745b5c272f..f4328f05f2 100644 --- a/app/Models/Labels/DefaultLabel.php +++ b/app/Models/Labels/DefaultLabel.php @@ -164,18 +164,17 @@ class DefaultLabel extends RectangleSheet $fieldsDone = 0; if ($settings->labels_display_name && $fieldsDone < $this->getSupportFields()) { - foreach($record->get('fields') as $field) - if ($asset->name) { + foreach ($record->get('fields') as $field){ static::writeText( - $pdf, $field['label'][0].': '.$field['value'], + $pdf, $field['label'][0] . ': ' . $field['value'], $textX1, $textY, 'freesans', '', $this->textSize, 'L', $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) { From 4fbea9512f2e134b3dba03909e578683a356a835 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Thu, 22 Feb 2024 12:08:47 -0800 Subject: [PATCH 04/13] puts textY inside of the forloop --- app/Models/Labels/DefaultLabel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/Labels/DefaultLabel.php b/app/Models/Labels/DefaultLabel.php index f4328f05f2..df8aff0072 100644 --- a/app/Models/Labels/DefaultLabel.php +++ b/app/Models/Labels/DefaultLabel.php @@ -172,9 +172,9 @@ class DefaultLabel extends RectangleSheet $textW, $this->textSize, true, 0 ); - } $textY += $this->textSize + self::TEXT_MARGIN; $fieldsDone++; + } } // if ($settings->labels_display_company_name && $fieldsDone < $this->getSupportFields()) { // if ($asset->company) { From e2dcee19590e44c7f010fc4623bb9b7fe6da8914 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Thu, 22 Feb 2024 12:26:57 -0800 Subject: [PATCH 05/13] cleans up dead code --- app/Models/Labels/DefaultLabel.php | 217 +++++++++++++++++------------ 1 file changed, 128 insertions(+), 89 deletions(-) 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++; -// } -// } - } } From 6ee24a75277257641cf4bad5deee07626f21efee Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Thu, 22 Feb 2024 12:36:27 -0800 Subject: [PATCH 06/13] remove unnecessary code reformat --- app/Models/Labels/DefaultLabel.php | 157 ++++++----------------------- 1 file changed, 32 insertions(+), 125 deletions(-) diff --git a/app/Models/Labels/DefaultLabel.php b/app/Models/Labels/DefaultLabel.php index 94f043ccd5..b7440e7d3b 100644 --- a/app/Models/Labels/DefaultLabel.php +++ b/app/Models/Labels/DefaultLabel.php @@ -38,24 +38,23 @@ 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; @@ -75,132 +74,41 @@ class DefaultLabel extends RectangleSheet } - public function getUnit() - { - return 'in'; - } + public function getUnit() { return 'in'; } - public function getPageWidth() - { - return $this->pageWidth; - } + public function getPageWidth() { return $this->pageWidth; } + public function getPageHeight() { return $this->pageHeight; } - public function getPageHeight() - { - return $this->pageHeight; - } + 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 getPageMarginTop() - { - return $this->pageMarginTop; - } + public function getColumns() { return $this->columns; } + public function getRows() { return $this->rows; } + public function getLabelBorder() { return 0; } - public function getPageMarginBottom() - { - return $this->pageMarginBottom; - } + public function getLabelWidth() { return $this->labelWidth; } + public function getLabelHeight() { return $this->labelHeight; } - public function getPageMarginLeft() - { - return $this->pageMarginLeft; - } + public function getLabelMarginTop() { return 0; } + public function getLabelMarginBottom() { return 0; } + public function getLabelMarginLeft() { return 0; } + public function getLabelMarginRight() { return 0; } - public function getPageMarginRight() - { - return $this->pageMarginRight; - } + public function getLabelColumnSpacing() { return $this->labelSpacingH; } + public function getLabelRowSpacing() { return $this->labelSpacingV; } - public function getColumns() - { - return $this->columns; - } + 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 getRows() - { - return $this->rows; - } + public function preparePDF($pdf) {} - 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) - { + public function write($pdf, $record) { $asset = $record->get('asset'); $settings = Setting::getSettings(); @@ -254,7 +162,6 @@ class DefaultLabel extends RectangleSheet // Fields $fieldsDone = 0; - if ($settings->labels_display_name && $fieldsDone < $this->getSupportFields()) { foreach ($record->get('fields') as $field) { static::writeText( From 550f9e2afa7936e323938b63f30f75616bb7ee47 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Thu, 22 Feb 2024 16:19:28 -0800 Subject: [PATCH 07/13] removes visibility checkmarks for certain fields when in new label engine --- resources/views/settings/labels.blade.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/views/settings/labels.blade.php b/resources/views/settings/labels.blade.php index a6edd29154..50d81a8883 100644 --- a/resources/views/settings/labels.blade.php +++ b/resources/views/settings/labels.blade.php @@ -378,7 +378,8 @@ {!! $errors->first('labels_pageheight', '') !!} - + @endif + @if(!$setting->label2_enable)
{{ Form::label('labels_display', trans('admin/settings/general.label_fields'), ['class' => 'control-label']) }} From b67ceab84948662b26be924aab245027dc419d1f Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Tue, 27 Feb 2024 11:29:19 -0800 Subject: [PATCH 08/13] fields appear in preview, but not bulk generate labels --- app/Models/Labels/DefaultLabel.php | 2 +- app/View/Label.php | 2 -- resources/views/settings/labels.blade.php | 8 +------- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/app/Models/Labels/DefaultLabel.php b/app/Models/Labels/DefaultLabel.php index b7440e7d3b..8e9273e769 100644 --- a/app/Models/Labels/DefaultLabel.php +++ b/app/Models/Labels/DefaultLabel.php @@ -165,7 +165,7 @@ class DefaultLabel extends RectangleSheet if ($settings->labels_display_name && $fieldsDone < $this->getSupportFields()) { foreach ($record->get('fields') as $field) { static::writeText( - $pdf, $field['label'][0] . ': ' . $field['value'], + $pdf, $field['label'][0]. ': ' . $field['value'], $textX1, $textY, 'freesans', '', $this->textSize, 'L', $textW, $this->textSize, diff --git a/app/View/Label.php b/app/View/Label.php index fd6b172550..0d2a00e8c8 100644 --- a/app/View/Label.php +++ b/app/View/Label.php @@ -79,7 +79,6 @@ class Label implements View $fieldDefinitions = collect(explode(';', $settings->label2_fields)) ->filter(fn($fieldString) => !empty($fieldString)) ->map(fn($fieldString) => Field::fromString($fieldString)); - // Prepare data $data = $assets ->map(function ($asset) use ($template, $settings, $fieldDefinitions) { @@ -154,7 +153,6 @@ class Label implements View return $toAdd ? $myFields->push($toAdd) : $myFields; }, new Collection()); - $assetData->put('fields', $fields->take($template->getSupportFields())); return $assetData; diff --git a/resources/views/settings/labels.blade.php b/resources/views/settings/labels.blade.php index 50d81a8883..1877b763e0 100644 --- a/resources/views/settings/labels.blade.php +++ b/resources/views/settings/labels.blade.php @@ -255,7 +255,6 @@ {{ Form::hidden('labels_display_model', old('labels_display_model', $setting->labels_display_model)) }} {{ Form::hidden('labels_display_company_name', old('labels_display_company_name', $setting->labels_display_company_name)) }} @else -
@@ -378,8 +377,7 @@ {!! $errors->first('labels_pageheight', '') !!}
- @endif - @if(!$setting->label2_enable) +
{{ Form::label('labels_display', trans('admin/settings/general.label_fields'), ['class' => 'control-label']) }} @@ -405,13 +403,9 @@ {{ Form::checkbox('labels_display_company_name', '1', old('labels_display_company_name', $setting->labels_display_company_name),['class' => 'minimal', 'aria-label'=>'labels_display_company_name']) }} {{ trans('admin/companies/table.name') }} -
- @endif - -
From ef52777ffb1b6eb5ef82b3e080909b02d4c0c087 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Tue, 27 Feb 2024 11:33:00 -0800 Subject: [PATCH 09/13] removed conditional --- app/Models/Labels/DefaultLabel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/Labels/DefaultLabel.php b/app/Models/Labels/DefaultLabel.php index 8e9273e769..796ead2378 100644 --- a/app/Models/Labels/DefaultLabel.php +++ b/app/Models/Labels/DefaultLabel.php @@ -162,7 +162,7 @@ class DefaultLabel extends RectangleSheet // Fields $fieldsDone = 0; - if ($settings->labels_display_name && $fieldsDone < $this->getSupportFields()) { + if ($fieldsDone < $this->getSupportFields()) { foreach ($record->get('fields') as $field) { static::writeText( $pdf, $field['label'][0]. ': ' . $field['value'], From d83827a44e54f6c6df43f95dd5ab974096d33cb6 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Tue, 5 Mar 2024 15:43:41 -0800 Subject: [PATCH 10/13] bulk actions are handled before sorting --- .../Assets/BulkAssetsController.php | 91 +++++++++---------- app/Models/Labels/DefaultLabel.php | 1 + app/View/Label.php | 2 +- 3 files changed, 47 insertions(+), 47 deletions(-) diff --git a/app/Http/Controllers/Assets/BulkAssetsController.php b/app/Http/Controllers/Assets/BulkAssetsController.php index 158f318133..5ff07f04ff 100644 --- a/app/Http/Controllers/Assets/BulkAssetsController.php +++ b/app/Http/Controllers/Assets/BulkAssetsController.php @@ -50,7 +50,6 @@ class BulkAssetsController extends Controller } $asset_ids = $request->input('ids'); - // Figure out where we need to send the user after the update is complete, and store that in the session $bulk_back_url = request()->headers->get('referer'); session(['bulk_back_url' => $bulk_back_url]); @@ -93,6 +92,51 @@ class BulkAssetsController extends Controller $assets = Asset::with('assignedTo', 'location', 'model')->whereIn('assets.id', $asset_ids); + $assets = $assets->get(); + + $models = $assets->unique('model_id'); + $modelNames = []; + foreach($models as $model) { + $modelNames[] = $model->model->name; + } + if ($request->filled('bulk_actions')) { + + switch ($request->input('bulk_actions')) { + case 'labels': + $this->authorize('view', Asset::class); + + return (new Label) + ->with('assets', $assets) + ->with('settings', Setting::getSettings()) + ->with('bulkedit', true) + ->with('count', 0); + + case 'delete': + $this->authorize('delete', Asset::class); + $assets->each(function ($assets) { + $this->authorize('delete', $assets); + }); + + return view('hardware/bulk-delete')->with('assets', $assets); + + case 'restore': + $this->authorize('update', Asset::class); + $assets = Asset::withTrashed()->find($asset_ids); + $assets->each(function ($asset) { + $this->authorize('delete', $asset); + }); + return view('hardware/bulk-restore')->with('assets', $assets); + + case 'edit': + $this->authorize('update', Asset::class); + + return view('hardware/bulk') + ->with('assets', $asset_ids) + ->with('statuslabel_list', Helper::statusLabelList()) + ->with('models', $models->pluck(['model'])) + ->with('modelNames', $modelNames); + } + } switch ($sort_override) { case 'model': $assets->OrderModels($order); @@ -128,53 +172,8 @@ class BulkAssetsController extends Controller break; } - $assets = $assets->get(); - - $models = $assets->unique('model_id'); - $modelNames = []; - foreach($models as $model) { - $modelNames[] = $model->model->name; - } - - if ($request->filled('bulk_actions')) { - switch ($request->input('bulk_actions')) { - case 'labels': - $this->authorize('view', Asset::class); - - return (new Label) - ->with('assets', $assets) - ->with('settings', Setting::getSettings()) - ->with('bulkedit', true) - ->with('count', 0); - - case 'delete': - $this->authorize('delete', Asset::class); - $assets->each(function ($assets) { - $this->authorize('delete', $assets); - }); - - return view('hardware/bulk-delete')->with('assets', $assets); - - case 'restore': - $this->authorize('update', Asset::class); - $assets = Asset::withTrashed()->find($asset_ids); - $assets->each(function ($asset) { - $this->authorize('delete', $asset); - }); - return view('hardware/bulk-restore')->with('assets', $assets); - - case 'edit': - $this->authorize('update', Asset::class); - - return view('hardware/bulk') - ->with('assets', $asset_ids) - ->with('statuslabel_list', Helper::statusLabelList()) - ->with('models', $models->pluck(['model'])) - ->with('modelNames', $modelNames); - } - } return redirect()->back()->with('error', 'No action selected'); } diff --git a/app/Models/Labels/DefaultLabel.php b/app/Models/Labels/DefaultLabel.php index 796ead2378..f4b480eb4d 100644 --- a/app/Models/Labels/DefaultLabel.php +++ b/app/Models/Labels/DefaultLabel.php @@ -163,6 +163,7 @@ class DefaultLabel extends RectangleSheet // Fields $fieldsDone = 0; if ($fieldsDone < $this->getSupportFields()) { +// dd($record->get('fields')); foreach ($record->get('fields') as $field) { static::writeText( $pdf, $field['label'][0]. ': ' . $field['value'], diff --git a/app/View/Label.php b/app/View/Label.php index 01e71e2d82..e6521c000a 100644 --- a/app/View/Label.php +++ b/app/View/Label.php @@ -126,7 +126,7 @@ class Label implements View switch ($settings->label2_2d_target) { case 'ht_tag': $barcode2DTarget = route('ht/assetTag', $asset->asset_tag); break; case 'hardware_id': - default: $barcode2DTarget = route('hardware.show', $asset->id); break; + default: $barcode2DTarget = route('hardware.show',['hardware' => $asset->id]); break; } $assetData->put('barcode2d', (object)[ 'type' => $barcode2DType, From 940f54dab1ef1fcd9ee2cb1f0af808edf80b6cef Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Tue, 5 Mar 2024 15:45:35 -0800 Subject: [PATCH 11/13] revert some changes --- .../Assets/BulkAssetsController.php | 73 +++++++++---------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/app/Http/Controllers/Assets/BulkAssetsController.php b/app/Http/Controllers/Assets/BulkAssetsController.php index 5ff07f04ff..1b7f56641d 100644 --- a/app/Http/Controllers/Assets/BulkAssetsController.php +++ b/app/Http/Controllers/Assets/BulkAssetsController.php @@ -92,6 +92,41 @@ class BulkAssetsController extends Controller $assets = Asset::with('assignedTo', 'location', 'model')->whereIn('assets.id', $asset_ids); + + switch ($sort_override) { + case 'model': + $assets->OrderModels($order); + break; + case 'model_number': + $assets->OrderModelNumber($order); + break; + case 'category': + $assets->OrderCategory($order); + break; + case 'manufacturer': + $assets->OrderManufacturer($order); + break; + case 'company': + $assets->OrderCompany($order); + break; + case 'location': + $assets->OrderLocation($order); + case 'rtd_location': + $assets->OrderRtdLocation($order); + break; + case 'status_label': + $assets->OrderStatus($order); + break; + case 'supplier': + $assets->OrderSupplier($order); + break; + case 'assigned_to': + $assets->OrderAssigned($order); + break; + default: + $assets->orderBy($column_sort, $order); + break; + } $assets = $assets->get(); $models = $assets->unique('model_id'); @@ -99,6 +134,7 @@ class BulkAssetsController extends Controller foreach($models as $model) { $modelNames[] = $model->model->name; } + if ($request->filled('bulk_actions')) { switch ($request->input('bulk_actions')) { @@ -137,43 +173,6 @@ class BulkAssetsController extends Controller ->with('modelNames', $modelNames); } } - switch ($sort_override) { - case 'model': - $assets->OrderModels($order); - break; - case 'model_number': - $assets->OrderModelNumber($order); - break; - case 'category': - $assets->OrderCategory($order); - break; - case 'manufacturer': - $assets->OrderManufacturer($order); - break; - case 'company': - $assets->OrderCompany($order); - break; - case 'location': - $assets->OrderLocation($order); - case 'rtd_location': - $assets->OrderRtdLocation($order); - break; - case 'status_label': - $assets->OrderStatus($order); - break; - case 'supplier': - $assets->OrderSupplier($order); - break; - case 'assigned_to': - $assets->OrderAssigned($order); - break; - default: - $assets->orderBy($column_sort, $order); - break; - } - - - return redirect()->back()->with('error', 'No action selected'); } From feb78d00cfd54309d622cc94d8e3e91193bfa5bb Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Wed, 6 Mar 2024 11:25:49 -0800 Subject: [PATCH 12/13] conditionally shows label fields if on old label engine only --- resources/views/settings/labels.blade.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/views/settings/labels.blade.php b/resources/views/settings/labels.blade.php index 1877b763e0..6f3694caff 100644 --- a/resources/views/settings/labels.blade.php +++ b/resources/views/settings/labels.blade.php @@ -377,7 +377,8 @@ {!! $errors->first('labels_pageheight', '') !!} - + @endif + @if(!$setting->label2_enable)
{{ Form::label('labels_display', trans('admin/settings/general.label_fields'), ['class' => 'control-label']) }} From d78262f52b3b1183475a8f0a8d144e275b2bd780 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Wed, 6 Mar 2024 14:48:47 -0800 Subject: [PATCH 13/13] resolved merge conflicts --- .../Assets/BulkAssetsController.php | 72 ++++++++++--------- app/View/Label.php | 4 +- 2 files changed, 40 insertions(+), 36 deletions(-) diff --git a/app/Http/Controllers/Assets/BulkAssetsController.php b/app/Http/Controllers/Assets/BulkAssetsController.php index 1b7f56641d..51892e4259 100644 --- a/app/Http/Controllers/Assets/BulkAssetsController.php +++ b/app/Http/Controllers/Assets/BulkAssetsController.php @@ -50,6 +50,7 @@ class BulkAssetsController extends Controller } $asset_ids = $request->input('ids'); + // Figure out where we need to send the user after the update is complete, and store that in the session $bulk_back_url = request()->headers->get('referer'); session(['bulk_back_url' => $bulk_back_url]); @@ -92,41 +93,6 @@ class BulkAssetsController extends Controller $assets = Asset::with('assignedTo', 'location', 'model')->whereIn('assets.id', $asset_ids); - - switch ($sort_override) { - case 'model': - $assets->OrderModels($order); - break; - case 'model_number': - $assets->OrderModelNumber($order); - break; - case 'category': - $assets->OrderCategory($order); - break; - case 'manufacturer': - $assets->OrderManufacturer($order); - break; - case 'company': - $assets->OrderCompany($order); - break; - case 'location': - $assets->OrderLocation($order); - case 'rtd_location': - $assets->OrderRtdLocation($order); - break; - case 'status_label': - $assets->OrderStatus($order); - break; - case 'supplier': - $assets->OrderSupplier($order); - break; - case 'assigned_to': - $assets->OrderAssigned($order); - break; - default: - $assets->orderBy($column_sort, $order); - break; - } $assets = $assets->get(); $models = $assets->unique('model_id'); @@ -137,6 +103,7 @@ class BulkAssetsController extends Controller if ($request->filled('bulk_actions')) { + switch ($request->input('bulk_actions')) { case 'labels': $this->authorize('view', Asset::class); @@ -174,6 +141,41 @@ class BulkAssetsController extends Controller } } + switch ($sort_override) { + case 'model': + $assets->OrderModels($order); + break; + case 'model_number': + $assets->OrderModelNumber($order); + break; + case 'category': + $assets->OrderCategory($order); + break; + case 'manufacturer': + $assets->OrderManufacturer($order); + break; + case 'company': + $assets->OrderCompany($order); + break; + case 'location': + $assets->OrderLocation($order); + case 'rtd_location': + $assets->OrderRtdLocation($order); + break; + case 'status_label': + $assets->OrderStatus($order); + break; + case 'supplier': + $assets->OrderSupplier($order); + break; + case 'assigned_to': + $assets->OrderAssigned($order); + break; + default: + $assets->orderBy($column_sort, $order); + break; + } + return redirect()->back()->with('error', 'No action selected'); } diff --git a/app/View/Label.php b/app/View/Label.php index e6521c000a..b52861d445 100644 --- a/app/View/Label.php +++ b/app/View/Label.php @@ -72,6 +72,7 @@ class Label implements View $fieldDefinitions = collect(explode(';', $settings->label2_fields)) ->filter(fn($fieldString) => !empty($fieldString)) ->map(fn($fieldString) => Field::fromString($fieldString)); + // Prepare data $data = $assets ->map(function ($asset) use ($template, $settings, $fieldDefinitions) { @@ -126,7 +127,7 @@ class Label implements View switch ($settings->label2_2d_target) { case 'ht_tag': $barcode2DTarget = route('ht/assetTag', $asset->asset_tag); break; case 'hardware_id': - default: $barcode2DTarget = route('hardware.show',['hardware' => $asset->id]); break; + default: $barcode2DTarget = route('hardware.show', ['hardware' => $asset->id]); break; } $assetData->put('barcode2d', (object)[ 'type' => $barcode2DType, @@ -146,6 +147,7 @@ class Label implements View return $toAdd ? $myFields->push($toAdd) : $myFields; }, new Collection()); + $assetData->put('fields', $fields->take($template->getSupportFields())); return $assetData;