Merge pull request #13170 from elisseck/dev/core/485
[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
65c86f7d 9 * (GenCodeChecksum:a81d4789f6650c68145ab9bf1e4481a8)
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 */
22 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 */
c3fc2621
CW
29 static $_log = TRUE;
30
e501603b
TO
31 /**
32 * Unique Address ID
33 *
34 * @var int unsigned
35 */
36 public $id;
c3fc2621 37
e501603b
TO
38 /**
39 * FK to Contact ID
40 *
41 * @var int unsigned
42 */
43 public $contact_id;
c3fc2621 44
e501603b
TO
45 /**
46 * Which Location does this address belong to.
47 *
48 * @var int unsigned
49 */
50 public $location_type_id;
c3fc2621 51
e501603b
TO
52 /**
53 * Is this the primary address.
54 *
55 * @var boolean
56 */
57 public $is_primary;
c3fc2621 58
e501603b
TO
59 /**
60 * Is this the billing address.
61 *
62 * @var boolean
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
68 number OR P.O. Box). Apps should be able to determine physical location with this data (for mapping, mail
69 delivery, etc.).
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 *
155 * @var int unsigned
156 */
157 public $county_id;
c3fc2621 158
e501603b
TO
159 /**
160 * Which State_Province does this address belong to.
161 *
162 * @var int unsigned
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 *
190 * @var int unsigned
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 *
211 * @var boolean
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 *
230 * @var int unsigned
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
TO
249 if (!isset(Civi::$statics[__CLASS__]['links'])) {
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,
522a26c9 275 'table_name' => 'civicrm_address',
276 'entity' => 'Address',
277 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 278 'localizable' => 0,
c3fc2621
CW
279 ],
280 'contact_id' => [
e501603b
TO
281 'name' => 'contact_id',
282 'type' => CRM_Utils_Type::T_INT,
c3fc2621 283 'title' => ts('Contact ID'),
215b423e 284 'description' => ts('FK to Contact ID'),
522a26c9 285 'table_name' => 'civicrm_address',
286 'entity' => 'Address',
287 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 288 'localizable' => 0,
e501603b 289 'FKClassName' => 'CRM_Contact_DAO_Contact',
c3fc2621
CW
290 ],
291 'location_type_id' => [
e501603b
TO
292 'name' => 'location_type_id',
293 'type' => CRM_Utils_Type::T_INT,
c3fc2621 294 'title' => ts('Address Location Type'),
215b423e 295 'description' => ts('Which Location does this address belong to.'),
522a26c9 296 'table_name' => 'civicrm_address',
297 'entity' => 'Address',
298 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 299 'localizable' => 0,
c3fc2621 300 'html' => [
e501603b 301 'type' => 'Select',
c3fc2621
CW
302 ],
303 'pseudoconstant' => [
e501603b
TO
304 'table' => 'civicrm_location_type',
305 'keyColumn' => 'id',
306 'labelColumn' => 'display_name',
c3fc2621
CW
307 ]
308 ],
309 'is_primary' => [
e501603b
TO
310 'name' => 'is_primary',
311 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 312 'title' => ts('Is Address Primary?'),
215b423e 313 'description' => ts('Is this the primary address.'),
45a83e42 314 'default' => '0',
522a26c9 315 'table_name' => 'civicrm_address',
316 'entity' => 'Address',
317 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 318 'localizable' => 0,
c3fc2621 319 'html' => [
e501603b 320 'type' => 'CheckBox',
c3fc2621
CW
321 ],
322 ],
323 'is_billing' => [
e501603b
TO
324 'name' => 'is_billing',
325 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 326 'title' => ts('Is Billing Address'),
215b423e 327 'description' => ts('Is this the billing address.'),
45a83e42 328 'default' => '0',
522a26c9 329 'table_name' => 'civicrm_address',
330 'entity' => 'Address',
331 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 332 'localizable' => 0,
c3fc2621 333 'html' => [
e501603b 334 'type' => 'CheckBox',
c3fc2621
CW
335 ],
336 ],
337 'street_address' => [
e501603b
TO
338 'name' => 'street_address',
339 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 340 'title' => ts('Street Address'),
215b423e 341 'description' => ts('Concatenation of all routable street address components (prefix, street number, street name, suffix, unit
e501603b
TO
342 number OR P.O. Box). Apps should be able to determine physical location with this data (for mapping, mail
343 delivery, etc.).
215b423e 344 '),
e501603b
TO
345 'maxlength' => 96,
346 'size' => CRM_Utils_Type::HUGE,
c3fc2621 347 'import' => TRUE,
e501603b
TO
348 'where' => 'civicrm_address.street_address',
349 'headerPattern' => '/(street|address)/i',
350 'dataPattern' => '/^(\d{1,5}( [0-9A-Za-z]+)+)$|^(P\.?O\.\? Box \d{1,5})$/i',
c3fc2621 351 'export' => TRUE,
522a26c9 352 'table_name' => 'civicrm_address',
353 'entity' => 'Address',
354 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 355 'localizable' => 0,
c3fc2621 356 'html' => [
e501603b 357 'type' => 'Text',
c3fc2621
CW
358 ],
359 ],
360 'street_number' => [
e501603b
TO
361 'name' => 'street_number',
362 'type' => CRM_Utils_Type::T_INT,
c3fc2621 363 'title' => ts('Street Number'),
215b423e 364 'description' => ts('Numeric portion of address number on the street, e.g. For 112A Main St, the street_number = 112.'),
c3fc2621 365 'export' => TRUE,
e501603b
TO
366 'where' => 'civicrm_address.street_number',
367 'headerPattern' => '',
368 'dataPattern' => '',
522a26c9 369 'table_name' => 'civicrm_address',
370 'entity' => 'Address',
371 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 372 'localizable' => 0,
c3fc2621 373 'html' => [
e501603b 374 'type' => 'Text',
c3fc2621
CW
375 ],
376 ],
377 'street_number_suffix' => [
e501603b
TO
378 'name' => 'street_number_suffix',
379 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 380 'title' => ts('Street Number Suffix'),
215b423e 381 'description' => ts('Non-numeric portion of address number on the street, e.g. For 112A Main St, the street_number_suffix = A
382 '),
e501603b
TO
383 'maxlength' => 8,
384 'size' => CRM_Utils_Type::EIGHT,
c3fc2621 385 'export' => TRUE,
e501603b
TO
386 'where' => 'civicrm_address.street_number_suffix',
387 'headerPattern' => '',
388 'dataPattern' => '',
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,
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,
c3fc2621 419 'export' => TRUE,
e501603b
TO
420 'where' => 'civicrm_address.street_name',
421 'headerPattern' => '',
422 'dataPattern' => '',
522a26c9 423 'table_name' => 'civicrm_address',
424 'entity' => 'Address',
425 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 426 'localizable' => 0,
c3fc2621 427 'html' => [
e501603b 428 'type' => 'Text',
c3fc2621
CW
429 ],
430 ],
431 'street_type' => [
e501603b
TO
432 'name' => 'street_type',
433 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 434 'title' => ts('Street Type'),
215b423e 435 'description' => ts('St, Rd, Dr, etc.'),
e501603b
TO
436 'maxlength' => 8,
437 'size' => CRM_Utils_Type::EIGHT,
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,
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,
c3fc2621 468 'export' => TRUE,
e501603b
TO
469 'where' => 'civicrm_address.street_unit',
470 'headerPattern' => '',
471 'dataPattern' => '',
522a26c9 472 'table_name' => 'civicrm_address',
473 'entity' => 'Address',
474 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 475 'localizable' => 0,
c3fc2621 476 'html' => [
e501603b 477 'type' => 'Text',
c3fc2621
CW
478 ],
479 ],
480 'supplemental_address_1' => [
e501603b
TO
481 'name' => 'supplemental_address_1',
482 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 483 'title' => ts('Supplemental Address 1'),
215b423e 484 'description' => ts('Supplemental Address Information, Line 1'),
e501603b
TO
485 'maxlength' => 96,
486 'size' => CRM_Utils_Type::HUGE,
c3fc2621 487 'import' => TRUE,
e501603b
TO
488 'where' => 'civicrm_address.supplemental_address_1',
489 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
490 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
c3fc2621 491 'export' => TRUE,
522a26c9 492 'table_name' => 'civicrm_address',
493 'entity' => 'Address',
494 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 495 'localizable' => 0,
c3fc2621 496 'html' => [
e501603b 497 'type' => 'Text',
c3fc2621
CW
498 ],
499 ],
500 'supplemental_address_2' => [
e501603b
TO
501 'name' => 'supplemental_address_2',
502 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 503 'title' => ts('Supplemental Address 2'),
215b423e 504 'description' => ts('Supplemental Address Information, Line 2'),
e501603b
TO
505 'maxlength' => 96,
506 'size' => CRM_Utils_Type::HUGE,
c3fc2621 507 'import' => TRUE,
e501603b
TO
508 'where' => 'civicrm_address.supplemental_address_2',
509 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
510 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
c3fc2621 511 'export' => TRUE,
522a26c9 512 'table_name' => 'civicrm_address',
513 'entity' => 'Address',
514 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 515 'localizable' => 0,
c3fc2621 516 'html' => [
e501603b 517 'type' => 'Text',
c3fc2621
CW
518 ],
519 ],
520 'supplemental_address_3' => [
e501603b
TO
521 'name' => 'supplemental_address_3',
522 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 523 'title' => ts('Supplemental Address 3'),
215b423e 524 'description' => ts('Supplemental Address Information, Line 3'),
e501603b
TO
525 'maxlength' => 96,
526 'size' => CRM_Utils_Type::HUGE,
c3fc2621 527 'import' => TRUE,
207f62c6
AS
528 'where' => 'civicrm_address.supplemental_address_3',
529 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
530 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
c3fc2621 531 'export' => TRUE,
522a26c9 532 'table_name' => 'civicrm_address',
533 'entity' => 'Address',
534 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 535 'localizable' => 0,
c3fc2621 536 'html' => [
e501603b 537 'type' => 'Text',
c3fc2621
CW
538 ],
539 ],
540 'city' => [
e501603b
TO
541 'name' => 'city',
542 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 543 'title' => ts('City'),
215b423e 544 'description' => ts('City, Town or Village Name.'),
e501603b
TO
545 'maxlength' => 64,
546 'size' => CRM_Utils_Type::BIG,
c3fc2621 547 'import' => TRUE,
e501603b
TO
548 'where' => 'civicrm_address.city',
549 'headerPattern' => '/city/i',
550 'dataPattern' => '/^[A-Za-z]+(\.?)(\s?[A-Za-z]+){0,2}$/',
c3fc2621 551 'export' => TRUE,
522a26c9 552 'table_name' => 'civicrm_address',
553 'entity' => 'Address',
554 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 555 'localizable' => 0,
c3fc2621 556 'html' => [
e501603b 557 'type' => 'Text',
c3fc2621
CW
558 ],
559 ],
560 'county_id' => [
e501603b
TO
561 'name' => 'county_id',
562 'type' => CRM_Utils_Type::T_INT,
c3fc2621 563 'title' => ts('County'),
215b423e 564 'description' => ts('Which County does this address belong to.'),
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',
c3fc2621
CW
572 ],
573 'pseudoconstant' => [
e501603b
TO
574 'table' => 'civicrm_county',
575 'keyColumn' => 'id',
576 'labelColumn' => 'name',
c3fc2621
CW
577 ]
578 ],
579 'state_province_id' => [
e501603b
TO
580 'name' => 'state_province_id',
581 'type' => CRM_Utils_Type::T_INT,
c3fc2621 582 'title' => ts('State/Province'),
215b423e 583 'description' => ts('Which State_Province does this address belong to.'),
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',
c3fc2621
CW
597 ]
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,
522a26c9 646 'table_name' => 'civicrm_address',
647 'entity' => 'Address',
648 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 649 'localizable' => 0,
c3fc2621
CW
650 ],
651 'country_id' => [
e501603b
TO
652 'name' => 'country_id',
653 'type' => CRM_Utils_Type::T_INT,
c3fc2621 654 'title' => ts('Country'),
215b423e 655 'description' => ts('Which Country does this address belong to.'),
522a26c9 656 'table_name' => 'civicrm_address',
657 'entity' => 'Address',
658 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 659 'localizable' => 0,
65c86f7d 660 'localize_context' => 'country',
e501603b 661 'FKClassName' => 'CRM_Core_DAO_Country',
c3fc2621 662 'html' => [
e501603b 663 'type' => 'Select',
c3fc2621
CW
664 ],
665 'pseudoconstant' => [
e501603b
TO
666 'table' => 'civicrm_country',
667 'keyColumn' => 'id',
668 'labelColumn' => 'name',
669 'nameColumn' => 'iso_code',
c3fc2621
CW
670 ]
671 ],
672 'geo_code_1' => [
e501603b
TO
673 'name' => 'geo_code_1',
674 'type' => CRM_Utils_Type::T_FLOAT,
c3fc2621 675 'title' => ts('Latitude'),
215b423e 676 'description' => ts('Latitude'),
c3fc2621 677 'import' => TRUE,
e501603b
TO
678 'where' => 'civicrm_address.geo_code_1',
679 'headerPattern' => '/geo/i',
680 'dataPattern' => '',
c3fc2621 681 'export' => TRUE,
522a26c9 682 'table_name' => 'civicrm_address',
683 'entity' => 'Address',
684 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 685 'localizable' => 0,
c3fc2621 686 'html' => [
e501603b 687 'type' => 'Text',
c3fc2621
CW
688 ],
689 ],
690 'geo_code_2' => [
e501603b
TO
691 'name' => 'geo_code_2',
692 'type' => CRM_Utils_Type::T_FLOAT,
c3fc2621 693 'title' => ts('Longitude'),
215b423e 694 'description' => ts('Longitude'),
c3fc2621 695 'import' => TRUE,
e501603b
TO
696 'where' => 'civicrm_address.geo_code_2',
697 'headerPattern' => '/geo/i',
698 'dataPattern' => '',
c3fc2621 699 'export' => TRUE,
522a26c9 700 'table_name' => 'civicrm_address',
701 'entity' => 'Address',
702 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 703 'localizable' => 0,
c3fc2621 704 'html' => [
e501603b 705 'type' => 'Text',
c3fc2621
CW
706 ],
707 ],
708 'manual_geo_code' => [
e501603b
TO
709 'name' => 'manual_geo_code',
710 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 711 'title' => ts('Is manually geocoded'),
215b423e 712 'description' => ts('Is this a manually entered geo code'),
45a83e42 713 'default' => '0',
522a26c9 714 'table_name' => 'civicrm_address',
715 'entity' => 'Address',
716 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 717 'localizable' => 0,
c3fc2621 718 'html' => [
e501603b 719 'type' => 'CheckBox',
c3fc2621
CW
720 ],
721 ],
722 'timezone' => [
e501603b
TO
723 'name' => 'timezone',
724 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 725 'title' => ts('Timezone'),
215b423e 726 'description' => ts('Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6".'),
e501603b
TO
727 'maxlength' => 8,
728 'size' => CRM_Utils_Type::EIGHT,
522a26c9 729 'table_name' => 'civicrm_address',
730 'entity' => 'Address',
731 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 732 'localizable' => 0,
c3fc2621 733 'html' => [
e501603b 734 'type' => 'Text',
c3fc2621
CW
735 ],
736 ],
737 'address_name' => [
e501603b
TO
738 'name' => 'name',
739 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 740 'title' => ts('Address Name'),
e501603b
TO
741 'maxlength' => 255,
742 'size' => CRM_Utils_Type::HUGE,
c3fc2621 743 'import' => TRUE,
e501603b
TO
744 'where' => 'civicrm_address.name',
745 'headerPattern' => '/^location|(l(ocation\s)?name)$/i',
746 'dataPattern' => '/^\w+$/',
c3fc2621 747 'export' => TRUE,
522a26c9 748 'table_name' => 'civicrm_address',
749 'entity' => 'Address',
750 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 751 'localizable' => 0,
c3fc2621 752 'html' => [
e501603b 753 'type' => 'Text',
c3fc2621
CW
754 ],
755 ],
756 'master_id' => [
e501603b
TO
757 'name' => 'master_id',
758 'type' => CRM_Utils_Type::T_INT,
c3fc2621 759 'title' => ts('Master Address Belongs To'),
215b423e 760 'description' => ts('FK to Address ID'),
c3fc2621 761 'import' => TRUE,
e501603b
TO
762 'where' => 'civicrm_address.master_id',
763 'headerPattern' => '',
764 'dataPattern' => '',
c3fc2621 765 'export' => TRUE,
522a26c9 766 'table_name' => 'civicrm_address',
767 'entity' => 'Address',
768 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 769 'localizable' => 0,
e501603b 770 'FKClassName' => 'CRM_Core_DAO_Address',
c3fc2621
CW
771 ],
772 ];
346aaaba 773 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 774 }
346aaaba 775 return Civi::$statics[__CLASS__]['fields'];
e501603b 776 }
c3fc2621 777
e501603b 778 /**
bd8e0b14 779 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
780 *
781 * @return array
bd8e0b14 782 * Array(string $name => string $uniqueName).
e501603b 783 */
c3fc2621 784 public static function &fieldKeys() {
bd8e0b14
TO
785 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
786 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 787 }
bd8e0b14 788 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 789 }
c3fc2621 790
e501603b
TO
791 /**
792 * Returns the names of this table
793 *
794 * @return string
795 */
c3fc2621 796 public static function getTableName() {
e501603b
TO
797 return self::$_tableName;
798 }
c3fc2621 799
e501603b
TO
800 /**
801 * Returns if this table needs to be logged
802 *
c3fc2621 803 * @return bool
e501603b 804 */
c3fc2621 805 public function getLog() {
e501603b
TO
806 return self::$_log;
807 }
c3fc2621 808
e501603b
TO
809 /**
810 * Returns the list of fields that can be imported
811 *
812 * @param bool $prefix
813 *
814 * @return array
815 */
c3fc2621
CW
816 public static function &import($prefix = FALSE) {
817 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'address', $prefix, [
60808919
TO
818 'CRM_Core_DAO_County',
819 'CRM_Core_DAO_StateProvince',
820 'CRM_Core_DAO_Country',
c3fc2621 821 ]);
60808919 822 return $r;
e501603b 823 }
c3fc2621 824
e501603b
TO
825 /**
826 * Returns the list of fields that can be exported
827 *
828 * @param bool $prefix
829 *
830 * @return array
831 */
c3fc2621
CW
832 public static function &export($prefix = FALSE) {
833 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'address', $prefix, [
60808919
TO
834 'CRM_Core_DAO_County',
835 'CRM_Core_DAO_StateProvince',
836 'CRM_Core_DAO_Country',
c3fc2621 837 ]);
60808919 838 return $r;
e501603b 839 }
c3fc2621 840
e7a6b91a
AS
841 /**
842 * Returns the list of indices
c3fc2621
CW
843 *
844 * @param bool $localize
845 *
846 * @return array
e7a6b91a
AS
847 */
848 public static function indices($localize = TRUE) {
c3fc2621
CW
849 $indices = [
850 'index_location_type' => [
e7a6b91a 851 'name' => 'index_location_type',
c3fc2621 852 'field' => [
e7a6b91a 853 0 => 'location_type_id',
c3fc2621
CW
854 ],
855 'localizable' => FALSE,
e7a6b91a 856 'sig' => 'civicrm_address::0::location_type_id',
c3fc2621
CW
857 ],
858 'index_is_primary' => [
e7a6b91a 859 'name' => 'index_is_primary',
c3fc2621 860 'field' => [
e7a6b91a 861 0 => 'is_primary',
c3fc2621
CW
862 ],
863 'localizable' => FALSE,
e7a6b91a 864 'sig' => 'civicrm_address::0::is_primary',
c3fc2621
CW
865 ],
866 'index_is_billing' => [
e7a6b91a 867 'name' => 'index_is_billing',
c3fc2621 868 'field' => [
e7a6b91a 869 0 => 'is_billing',
c3fc2621
CW
870 ],
871 'localizable' => FALSE,
e7a6b91a 872 'sig' => 'civicrm_address::0::is_billing',
c3fc2621
CW
873 ],
874 'index_street_name' => [
e7a6b91a 875 'name' => 'index_street_name',
c3fc2621 876 'field' => [
e7a6b91a 877 0 => 'street_name',
c3fc2621
CW
878 ],
879 'localizable' => FALSE,
e7a6b91a 880 'sig' => 'civicrm_address::0::street_name',
c3fc2621
CW
881 ],
882 'index_city' => [
e7a6b91a 883 'name' => 'index_city',
c3fc2621 884 'field' => [
e7a6b91a 885 0 => 'city',
c3fc2621
CW
886 ],
887 'localizable' => FALSE,
e7a6b91a 888 'sig' => 'civicrm_address::0::city',
c3fc2621
CW
889 ],
890 ];
e7a6b91a
AS
891 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
892 }
c3fc2621 893
e501603b 894}