2 +--------------------------------------------------------------------+
3 | Copyright CiviCRM LLC. All rights reserved. |
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 +--------------------------------------------------------------------+
10 {*Javascript function controls showing and hiding of form elements based on html type.*}
12 <script type="text/Javascript">
13 function option_html_type(form) {
14 var html_type_name = cj('#html_type').val();
16 if (html_type_name == "Text") {
17 cj("#price-block").show();
18 cj("#showoption").hide();
22 cj("#price-block").hide();
23 cj("#showoption").show();
26 if (html_type_name == 'Radio' || html_type_name == 'CheckBox') {
27 cj("#optionsPerLine").show( );
30 cj("#optionsPerLine").hide( );
31 cj("#optionsPerLineDef").hide( );
34 var radioOption, checkBoxOption;
36 for (var i=1; i<=15; i++) {
37 radioOption = '#radio'+i;
38 checkBoxOption = '#checkbox'+i;
39 if (html_type_name == 'Radio' || html_type_name == 'CheckBox' || html_type_name == 'Select') {
40 if (html_type_name == "CheckBox") {
41 cj(checkBoxOption).show();
42 cj(radioOption).hide();
45 cj(radioOption).show();
46 cj(checkBoxOption).hide();
53 var adminVisibilityID = 0;
54 cj('#visibility_id').on('change', function () {
55 if (adminVisibilityID == 0) {
56 CRM.api3('OptionValue', 'getvalue', {
59 'option_group_id': 'visibility',
61 }).done(function(result) {
62 adminVisibilityID = result.result;
63 if (cj('#visibility_id').val() == adminVisibilityID) {
64 updateVisibilitySelects(adminVisibilityID);
68 if (cj('#visibility_id').val() == adminVisibilityID) {
69 updateVisibilitySelects(adminVisibilityID);
74 function updateVisibilitySelects(value) {
75 for (var i=1; i<=15; i++) {
76 cj('#option_visibility_id_' + i).val(value);
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}
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}
94 {if $action neq 4 and $action neq 2}
97 <td class="description">{ts}Select the html type used to offer options for this field{/ts}
103 <div class="spacer"></div>
104 <div id="price-block" {if $action eq 2 && $form.html_type.value.0 eq 'Text'} class="show-block" {else} class="hiddenElement" {/if}>
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}
110 <br /><span class="description">{ts}Unit price.{/ts}</span> {help id="id-negative"}
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>
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"}
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}
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>
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}
139 {$form.financial_type_id.html}
147 {* Conditionally show table for setting up selection options - for field types = radio, checkbox or select *}
148 <div id='showoption' class="hiddenElement">{ include file="CRM/Price/Form/OptionFields.tpl"}</div>
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>
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}
159 <div class="description">{ts}Display amount next to each option? If no, then the amount should be in the option description.{/ts}</div>
163 <tr class="crm-price-field-form-block-weight">
164 <td class="label">{$form.weight.label}</td>
165 <td>{$form.weight.html|crmAddClass:two}
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>
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}
176 <div class="description">{ts}Explanatory text displayed to users at the beginning of this field.{/ts}</div>
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}
185 <div class="description">{ts}Explanatory text displayed to users below this field.{/ts}</div>
190 <tr class="crm-price-field-form-block-active_on">
191 <td class="label">{$form.active_on.label}</td>
192 <td>{$form.active_on.html}
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>
199 <tr class="crm-price-field-form-block-expire_on">
200 <td class="label">{$form.expire_on.label}</td>
201 <td>{$form.expire_on.html}
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>
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>
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>
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>
221 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
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}";
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);
236 cj("#membership_num_terms_"+ row).val('1');
239 cj("#membership_num_terms_"+ row).val('');
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>