mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-14 11:04:39 -04:00
Optional shipping address #1088
This commit is contained in:
parent
4de9b614dc
commit
b202b62a23
@ -451,6 +451,9 @@ if (! defined('APP_NAME')) {
|
|||||||
define('FILTER_INVOICE_DATE', 'invoice_date');
|
define('FILTER_INVOICE_DATE', 'invoice_date');
|
||||||
define('FILTER_PAYMENT_DATE', 'payment_date');
|
define('FILTER_PAYMENT_DATE', 'payment_date');
|
||||||
|
|
||||||
|
define('ADDRESS_BILLING', 'billing_address');
|
||||||
|
define('ADDRESS_SHIPPING', 'shipping_address');
|
||||||
|
|
||||||
define('SOCIAL_GOOGLE', 'Google');
|
define('SOCIAL_GOOGLE', 'Google');
|
||||||
define('SOCIAL_FACEBOOK', 'Facebook');
|
define('SOCIAL_FACEBOOK', 'Facebook');
|
||||||
define('SOCIAL_GITHUB', 'GitHub');
|
define('SOCIAL_GITHUB', 'GitHub');
|
||||||
|
@ -170,7 +170,7 @@ class ExportController extends BaseController
|
|||||||
|
|
||||||
if ($request->input('include') === 'all' || $request->input('clients')) {
|
if ($request->input('include') === 'all' || $request->input('clients')) {
|
||||||
$data['clients'] = Client::scope()
|
$data['clients'] = Client::scope()
|
||||||
->with('user', 'contacts', 'country', 'currency')
|
->with('user', 'contacts', 'country', 'currency', 'shipping_country')
|
||||||
->withArchived()
|
->withArchived()
|
||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,12 @@ class Client extends EntityModel
|
|||||||
'quote_number_counter',
|
'quote_number_counter',
|
||||||
'public_notes',
|
'public_notes',
|
||||||
'task_rate',
|
'task_rate',
|
||||||
|
'shipping_address1',
|
||||||
|
'shipping_address2',
|
||||||
|
'shipping_city',
|
||||||
|
'shipping_state',
|
||||||
|
'shipping_postal_code',
|
||||||
|
'shipping_country_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
@ -179,6 +185,14 @@ class Client extends EntityModel
|
|||||||
return $this->belongsTo('App\Models\Country');
|
return $this->belongsTo('App\Models\Country');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||||
|
*/
|
||||||
|
public function shipping_country()
|
||||||
|
{
|
||||||
|
return $this->belongsTo('App\Models\Country');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||||
*/
|
*/
|
||||||
|
@ -11,6 +11,11 @@ class ClientPresenter extends EntityPresenter
|
|||||||
return $this->entity->country ? $this->entity->country->name : '';
|
return $this->entity->country ? $this->entity->country->name : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function shipping_country()
|
||||||
|
{
|
||||||
|
return $this->entity->shipping_country ? $this->entity->shipping_country->name : '';
|
||||||
|
}
|
||||||
|
|
||||||
public function balance()
|
public function balance()
|
||||||
{
|
{
|
||||||
$client = $this->entity;
|
$client = $this->entity;
|
||||||
@ -51,6 +56,49 @@ class ClientPresenter extends EntityPresenter
|
|||||||
return sprintf('%s: %s %s', trans('texts.payment_terms'), trans('texts.payment_terms_net'), $client->defaultDaysDue());
|
return sprintf('%s: %s %s', trans('texts.payment_terms'), trans('texts.payment_terms_net'), $client->defaultDaysDue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function address($addressType = ADDRESS_BILLING)
|
||||||
|
{
|
||||||
|
$str = '';
|
||||||
|
$prefix = $addressType == ADDRESS_BILLING ? '' : 'shipping_';
|
||||||
|
$client = $this->entity;
|
||||||
|
|
||||||
|
if ($address1 = $client->{$prefix . 'address1'}) {
|
||||||
|
$str .= e($address1) . '<br/>';
|
||||||
|
}
|
||||||
|
if ($address2 = $client->{$prefix . 'address2'}) {
|
||||||
|
$str .= e($address2) . '<br/>';
|
||||||
|
}
|
||||||
|
if ($cityState = $this->getCityState($addressType)) {
|
||||||
|
$str .= e($cityState) . '<br/>';
|
||||||
|
}
|
||||||
|
if ($country = $client->{$prefix . 'country'}) {
|
||||||
|
$str .= e($country->name) . '<br/>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($str) {
|
||||||
|
$str = '<b>' . trans('texts.' . $addressType) . '</b><br/>' . $str;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $str;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getCityState($addressType = ADDRESS_BILLING)
|
||||||
|
{
|
||||||
|
$client = $this->entity;
|
||||||
|
$prefix = $addressType == ADDRESS_BILLING ? '' : 'shipping_';
|
||||||
|
$swap = $client->{$prefix . 'country'} && $client->{$prefix . 'country'}->swap_postal_code;
|
||||||
|
|
||||||
|
$city = e($client->{$prefix . 'city'});
|
||||||
|
$state = e($client->{$prefix . 'state'});
|
||||||
|
$postalCode = e($client->{$prefix . 'post_code'});
|
||||||
|
|
||||||
|
return Utils::cityStateZip($city, $state, $postalCode, $swap);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -38,6 +38,12 @@ class ClientTransformer extends EntityTransformer
|
|||||||
* @SWG\Property(property="id_number", type="string", example="123456")
|
* @SWG\Property(property="id_number", type="string", example="123456")
|
||||||
* @SWG\Property(property="language_id", type="integer", example=1)
|
* @SWG\Property(property="language_id", type="integer", example=1)
|
||||||
* @SWG\Property(property="task_rate", type="number", format="float", example=10)
|
* @SWG\Property(property="task_rate", type="number", format="float", example=10)
|
||||||
|
* @SWG\Property(property="shipping_address1", type="string", example="10 Main St.")
|
||||||
|
* @SWG\Property(property="shipping_address2", type="string", example="1st Floor")
|
||||||
|
* @SWG\Property(property="shipping_city", type="string", example="New York")
|
||||||
|
* @SWG\Property(property="shipping_state", type="string", example="NY")
|
||||||
|
* @SWG\Property(property="shipping_postal_code", type="string", example=10010)
|
||||||
|
* @SWG\Property(property="shipping_country_id", type="integer", example=840)
|
||||||
*/
|
*/
|
||||||
protected $defaultIncludes = [
|
protected $defaultIncludes = [
|
||||||
'contacts',
|
'contacts',
|
||||||
@ -137,6 +143,12 @@ class ClientTransformer extends EntityTransformer
|
|||||||
'invoice_number_counter' => (int) $client->invoice_number_counter,
|
'invoice_number_counter' => (int) $client->invoice_number_counter,
|
||||||
'quote_number_counter' => (int) $client->quote_number_counter,
|
'quote_number_counter' => (int) $client->quote_number_counter,
|
||||||
'task_rate' => (float) $client->task_rate,
|
'task_rate' => (float) $client->task_rate,
|
||||||
|
'shipping_address1' => $client->shipping_address1,
|
||||||
|
'shipping_address2' => $client->shipping_address2,
|
||||||
|
'shipping_city' => $client->shipping_city,
|
||||||
|
'shipping_state' => $client->shipping_state,
|
||||||
|
'shipping_postal_code' => $client->shipping_postal_code,
|
||||||
|
'shipping_country_id' => (int) $client->shipping_country_id,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,18 @@ class AddSubdomainToLookups extends Migration
|
|||||||
$table->decimal('exchange_rate', 13, 4)->default(1)->change();
|
$table->decimal('exchange_rate', 13, 4)->default(1)->change();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Schema::table('clients', function ($table) {
|
||||||
|
$table->string('shipping_address1')->nullable();
|
||||||
|
$table->string('shipping_address2')->nullable();
|
||||||
|
$table->string('shipping_city')->nullable();
|
||||||
|
$table->string('shipping_state')->nullable();
|
||||||
|
$table->string('shipping_postal_code')->nullable();
|
||||||
|
$table->unsignedInteger('shipping_country_id')->nullable();
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('clients', function ($table) {
|
||||||
|
$table->foreign('shipping_country_id')->references('id')->on('currencies');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,5 +55,15 @@ class AddSubdomainToLookups extends Migration
|
|||||||
$table->dropColumn('exchange_rate');
|
$table->dropColumn('exchange_rate');
|
||||||
$table->dropColumn('exchange_currency_id');
|
$table->dropColumn('exchange_currency_id');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Schema::table('clients', function ($table) {
|
||||||
|
$table->dropForeign('clients_shipping_country_id_foreign');
|
||||||
|
$table->dropColumn('shipping_address1');
|
||||||
|
$table->dropColumn('shipping_address2');
|
||||||
|
$table->dropColumn('shipping_city');
|
||||||
|
$table->dropColumn('shipping_state');
|
||||||
|
$table->dropColumn('shipping_postal_code');
|
||||||
|
$table->dropColumn('shipping_country_id');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2526,6 +2526,20 @@ $LANG = array(
|
|||||||
'client_login' => 'Client Login',
|
'client_login' => 'Client Login',
|
||||||
'converted_amount' => 'Converted Amount',
|
'converted_amount' => 'Converted Amount',
|
||||||
'default' => 'Default',
|
'default' => 'Default',
|
||||||
|
'shipping_address' => 'Shipping Address',
|
||||||
|
'bllling_address' => 'Billing Address',
|
||||||
|
'billing_address1' => 'Billing Street',
|
||||||
|
'billing_address2' => 'Billing Apt/Suite',
|
||||||
|
'billing_city' => 'Billing City',
|
||||||
|
'billing_state' => 'Billing State/Province',
|
||||||
|
'billing_postal_code' => 'Billing Postal Code',
|
||||||
|
'billing_country' => 'Billing Country',
|
||||||
|
'shipping_address1' => 'Shipping Street',
|
||||||
|
'shipping_address2' => 'Shipping Apt/Suite',
|
||||||
|
'shipping_city' => 'Shipping City',
|
||||||
|
'shipping_state' => 'Shipping State/Province',
|
||||||
|
'shipping_postal_code' => 'Shipping Postal Code',
|
||||||
|
'shipping_country' => 'Shipping Country',
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -74,6 +74,18 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
|
||||||
|
<div role="tabpanel">
|
||||||
|
<ul class="nav nav-tabs" role="tablist" style="border: none">
|
||||||
|
<li role="presentation" class="active">
|
||||||
|
<a href="#billing_address" aria-controls="billing_address" role="tab" data-toggle="tab">{{ trans('texts.billing_address') }}</a>
|
||||||
|
</li>
|
||||||
|
<li role="presentation">
|
||||||
|
<a href="#shipping_address" aria-controls="shipping_address" role="tab" data-toggle="tab">{{ trans('texts.shipping_address') }}</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="tab-content" style="padding-top:24px;">
|
||||||
|
<div role="tabpanel" class="tab-pane active" id="billing_address">
|
||||||
{!! Former::text('address1') !!}
|
{!! Former::text('address1') !!}
|
||||||
{!! Former::text('address2') !!}
|
{!! Former::text('address2') !!}
|
||||||
{!! Former::text('city') !!}
|
{!! Former::text('city') !!}
|
||||||
@ -81,6 +93,17 @@
|
|||||||
{!! Former::text('postal_code') !!}
|
{!! Former::text('postal_code') !!}
|
||||||
{!! Former::select('country_id')->addOption('','')
|
{!! Former::select('country_id')->addOption('','')
|
||||||
->fromQuery($countries, 'name', 'id') !!}
|
->fromQuery($countries, 'name', 'id') !!}
|
||||||
|
</div>
|
||||||
|
<div role="tabpanel" class="tab-pane" id="shipping_address">
|
||||||
|
{!! Former::text('shipping_address1')->label('address1') !!}
|
||||||
|
{!! Former::text('shipping_address2')->label('address2') !!}
|
||||||
|
{!! Former::text('shipping_city')->label('city') !!}
|
||||||
|
{!! Former::text('shipping_state')->label('state') !!}
|
||||||
|
{!! Former::text('shipping_postal_code')->label('postal_code') !!}
|
||||||
|
{!! Former::select('shipping_country_id')->addOption('','')
|
||||||
|
->fromQuery($countries, 'name', 'id')->label('country_id') !!}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -233,7 +256,7 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
$('#country_id').combobox();
|
$('#country_id, #shipping_country_id').combobox();
|
||||||
});
|
});
|
||||||
|
|
||||||
function ContactModel(data) {
|
function ContactModel(data) {
|
||||||
|
@ -98,18 +98,8 @@
|
|||||||
<p><i class="fa fa-vat-number" style="width: 20px"></i>{{ trans('texts.vat_number').': '.$client->vat_number }}</p>
|
<p><i class="fa fa-vat-number" style="width: 20px"></i>{{ trans('texts.vat_number').': '.$client->vat_number }}</p>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if ($client->address1)
|
{!! $client->present()->address(ADDRESS_BILLING) !!}
|
||||||
{{ $client->address1 }}<br/>
|
{!! $client->present()->address(ADDRESS_SHIPPING) !!}
|
||||||
@endif
|
|
||||||
@if ($client->address2)
|
|
||||||
{{ $client->address2 }}<br/>
|
|
||||||
@endif
|
|
||||||
@if ($client->getCityState())
|
|
||||||
{{ $client->getCityState() }}<br/>
|
|
||||||
@endif
|
|
||||||
@if ($client->country)
|
|
||||||
{{ $client->country->name }}<br/>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
|
@ -5,12 +5,18 @@
|
|||||||
@endif
|
@endif
|
||||||
<td>{{ trans('texts.balance') }}</td>
|
<td>{{ trans('texts.balance') }}</td>
|
||||||
<td>{{ trans('texts.paid_to_date') }}</td>
|
<td>{{ trans('texts.paid_to_date') }}</td>
|
||||||
<td>{{ trans('texts.address1') }}</td>
|
<td>{{ trans('texts.billing_address1') }}</td>
|
||||||
<td>{{ trans('texts.address2') }}</td>
|
<td>{{ trans('texts.billing_address2') }}</td>
|
||||||
<td>{{ trans('texts.city') }}</td>
|
<td>{{ trans('texts.billing_city') }}</td>
|
||||||
<td>{{ trans('texts.state') }}</td>
|
<td>{{ trans('texts.billing_state') }}</td>
|
||||||
<td>{{ trans('texts.postal_code') }}</td>
|
<td>{{ trans('texts.billing_postal_code') }}</td>
|
||||||
<td>{{ trans('texts.country') }}</td>
|
<td>{{ trans('texts.billing_country') }}</td>
|
||||||
|
<td>{{ trans('texts.shipping_address1') }}</td>
|
||||||
|
<td>{{ trans('texts.shipping_address2') }}</td>
|
||||||
|
<td>{{ trans('texts.shipping_city') }}</td>
|
||||||
|
<td>{{ trans('texts.shipping_state') }}</td>
|
||||||
|
<td>{{ trans('texts.shipping_postal_code') }}</td>
|
||||||
|
<td>{{ trans('texts.shipping_country') }}</td>
|
||||||
<td>{{ trans('texts.id_number') }}</td>
|
<td>{{ trans('texts.id_number') }}</td>
|
||||||
<td>{{ trans('texts.vat_number') }}</td>
|
<td>{{ trans('texts.vat_number') }}</td>
|
||||||
<td>{{ trans('texts.website') }}</td>
|
<td>{{ trans('texts.website') }}</td>
|
||||||
@ -50,6 +56,12 @@
|
|||||||
<td>{{ $client->state }}</td>
|
<td>{{ $client->state }}</td>
|
||||||
<td>{{ $client->postal_code }}</td>
|
<td>{{ $client->postal_code }}</td>
|
||||||
<td>{{ $client->present()->country }}</td>
|
<td>{{ $client->present()->country }}</td>
|
||||||
|
<td>{{ $client->shipping_address1 }}</td>
|
||||||
|
<td>{{ $client->shipping_address2 }}</td>
|
||||||
|
<td>{{ $client->shipping_city }}</td>
|
||||||
|
<td>{{ $client->shipping_state }}</td>
|
||||||
|
<td>{{ $client->shipping_postal_code }}</td>
|
||||||
|
<td>{{ $client->present()->shipping_country }}</td>
|
||||||
<td>{{ $client->id_number }}</td>
|
<td>{{ $client->id_number }}</td>
|
||||||
<td>{{ $client->vat_number }}</td>
|
<td>{{ $client->vat_number }}</td>
|
||||||
<td>{{ $client->website }}</td>
|
<td>{{ $client->website }}</td>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user