adds button to email user list of assets from profile

This commit is contained in:
Godfrey M 2022-06-29 11:15:15 -07:00
parent f8fd87b896
commit e471aa8639
5 changed files with 34 additions and 0 deletions

View file

@ -23,6 +23,7 @@ use Redirect;
use Str; use Str;
use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\HttpFoundation\StreamedResponse;
use View; use View;
use App\Notifications\CurrentInventory;
/** /**
* This controller handles all actions related to Users for * This controller handles all actions related to Users for
@ -614,6 +615,19 @@ class UsersController extends Controller
->with('show_user', $show_user) ->with('show_user', $show_user)
->with('settings', Setting::getSettings()); ->with('settings', Setting::getSettings());
} }
public function emailAssetList($id)
{
$this->authorize('view', User::class);
if( User::where('id', $id)->first()->exists())
{
$user= User::where('id', $id)->first();
$user->notify((new CurrentInventory($user)));
return redirect()->back()->with('success', 'admin/users/general.user_notified');
}
return redirect()->back()->with('error', 'admin/accessories/message.user_does_not_exist');
}
/** /**
* Send individual password reset email * Send individual password reset email

View file

@ -17,6 +17,8 @@ return [
'last_login' => 'Last Login', 'last_login' => 'Last Login',
'ldap_config_text' => 'LDAP configuration settings can be found Admin > Settings. The (optional) selected location will be set for all imported users.', 'ldap_config_text' => 'LDAP configuration settings can be found Admin > Settings. The (optional) selected location will be set for all imported users.',
'print_assigned' => 'Print All Assigned', 'print_assigned' => 'Print All Assigned',
'email_assigned' => 'Email List of All Assigned',
'user_notified' => 'User has been emailed a list of their currently assigned items.',
'software_user' => 'Software Checked out to :name', 'software_user' => 'Software Checked out to :name',
'send_email_help' => 'You must provide an email address for this user to send them credentials. Emailing credentials can only be done on user creation. Passwords are stored in a one-way hash and cannot be retrieved once saved.', 'send_email_help' => 'You must provide an email address for this user to send them credentials. Emailing credentials can only be done on user creation. Passwords are stored in a one-way hash and cannot be retrieved once saved.',
'view_user' => 'View User :name', 'view_user' => 'View User :name',

View file

@ -67,6 +67,7 @@
<th style="width: 20%;">{{ trans('admin/hardware/table.asset_tag') }}</th> <th style="width: 20%;">{{ trans('admin/hardware/table.asset_tag') }}</th>
<th style="width: 20%;">{{ trans('general.name') }}</th> <th style="width: 20%;">{{ trans('general.name') }}</th>
<th style="width: 10%;">{{ trans('general.category') }}</th> <th style="width: 10%;">{{ trans('general.category') }}</th>
<th style="width: 20%;">{{ trans('admin/hardware/form.serial') }}</th>
<th style="width: 20%;">{{ trans('admin/hardware/form.model') }}</th> <th style="width: 20%;">{{ trans('admin/hardware/form.model') }}</th>
<th style="width: 20%;">{{ trans('admin/hardware/form.serial') }}</th> <th style="width: 20%;">{{ trans('admin/hardware/form.serial') }}</th>
<th style="width: 10%;">{{ trans('admin/hardware/table.checkout_date') }}</th> <th style="width: 10%;">{{ trans('admin/hardware/table.checkout_date') }}</th>

View file

@ -188,6 +188,15 @@
</div> </div>
@endcan @endcan
@can('view', $user)
<div class="col-md-12" style="padding-top: 5px;">
<form action="{{ route('users.email',['userId'=> $user->id]) }}" method="POST">
{{ csrf_field() }}
<button style="width: 100%;" class="btn btn-sm btn-primary hidden-print" rel="noopener">{{ trans('admin/users/general.email_assigned') }}</button>
</form>
</div>
@endcan
@can('update', $user) @can('update', $user)
@if (($user->activated == '1') && ($user->email != '') && ($user->ldap_import == '0')) @if (($user->activated == '1') && ($user->email != '') && ($user->ldap_import == '0'))
<div class="col-md-12" style="padding-top: 5px;"> <div class="col-md-12" style="padding-top: 5px;">

View file

@ -144,6 +144,14 @@ Route::group(['prefix' => 'users', 'middleware' => ['auth']], function () {
] ]
)->name('users.print'); )->name('users.print');
Route::post(
'{userId}/email',
[
Users\UsersController::class,
'emailAssetList'
]
)->name('users.email');
Route::post( Route::post(
'bulkedit', 'bulkedit',
[ [