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:99193964db864f9ec91b02b2bbc2d8f4)
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 public static $_tableName = 'civicrm_activity';
25 * Icon associated with this entity.
29 public static $_icon = 'fa-tasks';
32 * Should CiviCRM log any modifications to this table in the civicrm_log table.
36 public static $_log = TRUE;
39 * Unique Other Activity ID
46 * 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.
50 public $source_record_id;
53 * FK to civicrm_option_value.id, that has to be valid, registered activity type.
57 public $activity_type_id;
60 * The subject/purpose/short description of the activity.
67 * Date and time this activity is scheduled to occur. Formerly named scheduled_date_time.
71 public $activity_date_time;
74 * Planned or actual duration of activity expressed in minutes. Conglomerate of former duration_hours and duration_minutes.
81 * Location of the activity (optional, open text).
88 * Phone ID of the number called (optional - used if an existing phone number is selected).
95 * Phone number in case the number does not exist in the civicrm_phone table.
102 * Details about the activity (agenda, notes, etc).
109 * ID of the status this activity is currently in. Foreign key to civicrm_option_value.
116 * ID of the priority given to this activity. Foreign key to civicrm_option_value.
123 * Parent meeting ID (if this is a follow-up item). This is not currently implemented
135 * Activity Medium, Implicit FK to civicrm_option_value where option_group = encounter_medium.
147 * FK to Relationship ID
151 public $relationship_id;
156 public $is_current_revision;
159 * Activity ID of the first activity record in versioning chain.
166 * Currently being used to store result id for survey activity, FK to option value.
178 * The campaign for which this activity has been triggered.
185 * Assign a specific level of engagement to this activity. Used for tracking constituents in ladder of engagement.
189 public $engagement_level;
197 * Activity marked as favorite.
204 * When was the activity was created.
208 public $created_date;
211 * When was the activity (or closely related entity) was created or modified or deleted.
215 public $modified_date;
220 public function __construct() {
221 $this->__table
= 'civicrm_activity';
222 parent
::__construct();
226 * Returns localized title of this entity.
228 public static function getEntityTitle() {
229 return ts('Activities');
233 * Returns foreign keys and entity references.
236 * [CRM_Core_Reference_Interface]
238 public static function getReferenceColumns() {
239 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
240 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
241 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'phone_id', 'civicrm_phone', 'id');
242 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'parent_id', 'civicrm_activity', 'id');
243 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'relationship_id', 'civicrm_relationship', 'id');
244 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'original_id', 'civicrm_activity', 'id');
245 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
246 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
248 return Civi
::$statics[__CLASS__
]['links'];
252 * Returns all the column names of this table
256 public static function &fields() {
257 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
258 Civi
::$statics[__CLASS__
]['fields'] = [
261 'type' => CRM_Utils_Type
::T_INT
,
262 'title' => ts('Activity ID'),
263 'description' => ts('Unique Other Activity ID'),
266 'where' => 'civicrm_activity.id',
268 'table_name' => 'civicrm_activity',
269 'entity' => 'Activity',
270 'bao' => 'CRM_Activity_BAO_Activity',
274 'source_record_id' => [
275 'name' => 'source_record_id',
276 'type' => CRM_Utils_Type
::T_INT
,
277 'title' => ts('Source Record'),
278 '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.'),
279 'where' => 'civicrm_activity.source_record_id',
280 'table_name' => 'civicrm_activity',
281 'entity' => 'Activity',
282 'bao' => 'CRM_Activity_BAO_Activity',
286 'activity_type_id' => [
287 'name' => 'activity_type_id',
288 'type' => CRM_Utils_Type
::T_INT
,
289 'title' => ts('Activity Type'),
290 'description' => ts('FK to civicrm_option_value.id, that has to be valid, registered activity type.'),
293 'where' => 'civicrm_activity.activity_type_id',
294 'headerPattern' => '/(activity.)?type(.id$)/i',
297 'table_name' => 'civicrm_activity',
298 'entity' => 'Activity',
299 'bao' => 'CRM_Activity_BAO_Activity',
304 'pseudoconstant' => [
305 'optionGroupName' => 'activity_type',
306 'optionEditPath' => 'civicrm/admin/options/activity_type',
310 'activity_subject' => [
312 'type' => CRM_Utils_Type
::T_STRING
,
313 'title' => ts('Subject'),
314 'description' => ts('The subject/purpose/short description of the activity.'),
316 'size' => CRM_Utils_Type
::HUGE
,
318 'where' => 'civicrm_activity.subject',
319 'headerPattern' => '/(activity.)?subject/i',
321 'table_name' => 'civicrm_activity',
322 'entity' => 'Activity',
323 'bao' => 'CRM_Activity_BAO_Activity',
330 'activity_date_time' => [
331 'name' => 'activity_date_time',
332 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
333 'title' => ts('Activity Date'),
334 'description' => ts('Date and time this activity is scheduled to occur. Formerly named scheduled_date_time.'),
337 'where' => 'civicrm_activity.activity_date_time',
338 'headerPattern' => '/(activity.)?date(.time$)?/i',
340 'default' => 'CURRENT_TIMESTAMP',
341 'table_name' => 'civicrm_activity',
342 'entity' => 'Activity',
343 'bao' => 'CRM_Activity_BAO_Activity',
346 'type' => 'Select Date',
347 'formatType' => 'activityDateTime',
351 'activity_duration' => [
352 'name' => 'duration',
353 'type' => CRM_Utils_Type
::T_INT
,
354 'title' => ts('Duration'),
355 'description' => ts('Planned or actual duration of activity expressed in minutes. Conglomerate of former duration_hours and duration_minutes.'),
357 'where' => 'civicrm_activity.duration',
358 'headerPattern' => '/(activity.)?duration(s)?$/i',
360 'table_name' => 'civicrm_activity',
361 'entity' => 'Activity',
362 'bao' => 'CRM_Activity_BAO_Activity',
369 'activity_location' => [
370 'name' => 'location',
371 'type' => CRM_Utils_Type
::T_STRING
,
372 'title' => ts('Location'),
373 'description' => ts('Location of the activity (optional, open text).'),
375 'size' => CRM_Utils_Type
::HUGE
,
377 'where' => 'civicrm_activity.location',
378 'headerPattern' => '/(activity.)?location$/i',
380 'table_name' => 'civicrm_activity',
381 'entity' => 'Activity',
382 'bao' => 'CRM_Activity_BAO_Activity',
390 'name' => 'phone_id',
391 'type' => CRM_Utils_Type
::T_INT
,
392 'title' => ts('Phone (called)'),
393 'description' => ts('Phone ID of the number called (optional - used if an existing phone number is selected).'),
394 'where' => 'civicrm_activity.phone_id',
395 'table_name' => 'civicrm_activity',
396 'entity' => 'Activity',
397 'bao' => 'CRM_Activity_BAO_Activity',
399 'FKClassName' => 'CRM_Core_DAO_Phone',
401 'type' => 'EntityRef',
406 'name' => 'phone_number',
407 'type' => CRM_Utils_Type
::T_STRING
,
408 'title' => ts('Phone (called) Number'),
409 'description' => ts('Phone number in case the number does not exist in the civicrm_phone table.'),
411 'size' => CRM_Utils_Type
::BIG
,
412 'where' => 'civicrm_activity.phone_number',
413 'table_name' => 'civicrm_activity',
414 'entity' => 'Activity',
415 'bao' => 'CRM_Activity_BAO_Activity',
422 'activity_details' => [
424 'type' => CRM_Utils_Type
::T_LONGTEXT
,
425 'title' => ts('Details'),
426 'description' => ts('Details about the activity (agenda, notes, etc).'),
428 'where' => 'civicrm_activity.details',
429 'headerPattern' => '/(activity.)?detail(s)?$/i',
431 'table_name' => 'civicrm_activity',
432 'entity' => 'Activity',
433 'bao' => 'CRM_Activity_BAO_Activity',
436 'type' => 'RichTextEditor',
440 'activity_status_id' => [
441 'name' => 'status_id',
442 'type' => CRM_Utils_Type
::T_INT
,
443 'title' => ts('Activity Status'),
444 'description' => ts('ID of the status this activity is currently in. Foreign key to civicrm_option_value.'),
446 'where' => 'civicrm_activity.status_id',
447 'headerPattern' => '/(activity.)?status(.label$)?/i',
449 'table_name' => 'civicrm_activity',
450 'entity' => 'Activity',
451 'bao' => 'CRM_Activity_BAO_Activity',
456 'pseudoconstant' => [
457 'optionGroupName' => 'activity_status',
458 'optionEditPath' => 'civicrm/admin/options/activity_status',
463 'name' => 'priority_id',
464 'type' => CRM_Utils_Type
::T_INT
,
465 'title' => ts('Priority'),
466 'description' => ts('ID of the priority given to this activity. Foreign key to civicrm_option_value.'),
468 'where' => 'civicrm_activity.priority_id',
470 'table_name' => 'civicrm_activity',
471 'entity' => 'Activity',
472 'bao' => 'CRM_Activity_BAO_Activity',
477 'pseudoconstant' => [
478 'optionGroupName' => 'priority',
479 'optionEditPath' => 'civicrm/admin/options/priority',
484 'name' => 'parent_id',
485 'type' => CRM_Utils_Type
::T_INT
,
486 'title' => ts('Parent Activity Id'),
487 'description' => ts('Parent meeting ID (if this is a follow-up item). This is not currently implemented'),
488 'where' => 'civicrm_activity.parent_id',
489 'table_name' => 'civicrm_activity',
490 'entity' => 'Activity',
491 'bao' => 'CRM_Activity_BAO_Activity',
493 'FKClassName' => 'CRM_Activity_DAO_Activity',
496 'activity_is_test' => [
498 'type' => CRM_Utils_Type
::T_BOOLEAN
,
499 'title' => ts('Test'),
501 'where' => 'civicrm_activity.is_test',
502 'headerPattern' => '/(is.)?test(.activity)?/i',
505 'table_name' => 'civicrm_activity',
506 'entity' => 'Activity',
507 'bao' => 'CRM_Activity_BAO_Activity',
510 'type' => 'CheckBox',
514 'activity_medium_id' => [
515 'name' => 'medium_id',
516 'type' => CRM_Utils_Type
::T_INT
,
517 'title' => ts('Activity Medium'),
518 'description' => ts('Activity Medium, Implicit FK to civicrm_option_value where option_group = encounter_medium.'),
519 'where' => 'civicrm_activity.medium_id',
521 'table_name' => 'civicrm_activity',
522 'entity' => 'Activity',
523 'bao' => 'CRM_Activity_BAO_Activity',
528 'pseudoconstant' => [
529 'optionGroupName' => 'encounter_medium',
530 'optionEditPath' => 'civicrm/admin/options/encounter_medium',
536 'type' => CRM_Utils_Type
::T_BOOLEAN
,
537 'title' => ts('Auto'),
538 'where' => 'civicrm_activity.is_auto',
540 'table_name' => 'civicrm_activity',
541 'entity' => 'Activity',
542 'bao' => 'CRM_Activity_BAO_Activity',
546 'relationship_id' => [
547 'name' => 'relationship_id',
548 'type' => CRM_Utils_Type
::T_INT
,
549 'title' => ts('Relationship Id'),
550 'description' => ts('FK to Relationship ID'),
551 'where' => 'civicrm_activity.relationship_id',
553 'table_name' => 'civicrm_activity',
554 'entity' => 'Activity',
555 'bao' => 'CRM_Activity_BAO_Activity',
557 'FKClassName' => 'CRM_Contact_DAO_Relationship',
560 'is_current_revision' => [
561 'name' => 'is_current_revision',
562 'type' => CRM_Utils_Type
::T_BOOLEAN
,
563 'title' => ts('Is this activity a current revision in versioning chain?'),
565 'where' => 'civicrm_activity.is_current_revision',
566 'headerPattern' => '/(is.)?(current.)?(revision|version(ing)?)/i',
569 'table_name' => 'civicrm_activity',
570 'entity' => 'Activity',
571 'bao' => 'CRM_Activity_BAO_Activity',
576 'name' => 'original_id',
577 'type' => CRM_Utils_Type
::T_INT
,
578 'title' => ts('Original Activity ID '),
579 'description' => ts('Activity ID of the first activity record in versioning chain.'),
580 'where' => 'civicrm_activity.original_id',
581 'table_name' => 'civicrm_activity',
582 'entity' => 'Activity',
583 'bao' => 'CRM_Activity_BAO_Activity',
585 'FKClassName' => 'CRM_Activity_DAO_Activity',
588 'activity_result' => [
590 'type' => CRM_Utils_Type
::T_STRING
,
591 'title' => ts('Result'),
592 'description' => ts('Currently being used to store result id for survey activity, FK to option value.'),
594 'size' => CRM_Utils_Type
::HUGE
,
595 'where' => 'civicrm_activity.result',
596 'table_name' => 'civicrm_activity',
597 'entity' => 'Activity',
598 'bao' => 'CRM_Activity_BAO_Activity',
602 'activity_is_deleted' => [
603 'name' => 'is_deleted',
604 'type' => CRM_Utils_Type
::T_BOOLEAN
,
605 'title' => ts('Activity is in the Trash'),
607 'where' => 'civicrm_activity.is_deleted',
608 'headerPattern' => '/(activity.)?(trash|deleted)/i',
611 'table_name' => 'civicrm_activity',
612 'entity' => 'Activity',
613 'bao' => 'CRM_Activity_BAO_Activity',
616 'type' => 'CheckBox',
620 'activity_campaign_id' => [
621 'name' => 'campaign_id',
622 'type' => CRM_Utils_Type
::T_INT
,
623 'title' => ts('Campaign'),
624 'description' => ts('The campaign for which this activity has been triggered.'),
626 'where' => 'civicrm_activity.campaign_id',
628 'table_name' => 'civicrm_activity',
629 'entity' => 'Activity',
630 'bao' => 'CRM_Activity_BAO_Activity',
632 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
636 'pseudoconstant' => [
637 'table' => 'civicrm_campaign',
639 'labelColumn' => 'title',
643 'activity_engagement_level' => [
644 'name' => 'engagement_level',
645 'type' => CRM_Utils_Type
::T_INT
,
646 'title' => ts('Engagement Index'),
647 'description' => ts('Assign a specific level of engagement to this activity. Used for tracking constituents in ladder of engagement.'),
649 'where' => 'civicrm_activity.engagement_level',
651 'table_name' => 'civicrm_activity',
652 'entity' => 'Activity',
653 'bao' => 'CRM_Activity_BAO_Activity',
658 'pseudoconstant' => [
659 'optionGroupName' => 'engagement_index',
660 'optionEditPath' => 'civicrm/admin/options/engagement_index',
666 'type' => CRM_Utils_Type
::T_INT
,
667 'title' => ts('Order'),
668 'where' => 'civicrm_activity.weight',
669 'table_name' => 'civicrm_activity',
670 'entity' => 'Activity',
671 'bao' => 'CRM_Activity_BAO_Activity',
677 'type' => CRM_Utils_Type
::T_BOOLEAN
,
678 'title' => ts('Is Starred'),
679 'description' => ts('Activity marked as favorite.'),
681 'where' => 'civicrm_activity.is_star',
682 'headerPattern' => '/(activity.)?(star|favorite)/i',
685 'table_name' => 'civicrm_activity',
686 'entity' => 'Activity',
687 'bao' => 'CRM_Activity_BAO_Activity',
690 'type' => 'Checkbox',
694 'activity_created_date' => [
695 'name' => 'created_date',
696 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
697 'title' => ts('Created Date'),
698 'description' => ts('When was the activity was created.'),
700 'where' => 'civicrm_activity.created_date',
702 'default' => 'CURRENT_TIMESTAMP',
703 'table_name' => 'civicrm_activity',
704 'entity' => 'Activity',
705 'bao' => 'CRM_Activity_BAO_Activity',
709 'activity_modified_date' => [
710 'name' => 'modified_date',
711 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
712 'title' => ts('Modified Date'),
713 'description' => ts('When was the activity (or closely related entity) was created or modified or deleted.'),
715 'where' => 'civicrm_activity.modified_date',
717 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
718 'table_name' => 'civicrm_activity',
719 'entity' => 'Activity',
720 'bao' => 'CRM_Activity_BAO_Activity',
725 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
727 return Civi
::$statics[__CLASS__
]['fields'];
731 * Return a mapping from field-name to the corresponding key (as used in fields()).
734 * Array(string $name => string $uniqueName).
736 public static function &fieldKeys() {
737 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
738 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
740 return Civi
::$statics[__CLASS__
]['fieldKeys'];
744 * Returns the names of this table
748 public static function getTableName() {
749 return self
::$_tableName;
753 * Returns if this table needs to be logged
757 public function getLog() {
762 * Returns the list of fields that can be imported
764 * @param bool $prefix
768 public static function &import($prefix = FALSE) {
769 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'activity', $prefix, []);
774 * Returns the list of fields that can be exported
776 * @param bool $prefix
780 public static function &export($prefix = FALSE) {
781 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'activity', $prefix, []);
786 * Returns the list of indices
788 * @param bool $localize
792 public static function indices($localize = TRUE) {
794 'UI_source_record_id' => [
795 'name' => 'UI_source_record_id',
797 0 => 'source_record_id',
799 'localizable' => FALSE,
800 'sig' => 'civicrm_activity::0::source_record_id',
802 'UI_activity_type_id' => [
803 'name' => 'UI_activity_type_id',
805 0 => 'activity_type_id',
807 'localizable' => FALSE,
808 'sig' => 'civicrm_activity::0::activity_type_id',
810 'index_activity_date_time' => [
811 'name' => 'index_activity_date_time',
813 0 => 'activity_date_time',
815 'localizable' => FALSE,
816 'sig' => 'civicrm_activity::0::activity_date_time',
818 'index_status_id' => [
819 'name' => 'index_status_id',
823 'localizable' => FALSE,
824 'sig' => 'civicrm_activity::0::status_id',
826 'index_is_current_revision' => [
827 'name' => 'index_is_current_revision',
829 0 => 'is_current_revision',
831 'localizable' => FALSE,
832 'sig' => 'civicrm_activity::0::is_current_revision',
834 'index_is_deleted' => [
835 'name' => 'index_is_deleted',
839 'localizable' => FALSE,
840 'sig' => 'civicrm_activity::0::is_deleted',
843 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;