bug fix to expense module - was not able to add a contact to a new vendor

This commit is contained in:
steenrabol 2016-01-15 11:31:12 +01:00
parent 172c1a0548
commit f550e3734f
7 changed files with 77 additions and 62 deletions

View File

@ -75,9 +75,9 @@ class VendorController extends BaseController
public function store(CreateVendorRequest $request) public function store(CreateVendorRequest $request)
{ {
$vendor = $this->vendorService->save($request->input()); $vendor = $this->vendorService->save($request->input());
Session::flash('message', trans('texts.created_vendor')); Session::flash('message', trans('texts.created_vendor'));
return redirect()->to($vendor->getRoute()); return redirect()->to($vendor->getRoute());
} }
@ -167,7 +167,8 @@ class VendorController extends BaseController
'data' => Input::old('data'), 'data' => Input::old('data'),
'account' => Auth::user()->account, 'account' => Auth::user()->account,
'sizes' => Cache::get('sizes'), 'sizes' => Cache::get('sizes'),
'paymentTerms' => Cache::get('paymentTerms'), //'paymentTerms' => Cache::get('paymentTerms'),
'paymentTerms' => PaymentTerm::get(),
'industries' => Cache::get('industries'), 'industries' => Cache::get('industries'),
'currencies' => Cache::get('currencies'), 'currencies' => Cache::get('currencies'),
'languages' => Cache::get('languages'), 'languages' => Cache::get('languages'),
@ -186,9 +187,9 @@ class VendorController extends BaseController
public function update(UpdateVendorRequest $request) public function update(UpdateVendorRequest $request)
{ {
$vendor = $this->vendorService->save($request->input()); $vendor = $this->vendorService->save($request->input());
Session::flash('message', trans('texts.updated_vendor')); Session::flash('message', trans('texts.updated_vendor'));
return redirect()->to($vendor->getRoute()); return redirect()->to($vendor->getRoute());
} }

View File

@ -87,7 +87,7 @@ Route::group(['middleware' => 'auth'], function() {
Route::get('view_archive/{entity_type}/{visible}', 'AccountController@setTrashVisible'); Route::get('view_archive/{entity_type}/{visible}', 'AccountController@setTrashVisible');
Route::get('hide_message', 'HomeController@hideMessage'); Route::get('hide_message', 'HomeController@hideMessage');
Route::get('force_inline_pdf', 'UserController@forcePDFJS'); Route::get('force_inline_pdf', 'UserController@forcePDFJS');
Route::get('api/users', array('as'=>'api.users', 'uses'=>'UserController@getDatatable')); Route::get('api/users', array('as'=>'api.users', 'uses'=>'UserController@getDatatable'));
Route::resource('users', 'UserController'); Route::resource('users', 'UserController');
Route::post('users/bulk', 'UserController@bulk'); Route::post('users/bulk', 'UserController@bulk');
@ -118,18 +118,18 @@ Route::group(['middleware' => 'auth'], function() {
Route::post('settings/cancel_account', 'AccountController@cancelAccount'); Route::post('settings/cancel_account', 'AccountController@cancelAccount');
Route::get('settings/{section?}', 'AccountController@showSection'); Route::get('settings/{section?}', 'AccountController@showSection');
Route::post('settings/{section?}', 'AccountController@doSection'); Route::post('settings/{section?}', 'AccountController@doSection');
// Payment term // Payment term
Route::get('api/payment_terms', array('as'=>'api.payment_terms', 'uses'=>'PaymentTermController@getDatatable')); Route::get('api/payment_terms', array('as'=>'api.payment_terms', 'uses'=>'PaymentTermController@getDatatable'));
Route::resource('payment_terms', 'PaymentTermController'); Route::resource('payment_terms', 'PaymentTermController');
Route::post('payment_terms/bulk', 'PaymentTermController@bulk'); Route::post('payment_terms/bulk', 'PaymentTermController@bulk');
Route::get('account/getSearchData', array('as' => 'getSearchData', 'uses' => 'AccountController@getSearchData')); Route::get('account/getSearchData', array('as' => 'getSearchData', 'uses' => 'AccountController@getSearchData'));
Route::post('user/setTheme', 'UserController@setTheme'); Route::post('user/setTheme', 'UserController@setTheme');
Route::post('remove_logo', 'AccountController@removeLogo'); Route::post('remove_logo', 'AccountController@removeLogo');
Route::post('account/go_pro', 'AccountController@enableProPlan'); Route::post('account/go_pro', 'AccountController@enableProPlan');
Route::post('/export', 'ExportController@doExport'); Route::post('/export', 'ExportController@doExport');
Route::post('/import', 'ImportController@doImport'); Route::post('/import', 'ImportController@doImport');
Route::post('/import_csv', 'ImportController@doImportCSV'); Route::post('/import_csv', 'ImportController@doImportCSV');
@ -149,10 +149,10 @@ Route::group(['middleware' => 'auth'], function() {
Route::post('tasks/bulk', 'TaskController@bulk'); Route::post('tasks/bulk', 'TaskController@bulk');
Route::get('api/recurring_invoices/{client_id?}', array('as'=>'api.recurring_invoices', 'uses'=>'InvoiceController@getRecurringDatatable')); Route::get('api/recurring_invoices/{client_id?}', array('as'=>'api.recurring_invoices', 'uses'=>'InvoiceController@getRecurringDatatable'));
Route::get('invoices/invoice_history/{invoice_id}', 'InvoiceController@invoiceHistory'); Route::get('invoices/invoice_history/{invoice_id}', 'InvoiceController@invoiceHistory');
Route::get('quotes/quote_history/{invoice_id}', 'InvoiceController@invoiceHistory'); Route::get('quotes/quote_history/{invoice_id}', 'InvoiceController@invoiceHistory');
Route::resource('invoices', 'InvoiceController'); Route::resource('invoices', 'InvoiceController');
Route::get('api/invoices/{client_id?}', array('as'=>'api.invoices', 'uses'=>'InvoiceController@getDatatable')); Route::get('api/invoices/{client_id?}', array('as'=>'api.invoices', 'uses'=>'InvoiceController@getDatatable'));
Route::get('invoices/create/{client_id?}', 'InvoiceController@create'); Route::get('invoices/create/{client_id?}', 'InvoiceController@create');
@ -188,7 +188,7 @@ Route::group(['middleware' => 'auth'], function() {
get('/resend_confirmation', 'AccountController@resendConfirmation'); get('/resend_confirmation', 'AccountController@resendConfirmation');
post('/update_setup', 'AppController@updateSetup'); post('/update_setup', 'AppController@updateSetup');
// vendor // vendor
Route::resource('vendors', 'VendorController'); Route::resource('vendors', 'VendorController');
Route::get('api/vendor', array('as'=>'api.vendors', 'uses'=>'VendorController@getDatatable')); Route::get('api/vendor', array('as'=>'api.vendors', 'uses'=>'VendorController@getDatatable'));
@ -200,8 +200,8 @@ Route::group(['middleware' => 'auth'], function() {
Route::get('expenses/create/{vendor_id?}', 'ExpenseController@create'); Route::get('expenses/create/{vendor_id?}', 'ExpenseController@create');
Route::post('expenses/bulk', 'ExpenseController@bulk'); Route::post('expenses/bulk', 'ExpenseController@bulk');
Route::get('api/expense/', array('as'=>'api.expenses', 'uses'=>'ExpenseController@getDatatable')); Route::get('api/expense/', array('as'=>'api.expenses', 'uses'=>'ExpenseController@getDatatable'));
Route::get('api/expenseactivities/{vendor_id?}', array('as'=>'api.expenseactivities', 'uses'=>'ExpenseActivityController@getDatatable')); Route::get('api/expenseactivities/{expense_id?}', array('as'=>'api.expenseactivities', 'uses'=>'ExpenseActivityController@getDatatable'));
}); });
// Route groups for API // Route groups for API
@ -287,11 +287,11 @@ if (!defined('CONTACT_EMAIL')) {
define('ENTITY_EXPENSE', 'expense'); define('ENTITY_EXPENSE', 'expense');
define('ENTITY_PAYMENT_TERM','payment_term'); define('ENTITY_PAYMENT_TERM','payment_term');
define('ENTITY_EXPENSE_ACTIVITY','expense_activity'); define('ENTITY_EXPENSE_ACTIVITY','expense_activity');
define('PERSON_CONTACT', 'contact'); define('PERSON_CONTACT', 'contact');
define('PERSON_USER', 'user'); define('PERSON_USER', 'user');
define('PERSON_VENDOR_CONTACT','vendorcontact'); define('PERSON_VENDOR_CONTACT','vendorcontact');
define('BASIC_SETTINGS', 'basic_settings'); define('BASIC_SETTINGS', 'basic_settings');
define('ADVANCED_SETTINGS', 'advanced_settings'); define('ADVANCED_SETTINGS', 'advanced_settings');
@ -369,7 +369,7 @@ if (!defined('CONTACT_EMAIL')) {
define('ACTIVITY_TYPE_ARCHIVE_EXPENSE', 35); define('ACTIVITY_TYPE_ARCHIVE_EXPENSE', 35);
define('ACTIVITY_TYPE_DELETE_EXPENSE', 36); define('ACTIVITY_TYPE_DELETE_EXPENSE', 36);
define('ACTIVITY_TYPE_RESTORE_EXPENSE', 37); define('ACTIVITY_TYPE_RESTORE_EXPENSE', 37);
define('DEFAULT_INVOICE_NUMBER', '0001'); define('DEFAULT_INVOICE_NUMBER', '0001');
define('RECENTLY_VIEWED_LIMIT', 8); define('RECENTLY_VIEWED_LIMIT', 8);
define('LOGGED_ERROR_LIMIT', 100); define('LOGGED_ERROR_LIMIT', 100);
@ -404,7 +404,7 @@ if (!defined('CONTACT_EMAIL')) {
define('MAX_NUM_VENDORS', 100); define('MAX_NUM_VENDORS', 100);
define('MAX_NUM_VENDORS_PRO', 20000); define('MAX_NUM_VENDORS_PRO', 20000);
define('MAX_NUM_VENDORS_LEGACY', 500); define('MAX_NUM_VENDORS_LEGACY', 500);
define('INVOICE_STATUS_DRAFT', 1); define('INVOICE_STATUS_DRAFT', 1);
define('INVOICE_STATUS_SENT', 2); define('INVOICE_STATUS_SENT', 2);
define('INVOICE_STATUS_VIEWED', 3); define('INVOICE_STATUS_VIEWED', 3);

View File

@ -4,13 +4,14 @@ use Laracasts\Presenter\PresentableTrait;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use App\Events\ExpenseWasCreated; use App\Events\ExpenseWasCreated;
use App\Events\ExpenseWasUpdated; use App\Events\ExpenseWasUpdated;
use App\Events\ExpenseWasDeleted;
class Expense extends EntityModel class Expense extends EntityModel
{ {
// Expenses // Expenses
use SoftDeletes; use SoftDeletes;
use PresentableTrait; use PresentableTrait;
protected $dates = ['deleted_at']; protected $dates = ['deleted_at'];
protected $presenter = 'App\Ninja\Presenters\ExpensePresenter'; protected $presenter = 'App\Ninja\Presenters\ExpensePresenter';
@ -20,7 +21,7 @@ class Expense extends EntityModel
'exchange_rate', 'exchange_rate',
'private_notes', 'private_notes',
'public_notes', 'public_notes',
]; ];
public function account() public function account()
{ {
return $this->belongsTo('App\Models\Account'); return $this->belongsTo('App\Models\Account');
@ -40,10 +41,10 @@ class Expense extends EntityModel
{ {
if($this->expense_number) if($this->expense_number)
return $this->expense_number; return $this->expense_number;
return $this->public_id; return $this->public_id;
} }
public function getDisplayName() public function getDisplayName()
{ {
return $this->getName(); return $this->getName();
@ -53,7 +54,7 @@ class Expense extends EntityModel
{ {
return "/expenses/{$this->public_id}"; return "/expenses/{$this->public_id}";
} }
public function getEntityType() public function getEntityType()
{ {
return ENTITY_EXPENSE; return ENTITY_EXPENSE;
@ -91,5 +92,10 @@ Expense::updated(function ($expense) {
event(new ExpenseWasUpdated($expense)); event(new ExpenseWasUpdated($expense));
}); });
Expense::deleting(function ($expense) {
$expense->setNullValues();
});
Expense::deleted(function ($expense) {
event(new ExpenseWasDeleted($expense));
});

View File

@ -154,7 +154,7 @@ class Vendor extends EntityModel
$this->balance = $this->balance + $balanceAdjustment; $this->balance = $this->balance + $balanceAdjustment;
$this->paid_to_date = $this->paid_to_date + $paidToDateAdjustment; $this->paid_to_date = $this->paid_to_date + $paidToDateAdjustment;
$this->save(); $this->save();
} }
@ -167,18 +167,18 @@ class Vendor extends EntityModel
{ {
return 0; return 0;
} }
public function getName() public function getName()
{ {
return $this->name; return $this->name;
} }
public function getDisplayName() public function getDisplayName()
{ {
if ($this->name) { if ($this->name) {
return $this->name; return $this->name;
} }
if ( ! count($this->contacts)) { if ( ! count($this->contacts)) {
return ''; return '';
} }
@ -236,7 +236,7 @@ class Vendor extends EntityModel
} }
$accountGateway = $this->account->getGatewayConfig(GATEWAY_STRIPE); $accountGateway = $this->account->getGatewayConfig(GATEWAY_STRIPE);
if (!$accountGateway) { if (!$accountGateway) {
return false; return false;
} }
@ -282,3 +282,11 @@ Vendor::updated(function ($vendor) {
event(new VendorWasUpdated($vendor)); event(new VendorWasUpdated($vendor));
}); });
Vendor::deleting(function ($vendor) {
$vendor->setNullValues();
});
Vendor::deleted(function ($vendor) {
event(new VendorWasDeleted($vendor));
});

View File

@ -74,12 +74,11 @@
<div class="tab-pane active" id="activity"> <div class="tab-pane active" id="activity">
{!! Datatable::table() {!! Datatable::table()
->addColumn( ->addColumn(
trans('texts.date'), trans('texts.expense_date'),
trans('texts.message'), trans('texts.message'),
trans('texts.balance'), trans('texts.amount'),
trans('texts.adjustment')) trans('texts.public_notes'))
->setUrl(url('api/expenseactivities/'. $expense->public_id)) ->setUrl(url('api/expenseactivities/'. $expense->public_id))
->setCustomValues('entityType', 'activity')
->setOptions('sPaginationType', 'bootstrap') ->setOptions('sPaginationType', 'bootstrap')
->setOptions('bFilter', false) ->setOptions('bFilter', false)
->setOptions('aaSorting', [['0', 'desc']]) ->setOptions('aaSorting', [['0', 'desc']])
@ -98,6 +97,7 @@
$('.primaryDropDown:not(.dropdown-toggle)').click(function() { $('.primaryDropDown:not(.dropdown-toggle)').click(function() {
window.location = '{{ URL::to('expenses/create/' . $expense->public_id ) }}'; window.location = '{{ URL::to('expenses/create/' . $expense->public_id ) }}';
}); });
}); });
function onArchiveClick() { function onArchiveClick() {

View File

@ -7,8 +7,8 @@
@section('content') @section('content')
@if ($errors->first('vendor_contacts')) @if ($errors->first('vendorcontacts'))
<div class="alert alert-danger">{{ trans($errors->first('vendor_contacts')) }}</div> <div class="alert alert-danger">{{ trans($errors->first('vendorcontacts')) }}</div>
@endif @endif
<div class="row"> <div class="row">
@ -19,7 +19,7 @@
['email' => 'email'] ['email' => 'email']
)->addClass('col-md-12 warn-on-exit') )->addClass('col-md-12 warn-on-exit')
->method($method) !!} ->method($method) !!}
@include('partials.autocomplete_fix') @include('partials.autocomplete_fix')
@if ($vendor) @if ($vendor)
@ -36,13 +36,13 @@
<h3 class="panel-title">{!! trans('texts.organization') !!}</h3> <h3 class="panel-title">{!! trans('texts.organization') !!}</h3>
</div> </div>
<div class="panel-body"> <div class="panel-body">
{!! Former::text('name')->data_bind("attr { placeholder: placeholderName }") !!} {!! Former::text('name')->data_bind("attr { placeholder: placeholderName }") !!}
{!! Former::text('id_number') !!} {!! Former::text('id_number') !!}
{!! Former::text('vat_number') !!} {!! Former::text('vat_number') !!}
{!! Former::text('website') !!} {!! Former::text('website') !!}
{!! Former::text('work_phone') !!} {!! Former::text('work_phone') !!}
@if (Auth::user()->isPro()) @if (Auth::user()->isPro())
@if ($customLabel1) @if ($customLabel1)
{!! Former::text('custom_value1')->label($customLabel1) !!} {!! Former::text('custom_value1')->label($customLabel1) !!}
@ -59,7 +59,7 @@
<h3 class="panel-title">{!! trans('texts.address') !!}</h3> <h3 class="panel-title">{!! trans('texts.address') !!}</h3>
</div> </div>
<div class="panel-body"> <div class="panel-body">
{!! Former::text('address1') !!} {!! Former::text('address1') !!}
{!! Former::text('address2') !!} {!! Former::text('address2') !!}
{!! Former::text('city') !!} {!! Former::text('city') !!}
@ -84,21 +84,21 @@
beforeRemove: hideContact, beforeRemove: hideContact,
afterAdd: showContact }'> afterAdd: showContact }'>
{!! Former::hidden('public_id')->data_bind("value: public_id, valueUpdate: 'afterkeydown', {!! Former::hidden('public_id')->data_bind("value: public_id, valueUpdate: 'afterkeydown',
attr: {name: 'vendor_contacts[' + \$index() + '][public_id]'}") !!} attr: {name: 'vendorcontacts[' + \$index() + '][public_id]'}") !!}
{!! Former::text('first_name')->data_bind("value: first_name, valueUpdate: 'afterkeydown', {!! Former::text('first_name')->data_bind("value: first_name, valueUpdate: 'afterkeydown',
attr: {name: 'vendor_contacts[' + \$index() + '][first_name]'}") !!} attr: {name: 'vendorcontacts[' + \$index() + '][first_name]'}") !!}
{!! Former::text('last_name')->data_bind("value: last_name, valueUpdate: 'afterkeydown', {!! Former::text('last_name')->data_bind("value: last_name, valueUpdate: 'afterkeydown',
attr: {name: 'vendor_contacts[' + \$index() + '][last_name]'}") !!} attr: {name: 'vendorcontacts[' + \$index() + '][last_name]'}") !!}
{!! Former::text('email')->data_bind("value: email, valueUpdate: 'afterkeydown', {!! Former::text('email')->data_bind("value: email, valueUpdate: 'afterkeydown',
attr: {name: 'vendor_contacts[' + \$index() + '][email]', id:'email'+\$index()}") !!} attr: {name: 'vendorcontacts[' + \$index() + '][email]', id:'email'+\$index()}") !!}
{!! Former::text('phone')->data_bind("value: phone, valueUpdate: 'afterkeydown', {!! Former::text('phone')->data_bind("value: phone, valueUpdate: 'afterkeydown',
attr: {name: 'vendor_contacts[' + \$index() + '][phone]'}") !!} attr: {name: 'vendorcontacts[' + \$index() + '][phone]'}") !!}
<div class="form-group"> <div class="form-group">
<div class="col-lg-8 col-lg-offset-4 bold"> <div class="col-lg-8 col-lg-offset-4 bold">
<span class="redlink bold" data-bind="visible: $parent.vendorcontacts().length > 1"> <span class="redlink bold" data-bind="visible: $parent.vendorcontacts().length > 1">
{!! link_to('#', trans('texts.remove_contact').' -', array('data-bind'=>'click: $parent.removeContact')) !!} {!! link_to('#', trans('texts.remove_contact').' -', array('data-bind'=>'click: $parent.removeContact')) !!}
</span> </span>
<span data-bind="visible: $index() === ($parent.vendorcontacts().length - 1)" class="pull-right greenlink bold"> <span data-bind="visible: $index() === ($parent.vendorcontacts().length - 1)" class="pull-right greenlink bold">
{!! link_to('#', trans('texts.add_contact').' +', array('onclick'=>'return addContact()')) !!} {!! link_to('#', trans('texts.add_contact').' +', array('onclick'=>'return addContact()')) !!}
</span> </span>
@ -114,7 +114,7 @@
<h3 class="panel-title">{!! trans('texts.additional_info') !!}</h3> <h3 class="panel-title">{!! trans('texts.additional_info') !!}</h3>
</div> </div>
<div class="panel-body"> <div class="panel-body">
{!! Former::select('currency_id')->addOption('','') {!! Former::select('currency_id')->addOption('','')
->placeholder($account->currency ? $account->currency->name : '') ->placeholder($account->currency ? $account->currency->name : '')
->fromQuery($currencies, 'name', 'id') !!} ->fromQuery($currencies, 'name', 'id') !!}
@ -175,10 +175,10 @@
function VendorModel(data) { function VendorModel(data) {
var self = this; var self = this;
self.vendor_contacts = ko.observableArray(); self.vendorcontacts = ko.observableArray();
self.mapping = { self.mapping = {
'vendor_contacts': { 'vendorcontacts': {
create: function(options) { create: function(options) {
return new VendorContactModel(options.data); return new VendorContactModel(options.data);
} }
@ -188,18 +188,18 @@
if (data) { if (data) {
ko.mapping.fromJS(data, self.mapping, this); ko.mapping.fromJS(data, self.mapping, this);
} else { } else {
self.vendor_contacts.push(new VendorContactModel()); self.vendorcontacts.push(new VendorContactModel());
} }
self.placeholderName = ko.computed(function() { self.placeholderName = ko.computed(function() {
if (self.vendor_contacts().length == 0) return ''; if (self.vendorcontacts().length == 0) return '';
var contact = self.vendor_contacts()[0]; var contact = self.vendorcontacts()[0];
if (contact.first_name() || contact.last_name()) { if (contact.first_name() || contact.last_name()) {
return contact.first_name() + ' ' + contact.last_name(); return contact.first_name() + ' ' + contact.last_name();
} else { } else {
return contact.email(); return contact.email();
} }
}); });
} }
@if ($data) @if ($data)

View File

@ -100,13 +100,13 @@
@if ($vendor->private_notes) @if ($vendor->private_notes)
<p><i>{{ $vendor->private_notes }}</i></p> <p><i>{{ $vendor->private_notes }}</i></p>
@endif @endif
@if ($vendor->vendor_industry) @if ($vendor->vendor_industry)
{{ $vendor->vendor_industry->name }}<br/> {{ $vendor->vendor_industry->name }}<br/>
@endif @endif
@if ($vendor->vendor_size) @if ($vendor->vendor_size)
{{ $vendor->vendor_size->name }}<br/> {{ $vendor->vendor_size->name }}<br/>
@endif @endif
@if ($vendor->website) @if ($vendor->website)
<p>{!! Utils::formatWebsite($vendor->website) !!}</p> <p>{!! Utils::formatWebsite($vendor->website) !!}</p>
@ -130,7 +130,7 @@
@endif @endif
@if ($contact->phone) @if ($contact->phone)
<i class="fa fa-phone" style="width: 20px"></i>{{ $contact->phone }}<br/> <i class="fa fa-phone" style="width: 20px"></i>{{ $contact->phone }}<br/>
@endif @endif
@endforeach @endforeach
</div> </div>
@ -194,7 +194,7 @@
trans('texts.credit_balance'), trans('texts.credit_balance'),
trans('texts.credit_date'), trans('texts.credit_date'),
trans('texts.private_notes')) trans('texts.private_notes'))
->setUrl(url('api/credits/' . $vendor->public_id)) ->setUrl(url('api/expenses/' . $vendor->public_id))
->setCustomValues('entityType', 'credits') ->setCustomValues('entityType', 'credits')
->setOptions('sPaginationType', 'bootstrap') ->setOptions('sPaginationType', 'bootstrap')
->setOptions('bFilter', false) ->setOptions('bFilter', false)
@ -266,14 +266,14 @@
var map = new google.maps.Map(mapCanvas, mapOptions) var map = new google.maps.Map(mapCanvas, mapOptions)
var address = "{{ "{$vendor->address1} {$vendor->address2} {$vendor->city} {$vendor->state} {$vendor->postal_code} " . ($vendor->country ? $vendor->country->name : '') }}"; var address = "{{ "{$vendor->address1} {$vendor->address2} {$vendor->city} {$vendor->state} {$vendor->postal_code} " . ($vendor->country ? $vendor->country->name : '') }}";
geocoder = new google.maps.Geocoder(); geocoder = new google.maps.Geocoder();
geocoder.geocode( { 'address': address}, function(results, status) { geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) { if (status == google.maps.GeocoderStatus.OK) {
if (status != google.maps.GeocoderStatus.ZERO_RESULTS) { if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
var result = results[0]; var result = results[0];
map.setCenter(result.geometry.location); map.setCenter(result.geometry.location);
var infowindow = new google.maps.InfoWindow( var infowindow = new google.maps.InfoWindow(
{ content: '<b>'+result.formatted_address+'</b>', { content: '<b>'+result.formatted_address+'</b>',
size: new google.maps.Size(150, 50) size: new google.maps.Size(150, 50)
@ -281,9 +281,9 @@
var marker = new google.maps.Marker({ var marker = new google.maps.Marker({
position: result.geometry.location, position: result.geometry.location,
map: map, map: map,
title:address, title:address,
}); });
google.maps.event.addListener(marker, 'click', function() { google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker); infowindow.open(map, marker);
}); });