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> |
4f6cdd27 EM |
33 | {if $form.$expressButtonName} |
34 | {include file= "CRM/Core/paypalexpress.tpl"} | |
dc3560bc | 35 | {/if} |
92ec1d7f EM |
36 | <div class="crm-section billing_mode-section {$paymentTypeName}_info-section"> |
37 | {foreach from=$paymentFields item=paymentField} | |
38 | <div class="crm-section {$form.$paymentField.name}-section"> | |
39 | <div class="label">{$form.$paymentField.label}</div> | |
40 | <div class="content">{$form.$paymentField.html} | |
41 | {if $paymentField == 'cvv2'}{* @todo move to form assignment*} | |
42 | <span class="cvv2-icon" title="{ts}Usually the last 3-4 digits in the signature area on the back of the card.{/ts}"> </span> | |
43 | {/if} | |
44 | {if $paymentField == 'credit_card_type'} | |
45 | <div class="crm-credit_card_type-icons"></div> | |
46 | {/if} | |
6a488035 | 47 | </div> |
dc3560bc EM |
48 | <div class="clear"></div> |
49 | </div> | |
92ec1d7f | 50 | {/foreach} |
dc3560bc | 51 | </div> |
c78d6d60 EM |
52 | </fieldset> |
53 | {/if} | |
dc913073 | 54 | {if $billingDetailsFields|@count} |
c78d6d60 EM |
55 | {if $profileAddressFields} |
56 | <input type="checkbox" id="billingcheckbox" value="0"> | |
57 | <label for="billingcheckbox">{ts}My billing address is the same as above{/ts}</label> | |
dc3560bc | 58 | {/if} |
c78d6d60 EM |
59 | <fieldset class="billing_name_address-group"> |
60 | <legend>{ts}Billing Name and Address{/ts}</legend> | |
61 | <div class="crm-section billing_name_address-section"> | |
62 | {foreach from=$billingDetailsFields item=billingField} | |
63 | <div class="crm-section {$form.$billingField.name}-section"> | |
64 | <div class="label">{$form.$billingField.label}</div> | |
65 | {if $form.$billingField.type == 'text'} | |
66 | <div class="content">{$form.$billingField.html}</div> | |
67 | {else} | |
68 | <div class="content">{$form.$billingField.html|crmAddClass:big}</div> | |
69 | {/if} | |
70 | <div class="clear"></div> | |
71 | </div> | |
72 | {/foreach} | |
73 | </div> | |
74 | </fieldset> | |
75 | {/if} | |
76 | </div> | |
dc3560bc EM |
77 | {if $profileAddressFields} |
78 | <script type="text/javascript"> | |
79 | {literal} | |
8ae4d0d3 | 80 | |
dc3560bc EM |
81 | CRM.$(function ($) { |
82 | // build list of ids to track changes on | |
83 | var address_fields = {/literal}{$profileAddressFields|@json_encode}{literal}; | |
84 | var input_ids = {}; | |
85 | var select_ids = {}; | |
86 | var orig_id, field, field_name; | |
6a488035 | 87 | |
dc3560bc EM |
88 | // build input ids |
89 | $('.billing_name_address-section input').each(function (i) { | |
90 | orig_id = $(this).attr('id'); | |
91 | field = orig_id.split('-'); | |
92 | field_name = field[0].replace('billing_', ''); | |
93 | if (field[1]) { | |
94 | if (address_fields[field_name]) { | |
95 | input_ids['#' + field_name + '-' + address_fields[field_name]] = '#' + orig_id; | |
96 | } | |
97 | } | |
98 | }); | |
99 | if ($('#first_name').length) | |
100 | input_ids['#first_name'] = '#billing_first_name'; | |
101 | if ($('#middle_name').length) | |
102 | input_ids['#middle_name'] = '#billing_middle_name'; | |
103 | if ($('#last_name').length) | |
104 | input_ids['#last_name'] = '#billing_last_name'; | |
6a488035 | 105 | |
dc3560bc EM |
106 | // build select ids |
107 | $('.billing_name_address-section select').each(function (i) { | |
108 | orig_id = $(this).attr('id'); | |
109 | field = orig_id.split('-'); | |
110 | field_name = field[0].replace('billing_', '').replace('_id', ''); | |
111 | if (field[1]) { | |
112 | if (address_fields[field_name]) { | |
113 | select_ids['#' + field_name + '-' + address_fields[field_name]] = '#' + orig_id; | |
114 | } | |
115 | } | |
116 | }); | |
6a488035 | 117 | |
dc3560bc EM |
118 | // detect if billing checkbox should default to checked |
119 | var checked = true; | |
120 | for (var id in input_ids) { | |
121 | orig_id = input_ids[id]; | |
122 | if ($(id).val() != $(orig_id).val()) { | |
123 | checked = false; | |
124 | break; | |
125 | } | |
6a488035 | 126 | } |
dc3560bc EM |
127 | for (var id in select_ids) { |
128 | orig_id = select_ids[id]; | |
129 | if ($(id).val() != $(orig_id).val()) { | |
130 | checked = false; | |
131 | break; | |
132 | } | |
133 | } | |
134 | if (checked) { | |
135 | $('#billingcheckbox').prop('checked', true); | |
ab2e3179 | 136 | if (!CRM.billing || CRM.billing.billingProfileIsHideable) { |
dc3560bc EM |
137 | $('.billing_name_address-group').hide(); |
138 | } | |
6a488035 | 139 | } |
6a488035 | 140 | |
dc3560bc EM |
141 | // onchange handlers for non-billing fields |
142 | for (var id in input_ids) { | |
143 | orig_id = input_ids[id]; | |
144 | $(id).change(function () { | |
145 | var id = '#' + $(this).attr('id'); | |
146 | var orig_id = input_ids[id]; | |
6a488035 | 147 | |
dc3560bc EM |
148 | // if billing checkbox is active, copy other field into billing field |
149 | if ($('#billingcheckbox').prop('checked')) { | |
150 | $(orig_id).val($(id).val()); | |
151 | } | |
152 | }); | |
ae8f569f | 153 | } |
dc3560bc EM |
154 | for (var id in select_ids) { |
155 | orig_id = select_ids[id]; | |
156 | $(id).change(function () { | |
157 | var id = '#' + $(this).attr('id'); | |
158 | var orig_id = select_ids[id]; | |
6a488035 | 159 | |
dc3560bc EM |
160 | // if billing checkbox is active, copy other field into billing field |
161 | if ($('#billingcheckbox').prop('checked')) { | |
162 | $(orig_id + ' option').prop('selected', false); | |
163 | $(orig_id + ' option[value="' + $(id).val() + '"]').prop('selected', true); | |
dc3560bc EM |
164 | $(orig_id).change(); |
165 | } | |
166 | }); | |
6a488035 | 167 | } |
6a488035 TO |
168 | |
169 | ||
dc3560bc EM |
170 | // toggle show/hide |
171 | $('#billingcheckbox').click(function () { | |
172 | if (this.checked) { | |
ab2e3179 | 173 | if (!CRM.billing || CRM.billing.billingProfileIsHideable) { |
dc3560bc EM |
174 | $('.billing_name_address-group').hide(200); |
175 | } | |
6a488035 | 176 | |
dc3560bc EM |
177 | // copy all values |
178 | for (var id in input_ids) { | |
179 | orig_id = input_ids[id]; | |
180 | $(orig_id).val($(id).val()); | |
181 | } | |
182 | for (var id in select_ids) { | |
183 | orig_id = select_ids[id]; | |
184 | $(orig_id + ' option').prop('selected', false); | |
185 | $(orig_id + ' option[value="' + $(id).val() + '"]').prop('selected', true); | |
84466477 | 186 | $(orig_id).change(); |
dc3560bc EM |
187 | } |
188 | } else { | |
189 | $('.billing_name_address-group').show(200); | |
190 | } | |
191 | }); | |
6a488035 | 192 | |
dc3560bc EM |
193 | // remove spaces, dashes from credit card number |
194 | $('#credit_card_number').change(function () { | |
195 | var cc = $('#credit_card_number').val() | |
196 | .replace(/ /g, '') | |
197 | .replace(/-/g, ''); | |
198 | $('#credit_card_number').val(cc); | |
199 | }); | |
200 | }); | |
201 | {/literal} | |
202 | </script> | |
6a488035 | 203 | {/if} |
8ae4d0d3 | 204 | |
6a488035 | 205 | {/crmRegion} |