$optionalParameters = array(
'context' => 'String',
+ 'activity_type_id' => 'Integer',
+ 'activity_type_exclude_id' => 'Integer',
);
$params = CRM_Core_Page_AJAX::defaultSortAndPagerParams();
// get the contact activities
$activities = CRM_Activity_BAO_Activity::getContactActivitySelector($params);
+ if (!empty($_GET['is_unit_test'])) {
+ return $activities;
+ }
+
foreach ($activities['data'] as $key => $value) {
// Check if recurring activity.
if (!empty($value['is_recurring_activity'])) {
"ajax": {
"url": {/literal}'{crmURL p="civicrm/ajax/contactactivity" h=0 q="snippet=4&context=$context&cid=$contactId"}'{literal},
"data": function (d) {
- d.activity_type_id = $('.crm-activity-selector-activity select#activity_type_filter_id').val(),
- d.activity_type_exclude_id = $('.crm-activity-selector-activity select#activity_type_exclude_filter_id').val()
+ d.activity_type_id = $('.crm-activity-selector-' + context + ' select#activity_type_filter_id').val(),
+ d.activity_type_exclude_id = $('.crm-activity-selector-' + context + ' select#activity_type_exclude_filter_id').val()
}
}
});
$(function($) {
$('.activity-search-options :input').change(function(){
- CRM.$('.contact-activity-selector-activity').DataTable().draw();
+ CRM.$('table.contact-activity-selector-' + context).DataTable().draw();
});
});
})(CRM.$);
$this->assertEquals($count, $activityCount);
}
+ /**
+ * CRM-18706 - Test Include/Exclude Activity Filters
+ */
+ public function testActivityFilters() {
+ $op = new PHPUnit_Extensions_Database_Operation_Insert();
+ $op->execute($this->_dbconn,
+ $this->createFlatXMLDataSet(
+ dirname(__FILE__) . '/activities_for_dashboard_count.xml'
+ )
+ );
+
+ global $_GET;
+ $_GET = array(
+ 'cid' => 9,
+ 'context' => 'activity',
+ 'activity_type_id' => 1,
+ 'is_unit_test' => 1,
+ );
+ $obj = new CRM_Activity_Page_AJAX();
+
+ $activities = $obj->getContactActivity();
+ // This should include activities of type Meeting only.
+ foreach ($activities['data'] as $key => $value) {
+ $this->assertEquals('Meeting', $value['activity_type']);
+ }
+ unset($_GET['activity_type_id']);
+
+ $_GET['activity_type_exclude_id'] = 1;
+ $activities = $obj->getContactActivity();
+ // None of the activities should be of type Meeting.
+ foreach ($activities['data'] as $key => $value) {
+ $this->assertNotEquals('Meeting', $value['activity_type']);
+ }
+ }
+
/**
* Test getActivitiesCount BAO method.
*/