Skip to content

Commit 40b41e6

Browse files
authored
Merge pull request #16033 from Godmartinz/barcode-fix
2 parents 63853db + 83ee0e0 commit 40b41e6

File tree

4 files changed

+63
-26
lines changed

4 files changed

+63
-26
lines changed

app/View/Label.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function render(callable $callback = null)
105105
}
106106
}
107107

108-
if ($settings->alt_barcode_enabled) {
108+
109109
if ($template->getSupport1DBarcode()) {
110110
$barcode1DType = $settings->label2_1d_type;
111111
if ($barcode1DType != 'none') {
@@ -115,25 +115,25 @@ public function render(callable $callback = null)
115115
]);
116116
}
117117
}
118-
}
119118

120-
if ($template->getSupport2DBarcode()) {
121-
$barcode2DType = $settings->label2_2d_type;
122-
$barcode2DType = ($barcode2DType == 'default') ?
123-
$settings->barcode_type :
124-
$barcode2DType;
125-
if (($barcode2DType != 'none') && (!is_null($barcode2DType))) {
126-
switch ($settings->label2_2d_target) {
127-
case 'ht_tag': $barcode2DTarget = route('ht/assetTag', $asset->asset_tag); break;
128-
case 'hardware_id':
129-
default: $barcode2DTarget = route('hardware.show', ['hardware' => $asset->id]); break;
119+
if ($template->getSupport2DBarcode()) {
120+
$barcode2DType = $settings->label2_2d_type;
121+
if (($barcode2DType != 'none') && (!is_null($barcode2DType))) {
122+
switch ($settings->label2_2d_target) {
123+
case 'ht_tag':
124+
$barcode2DTarget = route('ht/assetTag', $asset->asset_tag);
125+
break;
126+
case 'hardware_id':
127+
default:
128+
$barcode2DTarget = route('hardware.show', ['hardware' => $asset->id]);
129+
break;
130+
}
131+
$assetData->put('barcode2d', (object)[
132+
'type' => $barcode2DType,
133+
'content' => $barcode2DTarget,
134+
]);
130135
}
131-
$assetData->put('barcode2d', (object)[
132-
'type' => $barcode2DType,
133-
'content' => $barcode2DTarget,
134-
]);
135136
}
136-
}
137137

138138
$fields = $fieldDefinitions
139139
->map(fn($field) => $field->toArray($asset))
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
DB::table('settings')->where('label2_2d_type', 'default')->update([
15+
'label2_2d_type' => 'QRCODE',
16+
]);
17+
18+
DB::table('settings')->where('label2_1d_type', 'default')->update([
19+
'label2_1d_type' => 'C128',
20+
]);
21+
22+
DB::table('settings')->whereNull('label2_2d_type')->orWhere('label2_2d_type', '')->update([
23+
'label2_2d_type' => 'none',
24+
]);
25+
26+
DB::table('settings')->whereNull('label2_1d_type')->orWhere('label2_1d_type', '')->update([
27+
'label2_1d_type' => 'none',
28+
]);
29+
30+
Schema::table('settings', function (Blueprint $table) {
31+
$table->string('label2_2d_type')->default('QRCODE')->change();
32+
$table->string('label2_1d_type')->default('C128')->change();
33+
});
34+
}
35+
36+
/**
37+
* Reverse the migrations.
38+
*/
39+
public function down(): void
40+
{
41+
//
42+
}
43+
};

resources/lang/en-US/admin/settings/general.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@
367367
'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.',
368368
'help_asterisk_bold' => 'Text entered as <code>**text**</code> will be displayed as bold',
369369
'help_blank_to_use' => 'Leave blank to use the value from <code>:setting_name</code>',
370-
'help_default_will_use' => '<code>:default</code> will use the value from <code>:setting_name</code>. <br>Note that the value of the barcodes must comply with the respective barcode spec in order to be successfully generated. Please see <a href="https://snipe-it.readme.io/docs/barcodes">the documentation <i class="fa fa-external-link"></i></a> for more details. ',
370+
'help_default_will_use' => '<br>Note that the value of the barcodes must comply with the respective barcode spec in order to be successfully generated. Please see <a href="https://snipe-it.readme.io/docs/barcodes">the documentation <i class="fa fa-external-link"></i></a> for more details. ',
371371
'default' => 'Default',
372372
'none' => 'None',
373373
'google_callback_help' => 'This should be entered as the callback URL in your Google OAuth app settings in your organization&apos;s <strong><a href="https://console.cloud.google.com/" target="_blank">Google developer console <i class="fa fa-external-link" aria-hidden="true"></i></a></strong>.',

resources/views/settings/labels.blade.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,7 @@ class="table table-striped snipe-table"
175175
<p class="help-block">
176176
{{ trans('admin/settings/general.label2_1d_type_help') }}.
177177
{!!
178-
trans('admin/settings/general.help_default_will_use', [
179-
'default' => trans('admin/settings/general.default'),
180-
'setting_name' => trans('admin/settings/general.barcodes').' &gt; '.trans('admin/settings/general.alt_barcode_type'),
181-
])
178+
trans('admin/settings/general.help_default_will_use')
182179
!!}
183180
</p>
184181
</div>
@@ -218,10 +215,7 @@ class="table table-striped snipe-table"
218215
<p class="help-block">
219216
{{ trans('admin/settings/general.label2_2d_type_help', ['current' => $setting->barcode_type]) }}.
220217
{!!
221-
trans('admin/settings/general.help_default_will_use', [
222-
'default' => trans('admin/settings/general.default'),
223-
'setting_name' => trans('admin/settings/general.barcodes').' &gt; '.trans('admin/settings/general.barcode_type'),
224-
])
218+
trans('admin/settings/general.help_default_will_use')
225219
!!}
226220
</p>
227221
</div>

0 commit comments

Comments
 (0)