Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
fee14197 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
6b83d5bd | 6 | | Copyright CiviCRM LLC (c) 2004-2019 | |
6a488035 TO |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
6b83d5bd | 31 | * @copyright CiviCRM LLC (c) 2004-2019 |
6a488035 TO |
32 | */ |
33 | class CRM_Case_XMLProcessor_Report extends CRM_Case_XMLProcessor { | |
34 | ||
35 | /** | |
fe482240 | 36 | * The default variable defined. |
6a488035 | 37 | * |
b67daa72 | 38 | * @var bool |
6a488035 TO |
39 | */ |
40 | protected $_isRedact; | |
41 | ||
4c6ce474 | 42 | /** |
4c6ce474 | 43 | */ |
e547f744 TO |
44 | public function __construct() { |
45 | } | |
6a488035 | 46 | |
4c6ce474 | 47 | /** |
100fef9d CW |
48 | * @param int $clientID |
49 | * @param int $caseID | |
50 | * @param string $activitySetName | |
c490a46a | 51 | * @param array $params |
4c6ce474 EM |
52 | * |
53 | * @return mixed | |
54 | */ | |
00be9182 | 55 | public function run($clientID, $caseID, $activitySetName, $params) { |
6a488035 TO |
56 | $contents = self::getCaseReport($clientID, |
57 | $caseID, | |
58 | $activitySetName, | |
59 | $params, | |
60 | $this | |
61 | ); | |
62 | ||
63 | return CRM_Case_Audit_Audit::run($contents, $clientID, $caseID); | |
64 | } | |
65 | ||
a7e52def | 66 | public function getRedactionRules() { |
6a488035 | 67 | foreach (array( |
f157740d SL |
68 | 'redactionStringRules', |
69 | 'redactionRegexRules', | |
70 | ) as $key => $rule) { | |
6a488035 TO |
71 | $$rule = CRM_Case_PseudoConstant::redactionRule($key); |
72 | ||
73 | if (!empty($$rule)) { | |
74 | foreach ($$rule as & $val) { | |
75 | //suffixed with a randomly generated 4-digit number | |
76 | if ($key == 'redactionStringRules') { | |
77 | $val .= rand(10000, 100000); | |
78 | } | |
79 | } | |
80 | ||
81 | if (!empty($this->{'_' . $rule})) { | |
82 | $this->{'_' . $rule} = CRM_Utils_Array::crmArrayMerge($this->{'_' . $rule}, $$rule); | |
83 | } | |
84 | else { | |
85 | $this->{'_' . $rule} = $$rule; | |
86 | } | |
87 | } | |
88 | } | |
89 | } | |
90 | ||
4c6ce474 | 91 | /** |
100fef9d CW |
92 | * @param int $clientID |
93 | * @param int $caseID | |
4c6ce474 EM |
94 | * |
95 | * @return array | |
96 | */ | |
acb1052e | 97 | public function &caseInfo( |
28d4d481 | 98 | $clientID, |
6a488035 TO |
99 | $caseID |
100 | ) { | |
101 | $case = $this->_redactionRegexRules = array(); | |
102 | ||
103 | if (empty($this->_redactionStringRules)) { | |
104 | $this->_redactionStringRules = array(); | |
105 | } | |
106 | ||
107 | if ($this->_isRedact == 1) { | |
108 | $this->getRedactionRules(); | |
109 | } | |
110 | ||
111 | $client = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $clientID, 'display_name'); | |
112 | ||
113 | // add Client to the strings to be redacted across the case session | |
114 | if (!array_key_exists($client, $this->_redactionStringRules)) { | |
115 | $this->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($this->_redactionStringRules, | |
116 | array($client => 'name_' . rand(10000, 100000)) | |
117 | ); | |
118 | $clientSortName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $clientID, 'sort_name'); | |
119 | if (!array_key_exists($clientSortName, $this->_redactionStringRules)) { | |
120 | $this->_redactionStringRules[$clientSortName] = $this->_redactionStringRules[$client]; | |
121 | } | |
122 | } | |
123 | ||
124 | $case['clientName'] = $this->redact($client); | |
125 | ||
126 | $dao = new CRM_Case_DAO_Case(); | |
127 | $dao->id = $caseID; | |
128 | if ($dao->find(TRUE)) { | |
353ffa53 | 129 | $case['subject'] = $dao->subject; |
6a488035 | 130 | $case['start_date'] = $dao->start_date; |
353ffa53 | 131 | $case['end_date'] = $dao->end_date; |
6a488035 TO |
132 | $case['caseType'] = CRM_Case_BAO_Case::getCaseType($caseID); |
133 | $case['caseTypeName'] = CRM_Case_BAO_Case::getCaseType($caseID, 'name'); | |
cedb74cd | 134 | $case['status'] = CRM_Core_PseudoConstant::getLabel('CRM_Case_BAO_Case', 'status_id', $dao->status_id); |
6a488035 TO |
135 | } |
136 | return $case; | |
137 | } | |
138 | ||
4c6ce474 EM |
139 | /** |
140 | * @param $xml | |
100fef9d | 141 | * @param string $activitySetName |
4c6ce474 EM |
142 | * |
143 | * @return array|bool | |
144 | */ | |
00be9182 | 145 | public function getActivityTypes($xml, $activitySetName) { |
6a488035 TO |
146 | foreach ($xml->ActivitySets as $activitySetsXML) { |
147 | foreach ($activitySetsXML->ActivitySet as $activitySetXML) { | |
148 | if ((string ) $activitySetXML->name == $activitySetName) { | |
149 | $activityTypes = array(); | |
150 | $allActivityTypes = &$this->allActivityTypes(); | |
151 | foreach ($activitySetXML->ActivityTypes as $activityTypesXML) { | |
152 | foreach ($activityTypesXML as $activityTypeXML) { | |
153 | $activityTypeName = (string ) $activityTypeXML->name; | |
154 | $activityTypeInfo = CRM_Utils_Array::value($activityTypeName, $allActivityTypes); | |
155 | if ($activityTypeInfo) { | |
156 | $activityTypes[$activityTypeInfo['id']] = $activityTypeInfo; | |
157 | } | |
158 | } | |
159 | } | |
160 | return empty($activityTypes) ? FALSE : $activityTypes; | |
161 | } | |
162 | } | |
163 | } | |
164 | return FALSE; | |
165 | } | |
166 | ||
4c6ce474 EM |
167 | /** |
168 | * @param $xml | |
100fef9d | 169 | * @param string $activitySetName |
4c6ce474 EM |
170 | * |
171 | * @return null|string | |
172 | */ | |
00be9182 | 173 | public function getActivitySetLabel($xml, $activitySetName) { |
6a488035 TO |
174 | foreach ($xml->ActivitySets as $activitySetsXML) { |
175 | foreach ($activitySetsXML->ActivitySet as $activitySetXML) { | |
176 | if ((string ) $activitySetXML->name == $activitySetName) { | |
177 | return (string ) $activitySetXML->label; | |
178 | } | |
179 | } | |
180 | } | |
181 | return NULL; | |
182 | } | |
183 | ||
4c6ce474 | 184 | /** |
100fef9d CW |
185 | * @param int $clientID |
186 | * @param int $caseID | |
4c6ce474 EM |
187 | * @param $activityTypes |
188 | * @param $activities | |
189 | */ | |
00be9182 | 190 | public function getActivities($clientID, $caseID, $activityTypes, &$activities) { |
6a488035 TO |
191 | // get all activities for this case that in this activityTypes set |
192 | foreach ($activityTypes as $aType) { | |
193 | $map[$aType['id']] = $aType; | |
194 | } | |
195 | ||
196 | // get all core activities | |
197 | $coreActivityTypes = CRM_Case_PseudoConstant::caseActivityType(FALSE, TRUE); | |
198 | ||
199 | foreach ($coreActivityTypes as $aType) { | |
200 | $map[$aType['id']] = $aType; | |
201 | } | |
202 | ||
203 | $activityTypeIDs = implode(',', array_keys($map)); | |
204 | $query = " | |
205 | SELECT a.*, c.id as caseID | |
206 | FROM civicrm_activity a, | |
207 | civicrm_case c, | |
208 | civicrm_case_activity ac | |
209 | WHERE a.is_current_revision = 1 | |
210 | AND a.is_deleted =0 | |
211 | AND a.activity_type_id IN ( $activityTypeIDs ) | |
212 | AND c.id = ac.case_id | |
213 | AND a.id = ac.activity_id | |
214 | AND ac.case_id = %1 | |
215 | "; | |
216 | ||
217 | $params = array(1 => array($caseID, 'Integer')); | |
218 | $dao = CRM_Core_DAO::executeQuery($query, $params); | |
219 | while ($dao->fetch()) { | |
220 | $activityTypeInfo = $map[$dao->activity_type_id]; | |
221 | $activities[] = $this->getActivity($clientID, | |
222 | $dao, | |
223 | $activityTypeInfo | |
224 | ); | |
225 | } | |
226 | } | |
227 | ||
4c6ce474 | 228 | /** |
100fef9d CW |
229 | * @param int $clientID |
230 | * @param int $activityID | |
4c6ce474 EM |
231 | * @param bool $anyActivity |
232 | * @param int $redact | |
233 | * | |
234 | * @return mixed | |
235 | */ | |
00be9182 | 236 | public function &getActivityInfo($clientID, $activityID, $anyActivity = FALSE, $redact = 0) { |
6a488035 TO |
237 | static $activityInfos = array(); |
238 | if ($redact) { | |
239 | $this->_isRedact = 1; | |
240 | $this->getRedactionRules(); | |
241 | } | |
242 | ||
6a488035 TO |
243 | $index = $activityID . '_' . (int) $anyActivity; |
244 | ||
245 | if ($clientID) { | |
246 | $index = $index . '_' . $clientID; | |
247 | } | |
248 | ||
6a488035 TO |
249 | if (!array_key_exists($index, $activityInfos)) { |
250 | $activityInfos[$index] = array(); | |
251 | $selectCaseActivity = ""; | |
252 | $joinCaseActivity = ""; | |
253 | ||
254 | if ($clientID) { | |
255 | $selectCaseActivity = ", ca.case_id as caseID "; | |
256 | $joinCaseActivity = " INNER JOIN civicrm_case_activity ca ON a.id = ca.activity_id "; | |
257 | } | |
258 | ||
44f817d4 | 259 | $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); |
9e74e3ce | 260 | $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); |
261 | $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); | |
8ef12e64 | 262 | |
6a488035 | 263 | $query = " |
5a1bd70b | 264 | SELECT a.*, aa.contact_id as assigneeID, at.contact_id as targetID |
6a488035 TO |
265 | {$selectCaseActivity} |
266 | FROM civicrm_activity a | |
267 | {$joinCaseActivity} | |
9e74e3ce | 268 | LEFT JOIN civicrm_activity_contact at ON a.id = at.activity_id AND at.record_type_id = $targetID |
269 | LEFT JOIN civicrm_activity_contact aa ON a.id = aa.activity_id AND aa.record_type_id = $assigneeID | |
6a488035 TO |
270 | WHERE a.id = %1 |
271 | "; | |
272 | $params = array(1 => array($activityID, 'Integer')); | |
273 | $dao = CRM_Core_DAO::executeQuery($query, $params); | |
274 | ||
275 | if ($dao->fetch()) { | |
276 | //if activity type is email get info of all activities. | |
95a718e1 | 277 | if ($dao->activity_type_id == CRM_Core_PseudoConstant::getKey('CRM_Activity_DAO_Activity', 'activity_type_id', 'Email')) { |
6a488035 TO |
278 | $anyActivity = TRUE; |
279 | } | |
a953bf20 | 280 | $activityTypes = CRM_Case_PseudoConstant::caseActivityType(FALSE, $anyActivity); |
6a488035 TO |
281 | $activityTypeInfo = NULL; |
282 | ||
283 | if (isset($activityTypes[$dao->activity_type_id])) { | |
284 | $activityTypeInfo = $activityTypes[$dao->activity_type_id]; | |
285 | } | |
286 | if ($activityTypeInfo) { | |
287 | $activityInfos[$index] = $this->getActivity($clientID, $dao, $activityTypeInfo); | |
288 | } | |
289 | } | |
290 | } | |
291 | ||
292 | return $activityInfos[$index]; | |
293 | } | |
294 | ||
4c6ce474 | 295 | /** |
100fef9d | 296 | * @param int $clientID |
4c6ce474 EM |
297 | * @param $activityDAO |
298 | * @param $activityTypeInfo | |
299 | * | |
300 | * @return array | |
301 | */ | |
00be9182 | 302 | public function &getActivity($clientID, $activityDAO, &$activityTypeInfo) { |
6a488035 TO |
303 | if (empty($this->_redactionStringRules)) { |
304 | $this->_redactionStringRules = array(); | |
305 | } | |
306 | ||
307 | $activity = array(); | |
308 | $activity['fields'] = array(); | |
309 | if ($clientID) { | |
310 | $clientID = CRM_Utils_Type::escape($clientID, 'Integer'); | |
311 | if (!in_array($activityTypeInfo['name'], array( | |
353ffa53 | 312 | 'Email', |
acb1052e | 313 | 'Inbound Email', |
353ffa53 TO |
314 | )) |
315 | ) { | |
6a488035 TO |
316 | $activity['editURL'] = CRM_Utils_System::url('civicrm/case/activity', |
317 | "reset=1&cid={$clientID}&caseid={$activityDAO->caseID}&action=update&atype={$activityDAO->activity_type_id}&id={$activityDAO->id}" | |
318 | ); | |
319 | } | |
320 | else { | |
321 | $activity['editURL'] = ''; | |
322 | } | |
323 | ||
324 | $client = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $clientID, 'display_name'); | |
325 | // add Client SortName as well as Display to the strings to be redacted across the case session | |
326 | // suffixed with a randomly generated 4-digit number | |
327 | if (!array_key_exists($client, $this->_redactionStringRules)) { | |
328 | $this->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($this->_redactionStringRules, | |
329 | array($client => 'name_' . rand(10000, 100000)) | |
330 | ); | |
331 | ||
332 | $clientSortName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $clientID, 'sort_name'); | |
333 | if (!array_key_exists($clientSortName, $this->_redactionStringRules)) { | |
334 | $this->_redactionStringRules[$clientSortName] = $this->_redactionStringRules[$client]; | |
335 | } | |
336 | } | |
337 | ||
338 | $activity['fields'][] = array( | |
339 | 'label' => 'Client', | |
340 | 'value' => $this->redact($client), | |
341 | 'type' => 'String', | |
342 | ); | |
343 | } | |
344 | ||
44f817d4 | 345 | $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); |
034500d4 | 346 | $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); |
347 | $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); | |
6a488035 TO |
348 | if (!empty($activityDAO->targetID)) { |
349 | // Re-lookup the target ID since the DAO only has the first recipient if there are multiple. | |
350 | // Maybe not the best solution. | |
353ffa53 | 351 | $targetNames = CRM_Activity_BAO_ActivityContact::getNames($activityDAO->id, $targetID); |
6a488035 | 352 | $processTarget = FALSE; |
353ffa53 | 353 | $label = ts('With Contact(s)'); |
22d5fc65 | 354 | if (in_array($activityTypeInfo['name'], array('Email', 'Inbound Email'))) { |
6a488035 TO |
355 | $processTarget = TRUE; |
356 | $label = ts('Recipient'); | |
357 | } | |
358 | if (!$processTarget) { | |
359 | foreach ($targetNames as $targetID => $targetName) { | |
360 | if ($targetID != $clientID) { | |
361 | $processTarget = TRUE; | |
362 | break; | |
363 | } | |
364 | } | |
365 | } | |
366 | ||
367 | if ($processTarget) { | |
368 | $targetRedacted = array(); | |
369 | foreach ($targetNames as $targetID => $target) { | |
370 | // add Recipient SortName as well as Display to the strings to be redacted across the case session | |
371 | // suffixed with a randomly generated 4-digit number | |
372 | if (!array_key_exists($target, $this->_redactionStringRules)) { | |
373 | $this->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($this->_redactionStringRules, | |
374 | array($target => 'name_' . rand(10000, 100000)) | |
375 | ); | |
376 | $targetSortName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $targetID, 'sort_name'); | |
377 | if (!array_key_exists($targetSortName, $this->_redactionStringRules)) { | |
378 | $this->_redactionStringRules[$targetSortName] = $this->_redactionStringRules[$target]; | |
379 | } | |
380 | } | |
381 | $targetRedacted[] = $this->redact($target); | |
382 | } | |
383 | ||
384 | $activity['fields'][] = array( | |
385 | 'label' => $label, | |
386 | 'value' => implode('; ', $targetRedacted), | |
387 | 'type' => 'String', | |
388 | ); | |
389 | } | |
390 | } | |
391 | ||
392 | // Activity Type info is a special field | |
393 | $activity['fields'][] = array( | |
22d5fc65 | 394 | 'label' => ts('Activity Type'), |
6a488035 TO |
395 | 'value' => $activityTypeInfo['label'], |
396 | 'type' => 'String', | |
397 | ); | |
398 | ||
399 | $activity['fields'][] = array( | |
22d5fc65 | 400 | 'label' => ts('Subject'), |
6a488035 TO |
401 | 'value' => htmlspecialchars($this->redact($activityDAO->subject)), |
402 | 'type' => 'Memo', | |
403 | ); | |
404 | ||
405 | $creator = $this->getCreatedBy($activityDAO->id); | |
406 | // add Creator to the strings to be redacted across the case session | |
407 | if (!array_key_exists($creator, $this->_redactionStringRules)) { | |
408 | $this->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($this->_redactionStringRules, | |
409 | array($creator => 'name_' . rand(10000, 100000)) | |
410 | ); | |
411 | } | |
412 | $activity['fields'][] = array( | |
22d5fc65 | 413 | 'label' => ts('Created By'), |
6a488035 TO |
414 | 'value' => $this->redact($creator), |
415 | 'type' => 'String', | |
416 | ); | |
44f817d4 | 417 | $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); |
034500d4 | 418 | $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); |
419 | $source_contact_id = CRM_Activity_BAO_Activity::getActivityContact($activityDAO->id, $sourceID); | |
6a488035 | 420 | $reporter = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', |
034500d4 | 421 | $source_contact_id, |
6a488035 TO |
422 | 'display_name' |
423 | ); | |
424 | ||
425 | // add Reporter SortName as well as Display to the strings to be redacted across the case session | |
426 | // suffixed with a randomly generated 4-digit number | |
427 | if (!array_key_exists($reporter, $this->_redactionStringRules)) { | |
428 | $this->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($this->_redactionStringRules, | |
429 | array($reporter => 'name_' . rand(10000, 100000)) | |
430 | ); | |
431 | ||
432 | $reporterSortName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', | |
353ffa53 | 433 | $source_contact_id, |
6a488035 TO |
434 | 'sort_name' |
435 | ); | |
436 | if (!array_key_exists($reporterSortName, $this->_redactionStringRules)) { | |
437 | $this->_redactionStringRules[$reporterSortName] = $this->_redactionStringRules[$reporter]; | |
438 | } | |
439 | } | |
440 | ||
441 | $activity['fields'][] = array( | |
22d5fc65 | 442 | 'label' => ts('Reported By'), |
6a488035 TO |
443 | 'value' => $this->redact($reporter), |
444 | 'type' => 'String', | |
445 | ); | |
446 | ||
447 | if (!empty($activityDAO->assigneeID)) { | |
448 | //allow multiple assignee contacts.CRM-4503. | |
90b05581 | 449 | $assignee_contact_names = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames(array($activityDAO->id), TRUE); |
6a488035 TO |
450 | |
451 | foreach ($assignee_contact_names as & $assignee) { | |
452 | // add Assignee to the strings to be redacted across the case session | |
453 | $this->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($this->_redactionStringRules, | |
454 | array($assignee => 'name_' . rand(10000, 100000)) | |
455 | ); | |
456 | $assignee = $this->redact($assignee); | |
457 | } | |
458 | $assigneeContacts = implode(', ', $assignee_contact_names); | |
459 | $activity['fields'][] = array( | |
3bd48a28 | 460 | 'label' => ts('Assigned to'), |
6a488035 TO |
461 | 'value' => $assigneeContacts, |
462 | 'type' => 'String', | |
463 | ); | |
464 | } | |
465 | ||
466 | if ($activityDAO->medium_id) { | |
467 | $activity['fields'][] = array( | |
22d5fc65 | 468 | 'label' => ts('Medium'), |
cedb74cd | 469 | 'value' => CRM_Core_PseudoConstant::getLabel('CRM_Activity_BAO_Activity', 'medium_id', $activityDAO->medium_id), |
6a488035 TO |
470 | 'type' => 'String', |
471 | ); | |
472 | } | |
473 | ||
474 | $activity['fields'][] = array( | |
22d5fc65 | 475 | 'label' => ts('Location'), |
6a488035 TO |
476 | 'value' => $activityDAO->location, |
477 | 'type' => 'String', | |
478 | ); | |
479 | ||
480 | $activity['fields'][] = array( | |
22d5fc65 | 481 | 'label' => ts('Date and Time'), |
6a488035 TO |
482 | 'value' => $activityDAO->activity_date_time, |
483 | 'type' => 'Date', | |
484 | ); | |
485 | ||
486 | $activity['fields'][] = array( | |
22d5fc65 | 487 | 'label' => ts('Details'), |
6a488035 TO |
488 | 'value' => $this->redact(CRM_Utils_String::stripAlternatives($activityDAO->details)), |
489 | 'type' => 'Memo', | |
490 | ); | |
491 | ||
492 | // Skip Duration field if empty (to avoid " minutes" output). Might want to do this for all fields at some point. dgg | |
493 | if ($activityDAO->duration) { | |
494 | $activity['fields'][] = array( | |
22d5fc65 | 495 | 'label' => ts('Duration'), |
6a488035 TO |
496 | 'value' => $activityDAO->duration . ' ' . ts('minutes'), |
497 | 'type' => 'Int', | |
498 | ); | |
499 | } | |
500 | $activity['fields'][] = array( | |
22d5fc65 | 501 | 'label' => ts('Status'), |
95a718e1 | 502 | 'value' => CRM_Core_PseudoConstant::getLabel('CRM_Activity_DAO_Activity', 'activity_status_id', |
6a488035 TO |
503 | $activityDAO->status_id |
504 | ), | |
505 | 'type' => 'String', | |
506 | ); | |
507 | ||
508 | $activity['fields'][] = array( | |
22d5fc65 | 509 | 'label' => ts('Priority'), |
8d04ae48 | 510 | 'value' => CRM_Core_PseudoConstant::getLabel('CRM_Activity_DAO_Activity', 'priority_id', |
6a488035 TO |
511 | $activityDAO->priority_id |
512 | ), | |
513 | 'type' => 'String', | |
514 | ); | |
515 | ||
516 | //for now empty custom groups | |
517 | $activity['customGroups'] = $this->getCustomData($clientID, | |
518 | $activityDAO, | |
519 | $activityTypeInfo | |
520 | ); | |
521 | ||
522 | return $activity; | |
523 | } | |
524 | ||
4c6ce474 | 525 | /** |
100fef9d | 526 | * @param int $clientID |
4c6ce474 EM |
527 | * @param $activityDAO |
528 | * @param $activityTypeInfo | |
529 | * | |
530 | * @return array|null | |
531 | */ | |
00be9182 | 532 | public function getCustomData($clientID, $activityDAO, &$activityTypeInfo) { |
6a488035 TO |
533 | list($typeValues, $options, $sql) = $this->getActivityTypeCustomSQL($activityTypeInfo['id'], '%Y-%m-%d'); |
534 | ||
535 | $params = array(1 => array($activityDAO->id, 'Integer')); | |
536 | ||
537 | $customGroups = array(); | |
538 | foreach ($sql as $tableName => $sqlClause) { | |
539 | $dao = CRM_Core_DAO::executeQuery($sqlClause, $params); | |
540 | if ($dao->fetch()) { | |
541 | $customGroup = array(); | |
542 | foreach ($typeValues[$tableName] as $columnName => $typeValue) { | |
6a488035 TO |
543 | |
544 | if (CRM_Utils_Array::value('type', $typeValue) == 'Date') { | |
545 | $value = $dao->$columnName; | |
546 | } | |
2e894314 | 547 | else { |
f3ceb112 | 548 | $value = CRM_Core_BAO_CustomField::displayValue($dao->$columnName, $typeValue['fieldID'], $activityDAO->id); |
2e894314 | 549 | } |
6a488035 TO |
550 | |
551 | if ($value) { | |
552 | // Note: this is already taken care in getDisplayValue above, but sometimes | |
553 | // strings like '^A^A' creates problem. So to fix this special case - | |
554 | if (strstr($value, CRM_Core_DAO::VALUE_SEPARATOR)) { | |
555 | $value = trim($value, CRM_Core_DAO::VALUE_SEPARATOR); | |
556 | } | |
557 | if (CRM_Utils_Array::value('type', $typeValue) == 'String' || | |
558 | CRM_Utils_Array::value('type', $typeValue) == 'Memo' | |
559 | ) { | |
560 | $value = $this->redact($value); | |
561 | } | |
6a488035 TO |
562 | elseif (CRM_Utils_Array::value('type', $typeValue) == 'Link') { |
563 | $value = CRM_Utils_System::formatWikiURL($value); | |
564 | } | |
565 | } | |
566 | //$typeValue | |
567 | $customGroup[] = array( | |
568 | 'label' => $typeValue['label'], | |
569 | 'value' => $value, | |
570 | 'type' => $typeValue['type'], | |
dc7c0d62 | 571 | 'fieldID' => $typeValue['fieldID'], |
6a488035 TO |
572 | ); |
573 | } | |
574 | $customGroups[$dao->groupTitle] = $customGroup; | |
575 | } | |
576 | } | |
577 | ||
578 | return empty($customGroups) ? NULL : $customGroups; | |
579 | } | |
580 | ||
4c6ce474 | 581 | /** |
100fef9d | 582 | * @param int $activityTypeID |
4c6ce474 | 583 | * @param null $dateFormat |
54f54538 | 584 | * @param bool $onlyActive |
4c6ce474 EM |
585 | * |
586 | * @return mixed | |
587 | */ | |
54f54538 | 588 | public function getActivityTypeCustomSQL($activityTypeID, $dateFormat = NULL, $onlyActive = TRUE) { |
6a488035 TO |
589 | static $cache = array(); |
590 | ||
591 | if (is_null($activityTypeID)) { | |
592 | $activityTypeID = 0; | |
593 | } | |
594 | ||
595 | if (!isset($cache[$activityTypeID])) { | |
596 | $query = " | |
597 | SELECT cg.title as groupTitle, | |
598 | cg.table_name as tableName , | |
599 | cf.column_name as columnName, | |
600 | cf.label as label , | |
601 | cg.id as groupID , | |
602 | cf.id as fieldID , | |
603 | cf.data_type as dataType , | |
604 | cf.html_type as htmlType , | |
605 | cf.option_group_id as optionGroupID | |
606 | FROM civicrm_custom_group cg, | |
607 | civicrm_custom_field cf | |
608 | WHERE cf.custom_group_id = cg.id | |
fb6aa4b9 | 609 | AND cg.extends = 'Activity' |
610 | AND " . CRM_Core_Permission::customGroupClause(CRM_Core_Permission::VIEW, 'cg.'); | |
6a488035 | 611 | |
54f54538 JP |
612 | if ($onlyActive) { |
613 | $query .= " AND cf.is_active = 1 "; | |
614 | } | |
6a488035 TO |
615 | if ($activityTypeID) { |
616 | $query .= "AND ( cg.extends_entity_column_value IS NULL OR cg.extends_entity_column_value LIKE '%" . CRM_Core_DAO::VALUE_SEPARATOR . "%1" . CRM_Core_DAO::VALUE_SEPARATOR . "%' )"; | |
617 | } | |
618 | else { | |
619 | $query .= "AND cg.extends_entity_column_value IS NULL"; | |
620 | } | |
a5c0c7f2 | 621 | $query .= "ORDER BY cg.weight, cf.weight"; |
6a488035 | 622 | $params = array( |
353ffa53 TO |
623 | 1 => array( |
624 | $activityTypeID, | |
6a488035 | 625 | 'Integer', |
acb1052e | 626 | ), |
353ffa53 | 627 | ); |
6a488035 TO |
628 | $dao = CRM_Core_DAO::executeQuery($query, $params); |
629 | ||
630 | $result = $options = $sql = $groupTitle = array(); | |
631 | while ($dao->fetch()) { | |
632 | if (!array_key_exists($dao->tableName, $result)) { | |
633 | $result[$dao->tableName] = array(); | |
634 | $sql[$dao->tableName] = array(); | |
635 | } | |
636 | $result[$dao->tableName][$dao->columnName] = array( | |
637 | 'label' => $dao->label, | |
638 | 'type' => $dao->dataType, | |
639 | 'fieldID' => $dao->fieldID, | |
640 | ); | |
641 | ||
642 | $options[$dao->fieldID] = array(); | |
643 | $options[$dao->fieldID]['attributes'] = array( | |
644 | 'label' => $dao->label, | |
645 | 'data_type' => $dao->dataType, | |
646 | 'html_type' => $dao->htmlType, | |
647 | ); | |
648 | // since we want to add ISO date format. | |
649 | if ($dateFormat && $dao->htmlType == 'Select Date') { | |
650 | $options[$dao->fieldID]['attributes']['format'] = $dateFormat; | |
651 | } | |
652 | if ($dao->optionGroupID) { | |
653 | $query = " | |
654 | SELECT label, value | |
655 | FROM civicrm_option_value | |
78c187fb | 656 | WHERE option_group_id = %1 |
6a488035 TO |
657 | "; |
658 | ||
78c187fb | 659 | $option = CRM_Core_DAO::executeQuery($query, array(1 => array($dao->optionGroupID, 'Positive'))); |
6a488035 TO |
660 | while ($option->fetch()) { |
661 | $dataType = $dao->dataType; | |
662 | if ($dataType == 'Int' || $dataType == 'Float') { | |
663 | $num = round($option->value, 2); | |
664 | $options[$dao->fieldID]["$num"] = $option->label; | |
665 | } | |
666 | else { | |
667 | $options[$dao->fieldID][$option->value] = $option->label; | |
668 | } | |
669 | } | |
670 | } | |
671 | ||
672 | $sql[$dao->tableName][] = $dao->columnName; | |
673 | $groupTitle[$dao->tableName] = $dao->groupTitle; | |
674 | } | |
675 | ||
676 | foreach ($sql as $tableName => $values) { | |
677 | $columnNames = implode(',', $values); | |
79acbc27 SL |
678 | $title = CRM_Core_DAO::escapeString($groupTitle[$tableName]); |
679 | $mysqlTableName = CRM_Utils_Type::escape($tableName, 'MysqlColumnNameOrAlias'); | |
6a488035 | 680 | $sql[$tableName] = " |
79acbc27 SL |
681 | SELECT '" . $title . "' as groupTitle, $columnNames |
682 | FROM $mysqlTableName | |
6a488035 TO |
683 | WHERE entity_id = %1 |
684 | "; | |
685 | } | |
686 | ||
687 | $cache[$activityTypeID] = array($result, $options, $sql); | |
688 | } | |
689 | return $cache[$activityTypeID]; | |
690 | } | |
691 | ||
4c6ce474 | 692 | /** |
100fef9d | 693 | * @param int $activityID |
4c6ce474 EM |
694 | * |
695 | * @return null|string | |
696 | */ | |
00be9182 | 697 | public function getCreatedBy($activityID) { |
6a488035 TO |
698 | $query = " |
699 | SELECT c.display_name | |
700 | FROM civicrm_contact c, | |
701 | civicrm_log l | |
702 | WHERE l.entity_table = 'civicrm_activity' | |
703 | AND l.entity_id = %1 | |
704 | AND l.modified_id = c.id | |
705 | LIMIT 1 | |
706 | "; | |
707 | ||
708 | $params = array(1 => array($activityID, 'Integer')); | |
709 | return CRM_Core_DAO::singleValueQuery($query, $params); | |
710 | } | |
711 | ||
4c6ce474 EM |
712 | /** |
713 | * @param $string | |
714 | * @param bool $printReport | |
715 | * @param array $replaceString | |
716 | * | |
717 | * @return mixed | |
718 | */ | |
c490a46a | 719 | private function redact($string, $printReport = FALSE, $replaceString = array()) { |
6a488035 TO |
720 | if ($printReport) { |
721 | return CRM_Utils_String::redaction($string, $replaceString); | |
722 | } | |
723 | elseif ($this->_isRedact) { | |
724 | $regexToReplaceString = CRM_Utils_String::regex($string, $this->_redactionRegexRules); | |
725 | return CRM_Utils_String::redaction($string, array_merge($this->_redactionStringRules, $regexToReplaceString)); | |
726 | } | |
727 | return $string; | |
728 | } | |
729 | ||
4c6ce474 | 730 | /** |
100fef9d CW |
731 | * @param int $clientID |
732 | * @param int $caseID | |
733 | * @param string $activitySetName | |
c490a46a CW |
734 | * @param array $params |
735 | * @param CRM_Core_Form $form | |
4c6ce474 EM |
736 | * |
737 | * @return mixed | |
738 | */ | |
00be9182 | 739 | public static function getCaseReport($clientID, $caseID, $activitySetName, $params, $form) { |
6a488035 TO |
740 | |
741 | $template = CRM_Core_Smarty::singleton(); | |
742 | ||
743 | $template->assign('caseId', $caseID); | |
744 | $template->assign('clientID', $clientID); | |
745 | $template->assign('activitySetName', $activitySetName); | |
746 | ||
a7488080 | 747 | if (!empty($params['is_redact'])) { |
6a488035 TO |
748 | $form->_isRedact = TRUE; |
749 | $template->assign('_isRedact', 'true'); | |
750 | } | |
751 | else { | |
752 | $form->_isRedact = FALSE; | |
753 | $template->assign('_isRedact', 'false'); | |
754 | } | |
755 | ||
756 | // first get all case information | |
757 | $case = $form->caseInfo($clientID, $caseID); | |
758 | $template->assign_by_ref('case', $case); | |
759 | ||
760 | if ($params['include_activities'] == 1) { | |
761 | $template->assign('includeActivities', 'All'); | |
762 | } | |
763 | else { | |
764 | $template->assign('includeActivities', 'Missing activities only'); | |
765 | } | |
766 | ||
767 | $xml = $form->retrieve($case['caseTypeName']); | |
768 | ||
769 | $activitySetNames = CRM_Case_XMLProcessor_Process::activitySets($xml->ActivitySets); | |
770 | $pageTitle = CRM_Utils_Array::value($activitySetName, $activitySetNames); | |
771 | $template->assign('pageTitle', $pageTitle); | |
772 | ||
773 | if ($activitySetName) { | |
774 | $activityTypes = $form->getActivityTypes($xml, $activitySetName); | |
775 | } | |
776 | else { | |
777 | $activityTypes = CRM_Case_XMLProcessor::allActivityTypes(); | |
778 | } | |
779 | ||
780 | if (!$activityTypes) { | |
781 | return FALSE; | |
782 | } | |
783 | ||
b44e3f84 | 784 | // next get activity set Information |
e547f744 | 785 | $activitySet = array( |
353ffa53 | 786 | 'label' => $form->getActivitySetLabel($xml, $activitySetName), |
6a488035 TO |
787 | 'includeActivities' => 'All', |
788 | 'redact' => 'false', | |
789 | ); | |
790 | $template->assign_by_ref('activitySet', $activitySet); | |
791 | ||
792 | //now collect all the information about activities | |
793 | $activities = array(); | |
794 | $form->getActivities($clientID, $caseID, $activityTypes, $activities); | |
795 | $template->assign_by_ref('activities', $activities); | |
796 | ||
797 | // now run the template | |
798 | $contents = $template->fetch('CRM/Case/XMLProcessor/Report.tpl'); | |
799 | return $contents; | |
800 | } | |
801 | ||
00be9182 | 802 | public static function printCaseReport() { |
a3d827a7 CW |
803 | $caseID = CRM_Utils_Request::retrieve('caseID', 'Positive'); |
804 | $clientID = CRM_Utils_Request::retrieve('cid', 'Positive'); | |
805 | $activitySetName = CRM_Utils_Request::retrieve('asn', 'String'); | |
806 | $isRedact = CRM_Utils_Request::retrieve('redact', 'Boolean'); | |
807 | $includeActivities = CRM_Utils_Request::retrieve('all', 'Positive'); | |
353ffa53 TO |
808 | $params = $otherRelationships = $globalGroupInfo = array(); |
809 | $report = new CRM_Case_XMLProcessor_Report($isRedact); | |
6a488035 TO |
810 | if ($includeActivities) { |
811 | $params['include_activities'] = 1; | |
812 | } | |
813 | ||
814 | if ($isRedact) { | |
815 | $params['is_redact'] = 1; | |
816 | $report->_redactionStringRules = array(); | |
817 | } | |
818 | $template = CRM_Core_Smarty::singleton(); | |
819 | ||
820 | //get case related relationships (Case Role) | |
821 | $caseRelationships = CRM_Case_BAO_Case::getCaseRoles($clientID, $caseID); | |
822 | $caseType = CRM_Case_BAO_Case::getCaseType($caseID, 'name'); | |
823 | ||
824 | $xmlProcessor = new CRM_Case_XMLProcessor_Process(); | |
825 | $caseRoles = $xmlProcessor->get($caseType, 'CaseRoles'); | |
826 | foreach ($caseRelationships as $key => & $value) { | |
5655a8d4 AF |
827 | if (!empty($caseRoles[$value['relation_type'] . '_' . $value['relationship_direction']])) { |
828 | unset($caseRoles[$value['relation_type'] . '_' . $value['relationship_direction']]); | |
6a488035 TO |
829 | } |
830 | if ($isRedact) { | |
831 | if (!array_key_exists($value['name'], $report->_redactionStringRules)) { | |
832 | $report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, | |
833 | array($value['name'] => 'name_' . rand(10000, 100000)) | |
834 | ); | |
835 | } | |
a7e52def | 836 | $value['name'] = $report->redact($value['name'], TRUE, $report->_redactionStringRules); |
a7488080 | 837 | if (!empty($value['email']) && |
6a488035 TO |
838 | !array_key_exists($value['email'], $report->_redactionStringRules) |
839 | ) { | |
840 | $report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, | |
841 | array($value['email'] => 'email_' . rand(10000, 100000)) | |
842 | ); | |
843 | } | |
844 | ||
a7e52def | 845 | $value['email'] = $report->redact($value['email'], TRUE, $report->_redactionStringRules); |
6a488035 | 846 | |
a7488080 | 847 | if (!empty($value['phone']) && |
6a488035 TO |
848 | !array_key_exists($value['phone'], $report->_redactionStringRules) |
849 | ) { | |
850 | $report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, | |
851 | array($value['phone'] => 'phone_' . rand(10000, 100000)) | |
852 | ); | |
853 | } | |
a7e52def | 854 | $value['phone'] = $report->redact($value['phone'], TRUE, $report->_redactionStringRules); |
6a488035 TO |
855 | } |
856 | } | |
857 | ||
858 | $caseRoles['client'] = CRM_Case_BAO_Case::getContactNames($caseID); | |
859 | if ($isRedact) { | |
a7e52def | 860 | foreach ($caseRoles['client'] as &$client) { |
861 | if (!array_key_exists(CRM_Utils_Array::value('sort_name', $client), $report->_redactionStringRules)) { | |
6a488035 | 862 | |
a7e52def | 863 | $report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, |
864 | array(CRM_Utils_Array::value('sort_name', $client) => 'name_' . rand(10000, 100000)) | |
865 | ); | |
866 | } | |
867 | if (!array_key_exists(CRM_Utils_Array::value('display_name', $client), $report->_redactionStringRules)) { | |
868 | $report->_redactionStringRules[CRM_Utils_Array::value('display_name', $client)] = $report->_redactionStringRules[CRM_Utils_Array::value('sort_name', $client)]; | |
869 | } | |
870 | $client['sort_name'] = $report->redact(CRM_Utils_Array::value('sort_name', $client), TRUE, $report->_redactionStringRules); | |
01217591 | 871 | if (!empty($client['email']) && |
872 | !array_key_exists($client['email'], $report->_redactionStringRules) | |
a7e52def | 873 | ) { |
874 | $report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, | |
01217591 | 875 | array($client['email'] => 'email_' . rand(10000, 100000)) |
a7e52def | 876 | ); |
877 | } | |
878 | $client['email'] = $report->redact(CRM_Utils_Array::value('email', $client), TRUE, $report->_redactionStringRules); | |
879 | ||
01217591 | 880 | if (!empty($client['phone']) && |
881 | !array_key_exists($client['phone'], $report->_redactionStringRules) | |
a7e52def | 882 | ) { |
883 | $report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, | |
01217591 | 884 | array($client['phone'] => 'phone_' . rand(10000, 100000)) |
a7e52def | 885 | ); |
886 | } | |
887 | $client['phone'] = $report->redact(CRM_Utils_Array::value('phone', $client), TRUE, $report->_redactionStringRules); | |
6a488035 | 888 | } |
6a488035 | 889 | } |
6a488035 TO |
890 | // Retrieve ALL client relationships |
891 | $relClient = CRM_Contact_BAO_Relationship::getRelationship($clientID, | |
892 | CRM_Contact_BAO_Relationship::CURRENT, | |
893 | 0, 0, 0, NULL, NULL, FALSE | |
894 | ); | |
895 | foreach ($relClient as $r) { | |
896 | if ($isRedact) { | |
897 | if (!array_key_exists($r['name'], $report->_redactionStringRules)) { | |
898 | $report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, | |
899 | array($r['name'] => 'name_' . rand(10000, 100000)) | |
900 | ); | |
901 | } | |
902 | if (!array_key_exists($r['display_name'], $report->_redactionStringRules)) { | |
903 | $report->_redactionStringRules[$r['display_name']] = $report->_redactionStringRules[$r['name']]; | |
904 | } | |
a7e52def | 905 | $r['name'] = $report->redact($r['name'], TRUE, $report->_redactionStringRules); |
6a488035 | 906 | |
a7488080 | 907 | if (!empty($r['phone']) && |
6a488035 TO |
908 | !array_key_exists($r['phone'], $report->_redactionStringRules) |
909 | ) { | |
910 | $report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, | |
911 | array($r['phone'] => 'phone_' . rand(10000, 100000)) | |
912 | ); | |
913 | } | |
a7e52def | 914 | $r['phone'] = $report->redact($r['phone'], TRUE, $report->_redactionStringRules); |
6a488035 | 915 | |
a7488080 | 916 | if (!empty($r['email']) && |
6a488035 TO |
917 | !array_key_exists($r['email'], $report->_redactionStringRules) |
918 | ) { | |
919 | $report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, | |
920 | array($r['email'] => 'email_' . rand(10000, 100000)) | |
921 | ); | |
922 | } | |
a7e52def | 923 | $r['email'] = $report->redact($r['email'], TRUE, $report->_redactionStringRules); |
6a488035 TO |
924 | } |
925 | if (!array_key_exists($r['id'], $caseRelationships)) { | |
926 | $otherRelationships[] = $r; | |
927 | } | |
928 | } | |
929 | ||
930 | // Now global contact list that appears on all cases. | |
931 | $relGlobal = CRM_Case_BAO_Case::getGlobalContacts($globalGroupInfo); | |
932 | foreach ($relGlobal as & $r) { | |
933 | if ($isRedact) { | |
934 | if (!array_key_exists($r['sort_name'], $report->_redactionStringRules)) { | |
935 | $report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, | |
936 | array($r['sort_name'] => 'name_' . rand(10000, 100000)) | |
937 | ); | |
938 | } | |
939 | if (!array_key_exists($r['display_name'], $report->_redactionStringRules)) { | |
940 | $report->_redactionStringRules[$r['display_name']] = $report->_redactionStringRules[$r['sort_name']]; | |
941 | } | |
942 | ||
a7e52def | 943 | $r['sort_name'] = $report->redact($r['sort_name'], TRUE, $report->_redactionStringRules); |
a7488080 | 944 | if (!empty($r['phone']) && |
6a488035 TO |
945 | !array_key_exists($r['phone'], $report->_redactionStringRules) |
946 | ) { | |
947 | $report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, | |
948 | array($r['phone'] => 'phone_' . rand(10000, 100000)) | |
949 | ); | |
950 | } | |
a7e52def | 951 | $r['phone'] = $report->redact($r['phone'], TRUE, $report->_redactionStringRules); |
6a488035 | 952 | |
a7488080 | 953 | if (!empty($r['email']) && |
6a488035 TO |
954 | !array_key_exists($r['email'], $report->_redactionStringRules) |
955 | ) { | |
956 | $report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, | |
957 | array($r['email'] => 'email_' . rand(10000, 100000)) | |
958 | ); | |
959 | } | |
a7e52def | 960 | $r['email'] = $report->redact($r['email'], TRUE, $report->_redactionStringRules); |
6a488035 TO |
961 | } |
962 | } | |
963 | ||
b077cff9 JM |
964 | // Retrieve custom values for cases. |
965 | $customValues = CRM_Core_BAO_CustomValueTable::getEntityValues($caseID, 'Case'); | |
966 | $extends = array('case'); | |
967 | $groupTree = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, NULL, $extends); | |
968 | $caseCustomFields = array(); | |
762891db SL |
969 | foreach ($groupTree as $gid => $group_values) { |
970 | foreach ($group_values['fields'] as $id => $field_values) { | |
219af4d3 CW |
971 | if (array_key_exists($id, $customValues)) { |
972 | $caseCustomFields[$gid]['title'] = $group_values['title']; | |
973 | $caseCustomFields[$gid]['values'][$id] = array( | |
b077cff9 JM |
974 | 'label' => $field_values['label'], |
975 | 'value' => $customValues[$id], | |
976 | ); | |
977 | } | |
978 | } | |
979 | } | |
6a488035 TO |
980 | $template->assign('caseRelationships', $caseRelationships); |
981 | $template->assign('caseRoles', $caseRoles); | |
982 | $template->assign('otherRelationships', $otherRelationships); | |
983 | $template->assign('globalRelationships', $relGlobal); | |
984 | $template->assign('globalGroupInfo', $globalGroupInfo); | |
b077cff9 | 985 | $template->assign('caseCustomFields', $caseCustomFields); |
6a488035 TO |
986 | $contents = self::getCaseReport($clientID, |
987 | $caseID, | |
988 | $activitySetName, | |
989 | $params, | |
990 | $report | |
991 | ); | |
992 | $printReport = CRM_Case_Audit_Audit::run($contents, $clientID, $caseID, TRUE); | |
993 | echo $printReport; | |
994 | CRM_Utils_System::civiExit(); | |
995 | } | |
96025800 | 996 | |
6a488035 | 997 | } |