Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes check for archived setting on counts #11382

Merged
merged 4 commits into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions app/Models/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
2 changes: 1 addition & 1 deletion resources/views/categories/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<li class="active">
<a href="#items" data-toggle="tab" title="{{ trans('general.items') }}"> {{ ucwords($category_type_route) }}
@if ($category->category_type=='asset')
<badge class="badge badge-secondary"> {{ $category->assets->count() }}</badge>
<badge class="badge badge-secondary"> {{ $category->assets()->AssetsForShow()->count() }}</badge>
@endif
</a>
</li>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/companies/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<i class="fas fa-barcode" aria-hidden="true"></i>
</span>
<span class="hidden-xs hidden-sm">{{ trans('general.assets') }}
{!! (($company->assets) && ($company->assets->count() > 0 )) ? '<badge class="badge badge-secondary">'.number_format($company->assets->count()).'</badge>' : '' !!}
{!! (($company->assets) && ($company->assets()->AssetsForShow()->count() > 0 )) ? '<badge class="badge badge-secondary">'.number_format($company->assets()->AssetsForShow()->count()).'</badge>' : '' !!}

</span>
</a>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<!-- small box -->
<div class="small-box bg-teal">
<div class="inner">
<h3>{{ number_format($counts['asset']) }}</h3>
<h3>{{ number_format(\App\Models\Asset::AssetsForShow()->count()) }}</h3>
<p>{{ strtolower(trans('general.assets')) }}</p>
</div>
<div class="icon" aria-hidden="true">
Expand Down
2 changes: 1 addition & 1 deletion resources/views/locations/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</span>
<span class="hidden-xs hidden-sm">
{{ trans('general.assets') }}
{!! (($location->assets) && ($location->assets->count() > 0 )) ? '<badge class="badge badge-secondary">'.number_format($location->assets->count()).'</badge>' : '' !!}
{!! (($location->assets) && ($location->assets()->AssetsForShow()->count() > 0 )) ? '<badge class="badge badge-secondary">'.number_format($location->assets()->AssetsForShow()->count()).'</badge>' : '' !!}
</span>
</a>
</li>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/manufacturers/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</span>
<span class="hidden-xs hidden-sm">
{{ trans('general.assets') }}
{!! (($manufacturer->assets) && ($manufacturer->assets->count() > 0 )) ? '<badge class="badge badge-secondary">'.number_format($manufacturer->assets->count()).'</badge>' : '' !!}
{!! (($manufacturer->assets) && ($manufacturer->assets()->AssetsForShow()->count() > 0 )) ? '<badge class="badge badge-secondary">'.number_format($manufacturer->assets()->AssetsForShow()->count()).'</badge>' : '' !!}
</span>

</a>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/suppliers/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</span>
<span class="hidden-xs hidden-sm">
{{ trans('general.assets') }}
{!! (($supplier->assets) && ($supplier->assets->count() > 0 )) ? '<badge class="badge badge-secondary">'.number_format($supplier->assets->count()).'</badge>' : '' !!}
{!! (($supplier->assets) && ($supplier->assets()->AssetsForShow()->count() > 0 )) ? '<badge class="badge badge-secondary">'.number_format($supplier->assets()->AssetsForShow()->count()).'</badge>' : '' !!}
</span>

</a>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/users/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<i class="fas fa-barcode fa-2x" aria-hidden="true"></i>
</span>
<span class="hidden-xs hidden-sm">{{ trans('general.assets') }}
{!! ($user->assets->count() > 0 ) ? '<badge class="badge badge-secondary">'.number_format($user->assets->count()).'</badge>' : '' !!}
{!! ($user->assets()->AssetsForShow()->count() > 0 ) ? '<badge class="badge badge-secondary">'.number_format($user->assets()->AssetsForShow()->count()).'</badge>' : '' !!}
</span>
</a>
</li>
Expand Down