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