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)) }}