2 +--------------------------------------------------------------------+
3 | Copyright CiviCRM LLC. All rights reserved. |
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 +--------------------------------------------------------------------+
10 {crmRegion name="billing-block"}
11 <div id="payment_information">
12 {if $paymentFields|@count}
13 <fieldset class="billing_mode-group {$paymentTypeName}_info-group">
17 {crmRegion name="billing-block-pre"}
19 <div class="crm-section billing_mode-section {$paymentTypeName}_info-section">
20 {foreach from=$paymentFields item=paymentField}
21 {assign var='name' value=$form.$paymentField.name}
22 <div class="crm-section {$form.$paymentField.name}-section">
23 <div class="label">{$form.$paymentField.label}</div>
25 {$form.$paymentField.html}
26 {if $paymentFieldsMetadata.$name.description}
27 <div class="description">{$paymentFieldsMetadata.$name.description}</div>
28 {elseif $paymentField == 'cvv2'}{* @todo move to form assignment*}
29 <span class="cvv2-icon" title="{ts}Usually the last 3-4 digits in the signature area on the back of the card.{/ts}"> </span>
31 {if $paymentField == 'credit_card_type'}
32 <div class="crm-credit_card_type-icons"></div>
35 <div class="clear"></div>
41 {if $billingDetailsFields|@count && $paymentProcessor.payment_processor_type neq 'PayPal_Express'}
42 {if $profileAddressFields && !$ccid}
43 <input type="checkbox" id="billingcheckbox" value="0">
44 <label for="billingcheckbox">{ts}My billing address is the same as above{/ts}</label>
46 <fieldset class="billing_name_address-group">
47 <legend>{ts}Billing Name and Address{/ts}</legend>
48 <div class="crm-section billing_name_address-section">
49 {foreach from=$billingDetailsFields item=billingField}
50 {assign var='name' value=$form.$billingField.name}
51 <div class="crm-section {$form.$billingField.name}-section">
52 <div class="label">{$form.$billingField.label}</div>
53 {if $form.$billingField.type == 'text'}
54 <div class="content">{$form.$billingField.html}</div>
56 <div class="content">{$form.$billingField.html|crmAddClass:big}</div>
58 <div class="clear"></div>
65 {if $profileAddressFields}
66 <script type="text/javascript">
70 // build list of ids to track changes on
71 var address_fields = {/literal}{$profileAddressFields|@json_encode}{literal};
74 var orig_id, field, field_name;
77 $('.billing_name_address-section input').each(function (i) {
78 orig_id = $(this).attr('id');
79 field = orig_id.split('-');
80 field_name = field[0].replace('billing_', '');
82 if (address_fields[field_name]) {
83 input_ids['#' + field_name + '-' + address_fields[field_name]] = '#' + orig_id;
87 if ($('#first_name').length)
88 input_ids['#first_name'] = '#billing_first_name';
89 if ($('#middle_name').length)
90 input_ids['#middle_name'] = '#billing_middle_name';
91 if ($('#last_name').length)
92 input_ids['#last_name'] = '#billing_last_name';
95 $('.billing_name_address-section select').each(function (i) {
96 orig_id = $(this).attr('id');
97 field = orig_id.split('-');
98 field_name = field[0].replace('billing_', '').replace('_id', '');
100 if (address_fields[field_name]) {
101 select_ids['#' + field_name + '-' + address_fields[field_name]] = '#' + orig_id;
106 // detect if billing checkbox should default to checked
108 for (var id in input_ids) {
109 orig_id = input_ids[id];
110 if ($(id).val() != $(orig_id).val()) {
115 for (var id in select_ids) {
116 orig_id = select_ids[id];
117 if ($(id).val() != $(orig_id).val()) {
123 $('#billingcheckbox').prop('checked', true).data('crm-initial-value', true);
124 if (!CRM.billing || CRM.billing.billingProfileIsHideable) {
125 $('.billing_name_address-group').hide();
129 // onchange handlers for non-billing fields
130 for (var id in input_ids) {
131 orig_id = input_ids[id];
132 $(id).change(function () {
133 var id = '#' + $(this).attr('id');
134 var orig_id = input_ids[id];
136 // if billing checkbox is active, copy other field into billing field
137 if ($('#billingcheckbox').prop('checked')) {
138 $(orig_id).val($(id).val());
142 for (var id in select_ids) {
143 orig_id = select_ids[id];
144 $(id).change(function () {
145 var id = '#' + $(this).attr('id');
146 var orig_id = select_ids[id];
148 // if billing checkbox is active, copy other field into billing field
149 if ($('#billingcheckbox').prop('checked')) {
150 $(orig_id + ' option').prop('selected', false);
151 $(orig_id + ' option[value="' + $(id).val() + '"]').prop('selected', true);
158 var billingCheckboxElement = $('#billingcheckbox');
159 billingCheckboxElement.click(function() {
160 billingCheckboxChanged(billingCheckboxElement);
163 billingCheckboxElement.change(function() {
164 billingCheckboxChanged(billingCheckboxElement);
167 function billingCheckboxChanged(billingCheckbox) {
168 if (billingCheckbox.prop('checked')) {
169 if (!CRM.billing || CRM.billing.billingProfileIsHideable) {
170 $('.billing_name_address-group').hide(200);
174 for (var id in input_ids) {
175 orig_id = input_ids[id];
176 $(orig_id).val($(id).val());
178 for (var id in select_ids) {
179 orig_id = select_ids[id];
180 $(orig_id + ' option').prop('selected', false);
181 $(orig_id + ' option[value="' + $(id).val() + '"]').prop('selected', true);
185 $('.billing_name_address-group').show(200);
189 // remove spaces, dashes from credit card number
190 $('#credit_card_number').change(function () {
191 var cc = $('#credit_card_number').val()
194 $('#credit_card_number').val(cc);
201 {if $suppressSubmitButton}
203 <script type="text/javascript">
205 $('.crm-submit-buttons', $('#billing-payment-block').closest('form')).hide();
211 {crmRegion name="billing-block-post"}
212 {* Payment processors sometimes need to append something to the end of the billing block. We create a region for
213 clarity - the plan is to move to assigning this through the payment processor to this region *}