+++ /dev/null
-// http://civicrm.org/licensing
-cj(function($) {
- // Elements are sometimes in a jQuery dialog box which is outside crm-container,
- // So gotta attach this handler to the whole body - sorry.
- $('body').on('click', 'a.crm-activity-change-status', function() {
- var link = $(this),
- activityId = $(this).attr('activity_id'),
- current_status_id = $(this).attr('current_status'),
- caseId = $(this).attr('case_id'),
- data = 'snippet=1&reset=1',
- o = $('<div class="crm-container crm-activity_change_status"></div>');
- o.block({theme:true});
-
- o.load(CRM.url('civicrm/case/changeactivitystatus'), data, function() {
- o.unblock();
- cj("#activity_change_status").val(current_status_id);
- });
-
- 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 {
- // reload the table on success
- if (window.buildCaseActivities) {
- // If we are using a datatable
- buildCaseActivities(true);
- }
- else {
- // Legacy refresh for non-datatable screens
- var table = link.closest('table.nestedActivitySelector');
- table.parent().load(CRM.url('civicrm/case/details', table.data('params')));
- }
- }
- },
- error : function(jqXHR) {
- CRM.alert(jqXHR.responseText, jqXHR.statusText, 'error');
- return false;
- }
- });
- }
- ,{
- title: ts('Change Activity Status'),
- message: o
- }
- );
- return false;
- });
-});
\ No newline at end of file
--- /dev/null
+{*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.4 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2013 |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM. |
+ | |
+ | CiviCRM is free software; you can copy, modify, and distribute it |
+ | under the terms of the GNU Affero General Public License |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ | |
+ | CiviCRM is distributed in the hope that it will be useful, but |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ | See the GNU Affero General Public License for more details. |
+ | |
+ | You should have received a copy of the GNU Affero General Public |
+ | License and the CiviCRM Licensing Exception along |
+ | with this program; if not, contact CiviCRM LLC |
+ | at info[AT]civicrm[DOT]org. If you have questions about the |
+ | GNU Affero General Public License or the licensing of CiviCRM, |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+*}
+{* CiviCase - change activity status inline *}
+{literal}
+ <script type="text/javascript">
+ cj(function($) {
+ // Elements are sometimes in a jQuery dialog box which is outside crm-container,
+ // So gotta attach this handler to the whole body - sorry.
+ $('body').off('click.changeActivityStatus');
+ $('body').on('click.changeActivityStatus', 'a.crm-activity-change-status', function() {
+ var link = $(this),
+ activityId = $(this).attr('activity_id'),
+ current_status_id = $(this).attr('current_status'),
+ caseId = $(this).attr('case_id'),
+ data = 'snippet=1&reset=1',
+ $el = $('<div class="crm-container crm-activity_change_status"></div>');
+ $el.block({theme:true});
+
+ $el.load(CRM.url('civicrm/case/changeactivitystatus'), data, function() {
+ $el.unblock().trigger('crmLoad');
+ cj("#activity_change_status").val(current_status_id);
+ });
+
+ 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;
+ var request = $.ajax({
+ type : 'POST',
+ dataType : 'json',
+ url : dataUrl,
+ data : data,
+ success : function(values) {
+ if (values.is_error) {
+ CRM.alert(values.error_message, {/literal}'{ts escape='js'}Unable to change status{/ts}'{literal}, 'error');
+ return false;
+ }
+ else {
+ // reload the table on success
+ if (window.buildCaseActivities) {
+ // If we are using a datatable
+ buildCaseActivities(true);
+ }
+ else {
+ // Legacy refresh for non-datatable screens
+ var table = link.closest('table.nestedActivitySelector');
+ table.parent().crmSnippet({url: CRM.url('civicrm/case/details', table.data('params'))}).crmSnippet('refresh');
+ }
+ }
+ },
+ error : function(jqXHR) {
+ CRM.alert(jqXHR.responseText, jqXHR.statusText, 'error');
+ return false;
+ }
+ });
+ CRM.status({}, request);
+ }
+ ,{
+ title: {/literal}'{ts escape='js'}Change Activity Status{/ts}'{literal},
+ message: $el
+ }
+ );
+ return false;
+ });
+ });
+ </script>
+{/literal}