Merge pull request #2758 from pratik-joshi/CRM-14278
[civicrm-core.git] / templates / CRM / Case / Form / Activity / LinkCases.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.5 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2014 |
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 {* Template for to create a link between two cases. *}
27 <div class="crm-block crm-form-block crm-case-linkcases-form-block">
28 <tr class="crm-case-linkcases-form-block-link_to_case_id">
29 <td class="label">{$form.link_to_case_id.label}</td>
30 <td>{$form.link_to_case_id.html}</td>
31 </tr>
32
33 {literal}
34 <script type="text/javascript">
35 CRM.$(function($) {
36 var $form = $("#{/literal}{$form.formName}{literal}");
37 $('input[name=link_to_case_id]', $form).select2({
38 placeholder: {/literal}'{ts escape="js"}- select case -{/ts}'{literal},
39 minimumInputLength: 1,
40 ajax: {
41 url: {/literal}"{crmURL p='civicrm/case/ajax/unclosed' h=0}"{literal},
42 data: function(term) {
43 return {term: term, excludeCaseIds: "{/literal}{$excludeCaseIds}{literal}"};
44 },
45 results: function(response) {
46 return {results: response};
47 }
48 }
49 }).change(function() {
50 if ($(this).val()) {
51 var info = $(this).select2('data').extra;
52 {/literal}{* Mix in variables and placeholders for clientside substitution *}
53 var subject = "{ts escape=js 1="%1" 2="%2" 3="%3" 4=$client.sort_name 5=$caseTypeLabel 6=$caseId}Create link between %1 - %2 (CaseID: %3) and %4 - %5 (CaseID: %6){/ts}";
54 {literal}
55 $('#subject', $form).val(ts(subject, {1: info.sort_name, 2: info.case_type, 3: $(this).val()}));
56 }
57 });
58 });
59 </script>
60 {/literal}
61 </div>