adds custom field select to default label view

This commit is contained in:
Godfrey M 2024-02-22 11:36:39 -08:00
parent 54552fc95c
commit c62758c5b5
4 changed files with 59 additions and 55 deletions

View file

@ -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();

View file

@ -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++;
// }
// }
}
}
?>

View file

@ -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');

View file

@ -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)
<!-- Hidden version of legacy settings -->
{{ Form::hidden('labels_per_page', old('labels_per_page', $setting->labels_per_page)) }}
{{ Form::hidden('labels_fontsize', old('labels_fontsize', $setting->labels_fontsize)) }}