Skip to content

A free open source IT asset/license management system

2.6 KB
Raw Blame
<?php

namespace App\Models\Labels\Tapes\Brother;

class TZe_12mm_A extends TZe_12mm
{
    private const BARCODE_SIZE = 3.20;

    private const BARCODE_MARGIN = 0.30;

    private const TEXT_SIZE_MOD = 1.00;

    public function getUnit()
    {
        return 'mm';
    }

    public function getWidth()
    {
        return 50.0;
    }

    public function getBarcodeSize(): float
    {
        return self::BARCODE_SIZE;
    }

    public function getBarcodeMargin(): float
    {
        return self::BARCODE_MARGIN;
    }

    public function getTextSizeMod(): float
    {
        return self::TEXT_SIZE_MOD;
    }


    public function getSupportAssetTag()
    {
        return true;
    }

    public function getSupport1DBarcode()
    {
        return true;
    }

    public function getSupport2DBarcode()
    {
        return false;
    }

    public function getSupportFields()
    {
        return 1;
    }

    public function getSupportLogo()
    {
        return false;
    }

    public function getSupportTitle()
    {
        return false;
    }

    protected function getContentEditorConfig(): array
    {
        return [
            'barcode_size' => $this->getBarcodeSize(),
            'barcode_margin' => $this->getBarcodeMargin(),
            'text_size_mod' => $this->getTextSizeMod(),
            'field_label_font_size' => 0.1,
            'field_value_font_size' => 0,
            'tag_font_size' => 3.5,
        ];
    }

    public function write($pdf, $record)
    {
        $pa = $this->getPrintableArea();

        if ($record->has('barcode1d')) {
            static::write1DBarcode(
                $pdf, $record->get('barcode1d')->content, $record->get('barcode1d')->type,
                $pa->x1, $pa->y1, $pa->w, self::BARCODE_SIZE
            );
        }

        $currentY = $pa->y1 + self::BARCODE_SIZE + self::BARCODE_MARGIN;
        $usableHeight = $pa->h - self::BARCODE_SIZE - self::BARCODE_MARGIN;
        $fontSize = $usableHeight + self::TEXT_SIZE_MOD;

        $tagWidth = $pa->w / 3;
        $fieldWidth = $pa->w / 3 * 2;

        static::writeText(
            $pdf, $record->get('tag'),
            $pa->x1, $currentY,
            'freemono', 'b', $fontSize, 'L',
            $tagWidth, $usableHeight, true, 0, 0
        );

        if ($record->get('fields')->count() >= 1) {
            static::writeText(
                $pdf, $record->get('fields')->values()->get(0)['value'],
                $pa->x1 + ($tagWidth), $currentY,
                'freemono', 'b', $fontSize, 'R',
                $fieldWidth, $usableHeight, true, 0, 0
            );
        }

    }
}