Merge pull request #17458 from eileenmcnaughton/export
[civicrm-core.git] / CRM / Core / DAO / Phone.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/Phone.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:3c1f1743128af72b009c6cf4effc1da2)
10 */
11
12 /**
13 * Database access object for the Phone entity.
14 */
15 class CRM_Core_DAO_Phone extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 public static $_tableName = 'civicrm_phone';
23
24 /**
25 * Icon associated with this entity.
26 *
27 * @var string
28 */
29 public static $_icon = 'fa-phone';
30
31 /**
32 * Should CiviCRM log any modifications to this table in the civicrm_log table.
33 *
34 * @var bool
35 */
36 public static $_log = TRUE;
37
38 /**
39 * Unique Phone ID
40 *
41 * @var int
42 */
43 public $id;
44
45 /**
46 * FK to Contact ID
47 *
48 * @var int
49 */
50 public $contact_id;
51
52 /**
53 * Which Location does this phone belong to.
54 *
55 * @var int
56 */
57 public $location_type_id;
58
59 /**
60 * Is this the primary phone for this contact and location.
61 *
62 * @var bool
63 */
64 public $is_primary;
65
66 /**
67 * Is this the billing?
68 *
69 * @var bool
70 */
71 public $is_billing;
72
73 /**
74 * Which Mobile Provider does this phone belong to.
75 *
76 * @var int
77 */
78 public $mobile_provider_id;
79
80 /**
81 * Complete phone number.
82 *
83 * @var string
84 */
85 public $phone;
86
87 /**
88 * Optional extension for a phone number.
89 *
90 * @var string
91 */
92 public $phone_ext;
93
94 /**
95 * Phone number stripped of all whitespace, letters, and punctuation.
96 *
97 * @var string
98 */
99 public $phone_numeric;
100
101 /**
102 * Which type of phone does this number belongs.
103 *
104 * @var int
105 */
106 public $phone_type_id;
107
108 /**
109 * Class constructor.
110 */
111 public function __construct() {
112 $this->__table = 'civicrm_phone';
113 parent::__construct();
114 }
115
116 /**
117 * Returns localized title of this entity.
118 */
119 public static function getEntityTitle() {
120 return ts('Phones');
121 }
122
123 /**
124 * Returns foreign keys and entity references.
125 *
126 * @return array
127 * [CRM_Core_Reference_Interface]
128 */
129 public static function getReferenceColumns() {
130 if (!isset(Civi::$statics[__CLASS__]['links'])) {
131 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
132 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
133 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
134 }
135 return Civi::$statics[__CLASS__]['links'];
136 }
137
138 /**
139 * Returns all the column names of this table
140 *
141 * @return array
142 */
143 public static function &fields() {
144 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
145 Civi::$statics[__CLASS__]['fields'] = [
146 'id' => [
147 'name' => 'id',
148 'type' => CRM_Utils_Type::T_INT,
149 'title' => ts('Phone ID'),
150 'description' => ts('Unique Phone ID'),
151 'required' => TRUE,
152 'where' => 'civicrm_phone.id',
153 'table_name' => 'civicrm_phone',
154 'entity' => 'Phone',
155 'bao' => 'CRM_Core_BAO_Phone',
156 'localizable' => 0,
157 'add' => '1.1',
158 ],
159 'contact_id' => [
160 'name' => 'contact_id',
161 'type' => CRM_Utils_Type::T_INT,
162 'title' => ts('Phone Contact'),
163 'description' => ts('FK to Contact ID'),
164 'where' => 'civicrm_phone.contact_id',
165 'table_name' => 'civicrm_phone',
166 'entity' => 'Phone',
167 'bao' => 'CRM_Core_BAO_Phone',
168 'localizable' => 0,
169 'FKClassName' => 'CRM_Contact_DAO_Contact',
170 'add' => '2.0',
171 ],
172 'location_type_id' => [
173 'name' => 'location_type_id',
174 'type' => CRM_Utils_Type::T_INT,
175 'title' => ts('Phone Location Type'),
176 'description' => ts('Which Location does this phone belong to.'),
177 'where' => 'civicrm_phone.location_type_id',
178 'table_name' => 'civicrm_phone',
179 'entity' => 'Phone',
180 'bao' => 'CRM_Core_BAO_Phone',
181 'localizable' => 0,
182 'html' => [
183 'type' => 'Select',
184 ],
185 'pseudoconstant' => [
186 'table' => 'civicrm_location_type',
187 'keyColumn' => 'id',
188 'labelColumn' => 'display_name',
189 ],
190 'add' => '2.0',
191 ],
192 'is_primary' => [
193 'name' => 'is_primary',
194 'type' => CRM_Utils_Type::T_BOOLEAN,
195 'title' => ts('Primary phone'),
196 'description' => ts('Is this the primary phone for this contact and location.'),
197 'where' => 'civicrm_phone.is_primary',
198 'default' => '0',
199 'table_name' => 'civicrm_phone',
200 'entity' => 'Phone',
201 'bao' => 'CRM_Core_BAO_Phone',
202 'localizable' => 0,
203 'html' => [
204 'type' => 'Radio',
205 ],
206 'add' => '1.1',
207 ],
208 'is_billing' => [
209 'name' => 'is_billing',
210 'type' => CRM_Utils_Type::T_BOOLEAN,
211 'title' => ts('Is Billing Phone'),
212 'description' => ts('Is this the billing?'),
213 'where' => 'civicrm_phone.is_billing',
214 'default' => '0',
215 'table_name' => 'civicrm_phone',
216 'entity' => 'Phone',
217 'bao' => 'CRM_Core_BAO_Phone',
218 'localizable' => 0,
219 'add' => '2.0',
220 ],
221 'mobile_provider_id' => [
222 'name' => 'mobile_provider_id',
223 'type' => CRM_Utils_Type::T_INT,
224 'title' => ts('Mobile Provider'),
225 'description' => ts('Which Mobile Provider does this phone belong to.'),
226 'where' => 'civicrm_phone.mobile_provider_id',
227 'table_name' => 'civicrm_phone',
228 'entity' => 'Phone',
229 'bao' => 'CRM_Core_BAO_Phone',
230 'localizable' => 0,
231 'add' => '1.1',
232 ],
233 'phone' => [
234 'name' => 'phone',
235 'type' => CRM_Utils_Type::T_STRING,
236 'title' => ts('Phone'),
237 'description' => ts('Complete phone number.'),
238 'maxlength' => 32,
239 'size' => CRM_Utils_Type::MEDIUM,
240 'import' => TRUE,
241 'where' => 'civicrm_phone.phone',
242 'headerPattern' => '/phone/i',
243 'dataPattern' => '/^[\d\(\)\-\.\s]+$/',
244 'export' => TRUE,
245 'table_name' => 'civicrm_phone',
246 'entity' => 'Phone',
247 'bao' => 'CRM_Core_BAO_Phone',
248 'localizable' => 0,
249 'html' => [
250 'type' => 'Text',
251 ],
252 'add' => '1.1',
253 ],
254 'phone_ext' => [
255 'name' => 'phone_ext',
256 'type' => CRM_Utils_Type::T_STRING,
257 'title' => ts('Phone Extension'),
258 'description' => ts('Optional extension for a phone number.'),
259 'maxlength' => 16,
260 'size' => 4,
261 'import' => TRUE,
262 'where' => 'civicrm_phone.phone_ext',
263 'headerPattern' => '/extension/i',
264 'dataPattern' => '/^\d+$/',
265 'export' => TRUE,
266 'table_name' => 'civicrm_phone',
267 'entity' => 'Phone',
268 'bao' => 'CRM_Core_BAO_Phone',
269 'localizable' => 0,
270 'html' => [
271 'type' => 'Text',
272 ],
273 'add' => '3.3',
274 ],
275 'phone_numeric' => [
276 'name' => 'phone_numeric',
277 'type' => CRM_Utils_Type::T_STRING,
278 'title' => ts('Phone Numeric'),
279 'description' => ts('Phone number stripped of all whitespace, letters, and punctuation.'),
280 'maxlength' => 32,
281 'size' => CRM_Utils_Type::MEDIUM,
282 'where' => 'civicrm_phone.phone_numeric',
283 'table_name' => 'civicrm_phone',
284 'entity' => 'Phone',
285 'bao' => 'CRM_Core_BAO_Phone',
286 'localizable' => 0,
287 'add' => '4.3',
288 ],
289 'phone_type_id' => [
290 'name' => 'phone_type_id',
291 'type' => CRM_Utils_Type::T_INT,
292 'title' => ts('Phone Type'),
293 'description' => ts('Which type of phone does this number belongs.'),
294 'where' => 'civicrm_phone.phone_type_id',
295 'export' => TRUE,
296 'table_name' => 'civicrm_phone',
297 'entity' => 'Phone',
298 'bao' => 'CRM_Core_BAO_Phone',
299 'localizable' => 0,
300 'html' => [
301 'type' => 'Select',
302 ],
303 'pseudoconstant' => [
304 'optionGroupName' => 'phone_type',
305 'optionEditPath' => 'civicrm/admin/options/phone_type',
306 ],
307 'add' => '2.2',
308 ],
309 ];
310 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
311 }
312 return Civi::$statics[__CLASS__]['fields'];
313 }
314
315 /**
316 * Return a mapping from field-name to the corresponding key (as used in fields()).
317 *
318 * @return array
319 * Array(string $name => string $uniqueName).
320 */
321 public static function &fieldKeys() {
322 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
323 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
324 }
325 return Civi::$statics[__CLASS__]['fieldKeys'];
326 }
327
328 /**
329 * Returns the names of this table
330 *
331 * @return string
332 */
333 public static function getTableName() {
334 return self::$_tableName;
335 }
336
337 /**
338 * Returns if this table needs to be logged
339 *
340 * @return bool
341 */
342 public function getLog() {
343 return self::$_log;
344 }
345
346 /**
347 * Returns the list of fields that can be imported
348 *
349 * @param bool $prefix
350 *
351 * @return array
352 */
353 public static function &import($prefix = FALSE) {
354 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'phone', $prefix, []);
355 return $r;
356 }
357
358 /**
359 * Returns the list of fields that can be exported
360 *
361 * @param bool $prefix
362 *
363 * @return array
364 */
365 public static function &export($prefix = FALSE) {
366 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'phone', $prefix, []);
367 return $r;
368 }
369
370 /**
371 * Returns the list of indices
372 *
373 * @param bool $localize
374 *
375 * @return array
376 */
377 public static function indices($localize = TRUE) {
378 $indices = [
379 'index_location_type' => [
380 'name' => 'index_location_type',
381 'field' => [
382 0 => 'location_type_id',
383 ],
384 'localizable' => FALSE,
385 'sig' => 'civicrm_phone::0::location_type_id',
386 ],
387 'index_is_primary' => [
388 'name' => 'index_is_primary',
389 'field' => [
390 0 => 'is_primary',
391 ],
392 'localizable' => FALSE,
393 'sig' => 'civicrm_phone::0::is_primary',
394 ],
395 'index_is_billing' => [
396 'name' => 'index_is_billing',
397 'field' => [
398 0 => 'is_billing',
399 ],
400 'localizable' => FALSE,
401 'sig' => 'civicrm_phone::0::is_billing',
402 ],
403 'UI_mobile_provider_id' => [
404 'name' => 'UI_mobile_provider_id',
405 'field' => [
406 0 => 'mobile_provider_id',
407 ],
408 'localizable' => FALSE,
409 'sig' => 'civicrm_phone::0::mobile_provider_id',
410 ],
411 'index_phone_numeric' => [
412 'name' => 'index_phone_numeric',
413 'field' => [
414 0 => 'phone_numeric',
415 ],
416 'localizable' => FALSE,
417 'sig' => 'civicrm_phone::0::phone_numeric',
418 ],
419 ];
420 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
421 }
422
423 }