Merge pull request #16098 from MegaphoneJon/event-23-correct
[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
b6673dcd 9 * (GenCodeChecksum:aed8175462599ecc4c8d43887d76350a)
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 268 Civi::$statics[__CLASS__]['fields'] = [
7e18723f 269 'address_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',
7e18723f 276 'export' => TRUE,
522a26c9 277 'table_name' => 'civicrm_address',
278 'entity' => 'Address',
279 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 280 'localizable' => 0,
c3fc2621
CW
281 ],
282 'contact_id' => [
e501603b
TO
283 'name' => 'contact_id',
284 'type' => CRM_Utils_Type::T_INT,
c3fc2621 285 'title' => ts('Contact ID'),
215b423e 286 'description' => ts('FK to Contact ID'),
a36434b9 287 'where' => 'civicrm_address.contact_id',
522a26c9 288 'table_name' => 'civicrm_address',
289 'entity' => 'Address',
290 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 291 'localizable' => 0,
e501603b 292 'FKClassName' => 'CRM_Contact_DAO_Contact',
c3fc2621
CW
293 ],
294 'location_type_id' => [
e501603b
TO
295 'name' => 'location_type_id',
296 'type' => CRM_Utils_Type::T_INT,
c3fc2621 297 'title' => ts('Address Location Type'),
215b423e 298 'description' => ts('Which Location does this address belong to.'),
a36434b9 299 'where' => 'civicrm_address.location_type_id',
522a26c9 300 'table_name' => 'civicrm_address',
301 'entity' => 'Address',
302 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 303 'localizable' => 0,
c3fc2621 304 'html' => [
e501603b 305 'type' => 'Select',
c3fc2621
CW
306 ],
307 'pseudoconstant' => [
e501603b
TO
308 'table' => 'civicrm_location_type',
309 'keyColumn' => 'id',
310 'labelColumn' => 'display_name',
e6ca0a57 311 ],
c3fc2621
CW
312 ],
313 'is_primary' => [
e501603b
TO
314 'name' => 'is_primary',
315 'type' => CRM_Utils_Type::T_BOOLEAN,
b6673dcd 316 'title' => ts('Primary address'),
215b423e 317 'description' => ts('Is this the primary address.'),
a36434b9 318 'where' => 'civicrm_address.is_primary',
45a83e42 319 'default' => '0',
522a26c9 320 'table_name' => 'civicrm_address',
321 'entity' => 'Address',
322 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 323 'localizable' => 0,
c3fc2621 324 'html' => [
b6673dcd 325 'type' => 'Radio',
c3fc2621
CW
326 ],
327 ],
328 'is_billing' => [
e501603b
TO
329 'name' => 'is_billing',
330 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 331 'title' => ts('Is Billing Address'),
215b423e 332 'description' => ts('Is this the billing address.'),
a36434b9 333 'where' => 'civicrm_address.is_billing',
45a83e42 334 'default' => '0',
522a26c9 335 'table_name' => 'civicrm_address',
336 'entity' => 'Address',
337 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 338 'localizable' => 0,
c3fc2621 339 'html' => [
e501603b 340 'type' => 'CheckBox',
c3fc2621
CW
341 ],
342 ],
343 'street_address' => [
e501603b
TO
344 'name' => 'street_address',
345 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 346 'title' => ts('Street Address'),
215b423e 347 'description' => ts('Concatenation of all routable street address components (prefix, street number, street name, suffix, unit
e501603b 348 number OR P.O. Box). Apps should be able to determine physical location with this data (for mapping, mail
fb607354 349 delivery, etc.).'),
e501603b
TO
350 'maxlength' => 96,
351 'size' => CRM_Utils_Type::HUGE,
c3fc2621 352 'import' => TRUE,
e501603b
TO
353 'where' => 'civicrm_address.street_address',
354 'headerPattern' => '/(street|address)/i',
355 'dataPattern' => '/^(\d{1,5}( [0-9A-Za-z]+)+)$|^(P\.?O\.\? Box \d{1,5})$/i',
c3fc2621 356 'export' => TRUE,
522a26c9 357 'table_name' => 'civicrm_address',
358 'entity' => 'Address',
359 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 360 'localizable' => 0,
c3fc2621 361 'html' => [
e501603b 362 'type' => 'Text',
c3fc2621
CW
363 ],
364 ],
365 'street_number' => [
e501603b
TO
366 'name' => 'street_number',
367 'type' => CRM_Utils_Type::T_INT,
c3fc2621 368 'title' => ts('Street Number'),
215b423e 369 'description' => ts('Numeric portion of address number on the street, e.g. For 112A Main St, the street_number = 112.'),
e501603b 370 'where' => 'civicrm_address.street_number',
a36434b9 371 'export' => TRUE,
522a26c9 372 'table_name' => 'civicrm_address',
373 'entity' => 'Address',
374 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 375 'localizable' => 0,
c3fc2621 376 'html' => [
e501603b 377 'type' => 'Text',
c3fc2621
CW
378 ],
379 ],
380 'street_number_suffix' => [
e501603b
TO
381 'name' => 'street_number_suffix',
382 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 383 'title' => ts('Street Number Suffix'),
fb607354 384 'description' => ts('Non-numeric portion of address number on the street, e.g. For 112A Main St, the street_number_suffix = A'),
e501603b
TO
385 'maxlength' => 8,
386 'size' => CRM_Utils_Type::EIGHT,
e501603b 387 'where' => 'civicrm_address.street_number_suffix',
a36434b9 388 'export' => TRUE,
522a26c9 389 'table_name' => 'civicrm_address',
390 'entity' => 'Address',
391 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 392 'localizable' => 0,
c3fc2621 393 'html' => [
e501603b 394 'type' => 'Text',
c3fc2621
CW
395 ],
396 ],
397 'street_number_predirectional' => [
e501603b
TO
398 'name' => 'street_number_predirectional',
399 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 400 'title' => ts('Street Direction Prefix'),
215b423e 401 'description' => ts('Directional prefix, e.g. SE Main St, SE is the prefix.'),
e501603b
TO
402 'maxlength' => 8,
403 'size' => CRM_Utils_Type::EIGHT,
a36434b9 404 'where' => 'civicrm_address.street_number_predirectional',
522a26c9 405 'table_name' => 'civicrm_address',
406 'entity' => 'Address',
407 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 408 'localizable' => 0,
c3fc2621 409 'html' => [
e501603b 410 'type' => 'Text',
c3fc2621
CW
411 ],
412 ],
413 'street_name' => [
e501603b
TO
414 'name' => 'street_name',
415 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 416 'title' => ts('Street Name'),
215b423e 417 'description' => ts('Actual street name, excluding St, Dr, Rd, Ave, e.g. For 112 Main St, the street_name = Main.'),
e501603b
TO
418 'maxlength' => 64,
419 'size' => CRM_Utils_Type::BIG,
e501603b 420 'where' => 'civicrm_address.street_name',
a36434b9 421 'export' => TRUE,
522a26c9 422 'table_name' => 'civicrm_address',
423 'entity' => 'Address',
424 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 425 'localizable' => 0,
c3fc2621 426 'html' => [
e501603b 427 'type' => 'Text',
c3fc2621
CW
428 ],
429 ],
430 'street_type' => [
e501603b
TO
431 'name' => 'street_type',
432 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 433 'title' => ts('Street Type'),
215b423e 434 'description' => ts('St, Rd, Dr, etc.'),
e501603b
TO
435 'maxlength' => 8,
436 'size' => CRM_Utils_Type::EIGHT,
a36434b9 437 'where' => 'civicrm_address.street_type',
522a26c9 438 'table_name' => 'civicrm_address',
439 'entity' => 'Address',
440 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 441 'localizable' => 0,
c3fc2621 442 'html' => [
e501603b 443 'type' => 'Text',
c3fc2621
CW
444 ],
445 ],
446 'street_number_postdirectional' => [
e501603b
TO
447 'name' => 'street_number_postdirectional',
448 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 449 'title' => ts('Street Direction Suffix'),
215b423e 450 'description' => ts('Directional prefix, e.g. Main St S, S is the suffix.'),
e501603b
TO
451 'maxlength' => 8,
452 'size' => CRM_Utils_Type::EIGHT,
a36434b9 453 'where' => 'civicrm_address.street_number_postdirectional',
522a26c9 454 'table_name' => 'civicrm_address',
455 'entity' => 'Address',
456 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 457 'localizable' => 0,
c3fc2621 458 'html' => [
e501603b 459 'type' => 'Text',
c3fc2621
CW
460 ],
461 ],
462 'street_unit' => [
e501603b
TO
463 'name' => 'street_unit',
464 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 465 'title' => ts('Street Unit'),
215b423e 466 'description' => ts('Secondary unit designator, e.g. Apt 3 or Unit # 14, or Bldg 1200'),
e501603b
TO
467 'maxlength' => 16,
468 'size' => CRM_Utils_Type::TWELVE,
e501603b 469 'where' => 'civicrm_address.street_unit',
a36434b9 470 'export' => TRUE,
522a26c9 471 'table_name' => 'civicrm_address',
472 'entity' => 'Address',
473 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 474 'localizable' => 0,
c3fc2621 475 'html' => [
e501603b 476 'type' => 'Text',
c3fc2621
CW
477 ],
478 ],
479 'supplemental_address_1' => [
e501603b
TO
480 'name' => 'supplemental_address_1',
481 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 482 'title' => ts('Supplemental Address 1'),
215b423e 483 'description' => ts('Supplemental Address Information, Line 1'),
e501603b
TO
484 'maxlength' => 96,
485 'size' => CRM_Utils_Type::HUGE,
c3fc2621 486 'import' => TRUE,
e501603b
TO
487 'where' => 'civicrm_address.supplemental_address_1',
488 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
489 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
c3fc2621 490 'export' => TRUE,
522a26c9 491 'table_name' => 'civicrm_address',
492 'entity' => 'Address',
493 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 494 'localizable' => 0,
c3fc2621 495 'html' => [
e501603b 496 'type' => 'Text',
c3fc2621
CW
497 ],
498 ],
499 'supplemental_address_2' => [
e501603b
TO
500 'name' => 'supplemental_address_2',
501 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 502 'title' => ts('Supplemental Address 2'),
215b423e 503 'description' => ts('Supplemental Address Information, Line 2'),
e501603b
TO
504 'maxlength' => 96,
505 'size' => CRM_Utils_Type::HUGE,
c3fc2621 506 'import' => TRUE,
e501603b
TO
507 'where' => 'civicrm_address.supplemental_address_2',
508 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
509 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
c3fc2621 510 'export' => TRUE,
522a26c9 511 'table_name' => 'civicrm_address',
512 'entity' => 'Address',
513 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 514 'localizable' => 0,
c3fc2621 515 'html' => [
e501603b 516 'type' => 'Text',
c3fc2621
CW
517 ],
518 ],
519 'supplemental_address_3' => [
e501603b
TO
520 'name' => 'supplemental_address_3',
521 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 522 'title' => ts('Supplemental Address 3'),
215b423e 523 'description' => ts('Supplemental Address Information, Line 3'),
e501603b
TO
524 'maxlength' => 96,
525 'size' => CRM_Utils_Type::HUGE,
c3fc2621 526 'import' => TRUE,
207f62c6
AS
527 'where' => 'civicrm_address.supplemental_address_3',
528 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
529 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
c3fc2621 530 'export' => TRUE,
522a26c9 531 'table_name' => 'civicrm_address',
532 'entity' => 'Address',
533 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 534 'localizable' => 0,
c3fc2621 535 'html' => [
e501603b 536 'type' => 'Text',
c3fc2621
CW
537 ],
538 ],
539 'city' => [
e501603b
TO
540 'name' => 'city',
541 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 542 'title' => ts('City'),
215b423e 543 'description' => ts('City, Town or Village Name.'),
e501603b
TO
544 'maxlength' => 64,
545 'size' => CRM_Utils_Type::BIG,
c3fc2621 546 'import' => TRUE,
e501603b
TO
547 'where' => 'civicrm_address.city',
548 'headerPattern' => '/city/i',
549 'dataPattern' => '/^[A-Za-z]+(\.?)(\s?[A-Za-z]+){0,2}$/',
c3fc2621 550 'export' => TRUE,
522a26c9 551 'table_name' => 'civicrm_address',
552 'entity' => 'Address',
553 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 554 'localizable' => 0,
c3fc2621 555 'html' => [
e501603b 556 'type' => 'Text',
c3fc2621
CW
557 ],
558 ],
559 'county_id' => [
e501603b
TO
560 'name' => 'county_id',
561 'type' => CRM_Utils_Type::T_INT,
c3fc2621 562 'title' => ts('County'),
215b423e 563 'description' => ts('Which County does this address belong to.'),
a36434b9 564 'where' => 'civicrm_address.county_id',
522a26c9 565 'table_name' => 'civicrm_address',
566 'entity' => 'Address',
567 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 568 'localizable' => 0,
e501603b 569 'FKClassName' => 'CRM_Core_DAO_County',
c3fc2621 570 'html' => [
e501603b 571 'type' => 'ChainSelect',
8ada2bfd 572 'controlField' => 'state_province_id',
c3fc2621
CW
573 ],
574 'pseudoconstant' => [
e501603b
TO
575 'table' => 'civicrm_county',
576 'keyColumn' => 'id',
577 'labelColumn' => 'name',
e6ca0a57 578 ],
c3fc2621
CW
579 ],
580 'state_province_id' => [
e501603b
TO
581 'name' => 'state_province_id',
582 'type' => CRM_Utils_Type::T_INT,
c3fc2621 583 'title' => ts('State/Province'),
215b423e 584 'description' => ts('Which State_Province does this address belong to.'),
a36434b9 585 'where' => 'civicrm_address.state_province_id',
522a26c9 586 'table_name' => 'civicrm_address',
587 'entity' => 'Address',
588 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 589 'localizable' => 0,
65c86f7d 590 'localize_context' => 'province',
e501603b 591 'FKClassName' => 'CRM_Core_DAO_StateProvince',
c3fc2621 592 'html' => [
e501603b 593 'type' => 'ChainSelect',
8ada2bfd 594 'controlField' => 'country_id',
c3fc2621
CW
595 ],
596 'pseudoconstant' => [
e501603b
TO
597 'table' => 'civicrm_state_province',
598 'keyColumn' => 'id',
599 'labelColumn' => 'name',
e6ca0a57 600 ],
c3fc2621
CW
601 ],
602 'postal_code_suffix' => [
e501603b
TO
603 'name' => 'postal_code_suffix',
604 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 605 'title' => ts('Postal Code Suffix'),
215b423e 606 'description' => ts('Store the suffix, like the +4 part in the USPS system.'),
e501603b
TO
607 'maxlength' => 12,
608 'size' => 3,
c3fc2621 609 'import' => TRUE,
e501603b
TO
610 'where' => 'civicrm_address.postal_code_suffix',
611 'headerPattern' => '/p(ostal)\sc(ode)\ss(uffix)/i',
612 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
c3fc2621 613 'export' => TRUE,
522a26c9 614 'table_name' => 'civicrm_address',
615 'entity' => 'Address',
616 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 617 'localizable' => 0,
c3fc2621 618 'html' => [
e501603b 619 'type' => 'Text',
c3fc2621
CW
620 ],
621 ],
622 'postal_code' => [
e501603b
TO
623 'name' => 'postal_code',
624 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 625 'title' => ts('Postal Code'),
215b423e 626 'description' => ts('Store both US (zip5) AND international postal codes. App is responsible for country/region appropriate validation.'),
e501603b
TO
627 'maxlength' => 64,
628 'size' => 6,
c3fc2621 629 'import' => TRUE,
e501603b
TO
630 'where' => 'civicrm_address.postal_code',
631 'headerPattern' => '/postal|zip/i',
632 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
c3fc2621 633 'export' => TRUE,
522a26c9 634 'table_name' => 'civicrm_address',
635 'entity' => 'Address',
636 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 637 'localizable' => 0,
c3fc2621 638 'html' => [
e501603b 639 'type' => 'Text',
c3fc2621
CW
640 ],
641 ],
642 'usps_adc' => [
e501603b
TO
643 'name' => 'usps_adc',
644 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 645 'title' => ts('USPS Code'),
215b423e 646 'description' => ts('USPS Bulk mailing code.'),
e501603b
TO
647 'maxlength' => 32,
648 'size' => CRM_Utils_Type::MEDIUM,
a36434b9 649 'where' => 'civicrm_address.usps_adc',
522a26c9 650 'table_name' => 'civicrm_address',
651 'entity' => 'Address',
652 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 653 'localizable' => 0,
c3fc2621
CW
654 ],
655 'country_id' => [
e501603b
TO
656 'name' => 'country_id',
657 'type' => CRM_Utils_Type::T_INT,
c3fc2621 658 'title' => ts('Country'),
215b423e 659 'description' => ts('Which Country does this address belong to.'),
a36434b9 660 'where' => 'civicrm_address.country_id',
522a26c9 661 'table_name' => 'civicrm_address',
662 'entity' => 'Address',
663 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 664 'localizable' => 0,
65c86f7d 665 'localize_context' => 'country',
e501603b 666 'FKClassName' => 'CRM_Core_DAO_Country',
c3fc2621 667 'html' => [
e501603b 668 'type' => 'Select',
c3fc2621
CW
669 ],
670 'pseudoconstant' => [
e501603b
TO
671 'table' => 'civicrm_country',
672 'keyColumn' => 'id',
673 'labelColumn' => 'name',
674 'nameColumn' => 'iso_code',
a8fdb24e 675 'abbrColumn' => 'iso_code',
e6ca0a57 676 ],
c3fc2621
CW
677 ],
678 'geo_code_1' => [
e501603b
TO
679 'name' => 'geo_code_1',
680 'type' => CRM_Utils_Type::T_FLOAT,
c3fc2621 681 'title' => ts('Latitude'),
215b423e 682 'description' => ts('Latitude'),
c3fc2621 683 'import' => TRUE,
e501603b
TO
684 'where' => 'civicrm_address.geo_code_1',
685 'headerPattern' => '/geo/i',
c3fc2621 686 'export' => TRUE,
522a26c9 687 'table_name' => 'civicrm_address',
688 'entity' => 'Address',
689 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 690 'localizable' => 0,
c3fc2621 691 'html' => [
e501603b 692 'type' => 'Text',
c3fc2621
CW
693 ],
694 ],
695 'geo_code_2' => [
e501603b
TO
696 'name' => 'geo_code_2',
697 'type' => CRM_Utils_Type::T_FLOAT,
c3fc2621 698 'title' => ts('Longitude'),
215b423e 699 'description' => ts('Longitude'),
c3fc2621 700 'import' => TRUE,
e501603b
TO
701 'where' => 'civicrm_address.geo_code_2',
702 'headerPattern' => '/geo/i',
c3fc2621 703 'export' => TRUE,
522a26c9 704 'table_name' => 'civicrm_address',
705 'entity' => 'Address',
706 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 707 'localizable' => 0,
c3fc2621 708 'html' => [
e501603b 709 'type' => 'Text',
c3fc2621
CW
710 ],
711 ],
712 'manual_geo_code' => [
e501603b
TO
713 'name' => 'manual_geo_code',
714 'type' => CRM_Utils_Type::T_BOOLEAN,
4fcfc078 715 'title' => ts('Is Manually Geocoded'),
215b423e 716 'description' => ts('Is this a manually entered geo code'),
a36434b9 717 'where' => 'civicrm_address.manual_geo_code',
4fcfc078 718 'export' => TRUE,
45a83e42 719 'default' => '0',
522a26c9 720 'table_name' => 'civicrm_address',
721 'entity' => 'Address',
722 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 723 'localizable' => 0,
c3fc2621 724 'html' => [
e501603b 725 'type' => 'CheckBox',
c3fc2621
CW
726 ],
727 ],
728 'timezone' => [
e501603b
TO
729 'name' => 'timezone',
730 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 731 'title' => ts('Timezone'),
215b423e 732 'description' => ts('Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6".'),
e501603b
TO
733 'maxlength' => 8,
734 'size' => CRM_Utils_Type::EIGHT,
a36434b9 735 'where' => 'civicrm_address.timezone',
522a26c9 736 'table_name' => 'civicrm_address',
737 'entity' => 'Address',
738 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 739 'localizable' => 0,
c3fc2621 740 'html' => [
e501603b 741 'type' => 'Text',
c3fc2621
CW
742 ],
743 ],
744 'address_name' => [
e501603b
TO
745 'name' => 'name',
746 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 747 'title' => ts('Address Name'),
e501603b
TO
748 'maxlength' => 255,
749 'size' => CRM_Utils_Type::HUGE,
c3fc2621 750 'import' => TRUE,
e501603b
TO
751 'where' => 'civicrm_address.name',
752 'headerPattern' => '/^location|(l(ocation\s)?name)$/i',
753 'dataPattern' => '/^\w+$/',
c3fc2621 754 'export' => TRUE,
522a26c9 755 'table_name' => 'civicrm_address',
756 'entity' => 'Address',
757 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 758 'localizable' => 0,
c3fc2621 759 'html' => [
e501603b 760 'type' => 'Text',
c3fc2621
CW
761 ],
762 ],
763 'master_id' => [
e501603b
TO
764 'name' => 'master_id',
765 'type' => CRM_Utils_Type::T_INT,
c3fc2621 766 'title' => ts('Master Address Belongs To'),
215b423e 767 'description' => ts('FK to Address ID'),
c3fc2621 768 'import' => TRUE,
e501603b 769 'where' => 'civicrm_address.master_id',
c3fc2621 770 'export' => TRUE,
522a26c9 771 'table_name' => 'civicrm_address',
772 'entity' => 'Address',
773 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 774 'localizable' => 0,
e501603b 775 'FKClassName' => 'CRM_Core_DAO_Address',
c3fc2621
CW
776 ],
777 ];
346aaaba 778 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 779 }
346aaaba 780 return Civi::$statics[__CLASS__]['fields'];
e501603b 781 }
c3fc2621 782
e501603b 783 /**
bd8e0b14 784 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
785 *
786 * @return array
bd8e0b14 787 * Array(string $name => string $uniqueName).
e501603b 788 */
c3fc2621 789 public static function &fieldKeys() {
bd8e0b14
TO
790 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
791 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 792 }
bd8e0b14 793 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 794 }
c3fc2621 795
e501603b
TO
796 /**
797 * Returns the names of this table
798 *
799 * @return string
800 */
c3fc2621 801 public static function getTableName() {
e501603b
TO
802 return self::$_tableName;
803 }
c3fc2621 804
e501603b
TO
805 /**
806 * Returns if this table needs to be logged
807 *
c3fc2621 808 * @return bool
e501603b 809 */
c3fc2621 810 public function getLog() {
e501603b
TO
811 return self::$_log;
812 }
c3fc2621 813
e501603b
TO
814 /**
815 * Returns the list of fields that can be imported
816 *
817 * @param bool $prefix
818 *
819 * @return array
820 */
c3fc2621
CW
821 public static function &import($prefix = FALSE) {
822 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'address', $prefix, [
60808919
TO
823 'CRM_Core_DAO_County',
824 'CRM_Core_DAO_StateProvince',
825 'CRM_Core_DAO_Country',
c3fc2621 826 ]);
60808919 827 return $r;
e501603b 828 }
c3fc2621 829
e501603b
TO
830 /**
831 * Returns the list of fields that can be exported
832 *
833 * @param bool $prefix
834 *
835 * @return array
836 */
c3fc2621
CW
837 public static function &export($prefix = FALSE) {
838 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'address', $prefix, [
60808919
TO
839 'CRM_Core_DAO_County',
840 'CRM_Core_DAO_StateProvince',
841 'CRM_Core_DAO_Country',
c3fc2621 842 ]);
60808919 843 return $r;
e501603b 844 }
c3fc2621 845
e7a6b91a
AS
846 /**
847 * Returns the list of indices
c3fc2621
CW
848 *
849 * @param bool $localize
850 *
851 * @return array
e7a6b91a
AS
852 */
853 public static function indices($localize = TRUE) {
c3fc2621
CW
854 $indices = [
855 'index_location_type' => [
e7a6b91a 856 'name' => 'index_location_type',
c3fc2621 857 'field' => [
e7a6b91a 858 0 => 'location_type_id',
c3fc2621
CW
859 ],
860 'localizable' => FALSE,
e7a6b91a 861 'sig' => 'civicrm_address::0::location_type_id',
c3fc2621
CW
862 ],
863 'index_is_primary' => [
e7a6b91a 864 'name' => 'index_is_primary',
c3fc2621 865 'field' => [
e7a6b91a 866 0 => 'is_primary',
c3fc2621
CW
867 ],
868 'localizable' => FALSE,
e7a6b91a 869 'sig' => 'civicrm_address::0::is_primary',
c3fc2621
CW
870 ],
871 'index_is_billing' => [
e7a6b91a 872 'name' => 'index_is_billing',
c3fc2621 873 'field' => [
e7a6b91a 874 0 => 'is_billing',
c3fc2621
CW
875 ],
876 'localizable' => FALSE,
e7a6b91a 877 'sig' => 'civicrm_address::0::is_billing',
c3fc2621
CW
878 ],
879 'index_street_name' => [
e7a6b91a 880 'name' => 'index_street_name',
c3fc2621 881 'field' => [
e7a6b91a 882 0 => 'street_name',
c3fc2621
CW
883 ],
884 'localizable' => FALSE,
e7a6b91a 885 'sig' => 'civicrm_address::0::street_name',
c3fc2621
CW
886 ],
887 'index_city' => [
e7a6b91a 888 'name' => 'index_city',
c3fc2621 889 'field' => [
e7a6b91a 890 0 => 'city',
c3fc2621
CW
891 ],
892 'localizable' => FALSE,
e7a6b91a 893 'sig' => 'civicrm_address::0::city',
c3fc2621 894 ],
d56bfd0e
SL
895 'index_geo_code_1_geo_code_2' => [
896 'name' => 'index_geo_code_1_geo_code_2',
897 'field' => [
898 0 => 'geo_code_1',
899 1 => 'geo_code_2',
900 ],
901 'localizable' => FALSE,
902 'sig' => 'civicrm_address::0::geo_code_1::geo_code_2',
903 ],
c3fc2621 904 ];
e7a6b91a
AS
905 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
906 }
c3fc2621 907
e501603b 908}