mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on shipping address
This commit is contained in:
parent
8ff7b7fd21
commit
444ffd64cf
@ -119,9 +119,9 @@ class AccountGatewayController extends BaseController
|
||||
$creditCards = [];
|
||||
foreach ($creditCardsArray as $card => $name) {
|
||||
if ($selectedCards > 0 && ($selectedCards & $card) == $card) {
|
||||
$creditCards[$name['text']] = ['value' => $card, 'data-imageUrl' => asset($name['card']), 'checked' => 'checked'];
|
||||
$creditCards['<div>' . $name['text'] . '</div>'] = ['value' => $card, 'data-imageUrl' => asset($name['card']), 'checked' => 'checked'];
|
||||
} else {
|
||||
$creditCards[$name['text']] = ['value' => $card, 'data-imageUrl' => asset($name['card'])];
|
||||
$creditCards['<div>' . $name['text'] . '</div>'] = ['value' => $card, 'data-imageUrl' => asset($name['card'])];
|
||||
}
|
||||
}
|
||||
|
||||
@ -316,6 +316,7 @@ class AccountGatewayController extends BaseController
|
||||
|
||||
$accountGateway->accepted_credit_cards = $cardCount;
|
||||
$accountGateway->show_address = Input::get('show_address') ? true : false;
|
||||
$accountGateway->show_shipping_address = Input::get('show_shipping_address') ? true : false;
|
||||
$accountGateway->update_address = Input::get('update_address') ? true : false;
|
||||
$accountGateway->setConfig($config);
|
||||
|
||||
|
@ -173,7 +173,6 @@ class BasePaymentDriver
|
||||
'accountGateway' => $this->accountGateway,
|
||||
'acceptedCreditCardTypes' => $this->accountGateway->getCreditcardTypes(),
|
||||
'gateway' => $gateway,
|
||||
'showAddress' => $this->accountGateway->show_address,
|
||||
'showBreadcrumbs' => false,
|
||||
'url' => $url,
|
||||
'amount' => $this->invoice()->getRequestedAmount(),
|
||||
@ -407,18 +406,32 @@ class BasePaymentDriver
|
||||
$this->contact()->save();
|
||||
}
|
||||
|
||||
// update the address info
|
||||
if ($this->accountGateway->update_address) {
|
||||
$client = $this->client();
|
||||
if ($this->accountGateway->show_address) {
|
||||
$client->address1 = trim($this->input['address1']);
|
||||
$client->address2 = trim($this->input['address2']);
|
||||
$client->city = trim($this->input['city']);
|
||||
$client->state = trim($this->input['state']);
|
||||
$client->postal_code = trim($this->input['postal_code']);
|
||||
$client->country_id = trim($this->input['country_id']);
|
||||
}
|
||||
if ($this->accountGateway->show_shipping_address) {
|
||||
$client->shipping_address1 = trim($this->input['shipping_address1']);
|
||||
$client->shipping_address2 = trim($this->input['shipping_address2']);
|
||||
$client->shipping_city = trim($this->input['shipping_city']);
|
||||
$client->shipping_state = trim($this->input['shipping_state']);
|
||||
$client->shipping_postal_code = trim($this->input['shipping_postal_code']);
|
||||
$client->shipping_country_id = trim($this->input['shipping_country_id']);
|
||||
}
|
||||
}
|
||||
|
||||
if (! $this->accountGateway->show_address || ! $this->accountGateway->update_address) {
|
||||
return;
|
||||
}
|
||||
|
||||
// update the address info
|
||||
$client = $this->client();
|
||||
$client->address1 = trim($this->input['address1']);
|
||||
$client->address2 = trim($this->input['address2']);
|
||||
$client->city = trim($this->input['city']);
|
||||
$client->state = trim($this->input['state']);
|
||||
$client->postal_code = trim($this->input['postal_code']);
|
||||
$client->country_id = trim($this->input['country_id']);
|
||||
|
||||
$client->save();
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,11 @@ class AddSubdomainToLookups extends Migration
|
||||
});
|
||||
|
||||
Schema::table('clients', function ($table) {
|
||||
$table->foreign('shipping_country_id')->references('id')->on('currencies');
|
||||
$table->foreign('shipping_country_id')->references('id')->on('countries');
|
||||
});
|
||||
|
||||
Schema::table('account_gateways', function ($table) {
|
||||
$table->boolean('show_shipping_address')->default(false)->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
@ -65,5 +69,9 @@ class AddSubdomainToLookups extends Migration
|
||||
$table->dropColumn('shipping_postal_code');
|
||||
$table->dropColumn('shipping_country_id');
|
||||
});
|
||||
|
||||
Schema::table('account_gateways', function ($table) {
|
||||
$table->dropColumn('show_shipping_address');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -2541,6 +2541,8 @@ $LANG = array(
|
||||
'shipping_postal_code' => 'Shipping Postal Code',
|
||||
'shipping_country' => 'Shipping Country',
|
||||
'classify' => 'Classify',
|
||||
'show_shipping_address_help' => 'Require client to provide their shipping address',
|
||||
'ship_to_billing_address' => 'Ship to billing address',
|
||||
|
||||
);
|
||||
|
||||
|
@ -1,5 +1,20 @@
|
||||
@extends('header')
|
||||
|
||||
@section('head')
|
||||
@parent
|
||||
|
||||
<style type="text/css">
|
||||
label.checkbox-inline {
|
||||
padding-left: 0px;
|
||||
}
|
||||
|
||||
label.checkbox-inline div {
|
||||
padding-left: 20px;
|
||||
}
|
||||
</style>
|
||||
@stop
|
||||
|
||||
|
||||
@section('top-right')
|
||||
@if (env('WEPAY_CLIENT_ID') && isset($accountGatewaysIds) && ! count($accountGatewaysIds))
|
||||
{!! Button::primary(trans('texts.sign_up_with_wepay'))
|
||||
@ -23,6 +38,7 @@
|
||||
{!! Former::populateField('primary_gateway_id', $accountGateway->gateway_id) !!}
|
||||
{!! Former::populateField('recommendedGateway_id', $accountGateway->gateway_id) !!}
|
||||
{!! Former::populateField('show_address', intval($accountGateway->show_address)) !!}
|
||||
{!! Former::populateField('show_shipping_address', intval($accountGateway->show_shipping_address)) !!}
|
||||
{!! Former::populateField('update_address', intval($accountGateway->update_address)) !!}
|
||||
{!! Former::populateField('publishable_key', $accountGateway->getPublishableStripeKey() ? str_repeat('*', strlen($accountGateway->getPublishableStripeKey())) : '') !!}
|
||||
{!! Former::populateField('enable_ach', $accountGateway->getAchEnabled() ? 1 : 0) !!}
|
||||
@ -142,6 +158,12 @@
|
||||
->addGroupClass('gateway-option')
|
||||
->value(1) !!}
|
||||
|
||||
{!! Former::checkbox('show_shipping_address')
|
||||
->label(trans('texts.shipping_address'))
|
||||
->text(trans('texts.show_shipping_address_help'))
|
||||
->addGroupClass('gateway-option')
|
||||
->value(1) !!}
|
||||
|
||||
{!! Former::checkbox('update_address')
|
||||
->label(' ')
|
||||
->text(trans('texts.update_address_help'))
|
||||
@ -153,8 +175,10 @@
|
||||
->checkboxes($creditCardTypes)
|
||||
->class('creditcard-types')
|
||||
->addGroupClass('gateway-option')
|
||||
->inline()
|
||||
->value(1)
|
||||
!!}
|
||||
<br/>
|
||||
</div>
|
||||
|
||||
@if (!$accountGateway || $accountGateway->gateway_id == GATEWAY_STRIPE)
|
||||
@ -279,14 +303,9 @@
|
||||
}
|
||||
|
||||
function enableUpdateAddress(event) {
|
||||
var disabled = !$('#show_address').is(':checked');
|
||||
var disabled = ! $('#show_address').is(':checked') && ! $('#show_shipping_address').is(':checked');
|
||||
$('#update_address').prop('disabled', disabled);
|
||||
$('label[for=update_address]').css('color', disabled ? '#888' : '#000');
|
||||
if (disabled) {
|
||||
$('#update_address').prop('checked', false);
|
||||
} else if (event) {
|
||||
$('#update_address').prop('checked', true);
|
||||
}
|
||||
}
|
||||
|
||||
function updateWebhookShown() {
|
||||
@ -306,7 +325,7 @@
|
||||
setFieldsShown();
|
||||
updateWebhookShown();
|
||||
|
||||
$('#show_address').change(enableUpdateAddress);
|
||||
$('#show_address, #show_shipping_address').change(enableUpdateAddress);
|
||||
enableUpdateAddress();
|
||||
|
||||
$('#enable_ach').change(updateWebhookShown);
|
||||
|
@ -39,7 +39,7 @@
|
||||
|
||||
<div class="panel panel-default" style="min-height: 380px">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">{!! trans('texts.organization') !!}</h3>
|
||||
<h3 class="panel-title">{!! trans('texts.details') !!}</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
|
||||
|
@ -98,11 +98,6 @@
|
||||
<p><i class="fa fa-vat-number" style="width: 20px"></i>{{ trans('texts.vat_number').': '.$client->vat_number }}</p>
|
||||
@endif
|
||||
|
||||
{!! $client->present()->address(ADDRESS_BILLING) !!}
|
||||
{!! $client->present()->address(ADDRESS_SHIPPING) !!}
|
||||
|
||||
<br/>
|
||||
|
||||
@if ($client->account->custom_client_label1 && $client->custom_value1)
|
||||
{{ $client->account->custom_client_label1 . ': ' . $client->custom_value1 }}<br/>
|
||||
@endif
|
||||
@ -144,6 +139,14 @@
|
||||
<p>{{ $client->present()->paymentTerms }}</p>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<h3>{{ trans('texts.address') }}</h3>
|
||||
|
||||
{!! $client->present()->address(ADDRESS_BILLING) !!}<br/>
|
||||
{!! $client->present()->address(ADDRESS_SHIPPING) !!}
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<h3>{{ trans('texts.contacts') }}</h3>
|
||||
@foreach ($client->contacts as $contact)
|
||||
@ -173,7 +176,7 @@
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="col-md-3">
|
||||
<h3>{{ trans('texts.standing') }}
|
||||
<table class="table" style="width:100%">
|
||||
<tr>
|
||||
|
@ -24,6 +24,32 @@
|
||||
return true;
|
||||
});
|
||||
|
||||
$('#shipToBillingAddress').click(function() {
|
||||
var checked = $('#shipToBillingAddress').is(':checked');
|
||||
var fields = [
|
||||
'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) {
|
||||
$('#shipping_country_id').combobox('refresh');
|
||||
} else {
|
||||
$('#shipping_country_id').combobox('toggle');
|
||||
$('#shipping_address1').focus();
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
@if ($accountGateway->gateway_id != GATEWAY_BRAINTREE)
|
||||
var card = new Card({
|
||||
form: 'form#payment-form', // *required*
|
||||
@ -91,6 +117,11 @@
|
||||
'routing_number' => 'required',
|
||||
'account_holder_name' => 'required',
|
||||
'account_holder_type' => 'required',
|
||||
'shipping_address1' => 'required',
|
||||
'shipping_city' => 'required',
|
||||
'shipping_state' => 'required',
|
||||
'shipping_postal_code' => 'required',
|
||||
'shipping_country_id' => 'required',
|
||||
)) !!}
|
||||
|
||||
|
||||
@ -101,6 +132,7 @@
|
||||
{{ Former::populateField('email', $contact->email) }}
|
||||
@if (!$client->country_id && $client->account->country_id)
|
||||
{{ Former::populateField('country_id', $client->account->country_id) }}
|
||||
{{ Former::populateField('shipping_country_id', $client->account->country_id) }}
|
||||
@endif
|
||||
@if (!$client->currency_id && $client->account->currency_id)
|
||||
{{ Former::populateField('currency_id', $client->account->currency_id) }}
|
||||
@ -153,8 +185,8 @@
|
||||
|
||||
<p> <br/> </p>
|
||||
|
||||
@if (!empty($showAddress))
|
||||
<h3>{{ trans('texts.billing_address') }} <span class="help">{{ trans('texts.payment_footer1') }}</span></h3>
|
||||
@if (!empty($accountGateway->show_address))
|
||||
<h3>{{ trans('texts.billing_address') }} <span class="help">{{ trans('texts.payment_footer1') }}</span></h3>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{!! Former::text('address1')
|
||||
@ -202,6 +234,62 @@
|
||||
<p> <br/> </p>
|
||||
@endif
|
||||
|
||||
@if (!empty($accountGateway->show_shipping_address))
|
||||
<h3>{{ trans('texts.shipping_address') }}
|
||||
<span>
|
||||
<label for="shipToBillingAddress" style="font-weight:normal">
|
||||
<input id="shipToBillingAddress" type="checkbox"/>
|
||||
{{ trans('texts.ship_to_billing_address') }}
|
||||
</label>
|
||||
</span>
|
||||
</h3>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{!! Former::text('shipping_address1')
|
||||
->autocomplete('shipping address-line1')
|
||||
->placeholder(trans('texts.address1'))
|
||||
->label('') !!}
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
{!! Former::text('shipping_address2')
|
||||
->autocomplete('shipping address-line2')
|
||||
->placeholder(trans('texts.address2'))
|
||||
->label('') !!}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{!! Former::text('shipping_city')
|
||||
->autocomplete('shipping address-level2')
|
||||
->placeholder(trans('texts.city'))
|
||||
->label('') !!}
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
{!! Former::text('shipping_state')
|
||||
->autocomplete('shipping address-level1')
|
||||
->placeholder(trans('texts.state'))
|
||||
->label('') !!}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{!! Former::text('shipping_postal_code')
|
||||
->autocomplete('shipping postal-code')
|
||||
->placeholder(trans('texts.postal_code'))
|
||||
->label('') !!}
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
{!! Former::select('shipping_country_id')
|
||||
->placeholder(trans('texts.country_id'))
|
||||
->fromQuery($countries, 'name', 'id')
|
||||
->addGroupClass('shipping-country-select')
|
||||
->label('') !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p> <br/> </p>
|
||||
@endif
|
||||
|
||||
@if ($accountGateway->isGateway(GATEWAY_WEPAY) && $account->token_billing_type_id == TOKEN_BILLING_DISABLED)
|
||||
{{--- do nothing ---}}
|
||||
@else
|
||||
|
@ -67,7 +67,7 @@
|
||||
$(this).css({color:'#444444'});
|
||||
});
|
||||
|
||||
$('#country_id').combobox();
|
||||
$('#country_id, #shipping_country_id').combobox();
|
||||
$('#currency_id').combobox();
|
||||
$('#first_name').focus();
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user