Merge pull request #11949 from magnolia61/Hide_waitinglist_for_past_and_registration_...
[civicrm-core.git] / templates / CRM / Case / Form / ActivityToCase.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 5 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2018 |
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 *}
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>
33 </tr>
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>
37 </tr>
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>
42 </td>
43 </tr>
44 </table>
45 </div>
46 {* main form end *}
47
48 {else}
49 {* Markup and js to go on the main page for loading the above form in a popup *}
50 {literal}
51 <script type="text/javascript">
52 (function($) {
53 window.fileOnCase = function(action, activityID, currentCaseId, a) {
54 if ( action == "move" ) {
55 var dialogTitle = "{/literal}{ts escape='js'}Move to Case{/ts}{literal}";
56 } else if ( action == "copy" ) {
57 var dialogTitle = "{/literal}{ts escape='js'}Copy to Case{/ts}{literal}";
58 } else if ( action == "file" ) {
59 var dialogTitle = "{/literal}{ts escape='js'}File on Case{/ts}{literal}";
60 }
61
62 var dataUrl = {/literal}"{crmURL p='civicrm/case/addToCase' q='reset=1' h=0}"{literal};
63 dataUrl += '&activityId=' + activityID + '&caseId=' + currentCaseId + '&cid=' + {/literal}"{$contactID}"{literal};
64
65 function save() {
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
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();
77
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;
90
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);
94 }
95 }
96 );
97 }
98
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}"},
104 url: dataUrl
105 }).on('crmConfirm:yes', save);
106
107 }
108 })(CRM.$);
109 </script>
110 {/literal}
111 {/if}