Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
39de6fd5 | 3 | | CiviCRM version 4.6 | |
6a488035 | 4 | +--------------------------------------------------------------------+ |
819d0d41 | 5 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
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 | *} | |
cf111af5 | 26 | {* CiviCase - assign activity to case form *} |
6a488035 | 27 | {if !empty($buildCaseActivityForm)} |
cf111af5 CW |
28 | <div class="crm-block crm-form-block crm-case-activitytocase-form-block"> |
29 | <table class="form-layout"> | |
050fc124 CW |
30 | <tr class="crm-case-activitytocase-form-block-file_on_case_unclosed_case_id"> |
31 | <td class="label">{$form.file_on_case_unclosed_case_id.label}</td> | |
32 | <td>{$form.file_on_case_unclosed_case_id.html}</td> | |
cf111af5 | 33 | </tr> |
050fc124 CW |
34 | <tr class="crm-case-activitytocase-form-block-file_on_case_target_contact_id"> |
35 | <td class="label">{$form.file_on_case_target_contact_id.label}</td> | |
36 | <td>{$form.file_on_case_target_contact_id.html}</td> | |
cf111af5 | 37 | </tr> |
050fc124 CW |
38 | <tr class="crm-case-activitytocase-form-block-file_on_case_activity_subject"> |
39 | <td class="label">{$form.file_on_case_activity_subject.label}</td> | |
40 | <td>{$form.file_on_case_activity_subject.html}<br /> | |
6a488035 | 41 | <span class="description">{ts}You can modify the activity subject before filing.{/ts}</span> |
cf111af5 CW |
42 | </td> |
43 | </tr> | |
44 | </table> | |
45 | </div> | |
6a488035 | 46 | {literal} |
cf111af5 | 47 | <script type="text/javascript"> |
3cc60a06 | 48 | CRM.$(function($) { |
e3756c36 CW |
49 | var $form = $('form.{/literal}{$form.formClass}{literal}'); |
50 | $('input[name=file_on_case_unclosed_case_id]', $form).crmSelect2({ | |
f72119d9 CW |
51 | placeholder: {/literal}'{ts escape="js"}- select case -{/ts}'{literal}, |
52 | minimumInputLength: 1, | |
3c0b6a40 CW |
53 | formatResult: CRM.utils.formatSelect2Result, |
54 | formatSelection: function(row) { | |
55 | return row.label; | |
56 | }, | |
bd343dcc CW |
57 | initSelection: function($el, callback) { |
58 | callback($el.data('value')); | |
59 | }, | |
f72119d9 CW |
60 | ajax: { |
61 | url: {/literal}"{crmURL p='civicrm/case/ajax/unclosed' h=0}"{literal}, | |
62 | data: function(term) { | |
63 | return {term: term, excludeCaseIds: "{/literal}{$currentCaseId}{literal}"}; | |
64 | }, | |
65 | results: function(response) { | |
66 | return {results: response}; | |
67 | } | |
68 | } | |
f72119d9 | 69 | }); |
cf111af5 | 70 | }); |
cf111af5 | 71 | </script> |
6a488035 | 72 | {/literal} |
cf111af5 | 73 | {* main form end *} |
6a488035 | 74 | |
cf111af5 CW |
75 | {else} |
76 | {* Markup and js to go on the main page for loading the above form in a popup *} | |
6a488035 TO |
77 | {literal} |
78 | <script type="text/javascript"> | |
e3756c36 CW |
79 | (function($) { |
80 | window.fileOnCase = function(action, activityID, currentCaseId, a) { | |
6a488035 | 81 | if ( action == "move" ) { |
cf111af5 | 82 | var dialogTitle = "{/literal}{ts escape='js'}Move to Case{/ts}{literal}"; |
6a488035 | 83 | } else if ( action == "copy" ) { |
cf111af5 | 84 | var dialogTitle = "{/literal}{ts escape='js'}Copy to Case{/ts}{literal}"; |
6a488035 | 85 | } else if ( action == "file" ) { |
ac8588ff | 86 | var dialogTitle = "{/literal}{ts escape='js'}File on Case{/ts}{literal}"; |
6a488035 TO |
87 | } |
88 | ||
e3756c36 | 89 | var dataUrl = {/literal}"{crmURL p='civicrm/case/addToCase' q='reset=1' h=0}"{literal}; |
cf111af5 | 90 | dataUrl += '&activityId=' + activityID + '&caseId=' + currentCaseId + '&cid=' + {/literal}"{$contactID}"{literal}; |
6a488035 | 91 | |
e3756c36 CW |
92 | function save() { |
93 | var $context = $('div.crm-confirm-dialog'), | |
94 | selectedCaseId = $('input[name=file_on_case_unclosed_case_id]', $context).val(), | |
95 | caseTitle = $('input[name=file_on_case_unclosed_case_id]', $context).select2('data').label, | |
96 | contactId = $('input[name=file_on_case_unclosed_case_id]', $context).select2('data').extra.contact_id, | |
97 | subject = $("#file_on_case_activity_subject").val(), | |
98 | targetContactId = $("#file_on_case_target_contact_id").val(); | |
cf111af5 | 99 | |
e3756c36 CW |
100 | if (!$("#file_on_case_unclosed_case_id").val()) { |
101 | $("#file_on_case_unclosed_case_id").crmError('{/literal}{ts escape="js"}Please select a case from the list{/ts}{literal}.'); | |
102 | return false; | |
103 | } | |
cf111af5 | 104 | |
e3756c36 CW |
105 | var postUrl = {/literal}"{crmURL p='civicrm/ajax/activity/convert' h=0 }"{literal}; |
106 | $.post( postUrl, { activityID: activityID, caseID: selectedCaseId, contactID: contactId, newSubject: subject, targetContactIds: targetContactId, mode: action, key: {/literal}"{crmKey name='civicrm/ajax/activity/convert'}"{literal} }, | |
107 | function( values ) { | |
108 | if ( values.error_msg ) { | |
109 | $().crmError(values.error_msg, "{/literal}{ts escape='js'}Unable to file on case.{/ts}{literal}"); | |
110 | } else { | |
111 | var destUrl = {/literal}"{crmURL p='civicrm/contact/view/case' q='reset=1&action=view&id=' h=0 }"{literal}; | |
112 | var context = ''; | |
113 | {/literal}{if !empty($fulltext)}{literal} | |
114 | context = '&context={/literal}{$fulltext}{literal}'; | |
115 | {/literal}{/if}{literal} | |
116 | var caseUrl = destUrl + selectedCaseId + '&cid=' + contactId + context; | |
6a488035 | 117 | |
e3756c36 CW |
118 | var statusMsg = {/literal}'{ts escape='js' 1='%1'}Activity has been filed to %1 case.{/ts}'{literal}; |
119 | CRM.alert(ts(statusMsg, {1: '<a href="' + caseUrl + '">' + caseTitle + '</a>'}), '{/literal}{ts escape="js"}Saved{/ts}{literal}', 'success'); | |
120 | CRM.refreshParent(a); | |
cf111af5 | 121 | } |
e3756c36 CW |
122 | } |
123 | ); | |
124 | } | |
31037a42 | 125 | |
e3756c36 CW |
126 | CRM.confirm({ |
127 | title: dialogTitle, | |
128 | width: '600', | |
129 | resizable: true, | |
130 | options: {yes: "{/literal}{ts escape='js'}Save{/ts}{literal}", no: "{/literal}{ts escape='js'}Cancel{/ts}{literal}"}, | |
3f4328da | 131 | url: dataUrl |
e3756c36 | 132 | }).on('crmConfirm:yes', save); |
31037a42 | 133 | |
cf111af5 | 134 | } |
e3756c36 | 135 | })(CRM.$); |
6a488035 TO |
136 | </script> |
137 | {/literal} | |
cf111af5 | 138 | {/if} |