diff --git a/CRM/Case/BAO/Case.php b/CRM/Case/BAO/Case.php index 4a9aa6e03bbd..5daee0cb33aa 100644 --- a/CRM/Case/BAO/Case.php +++ b/CRM/Case/BAO/Case.php @@ -1989,7 +1989,8 @@ public static function getRelatedCases($caseId, $excludeDeleted = TRUE) { SELECT relCase.id as id, civicrm_case_type.title as case_type, client.display_name as client_name, - client.id as client_id + client.id as client_id, + relCase.status_id FROM civicrm_case relCase INNER JOIN civicrm_case_contact relCaseContact ON ( relCase.id = relCaseContact.case_id ) INNER JOIN civicrm_contact client ON ( client.id = relCaseContact.contact_id ) @@ -1999,6 +2000,7 @@ public static function getRelatedCases($caseId, $excludeDeleted = TRUE) { $dao = CRM_Core_DAO::executeQuery($query); $contactViewUrl = CRM_Utils_System::url("civicrm/contact/view", "reset=1&cid="); $hasViewContact = CRM_Core_Permission::giveMeAllACLs(); + $statuses = CRM_Case_BAO_Case::buildOptions('status_id'); while ($dao->fetch()) { $caseView = NULL; @@ -2016,6 +2018,7 @@ public static function getRelatedCases($caseId, $excludeDeleted = TRUE) { 'case_id' => $dao->id, 'case_type' => $dao->case_type, 'client_name' => $clientView, + 'case_status' => $statuses[$dao->status_id], 'links' => $caseView, ); } diff --git a/CRM/Case/Form/Activity/ChangeCaseStatus.php b/CRM/Case/Form/Activity/ChangeCaseStatus.php index 8006b0c37bb7..57361dcd610e 100644 --- a/CRM/Case/Form/Activity/ChangeCaseStatus.php +++ b/CRM/Case/Form/Activity/ChangeCaseStatus.php @@ -45,6 +45,12 @@ public static function preProcess(&$form) { if (!isset($form->_caseId)) { CRM_Core_Error::fatal(ts('Case Id not found.')); } + + $form->addElement('checkbox', 'updateLinkedCases', NULL, NULL, array('class' => 'select-row')); + + $caseID = CRM_Utils_Array::first($form->_caseId); + $cases = CRM_Case_BAO_Case::getRelatedCases($caseID); + $form->assign('linkedCases', $cases); } /** @@ -136,23 +142,33 @@ public static function formRule($values, $files, $form) { /** * Process the form submission. * - * * @param CRM_Core_Form $form * @param array $params */ public static function beginPostProcess(&$form, &$params) { $params['id'] = CRM_Utils_Array::value('case_id', $params); + + if ($params['updateLinkedCases'] === '1') { + $caseID = CRM_Utils_Array::first($form->_caseId); + $cases = CRM_Case_BAO_Case::getRelatedCases($caseID); + + foreach ($cases as $currentCase) { + if ($currentCase['status_id'] != $params['case_status_id']) { + $form->_caseId[] = $currentCase['case_id']; + } + } + } } /** * Process the form submission. * - * * @param CRM_Core_Form $form * @param array $params * @param CRM_Activity_BAO_Activity $activity */ public static function endPostProcess(&$form, &$params, $activity) { + $groupingValues = CRM_Core_OptionGroup::values('case_status', FALSE, TRUE, FALSE, NULL, 'value'); // Set case end_date if we're closing the case. Clear end_date if we're (re)opening it. diff --git a/templates/CRM/Case/Form/Activity/ChangeCaseStatus.tpl b/templates/CRM/Case/Form/Activity/ChangeCaseStatus.tpl index 8f1ad08a194b..5070b1d57c5a 100644 --- a/templates/CRM/Case/Form/Activity/ChangeCaseStatus.tpl +++ b/templates/CRM/Case/Form/Activity/ChangeCaseStatus.tpl @@ -24,14 +24,40 @@ +--------------------------------------------------------------------+ *} {* Template for "Change Case Status" activities. *} -
ID | +Case Client | +Case Type | +Status | +
---|---|---|---|
{$linkedCase.case_id} | +{$linkedCase.client_name} | +{$linkedCase.case_type} | +{$linkedCase.case_status} | +