diff --git a/app/Models/Labels/DefaultLabel.php b/app/Models/Labels/DefaultLabel.php index f06c4582f9..f4b480eb4d 100644 --- a/app/Models/Labels/DefaultLabel.php +++ b/app/Models/Labels/DefaultLabel.php @@ -162,10 +162,11 @@ class DefaultLabel extends RectangleSheet // Fields $fieldsDone = 0; - if ($settings->labels_display_name && $fieldsDone < $this->getSupportFields()) { - if ($asset->name) { + if ($fieldsDone < $this->getSupportFields()) { +// dd($record->get('fields')); + foreach ($record->get('fields') as $field) { static::writeText( - $pdf, 'N: '.$asset->name, + $pdf, $field['label'][0]. ': ' . $field['value'], $textX1, $textY, 'freesans', '', $this->textSize, 'L', $textW, $this->textSize, @@ -175,60 +176,8 @@ 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 eb030bc8b6..5761cf95a6 100644 --- a/app/View/Label.php +++ b/app/View/Label.php @@ -146,7 +146,7 @@ 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 a6edd29154..6f3694caff 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 -