mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 10:54:41 -04:00
bug fix to expense module - was not able to add a contact to a new vendor
This commit is contained in:
parent
172c1a0548
commit
f550e3734f
@ -75,9 +75,9 @@ class VendorController extends BaseController
|
||||
public function store(CreateVendorRequest $request)
|
||||
{
|
||||
$vendor = $this->vendorService->save($request->input());
|
||||
|
||||
|
||||
Session::flash('message', trans('texts.created_vendor'));
|
||||
|
||||
|
||||
return redirect()->to($vendor->getRoute());
|
||||
}
|
||||
|
||||
@ -167,7 +167,8 @@ class VendorController extends BaseController
|
||||
'data' => Input::old('data'),
|
||||
'account' => Auth::user()->account,
|
||||
'sizes' => Cache::get('sizes'),
|
||||
'paymentTerms' => Cache::get('paymentTerms'),
|
||||
//'paymentTerms' => Cache::get('paymentTerms'),
|
||||
'paymentTerms' => PaymentTerm::get(),
|
||||
'industries' => Cache::get('industries'),
|
||||
'currencies' => Cache::get('currencies'),
|
||||
'languages' => Cache::get('languages'),
|
||||
@ -186,9 +187,9 @@ class VendorController extends BaseController
|
||||
public function update(UpdateVendorRequest $request)
|
||||
{
|
||||
$vendor = $this->vendorService->save($request->input());
|
||||
|
||||
|
||||
Session::flash('message', trans('texts.updated_vendor'));
|
||||
|
||||
|
||||
return redirect()->to($vendor->getRoute());
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ Route::group(['middleware' => 'auth'], function() {
|
||||
Route::get('view_archive/{entity_type}/{visible}', 'AccountController@setTrashVisible');
|
||||
Route::get('hide_message', 'HomeController@hideMessage');
|
||||
Route::get('force_inline_pdf', 'UserController@forcePDFJS');
|
||||
|
||||
|
||||
Route::get('api/users', array('as'=>'api.users', 'uses'=>'UserController@getDatatable'));
|
||||
Route::resource('users', 'UserController');
|
||||
Route::post('users/bulk', 'UserController@bulk');
|
||||
@ -118,18 +118,18 @@ Route::group(['middleware' => 'auth'], function() {
|
||||
Route::post('settings/cancel_account', 'AccountController@cancelAccount');
|
||||
Route::get('settings/{section?}', 'AccountController@showSection');
|
||||
Route::post('settings/{section?}', 'AccountController@doSection');
|
||||
|
||||
|
||||
// Payment term
|
||||
Route::get('api/payment_terms', array('as'=>'api.payment_terms', 'uses'=>'PaymentTermController@getDatatable'));
|
||||
Route::resource('payment_terms', 'PaymentTermController');
|
||||
Route::post('payment_terms/bulk', 'PaymentTermController@bulk');
|
||||
|
||||
|
||||
|
||||
Route::get('account/getSearchData', array('as' => 'getSearchData', 'uses' => 'AccountController@getSearchData'));
|
||||
Route::post('user/setTheme', 'UserController@setTheme');
|
||||
Route::post('remove_logo', 'AccountController@removeLogo');
|
||||
Route::post('account/go_pro', 'AccountController@enableProPlan');
|
||||
|
||||
|
||||
Route::post('/export', 'ExportController@doExport');
|
||||
Route::post('/import', 'ImportController@doImport');
|
||||
Route::post('/import_csv', 'ImportController@doImportCSV');
|
||||
@ -149,10 +149,10 @@ Route::group(['middleware' => 'auth'], function() {
|
||||
Route::post('tasks/bulk', 'TaskController@bulk');
|
||||
|
||||
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('quotes/quote_history/{invoice_id}', 'InvoiceController@invoiceHistory');
|
||||
|
||||
|
||||
Route::resource('invoices', 'InvoiceController');
|
||||
Route::get('api/invoices/{client_id?}', array('as'=>'api.invoices', 'uses'=>'InvoiceController@getDatatable'));
|
||||
Route::get('invoices/create/{client_id?}', 'InvoiceController@create');
|
||||
@ -188,7 +188,7 @@ Route::group(['middleware' => 'auth'], function() {
|
||||
get('/resend_confirmation', 'AccountController@resendConfirmation');
|
||||
post('/update_setup', 'AppController@updateSetup');
|
||||
|
||||
|
||||
|
||||
// vendor
|
||||
Route::resource('vendors', 'VendorController');
|
||||
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::post('expenses/bulk', 'ExpenseController@bulk');
|
||||
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
|
||||
@ -287,11 +287,11 @@ if (!defined('CONTACT_EMAIL')) {
|
||||
define('ENTITY_EXPENSE', 'expense');
|
||||
define('ENTITY_PAYMENT_TERM','payment_term');
|
||||
define('ENTITY_EXPENSE_ACTIVITY','expense_activity');
|
||||
|
||||
|
||||
define('PERSON_CONTACT', 'contact');
|
||||
define('PERSON_USER', 'user');
|
||||
define('PERSON_VENDOR_CONTACT','vendorcontact');
|
||||
|
||||
|
||||
define('BASIC_SETTINGS', 'basic_settings');
|
||||
define('ADVANCED_SETTINGS', 'advanced_settings');
|
||||
|
||||
@ -369,7 +369,7 @@ if (!defined('CONTACT_EMAIL')) {
|
||||
define('ACTIVITY_TYPE_ARCHIVE_EXPENSE', 35);
|
||||
define('ACTIVITY_TYPE_DELETE_EXPENSE', 36);
|
||||
define('ACTIVITY_TYPE_RESTORE_EXPENSE', 37);
|
||||
|
||||
|
||||
define('DEFAULT_INVOICE_NUMBER', '0001');
|
||||
define('RECENTLY_VIEWED_LIMIT', 8);
|
||||
define('LOGGED_ERROR_LIMIT', 100);
|
||||
@ -404,7 +404,7 @@ if (!defined('CONTACT_EMAIL')) {
|
||||
define('MAX_NUM_VENDORS', 100);
|
||||
define('MAX_NUM_VENDORS_PRO', 20000);
|
||||
define('MAX_NUM_VENDORS_LEGACY', 500);
|
||||
|
||||
|
||||
define('INVOICE_STATUS_DRAFT', 1);
|
||||
define('INVOICE_STATUS_SENT', 2);
|
||||
define('INVOICE_STATUS_VIEWED', 3);
|
||||
|
@ -4,13 +4,14 @@ use Laracasts\Presenter\PresentableTrait;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use App\Events\ExpenseWasCreated;
|
||||
use App\Events\ExpenseWasUpdated;
|
||||
use App\Events\ExpenseWasDeleted;
|
||||
|
||||
class Expense extends EntityModel
|
||||
{
|
||||
// Expenses
|
||||
use SoftDeletes;
|
||||
use PresentableTrait;
|
||||
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $presenter = 'App\Ninja\Presenters\ExpensePresenter';
|
||||
|
||||
@ -20,7 +21,7 @@ class Expense extends EntityModel
|
||||
'exchange_rate',
|
||||
'private_notes',
|
||||
'public_notes',
|
||||
];
|
||||
];
|
||||
public function account()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Account');
|
||||
@ -40,10 +41,10 @@ class Expense extends EntityModel
|
||||
{
|
||||
if($this->expense_number)
|
||||
return $this->expense_number;
|
||||
|
||||
|
||||
return $this->public_id;
|
||||
}
|
||||
|
||||
|
||||
public function getDisplayName()
|
||||
{
|
||||
return $this->getName();
|
||||
@ -53,7 +54,7 @@ class Expense extends EntityModel
|
||||
{
|
||||
return "/expenses/{$this->public_id}";
|
||||
}
|
||||
|
||||
|
||||
public function getEntityType()
|
||||
{
|
||||
return ENTITY_EXPENSE;
|
||||
@ -91,5 +92,10 @@ Expense::updated(function ($expense) {
|
||||
event(new ExpenseWasUpdated($expense));
|
||||
});
|
||||
|
||||
Expense::deleting(function ($expense) {
|
||||
$expense->setNullValues();
|
||||
});
|
||||
|
||||
|
||||
Expense::deleted(function ($expense) {
|
||||
event(new ExpenseWasDeleted($expense));
|
||||
});
|
||||
|
@ -154,7 +154,7 @@ class Vendor extends EntityModel
|
||||
|
||||
$this->balance = $this->balance + $balanceAdjustment;
|
||||
$this->paid_to_date = $this->paid_to_date + $paidToDateAdjustment;
|
||||
|
||||
|
||||
$this->save();
|
||||
}
|
||||
|
||||
@ -167,18 +167,18 @@ class Vendor extends EntityModel
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
|
||||
public function getDisplayName()
|
||||
{
|
||||
if ($this->name) {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
|
||||
if ( ! count($this->contacts)) {
|
||||
return '';
|
||||
}
|
||||
@ -236,7 +236,7 @@ class Vendor extends EntityModel
|
||||
}
|
||||
|
||||
$accountGateway = $this->account->getGatewayConfig(GATEWAY_STRIPE);
|
||||
|
||||
|
||||
if (!$accountGateway) {
|
||||
return false;
|
||||
}
|
||||
@ -282,3 +282,11 @@ Vendor::updated(function ($vendor) {
|
||||
event(new VendorWasUpdated($vendor));
|
||||
});
|
||||
|
||||
|
||||
Vendor::deleting(function ($vendor) {
|
||||
$vendor->setNullValues();
|
||||
});
|
||||
|
||||
Vendor::deleted(function ($vendor) {
|
||||
event(new VendorWasDeleted($vendor));
|
||||
});
|
||||
|
@ -74,12 +74,11 @@
|
||||
<div class="tab-pane active" id="activity">
|
||||
{!! Datatable::table()
|
||||
->addColumn(
|
||||
trans('texts.date'),
|
||||
trans('texts.expense_date'),
|
||||
trans('texts.message'),
|
||||
trans('texts.balance'),
|
||||
trans('texts.adjustment'))
|
||||
trans('texts.amount'),
|
||||
trans('texts.public_notes'))
|
||||
->setUrl(url('api/expenseactivities/'. $expense->public_id))
|
||||
->setCustomValues('entityType', 'activity')
|
||||
->setOptions('sPaginationType', 'bootstrap')
|
||||
->setOptions('bFilter', false)
|
||||
->setOptions('aaSorting', [['0', 'desc']])
|
||||
@ -98,6 +97,7 @@
|
||||
$('.primaryDropDown:not(.dropdown-toggle)').click(function() {
|
||||
window.location = '{{ URL::to('expenses/create/' . $expense->public_id ) }}';
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function onArchiveClick() {
|
||||
|
42
resources/views/vendors/edit.blade.php
vendored
42
resources/views/vendors/edit.blade.php
vendored
@ -7,8 +7,8 @@
|
||||
|
||||
@section('content')
|
||||
|
||||
@if ($errors->first('vendor_contacts'))
|
||||
<div class="alert alert-danger">{{ trans($errors->first('vendor_contacts')) }}</div>
|
||||
@if ($errors->first('vendorcontacts'))
|
||||
<div class="alert alert-danger">{{ trans($errors->first('vendorcontacts')) }}</div>
|
||||
@endif
|
||||
|
||||
<div class="row">
|
||||
@ -19,7 +19,7 @@
|
||||
['email' => 'email']
|
||||
)->addClass('col-md-12 warn-on-exit')
|
||||
->method($method) !!}
|
||||
|
||||
|
||||
@include('partials.autocomplete_fix')
|
||||
|
||||
@if ($vendor)
|
||||
@ -36,13 +36,13 @@
|
||||
<h3 class="panel-title">{!! trans('texts.organization') !!}</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
|
||||
|
||||
{!! Former::text('name')->data_bind("attr { placeholder: placeholderName }") !!}
|
||||
{!! Former::text('id_number') !!}
|
||||
{!! Former::text('vat_number') !!}
|
||||
{!! Former::text('website') !!}
|
||||
{!! Former::text('work_phone') !!}
|
||||
|
||||
|
||||
@if (Auth::user()->isPro())
|
||||
@if ($customLabel1)
|
||||
{!! Former::text('custom_value1')->label($customLabel1) !!}
|
||||
@ -59,7 +59,7 @@
|
||||
<h3 class="panel-title">{!! trans('texts.address') !!}</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
|
||||
|
||||
{!! Former::text('address1') !!}
|
||||
{!! Former::text('address2') !!}
|
||||
{!! Former::text('city') !!}
|
||||
@ -84,21 +84,21 @@
|
||||
beforeRemove: hideContact,
|
||||
afterAdd: showContact }'>
|
||||
{!! Former::hidden('public_id')->data_bind("value: public_id, valueUpdate: 'afterkeydown',
|
||||
attr: {name: 'vendor_contacts[' + \$index() + '][public_id]'}") !!}
|
||||
{!! Former::text('first_name')->data_bind("value: first_name, valueUpdate: 'afterkeydown',
|
||||
attr: {name: 'vendor_contacts[' + \$index() + '][first_name]'}") !!}
|
||||
attr: {name: 'vendorcontacts[' + \$index() + '][public_id]'}") !!}
|
||||
{!! Former::text('first_name')->data_bind("value: first_name, valueUpdate: 'afterkeydown',
|
||||
attr: {name: 'vendorcontacts[' + \$index() + '][first_name]'}") !!}
|
||||
{!! Former::text('last_name')->data_bind("value: last_name, valueUpdate: 'afterkeydown',
|
||||
attr: {name: 'vendor_contacts[' + \$index() + '][last_name]'}") !!}
|
||||
{!! Former::text('email')->data_bind("value: email, valueUpdate: 'afterkeydown',
|
||||
attr: {name: 'vendor_contacts[' + \$index() + '][email]', id:'email'+\$index()}") !!}
|
||||
attr: {name: 'vendorcontacts[' + \$index() + '][last_name]'}") !!}
|
||||
{!! Former::text('email')->data_bind("value: email, valueUpdate: 'afterkeydown',
|
||||
attr: {name: 'vendorcontacts[' + \$index() + '][email]', id:'email'+\$index()}") !!}
|
||||
{!! 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="col-lg-8 col-lg-offset-4 bold">
|
||||
<span class="redlink bold" data-bind="visible: $parent.vendorcontacts().length > 1">
|
||||
{!! 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">
|
||||
{!! link_to('#', trans('texts.add_contact').' +', array('onclick'=>'return addContact()')) !!}
|
||||
</span>
|
||||
@ -114,7 +114,7 @@
|
||||
<h3 class="panel-title">{!! trans('texts.additional_info') !!}</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
|
||||
|
||||
{!! Former::select('currency_id')->addOption('','')
|
||||
->placeholder($account->currency ? $account->currency->name : '')
|
||||
->fromQuery($currencies, 'name', 'id') !!}
|
||||
@ -175,10 +175,10 @@
|
||||
function VendorModel(data) {
|
||||
var self = this;
|
||||
|
||||
self.vendor_contacts = ko.observableArray();
|
||||
self.vendorcontacts = ko.observableArray();
|
||||
|
||||
self.mapping = {
|
||||
'vendor_contacts': {
|
||||
'vendorcontacts': {
|
||||
create: function(options) {
|
||||
return new VendorContactModel(options.data);
|
||||
}
|
||||
@ -188,18 +188,18 @@
|
||||
if (data) {
|
||||
ko.mapping.fromJS(data, self.mapping, this);
|
||||
} else {
|
||||
self.vendor_contacts.push(new VendorContactModel());
|
||||
self.vendorcontacts.push(new VendorContactModel());
|
||||
}
|
||||
|
||||
self.placeholderName = ko.computed(function() {
|
||||
if (self.vendor_contacts().length == 0) return '';
|
||||
var contact = self.vendor_contacts()[0];
|
||||
if (self.vendorcontacts().length == 0) return '';
|
||||
var contact = self.vendorcontacts()[0];
|
||||
if (contact.first_name() || contact.last_name()) {
|
||||
return contact.first_name() + ' ' + contact.last_name();
|
||||
} else {
|
||||
return contact.email();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@if ($data)
|
||||
|
16
resources/views/vendors/show.blade.php
vendored
16
resources/views/vendors/show.blade.php
vendored
@ -100,13 +100,13 @@
|
||||
@if ($vendor->private_notes)
|
||||
<p><i>{{ $vendor->private_notes }}</i></p>
|
||||
@endif
|
||||
|
||||
|
||||
@if ($vendor->vendor_industry)
|
||||
{{ $vendor->vendor_industry->name }}<br/>
|
||||
@endif
|
||||
@if ($vendor->vendor_size)
|
||||
{{ $vendor->vendor_size->name }}<br/>
|
||||
@endif
|
||||
@endif
|
||||
|
||||
@if ($vendor->website)
|
||||
<p>{!! Utils::formatWebsite($vendor->website) !!}</p>
|
||||
@ -130,7 +130,7 @@
|
||||
@endif
|
||||
@if ($contact->phone)
|
||||
<i class="fa fa-phone" style="width: 20px"></i>{{ $contact->phone }}<br/>
|
||||
@endif
|
||||
@endif
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
@ -194,7 +194,7 @@
|
||||
trans('texts.credit_balance'),
|
||||
trans('texts.credit_date'),
|
||||
trans('texts.private_notes'))
|
||||
->setUrl(url('api/credits/' . $vendor->public_id))
|
||||
->setUrl(url('api/expenses/' . $vendor->public_id))
|
||||
->setCustomValues('entityType', 'credits')
|
||||
->setOptions('sPaginationType', 'bootstrap')
|
||||
->setOptions('bFilter', false)
|
||||
@ -266,14 +266,14 @@
|
||||
|
||||
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 : '') }}";
|
||||
|
||||
|
||||
geocoder = new google.maps.Geocoder();
|
||||
geocoder.geocode( { 'address': address}, function(results, status) {
|
||||
if (status == google.maps.GeocoderStatus.OK) {
|
||||
if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
|
||||
var result = results[0];
|
||||
map.setCenter(result.geometry.location);
|
||||
|
||||
|
||||
var infowindow = new google.maps.InfoWindow(
|
||||
{ content: '<b>'+result.formatted_address+'</b>',
|
||||
size: new google.maps.Size(150, 50)
|
||||
@ -281,9 +281,9 @@
|
||||
|
||||
var marker = new google.maps.Marker({
|
||||
position: result.geometry.location,
|
||||
map: map,
|
||||
map: map,
|
||||
title:address,
|
||||
});
|
||||
});
|
||||
google.maps.event.addListener(marker, 'click', function() {
|
||||
infowindow.open(map, marker);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user