Merge remote-tracking branch 'upstream/4.3' into 4.3-4.4-2013-11-11-10-44-51
[civicrm-core.git] / templates / CRM / Price / Form / Field.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.4 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2013 |
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 = document.getElementById("html_type");
31 var html_type_name = html_type.options[html_type.selectedIndex].value;
32
33 if (html_type_name == "Text") {
34 document.getElementById("price-block").style.display="block";
35 document.getElementById("showoption").style.display="none";
36
37 }
38 else {
39 document.getElementById("price-block").style.display="none";
40 document.getElementById("showoption").style.display="block";
41 }
42
43 if (html_type_name == 'Radio' || html_type_name == 'CheckBox') {
44 cj("#optionsPerLine").show( );
45 }
46 else {
47 cj("#optionsPerLine").hide( );
48 cj("#optionsPerLineDef").hide( );
49 }
50
51 var radioOption, checkBoxOption;
52
53 for (var i=1; i<=15; i++) {
54 radioOption = 'radio'+i;
55 checkBoxOption = 'checkbox'+i
56 if (html_type_name == 'Radio' || html_type_name == 'CheckBox' || html_type_name == 'Select') {
57 if (html_type_name == "CheckBox") {
58 document.getElementById(checkBoxOption).style.display="block";
59 document.getElementById(radioOption).style.display="none";
60 }
61 else {
62 document.getElementById(radioOption).style.display="block";
63 document.getElementById(checkBoxOption).style.display="none";
64 }
65 }
66 }
67
68 }
69 </script>
70 {/literal}
71 <h3>{if $action eq 1}{ts}Add Field{/ts}{elseif $action eq 2}{ts}Edit Field{/ts}{/if}</h3>
72 <div class="crm-block crm-form-block crm-price-field-form-block">
73 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
74 <table class="form-layout">
75 <tr class="crm-price-field-form-block-label">
76 <td class="label">{$form.label.label}</td>
77 <td>{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_price_field' field='label' id=$fid}{/if}{$form.label.html}
78 </td>
79 </tr>
80 <tr class="crm-price-field-form-block-html_type">
81 <td class="label">{$form.html_type.label}</td>
82 <td>{$form.html_type.html}
83 </td>
84 </tr>
85 {if $action neq 4 and $action neq 2}
86 <tr>
87 <td>&nbsp;</td>
88 <td class="description">{ts}Select the html type used to offer options for this field{/ts}
89 </td>
90 </tr>
91 {/if}
92 </table>
93
94 <div class="spacer"></div>
95 <div id="price-block" {if $action eq 2 && $form.html_type.value.0 eq 'Text'} class="show-block" {else} class="hide-block" {/if}>
96 <table class="form-layout">
97 <tr class="crm-price-field-form-block-price">
98 <td class="label">{$form.price.label} <span class="crm-marker" title="{ts}This field is required.{/ts}">*</span></td>
99 <td>{$form.price.html}
100 {if $action neq 4}
101 <br /><span class="description">{ts}Unit price.{/ts}</span> {help id="id-negative"}
102 {/if}
103 </td>
104 </tr>
105 {if $useForEvent}
106 <tr class="crm-price-field-form-block-count">
107 <td class="label">{$form.count.label}</td>
108 <td>{$form.count.html}<br />
109 <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>
110 {help id="id-participant-count"}
111 </td>
112 </tr>
113 <tr class="crm-price-field-form-block-max_value">
114 <td class="label">{$form.max_value.label}</td>
115 <td>{$form.max_value.html}
116 </td>
117 </tr>
118 {/if}
119 <tr class="crm-price-field-form-block-financial_type">
120 <td class="label">{$form.financial_type_id.label}<span class="crm-marker" title="{ts}This field is required.{/ts}">*</span></td></td>
121 <td>
122 {if !$financialType}
123 {capture assign=ftUrl}{crmURL p='civicrm/admin/financial/financialType' q="reset=1"}{/capture}
124 {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}
125 {else}
126 {$form.financial_type_id.html}
127 {/if}
128 </td>
129 </tr>
130 </table>
131 </div>
132
133 {if $action eq 1}
134 {* Conditionally show table for setting up selection options - for field types = radio, checkbox or select *}
135 <div id='showoption' class="hide-block">{ include file="CRM/Price/Form/OptionFields.tpl"}</div>
136 {/if}
137 <table class="form-layout">
138 <tr id="optionsPerLine" class="crm-price-field-form-block-options_per_line">
139 <td class="label">{$form.options_per_line.label}</td>
140 <td>{$form.options_per_line.html|crmAddClass:two}</td>
141 </tr>
142 <tr class="crm-price-field-form-block-is_display_amounts">
143 <td class="label">{$form.is_display_amounts.label}</td>
144 <td>{$form.is_display_amounts.html}
145 {if $action neq 4}
146 <div class="description">{ts}Display amount next to each option? If no, then the amount should be in the option description.{/ts}</div>
147 {/if}
148 </td>
149 </tr>
150 <tr class="crm-price-field-form-block-weight">
151 <td class="label">{$form.weight.label}</td>
152 <td>{$form.weight.html|crmAddClass:two}
153 {if $action neq 4}
154 <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>
155 {/if}
156 </td>
157 </tr>
158
159 <tr class="crm-price-field-form-block-help_post">
160 <td class="label">{$form.help_post.label}</td>
161 <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;
162 {if $action neq 4}
163 <div class="description">{ts}Explanatory text displayed to users for this field.{/ts}</div>
164 {/if}
165 </td>
166 </tr>
167
168 <tr class="crm-price-field-form-block-active_on">
169 <td class="label">{$form.active_on.label}</td>
170 <td>{include file="CRM/common/jcalendar.tpl" elementName=active_on}
171 {if $action neq 4}
172 <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>
173 {/if}
174 </td>
175 </tr>
176
177 <tr class="crm-price-field-form-block-expire_on">
178 <td class="label">{$form.expire_on.label}</td>
179 <td>{include file="CRM/common/jcalendar.tpl" elementName=expire_on}
180 {if $action neq 4}
181 <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>
182 {/if}
183 </td>
184 </tr>
185
186 <tr class="crm-price-field-form-block-is_required">
187 <td class="label">{$form.is_required.label}</td>
188 <td>&nbsp;{$form.is_required.html}</td>
189 </tr>
190 <tr class="crm-price-field-form-block-visibility_id">
191 <td class="label">{$form.visibility_id.label}</td>
192 <td>&nbsp;{$form.visibility_id.html} {help id="id-visibility"}</td>
193 </tr>
194 <tr class="crm-price-field-form-block-is_active">
195 <td class="label">{$form.is_active.label}</td>
196 <td>{$form.is_active.html}</td>
197 </tr>
198 </table>
199 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
200 </div>
201
202 {literal}
203 <script type="text/javascript">
204 option_html_type(this.form);
205 function calculateRowValues( row ) {
206 var mtype = cj("#membership_type_id_"+row).val();
207 var postUrl = "{/literal}{crmURL p='civicrm/ajax/memType' h=0}{literal}";
208
209 cj.post( postUrl, {mtype: mtype}, function(data) {
210 cj("#option_amount_"+ row).val(data.total_amount);
211 cj("#option_label_"+ row).val(data.name);
212 cj("#option_financial_type_id_"+ row).val(data.financial_type_id);
213 if (data.name) {
214 cj("#membership_num_terms_"+ row).val('1');
215 }
216 else {
217 cj("#membership_num_terms_"+ row).val('');
218 }
219 }, 'json');
220 }
221 </script>
222 {/literal}
223
224 {* Give link to view/edit choice options if in edit mode and html_type is one of the multiple choice types *}
225 {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') }
226 <div class="action-link">
227 <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>
228 </div>
229 {/if}
230