Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 28 additions & 11 deletions app/View/Label.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,34 @@ public function render(callable $callback = null)
? route('locations.show', $asset->location_id)
: null;
break;
case 'hardware_id':
default:
$barcode2DTarget = route('hardware.show', $asset);
break;
}
$assetData->put('barcode2d', (object)[
'type' => $barcode2DType,
'content' => $barcode2DTarget,
]);
}
}
// Special case for mailto link
case 'mailto':
// Get company email or fallback to default support email or from .env
$companyEmail = $asset->company->email ?? config('mail.from.address');
$assetUrl = url("/ht/{$asset->asset_tag}");
$subject = rawurlencode("Lost Asset - " . $asset->asset_tag);
$bodyPlain = "Hello,\n\n"
. "I found this asset with tag: " . $asset->asset_tag . "\n\n"
. "Asset page: " . $assetUrl . "\n\n"
. "Please contact me for retrieval.\n\n"
. "Thank you!";
$body = rawurlencode($bodyPlain);
// Create mailto link
$barcode2DTarget = "mailto:{$companyEmail}?subject={$subject}";
// If you want to include the body as well, uncomment the line below and comment the line above
// $barcode2DTarget = "mailto:{$companyEmail}?subject={$subject}&body={$body}";
break;
case 'hardware_id':
default:
$barcode2DTarget = route('hardware.show', $asset);
break;
}
$assetData->put('barcode2d', (object)[
'type' => $barcode2DType,
'content' => $barcode2DTarget,
]);
}
}

$fields = $fieldDefinitions
->map(fn($field) => $field->toArray($asset))
Expand Down
1 change: 1 addition & 0 deletions resources/views/settings/labels.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ class="form-control"
:options="[
'hardware_id'=> config('app.url').'/hardware/{id} ('.trans('admin/settings/general.default').')',
'ht_tag'=> config('app.url').'/ht/{asset_tag}',
'mailto' => 'Mailto (Send Email to Company)',
'location' => config('app.url').'/locations/{location_id}',
'plain_asset_id'=> trans('admin/settings/general.asset_id'),
'plain_asset_tag'=> trans('general.asset_tag'),
Expand Down
Loading