$userID = CRM_Utils_Type::escape($_GET['userID'], 'Integer');
$context = CRM_Utils_Type::escape(CRM_Utils_Array::value('context', $_GET), 'String');
- $sortMapper = array(
- 0 => 'display_date',
- 1 => 'ca.subject',
- 2 => 'ca.activity_type_id',
- 3 => 'acc.sort_name',
- 4 => 'cc.sort_name',
- 5 => 'ca.status_id',
- );
+ $sortMapper = array();
+ foreach ($_GET['columns'] as $key => $value) {
+ $sortMapper[$key] = $value['data'];
+ };
- $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
- $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
- $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
- $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : NULL;
- $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
+ $offset = isset($_GET['start']) ? CRM_Utils_Type::escape($_GET['start'], 'Integer') : 0;
+ $rowCount = isset($_GET['length']) ? CRM_Utils_Type::escape($_GET['length'], 'Integer') : 25;
+ $sort = isset($_GET['order'][0]['column']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_GET['order'][0]['column'], 'Integer'), $sortMapper) : NULL;
+ $sortOrder = isset($_GET['order'][0]['dir']) ? CRM_Utils_Type::escape($_GET['order'][0]['dir'], 'String') : 'asc';
- $params = $_POST;
+ $params = $_GET;
if ($sort && $sortOrder) {
- $params['sortname'] = $sort;
- $params['sortorder'] = $sortOrder;
+ $params['sortBy'] = $sort . ' ' . $sortOrder;
}
$params['page'] = ($offset / $rowCount) + 1;
$params['rp'] = $rowCount;
// get the activities related to given case
$activities = CRM_Case_BAO_Case::getCaseActivity($caseID, $params, $contactID, $context, $userID);
- $iFilteredTotal = $iTotal = $params['total'];
- $selectorElements = array(
- 'display_date',
- 'subject',
- 'type',
- 'with_contacts',
- 'reporter',
- 'status',
- 'links',
- 'class',
- );
-
- header('Content-Type: application/json');
- echo CRM_Utils_JSON::encodeDataTableSelector($activities, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
- CRM_Utils_System::civiExit();
+ CRM_Utils_JSON::output($activities);
}
public static function getCaseGlobalRelationships() {
- $sortMapper = array(
- 0 => 'sort_name',
- 1 => 'phone',
- 2 => 'email',
- );
+ $sortMapper = array();
+ foreach ($_GET['columns'] as $key => $value) {
+ $sortMapper[$key] = $value['data'];
+ };
+
+ $offset = isset($_GET['start']) ? CRM_Utils_Type::escape($_GET['start'], 'Integer') : 0;
+ $rowCount = isset($_GET['length']) ? CRM_Utils_Type::escape($_GET['length'], 'Integer') : 25;
+ $sort = isset($_GET['order'][0]['column']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_GET['order'][0]['column'], 'Integer'), $sortMapper) : NULL;
+ $sortOrder = isset($_GET['order'][0]['dir']) ? CRM_Utils_Type::escape($_GET['order'][0]['dir'], 'String') : 'asc';
- $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
- $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
- $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
- $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : NULL;
- $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
+ $params = $_GET;
- $params = $_POST;
//CRM-14466 initialize variable to avoid php notice
$sortSQL = "";
if ($sort && $sortOrder) {
// limit the rows
$relGlobal = CRM_Case_BAO_Case::getGlobalContacts($globalGroupInfo, $sortSQL, $showLinks = TRUE, FALSE, $offset, $rowCount);
- $iFilteredTotal = $iTotal = $relGlobalTotalCount;
- $selectorElements = array('sort_name', 'phone', 'email');
+ $relationships = array();
+ // after sort we can update username fields to be a url
+ foreach ($relGlobal as $key => $value) {
+ $relationship = array();
+ $relationship['sort_name'] = $value['sort_name'];
+ $relationship['phone'] = $value['phone'];
+ $relationship['email'] = $value['email'];
+
+ array_push($relationships, $relationship);
+ }
+
+ $params['total'] = count($relationships);
- header('Content-Type: application/json');
- echo CRM_Utils_JSON::encodeDataTableSelector($relGlobal, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
- CRM_Utils_System::civiExit();
+ $globalRelationshipsDT = array();
+ $globalRelationshipsDT['data'] = $relationships;
+ $globalRelationshipsDT['recordsTotal'] = $params['total'];
+ $globalRelationshipsDT['recordsFiltered'] = $params['total'];
+
+ CRM_Utils_JSON::output($globalRelationshipsDT);
}
public static function getCaseClientRelationships() {
$caseID = CRM_Utils_Type::escape($_GET['caseID'], 'Integer');
$contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
- $sortMapper = array(
- 0 => 'relation',
- 1 => 'name',
- 2 => 'phone',
- 3 => 'email',
- );
+ $sortMapper = array();
+ foreach ($_GET['columns'] as $key => $value) {
+ $sortMapper[$key] = $value['data'];
+ };
- $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
- $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
- $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
- $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : 'relation';
- $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
+ $offset = isset($_GET['start']) ? CRM_Utils_Type::escape($_GET['start'], 'Integer') : 0;
+ $rowCount = isset($_GET['length']) ? CRM_Utils_Type::escape($_GET['length'], 'Integer') : 25;
+ $sort = isset($_GET['order'][0]['column']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_GET['order'][0]['column'], 'Integer'), $sortMapper) : NULL;
+ $sortOrder = isset($_GET['order'][0]['dir']) ? CRM_Utils_Type::escape($_GET['order'][0]['dir'], 'String') : 'asc';
- $params = $_POST;
- if ($sort && $sortOrder) {
- $sortSQL = $sort . ' ' . $sortOrder;
- }
+ $params = $_GET;
// Retrieve ALL client relationships
$relClient = CRM_Contact_BAO_Relationship::getRelationship($contactID,
$sort_type = "SORT_" . strtoupper($sortOrder);
array_multisort($sortArray, constant($sort_type), $clientRelationships);
- //limit the rows
- $allClientRelationships = $clientRelationships;
- $clientRelationships = array_slice($allClientRelationships, $offset, $rowCount, TRUE);
-
+ $relationships = array();
// after sort we can update username fields to be a url
foreach ($clientRelationships as $key => $value) {
- $clientRelationships[$key]['name'] = '<a href=' . CRM_Utils_System::url('civicrm/contact/view',
+ $relationship = array();
+ $relationship['relation'] = $value['relation'];
+ $relationship['name'] = '<a href=' . CRM_Utils_System::url('civicrm/contact/view',
'action=view&reset=1&cid=' . $clientRelationships[$key]['cid']) . '>' . $clientRelationships[$key]['name'] . '</a>';
+ $relationship['phone'] = $value['phone'];
+ $relationship['email'] = $value['email'];
+
+ array_push($relationships, $relationship);
}
- $iFilteredTotal = $iTotal = $params['total'] = count($allClientRelationships);
- $selectorElements = array('relation', 'name', 'phone', 'email');
+ $params['total'] = count($relationships);
+
+ $clientRelationshipsDT = array();
+ $clientRelationshipsDT['data'] = $relationships;
+ $clientRelationshipsDT['recordsTotal'] = $params['total'];
+ $clientRelationshipsDT['recordsFiltered'] = $params['total'];
- header('Content-Type: application/json');
- echo CRM_Utils_JSON::encodeDataTableSelector($clientRelationships, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
- CRM_Utils_System::civiExit();
+ CRM_Utils_JSON::output($clientRelationshipsDT);
}
$caseID = CRM_Utils_Type::escape($_GET['caseID'], 'Integer');
$contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
- $sortMapper = array(
- 0 => 'relation',
- 1 => 'name',
- 2 => 'phone',
- 3 => 'email',
- 4 => 'actions',
- );
+ $sortMapper = array();
+ foreach ($_GET['columns'] as $key => $value) {
+ $sortMapper[$key] = $value['data'];
+ };
- $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
- $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
- $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
- $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : 'relation';
- $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
+ $offset = isset($_GET['start']) ? CRM_Utils_Type::escape($_GET['start'], 'Integer') : 0;
+ $rowCount = isset($_GET['length']) ? CRM_Utils_Type::escape($_GET['length'], 'Integer') : 25;
+ $sort = isset($_GET['order'][0]['column']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_GET['order'][0]['column'], 'Integer'), $sortMapper) : NULL;
+ $sortOrder = isset($_GET['order'][0]['dir']) ? CRM_Utils_Type::escape($_GET['order'][0]['dir'], 'String') : 'asc';
- $params = $_POST;
- if ($sort && $sortOrder) {
- $sortSQL = $sort . ' ' . $sortOrder;
- }
+ $params = $_GET;
$caseRelationships = CRM_Case_BAO_Case::getCaseRoles($contactID, $caseID);
$caseTypeName = CRM_Case_BAO_Case::getCaseType($caseID, 'name');
$caseRoles[$managerRoleId] = $caseRoles[$managerRoleId] . '<br />' . '(' . ts('Case Manager') . ')';
}
+ $relationships = array();
+
foreach ($caseRelationships as $key => $value) {
//calculate roles that don't have relationships
if (!empty($caseRoles[$value['relation_type']])) {
$caseRelationships[$key]['relation'] = $caseRoles[$value['relation_type']];
unset($caseRoles[$value['relation_type']]);
}
- // mark orginal case relationships record to use on setting edit links below
+ // mark original case relationships record to use on setting edit links below
$caseRelationships[$key]['source'] = 'caseRel';
}
foreach ($caseRelationships as $key => $row) {
$sortArray[$key] = $row[$sort];
}
-
$sort_type = "SORT_" . strtoupper($sortOrder);
array_multisort($sortArray, constant($sort_type), $caseRelationships);
- //limit rows display
- $allCaseRelationships = $caseRelationships;
- $caseRelationships = array_slice($allCaseRelationships, $offset, $rowCount, TRUE);
+ $relationships = array();
// set user name, email and edit columns links
- // idx will count number of current row / needed by edit links
- $idx = 1;
- foreach ($caseRelationships as &$row) {
+ foreach ($caseRelationships as $key => &$row) {
// Get rid of the "<br />(Case Manager)" from label
list($typeLabel) = explode('<', $row['relation']);
// view user links
$contactType = $contactType == 'Contact' ? '' : $contactType;
switch ($row['source']) {
case 'caseRel':
- $row['actions']
- = '<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') . '">' .
+ $row['actions'] = '<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') . '">' .
'<span class="icon ui-icon-pencil"></span>' .
'</a>' .
'<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') . '">' .
break;
case 'caseRoles':
- $row['actions']
- = '<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') . '">' .
+ $row['actions'] = '<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') . '">' .
'<span class="icon ui-icon-pencil"></span>' .
'</a>';
break;
}
}
- $idx++;
+ unset($row['cid']);
+ unset($row['relation_type']);
+ unset($row['rel_id']);
+ unset($row['client_id']);
+ unset($row['source']);
+ array_push($relationships, $row);
}
- $iFilteredTotal = $iTotal = $params['total'] = count($allCaseRelationships);
- $selectorElements = array('relation', 'name', 'phone', 'email', 'actions');
+ $params['total'] = count($relationships);
+
+ $caseRelationshipsDT = array();
+ $caseRelationshipsDT['data'] = $relationships;
+ $caseRelationshipsDT['recordsTotal'] = $params['total'];
+ $caseRelationshipsDT['recordsFiltered'] = $params['total'];
+
+ CRM_Utils_JSON::output($caseRelationshipsDT);
- header('Content-Type: application/json');
- echo CRM_Utils_JSON::encodeDataTableSelector($caseRelationships, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
- CRM_Utils_System::civiExit();
}
public static function convertToCaseActivity() {
}
public static function getContactActivity() {
- $contactID = CRM_Utils_Type::escape($_POST['contact_id'], 'Integer');
+ $contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
$context = CRM_Utils_Type::escape(CRM_Utils_Array::value('context', $_GET), 'String');
- $sortMapper = array(
- 0 => 'activity_type',
- 1 => 'subject',
- 2 => 'source_contact_name',
- 3 => '',
- 4 => '',
- 5 => 'activity_date_time',
- 6 => 'status_id',
- );
+ $sortMapper = array();
+ foreach ($_GET['columns'] as $key => $value) {
+ $sortMapper[$key] = $value['data'];
+ };
- $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
- $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
- $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
- $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : NULL;
- $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
+ $offset = isset($_GET['start']) ? CRM_Utils_Type::escape($_GET['start'], 'Integer') : 0;
+ $rowCount = isset($_GET['length']) ? CRM_Utils_Type::escape($_GET['length'], 'Integer') : 25;
+ $sort = isset($_GET['order'][0]['column']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_GET['order'][0]['column'], 'Integer'), $sortMapper) : NULL;
+ $sortOrder = isset($_GET['order'][0]['dir']) ? CRM_Utils_Type::escape($_GET['order'][0]['dir'], 'String') : 'asc';
- $params = $_POST;
+ $params = $_GET;
if ($sort && $sortOrder) {
$params['sortBy'] = $sort . ' ' . $sortOrder;
}
foreach ($activities as $key => $value) {
//Check if recurring activity
if (!empty($value['is_recurring_activity'])) {
- if ($key == $value['is_recurring_activity']) {
- $activities[$key]['activity_type'] = $activities[$key]['activity_type'] . '<br/><span class="bold">Recurring Activity - (Parent)</span>';
- }
- else {
- $activities[$key]['activity_type'] = $activities[$key]['activity_type'] . '<br/><span class="bold">Recurring Activity - (Child)</span>';
- }
+ $repeat = $value['is_recurring_activity'];
+ $activities[$key]['activity_type'] .= '<br/><span class="bold">' . ts('Repeating (%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1])) . '</span>';
}
}
);
}
- $iFilteredTotal = $iTotal = $params['total'];
- $selectorElements = array(
- 'activity_type',
- 'subject',
- 'source_contact',
- 'target_contact',
- 'assignee_contact',
- 'activity_date',
- 'status',
- 'links',
- 'class',
- );
-
- header('Content-Type: application/json');
- echo CRM_Utils_JSON::encodeDataTableSelector($activities, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
- CRM_Utils_System::civiExit();
+ CRM_Utils_JSON::output($activities);
}
}