5 * @copyright CiviCRM LLC (c) 2004-2018
7 * Generated from xml/schema/CRM/Activity/Activity.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:dfa63754ef6ea1a9c7148e735dd6ff8a)
13 * Database access object for the Activity entity.
15 class CRM_Activity_DAO_Activity
extends CRM_Core_DAO
{
18 * Static instance to hold the table name.
22 static $_tableName = 'civicrm_activity';
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
32 * Unique Other Activity ID
39 * Artificial FK to original transaction (e.g. contribution) IF it is not an Activity. Table can be figured out through activity_type_id, and further through component registry.
43 public $source_record_id;
46 * FK to civicrm_option_value.id, that has to be valid, registered activity type.
50 public $activity_type_id;
53 * The subject/purpose/short description of the activity.
60 * Date and time this activity is scheduled to occur. Formerly named scheduled_date_time.
64 public $activity_date_time;
67 * Planned or actual duration of activity expressed in minutes. Conglomerate of former duration_hours and duration_minutes.
74 * Location of the activity (optional, open text).
81 * Phone ID of the number called (optional - used if an existing phone number is selected).
88 * Phone number in case the number does not exist in the civicrm_phone table.
95 * Details about the activity (agenda, notes, etc).
102 * ID of the status this activity is currently in. Foreign key to civicrm_option_value.
109 * ID of the priority given to this activity. Foreign key to civicrm_option_value.
116 * Parent meeting ID (if this is a follow-up item). This is not currently implemented
128 * Activity Medium, Implicit FK to civicrm_option_value where option_group = encounter_medium.
140 * FK to Relationship ID
144 public $relationship_id;
149 public $is_current_revision;
152 * Activity ID of the first activity record in versioning chain.
159 * Currently being used to store result id for survey activity, FK to option value.
171 * The campaign for which this activity has been triggered.
178 * Assign a specific level of engagement to this activity. Used for tracking constituents in ladder of engagement.
182 public $engagement_level;
190 * Activity marked as favorite.
197 * When was the activity was created.
201 public $created_date;
204 * When was the activity (or closely related entity) was created or modified or deleted.
208 public $modified_date;
213 public function __construct() {
214 $this->__table
= 'civicrm_activity';
215 parent
::__construct();
219 * Returns foreign keys and entity references.
222 * [CRM_Core_Reference_Interface]
224 public static function getReferenceColumns() {
225 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
226 Civi
::$statics[__CLASS__
]['links'] = static ::createReferenceColumns(__CLASS__
);
227 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'phone_id', 'civicrm_phone', 'id');
228 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'parent_id', 'civicrm_activity', 'id');
229 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'relationship_id', 'civicrm_relationship', 'id');
230 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'original_id', 'civicrm_activity', 'id');
231 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
232 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
234 return Civi
::$statics[__CLASS__
]['links'];
238 * Returns all the column names of this table
242 public static function &fields() {
243 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
244 Civi
::$statics[__CLASS__
]['fields'] = [
247 'type' => CRM_Utils_Type
::T_INT
,
248 'title' => ts('Activity ID'),
249 'description' => 'Unique Other Activity ID',
252 'where' => 'civicrm_activity.id',
253 'headerPattern' => '',
256 'table_name' => 'civicrm_activity',
257 'entity' => 'Activity',
258 'bao' => 'CRM_Activity_BAO_Activity',
261 'source_record_id' => [
262 'name' => 'source_record_id',
263 'type' => CRM_Utils_Type
::T_INT
,
264 'title' => ts('Source Record'),
265 'description' => 'Artificial FK to original transaction (e.g. contribution) IF it is not an Activity. Table can be figured out through activity_type_id, and further through component registry.',
266 'table_name' => 'civicrm_activity',
267 'entity' => 'Activity',
268 'bao' => 'CRM_Activity_BAO_Activity',
271 'activity_type_id' => [
272 'name' => 'activity_type_id',
273 'type' => CRM_Utils_Type
::T_INT
,
274 'title' => ts('Activity Type ID'),
275 'description' => 'FK to civicrm_option_value.id, that has to be valid, registered activity type.',
278 'where' => 'civicrm_activity.activity_type_id',
279 'headerPattern' => '/(activity.)?type(.id$)/i',
283 'table_name' => 'civicrm_activity',
284 'entity' => 'Activity',
285 'bao' => 'CRM_Activity_BAO_Activity',
290 'pseudoconstant' => [
291 'optionGroupName' => 'activity_type',
292 'optionEditPath' => 'civicrm/admin/options/activity_type',
295 'activity_subject' => [
297 'type' => CRM_Utils_Type
::T_STRING
,
298 'title' => ts('Subject'),
299 'description' => 'The subject/purpose/short description of the activity.',
301 'size' => CRM_Utils_Type
::HUGE
,
303 'where' => 'civicrm_activity.subject',
304 'headerPattern' => '/(activity.)?subject/i',
307 'table_name' => 'civicrm_activity',
308 'entity' => 'Activity',
309 'bao' => 'CRM_Activity_BAO_Activity',
315 'activity_date_time' => [
316 'name' => 'activity_date_time',
317 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
318 'title' => ts('Activity Date'),
319 'description' => 'Date and time this activity is scheduled to occur. Formerly named scheduled_date_time.',
321 'where' => 'civicrm_activity.activity_date_time',
322 'headerPattern' => '/(activity.)?date(.time$)?/i',
325 'table_name' => 'civicrm_activity',
326 'entity' => 'Activity',
327 'bao' => 'CRM_Activity_BAO_Activity',
330 'type' => 'Select Date',
331 'formatType' => 'activityDateTime',
334 'activity_duration' => [
335 'name' => 'duration',
336 'type' => CRM_Utils_Type
::T_INT
,
337 'title' => ts('Duration'),
338 'description' => 'Planned or actual duration of activity expressed in minutes. Conglomerate of former duration_hours and duration_minutes.',
340 'where' => 'civicrm_activity.duration',
341 'headerPattern' => '/(activity.)?duration(s)?$/i',
344 'table_name' => 'civicrm_activity',
345 'entity' => 'Activity',
346 'bao' => 'CRM_Activity_BAO_Activity',
352 'activity_location' => [
353 'name' => 'location',
354 'type' => CRM_Utils_Type
::T_STRING
,
355 'title' => ts('Location'),
356 'description' => 'Location of the activity (optional, open text).',
358 'size' => CRM_Utils_Type
::HUGE
,
360 'where' => 'civicrm_activity.location',
361 'headerPattern' => '/(activity.)?location$/i',
364 'table_name' => 'civicrm_activity',
365 'entity' => 'Activity',
366 'bao' => 'CRM_Activity_BAO_Activity',
373 'name' => 'phone_id',
374 'type' => CRM_Utils_Type
::T_INT
,
375 'title' => ts('Phone (called) ID'),
376 'description' => 'Phone ID of the number called (optional - used if an existing phone number is selected).',
377 'table_name' => 'civicrm_activity',
378 'entity' => 'Activity',
379 'bao' => 'CRM_Activity_BAO_Activity',
381 'FKClassName' => 'CRM_Core_DAO_Phone',
383 'type' => 'EntityRef',
387 'name' => 'phone_number',
388 'type' => CRM_Utils_Type
::T_STRING
,
389 'title' => ts('Phone (called) Number'),
390 'description' => 'Phone number in case the number does not exist in the civicrm_phone table.',
392 'size' => CRM_Utils_Type
::BIG
,
393 'table_name' => 'civicrm_activity',
394 'entity' => 'Activity',
395 'bao' => 'CRM_Activity_BAO_Activity',
401 'activity_details' => [
403 'type' => CRM_Utils_Type
::T_LONGTEXT
,
404 'title' => ts('Details'),
405 'description' => 'Details about the activity (agenda, notes, etc).',
407 'where' => 'civicrm_activity.details',
408 'headerPattern' => '/(activity.)?detail(s)?$/i',
411 'table_name' => 'civicrm_activity',
412 'entity' => 'Activity',
413 'bao' => 'CRM_Activity_BAO_Activity',
416 'type' => 'RichTextEditor',
419 'activity_status_id' => [
420 'name' => 'status_id',
421 'type' => CRM_Utils_Type
::T_INT
,
422 'title' => ts('Activity Status'),
423 'description' => 'ID of the status this activity is currently in. Foreign key to civicrm_option_value.',
425 'where' => 'civicrm_activity.status_id',
426 'headerPattern' => '/(activity.)?status(.label$)?/i',
429 'table_name' => 'civicrm_activity',
430 'entity' => 'Activity',
431 'bao' => 'CRM_Activity_BAO_Activity',
436 'pseudoconstant' => [
437 'optionGroupName' => 'activity_status',
438 'optionEditPath' => 'civicrm/admin/options/activity_status',
442 'name' => 'priority_id',
443 'type' => CRM_Utils_Type
::T_INT
,
444 'title' => ts('Priority'),
445 'description' => 'ID of the priority given to this activity. Foreign key to civicrm_option_value.',
446 'table_name' => 'civicrm_activity',
447 'entity' => 'Activity',
448 'bao' => 'CRM_Activity_BAO_Activity',
453 'pseudoconstant' => [
454 'optionGroupName' => 'priority',
455 'optionEditPath' => 'civicrm/admin/options/priority',
459 'name' => 'parent_id',
460 'type' => CRM_Utils_Type
::T_INT
,
461 'title' => ts('Parent Activity Id'),
462 'description' => 'Parent meeting ID (if this is a follow-up item). This is not currently implemented',
463 'table_name' => 'civicrm_activity',
464 'entity' => 'Activity',
465 'bao' => 'CRM_Activity_BAO_Activity',
467 'FKClassName' => 'CRM_Activity_DAO_Activity',
469 'activity_is_test' => [
471 'type' => CRM_Utils_Type
::T_BOOLEAN
,
472 'title' => ts('Test'),
474 'where' => 'civicrm_activity.is_test',
475 'headerPattern' => '/(is.)?test(.activity)?/i',
479 'table_name' => 'civicrm_activity',
480 'entity' => 'Activity',
481 'bao' => 'CRM_Activity_BAO_Activity',
487 'activity_medium_id' => [
488 'name' => 'medium_id',
489 'type' => CRM_Utils_Type
::T_INT
,
490 'title' => ts('Activity Medium'),
491 'description' => 'Activity Medium, Implicit FK to civicrm_option_value where option_group = encounter_medium.',
493 'table_name' => 'civicrm_activity',
494 'entity' => 'Activity',
495 'bao' => 'CRM_Activity_BAO_Activity',
500 'pseudoconstant' => [
501 'optionGroupName' => 'encounter_medium',
502 'optionEditPath' => 'civicrm/admin/options/encounter_medium',
507 'type' => CRM_Utils_Type
::T_BOOLEAN
,
508 'title' => ts('Auto'),
510 'table_name' => 'civicrm_activity',
511 'entity' => 'Activity',
512 'bao' => 'CRM_Activity_BAO_Activity',
515 'relationship_id' => [
516 'name' => 'relationship_id',
517 'type' => CRM_Utils_Type
::T_INT
,
518 'title' => ts('Relationship Id'),
519 'description' => 'FK to Relationship ID',
521 'table_name' => 'civicrm_activity',
522 'entity' => 'Activity',
523 'bao' => 'CRM_Activity_BAO_Activity',
525 'FKClassName' => 'CRM_Contact_DAO_Relationship',
527 'is_current_revision' => [
528 'name' => 'is_current_revision',
529 'type' => CRM_Utils_Type
::T_BOOLEAN
,
530 'title' => ts('Is this activity a current revision in versioning chain?'),
532 'where' => 'civicrm_activity.is_current_revision',
533 'headerPattern' => '/(is.)?(current.)?(revision|version(ing)?)/i',
537 'table_name' => 'civicrm_activity',
538 'entity' => 'Activity',
539 'bao' => 'CRM_Activity_BAO_Activity',
542 'type' => 'CheckBox',
546 'name' => 'original_id',
547 'type' => CRM_Utils_Type
::T_INT
,
548 'title' => ts('Original Activity ID '),
549 'description' => 'Activity ID of the first activity record in versioning chain.',
550 'table_name' => 'civicrm_activity',
551 'entity' => 'Activity',
552 'bao' => 'CRM_Activity_BAO_Activity',
554 'FKClassName' => 'CRM_Activity_DAO_Activity',
556 'activity_result' => [
558 'type' => CRM_Utils_Type
::T_STRING
,
559 'title' => ts('Result'),
560 'description' => 'Currently being used to store result id for survey activity, FK to option value.',
562 'size' => CRM_Utils_Type
::HUGE
,
563 'table_name' => 'civicrm_activity',
564 'entity' => 'Activity',
565 'bao' => 'CRM_Activity_BAO_Activity',
571 'activity_is_deleted' => [
572 'name' => 'is_deleted',
573 'type' => CRM_Utils_Type
::T_BOOLEAN
,
574 'title' => ts('Activity is in the Trash'),
576 'where' => 'civicrm_activity.is_deleted',
577 'headerPattern' => '/(activity.)?(trash|deleted)/i',
581 'table_name' => 'civicrm_activity',
582 'entity' => 'Activity',
583 'bao' => 'CRM_Activity_BAO_Activity',
589 'activity_campaign_id' => [
590 'name' => 'campaign_id',
591 'type' => CRM_Utils_Type
::T_INT
,
592 'title' => ts('Campaign'),
593 'description' => 'The campaign for which this activity has been triggered.',
595 'where' => 'civicrm_activity.campaign_id',
596 'headerPattern' => '',
599 'table_name' => 'civicrm_activity',
600 'entity' => 'Activity',
601 'bao' => 'CRM_Activity_BAO_Activity',
603 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
605 'type' => 'CheckBox',
607 'pseudoconstant' => [
608 'table' => 'civicrm_campaign',
610 'labelColumn' => 'title',
613 'activity_engagement_level' => [
614 'name' => 'engagement_level',
615 'type' => CRM_Utils_Type
::T_INT
,
616 'title' => ts('Engagement Index'),
617 'description' => 'Assign a specific level of engagement to this activity. Used for tracking constituents in ladder of engagement.',
619 'where' => 'civicrm_activity.engagement_level',
620 'headerPattern' => '',
623 'table_name' => 'civicrm_activity',
624 'entity' => 'Activity',
625 'bao' => 'CRM_Activity_BAO_Activity',
630 'pseudoconstant' => [
631 'optionGroupName' => 'engagement_index',
632 'optionEditPath' => 'civicrm/admin/options/engagement_index',
637 'type' => CRM_Utils_Type
::T_INT
,
638 'title' => ts('Order'),
639 'table_name' => 'civicrm_activity',
640 'entity' => 'Activity',
641 'bao' => 'CRM_Activity_BAO_Activity',
649 'type' => CRM_Utils_Type
::T_BOOLEAN
,
650 'title' => ts('Is Starred'),
651 'description' => 'Activity marked as favorite.',
653 'where' => 'civicrm_activity.is_star',
654 'headerPattern' => '/(activity.)?(star|favorite)/i',
658 'table_name' => 'civicrm_activity',
659 'entity' => 'Activity',
660 'bao' => 'CRM_Activity_BAO_Activity',
663 'activity_created_date' => [
664 'name' => 'created_date',
665 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
666 'title' => ts('Created Date'),
667 'description' => 'When was the activity was created.',
670 'where' => 'civicrm_activity.created_date',
671 'headerPattern' => '',
674 'table_name' => 'civicrm_activity',
675 'entity' => 'Activity',
676 'bao' => 'CRM_Activity_BAO_Activity',
679 'activity_modified_date' => [
680 'name' => 'modified_date',
681 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
682 'title' => ts('Modified Date'),
683 'description' => 'When was the activity (or closely related entity) was created or modified or deleted.',
686 'where' => 'civicrm_activity.modified_date',
687 'headerPattern' => '',
689 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
690 'table_name' => 'civicrm_activity',
691 'entity' => 'Activity',
692 'bao' => 'CRM_Activity_BAO_Activity',
696 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
698 return Civi
::$statics[__CLASS__
]['fields'];
702 * Return a mapping from field-name to the corresponding key (as used in fields()).
705 * Array(string $name => string $uniqueName).
707 public static function &fieldKeys() {
708 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
709 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
711 return Civi
::$statics[__CLASS__
]['fieldKeys'];
715 * Returns the names of this table
719 public static function getTableName() {
720 return self
::$_tableName;
724 * Returns if this table needs to be logged
728 public function getLog() {
733 * Returns the list of fields that can be imported
735 * @param bool $prefix
739 public static function &import($prefix = FALSE) {
740 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'activity', $prefix, []);
745 * Returns the list of fields that can be exported
747 * @param bool $prefix
751 public static function &export($prefix = FALSE) {
752 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'activity', $prefix, []);
757 * Returns the list of indices
759 * @param bool $localize
763 public static function indices($localize = TRUE) {
765 'UI_source_record_id' => [
766 'name' => 'UI_source_record_id',
768 0 => 'source_record_id',
770 'localizable' => FALSE,
771 'sig' => 'civicrm_activity::0::source_record_id',
773 'UI_activity_type_id' => [
774 'name' => 'UI_activity_type_id',
776 0 => 'activity_type_id',
778 'localizable' => FALSE,
779 'sig' => 'civicrm_activity::0::activity_type_id',
781 'index_activity_date_time' => [
782 'name' => 'index_activity_date_time',
784 0 => 'activity_date_time',
786 'localizable' => FALSE,
787 'sig' => 'civicrm_activity::0::activity_date_time',
789 'index_status_id' => [
790 'name' => 'index_status_id',
794 'localizable' => FALSE,
795 'sig' => 'civicrm_activity::0::status_id',
797 'index_medium_id' => [
798 'name' => 'index_medium_id',
802 'localizable' => FALSE,
803 'sig' => 'civicrm_activity::0::medium_id',
805 'index_is_current_revision' => [
806 'name' => 'index_is_current_revision',
808 0 => 'is_current_revision',
810 'localizable' => FALSE,
811 'sig' => 'civicrm_activity::0::is_current_revision',
813 'index_is_deleted' => [
814 'name' => 'index_is_deleted',
818 'localizable' => FALSE,
819 'sig' => 'civicrm_activity::0::is_deleted',
822 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;