From 4e3e2474aa0000242bd50331f93751091da38553 Mon Sep 17 00:00:00 2001 From: spencerrlongg Date: Wed, 29 Jan 2025 12:10:03 -0600 Subject: [PATCH 1/2] qr code warning --- app/Http/Controllers/Assets/AssetsController.php | 5 ++++- resources/lang/en-US/admin/settings/general.php | 1 + resources/views/hardware/labels.blade.php | 12 +++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Assets/AssetsController.php b/app/Http/Controllers/Assets/AssetsController.php index 6fd27ed03c2d..ad5df35ab0f8 100755 --- a/app/Http/Controllers/Assets/AssetsController.php +++ b/app/Http/Controllers/Assets/AssetsController.php @@ -531,7 +531,7 @@ public function getAssetByTag(Request $request, $tag=null) : RedirectResponse * @param int $assetId * @since [v1.0] */ - public function getQrCode($assetId = null) : Response | BinaryFileResponse | string | bool + public function getQrCode($assetId = null): Response|BinaryFileResponse|string|bool { $settings = Setting::getSettings(); @@ -548,6 +548,9 @@ public function getQrCode($assetId = null) : Response | BinaryFileResponse | str return response()->file($qr_file, $header); } else { $barcode = new \Com\Tecnick\Barcode\Barcode(); + if ($settings->label2_2d_type == 'none') { + return false; + } $barcode_obj = $barcode->getBarcodeObj($settings->label2_2d_type, route('hardware.show', $asset->id), $size['height'], $size['width'], 'black', [-2, -2, -2, -2]); file_put_contents($qr_file, $barcode_obj->getPngData()); diff --git a/resources/lang/en-US/admin/settings/general.php b/resources/lang/en-US/admin/settings/general.php index 97567df8dfd4..cf46c63d4bab 100644 --- a/resources/lang/en-US/admin/settings/general.php +++ b/resources/lang/en-US/admin/settings/general.php @@ -248,6 +248,7 @@ 'labels_pagewidth' => 'Label sheet width', 'labels_pageheight' => 'Label sheet height', 'label_gutters' => 'Label spacing (inches)', + 'label_qr_setting_invalid' => 'Your QR Code type is set to \'None\', but you have enabled QR Codes. Please select a QR Code type.', 'page_dimensions' => 'Page dimensions (inches)', 'label_fields' => 'Label visible fields', 'inches' => 'inches', diff --git a/resources/views/hardware/labels.blade.php b/resources/views/hardware/labels.blade.php index 0d675d3beb78..da651dae8a2b 100644 --- a/resources/views/hardware/labels.blade.php +++ b/resources/views/hardware/labels.blade.php @@ -83,6 +83,10 @@ .next-padding { margin: {{ $settings->labels_pmargin_top }}in {{ $settings->labels_pmargin_right }}in {{ $settings->labels_pmargin_bottom }}in {{ $settings->labels_pmargin_left }}in; } + + .qr-warning { + color: red; + } @media print { .noprint { display: none !important; @@ -105,12 +109,18 @@ {!! $snipeSettings->show_custom_css() !!} @endif +@if ($settings->qr_code=='1' && ($settings->label2_2d_type == 'none')) +
+

+ {{ __('admin/settings/general.label_qr_setting_invalid') }} +
+@endif @foreach ($assets as $asset)
- @if ($settings->qr_code=='1') + @if ($settings->qr_code=='1' && (!$settings->label2_2d_type == 'none'))
From f0f820d75c714ae8fa784f0963a59d744faa50ac Mon Sep 17 00:00:00 2001 From: spencerrlongg Date: Wed, 29 Jan 2025 12:22:26 -0600 Subject: [PATCH 2/2] get rid of unneccessary condition --- resources/views/hardware/labels.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/hardware/labels.blade.php b/resources/views/hardware/labels.blade.php index da651dae8a2b..70ba4326b7a8 100644 --- a/resources/views/hardware/labels.blade.php +++ b/resources/views/hardware/labels.blade.php @@ -120,7 +120,7 @@
- @if ($settings->qr_code=='1' && (!$settings->label2_2d_type == 'none')) + @if ($settings->qr_code=='1')