Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
06b69b18 | 4 | | CiviCRM version 4.5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06b69b18 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
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 | +--------------------------------------------------------------------+ | |
26 | */ | |
27 | ||
28 | /** | |
29 | * | |
30 | * @package CRM | |
06b69b18 | 31 | * @copyright CiviCRM LLC (c) 2004-2014 |
6a488035 TO |
32 | * $Id$ |
33 | * | |
34 | */ | |
35 | ||
36 | /** | |
37 | * This class generates view mode for CiviCase | |
38 | * | |
39 | */ | |
40 | class CRM_Case_Form_CaseView extends CRM_Core_Form { | |
41 | /* | |
42 | * check for merge cases. | |
43 | */ | |
44 | ||
45 | private $_mergeCases = FALSE; | |
46 | ||
47 | /** | |
48 | * Function to set variables up before form is built | |
49 | * | |
50 | * @return void | |
51 | * @access public | |
52 | */ | |
53 | public function preProcess() { | |
0ee2ad76 | 54 | $this->_showRelatedCases = CRM_Utils_Array::value('relatedCases', $_GET); |
6a488035 TO |
55 | |
56 | $xmlProcessorProcess = new CRM_Case_XMLProcessor_Process(); | |
57 | $isMultiClient = $xmlProcessorProcess->getAllowMultipleCaseClients(); | |
58 | $this->assign('multiClient', $isMultiClient); | |
59 | ||
60 | //pull the related cases. | |
61 | $this->assign('showRelatedCases', FALSE); | |
62 | if ($this->_showRelatedCases) { | |
63 | $relatedCases = $this->get('relatedCases'); | |
64 | if (!isset($relatedCases)) { | |
65 | $cId = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject); | |
66 | $caseId = CRM_Utils_Request::retrieve('id', 'Integer', CRM_Core_DAO::$_nullObject); | |
67 | $relatedCases = CRM_Case_BAO_Case::getRelatedCases($caseId, $cId); | |
68 | } | |
69 | $this->assign('relatedCases', $relatedCases); | |
70 | $this->assign('showRelatedCases', TRUE); | |
5ffd5a35 | 71 | CRM_Utils_System::setTitle(ts('Related Cases')); |
6a488035 TO |
72 | return; |
73 | } | |
74 | ||
75 | //check for civicase access. | |
76 | if (!CRM_Case_BAO_Case::accessCiviCase()) { | |
77 | CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); | |
78 | } | |
79 | $this->_hasAccessToAllCases = CRM_Core_Permission::check('access all cases and activities'); | |
80 | $this->assign('hasAccessToAllCases', $this->_hasAccessToAllCases); | |
81 | ||
82 | $this->_contactID = $this->get('cid'); | |
83 | $this->_caseID = $this->get('id'); | |
84 | ||
85 | $fulltext = CRM_Utils_Request::retrieve('context', 'String', CRM_Core_DAO::$_nullObject); | |
86 | if ($fulltext == 'fulltext') { | |
87 | $this->assign('fulltext', $fulltext); | |
88 | } | |
89 | ||
90 | $this->assign('caseID', $this->_caseID); | |
91 | $this->assign('contactID', $this->_contactID); | |
92 | ||
93 | //validate case id. | |
94 | $this->_userCases = array(); | |
95 | $session = CRM_Core_Session::singleton(); | |
96 | $userID = $session->get('userID'); | |
97 | if (!$this->_hasAccessToAllCases) { | |
90319720 | 98 | $this->_userCases = CRM_Case_BAO_Case::getCases(FALSE, $userID, 'any'); |
6a488035 TO |
99 | if (!array_key_exists($this->_caseID, $this->_userCases)) { |
100 | CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); | |
101 | } | |
102 | } | |
103 | $this->assign('userID', $userID); | |
104 | ||
105 | if (CRM_Case_BAO_Case::caseCount($this->_contactID) >= 2) { | |
106 | $this->_mergeCases = TRUE; | |
107 | } | |
108 | $this->assign('mergeCases', $this->_mergeCases); | |
109 | ||
110 | //retrieve details about case | |
111 | $params = array('id' => $this->_caseID); | |
112 | ||
113 | $returnProperties = array('case_type_id', 'subject', 'status_id', 'start_date'); | |
114 | CRM_Core_DAO::commonRetrieve('CRM_Case_BAO_Case', $params, $values, $returnProperties); | |
115 | ||
116 | $values['case_type_id'] = trim(CRM_Utils_Array::value('case_type_id', $values), | |
117 | CRM_Core_DAO::VALUE_SEPARATOR | |
118 | ); | |
119 | $values['case_type_id'] = explode(CRM_Core_DAO::VALUE_SEPARATOR, | |
120 | CRM_Utils_Array::value('case_type_id', $values) | |
121 | ); | |
122 | ||
123 | $statuses = CRM_Case_PseudoConstant::caseStatus('label', FALSE); | |
124 | $caseTypeName = CRM_Case_BAO_Case::getCaseType($this->_caseID, 'name'); | |
125 | $caseType = CRM_Case_BAO_Case::getCaseType($this->_caseID); | |
126 | ||
127 | $this->_caseDetails = array( | |
128 | 'case_type' => $caseType, | |
129 | 'case_status' => $statuses[$values['case_status_id']], | |
130 | 'case_subject' => CRM_Utils_Array::value('subject', $values), | |
131 | 'case_start_date' => $values['case_start_date'], | |
132 | ); | |
133 | $this->_caseType = $caseTypeName; | |
134 | $this->assign('caseDetails', $this->_caseDetails); | |
135 | ||
6a488035 TO |
136 | $reportUrl = CRM_Utils_System::url('civicrm/case/report', |
137 | "reset=1&cid={$this->_contactID}&caseid={$this->_caseID}&asn=", | |
138 | FALSE, NULL, FALSE | |
139 | ); | |
140 | $this->assign('reportUrl', $reportUrl); | |
141 | ||
142 | // add to recently viewed | |
143 | ||
144 | $url = CRM_Utils_System::url('civicrm/contact/view/case', | |
145 | "action=view&reset=1&id={$this->_caseID}&cid={$this->_contactID}&context=home" | |
146 | ); | |
147 | ||
148 | $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactID); | |
149 | $this->assign('displayName', $displayName); | |
150 | ||
b74958a4 | 151 | CRM_Utils_System::setTitle($displayName . ' - ' . $caseType); |
6a488035 TO |
152 | |
153 | $recentOther = array(); | |
154 | if (CRM_Core_Permission::checkActionPermission('CiviCase', CRM_Core_Action::DELETE)) { | |
155 | $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/case', | |
156 | "action=delete&reset=1&id={$this->_caseID}&cid={$this->_contactID}&context=home" | |
157 | ); | |
158 | } | |
159 | ||
b74958a4 | 160 | // Add the recently viewed case |
6a488035 TO |
161 | CRM_Utils_Recent::add($displayName . ' - ' . $caseType, |
162 | $url, | |
163 | $this->_caseID, | |
164 | 'Case', | |
165 | $this->_contactID, | |
166 | NULL, | |
167 | $recentOther | |
168 | ); | |
169 | ||
170 | ||
171 | //get the related cases for given case. | |
172 | $relatedCases = $this->get('relatedCases'); | |
173 | if (!isset($relatedCases)) { | |
174 | $relatedCases = CRM_Case_BAO_Case::getRelatedCases($this->_caseID, $this->_contactID); | |
175 | $relatedCases = empty($relatedCases) ? FALSE : $relatedCases; | |
176 | $this->set('relatedCases', $relatedCases); | |
177 | } | |
5ffd5a35 CW |
178 | $this->assign('hasRelatedCases', (bool) $relatedCases); |
179 | if ($relatedCases) { | |
180 | $this->assign('relatedCaseLabel', ts('%1 Related Case', array('count' => count($relatedCases), 'plural' => '%1 Related Cases'))); | |
181 | $this->assign('relatedCaseUrl', CRM_Utils_System::url('civicrm/contact/view/case', array( | |
182 | 'id' => $this->_caseID, | |
183 | 'cid' => $this->_contactID, | |
184 | 'relatedCases' => 1, | |
185 | 'action' => 'view', | |
186 | ))); | |
187 | } | |
6a488035 TO |
188 | |
189 | $entitySubType = !empty($values['case_type_id']) ? $values['case_type_id'][0] : NULL; | |
190 | $this->assign('caseTypeID', $entitySubType); | |
191 | $groupTree = &CRM_Core_BAO_CustomGroup::getTree('Case', | |
192 | $this, | |
193 | $this->_caseID, | |
194 | NULL, | |
195 | $entitySubType | |
196 | ); | |
197 | CRM_Core_BAO_CustomGroup::buildCustomDataView($this, | |
198 | $groupTree | |
199 | ); | |
200 | } | |
201 | ||
202 | /** | |
203 | * This function sets the default values for the form. For edit/view mode | |
204 | * the default values are retrieved from the database | |
205 | * | |
206 | * @access public | |
207 | * | |
355ba699 | 208 | * @return void |
6a488035 TO |
209 | */ |
210 | function setDefaultValues() { | |
211 | $defaults = array(); | |
212 | return $defaults; | |
213 | } | |
214 | ||
215 | /** | |
216 | * Function to build the form | |
217 | * | |
355ba699 | 218 | * @return void |
6a488035 TO |
219 | * @access public |
220 | */ | |
221 | public function buildQuickForm() { | |
222 | //this call is for show related cases. | |
223 | if ($this->_showRelatedCases) { | |
224 | return; | |
225 | } | |
226 | ||
5ffd5a35 CW |
227 | CRM_Core_Resources::singleton() |
228 | ->addScriptFile('civicrm', 'js/crm.livePage.js') | |
229 | ->addScriptFile('civicrm', 'templates/CRM/Case/Form/CaseView.js'); | |
230 | ||
6a488035 TO |
231 | $xmlProcessor = new CRM_Case_XMLProcessor_Process(); |
232 | $caseRoles = $xmlProcessor->get($this->_caseType, 'CaseRoles'); | |
233 | $reports = $xmlProcessor->get($this->_caseType, 'ActivitySets'); | |
234 | ||
235 | //adding case manager.CRM-4510. | |
236 | $managerRoleId = $xmlProcessor->getCaseManagerRoleId($this->_caseType); | |
237 | if (!empty($managerRoleId)) { | |
238 | $caseRoles[$managerRoleId] = $caseRoles[$managerRoleId] . '<br />' . '(' . ts('Case Manager') . ')'; | |
239 | } | |
240 | ||
241 | $aTypes = $xmlProcessor->get($this->_caseType, 'ActivityTypes', TRUE); | |
242 | ||
243 | $allActTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name'); | |
244 | ||
5ffd5a35 CW |
245 | $emailActivityType = array_search('Email', $allActTypes); |
246 | ||
6a488035 | 247 | // remove Open Case activity type since we're inside an existing case |
5ffd5a35 | 248 | if ($openActTypeId = array_search('Open Case', $allActTypes)) { |
6a488035 TO |
249 | unset($aTypes[$openActTypeId]); |
250 | } | |
251 | ||
252 | //check for link cases. | |
253 | $unclosedCases = CRM_Case_BAO_Case::getUnclosedCases(NULL, array($this->_caseID)); | |
5ffd5a35 | 254 | if (empty($unclosedCases) && ($linkActTypeId = array_search('Link Cases', $allActTypes))) { |
6a488035 TO |
255 | unset($aTypes[$linkActTypeId]); |
256 | } | |
257 | ||
258 | if (!$xmlProcessor->getNaturalActivityTypeSort()) { | |
259 | asort($aTypes); | |
260 | } | |
261 | ||
5ffd5a35 CW |
262 | $activityLinks = array('' => ts('Add Activity')); |
263 | foreach ($aTypes as $type => $label) { | |
264 | if ($type == $emailActivityType) { | |
265 | $url = CRM_Utils_System::url('civicrm/activity/email/add', | |
266 | "action=add&context=standalone&reset=1&caseid={$this->_caseID}&atype=$type", | |
267 | FALSE, NULL, FALSE | |
268 | ); | |
269 | } | |
270 | else { | |
271 | $url = CRM_Utils_System::url('civicrm/case/activity', | |
272 | "action=add&reset=1&cid={$this->_contactID}&caseid={$this->_caseID}&atype=$type", | |
273 | FALSE, NULL, FALSE | |
274 | ); | |
275 | } | |
276 | $activityLinks[$url] = $label; | |
277 | } | |
278 | ||
2a06342c | 279 | $this->add('select', 'add_activity_type_id', '', $activityLinks, FALSE, array('class' => 'crm-select2 crm-action-menu twenty')); |
6a488035 | 280 | if ($this->_hasAccessToAllCases) { |
2a06342c CW |
281 | $this->add('select', 'report_id', '', |
282 | array('' => ts('Run QA Audit / Redact')) + $reports, | |
283 | FALSE, | |
284 | array('class' => 'crm-select2 crm-action-menu') | |
6a488035 | 285 | ); |
2a06342c CW |
286 | $this->add('select', 'timeline_id', '', |
287 | array('' => ts('Add Timeline')) + $reports, | |
288 | FALSE, | |
289 | array('class' => 'crm-select2 crm-action-menu') | |
6a488035 TO |
290 | ); |
291 | } | |
2a06342c | 292 | $this->addElement('submit', $this->getButtonName('next'), ' ', array('class' => 'hiddenElement')); |
6a488035 TO |
293 | |
294 | if ($this->_mergeCases) { | |
295 | $allCases = CRM_Case_BAO_Case::getContactCases($this->_contactID); | |
296 | $otherCases = array(); | |
297 | foreach ($allCases as $caseId => $details) { | |
298 | //filter current and own cases. | |
299 | if (($caseId == $this->_caseID) || | |
300 | (!$this->_hasAccessToAllCases && | |
301 | !array_key_exists($caseId, $this->_userCases) | |
302 | ) | |
303 | ) { | |
304 | continue; | |
305 | } | |
306 | ||
307 | $otherCases[$caseId] = 'Case ID: ' . $caseId . ' Type: ' . $details['case_type'] . ' Start: ' . $details['case_start_date']; | |
308 | } | |
309 | if (empty($otherCases)) { | |
310 | $this->_mergeCases = FALSE; | |
311 | $this->assign('mergeCases', $this->_mergeCases); | |
312 | } | |
313 | else { | |
314 | $this->add('select', 'merge_case_id', | |
315 | ts('Select Case for Merge'), | |
316 | array( | |
2a06342c CW |
317 | '' => ts('- select case -')) + $otherCases, |
318 | FALSE, | |
319 | array('class' => 'crm-select2 huge') | |
6a488035 TO |
320 | ); |
321 | $this->addElement('submit', | |
322 | $this->getButtonName('next', 'merge_case'), | |
323 | ts('Merge'), | |
324 | array( | |
2a06342c | 325 | 'class' => 'form-submit-inline hiddenElement', |
6a488035 TO |
326 | ) |
327 | ); | |
328 | } | |
329 | } | |
330 | ||
fc7d8951 | 331 | //call activity form |
85859f88 | 332 | self::activityForm($this); |
6a488035 TO |
333 | |
334 | //get case related relationships (Case Role) | |
335 | $caseRelationships = CRM_Case_BAO_Case::getCaseRoles($this->_contactID, $this->_caseID); | |
336 | ||
337 | //save special label because we unset it in the loop | |
338 | $managerLabel = empty($managerRoleId) ? '' : $caseRoles[$managerRoleId]; | |
339 | ||
6a488035 | 340 | foreach ($caseRelationships as $key => & $value) { |
6a488035 TO |
341 | if (!empty($managerRoleId)) { |
342 | if ($managerRoleId == $value['relation_type']) { | |
343 | $value['relation'] = $managerLabel; | |
344 | } | |
345 | } | |
346 | ||
347 | //calculate roles that don't have relationships | |
a7488080 | 348 | if (!empty($caseRoles[$value['relation_type']])) { |
6a488035 TO |
349 | unset($caseRoles[$value['relation_type']]); |
350 | } | |
351 | } | |
352 | ||
6a488035 TO |
353 | $this->assign('caseRelationships', $caseRelationships); |
354 | ||
355 | //also add client as role. CRM-4438 | |
356 | $caseRoles['client'] = CRM_Case_BAO_Case::getContactNames($this->_caseID); | |
357 | ||
358 | $this->assign('caseRoles', $caseRoles); | |
359 | ||
6a488035 TO |
360 | // Retrieve ALL client relationships |
361 | $relClient = CRM_Contact_BAO_Relationship::getRelationship($this->_contactID, | |
362 | CRM_Contact_BAO_Relationship::CURRENT, | |
363 | 0, 0, 0, NULL, NULL, FALSE | |
364 | ); | |
365 | ||
366 | // Now build 'Other Relationships' array by removing relationships that are already listed under Case Roles | |
367 | // so they don't show up twice. | |
368 | $clientRelationships = array(); | |
369 | foreach ($relClient as $r) { | |
370 | if (!array_key_exists($r['id'], $caseRelationships)) { | |
371 | $clientRelationships[] = $r; | |
372 | } | |
373 | } | |
374 | $this->assign('clientRelationships', $clientRelationships); | |
375 | ||
376 | // Now global contact list that appears on all cases. | |
377 | $globalGroupInfo = array(); | |
d79c94d5 | 378 | CRM_Case_BAO_Case::getGlobalContacts($globalGroupInfo); |
6a488035 TO |
379 | $this->assign('globalGroupInfo', $globalGroupInfo); |
380 | ||
381 | // List of relationship types | |
382 | $baoRel = new CRM_Contact_BAO_Relationship(); | |
383 | $relType = $baoRel->getRelationType('Individual'); | |
384 | $roleTypes = array(); | |
385 | foreach ($relType as $k => $v) { | |
386 | $roleTypes[substr($k, 0, strpos($k, '_'))] = $v; | |
387 | } | |
c91df8b4 | 388 | $this->add('select', 'role_type', ts('Relationship Type'), array('' => ts('- select type -')) + $roleTypes, FALSE, array('class' => 'crm-select2 twenty')); |
6a488035 TO |
389 | |
390 | $hookCaseSummary = CRM_Utils_Hook::caseSummary($this->_caseID); | |
391 | if (is_array($hookCaseSummary)) { | |
392 | $this->assign('hookCaseSummary', $hookCaseSummary); | |
393 | } | |
394 | ||
395 | ||
396 | $allTags = CRM_Core_BAO_Tag::getTags('civicrm_case'); | |
397 | ||
398 | if (!empty($allTags)) { | |
399 | $this->add('select', 'case_tag', ts('Tags'), $allTags, FALSE, | |
ab345ca5 | 400 | array('id' => 'tags', 'multiple' => 'multiple', 'class' => 'crm-select2') |
6a488035 TO |
401 | ); |
402 | ||
403 | $tags = CRM_Core_BAO_EntityTag::getTag($this->_caseID, 'civicrm_case'); | |
404 | ||
405 | $this->setDefaults(array('case_tag' => $tags)); | |
406 | ||
407 | foreach ($tags as $tid) { | |
6fd5424b | 408 | if (isset($allTags[$tid])) { |
409 | $tags[$tid] = $allTags[$tid]; | |
410 | } | |
411 | else { | |
412 | unset($tags[$tid]); | |
413 | } | |
6a488035 TO |
414 | } |
415 | ||
416 | $this->assign('tags', implode(', ', array_filter($tags))); | |
417 | $this->assign('showTags', TRUE); | |
418 | } | |
419 | else { | |
420 | $this->assign('showTags', FALSE); | |
421 | } | |
422 | ||
423 | // build tagset widget | |
424 | ||
425 | // see if we have any tagsets which can be assigned to cases | |
426 | $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_case'); | |
427 | if ($parentNames) { | |
428 | $this->assign('showTagsets', TRUE); | |
429 | } | |
430 | else { | |
431 | $this->assign('showTagsets', FALSE); | |
432 | } | |
6fd5424b | 433 | CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_case', $this->_caseID, TRUE, TRUE); |
6a488035 TO |
434 | |
435 | $this->addButtons(array( | |
436 | array( | |
437 | 'type' => 'cancel', | |
438 | 'name' => ts('Done'), | |
439 | 'spacing' => ' ', | |
440 | 'isDefault' => TRUE, | |
441 | ), | |
442 | ) | |
443 | ); | |
444 | } | |
445 | ||
446 | /** | |
447 | * Process the form | |
448 | * | |
449 | * @return void | |
450 | * @access public | |
451 | */ | |
452 | public function postProcess() { | |
453 | $params = $this->controller->exportValues($this->_name); | |
454 | $buttonName = $this->controller->getButtonName(); | |
455 | ||
456 | // user context | |
457 | $url = CRM_Utils_System::url('civicrm/contact/view/case', | |
458 | "reset=1&action=view&cid={$this->_contactID}&id={$this->_caseID}&show=1" | |
459 | ); | |
460 | $session = CRM_Core_Session::singleton(); | |
461 | $session->pushUserContext($url); | |
462 | ||
8cc574cf | 463 | if (!empty($params['timeline_id']) && !empty($_POST['_qf_CaseView_next'])) { |
6a488035 TO |
464 | $session = CRM_Core_Session::singleton(); |
465 | $this->_uid = $session->get('userID'); | |
466 | $xmlProcessor = new CRM_Case_XMLProcessor_Process(); | |
467 | $xmlProcessorParams = array( | |
468 | 'clientID' => $this->_contactID, | |
469 | 'creatorID' => $this->_uid, | |
470 | 'standardTimeline' => 0, | |
471 | 'activity_date_time' => date('YmdHis'), | |
472 | 'caseID' => $this->_caseID, | |
473 | 'caseType' => $this->_caseType, | |
474 | 'activitySetName' => $params['timeline_id'], | |
475 | ); | |
476 | $xmlProcessor->run($this->_caseType, $xmlProcessorParams); | |
477 | $reports = $xmlProcessor->get($this->_caseType, 'ActivitySets'); | |
478 | ||
479 | CRM_Core_Session::setStatus(ts('Activities from the %1 activity set have been added to this case.', | |
480 | array(1 => $reports[$params['timeline_id']]) | |
481 | ), ts('Done'), 'success'); | |
482 | } | |
483 | elseif ($this->_mergeCases && | |
484 | $buttonName == '_qf_CaseView_next_merge_case' | |
485 | ) { | |
486 | ||
487 | $mainCaseId = $params['merge_case_id']; | |
488 | $otherCaseId = $this->_caseID; | |
489 | ||
490 | //merge two cases. | |
491 | CRM_Case_BAO_Case::mergeCases($this->_contactID, $mainCaseId, NULL, $otherCaseId); | |
492 | ||
493 | //redirect user to main case view. | |
494 | $url = CRM_Utils_System::url('civicrm/contact/view/case', | |
495 | "reset=1&action=view&cid={$this->_contactID}&id={$mainCaseId}&show=1" | |
496 | ); | |
497 | $session = CRM_Core_Session::singleton(); | |
498 | $session->pushUserContext($url); | |
499 | } | |
6a488035 | 500 | } |
85859f88 CW |
501 | |
502 | /** | |
503 | * Build the activity selector/datatable | |
504 | * @param CRM_Core_Form $form | |
505 | */ | |
506 | static function activityForm($form) { | |
507 | $caseRelationships = CRM_Case_BAO_Case::getCaseRoles($form->_contactID, $form->_caseID); | |
508 | //build reporter select | |
509 | $reporters = array("" => ts(' - any reporter - ')); | |
510 | foreach ($caseRelationships as $key => & $value) { | |
511 | $reporters[$value['cid']] = $value['name'] . " ( {$value['relation']} )"; | |
512 | } | |
513 | $form->add('select', 'reporter_id', ts('Reporter/Role'), $reporters); | |
514 | ||
515 | // take all case activity types for search filter, CRM-7187 | |
516 | $aTypesFilter = array(); | |
517 | $allCaseActTypes = CRM_Case_PseudoConstant::caseActivityType(); | |
518 | foreach ($allCaseActTypes as $typeDetails) { | |
519 | if (!in_array($typeDetails['name'], array('Open Case'))) { | |
520 | $aTypesFilter[$typeDetails['id']] = CRM_Utils_Array::value('label', $typeDetails); | |
521 | } | |
522 | } | |
523 | asort($aTypesFilter); | |
524 | $form->add('select', 'activity_type_filter_id', ts('Activity Type'), array('' => ts('- select activity type -')) + $aTypesFilter); | |
525 | ||
526 | $activityStatus = CRM_Core_PseudoConstant::activityStatus(); | |
527 | $form->add('select', 'status_id', ts('Status'), array("" => ts(' - any status - ')) + $activityStatus); | |
528 | ||
529 | // activity dates | |
530 | $form->addDate('activity_date_low', ts('Activity Dates - From'), FALSE, array('formatType' => 'searchDate')); | |
531 | $form->addDate('activity_date_high', ts('To'), FALSE, array('formatType' => 'searchDate')); | |
532 | ||
533 | if (CRM_Core_Permission::check('administer CiviCRM')) { | |
534 | $form->add('checkbox', 'activity_deleted', ts('Deleted Activities')); | |
535 | } | |
536 | } | |
6a488035 TO |
537 | } |
538 |