Skip to content

Commit

Permalink
Use bulk actions menu
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusmoore committed Sep 23, 2024
1 parent 54044bf commit a2d4dcf
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 36 deletions.
25 changes: 25 additions & 0 deletions app/Http/Controllers/Users/BulkUsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
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;
Expand Down Expand Up @@ -76,6 +77,30 @@ public function edit(Request $request)
}
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());
}
}

Expand Down
31 changes: 0 additions & 31 deletions app/Http/Controllers/Users/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -619,37 +619,6 @@ public function printInventory($id)
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
*
Expand Down
3 changes: 2 additions & 1 deletion resources/views/partials/users-bulk-actions.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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>
4 changes: 0 additions & 4 deletions routes/web/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,6 @@
]
)->name('users.print');

Route::get('print-all-things', [Users\UsersController::class, 'printAllThings'])
->withoutMiddleware([AssetCountForSidebar::class])
->name('users.print-all-things');

Route::post(
'{userId}/email',
[
Expand Down

0 comments on commit a2d4dcf

Please sign in to comment.