From: Kurund Jalmi Date: Thu, 28 Mar 2013 09:48:28 +0000 (+0530) Subject: worked on CRM-12202, localized buttons and removed unwanted variables X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e3afb6afc0dc49dc39c7c4542a8195886d676fd4;p=civicrm-core.git worked on CRM-12202, localized buttons and removed unwanted variables --- diff --git a/CRM/Case/BAO/Case.php b/CRM/Case/BAO/Case.php index 181c013dde..a2a71ff0c6 100644 --- a/CRM/Case/BAO/Case.php +++ b/CRM/Case/BAO/Case.php @@ -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'] = '' . $values[$dao->id]['status'] . ''; + $values[$dao->id]['status'] = '' . $values[$dao->id]['status'] . ''; } } $dao->free(); diff --git a/templates/CRM/Case/Form/ActivityChangeStatus.js b/templates/CRM/Case/Form/ActivityChangeStatus.js index 3273b4905b..cee2acd5d5 100644 --- a/templates/CRM/Case/Form/ActivityChangeStatus.js +++ b/templates/CRM/Case/Form/ActivityChangeStatus.js @@ -3,14 +3,53 @@ 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 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'; $('
') .load(CRM.url('civicrm/case/changeactivitystatus'), data, function() { @@ -19,48 +58,7 @@ cj(function($) { .dialog({ modal: true, title: ts('Change Activity Status'), - buttons: { - "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 ) { - // 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(); - }, - "Cancel": function() { - $(this).dialog('close').remove(); - } - }, + buttons: buttons, beforeClose: function() { $(this).dialog("destroy"); }