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',
478 'table_name' => 'civicrm_activity',
479 'entity' => 'Activity',
480 'bao' => 'CRM_Activity_BAO_Activity',
486 'activity_medium_id' => [
487 'name' => 'medium_id',
488 'type' => CRM_Utils_Type
::T_INT
,
489 'title' => ts('Activity Medium'),
490 'description' => 'Activity Medium, Implicit FK to civicrm_option_value where option_group = encounter_medium.',
492 'table_name' => 'civicrm_activity',
493 'entity' => 'Activity',
494 'bao' => 'CRM_Activity_BAO_Activity',
499 'pseudoconstant' => [
500 'optionGroupName' => 'encounter_medium',
501 'optionEditPath' => 'civicrm/admin/options/encounter_medium',
506 'type' => CRM_Utils_Type
::T_BOOLEAN
,
507 'title' => ts('Auto'),
508 'table_name' => 'civicrm_activity',
509 'entity' => 'Activity',
510 'bao' => 'CRM_Activity_BAO_Activity',
513 'relationship_id' => [
514 'name' => 'relationship_id',
515 'type' => CRM_Utils_Type
::T_INT
,
516 'title' => ts('Relationship Id'),
517 'description' => 'FK to Relationship ID',
519 'table_name' => 'civicrm_activity',
520 'entity' => 'Activity',
521 'bao' => 'CRM_Activity_BAO_Activity',
523 'FKClassName' => 'CRM_Contact_DAO_Relationship',
525 'is_current_revision' => [
526 'name' => 'is_current_revision',
527 'type' => CRM_Utils_Type
::T_BOOLEAN
,
528 'title' => ts('Is this activity a current revision in versioning chain?'),
530 'where' => 'civicrm_activity.is_current_revision',
531 'headerPattern' => '/(is.)?(current.)?(revision|version(ing)?)/i',
535 'table_name' => 'civicrm_activity',
536 'entity' => 'Activity',
537 'bao' => 'CRM_Activity_BAO_Activity',
540 'type' => 'CheckBox',
544 'name' => 'original_id',
545 'type' => CRM_Utils_Type
::T_INT
,
546 'title' => ts('Original Activity ID '),
547 'description' => 'Activity ID of the first activity record in versioning chain.',
548 'table_name' => 'civicrm_activity',
549 'entity' => 'Activity',
550 'bao' => 'CRM_Activity_BAO_Activity',
552 'FKClassName' => 'CRM_Activity_DAO_Activity',
554 'activity_result' => [
556 'type' => CRM_Utils_Type
::T_STRING
,
557 'title' => ts('Result'),
558 'description' => 'Currently being used to store result id for survey activity, FK to option value.',
560 'size' => CRM_Utils_Type
::HUGE
,
561 'table_name' => 'civicrm_activity',
562 'entity' => 'Activity',
563 'bao' => 'CRM_Activity_BAO_Activity',
569 'activity_is_deleted' => [
570 'name' => 'is_deleted',
571 'type' => CRM_Utils_Type
::T_BOOLEAN
,
572 'title' => ts('Activity is in the Trash'),
574 'where' => 'civicrm_activity.is_deleted',
575 'headerPattern' => '/(activity.)?(trash|deleted)/i',
578 'table_name' => 'civicrm_activity',
579 'entity' => 'Activity',
580 'bao' => 'CRM_Activity_BAO_Activity',
586 'activity_campaign_id' => [
587 'name' => 'campaign_id',
588 'type' => CRM_Utils_Type
::T_INT
,
589 'title' => ts('Campaign'),
590 'description' => 'The campaign for which this activity has been triggered.',
592 'where' => 'civicrm_activity.campaign_id',
593 'headerPattern' => '',
596 'table_name' => 'civicrm_activity',
597 'entity' => 'Activity',
598 'bao' => 'CRM_Activity_BAO_Activity',
600 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
602 'type' => 'CheckBox',
604 'pseudoconstant' => [
605 'table' => 'civicrm_campaign',
607 'labelColumn' => 'title',
610 'activity_engagement_level' => [
611 'name' => 'engagement_level',
612 'type' => CRM_Utils_Type
::T_INT
,
613 'title' => ts('Engagement Index'),
614 'description' => 'Assign a specific level of engagement to this activity. Used for tracking constituents in ladder of engagement.',
616 'where' => 'civicrm_activity.engagement_level',
617 'headerPattern' => '',
620 'table_name' => 'civicrm_activity',
621 'entity' => 'Activity',
622 'bao' => 'CRM_Activity_BAO_Activity',
627 'pseudoconstant' => [
628 'optionGroupName' => 'engagement_index',
629 'optionEditPath' => 'civicrm/admin/options/engagement_index',
634 'type' => CRM_Utils_Type
::T_INT
,
635 'title' => ts('Order'),
636 'table_name' => 'civicrm_activity',
637 'entity' => 'Activity',
638 'bao' => 'CRM_Activity_BAO_Activity',
646 'type' => CRM_Utils_Type
::T_BOOLEAN
,
647 'title' => ts('Is Starred'),
648 'description' => 'Activity marked as favorite.',
650 'where' => 'civicrm_activity.is_star',
651 'headerPattern' => '/(activity.)?(star|favorite)/i',
654 'table_name' => 'civicrm_activity',
655 'entity' => 'Activity',
656 'bao' => 'CRM_Activity_BAO_Activity',
659 'activity_created_date' => [
660 'name' => 'created_date',
661 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
662 'title' => ts('Created Date'),
663 'description' => 'When was the activity was created.',
666 'where' => 'civicrm_activity.created_date',
667 'headerPattern' => '',
670 'table_name' => 'civicrm_activity',
671 'entity' => 'Activity',
672 'bao' => 'CRM_Activity_BAO_Activity',
675 'activity_modified_date' => [
676 'name' => 'modified_date',
677 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
678 'title' => ts('Modified Date'),
679 'description' => 'When was the activity (or closely related entity) was created or modified or deleted.',
682 'where' => 'civicrm_activity.modified_date',
683 'headerPattern' => '',
685 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
686 'table_name' => 'civicrm_activity',
687 'entity' => 'Activity',
688 'bao' => 'CRM_Activity_BAO_Activity',
692 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
694 return Civi
::$statics[__CLASS__
]['fields'];
698 * Return a mapping from field-name to the corresponding key (as used in fields()).
701 * Array(string $name => string $uniqueName).
703 public static function &fieldKeys() {
704 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
705 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
707 return Civi
::$statics[__CLASS__
]['fieldKeys'];
711 * Returns the names of this table
715 public static function getTableName() {
716 return self
::$_tableName;
720 * Returns if this table needs to be logged
724 public function getLog() {
729 * Returns the list of fields that can be imported
731 * @param bool $prefix
735 public static function &import($prefix = FALSE) {
736 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'activity', $prefix, []);
741 * Returns the list of fields that can be exported
743 * @param bool $prefix
747 public static function &export($prefix = FALSE) {
748 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'activity', $prefix, []);
753 * Returns the list of indices
755 * @param bool $localize
759 public static function indices($localize = TRUE) {
761 'UI_source_record_id' => [
762 'name' => 'UI_source_record_id',
764 0 => 'source_record_id',
766 'localizable' => FALSE,
767 'sig' => 'civicrm_activity::0::source_record_id',
769 'UI_activity_type_id' => [
770 'name' => 'UI_activity_type_id',
772 0 => 'activity_type_id',
774 'localizable' => FALSE,
775 'sig' => 'civicrm_activity::0::activity_type_id',
777 'index_activity_date_time' => [
778 'name' => 'index_activity_date_time',
780 0 => 'activity_date_time',
782 'localizable' => FALSE,
783 'sig' => 'civicrm_activity::0::activity_date_time',
785 'index_status_id' => [
786 'name' => 'index_status_id',
790 'localizable' => FALSE,
791 'sig' => 'civicrm_activity::0::status_id',
793 'index_medium_id' => [
794 'name' => 'index_medium_id',
798 'localizable' => FALSE,
799 'sig' => 'civicrm_activity::0::medium_id',
801 'index_is_current_revision' => [
802 'name' => 'index_is_current_revision',
804 0 => 'is_current_revision',
806 'localizable' => FALSE,
807 'sig' => 'civicrm_activity::0::is_current_revision',
809 'index_is_deleted' => [
810 'name' => 'index_is_deleted',
814 'localizable' => FALSE,
815 'sig' => 'civicrm_activity::0::is_deleted',
818 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;