Use bulk actions menu

This commit is contained in:
Marcus Moore 2024-09-23 12:49:36 -07:00
parent 54044bfa5e
commit a2d4dcf6e8
No known key found for this signature in database
4 changed files with 27 additions and 36 deletions

View file

@ -13,6 +13,7 @@ use App\Models\Group;
use App\Models\LicenseSeat;
use App\Models\ConsumableAssignment;
use App\Models\Consumable;
use App\Models\Setting;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Http\Request;
@ -76,6 +77,30 @@ class BulkUsersController extends Controller
}
return redirect()->back()->with('success', trans('admin/users/message.password_resets_sent'));
} elseif ($request->input('bulk_actions') == 'print') {
$users = User::query()
->with([
'assets.assetlog',
'assets.assignedAssets.assetlog',
'assets.assignedAssets.defaultLoc',
'assets.assignedAssets.location',
'assets.assignedAssets.model.category',
'assets.defaultLoc',
'assets.location',
'assets.model.category',
'accessories.category',
'accessories.manufacturer',
'consumables.assetlog',
'consumables.category',
'consumables.manufacturer',
'licenses.category',
])
->withTrashed()
->findMany($request->input('ids'));
return view('users.print')
->with('users', $users)
->with('settings', Setting::getSettings());
}
}

View file

@ -619,37 +619,6 @@ class UsersController extends Controller
return redirect()->route('users.index')->with('error', trans('admin/users/message.user_not_found', compact('id')));
}
public function printAllThings()
{
$this->authorize('view', User::class);
$users = User::query()
->with([
'assets.assetlog',
'assets.assignedAssets.assetlog',
'assets.assignedAssets.defaultLoc',
'assets.assignedAssets.location',
'assets.assignedAssets.model.category',
'assets.defaultLoc',
'assets.location',
'assets.model.category',
'accessories.category',
'accessories.manufacturer',
'consumables.assetlog',
'consumables.category',
'consumables.manufacturer',
'licenses.category',
])
->withTrashed()
->get();
// @todo: more authorization
return view('users.print')
->with('users', $users)
->with('settings', Setting::getSettings());
}
/**
* Emails user a list of assigned assets
*

View file

@ -14,10 +14,11 @@
<option value="delete">{!! trans('general.bulk_checkin_delete') !!}</option>
<option value="merge">{!! trans('general.merge_users') !!}</option>
<option value="bulkpasswordreset">{{ trans('button.send_password_link') }}</option>
<option value="print">{{ trans('admin/users/general.print_assigned') }}</option>
</select>
<button class="btn btn-primary" id="bulkUserEditButton" disabled>{{ trans('button.go') }}</button>
</div>
@endcan
@endif
{{ Form::close() }}
</div>
</div>

View file

@ -105,10 +105,6 @@ Route::group(['prefix' => 'users', 'middleware' => ['auth']], function () {
]
)->name('users.print');
Route::get('print-all-things', [Users\UsersController::class, 'printAllThings'])
->withoutMiddleware([AssetCountForSidebar::class])
->name('users.print-all-things');
Route::post(
'{userId}/email',
[