1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Handle client portal shipping address change

This commit is contained in:
Hillel Coren 2017-12-07 14:49:33 +02:00
parent 180a8b5e0f
commit 32864bdb10

View File

@ -14,6 +14,37 @@
<script type="text/javascript"> <script type="text/javascript">
function copyBillingAddress() {
var fields = [
'address1',
'address2',
'city',
'state',
'postal_code',
'country_id',
]
$.each(fields, function(i, field) {
$('#shipping_' + field).val($('#' + field).val());
})
$('#shipping_country_id').combobox('refresh');
}
function clearShippingAddress() {
var fields = [
'address1',
'address2',
'city',
'state',
'postal_code',
'country_id',
]
$.each(fields, function(i, field) {
$('#shipping_' + field).val('');
})
$('#shipping_country_id').combobox('toggle');
$('#shipping_address1').focus();
}
$(function() { $(function() {
$('.payment-form').submit(function(event) { $('.payment-form').submit(function(event) {
var $form = $(this); var $form = $(this);
@ -26,30 +57,20 @@
$('#shipToBillingAddress').click(function() { $('#shipToBillingAddress').click(function() {
var checked = $('#shipToBillingAddress').is(':checked'); var checked = $('#shipToBillingAddress').is(':checked');
var fields = [ $('.shipping-address input').prop('disabled', checked);
'address1',
'address2',
'city',
'state',
'postal_code',
'country_id',
]
$.each(fields, function(i, field) {
if (checked) {
$('#shipping_' + field).val($('#' + field).val());
} else {
$('#shipping_' + field).val('');
}
})
if (checked) { if (checked) {
$('#shipping_country_id').combobox('refresh'); copyBillingAddress();
} else { } else {
$('#shipping_country_id').combobox('toggle'); clearShippingAddress();
$('#shipping_address1').focus();
} }
}) })
$('.billing-address').change(function() {
if ($('#shipToBillingAddress').is(':checked')) {
copyBillingAddress();
}
});
@if ($accountGateway->gateway_id != GATEWAY_BRAINTREE) @if ($accountGateway->gateway_id != GATEWAY_BRAINTREE)
var card = new Card({ var card = new Card({
form: 'form#payment-form', // *required* form: 'form#payment-form', // *required*
@ -191,7 +212,7 @@
<h3>{{ trans('texts.billing_address') }} &nbsp;&nbsp; <span class="help">{{ trans('texts.payment_footer1') }}</span></h3> <h3>{{ trans('texts.billing_address') }} &nbsp;&nbsp; <span class="help">{{ trans('texts.payment_footer1') }}</span></h3>
<hr class="form-legend"/> <hr class="form-legend"/>
<div style="padding-bottom: 22px;"> <div style="padding-bottom: 22px;" class="billing-address">
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
{!! Former::text('address1') {!! Former::text('address1')
@ -251,7 +272,7 @@
</h3> </h3>
<hr class="form-legend"/> <hr class="form-legend"/>
<div style="padding-bottom: 22px;"> <div style="padding-bottom: 22px;" class="shipping-address">
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
{!! Former::text('shipping_address1') {!! Former::text('shipping_address1')