Merge pull request #22850 from ixiam/dev_Issue#3080
[civicrm-core.git] / templates / CRM / Financial / Form / FinancialTypeAccount.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 {* this template is used for adding/editing/deleting financial type *}
11 <div class="crm-block crm-form-block crm-financial_type-form-block">
12 {if $action eq 8}
13 <div class="messages status">
14 {icon icon="fa-info-circle"}{/icon}
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}
16 </div>
17 {else}
18 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
19
20 <table class="form-layout">
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>
25 </tr>
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>
29 </tr>
30
31 </table>
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}
38 CRM.$(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 }
66 }
67 });
68 }
69 if (financialId == 'select') {
70 {/literal}
71 callbackURLs = "{crmURL p='civicrm/ajax/rest' h=0 q='className=CRM_Financial_Page_AJAX&fnName=jqFinancial'}"
72 {literal}
73 callbackURLs = callbackURLs + "&_value=select";
74 $.ajax({
75 url: callbackURLs,
76 context: document.body,
77 success: function(data, textStatus) {
78 $(financialAccountID).html("");//clear old options
79 data = eval(data);//get json array
80 if (data != null) {
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 }
86 });
87 }
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();
97 callbackURLs = callbackURLs+"&_value="+financialId;
98 $.ajax({
99 url: callbackURLs,
100 context: document.body,
101 success: function(data, textStatus) {
102 $(financialAccountID).html("");//clear old options
103 data = eval(data);//get json array
104 if (data != null) {
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);
114 }
115 }
116 });
117 if (financialId == 'select') {
118 {/literal}
119 callbackURL = "{crmURL p='civicrm/ajax/rest' h=0 q='className=CRM_Financial_Page_AJAX&fnName=jqFinancialRelation'}"
120 {literal}
121 callbackURL = callbackURL+"&_value=select";
122 $.ajax({
123 url: callbackURL,
124 context: document.body,
125 success: function(data, textStatus) {
126 $(relationID).html("");//clear old options
127 data = eval(data);//get json array
128 if (data != null) {
129 for (i = 0; i < data.length; i++) {
130 if (data[i].selected == 'Selected') {
131 var idf = data[i].value;
132 }
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);
138 }
139 }
140 });
141 }
142 });
143 });
144 {/literal}
145 </script>