Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
1188c7a8 | 3 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 4 | | | |
1188c7a8 TO |
5 | | This work is published under the GNU AGPLv3 license with some | |
6 | | permitted exceptions and without any warranty. For full license | | |
7 | | and copyright information, see https://civicrm.org/licensing | | |
6a488035 TO |
8 | +--------------------------------------------------------------------+ |
9 | *} | |
cf111af5 | 10 | {* CiviCase - assign activity to case form *} |
6a488035 | 11 | {if !empty($buildCaseActivityForm)} |
cf111af5 CW |
12 | <div class="crm-block crm-form-block crm-case-activitytocase-form-block"> |
13 | <table class="form-layout"> | |
050fc124 CW |
14 | <tr class="crm-case-activitytocase-form-block-file_on_case_unclosed_case_id"> |
15 | <td class="label">{$form.file_on_case_unclosed_case_id.label}</td> | |
16 | <td>{$form.file_on_case_unclosed_case_id.html}</td> | |
cf111af5 | 17 | </tr> |
050fc124 CW |
18 | <tr class="crm-case-activitytocase-form-block-file_on_case_target_contact_id"> |
19 | <td class="label">{$form.file_on_case_target_contact_id.label}</td> | |
20 | <td>{$form.file_on_case_target_contact_id.html}</td> | |
cf111af5 | 21 | </tr> |
050fc124 CW |
22 | <tr class="crm-case-activitytocase-form-block-file_on_case_activity_subject"> |
23 | <td class="label">{$form.file_on_case_activity_subject.label}</td> | |
24 | <td>{$form.file_on_case_activity_subject.html}<br /> | |
6a488035 | 25 | <span class="description">{ts}You can modify the activity subject before filing.{/ts}</span> |
cf111af5 CW |
26 | </td> |
27 | </tr> | |
28 | </table> | |
29 | </div> | |
cf111af5 | 30 | {* main form end *} |
6a488035 | 31 | |
cf111af5 CW |
32 | {else} |
33 | {* Markup and js to go on the main page for loading the above form in a popup *} | |
6a488035 TO |
34 | {literal} |
35 | <script type="text/javascript"> | |
e3756c36 CW |
36 | (function($) { |
37 | window.fileOnCase = function(action, activityID, currentCaseId, a) { | |
6a488035 | 38 | if ( action == "move" ) { |
cf111af5 | 39 | var dialogTitle = "{/literal}{ts escape='js'}Move to Case{/ts}{literal}"; |
6a488035 | 40 | } else if ( action == "copy" ) { |
cf111af5 | 41 | var dialogTitle = "{/literal}{ts escape='js'}Copy to Case{/ts}{literal}"; |
6a488035 | 42 | } else if ( action == "file" ) { |
ac8588ff | 43 | var dialogTitle = "{/literal}{ts escape='js'}File on Case{/ts}{literal}"; |
6a488035 TO |
44 | } |
45 | ||
e3756c36 | 46 | var dataUrl = {/literal}"{crmURL p='civicrm/case/addToCase' q='reset=1' h=0}"{literal}; |
6a1e5601 | 47 | dataUrl += '&activityId=' + activityID + '&caseId=' + currentCaseId + '&cid=' + {/literal}"{$contactID}"{literal} + '&fileOnCaseAction=' + action; |
6a488035 | 48 | |
e3756c36 | 49 | function save() { |
abd06efc CW |
50 | if (!$("#file_on_case_unclosed_case_id").val()) { |
51 | $("#file_on_case_unclosed_case_id").crmError('{/literal}{ts escape="js"}Please select a case from the list{/ts}{literal}.'); | |
52 | return false; | |
53 | } | |
54 | ||
e3756c36 CW |
55 | var $context = $('div.crm-confirm-dialog'), |
56 | selectedCaseId = $('input[name=file_on_case_unclosed_case_id]', $context).val(), | |
57 | caseTitle = $('input[name=file_on_case_unclosed_case_id]', $context).select2('data').label, | |
58 | contactId = $('input[name=file_on_case_unclosed_case_id]', $context).select2('data').extra.contact_id, | |
59 | subject = $("#file_on_case_activity_subject").val(), | |
60 | targetContactId = $("#file_on_case_target_contact_id").val(); | |
cf111af5 | 61 | |
e3756c36 CW |
62 | var postUrl = {/literal}"{crmURL p='civicrm/ajax/activity/convert' h=0 }"{literal}; |
63 | $.post( postUrl, { activityID: activityID, caseID: selectedCaseId, contactID: contactId, newSubject: subject, targetContactIds: targetContactId, mode: action, key: {/literal}"{crmKey name='civicrm/ajax/activity/convert'}"{literal} }, | |
64 | function( values ) { | |
65 | if ( values.error_msg ) { | |
66 | $().crmError(values.error_msg, "{/literal}{ts escape='js'}Unable to file on case.{/ts}{literal}"); | |
67 | } else { | |
68 | var destUrl = {/literal}"{crmURL p='civicrm/contact/view/case' q='reset=1&action=view&id=' h=0 }"{literal}; | |
69 | var context = ''; | |
70 | {/literal}{if !empty($fulltext)}{literal} | |
71 | context = '&context={/literal}{$fulltext}{literal}'; | |
72 | {/literal}{/if}{literal} | |
73 | var caseUrl = destUrl + selectedCaseId + '&cid=' + contactId + context; | |
6a488035 | 74 | |
e3756c36 | 75 | var statusMsg = {/literal}'{ts escape='js' 1='%1'}Activity has been filed to %1 case.{/ts}'{literal}; |
5402bfb8 | 76 | CRM.alert(ts(statusMsg, {1: '<a href="' + caseUrl + '">' + CRM._.escape(caseTitle) + '</a>'}), '{/literal}{ts escape="js"}Saved{/ts}{literal}', 'success'); |
e3756c36 | 77 | CRM.refreshParent(a); |
cf111af5 | 78 | } |
e3756c36 CW |
79 | } |
80 | ); | |
81 | } | |
31037a42 | 82 | |
e3756c36 CW |
83 | CRM.confirm({ |
84 | title: dialogTitle, | |
85 | width: '600', | |
86 | resizable: true, | |
87 | options: {yes: "{/literal}{ts escape='js'}Save{/ts}{literal}", no: "{/literal}{ts escape='js'}Cancel{/ts}{literal}"}, | |
3f4328da | 88 | url: dataUrl |
e3756c36 | 89 | }).on('crmConfirm:yes', save); |
31037a42 | 90 | |
cf111af5 | 91 | } |
e3756c36 | 92 | })(CRM.$); |
6a488035 TO |
93 | </script> |
94 | {/literal} | |
cf111af5 | 95 | {/if} |