diff --git a/app/Models/Account.php b/app/Models/Account.php index 1e2f8bda1860..b922f3162f46 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -760,6 +760,14 @@ class Account extends Eloquent return $this->currency_id ?: DEFAULT_CURRENCY; } + /** + * @return mixed + */ + public function getCountryId() + { + return $this->country_id ?: DEFAULT_COUNTRY; + } + /** * @param $date * diff --git a/config/ninja.php b/config/ninja.php index 5fb1ffd754e7..a7ca1c793652 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -26,4 +26,8 @@ return [ // privacy policy 'privacy_policy_url' => env('PRIVACY_POLICY_URL', ''), + // Google maps + 'google_maps_enabled' => env('GOOGLE_MAPS_ENABLED', true), + 'google_maps_api_key' => env('GOOGLE_MAPS_API_KEY', ''), + ]; diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 35b5971522df..bebfecf6caac 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -2823,6 +2823,8 @@ $LANG = array( 'paid_invoice' => 'Paid Invoice', 'unapproved_quote' => 'Unapproved Quote', 'unapproved_proposal' => 'Unapproved Proposal', + 'autofills_city_state' => 'Auto-fills city/state', + 'no_match_found' => 'No match found', ); diff --git a/resources/views/clients/edit.blade.php b/resources/views/clients/edit.blade.php index dae056332eed..df8a7498d9b6 100644 --- a/resources/views/clients/edit.blade.php +++ b/resources/views/clients/edit.blade.php @@ -4,6 +4,12 @@ $('input#name').focus(); @stop +@section('head') + @if (config('ninja.google_maps_enabled')) + @include('partials.google_geocode') + @endif +@stop + @section('content') @if ($errors->first('contacts')) @@ -87,7 +93,8 @@ {!! Former::text('address2') !!} {!! Former::text('city') !!} {!! Former::text('state') !!} - {!! Former::text('postal_code') !!} + {!! Former::text('postal_code') + ->onchange(config('ninja.google_maps_enabled') ? 'lookupPostalCode()' : '') !!} {!! Former::select('country_id')->addOption('','') ->fromQuery($countries, 'name', 'id') !!} @@ -104,7 +111,9 @@ {!! 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::text('shipping_postal_code') + ->onchange(config('ninja.google_maps_enabled') ? 'lookupPostalCode(true)' : '') + ->label('postal_code') !!} {!! Former::select('shipping_country_id')->addOption('','') ->fromQuery($countries, 'name', 'id')->label('country_id') !!} @@ -239,7 +248,7 @@ @foreach (App\Models\Account::$customMessageTypes as $type) {!! Former::textarea('custom_messages[' . $type . ']') ->label($type) !!} - @endforeach + @endforeach