Skip to content

Commit e03ed75

Browse files
authored
Merge pull request #15747 from NebelKreis/feature/custom-data-options-for-2d-barcode
2 parents 3f5c166 + 9f05812 commit e03ed75

File tree

3 files changed

+66
-42
lines changed

3 files changed

+66
-42
lines changed

app/View/Label.php

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,30 @@ public function render(callable $callback = null)
115115
]);
116116
}
117117
}
118-
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;
118+
119+
if ($template->getSupport2DBarcode()) {
120+
$barcode2DType = $settings->label2_2d_type;
121+
$barcode2DType = ($barcode2DType == 'default') ?
122+
$settings->barcode_type :
123+
$barcode2DType;
124+
if (($barcode2DType != 'none') && (!is_null($barcode2DType))) {
125+
switch ($settings->label2_2d_target) {
126+
case 'ht_tag':
127+
$barcode2DTarget = route('ht/assetTag', $asset->asset_tag);
128+
break;
129+
case 'plain_asset_id':
130+
$barcode2DTarget = (string) $asset->id;
131+
break;
132+
case 'plain_asset_tag':
133+
$barcode2DTarget = $asset->asset_tag;
134+
break;
135+
case 'plain_serial_number':
136+
$barcode2DTarget = $asset->serial;
137+
break;
138+
case 'hardware_id':
139+
default:
140+
$barcode2DTarget = route('hardware.show', ['hardware' => $asset->id]);
141+
break;
130142
}
131143
$assetData->put('barcode2d', (object)[
132144
'type' => $barcode2DType,

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,12 +362,14 @@
362362
'label2_2d_type' => '2D Barcode Type',
363363
'label2_2d_type_help' => 'Format for 2D barcodes',
364364
'label2_2d_target' => '2D Barcode Target',
365-
'label2_2d_target_help' => 'The URL the 2D barcode points to when scanned',
365+
'label2_2d_target_help' => 'The data that will be contained in the 2D barcode',
366366
'label2_fields' => 'Field Definitions',
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' => '<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' => '<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. ',
371+
'asset_id' => 'Asset ID',
372+
'data' => 'Data',
371373
'default' => 'Default',
372374
'none' => 'None',
373375
'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: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ class="table table-striped snipe-table"
143143
@if ($is_gd_installed)
144144
<!-- barcode -->
145145
<div class="form-group">
146-
147146
<div class="col-md-9 col-md-offset-3">
148147
<label class="form-control">
149148
{{ Form::checkbox('alt_barcode_enabled', '1', old('alt_barcode_enabled', $setting->alt_barcode_enabled),array( 'aria-label'=>'alt_barcode_enabled')) }}
@@ -153,33 +152,38 @@ class="table table-striped snipe-table"
153152
</div>
154153
@endif
155154
@endif
156-
<!-- 1D Barcode Type -->
157-
<div class="form-group{{ $errors->has('label2_1d_type') ? ' has-error' : '' }}">
158-
<div class="col-md-3 text-right">
159-
{{ Form::label('label2_1d_type', trans('admin/settings/general.label2_1d_type'), ['class'=>'control-label']) }}
160-
</div>
161-
<div class="col-md-7">
162-
@php
163-
$select1DValues = [
164-
'C128' => 'C128',
165-
'C39' => 'C39',
166-
'EAN5' => 'EAN5',
167-
'EAN13' => 'EAN13',
168-
'UPCA' => 'UPCA',
169-
'UPCE' => 'UPCE',
170-
'none' => trans('admin/settings/general.none'),
171-
];
172-
@endphp
173-
{{ Form::select('label2_1d_type', $select1DValues, old('label2_1d_type', $setting->label2_1d_type), [ 'class'=>'select2 col-md-4', 'aria-label'=>'label2_1d_type' ]) }}
174-
{!! $errors->first('label2_1d_type', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
175-
<p class="help-block">
176-
{{ trans('admin/settings/general.label2_1d_type_help') }}.
177-
{!!
178-
trans('admin/settings/general.help_default_will_use')
179-
!!}
180-
</p>
181-
</div>
155+
156+
<!-- 1D Barcode Type -->
157+
<div class="form-group{{ $errors->has('label2_1d_type') ? ' has-error' : '' }}">
158+
<div class="col-md-3 text-right">
159+
{{ Form::label('label2_1d_type', trans('admin/settings/general.label2_1d_type'), ['class'=>'control-label']) }}
182160
</div>
161+
<div class="col-md-7">
162+
@php
163+
$select1DValues = [
164+
'C128' => 'C128',
165+
'C39' => 'C39',
166+
'EAN5' => 'EAN5',
167+
'EAN13' => 'EAN13',
168+
'UPCA' => 'UPCA',
169+
'UPCE' => 'UPCE',
170+
'none' => trans('admin/settings/general.none'),
171+
];
172+
@endphp
173+
{{ Form::select('label2_1d_type', $select1DValues, old('label2_1d_type', $setting->label2_1d_type), [ 'class'=>'select2 col-md-4', 'aria-label'=>'label2_1d_type' ]) }}
174+
{!! $errors->first('label2_1d_type', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
175+
<p class="help-block">
176+
{{ trans('admin/settings/general.label2_1d_type_help') }}.
177+
{!!
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+
])
182+
!!}
183+
</p>
184+
</div>
185+
</div>
186+
183187
@if($setting->label2_enable == 0)
184188

185189
<!-- qr code -->
@@ -273,7 +277,13 @@ class="table table-striped snipe-table"
273277
{{ Form::label('label2_2d_target', trans('admin/settings/general.label2_2d_target'), ['class'=>'control-label']) }}
274278
</div>
275279
<div class="col-md-9">
276-
{{ Form::select('label2_2d_target', ['hardware_id'=>'/hardware/{id} ('.trans('admin/settings/general.default').')', 'ht_tag'=>'/ht/{asset_tag}'], old('label2_2d_target', $setting->label2_2d_target), [ 'class'=>'select2 col-md-4', 'aria-label'=>'label2_2d_target' ]) }}
280+
{{ Form::select('label2_2d_target', [
281+
'hardware_id' => trans('general.url') .': /hardware/{id} ('.trans('admin/settings/general.default').')',
282+
'ht_tag' => trans('general.url') .': /ht/{asset_tag}',
283+
'plain_asset_id' => trans('admin/settings/general.data') .': '. trans('admin/settings/general.asset_id') .' {id}',
284+
'plain_asset_tag' => trans('admin/settings/general.data') .': '. trans('general.asset_tag') .' {asset_tag}',
285+
'plain_serial_number' => trans('admin/settings/general.data') .': '. trans('general.serial_number') .' {serial}',
286+
], old('label2_2d_target', $setting->label2_2d_target), [ 'class'=>'select2 col-md-4', 'aria-label'=>'label2_2d_target' ]) }}
277287
{!! $errors->first('label2_2d_target', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
278288
<p class="help-block">{{ trans('admin/settings/general.label2_2d_target_help') }}</p>
279289
</div>

0 commit comments

Comments
 (0)