Skip to content

Commit 6904ad0

Browse files
authored
Renamed L6009.php -> L4736.php
Renamed L6009_A.php -> L4736_A.php Added correct L6009.php Added correct L6009_A.php
1 parent 07256fd commit 6904ad0

File tree

4 files changed

+380
-231
lines changed

4 files changed

+380
-231
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?php
2+
3+
namespace App\Models\Labels\Sheets\Avery;
4+
5+
use App\Helpers\Helper;
6+
use App\Models\Labels\RectangleSheet;
7+
8+
abstract class L4736 extends RectangleSheet
9+
{
10+
11+
private const PAPER_FORMAT = 'A4';
12+
private const PAPER_ORIENTATION = 'P';
13+
14+
/* Data in pt from Word Template */
15+
private const COLUMN1_X = 31.70;
16+
private const COLUMN2_X = 167.92;
17+
private const ROW1_Y = 53.00;
18+
private const ROW2_Y = 112.8;
19+
private const LABEL_W = 122.24;
20+
private const LABEL_H = 66.5;
21+
22+
private float $pageWidth;
23+
private float $pageHeight;
24+
private float $pageMarginLeft;
25+
private float $pageMarginTop;
26+
27+
private float $columnSpacing;
28+
private float $rowSpacing;
29+
30+
private float $labelWidth;
31+
private float $labelHeight;
32+
33+
public function __construct()
34+
{
35+
$paperSize = static::fromFormat(self::PAPER_FORMAT, self::PAPER_ORIENTATION, $this->getUnit(), 0);
36+
$this->pageWidth = $paperSize->width;
37+
$this->pageHeight = $paperSize->height;
38+
39+
$this->pageMarginLeft = Helper::convertUnit(self::COLUMN1_X, 'pt', $this->getUnit());
40+
$this->pageMarginTop = Helper::convertUnit(self::ROW1_Y, 'pt', $this->getUnit());
41+
42+
$columnSpacingPt = self::COLUMN2_X - self::COLUMN1_X - self::LABEL_W;
43+
$this->columnSpacing = Helper::convertUnit($columnSpacingPt, 'pt', $this->getUnit());
44+
$rowSpacingPt = self::ROW2_Y - self::ROW1_Y - self::LABEL_H;
45+
$this->rowSpacing = Helper::convertUnit($rowSpacingPt, 'pt', $this->getUnit());
46+
47+
$this->labelWidth = Helper::convertUnit(self::LABEL_W, 'pt', $this->getUnit());
48+
$this->labelHeight = Helper::convertUnit(self::LABEL_H, 'pt', $this->getUnit());
49+
}
50+
51+
public function getPageWidth()
52+
{
53+
return $this->pageWidth;
54+
}
55+
public function getPageHeight()
56+
{
57+
return $this->pageHeight;
58+
}
59+
60+
public function getPageMarginTop()
61+
{
62+
return $this->pageMarginTop;
63+
}
64+
public function getPageMarginBottom()
65+
{
66+
return $this->pageMarginTop;
67+
}
68+
public function getPageMarginLeft()
69+
{
70+
return $this->pageMarginLeft;
71+
}
72+
public function getPageMarginRight()
73+
{
74+
return $this->pageMarginLeft;
75+
}
76+
77+
public function getColumns()
78+
{
79+
return 4;
80+
}
81+
public function getRows()
82+
{
83+
return 12;
84+
}
85+
86+
public function getLabelColumnSpacing()
87+
{
88+
return $this->columnSpacing;
89+
}
90+
public function getLabelRowSpacing()
91+
{
92+
return $this->rowSpacing;
93+
}
94+
95+
public function getLabelWidth()
96+
{
97+
return $this->labelWidth;
98+
}
99+
public function getLabelHeight()
100+
{
101+
return $this->labelHeight;
102+
}
103+
104+
public function getLabelBorder()
105+
{
106+
return 0;
107+
}
108+
}
109+
110+
?>
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
<?php
2+
3+
namespace App\Models\Labels\Sheets\Avery;
4+
5+
6+
class L4736_A extends L4736
7+
{
8+
private const BARCODE_MARGIN = 1.80;
9+
private const TAG_SIZE = 4.80;
10+
private const TITLE_SIZE = 3.00;
11+
private const TITLE_MARGIN = 1.80;
12+
private const LABEL_SIZE = 2.8;
13+
private const LABEL_MARGIN = - 0.45;
14+
private const FIELD_SIZE = 3.80;
15+
private const FIELD_MARGIN = 0.20;
16+
17+
public function getUnit()
18+
{
19+
return 'mm';
20+
}
21+
22+
public function getLabelMarginTop()
23+
{
24+
return 0.06;
25+
}
26+
public function getLabelMarginBottom()
27+
{
28+
return 0.06;
29+
}
30+
public function getLabelMarginLeft()
31+
{
32+
return 0.06;
33+
}
34+
public function getLabelMarginRight()
35+
{
36+
return 0.06;
37+
}
38+
39+
public function getSupportAssetTag()
40+
{
41+
return true;
42+
}
43+
public function getSupport1DBarcode()
44+
{
45+
return false;
46+
}
47+
public function getSupport2DBarcode()
48+
{
49+
return true;
50+
}
51+
public function getSupportFields()
52+
{
53+
return 4;
54+
}
55+
public function getSupportLogo()
56+
{
57+
return false;
58+
}
59+
public function getSupportTitle()
60+
{
61+
return true;
62+
}
63+
64+
public function preparePDF($pdf)
65+
{
66+
}
67+
68+
public function write($pdf, $record)
69+
{
70+
$pa = $this->getLabelPrintableArea();
71+
72+
$currentX = $pa->x1;
73+
$currentY = $pa->y1;
74+
$usableWidth = $pa->w;
75+
$usableHeight = $pa->h;
76+
77+
if ($record->has('title')) {
78+
static::writeText(
79+
$pdf, $record->get('title'),
80+
$pa->x1, $pa->y1,
81+
'freesans', '', self::TITLE_SIZE, 'C',
82+
$pa->w, self::TITLE_SIZE, true, 0
83+
);
84+
85+
}
86+
$currentY += self::TITLE_SIZE + self::TITLE_MARGIN;
87+
$usableHeight -= self::TITLE_SIZE + self::TITLE_MARGIN;
88+
$barcodeSize = $usableHeight;
89+
if ($record->has('barcode2d')) {
90+
static::write2DBarcode(
91+
$pdf, $record->get('barcode2d')->content, $record->get('barcode2d')->type,
92+
$currentX, $currentY,
93+
$barcodeSize, $barcodeSize
94+
);
95+
$currentX += $barcodeSize + self::BARCODE_MARGIN;
96+
$usableWidth -= $barcodeSize + self::BARCODE_MARGIN;
97+
}
98+
99+
foreach ($record->get('fields') as $field) {
100+
static::writeText(
101+
$pdf, $field['label'],
102+
$currentX, $currentY,
103+
'freesans', '', self::LABEL_SIZE, 'L',
104+
$usableWidth, self::LABEL_SIZE, true, 0
105+
);
106+
$currentY += self::LABEL_SIZE + self::LABEL_MARGIN;
107+
108+
static::writeText(
109+
$pdf, $field['value'],
110+
$currentX, $currentY,
111+
'freemono', 'B', self::FIELD_SIZE, 'L',
112+
$usableWidth, self::FIELD_SIZE, true, 0, 0.01
113+
);
114+
$currentY += self::FIELD_SIZE + self::FIELD_MARGIN;
115+
}
116+
117+
}
118+
}
119+
120+
121+
?>

0 commit comments

Comments
 (0)