Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
contact.php
1<?php
3
5
6class Contact extends Base
7{
8 public function getName()
9 {
10 return $this->fields->get('NAME');
11 }
12
13 public function setName($value)
14 {
15 $this->fields->set('NAME', $value);
16 return $this;
17 }
18
19 public function getLastName()
20 {
21 return $this->fields->get('LAST_NAME');
22 }
23
24 public function setLastName($value)
25 {
26 $this->fields->set('LAST_NAME', $value);
27 return $this;
28 }
29
30 public function getEmail()
31 {
32 return $this->fields->get('EMAIL');
33 }
34
35 public function setEmail($value)
36 {
37 $this->fields->set('EMAIL', $value);
38 return $this;
39 }
40
41 public function getPhone()
42 {
43 return $this->fields->get('PHONE');
44 }
45
46 public function setPhone($value)
47 {
48 $this->fields->set('PHONE', $value);
49 return $this;
50 }
51
52 public function getZip()
53 {
54 return $this->fields->get('ZIP');
55 }
56
57 public function setZip($value)
58 {
59 $this->fields->set('ZIP', $value);
60 return $this;
61 }
62
63 public function getLocation()
64 {
65 return $this->fields->get('LOCATION');
66 }
67
68 public function setLocation($value)
69 {
70 $this->fields->set('LOCATION', $value);
71 return $this;
72 }
73
74 public function getCity()
75 {
76 return $this->fields->get('CITY');
77 }
78
79 public function setCity($value)
80 {
81 $this->fields->set('CITY', $value);
82 return $this;
83 }
84
85 public function getAddress()
86 {
87 return $this->fields->get('ADDRESS');
88 }
89
90 public function setAddress($value)
91 {
92 $this->fields->set('ADDRESS', $value);
93 return $this;
94 }
95
96 static protected function resolveFields(array $list)
97 {
98 $result = [];
99 foreach($list as $item)
100 {
101 $result['ID'] = $item['SALE_INTERNALS_ORDER_USER_ID'];
102
103 if($item['SALE_INTERNALS_ORDER_PROPERTY_CODE'] == 'FIO')
104 {
105 $name = explode(' ', $item['SALE_INTERNALS_ORDER_PROPERTY_VALUE'])[0];
106 $last = explode(' ', $item['SALE_INTERNALS_ORDER_PROPERTY_VALUE'])[1];
107
108 $name = $name<>'' ? $name:$item['SALE_INTERNALS_ORDER_USER_NAME'];
109 $last = $last<>'' ? $last:$item['SALE_INTERNALS_ORDER_USER_LAST_NAME'];
110
111 $name = $name<>'' ? $name:'User №'.$item['SALE_INTERNALS_ORDER_USER_ID'];
112 $last = $last<>'' ? $last:'User №'.$item['SALE_INTERNALS_ORDER_USER_ID'];
113
114 $result['NAME'] = $name;
115 $result['LAST_NAME'] = $last;
116 }
117 else
118 {
119 $result[$item['SALE_INTERNALS_ORDER_PROPERTY_CODE']] = $item['SALE_INTERNALS_ORDER_PROPERTY_VALUE'];
120 }
121 }
122 return $result;
123 }
124
125 public function getType()
126 {
127 return EntityType::TYPE_I;
128 }
129
130 static public function createFromArray(array $fields)
131 {
132 return new static([
133 'ID' => $fields['ID'],
134 'NAME' => $fields['NAME'],
135 'LAST_NAME' => $fields['LAST_NAME'],
136 'EMAIL' => $fields['EMAIL'],
137 'PHONE' => $fields['PHONE'],
138 'ZIP' => $fields['ZIP'],
139 'ADDRESS' => $fields['ADDRESS'],
140 ]);
141 }
142}