Regenerate DAO files with improved var docblocks
[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:80a3c43c953f8fe1ddb7ac96cd926139)
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|null
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|null
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|null
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 'where' => 'civicrm_address.is_primary',
406 'default' => '0',
407 'table_name' => 'civicrm_address',
408 'entity' => 'Address',
409 'bao' => 'CRM_Core_BAO_Address',
410 'localizable' => 0,
411 'html' => [
412 'type' => 'Radio',
413 ],
414 'add' => '2.0',
415 ],
416 'is_billing' => [
417 'name' => 'is_billing',
418 'type' => CRM_Utils_Type::T_BOOLEAN,
419 'title' => ts('Is Billing Address'),
420 'description' => ts('Is this the billing address.'),
421 'where' => 'civicrm_address.is_billing',
422 'default' => '0',
423 'table_name' => 'civicrm_address',
424 'entity' => 'Address',
425 'bao' => 'CRM_Core_BAO_Address',
426 'localizable' => 0,
427 'html' => [
428 'type' => 'CheckBox',
429 ],
430 'add' => '2.0',
431 ],
432 'street_address' => [
433 'name' => 'street_address',
434 'type' => CRM_Utils_Type::T_STRING,
435 'title' => ts('Street Address'),
436 'description' => ts('Concatenation of all routable street address components (prefix, street number, street name, suffix, unit
437 number OR P.O. Box). Apps should be able to determine physical location with this data (for mapping, mail
438 delivery, etc.).'),
439 'maxlength' => 96,
440 'size' => CRM_Utils_Type::HUGE,
441 'import' => TRUE,
442 'where' => 'civicrm_address.street_address',
443 'headerPattern' => '/(street|address)/i',
444 'dataPattern' => '/^(\d{1,5}( [0-9A-Za-z]+)+)$|^(P\.?O\.\? Box \d{1,5})$/i',
445 'export' => TRUE,
446 'table_name' => 'civicrm_address',
447 'entity' => 'Address',
448 'bao' => 'CRM_Core_BAO_Address',
449 'localizable' => 0,
450 'html' => [
451 'type' => 'Text',
452 ],
453 'add' => '1.1',
454 ],
455 'street_number' => [
456 'name' => 'street_number',
457 'type' => CRM_Utils_Type::T_INT,
458 'title' => ts('Street Number'),
459 'description' => ts('Numeric portion of address number on the street, e.g. For 112A Main St, the street_number = 112.'),
460 'where' => 'civicrm_address.street_number',
461 'export' => TRUE,
462 'table_name' => 'civicrm_address',
463 'entity' => 'Address',
464 'bao' => 'CRM_Core_BAO_Address',
465 'localizable' => 0,
466 'html' => [
467 'type' => 'Text',
468 ],
469 'add' => '1.1',
470 ],
471 'street_number_suffix' => [
472 'name' => 'street_number_suffix',
473 'type' => CRM_Utils_Type::T_STRING,
474 'title' => ts('Street Number Suffix'),
475 'description' => ts('Non-numeric portion of address number on the street, e.g. For 112A Main St, the street_number_suffix = A'),
476 'maxlength' => 8,
477 'size' => CRM_Utils_Type::EIGHT,
478 'where' => 'civicrm_address.street_number_suffix',
479 'export' => TRUE,
480 'table_name' => 'civicrm_address',
481 'entity' => 'Address',
482 'bao' => 'CRM_Core_BAO_Address',
483 'localizable' => 0,
484 'html' => [
485 'type' => 'Text',
486 ],
487 'add' => '1.1',
488 ],
489 'street_number_predirectional' => [
490 'name' => 'street_number_predirectional',
491 'type' => CRM_Utils_Type::T_STRING,
492 'title' => ts('Street Direction Prefix'),
493 'description' => ts('Directional prefix, e.g. SE Main St, SE is the prefix.'),
494 'maxlength' => 8,
495 'size' => CRM_Utils_Type::EIGHT,
496 'where' => 'civicrm_address.street_number_predirectional',
497 'table_name' => 'civicrm_address',
498 'entity' => 'Address',
499 'bao' => 'CRM_Core_BAO_Address',
500 'localizable' => 0,
501 'html' => [
502 'type' => 'Text',
503 ],
504 'add' => '1.1',
505 ],
506 'street_name' => [
507 'name' => 'street_name',
508 'type' => CRM_Utils_Type::T_STRING,
509 'title' => ts('Street Name'),
510 'description' => ts('Actual street name, excluding St, Dr, Rd, Ave, e.g. For 112 Main St, the street_name = Main.'),
511 'maxlength' => 64,
512 'size' => CRM_Utils_Type::BIG,
513 'where' => 'civicrm_address.street_name',
514 'export' => TRUE,
515 'table_name' => 'civicrm_address',
516 'entity' => 'Address',
517 'bao' => 'CRM_Core_BAO_Address',
518 'localizable' => 0,
519 'html' => [
520 'type' => 'Text',
521 ],
522 'add' => '1.1',
523 ],
524 'street_type' => [
525 'name' => 'street_type',
526 'type' => CRM_Utils_Type::T_STRING,
527 'title' => ts('Street Type'),
528 'description' => ts('St, Rd, Dr, etc.'),
529 'maxlength' => 8,
530 'size' => CRM_Utils_Type::EIGHT,
531 'where' => 'civicrm_address.street_type',
532 'table_name' => 'civicrm_address',
533 'entity' => 'Address',
534 'bao' => 'CRM_Core_BAO_Address',
535 'localizable' => 0,
536 'html' => [
537 'type' => 'Text',
538 ],
539 'add' => '1.1',
540 ],
541 'street_number_postdirectional' => [
542 'name' => 'street_number_postdirectional',
543 'type' => CRM_Utils_Type::T_STRING,
544 'title' => ts('Street Direction Suffix'),
545 'description' => ts('Directional prefix, e.g. Main St S, S is the suffix.'),
546 'maxlength' => 8,
547 'size' => CRM_Utils_Type::EIGHT,
548 'where' => 'civicrm_address.street_number_postdirectional',
549 'table_name' => 'civicrm_address',
550 'entity' => 'Address',
551 'bao' => 'CRM_Core_BAO_Address',
552 'localizable' => 0,
553 'html' => [
554 'type' => 'Text',
555 ],
556 'add' => '1.1',
557 ],
558 'street_unit' => [
559 'name' => 'street_unit',
560 'type' => CRM_Utils_Type::T_STRING,
561 'title' => ts('Street Unit'),
562 'description' => ts('Secondary unit designator, e.g. Apt 3 or Unit # 14, or Bldg 1200'),
563 'maxlength' => 16,
564 'size' => CRM_Utils_Type::TWELVE,
565 'where' => 'civicrm_address.street_unit',
566 'export' => TRUE,
567 'table_name' => 'civicrm_address',
568 'entity' => 'Address',
569 'bao' => 'CRM_Core_BAO_Address',
570 'localizable' => 0,
571 'html' => [
572 'type' => 'Text',
573 ],
574 'add' => '1.1',
575 ],
576 'supplemental_address_1' => [
577 'name' => 'supplemental_address_1',
578 'type' => CRM_Utils_Type::T_STRING,
579 'title' => ts('Supplemental Address 1'),
580 'description' => ts('Supplemental Address Information, Line 1'),
581 'maxlength' => 96,
582 'size' => CRM_Utils_Type::HUGE,
583 'import' => TRUE,
584 'where' => 'civicrm_address.supplemental_address_1',
585 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
586 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
587 'export' => TRUE,
588 'table_name' => 'civicrm_address',
589 'entity' => 'Address',
590 'bao' => 'CRM_Core_BAO_Address',
591 'localizable' => 0,
592 'html' => [
593 'type' => 'Text',
594 ],
595 'add' => '1.1',
596 ],
597 'supplemental_address_2' => [
598 'name' => 'supplemental_address_2',
599 'type' => CRM_Utils_Type::T_STRING,
600 'title' => ts('Supplemental Address 2'),
601 'description' => ts('Supplemental Address Information, Line 2'),
602 'maxlength' => 96,
603 'size' => CRM_Utils_Type::HUGE,
604 'import' => TRUE,
605 'where' => 'civicrm_address.supplemental_address_2',
606 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
607 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
608 'export' => TRUE,
609 'table_name' => 'civicrm_address',
610 'entity' => 'Address',
611 'bao' => 'CRM_Core_BAO_Address',
612 'localizable' => 0,
613 'html' => [
614 'type' => 'Text',
615 ],
616 'add' => '1.1',
617 ],
618 'supplemental_address_3' => [
619 'name' => 'supplemental_address_3',
620 'type' => CRM_Utils_Type::T_STRING,
621 'title' => ts('Supplemental Address 3'),
622 'description' => ts('Supplemental Address Information, Line 3'),
623 'maxlength' => 96,
624 'size' => CRM_Utils_Type::HUGE,
625 'import' => TRUE,
626 'where' => 'civicrm_address.supplemental_address_3',
627 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
628 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
629 'export' => TRUE,
630 'table_name' => 'civicrm_address',
631 'entity' => 'Address',
632 'bao' => 'CRM_Core_BAO_Address',
633 'localizable' => 0,
634 'html' => [
635 'type' => 'Text',
636 ],
637 'add' => '1.1',
638 ],
639 'city' => [
640 'name' => 'city',
641 'type' => CRM_Utils_Type::T_STRING,
642 'title' => ts('City'),
643 'description' => ts('City, Town or Village Name.'),
644 'maxlength' => 64,
645 'size' => CRM_Utils_Type::BIG,
646 'import' => TRUE,
647 'where' => 'civicrm_address.city',
648 'headerPattern' => '/city/i',
649 'dataPattern' => '/^[A-Za-z]+(\.?)(\s?[A-Za-z]+){0,2}$/',
650 'export' => TRUE,
651 'table_name' => 'civicrm_address',
652 'entity' => 'Address',
653 'bao' => 'CRM_Core_BAO_Address',
654 'localizable' => 0,
655 'html' => [
656 'type' => 'Text',
657 ],
658 'add' => '1.1',
659 ],
660 'county_id' => [
661 'name' => 'county_id',
662 'type' => CRM_Utils_Type::T_INT,
663 'title' => ts('County ID'),
664 'description' => ts('Which County does this address belong to.'),
665 'where' => 'civicrm_address.county_id',
666 'table_name' => 'civicrm_address',
667 'entity' => 'Address',
668 'bao' => 'CRM_Core_BAO_Address',
669 'localizable' => 0,
670 'FKClassName' => 'CRM_Core_DAO_County',
671 'html' => [
672 'type' => 'ChainSelect',
673 'label' => ts("County"),
674 'controlField' => 'state_province_id',
675 ],
676 'pseudoconstant' => [
677 'table' => 'civicrm_county',
678 'keyColumn' => 'id',
679 'labelColumn' => 'name',
680 'abbrColumn' => 'abbreviation',
681 ],
682 'add' => '1.1',
683 ],
684 'state_province_id' => [
685 'name' => 'state_province_id',
686 'type' => CRM_Utils_Type::T_INT,
687 'title' => ts('State/Province ID'),
688 'description' => ts('Which State_Province does this address belong to.'),
689 'where' => 'civicrm_address.state_province_id',
690 'table_name' => 'civicrm_address',
691 'entity' => 'Address',
692 'bao' => 'CRM_Core_BAO_Address',
693 'localizable' => 0,
694 'localize_context' => 'province',
695 'FKClassName' => 'CRM_Core_DAO_StateProvince',
696 'html' => [
697 'type' => 'ChainSelect',
698 'label' => ts("State/Province"),
699 'controlField' => 'country_id',
700 ],
701 'pseudoconstant' => [
702 'table' => 'civicrm_state_province',
703 'keyColumn' => 'id',
704 'labelColumn' => 'name',
705 'abbrColumn' => 'abbreviation',
706 ],
707 'add' => '1.1',
708 ],
709 'postal_code_suffix' => [
710 'name' => 'postal_code_suffix',
711 'type' => CRM_Utils_Type::T_STRING,
712 'title' => ts('Postal Code Suffix'),
713 'description' => ts('Store the suffix, like the +4 part in the USPS system.'),
714 'maxlength' => 12,
715 'size' => 3,
716 'import' => TRUE,
717 'where' => 'civicrm_address.postal_code_suffix',
718 'headerPattern' => '/p(ostal)\sc(ode)\ss(uffix)/i',
719 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
720 'export' => TRUE,
721 'table_name' => 'civicrm_address',
722 'entity' => 'Address',
723 'bao' => 'CRM_Core_BAO_Address',
724 'localizable' => 0,
725 'html' => [
726 'type' => 'Text',
727 ],
728 'add' => '1.1',
729 ],
730 'postal_code' => [
731 'name' => 'postal_code',
732 'type' => CRM_Utils_Type::T_STRING,
733 'title' => ts('Postal Code'),
734 'description' => ts('Store both US (zip5) AND international postal codes. App is responsible for country/region appropriate validation.'),
735 'maxlength' => 64,
736 'size' => 6,
737 'import' => TRUE,
738 'where' => 'civicrm_address.postal_code',
739 'headerPattern' => '/postal|zip/i',
740 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
741 'export' => TRUE,
742 'table_name' => 'civicrm_address',
743 'entity' => 'Address',
744 'bao' => 'CRM_Core_BAO_Address',
745 'localizable' => 0,
746 'html' => [
747 'type' => 'Text',
748 ],
749 'add' => '1.1',
750 ],
751 'usps_adc' => [
752 'name' => 'usps_adc',
753 'type' => CRM_Utils_Type::T_STRING,
754 'title' => ts('USPS Code'),
755 'description' => ts('USPS Bulk mailing code.'),
756 'maxlength' => 32,
757 'size' => CRM_Utils_Type::MEDIUM,
758 'where' => 'civicrm_address.usps_adc',
759 'table_name' => 'civicrm_address',
760 'entity' => 'Address',
761 'bao' => 'CRM_Core_BAO_Address',
762 'localizable' => 0,
763 'add' => '1.1',
764 ],
765 'country_id' => [
766 'name' => 'country_id',
767 'type' => CRM_Utils_Type::T_INT,
768 'title' => ts('Country ID'),
769 'description' => ts('Which Country does this address belong to.'),
770 'where' => 'civicrm_address.country_id',
771 'table_name' => 'civicrm_address',
772 'entity' => 'Address',
773 'bao' => 'CRM_Core_BAO_Address',
774 'localizable' => 0,
775 'localize_context' => 'country',
776 'FKClassName' => 'CRM_Core_DAO_Country',
777 'html' => [
778 'type' => 'Select',
779 'label' => ts("Country"),
780 ],
781 'pseudoconstant' => [
782 'table' => 'civicrm_country',
783 'keyColumn' => 'id',
784 'labelColumn' => 'name',
785 'nameColumn' => 'iso_code',
786 'abbrColumn' => 'iso_code',
787 ],
788 'add' => '1.1',
789 ],
790 'geo_code_1' => [
791 'name' => 'geo_code_1',
792 'type' => CRM_Utils_Type::T_FLOAT,
793 'title' => ts('Latitude'),
794 'description' => ts('Latitude'),
795 'import' => TRUE,
796 'where' => 'civicrm_address.geo_code_1',
797 'headerPattern' => '/geo/i',
798 'export' => TRUE,
799 'table_name' => 'civicrm_address',
800 'entity' => 'Address',
801 'bao' => 'CRM_Core_BAO_Address',
802 'localizable' => 0,
803 'html' => [
804 'type' => 'Text',
805 ],
806 'add' => '1.1',
807 ],
808 'geo_code_2' => [
809 'name' => 'geo_code_2',
810 'type' => CRM_Utils_Type::T_FLOAT,
811 'title' => ts('Longitude'),
812 'description' => ts('Longitude'),
813 'import' => TRUE,
814 'where' => 'civicrm_address.geo_code_2',
815 'headerPattern' => '/geo/i',
816 'export' => TRUE,
817 'table_name' => 'civicrm_address',
818 'entity' => 'Address',
819 'bao' => 'CRM_Core_BAO_Address',
820 'localizable' => 0,
821 'html' => [
822 'type' => 'Text',
823 ],
824 'add' => '1.1',
825 ],
826 'manual_geo_code' => [
827 'name' => 'manual_geo_code',
828 'type' => CRM_Utils_Type::T_BOOLEAN,
829 'title' => ts('Is Manually Geocoded'),
830 'description' => ts('Is this a manually entered geo code'),
831 'where' => 'civicrm_address.manual_geo_code',
832 'export' => TRUE,
833 'default' => '0',
834 'table_name' => 'civicrm_address',
835 'entity' => 'Address',
836 'bao' => 'CRM_Core_BAO_Address',
837 'localizable' => 0,
838 'html' => [
839 'type' => 'CheckBox',
840 ],
841 'add' => '4.3',
842 ],
843 'timezone' => [
844 'name' => 'timezone',
845 'type' => CRM_Utils_Type::T_STRING,
846 'title' => ts('Timezone'),
847 'description' => ts('Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6".'),
848 'maxlength' => 8,
849 'size' => CRM_Utils_Type::EIGHT,
850 'where' => 'civicrm_address.timezone',
851 'table_name' => 'civicrm_address',
852 'entity' => 'Address',
853 'bao' => 'CRM_Core_BAO_Address',
854 'localizable' => 0,
855 'html' => [
856 'type' => 'Text',
857 ],
858 'add' => '1.1',
859 ],
860 'address_name' => [
861 'name' => 'name',
862 'type' => CRM_Utils_Type::T_STRING,
863 'title' => ts('Address Name'),
864 'maxlength' => 255,
865 'size' => CRM_Utils_Type::HUGE,
866 'import' => TRUE,
867 'where' => 'civicrm_address.name',
868 'headerPattern' => '/^location|(l(ocation\s)?name)$/i',
869 'dataPattern' => '/^\w+$/',
870 'export' => TRUE,
871 'table_name' => 'civicrm_address',
872 'entity' => 'Address',
873 'bao' => 'CRM_Core_BAO_Address',
874 'localizable' => 0,
875 'html' => [
876 'type' => 'Text',
877 ],
878 'add' => '2.1',
879 ],
880 'master_id' => [
881 'name' => 'master_id',
882 'type' => CRM_Utils_Type::T_INT,
883 'title' => ts('Master Address ID'),
884 'description' => ts('FK to Address ID'),
885 'import' => TRUE,
886 'where' => 'civicrm_address.master_id',
887 'export' => TRUE,
888 'table_name' => 'civicrm_address',
889 'entity' => 'Address',
890 'bao' => 'CRM_Core_BAO_Address',
891 'localizable' => 0,
892 'FKClassName' => 'CRM_Core_DAO_Address',
893 'html' => [
894 'label' => ts("Master Address Belongs To"),
895 ],
896 'add' => '3.3',
897 ],
898 ];
899 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
900 }
901 return Civi::$statics[__CLASS__]['fields'];
902 }
903
904 /**
905 * Return a mapping from field-name to the corresponding key (as used in fields()).
906 *
907 * @return array
908 * Array(string $name => string $uniqueName).
909 */
910 public static function &fieldKeys() {
911 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
912 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
913 }
914 return Civi::$statics[__CLASS__]['fieldKeys'];
915 }
916
917 /**
918 * Returns the names of this table
919 *
920 * @return string
921 */
922 public static function getTableName() {
923 return self::$_tableName;
924 }
925
926 /**
927 * Returns if this table needs to be logged
928 *
929 * @return bool
930 */
931 public function getLog() {
932 return self::$_log;
933 }
934
935 /**
936 * Returns the list of fields that can be imported
937 *
938 * @param bool $prefix
939 *
940 * @return array
941 */
942 public static function &import($prefix = FALSE) {
943 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'address', $prefix, [
944 'CRM_Core_DAO_County',
945 'CRM_Core_DAO_StateProvince',
946 'CRM_Core_DAO_Country',
947 ]);
948 return $r;
949 }
950
951 /**
952 * Returns the list of fields that can be exported
953 *
954 * @param bool $prefix
955 *
956 * @return array
957 */
958 public static function &export($prefix = FALSE) {
959 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'address', $prefix, [
960 'CRM_Core_DAO_County',
961 'CRM_Core_DAO_StateProvince',
962 'CRM_Core_DAO_Country',
963 ]);
964 return $r;
965 }
966
967 /**
968 * Returns the list of indices
969 *
970 * @param bool $localize
971 *
972 * @return array
973 */
974 public static function indices($localize = TRUE) {
975 $indices = [
976 'index_location_type' => [
977 'name' => 'index_location_type',
978 'field' => [
979 0 => 'location_type_id',
980 ],
981 'localizable' => FALSE,
982 'sig' => 'civicrm_address::0::location_type_id',
983 ],
984 'index_is_primary' => [
985 'name' => 'index_is_primary',
986 'field' => [
987 0 => 'is_primary',
988 ],
989 'localizable' => FALSE,
990 'sig' => 'civicrm_address::0::is_primary',
991 ],
992 'index_is_billing' => [
993 'name' => 'index_is_billing',
994 'field' => [
995 0 => 'is_billing',
996 ],
997 'localizable' => FALSE,
998 'sig' => 'civicrm_address::0::is_billing',
999 ],
1000 'index_street_name' => [
1001 'name' => 'index_street_name',
1002 'field' => [
1003 0 => 'street_name',
1004 ],
1005 'localizable' => FALSE,
1006 'sig' => 'civicrm_address::0::street_name',
1007 ],
1008 'index_city' => [
1009 'name' => 'index_city',
1010 'field' => [
1011 0 => 'city',
1012 ],
1013 'localizable' => FALSE,
1014 'sig' => 'civicrm_address::0::city',
1015 ],
1016 'index_geo_code_1_geo_code_2' => [
1017 'name' => 'index_geo_code_1_geo_code_2',
1018 'field' => [
1019 0 => 'geo_code_1',
1020 1 => 'geo_code_2',
1021 ],
1022 'localizable' => FALSE,
1023 'sig' => 'civicrm_address::0::geo_code_1::geo_code_2',
1024 ],
1025 ];
1026 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
1027 }
1028
1029 }