Merge pull request #12592 from civicrm/5.4
[civicrm-core.git] / templates / CRM / Price / Form / Field.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 5 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2018 |
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) {
30 var html_type_name = cj('#html_type').val();
31
32 if (html_type_name == "Text") {
33 cj("#price-block").show();
34 cj("#showoption").hide();
35
36 }
37 else {
38 cj("#price-block").hide();
39 cj("#showoption").show();
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
52 for (var i=1; i<=15; i++) {
53 radioOption = '#radio'+i;
54 checkBoxOption = '#checkbox'+i;
55 if (html_type_name == 'Radio' || html_type_name == 'CheckBox' || html_type_name == 'Select') {
56 if (html_type_name == "CheckBox") {
57 cj(checkBoxOption).show();
58 cj(radioOption).hide();
59 }
60 else {
61 cj(radioOption).show();
62 cj(checkBoxOption).hide();
63 }
64 }
65 }
66
67 }
68
69 var adminVisibilityID = 0;
70 cj('#visibility_id').on('change', function () {
71 if (adminVisibilityID == 0) {
72 CRM.api3('OptionValue', 'getvalue', {
73 'sequential': 1,
74 'return': 'value',
75 'option_group_id': 'visibility',
76 'name': 'admin'
77 }).done(function(result) {
78 adminVisibilityID = result.result;
79 if (cj('#visibility_id').val() == adminVisibilityID) {
80 updateVisibilitySelects(adminVisibilityID);
81 }
82 });
83 } else {
84 if (cj('#visibility_id').val() == adminVisibilityID) {
85 updateVisibilitySelects(adminVisibilityID);
86 }
87 }
88 });
89
90 function updateVisibilitySelects(value) {
91 for (var i=1; i<=15; i++) {
92 cj('#option_visibility_id_' + i).val(value);
93 }
94 }
95 </script>
96 {/literal}
97 <div class="crm-block crm-form-block crm-price-field-form-block">
98 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
99 <table class="form-layout">
100 <tr class="crm-price-field-form-block-label">
101 <td class="label">{$form.label.label}</td>
102 <td>{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_price_field' field='label' id=$fid}{/if}{$form.label.html}
103 </td>
104 </tr>
105 <tr class="crm-price-field-form-block-html_type">
106 <td class="label">{$form.html_type.label}</td>
107 <td>{$form.html_type.html}
108 </td>
109 </tr>
110 {if $action neq 4 and $action neq 2}
111 <tr>
112 <td>&nbsp;</td>
113 <td class="description">{ts}Select the html type used to offer options for this field{/ts}
114 </td>
115 </tr>
116 {/if}
117 </table>
118
119 <div class="spacer"></div>
120 <div id="price-block" {if $action eq 2 && $form.html_type.value.0 eq 'Text'} class="show-block" {else} class="hiddenElement" {/if}>
121 <table class="form-layout">
122 <tr class="crm-price-field-form-block-price">
123 <td class="label">{$form.price.label} <span class="crm-marker" title="{ts}This field is required.{/ts}">*</span></td>
124 <td>{$form.price.html}
125 {if $action neq 4}
126 <br /><span class="description">{ts}Unit price.{/ts}</span> {help id="id-negative"}
127 {/if}
128 </td>
129 </tr>
130 <tr class="crm-price-field-form-block-non-deductible-amount">
131 <td class="label">{$form.non_deductible_amount.label}</td>
132 <td>{$form.non_deductible_amount.html}</td>
133 </tr>
134 {if $useForEvent}
135 <tr class="crm-price-field-form-block-count">
136 <td class="label">{$form.count.label}</td>
137 <td>{$form.count.html}<br />
138 <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>
139 {help id="id-participant-count"}
140 </td>
141 </tr>
142 <tr class="crm-price-field-form-block-max_value">
143 <td class="label">{$form.max_value.label}</td>
144 <td>{$form.max_value.html}
145 </td>
146 </tr>
147 {/if}
148 <tr class="crm-price-field-form-block-financial_type">
149 <td class="label">{$form.financial_type_id.label}<span class="crm-marker" title="{ts}This field is required.{/ts}">*</span></td></td>
150 <td>
151 {if !$financialType}
152 {capture assign=ftUrl}{crmURL p='civicrm/admin/financial/financialType' q="reset=1"}{/capture}
153 {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}
154 {else}
155 {$form.financial_type_id.html}
156 {/if}
157 </td>
158 </tr>
159 </table>
160 </div>
161
162 {if $action eq 1}
163 {* Conditionally show table for setting up selection options - for field types = radio, checkbox or select *}
164 <div id='showoption' class="hiddenElement">{ include file="CRM/Price/Form/OptionFields.tpl"}</div>
165 {/if}
166 <table class="form-layout">
167 <tr id="optionsPerLine" class="crm-price-field-form-block-options_per_line">
168 <td class="label">{$form.options_per_line.label}</td>
169 <td>{$form.options_per_line.html|crmAddClass:two}</td>
170 </tr>
171 <tr class="crm-price-field-form-block-is_display_amounts">
172 <td class="label">{$form.is_display_amounts.label}</td>
173 <td>{$form.is_display_amounts.html}
174 {if $action neq 4}
175 <div class="description">{ts}Display amount next to each option? If no, then the amount should be in the option description.{/ts}</div>
176 {/if}
177 </td>
178 </tr>
179 <tr class="crm-price-field-form-block-weight">
180 <td class="label">{$form.weight.label}</td>
181 <td>{$form.weight.html|crmAddClass:two}
182 {if $action neq 4}
183 <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>
184 {/if}
185 </td>
186 </tr>
187
188 <tr class="crm-price-field-form-block-help_pre">
189 <td class="label">{$form.help_pre.label}</td>
190 <td>{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_price_field' field='help_pre' id=$fid}{/if}{$form.help_pre.html|crmAddClass:huge}&nbsp;
191 {if $action neq 4}
192 <div class="description">{ts}Explanatory text displayed to users at the beginning of this field.{/ts}</div>
193 {/if}
194 </td>
195 </tr>
196
197 <tr class="crm-price-field-form-block-help_post">
198 <td class="label">{$form.help_post.label}</td>
199 <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;
200 {if $action neq 4}
201 <div class="description">{ts}Explanatory text displayed to users below this field.{/ts}</div>
202 {/if}
203 </td>
204 </tr>
205
206 <tr class="crm-price-field-form-block-active_on">
207 <td class="label">{$form.active_on.label}</td>
208 <td>{include file="CRM/common/jcalendar.tpl" elementName=active_on}
209 {if $action neq 4}
210 <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>
211 {/if}
212 </td>
213 </tr>
214
215 <tr class="crm-price-field-form-block-expire_on">
216 <td class="label">{$form.expire_on.label}</td>
217 <td>{include file="CRM/common/jcalendar.tpl" elementName=expire_on}
218 {if $action neq 4}
219 <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>
220 {/if}
221 </td>
222 </tr>
223
224 <tr class="crm-price-field-form-block-is_required">
225 <td class="label">{$form.is_required.label}</td>
226 <td>&nbsp;{$form.is_required.html}</td>
227 </tr>
228 <tr class="crm-price-field-form-block-visibility_id">
229 <td class="label">{$form.visibility_id.label}</td>
230 <td>&nbsp;{$form.visibility_id.html} {help id="id-visibility"}</td>
231 </tr>
232 <tr class="crm-price-field-form-block-is_active">
233 <td class="label">{$form.is_active.label}</td>
234 <td>{$form.is_active.html}</td>
235 </tr>
236 </table>
237 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
238 </div>
239
240 {literal}
241 <script type="text/javascript">
242 option_html_type(this.form);
243 function calculateRowValues( row ) {
244 var mtype = cj("#membership_type_id_"+row).val();
245 var postUrl = "{/literal}{crmURL p='civicrm/ajax/memType' h=0}{literal}";
246
247 cj.post( postUrl, {mtype: mtype}, function(data) {
248 cj("#option_amount_"+ row).val(data.total_amount);
249 cj("#option_label_"+ row).val(data.name);
250 cj("#option_financial_type_id_"+ row).val(data.financial_type_id);
251 if (data.name) {
252 cj("#membership_num_terms_"+ row).val('1');
253 }
254 else {
255 cj("#membership_num_terms_"+ row).val('');
256 }
257 }, 'json');
258 }
259 </script>
260 {/literal}
261
262 {* Give link to view/edit choice options if in edit mode and html_type is one of the multiple choice types *}
263 {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') }
264 <div class="action-link">
265 <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>
266 </div>
267 {/if}
268