mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 21:54:14 -08:00
Added dept helper reference in create/edit/bulk edit users
This commit is contained in:
parent
7ec1724308
commit
e9c39add4f
|
@ -90,6 +90,7 @@ class UsersController extends Controller
|
||||||
->with('location_list', Helper::locationsList())
|
->with('location_list', Helper::locationsList())
|
||||||
->with('manager_list', Helper::managerList())
|
->with('manager_list', Helper::managerList())
|
||||||
->with('company_list', Helper::companyList())
|
->with('company_list', Helper::companyList())
|
||||||
|
->with('department_list', Helper::departmentList())
|
||||||
->with('user', new User);
|
->with('user', new User);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +121,7 @@ class UsersController extends Controller
|
||||||
$user->jobtitle = $request->input('jobtitle');
|
$user->jobtitle = $request->input('jobtitle');
|
||||||
$user->phone = $request->input('phone');
|
$user->phone = $request->input('phone');
|
||||||
$user->location_id = $request->input('location_id', null);
|
$user->location_id = $request->input('location_id', null);
|
||||||
|
$user->department_id = $request->input('department_id', null);
|
||||||
$user->company_id = Company::getIdForUser($request->input('company_id', null));
|
$user->company_id = Company::getIdForUser($request->input('company_id', null));
|
||||||
$user->manager_id = $request->input('manager_id', null);
|
$user->manager_id = $request->input('manager_id', null);
|
||||||
$user->notes = $request->input('notes');
|
$user->notes = $request->input('notes');
|
||||||
|
@ -167,7 +169,7 @@ class UsersController extends Controller
|
||||||
* @since [v1.8]
|
* @since [v1.8]
|
||||||
* @return string JSON
|
* @return string JSON
|
||||||
*/
|
*/
|
||||||
public function apiStore()
|
public function apiStore(Request $request)
|
||||||
{
|
{
|
||||||
$this->authorize('create', User::class);
|
$this->authorize('create', User::class);
|
||||||
|
|
||||||
|
@ -175,12 +177,13 @@ class UsersController extends Controller
|
||||||
$inputs = Input::except('csrf_token', 'password_confirm', 'groups', 'email_user');
|
$inputs = Input::except('csrf_token', 'password_confirm', 'groups', 'email_user');
|
||||||
$inputs['activated'] = true;
|
$inputs['activated'] = true;
|
||||||
|
|
||||||
$user->first_name = Input::get('first_name');
|
$user->first_name = $request->input('first_name');
|
||||||
$user->last_name = Input::get('last_name');
|
$user->last_name = $request->input('last_name');
|
||||||
$user->username = Input::get('username');
|
$user->username = $request->input('username');
|
||||||
$user->email = Input::get('email');
|
$user->email = $request->input('email');
|
||||||
if (Input::has('password')) {
|
$user->department_id = $request->input('department_id', null);
|
||||||
$user->password = bcrypt(Input::get('password'));
|
if ($request->has('password')) {
|
||||||
|
$user->password = bcrypt($request->input('password'));
|
||||||
}
|
}
|
||||||
$user->activated = true;
|
$user->activated = true;
|
||||||
|
|
||||||
|
@ -190,10 +193,10 @@ class UsersController extends Controller
|
||||||
if (Input::get('email_user') == 1) {
|
if (Input::get('email_user') == 1) {
|
||||||
// Send the credentials through email
|
// Send the credentials through email
|
||||||
$data = array();
|
$data = array();
|
||||||
$data['email'] = e(Input::get('email'));
|
$data['email'] = $request->input('email');
|
||||||
$data['first_name'] = e(Input::get('first_name'));
|
$data['first_name'] = $request->input('first_name');
|
||||||
$data['last_name'] = e(Input::get('last_name'));
|
$data['last_name'] = $request->input('last_name');
|
||||||
$data['password'] = e(Input::get('password'));
|
$data['password'] = $request->input('password');
|
||||||
|
|
||||||
Mail::send('emails.send-login', $data, function ($m) use ($user) {
|
Mail::send('emails.send-login', $data, function ($m) use ($user) {
|
||||||
$m->to($user->email, $user->first_name . ' ' . $user->last_name);
|
$m->to($user->email, $user->first_name . ' ' . $user->last_name);
|
||||||
|
@ -229,10 +232,10 @@ class UsersController extends Controller
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function edit($id = null)
|
public function edit($id)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// Get the user information
|
|
||||||
$user = User::find($id);
|
$user = User::find($id);
|
||||||
$this->authorize('update', $user);
|
$this->authorize('update', $user);
|
||||||
$permissions = config('permissions');
|
$permissions = config('permissions');
|
||||||
|
@ -243,17 +246,17 @@ class UsersController extends Controller
|
||||||
$user->permissions = $user->decodePermissions();
|
$user->permissions = $user->decodePermissions();
|
||||||
$userPermissions = Helper::selectedPermissionsArray($permissions, $user->permissions);
|
$userPermissions = Helper::selectedPermissionsArray($permissions, $user->permissions);
|
||||||
$permissions = $this->filterDisplayable($permissions);
|
$permissions = $this->filterDisplayable($permissions);
|
||||||
} catch (UserNotFoundException $e) {
|
|
||||||
// Prepare the error message
|
|
||||||
$error = trans('admin/users/message.user_not_found', compact('id'));
|
|
||||||
|
|
||||||
// Redirect to the user management page
|
} catch (UserNotFoundException $e) {
|
||||||
|
|
||||||
|
$error = trans('admin/users/message.user_not_found', compact('id'));
|
||||||
return redirect()->route('users.index')->with('error', $error);
|
return redirect()->route('users.index')->with('error', $error);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show the page
|
// Show the page
|
||||||
return View::make('users/edit', compact('user', 'groups', 'userGroups', 'permissions', 'userPermissions'))
|
return View::make('users/edit', compact('user', 'groups', 'userGroups', 'permissions', 'userPermissions'))
|
||||||
->with('location_list', Helper::locationsList())
|
->with('location_list', Helper::locationsList())
|
||||||
|
->with('department_list', Helper::departmentList())
|
||||||
->with('company_list', Helper::companyList())
|
->with('company_list', Helper::companyList())
|
||||||
->with('manager_list', Helper::managerList());
|
->with('manager_list', Helper::managerList());
|
||||||
}
|
}
|
||||||
|
@ -329,6 +332,7 @@ class UsersController extends Controller
|
||||||
$user->company_id = Company::getIdForUser($request->input('company_id', null));
|
$user->company_id = Company::getIdForUser($request->input('company_id', null));
|
||||||
$user->manager_id = $request->input('manager_id', null);
|
$user->manager_id = $request->input('manager_id', null);
|
||||||
$user->notes = $request->input('notes');
|
$user->notes = $request->input('notes');
|
||||||
|
$user->department_id = $request->input('department_id', null);
|
||||||
|
|
||||||
// Strip out the superuser permission if the user isn't a superadmin
|
// Strip out the superuser permission if the user isn't a superadmin
|
||||||
$permissions_array = $request->input('permission');
|
$permissions_array = $request->input('permission');
|
||||||
|
@ -424,6 +428,7 @@ class UsersController extends Controller
|
||||||
->with('company_list', Helper::companyList())
|
->with('company_list', Helper::companyList())
|
||||||
->with('manager_list', Helper::managerList())
|
->with('manager_list', Helper::managerList())
|
||||||
->with('manager_list', Helper::managerList())
|
->with('manager_list', Helper::managerList())
|
||||||
|
->with('department_list', Helper::departmentList())
|
||||||
->with('groups', Group::pluck('name', 'id'));
|
->with('groups', Group::pluck('name', 'id'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,12 +453,16 @@ class UsersController extends Controller
|
||||||
|
|
||||||
$user_raw_array = Input::get('ids');
|
$user_raw_array = Input::get('ids');
|
||||||
$update_array = array();
|
$update_array = array();
|
||||||
|
$manager_conflict = false;
|
||||||
|
|
||||||
$users = User::whereIn('id', $user_raw_array)->where('id','!=',Auth::user()->id)->get();
|
$users = User::whereIn('id', $user_raw_array)->where('id','!=',Auth::user()->id)->get();
|
||||||
|
|
||||||
if ($request->has('location_id')) {
|
if ($request->has('location_id')) {
|
||||||
$update_array['location_id'] = $request->input('location_id');
|
$update_array['location_id'] = $request->input('location_id');
|
||||||
}
|
}
|
||||||
|
if ($request->has('department_id')) {
|
||||||
|
$update_array['department_id'] = $request->input('department_id');
|
||||||
|
}
|
||||||
if ($request->has('company_id')) {
|
if ($request->has('company_id')) {
|
||||||
$update_array['company_id'] = $request->input('company_id');
|
$update_array['company_id'] = $request->input('company_id');
|
||||||
}
|
}
|
||||||
|
@ -464,7 +473,7 @@ class UsersController extends Controller
|
||||||
// edited.
|
// edited.
|
||||||
if (!array_key_exists($request->input('manager_id'), $user_raw_array)) {
|
if (!array_key_exists($request->input('manager_id'), $user_raw_array)) {
|
||||||
$update_array['manager_id'] = $request->input('manager_id');
|
$update_array['manager_id'] = $request->input('manager_id');
|
||||||
$manager_conflict = false;
|
|
||||||
} else {
|
} else {
|
||||||
$manager_conflict = true;
|
$manager_conflict = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue