diff --git a/app/Models/Asset.php b/app/Models/Asset.php
index 0bbb06aa131f..14613149a129 100644
--- a/app/Models/Asset.php
+++ b/app/Models/Asset.php
@@ -1147,6 +1147,31 @@ public function scopeDueOrOverdueForAudit($query, $settings)
}
+ /**
+ * Query builder scope for Archived assets counting
+ *
+ * This is primarily used for the tab counters so that IF the admin
+ * has chosen to not display archived assets in their regular lists
+ * and views, it will return the correct number.
+ *
+ * @param \Illuminate\Database\Query\Builder $query Query builder instance
+ *
+ * @return \Illuminate\Database\Query\Builder Modified query builder
+ */
+
+ public function scopeAssetsForShow($query)
+ {
+
+ if (Setting::getSettings()->show_archived_in_list!=1) {
+ return $query->whereHas('assetstatus', function ($query) {
+ $query->where('archived', '=', 0);
+ });
+ } else {
+ return $query;
+ }
+
+ }
+
/**
* Query builder scope for Archived assets
*
diff --git a/resources/views/categories/view.blade.php b/resources/views/categories/view.blade.php
index b32bb8df068d..6e33594b176d 100644
--- a/resources/views/categories/view.blade.php
+++ b/resources/views/categories/view.blade.php
@@ -39,7 +39,7 @@
{{ ucwords($category_type_route) }}
@if ($category->category_type=='asset')
- {{ $category->assets->count() }}
+ {{ $category->assets()->AssetsForShow()->count() }}
@endif
diff --git a/resources/views/companies/view.blade.php b/resources/views/companies/view.blade.php
index 19a27c68bae4..4324f3f78eda 100644
--- a/resources/views/companies/view.blade.php
+++ b/resources/views/companies/view.blade.php
@@ -21,7 +21,7 @@
{{ trans('general.assets') }}
- {!! (($company->assets) && ($company->assets->count() > 0 )) ? ''.number_format($company->assets->count()).'' : '' !!}
+ {!! (($company->assets) && ($company->assets()->AssetsForShow()->count() > 0 )) ? ''.number_format($company->assets()->AssetsForShow()->count()).'' : '' !!}
diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php
index dab2e1dbdc99..f4e8cc714a21 100755
--- a/resources/views/dashboard.blade.php
+++ b/resources/views/dashboard.blade.php
@@ -33,7 +33,7 @@
-
{{ number_format($counts['asset']) }}
+
{{ number_format(\App\Models\Asset::AssetsForShow()->count()) }}
{{ strtolower(trans('general.assets')) }}
diff --git a/resources/views/locations/view.blade.php b/resources/views/locations/view.blade.php
index 566e118c824e..ce4394f8c79f 100644
--- a/resources/views/locations/view.blade.php
+++ b/resources/views/locations/view.blade.php
@@ -38,7 +38,7 @@
{{ trans('general.assets') }}
- {!! (($location->assets) && ($location->assets->count() > 0 )) ? ''.number_format($location->assets->count()).'' : '' !!}
+ {!! (($location->assets) && ($location->assets()->AssetsForShow()->count() > 0 )) ? ''.number_format($location->assets()->AssetsForShow()->count()).'' : '' !!}
diff --git a/resources/views/manufacturers/view.blade.php b/resources/views/manufacturers/view.blade.php
index a6472fbcaec2..3872801a6900 100644
--- a/resources/views/manufacturers/view.blade.php
+++ b/resources/views/manufacturers/view.blade.php
@@ -41,7 +41,7 @@
{{ trans('general.assets') }}
- {!! (($manufacturer->assets) && ($manufacturer->assets->count() > 0 )) ? ''.number_format($manufacturer->assets->count()).'' : '' !!}
+ {!! (($manufacturer->assets) && ($manufacturer->assets()->AssetsForShow()->count() > 0 )) ? ''.number_format($manufacturer->assets()->AssetsForShow()->count()).'' : '' !!}
diff --git a/resources/views/suppliers/view.blade.php b/resources/views/suppliers/view.blade.php
index 4316497f1e63..1cf95cfe44d5 100755
--- a/resources/views/suppliers/view.blade.php
+++ b/resources/views/suppliers/view.blade.php
@@ -35,7 +35,7 @@
{{ trans('general.assets') }}
- {!! (($supplier->assets) && ($supplier->assets->count() > 0 )) ? ''.number_format($supplier->assets->count()).'' : '' !!}
+ {!! (($supplier->assets) && ($supplier->assets()->AssetsForShow()->count() > 0 )) ? ''.number_format($supplier->assets()->AssetsForShow()->count()).'' : '' !!}
diff --git a/resources/views/users/view.blade.php b/resources/views/users/view.blade.php
index e97c063df6ea..41f7b4774865 100755
--- a/resources/views/users/view.blade.php
+++ b/resources/views/users/view.blade.php
@@ -31,7 +31,7 @@
{{ trans('general.assets') }}
- {!! ($user->assets->count() > 0 ) ? ''.number_format($user->assets->count()).'' : '' !!}
+ {!! ($user->assets()->AssetsForShow()->count() > 0 ) ? ''.number_format($user->assets()->AssetsForShow()->count()).'' : '' !!}