Skip to content

Commit

Permalink
Merge pull request #16033 from Godmartinz/barcode-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
snipe authored Jan 7, 2025
2 parents 63853db + 83ee0e0 commit 40b41e6
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 26 deletions.
34 changes: 17 additions & 17 deletions app/View/Label.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function render(callable $callback = null)
}
}

if ($settings->alt_barcode_enabled) {

if ($template->getSupport1DBarcode()) {
$barcode1DType = $settings->label2_1d_type;
if ($barcode1DType != 'none') {
Expand All @@ -115,25 +115,25 @@ public function render(callable $callback = null)
]);
}
}
}

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 'hardware_id':
default: $barcode2DTarget = route('hardware.show', ['hardware' => $asset->id]); break;
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;
}
$assetData->put('barcode2d', (object)[
'type' => $barcode2DType,
'content' => $barcode2DTarget,
]);
}
$assetData->put('barcode2d', (object)[
'type' => $barcode2DType,
'content' => $barcode2DTarget,
]);
}
}

$fields = $fieldDefinitions
->map(fn($field) => $field->toArray($asset))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
DB::table('settings')->where('label2_2d_type', 'default')->update([
'label2_2d_type' => 'QRCODE',
]);

DB::table('settings')->where('label2_1d_type', 'default')->update([
'label2_1d_type' => 'C128',
]);

DB::table('settings')->whereNull('label2_2d_type')->orWhere('label2_2d_type', '')->update([
'label2_2d_type' => 'none',
]);

DB::table('settings')->whereNull('label2_1d_type')->orWhere('label2_1d_type', '')->update([
'label2_1d_type' => 'none',
]);

Schema::table('settings', function (Blueprint $table) {
$table->string('label2_2d_type')->default('QRCODE')->change();
$table->string('label2_1d_type')->default('C128')->change();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
//
}
};
2 changes: 1 addition & 1 deletion resources/lang/en-US/admin/settings/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@
'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' => '<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. ',
'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. ',
'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
10 changes: 2 additions & 8 deletions resources/views/settings/labels.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,7 @@ class="table table-striped snipe-table"
<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'),
])
trans('admin/settings/general.help_default_will_use')
!!}
</p>
</div>
Expand Down Expand Up @@ -218,10 +215,7 @@ class="table table-striped snipe-table"
<p class="help-block">
{{ trans('admin/settings/general.label2_2d_type_help', ['current' => $setting->barcode_type]) }}.
{!!
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.barcode_type'),
])
trans('admin/settings/general.help_default_will_use')
!!}
</p>
</div>
Expand Down

0 comments on commit 40b41e6

Please sign in to comment.