diff --git a/app/Models/User.php b/app/Models/User.php index f54d99188e..70c9fc44ae 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -750,4 +750,26 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo { return $this->locale; } + public function getUserTotalCost(){ + $asset_cost= 0; + $license_cost= 0; + $accessory_cost= 0; + foreach ($this->assets as $asset){ + $asset_cost += $asset->purchase_cost; + $this->asset_cost = $asset_cost; + } + foreach ($this->licenses as $license){ + $license_cost += $license->purchase_cost; + $this->license_cost = $license_cost; + } + foreach ($this->accessories as $accessory){ + $accessory_cost += $accessory->purchase_cost; + $this->accessory_cost = $accessory_cost; + } + + $this->total_user_cost = ($asset_cost + $accessory_cost + $license_cost); + + + return $this; + } } diff --git a/resources/lang/en/admin/users/table.php b/resources/lang/en/admin/users/table.php index e318d51545..21e2154280 100644 --- a/resources/lang/en/admin/users/table.php +++ b/resources/lang/en/admin/users/table.php @@ -29,6 +29,7 @@ return array( 'show_deleted' => 'Show Deleted Users', 'title' => 'Title', 'to_restore_them' => 'to restore them.', + 'total_assets_cost' => "Total Assets Cost", 'updateuser' => 'Update User', 'username' => 'Username', 'user_deleted_text' => 'This user has been marked as deleted.', diff --git a/resources/views/users/view.blade.php b/resources/views/users/view.blade.php index 83c624f36b..ee0495a70a 100755 --- a/resources/views/users/view.blade.php +++ b/resources/views/users/view.blade.php @@ -638,6 +638,27 @@ @endif +
+ +
+ {{ trans('admin/users/table.total_assets_cost') }} +
+
+ {{Helper::formatCurrencyOutput($user->getUserTotalCost()->total_user_cost)}} + + + {{ trans('admin/hardware/form.optional_infos') }} + +
+ +
@@ -1109,6 +1130,12 @@ $(function () { } }); + $("#optional_info").on("click",function(){ + $('#optional_details').fadeToggle(100); + $('#optional_info_icon').toggleClass('fa-caret-right fa-caret-down'); + var optional_info_open = $('#optional_info_icon').hasClass('fa-caret-down'); + document.cookie = "optional_info_open="+optional_info_open+'; path=/'; + }); });