Skip to content

Commit

Permalink
CRM-19778 - Limit statuses in 'change case status' activity
Browse files Browse the repository at this point in the history
  • Loading branch information
colemanw committed Jan 23, 2017
1 parent d724865 commit 766b126
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions CRM/Case/Form/Activity/ChangeCaseStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,26 @@ public static function buildQuickForm(&$form) {
$form->removeElement('status_id');
$form->removeElement('priority_id');

$caseTypes = array();

$form->_caseStatus = CRM_Case_PseudoConstant::caseStatus();
$statusNames = CRM_Case_PseudoConstant::caseStatus('name');

// Limit case statuses to allowed types for these case(s)
$allCases = civicrm_api3('Case', 'get', array('return' => 'case_type_id', 'id' => array('IN' => (array) $form->_caseId)));
foreach ($allCases['values'] as $case) {
$caseTypes[$case['case_type_id']] = $case['case_type_id'];
}
$caseTypes = civicrm_api3('CaseType', 'get', array('id' => array('IN' => $caseTypes)));
foreach ($caseTypes['values'] as $ct) {
if (!empty($ct['definition']['statuses'])) {
foreach ($form->_caseStatus as $id => $label) {
if (!in_array($statusNames[$id], $ct['definition']['statuses'])) {
unset($form->_caseStatus[$id]);
}
}
}
}

foreach ($form->_caseId as $key => $val) {
$form->_oldCaseStatus[] = $form->_defaultCaseStatus[] = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $val, 'status_id');
Expand Down Expand Up @@ -183,9 +202,6 @@ public static function endPostProcess(&$form, &$params, $activity) {
$activity->save();
}
}

// FIXME: does this do anything ?
$params['statusMsg'] = ts('Case Status changed successfully.');
}

}

0 comments on commit 766b126

Please sign in to comment.