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