Merge pull request #10115 from jmcclelland/CRM-20388
[civicrm-core.git] / templates / CRM / Event / Form / ManageEvent / Fee.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.7 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2017 |
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="crm-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="crm-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 <tr>
105 <td class="extra-long-fourty label">{$form.is_billing_required.html}</td>
106 <td>
107 {$form.is_billing_required.label}<br />
108 <span class="description">{ts}Check this box to require users who select the pay later option to provide billing name and address.{/ts}</span>
109 </td>
110 </tr>
111 </table>
112
113 <table id="contributionType" class="form-layout">
114 <tr class="crm-event-manage-fee-form-block-fee_label">
115 <td class="label">{$form.fee_label.label}<span class="crm-marker"> *</span>
116 </td>
117 <td>{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='fee_label' id=$id}{/if}{$form.fee_label.html}
118 </td>
119 </tr>
120 <tr>
121 <td>&nbsp;</td>
122 <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}
123 </td>
124 </tr>
125 <tr class="crm-event-manage-fee-form-block-financial_type_id">
126 <td class="label">{$form.financial_type_id.label}<span class="crm-marker"> *</span></td>
127 <td>{$form.financial_type_id.html}</td>
128 </tr>
129 <tr>
130 <td>&nbsp;</td>
131 <td class="description">{ts}This financial type will be assigned to payments made by participants when they register online. If using a price set below note that the contribution record will have this financial type, however line items will be processed using the actual financial type selected for the price set item.{/ts}
132 </td>
133 </tr>
134 </table>
135
136 <table id="priceSet" class="form-layout">
137 <tr class="crm-event-manage-fee-form-block-price_set_id">
138 <td class="label">{$form.price_set_id.label}</td>
139 <td>{if $price eq false}
140 <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>
141 {else}
142 {$form.price_set_id.html}
143 </td>
144 </tr>
145 <tr>
146 <td>&nbsp;</td>
147 <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}
148 {/if}
149 </td>
150 </tr>
151 </table>
152
153 <div id="map-field" >
154 <fieldset id="map-field"><legend>{ts}Regular Fees{/ts}</legend>
155 {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 />
156 {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}
157 <table id="map-field-table">
158 <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>
159 {section name=loop start=1 loop=11}
160 {assign var=idx value=$smarty.section.loop.index}
161 <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>
162 {/section}
163 </table>
164 </fieldset>
165
166 <div id="isDiscount">
167 <table class="form-layout">
168 <tr class="crm-event-manage-fee-form-block-is_discount">
169 <td class="extra-long-fourty label">{$form.is_discount.html}</td>
170 <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>
171 </td>
172 </tr>
173 </table>
174 </div>
175 <div class="spacer"></div>
176 <div>
177 <fieldset id="discount">
178 <table>
179 <tr class="columnheader">
180 <td>&nbsp;</th>
181 <td>{ts}Discount Set{/ts}</td>
182 <td>{ts}Start Date{/ts}</td>
183 <td>{ts}End Date{/ts}</td>
184 </tr>
185
186 {section name=rowLoop start=1 loop=6}
187 {assign var=index value=$smarty.section.rowLoop.index}
188 <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"}">
189 <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}
190 </td>
191 <td class="crm-event-manage-fee-form-block-discount_name"> {$form.discount_name.$index.html}</td>
192 <td class="crm-event-manage-fee-form-block-discount_start_date"> {include file="CRM/common/jcalendar.tpl" elementName='discount_start_date' elementIndex=$index} </td>
193 <td class="crm-event-manage-fee-form-block-discount_end_date"> {include file="CRM/common/jcalendar.tpl" elementName='discount_end_date' elementIndex=$index} </td>
194 </tr>
195 {/section}
196 </table>
197 <div id="discountLink" class="add-remove-link">
198 <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>
199 </div>
200 {$form._qf_Fee_submit.html}
201
202 {if $discountSection}
203 <fieldset id="map-field"><legend>{ts}Discounted Fees{/ts}</legend>
204 <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>
205 <table id="map-field-table">
206 <tr class="columnheader">
207 <td scope="column">{ts}Fee Label{/ts}</td>
208 {section name=dloop start=1 loop=6}
209 {assign var=i value=$smarty.section.dloop.index}
210 {if $form.discount_name.$i.value}
211 <td scope="column">{$form.discount_name.$i.value}</td>
212 {/if}
213 {/section}
214 <td scope="column">{ts}Default?{/ts}</td>
215 </tr>
216
217 {section name=loop start=1 loop=11}
218 {assign var=idx value=$smarty.section.loop.index}
219 <tr><td class="even-row">{$form.discounted_label.$idx.html}</td>
220 {section name=loop1 start=1 loop=6}
221 {assign var=idy value=$smarty.section.loop1.index}
222 {if $form.discount_name.$idy.value}
223 <td>{$form.discounted_value.$idx.$idy.html|crmMoney}</td>
224 {/if}
225 {/section}
226 <td class="even-row">{$form.discounted_default.$idx.html}</td>
227 </tr>
228 {/section}
229 </table>
230 </fieldset>
231 {if $discountSection eq 2}
232 <script type="text/javascript">
233 {literal}
234 CRM.$(function($) {
235 $('#discounted_label_1').focus( );
236 });
237 {/literal}
238 </script>
239 {/if}
240 {/if}
241 </fieldset>
242 </div>
243 </div>
244 </div>
245 <div class="crm-submit-buttons">
246 {include file="CRM/common/formButtons.tpl" location="bottom"}
247 </div>
248 </div>
249
250 {include file="CRM/common/deferredFinancialType.tpl" context='Event'}
251 {include file="CRM/common/showHide.tpl"}
252 <script type="text/javascript">
253 {if $price}
254 {literal}
255 // Re-show Fee Level grid if Price Set select has been set to none.
256 if (cj('#price_set_id').val() == '') {
257 cj('#map-field').show();
258 }
259 {/literal}
260 {/if}
261 {literal}
262
263 if ( document.getElementsByName('is_monetary')[0].checked ) {
264 cj('#event-fees').show();
265 }
266
267 function warnDiscountDel( ) {
268 if ( ! document.getElementsByName('is_discount')[0].checked ) {
269 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});
270 }
271 }
272
273 /**
274 * Function used to show /hide discount and set defaults
275 */
276 function showHideDiscountRow( rowName, show, index ) {
277 if ( show ) {
278 // show first hidden element and set date default
279 var counter = 0;
280 cj('tr[id^=' + rowName + ']').each( function( i ) {
281 counter++;
282 if ( cj(this).css('display') == 'none' ) {
283 cj(this).show( );
284
285 // set default
286 var currentRowId = cj(this).attr('id');
287 var temp = currentRowId.split('_');
288 var currentElementID = temp[1];
289 var lastElementID = currentElementID - 1 ;
290
291 var lastEndDate = cj( '#discount_end_date_' + lastElementID ).datepicker( 'getDate' );
292 if ( lastEndDate ) {
293 var discountDate = new Date( Date.parse( lastEndDate ) );
294 discountDate.setDate( discountDate.getDate() + 1 );
295 var newDate = discountDate.toDateString();
296 newDate = new Date( Date.parse( newDate ) );
297 cj( '#discount_start_date_' + currentElementID ).datepicker('setDate', newDate );
298 }
299
300 if ( counter == 5 ) {
301 cj('#discountLink').hide( );
302 }
303 return false;
304 }
305 });
306 } else {
307 // hide tr and clear dates
308 cj( '#discount_end_date_' + index ).val('');
309 cj( '#discount_name_' + index ).val('');
310 cj( '#discount_start_date_' + index ).val('');
311 cj( '#' + rowName ).hide( );
312 cj('#discountLink').show( );
313 }
314 }
315
316 {/literal}
317 </script>
318
319
320 {include file="CRM/common/showHideByFieldValue.tpl"
321 trigger_field_id ="is_pay_later"
322 trigger_value =""
323 target_element_id ="payLaterOptions"
324 target_element_type ="block"
325 field_type ="radio"
326 invert = 0
327 }
328 {if $price }
329 {include file="CRM/common/showHideByFieldValue.tpl"
330 trigger_field_id ="price_set_id"
331 trigger_value =""
332 target_element_id ="map-field"
333 target_element_type ="block"
334 field_type ="select"
335 invert = 0
336 }
337 {/if}
338 {include file="CRM/common/showHideByFieldValue.tpl"
339 trigger_field_id ="is_discount"
340 trigger_value =""
341 target_element_id ="discount"
342 target_element_type ="block"
343 field_type ="radio"
344 invert = 0
345 }
346
347 {if $isQuick}
348 {literal}
349 <script type="text/javascript">
350 CRM.$(function($) {
351 $("#quickconfig").click(function(e) {
352 e.preventDefault();
353 CRM.confirm({
354 width: 400,
355 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}
356 }).on('crmConfirm:yes', function() {
357 {/literal}
358 var dataUrl = '{crmURL p="civicrm/ajax/rest" h=0 q="className=CRM_Core_Page_AJAX&fnName=setIsQuickConfig&context=civicrm_event&id=$eventId" }';
359 {literal}
360 $.getJSON(dataUrl).done(function(result) {window.location = CRM.url("civicrm/admin/price/field", {reset: 1, action: 'browse', sid: result});});
361 });
362 });
363 });
364 </script>
365 {/literal}
366 {/if}