A free open source IT asset/license management system
adds component costs to asset view
Godfrey Mbd212b31088c
diff --git a/app/Models/Asset.php b/app/Models/Asset.phpindex a5211e8001..8c92f8c78e 100644--- a/app/Models/Asset.php+++ b/app/Models/Asset.php@@ -909,7 +909,13 @@ class Asset extends Depreciablereturn false;}-+ public function getComponentCost(){+ $cost = 0;+ foreach($this->components as $component) {+ $cost += $component->pivot->assigned_qty*$component->purchase_cost;+ }+ return $cost;+ }/*** -----------------------------------------------diff --git a/resources/lang/en/admin/hardware/table.php b/resources/lang/en/admin/hardware/table.phpindex 6166ba8045..10629fd22c 100644--- a/resources/lang/en/admin/hardware/table.php+++ b/resources/lang/en/admin/hardware/table.php@@ -8,6 +8,7 @@ return ['change' => 'In/Out','checkout_date' => 'Checkout Date','checkoutto' => 'Checked Out',+ 'components_cost' => 'Total Components Cost','current_value' => 'Current Value','diff' => 'Diff','dl_csv' => 'Download CSV',diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.phpindex ccd3f86536..ce3a040c82 100755--- a/resources/views/hardware/view.blade.php+++ b/resources/views/hardware/view.blade.php@@ -530,6 +530,25 @@</div></div>@endif+ @if(($asset->components->count() > 0) && ($asset->purchase_cost))+ <div class="row">+ <div class="col-md-2">+ <strong>+ {{ trans('admin/hardware/table.components_cost') }}+ </strong>+ </div>+ <div class="col-md-6">+ @if (($asset->id) && ($asset->location))+ {{ $asset->location->currency }}+ @elseif (($asset->id) && ($asset->location))+ {{ $asset->location->currency }}+ @else+ {{ $snipeSettings->default_currency }}+ @endif+ {{Helper::formatCurrencyOutput($asset->getComponentCost())}}+ </div>+ </div>+ @endif@if (($asset->model) && ($asset->depreciation) && ($asset->purchase_date))<div class="row"><div class="col-md-2">