diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php
index 48ebccd6b4..3309923c50 100755
--- a/app/controllers/AccountController.php
+++ b/app/controllers/AccountController.php
@@ -85,7 +85,11 @@ class AccountController extends \BaseController
{
Session::put("show_trash:{$entityType}", $visible == 'true');
- return Redirect::to("{$entityType}s");
+ if ($entityType == 'user') {
+ return Redirect::to('company/'.ACCOUNT_ADVANCED_SETTINGS.'/'.ACCOUNT_USER_MANAGEMENT);
+ } else {
+ return Redirect::to("{$entityType}s");
+ }
}
public function getSearchData()
diff --git a/app/controllers/UserController.php b/app/controllers/UserController.php
index 79d8a5d1a5..ec6b701c29 100755
--- a/app/controllers/UserController.php
+++ b/app/controllers/UserController.php
@@ -31,26 +31,43 @@ class UserController extends BaseController
public function getDatatable()
{
$query = DB::table('users')
- ->where('users.account_id', '=', Auth::user()->account_id)
- ->where('users.deleted_at', '=', null)
- ->where('users.public_id', '>', 0)
- ->select('users.public_id', 'users.first_name', 'users.last_name', 'users.email', 'users.confirmed', 'users.public_id');
+ ->where('users.account_id', '=', Auth::user()->account_id);
+
+ if (!Session::get('show_trash:user')) {
+ $query->where('users.deleted_at', '=', null);
+ }
+
+ $query->where('users.public_id', '>', 0)
+ ->select('users.public_id', 'users.first_name', 'users.last_name', 'users.email', 'users.confirmed', 'users.public_id', 'users.deleted_at');
return Datatable::query($query)
->addColumn('first_name', function ($model) { return link_to('users/'.$model->public_id.'/edit', $model->first_name.' '.$model->last_name); })
->addColumn('email', function ($model) { return $model->email; })
- ->addColumn('confirmed', function ($model) { return $model->confirmed ? trans('texts.active') : trans('texts.pending'); })
+ ->addColumn('confirmed', function ($model) { return $model->deleted_at ? trans('texts.deleted') : ($model->confirmed ? trans('texts.active') : trans('texts.pending')); })
->addColumn('dropdown', function ($model) {
- return '
+ $actions = '
-
+
';
+
+ return $actions;
})
->orderColumns(['first_name', 'email', 'confirmed'])
->make();
@@ -147,6 +164,19 @@ class UserController extends BaseController
return Redirect::to('company/advanced_settings/user_management');
}
+ public function restoreUser($userPublicId)
+ {
+ $user = User::where('account_id', '=', Auth::user()->account_id)
+ ->where('public_id', '=', $userPublicId)
+ ->withTrashed()->firstOrFail();
+
+ $user->restore();
+
+ Session::flash('message', trans('texts.restored_user'));
+
+ return Redirect::to('company/advanced_settings/user_management');
+ }
+
/**
* Stores new account
*
@@ -208,6 +238,17 @@ class UserController extends BaseController
return Redirect::to('company/advanced_settings/user_management');
}
+ public function sendConfirmation($userPublicId)
+ {
+ $user = User::where('account_id', '=', Auth::user()->account_id)
+ ->where('public_id', '=', $userPublicId)->firstOrFail();
+
+ $this->userMailer->sendConfirmation($user, Auth::user());
+ Session::flash('message', trans('texts.sent_invite'));
+
+ return Redirect::to('company/advanced_settings/user_management');
+ }
+
/**
* Displays the login form
*
diff --git a/app/lang/en/texts.php b/app/lang/en/texts.php
index 5d7e1cf49a..934b741ea2 100644
--- a/app/lang/en/texts.php
+++ b/app/lang/en/texts.php
@@ -303,7 +303,7 @@ return array(
'email_taken' => 'The email address is already registered',
'working' => 'Working',
'success' => 'Success',
- 'success_message' => 'You have succesfully registered. Please visit the link in the account confirmation email to verify your email address.',
+ 'success_message' => 'You have successfully registered. Please visit the link in the account confirmation email to verify your email address.',
'erase_data' => 'This will permanently erase your data.',
'password' => 'Password',
@@ -499,5 +499,9 @@ return array(
'edit_payment' => 'Edit Payment',
'updated_payment' => 'Successfully updated payment',
-
+ 'deleted' => 'Deleted',
+ 'restore_user' => 'Restore User',
+ 'restored_user' => 'Successfully restored user',
+ 'show_deleted_users' => 'Show deleted users',
+
);
diff --git a/app/routes.php b/app/routes.php
index 9ad377cdf3..a92e406403 100755
--- a/app/routes.php
+++ b/app/routes.php
@@ -88,6 +88,8 @@ Route::group(array('before' => 'auth'), function() {
Route::get('api/users', array('as'=>'api.users', 'uses'=>'UserController@getDatatable'));
Route::resource('users', 'UserController');
Route::post('users/delete', 'UserController@delete');
+ Route::get('send_confirmation/{user_id}', 'UserController@sendConfirmation');
+ Route::get('restore_user/{user_id}', 'UserController@restoreUser');
Route::get('api/products', array('as'=>'api.products', 'uses'=>'ProductController@getDatatable'));
Route::resource('products', 'ProductController');
diff --git a/app/views/accounts/user_management.blade.php b/app/views/accounts/user_management.blade.php
index 09e3f476f2..6d46a19bf0 100644
--- a/app/views/accounts/user_management.blade.php
+++ b/app/views/accounts/user_management.blade.php
@@ -1,12 +1,14 @@
@extends('accounts.nav')
-@section('content')
+@section('content')
@parent
@include('accounts.nav_advanced')
{{ Former::open('users/delete')->addClass('user-form') }}
{{ Former::legend('user_management') }}
+
+
{{ Former::text('userPublicId') }}
@@ -14,34 +16,46 @@
@if (Utils::isPro())
- {{ Button::success_link(URL::to('users/create'), trans("texts.add_user"), array('class' => 'pull-right'))->append_with_icon('plus-sign') }}
+ {{ Button::success_link(URL::to('users/create'), trans("texts.add_user"), array('class' => 'pull-right'))->append_with_icon('plus-sign') }}
@endif
- {{ Datatable::table()
+
+
+
+
+ {{ Datatable::table()
->addColumn(
trans('texts.name'),
trans('texts.email'),
trans('texts.user_state'),
trans('texts.action'))
- ->setUrl(url('api/users/'))
+ ->setUrl(url('api/users/'))
->setOptions('sPaginationType', 'bootstrap')
- ->setOptions('bFilter', false)
- ->setOptions('bAutoWidth', false)
- ->setOptions('aoColumns', [[ "sWidth"=> "20%" ], [ "sWidth"=> "45%" ], ["sWidth"=> "20%"], ["sWidth"=> "15%" ]])
+ ->setOptions('bFilter', false)
+ ->setOptions('bAutoWidth', false)
+ ->setOptions('aoColumns', [[ "sWidth"=> "20%" ], [ "sWidth"=> "45%" ], ["sWidth"=> "20%"], ["sWidth"=> "15%" ]])
->setOptions('aoColumnDefs', [['bSortable'=>false, 'aTargets'=>[3]]])
->render('datatable') }}
+ $('form.user-form').submit();
+ }
+
@stop