Skip to content

Commit

Permalink
Merge pull request #15747 from NebelKreis/feature/custom-data-options…
Browse files Browse the repository at this point in the history
…-for-2d-barcode
  • Loading branch information
snipe authored Jan 13, 2025
2 parents 3f5c166 + 9f05812 commit e03ed75
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 42 deletions.
36 changes: 24 additions & 12 deletions app/View/Label.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,30 @@ public function render(callable $callback = null)
]);
}
}

if ($template->getSupport2DBarcode()) {
$barcode2DType = $settings->label2_2d_type;
if (($barcode2DType != 'none') && (!is_null($barcode2DType))) {
switch ($settings->label2_2d_target) {
case 'ht_tag':
$barcode2DTarget = route('ht/assetTag', $asset->asset_tag);
break;
case 'hardware_id':
default:
$barcode2DTarget = route('hardware.show', ['hardware' => $asset->id]);
break;

if ($template->getSupport2DBarcode()) {
$barcode2DType = $settings->label2_2d_type;
$barcode2DType = ($barcode2DType == 'default') ?
$settings->barcode_type :
$barcode2DType;
if (($barcode2DType != 'none') && (!is_null($barcode2DType))) {
switch ($settings->label2_2d_target) {
case 'ht_tag':
$barcode2DTarget = route('ht/assetTag', $asset->asset_tag);
break;
case 'plain_asset_id':
$barcode2DTarget = (string) $asset->id;
break;
case 'plain_asset_tag':
$barcode2DTarget = $asset->asset_tag;
break;
case 'plain_serial_number':
$barcode2DTarget = $asset->serial;
break;
case 'hardware_id':
default:
$barcode2DTarget = route('hardware.show', ['hardware' => $asset->id]);
break;
}
$assetData->put('barcode2d', (object)[
'type' => $barcode2DType,
Expand Down
6 changes: 4 additions & 2 deletions resources/lang/en-US/admin/settings/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,12 +362,14 @@
'label2_2d_type' => '2D Barcode Type',
'label2_2d_type_help' => 'Format for 2D barcodes',
'label2_2d_target' => '2D Barcode Target',
'label2_2d_target_help' => 'The URL the 2D barcode points to when scanned',
'label2_2d_target_help' => 'The data that will be contained in the 2D barcode',
'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.',
'help_asterisk_bold' => 'Text entered as <code>**text**</code> will be displayed as bold',
'help_blank_to_use' => 'Leave blank to use the value from <code>:setting_name</code>',
'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. ',
'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. ',
'asset_id' => 'Asset ID',
'data' => 'Data',
'default' => 'Default',
'none' => 'None',
'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>.',
Expand Down
66 changes: 38 additions & 28 deletions resources/views/settings/labels.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ class="table table-striped snipe-table"
@if ($is_gd_installed)
<!-- barcode -->
<div class="form-group">
<div class="col-md-9 col-md-offset-3">
<label class="form-control">
{{ Form::checkbox('alt_barcode_enabled', '1', old('alt_barcode_enabled', $setting->alt_barcode_enabled),array( 'aria-label'=>'alt_barcode_enabled')) }}
Expand All @@ -153,33 +152,38 @@ class="table table-striped snipe-table"
</div>
@endif
@endif
<!-- 1D Barcode Type -->
<div class="form-group{{ $errors->has('label2_1d_type') ? ' has-error' : '' }}">
<div class="col-md-3 text-right">
{{ Form::label('label2_1d_type', trans('admin/settings/general.label2_1d_type'), ['class'=>'control-label']) }}
</div>
<div class="col-md-7">
@php
$select1DValues = [
'C128' => 'C128',
'C39' => 'C39',
'EAN5' => 'EAN5',
'EAN13' => 'EAN13',
'UPCA' => 'UPCA',
'UPCE' => 'UPCE',
'none' => trans('admin/settings/general.none'),
];
@endphp
{{ Form::select('label2_1d_type', $select1DValues, old('label2_1d_type', $setting->label2_1d_type), [ 'class'=>'select2 col-md-4', 'aria-label'=>'label2_1d_type' ]) }}
{!! $errors->first('label2_1d_type', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
<p class="help-block">
{{ trans('admin/settings/general.label2_1d_type_help') }}.
{!!
trans('admin/settings/general.help_default_will_use')
!!}
</p>
</div>
<!-- 1D Barcode Type -->
<div class="form-group{{ $errors->has('label2_1d_type') ? ' has-error' : '' }}">
<div class="col-md-3 text-right">
{{ Form::label('label2_1d_type', trans('admin/settings/general.label2_1d_type'), ['class'=>'control-label']) }}
</div>
<div class="col-md-7">
@php
$select1DValues = [
'C128' => 'C128',
'C39' => 'C39',
'EAN5' => 'EAN5',
'EAN13' => 'EAN13',
'UPCA' => 'UPCA',
'UPCE' => 'UPCE',
'none' => trans('admin/settings/general.none'),
];
@endphp
{{ Form::select('label2_1d_type', $select1DValues, old('label2_1d_type', $setting->label2_1d_type), [ 'class'=>'select2 col-md-4', 'aria-label'=>'label2_1d_type' ]) }}
{!! $errors->first('label2_1d_type', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
<p class="help-block">
{{ trans('admin/settings/general.label2_1d_type_help') }}.
{!!
trans('admin/settings/general.help_default_will_use', [
'default' => trans('admin/settings/general.default'),
'setting_name' => trans('admin/settings/general.barcodes').' &gt; '.trans('admin/settings/general.alt_barcode_type'),
])
!!}
</p>
</div>
</div>

@if($setting->label2_enable == 0)

<!-- qr code -->
Expand Down Expand Up @@ -273,7 +277,13 @@ class="table table-striped snipe-table"
{{ Form::label('label2_2d_target', trans('admin/settings/general.label2_2d_target'), ['class'=>'control-label']) }}
</div>
<div class="col-md-9">
{{ 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' ]) }}
{{ Form::select('label2_2d_target', [
'hardware_id' => trans('general.url') .': /hardware/{id} ('.trans('admin/settings/general.default').')',
'ht_tag' => trans('general.url') .': /ht/{asset_tag}',
'plain_asset_id' => trans('admin/settings/general.data') .': '. trans('admin/settings/general.asset_id') .' {id}',
'plain_asset_tag' => trans('admin/settings/general.data') .': '. trans('general.asset_tag') .' {asset_tag}',
'plain_serial_number' => trans('admin/settings/general.data') .': '. trans('general.serial_number') .' {serial}',
], old('label2_2d_target', $setting->label2_2d_target), [ 'class'=>'select2 col-md-4', 'aria-label'=>'label2_2d_target' ]) }}
{!! $errors->first('label2_2d_target', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
<p class="help-block">{{ trans('admin/settings/general.label2_2d_target_help') }}</p>
</div>
Expand Down

0 comments on commit e03ed75

Please sign in to comment.