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