|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of riesenia/pohoda package. |
|
5
|
|
|
* |
|
6
|
|
|
* Licensed under the MIT License |
|
7
|
|
|
* (c) RIESENIA.com |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
declare(strict_types=1); |
|
11
|
|
|
|
|
12
|
|
|
namespace Riesenia\Pohoda\StockTransfer; |
|
13
|
|
|
|
|
14
|
|
|
use Riesenia\Pohoda\AbstractAgenda; |
|
15
|
|
|
use Riesenia\Pohoda\Common; |
|
16
|
|
|
use Riesenia\Pohoda\Type; |
|
17
|
|
|
|
|
18
|
|
|
class Header extends AbstractAgenda |
|
19
|
|
|
{ |
|
20
|
|
|
use Common\AddParameterTrait; |
|
21
|
|
|
|
|
22
|
|
|
/** @var string[] */ |
|
23
|
|
|
protected array $refElements = ['number', 'store', 'centreSource', 'centreDestination', 'activity', 'contract']; |
|
24
|
|
|
|
|
25
|
|
|
/** @var string[] */ |
|
26
|
|
|
protected array $elements = ['number', 'date', 'time', 'dateOfReceipt', 'timeOfReceipt', 'symPar', 'store', 'text', 'partnerIdentity', 'centreSource', 'centreDestination', 'activity', 'contract', 'note', 'intNote']; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* {@inheritdoc} |
|
30
|
|
|
*/ |
|
31
|
4 |
|
public function setData(array $data): parent |
|
32
|
|
|
{ |
|
33
|
|
|
// process partner identity |
|
34
|
4 |
|
if (isset($data['partnerIdentity'])) { |
|
35
|
4 |
|
$partnerIdentity = new Type\Address($this->namespacesPaths, $this->sanitizeEncoding, $this->companyRegistrationNumber, $this->resolveOptions, $this->normalizerFactory); |
|
36
|
4 |
|
$data['partnerIdentity'] = $partnerIdentity->setDirectionalVariable($this->useOneDirectionalVariables)->setData($data['partnerIdentity']); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
4 |
|
return parent::setData($data); |
|
|
|
|
|
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* {@inheritdoc} |
|
44
|
|
|
*/ |
|
45
|
3 |
|
public function getXML(): \SimpleXMLElement |
|
46
|
|
|
{ |
|
47
|
3 |
|
$xml = $this->createXML()->addChild('pre:prevodkaHeader', '', $this->namespace('pre')); |
|
48
|
|
|
|
|
49
|
3 |
|
$this->addElements($xml, \array_merge($this->elements, ['parameters']), 'pre'); |
|
50
|
|
|
|
|
51
|
3 |
|
return $xml; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* {@inheritdoc} |
|
56
|
|
|
*/ |
|
57
|
1 |
|
protected function configureOptions(Common\OptionsResolver $resolver): void |
|
58
|
|
|
{ |
|
59
|
|
|
// available options |
|
60
|
1 |
|
$resolver->setDefined($this->elements); |
|
61
|
|
|
|
|
62
|
|
|
// validate / format options |
|
63
|
1 |
|
$resolver->setNormalizer('date', $this->normalizerFactory->getClosure('date')); |
|
64
|
1 |
|
$resolver->setNormalizer('time', $this->normalizerFactory->getClosure('time')); |
|
65
|
1 |
|
$resolver->setNormalizer('dateOfReceipt', $this->normalizerFactory->getClosure('date')); |
|
66
|
1 |
|
$resolver->setNormalizer('timeOfReceipt', $this->normalizerFactory->getClosure('time')); |
|
67
|
1 |
|
$resolver->setNormalizer('symPar', $this->normalizerFactory->getClosure('string20')); |
|
68
|
1 |
|
$resolver->setNormalizer('text', $this->normalizerFactory->getClosure('string48')); |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|