Moved unlink to separate page

This commit is contained in:
Hillel Coren 2015-08-03 10:15:58 +03:00
parent c91ac017ad
commit 559a7d8a46
22 changed files with 168 additions and 63 deletions

View File

@ -639,6 +639,7 @@ class AccountController extends BaseController
{ {
$rules = array( $rules = array(
'name' => 'required', 'name' => 'required',
'logo' => 'sometimes|max:1024|mimes:jpeg,gif,png',
); );
$user = Auth::user()->account->users()->orderBy('id')->first(); $user = Auth::user()->account->users()->orderBy('id')->first();

View File

@ -60,8 +60,7 @@ class InvoiceController extends BaseController
'columns' => Utils::trans(['checkbox', 'invoice_number', 'client', 'invoice_date', 'invoice_total', 'balance_due', 'due_date', 'status', 'action']), 'columns' => Utils::trans(['checkbox', 'invoice_number', 'client', 'invoice_date', 'invoice_total', 'balance_due', 'due_date', 'status', 'action']),
]; ];
$recurringInvoices = Invoice::scope() $recurringInvoices = Invoice::scope()->where('is_recurring', '=', true);
->where('is_recurring', '=', true);
if (Session::get('show_trash:invoice')) { if (Session::get('show_trash:invoice')) {
$recurringInvoices->withTrashed(); $recurringInvoices->withTrashed();

View File

@ -543,16 +543,17 @@ class PaymentController extends BaseController
->withErrors($validator) ->withErrors($validator)
->withInput(); ->withInput();
} }
}
if ($onSite && $accountGateway->update_address) {
$client->address1 = trim(Input::get('address1')); if ($accountGateway->update_address) {
$client->address2 = trim(Input::get('address2')); $client->address1 = trim(Input::get('address1'));
$client->city = trim(Input::get('city')); $client->address2 = trim(Input::get('address2'));
$client->state = trim(Input::get('state')); $client->city = trim(Input::get('city'));
$client->postal_code = trim(Input::get('postal_code')); $client->state = trim(Input::get('state'));
$client->country_id = Input::get('country_id'); $client->postal_code = trim(Input::get('postal_code'));
$client->save(); $client->country_id = Input::get('country_id');
$client->save();
}
} }
try { try {

View File

@ -377,6 +377,15 @@ class UserController extends BaseController
Session::put(SESSION_USER_ACCOUNTS, $users); Session::put(SESSION_USER_ACCOUNTS, $users);
Session::flash('message', trans('texts.unlinked_account')); Session::flash('message', trans('texts.unlinked_account'));
return Redirect::to($referer); return Redirect::to('/dashboard');
}
public function manageCompanies()
{
$data = [
];
return View::make('users.account_management', $data);
} }
} }

View File

@ -1,5 +1,7 @@
<?php <?php
//dd("We're currently undergoing a brief maintenance, we'll be right back.");
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Application Routes | Application Routes
@ -95,6 +97,7 @@ Route::group(['middleware' => 'auth'], function() {
Route::post('users/change_password', 'UserController@changePassword'); Route::post('users/change_password', 'UserController@changePassword');
Route::get('/switch_account/{user_id}', 'UserController@switchAccount'); Route::get('/switch_account/{user_id}', 'UserController@switchAccount');
Route::get('/unlink_account/{user_account_id}/{user_id}', 'UserController@unlinkAccount'); Route::get('/unlink_account/{user_account_id}/{user_id}', 'UserController@unlinkAccount');
Route::get('/manage_companies', 'UserController@manageCompanies');
Route::get('api/tokens', array('as'=>'api.tokens', 'uses'=>'TokenController@getDatatable')); Route::get('api/tokens', array('as'=>'api.tokens', 'uses'=>'TokenController@getDatatable'));
Route::resource('tokens', 'TokenController'); Route::resource('tokens', 'TokenController');
@ -363,7 +366,7 @@ define('NINJA_GATEWAY_ID', GATEWAY_STRIPE);
define('NINJA_GATEWAY_CONFIG', ''); define('NINJA_GATEWAY_CONFIG', '');
define('NINJA_WEB_URL', 'https://www.invoiceninja.com'); define('NINJA_WEB_URL', 'https://www.invoiceninja.com');
define('NINJA_APP_URL', 'https://app.invoiceninja.com'); define('NINJA_APP_URL', 'https://app.invoiceninja.com');
define('NINJA_VERSION', '2.2.2'); define('NINJA_VERSION', '2.3.0');
define('NINJA_DATE', '2000-01-01'); define('NINJA_DATE', '2000-01-01');
define('NINJA_FROM_EMAIL', 'maildelivery@invoiceninja.com'); define('NINJA_FROM_EMAIL', 'maildelivery@invoiceninja.com');

View File

@ -315,7 +315,7 @@ class Account extends Eloquent
public function isWhiteLabel() public function isWhiteLabel()
{ {
if (Utils::isNinja()) { if (Utils::isNinja()) {
return self::isPro(); return self::isPro() && $this->pro_plan_paid != NINJA_DATE;
} else { } else {
return $this->pro_plan_paid == NINJA_DATE; return $this->pro_plan_paid == NINJA_DATE;
} }

View File

@ -738,6 +738,12 @@ return array(
'header' => 'Header', 'header' => 'Header',
'footer' => 'Footer', 'footer' => 'Footer',
'custom' => 'Custom', 'custom' => 'Custom',
'invoice_to' => 'Invoice to',
'invoice_no' => 'Invoice No.',
'recent_payments' => 'Recent Payments',
'outstanding' => 'Outstanding',
'manage_companies' => 'Manage Companies',

View File

@ -732,7 +732,8 @@ return array(
'invoice_to' => 'Rechnunge an', 'invoice_to' => 'Rechnunge an',
'invoice_no' => 'Rechnung Nr.', 'invoice_no' => 'Rechnung Nr.',
'recent_payments' => 'Kürzliche Zahlungen', 'recent_payments' => 'Kürzliche Zahlungen',
'outstanding' => 'Ausstehend', 'manage_companies' => 'Manage Companies',
); );

View File

@ -740,6 +740,7 @@ return array(
'invoice_no' => 'Invoice No.', 'invoice_no' => 'Invoice No.',
'recent_payments' => 'Recent Payments', 'recent_payments' => 'Recent Payments',
'outstanding' => 'Outstanding', 'outstanding' => 'Outstanding',
'manage_companies' => 'Manage Companies',
); );

View File

@ -708,6 +708,12 @@ return array(
'header' => 'Header', 'header' => 'Header',
'footer' => 'Footer', 'footer' => 'Footer',
'custom' => 'Custom', 'custom' => 'Custom',
'invoice_to' => 'Invoice to',
'invoice_no' => 'Invoice No.',
'recent_payments' => 'Recent Payments',
'outstanding' => 'Outstanding',
'manage_companies' => 'Manage Companies',
); );

View File

@ -737,6 +737,12 @@ return array(
'header' => 'Header', 'header' => 'Header',
'footer' => 'Footer', 'footer' => 'Footer',
'custom' => 'Custom', 'custom' => 'Custom',
'invoice_to' => 'Invoice to',
'invoice_no' => 'Invoice No.',
'recent_payments' => 'Recent Payments',
'outstanding' => 'Outstanding',
'manage_companies' => 'Manage Companies',

View File

@ -729,6 +729,12 @@ return array(
'header' => 'Header', 'header' => 'Header',
'footer' => 'Footer', 'footer' => 'Footer',
'custom' => 'Custom', 'custom' => 'Custom',
'invoice_to' => 'Invoice to',
'invoice_no' => 'Invoice No.',
'recent_payments' => 'Recent Payments',
'outstanding' => 'Outstanding',
'manage_companies' => 'Manage Companies',

View File

@ -730,6 +730,12 @@ return array(
'header' => 'Header', 'header' => 'Header',
'footer' => 'Footer', 'footer' => 'Footer',
'custom' => 'Custom', 'custom' => 'Custom',
'invoice_to' => 'Invoice to',
'invoice_no' => 'Invoice No.',
'recent_payments' => 'Recent Payments',
'outstanding' => 'Outstanding',
'manage_companies' => 'Manage Companies',
); );

View File

@ -732,6 +732,12 @@ return array(
'header' => 'Header', 'header' => 'Header',
'footer' => 'Footer', 'footer' => 'Footer',
'custom' => 'Custom', 'custom' => 'Custom',
'invoice_to' => 'Invoice to',
'invoice_no' => 'Invoice No.',
'recent_payments' => 'Recent Payments',
'outstanding' => 'Outstanding',
'manage_companies' => 'Manage Companies',

View File

@ -739,6 +739,12 @@ return array(
'header' => 'Header', 'header' => 'Header',
'footer' => 'Footer', 'footer' => 'Footer',
'custom' => 'Custom', 'custom' => 'Custom',
'invoice_to' => 'Invoice to',
'invoice_no' => 'Invoice No.',
'recent_payments' => 'Recent Payments',
'outstanding' => 'Outstanding',
'manage_companies' => 'Manage Companies',

View File

@ -737,6 +737,12 @@ return array(
'header' => 'Header', 'header' => 'Header',
'footer' => 'Footer', 'footer' => 'Footer',
'custom' => 'Custom', 'custom' => 'Custom',
'invoice_to' => 'Invoice to',
'invoice_no' => 'Invoice No.',
'recent_payments' => 'Recent Payments',
'outstanding' => 'Outstanding',
'manage_companies' => 'Manage Companies',

View File

@ -732,6 +732,12 @@ return array(
'header' => 'Header', 'header' => 'Header',
'footer' => 'Footer', 'footer' => 'Footer',
'custom' => 'Custom', 'custom' => 'Custom',
'invoice_to' => 'Invoice to',
'invoice_no' => 'Invoice No.',
'recent_payments' => 'Recent Payments',
'outstanding' => 'Outstanding',
'manage_companies' => 'Manage Companies',

View File

@ -732,6 +732,12 @@ return array(
'header' => 'Header', 'header' => 'Header',
'footer' => 'Footer', 'footer' => 'Footer',
'custom' => 'Custom', 'custom' => 'Custom',
'invoice_to' => 'Invoice to',
'invoice_no' => 'Invoice No.',
'recent_payments' => 'Recent Payments',
'outstanding' => 'Outstanding',
'manage_companies' => 'Manage Companies',
); );

View File

@ -735,6 +735,12 @@ return array(
'header' => 'Header', 'header' => 'Header',
'footer' => 'Footer', 'footer' => 'Footer',
'custom' => 'Custom', 'custom' => 'Custom',
'invoice_to' => 'Invoice to',
'invoice_no' => 'Invoice No.',
'recent_payments' => 'Recent Payments',
'outstanding' => 'Outstanding',
'manage_companies' => 'Manage Companies',

View File

@ -203,19 +203,6 @@
}); });
} }
function showUnlink(userAccountId, userId) {
NINJA.unlink = {
'userAccountId': userAccountId,
'userId': userId
};
$('#unlinkModal').modal('show');
return false;
}
function unlinkAccount() {
window.location = '{{ URL::to('/unlink_account') }}' + '/' + NINJA.unlink.userAccountId + '/' + NINJA.unlink.userId;
}
function wordWrapText(value, width) function wordWrapText(value, width)
{ {
@if (Auth::user()->account->auto_wrap) @if (Auth::user()->account->auto_wrap)
@ -389,7 +376,7 @@
<span class="caret"></span> <span class="caret"></span>
</div> </div>
</button> </button>
<ul class="dropdown-menu user-accounts" role="menu"> <ul class="dropdown-menu user-accounts">
@if (session(SESSION_USER_ACCOUNTS)) @if (session(SESSION_USER_ACCOUNTS))
@foreach (session(SESSION_USER_ACCOUNTS) as $item) @foreach (session(SESSION_USER_ACCOUNTS) as $item)
@if ($item->user_id == Auth::user()->id) @if ($item->user_id == Auth::user()->id)
@ -400,7 +387,6 @@
'user_name' => $item->user_name, 'user_name' => $item->user_name,
'account_key' => $item->account_key, 'account_key' => $item->account_key,
'selected' => true, 'selected' => true,
'show_remove' => count(session(SESSION_USER_ACCOUNTS)) > 1,
]) ])
@endif @endif
@endforeach @endforeach
@ -413,7 +399,6 @@
'user_name' => $item->user_name, 'user_name' => $item->user_name,
'account_key' => $item->account_key, 'account_key' => $item->account_key,
'selected' => false, 'selected' => false,
'show_remove' => count(session(SESSION_USER_ACCOUNTS)) > 1,
]) ])
@endif @endif
@endforeach @endforeach
@ -429,6 +414,9 @@
@if (!session(SESSION_USER_ACCOUNTS) || count(session(SESSION_USER_ACCOUNTS)) < 5) @if (!session(SESSION_USER_ACCOUNTS) || count(session(SESSION_USER_ACCOUNTS)) < 5)
<li>{!! link_to('/login?new_company=true', trans('texts.add_company')) !!}</li> <li>{!! link_to('/login?new_company=true', trans('texts.add_company')) !!}</li>
@endif @endif
@if (count(session(SESSION_USER_ACCOUNTS)) > 1)
<li>{!! link_to('/manage_companies', trans('texts.manage_companies')) !!}</li>
@endif
<li>{!! link_to('#', trans('texts.logout'), array('onclick'=>'logout()')) !!}</li> <li>{!! link_to('#', trans('texts.logout'), array('onclick'=>'logout()')) !!}</li>
</ul> </ul>
</div> </div>
@ -603,28 +591,6 @@
</div> </div>
@endif @endif
@if (Auth::check() && session(SESSION_USER_ACCOUNTS) && count(session(SESSION_USER_ACCOUNTS)))
<div class="modal fade" id="unlinkModal" tabindex="-1" role="dialog" aria-labelledby="unlinkModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel">{{ trans('texts.unlink_account') }}</h4>
</div>
<div class="container">
<h3>{{ trans('texts.are_you_sure') }}</h3>
</div>
<div class="modal-footer" id="signUpFooter">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('texts.cancel') }}</button>
<button type="button" class="btn btn-primary" onclick="unlinkAccount()">{{ trans('texts.unlink') }}</button>
</div>
</div>
</div>
</div>
@endif
@if (Auth::check() && !Auth::user()->isPro()) @if (Auth::check() && !Auth::user()->isPro())
<div class="modal fade" id="proPlanModal" tabindex="-1" role="dialog" aria-labelledby="proPlanModalLabel" aria-hidden="true"> <div class="modal fade" id="proPlanModal" tabindex="-1" role="dialog" aria-labelledby="proPlanModalLabel" aria-hidden="true">
<div class="modal-dialog large-dialog"> <div class="modal-dialog large-dialog">

View File

@ -1,14 +1,10 @@
<li style="margin-top: 4px; margin-bottom: 4px; min-width: 220px; cursor: pointer"> <li style="margin-top: 4px; margin-bottom: 4px; min-width: 220px; cursor: pointer">
@if (isset($user_id) && $show_remove) @if (isset($user_id))
<a href='{{ URL::to("/switch_account/{$user_id}") }}'> <a href="{{ URL::to("/switch_account/{$user_id}") }}">
@else @else
<a href='{{ URL::to("/company/details") }}'> <a href="{{ URL::to("/company/details") }}">
@endif @endif
@if (isset($show_remove) && $show_remove)
<div class="pull-right glyphicon glyphicon-remove remove" onclick="return showUnlink({{ $user_account_id }}, {{ $user_id }})" title="{{ trans('texts.unlink') }}"></div>
@endif
@if (file_exists('logo/'.$account_key.'.jpg')) @if (file_exists('logo/'.$account_key.'.jpg'))
<div class="pull-left" style="height: 40px; margin-right: 16px;"> <div class="pull-left" style="height: 40px; margin-right: 16px;">
<img style="width: 40px; margin-top:6px" src="{{ asset('logo/'.$account_key.'.jpg') }}"/> <img style="width: 40px; margin-top:6px" src="{{ asset('logo/'.$account_key.'.jpg') }}"/>

View File

@ -0,0 +1,62 @@
@extends('header')
@section('content')
<p>&nbsp;</p>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="panel panel-default">
<div class="panel-body">
<table class="table table-striped">
@foreach (Session::get(SESSION_USER_ACCOUNTS) as $account)
<tr>
<td><b>{{ $account->account_name }}</b></td>
<td>{{ $account->user_name }}</td>
<td>{!! Button::primary(trans('texts.unlink'))->small()->withAttributes(['onclick'=>"return showUnlink({$account->id}, {$account->user_id})"]) !!}</td>
</tr>
@endforeach
</table>
</div>
</div>
</div>
</div>
<div class="modal fade" id="unlinkModal" tabindex="-1" role="dialog" aria-labelledby="unlinkModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel">{{ trans('texts.unlink_account') }}</h4>
</div>
<div class="container">
<h3>{{ trans('texts.are_you_sure') }}</h3>
</div>
<div class="modal-footer" id="signUpFooter">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('texts.cancel') }}</button>
<button type="button" class="btn btn-primary" onclick="unlinkAccount()">{{ trans('texts.unlink') }}</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
function showUnlink(userAccountId, userId) {
NINJA.unlink = {
'userAccountId': userAccountId,
'userId': userId
};
$('#unlinkModal').modal('show');
return false;
}
function unlinkAccount() {
window.location = '{{ URL::to('/unlink_account') }}' + '/' + NINJA.unlink.userAccountId + '/' + NINJA.unlink.userId;
}
</script>
@stop