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