1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* FlexiPeeHP - Objekt adresáře. |
4
|
|
|
* |
5
|
|
|
* @author Vítězslav Dvořák <[email protected]> |
6
|
|
|
* @copyright (C) 2015-2017 Spoje.Net |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace FlexiPeeHP; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Adresář |
13
|
|
|
* |
14
|
|
|
* @link https://demo.flexibee.eu/c/demo/adresar/properties položky evidence |
15
|
|
|
*/ |
16
|
|
|
class Adresar extends FlexiBeeRW |
17
|
|
|
{ |
18
|
|
|
use Stitky; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Evidence užitá objektem. |
22
|
|
|
* |
23
|
|
|
* @var string |
24
|
|
|
*/ |
25
|
|
|
public $evidence = 'adresar'; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* get Email address for Customer with primary contact prefered |
29
|
|
|
* |
30
|
|
|
* @return string email of primary contact or address email or null |
31
|
|
|
*/ |
32
|
|
|
public function getNotificationEmailAddress() |
33
|
|
|
{ |
34
|
|
|
$email = null; |
35
|
|
|
$emailsRaw = $this->getFlexiData($this->getApiURL(), |
36
|
|
|
['detail' => 'custom:id,email,kontakty(primarni,email)', 'relations' => 'kontakty']); |
37
|
|
|
if (is_array($emailsRaw) && !empty($emailsRaw[0])) { |
38
|
|
|
$emails = $emailsRaw[0]; |
39
|
|
|
if (array_key_exists('email', $emails) && strlen(trim($emails['email']))) { |
40
|
|
|
$email = $emails['email']; |
41
|
|
|
} |
42
|
|
|
if (array_key_exists('kontakty', $emails) && !empty($emails['kontakty'])) { |
43
|
|
|
foreach ($emails['kontakty'] as $kontakt) { |
44
|
|
|
if (($kontakt['primarni'] == 'true') && strlen(trim($kontakt['email']))) { |
45
|
|
|
$email = $kontakt['email']; |
46
|
|
|
break; |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
return $email; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* get cell phone Number for Customer with primary contact prefered |
56
|
|
|
* |
57
|
|
|
* @return string cell phone number of primary contact or address cell number or null |
58
|
|
|
*/ |
59
|
|
|
public function getCellPhoneNumber() |
60
|
|
|
{ |
61
|
|
|
$mobil = null; |
62
|
|
|
$mobilsRaw = $this->getFlexiData($this->getApiURL(), |
63
|
|
|
['detail' => 'custom:id,mobil,kontakty(primarni,mobil)', 'relations' => 'kontakty']); |
64
|
|
|
if (is_array($mobilsRaw)) { |
|
|
|
|
65
|
|
|
$mobils = $mobilsRaw[0]; |
66
|
|
|
if (array_key_exists('mobil', $mobils) && strlen(trim($mobils['mobil']))) { |
67
|
|
|
$mobil = $mobils['mobil']; |
68
|
|
|
} |
69
|
|
|
if (array_key_exists('kontakty', $mobils) && !empty($mobils['kontakty'])) { |
70
|
|
|
foreach ($mobils['kontakty'] as $kontakt) { |
71
|
|
|
if (($kontakt['primarni'] == 'true') && strlen(trim($kontakt['mobil']))) { |
72
|
|
|
$mobil = $kontakt['mobil']; |
73
|
|
|
break; |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
return $mobil; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* get any phone Number for Customer with primary contact prefered |
83
|
|
|
* |
84
|
|
|
* @return string phone number of primary contact or address's phone number or null |
85
|
|
|
*/ |
86
|
|
|
public function getAnyPhoneNumber() |
87
|
|
|
{ |
88
|
|
|
$phoneNo = null; |
89
|
|
|
$numbersRaw = $this->getFlexiData($this->getApiURL(), |
90
|
|
|
['detail' => 'custom:id,mobil,tel,kontakty(primarni,mobil,tel)', 'relations' => 'kontakty']); |
91
|
|
|
if (is_array($numbersRaw) && !empty($numbersRaw[0])) { |
92
|
|
|
$numbers = $numbersRaw[0]; |
93
|
|
|
if (array_key_exists('mobil', $numbers) && strlen(trim($numbers['mobil']))) { |
94
|
|
|
$phoneNo = $numbers['mobil']; |
95
|
|
|
} |
96
|
|
|
if (array_key_exists('tel', $numbers) && strlen(trim($numbers['tel']))) { |
97
|
|
|
$phoneNo = $numbers['tel']; |
98
|
|
|
} |
99
|
|
|
if (array_key_exists('kontakty', $numbers) && !empty($numbers['kontakty'])) { |
100
|
|
|
foreach ($numbers['kontakty'] as $kontakt) { |
101
|
|
|
if ($kontakt['primarni'] == 'true') { |
|
|
|
|
102
|
|
|
|
103
|
|
|
} |
104
|
|
|
if (strlen(trim($kontakt['mobil']))) { |
105
|
|
|
$phoneNo = $kontakt['mobil']; |
106
|
|
|
break; |
107
|
|
|
} elseif (strlen(trim($kontakt['mobil']))) { |
108
|
|
|
$phoneNo = $kontakt['mobil']; |
109
|
|
|
break; |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
return $phoneNo; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* |
120
|
|
|
* |
121
|
|
|
* @param Adresar|string|int $address |
122
|
|
|
* |
123
|
|
|
* @return array bank account details |
124
|
|
|
*/ |
125
|
|
|
public function getBankAccountNumber($address = null) |
126
|
|
|
{ |
127
|
|
|
if (is_null($address)) { |
128
|
|
|
$address = $this->getMyKey(); |
129
|
|
|
} |
130
|
|
|
$bucRaw = $this->getColumnsFromFlexibee(['buc', 'smerKod'], ['firma'=> $address ,'evidence' => 'adresar-bankovni-ucet']); |
131
|
|
|
return (!empty($bucRaw) && array_key_exists(0, $bucRaw)) ? $bucRaw : []; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
} |
135
|
|
|
|