Cleanup tpl js for switching to a price set
[civicrm-core.git] / templates / CRM / Event / Form / ManageEvent / Fee.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.5 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2014 |
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 {* this template is used for adding event *}
27 {capture assign="adminPriceSets"}{crmURL p='civicrm/admin/price' q="reset=1"}{/capture}
28 {if !$paymentProcessor}
29 {capture assign=ppUrl}{crmURL p='civicrm/admin/paymentProcessor' q="reset=1"}{/capture}
30 <div class="status message">
31 {ts 1=$ppUrl}No Payment Processor has been configured / enabled for your site. If this is a <strong>paid event</strong> AND you want users to be able to <strong>register and pay online</strong>, you will need to <a href='%1'>configure a Payment Processor</a> first. Then return to this screen and assign the processor to this event.{/ts} {docURL page="user/contributions/payment-processors"}
32 <p>{ts}NOTE: Alternatively, you can enable the <strong>Pay Later</strong> option below without setting up a payment processor. All users will then be asked to submit payment offline (e.g. mail in a check, call in a credit card, etc.).{/ts}</p>
33 </div>
34 {/if}
35 <div class="crm-block crm-form-block crm-event-manage-fee-form-block">
36 <div class="crm-submit-buttons">
37 {include file="CRM/common/formButtons.tpl" location="top"}
38 </div>
39
40 <table class="form-layout">
41 <tr class="crm-event-manage-fee-form-block-title">
42 <td class="label">{$form.title.label}</td>
43 <td>{$form.title.html}</td>
44 </tr>
45 <tr class="crm-event-manage-fee-form-block-is_monetary">
46 <td class="label">{$form.is_monetary.label}</td>
47 <td>{$form.is_monetary.html}</td>
48 </tr>
49 </table>
50
51 <div id="event-fees">
52 <table id="currency" class="form-layout">
53 <tr class='crm-event-manage-fee-form-block-currency'>
54 <td class="label">{$form.currency.label}</td>
55 <td>{$form.currency.html}<br />
56 <span class="description">{ts}Select the currency to be used for event registration.{/ts}</span>
57 </td>
58 </tr>
59 </table>
60 {if $paymentProcessor}
61 <table id="paymentProcessor" class="form-layout">
62 <tr class="crm-event-manage-fee-form-block-payment_processor">
63 <td class="label">{$form.payment_processor.label}</td>
64 <td>{$form.payment_processor.html}</td>
65 </tr>
66 <tr>
67 <td class="">&nbsp;</td>
68 <td class="description">
69 {ts}If this is a paid event and you want users to be able to register and pay online, select a payment processor to use.{/ts}
70 {ts}NOTE: Alternatively, you can enable the <strong>Pay Later</strong> feature below without setting up a payment processor. All users will then be asked to submit payment offline (e.g. mail in a check, call in a credit card, etc.).{/ts} {docURL page="user/contributions/payment-processors"}<td>
71 </tr>
72 </table>
73 {/if}
74
75 <table id="payLater" class="form-layout">
76 <tr class="crm-event-manage-fee-form-block-is_pay_later">
77 <td class="extra-long-fourty label">{$form.is_pay_later.html}</td>
78 <td>{$form.is_pay_later.label}<br />
79 <span class="description">{ts}Check this box if you want to give users the option to submit payment offline (e.g. mail in a check, call in a credit card, etc.).{/ts}</span>
80 </td>
81 </tr>
82 </table>
83
84 <table id="payLaterOptions" class="form-layout">
85 <tr class="crm-event-manage-fee-form-block-pay_later_text">
86 <td class="label">{$form.pay_later_text.label}<span class="marker"> *</span> </td>
87 <td>{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='pay_later_text' id=$id}{/if}{$form.pay_later_text.html|crmAddClass:big}
88 </td>
89 </tr>
90 <tr>
91 <td>&nbsp;</td>
92 <td class="description">{ts}Text displayed next to the checkbox for the 'pay later' option on the contribution form. You may include HTML formatting tags.{/ts}</td>
93 </tr>
94 <tr class="crm-event-manage-fee-form-block-pay_later_receipt">
95 <td class="label">{$form.pay_later_receipt.label}<span class="marker"> *</span> </td>
96 <td>{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='pay_later_receipt' id=$id}{/if}{$form.pay_later_receipt.html|crmAddClass:big}
97 </td>
98 </tr>
99 <tr>
100 <td>&nbsp;</td>
101 <td class="description">{ts}Instructions added to Confirmation and Thank-you pages when the user selects the 'pay later' option (e.g. 'Mail your check to ... within 3 business days.').{/ts}
102 </td>
103 </tr>
104
105 </table>
106
107 <table id="contributionType" class="form-layout">
108 <tr class="crm-event-manage-fee-form-block-fee_label">
109 <td class="label">{$form.fee_label.label}<span class="marker"> *</span>
110 </td>
111 <td>{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='fee_label' id=$id}{/if}{$form.fee_label.html}
112 </td>
113 </tr>
114 <tr>
115 <td>&nbsp;</td>
116 <td class="description">{ts}This label is displayed with the list of event fees. When using a Price Set, this label is the title for the section containing the price fields.{/ts}
117 </td>
118 </tr>
119 <tr class="crm-event-manage-fee-form-block-financial_type_id">
120 <td class="label">{$form.financial_type_id.label}<span class="marker"> *</span></td>
121 <td>{$form.financial_type_id.html}</td>
122 </tr>
123 <tr>
124 <td>&nbsp;</td>
125 <td class="description">{ts}This financial type will be assigned to payments made by participants when they register online.{/ts}
126 </td>
127 </tr>
128 </table>
129
130 <table id="priceSet" class="form-layout">
131 <tr class="crm-event-manage-fee-form-block-price_set_id">
132 <td class="label">{$form.price_set_id.label}</td>
133 <td>{if $price eq false}
134 <div class="status message">{ts 1=$adminPriceSets}No Price Set has been configured / enabled for your site. Price sets allow you to meet the complex demands of your event registration structure.(e.g. "Pay $15 more for lunch."). Click <a href='%1'>here</a> if you want to configure price sets for your site.{/ts}</div>
135 {else}
136 {$form.price_set_id.html}
137 </td>
138 </tr>
139 <tr>
140 <td>&nbsp;</td>
141 <td class="description">{ts 1=$adminPriceSets}Select a pre-configured Price Set to offer multiple individually priced options for event registrants. Otherwise, select &quot;-none-&quot; and enter one or more fee levels in the table below. Create or edit Price Sets <a href='%1'>here</a>.{/ts}
142 {/if}
143 </td>
144 </tr>
145 </table>
146
147 <div id="map-field" >
148 <fieldset id="map-field"><legend>{ts}Regular Fees{/ts}</legend>
149 {ts}Use the table below to enter descriptive labels and amounts for up to ten event fee levels. These will be presented as a list of radio button options. Both the label and dollar amount will be displayed. You can also configure one or more sets of discounted fees by checking "Discounts by Signup Date" below.{/ts}<br />
150 {if $isQuick}{ts}Click <a id='quickconfig' href='#'>here</a> if you want to configure the Regular Fees below as part of a Price Set, with the added flexibility and complexity that entails.{/ts}{/if}
151 <table id="map-field-table">
152 <tr class="columnheader"><td scope="column">{ts}Fee Label{/ts}</td><td scope="column">{ts}Amount{/ts}</td><td scope="column">{ts}Default?{/ts}<br />{$form.default.0.html}</td></tr>
153 {section name=loop start=1 loop=11}
154 {assign var=idx value=$smarty.section.loop.index}
155 <tr><td class="even-row crm-event-manage-fee-form-block-label_{$idx}">{$form.label.$idx.html}</td><td class="crm-event-manage-fee-form-block-value_{$idx}">{$form.value.$idx.html|crmMoney}</td><td class="even-row crm-event-manage-fee-form-block-default_{$idx}">{$form.default.$idx.html}</td></tr>
156 {/section}
157 </table>
158 </fieldset>
159
160 <div id="isDiscount">
161 <table class="form-layout">
162 <tr class="crm-event-manage-fee-form-block-is_discount">
163 <td class="extra-long-fourty label">{$form.is_discount.html}</td>
164 <td>{$form.is_discount.label}<br /><span class="description">{ts}Check this box if you want to offer discounted fees based on registration date (e.g. 'early-registration discounts').{/ts}</span>
165 </td>
166 </tr>
167 </table>
168 </div>
169 <div class="spacer"></div>
170 <div>
171 <fieldset id="discount">
172 <table>
173 <tr class="columnheader">
174 <td>&nbsp;</th>
175 <td>{ts}Discount Set{/ts}</td>
176 <td>{ts}Start Date{/ts}</td>
177 <td>{ts}End Date{/ts}</td>
178 </tr>
179
180 {section name=rowLoop start=1 loop=6}
181 {assign var=index value=$smarty.section.rowLoop.index}
182 <tr id="discount_{$index}" class=" crm-event-manage-fee-form-block-discount_{$index} {if $index GT 1 AND empty( $form.discount_name[$index].value) } hiddenElement {/if} form-item {cycle values="odd-row,even-row"}">
183 <td>{if $index GT 1} <a onclick="showHideDiscountRow('discount_{$index}', false, {$index}); return false;" name="discount_{$index}" href="#" class="form-link"><img src="{$config->resourceBase}i/TreeMinus.gif" class="action-icon" alt="{ts}hide field or section{/ts}"/></a>{/if}
184 </td>
185 <td class="crm-event-manage-fee-form-block-discount_name"> {$form.discount_name.$index.html}</td>
186 <td class="crm-event-manage-fee-form-block-discount_start_date"> {include file="CRM/common/jcalendar.tpl" elementName='discount_start_date' elementIndex=$index} </td>
187 <td class="crm-event-manage-fee-form-block-discount_end_date"> {include file="CRM/common/jcalendar.tpl" elementName='discount_end_date' elementIndex=$index} </td>
188 </tr>
189 {/section}
190 </table>
191 <div id="discountLink" class="add-remove-link">
192 <a onclick="showHideDiscountRow( 'discount', true);return false;" id="discountLink" href="#" class="form-link"><img src="{$config->resourceBase}i/TreePlus.gif" class="action-icon" alt="{ts}show field or section{/ts}"/>{ts}another discount set{/ts}</a>
193 </div>
194 {$form._qf_Fee_submit.html}
195
196 {if $discountSection}
197 <fieldset id="map-field"><legend>{ts}Discounted Fees{/ts}</legend>
198 <p>{ts}Use the table below to enter descriptive labels and amounts for up to ten discounted event fees for each discount set. <strong>Don't forget to click 'Save' when you are finished.</strong>{/ts}</p>
199 <table id="map-field-table">
200 <tr class="columnheader">
201 <td scope="column">{ts}Fee Label{/ts}</td>
202 {section name=dloop start=1 loop=6}
203 {assign var=i value=$smarty.section.dloop.index}
204 {if $form.discount_name.$i.value}
205 <td scope="column">{$form.discount_name.$i.value}</td>
206 {/if}
207 {/section}
208 <td scope="column">{ts}Default?{/ts}</td>
209 </tr>
210
211 {section name=loop start=1 loop=11}
212 {assign var=idx value=$smarty.section.loop.index}
213 <tr><td class="even-row">{$form.discounted_label.$idx.html}</td>
214 {section name=loop1 start=1 loop=6}
215 {assign var=idy value=$smarty.section.loop1.index}
216 {if $form.discount_name.$idy.value}
217 <td>{$form.discounted_value.$idx.$idy.html|crmMoney}</td>
218 {/if}
219 {/section}
220 <td class="even-row">{$form.discounted_default.$idx.html}</td>
221 </tr>
222 {/section}
223 </table>
224 </fieldset>
225 {if $discountSection eq 2}
226 <script type="text/javascript">
227 {literal}
228 CRM.$(function($) {
229 $('#discounted_label_1').focus( );
230 });
231 {/literal}
232 </script>
233 {/if}
234 {/if}
235 </fieldset>
236 </div>
237 </div>
238 </div>
239 <div class="crm-submit-buttons">
240 {include file="CRM/common/formButtons.tpl" location="bottom"}
241 </div>
242 </div>
243
244 {include file="CRM/common/showHide.tpl"}
245 <script type="text/javascript">
246 {if $price}
247 {literal}
248 // Re-show Fee Level grid if Price Set select has been set to none.
249 if (cj('#price_set_id').val() == '') {
250 cj('#map-field').show();
251 }
252 {/literal}
253 {/if}
254 {literal}
255
256 if ( document.getElementsByName('is_monetary')[0].checked ) {
257 cj('#event-fees').show();
258 }
259
260 function warnDiscountDel( ) {
261 if ( ! document.getElementsByName('is_discount')[0].checked ) {
262 CRM.alert('{/literal}{ts escape="js"}If you uncheck "Discounts by Signup Date" and Save this form, any existing discount sets will be deleted.{/ts} {ts escape="js"}This action cannot be undone.{/ts} {ts escape="js"}If this is NOT what you want to do, you can check "Discounts by Signup Date" again.{/ts}', '{ts escape="js}Warning{/ts}{literal}', 'alert', {expires: 0});
263 }
264 }
265
266 /**
267 * Function used to show /hide discount and set defaults
268 */
269 function showHideDiscountRow( rowName, show, index ) {
270 if ( show ) {
271 // show first hidden element and set date default
272 var counter = 0;
273 cj('tr[id^=' + rowName + ']').each( function( i ) {
274 counter++;
275 if ( cj(this).css('display') == 'none' ) {
276 cj(this).show( );
277
278 // set default
279 var currentRowId = cj(this).attr('id');
280 var temp = currentRowId.split('_');
281 var currentElementID = temp[1];
282 var lastElementID = currentElementID - 1 ;
283
284 var lastEndDate = cj( '#discount_end_date_' + lastElementID ).datepicker( 'getDate' );
285 if ( lastEndDate ) {
286 var discountDate = new Date( Date.parse( lastEndDate ) );
287 discountDate.setDate( discountDate.getDate() + 1 );
288 var newDate = discountDate.toDateString();
289 newDate = new Date( Date.parse( newDate ) );
290 cj( '#discount_start_date_' + currentElementID ).datepicker('setDate', newDate );
291 }
292
293 if ( counter == 5 ) {
294 cj('#discountLink').hide( );
295 }
296 return false;
297 }
298 });
299 } else {
300 // hide tr and clear dates
301 cj( '#discount_end_date_' + index ).val('');
302 cj( '#discount_name_' + index ).val('');
303 cj( '#discount_start_date_' + index ).val('');
304 cj( '#' + rowName ).hide( );
305 cj('#discountLink').show( );
306 }
307 }
308
309 {/literal}
310 </script>
311
312
313 {include file="CRM/common/showHideByFieldValue.tpl"
314 trigger_field_id ="is_pay_later"
315 trigger_value =""
316 target_element_id ="payLaterOptions"
317 target_element_type ="block"
318 field_type ="radio"
319 invert = 0
320 }
321 {if $price }
322 {include file="CRM/common/showHideByFieldValue.tpl"
323 trigger_field_id ="price_set_id"
324 trigger_value =""
325 target_element_id ="map-field"
326 target_element_type ="block"
327 field_type ="select"
328 invert = 0
329 }
330 {/if}
331 {include file="CRM/common/showHideByFieldValue.tpl"
332 trigger_field_id ="is_discount"
333 trigger_value =""
334 target_element_id ="discount"
335 target_element_type ="block"
336 field_type ="radio"
337 invert = 0
338 }
339
340 {if $isQuick}
341 {literal}
342 <script type="text/javascript">
343 CRM.$(function($) {
344 $("#quickconfig").click(function(e) {
345 e.preventDefault();
346 CRM.confirm({
347 width: 400.
348 message: {/literal}"{ts escape='js'}Once you switch to using a Price Set, you won't be able to switch back to your existing settings below except by re-entering them. Are you sure you want to switch to a Price Set?{/ts}"{literal}
349 }).on('crmConfirm:yes', function() {
350 {/literal}
351 var dataUrl = '{crmURL p="civicrm/ajax/rest" h=0 q="className=CRM_Core_Page_AJAX&fnName=setIsQuickConfig&context=civicrm_event&id=$eventId" }';
352 {literal}
353 $.getJSON(dataUrl).done(function(result) {window.location = CRM.url("civicrm/admin/price/field", {reset: 1, action: 'browse', sid: result});});
354 });
355 });
356 });
357 </script>
358 {/literal}
359 {/if}