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

worked on CRM-12202, reuse existing CRM.confirm(), more code cleanup

parent 8516c142
Branches
Tags
No related merge requests found
......@@ -10,63 +10,49 @@ cj(function($) {
});
function changeActivityStatus(activityId, current_status_id, caseId) {
var buttons = {};
buttons[ts('Ok')] = function() {
// update the status
var status_id = $("#activity_change_status").val( );
if (status_id === current_status_id) {
$(this).dialog('close').remove();
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;
}
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();
};
buttons[ts('Cancel')] = function() {
$(this).dialog('close').remove();
};
var data = 'snippet=1&reset=1';
var o = $('<div class="crm-container crm-activity_change_status"></div>');
addCiviOverlay(o);
var data = 'snippet=1&reset=1';
o.load(CRM.url('civicrm/case/changeactivitystatus'), data, function() {
removeCiviOverlay(o);
cj("#activity_change_status").val(current_status_id);
})
.dialog({
modal: true,
title: ts('Change Activity Status'),
resizable: false,
buttons: buttons,
beforeClose: function() {
$(this).dialog("destroy");
});
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;
}
else {
// just reload the page on success
window.location.reload();
}
},
error : function(jqXHR) {
CRM.alert(jqXHR.responseText, jqXHR.statusText, 'error');
return false;
}
});
}
,{
title: ts('Change Activity Status'),
message: o
}
);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment