mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-11 05:47:28 -08:00
Merge pull request #15534 from marcusmoore/bulk-print-users
Added the ability to bulk print users
This commit is contained in:
commit
9b03f46490
|
@ -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,33 @@ 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.assetlog',
|
||||
'accessories.category',
|
||||
'accessories.manufacturer',
|
||||
'consumables.assetlog',
|
||||
'consumables.category',
|
||||
'consumables.manufacturer',
|
||||
'licenses.category',
|
||||
])
|
||||
->withTrashed()
|
||||
->findMany($request->input('ids'));
|
||||
|
||||
$users->each(fn($user) => $this->authorize('view', $user));
|
||||
|
||||
return view('users.print')
|
||||
->with('users', $users)
|
||||
->with('settings', Setting::getSettings());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -597,23 +597,37 @@ class UsersController extends Controller
|
|||
public function printInventory($id)
|
||||
{
|
||||
$this->authorize('view', User::class);
|
||||
if ($user = User::where('id', $id)->withTrashed()->first()) {
|
||||
|
||||
$user = User::where('id', $id)
|
||||
->with([
|
||||
'assets.assetlog',
|
||||
'assets.assignedAssets.assetlog',
|
||||
'assets.assignedAssets.defaultLoc',
|
||||
'assets.assignedAssets.location',
|
||||
'assets.assignedAssets.model.category',
|
||||
'assets.defaultLoc',
|
||||
'assets.location',
|
||||
'assets.model.category',
|
||||
'accessories.assetlog',
|
||||
'accessories.category',
|
||||
'accessories.manufacturer',
|
||||
'consumables.assetlog',
|
||||
'consumables.category',
|
||||
'consumables.manufacturer',
|
||||
'licenses.category',
|
||||
])
|
||||
->withTrashed()
|
||||
->first();
|
||||
|
||||
if ($user) {
|
||||
$this->authorize('view', $user);
|
||||
$assets = Asset::where('assigned_to', $id)->where('assigned_type', User::class)->with('model', 'model.category')->get();
|
||||
$accessories = $user->accessories()->get();
|
||||
$consumables = $user->consumables()->get();
|
||||
|
||||
return view('users/print')->with('assets', $assets)
|
||||
->with('licenses', $user->licenses()->get())
|
||||
->with('accessories', $accessories)
|
||||
->with('consumables', $consumables)
|
||||
->with('show_user', $user)
|
||||
return view('users.print')
|
||||
->with('users', [$user])
|
||||
->with('settings', Setting::getSettings());
|
||||
}
|
||||
|
||||
return redirect()->route('users.index')->with('error', trans('admin/users/message.user_not_found', compact('id')));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -282,6 +282,7 @@ return [
|
|||
'status_label' => 'Status Label',
|
||||
'status' => 'Status',
|
||||
'accept_eula' => 'Acceptance Agreement',
|
||||
'show_or_hide_eulas' => 'Show/Hide EULAs',
|
||||
'supplier' => 'Supplier',
|
||||
'suppliers' => 'Suppliers',
|
||||
'sure_to_delete' => 'Are you sure you wish to delete',
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -2,7 +2,11 @@
|
|||
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<title>{{ trans('general.assigned_to', ['name' => $show_user->present()->fullName()]) }} - {{ date('Y-m-d H:i', time()) }}</title>
|
||||
@if (count($users) === 1)
|
||||
<title>{{ trans('general.assigned_to', ['name' => $users[0]->present()->fullName()]) }} - {{ date('Y-m-d H:i', time()) }}</title>
|
||||
@else
|
||||
<title>{{ trans('admin/users/general.print_assigned') }} - {{ date('Y-m-d H:i', time()) }}</title>
|
||||
@endisset
|
||||
|
||||
<link rel="shortcut icon" type="image/ico" href="{{ ($snipeSettings) && ($snipeSettings->favicon!='') ? Storage::disk('public')->url(e($snipeSettings->favicon)) : config('app.url').'/favicon.ico' }}">
|
||||
|
||||
|
@ -33,6 +37,10 @@
|
|||
size: A4;
|
||||
}
|
||||
|
||||
#start_of_user_section {
|
||||
break-before: page;
|
||||
}
|
||||
|
||||
.print-logo {
|
||||
max-height: 40px;
|
||||
}
|
||||
|
@ -54,6 +62,16 @@
|
|||
</head>
|
||||
<body>
|
||||
|
||||
{{-- If we are rendering multiple users we'll add the ability to show/hide EULAs for all of them at once via this button --}}
|
||||
@if (count($users) > 1)
|
||||
<div class="pull-right hidden-print">
|
||||
<span>{{ trans('general.show_or_hide_eulas') }}</span>
|
||||
<button class="btn btn-default" type="button" data-toggle="collapse" data-target=".eula-row" aria-expanded="false" aria-controls="eula-row" title="EULAs">
|
||||
<i class="fa fa-eye-slash"></i>
|
||||
</button>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if ($snipeSettings->logo_print_assets=='1')
|
||||
@if ($snipeSettings->brand == '3')
|
||||
|
||||
|
@ -72,39 +90,39 @@
|
|||
@endif
|
||||
@endif
|
||||
|
||||
<h3>
|
||||
{{ trans('general.assigned_to', ['name' => $show_user->present()->fullName()]) }}
|
||||
{{ ($show_user->employee_num!='') ? ' (#'.$show_user->employee_num.') ' : '' }}
|
||||
{{ ($show_user->jobtitle!='' ? ' - '.$show_user->jobtitle : '') }}
|
||||
</h3>
|
||||
<p></p>{{ trans('admin/users/general.all_assigned_list_generation')}} {{ Helper::getFormattedDateObject(now(), 'datetime', false) }}
|
||||
@foreach ($users as $show_user)
|
||||
<div id="start_of_user_section"> {{-- used for page breaks when printing --}}</div>
|
||||
<h3>
|
||||
{{ trans('general.assigned_to', ['name' => $show_user->present()->fullName()]) }}
|
||||
{{ ($show_user->employee_num!='') ? ' (#'.$show_user->employee_num.') ' : '' }}
|
||||
{{ ($show_user->jobtitle!='' ? ' - '.$show_user->jobtitle : '') }}
|
||||
</h3>
|
||||
<p></p>{{ trans('admin/users/general.all_assigned_list_generation')}} {{ Helper::getFormattedDateObject(now(), 'datetime', false) }}
|
||||
|
||||
</body>
|
||||
|
||||
@if ($assets->count() > 0)
|
||||
@if ($show_user->assets->count() > 0)
|
||||
@php
|
||||
$counter = 1;
|
||||
@endphp
|
||||
|
||||
<div id="assets-toolbar">
|
||||
<h4>{{ trans_choice('general.countable.assets', $assets->count(), ['count' => $assets->count()]) }}
|
||||
<h4>{{ trans_choice('general.countable.assets', $show_user->assets->count(), ['count' => $show_user->assets->count()]) }}
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
<table
|
||||
class="snipe-table table table-striped inventory"
|
||||
id="AssetsAssigned"
|
||||
data-pagination="false"
|
||||
data-id-table="AssetsAssigned"
|
||||
data-search="false"
|
||||
data-side-pagination="client"
|
||||
data-sortable="true"
|
||||
data-toolbar="#assets-toolbar"
|
||||
data-show-columns="true"
|
||||
data-sort-order="desc"
|
||||
data-sort-name="created_at"
|
||||
data-show-columns-toggle-all="true"
|
||||
data-cookie-id-table="AssetsAssigned">
|
||||
class="snipe-table table table-striped inventory"
|
||||
id="AssetsAssigned"
|
||||
data-pagination="false"
|
||||
data-id-table="AssetsAssigned"
|
||||
data-search="false"
|
||||
data-side-pagination="client"
|
||||
data-sortable="true"
|
||||
data-toolbar="#assets-toolbar"
|
||||
data-show-columns="true"
|
||||
data-sort-order="desc"
|
||||
data-sort-name="created_at"
|
||||
data-show-columns-toggle-all="true"
|
||||
data-cookie-id-table="AssetsAssigned">
|
||||
<thead>
|
||||
<th data-field="asset_id" data-sortable="false" data-visible="true" data-switchable="false">#</th>
|
||||
<th data-field="asset_image" data-sortable="true" data-visible="false" data-switchable="true">{{ trans('general.image') }}</th>
|
||||
|
@ -119,7 +137,7 @@
|
|||
<th data-field="signature" data-sortable="true" data-visible="true">{{ trans('general.signature') }}</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($assets as $asset)
|
||||
@foreach ($show_user->assets as $asset)
|
||||
@php
|
||||
if ($asset->model->category->getEula()) $eulas[] = $asset->model->category->getEula()
|
||||
@endphp
|
||||
|
@ -185,25 +203,25 @@
|
|||
</table>
|
||||
@endif
|
||||
|
||||
@if ($licenses->count() > 0)
|
||||
@if ($show_user->licenses->count() > 0)
|
||||
<div id="licenses-toolbar">
|
||||
<h4>{{ trans_choice('general.countable.licenses', $licenses->count(), ['count' => $licenses->count()]) }}</h4>
|
||||
<h4>{{ trans_choice('general.countable.licenses', $show_user->licenses->count(), ['count' => $show_user->licenses->count()]) }}</h4>
|
||||
</div>
|
||||
|
||||
<table
|
||||
class="snipe-table table table-striped inventory"
|
||||
id="licensessAssigned"
|
||||
data-toolbar="#licenses-toolbar"
|
||||
data-pagination="false"
|
||||
data-id-table="licensessAssigned"
|
||||
data-search="false"
|
||||
data-side-pagination="client"
|
||||
data-sortable="true"
|
||||
data-show-columns="true"
|
||||
data-sort-order="desc"
|
||||
data-sort-name="created_at"
|
||||
data-show-columns-toggle-all="true"
|
||||
data-cookie-id-table="licensessAssigned">
|
||||
class="snipe-table table table-striped inventory"
|
||||
id="licensessAssigned"
|
||||
data-toolbar="#licenses-toolbar"
|
||||
data-pagination="false"
|
||||
data-id-table="licensessAssigned"
|
||||
data-search="false"
|
||||
data-side-pagination="client"
|
||||
data-sortable="true"
|
||||
data-show-columns="true"
|
||||
data-sort-order="desc"
|
||||
data-sort-name="created_at"
|
||||
data-show-columns-toggle-all="true"
|
||||
data-cookie-id-table="licensessAssigned">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 20px;" data-sortable="false" data-switchable="false">#</th>
|
||||
|
@ -216,7 +234,7 @@
|
|||
$lcounter = 1;
|
||||
@endphp
|
||||
|
||||
@foreach ($licenses as $license)
|
||||
@foreach ($show_user->licenses as $license)
|
||||
@php
|
||||
if ($license->category->getEula()) $eulas[] = $license->category->getEula()
|
||||
@endphp
|
||||
|
@ -240,25 +258,25 @@
|
|||
@endif
|
||||
|
||||
|
||||
@if ($accessories->count() > 0)
|
||||
@if ($show_user->accessories->count() > 0)
|
||||
<div id="accessories-toolbar">
|
||||
<h4>{{ trans_choice('general.countable.accessories', $accessories->count(), ['count' => $accessories->count()]) }}</h4>
|
||||
<h4>{{ trans_choice('general.countable.accessories', $show_user->accessories->count(), ['count' => $show_user->accessories->count()]) }}</h4>
|
||||
</div>
|
||||
|
||||
<table
|
||||
class="snipe-table table table-striped inventory"
|
||||
id="accessoriesAssigned"
|
||||
data-toolbar="#accessories-toolbar"
|
||||
data-pagination="false"
|
||||
data-id-table="accessoriesAssigned"
|
||||
data-search="false"
|
||||
data-side-pagination="client"
|
||||
data-sortable="true"
|
||||
data-show-columns="true"
|
||||
data-sort-order="desc"
|
||||
data-sort-name="created_at"
|
||||
data-show-columns-toggle-all="true"
|
||||
data-cookie-id-table="accessoriesAssigned">
|
||||
class="snipe-table table table-striped inventory"
|
||||
id="accessoriesAssigned"
|
||||
data-toolbar="#accessories-toolbar"
|
||||
data-pagination="false"
|
||||
data-id-table="accessoriesAssigned"
|
||||
data-search="false"
|
||||
data-side-pagination="client"
|
||||
data-sortable="true"
|
||||
data-show-columns="true"
|
||||
data-sort-order="desc"
|
||||
data-sort-name="created_at"
|
||||
data-show-columns-toggle-all="true"
|
||||
data-cookie-id-table="accessoriesAssigned">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 20px;" data-sortable="false" data-switchable="false">#</th>
|
||||
|
@ -273,7 +291,7 @@
|
|||
$acounter = 1;
|
||||
@endphp
|
||||
|
||||
@foreach ($accessories as $accessory)
|
||||
@foreach ($show_user->accessories as $accessory)
|
||||
@if ($accessory)
|
||||
@php
|
||||
if ($accessory->category->getEula()) $eulas[] = $accessory->category->getEula()
|
||||
|
@ -291,7 +309,7 @@
|
|||
|
||||
<td>
|
||||
@if (($accessory->assetlog->first()) && ($accessory->assetlog->first()->accept_signature!=''))
|
||||
<img style="width:auto;height:100px;" src="{{ asset('/') }}display-sig/{{ $accessory->assetlog->first()->accept_signature }}">
|
||||
<img style="width:auto;height:100px;" src="{{ asset('/') }}display-sig/{{ $accessory->assetlog->first()->accept_signature }}">
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -303,25 +321,25 @@
|
|||
</table>
|
||||
@endif
|
||||
|
||||
@if ($consumables->count() > 0)
|
||||
@if ($show_user->consumables->count() > 0)
|
||||
<div id="consumables-toolbar">
|
||||
<h4>{{ trans_choice('general.countable.consumables', $consumables->count(), ['count' => $consumables->count()]) }}</h4>
|
||||
<h4>{{ trans_choice('general.countable.consumables', $show_user->consumables->count(), ['count' => $show_user->consumables->count()]) }}</h4>
|
||||
</div>
|
||||
|
||||
<table
|
||||
class="snipe-table table table-striped inventory"
|
||||
id="consumablesAssigned"
|
||||
data-pagination="false"
|
||||
data-toolbar="#consumables-toolbar"
|
||||
data-id-table="consumablesAssigned"
|
||||
data-search="false"
|
||||
data-side-pagination="client"
|
||||
data-sortable="true"
|
||||
data-show-columns="true"
|
||||
data-sort-order="desc"
|
||||
data-sort-name="created_at"
|
||||
data-show-columns-toggle-all="true"
|
||||
data-cookie-id-table="consumablesAssigned">
|
||||
class="snipe-table table table-striped inventory"
|
||||
id="consumablesAssigned"
|
||||
data-pagination="false"
|
||||
data-toolbar="#consumables-toolbar"
|
||||
data-id-table="consumablesAssigned"
|
||||
data-search="false"
|
||||
data-side-pagination="client"
|
||||
data-sortable="true"
|
||||
data-show-columns="true"
|
||||
data-sort-order="desc"
|
||||
data-sort-name="created_at"
|
||||
data-show-columns-toggle-all="true"
|
||||
data-cookie-id-table="consumablesAssigned">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 20px;" data-sortable="false" data-switchable="false"></th>
|
||||
|
@ -336,7 +354,7 @@
|
|||
$ccounter = 1;
|
||||
@endphp
|
||||
|
||||
@foreach ($consumables as $consumable)
|
||||
@foreach ($show_user->consumables as $consumable)
|
||||
@if ($consumable)
|
||||
@php
|
||||
if ($consumable->category->getEula()) $eulas[] = $consumable->category->getEula()
|
||||
|
@ -347,7 +365,7 @@
|
|||
@if ($consumable->deleted_at!='')
|
||||
<td>{{ ($consumable->manufacturer) ? $consumable->manufacturer->name : '' }} {{ $consumable->name }} {{ $consumable->model_number }}</td>
|
||||
@else
|
||||
{{ ($consumable->manufacturer) ? $consumable->manufacturer->name : '' }} {{ $consumable->name }} {{ $consumable->model_number }}
|
||||
{{ ($consumable->manufacturer) ? $consumable->manufacturer->name : '' }} {{ $consumable->name }} {{ $consumable->model_number }}
|
||||
@endif
|
||||
</td>
|
||||
<td>{{ ($consumable->category) ? $consumable->category->name : ' invalid/deleted category' }} </td>
|
||||
|
@ -366,15 +384,18 @@
|
|||
</table>
|
||||
@endif
|
||||
|
||||
<p></p>
|
||||
<div class="pull-right">
|
||||
<button class="btn btn-default hidden-print" type="button" data-toggle="collapse" data-target="#eula-row" aria-expanded="false" aria-controls="eula-row" title="EULAs">
|
||||
<i class="fa fa-eye-slash"></i>
|
||||
</button>
|
||||
</div>
|
||||
{{-- This may have been render at the top of the page if we're rendering more than one user... --}}
|
||||
@if (count($users) === 1)
|
||||
<p></p>
|
||||
<div class="pull-right">
|
||||
<button class="btn btn-default hidden-print" type="button" data-toggle="collapse" data-target=".eula-row" aria-expanded="false" aria-controls="eula-row" title="EULAs">
|
||||
<i class="fa fa-eye-slash"></i>
|
||||
</button>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<table style="margin-top: 80px;" class="snipe-table">
|
||||
<tr class="collapse" id="eula-row">
|
||||
<table style="margin-top: 80px;">
|
||||
<tr class="collapse eula-row">
|
||||
<td style="padding-right: 10px; vertical-align: top; font-weight: bold;">EULA</td>
|
||||
<td style="padding-right: 10px; vertical-align: top; padding-bottom: 80px;" colspan="3">
|
||||
@php
|
||||
|
@ -386,7 +407,7 @@
|
|||
@endforeach
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-right: 10px; vertical-align: top; font-weight: bold;">{{ trans('general.signed_off_by') }}:</td>
|
||||
<td style="padding-right: 10px; vertical-align: top;">______________________________________</td>
|
||||
|
@ -414,6 +435,7 @@
|
|||
</tr>
|
||||
|
||||
</table>
|
||||
@endforeach
|
||||
|
||||
{{-- Javascript files --}}
|
||||
<script src="{{ url(mix('js/dist/all.js')) }}" nonce="{{ csrf_token() }}"></script>
|
||||
|
|
|
@ -153,4 +153,4 @@ Route::resource('users', Users\UsersController::class, [
|
|||
'middleware' => ['auth'],
|
||||
'parameters' => ['user' => 'user_id'],
|
||||
'except' => ['update']
|
||||
]);
|
||||
]);
|
||||
|
|
Loading…
Reference in a new issue