*
* @return array of case and related data keyed on case id
*/
- static function getUnclosedCases($params = array(), $excludeCaseIds = array(), $excludeDeleted = TRUE) {
+ static function getUnclosedCases($params = array(), $excludeCaseIds = array(), $excludeDeleted = TRUE, $includeClosed = FALSE) {
//params from ajax call.
- $where = array('( ca.end_date is null )');
+ $where = array($includeClosed ? '(1)' : '(ca.end_date is null)');
if ($caseType = CRM_Utils_Array::value('case_type', $params)) {
$where[] = "( civicrm_case_type.title LIKE '%$caseType%' )";
}
ca.id,
ca.subject as case_subject,
civicrm_case_type.title as case_type,
- ca.start_date as start_date
+ ca.start_date as start_date,
+ ca.end_date as end_date,
+ ca.status_id
FROM civicrm_case ca INNER JOIN civicrm_case_contact cc ON ca.id=cc.case_id
INNER JOIN civicrm_contact c ON cc.contact_id=c.id
INNER JOIN civicrm_case_type ON ca.case_type_id = civicrm_case_type.id
WHERE {$whereClause}
- ORDER BY c.sort_name
+ ORDER BY c.sort_name, ca.end_date
{$limitClause}
";
$dao = CRM_Core_DAO::executeQuery($query);
+ $statuses = CRM_Case_PseudoConstant::caseStatus();
$unclosedCases = array();
while ($dao->fetch()) {
if ($doFilterCases && !array_key_exists($dao->id, $filterCases)) {
'case_type' => $dao->case_type,
'contact_id' => $dao->contact_id,
'start_date' => $dao->start_date,
+ 'end_date' => $dao->end_date,
'case_subject' => $dao->case_subject,
+ 'case_status' => $statuses[$dao->status_id],
);
}
$dao->free();
if (!empty($_GET['excludeCaseIds'])) {
$excludeCaseIds = explode(',', CRM_Utils_Type::escape($_GET['excludeCaseIds'], 'String'));
}
- $unclosedCases = CRM_Case_BAO_Case::getUnclosedCases($params, $excludeCaseIds);
+ $unclosedCases = CRM_Case_BAO_Case::getUnclosedCases($params, $excludeCaseIds, TRUE, TRUE);
$results = array();
foreach ($unclosedCases as $caseId => $details) {
$results[] = array(
'id' => $caseId,
- 'text' => $details['sort_name'] . ' (' . $details['case_type'] . ': ' . $details['case_subject'] . ')',
+ 'label' => $details['sort_name'] . ' - ' . $details['case_type'] . ($details['end_date'] ? ' (' . ts('closed') . ')' : ''),
+ 'label_class' => $details['end_date'] ? 'strikethrough' : '',
+ 'description' => array($details['case_subject'] . ' (' . $details['case_status'] . ')'),
'extra' => $details,
);
}
background-position: -101px -222px;background-image: url("../i/icons/jquery-ui-3E3E3E.gif");
}
-.crm-container .survey-completed {
+.crm-container .survey-completed,
+.crm-container .strikethrough {
text-decoration: line-through;
}
}
},
minimumInputLength: 1,
- formatResult: formatSelect2Result,
+ formatResult: CRM.utils.formatSelect2Result,
formatSelection: function(row) {
return row.label;
},
});
};
- function formatSelect2Result(row) {
+ CRM.utils.formatSelect2Result = function (row) {
var markup = '<div class="crm-select2-row">';
if (row.image !== undefined) {
markup += '<div class="crm-select2-image"><img src="' + row.image + '"/></div>';
else if (row.icon_class) {
markup += '<div class="crm-select2-icon"><div class="crm-icon ' + row.icon_class + '-icon"></div></div>';
}
- markup += '<div><div class="crm-select2-row-label">' + row.label + '</div>';
+ markup += '<div><div class="crm-select2-row-label '+(row.label_class || '')+'">' + row.label + '</div>';
markup += '<div class="crm-select2-row-description">';
$.each(row.description || [], function(k, text) {
markup += '<p>' + text + '</p>';
});
markup += '</div></div></div>';
return markup;
- }
+ };
function formatSelect2CreateLinks($el) {
var
$('input[name=unclosed_case_id]', $form).crmSelect2({
placeholder: {/literal}'{ts escape="js"}- select case -{/ts}'{literal},
minimumInputLength: 1,
+ formatResult: CRM.utils.formatSelect2Result,
+ formatSelection: function(row) {
+ return row.label;
+ },
ajax: {
url: {/literal}"{crmURL p='civicrm/case/ajax/unclosed' h=0}"{literal},
data: function(term) {
$('input[name=link_to_case_id]', $form).crmSelect2({
placeholder: {/literal}'{ts escape="js"}- select case -{/ts}'{literal},
minimumInputLength: 1,
+ formatResult: CRM.utils.formatSelect2Result,
+ formatSelection: function(row) {
+ return row.label;
+ },
ajax: {
url: {/literal}"{crmURL p='civicrm/case/ajax/unclosed' h=0}"{literal},
data: function(term) {
$('input[name=file_on_case_unclosed_case_id]', '#fileOnCaseDialog').crmSelect2({
placeholder: {/literal}'{ts escape="js"}- select case -{/ts}'{literal},
minimumInputLength: 1,
+ formatResult: CRM.utils.formatSelect2Result,
+ formatSelection: function(row) {
+ return row.label;
+ },
ajax: {
url: {/literal}"{crmURL p='civicrm/case/ajax/unclosed' h=0}"{literal},
data: function(term) {