1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the skidata-library package. |
5
|
|
|
* |
6
|
|
|
* (c) 2017 WEBEWEB |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace WBW\Library\SkiData\Parser; |
13
|
|
|
|
14
|
|
|
use WBW\Library\Core\Helper\Argument\BooleanHelper; |
15
|
|
|
use WBW\Library\SkiData\Entity\SkiDataCustomer; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* SkiData customer parser. |
19
|
|
|
* |
20
|
|
|
* @author webeweb <https://github.com/webeweb/> |
21
|
|
|
* @package WBW\Library\SkiData\Parser |
22
|
|
|
*/ |
23
|
|
|
class SkiDataCustomerParser extends AbstractSkiDataParser { |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Constructor. |
27
|
|
|
*/ |
28
|
|
|
public function __construct() { |
29
|
|
|
parent::__construct(); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Parse a SkiData customer entity. |
34
|
|
|
* |
35
|
|
|
* @param SkiDataCustomer $entity The SkiData customer entity. |
36
|
|
|
* @return string Returns the parsed SkiData customer entity. |
37
|
|
|
*/ |
38
|
|
|
public function parseEntity(SkiDataCustomer $entity) { |
39
|
|
|
|
40
|
|
|
// Initialise the output. |
41
|
|
|
$output = []; |
42
|
|
|
|
43
|
|
|
$output[] = $this->encodeInteger($entity->getCustomerNumber(), 9); |
44
|
|
|
$output[] = $this->encodeString($entity->getTitle(), 10); |
45
|
|
|
$output[] = $this->encodeString($entity->getSurname(), 25); |
46
|
|
|
$output[] = $this->encodeString($entity->getFirstname(), 25); |
47
|
|
|
$output[] = $this->encodeString($entity->getStreet(), 25); |
48
|
|
|
$output[] = $this->encodeString($entity->getPCode(), 10); |
49
|
|
|
$output[] = $this->encodeString($entity->getCity(), 25); |
50
|
|
|
$output[] = $this->encodeString($entity->getCountry(), 3); |
51
|
|
|
$output[] = $this->encodeString($entity->getTaxCode(), 16); |
52
|
|
|
$output[] = $this->encodeString($entity->getIdDocumentNo(), 15); |
53
|
|
|
$output[] = $this->encodeString($entity->getTelephone(), 20); |
54
|
|
|
$output[] = $this->encodeString($entity->getRentalAgreementNo(), 20); |
55
|
|
|
$output[] = $this->encodeDate($entity->getBeginDate()); |
56
|
|
|
$output[] = $this->encodeDate($entity->getTerminationDate()); |
57
|
|
|
$output[] = $this->encodeInteger($entity->getDeposit(), 12); |
58
|
|
|
$output[] = $this->encodeInteger($entity->getMaximumLevel(), 4); |
59
|
|
|
$output[] = $this->encodeString($entity->getRemarks(), 50); |
60
|
|
|
$output[] = $this->encodeDateTime($entity->getDatetimeLastModification()); |
61
|
|
|
$output[] = $this->encodeBoolean($entity->getBlocked()); |
62
|
|
|
$output[] = $this->encodeDate($entity->getBlockedDate()); |
63
|
|
|
$output[] = $this->encodeBoolean($entity->getDeletedRecord()); |
64
|
|
|
$output[] = $this->encodeBoolean($entity->getTicketReturnAllowed()); |
65
|
|
|
$output[] = $this->encodeBoolean($entity->getGroupCounting()); |
66
|
|
|
$output[] = $this->encodeBoolean($entity->getEntryMaxLevelAllowed()); |
67
|
|
|
$output[] = $this->encodeBoolean($entity->getMaxLevelCarPark()); |
68
|
|
|
$output[] = $this->encodeString($entity->getRemarks2(), 50); |
69
|
|
|
$output[] = $this->encodeString($entity->getRemarks3(), 50); |
70
|
|
|
$output[] = $this->encodeString($entity->getDivision(), 25); |
71
|
|
|
$output[] = $this->encodeString($entity->getEmail(), 120); |
72
|
|
|
$output[] = $this->encodeBoolean($entity->getCountingNeutralCards()); |
73
|
|
|
$output[] = $this->encodeString($entity->getNationality(), 3); |
74
|
|
|
$output[] = $this->encodeString($entity->getAccountingNumber(), 20); |
75
|
|
|
|
76
|
|
|
// Return the output. |
77
|
|
|
return implode(";", $output); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Parse a line. |
82
|
|
|
* |
83
|
|
|
* @param string $line The line. |
84
|
|
|
* @return SkiDataCustomer Returns a SkiData customer entity. |
85
|
|
|
*/ |
86
|
|
|
public function parseLine($line) { |
87
|
|
|
|
88
|
|
|
// Split the line. |
89
|
|
|
$data = explode(";", $line); |
90
|
|
|
$i = 0; |
91
|
|
|
|
92
|
|
|
// Initialize the entity. |
93
|
|
|
$entity = new SkiDataCustomer(); |
94
|
|
|
|
95
|
|
|
$entity->setCustomerNumber($this->decodeInteger($data[$i++])); |
96
|
|
|
$entity->setTitle($this->decodeString($data[$i++])); |
97
|
|
|
$entity->setSurname($this->decodeString($data[$i++])); |
98
|
|
|
$entity->setFirstname($this->decodeString($data[$i++])); |
99
|
|
|
$entity->setStreet($this->decodeString($data[$i++])); |
100
|
|
|
$entity->setPCode($this->decodeString($data[$i++])); |
101
|
|
|
$entity->setCity($this->decodeString($data[$i++])); |
102
|
|
|
$entity->setCountry($this->decodeString($data[$i++])); |
103
|
|
|
$entity->setTaxCode($this->decodeString($data[$i++])); |
104
|
|
|
$entity->setIdDocumentNo($this->decodeString($data[$i++])); |
105
|
|
|
$entity->setTelephone($this->decodeString($data[$i++])); |
106
|
|
|
$entity->setRentalAgreementNo($this->decodeString($data[$i++])); |
107
|
|
|
$entity->setBeginDate($this->decodeDate($data[$i++])); |
108
|
|
|
$entity->setTerminationDate($this->decodeDate($data[$i++])); |
109
|
|
|
$entity->setDeposit($this->decodeInteger($data[$i++])); |
110
|
|
|
$entity->setMaximumLevel($this->decodeInteger($data[$i++])); |
111
|
|
|
$entity->setRemarks($this->decodeString($data[$i++])); |
112
|
|
|
$entity->setDatetimeLastModification($this->decodeDateTime($data[$i++])); |
113
|
|
|
$entity->setBlocked(BooleanHelper::parseString($data[$i++])); |
114
|
|
|
$entity->setBlockedDate($this->decodeDate($data[$i++])); |
115
|
|
|
$entity->setDeletedRecord(BooleanHelper::parseString($data[$i++])); |
116
|
|
|
$entity->setTicketReturnAllowed(BooleanHelper::parseString($data[$i++])); |
117
|
|
|
$entity->setGroupCounting(BooleanHelper::parseString($data[$i++])); |
118
|
|
|
$entity->setEntryMaxLevelAllowed(BooleanHelper::parseString($data[$i++])); |
119
|
|
|
$entity->setMaxLevelCarPark(BooleanHelper::parseString($data[$i++])); |
120
|
|
|
$entity->setRemarks2($this->decodeString($data[$i++])); |
121
|
|
|
$entity->setRemarks3($this->decodeString($data[$i++])); |
122
|
|
|
$entity->setDivision($this->decodeString($data[$i++])); |
123
|
|
|
$entity->setEmail($this->decodeString($data[$i++])); |
124
|
|
|
$entity->setCountingNeutralCards(BooleanHelper::parseString($data[$i++])); |
125
|
|
|
$entity->setNationality($this->decodeString($data[$i++])); |
126
|
|
|
$entity->setAccountingNumber($this->decodeString($data[$i++])); |
127
|
|
|
|
128
|
|
|
// Return the entity. |
129
|
|
|
return $entity; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
} |
133
|
|
|
|