Skip to content

Commit

Permalink
Merge pull request #7 from shahrukh-compucorp/CATL-1973-add-client-to…
Browse files Browse the repository at this point in the history
…kens

Add Client Tokens For A Case
  • Loading branch information
shahrukh-compucorp authored Nov 25, 2020
2 parents e63f6f2 + e79097b commit b48ec1d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions casetokens.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ function casetokens_civicrm_tokens(&$tokens) {
catch (Throwable $ex) {
}
}
//adding tokens for client case role
foreach ($allFields as $key =>$field) {
$tokens['case_roles']["case_roles.client_{$key}"] =
"Case Client". ' - ' . ts(ucwords($field));
}
}
}

Expand All @@ -242,7 +247,8 @@ function casetokens_civicrm_tokenvalues(&$values, $cids, $job = NULL, $tokens =
'case_id' => $caseId,
'options' => array('limit' => 0),
'contact_id.is_deleted' => 0,
'return' => array('contact_id.display_name'),
'sequential' => 1,
'return' => array('contact_id.display_name','contact_id.id'),
));
$clients = implode(', ', CRM_Utils_Array::collect('contact_id.display_name', $caseContact['values']));

Expand All @@ -268,7 +274,13 @@ function casetokens_civicrm_tokenvalues(&$values, $cids, $job = NULL, $tokens =
));
}
}

//fill client values
if (!empty($caseContact['values']) && !empty($caseContact['values'][0])) {
$contacts['client'] = civicrm_api3('Contact', 'getsingle', [
'id' => $caseContact['values'][0]['contact_id.id'],
'return' => array_keys($allFields),
]);
}
// Fill tokens
$caseRolesContact = array();
foreach ($contacts as $role => $contact) {
Expand Down

0 comments on commit b48ec1d

Please sign in to comment.