1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Resolved issue updating company details as additional user

This commit is contained in:
Hillel Coren 2014-09-14 14:39:15 +03:00
parent f8c2edc0dc
commit 0c2b75a324
2 changed files with 31 additions and 18 deletions

View File

@ -92,6 +92,7 @@ class AccountController extends \BaseController {
'datetimeFormats' => DatetimeFormat::remember(DEFAULT_QUERY_CACHE)->get(),
'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
'languages' => Language::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
'showUser' => Auth::user()->id === Auth::user()->account->users()->first()->id,
];
return View::make('accounts.details', $data);
@ -683,9 +684,15 @@ class AccountController extends \BaseController {
{
$rules = array(
'name' => 'required',
'email' => 'email|required|unique:users,email,' . Auth::user()->id . ',id'
);
$user = Auth::user()->account->users()->first();
if (Auth::user()->id === $user->id)
{
$rules['email'] = 'email|required|unique:users,email,' . $user->id . ',id';
}
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails())
@ -715,13 +722,15 @@ class AccountController extends \BaseController {
$account->language_id = Input::get('language_id') ? Input::get('language_id') : 1; // English
$account->save();
$user = Auth::user();
$user->first_name = trim(Input::get('first_name'));
$user->last_name = trim(Input::get('last_name'));
$user->username = trim(Input::get('email'));
$user->email = trim(strtolower(Input::get('email')));
$user->phone = trim(Input::get('phone'));
$user->save();
if (Auth::user()->id === $user->id)
{
$user->first_name = trim(Input::get('first_name'));
$user->last_name = trim(Input::get('last_name'));
$user->username = trim(Input::get('email'));
$user->email = trim(strtolower(Input::get('email')));
$user->phone = trim(Input::get('phone'));
$user->save();
}
/* Logo image file */
if ($file = Input::file('logo'))

View File

@ -17,11 +17,13 @@
)) }}
{{ Former::populate($account) }}
{{ Former::populateField('first_name', $account->users()->first()->first_name) }}
{{ Former::populateField('last_name', $account->users()->first()->last_name) }}
{{ Former::populateField('email', $account->users()->first()->email) }}
{{ Former::populateField('phone', $account->users()->first()->phone) }}
@if ($showUser)
{{ Former::populateField('first_name', $account->users()->first()->first_name) }}
{{ Former::populateField('last_name', $account->users()->first()->last_name) }}
{{ Former::populateField('email', $account->users()->first()->email) }}
{{ Former::populateField('phone', $account->users()->first()->phone) }}
@endif
<div class="row">
<div class="col-md-5">
@ -56,11 +58,13 @@
<div class="col-md-5 col-md-offset-1">
{{ Former::legend('users') }}
{{ Former::text('first_name') }}
{{ Former::text('last_name') }}
{{ Former::text('email') }}
{{ Former::text('phone') }}
@if ($showUser)
{{ Former::legend('users') }}
{{ Former::text('first_name') }}
{{ Former::text('last_name') }}
{{ Former::text('email') }}
{{ Former::text('phone') }}
@endif
{{ Former::legend('localization') }}
{{ Former::select('language_id')->addOption('','')