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
{!! Former::select('size_id')->addOption('','') @@ -327,9 +336,11 @@ // button handles to copy the address $('#copyBillingDiv button').click(function() { copyAddress(); + $('#copyBillingDiv').hide(); }); $('#copyShippingDiv button').click(function() { copyAddress(true); + $('#copyShippingDiv').hide(); }); // show/hide buttons based on loaded values diff --git a/resources/views/partials/google_geocode.blade.php b/resources/views/partials/google_geocode.blade.php new file mode 100644 index 000000000000..8af6593900fd --- /dev/null +++ b/resources/views/partials/google_geocode.blade.php @@ -0,0 +1,107 @@ + + diff --git a/resources/views/vendors/edit.blade.php b/resources/views/vendors/edit.blade.php index b28183978cb5..743a4562bd71 100644 --- a/resources/views/vendors/edit.blade.php +++ b/resources/views/vendors/edit.blade.php @@ -1,10 +1,15 @@ @extends('header') - @section('onReady') $('input#name').focus(); @stop +@section('head') + @if (config('ninja.google_maps_enabled')) + @include('partials.google_geocode') + @endif +@stop + @section('content') @if ($errors->first('vendor_contacts')) @@ -52,13 +57,15 @@

{!! trans('texts.address') !!}

-
+
{!! Former::text('address1') !!} {!! 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') !!}