Handle blank labels on asset label fields

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-03-10 14:03:21 +00:00
parent 37dfecf098
commit cde5502f94

View file

@ -160,25 +160,32 @@ class DefaultLabel extends RectangleSheet
$textY += $this->textSize + self::TEXT_MARGIN; $textY += $this->textSize + self::TEXT_MARGIN;
} }
// Fields // Render the selected fields with their labels
$fieldsDone = 0; $fieldsDone = 0;
if ($fieldsDone < $this->getSupportFields()) { if ($fieldsDone < $this->getSupportFields()) {
foreach ($record->get('fields') as $field) { foreach ($record->get('fields') as $field) {
if ((array_key_exists('label', $field)) && (is_array($field['label']))) { $field_label = $field['label'];
// If the label field in the visible fields on the asset label is NOT blank,
// set the label to that value.
if ($field_label!='') {
$field_label = $field_label.': ';
}
// Actually write the selected fields and their matching values
static::writeText( static::writeText(
$pdf, $field['label'][0]. ': ' . $field['value'], $pdf, $field_label . $field['value'],
$textX1, $textY, $textX1, $textY,
'freesans', '', $this->textSize, 'L', 'freesans', '', $this->textSize, 'L',
$textW, $this->textSize, $textW, $this->textSize,
true, 0 true, 0
); );
$textY += $this->textSize + self::TEXT_MARGIN; $textY += $this->textSize + self::TEXT_MARGIN;
$fieldsDone++; $fieldsDone++;
} }
}
} }
} }