Skip to content

A free open source IT asset/license management system

Fixed #18840 - added print inventory button back to locations

snipedb48c187666d
diff --git a/app/Models/Location.php b/app/Models/Location.php
index be7ba14243..ef3a2e6a0a 100755
--- a/app/Models/Location.php
+++ b/app/Models/Location.php
@@ -180,6 +180,11 @@ class Location extends SnipeModel
);
}
+ public function countAllTheThings()
+ {
+ return ($this->assets()->count() + $this->consumables()->count() + $this->components()->count() + $this->users()->count() + $this->assignedAccessories()->count() + $this->assignedAssets()->count() + $this->accessories()->count());
+ }
+
/**
* Establishes the asset -> rtd_location relationship
*
diff --git a/resources/views/blade/button/print.blade.php b/resources/views/blade/button/print.blade.php
new file mode 100644
index 0000000000..c23b3e0abb
--- /dev/null
+++ b/resources/views/blade/button/print.blade.php
@@ -0,0 +1,18 @@
+@props([
+ 'item' => null,
+ 'route' => null,
+ 'wide' => false,
+ 'count' => 0,
+ 'tooltip' => trans('admin/users/general.print_assigned'),
+])
+
+@can('view', $item)
+ @if ($count > 0)
+ <a href="{{ $route }}" class="btn btn-sm btn-primary hidden-print" data-tooltip="true" title="{{ $tooltip }}">
+ <x-icon type="print"/>
+ @if ($wide=='true')
+ {{ trans('general.print') }}
+ @endif
+ </a>
+ @endif
+@endcan
diff --git a/resources/views/locations/view.blade.php b/resources/views/locations/view.blade.php
index c4b01b9454..bbfe3ee601 100644
--- a/resources/views/locations/view.blade.php
+++ b/resources/views/locations/view.blade.php
@@ -221,11 +221,13 @@
<x-slot:buttons>
<x-button.edit :item="$location" :route="route('locations.edit', $location->id)" />
<x-button.clone :item="$location" :route="route('clone/location', $location->id)" />
- <x-button.delete :item="$location" />
<x-button.restore :item="$location" :route="route('locations.restore', ['location' => $location->id])" />
+ <x-button.print :count="$location->countAllTheThings()" :tooltip="trans('admin/locations/table.print_inventory')" :item="$location" :route="route('locations.print_assigned', ['locationId' => $location->id])"/>
+ <x-button.print :count="$location->assignedAssets()->AssetsForShow()->count()" :item="$location" :route="route('locations.print_all_assigned', ['locationId' => $location->id])"/>
+ <x-button.delete :item="$location"/>
</x-slot:buttons>
- @if ($location->ldap_ou)
+ @if ($location->ldap_ou)
<x-info-element icon_type="ldap">
{{ $location->ldap_ou }}
</x-info-element>