Merge pull request #13214 from aydun/getcontextvalues
[civicrm-core.git] / CRM / Core / DAO / Address.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
8c9251b3 5 * @copyright CiviCRM LLC (c) 2004-2018
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/Core/Address.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
e380ee3b 9 * (GenCodeChecksum:7e4fc550c624fb3f273f3b2f53a23ee3)
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,
e501603b 588 'FKClassName' => 'CRM_Core_DAO_StateProvince',
c3fc2621 589 'html' => [
e501603b 590 'type' => 'ChainSelect',
c3fc2621
CW
591 ],
592 'pseudoconstant' => [
e501603b
TO
593 'table' => 'civicrm_state_province',
594 'keyColumn' => 'id',
595 'labelColumn' => 'name',
c3fc2621
CW
596 ]
597 ],
598 'postal_code_suffix' => [
e501603b
TO
599 'name' => 'postal_code_suffix',
600 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 601 'title' => ts('Postal Code Suffix'),
215b423e 602 'description' => ts('Store the suffix, like the +4 part in the USPS system.'),
e501603b
TO
603 'maxlength' => 12,
604 'size' => 3,
c3fc2621 605 'import' => TRUE,
e501603b
TO
606 'where' => 'civicrm_address.postal_code_suffix',
607 'headerPattern' => '/p(ostal)\sc(ode)\ss(uffix)/i',
608 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
c3fc2621 609 'export' => TRUE,
522a26c9 610 'table_name' => 'civicrm_address',
611 'entity' => 'Address',
612 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 613 'localizable' => 0,
c3fc2621 614 'html' => [
e501603b 615 'type' => 'Text',
c3fc2621
CW
616 ],
617 ],
618 'postal_code' => [
e501603b
TO
619 'name' => 'postal_code',
620 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 621 'title' => ts('Postal Code'),
215b423e 622 'description' => ts('Store both US (zip5) AND international postal codes. App is responsible for country/region appropriate validation.'),
e501603b
TO
623 'maxlength' => 64,
624 'size' => 6,
c3fc2621 625 'import' => TRUE,
e501603b
TO
626 'where' => 'civicrm_address.postal_code',
627 'headerPattern' => '/postal|zip/i',
628 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
c3fc2621 629 'export' => TRUE,
522a26c9 630 'table_name' => 'civicrm_address',
631 'entity' => 'Address',
632 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 633 'localizable' => 0,
c3fc2621 634 'html' => [
e501603b 635 'type' => 'Text',
c3fc2621
CW
636 ],
637 ],
638 'usps_adc' => [
e501603b
TO
639 'name' => 'usps_adc',
640 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 641 'title' => ts('USPS Code'),
215b423e 642 'description' => ts('USPS Bulk mailing code.'),
e501603b
TO
643 'maxlength' => 32,
644 'size' => CRM_Utils_Type::MEDIUM,
522a26c9 645 'table_name' => 'civicrm_address',
646 'entity' => 'Address',
647 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 648 'localizable' => 0,
c3fc2621
CW
649 ],
650 'country_id' => [
e501603b
TO
651 'name' => 'country_id',
652 'type' => CRM_Utils_Type::T_INT,
c3fc2621 653 'title' => ts('Country'),
215b423e 654 'description' => ts('Which Country does this address belong to.'),
522a26c9 655 'table_name' => 'civicrm_address',
656 'entity' => 'Address',
657 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 658 'localizable' => 0,
e501603b 659 'FKClassName' => 'CRM_Core_DAO_Country',
c3fc2621 660 'html' => [
e501603b 661 'type' => 'Select',
c3fc2621
CW
662 ],
663 'pseudoconstant' => [
e501603b
TO
664 'table' => 'civicrm_country',
665 'keyColumn' => 'id',
666 'labelColumn' => 'name',
667 'nameColumn' => 'iso_code',
c3fc2621
CW
668 ]
669 ],
670 'geo_code_1' => [
e501603b
TO
671 'name' => 'geo_code_1',
672 'type' => CRM_Utils_Type::T_FLOAT,
c3fc2621 673 'title' => ts('Latitude'),
215b423e 674 'description' => ts('Latitude'),
c3fc2621 675 'import' => TRUE,
e501603b
TO
676 'where' => 'civicrm_address.geo_code_1',
677 'headerPattern' => '/geo/i',
678 'dataPattern' => '',
c3fc2621 679 'export' => TRUE,
522a26c9 680 'table_name' => 'civicrm_address',
681 'entity' => 'Address',
682 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 683 'localizable' => 0,
c3fc2621 684 'html' => [
e501603b 685 'type' => 'Text',
c3fc2621
CW
686 ],
687 ],
688 'geo_code_2' => [
e501603b
TO
689 'name' => 'geo_code_2',
690 'type' => CRM_Utils_Type::T_FLOAT,
c3fc2621 691 'title' => ts('Longitude'),
215b423e 692 'description' => ts('Longitude'),
c3fc2621 693 'import' => TRUE,
e501603b
TO
694 'where' => 'civicrm_address.geo_code_2',
695 'headerPattern' => '/geo/i',
696 'dataPattern' => '',
c3fc2621 697 'export' => TRUE,
522a26c9 698 'table_name' => 'civicrm_address',
699 'entity' => 'Address',
700 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 701 'localizable' => 0,
c3fc2621 702 'html' => [
e501603b 703 'type' => 'Text',
c3fc2621
CW
704 ],
705 ],
706 'manual_geo_code' => [
e501603b
TO
707 'name' => 'manual_geo_code',
708 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 709 'title' => ts('Is manually geocoded'),
215b423e 710 'description' => ts('Is this a manually entered geo code'),
45a83e42 711 'default' => '0',
522a26c9 712 'table_name' => 'civicrm_address',
713 'entity' => 'Address',
714 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 715 'localizable' => 0,
c3fc2621 716 'html' => [
e501603b 717 'type' => 'CheckBox',
c3fc2621
CW
718 ],
719 ],
720 'timezone' => [
e501603b
TO
721 'name' => 'timezone',
722 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 723 'title' => ts('Timezone'),
215b423e 724 'description' => ts('Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6".'),
e501603b
TO
725 'maxlength' => 8,
726 'size' => CRM_Utils_Type::EIGHT,
522a26c9 727 'table_name' => 'civicrm_address',
728 'entity' => 'Address',
729 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 730 'localizable' => 0,
c3fc2621 731 'html' => [
e501603b 732 'type' => 'Text',
c3fc2621
CW
733 ],
734 ],
735 'address_name' => [
e501603b
TO
736 'name' => 'name',
737 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 738 'title' => ts('Address Name'),
e501603b
TO
739 'maxlength' => 255,
740 'size' => CRM_Utils_Type::HUGE,
c3fc2621 741 'import' => TRUE,
e501603b
TO
742 'where' => 'civicrm_address.name',
743 'headerPattern' => '/^location|(l(ocation\s)?name)$/i',
744 'dataPattern' => '/^\w+$/',
c3fc2621 745 'export' => TRUE,
522a26c9 746 'table_name' => 'civicrm_address',
747 'entity' => 'Address',
748 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 749 'localizable' => 0,
c3fc2621 750 'html' => [
e501603b 751 'type' => 'Text',
c3fc2621
CW
752 ],
753 ],
754 'master_id' => [
e501603b
TO
755 'name' => 'master_id',
756 'type' => CRM_Utils_Type::T_INT,
c3fc2621 757 'title' => ts('Master Address Belongs To'),
215b423e 758 'description' => ts('FK to Address ID'),
c3fc2621 759 'import' => TRUE,
e501603b
TO
760 'where' => 'civicrm_address.master_id',
761 'headerPattern' => '',
762 'dataPattern' => '',
c3fc2621 763 'export' => TRUE,
522a26c9 764 'table_name' => 'civicrm_address',
765 'entity' => 'Address',
766 'bao' => 'CRM_Core_BAO_Address',
6a7e5e5d 767 'localizable' => 0,
e501603b 768 'FKClassName' => 'CRM_Core_DAO_Address',
c3fc2621
CW
769 ],
770 ];
346aaaba 771 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 772 }
346aaaba 773 return Civi::$statics[__CLASS__]['fields'];
e501603b 774 }
c3fc2621 775
e501603b 776 /**
bd8e0b14 777 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
778 *
779 * @return array
bd8e0b14 780 * Array(string $name => string $uniqueName).
e501603b 781 */
c3fc2621 782 public static function &fieldKeys() {
bd8e0b14
TO
783 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
784 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 785 }
bd8e0b14 786 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 787 }
c3fc2621 788
e501603b
TO
789 /**
790 * Returns the names of this table
791 *
792 * @return string
793 */
c3fc2621 794 public static function getTableName() {
e501603b
TO
795 return self::$_tableName;
796 }
c3fc2621 797
e501603b
TO
798 /**
799 * Returns if this table needs to be logged
800 *
c3fc2621 801 * @return bool
e501603b 802 */
c3fc2621 803 public function getLog() {
e501603b
TO
804 return self::$_log;
805 }
c3fc2621 806
e501603b
TO
807 /**
808 * Returns the list of fields that can be imported
809 *
810 * @param bool $prefix
811 *
812 * @return array
813 */
c3fc2621
CW
814 public static function &import($prefix = FALSE) {
815 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'address', $prefix, [
60808919
TO
816 'CRM_Core_DAO_County',
817 'CRM_Core_DAO_StateProvince',
818 'CRM_Core_DAO_Country',
c3fc2621 819 ]);
60808919 820 return $r;
e501603b 821 }
c3fc2621 822
e501603b
TO
823 /**
824 * Returns the list of fields that can be exported
825 *
826 * @param bool $prefix
827 *
828 * @return array
829 */
c3fc2621
CW
830 public static function &export($prefix = FALSE) {
831 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'address', $prefix, [
60808919
TO
832 'CRM_Core_DAO_County',
833 'CRM_Core_DAO_StateProvince',
834 'CRM_Core_DAO_Country',
c3fc2621 835 ]);
60808919 836 return $r;
e501603b 837 }
c3fc2621 838
e7a6b91a
AS
839 /**
840 * Returns the list of indices
c3fc2621
CW
841 *
842 * @param bool $localize
843 *
844 * @return array
e7a6b91a
AS
845 */
846 public static function indices($localize = TRUE) {
c3fc2621
CW
847 $indices = [
848 'index_location_type' => [
e7a6b91a 849 'name' => 'index_location_type',
c3fc2621 850 'field' => [
e7a6b91a 851 0 => 'location_type_id',
c3fc2621
CW
852 ],
853 'localizable' => FALSE,
e7a6b91a 854 'sig' => 'civicrm_address::0::location_type_id',
c3fc2621
CW
855 ],
856 'index_is_primary' => [
e7a6b91a 857 'name' => 'index_is_primary',
c3fc2621 858 'field' => [
e7a6b91a 859 0 => 'is_primary',
c3fc2621
CW
860 ],
861 'localizable' => FALSE,
e7a6b91a 862 'sig' => 'civicrm_address::0::is_primary',
c3fc2621
CW
863 ],
864 'index_is_billing' => [
e7a6b91a 865 'name' => 'index_is_billing',
c3fc2621 866 'field' => [
e7a6b91a 867 0 => 'is_billing',
c3fc2621
CW
868 ],
869 'localizable' => FALSE,
e7a6b91a 870 'sig' => 'civicrm_address::0::is_billing',
c3fc2621
CW
871 ],
872 'index_street_name' => [
e7a6b91a 873 'name' => 'index_street_name',
c3fc2621 874 'field' => [
e7a6b91a 875 0 => 'street_name',
c3fc2621
CW
876 ],
877 'localizable' => FALSE,
e7a6b91a 878 'sig' => 'civicrm_address::0::street_name',
c3fc2621
CW
879 ],
880 'index_city' => [
e7a6b91a 881 'name' => 'index_city',
c3fc2621 882 'field' => [
e7a6b91a 883 0 => 'city',
c3fc2621
CW
884 ],
885 'localizable' => FALSE,
e7a6b91a 886 'sig' => 'civicrm_address::0::city',
c3fc2621
CW
887 ],
888 ];
e7a6b91a
AS
889 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
890 }
c3fc2621 891
e501603b 892}