$defaults['file_on_case_activity_subject'] = $defaults['subject'];
$defaults['file_on_case_target_contact_id'] = $defaults['target_contact'];
+ // If this contact has an open case, supply it as a default
$cid = CRM_Utils_Request::retrieve('cid', 'Integer');
if ($cid) {
$cases = CRM_Case_BAO_Case::getUnclosedCases(array('contact_id' => $cid), $this->_currentCaseId);
foreach ($cases as $id => $details) {
$defaults['file_on_case_unclosed_case_id'] = $id;
- $value = array('label' => $details['sort_name'] . ' - ' . $details['case_type']);
+ $value = array(
+ 'label' => $details['sort_name'] . ' - ' . $details['case_type'],
+ 'extra' => array('contact_id' => $cid),
+ );
$this->updateElementAttr('file_on_case_unclosed_case_id', array('data-value' => json_encode($value)));
break;
}
return {results: response};
}
}
- }).change(function() {
- if ($(this).val()) {
- selectedCaseId = $(this).val();
- contactId = $(this).select2('data').extra.contact_id;
- }
});
});
},
buttons: {
"{/literal}{ts escape='js'}Save{/ts}{literal}": function() {
+ var selectedCaseId = cj('input[name=file_on_case_unclosed_case_id]', '#fileOnCaseDialog').val();
+ var contactId = cj('input[name=file_on_case_unclosed_case_id]', '#fileOnCaseDialog').select2('data').extra.contact_id;
var subject = cj("#file_on_case_activity_subject").val( );
var targetContactId = cj("#file_on_case_target_contact_id").val( );