Skip to content

A free open source IT asset/license management system

adds Field offset option to labels

Godfrey M7c2c5ea98de2
diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php
index a6de4466dd..7007398094 100644
--- a/app/Http/Controllers/SettingsController.php
+++ b/app/Http/Controllers/SettingsController.php
@@ -772,6 +772,7 @@ class SettingsController extends Controller
$setting->label2_2d_type = $request->input('label2_2d_type');
$setting->label2_2d_target = $request->input('label2_2d_target');
$setting->label2_fields = $request->input('label2_fields');
+ $setting->label2_empty_row_count = $request->input('label2_empty_row_count');
$setting->labels_per_page = $request->input('labels_per_page');
$setting->labels_width = $request->input('labels_width');
$setting->labels_height = $request->input('labels_height');
diff --git a/app/View/Label.php b/app/View/Label.php
index 6dbad39a34..e3b7b714d6 100644
--- a/app/View/Label.php
+++ b/app/View/Label.php
@@ -191,9 +191,28 @@ class Label implements View
return $toAdd ? $myFields->push($toAdd) : $myFields;
}, new Collection());
- $assetData->put('fields', $fields->take($template->getSupportFields()));
+ $emptyRowsCount = $settings->label2_empty_row_count;
+ if($emptyRowsCount) {
+ // Create empty rows
+ $emptyRows = collect(range(1, $emptyRowsCount))->map(function () {
+ return [
+ 'label' => '',
+ 'value' => '',
+ 'dataSource' => null,
+ ];
+ });
+
+ // Prepend empty rows to the existing fields
+ $fieldsWithEmpty = $emptyRows->merge($fields);
+
+ $assetData->put('fields', $fieldsWithEmpty->take($template->getSupportFields()));
+ return $assetData;
+ }
+ else{
+ $assetData->put('fields', $fields->take($template->getSupportFields()));
+ return $assetData;
+ }
- return $assetData;
});
if ($template instanceof Sheet) {
diff --git a/database/migrations/2025_04_22_170731_add_empty_row_count_to_settings_table.php b/database/migrations/2025_04_22_170731_add_empty_row_count_to_settings_table.php
new file mode 100644
index 0000000000..49b228b42d
--- /dev/null
+++ b/database/migrations/2025_04_22_170731_add_empty_row_count_to_settings_table.php
@@ -0,0 +1,21 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration {
+ public function up(): void
+ {
+ Schema::table('settings', function (Blueprint $table) {
+ $table->unsignedInteger('label2_empty_row_count')->default(0)->after('label2_fields');
+ });
+ }
+
+ public function down(): void
+ {
+ Schema::table('settings', function (Blueprint $table) {
+ $table->dropColumn('label2_empty_row_count');
+ });
+ }
+};
diff --git a/resources/lang/en-US/admin/settings/general.php b/resources/lang/en-US/admin/settings/general.php
index 61bc0c5f76..1063ba4009 100644
--- a/resources/lang/en-US/admin/settings/general.php
+++ b/resources/lang/en-US/admin/settings/general.php
@@ -64,6 +64,8 @@ return [
'enabled' => 'Enabled',
'eula_settings' => 'EULA Settings',
'eula_markdown' => 'This EULA allows <a href="https://help.github.com/articles/github-flavored-markdown/">Github flavored markdown</a>.',
+ 'empty_row_count' => 'Field Start Offset (Empty Rows)',
+ 'empty_row_count_help' => 'Fields will begin populating after this many empty rows are skipped at the top of the label.',
'favicon' => 'Favicon',
'favicon_format' => 'Accepted filetypes are ico, png, and gif. Other image formats may not work in all browsers.',
'favicon_size' => 'Favicons should be square images, 16x16 pixels.',
diff --git a/resources/views/settings/labels.blade.php b/resources/views/settings/labels.blade.php
index 6b3442420b..ae79c061a8 100644
--- a/resources/views/settings/labels.blade.php
+++ b/resources/views/settings/labels.blade.php
@@ -313,6 +313,28 @@
<p class="help-block">{{ trans('admin/settings/general.label2_2d_target_help') }}</p>
</div>
</div>
+ <!-- Title -->
+ <div class="form-group{{ $errors->has('label2_empty_row_count') ? ' has-error' : '' }}">
+ <div class="col-md-3 text-right">
+ <label for="label2_empty_row_count" class="control-label">{{trans('admin/settings/general.empty_row_count')}}</label>
+ </div>
+ <div class="form-group row">
+ <div class="col-md-2">
+ <input
+ class="form-control"
+ aria-label="Empty Row Count"
+ name="label2_empty_row_count"
+ type="number"
+ id="label2_empty_row_count"
+ min="0"
+ value="{{ old('label2_empty_row_count', $setting->label2_empty_row_count) }}">
+ </div>
+ <div class="col-md-7">
+ {!! $errors->first('empty_row_count', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
+ <p class="help-block">{!! trans('admin/settings/general.empty_row_count_help') !!}</p>
+ </div>
+ </div>
+ </div>
<div class="col-md-9 col-md-offset-3" style="margin-bottom: 10px;">
@include('partials.label2-preview')
</div>