A free open source IT asset/license management system
Added more info to checkin pages
snipe781889d9056c
diff --git a/app/Http/Controllers/Accessories/AccessoryCheckinController.php b/app/Http/Controllers/Accessories/AccessoryCheckinController.phpindex f43e211c86..df8c899bc5 100644--- a/app/Http/Controllers/Accessories/AccessoryCheckinController.php+++ b/app/Http/Controllers/Accessories/AccessoryCheckinController.php@@ -39,7 +39,8 @@ class AccessoryCheckinController extends Controllerreturn view('accessories/checkin', compact('accessory', 'target_option'))->with('target', $accessory_checkout->assignedTo)- ->with('backto', $backto);+ ->with('backto', $backto)+ ->with('checkoutLog', $accessory_checkout);}diff --git a/app/Http/Controllers/Assets/AssetCheckinController.php b/app/Http/Controllers/Assets/AssetCheckinController.phpindex 9f0402bd0f..f0ed400007 100644--- a/app/Http/Controllers/Assets/AssetCheckinController.php+++ b/app/Http/Controllers/Assets/AssetCheckinController.php@@ -70,12 +70,15 @@ class AssetCheckinController extends Controller$showRequestableToggle = is_numeric($selectedStatusId)&& in_array((int) $selectedStatusId, $deployableStatusIds, true);+ $checkoutLog = $asset->checkouts()->first();+return view('hardware/checkin', compact('asset', 'target_option'))->with('item', $asset)->with('statusLabel_list', Helper::statusLabelList())->with('deployable_status_ids', $deployableStatusIds)->with('show_requestable_toggle', $showRequestableToggle)->with('backto', $backto)+ ->with('checkoutLog', $checkoutLog)->with('table_name', 'Assets');}diff --git a/app/Http/Controllers/Components/ComponentCheckinController.php b/app/Http/Controllers/Components/ComponentCheckinController.phpindex 4980b4e997..bc6f400149 100644--- a/app/Http/Controllers/Components/ComponentCheckinController.php+++ b/app/Http/Controllers/Components/ComponentCheckinController.php@@ -7,6 +7,8 @@ use App\Helpers\Helper;use App\Http\Controllers\Controller;use App\Models\Asset;use App\Models\Component;+use App\Models\ComponentAssignment;+use App\Models\User;use Illuminate\Auth\Access\AuthorizationException;use Illuminate\Contracts\View\View;use Illuminate\Http\RedirectResponse;@@ -32,8 +34,7 @@ class ComponentCheckinController extends Controllerpublic function create($component_asset_id){- // This could probably be done more cleanly but I am very tired. - @snipe- if ($component_assets = DB::table('components_assets')->find($component_asset_id)) {+ if ($component_assets = ComponentAssignment::find($component_asset_id)) {if (is_null($component = Component::find($component_assets->component_id))) {return redirect()->route('components.index')->with('error', trans('admin/components/messages.not_found'));}@@ -43,8 +44,14 @@ class ComponentCheckinController extends Controller}$this->authorize('checkin', $component);+ $checkoutBy = $component_assets->created_by+ ? User::withTrashed()->find($component_assets->created_by)+ : null;+return view('components/checkin', compact('component_assets', 'component', 'asset'))- ->with('snipe_component', $component);+ ->with('snipe_component', $component)+ ->with('checkoutDate', $component_assets->created_at)+ ->with('checkoutBy', $checkoutBy);}return redirect()->route('components.index')->with('error', trans('admin/components/messages.not_found'));diff --git a/app/Http/Controllers/Licenses/LicenseCheckinController.php b/app/Http/Controllers/Licenses/LicenseCheckinController.phpindex 6960caadbf..79b0848caf 100644--- a/app/Http/Controllers/Licenses/LicenseCheckinController.php+++ b/app/Http/Controllers/Licenses/LicenseCheckinController.php@@ -38,7 +38,11 @@ class LicenseCheckinController extends Controller$license = License::find($licenseSeat->license_id);$this->authorize('checkin', $license);- return view('licenses/checkin', compact('licenseSeat'))->with('backto', $backTo);+ $checkoutLog = $licenseSeat->checkouts()->first();++ return view('licenses/checkin', compact('licenseSeat'))+ ->with('backto', $backTo)+ ->with('checkoutLog', $checkoutLog);}/**diff --git a/phpstan-baseline.neon b/phpstan-baseline.neonindex 52f1ba6aff..0b53234240 100644--- a/phpstan-baseline.neon+++ b/phpstan-baseline.neon@@ -972,12 +972,6 @@ parameters:count: 1path: app/Http/Controllers/Api/AccessoriesController.php- -- message: '#^Call to an undefined method App\\Models\\SnipeModel\:\:companies\(\)\.$#'- identifier: method.notFound- count: 1- path: app/Http/Controllers/Api/AccessoriesController.php--message: '#^Call to an undefined method App\\Models\\SnipeModel\:\:getErrors\(\)\.$#'identifier: method.notFound@@ -1896,12 +1890,6 @@ parameters:count: 1path: app/Http/Controllers/Api/UsersController.php- -- message: '#^Method App\\Http\\Transformers\\ConsumablesTransformer\:\:transformConsumables\(\) invoked with 3 parameters, 2 required\.$#'- identifier: arguments.count- count: 1- path: app/Http/Controllers/Api/UsersController.php--message: '#^PHPDoc tag @param for parameter \$request with type Illuminate\\Http\\Request is not subtype of native type App\\Http\\Requests\\SaveUserRequest\.$#'identifier: parameter.phpDocType@@ -2454,10 +2442,16 @@ parameters:count: 2path: app/Http/Controllers/CompaniesController.php+ -+ message: '#^Access to an undefined property App\\Models\\ComponentAssignment\|Illuminate\\Database\\Eloquent\\Collection\<int, App\\Models\\ComponentAssignment\>\:\:\$created_by\.$#'+ identifier: property.notFound+ count: 1+ path: app/Http/Controllers/Components/ComponentCheckinController.php+-message: '#^Cannot access property \$asset_id on array\<mixed\>\|object\.$#'identifier: property.nonObject- count: 2+ count: 1path: app/Http/Controllers/Components/ComponentCheckinController.php-@@ -2469,7 +2463,7 @@ parameters:-message: '#^Cannot access property \$component_id on array\<mixed\>\|object\.$#'identifier: property.nonObject- count: 2+ count: 1path: app/Http/Controllers/Components/ComponentCheckinController.php-@@ -4014,6 +4008,24 @@ parameters:count: 1path: app/Http/Transformers/UploadedFilesTransformer.php+ -+ message: '#^Access to an undefined property App\\Models\\Accessory\:\:\$pivot\.$#'+ identifier: property.notFound+ count: 1+ path: app/Http/Transformers/UsersTransformer.php++ -+ message: '#^Access to an undefined property App\\Models\\Consumable\:\:\$pivot\.$#'+ identifier: property.notFound+ count: 1+ path: app/Http/Transformers/UsersTransformer.php++ -+ message: '#^Access to an undefined property App\\Models\\License\:\:\$pivot\.$#'+ identifier: property.notFound+ count: 1+ path: app/Http/Transformers/UsersTransformer.php+-message: '#^Access to an undefined property App\\Models\\User\:\:\$manages_locations_count\.$#'identifier: property.notFound@@ -4038,6 +4050,18 @@ parameters:count: 3path: app/Http/Transformers/UsersTransformer.php+ -+ message: '#^Access to an undefined property Illuminate\\Database\\Eloquent\\Relations\\Pivot\:\:\$created_at\.$#'+ identifier: property.notFound+ count: 2+ path: app/Http/Transformers/UsersTransformer.php++ -+ message: '#^Access to an undefined property Illuminate\\Database\\Eloquent\\Relations\\Pivot\:\:\$note\.$#'+ identifier: property.notFound+ count: 2+ path: app/Http/Transformers/UsersTransformer.php+-message: '#^Expression on left side of \?\? is not nullable\.$#'identifier: nullCoalesce.expr@@ -6858,12 +6882,6 @@ parameters:count: 1path: app/Models/Consumable.php- -- message: '#^PHPDoc tag @param references unknown parameter\: \$acceptedBy$#'- identifier: parameter.notFound- count: 1- path: app/Models/Consumable.php--message: '#^PHPDoc type array of property App\\Models\\Consumable\:\:\$fillable is not covariant with PHPDoc type list\<string\> of overridden property Illuminate\\Database\\Eloquent\\Model\:\:\$fillable\.$#'identifier: property.phpDocType@@ -7578,12 +7596,6 @@ parameters:count: 1path: app/Models/LicenseSeat.php- -- message: '#^PHPDoc tag @param references unknown parameter\: \$acceptedBy$#'- identifier: parameter.notFound- count: 1- path: app/Models/LicenseSeat.php--message: '#^PHPDoc type array of property App\\Models\\LicenseSeat\:\:\$fillable is not covariant with PHPDoc type list\<string\> of overridden property Illuminate\\Database\\Eloquent\\Model\:\:\$fillable\.$#'identifier: property.phpDocType@@ -8238,12 +8250,6 @@ parameters:count: 2path: app/Models/User.php- -- message: '#^Access to an undefined property Illuminate\\Database\\Eloquent\\Model\:\:\$cost\.$#'- identifier: property.notFound- count: 1- path: app/Models/User.php--message: '#^Access to an undefined property Illuminate\\Database\\Eloquent\\Model\:\:\$id\.$#'identifier: property.notFound@@ -10379,33 +10385,3 @@ parameters:identifier: arguments.countcount: 1path: routes/web.php-- -- message: '#^Access to an undefined property App\\Models\\Consumable\:\:\$pivot\.$#'- identifier: property.notFound- count: 1- path: app/Http/Transformers/UsersTransformer.php-- -- message: '#^Access to an undefined property App\\Models\\Accessory\:\:\$pivot\.$#'- identifier: property.notFound- count: 1- path: app/Http/Transformers/UsersTransformer.php-- -- message: '#^Access to an undefined property App\\Models\\License\:\:\$pivot\.$#'- identifier: property.notFound- count: 1- path: app/Http/Transformers/UsersTransformer.php-- -- message: '#^Access to an undefined property Illuminate\\Database\\Eloquent\\Relations\\Pivot\:\:\$created_at\.$#'- identifier: property.notFound- count: 2- path: app/Http/Transformers/UsersTransformer.php-- -- message: '#^Access to an undefined property Illuminate\\Database\\Eloquent\\Relations\\Pivot\:\:\$note\.$#'- identifier: property.notFound- count: 2- path: app/Http/Transformers/UsersTransformer.phpdiff --git a/resources/views/accessories/checkin.blade.php b/resources/views/accessories/checkin.blade.phpindex d26c7f3afc..12fdc0232b 100755--- a/resources/views/accessories/checkin.blade.php+++ b/resources/views/accessories/checkin.blade.php@@ -23,7 +23,18 @@<x-form.static :label="trans('admin/hardware/form.name')">{{ $accessory->name }}</x-form.static>@endif- <x-checkin.checked-out-from :target="$target ?? null" />+ @if ($accessory->category)+ <x-form.static :label="trans('general.category')">+ <x-icon type="category" class="fa-fw" style="{{ $accessory->category->tag_color ? 'color: '.e($accessory->category->tag_color).';' : '' }}" />+ {{ $accessory->category->name }}+ </x-form.static>+ @endif++ <x-checkin.checked-out-from+ :target="$target ?? null"+ :checkout-date="$checkoutLog?->created_at"+ :checkout-by="$checkoutLog?->adminuser"+ /><x-form.row:label="trans('admin/hardware/form.notes')"diff --git a/resources/views/blade/checkin/checked-out-from.blade.php b/resources/views/blade/checkin/checked-out-from.blade.phpindex bf96dc5af9..64cb0c6150 100644--- a/resources/views/blade/checkin/checked-out-from.blade.php+++ b/resources/views/blade/checkin/checked-out-from.blade.php@@ -1,25 +1,42 @@@props(['target' => null,+ 'checkoutDate' => null,+ 'checkoutBy' => null,])-@if ($target)- @php- $iconType = match (class_basename($target)) {- 'User' => 'user',- 'Asset' => 'asset',- 'Location' => 'location',- default => null,- };- $tagColor = $target->tag_color ?? null;- $link = method_exists($target->present(), 'formattedNameLink')- ? $target->present()->formattedNameLink()- : e($target->present()->fullName() ?? $target->name ?? '');- @endphp+@if ($target || $checkoutDate || $checkoutBy)+ @if ($target)+ @php+ $iconType = match (class_basename($target)) {+ 'User' => 'user',+ 'Asset' => 'asset',+ 'Location' => 'location',+ default => null,+ };+ $tagColor = $target->tag_color ?? null;+ $link = method_exists($target->present(), 'formattedNameLink')+ ? $target->present()->formattedNameLink()+ : e($target->present()->fullName() ?? $target->name ?? '');+ @endphp- <x-form.static :label="trans('general.checked_out_to')">- @if ($iconType)- <x-icon :type="$iconType" class="fa-fw" style="{{ $tagColor ? 'color: '.e($tagColor).';' : '' }}" />- @endif- {!! $link !!}- </x-form.static>+ <x-form.static :label="trans('general.checked_out_to')">+ @if ($iconType)+ <x-icon :type="$iconType" class="fa-fw" style="{{ $tagColor ? 'color: '.e($tagColor).';' : '' }}" />+ @endif+ {!! $link !!}+ </x-form.static>+ @endif++ @if ($checkoutDate || $checkoutBy)+ <x-form.static :label="trans('general.checked_out')">+ @if ($checkoutDate)+ {{ \App\Helpers\Helper::getFormattedDateObject($checkoutDate, 'datetime', false) }}+ @endif+ @if ($checkoutBy)+ {{ strtolower(trans('general.by')) }}+ <x-icon type="user" class="fa-fw" />+ {!! $checkoutBy->present()->formattedNameLink() !!}+ @endif+ </x-form.static>+ @endif@endifdiff --git a/resources/views/components/checkin.blade.php b/resources/views/components/checkin.blade.phpindex 52d96bb367..f0ff7184bf 100644--- a/resources/views/components/checkin.blade.php+++ b/resources/views/components/checkin.blade.php@@ -19,7 +19,18 @@<x-box header="{{ $snipe_component->name }}">- <x-checkin.checked-out-from :target="$asset" />+ @if ($snipe_component->category)+ <x-form.static :label="trans('general.category')">+ <x-icon type="category" class="fa-fw" style="{{ $snipe_component->category->tag_color ? 'color: '.e($snipe_component->category->tag_color).';' : '' }}" />+ {{ $snipe_component->category->name }}+ </x-form.static>+ @endif++ <x-checkin.checked-out-from+ :target="$asset"+ :checkout-date="$checkoutDate"+ :checkout-by="$checkoutBy"+ /><x-input.quantityname="checkin_qty"diff --git a/resources/views/hardware/checkin.blade.php b/resources/views/hardware/checkin.blade.phpindex 913afb08af..46a8e525ef 100755--- a/resources/views/hardware/checkin.blade.php+++ b/resources/views/hardware/checkin.blade.php@@ -37,35 +37,27 @@@endif@if ($asset->model->category)- {{-- Category (read-only) --}}- <x-form.row :label="trans('general.category')" name="category_display" input_div_class="col-md-6">- <x-slot:input>- <p class="form-control-static">{!! $asset->model->category->present()->formattedNameLink !!}</p>- </x-slot:input>- </x-form.row>+ <x-form.static :label="trans('general.category')">+ <x-icon type="category" class="fa-fw" style="{{ $asset->model->category->tag_color ? 'color: '.e($asset->model->category->tag_color).';' : '' }}" />+ {{ $asset->model->category->name }}+ </x-form.static>@endif- {{-- Model (read-only with fallback UI when the model- reference is broken — asset points at a deleted or- invalid model). --}}- <x-form.row :label="trans('admin/hardware/form.model')" name="model_display" input_div_class="col-md-8">- <x-slot:input>- <p class="form-control-static">- @if ($asset->model)- {!! $asset->model->present()->formattedNameLink !!}- @else- <span class="text-danger text-bold">- <x-icon type="warning" />- {{ trans('admin/hardware/general.model_invalid') }}- </span>- {{ trans('admin/hardware/general.model_invalid_fix') }}- <a href="{{ route('hardware.edit', $asset->id) }}">- <strong>{{ trans('admin/hardware/general.edit') }}</strong>- </a>- @endif- </p>- </x-slot:input>- </x-form.row>+ <x-form.static :label="trans('admin/hardware/form.model')">+ @if ($asset->model)+ <x-icon type="model" class="fa-fw" />+ {{ $asset->model->name }}+ @else+ <span class="text-danger text-bold">+ <x-icon type="warning" />+ {{ trans('admin/hardware/general.model_invalid') }}+ </span>+ {{ trans('admin/hardware/general.model_invalid_fix') }}+ <a href="{{ route('hardware.edit', $asset->id) }}">+ <strong>{{ trans('admin/hardware/general.edit') }}</strong>+ </a>+ @endif+ </x-form.static>@if ($asset->defaultLoc){{-- Default Location (read-only) --}}@@ -76,7 +68,11 @@</x-form.row>@endif- <x-checkin.checked-out-from :target="$asset->assignedTo" />+ <x-checkin.checked-out-from+ :target="$asset->assignedTo"+ :checkout-date="$checkoutLog?->created_at"+ :checkout-by="$checkoutLog?->adminuser"+ />{{-- Asset name --}}<x-form.rowdiff --git a/resources/views/licenses/checkin.blade.php b/resources/views/licenses/checkin.blade.phpindex 4aa2975a94..af3e63055a 100755--- a/resources/views/licenses/checkin.blade.php+++ b/resources/views/licenses/checkin.blade.php@@ -25,11 +25,16 @@@if ($licenseSeat->license->category)<x-form.static :label="trans('general.category')">- {!! $licenseSeat->license->category->present()->formattedNameLink !!}+ <x-icon type="category" class="fa-fw" style="{{ $licenseSeat->license->category->tag_color ? 'color: '.e($licenseSeat->license->category->tag_color).';' : '' }}" />+ {{ $licenseSeat->license->category->name }}</x-form.static>@endif- <x-checkin.checked-out-from :target="$licenseSeat->user ?? $licenseSeat->asset" />+ <x-checkin.checked-out-from+ :target="$licenseSeat->user ?? $licenseSeat->asset"+ :checkout-date="$checkoutLog?->created_at"+ :checkout-by="$checkoutLog?->adminuser"+ />@if ($licenseSeat->license->serial)@can('viewKeys', $licenseSeat->license)