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