5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Activity/Activity.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:20d5b91c29b14f4df12aabfc07c58e94)
13 * Database access object for the Activity entity.
15 class CRM_Activity_DAO_Activity
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.1';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_activity';
27 * Icon associated with this entity.
31 public static $_icon = 'fa-tasks';
34 * Field to show when displaying a record.
38 public static $_labelField = 'subject';
41 * Should CiviCRM log any modifications to this table in the civicrm_log table.
45 public static $_log = TRUE;
48 * Paths for accessing this entity in the UI.
52 protected static $_paths = [
53 'add' => 'civicrm/activity?reset=1&action=add&context=standalone',
54 'view' => 'civicrm/activity?reset=1&action=view&id=[id]',
55 'update' => 'civicrm/activity/add?reset=1&action=update&id=[id]',
56 'delete' => 'civicrm/activity?reset=1&action=delete&id=[id]',
60 * Unique Other Activity ID
67 * 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.
71 public $source_record_id;
74 * FK to civicrm_option_value.id, that has to be valid, registered activity type.
78 public $activity_type_id;
81 * The subject/purpose/short description of the activity.
88 * Date and time this activity is scheduled to occur. Formerly named scheduled_date_time.
92 public $activity_date_time;
95 * Planned or actual duration of activity expressed in minutes. Conglomerate of former duration_hours and duration_minutes.
102 * Location of the activity (optional, open text).
109 * Phone ID of the number called (optional - used if an existing phone number is selected).
116 * Phone number in case the number does not exist in the civicrm_phone table.
120 public $phone_number;
123 * Details about the activity (agenda, notes, etc).
130 * ID of the status this activity is currently in. Foreign key to civicrm_option_value.
137 * ID of the priority given to this activity. Foreign key to civicrm_option_value.
144 * Parent meeting ID (if this is a follow-up item). This is not currently implemented
156 * Activity Medium, Implicit FK to civicrm_option_value where option_group = encounter_medium.
168 * FK to Relationship ID
172 public $relationship_id;
177 public $is_current_revision;
180 * Activity ID of the first activity record in versioning chain.
187 * Currently being used to store result id for survey activity, FK to option value.
199 * The campaign for which this activity has been triggered.
206 * Assign a specific level of engagement to this activity. Used for tracking constituents in ladder of engagement.
210 public $engagement_level;
218 * Activity marked as favorite.
225 * When was the activity was created.
229 public $created_date;
232 * When was the activity (or closely related entity) was created or modified or deleted.
236 public $modified_date;
241 public function __construct() {
242 $this->__table
= 'civicrm_activity';
243 parent
::__construct();
247 * Returns localized title of this entity.
249 * @param bool $plural
250 * Whether to return the plural version of the title.
252 public static function getEntityTitle($plural = FALSE) {
253 return $plural ?
ts('Activities') : ts('Activity');
257 * Returns foreign keys and entity references.
260 * [CRM_Core_Reference_Interface]
262 public static function getReferenceColumns() {
263 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
264 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
265 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'phone_id', 'civicrm_phone', 'id');
266 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'parent_id', 'civicrm_activity', 'id');
267 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'relationship_id', 'civicrm_relationship', 'id');
268 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'original_id', 'civicrm_activity', 'id');
269 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
270 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
272 return Civi
::$statics[__CLASS__
]['links'];
276 * Returns all the column names of this table
280 public static function &fields() {
281 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
282 Civi
::$statics[__CLASS__
]['fields'] = [
285 'type' => CRM_Utils_Type
::T_INT
,
286 'title' => ts('Activity ID'),
287 'description' => ts('Unique Other Activity ID'),
290 'where' => 'civicrm_activity.id',
292 'table_name' => 'civicrm_activity',
293 'entity' => 'Activity',
294 'bao' => 'CRM_Activity_BAO_Activity',
298 'source_record_id' => [
299 'name' => 'source_record_id',
300 'type' => CRM_Utils_Type
::T_INT
,
301 'title' => ts('Source Record'),
302 'description' => ts('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.'),
303 'where' => 'civicrm_activity.source_record_id',
304 'table_name' => 'civicrm_activity',
305 'entity' => 'Activity',
306 'bao' => 'CRM_Activity_BAO_Activity',
310 'activity_type_id' => [
311 'name' => 'activity_type_id',
312 'type' => CRM_Utils_Type
::T_INT
,
313 'title' => ts('Activity Type ID'),
314 'description' => ts('FK to civicrm_option_value.id, that has to be valid, registered activity type.'),
317 'where' => 'civicrm_activity.activity_type_id',
318 'headerPattern' => '/(activity.)?type(.id$)/i',
321 'table_name' => 'civicrm_activity',
322 'entity' => 'Activity',
323 'bao' => 'CRM_Activity_BAO_Activity',
327 'label' => ts("Activity Type"),
329 'pseudoconstant' => [
330 'optionGroupName' => 'activity_type',
331 'optionEditPath' => 'civicrm/admin/options/activity_type',
335 'activity_subject' => [
337 'type' => CRM_Utils_Type
::T_STRING
,
338 'title' => ts('Subject'),
339 'description' => ts('The subject/purpose/short description of the activity.'),
341 'size' => CRM_Utils_Type
::HUGE
,
343 'where' => 'civicrm_activity.subject',
344 'headerPattern' => '/(activity.)?subject/i',
346 'table_name' => 'civicrm_activity',
347 'entity' => 'Activity',
348 'bao' => 'CRM_Activity_BAO_Activity',
355 'activity_date_time' => [
356 'name' => 'activity_date_time',
357 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
358 'title' => ts('Activity Date'),
359 'description' => ts('Date and time this activity is scheduled to occur. Formerly named scheduled_date_time.'),
362 'where' => 'civicrm_activity.activity_date_time',
363 'headerPattern' => '/(activity.)?date(.time$)?/i',
365 'default' => 'CURRENT_TIMESTAMP',
366 'table_name' => 'civicrm_activity',
367 'entity' => 'Activity',
368 'bao' => 'CRM_Activity_BAO_Activity',
371 'type' => 'Select Date',
372 'formatType' => 'activityDateTime',
376 'activity_duration' => [
377 'name' => 'duration',
378 'type' => CRM_Utils_Type
::T_INT
,
379 'title' => ts('Duration'),
380 'description' => ts('Planned or actual duration of activity expressed in minutes. Conglomerate of former duration_hours and duration_minutes.'),
382 'where' => 'civicrm_activity.duration',
383 'headerPattern' => '/(activity.)?duration(s)?$/i',
385 'table_name' => 'civicrm_activity',
386 'entity' => 'Activity',
387 'bao' => 'CRM_Activity_BAO_Activity',
394 'activity_location' => [
395 'name' => 'location',
396 'type' => CRM_Utils_Type
::T_STRING
,
397 'title' => ts('Location'),
398 'description' => ts('Location of the activity (optional, open text).'),
400 'size' => CRM_Utils_Type
::HUGE
,
402 'where' => 'civicrm_activity.location',
403 'headerPattern' => '/(activity.)?location$/i',
405 'table_name' => 'civicrm_activity',
406 'entity' => 'Activity',
407 'bao' => 'CRM_Activity_BAO_Activity',
415 'name' => 'phone_id',
416 'type' => CRM_Utils_Type
::T_INT
,
417 'title' => ts('Phone (called) ID'),
418 'description' => ts('Phone ID of the number called (optional - used if an existing phone number is selected).'),
419 'where' => 'civicrm_activity.phone_id',
420 'table_name' => 'civicrm_activity',
421 'entity' => 'Activity',
422 'bao' => 'CRM_Activity_BAO_Activity',
424 'FKClassName' => 'CRM_Core_DAO_Phone',
426 'type' => 'EntityRef',
427 'label' => ts("Phone (called)"),
432 'name' => 'phone_number',
433 'type' => CRM_Utils_Type
::T_STRING
,
434 'title' => ts('Phone (called) Number'),
435 'description' => ts('Phone number in case the number does not exist in the civicrm_phone table.'),
437 'size' => CRM_Utils_Type
::BIG
,
438 'where' => 'civicrm_activity.phone_number',
439 'table_name' => 'civicrm_activity',
440 'entity' => 'Activity',
441 'bao' => 'CRM_Activity_BAO_Activity',
448 'activity_details' => [
450 'type' => CRM_Utils_Type
::T_LONGTEXT
,
451 'title' => ts('Details'),
452 'description' => ts('Details about the activity (agenda, notes, etc).'),
454 'where' => 'civicrm_activity.details',
455 'headerPattern' => '/(activity.)?detail(s)?$/i',
457 'table_name' => 'civicrm_activity',
458 'entity' => 'Activity',
459 'bao' => 'CRM_Activity_BAO_Activity',
462 'type' => 'RichTextEditor',
466 'activity_status_id' => [
467 'name' => 'status_id',
468 'type' => CRM_Utils_Type
::T_INT
,
469 'title' => ts('Activity Status'),
470 'description' => ts('ID of the status this activity is currently in. Foreign key to civicrm_option_value.'),
472 'where' => 'civicrm_activity.status_id',
473 'headerPattern' => '/(activity.)?status(.label$)?/i',
475 'table_name' => 'civicrm_activity',
476 'entity' => 'Activity',
477 'bao' => 'CRM_Activity_BAO_Activity',
482 'pseudoconstant' => [
483 'optionGroupName' => 'activity_status',
484 'optionEditPath' => 'civicrm/admin/options/activity_status',
489 'name' => 'priority_id',
490 'type' => CRM_Utils_Type
::T_INT
,
491 'title' => ts('Priority'),
492 'description' => ts('ID of the priority given to this activity. Foreign key to civicrm_option_value.'),
494 'where' => 'civicrm_activity.priority_id',
496 'table_name' => 'civicrm_activity',
497 'entity' => 'Activity',
498 'bao' => 'CRM_Activity_BAO_Activity',
503 'pseudoconstant' => [
504 'optionGroupName' => 'priority',
505 'optionEditPath' => 'civicrm/admin/options/priority',
510 'name' => 'parent_id',
511 'type' => CRM_Utils_Type
::T_INT
,
512 'title' => ts('Parent Activity Id'),
513 'description' => ts('Parent meeting ID (if this is a follow-up item). This is not currently implemented'),
514 'where' => 'civicrm_activity.parent_id',
515 'table_name' => 'civicrm_activity',
516 'entity' => 'Activity',
517 'bao' => 'CRM_Activity_BAO_Activity',
519 'FKClassName' => 'CRM_Activity_DAO_Activity',
522 'activity_is_test' => [
524 'type' => CRM_Utils_Type
::T_BOOLEAN
,
525 'title' => ts('Test'),
527 'where' => 'civicrm_activity.is_test',
528 'headerPattern' => '/(is.)?test(.activity)?/i',
531 'table_name' => 'civicrm_activity',
532 'entity' => 'Activity',
533 'bao' => 'CRM_Activity_BAO_Activity',
536 'type' => 'CheckBox',
540 'activity_medium_id' => [
541 'name' => 'medium_id',
542 'type' => CRM_Utils_Type
::T_INT
,
543 'title' => ts('Activity Medium'),
544 'description' => ts('Activity Medium, Implicit FK to civicrm_option_value where option_group = encounter_medium.'),
545 'where' => 'civicrm_activity.medium_id',
547 'table_name' => 'civicrm_activity',
548 'entity' => 'Activity',
549 'bao' => 'CRM_Activity_BAO_Activity',
554 'pseudoconstant' => [
555 'optionGroupName' => 'encounter_medium',
556 'optionEditPath' => 'civicrm/admin/options/encounter_medium',
562 'type' => CRM_Utils_Type
::T_BOOLEAN
,
563 'title' => ts('Auto'),
564 'where' => 'civicrm_activity.is_auto',
566 'table_name' => 'civicrm_activity',
567 'entity' => 'Activity',
568 'bao' => 'CRM_Activity_BAO_Activity',
572 'relationship_id' => [
573 'name' => 'relationship_id',
574 'type' => CRM_Utils_Type
::T_INT
,
575 'title' => ts('Relationship Id'),
576 'description' => ts('FK to Relationship ID'),
577 'where' => 'civicrm_activity.relationship_id',
579 'table_name' => 'civicrm_activity',
580 'entity' => 'Activity',
581 'bao' => 'CRM_Activity_BAO_Activity',
583 'FKClassName' => 'CRM_Contact_DAO_Relationship',
586 'is_current_revision' => [
587 'name' => 'is_current_revision',
588 'type' => CRM_Utils_Type
::T_BOOLEAN
,
589 'title' => ts('Is this activity a current revision in versioning chain?'),
591 'where' => 'civicrm_activity.is_current_revision',
592 'headerPattern' => '/(is.)?(current.)?(revision|version(ing)?)/i',
595 'table_name' => 'civicrm_activity',
596 'entity' => 'Activity',
597 'bao' => 'CRM_Activity_BAO_Activity',
602 'name' => 'original_id',
603 'type' => CRM_Utils_Type
::T_INT
,
604 'title' => ts('Original Activity ID '),
605 'description' => ts('Activity ID of the first activity record in versioning chain.'),
606 'where' => 'civicrm_activity.original_id',
607 'table_name' => 'civicrm_activity',
608 'entity' => 'Activity',
609 'bao' => 'CRM_Activity_BAO_Activity',
611 'FKClassName' => 'CRM_Activity_DAO_Activity',
614 'activity_result' => [
616 'type' => CRM_Utils_Type
::T_STRING
,
617 'title' => ts('Result'),
618 'description' => ts('Currently being used to store result id for survey activity, FK to option value.'),
620 'size' => CRM_Utils_Type
::HUGE
,
621 'where' => 'civicrm_activity.result',
622 'table_name' => 'civicrm_activity',
623 'entity' => 'Activity',
624 'bao' => 'CRM_Activity_BAO_Activity',
628 'activity_is_deleted' => [
629 'name' => 'is_deleted',
630 'type' => CRM_Utils_Type
::T_BOOLEAN
,
631 'title' => ts('Activity is in the Trash'),
633 'where' => 'civicrm_activity.is_deleted',
634 'headerPattern' => '/(activity.)?(trash|deleted)/i',
637 'table_name' => 'civicrm_activity',
638 'entity' => 'Activity',
639 'bao' => 'CRM_Activity_BAO_Activity',
642 'type' => 'CheckBox',
646 'activity_campaign_id' => [
647 'name' => 'campaign_id',
648 'type' => CRM_Utils_Type
::T_INT
,
649 'title' => ts('Campaign'),
650 'description' => ts('The campaign for which this activity has been triggered.'),
652 'where' => 'civicrm_activity.campaign_id',
654 'table_name' => 'civicrm_activity',
655 'entity' => 'Activity',
656 'bao' => 'CRM_Activity_BAO_Activity',
658 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
662 'pseudoconstant' => [
663 'table' => 'civicrm_campaign',
665 'labelColumn' => 'title',
669 'activity_engagement_level' => [
670 'name' => 'engagement_level',
671 'type' => CRM_Utils_Type
::T_INT
,
672 'title' => ts('Engagement Index'),
673 'description' => ts('Assign a specific level of engagement to this activity. Used for tracking constituents in ladder of engagement.'),
675 'where' => 'civicrm_activity.engagement_level',
677 'table_name' => 'civicrm_activity',
678 'entity' => 'Activity',
679 'bao' => 'CRM_Activity_BAO_Activity',
684 'pseudoconstant' => [
685 'optionGroupName' => 'engagement_index',
686 'optionEditPath' => 'civicrm/admin/options/engagement_index',
692 'type' => CRM_Utils_Type
::T_INT
,
693 'title' => ts('Order'),
694 'where' => 'civicrm_activity.weight',
695 'table_name' => 'civicrm_activity',
696 'entity' => 'Activity',
697 'bao' => 'CRM_Activity_BAO_Activity',
703 'type' => CRM_Utils_Type
::T_BOOLEAN
,
704 'title' => ts('Is Starred'),
705 'description' => ts('Activity marked as favorite.'),
707 'where' => 'civicrm_activity.is_star',
708 'headerPattern' => '/(activity.)?(star|favorite)/i',
711 'table_name' => 'civicrm_activity',
712 'entity' => 'Activity',
713 'bao' => 'CRM_Activity_BAO_Activity',
716 'type' => 'Checkbox',
720 'activity_created_date' => [
721 'name' => 'created_date',
722 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
723 'title' => ts('Created Date'),
724 'description' => ts('When was the activity was created.'),
726 'where' => 'civicrm_activity.created_date',
728 'default' => 'CURRENT_TIMESTAMP',
729 'table_name' => 'civicrm_activity',
730 'entity' => 'Activity',
731 'bao' => 'CRM_Activity_BAO_Activity',
735 'activity_modified_date' => [
736 'name' => 'modified_date',
737 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
738 'title' => ts('Modified Date'),
739 'description' => ts('When was the activity (or closely related entity) was created or modified or deleted.'),
741 'where' => 'civicrm_activity.modified_date',
743 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
744 'table_name' => 'civicrm_activity',
745 'entity' => 'Activity',
746 'bao' => 'CRM_Activity_BAO_Activity',
751 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
753 return Civi
::$statics[__CLASS__
]['fields'];
757 * Return a mapping from field-name to the corresponding key (as used in fields()).
760 * Array(string $name => string $uniqueName).
762 public static function &fieldKeys() {
763 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
764 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
766 return Civi
::$statics[__CLASS__
]['fieldKeys'];
770 * Returns the names of this table
774 public static function getTableName() {
775 return self
::$_tableName;
779 * Returns if this table needs to be logged
783 public function getLog() {
788 * Returns the list of fields that can be imported
790 * @param bool $prefix
794 public static function &import($prefix = FALSE) {
795 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'activity', $prefix, []);
800 * Returns the list of fields that can be exported
802 * @param bool $prefix
806 public static function &export($prefix = FALSE) {
807 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'activity', $prefix, []);
812 * Returns the list of indices
814 * @param bool $localize
818 public static function indices($localize = TRUE) {
820 'UI_source_record_id' => [
821 'name' => 'UI_source_record_id',
823 0 => 'source_record_id',
825 'localizable' => FALSE,
826 'sig' => 'civicrm_activity::0::source_record_id',
828 'UI_activity_type_id' => [
829 'name' => 'UI_activity_type_id',
831 0 => 'activity_type_id',
833 'localizable' => FALSE,
834 'sig' => 'civicrm_activity::0::activity_type_id',
836 'index_activity_date_time' => [
837 'name' => 'index_activity_date_time',
839 0 => 'activity_date_time',
841 'localizable' => FALSE,
842 'sig' => 'civicrm_activity::0::activity_date_time',
844 'index_status_id' => [
845 'name' => 'index_status_id',
849 'localizable' => FALSE,
850 'sig' => 'civicrm_activity::0::status_id',
852 'index_is_current_revision' => [
853 'name' => 'index_is_current_revision',
855 0 => 'is_current_revision',
857 'localizable' => FALSE,
858 'sig' => 'civicrm_activity::0::is_current_revision',
860 'index_is_deleted' => [
861 'name' => 'index_is_deleted',
865 'localizable' => FALSE,
866 'sig' => 'civicrm_activity::0::is_deleted',
869 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;