2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.7 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2015 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
26 {* CiviCase - assign activity to case form *}
27 {if !empty($buildCaseActivityForm)}
28 <div class="crm-block crm-form-block crm-case-activitytocase-form-block">
29 <table class="form-layout">
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>
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>
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 />
41 <span class="description">{ts}You can modify the activity subject before filing.{/ts}</span>
47 <script type="text/javascript">
49 var $form = $('form.{/literal}{$form.formClass}{literal}');
50 $('input[name=file_on_case_unclosed_case_id]', $form).crmSelect2({
51 placeholder: {/literal}'{ts escape="js"}- select case -{/ts}'{literal},
52 minimumInputLength: 1,
53 formatResult: CRM.utils.formatSelect2Result,
54 formatSelection: function(row) {
57 initSelection: function($el, callback) {
58 callback($el.data('value'));
61 url: {/literal}"{crmURL p='civicrm/case/ajax/unclosed' h=0}"{literal},
62 data: function(term) {
63 return {term: term, excludeCaseIds: "{/literal}{$currentCaseId}{literal}"};
65 results: function(response) {
66 return {results: response};
76 {* Markup and js to go on the main page for loading the above form in a popup *}
78 <script type="text/javascript">
80 window.fileOnCase = function(action, activityID, currentCaseId, a) {
81 if ( action == "move" ) {
82 var dialogTitle = "{/literal}{ts escape='js'}Move to Case{/ts}{literal}";
83 } else if ( action == "copy" ) {
84 var dialogTitle = "{/literal}{ts escape='js'}Copy to Case{/ts}{literal}";
85 } else if ( action == "file" ) {
86 var dialogTitle = "{/literal}{ts escape='js'}File on Case{/ts}{literal}";
89 var dataUrl = {/literal}"{crmURL p='civicrm/case/addToCase' q='reset=1' h=0}"{literal};
90 dataUrl += '&activityId=' + activityID + '&caseId=' + currentCaseId + '&cid=' + {/literal}"{$contactID}"{literal};
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();
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}.');
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} },
108 if ( values.error_msg ) {
109 $().crmError(values.error_msg, "{/literal}{ts escape='js'}Unable to file on case.{/ts}{literal}");
111 var destUrl = {/literal}"{crmURL p='civicrm/contact/view/case' q='reset=1&action=view&id=' h=0 }"{literal};
113 {/literal}{if !empty($fulltext)}{literal}
114 context = '&context={/literal}{$fulltext}{literal}';
115 {/literal}{/if}{literal}
116 var caseUrl = destUrl + selectedCaseId + '&cid=' + contactId + context;
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);
130 options: {yes: "{/literal}{ts escape='js'}Save{/ts}{literal}", no: "{/literal}{ts escape='js'}Cancel{/ts}{literal}"},
132 }).on('crmConfirm:yes', save);