A free open source IT asset/license management system
adds Eula tab and count to user account
Godfrey M6f4cee6334b7
diff --git a/app/Http/Controllers/ViewAssetsController.php b/app/Http/Controllers/ViewAssetsController.phpindex 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.phpindex 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 <[email protected]>+ * @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.phpindex 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.phpindex 050f53263e..830b05c08c 100755--- a/resources/views/account/view-assets.blade.php+++ b/resources/views/account/view-assets.blade.php@@ -87,6 +87,17 @@</a></li>+ <li>+ <a href="#eulas" data-toggle="tab">+ <span class="hidden-lg hidden-md" aria-hidden="true">+ <x-icon type="files" class="fa-2x" />+ </span>+ <span class="hidden-xs hidden-sm">{{ trans('general.eula') }}+ {!! ($user->eulas->count() > 0 ) ? '<span class="badge badge-secondary">'.number_format($user->eulas->count()).'</span>' : '' !!}+ </span>+ </a>+ </li>+</ul><div class="tab-content">@@ -703,7 +714,58 @@</tbody></table></div><!-- /consumables-tab -->+ <div class="tab-pane" id="eulas">+ <table+ data-toolbar="#userEULAToolbar"+ data-cookie-id-table="userEULATable"+ data-id-table="userEULATable"+ id="userEULATable"+ data-search="true"+ data-pagination="true"+ data-side-pagination="client"+ data-show-columns="true"+ data-show-fullscreen="true"+ data-show-export="true"+ data-show-footer="true"+ data-show-refresh="false"+ data-sort-order="asc"+ data-sort-name="name"+ class="table table-striped snipe-table table-hover"+ data-export-options='{+ "fileName": "export-eula-{{ str_slug($user->username) }}-{{ date('Y-m-d') }}",+ "ignoreColumn": ["actions","image","change","checkbox","checkincheckout","delete","purchasecost", "icon"]+ }'>+ <caption id="userConsumableToolbar" class="tableCaption">+ {{ trans('general.consumables') }}+ </caption>++ <thead>+ <tr>+ <th class="col-md-3">{{ trans('general.name') }}</th>+ @can('self.view_purchase_cost')+ <th class="col-md-2" data-footer-formatter="sumFormatter" data-fieldname="purchase_cost">{{ trans('general.purchase_cost') }}</th>+ @endcan+ <th class="col-md-2">{{ trans('general.date') }}</th>+ <th class="col-md-5">{{ trans('general.notes') }}</th>+ </tr>+ </thead>+ <tbody>+ @foreach ($user->consumables as $consumable)+ <tr>+ <td>{{ $consumable->name }}</td>+ @can('self.view_purchase_cost')+ <td>+ {!! Helper::formatCurrencyOutput($consumable->purchase_cost) !!}+ </td>+ @endcan+ <td>{{ Helper::getFormattedDateObject($consumable->pivot->created_at, 'datetime', false) }}</td>+ <td>{{ $consumable->pivot->note }}</td>+ </tr>+ @endforeach+ </tbody>+ </table>+ </div><!-- /consumables-tab --></div><!-- /.tab-content --></div><!-- nav-tabs-custom --></div>