From: yashodha Date: Mon, 16 Jan 2017 09:25:54 +0000 (+0530) Subject: CRM-19883 - Activity Priority Field is Not Included in Advanced Search or Activity... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=da236f9a89c54e957e9578482b005a55c5600fe4;p=civicrm-core.git CRM-19883 - Activity Priority Field is Not Included in Advanced Search or Activity Reports --- diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php index b990e3d7a8..05e5d09de9 100644 --- a/CRM/Activity/BAO/Activity.php +++ b/CRM/Activity/BAO/Activity.php @@ -2175,6 +2175,12 @@ AND cl.modified_id = c.id 'type' => CRM_Utils_Type::T_STRING, 'searchByLabel' => TRUE, ), + 'activity_priority' => array( + 'title' => ts('Activity Priority'), + 'name' => 'activity_priority', + 'type' => CRM_Utils_Type::T_STRING, + 'searchByLabel' => TRUE, + ), ); $fields = array_merge($Activityfields, $exportableFields); } diff --git a/CRM/Activity/BAO/Query.php b/CRM/Activity/BAO/Query.php index 00b314727e..042276c9c8 100644 --- a/CRM/Activity/BAO/Query.php +++ b/CRM/Activity/BAO/Query.php @@ -39,13 +39,13 @@ class CRM_Activity_BAO_Query { */ public static function select(&$query) { if (!empty($query->_returnProperties['activity_id'])) { - $query->_select['activity_id'] = "civicrm_activity.id as activity_id"; + $query->_select['activity_id'] = 'civicrm_activity.id as activity_id'; $query->_element['activity_id'] = 1; $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1; } if (!empty($query->_returnProperties['activity_type_id'])) { - $query->_select['activity_type_id'] = "activity_type.value as activity_type_id"; + $query->_select['activity_type_id'] = 'activity_type.value as activity_type_id'; $query->_element['activity_type_id'] = 1; $query->_tables['civicrm_activity'] = 1; $query->_tables['activity_type'] = 1; @@ -54,7 +54,7 @@ class CRM_Activity_BAO_Query { } if (!empty($query->_returnProperties['activity_type'])) { - $query->_select['activity_type'] = "activity_type.label as activity_type"; + $query->_select['activity_type'] = 'activity_type.label as activity_type'; $query->_element['activity_type'] = 1; $query->_tables['civicrm_activity'] = 1; $query->_tables['activity_type'] = 1; @@ -63,19 +63,19 @@ class CRM_Activity_BAO_Query { } if (!empty($query->_returnProperties['activity_subject'])) { - $query->_select['activity_subject'] = "civicrm_activity.subject as activity_subject"; + $query->_select['activity_subject'] = 'civicrm_activity.subject as activity_subject'; $query->_element['activity_subject'] = 1; $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1; } if (!empty($query->_returnProperties['activity_date_time'])) { - $query->_select['activity_date_time'] = "civicrm_activity.activity_date_time as activity_date_time"; + $query->_select['activity_date_time'] = 'civicrm_activity.activity_date_time as activity_date_time'; $query->_element['activity_date_time'] = 1; $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1; } if (!empty($query->_returnProperties['activity_status_id'])) { - $query->_select['activity_status_id'] = "activity_status.value as activity_status_id"; + $query->_select['activity_status_id'] = 'activity_status.value as activity_status_id'; $query->_element['activity_status_id'] = 1; $query->_tables['civicrm_activity'] = 1; $query->_tables['activity_status'] = 1; @@ -84,8 +84,8 @@ class CRM_Activity_BAO_Query { } if (!empty($query->_returnProperties['activity_status'])) { - $query->_select['activity_status'] = "activity_status.label as activity_status, - civicrm_activity.status_id as status_id"; + $query->_select['activity_status'] = 'activity_status.label as activity_status, + civicrm_activity.status_id as status_id'; $query->_element['activity_status'] = 1; $query->_tables['civicrm_activity'] = 1; $query->_tables['activity_status'] = 1; @@ -94,31 +94,31 @@ class CRM_Activity_BAO_Query { } if (!empty($query->_returnProperties['activity_duration'])) { - $query->_select['activity_duration'] = "civicrm_activity.duration as activity_duration"; + $query->_select['activity_duration'] = 'civicrm_activity.duration as activity_duration'; $query->_element['activity_duration'] = 1; $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1; } if (!empty($query->_returnProperties['activity_location'])) { - $query->_select['activity_location'] = "civicrm_activity.location as activity_location"; + $query->_select['activity_location'] = 'civicrm_activity.location as activity_location'; $query->_element['activity_location'] = 1; $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1; } if (!empty($query->_returnProperties['activity_details'])) { - $query->_select['activity_details'] = "civicrm_activity.details as activity_details"; + $query->_select['activity_details'] = 'civicrm_activity.details as activity_details'; $query->_element['activity_details'] = 1; $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1; } if (!empty($query->_returnProperties['source_record_id'])) { - $query->_select['source_record_id'] = "civicrm_activity.source_record_id as source_record_id"; + $query->_select['source_record_id'] = 'civicrm_activity.source_record_id as source_record_id'; $query->_element['source_record_id'] = 1; $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1; } if (!empty($query->_returnProperties['activity_is_test'])) { - $query->_select['activity_is_test'] = "civicrm_activity.is_test as activity_is_test"; + $query->_select['activity_is_test'] = 'civicrm_activity.is_test as activity_is_test'; $query->_element['activity_is_test'] = 1; $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1; } @@ -152,6 +152,15 @@ class CRM_Activity_BAO_Query { $query->_whereTables['parent_id'] = 1; $query->_element['parent_id'] = 1; } + + if (!empty($query->_returnProperties['activity_priority'])) { + $query->_select['activity_priority'] = 'activity_priority.label as activity_priority, + civicrm_activity.priority_id as priority_id'; + $query->_element['activity_priority'] = 1; + $query->_tables['activity_priority'] = 1; + $query->_whereTables['activity_priority'] = 1; + $query->_tables['civicrm_activity'] = $query->_whereTables['civicrm_activity'] = 1; + } } /** @@ -192,6 +201,7 @@ class CRM_Activity_BAO_Query { case 'activity_engagement_level': case 'activity_id': case 'activity_campaign_id': + case 'activity_priority_id': // We no longer expect "subject" as a specific criteria (as of CRM-19447), // but we still use activity_subject in Activity.Get API case 'activity_subject': @@ -200,7 +210,7 @@ class CRM_Activity_BAO_Query { if (in_array($name, array('activity_engagement_level', 'activity_id'))) { $name = $qillName = str_replace('activity_', '', $name); } - if (in_array($name, array('activity_status_id', 'activity_subject'))) { + if (in_array($name, array('activity_status_id', 'activity_subject', 'activity_priority_id'))) { $name = str_replace('activity_', '', $name); $qillName = str_replace('_id', '', $qillName); } @@ -221,6 +231,7 @@ class CRM_Activity_BAO_Query { case 'activity_type': case 'activity_status': + case 'activity_priority': $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("$name.label", $op, $value, 'String'); list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Activity_DAO_Activity', $name, $value, $op); $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$name]['title'], 2 => $op, 3 => $value)); @@ -379,6 +390,12 @@ class CRM_Activity_BAO_Query { AND option_group_activity_type.id = activity_type.option_group_id ) "; break; + case 'activity_priority': + $from .= " $side JOIN civicrm_option_group option_group_activity_priority ON (option_group_activity_priority.name = 'priority')"; + $from .= " $side JOIN civicrm_option_value activity_priority ON (civicrm_activity.priority_id = activity_priority.value + AND option_group_activity_priority.id = activity_priority.option_group_id ) "; + break; + case 'civicrm_activity_tag': $from .= " $side JOIN civicrm_entity_tag as civicrm_activity_tag ON ( civicrm_activity_tag.entity_table = 'civicrm_activity' AND civicrm_activity_tag.entity_id = civicrm_activity.id ) "; break; @@ -444,6 +461,11 @@ class CRM_Activity_BAO_Query { $form->addRadio('activity_option', '', CRM_Core_SelectValues::activityTextOptions()); $form->setDefaults(array('activity_option' => 'both')); + $priority = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id'); + $form->addSelect('priority_id', + array('entity' => 'activity', 'label' => ts('Priority'), 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -')) + ); + $form->addYesNo('activity_test', ts('Activity is a Test?')); $activity_tags = CRM_Core_BAO_Tag::getTags('civicrm_activity'); if ($activity_tags) { @@ -531,6 +553,7 @@ class CRM_Activity_BAO_Query { 'activity_location' => 1, 'activity_details' => 1, 'activity_status' => 1, + 'activity_priority' => 1, 'source_contact' => 1, 'source_record_id' => 1, 'activity_is_test' => 1, diff --git a/CRM/Activity/Form/Search.php b/CRM/Activity/Form/Search.php index 91917d1179..1ed11f3ddf 100644 --- a/CRM/Activity/Form/Search.php +++ b/CRM/Activity/Form/Search.php @@ -195,9 +195,14 @@ class CRM_Activity_Form_Search extends CRM_Core_Form_Search { $specialParams = array( 'activity_type_id', 'status_id', + 'priority_id', 'activity_text', ); - $changeNames = array('status_id' => 'activity_status_id'); + $changeNames = array( + 'status_id' => 'activity_status_id', + 'priority_id' => 'activity_priority_id', + ); + CRM_Contact_BAO_Query::processSpecialFormValue($this->_formValues, $specialParams, $changeNames); } diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 2cbacac170..07f7ce6ab4 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -1883,6 +1883,8 @@ class CRM_Contact_BAO_Query { case 'activity_role': case 'activity_status_id': case 'activity_status': + case 'activity_priority': + case 'activity_priority_id': case 'followup_parent_id': case 'parent_id': case 'source_contact_id': @@ -2659,6 +2661,7 @@ class CRM_Contact_BAO_Query { case 'parent_id': case 'civicrm_activity_contact': case 'source_contact': + case 'activity_priority': $from .= CRM_Activity_BAO_Query::from($name, $mode, $side); continue; diff --git a/CRM/Contact/Form/Search/Advanced.php b/CRM/Contact/Form/Search/Advanced.php index 3e2b7fcf54..d171068387 100644 --- a/CRM/Contact/Form/Search/Advanced.php +++ b/CRM/Contact/Form/Search/Advanced.php @@ -347,6 +347,7 @@ class CRM_Contact_Form_Search_Advanced extends CRM_Contact_Form_Search { 'contribution_trxn_id', 'activity_type_id', 'status_id', + 'priority_id', 'activity_subject', 'activity_details', 'contribution_page_id', @@ -356,7 +357,10 @@ class CRM_Contact_Form_Search_Advanced extends CRM_Contact_Form_Search { 'contact_tags', 'preferred_communication_method', ); - $changeNames = array('status_id' => 'activity_status_id'); + $changeNames = array( + 'status_id' => 'activity_status_id', + 'priority_id' => 'activity_priority_id', + ); CRM_Contact_BAO_Query::processSpecialFormValue($this->_formValues, $specialParams, $changeNames); $taglist = CRM_Utils_Array::value('contact_taglist', $this->_formValues); diff --git a/CRM/Report/Form/Activity.php b/CRM/Report/Form/Activity.php index 1447ce56b7..346d943b11 100644 --- a/CRM/Report/Form/Activity.php +++ b/CRM/Report/Form/Activity.php @@ -256,6 +256,11 @@ class CRM_Report_Form_Activity extends CRM_Report_Form { 'details' => array( 'title' => ts('Activity Details'), ), + 'priority_id' => array( + 'title' => ts('Priority'), + 'default' => TRUE, + 'type' => CRM_Utils_Type::T_STRING, + ), ), 'filters' => array( 'activity_date_time' => array( diff --git a/CRM/Report/Form/ActivitySummary.php b/CRM/Report/Form/ActivitySummary.php index e6041b1901..e1a1049a90 100644 --- a/CRM/Report/Form/ActivitySummary.php +++ b/CRM/Report/Form/ActivitySummary.php @@ -125,6 +125,11 @@ class CRM_Report_Form_ActivitySummary extends CRM_Report_Form { 'title' => ts('Duration'), 'default' => TRUE, ), + 'priority_id' => array( + 'title' => ts('Priority'), + 'default' => TRUE, + 'type' => CRM_Utils_Type::T_STRING, + ), 'id' => array( 'title' => ts('Total Activities'), 'required' => TRUE, @@ -672,6 +677,7 @@ class CRM_Report_Form_ActivitySummary extends CRM_Report_Form { $entryFound = FALSE; $activityType = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE); $activityStatus = CRM_Core_PseudoConstant::activityStatus(); + $priority = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id'); $onHover = ts('View Contact Summary for this Contact'); foreach ($rows as $rowNum => $row) { // make count columns point to activity detail report @@ -762,6 +768,13 @@ class CRM_Report_Form_ActivitySummary extends CRM_Report_Form { } } + if (array_key_exists('civicrm_activity_priority_id', $row)) { + if ($value = $row['civicrm_activity_priority_id']) { + $rows[$rowNum]['civicrm_activity_priority_id'] = $priority[$value]; + $entryFound = TRUE; + } + } + if (array_key_exists('civicrm_activity_duration', $row)) { if ($value = $row['civicrm_activity_duration']) { $rows[$rowNum]['civicrm_activity_duration'] = $rows[$rowNum]['civicrm_activity_duration_total']; diff --git a/templates/CRM/Activity/Form/Search/Common.tpl b/templates/CRM/Activity/Form/Search/Common.tpl index 73c0320a8a..df9923c00f 100644 --- a/templates/CRM/Activity/Form/Search/Common.tpl +++ b/templates/CRM/Activity/Form/Search/Common.tpl @@ -106,8 +106,10 @@ - {* td intentionally left blank to align the 'is test' widget on the right *} - + + {$form.priority_id.label}
+ {$form.priority_id.html} + {$form.activity_test.label} {help id="is-test" file="CRM/Contact/Form/Search/Advanced"}   {$form.activity_test.html}