From 6f4cee6334b7ed0d2db03a16b38162a9f6c6d510 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Wed, 4 Jun 2025 11:38:50 -0700 Subject: [PATCH] adds Eula tab and count to user account --- app/Http/Controllers/ViewAssetsController.php | 1 + app/Models/User.php | 17 +++++ resources/lang/en-US/general.php | 1 + resources/views/account/view-assets.blade.php | 62 +++++++++++++++++++ 4 files changed, 81 insertions(+) diff --git a/app/Http/Controllers/ViewAssetsController.php b/app/Http/Controllers/ViewAssetsController.php index bbff6ba4f7..6c35ca2e05 100755 --- a/app/Http/Controllers/ViewAssetsController.php +++ b/app/Http/Controllers/ViewAssetsController.php @@ -39,6 +39,7 @@ class ViewAssetsController extends Controller 'consumables', 'accessories', 'licenses', + 'eulas', )->find(auth()->id()); $field_array = array(); diff --git a/app/Models/User.php b/app/Models/User.php index 9b211e6a04..5c6fc14ff0 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -551,6 +551,23 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo ->orderBy('created_at', 'desc'); } + /** + * Establishes the user -> eula relationship + * + * @author A. Gianotto + * @since [v7.0.7] + * @return \Illuminate\Database\Eloquent\Relations\Relation + */ + public function eulas() + { + return $this->hasMany(Actionlog::class, 'target_id') + ->where('target_type', self::class) + ->where('action_type', 'accepted') + ->whereNotNull('filename') + ->whereNotNull('accept_signature') + ->orderBy('created_at', 'desc'); + } + /** * Establishes the user -> requested assets relationship * diff --git a/resources/lang/en-US/general.php b/resources/lang/en-US/general.php index 657d31d407..54fe8a7f31 100644 --- a/resources/lang/en-US/general.php +++ b/resources/lang/en-US/general.php @@ -287,6 +287,7 @@ return [ 'status_label' => 'Status Label', 'status' => 'Status', 'accept_eula' => 'Acceptance Agreement', + 'eula' => 'EULAs', 'show_or_hide_eulas' => 'Show/Hide EULAs', 'supplier' => 'Supplier', 'suppliers' => 'Suppliers', diff --git a/resources/views/account/view-assets.blade.php b/resources/views/account/view-assets.blade.php index 050f53263e..830b05c08c 100755 --- a/resources/views/account/view-assets.blade.php +++ b/resources/views/account/view-assets.blade.php @@ -87,6 +87,17 @@ +
  • + + + + +
  • +
    @@ -703,7 +714,58 @@
    +
    + + + + + + + @can('self.view_purchase_cost') + + @endcan + + + + + + @foreach ($user->consumables as $consumable) + + + @can('self.view_purchase_cost') + + @endcan + + + + @endforeach + +
    + {{ trans('general.consumables') }} +
    {{ trans('general.name') }}{{ trans('general.purchase_cost') }}{{ trans('general.date') }}{{ trans('general.notes') }}
    {{ $consumable->name }} + {!! Helper::formatCurrencyOutput($consumable->purchase_cost) !!} + {{ Helper::getFormattedDateObject($consumable->pivot->created_at, 'datetime', false) }}{{ $consumable->pivot->note }}
    +