Skip to content
Snippets Groups Projects
Commit 7f9683f3 authored by Kurund Jalmi's avatar Kurund Jalmi
Browse files

Merge pull request #270 from kurund/CRM-12202

CRM-12202
parents 7e96fee9 e290f251
Branches
Tags
No related merge requests found
......@@ -1287,7 +1287,7 @@ SELECT case_status.label AS case_status, status_id, case_type.label AS case_type
}
if ($allowEdit) {
$values[$dao->id]['status'] = '<a class="crm-activity-status crm-activity-status-' . $dao->id . ' ' . $values[$dao->id]['class'] . ' crm-activity-change-status" activity_id='. $dao->id. ' contact_id=' . $contactID . ' current_status=' . $dao->status . ' case_id=' . $caseID . '" href="#" title=\'' . $statusTitle . '\'>' . $values[$dao->id]['status'] . '</a>';
$values[$dao->id]['status'] = '<a class="crm-activity-status crm-activity-status-' . $dao->id . ' ' . $values[$dao->id]['class'] . ' crm-activity-change-status" activity_id='. $dao->id. ' current_status=' . $dao->status . ' case_id=' . $caseID . '" href="#" title=\'' . $statusTitle . '\'>' . $values[$dao->id]['status'] . '</a>';
}
}
$dao->free();
......
......@@ -3,67 +3,56 @@ cj(function($) {
$('.crm-container').on('click', 'a.crm-activity-change-status', function() {
changeActivityStatus(
$(this).attr('activity_id'),
$(this).attr('contact_id'),
$(this).attr('current_status'),
$(this).attr('case_id')
);
return false;
});
function changeActivityStatus(activityId, contactId, current_status_id, caseId) {
function changeActivityStatus(activityId, current_status_id, caseId) {
var o = $('<div class="crm-container crm-activity_change_status"></div>');
addCiviOverlay(o);
var data = 'snippet=1&reset=1';
$('<div>')
.load(CRM.url('civicrm/case/changeactivitystatus'), data, function() {
cj("#activity_change_status").val(current_status_id);
})
.dialog({
modal: true,
title: ts('Change Activity Status'),
buttons: {
"Ok" : function() {
// update the status
var status_id = $("#activity_change_status").val( );
o.load(CRM.url('civicrm/case/changeactivitystatus'), data, function() {
removeCiviOverlay(o);
cj("#activity_change_status").val(current_status_id);
});
if (status_id === current_status_id) {
$(this).dialog('close').remove();
CRM.confirm(function() {
// update the status
var status_id = $("#activity_change_status").val( );
if (status_id === current_status_id) {
return false;
}
var dataUrl = CRM.url('civicrm/ajax/rest');
var data = 'json=1&version=3&entity=Activity&action=update&id=' + activityId + '&status_id=' + status_id
+ '&case_id=' + caseId;
$.ajax({
type : 'POST',
dataType : 'json',
url : dataUrl,
data : data,
success : function(values) {
if (values.is_error) {
CRM.alert(values.error_message, ts('Unable to change status'), 'error');
return false;
}
var dataUrl = CRM.url('civicrm/ajax/rest');
var data = 'json=1&version=3&entity=Activity&action=update&id=' + activityId + '&status_id=' + status_id
+ '&case_id=' + caseId;
$.ajax({
type : "POST",
dataType : "json",
url : dataUrl,
data : data,
success : function( values ) {
if ( values.is_error ) {
// seems to be some discrepancy as to which spelling it should be
var err_msg = values.error_msg ? values.error_msg : values.error_message;
CRM.alert(err_msg, ts('Unable to change status'), 'error');
return false;
}
else {
// just reload the page on success
window.location.reload();
}
},
error : function( jqXHR, textStatus ) {
CRM.alert(jqXHR.responseText, jqXHR.statusText, 'error');
return false;
}
});
$(this).dialog('close').remove();
else {
// just reload the page on success
window.location.reload();
}
},
"Cancel": function() {
$(this).dialog('close').remove();
error : function(jqXHR) {
CRM.alert(jqXHR.responseText, jqXHR.statusText, 'error');
return false;
}
},
beforeClose: function() {
$(this).dialog("destroy");
}
});
}
,{
title: ts('Change Activity Status'),
message: o
}
);
}
......
......@@ -1123,3 +1123,4 @@ function printCaseReport( ) {
{/if} {* view related cases if end *}
</div>
{include file="CRM/common/overlay.tpl"}
......@@ -165,3 +165,4 @@ function buildCaseDetails( caseId, contactId )
</script>
{/literal}
{include file="CRM/common/overlay.tpl"}
......@@ -110,3 +110,4 @@
{/if}
{/if}
</div>
{include file="CRM/common/overlay.tpl"}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment