Merge pull request #17981 from eileenmcnaughton/merge_form
[civicrm-core.git] / templates / CRM / Contribute / Form / ContributionPage / AddProduct.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | Copyright CiviCRM LLC. All rights reserved. |
4 | |
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 +--------------------------------------------------------------------+
9 *}
10 {crmRegion name="contribute-form-contributionpage-addproduct-main"}
11 {capture assign=managePremiumsURL}{crmURL p='civicrm/admin/contribute/managePremiums' q="reset=1"}{/capture}
12 <h3>{if $action eq 2 }{ts}Add Products to This Page{/ts} {elseif $action eq 1024}{ts}Preview{/ts}{else} {ts}Remove Products from this Page{/ts}{/if}</h3>
13 <div class="crm-block crm-form-block crm-contribution-add_product-form-block">
14 <div class="help">
15 {if $action eq 1024}
16 {ts}This is a preview of this product as it will appear on your Contributions page(s).{/ts}
17 {else}
18 {ts}Use this form to select a premium to be offered on this Online Contribution Page.{/ts}
19 {/if}
20 </div>
21
22 {if $action eq 8}
23 <div class="messages status no-popup">
24 {icon icon="fa-info-circle"}{/icon}
25 {ts}Are you sure you want to remove this premium product from this Contribution page?{/ts}
26 </div>
27 {elseif $action eq 1024}
28 {include file="CRM/Contribute/Form/Contribution/PremiumBlock.tpl"}
29 {else}
30 <table class="form-layout-compressed">
31 <tr class="crm-contribution-form-block-product_id"><td class="label">{$form.product_id.label}</td><td class="html-adjust">{$form.product_id.html}<br />
32 <span class="description">{ts 1=$managePremiumsURL}Pick a premium to include on this Contribution Page. Use <a href='%1'>Manage Premiums</a> to create or enable additional premium choices for your site.{/ts}</span></td></tr>
33 <tr class="crm-contribution-form-block-financial_type">
34 <td class="label">{$form.financial_type_id.label}</td>
35 <td>
36 {if !$financialType }
37 {capture assign=ftUrl}{crmURL p='civicrm/admin/financial/financialType' q="reset=1"}{/capture}
38 {ts 1=$ftUrl}There are no financial types configured with linked 'Cost of Sales Premiums' and 'Premiums Inventory Account' accounts. If you want to generate accounting transactions which track the cost of premiums used <a href='%1'>click here</a> to configure financial types and accounts.{/ts}
39 {else}
40 {$form.financial_type_id.html} {help id="id-financial_type-product"} <a name='resetfinancialtype' id="resetfinancialtype" style="display: none;">{ts}Reset to default for selected product{/ts}</a>
41 {/if}
42 </td>
43 </tr>
44 <tr class="crm-contribution-form-block-weight"><td class="label">{$form.weight.label}</td><td class="html-adjust">{$form.weight.html}<br />
45 <span class="description">{ts}Weight controls the order that premiums are displayed on the Contribution Page.{/ts}</span></td></tr>
46 </table>
47 {/if}
48
49 {if $action ne 4}
50 <div class="crm-submit-buttons">
51 {include file="CRM/common/formButtons.tpl" location="bottom"}
52 </div>
53 {else}
54 <div class="crm-done-button">
55 {include file="CRM/common/formButtons.tpl"}
56 </div>
57 {/if} {* $action ne view *}
58 </div>
59
60 <script type="text/javascript">
61 {literal}
62
63 CRM.$(function($) {
64
65 function getFinancialType(set) {
66 var callbackURL = CRM.url('civicrm/ajax/rest', {
67 className: 'CRM_Financial_Page_AJAX',
68 fnName: 'jqFinancialType',
69 _value: $("#product_id").val()
70 });
71 $.ajax({
72 url: callbackURL,
73 success: function( data, textStatus ){
74 data = eval(data);//get json array
75 if ((data != null) && (set)) {
76 $("#financial_type_id").val(data);
77 }
78
79 if (data == $("#financial_type_id").val()) {
80 $("#resetfinancialtype").hide();
81 }
82 else {
83 $("#resetfinancialtype").show();
84 }
85 }
86 });
87 }
88
89 getFinancialType(false);
90 $("#product_id").change(function() { getFinancialType(true); });
91 $("#resetfinancialtype").click(function() { getFinancialType(true); });
92 $("#financial_type_id").change(function() { getFinancialType(false); });
93 });
94 {/literal}
95 </script>
96 {/crmRegion}
97 {crmRegion name="contribute-form-contributionpage-addproduct-post"}
98 {/crmRegion}