| 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).crmSelect2({ |
| 38 | placeholder: {/literal}'{ts escape="js"}- select case -{/ts}'{literal}, |
| 39 | minimumInputLength: 1, |
| 40 | formatResult: CRM.utils.formatSelect2Result, |
| 41 | formatSelection: function(row) { |
| 42 | return row.label; |
| 43 | }, |
| 44 | ajax: { |
| 45 | url: {/literal}"{crmURL p='civicrm/case/ajax/unclosed' h=0}"{literal}, |
| 46 | data: function(term) { |
| 47 | return {term: term, excludeCaseIds: "{/literal}{$excludeCaseIds}{literal}"}; |
| 48 | }, |
| 49 | results: function(response) { |
| 50 | return {results: response}; |
| 51 | } |
| 52 | } |
| 53 | }).change(function() { |
| 54 | if ($(this).val()) { |
| 55 | var info = $(this).select2('data').extra; |
| 56 | {/literal}{* Mix in variables and placeholders for clientside substitution *} |
| 57 | 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}"; |
| 58 | {literal} |
| 59 | $('#subject', $form).val(ts(subject, {1: info.sort_name, 2: info.case_type, 3: $(this).val()})); |
| 60 | } |
| 61 | }); |
| 62 | }); |
| 63 | </script> |
| 64 | {/literal} |
| 65 | </div> |