CRM-19427 - set deductible amount at price field option level
[civicrm-core.git] / templates / CRM / Price / Form / Field.tpl
CommitLineData
6a488035
TO
1{*
2 +--------------------------------------------------------------------+
2c4c49ca 3 | CiviCRM version 4.7 |
6a488035 4 +--------------------------------------------------------------------+
fa938177 5 | Copyright CiviCRM LLC (c) 2004-2016 |
6a488035
TO
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{*Javascript function controls showing and hiding of form elements based on html type.*}
27{literal}
28<script type="text/Javascript">
29 function option_html_type(form) {
60158442 30 var html_type_name = cj('#html_type').val();
6a488035
TO
31
32 if (html_type_name == "Text") {
60158442
CW
33 cj("#price-block").show();
34 cj("#showoption").hide();
6a488035
TO
35
36 }
37 else {
60158442
CW
38 cj("#price-block").hide();
39 cj("#showoption").show();
6a488035
TO
40 }
41
42 if (html_type_name == 'Radio' || html_type_name == 'CheckBox') {
43 cj("#optionsPerLine").show( );
44 }
45 else {
46 cj("#optionsPerLine").hide( );
47 cj("#optionsPerLineDef").hide( );
48 }
49
50 var radioOption, checkBoxOption;
51
0c165e1c 52 for (var i=1; i<=15; i++) {
60158442
CW
53 radioOption = '#radio'+i;
54 checkBoxOption = '#checkbox'+i;
6a488035
TO
55 if (html_type_name == 'Radio' || html_type_name == 'CheckBox' || html_type_name == 'Select') {
56 if (html_type_name == "CheckBox") {
60158442
CW
57 cj(checkBoxOption).show();
58 cj(radioOption).hide();
6a488035
TO
59 }
60 else {
60158442
CW
61 cj(radioOption).show();
62 cj(checkBoxOption).hide();
6a488035
TO
63 }
64 }
65 }
66
67 }
68</script>
69{/literal}
6a488035
TO
70<div class="crm-block crm-form-block crm-price-field-form-block">
71 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
72 <table class="form-layout">
73 <tr class="crm-price-field-form-block-label">
74 <td class="label">{$form.label.label}</td>
75 <td>{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_price_field' field='label' id=$fid}{/if}{$form.label.html}
76 </td>
77 </tr>
78 <tr class="crm-price-field-form-block-html_type">
79 <td class="label">{$form.html_type.label}</td>
80 <td>{$form.html_type.html}
81 </td>
82 </tr>
83 {if $action neq 4 and $action neq 2}
84 <tr>
85 <td>&nbsp;</td>
86 <td class="description">{ts}Select the html type used to offer options for this field{/ts}
87 </td>
88 </tr>
89 {/if}
90 </table>
91
92 <div class="spacer"></div>
22b67281 93 <div id="price-block" {if $action eq 2 && $form.html_type.value.0 eq 'Text'} class="show-block" {else} class="hiddenElement" {/if}>
6a488035
TO
94 <table class="form-layout">
95 <tr class="crm-price-field-form-block-price">
96 <td class="label">{$form.price.label} <span class="crm-marker" title="{ts}This field is required.{/ts}">*</span></td>
97 <td>{$form.price.html}
98 {if $action neq 4}
99 <br /><span class="description">{ts}Unit price.{/ts}</span> {help id="id-negative"}
100 {/if}
101 </td>
102 </tr>
5afce5ad 103 <tr class="crm-price-field-form-block-non-deductible-amount">
104 <td class="label">{$form.non_deductible_amount.label}</td>
105 <td>{$form.non_deductible_amount.html}</td>
106 </tr>
6a488035
TO
107 {if $useForEvent}
108 <tr class="crm-price-field-form-block-count">
109 <td class="label">{$form.count.label}</td>
110 <td>{$form.count.html}<br />
111 <span class="description">{ts}Enter a value here if you want to increment the number of registered participants per unit against the maximum number of participants allowed for this event.{/ts}</span>
112 {help id="id-participant-count"}
113 </td>
114 </tr>
115 <tr class="crm-price-field-form-block-max_value">
116 <td class="label">{$form.max_value.label}</td>
117 <td>{$form.max_value.html}
118 </td>
119 </tr>
120 {/if}
121 <tr class="crm-price-field-form-block-financial_type">
122 <td class="label">{$form.financial_type_id.label}<span class="crm-marker" title="{ts}This field is required.{/ts}">*</span></td></td>
123 <td>
124 {if !$financialType}
125 {capture assign=ftUrl}{crmURL p='civicrm/admin/financial/financialType' q="reset=1"}{/capture}
126 {ts 1=$ftUrl}There is no Financial Type configured of Account Relation Revenue. <a href='%1'>Click here</a> if you want to configure financial type for your site.{/ts}
127 {else}
128 {$form.financial_type_id.html}
129 {/if}
130 </td>
131 </tr>
132 </table>
133 </div>
134
135{if $action eq 1}
136{* Conditionally show table for setting up selection options - for field types = radio, checkbox or select *}
22b67281 137 <div id='showoption' class="hiddenElement">{ include file="CRM/Price/Form/OptionFields.tpl"}</div>
6a488035
TO
138{/if}
139 <table class="form-layout">
140 <tr id="optionsPerLine" class="crm-price-field-form-block-options_per_line">
141 <td class="label">{$form.options_per_line.label}</td>
142 <td>{$form.options_per_line.html|crmAddClass:two}</td>
143 </tr>
144 <tr class="crm-price-field-form-block-is_display_amounts">
145 <td class="label">{$form.is_display_amounts.label}</td>
146 <td>{$form.is_display_amounts.html}
147 {if $action neq 4}
148 <div class="description">{ts}Display amount next to each option? If no, then the amount should be in the option description.{/ts}</div>
149 {/if}
150 </td>
151 </tr>
152 <tr class="crm-price-field-form-block-weight">
153 <td class="label">{$form.weight.label}</td>
154 <td>{$form.weight.html|crmAddClass:two}
155 {if $action neq 4}
156 <div class="description">{ts}Weight controls the order in which fields are displayed in a group. Enter a positive or negative integer - lower numbers are displayed ahead of higher numbers.{/ts}</div>
157 {/if}
158 </td>
159 </tr>
160
161 <tr class="crm-price-field-form-block-help_post">
162 <td class="label">{$form.help_post.label}</td>
163 <td>{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_price_field' field='help_post' id=$fid}{/if}{$form.help_post.html|crmAddClass:huge}&nbsp;
164 {if $action neq 4}
165 <div class="description">{ts}Explanatory text displayed to users for this field.{/ts}</div>
166 {/if}
167 </td>
168 </tr>
169
170 <tr class="crm-price-field-form-block-active_on">
171 <td class="label">{$form.active_on.label}</td>
172 <td>{include file="CRM/common/jcalendar.tpl" elementName=active_on}
173 {if $action neq 4}
174 <br /><span class="description">{ts}Date this field becomes effective (optional). Used for price set fields that are made available starting on a specific date.{/ts}</span>
175 {/if}
176 </td>
177 </tr>
178
179 <tr class="crm-price-field-form-block-expire_on">
180 <td class="label">{$form.expire_on.label}</td>
181 <td>{include file="CRM/common/jcalendar.tpl" elementName=expire_on}
182 {if $action neq 4}
183 <br /><span class="description">{ts}Date this field expires (optional). Used for price set fields that are no longer available after a specific date (e.g. early-bird pricing).{/ts}</span>
184 {/if}
185 </td>
186 </tr>
187
188 <tr class="crm-price-field-form-block-is_required">
189 <td class="label">{$form.is_required.label}</td>
190 <td>&nbsp;{$form.is_required.html}</td>
191 </tr>
192 <tr class="crm-price-field-form-block-visibility_id">
193 <td class="label">{$form.visibility_id.label}</td>
194 <td>&nbsp;{$form.visibility_id.html} {help id="id-visibility"}</td>
195 </tr>
196 <tr class="crm-price-field-form-block-is_active">
197 <td class="label">{$form.is_active.label}</td>
198 <td>{$form.is_active.html}</td>
199 </tr>
200 </table>
201 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
202</div>
203
204{literal}
205<script type="text/javascript">
206 option_html_type(this.form);
207 function calculateRowValues( row ) {
208 var mtype = cj("#membership_type_id_"+row).val();
209 var postUrl = "{/literal}{crmURL p='civicrm/ajax/memType' h=0}{literal}";
210
211 cj.post( postUrl, {mtype: mtype}, function(data) {
212 cj("#option_amount_"+ row).val(data.total_amount);
213 cj("#option_label_"+ row).val(data.name);
214 cj("#option_financial_type_id_"+ row).val(data.financial_type_id);
215 if (data.name) {
216 cj("#membership_num_terms_"+ row).val('1');
217 }
218 else {
219 cj("#membership_num_terms_"+ row).val('');
220 }
221 }, 'json');
222 }
223</script>
224{/literal}
225
226{* Give link to view/edit choice options if in edit mode and html_type is one of the multiple choice types *}
227{if $action eq 2 AND ($form.data_type.value.1.0 eq 'CheckBox' OR $form.data_type.value.1.0 eq 'Radio' OR $form.data_type.value.1.0 eq 'Select') }
228<div class="action-link">
229 <a href="{crmURL p="civicrm/admin/event/field/option" q="reset=1&action=browse&fid=`$fid`"}" class="button"><span>{ts}Multiple Choice Options{/ts}</span></a>
230</div>
231{/if}
232