Merge pull request #23018 from colemanw/afformDeepSearch
[civicrm-core.git] / templates / CRM / Financial / Form / FinancialTypeAccount.tpl
CommitLineData
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*}
10{* this template is used for adding/editing/deleting financial type *}
6a488035 11<div class="crm-block crm-form-block crm-financial_type-form-block">
7b3622bf
PN
12 {if $action eq 8}
13 <div class="messages status">
34d6cec4 14 {icon icon="fa-info-circle"}{/icon}
3b67ab13 15 {ts}WARNING: You cannot delete a financial type if it is currently used by any Contributions, Contribution Pages or Membership Types. Consider disabling this option instead.{/ts} {ts}Deleting a financial type cannot be undone. Unbalanced transactions may be created if you delete this account.{/ts} {ts}Do you want to continue?{/ts}
6a488035 16 </div>
7b3622bf
PN
17 {else}
18 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
96cfe0d7 19
7b3622bf 20 <table class="form-layout">
96cfe0d7 21
22 <tr class="crm-contribution-form-block-account_relationship">
23 <td class="label">{$form.account_relationship.label}</td>
24 <td class="html-adjust">{$form.account_relationship.html}</td>
7b3622bf 25 </tr>
96cfe0d7 26 <tr class="crm-contribution-form-block-financial_account_id">
27 <td class="label">{$form.financial_account_id.label}</td>
28 <td class="html-adjust">{$form.financial_account_id.html}</td>
7b3622bf 29 </tr>
96cfe0d7 30
d0f466d1 31 </table>
6a488035
TO
32 {/if}
33 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="botttom"}</div>
34</div>
35
36<script language="JavaScript" type="text/javascript">
37{literal}
cbe2948b
PN
38CRM.$(function($) {
39 $("#financial_account_id").change(function() {
40 {/literal}
41 relationID = "#account_relationship"
42 financialAccountID = "#financial_account_id"
43 callbackURL = "{crmURL p='civicrm/ajax/rest' h=0 q='className=CRM_Financial_Page_AJAX&fnName=jqFinancialRelation'}"
44 {literal}
45 var financialId = $("#financial_account_id").val();
46 var check = $(relationID).val();
47 if (check == 'select' || financialId == 'select') {
48 callbackURL = callbackURL+"&_value=" + financialId;
49 $.ajax({
50 url: callbackURL,
51 context: document.body,
52 success: function(data, textStatus) {
53 $(relationID).html("");//clear old options
54 data = eval(data);//get json array
55 if (data != null) {
56 for (i = 0; i < data.length; i++) {
57 if (data[i].selected == 'Selected') {
58 var idf = data[i].value;
59 }
60 $(relationID).get(0).add(new Option(data[i].name, data[i].value), document.all ? i : null);
61 }
62 }
63 if (idf != null) {
64 $(relationID).val(idf);
65 }
7b3622bf 66 }
cbe2948b
PN
67 });
68 }
7b3622bf 69 if (financialId == 'select') {
cbe2948b
PN
70 {/literal}
71 callbackURLs = "{crmURL p='civicrm/ajax/rest' h=0 q='className=CRM_Financial_Page_AJAX&fnName=jqFinancial'}"
72 {literal}
7b3622bf 73 callbackURLs = callbackURLs + "&_value=select";
cbe2948b 74 $.ajax({
7b3622bf
PN
75 url: callbackURLs,
76 context: document.body,
77 success: function(data, textStatus) {
cbe2948b
PN
78 $(financialAccountID).html("");//clear old options
79 data = eval(data);//get json array
7b3622bf 80 if (data != null) {
cbe2948b
PN
81 for (i = 0; i < data.length; i++) {
82 $(financialAccountID).get(0).add(new Option(data[i].name, data[i].value), document.all ? i : null);
83 }
84 }
85 }
7b3622bf 86 });
a48d1d9c 87 }
cbe2948b
PN
88 });
89 $("#account_relationship").change(function() {
90 {/literal}
91 relationID = "#account_relationship"
92 financialAccountID = "#financial_account_id"
93 callbackURLs = "{crmURL p='civicrm/ajax/rest' h=0 q='className=CRM_Financial_Page_AJAX&fnName=jqFinancial'}"
94 {literal}
95 var financialId = $("#account_relationship").val();
96 var check = $(financialAccountID).val();
7b3622bf 97 callbackURLs = callbackURLs+"&_value="+financialId;
cbe2948b 98 $.ajax({
7b3622bf
PN
99 url: callbackURLs,
100 context: document.body,
101 success: function(data, textStatus) {
cbe2948b
PN
102 $(financialAccountID).html("");//clear old options
103 data = eval(data);//get json array
7b3622bf 104 if (data != null) {
cbe2948b
PN
105 for (i = 0; i < data.length; i++) {
106 if (data[i].selected == 'Selected') {
107 var idf = data[i].value;
108 }
109 $(financialAccountID).get(0).add(new Option(data[i].name, data[i].value), document.all ? i : null);
110 }
111 }
112 if (idf != null) {
113 $(financialAccountID).val(idf);
7b3622bf 114 }
96cfe0d7 115 }
7b3622bf
PN
116 });
117 if (financialId == 'select') {
cbe2948b
PN
118 {/literal}
119 callbackURL = "{crmURL p='civicrm/ajax/rest' h=0 q='className=CRM_Financial_Page_AJAX&fnName=jqFinancialRelation'}"
120 {literal}
7b3622bf 121 callbackURL = callbackURL+"&_value=select";
cbe2948b 122 $.ajax({
7b3622bf
PN
123 url: callbackURL,
124 context: document.body,
125 success: function(data, textStatus) {
cbe2948b
PN
126 $(relationID).html("");//clear old options
127 data = eval(data);//get json array
7b3622bf 128 if (data != null) {
cbe2948b
PN
129 for (i = 0; i < data.length; i++) {
130 if (data[i].selected == 'Selected') {
131 var idf = data[i].value;
7b3622bf 132 }
cbe2948b
PN
133 $(relationID).get(0).add(new Option(data[i].name, data[i].value), document.all ? i : null);
134 }
135 }
136 if (idf != null) {
137 $(relationID).val(idf);
a48d1d9c 138 }
7b3622bf 139 }
96cfe0d7 140 });
141 }
cbe2948b 142 });
6a488035
TO
143});
144{/literal}
232624b1 145</script>