more whitespace -remove trailing spaces
[civicrm-core.git] / templates / CRM / Case / Form / ActivityChangeStatusJs.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.5 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2014 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
8 | |
9 | CiviCRM is free software; you can copy, modify, and distribute it |
10 | under the terms of the GNU Affero General Public License |
11 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
12 | |
13 | CiviCRM is distributed in the hope that it will be useful, but |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
16 | See the GNU Affero General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU Affero General Public |
19 | License and the CiviCRM Licensing Exception along |
20 | with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
25 *}
26 {* CiviCase - change activity status inline *}
27 {literal}
28 <script type="text/javascript">
29 CRM.$(function($) {
30 // Elements are sometimes in a jQuery dialog box which is outside crm-container,
31 // So gotta attach this handler to the whole body - sorry.
32 $('body').off('click.changeActivityStatus');
33 $('body').on('click.changeActivityStatus', 'a.crm-activity-change-status', function() {
34 var link = $(this),
35 activityId = $(this).attr('activity_id'),
36 current_status_id = $(this).attr('current_status'),
37 caseId = $(this).attr('case_id'),
38 data = 'snippet=1&reset=1',
39 $el = $('<div class="crm-activity_change_status"></div>');
40 $el.block();
41
42 $el.load(CRM.url('civicrm/case/changeactivitystatus'), data, function() {
43 $el.unblock().trigger('crmLoad');
44 $("#activity_change_status").val(current_status_id);
45 });
46
47 CRM.confirm({
48 title: {/literal}'{ts escape='js'}Change Activity Status{/ts}'{literal},
49 message: $el
50 })
51 .on('crmConfirm:yes', function() {
52 // update the status
53 var status_id = $("#activity_change_status").val();
54 if (status_id === current_status_id) {
55 return false;
56 }
57
58 var dataUrl = CRM.url('civicrm/ajax/rest');
59 var data = 'json=1&version=3&entity=Activity&action=update&id=' + activityId + '&status_id=' + status_id
60 + '&case_id=' + caseId;
61 var request = $.ajax({
62 type : 'POST',
63 dataType : 'json',
64 url : dataUrl,
65 data : data,
66 success : function(values) {
67 if (values.is_error) {
68 CRM.alert(values.error_message, {/literal}'{ts escape='js'}Unable to change status{/ts}'{literal}, 'error');
69 return false;
70 }
71 else {
72 CRM.refreshParent(link);
73 }
74 },
75 error : function(jqXHR) {
76 CRM.alert(jqXHR.responseText, jqXHR.statusText, 'error');
77 return false;
78 }
79 });
80 CRM.status({}, request);
81 });
82 return false;
83 });
84 });
85 </script>
86 {/literal}