5 * @copyright CiviCRM LLC (c) 2004-2019
7 * Generated from xml/schema/CRM/Activity/Activity.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:808e801e250ba56b83f69fe90d8b52c2)
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 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 public static $_log = TRUE;
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' => ts('Unique Other Activity ID'),
252 'where' => 'civicrm_activity.id',
254 'table_name' => 'civicrm_activity',
255 'entity' => 'Activity',
256 'bao' => 'CRM_Activity_BAO_Activity',
259 'source_record_id' => [
260 'name' => 'source_record_id',
261 'type' => CRM_Utils_Type
::T_INT
,
262 'title' => ts('Source Record'),
263 '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.'),
264 'where' => 'civicrm_activity.source_record_id',
265 'table_name' => 'civicrm_activity',
266 'entity' => 'Activity',
267 'bao' => 'CRM_Activity_BAO_Activity',
270 'activity_type_id' => [
271 'name' => 'activity_type_id',
272 'type' => CRM_Utils_Type
::T_INT
,
273 'title' => ts('Activity Type ID'),
274 'description' => ts('FK to civicrm_option_value.id, that has to be valid, registered activity type.'),
277 'where' => 'civicrm_activity.activity_type_id',
278 'headerPattern' => '/(activity.)?type(.id$)/i',
281 'table_name' => 'civicrm_activity',
282 'entity' => 'Activity',
283 'bao' => 'CRM_Activity_BAO_Activity',
288 'pseudoconstant' => [
289 'optionGroupName' => 'activity_type',
290 'optionEditPath' => 'civicrm/admin/options/activity_type',
293 'activity_subject' => [
295 'type' => CRM_Utils_Type
::T_STRING
,
296 'title' => ts('Subject'),
297 'description' => ts('The subject/purpose/short description of the activity.'),
299 'size' => CRM_Utils_Type
::HUGE
,
301 'where' => 'civicrm_activity.subject',
302 'headerPattern' => '/(activity.)?subject/i',
304 'table_name' => 'civicrm_activity',
305 'entity' => 'Activity',
306 'bao' => 'CRM_Activity_BAO_Activity',
312 'activity_date_time' => [
313 'name' => 'activity_date_time',
314 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
315 'title' => ts('Activity Date'),
316 'description' => ts('Date and time this activity is scheduled to occur. Formerly named scheduled_date_time.'),
318 'where' => 'civicrm_activity.activity_date_time',
319 'headerPattern' => '/(activity.)?date(.time$)?/i',
321 'table_name' => 'civicrm_activity',
322 'entity' => 'Activity',
323 'bao' => 'CRM_Activity_BAO_Activity',
326 'type' => 'Select Date',
327 'formatType' => 'activityDateTime',
330 'activity_duration' => [
331 'name' => 'duration',
332 'type' => CRM_Utils_Type
::T_INT
,
333 'title' => ts('Duration'),
334 'description' => ts('Planned or actual duration of activity expressed in minutes. Conglomerate of former duration_hours and duration_minutes.'),
336 'where' => 'civicrm_activity.duration',
337 'headerPattern' => '/(activity.)?duration(s)?$/i',
339 'table_name' => 'civicrm_activity',
340 'entity' => 'Activity',
341 'bao' => 'CRM_Activity_BAO_Activity',
347 'activity_location' => [
348 'name' => 'location',
349 'type' => CRM_Utils_Type
::T_STRING
,
350 'title' => ts('Location'),
351 'description' => ts('Location of the activity (optional, open text).'),
353 'size' => CRM_Utils_Type
::HUGE
,
355 'where' => 'civicrm_activity.location',
356 'headerPattern' => '/(activity.)?location$/i',
358 'table_name' => 'civicrm_activity',
359 'entity' => 'Activity',
360 'bao' => 'CRM_Activity_BAO_Activity',
367 'name' => 'phone_id',
368 'type' => CRM_Utils_Type
::T_INT
,
369 'title' => ts('Phone (called) ID'),
370 'description' => ts('Phone ID of the number called (optional - used if an existing phone number is selected).'),
371 'where' => 'civicrm_activity.phone_id',
372 'table_name' => 'civicrm_activity',
373 'entity' => 'Activity',
374 'bao' => 'CRM_Activity_BAO_Activity',
376 'FKClassName' => 'CRM_Core_DAO_Phone',
378 'type' => 'EntityRef',
382 'name' => 'phone_number',
383 'type' => CRM_Utils_Type
::T_STRING
,
384 'title' => ts('Phone (called) Number'),
385 'description' => ts('Phone number in case the number does not exist in the civicrm_phone table.'),
387 'size' => CRM_Utils_Type
::BIG
,
388 'where' => 'civicrm_activity.phone_number',
389 'table_name' => 'civicrm_activity',
390 'entity' => 'Activity',
391 'bao' => 'CRM_Activity_BAO_Activity',
397 'activity_details' => [
399 'type' => CRM_Utils_Type
::T_LONGTEXT
,
400 'title' => ts('Details'),
401 'description' => ts('Details about the activity (agenda, notes, etc).'),
403 'where' => 'civicrm_activity.details',
404 'headerPattern' => '/(activity.)?detail(s)?$/i',
406 'table_name' => 'civicrm_activity',
407 'entity' => 'Activity',
408 'bao' => 'CRM_Activity_BAO_Activity',
411 'type' => 'RichTextEditor',
414 'activity_status_id' => [
415 'name' => 'status_id',
416 'type' => CRM_Utils_Type
::T_INT
,
417 'title' => ts('Activity Status'),
418 'description' => ts('ID of the status this activity is currently in. Foreign key to civicrm_option_value.'),
420 'where' => 'civicrm_activity.status_id',
421 'headerPattern' => '/(activity.)?status(.label$)?/i',
423 'table_name' => 'civicrm_activity',
424 'entity' => 'Activity',
425 'bao' => 'CRM_Activity_BAO_Activity',
430 'pseudoconstant' => [
431 'optionGroupName' => 'activity_status',
432 'optionEditPath' => 'civicrm/admin/options/activity_status',
436 'name' => 'priority_id',
437 'type' => CRM_Utils_Type
::T_INT
,
438 'title' => ts('Priority'),
439 'description' => ts('ID of the priority given to this activity. Foreign key to civicrm_option_value.'),
440 'where' => 'civicrm_activity.priority_id',
441 'table_name' => 'civicrm_activity',
442 'entity' => 'Activity',
443 'bao' => 'CRM_Activity_BAO_Activity',
448 'pseudoconstant' => [
449 'optionGroupName' => 'priority',
450 'optionEditPath' => 'civicrm/admin/options/priority',
454 'name' => 'parent_id',
455 'type' => CRM_Utils_Type
::T_INT
,
456 'title' => ts('Parent Activity Id'),
457 'description' => ts('Parent meeting ID (if this is a follow-up item). This is not currently implemented'),
458 'where' => 'civicrm_activity.parent_id',
459 'table_name' => 'civicrm_activity',
460 'entity' => 'Activity',
461 'bao' => 'CRM_Activity_BAO_Activity',
463 'FKClassName' => 'CRM_Activity_DAO_Activity',
465 'activity_is_test' => [
467 'type' => CRM_Utils_Type
::T_BOOLEAN
,
468 'title' => ts('Test'),
470 'where' => 'civicrm_activity.is_test',
471 'headerPattern' => '/(is.)?test(.activity)?/i',
474 'table_name' => 'civicrm_activity',
475 'entity' => 'Activity',
476 'bao' => 'CRM_Activity_BAO_Activity',
482 'activity_medium_id' => [
483 'name' => 'medium_id',
484 'type' => CRM_Utils_Type
::T_INT
,
485 'title' => ts('Activity Medium'),
486 'description' => ts('Activity Medium, Implicit FK to civicrm_option_value where option_group = encounter_medium.'),
487 'where' => 'civicrm_activity.medium_id',
489 'table_name' => 'civicrm_activity',
490 'entity' => 'Activity',
491 'bao' => 'CRM_Activity_BAO_Activity',
496 'pseudoconstant' => [
497 'optionGroupName' => 'encounter_medium',
498 'optionEditPath' => 'civicrm/admin/options/encounter_medium',
503 'type' => CRM_Utils_Type
::T_BOOLEAN
,
504 'title' => ts('Auto'),
505 'where' => 'civicrm_activity.is_auto',
507 'table_name' => 'civicrm_activity',
508 'entity' => 'Activity',
509 'bao' => 'CRM_Activity_BAO_Activity',
512 'relationship_id' => [
513 'name' => 'relationship_id',
514 'type' => CRM_Utils_Type
::T_INT
,
515 'title' => ts('Relationship Id'),
516 'description' => ts('FK to Relationship ID'),
517 'where' => 'civicrm_activity.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',
534 'table_name' => 'civicrm_activity',
535 'entity' => 'Activity',
536 'bao' => 'CRM_Activity_BAO_Activity',
539 'type' => 'CheckBox',
543 'name' => 'original_id',
544 'type' => CRM_Utils_Type
::T_INT
,
545 'title' => ts('Original Activity ID '),
546 'description' => ts('Activity ID of the first activity record in versioning chain.'),
547 'where' => 'civicrm_activity.original_id',
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' => ts('Currently being used to store result id for survey activity, FK to option value.'),
560 'size' => CRM_Utils_Type
::HUGE
,
561 'where' => 'civicrm_activity.result',
562 'table_name' => 'civicrm_activity',
563 'entity' => 'Activity',
564 'bao' => 'CRM_Activity_BAO_Activity',
570 'activity_is_deleted' => [
571 'name' => 'is_deleted',
572 'type' => CRM_Utils_Type
::T_BOOLEAN
,
573 'title' => ts('Activity is in the Trash'),
575 'where' => 'civicrm_activity.is_deleted',
576 'headerPattern' => '/(activity.)?(trash|deleted)/i',
579 'table_name' => 'civicrm_activity',
580 'entity' => 'Activity',
581 'bao' => 'CRM_Activity_BAO_Activity',
587 'activity_campaign_id' => [
588 'name' => 'campaign_id',
589 'type' => CRM_Utils_Type
::T_INT
,
590 'title' => ts('Campaign'),
591 'description' => ts('The campaign for which this activity has been triggered.'),
593 'where' => 'civicrm_activity.campaign_id',
595 'table_name' => 'civicrm_activity',
596 'entity' => 'Activity',
597 'bao' => 'CRM_Activity_BAO_Activity',
599 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
601 'type' => 'CheckBox',
603 'pseudoconstant' => [
604 'table' => 'civicrm_campaign',
606 'labelColumn' => 'title',
609 'activity_engagement_level' => [
610 'name' => 'engagement_level',
611 'type' => CRM_Utils_Type
::T_INT
,
612 'title' => ts('Engagement Index'),
613 'description' => ts('Assign a specific level of engagement to this activity. Used for tracking constituents in ladder of engagement.'),
615 'where' => 'civicrm_activity.engagement_level',
617 'table_name' => 'civicrm_activity',
618 'entity' => 'Activity',
619 'bao' => 'CRM_Activity_BAO_Activity',
624 'pseudoconstant' => [
625 'optionGroupName' => 'engagement_index',
626 'optionEditPath' => 'civicrm/admin/options/engagement_index',
631 'type' => CRM_Utils_Type
::T_INT
,
632 'title' => ts('Order'),
633 'where' => 'civicrm_activity.weight',
634 'table_name' => 'civicrm_activity',
635 'entity' => 'Activity',
636 'bao' => 'CRM_Activity_BAO_Activity',
644 'type' => CRM_Utils_Type
::T_BOOLEAN
,
645 'title' => ts('Is Starred'),
646 'description' => ts('Activity marked as favorite.'),
648 'where' => 'civicrm_activity.is_star',
649 'headerPattern' => '/(activity.)?(star|favorite)/i',
652 'table_name' => 'civicrm_activity',
653 'entity' => 'Activity',
654 'bao' => 'CRM_Activity_BAO_Activity',
657 'activity_created_date' => [
658 'name' => 'created_date',
659 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
660 'title' => ts('Created Date'),
661 'description' => ts('When was the activity was created.'),
663 'where' => 'civicrm_activity.created_date',
666 'table_name' => 'civicrm_activity',
667 'entity' => 'Activity',
668 'bao' => 'CRM_Activity_BAO_Activity',
671 'activity_modified_date' => [
672 'name' => 'modified_date',
673 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
674 'title' => ts('Modified Date'),
675 'description' => ts('When was the activity (or closely related entity) was created or modified or deleted.'),
677 'where' => 'civicrm_activity.modified_date',
679 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
680 'table_name' => 'civicrm_activity',
681 'entity' => 'Activity',
682 'bao' => 'CRM_Activity_BAO_Activity',
686 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
688 return Civi
::$statics[__CLASS__
]['fields'];
692 * Return a mapping from field-name to the corresponding key (as used in fields()).
695 * Array(string $name => string $uniqueName).
697 public static function &fieldKeys() {
698 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
699 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
701 return Civi
::$statics[__CLASS__
]['fieldKeys'];
705 * Returns the names of this table
709 public static function getTableName() {
710 return self
::$_tableName;
714 * Returns if this table needs to be logged
718 public function getLog() {
723 * Returns the list of fields that can be imported
725 * @param bool $prefix
729 public static function &import($prefix = FALSE) {
730 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'activity', $prefix, []);
735 * Returns the list of fields that can be exported
737 * @param bool $prefix
741 public static function &export($prefix = FALSE) {
742 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'activity', $prefix, []);
747 * Returns the list of indices
749 * @param bool $localize
753 public static function indices($localize = TRUE) {
755 'UI_source_record_id' => [
756 'name' => 'UI_source_record_id',
758 0 => 'source_record_id',
760 'localizable' => FALSE,
761 'sig' => 'civicrm_activity::0::source_record_id',
763 'UI_activity_type_id' => [
764 'name' => 'UI_activity_type_id',
766 0 => 'activity_type_id',
768 'localizable' => FALSE,
769 'sig' => 'civicrm_activity::0::activity_type_id',
771 'index_activity_date_time' => [
772 'name' => 'index_activity_date_time',
774 0 => 'activity_date_time',
776 'localizable' => FALSE,
777 'sig' => 'civicrm_activity::0::activity_date_time',
779 'index_status_id' => [
780 'name' => 'index_status_id',
784 'localizable' => FALSE,
785 'sig' => 'civicrm_activity::0::status_id',
787 'index_medium_id' => [
788 'name' => 'index_medium_id',
792 'localizable' => FALSE,
793 'sig' => 'civicrm_activity::0::medium_id',
795 'index_is_current_revision' => [
796 'name' => 'index_is_current_revision',
798 0 => 'is_current_revision',
800 'localizable' => FALSE,
801 'sig' => 'civicrm_activity::0::is_current_revision',
803 'index_is_deleted' => [
804 'name' => 'index_is_deleted',
808 'localizable' => FALSE,
809 'sig' => 'civicrm_activity::0::is_deleted',
812 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;