Added ability to send user inventory via bulk UI

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2025-02-22 12:07:54 +00:00
parent 056fbefb16
commit d1cc0fcfac
3 changed files with 26 additions and 0 deletions

View file

@ -15,6 +15,7 @@ use App\Models\ConsumableAssignment;
use App\Models\Consumable;
use App\Models\Setting;
use App\Models\User;
use App\Notifications\CurrentInventory;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
@ -52,6 +53,28 @@ class BulkUsersController extends Controller
return view('users/bulk-edit', compact('users'))
->with('groups', Group::pluck('name', 'id'));
// bulk send assigned inventory
} elseif ($request->input('bulk_actions') == 'send_assigned') {
$this->authorize('update', User::class);
$users_without_email = 0;
foreach ($users as $user) {
if (empty($user->email)) {
$users_without_email++;
} else {
$user->notify((new CurrentInventory($user)));
}
}
if ($users_without_email == 0) {
return redirect()->back()->with('success', trans_choice('admin/users/general.users_notified', $users->count()));
} else {
return redirect()->back()->with('warning', trans_choice('admin/users/general.users_notified_warning', $users->count(), ['no_email' => $users_without_email]));
}
// bulk delete, display the bulk delete confirmation form
} elseif ($request->input('bulk_actions') == 'delete') {
$this->authorize('delete', User::class);

View file

@ -19,6 +19,8 @@ return [
'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.',
'users_notified' => 'The user has been emailed a list of their currently assigned items.|:count users have been emailed a list of their currently assigned items.',
'users_notified_warning' => ':count user has been emailed a list of their currently assigned items, however :no_email users did not have an email address so could not be emailed.|:count users have been emailed a list of their currently assigned items, however :no_email users did not have an email address so could not be emailed.',
'auto_assign_label' => 'Include this user when auto-assigning eligible licenses',
'auto_assign_help' => 'Skip this user in auto assignment of licenses',
'software_user' => 'Software Checked out to :name',

View file

@ -18,6 +18,7 @@
@can('update', \App\Models\User::class)
<option value="edit">{{ trans('general.bulk_edit') }}</option>
<option value="send_assigned">{{ trans('admin/users/general.email_assigned') }}</option>
@endcan
@can('delete', \App\Models\User::class)