Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
2c4c49ca | 3 | | CiviCRM version 4.7 | |
6a488035 | 4 | +--------------------------------------------------------------------+ |
8c9251b3 | 5 | | Copyright CiviCRM LLC (c) 2004-2018 | |
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> | |
cf111af5 | 46 | {* main form end *} |
6a488035 | 47 | |
cf111af5 CW |
48 | {else} |
49 | {* Markup and js to go on the main page for loading the above form in a popup *} | |
6a488035 TO |
50 | {literal} |
51 | <script type="text/javascript"> | |
e3756c36 CW |
52 | (function($) { |
53 | window.fileOnCase = function(action, activityID, currentCaseId, a) { | |
6a488035 | 54 | if ( action == "move" ) { |
cf111af5 | 55 | var dialogTitle = "{/literal}{ts escape='js'}Move to Case{/ts}{literal}"; |
6a488035 | 56 | } else if ( action == "copy" ) { |
cf111af5 | 57 | var dialogTitle = "{/literal}{ts escape='js'}Copy to Case{/ts}{literal}"; |
6a488035 | 58 | } else if ( action == "file" ) { |
ac8588ff | 59 | var dialogTitle = "{/literal}{ts escape='js'}File on Case{/ts}{literal}"; |
6a488035 TO |
60 | } |
61 | ||
e3756c36 | 62 | var dataUrl = {/literal}"{crmURL p='civicrm/case/addToCase' q='reset=1' h=0}"{literal}; |
cf111af5 | 63 | dataUrl += '&activityId=' + activityID + '&caseId=' + currentCaseId + '&cid=' + {/literal}"{$contactID}"{literal}; |
6a488035 | 64 | |
e3756c36 | 65 | function save() { |
abd06efc CW |
66 | if (!$("#file_on_case_unclosed_case_id").val()) { |
67 | $("#file_on_case_unclosed_case_id").crmError('{/literal}{ts escape="js"}Please select a case from the list{/ts}{literal}.'); | |
68 | return false; | |
69 | } | |
70 | ||
e3756c36 CW |
71 | var $context = $('div.crm-confirm-dialog'), |
72 | selectedCaseId = $('input[name=file_on_case_unclosed_case_id]', $context).val(), | |
73 | caseTitle = $('input[name=file_on_case_unclosed_case_id]', $context).select2('data').label, | |
74 | contactId = $('input[name=file_on_case_unclosed_case_id]', $context).select2('data').extra.contact_id, | |
75 | subject = $("#file_on_case_activity_subject").val(), | |
76 | targetContactId = $("#file_on_case_target_contact_id").val(); | |
cf111af5 | 77 | |
e3756c36 CW |
78 | var postUrl = {/literal}"{crmURL p='civicrm/ajax/activity/convert' h=0 }"{literal}; |
79 | $.post( postUrl, { activityID: activityID, caseID: selectedCaseId, contactID: contactId, newSubject: subject, targetContactIds: targetContactId, mode: action, key: {/literal}"{crmKey name='civicrm/ajax/activity/convert'}"{literal} }, | |
80 | function( values ) { | |
81 | if ( values.error_msg ) { | |
82 | $().crmError(values.error_msg, "{/literal}{ts escape='js'}Unable to file on case.{/ts}{literal}"); | |
83 | } else { | |
84 | var destUrl = {/literal}"{crmURL p='civicrm/contact/view/case' q='reset=1&action=view&id=' h=0 }"{literal}; | |
85 | var context = ''; | |
86 | {/literal}{if !empty($fulltext)}{literal} | |
87 | context = '&context={/literal}{$fulltext}{literal}'; | |
88 | {/literal}{/if}{literal} | |
89 | var caseUrl = destUrl + selectedCaseId + '&cid=' + contactId + context; | |
6a488035 | 90 | |
e3756c36 CW |
91 | var statusMsg = {/literal}'{ts escape='js' 1='%1'}Activity has been filed to %1 case.{/ts}'{literal}; |
92 | CRM.alert(ts(statusMsg, {1: '<a href="' + caseUrl + '">' + caseTitle + '</a>'}), '{/literal}{ts escape="js"}Saved{/ts}{literal}', 'success'); | |
93 | CRM.refreshParent(a); | |
cf111af5 | 94 | } |
e3756c36 CW |
95 | } |
96 | ); | |
97 | } | |
31037a42 | 98 | |
e3756c36 CW |
99 | CRM.confirm({ |
100 | title: dialogTitle, | |
101 | width: '600', | |
102 | resizable: true, | |
103 | options: {yes: "{/literal}{ts escape='js'}Save{/ts}{literal}", no: "{/literal}{ts escape='js'}Cancel{/ts}{literal}"}, | |
3f4328da | 104 | url: dataUrl |
e3756c36 | 105 | }).on('crmConfirm:yes', save); |
31037a42 | 106 | |
cf111af5 | 107 | } |
e3756c36 | 108 | })(CRM.$); |
6a488035 TO |
109 | </script> |
110 | {/literal} | |
cf111af5 | 111 | {/if} |