Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a Label Fields vertical adjustment option for Dymo Labelwriters #15863

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Http/Controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ public function postLabels(StoreLabelSettings $request) : RedirectResponse
$setting->labels_pagewidth = $request->input('labels_pagewidth');
$setting->labels_pageheight = $request->input('labels_pageheight');
$setting->labels_display_company_name = $request->input('labels_display_company_name', '0');
$setting->labels_display_company_name = $request->input('labels_display_company_name', '0');
$setting->label_cell_margin_top = $request->input('label_cell_margin_top');



Expand Down
12 changes: 7 additions & 5 deletions app/Models/Labels/Tapes/Dymo/LabelWriter_1933081.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace App\Models\Labels\Tapes\Dymo;


use App\Models\Setting;

class LabelWriter_1933081 extends LabelWriter
{
private const BARCODE_MARGIN = 1.80;
Expand Down Expand Up @@ -32,7 +34,7 @@ public function write($pdf, $record) {
$currentX = $pa->x1;
$currentY = $pa->y1;
$usableWidth = $pa->w;

$cell_margin_top = Setting::getSettings()->label_cell_margin_top;
$barcodeSize = $pa->h - self::TAG_SIZE;

if ($record->has('barcode2d')) {
Expand All @@ -49,12 +51,12 @@ public function write($pdf, $record) {
);
$currentX += $barcodeSize + self::BARCODE_MARGIN;
$usableWidth -= $barcodeSize + self::BARCODE_MARGIN;
}

}
$titleY = $pa->y1;
if ($record->has('title')) {
static::writeText(
$pdf, $record->get('title'),
$currentX, $currentY,
$currentX, $titleY,
'freesans', 'b', self::TITLE_SIZE, 'L',
$usableWidth, self::TITLE_SIZE, true, 0
);
Expand All @@ -64,7 +66,7 @@ public function write($pdf, $record) {
foreach ($record->get('fields') as $field) {
static::writeText(
$pdf, (($field['label']) ? $field['label'].' ' : '') . $field['value'],
$currentX, $currentY,
$currentX, $currentY + $cell_margin_top,
'freesans', '', self::FIELD_SIZE, 'L',
$usableWidth, self::FIELD_SIZE, true, 0, 0.3
);
Expand Down
9 changes: 6 additions & 3 deletions app/Models/Labels/Tapes/Dymo/LabelWriter_2112283.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace App\Models\Labels\Tapes\Dymo;


use App\Models\Setting;

class LabelWriter_2112283 extends LabelWriter
{
private const BARCODE_MARGIN = 1.80;
Expand Down Expand Up @@ -32,7 +34,7 @@ public function write($pdf, $record) {
$currentX = $pa->x1;
$currentY = $pa->y1;
$usableWidth = $pa->w;

$cell_margin_top = Setting::getSettings()->label_cell_margin_top;
$barcodeSize = $pa->h - self::TAG_SIZE;

if ($record->has('barcode2d')) {
Expand All @@ -51,20 +53,21 @@ public function write($pdf, $record) {
$usableWidth -= $barcodeSize + self::BARCODE_MARGIN;
}

$titleY = $pa->y1;
if ($record->has('title')) {
static::writeText(
$pdf, $record->get('title'),
$currentX, $currentY,
'freesans', 'b', self::TITLE_SIZE, 'L',
$usableWidth, self::TITLE_SIZE, true, 0
);
$currentY += self::TITLE_SIZE + self::TITLE_MARGIN;
$currentY += $titleY + self::TITLE_SIZE + self::TITLE_MARGIN;
}

foreach ($record->get('fields') as $field) {
static::writeText(
$pdf, (($field['label']) ? $field['label'].' ' : '') . $field['value'],
$currentX, $currentY,
$currentX, $currentY + $cell_margin_top,
'freesans', '', self::FIELD_SIZE, 'L',
$usableWidth, self::FIELD_SIZE, true, 0, 0.3
);
Expand Down
12 changes: 7 additions & 5 deletions app/Models/Labels/Tapes/Dymo/LabelWriter_30252.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace App\Models\Labels\Tapes\Dymo;


use App\Models\Setting;

class LabelWriter_30252 extends LabelWriter
{
private const BARCODE_MARGIN = 1.80;
Expand Down Expand Up @@ -33,7 +35,7 @@ public function write($pdf, $record) {
$currentX = $pa->x1;
$currentY = $pa->y1;
$usableWidth = $pa->w;

$cell_margin_top = Setting::getSettings()->label_cell_margin_top;
$barcodeSize = $pa->h - self::TAG_SIZE;

if ($record->has('barcode2d')) {
Expand All @@ -51,11 +53,11 @@ public function write($pdf, $record) {
$currentX += $barcodeSize + self::BARCODE_MARGIN;
$usableWidth -= $barcodeSize + self::BARCODE_MARGIN;
}

$titleY= $pa->y1;
if ($record->has('title')) {
static::writeText(
$pdf, $record->get('title'),
$currentX, $currentY,
$currentX, $titleY,
'freesans', '', self::TITLE_SIZE, 'L',
$usableWidth, self::TITLE_SIZE, true, 0
);
Expand All @@ -65,15 +67,15 @@ public function write($pdf, $record) {
foreach ($record->get('fields') as $field) {
static::writeText(
$pdf, $field['label'],
$currentX, $currentY,
$currentX, $currentY + $cell_margin_top,
'freesans', '', self::LABEL_SIZE, 'L',
$usableWidth, self::LABEL_SIZE, true, 0, 0
);
$currentY += self::LABEL_SIZE + self::LABEL_MARGIN;

static::writeText(
$pdf, $field['value'],
$currentX, $currentY,
$currentX, $currentY+ $cell_margin_top,
'freemono', 'B', self::FIELD_SIZE, 'L',
$usableWidth, self::FIELD_SIZE, true, 0, 0.3
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?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
{
Schema::table('settings', function (Blueprint $table) {
$table->double('label_cell_margin_top', 4, 3)->after('label2_fields')->default(0)->nullable();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('settings', function (Blueprint $table) {
$table->dropColumn('label_cell_margin_top');
});
}
};
12 changes: 6 additions & 6 deletions docker/docker.env
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# --------------------------------------------
# REQUIRED: BASIC APP SETTINGS
# --------------------------------------------
#APP_ENV=develop
#APP_DEBUG=false
#APP_KEY=Change_this_key_or_snipe_will_get_ya
#APP_URL=http://127.0.0.1:32782
#APP_TIMEZONE=US/Pacific
#APP_LOCALE=en
APP_ENV=develop
APP_DEBUG=false
APP_KEY=base64:WpNieYLCLW/T+VC63PK0ypfNUZ+/zf0V6eG3XIpCCaY=
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want to hardcode app keys here.

APP_URL=http://127.0.0.1:32782
APP_TIMEZONE=US/Pacific
APP_LOCALE=en


# --------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions resources/lang/en-US/admin/settings/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
'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.',
'field_margin_top' => 'Field Margin Top',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What unit of measure is this using?

'footer_text' => 'Additional Footer Text ',
'footer_text_help' => 'This text will appear in the right-side footer. Links are allowed using <a href="https://help.github.com/articles/github-flavored-markdown/">Github flavored markdown</a>. Line breaks, headers, images, etc may result in unpredictable results.',
'general_settings' => 'General Settings',
Expand All @@ -78,6 +79,7 @@
'info' => 'These settings let you customize certain aspects of your installation.',
'label_logo' => 'Label Logo',
'label_logo_size' => 'Square logos look best - will be displayed in the top right of each asset label. ',
'label_cell_margin_top_help'=> 'Vertically align the label fields below if needed. Max value 10.',
'laravel' => 'Laravel Version',
'ldap' => 'LDAP',
'ldap_default_group' => 'Default Permissions Group',
Expand Down
31 changes: 29 additions & 2 deletions resources/views/settings/labels.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class="table table-striped snipe-table"
</div>

<!-- 2D Barcode Target -->
<div class="form-group{{ $errors->has('label2_2d_target') ? ' has-error' : '' }}">
<div class="form-group{{ $errors->has('label2_2d_target') ? ' has-error' : '' }}">
<div class="col-md-3 text-right">
{{ Form::label('label2_2d_target', trans('admin/settings/general.label2_2d_target'), ['class'=>'control-label']) }}
</div>
Expand All @@ -208,10 +208,37 @@ class="table table-striped snipe-table"
{!! $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>
</div>
</div>

<!--Field Cell Margin Top-->
@if(str_contains($setting->label2_template , 'Tapes\Dymo\LabelWriter'))
<div class="form-group{{ $errors->has('label_cell_margin_top') ? ' has-error' : '' }}">
<div class="col-md-3 text-right">
{{ Form::label('label_cell_margin_top', trans('admin/settings/general.field_margin_top'),['class'=>'control-label']) }}
</div>
<div class="col-md-3">
<div class="input-group" style="margin-bottom: 15px;">
{{ Form::number('label_cell_margin_top', old('label_cell_margin_top', $setting->label_cell_margin_top),[
'class' => 'form-control',
'aria-label' => 'label_cell_margin_top',
'step' => '0.01', // Increment/Decrement step
'min' => '0', // Optional: Minimum value
'max' => '10', // Optional: Maximum value

]) }}
<div class="input-group-addon">{{ trans('admin/settings/general.top') }}</div>
</div>
<p class="help-block">{{ trans('admin/settings/general.label_cell_margin_top_help') }}</p>
</div>


</div>
@endif
<div class="col-md-9 col-md-offset-3" style="margin-bottom: 10px;">
@include('partials.label2-preview')
</div>


<!-- Fields -->
<div class="form-group {{ $errors->has('label2_fields') ? 'error' : '' }}">
<div class="col-md-3 text-right">
Expand Down
Loading