mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04: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 $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
|
* @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());
|
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 = '';
|
$str = '';
|
||||||
$prefix = $addressType == ADDRESS_BILLING ? '' : 'shipping_';
|
$prefix = $addressType == ADDRESS_BILLING ? '' : 'shipping_';
|
||||||
@ -75,7 +75,7 @@ class ClientPresenter extends EntityPresenter
|
|||||||
$str .= e($country->getName()) . '<br/>';
|
$str .= e($country->getName()) . '<br/>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($str) {
|
if ($str && $showHeader) {
|
||||||
$str = '<b>' . trans('texts.' . $addressType) . '</b><br/>' . $str;
|
$str = '<b>' . trans('texts.' . $addressType) . '</b><br/>' . $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,8 +154,12 @@
|
|||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<h3>{{ trans('texts.address') }}</h3>
|
<h3>{{ trans('texts.address') }}</h3>
|
||||||
|
|
||||||
{!! $client->present()->address(ADDRESS_BILLING) !!}<br/>
|
@if ($client->addressesMatch())
|
||||||
{!! $client->present()->address(ADDRESS_SHIPPING) !!}
|
{!! $client->present()->address(ADDRESS_BILLING) !!}
|
||||||
|
@else
|
||||||
|
{!! $client->present()->address(ADDRESS_BILLING, true) !!}<br/>
|
||||||
|
{!! $client->present()->address(ADDRESS_SHIPPING, true) !!}
|
||||||
|
@endif
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user