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