Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
29 / 29 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
| Owner | |
100.00% |
29 / 29 |
|
100.00% |
4 / 4 |
5 | |
100.00% |
1 / 1 |
| getEntityMapping | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
1 | |||
| addConditionOrganisationId | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |||
| addConditionOwnerId | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| reverseEntityMapping | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace BO\Zmsdb\Query; |
| 4 | |
| 5 | class Owner extends Base implements MappingInterface |
| 6 | { |
| 7 | /** |
| 8 | * @var String TABLE mysql table reference |
| 9 | */ |
| 10 | const TABLE = 'kunde'; |
| 11 | |
| 12 | public function getEntityMapping() |
| 13 | { |
| 14 | return [ |
| 15 | 'contact__city' => self::expression( |
| 16 | 'TRIM(" " FROM SUBSTRING_INDEX(`owner`.`Anschrift`, " ", -1))' |
| 17 | ), |
| 18 | 'contact__street' => 'owner.Anschrift', |
| 19 | /* |
| 20 | 'contact__streetNumber' => self::expression( |
| 21 | 'TRIM("," FROM SUBSTRING_INDEX(SUBSTRING_INDEX(`owner`.`Anschrift`, ",", 1), " ", -1))' |
| 22 | ), |
| 23 | 'contact__postalCode' => self::expression( |
| 24 | 'TRIM(" " FROM SUBSTRING_INDEX(SUBSTRING_INDEX(`owner`.`Anschrift`, " ", -2), " ", 1))' |
| 25 | ), |
| 26 | 'contact__region' => self::expression( |
| 27 | 'TRIM(" " FROM SUBSTRING_INDEX(`owner`.`Anschrift`, " ", -1))' |
| 28 | ), |
| 29 | */ |
| 30 | 'contact__country' => self::expression('"Germany"'), |
| 31 | 'contact__name' => 'owner.Kundenname', |
| 32 | 'id' => 'owner.KundenID', |
| 33 | 'name' => 'owner.Kundenname', |
| 34 | 'url' => 'owner.TerminURL' |
| 35 | ]; |
| 36 | } |
| 37 | |
| 38 | public function addConditionOrganisationId($organisationId) |
| 39 | { |
| 40 | //error_log(var_export($isNotAssigned,1)); |
| 41 | $this->leftJoin( |
| 42 | new Alias(Organisation::TABLE, 'ownerorganisation'), |
| 43 | 'owner.KundenID', |
| 44 | '=', |
| 45 | 'ownerorganisation.KundenID' |
| 46 | ); |
| 47 | $this->query->where('ownerorganisation.OrganisationsID', '=', $organisationId); |
| 48 | return $this; |
| 49 | } |
| 50 | |
| 51 | public function addConditionOwnerId($ownerId) |
| 52 | { |
| 53 | $this->query->where('owner.KundenID', '=', $ownerId); |
| 54 | return $this; |
| 55 | } |
| 56 | |
| 57 | public function reverseEntityMapping(\BO\Zmsentities\Owner $entity) |
| 58 | { |
| 59 | $data = array(); |
| 60 | $data['Anschrift'] = $entity->contact['street']; |
| 61 | $data['Kundenname'] = $entity->name; |
| 62 | $data['TerminUrl'] = $entity->url; |
| 63 | $data = array_filter($data, function ($value) { |
| 64 | return ($value !== null && $value !== false); |
| 65 | }); |
| 66 | return $data; |
| 67 | } |
| 68 | } |