1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Sprain\SwissQrBill\PaymentPart\Output\PhpWordOutput\Table; |
4
|
|
|
|
5
|
|
|
use PhpOffice\PhpWord\Element\Cell; |
6
|
|
|
use Sprain\SwissQrBill\PaymentPart\Output\PhpWordOutput\PhpWordHelper; |
7
|
|
|
use Sprain\SwissQrBill\PaymentPart\Output\PhpWordOutput\Table\Receipt\AmountSection; |
8
|
|
|
use PhpOffice\PhpWord\Element\Table; |
9
|
|
|
|
10
|
|
|
class Payment |
11
|
|
|
{ |
12
|
|
|
private Table $table; |
13
|
|
|
private Cell $titleSection; |
14
|
|
|
private Cell $qrCodeSection; |
15
|
|
|
private AmountSection $amountSection; |
16
|
|
|
private Cell $informationSection; |
17
|
|
|
private Cell $furtherInformationSection; |
18
|
|
|
|
19
|
|
|
public function __construct(Cell $cell) |
20
|
|
|
{ |
21
|
|
|
$this->table = $cell->addTable([ |
22
|
|
|
'layout' => \PhpOffice\PhpWord\Style\Table::LAYOUT_FIXED, |
23
|
|
|
'width' => PhpWordHelper::percentToPct(100), |
24
|
|
|
'unit' => 'pct', |
25
|
|
|
]); |
26
|
|
|
$this->table->getStyle()->setLayout(\PhpOffice\PhpWord\Style\Table::LAYOUT_FIXED); |
27
|
|
|
|
28
|
|
|
$row = $this->table->addRow(PhpWordHelper::mmToTwip(Style::PAYMENT_PART_INFORMATION_SECTION_HEIGHT)); |
|
|
|
|
29
|
|
|
$paymentPartLeftCell = $row->addCell(PhpWordHelper::mmToTwip(Style::PAYMENT_PART_INNER_WIDTH - Style::PAYMENT_PART_INFORMATION_SECTION_WIDTH)); |
|
|
|
|
30
|
|
|
$this->informationSection = $row->addCell(PhpWordHelper::mmToTwip(Style::PAYMENT_PART_INFORMATION_SECTION_WIDTH)); |
31
|
|
|
|
32
|
|
|
$table = $paymentPartLeftCell->addTable([ |
33
|
|
|
'layout' => \PhpOffice\PhpWord\Style\Table::LAYOUT_FIXED, |
34
|
|
|
'width' => PhpWordHelper::percentToPct(100), |
35
|
|
|
'unit' => 'pct', |
36
|
|
|
]); |
37
|
|
|
$row = $table->addRow(PhpWordHelper::mmToTwip(Style::TITLE_SECTION_HEIGHT)); |
38
|
|
|
$this->titleSection = $row->addCell(); |
39
|
|
|
$this->addSpacerBeforeQrCode($table); |
40
|
|
|
$row = $table->addRow(PhpWordHelper::mmToTwip(Style::QR_CODE_SIZE_WITH_BOTTOM_SPACE)); |
41
|
|
|
$this->qrCodeSection = $row->addCell(); |
42
|
|
|
$row = $table->addRow(PhpWordHelper::mmToTwip(Style::PAYMENT_PART_AMOUNT_SECTION_HEIGHT)); |
43
|
|
|
$this->amountSection = new AmountSection( |
44
|
|
|
$row->addCell(), |
45
|
|
|
Style::PAYMENT_PART_CURRENCY_WIDTH, |
46
|
|
|
Style::PAYMENT_PART_AMOUNT_WIDTH, |
47
|
|
|
Style::PAYMENT_PART_AMOUNT_SECTION_HEIGHT |
48
|
|
|
); |
49
|
|
|
|
50
|
|
|
$row = $this->table->addRow(PhpWordHelper::mmToTwip(Style::PAYMENT_PART_FURTHER_INFORMATION_SECTION_HEIGHT)); |
51
|
|
|
$this->furtherInformationSection = $row->addCell(null, ['gridSpan' => 2]); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function getTitleSection() : Cell |
55
|
|
|
{ |
56
|
|
|
return $this->titleSection; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function getQrCodeSection() : Cell |
60
|
|
|
{ |
61
|
|
|
return $this->qrCodeSection; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function getAmountSection() : AmountSection |
65
|
|
|
{ |
66
|
|
|
return $this->amountSection; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function getInformationSection() : Cell |
70
|
|
|
{ |
71
|
|
|
return $this->informationSection; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function getFurtherInformationSection() : Cell |
75
|
|
|
{ |
76
|
|
|
return $this->furtherInformationSection; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
private function addSpacerBeforeQrCode(Table $table) : void |
80
|
|
|
{ |
81
|
|
|
$fontSizeMustBeSmallThanRowHeight = 7; |
82
|
|
|
$table->addRow(PhpWordHelper::mmToTwip(5))->addCell()->addText('', ['size' => $fontSizeMustBeSmallThanRowHeight], ['spaceAfter' => 0]); |
|
|
|
|
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|