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