From e95e8f5c876087006d8922bfa269fb3a97194fc4 Mon Sep 17 00:00:00 2001 From: denzfarid Date: Wed, 24 Dec 2025 12:34:35 +0700 Subject: [PATCH 01/11] Add Mailto --- app/View/Label.php | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/app/View/Label.php b/app/View/Label.php index 684618e0f05c..8b3f25278569 100644 --- a/app/View/Label.php +++ b/app/View/Label.php @@ -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') ?? 'support@example.com'; + $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)) From 47b2a510aadb34de2bde059b8a96b570dc71b48e Mon Sep 17 00:00:00 2001 From: denzfarid Date: Wed, 24 Dec 2025 12:36:48 +0700 Subject: [PATCH 02/11] Add Mailto in 2D Barcode Content label Settings --- resources/views/settings/labels.blade.php | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/views/settings/labels.blade.php b/resources/views/settings/labels.blade.php index f20ec46c5453..a9554b1cf373 100644 --- a/resources/views/settings/labels.blade.php +++ b/resources/views/settings/labels.blade.php @@ -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'), From 894221b19e3e0c6ea3f588c7101c0931b60f1360 Mon Sep 17 00:00:00 2001 From: denzfarid Date: Sun, 28 Dec 2025 15:34:38 +0700 Subject: [PATCH 03/11] Update company email retrieval logic Removed fallback email address for support@example.com --- app/View/Label.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/View/Label.php b/app/View/Label.php index 8b3f25278569..1acf7035946d 100644 --- a/app/View/Label.php +++ b/app/View/Label.php @@ -175,7 +175,7 @@ public function render(callable $callback = null) // 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') ?? 'support@example.com'; + $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" From 1aa46c8bbd8bfcc4cf54b352507ed2e9e6e26390 Mon Sep 17 00:00:00 2001 From: denzfarid Date: Mon, 29 Dec 2025 12:52:59 +0700 Subject: [PATCH 04/11] Refactor email retrieval to use MAIL_FROM_ADDR Updated email retrieval to use environment variable MAIL_FROM_ADDR for better configuration management. Blank QR if company email & MAIL_FROM_ADDR if empty --- app/View/Label.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/View/Label.php b/app/View/Label.php index 1acf7035946d..a432d0ed6109 100644 --- a/app/View/Label.php +++ b/app/View/Label.php @@ -175,7 +175,12 @@ public function render(callable $callback = null) // 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'); + $companyEmail = $asset->company->email ?? env('MAIL_FROM_ADDR'); + // Skip qrcode generation if no email found + if (empty($companyEmail)) { + $barcode2DTarget = null; + break; + } $assetUrl = url("/ht/{$asset->asset_tag}"); $subject = rawurlencode("Lost Asset - " . $asset->asset_tag); $bodyPlain = "Hello,\n\n" From 4379471c733acb18dbcb9ed4381cf1726238ee86 Mon Sep 17 00:00:00 2001 From: denzfarid Date: Mon, 29 Dec 2025 19:03:58 +0700 Subject: [PATCH 05/11] add general translation for mailto --- resources/lang/en-US/admin/settings/general.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/resources/lang/en-US/admin/settings/general.php b/resources/lang/en-US/admin/settings/general.php index 1ea8d6498c04..1bbbfebcc0ec 100644 --- a/resources/lang/en-US/admin/settings/general.php +++ b/resources/lang/en-US/admin/settings/general.php @@ -399,6 +399,14 @@ 'label2_2d_prefix_help' => 'This text will be prepended to the 2D Barcode Target value selected below when the 2D code is scanned. This can be used to prepend an external URL or any other value that you might need.', 'label2_2d_target' => '2D Barcode Content', 'label2_2d_target_help' => 'The data that will be contained in the 2D barcode. This can link to the asset directly in Snipe-IT or can be one of the non-linked field values. If you use the prefix above, it will be prepended to this value.', + // Custom: Mailto barcode translation + 'mailto_option' => 'Mailto (Send Email to Company)', + 'mailto_subject' => 'Lost Asset - :asset_tag', + 'mailto_body' => "Hello,\n\n" + . "I found this asset with tag: :asset_tag\n\n" + . "Asset page: :asset_url\n\n" + . "Please contact me for retrieval.\n\n" + . "Thank you!", 'select_template' => 'Select a Template', 'label2_fields' => 'Field Definitions', 'label2_fields_help' => 'Fields can be added, removed, and reordered in the left column. For each field, multiple options for Label and DataSource can be added, removed, and reordered in the right column. Field changes made here will be reflected immediately in the preview below but must be saved for them to apply to new labels.', From 9ee8f82eda982d7651ba3a544d5c677ed17422e9 Mon Sep 17 00:00:00 2001 From: denzfarid Date: Mon, 29 Dec 2025 19:20:37 +0700 Subject: [PATCH 06/11] Update Label.php mailto use translations --- app/View/Label.php | 53 +++++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/app/View/Label.php b/app/View/Label.php index a432d0ed6109..eae76ecb373b 100644 --- a/app/View/Label.php +++ b/app/View/Label.php @@ -174,26 +174,39 @@ public function render(callable $callback = null) break; // Special case for mailto link case 'mailto': - // Get company email or fallback to default support email or from .env - $companyEmail = $asset->company->email ?? env('MAIL_FROM_ADDR'); - // Skip qrcode generation if no email found - if (empty($companyEmail)) { - $barcode2DTarget = null; - break; - } - $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; + // Get from company email or fallback from .env + $companyEmail = $asset->company->email ?? env('MAIL_FROM_ADDR'); + + // Skip QR code if no email found + if (empty($companyEmail)) { + $barcode2DTarget = null; + break; + } + + // Get url Hardware Tag + $assetUrl = url("/ht/{$asset->asset_tag}"); + + // Get text from translation file + $subjectText = trans('admin/settings/general.mailto_subject', [ + 'asset_tag' => $asset->asset_tag, + ]); + + $bodyText = trans('admin/settings/general.mailto_body', [ + 'asset_tag' => $asset->asset_tag, + 'asset_url' => $assetUrl, + ]); + + // Encode for URL + $subject = rawurlencode($subjectText); + $body = rawurlencode($bodyText); + + // 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); From 7f63a70ac24f8dde93d4c7a5a26ca8c40dc74c6e Mon Sep 17 00:00:00 2001 From: denzfarid Date: Mon, 29 Dec 2025 19:23:47 +0700 Subject: [PATCH 07/11] update labels.blade.php mailto use translations --- resources/views/settings/labels.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/settings/labels.blade.php b/resources/views/settings/labels.blade.php index a9554b1cf373..a74e986be9e2 100644 --- a/resources/views/settings/labels.blade.php +++ b/resources/views/settings/labels.blade.php @@ -323,7 +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)', + 'mailto' => trans('admin/settings/general.mailto_option'), 'location' => config('app.url').'/locations/{location_id}', 'plain_asset_id'=> trans('admin/settings/general.asset_id'), 'plain_asset_tag'=> trans('general.asset_tag'), From 32bc8185d155e188968da5b661283fdc42a70e06 Mon Sep 17 00:00:00 2001 From: denzfarid Date: Tue, 30 Dec 2025 10:02:40 +0700 Subject: [PATCH 08/11] Remove mailto barcode translation settings Removed mailto barcode translation options from settings. --- resources/lang/en-US/admin/settings/general.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/resources/lang/en-US/admin/settings/general.php b/resources/lang/en-US/admin/settings/general.php index 1bbbfebcc0ec..1ea8d6498c04 100644 --- a/resources/lang/en-US/admin/settings/general.php +++ b/resources/lang/en-US/admin/settings/general.php @@ -399,14 +399,6 @@ 'label2_2d_prefix_help' => 'This text will be prepended to the 2D Barcode Target value selected below when the 2D code is scanned. This can be used to prepend an external URL or any other value that you might need.', 'label2_2d_target' => '2D Barcode Content', 'label2_2d_target_help' => 'The data that will be contained in the 2D barcode. This can link to the asset directly in Snipe-IT or can be one of the non-linked field values. If you use the prefix above, it will be prepended to this value.', - // Custom: Mailto barcode translation - 'mailto_option' => 'Mailto (Send Email to Company)', - 'mailto_subject' => 'Lost Asset - :asset_tag', - 'mailto_body' => "Hello,\n\n" - . "I found this asset with tag: :asset_tag\n\n" - . "Asset page: :asset_url\n\n" - . "Please contact me for retrieval.\n\n" - . "Thank you!", 'select_template' => 'Select a Template', 'label2_fields' => 'Field Definitions', 'label2_fields_help' => 'Fields can be added, removed, and reordered in the left column. For each field, multiple options for Label and DataSource can be added, removed, and reordered in the right column. Field changes made here will be reflected immediately in the preview below but must be saved for them to apply to new labels.', From 7202396ddf0c8efc37b76a404979d4aa554b1b73 Mon Sep 17 00:00:00 2001 From: denzfarid Date: Tue, 30 Dec 2025 10:09:10 +0700 Subject: [PATCH 09/11] Refactor mailto link handling in Label.php use translation --- app/View/Label.php | 42 +++++++++++++++--------------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/app/View/Label.php b/app/View/Label.php index eae76ecb373b..255df7ed3b00 100644 --- a/app/View/Label.php +++ b/app/View/Label.php @@ -172,52 +172,40 @@ public function render(callable $callback = null) ? route('locations.show', $asset->location_id) : null; break; - // Special case for mailto link - case 'mailto': - // Get from company email or fallback from .env + case 'mailto': $companyEmail = $asset->company->email ?? env('MAIL_FROM_ADDR'); - - // Skip QR code if no email found if (empty($companyEmail)) { $barcode2DTarget = null; break; } - - // Get url Hardware Tag $assetUrl = url("/ht/{$asset->asset_tag}"); - - // Get text from translation file $subjectText = trans('admin/settings/general.mailto_subject', [ 'asset_tag' => $asset->asset_tag, ]); - + $bodyText = trans('admin/settings/general.mailto_body', [ 'asset_tag' => $asset->asset_tag, 'asset_url' => $assetUrl, ]); - - // Encode for URL + $subject = rawurlencode($subjectText); $body = rawurlencode($bodyText); - - // Create Mailto Link - $barcode2DTarget = "mailto:{$companyEmail}?subject={$subject}"; + $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}"; - + // $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, - ]); - } + 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)) From 87bde2b9c6292719efdf81974fe7dc9d850d4520 Mon Sep 17 00:00:00 2001 From: denzfarid Date: Wed, 31 Dec 2025 06:12:28 +0700 Subject: [PATCH 10/11] Remove body text from mailto link Removed body text from mailto link generation. --- app/View/Label.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/app/View/Label.php b/app/View/Label.php index 255df7ed3b00..9f4f7a86c03d 100644 --- a/app/View/Label.php +++ b/app/View/Label.php @@ -182,18 +182,9 @@ public function render(callable $callback = null) $subjectText = trans('admin/settings/general.mailto_subject', [ 'asset_tag' => $asset->asset_tag, ]); - - $bodyText = trans('admin/settings/general.mailto_body', [ - 'asset_tag' => $asset->asset_tag, - 'asset_url' => $assetUrl, - ]); - + $subject = rawurlencode($subjectText); - $body = rawurlencode($bodyText); - $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: From 973773d9922491961ff4e6b7faf8b1fc8eb40d5a Mon Sep 17 00:00:00 2001 From: denzfarid Date: Wed, 31 Dec 2025 06:25:18 +0700 Subject: [PATCH 11/11] Remove asset URL assignment in Label.php --- app/View/Label.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/View/Label.php b/app/View/Label.php index 9f4f7a86c03d..a50d2e9c9163 100644 --- a/app/View/Label.php +++ b/app/View/Label.php @@ -178,7 +178,6 @@ public function render(callable $callback = null) $barcode2DTarget = null; break; } - $assetUrl = url("/ht/{$asset->asset_tag}"); $subjectText = trans('admin/settings/general.mailto_subject', [ 'asset_tag' => $asset->asset_tag, ]);