From 2353c8199cde14768c7f494736082417815217d5 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 22 Nov 2023 15:25:22 +0000 Subject: [PATCH 1/5] Set qty mutators Signed-off-by: snipe --- app/Models/Accessory.php | 29 +++++++++++++++++++++++++++++ app/Models/Component.php | 31 +++++++++++++++++++++++++++++++ app/Models/Consumable.php | 29 +++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+) diff --git a/app/Models/Accessory.php b/app/Models/Accessory.php index 86502dc7e7bf..9a93c386fc55 100755 --- a/app/Models/Accessory.php +++ b/app/Models/Accessory.php @@ -365,6 +365,35 @@ public function declinedCheckout(User $declinedBy, $signature) $accessory_user->limit(1)->delete(); } + /** + * ----------------------------------------------- + * BEGIN MUTATORS + * ----------------------------------------------- + **/ + + /** + * This sets a value for qty if no value is given. The database does not allow this + * field to be null, and in the other areas of the code, we set a default, but the importer + * does not. + * + * This simply checks that there is a value for quantity, and if there isn't, set it to 0. + * + * @author A. Gianotto + * @since v6.3.4 + * @param $value + * @return void + */ + public function setQtyAttribute($value) + { + $this->attributes['qty'] = (!$value) ? 0 : intval($value); + } + + /** + * ----------------------------------------------- + * BEGIN QUERY SCOPES + * ----------------------------------------------- + **/ + /** * Query builder scope to order on company * diff --git a/app/Models/Component.php b/app/Models/Component.php index 052ec1219d15..671b0101c47c 100644 --- a/app/Models/Component.php +++ b/app/Models/Component.php @@ -224,6 +224,37 @@ public function numRemaining() return $this->qty - $this->numCheckedOut(); } + + /** + * ----------------------------------------------- + * BEGIN MUTATORS + * ----------------------------------------------- + **/ + + /** + * This sets a value for qty if no value is given. The database does not allow this + * field to be null, and in the other areas of the code, we set a default, but the importer + * does not. + * + * This simply checks that there is a value for quantity, and if there isn't, set it to 0. + * + * @author A. Gianotto + * @since v6.3.4 + * @param $value + * @return void + */ + public function setQtyAttribute($value) + { + $this->attributes['qty'] = (!$value) ? 0 : intval($value); + } + + /** + * ----------------------------------------------- + * BEGIN QUERY SCOPES + * ----------------------------------------------- + **/ + + /** * Query builder scope to order on company * diff --git a/app/Models/Consumable.php b/app/Models/Consumable.php index a3a0d5917822..008dffa4cafc 100644 --- a/app/Models/Consumable.php +++ b/app/Models/Consumable.php @@ -339,6 +339,35 @@ public function numRemaining() return $remaining; } + /** + * ----------------------------------------------- + * BEGIN MUTATORS + * ----------------------------------------------- + **/ + + /** + * This sets a value for qty if no value is given. The database does not allow this + * field to be null, and in the other areas of the code, we set a default, but the importer + * does not. + * + * This simply checks that there is a value for quantity, and if there isn't, set it to 0. + * + * @author A. Gianotto + * @since v6.3.4 + * @param $value + * @return void + */ + public function setQtyAttribute($value) + { + $this->attributes['qty'] = (!$value) ? 0 : intval($value); + } + + /** + * ----------------------------------------------- + * BEGIN QUERY SCOPES + * ----------------------------------------------- + **/ + /** * Query builder scope to order on company * From 3fe3697a2907608a902567a2f1a4493dc1cde74a Mon Sep 17 00:00:00 2001 From: akemidx Date: Mon, 18 Dec 2023 18:26:47 -0500 Subject: [PATCH 2/5] adding column, needs table join --- app/Http/Controllers/Api/LicenseSeatsController.php | 2 +- app/Presenters/LicensePresenter.php | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Api/LicenseSeatsController.php b/app/Http/Controllers/Api/LicenseSeatsController.php index 5e79c49b23a4..78cf49fd9e4d 100644 --- a/app/Http/Controllers/Api/LicenseSeatsController.php +++ b/app/Http/Controllers/Api/LicenseSeatsController.php @@ -27,7 +27,7 @@ public function index(Request $request, $licenseId) if ($license = License::find($licenseId)) { $this->authorize('view', $license); - $seats = LicenseSeat::with('license', 'user', 'asset', 'user.department') + $seats = LicenseSeat::with('license', 'user', 'email', 'asset', 'user.department') ->where('license_seats.license_id', $licenseId); $order = $request->input('order') === 'asc' ? 'asc' : 'desc'; diff --git a/app/Presenters/LicensePresenter.php b/app/Presenters/LicensePresenter.php index e76c9152cb8f..8c827a18098b 100644 --- a/app/Presenters/LicensePresenter.php +++ b/app/Presenters/LicensePresenter.php @@ -228,6 +228,14 @@ public static function dataTableLayoutSeats() 'title' => trans('admin/licenses/general.user'), 'visible' => true, 'formatter' => 'usersLinkObjFormatter', + ], [ + 'field' => 'email', + 'searchable' => false, + 'sortable' => false, + 'switchable' => true, + 'title' => trans('admin/users/table.email'), + 'visible' => true, + 'formatter' => 'emailFormatter', ], [ 'field' => 'department', 'searchable' => false, @@ -236,8 +244,7 @@ public static function dataTableLayoutSeats() 'title' => trans('general.department'), 'visible' => false, 'formatter' => 'departmentNameLinkFormatter', - ], - [ + ], [ 'field' => 'assigned_asset', 'searchable' => false, 'sortable' => false, From 85bfbf8bc4a9a59c1d25b92d17e8c0b87580d60c Mon Sep 17 00:00:00 2001 From: akemidx Date: Mon, 18 Dec 2023 20:15:06 -0500 Subject: [PATCH 3/5] email in table, shows in export --- app/Http/Controllers/Api/LicenseSeatsController.php | 2 +- app/Http/Transformers/LicenseSeatsTransformer.php | 1 + app/Presenters/LicensePresenter.php | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Api/LicenseSeatsController.php b/app/Http/Controllers/Api/LicenseSeatsController.php index 78cf49fd9e4d..5e79c49b23a4 100644 --- a/app/Http/Controllers/Api/LicenseSeatsController.php +++ b/app/Http/Controllers/Api/LicenseSeatsController.php @@ -27,7 +27,7 @@ public function index(Request $request, $licenseId) if ($license = License::find($licenseId)) { $this->authorize('view', $license); - $seats = LicenseSeat::with('license', 'user', 'email', 'asset', 'user.department') + $seats = LicenseSeat::with('license', 'user', 'asset', 'user.department') ->where('license_seats.license_id', $licenseId); $order = $request->input('order') === 'asc' ? 'asc' : 'desc'; diff --git a/app/Http/Transformers/LicenseSeatsTransformer.php b/app/Http/Transformers/LicenseSeatsTransformer.php index 62614db4d3a2..47133a9b9511 100644 --- a/app/Http/Transformers/LicenseSeatsTransformer.php +++ b/app/Http/Transformers/LicenseSeatsTransformer.php @@ -29,6 +29,7 @@ public function transformLicenseSeat(LicenseSeat $seat, $seat_count = 0) 'assigned_user' => ($seat->user) ? [ 'id' => (int) $seat->user->id, 'name'=> e($seat->user->present()->fullName), + 'email' => e($seat->user->email), 'department'=> ($seat->user->department) ? [ 'id' => (int) $seat->user->department->id, diff --git a/app/Presenters/LicensePresenter.php b/app/Presenters/LicensePresenter.php index 8c827a18098b..4b86a35069cb 100644 --- a/app/Presenters/LicensePresenter.php +++ b/app/Presenters/LicensePresenter.php @@ -229,7 +229,7 @@ public static function dataTableLayoutSeats() 'visible' => true, 'formatter' => 'usersLinkObjFormatter', ], [ - 'field' => 'email', + 'field' => 'assigned_user.email', 'searchable' => false, 'sortable' => false, 'switchable' => true, From c0dba95426ef4f5fb7abad0bcb64d2eda24f3eec Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Tue, 19 Dec 2023 09:32:26 -0800 Subject: [PATCH 4/5] testing ldap test table fix --- resources/views/settings/ldap.blade.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/views/settings/ldap.blade.php b/resources/views/settings/ldap.blade.php index 016d54f48fd2..8c62c0cd8de6 100644 --- a/resources/views/settings/ldap.blade.php +++ b/resources/views/settings/ldap.blade.php @@ -696,7 +696,8 @@ * Build the results html table */ function buildLdapTestResults(results) { - let html = '
    ' + let html = '' + html += '
      ' html += '
    • ' + results.login.message + '
    • ' html += '
    • ' + results.bind.message + '
    • ' html += '
    ' @@ -704,7 +705,7 @@ function buildLdapTestResults(results) { html += '
    ' html += buildLdapResultsTableHeader() html += buildLdapResultsTableBody(results.user_sync.users) - html += '
    ' + html += '
    ' return html; } From 4b071745fa7b95a615250cbb3d62409647c27ba4 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Tue, 19 Dec 2023 09:49:40 -0800 Subject: [PATCH 5/5] prevents tables and table data from overflowing --- resources/views/settings/ldap.blade.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/resources/views/settings/ldap.blade.php b/resources/views/settings/ldap.blade.php index 8c62c0cd8de6..87b0bb69d5db 100644 --- a/resources/views/settings/ldap.blade.php +++ b/resources/views/settings/ldap.blade.php @@ -696,16 +696,15 @@ * Build the results html table */ function buildLdapTestResults(results) { - let html = '' - html += '
      ' + let html = '
        ' html += '
      • ' + results.login.message + '
      • ' html += '
      • ' + results.bind.message + '
      • ' html += '
      ' html += '
      {{ trans('admin/settings/message.ldap.sync_success') }}
      ' - html += '
    ' + html += '
    ' html += buildLdapResultsTableHeader() html += buildLdapResultsTableBody(results.user_sync.users) - html += '
    ' + html += '' return html; } @@ -730,7 +729,7 @@ function buildLdapResultsTableBody(users) { let body = '' for (var i in users) { - body += '' + body += '' } body += "" return body;
    ' + users[i].employee_number + '' + users[i].username + '' + users[i].firstname + '' + users[i].lastname + '' + users[i].email + '
    ' + users[i].employee_number + '' + users[i].username + '' + users[i].firstname + '' + users[i].lastname + '' + users[i].email + '