Merge pull request #18327 from civicrm/5.29
[civicrm-core.git] / templates / CRM / Case / Form / ActivityToCase.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | Copyright CiviCRM LLC. All rights reserved. |
4 | |
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 |
8 +--------------------------------------------------------------------+
9 *}
10 {* CiviCase - assign activity to case form *}
11 {if !empty($buildCaseActivityForm)}
12 <div class="crm-block crm-form-block crm-case-activitytocase-form-block">
13 <table class="form-layout">
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>
17 </tr>
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>
21 </tr>
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 />
25 <span class="description">{ts}You can modify the activity subject before filing.{/ts}</span>
26 </td>
27 </tr>
28 </table>
29 </div>
30 {* main form end *}
31
32 {else}
33 {* Markup and js to go on the main page for loading the above form in a popup *}
34 {literal}
35 <script type="text/javascript">
36 (function($) {
37 window.fileOnCase = function(action, activityID, currentCaseId, a) {
38 if ( action == "move" ) {
39 var dialogTitle = "{/literal}{ts escape='js'}Move to Case{/ts}{literal}";
40 } else if ( action == "copy" ) {
41 var dialogTitle = "{/literal}{ts escape='js'}Copy to Case{/ts}{literal}";
42 } else if ( action == "file" ) {
43 var dialogTitle = "{/literal}{ts escape='js'}File on Case{/ts}{literal}";
44 }
45
46 var dataUrl = {/literal}"{crmURL p='civicrm/case/addToCase' q='reset=1' h=0}"{literal};
47 dataUrl += '&activityId=' + activityID + '&caseId=' + currentCaseId + '&cid=' + {/literal}"{$contactID}"{literal} + '&fileOnCaseAction=' + action;
48
49 function save() {
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
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();
61
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;
74
75 var statusMsg = {/literal}'{ts escape='js' 1='%1'}Activity has been filed to %1 case.{/ts}'{literal};
76 CRM.alert(ts(statusMsg, {1: '<a href="' + caseUrl + '">' + CRM._.escape(caseTitle) + '</a>'}), '{/literal}{ts escape="js"}Saved{/ts}{literal}', 'success');
77 CRM.refreshParent(a);
78 }
79 }
80 );
81 }
82
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}"},
88 url: dataUrl
89 }).on('crmConfirm:yes', save);
90
91 }
92 })(CRM.$);
93 </script>
94 {/literal}
95 {/if}