2 +--------------------------------------------------------------------+
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2018 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
26 {crmRegion name="billing-block"}
27 <div id="payment_information">
28 {if $paymentFields|@count}
29 <fieldset class="billing_mode-group {$paymentTypeName}_info-group">
33 {crmRegion name="billing-block-pre"}
35 <div class="crm-section billing_mode-section {$paymentTypeName}_info-section">
36 {foreach from=$paymentFields item=paymentField}
37 {assign var='name' value=$form.$paymentField.name}
38 <div class="crm-section {$form.$paymentField.name}-section">
39 <div class="label">{$form.$paymentField.label}
40 {if $requiredPaymentFields.$name}<span class="crm-marker" title="{ts}This field is required.{/ts}">*</span>{/if}
43 {$form.$paymentField.html}
44 {if $paymentField == 'cvv2'}{* @todo move to form assignment*}
45 <span class="cvv2-icon" title="{ts}Usually the last 3-4 digits in the signature area on the back of the card.{/ts}"> </span>
47 {if $paymentField == 'credit_card_type'}
48 <div class="crm-credit_card_type-icons"></div>
51 <div class="clear"></div>
57 {if $billingDetailsFields|@count && $paymentProcessor.payment_processor_type neq 'PayPal_Express'}
58 {if $profileAddressFields && !$ccid}
59 <input type="checkbox" id="billingcheckbox" value="0">
60 <label for="billingcheckbox">{ts}My billing address is the same as above{/ts}</label>
62 <fieldset class="billing_name_address-group">
63 <legend>{ts}Billing Name and Address{/ts}</legend>
64 <div class="crm-section billing_name_address-section">
65 {foreach from=$billingDetailsFields item=billingField}
66 {assign var='name' value=$form.$billingField.name}
67 <div class="crm-section {$form.$billingField.name}-section">
68 <div class="label">{$form.$billingField.label}
69 {if $requiredPaymentFields.$name}<span class="crm-marker" title="{ts}This field is required.{/ts}">*</span>{/if}
71 {if $form.$billingField.type == 'text'}
72 <div class="content">{$form.$billingField.html}</div>
74 <div class="content">{$form.$billingField.html|crmAddClass:big}</div>
76 <div class="clear"></div>
83 {if $profileAddressFields}
84 <script type="text/javascript">
88 // build list of ids to track changes on
89 var address_fields = {/literal}{$profileAddressFields|@json_encode}{literal};
92 var orig_id, field, field_name;
95 $('.billing_name_address-section input').each(function (i) {
96 orig_id = $(this).attr('id');
97 field = orig_id.split('-');
98 field_name = field[0].replace('billing_', '');
100 if (address_fields[field_name]) {
101 input_ids['#' + field_name + '-' + address_fields[field_name]] = '#' + orig_id;
105 if ($('#first_name').length)
106 input_ids['#first_name'] = '#billing_first_name';
107 if ($('#middle_name').length)
108 input_ids['#middle_name'] = '#billing_middle_name';
109 if ($('#last_name').length)
110 input_ids['#last_name'] = '#billing_last_name';
113 $('.billing_name_address-section select').each(function (i) {
114 orig_id = $(this).attr('id');
115 field = orig_id.split('-');
116 field_name = field[0].replace('billing_', '').replace('_id', '');
118 if (address_fields[field_name]) {
119 select_ids['#' + field_name + '-' + address_fields[field_name]] = '#' + orig_id;
124 // detect if billing checkbox should default to checked
126 for (var id in input_ids) {
127 orig_id = input_ids[id];
128 if ($(id).val() != $(orig_id).val()) {
133 for (var id in select_ids) {
134 orig_id = select_ids[id];
135 if ($(id).val() != $(orig_id).val()) {
141 $('#billingcheckbox').prop('checked', true).data('crm-initial-value', true);
142 if (!CRM.billing || CRM.billing.billingProfileIsHideable) {
143 $('.billing_name_address-group').hide();
147 // onchange handlers for non-billing fields
148 for (var id in input_ids) {
149 orig_id = input_ids[id];
150 $(id).change(function () {
151 var id = '#' + $(this).attr('id');
152 var orig_id = input_ids[id];
154 // if billing checkbox is active, copy other field into billing field
155 if ($('#billingcheckbox').prop('checked')) {
156 $(orig_id).val($(id).val());
160 for (var id in select_ids) {
161 orig_id = select_ids[id];
162 $(id).change(function () {
163 var id = '#' + $(this).attr('id');
164 var orig_id = select_ids[id];
166 // if billing checkbox is active, copy other field into billing field
167 if ($('#billingcheckbox').prop('checked')) {
168 $(orig_id + ' option').prop('selected', false);
169 $(orig_id + ' option[value="' + $(id).val() + '"]').prop('selected', true);
177 $('#billingcheckbox').click(function () {
179 if (!CRM.billing || CRM.billing.billingProfileIsHideable) {
180 $('.billing_name_address-group').hide(200);
184 for (var id in input_ids) {
185 orig_id = input_ids[id];
186 $(orig_id).val($(id).val());
188 for (var id in select_ids) {
189 orig_id = select_ids[id];
190 $(orig_id + ' option').prop('selected', false);
191 $(orig_id + ' option[value="' + $(id).val() + '"]').prop('selected', true);
195 $('.billing_name_address-group').show(200);
199 // remove spaces, dashes from credit card number
200 $('#credit_card_number').change(function () {
201 var cc = $('#credit_card_number').val()
204 $('#credit_card_number').val(cc);
211 {if $suppressSubmitButton}
213 <script type="text/javascript">
215 $('.crm-submit-buttons', $('#billing-payment-block').closest('form')).hide();
221 {crmRegion name="billing-block-post"}
222 {* Payment processors sometimes need to append something to the end of the billing block. We create a region for
223 clarity - the plan is to move to assigning this through the payment processor to this region *}