|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of riesenia/pohoda package. |
|
4
|
|
|
* |
|
5
|
|
|
* Licensed under the MIT License |
|
6
|
|
|
* (c) RIESENIA.com |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
declare(strict_types=1); |
|
10
|
|
|
|
|
11
|
|
|
namespace Riesenia\Pohoda\AddressBook; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
use Riesenia\Pohoda\AbstractAgenda; |
|
15
|
|
|
use Riesenia\Pohoda\Common; |
|
16
|
|
|
use Riesenia\Pohoda\Type\Address; |
|
17
|
|
|
use Riesenia\Pohoda\ValueTransformer\SanitizeEncoding; |
|
18
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
class Header extends AbstractAgenda |
|
21
|
|
|
{ |
|
22
|
|
|
use Common\AddParameterTrait; |
|
23
|
|
|
|
|
24
|
|
|
/** @var string[] */ |
|
25
|
|
|
protected array $refElements = ['paymentType', 'centre', 'activity', 'contract', 'number', 'accountingReceivedInvoice', 'accountingIssuedInvoice', 'classificationVATReceivedInvoice', 'classificationVATIssuedInvoice', 'classificationKVDPHReceivedInvoice', 'classificationKVDPHIssuedInvoice', 'accountForInvoicing', 'foreignCurrency']; |
|
26
|
|
|
|
|
27
|
|
|
/** @var string[] */ |
|
28
|
|
|
protected array $elements = ['identity', 'region', 'phone', 'mobil', 'fax', 'email', 'web', 'ICQ', 'Skype', 'GPS', 'credit', 'priceIDS', 'maturity', 'maturityCommitments', 'paymentType', 'agreement', 'number', 'ost1', 'ost2', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'markRecord', 'message', 'note', 'intNote', 'accountingReceivedInvoice', 'accountingIssuedInvoice', 'classificationVATReceivedInvoice', 'classificationVATIssuedInvoice', 'classificationKVDPHReceivedInvoice', 'classificationKVDPHIssuedInvoice', 'accountForInvoicing', 'foreignCurrency', 'centre', 'activity', 'contract', 'adGroup']; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* {@inheritdoc} |
|
32
|
|
|
*/ |
|
33
|
6 |
|
public function __construct( |
|
34
|
|
|
Common\NamespacesPaths $namespacesPaths, |
|
35
|
|
|
SanitizeEncoding $sanitizeEncoding, |
|
36
|
|
|
array $data, |
|
37
|
|
|
string $companyRegistrationNumber, |
|
38
|
|
|
bool $resolveOptions = true, |
|
39
|
|
|
) |
|
40
|
|
|
{ |
|
41
|
|
|
// process identity |
|
42
|
6 |
|
if (isset($data['identity'])) { |
|
43
|
6 |
|
$data['identity'] = new Address($namespacesPaths, $sanitizeEncoding, $data['identity'], $companyRegistrationNumber, $resolveOptions); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
6 |
|
parent::__construct($namespacesPaths, $sanitizeEncoding, $data, $companyRegistrationNumber, $resolveOptions); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* {@inheritdoc} |
|
51
|
|
|
*/ |
|
52
|
5 |
|
public function getXML(): \SimpleXMLElement |
|
53
|
|
|
{ |
|
54
|
5 |
|
$xml = $this->createXML()->addChild('adb:addressbookHeader', '', $this->namespace('adb')); |
|
55
|
|
|
|
|
56
|
5 |
|
$this->addElements($xml, \array_merge($this->elements, ['parameters']), 'adb'); |
|
57
|
|
|
|
|
58
|
5 |
|
return $xml; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* {@inheritdoc} |
|
63
|
|
|
*/ |
|
64
|
1 |
|
protected function configureOptions(Common\OptionsResolver $resolver): void |
|
65
|
|
|
{ |
|
66
|
|
|
// available options |
|
67
|
1 |
|
$resolver->setDefined($this->elements); |
|
68
|
|
|
|
|
69
|
|
|
// validate / format options |
|
70
|
1 |
|
$resolver->setNormalizer('region', $this->normalizerFactory->getClosure('string32')); |
|
71
|
1 |
|
$resolver->setNormalizer('phone', $this->normalizerFactory->getClosure('string40')); |
|
72
|
1 |
|
$resolver->setNormalizer('mobil', $this->normalizerFactory->getClosure('string24')); |
|
73
|
1 |
|
$resolver->setNormalizer('fax', $this->normalizerFactory->getClosure('string24')); |
|
74
|
1 |
|
$resolver->setNormalizer('email', $this->normalizerFactory->getClosure('string98')); |
|
75
|
1 |
|
$resolver->setNormalizer('web', $this->normalizerFactory->getClosure('string32')); |
|
76
|
1 |
|
$resolver->setNormalizer('ICQ', $this->normalizerFactory->getClosure('string12')); |
|
77
|
1 |
|
$resolver->setNormalizer('Skype', $this->normalizerFactory->getClosure('string32')); |
|
78
|
1 |
|
$resolver->setNormalizer('GPS', $this->normalizerFactory->getClosure('string38')); |
|
79
|
1 |
|
$resolver->setNormalizer('credit', $this->normalizerFactory->getClosure('float')); |
|
80
|
1 |
|
$resolver->setNormalizer('priceIDS', $this->normalizerFactory->getClosure('string10')); |
|
81
|
1 |
|
$resolver->setNormalizer('maturity', $this->normalizerFactory->getClosure('int')); |
|
82
|
1 |
|
$resolver->setNormalizer('agreement', $this->normalizerFactory->getClosure('string12')); |
|
83
|
1 |
|
$resolver->setNormalizer('ost1', $this->normalizerFactory->getClosure('string8')); |
|
84
|
1 |
|
$resolver->setNormalizer('ost2', $this->normalizerFactory->getClosure('string8')); |
|
85
|
1 |
|
$resolver->setNormalizer('p1', $this->normalizerFactory->getClosure('bool')); |
|
86
|
1 |
|
$resolver->setNormalizer('p2', $this->normalizerFactory->getClosure('bool')); |
|
87
|
1 |
|
$resolver->setNormalizer('p3', $this->normalizerFactory->getClosure('bool')); |
|
88
|
1 |
|
$resolver->setNormalizer('p4', $this->normalizerFactory->getClosure('bool')); |
|
89
|
1 |
|
$resolver->setNormalizer('p5', $this->normalizerFactory->getClosure('bool')); |
|
90
|
1 |
|
$resolver->setNormalizer('p6', $this->normalizerFactory->getClosure('bool')); |
|
91
|
1 |
|
$resolver->setNormalizer('markRecord', $this->normalizerFactory->getClosure('bool')); |
|
92
|
1 |
|
$resolver->setNormalizer('message', $this->normalizerFactory->getClosure('string64')); |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|