Merge pull request #16488 from mattwire/quickform_requiredfields
[civicrm-core.git] / CRM / Core / DAO / Address.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/Address.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:ecd12ccf6f73ab607645bb57298e8366)
10 */
11
12 /**
13 * Database access object for the Address entity.
14 */
15 class CRM_Core_DAO_Address extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 public static $_tableName = 'civicrm_address';
23
24 /**
25 * Icon associated with this entity.
26 *
27 * @var string
28 */
29 public static $_icon = 'fa-map-marker';
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 Address 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 address belong to.
54 *
55 * @var int
56 */
57 public $location_type_id;
58
59 /**
60 * Is this the primary address.
61 *
62 * @var bool
63 */
64 public $is_primary;
65
66 /**
67 * Is this the billing address.
68 *
69 * @var bool
70 */
71 public $is_billing;
72
73 /**
74 * Concatenation of all routable street address components (prefix, street number, street name, suffix, unit
75 * number OR P.O. Box). Apps should be able to determine physical location with this data (for mapping, mail
76 * delivery, etc.).
77 *
78 * @var string
79 */
80 public $street_address;
81
82 /**
83 * Numeric portion of address number on the street, e.g. For 112A Main St, the street_number = 112.
84 *
85 * @var int
86 */
87 public $street_number;
88
89 /**
90 * Non-numeric portion of address number on the street, e.g. For 112A Main St, the street_number_suffix = A
91 *
92 * @var string
93 */
94 public $street_number_suffix;
95
96 /**
97 * Directional prefix, e.g. SE Main St, SE is the prefix.
98 *
99 * @var string
100 */
101 public $street_number_predirectional;
102
103 /**
104 * Actual street name, excluding St, Dr, Rd, Ave, e.g. For 112 Main St, the street_name = Main.
105 *
106 * @var string
107 */
108 public $street_name;
109
110 /**
111 * St, Rd, Dr, etc.
112 *
113 * @var string
114 */
115 public $street_type;
116
117 /**
118 * Directional prefix, e.g. Main St S, S is the suffix.
119 *
120 * @var string
121 */
122 public $street_number_postdirectional;
123
124 /**
125 * Secondary unit designator, e.g. Apt 3 or Unit # 14, or Bldg 1200
126 *
127 * @var string
128 */
129 public $street_unit;
130
131 /**
132 * Supplemental Address Information, Line 1
133 *
134 * @var string
135 */
136 public $supplemental_address_1;
137
138 /**
139 * Supplemental Address Information, Line 2
140 *
141 * @var string
142 */
143 public $supplemental_address_2;
144
145 /**
146 * Supplemental Address Information, Line 3
147 *
148 * @var string
149 */
150 public $supplemental_address_3;
151
152 /**
153 * City, Town or Village Name.
154 *
155 * @var string
156 */
157 public $city;
158
159 /**
160 * Which County does this address belong to.
161 *
162 * @var int
163 */
164 public $county_id;
165
166 /**
167 * Which State_Province does this address belong to.
168 *
169 * @var int
170 */
171 public $state_province_id;
172
173 /**
174 * Store the suffix, like the +4 part in the USPS system.
175 *
176 * @var string
177 */
178 public $postal_code_suffix;
179
180 /**
181 * Store both US (zip5) AND international postal codes. App is responsible for country/region appropriate validation.
182 *
183 * @var string
184 */
185 public $postal_code;
186
187 /**
188 * USPS Bulk mailing code.
189 *
190 * @var string
191 */
192 public $usps_adc;
193
194 /**
195 * Which Country does this address belong to.
196 *
197 * @var int
198 */
199 public $country_id;
200
201 /**
202 * Latitude
203 *
204 * @var float
205 */
206 public $geo_code_1;
207
208 /**
209 * Longitude
210 *
211 * @var float
212 */
213 public $geo_code_2;
214
215 /**
216 * Is this a manually entered geo code
217 *
218 * @var bool
219 */
220 public $manual_geo_code;
221
222 /**
223 * Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6".
224 *
225 * @var string
226 */
227 public $timezone;
228
229 /**
230 * @var string
231 */
232 public $name;
233
234 /**
235 * FK to Address ID
236 *
237 * @var int
238 */
239 public $master_id;
240
241 /**
242 * Class constructor.
243 */
244 public function __construct() {
245 $this->__table = 'civicrm_address';
246 parent::__construct();
247 }
248
249 /**
250 * Returns localized title of this entity.
251 */
252 public static function getEntityTitle() {
253 return ts('Addresses');
254 }
255
256 /**
257 * Returns foreign keys and entity references.
258 *
259 * @return array
260 * [CRM_Core_Reference_Interface]
261 */
262 public static function getReferenceColumns() {
263 if (!isset(Civi::$statics[__CLASS__]['links'])) {
264 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
265 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
266 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'county_id', 'civicrm_county', 'id');
267 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'state_province_id', 'civicrm_state_province', 'id');
268 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'country_id', 'civicrm_country', 'id');
269 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'master_id', 'civicrm_address', 'id');
270 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
271 }
272 return Civi::$statics[__CLASS__]['links'];
273 }
274
275 /**
276 * Returns all the column names of this table
277 *
278 * @return array
279 */
280 public static function &fields() {
281 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
282 Civi::$statics[__CLASS__]['fields'] = [
283 'address_id' => [
284 'name' => 'id',
285 'type' => CRM_Utils_Type::T_INT,
286 'title' => ts('Address ID'),
287 'description' => ts('Unique Address ID'),
288 'required' => TRUE,
289 'where' => 'civicrm_address.id',
290 'export' => TRUE,
291 'table_name' => 'civicrm_address',
292 'entity' => 'Address',
293 'bao' => 'CRM_Core_BAO_Address',
294 'localizable' => 0,
295 ],
296 'contact_id' => [
297 'name' => 'contact_id',
298 'type' => CRM_Utils_Type::T_INT,
299 'title' => ts('Contact ID'),
300 'description' => ts('FK to Contact ID'),
301 'where' => 'civicrm_address.contact_id',
302 'table_name' => 'civicrm_address',
303 'entity' => 'Address',
304 'bao' => 'CRM_Core_BAO_Address',
305 'localizable' => 0,
306 'FKClassName' => 'CRM_Contact_DAO_Contact',
307 ],
308 'location_type_id' => [
309 'name' => 'location_type_id',
310 'type' => CRM_Utils_Type::T_INT,
311 'title' => ts('Address Location Type'),
312 'description' => ts('Which Location does this address belong to.'),
313 'where' => 'civicrm_address.location_type_id',
314 'table_name' => 'civicrm_address',
315 'entity' => 'Address',
316 'bao' => 'CRM_Core_BAO_Address',
317 'localizable' => 0,
318 'html' => [
319 'type' => 'Select',
320 ],
321 'pseudoconstant' => [
322 'table' => 'civicrm_location_type',
323 'keyColumn' => 'id',
324 'labelColumn' => 'display_name',
325 ],
326 ],
327 'is_primary' => [
328 'name' => 'is_primary',
329 'type' => CRM_Utils_Type::T_BOOLEAN,
330 'title' => ts('Primary address'),
331 'description' => ts('Is this the primary address.'),
332 'where' => 'civicrm_address.is_primary',
333 'default' => '0',
334 'table_name' => 'civicrm_address',
335 'entity' => 'Address',
336 'bao' => 'CRM_Core_BAO_Address',
337 'localizable' => 0,
338 'html' => [
339 'type' => 'Radio',
340 ],
341 ],
342 'is_billing' => [
343 'name' => 'is_billing',
344 'type' => CRM_Utils_Type::T_BOOLEAN,
345 'title' => ts('Is Billing Address'),
346 'description' => ts('Is this the billing address.'),
347 'where' => 'civicrm_address.is_billing',
348 'default' => '0',
349 'table_name' => 'civicrm_address',
350 'entity' => 'Address',
351 'bao' => 'CRM_Core_BAO_Address',
352 'localizable' => 0,
353 'html' => [
354 'type' => 'CheckBox',
355 ],
356 ],
357 'street_address' => [
358 'name' => 'street_address',
359 'type' => CRM_Utils_Type::T_STRING,
360 'title' => ts('Street Address'),
361 'description' => ts('Concatenation of all routable street address components (prefix, street number, street name, suffix, unit
362 number OR P.O. Box). Apps should be able to determine physical location with this data (for mapping, mail
363 delivery, etc.).'),
364 'maxlength' => 96,
365 'size' => CRM_Utils_Type::HUGE,
366 'import' => TRUE,
367 'where' => 'civicrm_address.street_address',
368 'headerPattern' => '/(street|address)/i',
369 'dataPattern' => '/^(\d{1,5}( [0-9A-Za-z]+)+)$|^(P\.?O\.\? Box \d{1,5})$/i',
370 'export' => TRUE,
371 'table_name' => 'civicrm_address',
372 'entity' => 'Address',
373 'bao' => 'CRM_Core_BAO_Address',
374 'localizable' => 0,
375 'html' => [
376 'type' => 'Text',
377 ],
378 ],
379 'street_number' => [
380 'name' => 'street_number',
381 'type' => CRM_Utils_Type::T_INT,
382 'title' => ts('Street Number'),
383 'description' => ts('Numeric portion of address number on the street, e.g. For 112A Main St, the street_number = 112.'),
384 'where' => 'civicrm_address.street_number',
385 'export' => TRUE,
386 'table_name' => 'civicrm_address',
387 'entity' => 'Address',
388 'bao' => 'CRM_Core_BAO_Address',
389 'localizable' => 0,
390 'html' => [
391 'type' => 'Text',
392 ],
393 ],
394 'street_number_suffix' => [
395 'name' => 'street_number_suffix',
396 'type' => CRM_Utils_Type::T_STRING,
397 'title' => ts('Street Number Suffix'),
398 'description' => ts('Non-numeric portion of address number on the street, e.g. For 112A Main St, the street_number_suffix = A'),
399 'maxlength' => 8,
400 'size' => CRM_Utils_Type::EIGHT,
401 'where' => 'civicrm_address.street_number_suffix',
402 'export' => TRUE,
403 'table_name' => 'civicrm_address',
404 'entity' => 'Address',
405 'bao' => 'CRM_Core_BAO_Address',
406 'localizable' => 0,
407 'html' => [
408 'type' => 'Text',
409 ],
410 ],
411 'street_number_predirectional' => [
412 'name' => 'street_number_predirectional',
413 'type' => CRM_Utils_Type::T_STRING,
414 'title' => ts('Street Direction Prefix'),
415 'description' => ts('Directional prefix, e.g. SE Main St, SE is the prefix.'),
416 'maxlength' => 8,
417 'size' => CRM_Utils_Type::EIGHT,
418 'where' => 'civicrm_address.street_number_predirectional',
419 'table_name' => 'civicrm_address',
420 'entity' => 'Address',
421 'bao' => 'CRM_Core_BAO_Address',
422 'localizable' => 0,
423 'html' => [
424 'type' => 'Text',
425 ],
426 ],
427 'street_name' => [
428 'name' => 'street_name',
429 'type' => CRM_Utils_Type::T_STRING,
430 'title' => ts('Street Name'),
431 'description' => ts('Actual street name, excluding St, Dr, Rd, Ave, e.g. For 112 Main St, the street_name = Main.'),
432 'maxlength' => 64,
433 'size' => CRM_Utils_Type::BIG,
434 'where' => 'civicrm_address.street_name',
435 'export' => TRUE,
436 'table_name' => 'civicrm_address',
437 'entity' => 'Address',
438 'bao' => 'CRM_Core_BAO_Address',
439 'localizable' => 0,
440 'html' => [
441 'type' => 'Text',
442 ],
443 ],
444 'street_type' => [
445 'name' => 'street_type',
446 'type' => CRM_Utils_Type::T_STRING,
447 'title' => ts('Street Type'),
448 'description' => ts('St, Rd, Dr, etc.'),
449 'maxlength' => 8,
450 'size' => CRM_Utils_Type::EIGHT,
451 'where' => 'civicrm_address.street_type',
452 'table_name' => 'civicrm_address',
453 'entity' => 'Address',
454 'bao' => 'CRM_Core_BAO_Address',
455 'localizable' => 0,
456 'html' => [
457 'type' => 'Text',
458 ],
459 ],
460 'street_number_postdirectional' => [
461 'name' => 'street_number_postdirectional',
462 'type' => CRM_Utils_Type::T_STRING,
463 'title' => ts('Street Direction Suffix'),
464 'description' => ts('Directional prefix, e.g. Main St S, S is the suffix.'),
465 'maxlength' => 8,
466 'size' => CRM_Utils_Type::EIGHT,
467 'where' => 'civicrm_address.street_number_postdirectional',
468 'table_name' => 'civicrm_address',
469 'entity' => 'Address',
470 'bao' => 'CRM_Core_BAO_Address',
471 'localizable' => 0,
472 'html' => [
473 'type' => 'Text',
474 ],
475 ],
476 'street_unit' => [
477 'name' => 'street_unit',
478 'type' => CRM_Utils_Type::T_STRING,
479 'title' => ts('Street Unit'),
480 'description' => ts('Secondary unit designator, e.g. Apt 3 or Unit # 14, or Bldg 1200'),
481 'maxlength' => 16,
482 'size' => CRM_Utils_Type::TWELVE,
483 'where' => 'civicrm_address.street_unit',
484 'export' => TRUE,
485 'table_name' => 'civicrm_address',
486 'entity' => 'Address',
487 'bao' => 'CRM_Core_BAO_Address',
488 'localizable' => 0,
489 'html' => [
490 'type' => 'Text',
491 ],
492 ],
493 'supplemental_address_1' => [
494 'name' => 'supplemental_address_1',
495 'type' => CRM_Utils_Type::T_STRING,
496 'title' => ts('Supplemental Address 1'),
497 'description' => ts('Supplemental Address Information, Line 1'),
498 'maxlength' => 96,
499 'size' => CRM_Utils_Type::HUGE,
500 'import' => TRUE,
501 'where' => 'civicrm_address.supplemental_address_1',
502 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
503 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
504 'export' => TRUE,
505 'table_name' => 'civicrm_address',
506 'entity' => 'Address',
507 'bao' => 'CRM_Core_BAO_Address',
508 'localizable' => 0,
509 'html' => [
510 'type' => 'Text',
511 ],
512 ],
513 'supplemental_address_2' => [
514 'name' => 'supplemental_address_2',
515 'type' => CRM_Utils_Type::T_STRING,
516 'title' => ts('Supplemental Address 2'),
517 'description' => ts('Supplemental Address Information, Line 2'),
518 'maxlength' => 96,
519 'size' => CRM_Utils_Type::HUGE,
520 'import' => TRUE,
521 'where' => 'civicrm_address.supplemental_address_2',
522 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
523 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
524 'export' => TRUE,
525 'table_name' => 'civicrm_address',
526 'entity' => 'Address',
527 'bao' => 'CRM_Core_BAO_Address',
528 'localizable' => 0,
529 'html' => [
530 'type' => 'Text',
531 ],
532 ],
533 'supplemental_address_3' => [
534 'name' => 'supplemental_address_3',
535 'type' => CRM_Utils_Type::T_STRING,
536 'title' => ts('Supplemental Address 3'),
537 'description' => ts('Supplemental Address Information, Line 3'),
538 'maxlength' => 96,
539 'size' => CRM_Utils_Type::HUGE,
540 'import' => TRUE,
541 'where' => 'civicrm_address.supplemental_address_3',
542 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
543 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
544 'export' => TRUE,
545 'table_name' => 'civicrm_address',
546 'entity' => 'Address',
547 'bao' => 'CRM_Core_BAO_Address',
548 'localizable' => 0,
549 'html' => [
550 'type' => 'Text',
551 ],
552 ],
553 'city' => [
554 'name' => 'city',
555 'type' => CRM_Utils_Type::T_STRING,
556 'title' => ts('City'),
557 'description' => ts('City, Town or Village Name.'),
558 'maxlength' => 64,
559 'size' => CRM_Utils_Type::BIG,
560 'import' => TRUE,
561 'where' => 'civicrm_address.city',
562 'headerPattern' => '/city/i',
563 'dataPattern' => '/^[A-Za-z]+(\.?)(\s?[A-Za-z]+){0,2}$/',
564 'export' => TRUE,
565 'table_name' => 'civicrm_address',
566 'entity' => 'Address',
567 'bao' => 'CRM_Core_BAO_Address',
568 'localizable' => 0,
569 'html' => [
570 'type' => 'Text',
571 ],
572 ],
573 'county_id' => [
574 'name' => 'county_id',
575 'type' => CRM_Utils_Type::T_INT,
576 'title' => ts('County'),
577 'description' => ts('Which County does this address belong to.'),
578 'where' => 'civicrm_address.county_id',
579 'table_name' => 'civicrm_address',
580 'entity' => 'Address',
581 'bao' => 'CRM_Core_BAO_Address',
582 'localizable' => 0,
583 'FKClassName' => 'CRM_Core_DAO_County',
584 'html' => [
585 'type' => 'ChainSelect',
586 'controlField' => 'state_province_id',
587 ],
588 'pseudoconstant' => [
589 'table' => 'civicrm_county',
590 'keyColumn' => 'id',
591 'labelColumn' => 'name',
592 ],
593 ],
594 'state_province_id' => [
595 'name' => 'state_province_id',
596 'type' => CRM_Utils_Type::T_INT,
597 'title' => ts('State/Province'),
598 'description' => ts('Which State_Province does this address belong to.'),
599 'where' => 'civicrm_address.state_province_id',
600 'table_name' => 'civicrm_address',
601 'entity' => 'Address',
602 'bao' => 'CRM_Core_BAO_Address',
603 'localizable' => 0,
604 'localize_context' => 'province',
605 'FKClassName' => 'CRM_Core_DAO_StateProvince',
606 'html' => [
607 'type' => 'ChainSelect',
608 'controlField' => 'country_id',
609 ],
610 'pseudoconstant' => [
611 'table' => 'civicrm_state_province',
612 'keyColumn' => 'id',
613 'labelColumn' => 'name',
614 ],
615 ],
616 'postal_code_suffix' => [
617 'name' => 'postal_code_suffix',
618 'type' => CRM_Utils_Type::T_STRING,
619 'title' => ts('Postal Code Suffix'),
620 'description' => ts('Store the suffix, like the +4 part in the USPS system.'),
621 'maxlength' => 12,
622 'size' => 3,
623 'import' => TRUE,
624 'where' => 'civicrm_address.postal_code_suffix',
625 'headerPattern' => '/p(ostal)\sc(ode)\ss(uffix)/i',
626 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
627 'export' => TRUE,
628 'table_name' => 'civicrm_address',
629 'entity' => 'Address',
630 'bao' => 'CRM_Core_BAO_Address',
631 'localizable' => 0,
632 'html' => [
633 'type' => 'Text',
634 ],
635 ],
636 'postal_code' => [
637 'name' => 'postal_code',
638 'type' => CRM_Utils_Type::T_STRING,
639 'title' => ts('Postal Code'),
640 'description' => ts('Store both US (zip5) AND international postal codes. App is responsible for country/region appropriate validation.'),
641 'maxlength' => 64,
642 'size' => 6,
643 'import' => TRUE,
644 'where' => 'civicrm_address.postal_code',
645 'headerPattern' => '/postal|zip/i',
646 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
647 'export' => TRUE,
648 'table_name' => 'civicrm_address',
649 'entity' => 'Address',
650 'bao' => 'CRM_Core_BAO_Address',
651 'localizable' => 0,
652 'html' => [
653 'type' => 'Text',
654 ],
655 ],
656 'usps_adc' => [
657 'name' => 'usps_adc',
658 'type' => CRM_Utils_Type::T_STRING,
659 'title' => ts('USPS Code'),
660 'description' => ts('USPS Bulk mailing code.'),
661 'maxlength' => 32,
662 'size' => CRM_Utils_Type::MEDIUM,
663 'where' => 'civicrm_address.usps_adc',
664 'table_name' => 'civicrm_address',
665 'entity' => 'Address',
666 'bao' => 'CRM_Core_BAO_Address',
667 'localizable' => 0,
668 ],
669 'country_id' => [
670 'name' => 'country_id',
671 'type' => CRM_Utils_Type::T_INT,
672 'title' => ts('Country'),
673 'description' => ts('Which Country does this address belong to.'),
674 'where' => 'civicrm_address.country_id',
675 'table_name' => 'civicrm_address',
676 'entity' => 'Address',
677 'bao' => 'CRM_Core_BAO_Address',
678 'localizable' => 0,
679 'localize_context' => 'country',
680 'FKClassName' => 'CRM_Core_DAO_Country',
681 'html' => [
682 'type' => 'Select',
683 ],
684 'pseudoconstant' => [
685 'table' => 'civicrm_country',
686 'keyColumn' => 'id',
687 'labelColumn' => 'name',
688 'nameColumn' => 'iso_code',
689 'abbrColumn' => 'iso_code',
690 ],
691 ],
692 'geo_code_1' => [
693 'name' => 'geo_code_1',
694 'type' => CRM_Utils_Type::T_FLOAT,
695 'title' => ts('Latitude'),
696 'description' => ts('Latitude'),
697 'import' => TRUE,
698 'where' => 'civicrm_address.geo_code_1',
699 'headerPattern' => '/geo/i',
700 'export' => TRUE,
701 'table_name' => 'civicrm_address',
702 'entity' => 'Address',
703 'bao' => 'CRM_Core_BAO_Address',
704 'localizable' => 0,
705 'html' => [
706 'type' => 'Text',
707 ],
708 ],
709 'geo_code_2' => [
710 'name' => 'geo_code_2',
711 'type' => CRM_Utils_Type::T_FLOAT,
712 'title' => ts('Longitude'),
713 'description' => ts('Longitude'),
714 'import' => TRUE,
715 'where' => 'civicrm_address.geo_code_2',
716 'headerPattern' => '/geo/i',
717 'export' => TRUE,
718 'table_name' => 'civicrm_address',
719 'entity' => 'Address',
720 'bao' => 'CRM_Core_BAO_Address',
721 'localizable' => 0,
722 'html' => [
723 'type' => 'Text',
724 ],
725 ],
726 'manual_geo_code' => [
727 'name' => 'manual_geo_code',
728 'type' => CRM_Utils_Type::T_BOOLEAN,
729 'title' => ts('Is Manually Geocoded'),
730 'description' => ts('Is this a manually entered geo code'),
731 'where' => 'civicrm_address.manual_geo_code',
732 'export' => TRUE,
733 'default' => '0',
734 'table_name' => 'civicrm_address',
735 'entity' => 'Address',
736 'bao' => 'CRM_Core_BAO_Address',
737 'localizable' => 0,
738 'html' => [
739 'type' => 'CheckBox',
740 ],
741 ],
742 'timezone' => [
743 'name' => 'timezone',
744 'type' => CRM_Utils_Type::T_STRING,
745 'title' => ts('Timezone'),
746 'description' => ts('Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6".'),
747 'maxlength' => 8,
748 'size' => CRM_Utils_Type::EIGHT,
749 'where' => 'civicrm_address.timezone',
750 'table_name' => 'civicrm_address',
751 'entity' => 'Address',
752 'bao' => 'CRM_Core_BAO_Address',
753 'localizable' => 0,
754 'html' => [
755 'type' => 'Text',
756 ],
757 ],
758 'address_name' => [
759 'name' => 'name',
760 'type' => CRM_Utils_Type::T_STRING,
761 'title' => ts('Address Name'),
762 'maxlength' => 255,
763 'size' => CRM_Utils_Type::HUGE,
764 'import' => TRUE,
765 'where' => 'civicrm_address.name',
766 'headerPattern' => '/^location|(l(ocation\s)?name)$/i',
767 'dataPattern' => '/^\w+$/',
768 'export' => TRUE,
769 'table_name' => 'civicrm_address',
770 'entity' => 'Address',
771 'bao' => 'CRM_Core_BAO_Address',
772 'localizable' => 0,
773 'html' => [
774 'type' => 'Text',
775 ],
776 ],
777 'master_id' => [
778 'name' => 'master_id',
779 'type' => CRM_Utils_Type::T_INT,
780 'title' => ts('Master Address Belongs To'),
781 'description' => ts('FK to Address ID'),
782 'import' => TRUE,
783 'where' => 'civicrm_address.master_id',
784 'export' => TRUE,
785 'table_name' => 'civicrm_address',
786 'entity' => 'Address',
787 'bao' => 'CRM_Core_BAO_Address',
788 'localizable' => 0,
789 'FKClassName' => 'CRM_Core_DAO_Address',
790 ],
791 ];
792 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
793 }
794 return Civi::$statics[__CLASS__]['fields'];
795 }
796
797 /**
798 * Return a mapping from field-name to the corresponding key (as used in fields()).
799 *
800 * @return array
801 * Array(string $name => string $uniqueName).
802 */
803 public static function &fieldKeys() {
804 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
805 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
806 }
807 return Civi::$statics[__CLASS__]['fieldKeys'];
808 }
809
810 /**
811 * Returns the names of this table
812 *
813 * @return string
814 */
815 public static function getTableName() {
816 return self::$_tableName;
817 }
818
819 /**
820 * Returns if this table needs to be logged
821 *
822 * @return bool
823 */
824 public function getLog() {
825 return self::$_log;
826 }
827
828 /**
829 * Returns the list of fields that can be imported
830 *
831 * @param bool $prefix
832 *
833 * @return array
834 */
835 public static function &import($prefix = FALSE) {
836 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'address', $prefix, [
837 'CRM_Core_DAO_County',
838 'CRM_Core_DAO_StateProvince',
839 'CRM_Core_DAO_Country',
840 ]);
841 return $r;
842 }
843
844 /**
845 * Returns the list of fields that can be exported
846 *
847 * @param bool $prefix
848 *
849 * @return array
850 */
851 public static function &export($prefix = FALSE) {
852 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'address', $prefix, [
853 'CRM_Core_DAO_County',
854 'CRM_Core_DAO_StateProvince',
855 'CRM_Core_DAO_Country',
856 ]);
857 return $r;
858 }
859
860 /**
861 * Returns the list of indices
862 *
863 * @param bool $localize
864 *
865 * @return array
866 */
867 public static function indices($localize = TRUE) {
868 $indices = [
869 'index_location_type' => [
870 'name' => 'index_location_type',
871 'field' => [
872 0 => 'location_type_id',
873 ],
874 'localizable' => FALSE,
875 'sig' => 'civicrm_address::0::location_type_id',
876 ],
877 'index_is_primary' => [
878 'name' => 'index_is_primary',
879 'field' => [
880 0 => 'is_primary',
881 ],
882 'localizable' => FALSE,
883 'sig' => 'civicrm_address::0::is_primary',
884 ],
885 'index_is_billing' => [
886 'name' => 'index_is_billing',
887 'field' => [
888 0 => 'is_billing',
889 ],
890 'localizable' => FALSE,
891 'sig' => 'civicrm_address::0::is_billing',
892 ],
893 'index_street_name' => [
894 'name' => 'index_street_name',
895 'field' => [
896 0 => 'street_name',
897 ],
898 'localizable' => FALSE,
899 'sig' => 'civicrm_address::0::street_name',
900 ],
901 'index_city' => [
902 'name' => 'index_city',
903 'field' => [
904 0 => 'city',
905 ],
906 'localizable' => FALSE,
907 'sig' => 'civicrm_address::0::city',
908 ],
909 'index_geo_code_1_geo_code_2' => [
910 'name' => 'index_geo_code_1_geo_code_2',
911 'field' => [
912 0 => 'geo_code_1',
913 1 => 'geo_code_2',
914 ],
915 'localizable' => FALSE,
916 'sig' => 'civicrm_address::0::geo_code_1::geo_code_2',
917 ],
918 ];
919 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
920 }
921
922 }