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