Merge pull request #9599 from colemanw/CRM-19812
[civicrm-core.git] / CRM / Core / DAO / Address.php
CommitLineData
e501603b
TO
1<?php
2/*
3+--------------------------------------------------------------------+
4| CiviCRM version 4.7 |
5+--------------------------------------------------------------------+
6| Copyright CiviCRM LLC (c) 2004-2016 |
7+--------------------------------------------------------------------+
8| This file is a part of CiviCRM. |
9| |
10| CiviCRM is free software; you can copy, modify, and distribute it |
11| under the terms of the GNU Affero General Public License |
12| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13| |
14| CiviCRM is distributed in the hope that it will be useful, but |
15| WITHOUT ANY WARRANTY; without even the implied warranty of |
16| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17| See the GNU Affero General Public License for more details. |
18| |
19| You should have received a copy of the GNU Affero General Public |
20| License and the CiviCRM Licensing Exception along |
21| with this program; if not, contact CiviCRM LLC |
22| at info[AT]civicrm[DOT]org. If you have questions about the |
23| GNU Affero General Public License or the licensing of CiviCRM, |
24| see the CiviCRM license FAQ at http://civicrm.org/licensing |
25+--------------------------------------------------------------------+
26*/
27/**
28 * @package CRM
29 * @copyright CiviCRM LLC (c) 2004-2016
30 *
31 * Generated from xml/schema/CRM/Core/Address.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
437fafcf 33 * (GenCodeChecksum:af966c0284f44b6d20f654125b211c37)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
e501603b
TO
37class CRM_Core_DAO_Address extends CRM_Core_DAO {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 */
43 static $_tableName = 'civicrm_address';
e501603b
TO
44 /**
45 * static value to see if we should log any modifications to
46 * this table in the civicrm_log table
47 *
48 * @var boolean
49 */
50 static $_log = true;
51 /**
52 * Unique Address ID
53 *
54 * @var int unsigned
55 */
56 public $id;
57 /**
58 * FK to Contact ID
59 *
60 * @var int unsigned
61 */
62 public $contact_id;
63 /**
64 * Which Location does this address belong to.
65 *
66 * @var int unsigned
67 */
68 public $location_type_id;
69 /**
70 * Is this the primary address.
71 *
72 * @var boolean
73 */
74 public $is_primary;
75 /**
76 * Is this the billing address.
77 *
78 * @var boolean
79 */
80 public $is_billing;
81 /**
82 * Concatenation of all routable street address components (prefix, street number, street name, suffix, unit
83 number OR P.O. Box). Apps should be able to determine physical location with this data (for mapping, mail
84 delivery, etc.).
85 *
86 * @var string
87 */
88 public $street_address;
89 /**
90 * Numeric portion of address number on the street, e.g. For 112A Main St, the street_number = 112.
91 *
92 * @var int
93 */
94 public $street_number;
95 /**
96 * Non-numeric portion of address number on the street, e.g. For 112A Main St, the street_number_suffix = A
97 *
98 * @var string
99 */
100 public $street_number_suffix;
101 /**
102 * Directional prefix, e.g. SE Main St, SE is the prefix.
103 *
104 * @var string
105 */
106 public $street_number_predirectional;
107 /**
108 * Actual street name, excluding St, Dr, Rd, Ave, e.g. For 112 Main St, the street_name = Main.
109 *
110 * @var string
111 */
112 public $street_name;
113 /**
114 * St, Rd, Dr, etc.
115 *
116 * @var string
117 */
118 public $street_type;
119 /**
120 * Directional prefix, e.g. Main St S, S is the suffix.
121 *
122 * @var string
123 */
124 public $street_number_postdirectional;
125 /**
126 * Secondary unit designator, e.g. Apt 3 or Unit # 14, or Bldg 1200
127 *
128 * @var string
129 */
130 public $street_unit;
131 /**
132 * Supplemental Address Information, Line 1
133 *
134 * @var string
135 */
136 public $supplemental_address_1;
137 /**
138 * Supplemental Address Information, Line 2
139 *
140 * @var string
141 */
142 public $supplemental_address_2;
143 /**
144 * Supplemental Address Information, Line 3
145 *
146 * @var string
147 */
148 public $supplemental_address_3;
149 /**
150 * City, Town or Village Name.
151 *
152 * @var string
153 */
154 public $city;
155 /**
156 * Which County does this address belong to.
157 *
158 * @var int unsigned
159 */
160 public $county_id;
161 /**
162 * Which State_Province does this address belong to.
163 *
164 * @var int unsigned
165 */
166 public $state_province_id;
167 /**
168 * Store the suffix, like the +4 part in the USPS system.
169 *
170 * @var string
171 */
172 public $postal_code_suffix;
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;
179 /**
180 * USPS Bulk mailing code.
181 *
182 * @var string
183 */
184 public $usps_adc;
185 /**
186 * Which Country does this address belong to.
187 *
188 * @var int unsigned
189 */
190 public $country_id;
191 /**
192 * Latitude
193 *
194 * @var float
195 */
196 public $geo_code_1;
197 /**
198 * Longitude
199 *
200 * @var float
201 */
202 public $geo_code_2;
203 /**
204 * Is this a manually entered geo code
205 *
206 * @var boolean
207 */
208 public $manual_geo_code;
209 /**
210 * Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6".
211 *
212 * @var string
213 */
214 public $timezone;
215 /**
216 *
217 * @var string
218 */
219 public $name;
220 /**
221 * FK to Address ID
222 *
223 * @var int unsigned
224 */
225 public $master_id;
226 /**
227 * class constructor
228 *
229 * @return civicrm_address
230 */
231 function __construct() {
232 $this->__table = 'civicrm_address';
233 parent::__construct();
234 }
235 /**
236 * Returns foreign keys and entity references
237 *
238 * @return array
239 * [CRM_Core_Reference_Interface]
240 */
241 static function getReferenceColumns() {
346aaaba
TO
242 if (!isset(Civi::$statics[__CLASS__]['links'])) {
243 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
244 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'contact_id', 'civicrm_contact', 'id');
245 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'county_id', 'civicrm_county', 'id');
246 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'state_province_id', 'civicrm_state_province', 'id');
247 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'country_id', 'civicrm_country', 'id');
248 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'master_id', 'civicrm_address', 'id');
249 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 250 }
346aaaba 251 return Civi::$statics[__CLASS__]['links'];
e501603b
TO
252 }
253 /**
254 * Returns all the column names of this table
255 *
256 * @return array
257 */
258 static function &fields() {
346aaaba
TO
259 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
260 Civi::$statics[__CLASS__]['fields'] = array(
e501603b
TO
261 'id' => array(
262 'name' => 'id',
263 'type' => CRM_Utils_Type::T_INT,
264 'title' => ts('Address ID') ,
265 'description' => 'Unique Address ID',
266 'required' => true,
267 ) ,
268 'contact_id' => array(
269 'name' => 'contact_id',
270 'type' => CRM_Utils_Type::T_INT,
271 'title' => ts('Contact ID') ,
272 'description' => 'FK to Contact ID',
273 'FKClassName' => 'CRM_Contact_DAO_Contact',
274 ) ,
275 'location_type_id' => array(
276 'name' => 'location_type_id',
277 'type' => CRM_Utils_Type::T_INT,
278 'title' => ts('Address Location Type') ,
279 'description' => 'Which Location does this address belong to.',
280 'html' => array(
281 'type' => 'Select',
282 ) ,
283 'pseudoconstant' => array(
284 'table' => 'civicrm_location_type',
285 'keyColumn' => 'id',
286 'labelColumn' => 'display_name',
287 )
288 ) ,
289 'is_primary' => array(
290 'name' => 'is_primary',
291 'type' => CRM_Utils_Type::T_BOOLEAN,
292 'title' => ts('Is Address Primary?') ,
293 'description' => 'Is this the primary address.',
294 'html' => array(
295 'type' => 'CheckBox',
296 ) ,
297 ) ,
298 'is_billing' => array(
299 'name' => 'is_billing',
300 'type' => CRM_Utils_Type::T_BOOLEAN,
301 'title' => ts('Is Billing Address') ,
302 'description' => 'Is this the billing address.',
303 'html' => array(
304 'type' => 'CheckBox',
305 ) ,
306 ) ,
307 'street_address' => array(
308 'name' => 'street_address',
309 'type' => CRM_Utils_Type::T_STRING,
310 'title' => ts('Street Address') ,
311 'description' => 'Concatenation of all routable street address components (prefix, street number, street name, suffix, unit
312 number OR P.O. Box). Apps should be able to determine physical location with this data (for mapping, mail
313 delivery, etc.).
314 ',
315 'maxlength' => 96,
316 'size' => CRM_Utils_Type::HUGE,
317 'import' => true,
318 'where' => 'civicrm_address.street_address',
319 'headerPattern' => '/(street|address)/i',
320 'dataPattern' => '/^(\d{1,5}( [0-9A-Za-z]+)+)$|^(P\.?O\.\? Box \d{1,5})$/i',
321 'export' => true,
322 'html' => array(
323 'type' => 'Text',
324 ) ,
325 ) ,
326 'street_number' => array(
327 'name' => 'street_number',
328 'type' => CRM_Utils_Type::T_INT,
329 'title' => ts('Street Number') ,
330 'description' => 'Numeric portion of address number on the street, e.g. For 112A Main St, the street_number = 112.',
331 'export' => true,
332 'where' => 'civicrm_address.street_number',
333 'headerPattern' => '',
334 'dataPattern' => '',
335 'html' => array(
336 'type' => 'Text',
337 ) ,
338 ) ,
339 'street_number_suffix' => array(
340 'name' => 'street_number_suffix',
341 'type' => CRM_Utils_Type::T_STRING,
342 'title' => ts('Street Number Suffix') ,
343 'description' => 'Non-numeric portion of address number on the street, e.g. For 112A Main St, the street_number_suffix = A
344 ',
345 'maxlength' => 8,
346 'size' => CRM_Utils_Type::EIGHT,
347 'export' => true,
348 'where' => 'civicrm_address.street_number_suffix',
349 'headerPattern' => '',
350 'dataPattern' => '',
351 'html' => array(
352 'type' => 'Text',
353 ) ,
354 ) ,
355 'street_number_predirectional' => array(
356 'name' => 'street_number_predirectional',
357 'type' => CRM_Utils_Type::T_STRING,
358 'title' => ts('Street Direction Prefix') ,
359 'description' => 'Directional prefix, e.g. SE Main St, SE is the prefix.',
360 'maxlength' => 8,
361 'size' => CRM_Utils_Type::EIGHT,
362 'html' => array(
363 'type' => 'Text',
364 ) ,
365 ) ,
366 'street_name' => array(
367 'name' => 'street_name',
368 'type' => CRM_Utils_Type::T_STRING,
369 'title' => ts('Street Name') ,
370 'description' => 'Actual street name, excluding St, Dr, Rd, Ave, e.g. For 112 Main St, the street_name = Main.',
371 'maxlength' => 64,
372 'size' => CRM_Utils_Type::BIG,
373 'export' => true,
374 'where' => 'civicrm_address.street_name',
375 'headerPattern' => '',
376 'dataPattern' => '',
377 'html' => array(
378 'type' => 'Text',
379 ) ,
380 ) ,
381 'street_type' => array(
382 'name' => 'street_type',
383 'type' => CRM_Utils_Type::T_STRING,
384 'title' => ts('Street Type') ,
385 'description' => 'St, Rd, Dr, etc.',
386 'maxlength' => 8,
387 'size' => CRM_Utils_Type::EIGHT,
388 'html' => array(
389 'type' => 'Text',
390 ) ,
391 ) ,
392 'street_number_postdirectional' => array(
393 'name' => 'street_number_postdirectional',
394 'type' => CRM_Utils_Type::T_STRING,
395 'title' => ts('Street Direction Suffix') ,
396 'description' => 'Directional prefix, e.g. Main St S, S is the suffix.',
397 'maxlength' => 8,
398 'size' => CRM_Utils_Type::EIGHT,
399 'html' => array(
400 'type' => 'Text',
401 ) ,
402 ) ,
403 'street_unit' => array(
404 'name' => 'street_unit',
405 'type' => CRM_Utils_Type::T_STRING,
406 'title' => ts('Street Unit') ,
407 'description' => 'Secondary unit designator, e.g. Apt 3 or Unit # 14, or Bldg 1200',
408 'maxlength' => 16,
409 'size' => CRM_Utils_Type::TWELVE,
410 'export' => true,
411 'where' => 'civicrm_address.street_unit',
412 'headerPattern' => '',
413 'dataPattern' => '',
414 'html' => array(
415 'type' => 'Text',
416 ) ,
417 ) ,
418 'supplemental_address_1' => array(
419 'name' => 'supplemental_address_1',
420 'type' => CRM_Utils_Type::T_STRING,
421 'title' => ts('Supplemental Address 1') ,
422 'description' => 'Supplemental Address Information, Line 1',
423 'maxlength' => 96,
424 'size' => CRM_Utils_Type::HUGE,
425 'import' => true,
426 'where' => 'civicrm_address.supplemental_address_1',
427 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
428 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
429 'export' => true,
430 'html' => array(
431 'type' => 'Text',
432 ) ,
433 ) ,
434 'supplemental_address_2' => array(
435 'name' => 'supplemental_address_2',
436 'type' => CRM_Utils_Type::T_STRING,
437 'title' => ts('Supplemental Address 2') ,
438 'description' => 'Supplemental Address Information, Line 2',
439 'maxlength' => 96,
440 'size' => CRM_Utils_Type::HUGE,
441 'import' => true,
442 'where' => 'civicrm_address.supplemental_address_2',
443 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
444 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
445 'export' => true,
446 'html' => array(
447 'type' => 'Text',
448 ) ,
449 ) ,
450 'supplemental_address_3' => array(
451 'name' => 'supplemental_address_3',
452 'type' => CRM_Utils_Type::T_STRING,
453 'title' => ts('Supplemental Address 3') ,
454 'description' => 'Supplemental Address Information, Line 3',
455 'maxlength' => 96,
456 'size' => CRM_Utils_Type::HUGE,
457 'html' => array(
458 'type' => 'Text',
459 ) ,
460 ) ,
461 'city' => array(
462 'name' => 'city',
463 'type' => CRM_Utils_Type::T_STRING,
464 'title' => ts('City') ,
465 'description' => 'City, Town or Village Name.',
466 'maxlength' => 64,
467 'size' => CRM_Utils_Type::BIG,
468 'import' => true,
469 'where' => 'civicrm_address.city',
470 'headerPattern' => '/city/i',
471 'dataPattern' => '/^[A-Za-z]+(\.?)(\s?[A-Za-z]+){0,2}$/',
472 'export' => true,
473 'html' => array(
474 'type' => 'Text',
475 ) ,
476 ) ,
477 'county_id' => array(
478 'name' => 'county_id',
479 'type' => CRM_Utils_Type::T_INT,
480 'title' => ts('County') ,
481 'description' => 'Which County does this address belong to.',
482 'FKClassName' => 'CRM_Core_DAO_County',
483 'html' => array(
484 'type' => 'ChainSelect',
485 ) ,
486 'pseudoconstant' => array(
487 'table' => 'civicrm_county',
488 'keyColumn' => 'id',
489 'labelColumn' => 'name',
490 )
491 ) ,
492 'state_province_id' => array(
493 'name' => 'state_province_id',
494 'type' => CRM_Utils_Type::T_INT,
495 'title' => ts('State/Province') ,
496 'description' => 'Which State_Province does this address belong to.',
497 'FKClassName' => 'CRM_Core_DAO_StateProvince',
498 'html' => array(
499 'type' => 'ChainSelect',
500 ) ,
501 'pseudoconstant' => array(
502 'table' => 'civicrm_state_province',
503 'keyColumn' => 'id',
504 'labelColumn' => 'name',
505 )
506 ) ,
507 'postal_code_suffix' => array(
508 'name' => 'postal_code_suffix',
509 'type' => CRM_Utils_Type::T_STRING,
510 'title' => ts('Postal Code Suffix') ,
511 'description' => 'Store the suffix, like the +4 part in the USPS system.',
512 'maxlength' => 12,
513 'size' => 3,
514 'import' => true,
515 'where' => 'civicrm_address.postal_code_suffix',
516 'headerPattern' => '/p(ostal)\sc(ode)\ss(uffix)/i',
517 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
518 'export' => true,
519 'html' => array(
520 'type' => 'Text',
521 ) ,
522 ) ,
523 'postal_code' => array(
524 'name' => 'postal_code',
525 'type' => CRM_Utils_Type::T_STRING,
526 'title' => ts('Postal Code') ,
527 'description' => 'Store both US (zip5) AND international postal codes. App is responsible for country/region appropriate validation.',
528 'maxlength' => 64,
529 'size' => 6,
530 'import' => true,
531 'where' => 'civicrm_address.postal_code',
532 'headerPattern' => '/postal|zip/i',
533 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
534 'export' => true,
535 'html' => array(
536 'type' => 'Text',
537 ) ,
538 ) ,
539 'usps_adc' => array(
540 'name' => 'usps_adc',
541 'type' => CRM_Utils_Type::T_STRING,
542 'title' => ts('USPS Code') ,
543 'description' => 'USPS Bulk mailing code.',
544 'maxlength' => 32,
545 'size' => CRM_Utils_Type::MEDIUM,
546 ) ,
547 'country_id' => array(
548 'name' => 'country_id',
549 'type' => CRM_Utils_Type::T_INT,
550 'title' => ts('Country') ,
551 'description' => 'Which Country does this address belong to.',
552 'FKClassName' => 'CRM_Core_DAO_Country',
553 'html' => array(
554 'type' => 'Select',
555 ) ,
556 'pseudoconstant' => array(
557 'table' => 'civicrm_country',
558 'keyColumn' => 'id',
559 'labelColumn' => 'name',
560 'nameColumn' => 'iso_code',
561 )
562 ) ,
563 'geo_code_1' => array(
564 'name' => 'geo_code_1',
565 'type' => CRM_Utils_Type::T_FLOAT,
566 'title' => ts('Latitude') ,
567 'description' => 'Latitude',
568 'import' => true,
569 'where' => 'civicrm_address.geo_code_1',
570 'headerPattern' => '/geo/i',
571 'dataPattern' => '',
572 'export' => true,
573 'html' => array(
574 'type' => 'Text',
575 ) ,
576 ) ,
577 'geo_code_2' => array(
578 'name' => 'geo_code_2',
579 'type' => CRM_Utils_Type::T_FLOAT,
580 'title' => ts('Longitude') ,
581 'description' => 'Longitude',
582 'import' => true,
583 'where' => 'civicrm_address.geo_code_2',
584 'headerPattern' => '/geo/i',
585 'dataPattern' => '',
586 'export' => true,
587 'html' => array(
588 'type' => 'Text',
589 ) ,
590 ) ,
591 'manual_geo_code' => array(
592 'name' => 'manual_geo_code',
593 'type' => CRM_Utils_Type::T_BOOLEAN,
594 'title' => ts('Is manually geocoded') ,
595 'description' => 'Is this a manually entered geo code',
596 'html' => array(
597 'type' => 'CheckBox',
598 ) ,
599 ) ,
600 'timezone' => array(
601 'name' => 'timezone',
602 'type' => CRM_Utils_Type::T_STRING,
603 'title' => ts('Timezone') ,
604 'description' => 'Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6".',
605 'maxlength' => 8,
606 'size' => CRM_Utils_Type::EIGHT,
607 'html' => array(
608 'type' => 'Text',
609 ) ,
610 ) ,
611 'address_name' => array(
612 'name' => 'name',
613 'type' => CRM_Utils_Type::T_STRING,
614 'title' => ts('Address Name') ,
615 'maxlength' => 255,
616 'size' => CRM_Utils_Type::HUGE,
617 'import' => true,
618 'where' => 'civicrm_address.name',
619 'headerPattern' => '/^location|(l(ocation\s)?name)$/i',
620 'dataPattern' => '/^\w+$/',
621 'export' => true,
622 'html' => array(
623 'type' => 'Text',
624 ) ,
625 ) ,
626 'master_id' => array(
627 'name' => 'master_id',
628 'type' => CRM_Utils_Type::T_INT,
629 'title' => ts('Master Address Belongs To') ,
630 'description' => 'FK to Address ID',
631 'import' => true,
632 'where' => 'civicrm_address.master_id',
633 'headerPattern' => '',
634 'dataPattern' => '',
635 'export' => true,
636 'FKClassName' => 'CRM_Core_DAO_Address',
637 ) ,
638 );
346aaaba 639 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 640 }
346aaaba 641 return Civi::$statics[__CLASS__]['fields'];
e501603b
TO
642 }
643 /**
bd8e0b14 644 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
645 *
646 * @return array
bd8e0b14 647 * Array(string $name => string $uniqueName).
e501603b
TO
648 */
649 static function &fieldKeys() {
bd8e0b14
TO
650 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
651 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 652 }
bd8e0b14 653 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b
TO
654 }
655 /**
656 * Returns the names of this table
657 *
658 * @return string
659 */
660 static function getTableName() {
661 return self::$_tableName;
662 }
663 /**
664 * Returns if this table needs to be logged
665 *
666 * @return boolean
667 */
668 function getLog() {
669 return self::$_log;
670 }
671 /**
672 * Returns the list of fields that can be imported
673 *
674 * @param bool $prefix
675 *
676 * @return array
677 */
678 static function &import($prefix = false) {
60808919
TO
679 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'address', $prefix, array(
680 'CRM_Core_DAO_County',
681 'CRM_Core_DAO_StateProvince',
682 'CRM_Core_DAO_Country',
683 ));
684 return $r;
e501603b
TO
685 }
686 /**
687 * Returns the list of fields that can be exported
688 *
689 * @param bool $prefix
690 *
691 * @return array
692 */
693 static function &export($prefix = false) {
60808919
TO
694 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'address', $prefix, array(
695 'CRM_Core_DAO_County',
696 'CRM_Core_DAO_StateProvince',
697 'CRM_Core_DAO_Country',
698 ));
699 return $r;
e501603b
TO
700 }
701}