Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
48 / 48 |
|
100.00% |
6 / 6 |
CRAP | |
100.00% |
1 / 1 |
Organisation | |
100.00% |
48 / 48 |
|
100.00% |
6 / 6 |
10 | |
100.00% |
1 / 1 |
getEntityMapping | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
1 | |||
addConditionOrganisationId | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
addConditionOwnerId | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
addConditionScopeId | |
100.00% |
14 / 14 |
|
100.00% |
1 / 1 |
1 | |||
addConditionDepartmentId | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |||
reverseEntityMapping | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
5 |
1 | <?php |
2 | |
3 | namespace BO\Zmsdb\Query; |
4 | |
5 | class Organisation extends Base implements MappingInterface |
6 | { |
7 | /** |
8 | * @var String TABLE mysql table reference |
9 | */ |
10 | const TABLE = 'organisation'; |
11 | |
12 | public function getEntityMapping() |
13 | { |
14 | return [ |
15 | 'contact__city' => self::expression( |
16 | 'TRIM(" " FROM SUBSTRING_INDEX(`organisation`.`Anschrift`, " ", -1))' |
17 | ), |
18 | 'contact__street' => 'organisation.Anschrift', |
19 | /* |
20 | 'contact__streetNumber' => self::expression( |
21 | 'TRIM("," FROM SUBSTRING_INDEX(SUBSTRING_INDEX(`organisation`.`Anschrift`, ",", 1), " ", -1))' |
22 | ), |
23 | 'contact__postalCode' => self::expression( |
24 | 'TRIM(" " FROM SUBSTRING_INDEX(SUBSTRING_INDEX(`organisation`.`Anschrift`, " ", -2), " ", 1))' |
25 | ), |
26 | 'contact__region' => self::expression( |
27 | 'TRIM(" " FROM SUBSTRING_INDEX(`organisation`.`Anschrift`, " ", -1))' |
28 | ), |
29 | */ |
30 | 'contact__country' => self::expression('"Germany"'), |
31 | 'contact__name' => 'organisation.Organisationsname', |
32 | 'name' => 'organisation.Organisationsname', |
33 | 'id' => 'organisation.OrganisationsID', |
34 | 'preferences__ticketPrinterProtectionEnabled' => 'organisation.kioskpasswortschutz' |
35 | ]; |
36 | } |
37 | |
38 | public function addConditionOrganisationId($organisationId) |
39 | { |
40 | $this->query->where('organisation.OrganisationsID', '=', $organisationId); |
41 | return $this; |
42 | } |
43 | |
44 | public function addConditionOwnerId($ownerId) |
45 | { |
46 | $this->query->where('organisation.KundenID', '=', $ownerId); |
47 | return $this; |
48 | } |
49 | |
50 | public function addConditionScopeId($scopeId) |
51 | { |
52 | $this->leftJoin( |
53 | new Alias('behoerde', 'department'), |
54 | 'department.OrganisationsID', |
55 | '=', |
56 | 'organisation.OrganisationsID' |
57 | ); |
58 | $this->leftJoin( |
59 | new Alias('standort', 'scope'), |
60 | 'scope.BehoerdenID', |
61 | '=', |
62 | 'department.BehoerdenID' |
63 | ); |
64 | $this->query->where('scope.StandortID', '=', $scopeId); |
65 | return $this; |
66 | } |
67 | |
68 | public function addConditionDepartmentId($departmentId) |
69 | { |
70 | $this->leftJoin( |
71 | new Alias('behoerde', 'department'), |
72 | 'department.OrganisationsID', |
73 | '=', |
74 | 'organisation.OrganisationsID' |
75 | ); |
76 | $this->query->where('department.BehoerdenID', '=', $departmentId); |
77 | return $this; |
78 | } |
79 | |
80 | public function reverseEntityMapping(\BO\Zmsentities\Organisation $entity, $parentId = null) |
81 | { |
82 | $data = array(); |
83 | if (null !== $parentId) { |
84 | $data['KundenID'] = $parentId; |
85 | } |
86 | $data['Organisationsname'] = $entity->name; |
87 | $data['InfoBezirkID'] = 14; |
88 | $data['Anschrift'] = (isset($entity->contact['street'])) ? $entity->contact['street'] : ''; |
89 | $data['kioskpasswortschutz'] = ($entity->getPreference('ticketPrinterProtectionEnabled')) ? 1 : 0; |
90 | $data = array_filter($data, function ($value) { |
91 | return ($value !== null && $value !== false); |
92 | }); |
93 | return $data; |
94 | } |
95 | } |