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