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:c1b4cc908c0220abf69f57d281eeda95)
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 * Should CiviCRM log any modifications to this table in the civicrm_log table.
38 public static $_log = TRUE;
41 * Unique Other Activity ID
48 * 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.
52 public $source_record_id;
55 * FK to civicrm_option_value.id, that has to be valid, registered activity type.
59 public $activity_type_id;
62 * The subject/purpose/short description of the activity.
69 * Date and time this activity is scheduled to occur. Formerly named scheduled_date_time.
73 public $activity_date_time;
76 * Planned or actual duration of activity expressed in minutes. Conglomerate of former duration_hours and duration_minutes.
83 * Location of the activity (optional, open text).
90 * Phone ID of the number called (optional - used if an existing phone number is selected).
97 * Phone number in case the number does not exist in the civicrm_phone table.
101 public $phone_number;
104 * Details about the activity (agenda, notes, etc).
111 * ID of the status this activity is currently in. Foreign key to civicrm_option_value.
118 * ID of the priority given to this activity. Foreign key to civicrm_option_value.
125 * Parent meeting ID (if this is a follow-up item). This is not currently implemented
137 * Activity Medium, Implicit FK to civicrm_option_value where option_group = encounter_medium.
149 * FK to Relationship ID
153 public $relationship_id;
158 public $is_current_revision;
161 * Activity ID of the first activity record in versioning chain.
168 * Currently being used to store result id for survey activity, FK to option value.
180 * The campaign for which this activity has been triggered.
187 * Assign a specific level of engagement to this activity. Used for tracking constituents in ladder of engagement.
191 public $engagement_level;
199 * Activity marked as favorite.
206 * When was the activity was created.
210 public $created_date;
213 * When was the activity (or closely related entity) was created or modified or deleted.
217 public $modified_date;
222 public function __construct() {
223 $this->__table
= 'civicrm_activity';
224 parent
::__construct();
228 * Returns localized title of this entity.
230 * @param bool $plural
231 * Whether to return the plural version of the title.
233 public static function getEntityTitle($plural = FALSE) {
234 return $plural ?
ts('Activities') : ts('Activity');
238 * Returns foreign keys and entity references.
241 * [CRM_Core_Reference_Interface]
243 public static function getReferenceColumns() {
244 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
245 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
246 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'phone_id', 'civicrm_phone', 'id');
247 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'parent_id', 'civicrm_activity', 'id');
248 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'relationship_id', 'civicrm_relationship', 'id');
249 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'original_id', 'civicrm_activity', 'id');
250 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
251 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
253 return Civi
::$statics[__CLASS__
]['links'];
257 * Returns all the column names of this table
261 public static function &fields() {
262 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
263 Civi
::$statics[__CLASS__
]['fields'] = [
266 'type' => CRM_Utils_Type
::T_INT
,
267 'title' => ts('Activity ID'),
268 'description' => ts('Unique Other Activity ID'),
271 'where' => 'civicrm_activity.id',
273 'table_name' => 'civicrm_activity',
274 'entity' => 'Activity',
275 'bao' => 'CRM_Activity_BAO_Activity',
279 'source_record_id' => [
280 'name' => 'source_record_id',
281 'type' => CRM_Utils_Type
::T_INT
,
282 'title' => ts('Source Record'),
283 '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.'),
284 'where' => 'civicrm_activity.source_record_id',
285 'table_name' => 'civicrm_activity',
286 'entity' => 'Activity',
287 'bao' => 'CRM_Activity_BAO_Activity',
291 'activity_type_id' => [
292 'name' => 'activity_type_id',
293 'type' => CRM_Utils_Type
::T_INT
,
294 'title' => ts('Activity Type ID'),
295 'description' => ts('FK to civicrm_option_value.id, that has to be valid, registered activity type.'),
298 'where' => 'civicrm_activity.activity_type_id',
299 'headerPattern' => '/(activity.)?type(.id$)/i',
302 'table_name' => 'civicrm_activity',
303 'entity' => 'Activity',
304 'bao' => 'CRM_Activity_BAO_Activity',
308 'label' => ts("Activity Type"),
310 'pseudoconstant' => [
311 'optionGroupName' => 'activity_type',
312 'optionEditPath' => 'civicrm/admin/options/activity_type',
316 'activity_subject' => [
318 'type' => CRM_Utils_Type
::T_STRING
,
319 'title' => ts('Subject'),
320 'description' => ts('The subject/purpose/short description of the activity.'),
322 'size' => CRM_Utils_Type
::HUGE
,
324 'where' => 'civicrm_activity.subject',
325 'headerPattern' => '/(activity.)?subject/i',
327 'table_name' => 'civicrm_activity',
328 'entity' => 'Activity',
329 'bao' => 'CRM_Activity_BAO_Activity',
336 'activity_date_time' => [
337 'name' => 'activity_date_time',
338 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
339 'title' => ts('Activity Date'),
340 'description' => ts('Date and time this activity is scheduled to occur. Formerly named scheduled_date_time.'),
343 'where' => 'civicrm_activity.activity_date_time',
344 'headerPattern' => '/(activity.)?date(.time$)?/i',
346 'default' => 'CURRENT_TIMESTAMP',
347 'table_name' => 'civicrm_activity',
348 'entity' => 'Activity',
349 'bao' => 'CRM_Activity_BAO_Activity',
352 'type' => 'Select Date',
353 'formatType' => 'activityDateTime',
357 'activity_duration' => [
358 'name' => 'duration',
359 'type' => CRM_Utils_Type
::T_INT
,
360 'title' => ts('Duration'),
361 'description' => ts('Planned or actual duration of activity expressed in minutes. Conglomerate of former duration_hours and duration_minutes.'),
363 'where' => 'civicrm_activity.duration',
364 'headerPattern' => '/(activity.)?duration(s)?$/i',
366 'table_name' => 'civicrm_activity',
367 'entity' => 'Activity',
368 'bao' => 'CRM_Activity_BAO_Activity',
375 'activity_location' => [
376 'name' => 'location',
377 'type' => CRM_Utils_Type
::T_STRING
,
378 'title' => ts('Location'),
379 'description' => ts('Location of the activity (optional, open text).'),
381 'size' => CRM_Utils_Type
::HUGE
,
383 'where' => 'civicrm_activity.location',
384 'headerPattern' => '/(activity.)?location$/i',
386 'table_name' => 'civicrm_activity',
387 'entity' => 'Activity',
388 'bao' => 'CRM_Activity_BAO_Activity',
396 'name' => 'phone_id',
397 'type' => CRM_Utils_Type
::T_INT
,
398 'title' => ts('Phone (called) ID'),
399 'description' => ts('Phone ID of the number called (optional - used if an existing phone number is selected).'),
400 'where' => 'civicrm_activity.phone_id',
401 'table_name' => 'civicrm_activity',
402 'entity' => 'Activity',
403 'bao' => 'CRM_Activity_BAO_Activity',
405 'FKClassName' => 'CRM_Core_DAO_Phone',
407 'type' => 'EntityRef',
408 'label' => ts("Phone (called)"),
413 'name' => 'phone_number',
414 'type' => CRM_Utils_Type
::T_STRING
,
415 'title' => ts('Phone (called) Number'),
416 'description' => ts('Phone number in case the number does not exist in the civicrm_phone table.'),
418 'size' => CRM_Utils_Type
::BIG
,
419 'where' => 'civicrm_activity.phone_number',
420 'table_name' => 'civicrm_activity',
421 'entity' => 'Activity',
422 'bao' => 'CRM_Activity_BAO_Activity',
429 'activity_details' => [
431 'type' => CRM_Utils_Type
::T_LONGTEXT
,
432 'title' => ts('Details'),
433 'description' => ts('Details about the activity (agenda, notes, etc).'),
435 'where' => 'civicrm_activity.details',
436 'headerPattern' => '/(activity.)?detail(s)?$/i',
438 'table_name' => 'civicrm_activity',
439 'entity' => 'Activity',
440 'bao' => 'CRM_Activity_BAO_Activity',
443 'type' => 'RichTextEditor',
447 'activity_status_id' => [
448 'name' => 'status_id',
449 'type' => CRM_Utils_Type
::T_INT
,
450 'title' => ts('Activity Status'),
451 'description' => ts('ID of the status this activity is currently in. Foreign key to civicrm_option_value.'),
453 'where' => 'civicrm_activity.status_id',
454 'headerPattern' => '/(activity.)?status(.label$)?/i',
456 'table_name' => 'civicrm_activity',
457 'entity' => 'Activity',
458 'bao' => 'CRM_Activity_BAO_Activity',
463 'pseudoconstant' => [
464 'optionGroupName' => 'activity_status',
465 'optionEditPath' => 'civicrm/admin/options/activity_status',
470 'name' => 'priority_id',
471 'type' => CRM_Utils_Type
::T_INT
,
472 'title' => ts('Priority'),
473 'description' => ts('ID of the priority given to this activity. Foreign key to civicrm_option_value.'),
475 'where' => 'civicrm_activity.priority_id',
477 'table_name' => 'civicrm_activity',
478 'entity' => 'Activity',
479 'bao' => 'CRM_Activity_BAO_Activity',
484 'pseudoconstant' => [
485 'optionGroupName' => 'priority',
486 'optionEditPath' => 'civicrm/admin/options/priority',
491 'name' => 'parent_id',
492 'type' => CRM_Utils_Type
::T_INT
,
493 'title' => ts('Parent Activity Id'),
494 'description' => ts('Parent meeting ID (if this is a follow-up item). This is not currently implemented'),
495 'where' => 'civicrm_activity.parent_id',
496 'table_name' => 'civicrm_activity',
497 'entity' => 'Activity',
498 'bao' => 'CRM_Activity_BAO_Activity',
500 'FKClassName' => 'CRM_Activity_DAO_Activity',
503 'activity_is_test' => [
505 'type' => CRM_Utils_Type
::T_BOOLEAN
,
506 'title' => ts('Test'),
508 'where' => 'civicrm_activity.is_test',
509 'headerPattern' => '/(is.)?test(.activity)?/i',
512 'table_name' => 'civicrm_activity',
513 'entity' => 'Activity',
514 'bao' => 'CRM_Activity_BAO_Activity',
517 'type' => 'CheckBox',
521 'activity_medium_id' => [
522 'name' => 'medium_id',
523 'type' => CRM_Utils_Type
::T_INT
,
524 'title' => ts('Activity Medium'),
525 'description' => ts('Activity Medium, Implicit FK to civicrm_option_value where option_group = encounter_medium.'),
526 'where' => 'civicrm_activity.medium_id',
528 'table_name' => 'civicrm_activity',
529 'entity' => 'Activity',
530 'bao' => 'CRM_Activity_BAO_Activity',
535 'pseudoconstant' => [
536 'optionGroupName' => 'encounter_medium',
537 'optionEditPath' => 'civicrm/admin/options/encounter_medium',
543 'type' => CRM_Utils_Type
::T_BOOLEAN
,
544 'title' => ts('Auto'),
545 'where' => 'civicrm_activity.is_auto',
547 'table_name' => 'civicrm_activity',
548 'entity' => 'Activity',
549 'bao' => 'CRM_Activity_BAO_Activity',
553 'relationship_id' => [
554 'name' => 'relationship_id',
555 'type' => CRM_Utils_Type
::T_INT
,
556 'title' => ts('Relationship Id'),
557 'description' => ts('FK to Relationship ID'),
558 'where' => 'civicrm_activity.relationship_id',
560 'table_name' => 'civicrm_activity',
561 'entity' => 'Activity',
562 'bao' => 'CRM_Activity_BAO_Activity',
564 'FKClassName' => 'CRM_Contact_DAO_Relationship',
567 'is_current_revision' => [
568 'name' => 'is_current_revision',
569 'type' => CRM_Utils_Type
::T_BOOLEAN
,
570 'title' => ts('Is this activity a current revision in versioning chain?'),
572 'where' => 'civicrm_activity.is_current_revision',
573 'headerPattern' => '/(is.)?(current.)?(revision|version(ing)?)/i',
576 'table_name' => 'civicrm_activity',
577 'entity' => 'Activity',
578 'bao' => 'CRM_Activity_BAO_Activity',
583 'name' => 'original_id',
584 'type' => CRM_Utils_Type
::T_INT
,
585 'title' => ts('Original Activity ID '),
586 'description' => ts('Activity ID of the first activity record in versioning chain.'),
587 'where' => 'civicrm_activity.original_id',
588 'table_name' => 'civicrm_activity',
589 'entity' => 'Activity',
590 'bao' => 'CRM_Activity_BAO_Activity',
592 'FKClassName' => 'CRM_Activity_DAO_Activity',
595 'activity_result' => [
597 'type' => CRM_Utils_Type
::T_STRING
,
598 'title' => ts('Result'),
599 'description' => ts('Currently being used to store result id for survey activity, FK to option value.'),
601 'size' => CRM_Utils_Type
::HUGE
,
602 'where' => 'civicrm_activity.result',
603 'table_name' => 'civicrm_activity',
604 'entity' => 'Activity',
605 'bao' => 'CRM_Activity_BAO_Activity',
609 'activity_is_deleted' => [
610 'name' => 'is_deleted',
611 'type' => CRM_Utils_Type
::T_BOOLEAN
,
612 'title' => ts('Activity is in the Trash'),
614 'where' => 'civicrm_activity.is_deleted',
615 'headerPattern' => '/(activity.)?(trash|deleted)/i',
618 'table_name' => 'civicrm_activity',
619 'entity' => 'Activity',
620 'bao' => 'CRM_Activity_BAO_Activity',
623 'type' => 'CheckBox',
627 'activity_campaign_id' => [
628 'name' => 'campaign_id',
629 'type' => CRM_Utils_Type
::T_INT
,
630 'title' => ts('Campaign'),
631 'description' => ts('The campaign for which this activity has been triggered.'),
633 'where' => 'civicrm_activity.campaign_id',
635 'table_name' => 'civicrm_activity',
636 'entity' => 'Activity',
637 'bao' => 'CRM_Activity_BAO_Activity',
639 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
643 'pseudoconstant' => [
644 'table' => 'civicrm_campaign',
646 'labelColumn' => 'title',
650 'activity_engagement_level' => [
651 'name' => 'engagement_level',
652 'type' => CRM_Utils_Type
::T_INT
,
653 'title' => ts('Engagement Index'),
654 'description' => ts('Assign a specific level of engagement to this activity. Used for tracking constituents in ladder of engagement.'),
656 'where' => 'civicrm_activity.engagement_level',
658 'table_name' => 'civicrm_activity',
659 'entity' => 'Activity',
660 'bao' => 'CRM_Activity_BAO_Activity',
665 'pseudoconstant' => [
666 'optionGroupName' => 'engagement_index',
667 'optionEditPath' => 'civicrm/admin/options/engagement_index',
673 'type' => CRM_Utils_Type
::T_INT
,
674 'title' => ts('Order'),
675 'where' => 'civicrm_activity.weight',
676 'table_name' => 'civicrm_activity',
677 'entity' => 'Activity',
678 'bao' => 'CRM_Activity_BAO_Activity',
684 'type' => CRM_Utils_Type
::T_BOOLEAN
,
685 'title' => ts('Is Starred'),
686 'description' => ts('Activity marked as favorite.'),
688 'where' => 'civicrm_activity.is_star',
689 'headerPattern' => '/(activity.)?(star|favorite)/i',
692 'table_name' => 'civicrm_activity',
693 'entity' => 'Activity',
694 'bao' => 'CRM_Activity_BAO_Activity',
697 'type' => 'Checkbox',
701 'activity_created_date' => [
702 'name' => 'created_date',
703 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
704 'title' => ts('Created Date'),
705 'description' => ts('When was the activity was created.'),
707 'where' => 'civicrm_activity.created_date',
709 'default' => 'CURRENT_TIMESTAMP',
710 'table_name' => 'civicrm_activity',
711 'entity' => 'Activity',
712 'bao' => 'CRM_Activity_BAO_Activity',
716 'activity_modified_date' => [
717 'name' => 'modified_date',
718 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
719 'title' => ts('Modified Date'),
720 'description' => ts('When was the activity (or closely related entity) was created or modified or deleted.'),
722 'where' => 'civicrm_activity.modified_date',
724 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
725 'table_name' => 'civicrm_activity',
726 'entity' => 'Activity',
727 'bao' => 'CRM_Activity_BAO_Activity',
732 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
734 return Civi
::$statics[__CLASS__
]['fields'];
738 * Return a mapping from field-name to the corresponding key (as used in fields()).
741 * Array(string $name => string $uniqueName).
743 public static function &fieldKeys() {
744 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
745 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
747 return Civi
::$statics[__CLASS__
]['fieldKeys'];
751 * Returns the names of this table
755 public static function getTableName() {
756 return self
::$_tableName;
760 * Returns if this table needs to be logged
764 public function getLog() {
769 * Returns the list of fields that can be imported
771 * @param bool $prefix
775 public static function &import($prefix = FALSE) {
776 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'activity', $prefix, []);
781 * Returns the list of fields that can be exported
783 * @param bool $prefix
787 public static function &export($prefix = FALSE) {
788 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'activity', $prefix, []);
793 * Returns the list of indices
795 * @param bool $localize
799 public static function indices($localize = TRUE) {
801 'UI_source_record_id' => [
802 'name' => 'UI_source_record_id',
804 0 => 'source_record_id',
806 'localizable' => FALSE,
807 'sig' => 'civicrm_activity::0::source_record_id',
809 'UI_activity_type_id' => [
810 'name' => 'UI_activity_type_id',
812 0 => 'activity_type_id',
814 'localizable' => FALSE,
815 'sig' => 'civicrm_activity::0::activity_type_id',
817 'index_activity_date_time' => [
818 'name' => 'index_activity_date_time',
820 0 => 'activity_date_time',
822 'localizable' => FALSE,
823 'sig' => 'civicrm_activity::0::activity_date_time',
825 'index_status_id' => [
826 'name' => 'index_status_id',
830 'localizable' => FALSE,
831 'sig' => 'civicrm_activity::0::status_id',
833 'index_is_current_revision' => [
834 'name' => 'index_is_current_revision',
836 0 => 'is_current_revision',
838 'localizable' => FALSE,
839 'sig' => 'civicrm_activity::0::is_current_revision',
841 'index_is_deleted' => [
842 'name' => 'index_is_deleted',
846 'localizable' => FALSE,
847 'sig' => 'civicrm_activity::0::is_deleted',
850 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;