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