Merge pull request #5317 from sfe-ev/chainselect-missing-fields
[civicrm-core.git] / CRM / Activity / Page / AJAX.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26 */
27
28 /**
29 *
30 * @package CRM
31 * @copyright CiviCRM LLC (c) 2004-2014
32 *
33 */
34
35 /**
36 * This class contains all the function that are called using AJAX (jQuery)
37 */
38 class CRM_Activity_Page_AJAX {
39 static function getCaseActivity() {
40 $caseID = CRM_Utils_Type::escape($_GET['caseID'], 'Integer');
41 $contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
42 $userID = CRM_Utils_Type::escape($_GET['userID'], 'Integer');
43 $context = CRM_Utils_Type::escape(CRM_Utils_Array::value('context', $_GET), 'String');
44
45 $sortMapper = array(
46 0 => 'display_date', 1 => 'ca.subject', 2 => 'ca.activity_type_id',
47 3 => 'acc.sort_name', 4 => 'cc.sort_name', 5 => 'ca.status_id',
48 );
49
50 $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
51 $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
52 $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
53 $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : NULL;
54 $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
55
56 $params = $_POST;
57 if ($sort && $sortOrder) {
58 $params['sortname'] = $sort;
59 $params['sortorder'] = $sortOrder;
60 }
61 $params['page'] = ($offset / $rowCount) + 1;
62 $params['rp'] = $rowCount;
63
64 // get the activities related to given case
65 $activities = CRM_Case_BAO_Case::getCaseActivity($caseID, $params, $contactID, $context, $userID);
66
67 $iFilteredTotal = $iTotal = $params['total'];
68 $selectorElements = array('display_date', 'subject', 'type', 'with_contacts', 'reporter', 'status', 'links', 'class');
69
70 header('Content-Type: application/json');
71 echo CRM_Utils_JSON::encodeDataTableSelector($activities, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
72 CRM_Utils_System::civiExit();
73 }
74
75 static function getCaseGlobalRelationships() {
76 $sortMapper = array(
77 0 => 'sort_name', 1 => 'phone', 2 => 'email',
78 );
79
80 $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
81 $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
82 $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
83 $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : NULL;
84 $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
85
86 $params = $_POST;
87 //CRM-14466 initialize variable to avoid php notice
88 $sortSQL = "";
89 if ($sort && $sortOrder) {
90 $sortSQL = $sort .' '.$sortOrder;
91 }
92
93 // get the activities related to given case
94 $globalGroupInfo = array();
95
96 // get the total row count
97 $relGlobalTotalCount = CRM_Case_BAO_Case::getGlobalContacts($globalGroupInfo, NULL, FALSE, TRUE, NULL, NULL);
98 // limit the rows
99 $relGlobal = CRM_Case_BAO_Case::getGlobalContacts($globalGroupInfo, $sortSQL, $showLinks = TRUE, FALSE, $offset, $rowCount);
100
101 $iFilteredTotal = $iTotal = $relGlobalTotalCount;
102 $selectorElements = array('sort_name', 'phone', 'email');
103
104 header('Content-Type: application/json');
105 echo CRM_Utils_JSON::encodeDataTableSelector($relGlobal, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
106 CRM_Utils_System::civiExit();
107 }
108
109 static function getCaseClientRelationships() {
110 $caseID = CRM_Utils_Type::escape($_GET['caseID'], 'Integer');
111 $contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
112
113 $sortMapper = array(
114 0 => 'relation', 1 => 'name', 2 => 'phone', 3 => 'email'
115 );
116
117 $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
118 $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
119 $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
120 $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : 'relation';
121 $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
122
123 $params = $_POST;
124 if ($sort && $sortOrder) {
125 $sortSQL = $sort .' '.$sortOrder;
126 }
127
128 // Retrieve ALL client relationships
129 $relClient = CRM_Contact_BAO_Relationship::getRelationship($contactID,
130 CRM_Contact_BAO_Relationship::CURRENT,
131 0, 0, 0, NULL, NULL, FALSE
132 );
133
134 $caseRelationships = CRM_Case_BAO_Case::getCaseRoles($contactID, $caseID);
135
136 // Now build 'Other Relationships' array by removing relationships that are already listed under Case Roles
137 // so they don't show up twice.
138 $clientRelationships = array();
139 foreach ($relClient as $r) {
140 if (!array_key_exists($r['id'], $caseRelationships)) {
141 $clientRelationships[] = $r;
142 }
143 }
144
145 // sort clientRelationships array using jquery call params
146 foreach ($clientRelationships as $key => $row) {
147 $sortArray[$key] = $row[$sort];
148 }
149 $sort_type = "SORT_" . strtoupper($sortOrder);
150 array_multisort($sortArray, constant($sort_type), $clientRelationships);
151
152 //limit the rows
153 $allClientRelationships = $clientRelationships;
154 $clientRelationships = array_slice($allClientRelationships, $offset, $rowCount, TRUE);
155
156 // after sort we can update username fields to be a url
157 foreach($clientRelationships as $key => $value) {
158 $clientRelationships[$key]['name'] = '<a href='.CRM_Utils_System::url('civicrm/contact/view',
159 'action=view&reset=1&cid='.$clientRelationships[$key]['cid']).'>'.$clientRelationships[$key]['name'].'</a>';
160 }
161
162 $iFilteredTotal = $iTotal = $params['total'] = count($allClientRelationships);
163 $selectorElements = array('relation', 'name', 'phone', 'email');
164
165 header('Content-Type: application/json');
166 echo CRM_Utils_JSON::encodeDataTableSelector($clientRelationships, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
167 CRM_Utils_System::civiExit();
168 }
169
170
171 static function getCaseRoles() {
172 $caseID = CRM_Utils_Type::escape($_GET['caseID'], 'Integer');
173 $contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
174
175 $sortMapper = array(
176 0 => 'relation', 1 => 'name', 2 => 'phone', 3 => 'email', 4 => 'actions'
177 );
178
179 $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
180 $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
181 $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
182 $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : 'relation';
183 $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
184
185 $params = $_POST;
186 if ($sort && $sortOrder) {
187 $sortSQL = $sort .' '.$sortOrder;
188 }
189
190 $caseRelationships = CRM_Case_BAO_Case::getCaseRoles($contactID, $caseID);
191 $caseTypeName = CRM_Case_BAO_Case::getCaseType($caseID, 'name');
192 $xmlProcessor = new CRM_Case_XMLProcessor_Process();
193 $caseRoles = $xmlProcessor->get($caseTypeName, 'CaseRoles');
194
195 $hasAccessToAllCases = CRM_Core_Permission::check('access all cases and activities');
196
197 $managerRoleId = $xmlProcessor->getCaseManagerRoleId($caseTypeName);
198 if (!empty($managerRoleId)) {
199 $caseRoles[$managerRoleId] = $caseRoles[$managerRoleId] . '<br />' . '(' . ts('Case Manager') . ')';
200 }
201
202 foreach ($caseRelationships as $key => $value) {
203 //calculate roles that don't have relationships
204 if (!empty($caseRoles[$value['relation_type']])) {
205 //keep naming from careRoles array
206 $caseRelationships[$key]['relation'] = $caseRoles[$value['relation_type']];
207 unset($caseRoles[$value['relation_type']]);
208 }
209 // mark orginal case relationships record to use on setting edit links below
210 $caseRelationships[$key]['source'] = 'caseRel';
211 }
212
213 $caseRoles['client'] = CRM_Case_BAO_Case::getContactNames($caseID);
214
215 // move/transform caseRoles array data to caseRelationships
216 // for sorting and display
217 // CRM-14466 added cid to the non-client array to avoid php notice
218 foreach($caseRoles as $id => $value) {
219 if ($id != "client") {
220 $rel = array();
221 $rel['relation'] = $value;
222 $rel['relation_type'] = $id;
223 $rel['name'] = '(not assigned)';
224 $rel['phone'] = '';
225 $rel['email'] = '';
226 $rel['source'] = 'caseRoles';
227 $caseRelationships[] = $rel;
228 } else {
229 foreach($value as $clientRole) {
230 $relClient = array();
231 $relClient['relation'] = 'Client';
232 $relClient['name'] = $clientRole['sort_name'];
233 $relClient['phone'] = $clientRole['phone'];
234 $relClient['email'] = $clientRole['email'];
235 $relClient['cid'] = $clientRole['contact_id'];
236 $relClient['source'] = 'contact';
237 $caseRelationships[] = $relClient;
238 }
239 }
240 }
241
242 // sort clientRelationships array using jquery call params
243 foreach ($caseRelationships as $key => $row) {
244 $sortArray[$key] = $row[$sort];
245 }
246
247 $sort_type = "SORT_" . strtoupper($sortOrder);
248 array_multisort($sortArray, constant($sort_type), $caseRelationships);
249
250 //limit rows display
251 $allCaseRelationships = $caseRelationships;
252 $caseRelationships = array_slice($allCaseRelationships, $offset, $rowCount, TRUE);
253
254 // set user name, email and edit columns links
255 // idx will count number of current row / needed by edit links
256 $idx = 1;
257 foreach ($caseRelationships as &$row) {
258 // Get rid of the "<br />(Case Manager)" from label
259 list($typeLabel) = explode('<', $row['relation']);
260 // view user links
261 if (!empty($row['cid'])) {
262 $row['name'] = '<a class="view-contact" title="'. ts('View Contact') .'" href='.CRM_Utils_System::url('civicrm/contact/view',
263 'action=view&reset=1&cid='.$row['cid']).'>'.$row['name'].'</a>';
264 }
265 // email column links/icon
266 if ($row['email']) {
267 $row['email'] = '<a class="crm-hover-button crm-popup" href="'.CRM_Utils_System::url('civicrm/activity/email/add', 'reset=1&action=add&atype=3&cid='.$row['cid']).'&caseid='.$caseID.'" title="'. ts('Send an Email') . '"><span class="icon email-icon"></span></a>';
268 }
269 // edit links
270 $row['actions'] = '';
271 if ($hasAccessToAllCases) {
272 $contactType = empty($row['relation_type']) ? '' : (string) CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $row['relation_type'], 'contact_type_b');
273 $contactType = $contactType == 'Contact' ? '' : $contactType;
274 switch($row['source']) {
275 case 'caseRel':
276 $row['actions'] =
277 '<a href="#editCaseRoleDialog" title="'. ts('Reassign %1', array(1 => $typeLabel)) .'" class="crm-hover-button case-miniform" data-contact_type="' . $contactType . '" data-rel_type="'. $row['relation_type'] .'" data-rel_id="'. $row['rel_id'] .'"data-key="'. CRM_Core_Key::get('civicrm/ajax/relation') .'">'.
278 '<span class="icon edit-icon"></span>'.
279 '</a>'.
280 '<a href="#deleteCaseRoleDialog" title="'. ts('Remove %1', array(1 => $typeLabel)) .'" class="crm-hover-button case-miniform" data-contact_type="' . $contactType . '" data-rel_type="'.$row['relation_type'].'" data-key="'. CRM_Core_Key::get('civicrm/ajax/delcaserole') .'">'.
281 '<span class="icon delete-icon"></span>'.
282 '</a>';
283 break;
284
285 case 'caseRoles':
286 $row['actions'] =
287 '<a href="#editCaseRoleDialog" title="'. ts('Assign %1', array(1 => $typeLabel)) .'" class="crm-hover-button case-miniform" data-contact_type="' . $contactType . '" data-rel_type="'. $row['relation_type'] .'" data-key="'. CRM_Core_Key::get('civicrm/ajax/relation') .'">'.
288 '<span class="icon edit-icon"></span>'.
289 '</a>';
290 break;
291 }
292 }
293 $idx++;
294 }
295 $iFilteredTotal = $iTotal = $params['total'] = count($allCaseRelationships);
296 $selectorElements = array('relation', 'name', 'phone', 'email', 'actions');
297
298 header('Content-Type: application/json');
299 echo CRM_Utils_JSON::encodeDataTableSelector($caseRelationships, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
300 CRM_Utils_System::civiExit();
301 }
302
303 static function convertToCaseActivity() {
304 $params = array('caseID', 'activityID', 'contactID', 'newSubject', 'targetContactIds', 'mode');
305 $vals = array();
306 foreach ($params as $param) {
307 $vals[$param] = CRM_Utils_Array::value($param, $_POST);
308 }
309
310 CRM_Utils_JSON::output(self::_convertToCaseActivity($vals));
311 }
312
313 /**
314 * @param $params
315 *
316 * @return array
317 */
318 static function _convertToCaseActivity($params) {
319 if (!$params['activityID'] || !$params['caseID']) {
320 return (array('error_msg' => 'required params missing.'));
321 }
322
323 $otherActivity = new CRM_Activity_DAO_Activity();
324 $otherActivity->id = $params['activityID'];
325 if (!$otherActivity->find(TRUE)) {
326 return (array('error_msg' => 'activity record is missing.'));
327 }
328 $actDateTime = CRM_Utils_Date::isoToMysql($otherActivity->activity_date_time);
329
330 //create new activity record.
331 $mainActivity = new CRM_Activity_DAO_Activity();
332 $mainActVals = array();
333 CRM_Core_DAO::storeValues($otherActivity, $mainActVals);
334
335 //get new activity subject.
336 if (!empty($params['newSubject'])) {
337 $mainActVals['subject'] = $params['newSubject'];
338 }
339
340 $mainActivity->copyValues($mainActVals);
341 $mainActivity->id = NULL;
342 $mainActivity->activity_date_time = $actDateTime;
343 //make sure this is current revision.
344 $mainActivity->is_current_revision = TRUE;
345 //drop all relations.
346 $mainActivity->parent_id = $mainActivity->original_id = NULL;
347
348 $mainActivity->save();
349 $mainActivityId = $mainActivity->id;
350 CRM_Activity_BAO_Activity::logActivityAction($mainActivity);
351 $mainActivity->free();
352
353 /* Mark previous activity as deleted. If it was a non-case activity
354 * then just change the subject.
355 */
356
357 if (in_array($params['mode'], array(
358 'move', 'file'))) {
359 $caseActivity = new CRM_Case_DAO_CaseActivity();
360 $caseActivity->case_id = $params['caseID'];
361 $caseActivity->activity_id = $otherActivity->id;
362 if ($params['mode'] == 'move' || $caseActivity->find(TRUE)) {
363 $otherActivity->is_deleted = 1;
364 }
365 else {
366 $otherActivity->subject = ts('(Filed on case %1)', array(
367 1 => $params['caseID']
368 )) . ' ' . $otherActivity->subject;
369 }
370 $otherActivity->activity_date_time = $actDateTime;
371 $otherActivity->save();
372
373 $caseActivity->free();
374 }
375 $otherActivity->free();
376
377 $targetContacts = array();
378 if (!empty($params['targetContactIds'])) {
379 $targetContacts = array_unique(explode(',', $params['targetContactIds']));
380 }
381
382 $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
383 $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
384 $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
385 $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
386
387 $sourceContactID = CRM_Activity_BAO_Activity::getSourceContactID($params['activityID']);
388 $src_params = array(
389 'activity_id' => $mainActivityId,
390 'contact_id' => $sourceContactID,
391 'record_type_id' => $sourceID
392 );
393 CRM_Activity_BAO_ActivityContact::create($src_params);
394
395 foreach ($targetContacts as $key => $value) {
396 $targ_params = array(
397 'activity_id' => $mainActivityId,
398 'contact_id' => $value,
399 'record_type_id' => $targetID
400 );
401 CRM_Activity_BAO_ActivityContact::create($targ_params);
402 }
403
404 // typically this will be empty, since assignees on another case may be completely different
405 $assigneeContacts = array();
406 if (!empty($params['assigneeContactIds'])) {
407 $assigneeContacts = array_unique(explode(',', $params['assigneeContactIds']));
408 }
409 foreach ($assigneeContacts as $key => $value) {
410 $assigneeParams = array(
411 'activity_id' => $mainActivityId,
412 'contact_id' => $value,
413 'record_type_id' => $assigneeID
414 );
415 CRM_Activity_BAO_ActivityContact::create($assigneeParams);
416 }
417
418 //attach newly created activity to case.
419 $caseActivity = new CRM_Case_DAO_CaseActivity();
420 $caseActivity->case_id = $params['caseID'];
421 $caseActivity->activity_id = $mainActivityId;
422 $caseActivity->save();
423 $error_msg = $caseActivity->_lastError;
424 $caseActivity->free();
425
426 $params['mainActivityId'] = $mainActivityId;
427 CRM_Activity_BAO_Activity::copyExtendedActivityData($params);
428
429 return (array('error_msg' => $error_msg, 'newId' => $mainActivity->id));
430 }
431
432 static function getContactActivity() {
433 $contactID = CRM_Utils_Type::escape($_POST['contact_id'], 'Integer');
434 $context = CRM_Utils_Type::escape(CRM_Utils_Array::value('context', $_GET), 'String');
435
436 $sortMapper = array(
437 0 => 'activity_type',
438 1 => 'subject',
439 2 => 'source_contact_name',
440 3 => '',
441 4 => '',
442 5 => 'activity_date_time',
443 6 => 'status_id',
444 );
445
446 $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
447 $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
448 $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
449 $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : NULL;
450 $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
451
452 $params = $_POST;
453 if ($sort && $sortOrder) {
454 $params['sortBy'] = $sort . ' ' . $sortOrder;
455 }
456
457 $params['page'] = ($offset / $rowCount) + 1;
458 $params['rp'] = $rowCount;
459
460 $params['contact_id'] = $contactID;
461 $params['context'] = $context;
462
463 // get the contact activities
464 $activities = CRM_Activity_BAO_Activity::getContactActivitySelector($params);
465
466 // store the activity filter preference CRM-11761
467 $session = CRM_Core_Session::singleton();
468 $userID = $session->get('userID');
469 if ($userID) {
470 //flush cache before setting filter to account for global cache (memcache)
471 $domainID = CRM_Core_Config::domainID();
472 $cacheKey = CRM_Core_BAO_Setting::inCache(
473 CRM_Core_BAO_Setting::PERSONAL_PREFERENCES_NAME,
474 'activity_tab_filter',
475 NULL,
476 $userID,
477 TRUE,
478 $domainID,
479 TRUE
480 );
481 if ( $cacheKey ) {
482 CRM_Core_BAO_Setting::flushCache($cacheKey);
483 }
484
485 $activityFilter = array(
486 'activity_type_filter_id' => empty($params['activity_type_id']) ? '' :
487 CRM_Utils_Type::escape($params['activity_type_id'], 'Integer'),
488 'activity_type_exclude_filter_id' => empty($params['activity_type_exclude_id']) ? '' :
489 CRM_Utils_Type::escape($params['activity_type_exclude_id'], 'Integer'),
490 );
491
492 CRM_Core_BAO_Setting::setItem(
493 $activityFilter,
494 CRM_Core_BAO_Setting::PERSONAL_PREFERENCES_NAME,
495 'activity_tab_filter',
496 NULL,
497 $userID,
498 $userID
499 );
500 }
501
502 $iFilteredTotal = $iTotal = $params['total'];
503 $selectorElements = array(
504 'activity_type', 'subject', 'source_contact',
505 'target_contact', 'assignee_contact',
506 'activity_date', 'status','links', 'class',
507 );
508
509 header('Content-Type: application/json');
510 echo CRM_Utils_JSON::encodeDataTableSelector($activities, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
511 CRM_Utils_System::civiExit();
512 }
513 }
514