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