Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
2c4c49ca | 3 | | CiviCRM version 4.7 | |
6a488035 | 4 | +--------------------------------------------------------------------+ |
2a73d3b0 | 5 | | Copyright CiviCRM LLC (c) 2004-2017 | |
6a488035 TO |
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 | {crmRegion name="billing-block"} | |
c78d6d60 | 27 | <div id="payment_information"> |
3cc8d80d | 28 | {if $paymentFields|@count} |
fbfd63ec | 29 | <fieldset class="billing_mode-group {$paymentTypeName}_info-group"> |
dc3560bc | 30 | <legend> |
fbfd63ec | 31 | {$paymentTypeLabel} |
dc3560bc | 32 | </legend> |
aaff4c69 | 33 | {crmRegion name="billing-block-pre"} |
aaff4c69 | 34 | {/crmRegion} |
92ec1d7f EM |
35 | <div class="crm-section billing_mode-section {$paymentTypeName}_info-section"> |
36 | {foreach from=$paymentFields item=paymentField} | |
9d421118 | 37 | {assign var='name' value=$form.$paymentField.name} |
92ec1d7f | 38 | <div class="crm-section {$form.$paymentField.name}-section"> |
9d421118 | 39 | <div class="label">{$form.$paymentField.label} |
40 | {if $requiredPaymentFields.$name}<span class="crm-marker" title="{ts}This field is required.{/ts}">*</span>{/if} | |
41 | </div> | |
92ec1d7f EM |
42 | <div class="content">{$form.$paymentField.html} |
43 | {if $paymentField == 'cvv2'}{* @todo move to form assignment*} | |
44 | <span class="cvv2-icon" title="{ts}Usually the last 3-4 digits in the signature area on the back of the card.{/ts}"> </span> | |
45 | {/if} | |
46 | {if $paymentField == 'credit_card_type'} | |
47 | <div class="crm-credit_card_type-icons"></div> | |
48 | {/if} | |
6a488035 | 49 | </div> |
dc3560bc EM |
50 | <div class="clear"></div> |
51 | </div> | |
92ec1d7f | 52 | {/foreach} |
dc3560bc | 53 | </div> |
c78d6d60 | 54 | </fieldset> |
caec10c8 | 55 | {/if} |
b5eab107 | 56 | {if $billingDetailsFields|@count && $paymentProcessor.payment_processor_type neq 'PayPal_Express'} |
37e877b2 | 57 | {if $profileAddressFields && !$ccid} |
c78d6d60 EM |
58 | <input type="checkbox" id="billingcheckbox" value="0"> |
59 | <label for="billingcheckbox">{ts}My billing address is the same as above{/ts}</label> | |
dc3560bc | 60 | {/if} |
c78d6d60 EM |
61 | <fieldset class="billing_name_address-group"> |
62 | <legend>{ts}Billing Name and Address{/ts}</legend> | |
63 | <div class="crm-section billing_name_address-section"> | |
64 | {foreach from=$billingDetailsFields item=billingField} | |
9d421118 | 65 | {assign var='name' value=$form.$billingField.name} |
c78d6d60 | 66 | <div class="crm-section {$form.$billingField.name}-section"> |
9d421118 | 67 | <div class="label">{$form.$billingField.label} |
68 | {if $requiredPaymentFields.$name}<span class="crm-marker" title="{ts}This field is required.{/ts}">*</span>{/if} | |
69 | </div> | |
c78d6d60 EM |
70 | {if $form.$billingField.type == 'text'} |
71 | <div class="content">{$form.$billingField.html}</div> | |
72 | {else} | |
73 | <div class="content">{$form.$billingField.html|crmAddClass:big}</div> | |
74 | {/if} | |
75 | <div class="clear"></div> | |
76 | </div> | |
77 | {/foreach} | |
78 | </div> | |
79 | </fieldset> | |
80 | {/if} | |
81 | </div> | |
dc3560bc EM |
82 | {if $profileAddressFields} |
83 | <script type="text/javascript"> | |
84 | {literal} | |
8ae4d0d3 | 85 | |
dc3560bc EM |
86 | CRM.$(function ($) { |
87 | // build list of ids to track changes on | |
88 | var address_fields = {/literal}{$profileAddressFields|@json_encode}{literal}; | |
89 | var input_ids = {}; | |
90 | var select_ids = {}; | |
91 | var orig_id, field, field_name; | |
6a488035 | 92 | |
dc3560bc EM |
93 | // build input ids |
94 | $('.billing_name_address-section input').each(function (i) { | |
95 | orig_id = $(this).attr('id'); | |
96 | field = orig_id.split('-'); | |
97 | field_name = field[0].replace('billing_', ''); | |
98 | if (field[1]) { | |
99 | if (address_fields[field_name]) { | |
100 | input_ids['#' + field_name + '-' + address_fields[field_name]] = '#' + orig_id; | |
101 | } | |
102 | } | |
103 | }); | |
104 | if ($('#first_name').length) | |
105 | input_ids['#first_name'] = '#billing_first_name'; | |
106 | if ($('#middle_name').length) | |
107 | input_ids['#middle_name'] = '#billing_middle_name'; | |
108 | if ($('#last_name').length) | |
109 | input_ids['#last_name'] = '#billing_last_name'; | |
6a488035 | 110 | |
dc3560bc EM |
111 | // build select ids |
112 | $('.billing_name_address-section select').each(function (i) { | |
113 | orig_id = $(this).attr('id'); | |
114 | field = orig_id.split('-'); | |
115 | field_name = field[0].replace('billing_', '').replace('_id', ''); | |
116 | if (field[1]) { | |
117 | if (address_fields[field_name]) { | |
118 | select_ids['#' + field_name + '-' + address_fields[field_name]] = '#' + orig_id; | |
119 | } | |
120 | } | |
121 | }); | |
6a488035 | 122 | |
dc3560bc EM |
123 | // detect if billing checkbox should default to checked |
124 | var checked = true; | |
125 | for (var id in input_ids) { | |
126 | orig_id = input_ids[id]; | |
127 | if ($(id).val() != $(orig_id).val()) { | |
128 | checked = false; | |
129 | break; | |
130 | } | |
6a488035 | 131 | } |
dc3560bc EM |
132 | for (var id in select_ids) { |
133 | orig_id = select_ids[id]; | |
134 | if ($(id).val() != $(orig_id).val()) { | |
135 | checked = false; | |
136 | break; | |
137 | } | |
138 | } | |
139 | if (checked) { | |
cce5bc84 | 140 | $('#billingcheckbox').prop('checked', true).data('crm-initial-value', true); |
ab2e3179 | 141 | if (!CRM.billing || CRM.billing.billingProfileIsHideable) { |
dc3560bc EM |
142 | $('.billing_name_address-group').hide(); |
143 | } | |
6a488035 | 144 | } |
6a488035 | 145 | |
dc3560bc EM |
146 | // onchange handlers for non-billing fields |
147 | for (var id in input_ids) { | |
148 | orig_id = input_ids[id]; | |
149 | $(id).change(function () { | |
150 | var id = '#' + $(this).attr('id'); | |
151 | var orig_id = input_ids[id]; | |
6a488035 | 152 | |
dc3560bc EM |
153 | // if billing checkbox is active, copy other field into billing field |
154 | if ($('#billingcheckbox').prop('checked')) { | |
155 | $(orig_id).val($(id).val()); | |
156 | } | |
157 | }); | |
ae8f569f | 158 | } |
dc3560bc EM |
159 | for (var id in select_ids) { |
160 | orig_id = select_ids[id]; | |
161 | $(id).change(function () { | |
162 | var id = '#' + $(this).attr('id'); | |
163 | var orig_id = select_ids[id]; | |
6a488035 | 164 | |
dc3560bc EM |
165 | // if billing checkbox is active, copy other field into billing field |
166 | if ($('#billingcheckbox').prop('checked')) { | |
167 | $(orig_id + ' option').prop('selected', false); | |
168 | $(orig_id + ' option[value="' + $(id).val() + '"]').prop('selected', true); | |
dc3560bc EM |
169 | $(orig_id).change(); |
170 | } | |
171 | }); | |
6a488035 | 172 | } |
6a488035 TO |
173 | |
174 | ||
dc3560bc EM |
175 | // toggle show/hide |
176 | $('#billingcheckbox').click(function () { | |
177 | if (this.checked) { | |
ab2e3179 | 178 | if (!CRM.billing || CRM.billing.billingProfileIsHideable) { |
dc3560bc EM |
179 | $('.billing_name_address-group').hide(200); |
180 | } | |
6a488035 | 181 | |
dc3560bc EM |
182 | // copy all values |
183 | for (var id in input_ids) { | |
184 | orig_id = input_ids[id]; | |
185 | $(orig_id).val($(id).val()); | |
186 | } | |
187 | for (var id in select_ids) { | |
188 | orig_id = select_ids[id]; | |
189 | $(orig_id + ' option').prop('selected', false); | |
190 | $(orig_id + ' option[value="' + $(id).val() + '"]').prop('selected', true); | |
84466477 | 191 | $(orig_id).change(); |
dc3560bc EM |
192 | } |
193 | } else { | |
194 | $('.billing_name_address-group').show(200); | |
195 | } | |
196 | }); | |
6a488035 | 197 | |
dc3560bc EM |
198 | // remove spaces, dashes from credit card number |
199 | $('#credit_card_number').change(function () { | |
200 | var cc = $('#credit_card_number').val() | |
201 | .replace(/ /g, '') | |
202 | .replace(/-/g, ''); | |
203 | $('#credit_card_number').val(cc); | |
204 | }); | |
1ba4a3aa EM |
205 | }); |
206 | ||
dc3560bc | 207 | </script> |
31d31a05 | 208 | {/literal} |
6a488035 | 209 | {/if} |
079e7379 CW |
210 | {if $suppressSubmitButton} |
211 | {literal} | |
212 | <script type="text/javascript"> | |
213 | CRM.$(function($) { | |
214 | $('.crm-submit-buttons', $('#billing-payment-block').closest('form')).hide(); | |
215 | }); | |
216 | </script> | |
217 | {/literal} | |
218 | {/if} | |
6a488035 | 219 | {/crmRegion} |
dbbd55dc EM |
220 | {crmRegion name="billing-block-post"} |
221 | {* Payment processors sometimes need to append something to the end of the billing block. We create a region for | |
222 | clarity - the plan is to move to assigning this through the payment processor to this region *} | |
dbbd55dc | 223 | {/crmRegion} |