3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2017 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
29 * @copyright CiviCRM LLC (c) 2004-2017
31 * Generated from xml/schema/CRM/Core/Address.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:af966c0284f44b6d20f654125b211c37)
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 class CRM_Core_DAO_Address
extends CRM_Core_DAO
{
39 * static instance to hold the table name
43 static $_tableName = 'civicrm_address';
45 * static value to see if we should log any modifications to
46 * this table in the civicrm_log table
64 * Which Location does this address belong to.
68 public $location_type_id;
70 * Is this the primary address.
76 * Is this the billing address.
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
88 public $street_address;
90 * Numeric portion of address number on the street, e.g. For 112A Main St, the street_number = 112.
94 public $street_number;
96 * Non-numeric portion of address number on the street, e.g. For 112A Main St, the street_number_suffix = A
100 public $street_number_suffix;
102 * Directional prefix, e.g. SE Main St, SE is the prefix.
106 public $street_number_predirectional;
108 * Actual street name, excluding St, Dr, Rd, Ave, e.g. For 112 Main St, the street_name = Main.
120 * Directional prefix, e.g. Main St S, S is the suffix.
124 public $street_number_postdirectional;
126 * Secondary unit designator, e.g. Apt 3 or Unit # 14, or Bldg 1200
132 * Supplemental Address Information, Line 1
136 public $supplemental_address_1;
138 * Supplemental Address Information, Line 2
142 public $supplemental_address_2;
144 * Supplemental Address Information, Line 3
148 public $supplemental_address_3;
150 * City, Town or Village Name.
156 * Which County does this address belong to.
162 * Which State_Province does this address belong to.
166 public $state_province_id;
168 * Store the suffix, like the +4 part in the USPS system.
172 public $postal_code_suffix;
174 * Store both US (zip5) AND international postal codes. App is responsible for country/region appropriate validation.
180 * USPS Bulk mailing code.
186 * Which Country does this address belong to.
204 * Is this a manually entered geo code
208 public $manual_geo_code;
210 * Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6".
229 * @return civicrm_address
231 function __construct() {
232 $this->__table
= 'civicrm_address';
233 parent
::__construct();
236 * Returns foreign keys and entity references
239 * [CRM_Core_Reference_Interface]
241 static function getReferenceColumns() {
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']);
251 return Civi
::$statics[__CLASS__
]['links'];
254 * Returns all the column names of this table
258 static function &fields() {
259 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
260 Civi
::$statics[__CLASS__
]['fields'] = array(
263 'type' => CRM_Utils_Type
::T_INT
,
264 'title' => ts('Address ID') ,
265 'description' => 'Unique Address ID',
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',
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.',
283 'pseudoconstant' => array(
284 'table' => 'civicrm_location_type',
286 'labelColumn' => 'display_name',
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.',
295 'type' => 'CheckBox',
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.',
304 'type' => 'CheckBox',
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
316 'size' => CRM_Utils_Type
::HUGE
,
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',
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.',
332 'where' => 'civicrm_address.street_number',
333 'headerPattern' => '',
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
346 'size' => CRM_Utils_Type
::EIGHT
,
348 'where' => 'civicrm_address.street_number_suffix',
349 'headerPattern' => '',
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.',
361 'size' => CRM_Utils_Type
::EIGHT
,
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.',
372 'size' => CRM_Utils_Type
::BIG
,
374 'where' => 'civicrm_address.street_name',
375 'headerPattern' => '',
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.',
387 'size' => CRM_Utils_Type
::EIGHT
,
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.',
398 'size' => CRM_Utils_Type
::EIGHT
,
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',
409 'size' => CRM_Utils_Type
::TWELVE
,
411 'where' => 'civicrm_address.street_unit',
412 'headerPattern' => '',
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',
424 'size' => CRM_Utils_Type
::HUGE
,
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',
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',
440 'size' => CRM_Utils_Type
::HUGE
,
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',
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',
456 'size' => CRM_Utils_Type
::HUGE
,
463 'type' => CRM_Utils_Type
::T_STRING
,
464 'title' => ts('City') ,
465 'description' => 'City, Town or Village Name.',
467 'size' => CRM_Utils_Type
::BIG
,
469 'where' => 'civicrm_address.city',
470 'headerPattern' => '/city/i',
471 'dataPattern' => '/^[A-Za-z]+(\.?)(\s?[A-Za-z]+){0,2}$/',
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',
484 'type' => 'ChainSelect',
486 'pseudoconstant' => array(
487 'table' => 'civicrm_county',
489 'labelColumn' => 'name',
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',
499 'type' => 'ChainSelect',
501 'pseudoconstant' => array(
502 'table' => 'civicrm_state_province',
504 'labelColumn' => 'name',
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.',
515 'where' => 'civicrm_address.postal_code_suffix',
516 'headerPattern' => '/p(ostal)\sc(ode)\ss(uffix)/i',
517 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
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.',
531 'where' => 'civicrm_address.postal_code',
532 'headerPattern' => '/postal|zip/i',
533 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
540 'name' => 'usps_adc',
541 'type' => CRM_Utils_Type
::T_STRING
,
542 'title' => ts('USPS Code') ,
543 'description' => 'USPS Bulk mailing code.',
545 'size' => CRM_Utils_Type
::MEDIUM
,
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',
556 'pseudoconstant' => array(
557 'table' => 'civicrm_country',
559 'labelColumn' => 'name',
560 'nameColumn' => 'iso_code',
563 'geo_code_1' => array(
564 'name' => 'geo_code_1',
565 'type' => CRM_Utils_Type
::T_FLOAT
,
566 'title' => ts('Latitude') ,
567 'description' => 'Latitude',
569 'where' => 'civicrm_address.geo_code_1',
570 'headerPattern' => '/geo/i',
577 'geo_code_2' => array(
578 'name' => 'geo_code_2',
579 'type' => CRM_Utils_Type
::T_FLOAT
,
580 'title' => ts('Longitude') ,
581 'description' => 'Longitude',
583 'where' => 'civicrm_address.geo_code_2',
584 'headerPattern' => '/geo/i',
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',
597 'type' => 'CheckBox',
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".',
606 'size' => CRM_Utils_Type
::EIGHT
,
611 'address_name' => array(
613 'type' => CRM_Utils_Type
::T_STRING
,
614 'title' => ts('Address Name') ,
616 'size' => CRM_Utils_Type
::HUGE
,
618 'where' => 'civicrm_address.name',
619 'headerPattern' => '/^location|(l(ocation\s)?name)$/i',
620 'dataPattern' => '/^\w+$/',
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',
632 'where' => 'civicrm_address.master_id',
633 'headerPattern' => '',
636 'FKClassName' => 'CRM_Core_DAO_Address',
639 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
641 return Civi
::$statics[__CLASS__
]['fields'];
644 * Return a mapping from field-name to the corresponding key (as used in fields()).
647 * Array(string $name => string $uniqueName).
649 static function &fieldKeys() {
650 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
651 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
653 return Civi
::$statics[__CLASS__
]['fieldKeys'];
656 * Returns the names of this table
660 static function getTableName() {
661 return self
::$_tableName;
664 * Returns if this table needs to be logged
672 * Returns the list of fields that can be imported
674 * @param bool $prefix
678 static function &import($prefix = false) {
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',
687 * Returns the list of fields that can be exported
689 * @param bool $prefix
693 static function &export($prefix = false) {
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',