Merge remote-tracking branch 'origin/develop'

This commit is contained in:
snipe 2023-08-21 22:35:45 +01:00
commit 24a9deb735
7 changed files with 126 additions and 13 deletions

View file

@ -30,7 +30,7 @@ class LabelsController extends Controller
$exampleAsset = new Asset();
$exampleAsset->id = 999999;
$exampleAsset->name = 'AST-AB-CD-1234';
$exampleAsset->name = 'JEN-867-5309';
$exampleAsset->asset_tag = 'TCA-00001';
$exampleAsset->serial = 'SN9876543210';

View file

@ -26,8 +26,8 @@ class LabelsTransformer
'name' => $label->getName(),
'unit' => $label->getUnit(),
'width' => $label->getWidth(),
'height' => $label->getHeight(),
'width' => number_format($label->getWidth(), 2),
'height' => number_format($label->getHeight(), 2),
'margin_top' => $label->getMarginTop(),
'margin_bottom' => $label->getMarginBottom(),

View file

@ -370,7 +370,11 @@ abstract class Label
*/
public final function write1DBarcode(TCPDF $pdf, $value, $type, $x, $y, $width, $height) {
if (empty($value)) return;
try {
$pdf->write1DBarcode($value, $type, $x, $y, $width, $height, null, ['stretch'=>true]);
} catch (\Exception $e) {
\Log::error('The 1D barcode ' . $value . ' is not compliant with the barcode type '. $type);
}
}
/**

View file

@ -0,0 +1,19 @@
<?php
namespace App\Models\Labels\Tapes\Dymo;
use App\Helpers\Helper;
use App\Models\Labels\Label;
abstract class LabelWriter extends Label
{
private const HEIGHT = 1.15;
private const MARGIN_SIDES = 0.1;
private const MARGIN_ENDS = 0.1;
public function getHeight() { return Helper::convertUnit(self::HEIGHT, 'in', $this->getUnit()); }
public function getMarginTop() { return Helper::convertUnit(self::MARGIN_SIDES, 'in', $this->getUnit()); }
public function getMarginBottom() { return Helper::convertUnit(self::MARGIN_SIDES, 'in', $this->getUnit());}
public function getMarginLeft() { return Helper::convertUnit(self::MARGIN_ENDS, 'in', $this->getUnit()); }
public function getMarginRight() { return Helper::convertUnit(self::MARGIN_ENDS, 'in', $this->getUnit()); }
}

View file

@ -0,0 +1,90 @@
<?php
namespace App\Models\Labels\Tapes\Dymo;
class LabelWriter_30252 extends LabelWriter
{
private const BARCODE_MARGIN = 1.80;
private const TAG_SIZE = 2.80;
private const TITLE_SIZE = 2.80;
private const TITLE_MARGIN = 0.50;
private const LABEL_SIZE = 2.00;
private const LABEL_MARGIN = - 0.35;
private const FIELD_SIZE = 3.20;
private const FIELD_MARGIN = 0.15;
public function getUnit() { return 'mm'; }
public function getWidth() { return 96.52; }
public function getSupportAssetTag() { return true; }
public function getSupport1DBarcode() { return true; }
public function getSupport2DBarcode() { return true; }
public function getSupportFields() { return 3; }
public function getSupportLogo() { return false; }
public function getSupportTitle() { return true; }
public function preparePDF($pdf) {}
public function write($pdf, $record) {
$pa = $this->getPrintableArea();
$currentX = $pa->x1;
$currentY = $pa->y1;
$usableWidth = $pa->w;
$barcodeSize = $pa->h - self::TAG_SIZE;
if ($record->has('barcode2d')) {
static::writeText(
$pdf, $record->get('tag'),
$pa->x1, $pa->y2 - self::TAG_SIZE,
'freemono', 'b', self::TAG_SIZE, 'C',
$barcodeSize, self::TAG_SIZE, true, 0
);
static::write2DBarcode(
$pdf, $record->get('barcode2d')->content, $record->get('barcode2d')->type,
$currentX, $currentY,
$barcodeSize, $barcodeSize
);
$currentX += $barcodeSize + self::BARCODE_MARGIN;
$usableWidth -= $barcodeSize + self::BARCODE_MARGIN;
} else {
static::writeText(
$pdf, $record->get('tag'),
$pa->x1, $pa->y2 - self::TAG_SIZE,
'freemono', 'b', self::TAG_SIZE, 'R',
$usableWidth, self::TAG_SIZE, true, 0
);
}
if ($record->has('title')) {
static::writeText(
$pdf, $record->get('title'),
$currentX, $currentY,
'freesans', '', self::TITLE_SIZE, 'L',
$usableWidth, self::TITLE_SIZE, true, 0
);
$currentY += self::TITLE_SIZE + self::TITLE_MARGIN;
}
foreach ($record->get('fields') as $field) {
static::writeText(
$pdf, $field['label'],
$currentX, $currentY,
'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,
'freemono', 'B', self::FIELD_SIZE, 'L',
$usableWidth, self::FIELD_SIZE, true, 0, 0.3
);
$currentY += self::FIELD_SIZE + self::FIELD_MARGIN;
}
}
}

View file

@ -74,9 +74,9 @@ class AssetObserver
$tag = $asset->asset_tag;
$prefix = $settings->auto_increment_prefix;
$number = substr($tag, strlen($prefix));
// IF - auto_increment_assets is on, AND (the prefix matches the start of the tag OR there is no prefix)
// IF - auto_increment_assets is on, AND (there is no prefix OR the prefix matches the start of the tag)
// AND the rest of the string after the prefix is all digits, THEN...
if ($settings->auto_increment_assets && (strpos($tag, $prefix) === 0 || $prefix=='') && preg_match('/\d+/',$number) === 1) {
if ($settings->auto_increment_assets && ($prefix=='' || strpos($tag, $prefix) === 0) && preg_match('/\d+/',$number) === 1) {
// new way of auto-trueing-up auto_increment ID's
$next_asset_tag = intval($number, 10) + 1;
// we had to use 'intval' because the $number could be '01234' and

View file

@ -21,7 +21,7 @@ class LabelPresenter extends Presenter
], [
'field' => 'name',
'searchable' => true,
'sortable' => true,
'sortable' => false,
'switchable' => true,
'title' => trans('general.name'),
'visible' => true,
@ -44,14 +44,14 @@ class LabelPresenter extends Presenter
], [
'field' => 'support_fields',
'searchable' => false,
'sortable' => true,
'sortable' => false,
'switchable' => true,
'title' => trans('admin/labels/table.support_fields'),
'visible' => true
], [
'field' => 'support_asset_tag',
'searchable' => false,
'sortable' => true,
'sortable' => false,
'switchable' => true,
'title' => trans('admin/labels/table.support_asset_tag'),
'visible' => true,
@ -59,7 +59,7 @@ class LabelPresenter extends Presenter
], [
'field' => 'support_1d_barcode',
'searchable' => false,
'sortable' => true,
'sortable' => false,
'switchable' => true,
'title' => trans('admin/labels/table.support_1d_barcode'),
'visible' => true,
@ -67,7 +67,7 @@ class LabelPresenter extends Presenter
], [
'field' => 'support_2d_barcode',
'searchable' => false,
'sortable' => true,
'sortable' => false,
'switchable' => true,
'title' => trans('admin/labels/table.support_2d_barcode'),
'visible' => true,
@ -75,7 +75,7 @@ class LabelPresenter extends Presenter
], [
'field' => 'support_logo',
'searchable' => false,
'sortable' => true,
'sortable' => false,
'switchable' => true,
'title' => trans('admin/labels/table.support_logo'),
'visible' => true,
@ -83,7 +83,7 @@ class LabelPresenter extends Presenter
], [
'field' => 'support_title',
'searchable' => false,
'sortable' => true,
'sortable' => false,
'switchable' => true,
'title' => trans('admin/labels/table.support_title'),
'visible' => true,