From 7ad4a2997094f9302e4858e4ca61453758fbf3cc Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 19 Sep 2024 16:54:39 -0700 Subject: [PATCH 01/19] Add eager loading --- .../Controllers/Users/UsersController.php | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/Users/UsersController.php b/app/Http/Controllers/Users/UsersController.php index 1d7fc91ebd..f1826f1481 100755 --- a/app/Http/Controllers/Users/UsersController.php +++ b/app/Http/Controllers/Users/UsersController.php @@ -597,17 +597,25 @@ 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', + 'accessories', + 'consumables', + 'licenses', + ]) + ->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) + return view('users/print') + ->with('assets', $user->assets) + ->with('licenses', $user->licenses) + ->with('accessories', $user->accessories) + ->with('consumables', $user->consumables) ->with('show_user', $user) ->with('settings', Setting::getSettings()); } From e95703cb181b273b0fdbc5016ab585408c7636c0 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 19 Sep 2024 17:10:07 -0700 Subject: [PATCH 02/19] Use eager load --- .../Controllers/Users/UsersController.php | 6 +---- resources/views/users/print.blade.php | 25 ++++++++++--------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/app/Http/Controllers/Users/UsersController.php b/app/Http/Controllers/Users/UsersController.php index f1826f1481..31c5a1689d 100755 --- a/app/Http/Controllers/Users/UsersController.php +++ b/app/Http/Controllers/Users/UsersController.php @@ -611,11 +611,7 @@ class UsersController extends Controller if ($user) { $this->authorize('view', $user); - return view('users/print') - ->with('assets', $user->assets) - ->with('licenses', $user->licenses) - ->with('accessories', $user->accessories) - ->with('consumables', $user->consumables) + return view('users.print') ->with('show_user', $user) ->with('settings', Setting::getSettings()); } diff --git a/resources/views/users/print.blade.php b/resources/views/users/print.blade.php index 26ed2e8127..858f524b4a 100644 --- a/resources/views/users/print.blade.php +++ b/resources/views/users/print.blade.php @@ -81,13 +81,13 @@ - @if ($assets->count() > 0) + @if ($show_user->assets->count() > 0) @php $counter = 1; @endphp
-

{{ trans_choice('general.countable.assets', $assets->count(), ['count' => $assets->count()]) }} +

{{ trans_choice('general.countable.assets', $show_user->assets->count(), ['count' => $show_user->assets->count()]) }}

@@ -119,7 +119,7 @@ {{ trans('general.signature') }} - @foreach ($assets as $asset) + @foreach ($show_user->assets as $asset) @php if ($asset->model->category->getEula()) $eulas[] = $asset->model->category->getEula() @endphp @@ -185,9 +185,10 @@ @endif - @if ($licenses->count() > 0) +{{ $show_user->licenses->count() }} + @if ($show_user->licenses->count() > 0)
-

{{ trans_choice('general.countable.licenses', $licenses->count(), ['count' => $licenses->count()]) }}

+

{{ trans_choice('general.countable.licenses', $show_user->licenses->count(), ['count' => $show_user->licenses->count()]) }}

licenses as $license) @php if ($license->category->getEula()) $eulas[] = $license->category->getEula() @endphp @@ -240,9 +241,9 @@ @endif - @if ($accessories->count() > 0) + @if ($show_user->accessories->count() > 0)
-

{{ trans_choice('general.countable.accessories', $accessories->count(), ['count' => $accessories->count()]) }}

+

{{ trans_choice('general.countable.accessories', $show_user->accessories->count(), ['count' => $show_user->accessories->count()]) }}

accessories as $accessory) @if ($accessory) @php if ($accessory->category->getEula()) $eulas[] = $accessory->category->getEula() @@ -303,9 +304,9 @@
@endif - @if ($consumables->count() > 0) + @if ($show_user->consumables->count() > 0)
-

{{ trans_choice('general.countable.consumables', $consumables->count(), ['count' => $consumables->count()]) }}

+

{{ trans_choice('general.countable.consumables', $show_user->consumables->count(), ['count' => $show_user->consumables->count()]) }}

consumables as $consumable) @if ($consumable) @php if ($consumable->category->getEula()) $eulas[] = $consumable->category->getEula() From bdf5708bfcf4b9c95a8d8edf7544db74f8e69ffb Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 19 Sep 2024 17:10:43 -0700 Subject: [PATCH 03/19] Remove accidental line --- resources/views/users/print.blade.php | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/views/users/print.blade.php b/resources/views/users/print.blade.php index 858f524b4a..173c9109f2 100644 --- a/resources/views/users/print.blade.php +++ b/resources/views/users/print.blade.php @@ -185,7 +185,6 @@
@endif -{{ $show_user->licenses->count() }} @if ($show_user->licenses->count() > 0)

{{ trans_choice('general.countable.licenses', $show_user->licenses->count(), ['count' => $show_user->licenses->count()]) }}

From efd6d7625fa7e99719e483625a474a2c39061b21 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 19 Sep 2024 17:16:05 -0700 Subject: [PATCH 04/19] Remove bad closing tag --- resources/views/users/print.blade.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/resources/views/users/print.blade.php b/resources/views/users/print.blade.php index 173c9109f2..d4a8cebf1a 100644 --- a/resources/views/users/print.blade.php +++ b/resources/views/users/print.blade.php @@ -79,8 +79,6 @@

{{ trans('admin/users/general.all_assigned_list_generation')}} {{ Helper::getFormattedDateObject(now(), 'datetime', false) }} - - @if ($show_user->assets->count() > 0) @php $counter = 1; From 8364d26c9be3bafd6ab918f124a99bfa99e0aaa5 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 19 Sep 2024 17:18:26 -0700 Subject: [PATCH 05/19] Extract parent layout --- resources/views/users/print-shell.blade.php | 163 +++++++++++ resources/views/users/print.blade.php | 306 +++++--------------- 2 files changed, 238 insertions(+), 231 deletions(-) create mode 100644 resources/views/users/print-shell.blade.php diff --git a/resources/views/users/print-shell.blade.php b/resources/views/users/print-shell.blade.php new file mode 100644 index 0000000000..0ea843c8ae --- /dev/null +++ b/resources/views/users/print-shell.blade.php @@ -0,0 +1,163 @@ + + + + + {{ trans('general.assigned_to', ['name' => $show_user->present()->fullName()]) }} - {{ date('Y-m-d H:i', time()) }} + + + + + + {{-- stylesheets --}} + + + + + + + + + + + +@if ($snipeSettings->logo_print_assets=='1') + @if ($snipeSettings->brand == '3') + +

+ @if ($snipeSettings->logo!='') + + @endif + {{ $snipeSettings->site_name }} +

+ @elseif ($snipeSettings->brand == '2') + @if ($snipeSettings->logo!='') + + @endif + @else +

{{ $snipeSettings->site_name }}

+ @endif +@endif + +@yield('content') + +{{-- Javascript files --}} + + + + + + + + + + + + diff --git a/resources/views/users/print.blade.php b/resources/views/users/print.blade.php index d4a8cebf1a..822d15d883 100644 --- a/resources/views/users/print.blade.php +++ b/resources/views/users/print.blade.php @@ -1,83 +1,13 @@ - - - - - {{ trans('general.assigned_to', ['name' => $show_user->present()->fullName()]) }} - {{ date('Y-m-d H:i', time()) }} +@extends('users.print-shell') - +@section('content') - - - {{-- stylesheets --}} - - - - - - - - - - - -@if ($snipeSettings->logo_print_assets=='1') - @if ($snipeSettings->brand == '3') - -

- @if ($snipeSettings->logo!='') - - @endif - {{ $snipeSettings->site_name }} -

- @elseif ($snipeSettings->brand == '2') - @if ($snipeSettings->logo!='') - - @endif - @else -

{{ $snipeSettings->site_name }}

- @endif -@endif - -

- {{ trans('general.assigned_to', ['name' => $show_user->present()->fullName()]) }} - {{ ($show_user->employee_num!='') ? ' (#'.$show_user->employee_num.') ' : '' }} - {{ ($show_user->jobtitle!='' ? ' - '.$show_user->jobtitle : '') }} -

-

{{ trans('admin/users/general.all_assigned_list_generation')}} {{ Helper::getFormattedDateObject(now(), 'datetime', false) }} +

+ {{ trans('general.assigned_to', ['name' => $show_user->present()->fullName()]) }} + {{ ($show_user->employee_num!='') ? ' (#'.$show_user->employee_num.') ' : '' }} + {{ ($show_user->jobtitle!='' ? ' - '.$show_user->jobtitle : '') }} +

+

{{ trans('admin/users/general.all_assigned_list_generation')}} {{ Helper::getFormattedDateObject(now(), 'datetime', false) }} @if ($show_user->assets->count() > 0) @php @@ -90,31 +20,31 @@
+ 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"> - - - - - - - - - - - + + + + + + + + + + + @foreach ($show_user->assets as $asset) @@ -189,19 +119,19 @@
#{{ trans('general.image') }}{{ trans('admin/hardware/table.asset_tag') }}{{ trans('general.name') }}{{ trans('general.category') }}{{ trans('admin/hardware/form.model') }}{{ trans('admin/hardware/form.default_location') }}{{ trans('general.location') }}{{ trans('admin/hardware/form.serial') }}{{ trans('admin/hardware/table.checkout_date') }}{{ trans('general.signature') }}#{{ trans('general.image') }}{{ trans('admin/hardware/table.asset_tag') }}{{ trans('general.name') }}{{ trans('general.category') }}{{ trans('admin/hardware/form.model') }}{{ trans('admin/hardware/form.default_location') }}{{ trans('general.location') }}{{ trans('admin/hardware/form.serial') }}{{ trans('admin/hardware/table.checkout_date') }}{{ trans('general.signature') }}
+ 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"> @@ -244,19 +174,19 @@
#
+ 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"> @@ -289,7 +219,7 @@ @@ -307,19 +237,19 @@
# @if (($accessory->assetlog->first()) && ($accessory->assetlog->first()->accept_signature!='')) - + @endif
+ 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"> @@ -345,7 +275,7 @@ @if ($consumable->deleted_at!='') @else - {{ ($consumable->manufacturer) ? $consumable->manufacturer->name : '' }} {{ $consumable->name }} {{ $consumable->model_number }} + {{ ($consumable->manufacturer) ? $consumable->manufacturer->name : '' }} {{ $consumable->name }} {{ $consumable->model_number }} @endif @@ -384,7 +314,7 @@ @endforeach @endif - + @@ -413,90 +343,4 @@
{{ ($consumable->manufacturer) ? $consumable->manufacturer->name : '' }} {{ $consumable->name }} {{ $consumable->model_number }} {{ ($consumable->category) ? $consumable->category->name : ' invalid/deleted category' }}
{{ trans('general.signed_off_by') }}: ______________________________________
-{{-- Javascript files --}} - - - - - - - - - - - - +@endsection From 2d2d5bdc7ea37174da7069471eac03d002584698 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 19 Sep 2024 17:23:47 -0700 Subject: [PATCH 06/19] Pass user in array --- .../Controllers/Users/UsersController.php | 2 +- resources/views/users/print.blade.php | 628 +++++++++--------- 2 files changed, 316 insertions(+), 314 deletions(-) diff --git a/app/Http/Controllers/Users/UsersController.php b/app/Http/Controllers/Users/UsersController.php index 31c5a1689d..ddef9e3b30 100755 --- a/app/Http/Controllers/Users/UsersController.php +++ b/app/Http/Controllers/Users/UsersController.php @@ -612,7 +612,7 @@ class UsersController extends Controller $this->authorize('view', $user); return view('users.print') - ->with('show_user', $user) + ->with('users', [$user]) ->with('settings', Setting::getSettings()); } diff --git a/resources/views/users/print.blade.php b/resources/views/users/print.blade.php index 822d15d883..5627d76096 100644 --- a/resources/views/users/print.blade.php +++ b/resources/views/users/print.blade.php @@ -2,345 +2,347 @@ @section('content') -

- {{ trans('general.assigned_to', ['name' => $show_user->present()->fullName()]) }} - {{ ($show_user->employee_num!='') ? ' (#'.$show_user->employee_num.') ' : '' }} - {{ ($show_user->jobtitle!='' ? ' - '.$show_user->jobtitle : '') }} -

-

{{ trans('admin/users/general.all_assigned_list_generation')}} {{ Helper::getFormattedDateObject(now(), 'datetime', false) }} + @foreach($users as $show_user) +

+ {{ trans('general.assigned_to', ['name' => $show_user->present()->fullName()]) }} + {{ ($show_user->employee_num!='') ? ' (#'.$show_user->employee_num.') ' : '' }} + {{ ($show_user->jobtitle!='' ? ' - '.$show_user->jobtitle : '') }} +

+

{{ trans('admin/users/general.all_assigned_list_generation')}} {{ Helper::getFormattedDateObject(now(), 'datetime', false) }} - @if ($show_user->assets->count() > 0) - @php - $counter = 1; - @endphp + @if ($show_user->assets->count() > 0) + @php + $counter = 1; + @endphp -
-

{{ trans_choice('general.countable.assets', $show_user->assets->count(), ['count' => $show_user->assets->count()]) }} -

-
+
+

{{ trans_choice('general.countable.assets', $show_user->assets->count(), ['count' => $show_user->assets->count()]) }} +

+
- - - - - - - - - - - - - - - - @foreach ($show_user->assets as $asset) - @php - if ($asset->model->category->getEula()) $eulas[] = $asset->model->category->getEula() - @endphp - - - - - - - - - - - - - - @if ($settings->show_assigned_assets) +
#{{ trans('general.image') }}{{ trans('admin/hardware/table.asset_tag') }}{{ trans('general.name') }}{{ trans('general.category') }}{{ trans('admin/hardware/form.model') }}{{ trans('admin/hardware/form.default_location') }}{{ trans('general.location') }}{{ trans('admin/hardware/form.serial') }}{{ trans('admin/hardware/table.checkout_date') }}{{ trans('general.signature') }}
{{ $counter }} - @if ($asset->getImageUrl()) - - @endif - {{ $asset->asset_tag }}{{ $asset->name }}{{ (($asset->model) && ($asset->model->category)) ? $asset->model->category->name : trans('general.invalid_category') }}{{ ($asset->model) ? $asset->model->name : trans('general.invalid_model') }}{{ ($asset->defaultLoc) ? $asset->defaultLoc->name : '' }}{{ ($asset->location) ? $asset->location->name : '' }}{{ $asset->serial }} - {{ Helper::getFormattedDateObject($asset->last_checkout, 'datetime', false) }} - @if (($asset->assetlog->first()) && ($asset->assetlog->first()->accept_signature!='')) - - @endif -
+ + + + + + + + + + + + + + + @foreach ($show_user->assets as $asset) @php - $assignedCounter = 1; + if ($asset->model->category->getEula()) $eulas[] = $asset->model->category->getEula() @endphp - @foreach ($asset->assignedAssets as $asset) + + + + + + + + + + + + + + @if ($settings->show_assigned_assets) + @php + $assignedCounter = 1; + @endphp + @foreach ($asset->assignedAssets as $asset) + + + + + + + + + + + + + + @php + $assignedCounter++ + @endphp + @endforeach + @endif + @php + $counter++ + @endphp + @endforeach + +
#{{ trans('general.image') }}{{ trans('admin/hardware/table.asset_tag') }}{{ trans('general.name') }}{{ trans('general.category') }}{{ trans('admin/hardware/form.model') }}{{ trans('admin/hardware/form.default_location') }}{{ trans('general.location') }}{{ trans('admin/hardware/form.serial') }}{{ trans('admin/hardware/table.checkout_date') }}{{ trans('general.signature') }}
{{ $counter }} + @if ($asset->getImageUrl()) + + @endif + {{ $asset->asset_tag }}{{ $asset->name }}{{ (($asset->model) && ($asset->model->category)) ? $asset->model->category->name : trans('general.invalid_category') }}{{ ($asset->model) ? $asset->model->name : trans('general.invalid_model') }}{{ ($asset->defaultLoc) ? $asset->defaultLoc->name : '' }}{{ ($asset->location) ? $asset->location->name : '' }}{{ $asset->serial }} + {{ Helper::getFormattedDateObject($asset->last_checkout, 'datetime', false) }} + @if (($asset->assetlog->first()) && ($asset->assetlog->first()->accept_signature!='')) + + @endif +
{{ $counter }}.{{ $assignedCounter }} + @if ($asset->getImageUrl()) + + @endif + {{ $asset->asset_tag }}{{ $asset->name }}{{ (($asset->model) && ($asset->model->category)) ? $asset->model->category->name : trans('general.invalid_category') }}{{ ($asset->model) ? $asset->model->name : trans('general.invalid_model') }}{{ ($asset->defaultLoc) ? $asset->defaultLoc->name : '' }}{{ ($asset->location) ? $asset->location->name : '' }}{{ $asset->serial }} + {{ Helper::getFormattedDateObject($asset->last_checkout, 'datetime', false) }} + @if (($asset->assetlog->first()) && ($asset->assetlog->first()->accept_signature!='')) + + @endif +
+ @endif + + @if ($show_user->licenses->count() > 0) +
+

{{ trans_choice('general.countable.licenses', $show_user->licenses->count(), ['count' => $show_user->licenses->count()]) }}

+
+ + + + + + + + + + + @php + $lcounter = 1; + @endphp + + @foreach ($show_user->licenses as $license) + @php + if ($license->category->getEula()) $eulas[] = $license->category->getEula() + @endphp + + + + + + + @php + $lcounter++ + @endphp + @endforeach +
#{{ trans('general.name') }}{{ trans('admin/licenses/form.license_key') }}{{ trans('admin/hardware/table.checkout_date') }}
{{ $lcounter }}{{ $license->name }} + @can('viewKeys', $license) + {{ $license->serial }} + @else + {{ str_repeat('x', 15) }} + @endcan + {{ $license->pivot->updated_at }}
+ @endif + + + @if ($show_user->accessories->count() > 0) +
+

{{ trans_choice('general.countable.accessories', $show_user->accessories->count(), ['count' => $show_user->accessories->count()]) }}

+
+ + + + + + + + + + + + + @php + $acounter = 1; + @endphp + + @foreach ($show_user->accessories as $accessory) + @if ($accessory) + @php + if ($accessory->category->getEula()) $eulas[] = $accessory->category->getEula() + @endphp - + - - - - - - - + + + + - @php - $assignedCounter++ + $acounter++ @endphp - @endforeach - @endif - @php - $counter++ - @endphp - @endforeach - -
#{{ trans('general.image') }}{{ trans('general.name') }}{{ trans('general.category') }}{{ trans('admin/hardware/table.checkout_date') }}{{ trans('general.signature') }}
{{ $counter }}.{{ $assignedCounter }}{{ $acounter }} - @if ($asset->getImageUrl()) - + @if ($accessory->getImageUrl()) + @endif {{ $asset->asset_tag }}{{ $asset->name }}{{ (($asset->model) && ($asset->model->category)) ? $asset->model->category->name : trans('general.invalid_category') }}{{ ($asset->model) ? $asset->model->name : trans('general.invalid_model') }}{{ ($asset->defaultLoc) ? $asset->defaultLoc->name : '' }}{{ ($asset->location) ? $asset->location->name : '' }}{{ $asset->serial }}{{ ($accessory->manufacturer) ? $accessory->manufacturer->name : '' }} {{ $accessory->name }} {{ $accessory->model_number }}{{ $accessory->category->name }}{{ $accessory->pivot->created_at }} - {{ Helper::getFormattedDateObject($asset->last_checkout, 'datetime', false) }} - @if (($asset->assetlog->first()) && ($asset->assetlog->first()->accept_signature!='')) - + @if (($accessory->assetlog->first()) && ($accessory->assetlog->first()->accept_signature!='')) + @endif
- @endif + @endif + @endforeach + + @endif - @if ($show_user->licenses->count() > 0) -
-

{{ trans_choice('general.countable.licenses', $show_user->licenses->count(), ['count' => $show_user->licenses->count()]) }}

-
+ @if ($show_user->consumables->count() > 0) +
+

{{ trans_choice('general.countable.consumables', $show_user->consumables->count(), ['count' => $show_user->consumables->count()]) }}

+
- - - - - - - - - - @php - $lcounter = 1; - @endphp - - @foreach ($show_user->licenses as $license) - @php - if ($license->category->getEula()) $eulas[] = $license->category->getEula() - @endphp +
#{{ trans('general.name') }}{{ trans('admin/licenses/form.license_key') }}{{ trans('admin/hardware/table.checkout_date') }}
+ - - - - + + + + + + + @php - $lcounter++ + $ccounter = 1; @endphp - @endforeach -
{{ $lcounter }}{{ $license->name }} - @can('viewKeys', $license) - {{ $license->serial }} - @else - {{ str_repeat('x', 15) }} - @endcan - {{ $license->pivot->updated_at }}{{ trans('general.name') }}{{ trans('general.category') }}{{ trans('admin/hardware/table.checkout_date') }}{{ trans('general.signature') }}
- @endif - - @if ($show_user->accessories->count() > 0) -
-

{{ trans_choice('general.countable.accessories', $show_user->accessories->count(), ['count' => $show_user->accessories->count()]) }}

-
- - - - - - - - - - - - - @php - $acounter = 1; - @endphp - - @foreach ($show_user->accessories as $accessory) - @if ($accessory) - @php - if ($accessory->category->getEula()) $eulas[] = $accessory->category->getEula() - @endphp - - - - - - - - - - @php - $acounter++ - @endphp - @endif - @endforeach -
#{{ trans('general.image') }}{{ trans('general.name') }}{{ trans('general.category') }}{{ trans('admin/hardware/table.checkout_date') }}{{ trans('general.signature') }}
{{ $acounter }} - @if ($accessory->getImageUrl()) - - @endif - {{ ($accessory->manufacturer) ? $accessory->manufacturer->name : '' }} {{ $accessory->name }} {{ $accessory->model_number }}{{ $accessory->category->name }}{{ $accessory->pivot->created_at }} - @if (($accessory->assetlog->first()) && ($accessory->assetlog->first()->accept_signature!='')) - - @endif -
- @endif - - @if ($show_user->consumables->count() > 0) -
-

{{ trans_choice('general.countable.consumables', $show_user->consumables->count(), ['count' => $show_user->consumables->count()]) }}

-
- - - - - - - - - - - - - @php - $ccounter = 1; - @endphp - - @foreach ($show_user->consumables as $consumable) - @if ($consumable) - @php - if ($consumable->category->getEula()) $eulas[] = $consumable->category->getEula() - @endphp - - - - @else - {{ ($consumable->manufacturer) ? $consumable->manufacturer->name : '' }} {{ $consumable->name }} {{ $consumable->model_number }} - @endif - - - + @foreach ($show_user->consumables as $consumable) + @if ($consumable) + @php + if ($consumable->category->getEula()) $eulas[] = $consumable->category->getEula() + @endphp + + + @else + {{ ($consumable->manufacturer) ? $consumable->manufacturer->name : '' }} {{ $consumable->name }} {{ $consumable->model_number }} @endif - - + + + + + + @php + $ccounter++ + @endphp + @endif + @endforeach +
{{ trans('general.name') }}{{ trans('general.category') }}{{ trans('admin/hardware/table.checkout_date') }}{{ trans('general.signature') }}
{{ $ccounter }} - @if ($consumable->deleted_at!='') - {{ ($consumable->manufacturer) ? $consumable->manufacturer->name : '' }} {{ $consumable->name }} {{ $consumable->model_number }}{{ ($consumable->category) ? $consumable->category->name : ' invalid/deleted category' }} {{ $consumable->pivot->created_at }}
{{ $ccounter }} - @if (($consumable->assetlog->first()) && ($consumable->assetlog->first()->accept_signature!='')) - + @if ($consumable->deleted_at!='') + {{ ($consumable->manufacturer) ? $consumable->manufacturer->name : '' }} {{ $consumable->name }} {{ $consumable->model_number }}
{{ ($consumable->category) ? $consumable->category->name : ' invalid/deleted category' }} {{ $consumable->pivot->created_at }} + @if (($consumable->assetlog->first()) && ($consumable->assetlog->first()->accept_signature!='')) + + @endif +
+ @endif + +

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
EULA @php - $ccounter++ + if (!empty($eulas)) $eulas = array_unique($eulas); @endphp - @endif - @endforeach + @if (!empty($eulas)) + @foreach ($eulas as $key => $eula) + {!! $eula !!} + @endforeach + @endif +
{{ trans('general.signed_off_by') }}:_________________________________________________________________________________________
{{ trans('general.name') }}{{ trans('general.signature') }}{{ trans('general.date') }}
{{ trans('admin/users/table.manager') }}:_________________________________________________________________________________________
{{ trans('general.name') }}{{ trans('general.signature') }}{{ trans('general.date') }}
- @endif - -

-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EULA - @php - if (!empty($eulas)) $eulas = array_unique($eulas); - @endphp - @if (!empty($eulas)) - @foreach ($eulas as $key => $eula) - {!! $eula !!} - @endforeach - @endif -
{{ trans('general.signed_off_by') }}:_________________________________________________________________________________________
{{ trans('general.name') }}{{ trans('general.signature') }}{{ trans('general.date') }}
{{ trans('admin/users/table.manager') }}:_________________________________________________________________________________________
{{ trans('general.name') }}{{ trans('general.signature') }}{{ trans('general.date') }}
+ @endforeach @endsection From 5128fd49e6f7705c8b9b4b095a2423544439ff94 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 19 Sep 2024 17:27:25 -0700 Subject: [PATCH 07/19] Allow printing all users --- .../Controllers/Users/UsersController.php | 20 +++++++++++++++++++ routes/web/users.php | 4 +++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Users/UsersController.php b/app/Http/Controllers/Users/UsersController.php index ddef9e3b30..155024106c 100755 --- a/app/Http/Controllers/Users/UsersController.php +++ b/app/Http/Controllers/Users/UsersController.php @@ -617,7 +617,27 @@ 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', + 'accessories', + 'consumables', + 'licenses', + ]) + ->withTrashed() + ->get(); + + // @todo: more authorization + + return view('users.print') + ->with('users', $users) + ->with('settings', Setting::getSettings()); } /** diff --git a/routes/web/users.php b/routes/web/users.php index e55541a937..76c867519b 100644 --- a/routes/web/users.php +++ b/routes/web/users.php @@ -104,6 +104,8 @@ Route::group(['prefix' => 'users', 'middleware' => ['auth']], function () { ] )->name('users.print'); + Route::get('print-all-things', [Users\UsersController::class, 'printAllThings'])->name('users.print-all-things'); + Route::post( '{userId}/email', [ @@ -153,4 +155,4 @@ Route::resource('users', Users\UsersController::class, [ 'middleware' => ['auth'], 'parameters' => ['user' => 'user_id'], 'except' => ['update'] -]); \ No newline at end of file +]); From e493cc964daf88a8e4f0ddf5d397f6092d6f745e Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 23 Sep 2024 10:48:07 -0700 Subject: [PATCH 08/19] Remove AssetCountForSidebar middleware from print view --- routes/web/users.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/routes/web/users.php b/routes/web/users.php index 76c867519b..dd93d44982 100644 --- a/routes/web/users.php +++ b/routes/web/users.php @@ -2,6 +2,7 @@ use App\Http\Controllers\Users; use App\Http\Controllers\Users\UserFilesController; +use App\Http\Middleware\AssetCountForSidebar; use Illuminate\Support\Facades\Route; // User Management @@ -104,7 +105,9 @@ Route::group(['prefix' => 'users', 'middleware' => ['auth']], function () { ] )->name('users.print'); - Route::get('print-all-things', [Users\UsersController::class, 'printAllThings'])->name('users.print-all-things'); + Route::get('print-all-things', [Users\UsersController::class, 'printAllThings']) + ->withoutMiddleware([AssetCountForSidebar::class]) + ->name('users.print-all-things'); Route::post( '{userId}/email', From 54044bfa5e4752c3ac0dc907bb40734154520f31 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 23 Sep 2024 10:57:57 -0700 Subject: [PATCH 09/19] Add eager loads --- app/Http/Controllers/Users/UsersController.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Users/UsersController.php b/app/Http/Controllers/Users/UsersController.php index 5643a43f54..1a82a24093 100755 --- a/app/Http/Controllers/Users/UsersController.php +++ b/app/Http/Controllers/Users/UsersController.php @@ -625,10 +625,20 @@ class UsersController extends Controller $users = User::query() ->with([ - 'assets', - 'accessories', - 'consumables', - 'licenses', + '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(); From a2d4dcf6e82df284602990bf9465129e0997a27b Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 23 Sep 2024 12:49:36 -0700 Subject: [PATCH 10/19] Use bulk actions menu --- .../Controllers/Users/BulkUsersController.php | 25 +++++++++++++++ .../Controllers/Users/UsersController.php | 31 ------------------- .../partials/users-bulk-actions.blade.php | 3 +- routes/web/users.php | 4 --- 4 files changed, 27 insertions(+), 36 deletions(-) diff --git a/app/Http/Controllers/Users/BulkUsersController.php b/app/Http/Controllers/Users/BulkUsersController.php index d13f904419..e19db62633 100644 --- a/app/Http/Controllers/Users/BulkUsersController.php +++ b/app/Http/Controllers/Users/BulkUsersController.php @@ -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()); } } diff --git a/app/Http/Controllers/Users/UsersController.php b/app/Http/Controllers/Users/UsersController.php index 1a82a24093..003a8d41e3 100755 --- a/app/Http/Controllers/Users/UsersController.php +++ b/app/Http/Controllers/Users/UsersController.php @@ -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 * diff --git a/resources/views/partials/users-bulk-actions.blade.php b/resources/views/partials/users-bulk-actions.blade.php index cf22fde03d..a1dbd25476 100644 --- a/resources/views/partials/users-bulk-actions.blade.php +++ b/resources/views/partials/users-bulk-actions.blade.php @@ -14,10 +14,11 @@ + @endcan @endif {{ Form::close() }} - \ No newline at end of file + diff --git a/routes/web/users.php b/routes/web/users.php index dd93d44982..6ee2eda9f2 100644 --- a/routes/web/users.php +++ b/routes/web/users.php @@ -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', [ From 8ac5c0e471867163beae248ae5cb81891e8c2d9e Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 23 Sep 2024 14:05:47 -0700 Subject: [PATCH 11/19] Re-combine layout and view --- resources/views/users/print-shell.blade.php | 163 ---- resources/views/users/print.blade.php | 776 ++++++++++++-------- 2 files changed, 468 insertions(+), 471 deletions(-) delete mode 100644 resources/views/users/print-shell.blade.php diff --git a/resources/views/users/print-shell.blade.php b/resources/views/users/print-shell.blade.php deleted file mode 100644 index 0ea843c8ae..0000000000 --- a/resources/views/users/print-shell.blade.php +++ /dev/null @@ -1,163 +0,0 @@ - - - - - {{ trans('general.assigned_to', ['name' => $show_user->present()->fullName()]) }} - {{ date('Y-m-d H:i', time()) }} - - - - - - {{-- stylesheets --}} - - - - - - - - - - - -@if ($snipeSettings->logo_print_assets=='1') - @if ($snipeSettings->brand == '3') - -

- @if ($snipeSettings->logo!='') - - @endif - {{ $snipeSettings->site_name }} -

- @elseif ($snipeSettings->brand == '2') - @if ($snipeSettings->logo!='') - - @endif - @else -

{{ $snipeSettings->site_name }}

- @endif -@endif - -@yield('content') - -{{-- Javascript files --}} - - - - - - - - - - - - diff --git a/resources/views/users/print.blade.php b/resources/views/users/print.blade.php index 5627d76096..ac2de1f7b7 100644 --- a/resources/views/users/print.blade.php +++ b/resources/views/users/print.blade.php @@ -1,40 +1,114 @@ -@extends('users.print-shell') + + + + + @if (count($users) === 1) + {{ trans('general.assigned_to', ['name' => $users[0]->present()->fullName()]) }} - {{ date('Y-m-d H:i', time()) }} + @else + {{ trans('admin/users/general.print_assigned') }} - {{ date('Y-m-d H:i', time()) }} + @endisset -@section('content') + - @foreach($users as $show_user) -

- {{ trans('general.assigned_to', ['name' => $show_user->present()->fullName()]) }} - {{ ($show_user->employee_num!='') ? ' (#'.$show_user->employee_num.') ' : '' }} - {{ ($show_user->jobtitle!='' ? ' - '.$show_user->jobtitle : '') }} -

-

{{ trans('admin/users/general.all_assigned_list_generation')}} {{ Helper::getFormattedDateObject(now(), 'datetime', false) }} + - @if ($show_user->assets->count() > 0) - @php - $counter = 1; - @endphp + {{-- stylesheets --}} + -
-

{{ trans_choice('general.countable.assets', $show_user->assets->count(), ['count' => $show_user->assets->count()]) }} -

-
+ - - + + + + + + + +@if ($snipeSettings->logo_print_assets=='1') + @if ($snipeSettings->brand == '3') + +

+ @if ($snipeSettings->logo!='') + + @endif + {{ $snipeSettings->site_name }} +

+ @elseif ($snipeSettings->brand == '2') + @if ($snipeSettings->logo!='') + + @endif + @else +

{{ $snipeSettings->site_name }}

+ @endif +@endif + +@foreach($users as $show_user) +

+ {{ trans('general.assigned_to', ['name' => $show_user->present()->fullName()]) }} + {{ ($show_user->employee_num!='') ? ' (#'.$show_user->employee_num.') ' : '' }} + {{ ($show_user->jobtitle!='' ? ' - '.$show_user->jobtitle : '') }} +

+

{{ trans('admin/users/general.all_assigned_list_generation')}} {{ Helper::getFormattedDateObject(now(), 'datetime', false) }} + + @if ($show_user->assets->count() > 0) + @php + $counter = 1; + @endphp + +
+

{{ trans_choice('general.countable.assets', $show_user->assets->count(), ['count' => $show_user->assets->count()]) }} +

+
+ +
+ @@ -46,303 +120,389 @@ - - - @foreach ($show_user->assets as $asset) - @php - if ($asset->model->category->getEula()) $eulas[] = $asset->model->category->getEula() - @endphp - - - - - - - - - - - - - - @if ($settings->show_assigned_assets) - @php - $assignedCounter = 1; - @endphp - @foreach ($asset->assignedAssets as $asset) - - - - - - - - - - - - - - @php - $assignedCounter++ - @endphp - @endforeach - @endif - @php - $counter++ - @endphp - @endforeach - -
# {{ trans('general.image') }} {{ trans('admin/hardware/table.asset_tag') }}{{ trans('admin/hardware/form.serial') }} {{ trans('admin/hardware/table.checkout_date') }} {{ trans('general.signature') }}
{{ $counter }} - @if ($asset->getImageUrl()) - - @endif - {{ $asset->asset_tag }}{{ $asset->name }}{{ (($asset->model) && ($asset->model->category)) ? $asset->model->category->name : trans('general.invalid_category') }}{{ ($asset->model) ? $asset->model->name : trans('general.invalid_model') }}{{ ($asset->defaultLoc) ? $asset->defaultLoc->name : '' }}{{ ($asset->location) ? $asset->location->name : '' }}{{ $asset->serial }} - {{ Helper::getFormattedDateObject($asset->last_checkout, 'datetime', false) }} - @if (($asset->assetlog->first()) && ($asset->assetlog->first()->accept_signature!='')) - - @endif -
{{ $counter }}.{{ $assignedCounter }} - @if ($asset->getImageUrl()) - - @endif - {{ $asset->asset_tag }}{{ $asset->name }}{{ (($asset->model) && ($asset->model->category)) ? $asset->model->category->name : trans('general.invalid_category') }}{{ ($asset->model) ? $asset->model->name : trans('general.invalid_model') }}{{ ($asset->defaultLoc) ? $asset->defaultLoc->name : '' }}{{ ($asset->location) ? $asset->location->name : '' }}{{ $asset->serial }} - {{ Helper::getFormattedDateObject($asset->last_checkout, 'datetime', false) }} - @if (($asset->assetlog->first()) && ($asset->assetlog->first()->accept_signature!='')) - - @endif -
- @endif - - @if ($show_user->licenses->count() > 0) -
-

{{ trans_choice('general.countable.licenses', $show_user->licenses->count(), ['count' => $show_user->licenses->count()]) }}

-
- - - - - - - - - - + + + @foreach ($show_user->assets as $asset) @php - $lcounter = 1; + if ($asset->model->category->getEula()) $eulas[] = $asset->model->category->getEula() @endphp - - @foreach ($show_user->licenses as $license) - @php - if ($license->category->getEula()) $eulas[] = $license->category->getEula() - @endphp - - - - - - - @php - $lcounter++ - @endphp - @endforeach -
#{{ trans('general.name') }}{{ trans('admin/licenses/form.license_key') }}{{ trans('admin/hardware/table.checkout_date') }}
{{ $lcounter }}{{ $license->name }} - @can('viewKeys', $license) - {{ $license->serial }} - @else - {{ str_repeat('x', 15) }} - @endcan - {{ $license->pivot->updated_at }}
- @endif - - - @if ($show_user->accessories->count() > 0) -
-

{{ trans_choice('general.countable.accessories', $show_user->accessories->count(), ['count' => $show_user->accessories->count()]) }}

-
- - - - - - - - - + + + + + + + + + + + - - @php - $acounter = 1; - @endphp - - @foreach ($show_user->accessories as $accessory) - @if ($accessory) - @php - if ($accessory->category->getEula()) $eulas[] = $accessory->category->getEula() - @endphp + @if ($settings->show_assigned_assets) + @php + $assignedCounter = 1; + @endphp + @foreach ($asset->assignedAssets as $asset) - + - - - - + + + + + + + + @php - $acounter++ + $assignedCounter++ @endphp - @endif - @endforeach -
#{{ trans('general.image') }}{{ trans('general.name') }}{{ trans('general.category') }}{{ trans('admin/hardware/table.checkout_date') }}{{ trans('general.signature') }}{{ $counter }} + @if ($asset->getImageUrl()) + + @endif + {{ $asset->asset_tag }}{{ $asset->name }}{{ (($asset->model) && ($asset->model->category)) ? $asset->model->category->name : trans('general.invalid_category') }}{{ ($asset->model) ? $asset->model->name : trans('general.invalid_model') }}{{ ($asset->defaultLoc) ? $asset->defaultLoc->name : '' }}{{ ($asset->location) ? $asset->location->name : '' }}{{ $asset->serial }} + {{ Helper::getFormattedDateObject($asset->last_checkout, 'datetime', false) }} + @if (($asset->assetlog->first()) && ($asset->assetlog->first()->accept_signature!='')) + + @endif +
{{ $acounter }}{{ $counter }}.{{ $assignedCounter }} - @if ($accessory->getImageUrl()) - + @if ($asset->getImageUrl()) + @endif {{ ($accessory->manufacturer) ? $accessory->manufacturer->name : '' }} {{ $accessory->name }} {{ $accessory->model_number }}{{ $accessory->category->name }}{{ $accessory->pivot->created_at }}{{ $asset->asset_tag }}{{ $asset->name }}{{ (($asset->model) && ($asset->model->category)) ? $asset->model->category->name : trans('general.invalid_category') }}{{ ($asset->model) ? $asset->model->name : trans('general.invalid_model') }}{{ ($asset->defaultLoc) ? $asset->defaultLoc->name : '' }}{{ ($asset->location) ? $asset->location->name : '' }}{{ $asset->serial }} - @if (($accessory->assetlog->first()) && ($accessory->assetlog->first()->accept_signature!='')) - + {{ Helper::getFormattedDateObject($asset->last_checkout, 'datetime', false) }} + @if (($asset->assetlog->first()) && ($asset->assetlog->first()->accept_signature!='')) + @endif
- @endif - - @if ($show_user->consumables->count() > 0) -
-

{{ trans_choice('general.countable.consumables', $show_user->consumables->count(), ['count' => $show_user->consumables->count()]) }}

-
- - - - - - - - - - - - + @endforeach + @endif @php - $ccounter = 1; + $counter++ @endphp + @endforeach + +
{{ trans('general.name') }}{{ trans('general.category') }}{{ trans('admin/hardware/table.checkout_date') }}{{ trans('general.signature') }}
+ @endif - @foreach ($show_user->consumables as $consumable) - @if ($consumable) - @php - if ($consumable->category->getEula()) $eulas[] = $consumable->category->getEula() - @endphp - - {{ $ccounter }} - - @if ($consumable->deleted_at!='') - {{ ($consumable->manufacturer) ? $consumable->manufacturer->name : '' }} {{ $consumable->name }} {{ $consumable->model_number }} - @else - {{ ($consumable->manufacturer) ? $consumable->manufacturer->name : '' }} {{ $consumable->name }} {{ $consumable->model_number }} - @endif - - {{ ($consumable->category) ? $consumable->category->name : ' invalid/deleted category' }} - {{ $consumable->pivot->created_at }} - - @if (($consumable->assetlog->first()) && ($consumable->assetlog->first()->accept_signature!='')) - - @endif - - - @php - $ccounter++ - @endphp - @endif - @endforeach - - @endif - -

-
- + @if ($show_user->licenses->count() > 0) +
+

{{ trans_choice('general.countable.licenses', $show_user->licenses->count(), ['count' => $show_user->licenses->count()]) }}

- - - - - +
EULA - @php - if (!empty($eulas)) $eulas = array_unique($eulas); - @endphp - @if (!empty($eulas)) - @foreach ($eulas as $key => $eula) - {!! $eula !!} - @endforeach - @endif -
+ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + @php + $lcounter = 1; + @endphp + @foreach ($show_user->licenses as $license) + @php + if ($license->category->getEula()) $eulas[] = $license->category->getEula() + @endphp + + + + + + + @php + $lcounter++ + @endphp + @endforeach
{{ trans('general.signed_off_by') }}:_________________________________________________________________________________________
{{ trans('general.name') }}{{ trans('general.signature') }}{{ trans('general.date') }}
{{ trans('admin/users/table.manager') }}:_________________________________________________________________________________________
{{ trans('general.name') }}{{ trans('general.signature') }}{{ trans('general.date') }}#{{ trans('general.name') }}{{ trans('admin/licenses/form.license_key') }}{{ trans('admin/hardware/table.checkout_date') }}
{{ $lcounter }}{{ $license->name }} + @can('viewKeys', $license) + {{ $license->serial }} + @else + {{ str_repeat('x', 15) }} + @endcan + {{ $license->pivot->updated_at }}
- @endforeach + @endif -@endsection + + @if ($show_user->accessories->count() > 0) +
+

{{ trans_choice('general.countable.accessories', $show_user->accessories->count(), ['count' => $show_user->accessories->count()]) }}

+
+ + + + + + + + + + + + + @php + $acounter = 1; + @endphp + + @foreach ($show_user->accessories as $accessory) + @if ($accessory) + @php + if ($accessory->category->getEula()) $eulas[] = $accessory->category->getEula() + @endphp + + + + + + + + + + @php + $acounter++ + @endphp + @endif + @endforeach +
#{{ trans('general.image') }}{{ trans('general.name') }}{{ trans('general.category') }}{{ trans('admin/hardware/table.checkout_date') }}{{ trans('general.signature') }}
{{ $acounter }} + @if ($accessory->getImageUrl()) + + @endif + {{ ($accessory->manufacturer) ? $accessory->manufacturer->name : '' }} {{ $accessory->name }} {{ $accessory->model_number }}{{ $accessory->category->name }}{{ $accessory->pivot->created_at }} + @if (($accessory->assetlog->first()) && ($accessory->assetlog->first()->accept_signature!='')) + + @endif +
+ @endif + + @if ($show_user->consumables->count() > 0) +
+

{{ trans_choice('general.countable.consumables', $show_user->consumables->count(), ['count' => $show_user->consumables->count()]) }}

+
+ + + + + + + + + + + + + @php + $ccounter = 1; + @endphp + + @foreach ($show_user->consumables as $consumable) + @if ($consumable) + @php + if ($consumable->category->getEula()) $eulas[] = $consumable->category->getEula() + @endphp + + + + @else + {{ ($consumable->manufacturer) ? $consumable->manufacturer->name : '' }} {{ $consumable->name }} {{ $consumable->model_number }} + @endif + + + + + + @php + $ccounter++ + @endphp + @endif + @endforeach +
{{ trans('general.name') }}{{ trans('general.category') }}{{ trans('admin/hardware/table.checkout_date') }}{{ trans('general.signature') }}
{{ $ccounter }} + @if ($consumable->deleted_at!='') + {{ ($consumable->manufacturer) ? $consumable->manufacturer->name : '' }} {{ $consumable->name }} {{ $consumable->model_number }}{{ ($consumable->category) ? $consumable->category->name : ' invalid/deleted category' }} {{ $consumable->pivot->created_at }} + @if (($consumable->assetlog->first()) && ($consumable->assetlog->first()->accept_signature!='')) + + @endif +
+ @endif + +

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
EULA + @php + if (!empty($eulas)) $eulas = array_unique($eulas); + @endphp + @if (!empty($eulas)) + @foreach ($eulas as $key => $eula) + {!! $eula !!} + @endforeach + @endif +
{{ trans('general.signed_off_by') }}:_________________________________________________________________________________________
{{ trans('general.name') }}{{ trans('general.signature') }}{{ trans('general.date') }}
{{ trans('admin/users/table.manager') }}:_________________________________________________________________________________________
{{ trans('general.name') }}{{ trans('general.signature') }}{{ trans('general.date') }}
+@endforeach + +{{-- Javascript files --}} + + + + + + + + + + + + From a02e250b22538e440ff0b25578c62540a316c029 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 23 Sep 2024 15:26:15 -0700 Subject: [PATCH 12/19] Add page breaks for each user --- resources/views/users/print.blade.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/resources/views/users/print.blade.php b/resources/views/users/print.blade.php index ac2de1f7b7..9486173663 100644 --- a/resources/views/users/print.blade.php +++ b/resources/views/users/print.blade.php @@ -37,6 +37,10 @@ size: A4; } + #start_of_user_section { + break-before: page; + } + .print-logo { max-height: 40px; } @@ -77,6 +81,7 @@ @endif @foreach($users as $show_user) +
{{-- used for page breaks when printing --}}

{{ trans('general.assigned_to', ['name' => $show_user->present()->fullName()]) }} {{ ($show_user->employee_num!='') ? ' (#'.$show_user->employee_num.') ' : '' }} From 3870095a28784d7b776b4647b0bbe325cadea8aa Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 23 Sep 2024 15:50:24 -0700 Subject: [PATCH 13/19] Fix Cannot read properties of undefined error by removing snipe-table class from eula table --- resources/views/users/print.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/users/print.blade.php b/resources/views/users/print.blade.php index 9486173663..ef75dcb6d3 100644 --- a/resources/views/users/print.blade.php +++ b/resources/views/users/print.blade.php @@ -381,7 +381,7 @@

- +
EULA From cef7ddc719a7f6fdc63b341038aa28b89cd2ead2 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 23 Sep 2024 16:10:21 -0700 Subject: [PATCH 14/19] Add eager loads to userscontroller --- .../Controllers/Users/UsersController.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Users/UsersController.php b/app/Http/Controllers/Users/UsersController.php index 003a8d41e3..051db1f4ef 100755 --- a/app/Http/Controllers/Users/UsersController.php +++ b/app/Http/Controllers/Users/UsersController.php @@ -600,10 +600,21 @@ class UsersController extends Controller $user = User::where('id', $id) ->with([ - 'assets', - 'accessories', - 'consumables', - 'licenses', + '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(); From ab90c0cf05c36796e69641f1ee6c8120df2a2c56 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 23 Sep 2024 16:10:40 -0700 Subject: [PATCH 15/19] Add missing eager load in bulk users controller --- app/Http/Controllers/Users/BulkUsersController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Http/Controllers/Users/BulkUsersController.php b/app/Http/Controllers/Users/BulkUsersController.php index e19db62633..60d5bb3713 100644 --- a/app/Http/Controllers/Users/BulkUsersController.php +++ b/app/Http/Controllers/Users/BulkUsersController.php @@ -88,6 +88,7 @@ class BulkUsersController extends Controller 'assets.defaultLoc', 'assets.location', 'assets.model.category', + 'accessories.assetlog', 'accessories.category', 'accessories.manufacturer', 'consumables.assetlog', From 4b02db5031cb4e8f850a9ea942e99efe449c8895 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 23 Sep 2024 16:26:22 -0700 Subject: [PATCH 16/19] Add authorization check in bulk users controller --- app/Http/Controllers/Users/BulkUsersController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Http/Controllers/Users/BulkUsersController.php b/app/Http/Controllers/Users/BulkUsersController.php index 60d5bb3713..36b20973a7 100644 --- a/app/Http/Controllers/Users/BulkUsersController.php +++ b/app/Http/Controllers/Users/BulkUsersController.php @@ -99,6 +99,8 @@ class BulkUsersController extends Controller ->withTrashed() ->findMany($request->input('ids')); + $users->each(fn($user) => $this->authorize('view', $user)); + return view('users.print') ->with('users', $users) ->with('settings', Setting::getSettings()); From 8b3b68b308b55d35894f25abdfa3421ad8f9d64e Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 23 Sep 2024 16:43:14 -0700 Subject: [PATCH 17/19] Show or hide all eulas at once when printing multiple users --- resources/lang/en-US/general.php | 1 + resources/views/users/print.blade.php | 29 +++++++++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/resources/lang/en-US/general.php b/resources/lang/en-US/general.php index 3092228674..b566b1f19d 100644 --- a/resources/lang/en-US/general.php +++ b/resources/lang/en-US/general.php @@ -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', diff --git a/resources/views/users/print.blade.php b/resources/views/users/print.blade.php index ef75dcb6d3..5cf42b8a2b 100644 --- a/resources/views/users/print.blade.php +++ b/resources/views/users/print.blade.php @@ -62,6 +62,16 @@ +{{-- 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) +
+ {{ trans('general.show_or_hide_eulas') }} + +
+@endif + @if ($snipeSettings->logo_print_assets=='1') @if ($snipeSettings->brand == '3') @@ -80,7 +90,7 @@ @endif @endif -@foreach($users as $show_user) +@foreach ($users as $show_user)
{{-- used for page breaks when printing --}}

{{ trans('general.assigned_to', ['name' => $show_user->present()->fullName()]) }} @@ -374,15 +384,18 @@

@endif -

-
- -
+ {{-- This may have been render at the top of the page if we're rendering more than one user... --}} + @if (count($users) === 1) +

+
+ +
+ @endif - +
EULA @php From a12c9d053ff6fc399e30287c246f24b392e0209a Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 23 Sep 2024 16:44:25 -0700 Subject: [PATCH 18/19] Hide label when printing --- resources/views/users/print.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/users/print.blade.php b/resources/views/users/print.blade.php index 5cf42b8a2b..a1fa3373ff 100644 --- a/resources/views/users/print.blade.php +++ b/resources/views/users/print.blade.php @@ -64,9 +64,9 @@ {{-- 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) -
+
{{ trans('general.show_or_hide_eulas') }} -
From fac4833b58a8d5102fa97b365d753fb91447d848 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 23 Sep 2024 17:15:16 -0700 Subject: [PATCH 19/19] Remove unused import --- routes/web/users.php | 1 - 1 file changed, 1 deletion(-) diff --git a/routes/web/users.php b/routes/web/users.php index 6ee2eda9f2..e6aaf644ae 100644 --- a/routes/web/users.php +++ b/routes/web/users.php @@ -2,7 +2,6 @@ use App\Http\Controllers\Users; use App\Http\Controllers\Users\UserFilesController; -use App\Http\Middleware\AssetCountForSidebar; use Illuminate\Support\Facades\Route; // User Management