mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
Don't show both addresses if they're the same
This commit is contained in:
parent
1aa59512fe
commit
7bc91e5b0b
@ -386,6 +386,29 @@ class Client extends EntityModel
|
||||
return $this->hasAddress() && env('GOOGLE_MAPS_ENABLED') !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function addressesMatch()
|
||||
{
|
||||
$fields = [
|
||||
'address1',
|
||||
'address2',
|
||||
'city',
|
||||
'state',
|
||||
'postal_code',
|
||||
'country_id',
|
||||
];
|
||||
|
||||
foreach ($fields as $field) {
|
||||
if ($this->$field != $this->{'shipping_' . $field}) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
@ -56,7 +56,7 @@ class ClientPresenter extends EntityPresenter
|
||||
return sprintf('%s: %s %s', trans('texts.payment_terms'), trans('texts.payment_terms_net'), $client->defaultDaysDue());
|
||||
}
|
||||
|
||||
public function address($addressType = ADDRESS_BILLING)
|
||||
public function address($addressType = ADDRESS_BILLING, $showHeader = false)
|
||||
{
|
||||
$str = '';
|
||||
$prefix = $addressType == ADDRESS_BILLING ? '' : 'shipping_';
|
||||
@ -75,7 +75,7 @@ class ClientPresenter extends EntityPresenter
|
||||
$str .= e($country->getName()) . '<br/>';
|
||||
}
|
||||
|
||||
if ($str) {
|
||||
if ($str && $showHeader) {
|
||||
$str = '<b>' . trans('texts.' . $addressType) . '</b><br/>' . $str;
|
||||
}
|
||||
|
||||
|
@ -154,8 +154,12 @@
|
||||
<div class="col-md-3">
|
||||
<h3>{{ trans('texts.address') }}</h3>
|
||||
|
||||
{!! $client->present()->address(ADDRESS_BILLING) !!}<br/>
|
||||
{!! $client->present()->address(ADDRESS_SHIPPING) !!}
|
||||
@if ($client->addressesMatch())
|
||||
{!! $client->present()->address(ADDRESS_BILLING) !!}
|
||||
@else
|
||||
{!! $client->present()->address(ADDRESS_BILLING, true) !!}<br/>
|
||||
{!! $client->present()->address(ADDRESS_SHIPPING, true) !!}
|
||||
@endif
|
||||
|
||||
</div>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user