adds optional breakdowns for total cost

This commit is contained in:
Godfrey M 2023-04-19 17:51:37 -07:00
parent 6872f8da7b
commit 97df39001d
2 changed files with 11 additions and 7 deletions

View file

@ -767,23 +767,25 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
return $this->locale;
}
public function getUserTotalCost(){
$total_cost= array();
$asset_cost= 0;
$license_cost= 0;
$accessory_cost= 0;
foreach ($this->assets as $asset){
$asset_cost += $asset->purchase_cost;
array_push($total_cost, $asset_cost);
$this->asset_cost = $asset_cost;
}
foreach ($this->licenses as $license){
$license_cost += $license->purchase_cost;
array_push($total_cost, $license_cost);
$this->license_cost = $license_cost;
}
foreach ($this->accessories as $accessory){
$accessory_cost += $accessory->purchase_cost;
array_push($total_cost, $accessory_cost);
$this->accessory_cost = $accessory_cost;
}
return $total_cost;
$this->total_user_cost = ($asset_cost + $accessory_cost + $license_cost);
return $this;
}
}

View file

@ -644,7 +644,7 @@
{{ trans('admin/users/table.total_assets_cost') }}
</div>
<div class="col-md-9">
{{Helper::formatCurrencyOutput(array_sum(array ($user->getUserTotalCost())))}}
{{Helper::formatCurrencyOutput($user->getUserTotalCost()->total_user_cost)}}
<a id="optional_info" class="text-primary">
<i class="fa fa-caret-right fa-2x" id="optional_info_icon"></i>
<strong>{{ trans('admin/hardware/form.optional_infos') }}</strong>
@ -653,7 +653,9 @@
<div id="optional_details" class="col-md-12" style="display:none">
<br>
<div class="col-md-9">
Asset: {{$user->getUserTotalCost()->asset_cost}}
License: {{$user->getUserTotalCost()->license_cost}}
Accessory: {{$user->getUserTotalCost()->accessory_cost}}
</div>
</div>