From 0617480f7385fdaf56143b1c2e7c761e89529e9d Mon Sep 17 00:00:00 2001 From: Nathan Butler Date: Thu, 30 Jun 2022 09:23:52 +1000 Subject: [PATCH 001/554] Asset checkinbytag now consistent with existingAPI This is a non-breaking change to the checkinbytag endpoint to bring it inline with the usage/formatting of the other bytag endpoints that currently exist - using the URL path to define the asset_tag instead of passing it through as a url query. Both methods will work, but the URL Path method will take precidence if it is used (the query will be ignored if included) --- app/Http/Controllers/Api/AssetsController.php | 11 ++++++---- routes/api.php | 21 ++++++++++++------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index ebb19159dd..fbc56d21ec 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -907,18 +907,21 @@ class AssetsController extends Controller * @since [v6.0] * @return JsonResponse */ - public function checkinByTag(Request $request) + public function checkinByTag(Request $request, $tag = null) { $this->authorize('checkin', Asset::class); - $asset = Asset::where('asset_tag', $request->input('asset_tag'))->first(); + if(null == $tag && null !== ($request->input('asset_tag'))) { + $tag = $request->input('asset_tag'); + } + $asset = Asset::where('asset_tag', $tag)->first(); if($asset) { return $this->checkin($request, $asset->id); } return response()->json(Helper::formatStandardApiResponse('error', [ - 'asset'=> e($request->input('asset_tag')) - ], 'Asset with tag '.e($request->input('asset_tag')).' not found')); + 'asset'=> e($tag) + ], 'Asset with tag '.e($tag).' not found')); } diff --git a/routes/api.php b/routes/api.php index da2e92ee10..af5b797eb0 100644 --- a/routes/api.php +++ b/routes/api.php @@ -469,6 +469,20 @@ Route::group(['prefix' => 'v1', 'middleware' => ['api', 'throttle:api']], functi ] )->name('api.assets.checkout.bytag'); + Route::post('bytag/{any}/checkin', + [ + Api\AssetsController::class, + 'checkinbytag' + ] + )->name('api.asset.checkinbytagPath'); + + Route::post('checkinbytag', + [ + Api\AssetsController::class, + 'checkinbytag' + ] + )->name('api.asset.checkinbytag'); + Route::get('byserial/{any}', [ Api\AssetsController::class, @@ -498,13 +512,6 @@ Route::group(['prefix' => 'v1', 'middleware' => ['api', 'throttle:api']], functi ] )->name('api.asset.checkin'); - Route::post('checkinbytag', - [ - Api\AssetsController::class, - 'checkinbytag' - ] - )->name('api.asset.checkinbytag'); - Route::post('{id}/checkout', [ Api\AssetsController::class, From e457b2e98d9b34d335c6d79d0c606c8a8f50d9b5 Mon Sep 17 00:00:00 2001 From: Phan Nguyen Date: Mon, 17 Oct 2022 13:10:09 +0700 Subject: [PATCH 002/554] Correct assignedusers relation setting --- app/Models/License.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/License.php b/app/Models/License.php index d0e6f5c969..d74d69546a 100755 --- a/app/Models/License.php +++ b/app/Models/License.php @@ -357,7 +357,7 @@ class License extends Depreciable */ public function assignedusers() { - return $this->belongsToMany(\App\Models\User::class, 'license_seats', 'assigned_to', 'license_id'); + return $this->belongsToMany(\App\Models\User::class, 'license_seats', 'license_id', 'assigned_to'); } /** From 45636b81148c5bf1d3d62991ea6747d4ab6145e7 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Tue, 15 Nov 2022 15:42:57 -0800 Subject: [PATCH 003/554] adds should_autoassign boolean to users table --- .../Commands/CheckoutLicenseToAllUsers.php | 2 +- .../Controllers/Users/UsersController.php | 2 ++ ..._should_autoassign_bool_to_users_table.php | 32 +++++++++++++++++++ resources/lang/en/admin/users/general.php | 2 ++ resources/views/users/edit.blade.php | 13 ++++++++ 5 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2022_11_15_232525_adds_should_autoassign_bool_to_users_table.php diff --git a/app/Console/Commands/CheckoutLicenseToAllUsers.php b/app/Console/Commands/CheckoutLicenseToAllUsers.php index fab2b318c6..e29b8991b6 100644 --- a/app/Console/Commands/CheckoutLicenseToAllUsers.php +++ b/app/Console/Commands/CheckoutLicenseToAllUsers.php @@ -56,7 +56,7 @@ class CheckoutLicenseToAllUsers extends Command return false; } - $users = User::whereNull('deleted_at')->with('licenses')->get(); + $users = User::whereNull('deleted_at')->where('should_autoassign', '==', 1)->with('licenses')->get(); if ($users->count() > $license->getAvailSeatsCountAttribute()) { $this->info('You do not have enough free seats to complete this task, so we will check out as many as we can. '); diff --git a/app/Http/Controllers/Users/UsersController.php b/app/Http/Controllers/Users/UsersController.php index 52d423036f..b863fb966b 100755 --- a/app/Http/Controllers/Users/UsersController.php +++ b/app/Http/Controllers/Users/UsersController.php @@ -121,6 +121,7 @@ class UsersController extends Controller $user->created_by = Auth::user()->id; $user->start_date = $request->input('start_date', null); $user->end_date = $request->input('end_date', null); + $user->should_autoassign= $request->input('should_autoassign', 0); // Strip out the superuser permission if the user isn't a superadmin $permissions_array = $request->input('permission'); @@ -274,6 +275,7 @@ class UsersController extends Controller $user->website = $request->input('website', null); $user->start_date = $request->input('start_date', null); $user->end_date = $request->input('end_date', null); + $user->should_autoassign = $request->input('should_autoassign', 0); // Update the location of any assets checked out to this user Asset::where('assigned_type', User::class) diff --git a/database/migrations/2022_11_15_232525_adds_should_autoassign_bool_to_users_table.php b/database/migrations/2022_11_15_232525_adds_should_autoassign_bool_to_users_table.php new file mode 100644 index 0000000000..6f6f308e44 --- /dev/null +++ b/database/migrations/2022_11_15_232525_adds_should_autoassign_bool_to_users_table.php @@ -0,0 +1,32 @@ +boolean('should_autoassign')->nullable(false)->default(0); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('should_autoassign'); + }); + } +} diff --git a/resources/lang/en/admin/users/general.php b/resources/lang/en/admin/users/general.php index daa568e8bf..2ae8709251 100644 --- a/resources/lang/en/admin/users/general.php +++ b/resources/lang/en/admin/users/general.php @@ -19,6 +19,8 @@ return [ 'print_assigned' => 'Print All Assigned', 'email_assigned' => 'Email List of All Assigned', 'user_notified' => 'User has been emailed a list of their currently assigned items.', + 'auto_assign_label' => 'User should skipped during auto assignment commands', + 'auto_assign_help' => 'Skip this user in auto assignment of licenses', 'software_user' => 'Software Checked out to :name', 'send_email_help' => 'You must provide an email address for this user to send them credentials. Emailing credentials can only be done on user creation. Passwords are stored in a one-way hash and cannot be retrieved once saved.', 'view_user' => 'View User :name', diff --git a/resources/views/users/edit.blade.php b/resources/views/users/edit.blade.php index 7947d65a68..a689ab8983 100755 --- a/resources/views/users/edit.blade.php +++ b/resources/views/users/edit.blade.php @@ -376,6 +376,19 @@ + +
+
+ +

{{ trans('admin/users/general.auto_assign_help') }} +

+
+
+ @include ('partials.forms.edit.location-select', ['translated_name' => trans('general.location'), 'fieldname' => 'location_id']) From 90828e3a873f548d7bbb16f065c484204303178c Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Tue, 15 Nov 2022 15:51:52 -0800 Subject: [PATCH 004/554] fixes variable name --- app/Console/Commands/CheckoutLicenseToAllUsers.php | 4 ++-- resources/lang/en/admin/users/general.php | 2 +- resources/views/users/edit.blade.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Console/Commands/CheckoutLicenseToAllUsers.php b/app/Console/Commands/CheckoutLicenseToAllUsers.php index e29b8991b6..003c32c738 100644 --- a/app/Console/Commands/CheckoutLicenseToAllUsers.php +++ b/app/Console/Commands/CheckoutLicenseToAllUsers.php @@ -56,8 +56,8 @@ class CheckoutLicenseToAllUsers extends Command return false; } - $users = User::whereNull('deleted_at')->where('should_autoassign', '==', 1)->with('licenses')->get(); - + $users = User::whereNull('deleted_at')->where('should_autoassign', '==', 0)->with('licenses')->get(); + dd($users); if ($users->count() > $license->getAvailSeatsCountAttribute()) { $this->info('You do not have enough free seats to complete this task, so we will check out as many as we can. '); } diff --git a/resources/lang/en/admin/users/general.php b/resources/lang/en/admin/users/general.php index 2ae8709251..71f56c7a15 100644 --- a/resources/lang/en/admin/users/general.php +++ b/resources/lang/en/admin/users/general.php @@ -19,7 +19,7 @@ return [ 'print_assigned' => 'Print All Assigned', 'email_assigned' => 'Email List of All Assigned', 'user_notified' => 'User has been emailed a list of their currently assigned items.', - 'auto_assign_label' => 'User should skipped during auto assignment commands', + 'auto_assign_label' => 'User should be skipped during auto assignment commands', 'auto_assign_help' => 'Skip this user in auto assignment of licenses', 'software_user' => 'Software Checked out to :name', 'send_email_help' => 'You must provide an email address for this user to send them credentials. Emailing credentials can only be done on user creation. Passwords are stored in a one-way hash and cannot be retrieved once saved.', diff --git a/resources/views/users/edit.blade.php b/resources/views/users/edit.blade.php index a689ab8983..f0bbc989f6 100755 --- a/resources/views/users/edit.blade.php +++ b/resources/views/users/edit.blade.php @@ -380,7 +380,7 @@
From 8a0517fb5d83ef055b1a90bdb07903265d8a4011 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Tue, 15 Nov 2022 15:59:47 -0800 Subject: [PATCH 005/554] removes data dump --- app/Console/Commands/CheckoutLicenseToAllUsers.php | 2 +- resources/views/users/edit.blade.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/CheckoutLicenseToAllUsers.php b/app/Console/Commands/CheckoutLicenseToAllUsers.php index 003c32c738..44ec72e13c 100644 --- a/app/Console/Commands/CheckoutLicenseToAllUsers.php +++ b/app/Console/Commands/CheckoutLicenseToAllUsers.php @@ -57,7 +57,7 @@ class CheckoutLicenseToAllUsers extends Command } $users = User::whereNull('deleted_at')->where('should_autoassign', '==', 0)->with('licenses')->get(); - dd($users); + if ($users->count() > $license->getAvailSeatsCountAttribute()) { $this->info('You do not have enough free seats to complete this task, so we will check out as many as we can. '); } diff --git a/resources/views/users/edit.blade.php b/resources/views/users/edit.blade.php index f0bbc989f6..7126428607 100755 --- a/resources/views/users/edit.blade.php +++ b/resources/views/users/edit.blade.php @@ -380,7 +380,7 @@
From 6fbb484dfd5362c8300d2710fe2a3815a63d87ed Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Wed, 18 Jan 2023 08:43:03 -0800 Subject: [PATCH 006/554] renames db column for auto_assign boolean, rewords trans string, default value of 1 now --- ..._11_15_232525_adds_should_autoassign_bool_to_users_table.php | 2 +- resources/lang/en/admin/users/general.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/database/migrations/2022_11_15_232525_adds_should_autoassign_bool_to_users_table.php b/database/migrations/2022_11_15_232525_adds_should_autoassign_bool_to_users_table.php index 6f6f308e44..854feebfea 100644 --- a/database/migrations/2022_11_15_232525_adds_should_autoassign_bool_to_users_table.php +++ b/database/migrations/2022_11_15_232525_adds_should_autoassign_bool_to_users_table.php @@ -14,7 +14,7 @@ class AddsShouldAutoassignBoolToUsersTable extends Migration public function up() { Schema::table('users', function (Blueprint $table) { - $table->boolean('should_autoassign')->nullable(false)->default(0); + $table->boolean('autoassign_licenses')->nullable(false)->default(1); }); } diff --git a/resources/lang/en/admin/users/general.php b/resources/lang/en/admin/users/general.php index 71f56c7a15..58c54a7d27 100644 --- a/resources/lang/en/admin/users/general.php +++ b/resources/lang/en/admin/users/general.php @@ -19,7 +19,7 @@ return [ 'print_assigned' => 'Print All Assigned', 'email_assigned' => 'Email List of All Assigned', 'user_notified' => 'User has been emailed a list of their currently assigned items.', - 'auto_assign_label' => 'User should be skipped during auto assignment commands', + 'auto_assign_label' => 'Include this user when auto-assigning eligible licenses', 'auto_assign_help' => 'Skip this user in auto assignment of licenses', 'software_user' => 'Software Checked out to :name', 'send_email_help' => 'You must provide an email address for this user to send them credentials. Emailing credentials can only be done on user creation. Passwords are stored in a one-way hash and cannot be retrieved once saved.', From 7ce230fadcb47a4d1b5f39184bacdb18125059aa Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Wed, 18 Jan 2023 08:57:59 -0800 Subject: [PATCH 007/554] missed a few renames --- app/Console/Commands/CheckoutLicenseToAllUsers.php | 2 +- app/Http/Controllers/Users/UsersController.php | 4 ++-- ...1_15_232525_adds_should_autoassign_bool_to_users_table.php | 2 +- resources/views/users/edit.blade.php | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Console/Commands/CheckoutLicenseToAllUsers.php b/app/Console/Commands/CheckoutLicenseToAllUsers.php index 44ec72e13c..1ba57895c2 100644 --- a/app/Console/Commands/CheckoutLicenseToAllUsers.php +++ b/app/Console/Commands/CheckoutLicenseToAllUsers.php @@ -56,7 +56,7 @@ class CheckoutLicenseToAllUsers extends Command return false; } - $users = User::whereNull('deleted_at')->where('should_autoassign', '==', 0)->with('licenses')->get(); + $users = User::whereNull('deleted_at')->where('autoassign_licenses', '==', 1)->with('licenses')->get(); if ($users->count() > $license->getAvailSeatsCountAttribute()) { $this->info('You do not have enough free seats to complete this task, so we will check out as many as we can. '); diff --git a/app/Http/Controllers/Users/UsersController.php b/app/Http/Controllers/Users/UsersController.php index b863fb966b..eecce0aea6 100755 --- a/app/Http/Controllers/Users/UsersController.php +++ b/app/Http/Controllers/Users/UsersController.php @@ -121,7 +121,7 @@ class UsersController extends Controller $user->created_by = Auth::user()->id; $user->start_date = $request->input('start_date', null); $user->end_date = $request->input('end_date', null); - $user->should_autoassign= $request->input('should_autoassign', 0); + $user->autoassign_licenses= $request->input('autoassign_licenses', 1); // Strip out the superuser permission if the user isn't a superadmin $permissions_array = $request->input('permission'); @@ -275,7 +275,7 @@ class UsersController extends Controller $user->website = $request->input('website', null); $user->start_date = $request->input('start_date', null); $user->end_date = $request->input('end_date', null); - $user->should_autoassign = $request->input('should_autoassign', 0); + $user->autoassign_licenses = $request->input('autoassign_licenses', 1); // Update the location of any assets checked out to this user Asset::where('assigned_type', User::class) diff --git a/database/migrations/2022_11_15_232525_adds_should_autoassign_bool_to_users_table.php b/database/migrations/2022_11_15_232525_adds_should_autoassign_bool_to_users_table.php index 854feebfea..b728e1f22b 100644 --- a/database/migrations/2022_11_15_232525_adds_should_autoassign_bool_to_users_table.php +++ b/database/migrations/2022_11_15_232525_adds_should_autoassign_bool_to_users_table.php @@ -26,7 +26,7 @@ class AddsShouldAutoassignBoolToUsersTable extends Migration public function down() { Schema::table('users', function (Blueprint $table) { - $table->dropColumn('should_autoassign'); + $table->dropColumn('autoassign_licenses'); }); } } diff --git a/resources/views/users/edit.blade.php b/resources/views/users/edit.blade.php index 7126428607..e4666a4d0c 100755 --- a/resources/views/users/edit.blade.php +++ b/resources/views/users/edit.blade.php @@ -379,8 +379,8 @@
-
- + @endif + @if ($asset->asset_eol_date)
@@ -680,10 +681,10 @@
- @if ($asset->purchase_date) - {{ Helper::getFormattedDateObject($asset->present()->eol_date(), 'date', false) }} + @if ($asset->asset_eol_date) + {{ Helper::getFormattedDateObject($asset->asset_eol_date, 'date', false) }} - - {{ Carbon::parse($asset->present()->eol_date())->diffForHumans(['parts' => 2]) }} + {{ Carbon::parse($asset->asset_eol_date)->diffForHumans(['parts' => 2]) }} @else {{ trans('general.na_no_purchase_date') }} @endif From 4104d7260fb7b2e982c2bc7bb27dd3dcab22e658 Mon Sep 17 00:00:00 2001 From: snipe Date: Sun, 22 Jan 2023 00:55:31 -0800 Subject: [PATCH 012/554] Include new eol date picker blade Signed-off-by: snipe --- resources/views/hardware/edit.blade.php | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/views/hardware/edit.blade.php b/resources/views/hardware/edit.blade.php index 07c04d7f8b..f0788bc73f 100755 --- a/resources/views/hardware/edit.blade.php +++ b/resources/views/hardware/edit.blade.php @@ -149,6 +149,7 @@
@include ('partials.forms.edit.order_number') @include ('partials.forms.edit.purchase_date') + @include ('partials.forms.edit.eol_date') @include ('partials.forms.edit.supplier-select', ['translated_name' => trans('general.supplier'), 'fieldname' => 'supplier_id']) @php From cad76f671ae278a13b51b7aab7d896f60c6491ee Mon Sep 17 00:00:00 2001 From: snipe Date: Sun, 22 Jan 2023 00:55:42 -0800 Subject: [PATCH 013/554] Added asset_eol_date to blade Signed-off-by: snipe --- app/Presenters/AssetPresenter.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/Presenters/AssetPresenter.php b/app/Presenters/AssetPresenter.php index ccc4a4cf13..4be0f56010 100644 --- a/app/Presenters/AssetPresenter.php +++ b/app/Presenters/AssetPresenter.php @@ -163,9 +163,16 @@ class AssetPresenter extends Presenter ], [ 'field' => 'eol', 'searchable' => false, - 'sortable' => false, + 'sortable' => true, 'visible' => false, 'title' => trans('general.eol'), + ], + [ + 'field' => 'asset_eol_date', + 'searchable' => true, + 'sortable' => true, + 'visible' => false, + 'title' => trans('admin/hardware/form.eol_date'), 'formatter' => 'dateDisplayFormatter', ], [ 'field' => 'warranty_months', From febfcd480317bedfc9c89b733a6bd175810ba027 Mon Sep 17 00:00:00 2001 From: snipe Date: Sun, 22 Jan 2023 00:56:19 -0800 Subject: [PATCH 014/554] Updated model with new field Signed-off-by: snipe --- app/Models/Asset.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Models/Asset.php b/app/Models/Asset.php index f8e0cab314..102f48fea2 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -116,6 +116,7 @@ class Asset extends Depreciable 'next_audit_date' => 'date|nullable', 'last_audit_date' => 'date|nullable', 'supplier_id' => 'exists:suppliers,id|nullable', + 'asset_eol_date' => 'date|max:10|min:10|nullable', ]; /** @@ -145,6 +146,7 @@ class Asset extends Depreciable 'last_checkout', 'expected_checkin', 'byod', + 'asset_eol_date', ]; use Searchable; @@ -167,6 +169,7 @@ class Asset extends Depreciable 'expected_checkin', 'next_audit_date', 'last_audit_date', + 'asset_eol_date', ]; /** @@ -180,7 +183,7 @@ class Asset extends Depreciable 'company' => ['name'], 'defaultLoc' => ['name'], 'location' => ['name'], - 'model' => ['name', 'model_number'], + 'model' => ['name', 'model_number', 'eol'], 'model.category' => ['name'], 'model.manufacturer' => ['name'], ]; From 5f9af7d509a5dd2df0bfc938e49fe1972ac15ee9 Mon Sep 17 00:00:00 2001 From: snipe Date: Sun, 22 Jan 2023 00:56:28 -0800 Subject: [PATCH 015/554] Updated API response Signed-off-by: snipe --- app/Http/Transformers/AssetsTransformer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Http/Transformers/AssetsTransformer.php b/app/Http/Transformers/AssetsTransformer.php index a36d0ab89b..4b1616026b 100644 --- a/app/Http/Transformers/AssetsTransformer.php +++ b/app/Http/Transformers/AssetsTransformer.php @@ -38,7 +38,8 @@ class AssetsTransformer 'byod' => ($asset->byod ? true : false), 'model_number' => (($asset->model) && ($asset->model->model_number)) ? e($asset->model->model_number) : null, - 'eol' => ($asset->purchase_date != '') ? Helper::getFormattedDateObject($asset->present()->eol_date(), 'date') : null, + 'eol' => ($asset->model->eol != '') ? $asset->model->eol : null, + 'asset_eol_date' => ($asset->asset_eol_date != '') ? Helper::getFormattedDateObject($asset->asset_eol_date, 'date') : null, 'status_label' => ($asset->assetstatus) ? [ 'id' => (int) $asset->assetstatus->id, 'name'=> e($asset->assetstatus->name), From 41537a2449fb8f1a9cd6aa9a60658ff2e445c152 Mon Sep 17 00:00:00 2001 From: snipe Date: Sun, 22 Jan 2023 00:56:44 -0800 Subject: [PATCH 016/554] Added field to the API controller endpoints Signed-off-by: snipe --- app/Http/Controllers/Api/AssetsController.php | 7 +++++-- app/Http/Controllers/Assets/AssetsController.php | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index a843aa09db..213c6617ac 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -101,6 +101,7 @@ class AssetsController extends Controller 'checkin_counter', 'requests_counter', 'byod', + 'asset_eol_date', ]; $filter = []; @@ -128,7 +129,6 @@ class AssetsController extends Controller // They are also used by the individual searches on detail pages like // locations, etc. - // Search custom fields by column name foreach ($all_custom_fields as $field) { if ($request->filled($field->db_column_name())) { @@ -136,7 +136,6 @@ class AssetsController extends Controller } } - if ($request->filled('status_id')) { $assets->where('assets.status_id', '=', $request->input('status_id')); } @@ -173,6 +172,10 @@ class AssetsController extends Controller $assets->where('assets.supplier_id', '=', $request->input('supplier_id')); } + if ($request->filled('asset_eol_date')) { + $assets->where('assets.asset_eol_date', '=', $request->input('asset_eol_date')); + } + if (($request->filled('assigned_to')) && ($request->filled('assigned_type'))) { $assets->where('assets.assigned_to', '=', $request->input('assigned_to')) ->where('assets.assigned_type', '=', $request->input('assigned_type')); diff --git a/app/Http/Controllers/Assets/AssetsController.php b/app/Http/Controllers/Assets/AssetsController.php index 1c7080bd46..9b51b7f267 100755 --- a/app/Http/Controllers/Assets/AssetsController.php +++ b/app/Http/Controllers/Assets/AssetsController.php @@ -142,6 +142,7 @@ class AssetsController extends Controller $asset->warranty_months = request('warranty_months', null); $asset->purchase_cost = Helper::ParseCurrency($request->get('purchase_cost')); $asset->purchase_date = request('purchase_date', null); + $asset->asset_eol_date = request('asset_eol_date', null); $asset->assigned_to = request('assigned_to', null); $asset->supplier_id = request('supplier_id', null); $asset->requestable = request('requestable', 0); @@ -312,6 +313,8 @@ class AssetsController extends Controller $asset->status_id = $request->input('status_id', null); $asset->warranty_months = $request->input('warranty_months', null); $asset->purchase_cost = Helper::ParseCurrency($request->input('purchase_cost', null)); + $asset->asset_eol_date = request('asset_eol_date', null); + $asset->purchase_date = $request->input('purchase_date', null); $asset->supplier_id = $request->input('supplier_id', null); $asset->expected_checkin = $request->input('expected_checkin', null); From b92d1d3ec717f2bd99c62d960c6a64b44167efef Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Tue, 24 Jan 2023 11:54:56 -0800 Subject: [PATCH 017/554] Logically group query when searching users to scope to company --- app/Http/Controllers/Api/UsersController.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php index cca829c23f..e0c8d409bb 100644 --- a/app/Http/Controllers/Api/UsersController.php +++ b/app/Http/Controllers/Api/UsersController.php @@ -286,9 +286,11 @@ class UsersController extends Controller $users = Company::scopeCompanyables($users); if ($request->filled('search')) { - $users = $users->SimpleNameSearch($request->get('search')) - ->orWhere('username', 'LIKE', '%'.$request->get('search').'%') - ->orWhere('employee_num', 'LIKE', '%'.$request->get('search').'%'); + $users = $users->where(function ($query) use ($request) { + $query->SimpleNameSearch($request->get('search')) + ->orWhere('username', 'LIKE', '%'.$request->get('search').'%') + ->orWhere('employee_num', 'LIKE', '%'.$request->get('search').'%'); + }); } $users = $users->orderBy('last_name', 'asc')->orderBy('first_name', 'asc'); From c9f0f5fe8b428e6c4955fc4a8f621f6438e778c0 Mon Sep 17 00:00:00 2001 From: Brady Wetherington Date: Tue, 24 Jan 2023 17:35:44 -0800 Subject: [PATCH 018/554] Change Accessories report to use server-side pagination from URL --- app/Http/Controllers/ReportsController.php | 3 +-- resources/views/reports/accessories.blade.php | 21 ++++++------------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/app/Http/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php index 6cf2091f60..399e99612c 100644 --- a/app/Http/Controllers/ReportsController.php +++ b/app/Http/Controllers/ReportsController.php @@ -51,9 +51,8 @@ class ReportsController extends Controller public function getAccessoryReport() { $this->authorize('reports.view'); - $accessories = Accessory::orderBy('created_at', 'DESC')->with('company')->get(); - return view('reports/accessories', compact('accessories')); + return view('reports/accessories'); } /** diff --git a/resources/views/reports/accessories.blade.php b/resources/views/reports/accessories.blade.php index 49db62c7f6..44f90682ba 100644 --- a/resources/views/reports/accessories.blade.php +++ b/resources/views/reports/accessories.blade.php @@ -27,6 +27,7 @@ data-sort-order="asc" id="accessoriesReport" class="table table-striped snipe-table" + data-url="{{ route('api.accessories.index') }}" data-export-options='{ "fileName": "accessory-report-{{ date('Y-m-d') }}", "ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"] @@ -34,27 +35,17 @@ - {{ trans('admin/companies/table.title') }} - {{ trans('admin/accessories/table.title') }} - {{ trans('general.model_no') }} - {{ trans('admin/accessories/general.total') }} - {{ trans('admin/accessories/general.remaining') }} + {{ trans('admin/companies/table.title') }} + {{ trans('admin/accessories/table.title') }} + {{ trans('general.model_no') }} + {{ trans('admin/accessories/general.total') }} + {{ trans('admin/accessories/general.remaining') }} - @foreach ($accessories as $accessory) - - {{ is_null($accessory->company) ? '' : $accessory->company->name }} - {{ $accessory->name }} - {{ $accessory->model_number }} - {{ $accessory->qty }} - {{ $accessory->numRemaining() }} - - @endforeach -
From b3635243053327d1cb2dd85095be3c3962c19dff Mon Sep 17 00:00:00 2001 From: akemidx Date: Wed, 25 Jan 2023 15:58:44 -0500 Subject: [PATCH 019/554] vipuser label updated to vip --- app/Http/Controllers/Api/UsersController.php | 2 +- app/Http/Controllers/Users/UsersController.php | 2 +- app/Models/User.php | 4 ++-- app/Presenters/UserPresenter.php | 2 +- database/migrations/2023_01_23_232933_add_vip_to_users.php | 6 +++--- resources/views/users/edit.blade.php | 4 ++-- resources/views/users/view.blade.php | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php index 8185583868..36ba063674 100644 --- a/app/Http/Controllers/Api/UsersController.php +++ b/app/Http/Controllers/Api/UsersController.php @@ -246,7 +246,7 @@ class UsersController extends Controller 'two_factor_optin', 'two_factor_enrolled', 'remote', - 'vipuser', + 'vip', 'start_date', 'end_date', ]; diff --git a/app/Http/Controllers/Users/UsersController.php b/app/Http/Controllers/Users/UsersController.php index 9d322ca4d9..38afc66610 100755 --- a/app/Http/Controllers/Users/UsersController.php +++ b/app/Http/Controllers/Users/UsersController.php @@ -271,7 +271,7 @@ class UsersController extends Controller $user->activated = $request->input('activated', 0); $user->zip = $request->input('zip', null); $user->remote = $request->input('remote', 0); - $user->vipuser = $request->input('vipuser', 0); + $user->vipuser = $request->input('vip', 0); $user->website = $request->input('website', null); $user->start_date = $request->input('start_date', null); $user->end_date = $request->input('end_date', null); diff --git a/app/Models/User.php b/app/Models/User.php index b51d23626f..4e6566b2d6 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -62,7 +62,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo 'start_date', 'end_date', 'scim_externalid', - 'vipuser', + 'vip', ]; protected $casts = [ @@ -70,7 +70,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo 'manager_id' => 'integer', 'location_id' => 'integer', 'company_id' => 'integer', - 'vipuser' => 'boolean', + 'vip' => 'boolean', ]; diff --git a/app/Presenters/UserPresenter.php b/app/Presenters/UserPresenter.php index dc41050f5b..0811fbc500 100644 --- a/app/Presenters/UserPresenter.php +++ b/app/Presenters/UserPresenter.php @@ -86,7 +86,7 @@ class UserPresenter extends Presenter 'formatter' => 'usersLinkFormatter', ], [ - 'field' => 'vipuser', + 'field' => 'vip', 'searchable' => false, 'sortable' => true, 'switchable' => true, diff --git a/database/migrations/2023_01_23_232933_add_vip_to_users.php b/database/migrations/2023_01_23_232933_add_vip_to_users.php index 40db001b17..344f35d240 100644 --- a/database/migrations/2023_01_23_232933_add_vip_to_users.php +++ b/database/migrations/2023_01_23_232933_add_vip_to_users.php @@ -14,7 +14,7 @@ class AddVipToUsers extends Migration public function up() { Schema::table('users', function (Blueprint $table) { - $table->boolean('vipuser')->nullable()->default(0); + $table->boolean('vip')->nullable()->default(0); }); } @@ -26,8 +26,8 @@ class AddVipToUsers extends Migration public function down() { Schema::table('users', function (Blueprint $table) { - if (Schema::hasColumn('users', 'vipuser')) { - $table->dropColumn('vipuser'); + if (Schema::hasColumn('users', 'vip')) { + $table->dropColumn('vip'); } }); } diff --git a/resources/views/users/edit.blade.php b/resources/views/users/edit.blade.php index b06dcad237..8250fe2a58 100755 --- a/resources/views/users/edit.blade.php +++ b/resources/views/users/edit.blade.php @@ -365,8 +365,8 @@
-
- {!! ($user->vipuser=='1') ? ' '.trans('general.yes') : ' '.trans('general.no') !!} + {!! ($user->vip=='1') ? ' '.trans('general.yes') : ' '.trans('general.no') !!}
From 4a54586690b2ef6340d780e4fdb6cdb7b5b5189f Mon Sep 17 00:00:00 2001 From: Brady Wetherington Date: Thu, 26 Jan 2023 11:56:06 -0800 Subject: [PATCH 020/554] Add to Accessories#index an additional gate-check against reports.view --- app/Http/Controllers/Api/AccessoriesController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/AccessoriesController.php b/app/Http/Controllers/Api/AccessoriesController.php index a894dc3760..f822509680 100644 --- a/app/Http/Controllers/Api/AccessoriesController.php +++ b/app/Http/Controllers/Api/AccessoriesController.php @@ -26,7 +26,10 @@ class AccessoriesController extends Controller */ public function index(Request $request) { - $this->authorize('view', Accessory::class); + if ($request->user()->cannot('reports.view')) { + $this->authorize('view', Accessory::class); + } + // This array is what determines which fields should be allowed to be sorted on ON the table itself, no relations // Relations will be handled in query scopes a little further down. From df31a769064d2e5f2b787f6a57ec20861f2e1e2c Mon Sep 17 00:00:00 2001 From: akemidx Date: Thu, 26 Jan 2023 15:02:39 -0500 Subject: [PATCH 021/554] fixed apostraphe --- app/Models/User.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/User.php b/app/Models/User.php index f7a52aa8d9..d4852eae8b 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -64,7 +64,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo 'scim_externalid', 'avatar', 'gravatar', - 'vip`, + 'vip', ]; protected $casts = [ From 69c38bf686f756968d2a4a25a4c2005a2152d4c2 Mon Sep 17 00:00:00 2001 From: akemidx Date: Wed, 1 Feb 2023 20:32:16 -0500 Subject: [PATCH 022/554] translations on the User Creation page --- resources/lang/en/admin/users/general.php | 5 +++++ resources/views/setup/user.blade.php | 13 ++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/resources/lang/en/admin/users/general.php b/resources/lang/en/admin/users/general.php index daa568e8bf..e845ed09b7 100644 --- a/resources/lang/en/admin/users/general.php +++ b/resources/lang/en/admin/users/general.php @@ -41,4 +41,9 @@ return [ 'remote' => 'Remote', 'remote_help' => 'This can be useful if you need to filter by remote users who never or rarely come into your physical locations.', 'not_remote_label' => 'This is not a remote user', + 'create_user' => 'Create a user', + 'create_user_page_explaination' => 'This is the account information you will use to access the site for the first time.', + 'email_credentials' => 'Email credentials', + 'email_credentials_text' => 'Email my credentials to the email address above', + 'next_save_user' => 'Next: Save User', ]; diff --git a/resources/views/setup/user.blade.php b/resources/views/setup/user.blade.php index eaa74fb857..b6ff3293dc 100644 --- a/resources/views/setup/user.blade.php +++ b/resources/views/setup/user.blade.php @@ -1,15 +1,14 @@ @extends('layouts/setup') -{{-- TODO: Translate --}} -{{-- Page title --}} +{{ trans('admin/user/table.createuser') }} @section('title') -Create a User :: +{{ trans('admin/user/general.create_user') }} :: @parent @stop {{-- Page content --}} @section('content') -

This is the account information you'll use to access the site for the first time.

+

{{ trans('admin/user/general.create_user_page_explaination') }}

{{ csrf_field() }} @@ -157,10 +156,10 @@ Create a User ::
- +
@@ -168,7 +167,7 @@ Create a User :: @stop @section('button') - +
@parent @stop From b8951e2b541eb8b7ee6bdf07585849298a545613 Mon Sep 17 00:00:00 2001 From: akemidx Date: Thu, 2 Feb 2023 15:58:05 -0500 Subject: [PATCH 023/554] fixing name from vipuser to vip --- app/Http/Controllers/Users/UsersController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Users/UsersController.php b/app/Http/Controllers/Users/UsersController.php index f0f84af11b..ee8a96e010 100755 --- a/app/Http/Controllers/Users/UsersController.php +++ b/app/Http/Controllers/Users/UsersController.php @@ -271,7 +271,7 @@ class UsersController extends Controller $user->activated = $request->input('activated', 0); $user->zip = $request->input('zip', null); $user->remote = $request->input('remote', 0); - $user->vipuser = $request->input('vip', 0); + $user->vip = $request->input('vip', 0); $user->website = $request->input('website', null); $user->start_date = $request->input('start_date', null); $user->end_date = $request->input('end_date', null); From a2e47d19fcd12d6759559811e52323d07b504547 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 2 Feb 2023 13:47:00 -0800 Subject: [PATCH 024/554] Scaffold tests for user select list api and begin to implemenet --- .../Api/Users/UsersForSelectListTest.php | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tests/Feature/Api/Users/UsersForSelectListTest.php diff --git a/tests/Feature/Api/Users/UsersForSelectListTest.php b/tests/Feature/Api/Users/UsersForSelectListTest.php new file mode 100644 index 0000000000..fb1dde2909 --- /dev/null +++ b/tests/Feature/Api/Users/UsersForSelectListTest.php @@ -0,0 +1,50 @@ +create(); + + $actor = User::factory()->firstAdmin()->create(); + User::factory()->count(3)->create(); + + Passport::actingAs($actor); + $response = $this->getJson(route('api.users.selectlist')); + $response->assertOk(); + + $response->assertJsonStructure([ + 'results', + 'pagination', + 'total_count', + 'page', + 'page_count', + ]); + + $response->assertJson(fn(AssertableJson $json) => $json->has('results', 4)->etc()); + } + + public function testUsersScopedToCompanyWhenMultipleFullCompanySupportEnabled() + { + $this->markTestIncomplete(); + + } + + public function testUsersScopedToCompanyDuringSearchWhenMultipleFullCompanySupportEnabled() + { + $this->markTestIncomplete(); + + + } +} From 89eff23e44ebe454916e4b87e7c7b16bca982f3d Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 2 Feb 2023 17:41:32 -0800 Subject: [PATCH 025/554] Continue implementing tests --- database/factories/SettingFactory.php | 9 +++++ .../Api/Users/UsersForSelectListTest.php | 38 +++++++++++++++++-- tests/TestCase.php | 8 ++++ 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/database/factories/SettingFactory.php b/database/factories/SettingFactory.php index 73a9e049dc..cd88cdaf2f 100644 --- a/database/factories/SettingFactory.php +++ b/database/factories/SettingFactory.php @@ -52,4 +52,13 @@ class SettingFactory extends Factory 'email_domain' => 'test.com', ]; } + + public function withMultipleFullCompanySupport() + { + return $this->state(function () { + return [ + 'full_multiple_companies_support' => 1, + ]; + }); + } } diff --git a/tests/Feature/Api/Users/UsersForSelectListTest.php b/tests/Feature/Api/Users/UsersForSelectListTest.php index fb1dde2909..4769831fd4 100644 --- a/tests/Feature/Api/Users/UsersForSelectListTest.php +++ b/tests/Feature/Api/Users/UsersForSelectListTest.php @@ -2,6 +2,7 @@ namespace Tests\Feature\Api\Users; +use App\Models\Company; use App\Models\Setting; use App\Models\User; use Illuminate\Foundation\Testing\RefreshDatabase; @@ -37,14 +38,43 @@ class UsersForSelectListTest extends TestCase public function testUsersScopedToCompanyWhenMultipleFullCompanySupportEnabled() { - $this->markTestIncomplete(); + Setting::factory()->withMultipleFullCompanySupport()->create(); + [$jedi, $sith] = Company::factory()->count(2)->create(); + + User::factory() + ->for($sith) + ->create(['first_name' => 'Darth', 'last_name' => 'Vader']); + + User::factory() + ->for($jedi) + ->count(3) + ->sequence( + ['first_name' => 'Luke', 'last_name' => 'Skywalker'], + ['first_name' => 'Obi-Wan', 'last_name' => 'Kenobi'], + ['first_name' => 'Anakin', 'last_name' => 'Skywalker'], + ) + ->create(); + + Passport::actingAs($jedi->users->first()); + $response = $this->getJson(route('api.users.selectlist')); + $response->assertOk(); + + $results = collect($response->json('results')); + + $this->assertEquals($jedi->users->count(), $results->count()); + + $this->assertTrue( + $results->pluck('text')->contains(fn($text) => str_contains($text, $jedi->users->first()->first_name)) + ); + + $this->assertFalse( + $results->pluck('text')->contains(fn($text) => str_contains($text, $sith->users->first()->first_name)) + ); } public function testUsersScopedToCompanyDuringSearchWhenMultipleFullCompanySupportEnabled() { - $this->markTestIncomplete(); - - + } } diff --git a/tests/TestCase.php b/tests/TestCase.php index 2932d4a69d..5082341307 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,9 +2,17 @@ namespace Tests; +use App\Models\Setting; use Illuminate\Foundation\Testing\TestCase as BaseTestCase; abstract class TestCase extends BaseTestCase { use CreatesApplication; + + protected function setUp(): void + { + parent::setUp(); + + $this->beforeApplicationDestroyed(fn() => Setting::$_cache = null); + } } From 93a62c87c2ec4a194a3a0798f1c2dee98ae2fe19 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 2 Feb 2023 17:57:24 -0800 Subject: [PATCH 026/554] Implement test for searching users --- .../Api/Users/UsersForSelectListTest.php | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/tests/Feature/Api/Users/UsersForSelectListTest.php b/tests/Feature/Api/Users/UsersForSelectListTest.php index 4769831fd4..73db560473 100644 --- a/tests/Feature/Api/Users/UsersForSelectListTest.php +++ b/tests/Feature/Api/Users/UsersForSelectListTest.php @@ -22,8 +22,7 @@ class UsersForSelectListTest extends TestCase User::factory()->count(3)->create(); Passport::actingAs($actor); - $response = $this->getJson(route('api.users.selectlist')); - $response->assertOk(); + $response = $this->getJson(route('api.users.selectlist'))->assertOk(); $response->assertJsonStructure([ 'results', @@ -57,8 +56,7 @@ class UsersForSelectListTest extends TestCase ->create(); Passport::actingAs($jedi->users->first()); - $response = $this->getJson(route('api.users.selectlist')); - $response->assertOk(); + $response = $this->getJson(route('api.users.selectlist'))->assertOk(); $results = collect($response->json('results')); @@ -75,6 +73,36 @@ class UsersForSelectListTest extends TestCase public function testUsersScopedToCompanyDuringSearchWhenMultipleFullCompanySupportEnabled() { - + Setting::factory()->withMultipleFullCompanySupport()->create(); + + [$jedi, $sith] = Company::factory()->count(2)->create(); + + User::factory() + ->for($sith) + ->create(['first_name' => 'Darth', 'last_name' => 'Vader', 'username' => 'dvader']); + + User::factory() + ->for($jedi) + ->count(3) + ->sequence( + ['first_name' => 'Luke', 'last_name' => 'Skywalker', 'username' => 'lskywalker'], + ['first_name' => 'Obi-Wan', 'last_name' => 'Kenobi', 'username' => 'okenobi'], + ['first_name' => 'Anakin', 'last_name' => 'Skywalker', 'username' => 'askywalker'], + ) + ->create(); + + Passport::actingAs($jedi->users->first()); + + $response = $this->getJson(route('api.users.selectlist', ['search' => 'a']))->assertOk(); + + $results = collect($response->json('results')); + + $this->assertEquals(3, $results->count()); + $this->assertTrue($results->pluck('text')->contains(fn($text) => str_contains($text, 'Luke'))); + $this->assertTrue($results->pluck('text')->contains(fn($text) => str_contains($text, 'Anakin'))); + + $response = $this->getJson(route('api.users.selectlist', ['search' => 'v']))->assertOk(); + $results = collect($response->json('results')); + $this->assertEquals(0, $results->count()); } } From d8e92d29c048e0014d80fecfe7319be318ba902a Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 2 Feb 2023 18:25:54 -0800 Subject: [PATCH 027/554] Improve readability --- .../Api/Users/UsersForSelectListTest.php | 67 +++++++------------ 1 file changed, 26 insertions(+), 41 deletions(-) diff --git a/tests/Feature/Api/Users/UsersForSelectListTest.php b/tests/Feature/Api/Users/UsersForSelectListTest.php index 73db560473..666961fa93 100644 --- a/tests/Feature/Api/Users/UsersForSelectListTest.php +++ b/tests/Feature/Api/Users/UsersForSelectListTest.php @@ -18,41 +18,33 @@ class UsersForSelectListTest extends TestCase { Setting::factory()->create(); - $actor = User::factory()->firstAdmin()->create(); User::factory()->count(3)->create(); - Passport::actingAs($actor); - $response = $this->getJson(route('api.users.selectlist'))->assertOk(); - - $response->assertJsonStructure([ - 'results', - 'pagination', - 'total_count', - 'page', - 'page_count', - ]); - - $response->assertJson(fn(AssertableJson $json) => $json->has('results', 4)->etc()); + Passport::actingAs(User::factory()->firstAdmin()->create()); + $this->getJson(route('api.users.selectlist')) + ->assertOk() + ->assertJsonStructure([ + 'results', + 'pagination', + 'total_count', + 'page', + 'page_count', + ]) + ->assertJson(fn(AssertableJson $json) => $json->has('results', 4)->etc()); } public function testUsersScopedToCompanyWhenMultipleFullCompanySupportEnabled() { Setting::factory()->withMultipleFullCompanySupport()->create(); - [$jedi, $sith] = Company::factory()->count(2)->create(); + $jedi = Company::factory()->has(User::factory()->count(3)->sequence( + ['first_name' => 'Luke', 'last_name' => 'Skywalker', 'username' => 'lskywalker'], + ['first_name' => 'Obi-Wan', 'last_name' => 'Kenobi', 'username' => 'okenobi'], + ['first_name' => 'Anakin', 'last_name' => 'Skywalker', 'username' => 'askywalker'], + ))->create(); - User::factory() - ->for($sith) - ->create(['first_name' => 'Darth', 'last_name' => 'Vader']); - - User::factory() - ->for($jedi) - ->count(3) - ->sequence( - ['first_name' => 'Luke', 'last_name' => 'Skywalker'], - ['first_name' => 'Obi-Wan', 'last_name' => 'Kenobi'], - ['first_name' => 'Anakin', 'last_name' => 'Skywalker'], - ) + $sith = Company::factory() + ->has(User::factory()->state(['first_name' => 'Darth', 'last_name' => 'Vader', 'username' => 'dvader'])) ->create(); Passport::actingAs($jedi->users->first()); @@ -75,20 +67,14 @@ class UsersForSelectListTest extends TestCase { Setting::factory()->withMultipleFullCompanySupport()->create(); - [$jedi, $sith] = Company::factory()->count(2)->create(); + $jedi = Company::factory()->has(User::factory()->count(3)->sequence( + ['first_name' => 'Luke', 'last_name' => 'Skywalker', 'username' => 'lskywalker'], + ['first_name' => 'Obi-Wan', 'last_name' => 'Kenobi', 'username' => 'okenobi'], + ['first_name' => 'Anakin', 'last_name' => 'Skywalker', 'username' => 'askywalker'], + ))->create(); - User::factory() - ->for($sith) - ->create(['first_name' => 'Darth', 'last_name' => 'Vader', 'username' => 'dvader']); - - User::factory() - ->for($jedi) - ->count(3) - ->sequence( - ['first_name' => 'Luke', 'last_name' => 'Skywalker', 'username' => 'lskywalker'], - ['first_name' => 'Obi-Wan', 'last_name' => 'Kenobi', 'username' => 'okenobi'], - ['first_name' => 'Anakin', 'last_name' => 'Skywalker', 'username' => 'askywalker'], - ) + Company::factory() + ->has(User::factory()->state(['first_name' => 'Darth', 'last_name' => 'Vader', 'username' => 'dvader'])) ->create(); Passport::actingAs($jedi->users->first()); @@ -102,7 +88,6 @@ class UsersForSelectListTest extends TestCase $this->assertTrue($results->pluck('text')->contains(fn($text) => str_contains($text, 'Anakin'))); $response = $this->getJson(route('api.users.selectlist', ['search' => 'v']))->assertOk(); - $results = collect($response->json('results')); - $this->assertEquals(0, $results->count()); + $this->assertEquals(0, collect($response->json('results'))->count()); } } From 9a0c66bd305ec2a43cd9f5bb7399af462177f91a Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 2 Feb 2023 18:30:18 -0800 Subject: [PATCH 028/554] Clear some extra lines --- tests/Feature/Api/Users/UsersForSelectListTest.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/Feature/Api/Users/UsersForSelectListTest.php b/tests/Feature/Api/Users/UsersForSelectListTest.php index 666961fa93..960cf4e09d 100644 --- a/tests/Feature/Api/Users/UsersForSelectListTest.php +++ b/tests/Feature/Api/Users/UsersForSelectListTest.php @@ -53,11 +53,9 @@ class UsersForSelectListTest extends TestCase $results = collect($response->json('results')); $this->assertEquals($jedi->users->count(), $results->count()); - $this->assertTrue( $results->pluck('text')->contains(fn($text) => str_contains($text, $jedi->users->first()->first_name)) ); - $this->assertFalse( $results->pluck('text')->contains(fn($text) => str_contains($text, $sith->users->first()->first_name)) ); @@ -78,7 +76,6 @@ class UsersForSelectListTest extends TestCase ->create(); Passport::actingAs($jedi->users->first()); - $response = $this->getJson(route('api.users.selectlist', ['search' => 'a']))->assertOk(); $results = collect($response->json('results')); From 0cefc7de1506b0ce8c468f48fa9572361d77d2ca Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 2 Feb 2023 18:37:35 -0800 Subject: [PATCH 029/554] Skip security headers middleware when testing --- app/Http/Middleware/SecurityHeaders.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/Http/Middleware/SecurityHeaders.php b/app/Http/Middleware/SecurityHeaders.php index 25f0461fcf..f3e7ea7cfa 100644 --- a/app/Http/Middleware/SecurityHeaders.php +++ b/app/Http/Middleware/SecurityHeaders.php @@ -3,6 +3,7 @@ namespace App\Http\Middleware; use Closure; +use Illuminate\Support\Facades\App; class SecurityHeaders { @@ -22,6 +23,10 @@ class SecurityHeaders public function handle($request, Closure $next) { + if (App::environment(['testing', 'testing-ci'])) { + return $next($request); + } + $this->removeUnwantedHeaders($this->unwantedHeaderList); $response = $next($request); From 78343ddb7c1269c5f7d59a3e7861ddcd930104e8 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 6 Feb 2023 10:58:10 -0800 Subject: [PATCH 030/554] Add asset's company name to checkout page --- resources/views/hardware/checkout.blade.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/resources/views/hardware/checkout.blade.php b/resources/views/hardware/checkout.blade.php index 2b3cdbc19e..13c4514050 100755 --- a/resources/views/hardware/checkout.blade.php +++ b/resources/views/hardware/checkout.blade.php @@ -32,8 +32,7 @@

@if (($asset->model) && ($asset->model->name)) - {{ $asset->model->name }} - + {{ $asset->model->name }}@if ($asset->company && $asset->company->name) ({{ $asset->company->name }}) @endif @else This asset's model is invalid! From 38cdcdf064a039c7e8a051f0e02fc1f18429e818 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 6 Feb 2023 10:59:51 -0800 Subject: [PATCH 031/554] Eager load company --- app/Http/Controllers/Assets/AssetCheckoutController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Assets/AssetCheckoutController.php b/app/Http/Controllers/Assets/AssetCheckoutController.php index 38f7460986..e6326da6b1 100644 --- a/app/Http/Controllers/Assets/AssetCheckoutController.php +++ b/app/Http/Controllers/Assets/AssetCheckoutController.php @@ -27,7 +27,7 @@ class AssetCheckoutController extends Controller public function create($assetId) { // Check if the asset exists - if (is_null($asset = Asset::find(e($assetId)))) { + if (is_null($asset = Asset::with('company')->find(e($assetId)))) { return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist')); } From 45e8e9bbed0c33d49f1fe1c9484d278b1c15fd69 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 6 Feb 2023 12:21:09 -0800 Subject: [PATCH 032/554] Move company name to better location --- resources/views/hardware/checkout.blade.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/resources/views/hardware/checkout.blade.php b/resources/views/hardware/checkout.blade.php index 13c4514050..6b5d337b73 100755 --- a/resources/views/hardware/checkout.blade.php +++ b/resources/views/hardware/checkout.blade.php @@ -26,13 +26,23 @@

{{csrf_field()}} + @if ($asset->company && $asset->company->name) +
+ {{ Form::label('model', trans('admin/companies/general.company'), array('class' => 'col-md-3 control-label')) }} +
+

+ {{ $asset->company->name }} +

+
+
+ @endif
{{ Form::label('model', trans('admin/hardware/form.model'), array('class' => 'col-md-3 control-label')) }}

@if (($asset->model) && ($asset->model->name)) - {{ $asset->model->name }}@if ($asset->company && $asset->company->name) ({{ $asset->company->name }}) @endif + {{ $asset->model->name }} @else This asset's model is invalid! @@ -167,4 +177,4 @@ -@stop \ No newline at end of file +@stop From 0e57e4836eba840698232cd4387df4d1ad5688d5 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 6 Feb 2023 12:21:23 -0800 Subject: [PATCH 033/554] Add translation for Company --- resources/lang/en/admin/companies/general.php | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/lang/en/admin/companies/general.php b/resources/lang/en/admin/companies/general.php index 37781012ba..6ad64db576 100644 --- a/resources/lang/en/admin/companies/general.php +++ b/resources/lang/en/admin/companies/general.php @@ -1,6 +1,7 @@ 'Company', 'select_company' => 'Select Company', 'about_companies' => 'About Companies', 'about_companies_description' => ' You can use companies as a simple informative field, or you can use them to restrict asset visibility and availability to users with a specific company by enabling Full Company Support in your Admin Settings.', From c03079944a9bc997ca19e83eb4f991624c5ea9b0 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 6 Feb 2023 16:06:13 -0800 Subject: [PATCH 034/554] Be more explicit in test case --- tests/Feature/Api/Users/UsersForSelectListTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Feature/Api/Users/UsersForSelectListTest.php b/tests/Feature/Api/Users/UsersForSelectListTest.php index 960cf4e09d..558f362646 100644 --- a/tests/Feature/Api/Users/UsersForSelectListTest.php +++ b/tests/Feature/Api/Users/UsersForSelectListTest.php @@ -52,12 +52,12 @@ class UsersForSelectListTest extends TestCase $results = collect($response->json('results')); - $this->assertEquals($jedi->users->count(), $results->count()); + $this->assertEquals(3, $results->count()); $this->assertTrue( - $results->pluck('text')->contains(fn($text) => str_contains($text, $jedi->users->first()->first_name)) + $results->pluck('text')->contains(fn($text) => str_contains($text, 'Luke')) ); $this->assertFalse( - $results->pluck('text')->contains(fn($text) => str_contains($text, $sith->users->first()->first_name)) + $results->pluck('text')->contains(fn($text) => str_contains($text, 'Darth')) ); } From 6dbcec23105380c93fedab1059d7b841d2758311 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Tue, 7 Feb 2023 16:16:39 -0800 Subject: [PATCH 035/554] Exclude Dusk tests from phpunit test suite --- phpunit.xml | 1 + tests/Unit/ConsumableTest.php | 19 ------------------- 2 files changed, 1 insertion(+), 19 deletions(-) delete mode 100644 tests/Unit/ConsumableTest.php diff --git a/phpunit.xml b/phpunit.xml index bf3fd2dc33..9706518ab4 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -8,6 +8,7 @@ ./tests/ + ./tests/Browser diff --git a/tests/Unit/ConsumableTest.php b/tests/Unit/ConsumableTest.php deleted file mode 100644 index cbe89b13bb..0000000000 --- a/tests/Unit/ConsumableTest.php +++ /dev/null @@ -1,19 +0,0 @@ - Date: Tue, 7 Feb 2023 16:17:05 -0800 Subject: [PATCH 036/554] Use factories for relationships in asset factory --- database/factories/AssetFactory.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/database/factories/AssetFactory.php b/database/factories/AssetFactory.php index 24021921b3..858febe829 100644 --- a/database/factories/AssetFactory.php +++ b/database/factories/AssetFactory.php @@ -38,7 +38,7 @@ class AssetFactory extends Factory { return [ 'name' => null, - 'rtd_location_id' => Location::all()->random()->id, + 'rtd_location_id' => Location::factory(), 'serial' => $this->faker->uuid, 'status_id' => 1, 'user_id' => 1, @@ -47,7 +47,7 @@ class AssetFactory extends Factory 'purchase_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()), 'purchase_cost' => $this->faker->randomFloat(2, '299.99', '2999.99'), 'order_number' => $this->faker->numberBetween(1000000, 50000000), - 'supplier_id' => Supplier::all()->random()->id, + 'supplier_id' => Supplier::factory(), 'requestable' => $this->faker->boolean(), 'assigned_to' => null, 'assigned_type' => null, From 6b8c0f9e8838e6ad4c5e834a90e6d26d824c92de Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Tue, 7 Feb 2023 16:17:16 -0800 Subject: [PATCH 037/554] Make BaseTest abstract --- tests/Unit/BaseTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Unit/BaseTest.php b/tests/Unit/BaseTest.php index 83f1181083..136978be27 100644 --- a/tests/Unit/BaseTest.php +++ b/tests/Unit/BaseTest.php @@ -10,7 +10,7 @@ use Tests\TestCase; use Auth; use Artisan; -class BaseTest extends TestCase +abstract class BaseTest extends TestCase { use DatabaseTransactions; From 505ca48da283eaab368bca067cca839ddef25cda Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Tue, 7 Feb 2023 16:17:36 -0800 Subject: [PATCH 038/554] Remove test method without assertions --- tests/Unit/CustomFieldTest.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/Unit/CustomFieldTest.php b/tests/Unit/CustomFieldTest.php index 7df281fe1d..f991fda208 100644 --- a/tests/Unit/CustomFieldTest.php +++ b/tests/Unit/CustomFieldTest.php @@ -15,11 +15,6 @@ class CustomFieldTest extends BaseTest { protected $tester; - public function testConstructor() - { - $customfield = new CustomField(); - } - public function testFormat() { $customfield = CustomField::factory()->make(['format' => 'IP']); From 787f619a6b51859ed808a1edb2dd331a2d2a92bc Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Tue, 7 Feb 2023 16:28:40 -0800 Subject: [PATCH 039/554] Standardize test method syntax --- tests/Unit/AssetMaintenanceTest.php | 20 ++++------------ tests/Unit/AssetTest.php | 5 ---- tests/Unit/SnipeModelTest.php | 37 ++++++----------------------- 3 files changed, 11 insertions(+), 51 deletions(-) diff --git a/tests/Unit/AssetMaintenanceTest.php b/tests/Unit/AssetMaintenanceTest.php index ccae46ed76..ad16679887 100644 --- a/tests/Unit/AssetMaintenanceTest.php +++ b/tests/Unit/AssetMaintenanceTest.php @@ -12,10 +12,7 @@ class AssetMaintenanceTest extends BaseTest */ protected $tester; - /** - * @test - */ - public function it_zeros_out_warranty_if_blank() + public function testZerosOutWarrantyIfBlank() { $c = new AssetMaintenance; $c->is_warranty = ''; @@ -24,10 +21,7 @@ class AssetMaintenanceTest extends BaseTest $this->assertTrue($c->is_warranty == 4); } - /** - * @test - */ - public function it_sets_costs_appropriately() + public function testSetsCostsAppropriately() { $c = new AssetMaintenance(); $c->cost = '0.00'; @@ -38,10 +32,7 @@ class AssetMaintenanceTest extends BaseTest $this->assertTrue($c->cost === 9.5); } - /** - * @test - */ - public function it_nulls_out_notes_if_blank() + public function testNullsOutNotesIfBlank() { $c = new AssetMaintenance; $c->notes = ''; @@ -50,10 +41,7 @@ class AssetMaintenanceTest extends BaseTest $this->assertTrue($c->notes === 'This is a long note'); } - /** - * @test - */ - public function it_nulls_out_completion_date_if_blank_or_invalid() + public function testNullsOutCompletionDateIfBlankOrInvalid() { $c = new AssetMaintenance; $c->completion_date = ''; diff --git a/tests/Unit/AssetTest.php b/tests/Unit/AssetTest.php index 0cc27d80db..e3fa5b4497 100644 --- a/tests/Unit/AssetTest.php +++ b/tests/Unit/AssetTest.php @@ -41,10 +41,6 @@ class AssetTest extends BaseTest // $this->assertEquals($expected, $next); // } - - /** - * @test - */ public function testWarrantyExpiresAttribute() { @@ -66,5 +62,4 @@ class AssetTest extends BaseTest $this->assertEquals(Carbon::createFromDate(2019, 1, 1)->format('Y-m-d'), $asset->warranty_expires->format('Y-m-d')); } - } diff --git a/tests/Unit/SnipeModelTest.php b/tests/Unit/SnipeModelTest.php index 8884ecf6d3..f9dcfe0cb4 100644 --- a/tests/Unit/SnipeModelTest.php +++ b/tests/Unit/SnipeModelTest.php @@ -11,12 +11,7 @@ class SnipeModelTest extends BaseTest */ protected $tester; - // tests - - /** - * @test - */ - public function it_sets_purchase_dates_appropriately() + public function testSetsPurchaseDatesAppropriately() { $c = new SnipeModel; $c->purchase_date = ''; @@ -25,10 +20,7 @@ class SnipeModelTest extends BaseTest $this->assertTrue($c->purchase_date === '2016-03-25 12:35:50'); } - /** - * @test - */ - public function it_sets_purchase_costs_appropriately() + public function testSetsPurchaseCostsAppropriately() { $c = new SnipeModel; $c->purchase_cost = '0.00'; @@ -39,10 +31,7 @@ class SnipeModelTest extends BaseTest $this->assertTrue($c->purchase_cost === 9.5); } - /** - * @test - */ - public function it_nulls_blank_location_ids_but_not_others() + public function testNullsBlankLocationIdsButNotOthers() { $c = new SnipeModel; $c->location_id = ''; @@ -51,10 +40,7 @@ class SnipeModelTest extends BaseTest $this->assertTrue($c->location_id == 5); } - /** - * @test - */ - public function it_nulls_blank_categories_but_not_others() + public function testNullsBlankCategoriesButNotOthers() { $c = new SnipeModel; $c->category_id = ''; @@ -63,10 +49,7 @@ class SnipeModelTest extends BaseTest $this->assertTrue($c->category_id == 1); } - /** - * @test - */ - public function it_nulls_blank_suppliers_but_not_others() + public function testNullsBlankSuppliersButNotOthers() { $c = new SnipeModel; $c->supplier_id = ''; @@ -75,10 +58,7 @@ class SnipeModelTest extends BaseTest $this->assertTrue($c->supplier_id == 4); } - /** - * @test - */ - public function it_nulls_blank_depreciations_but_not_others() + public function testNullsBlankDepreciationsButNotOthers() { $c = new SnipeModel; $c->depreciation_id = ''; @@ -87,10 +67,7 @@ class SnipeModelTest extends BaseTest $this->assertTrue($c->depreciation_id == 4); } - /** - * @test - */ - public function it_nulls_blank_manufacturers_but_not_others() + public function testNullsBlankManufacturersButNotOthers() { $c = new SnipeModel; $c->manufacturer_id = ''; From 4f9ebf6cde33451e918d1b818c70d227ff4a1b59 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Tue, 7 Feb 2023 16:40:27 -0800 Subject: [PATCH 040/554] Fix array key --- tests/Unit/AccessoryTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Unit/AccessoryTest.php b/tests/Unit/AccessoryTest.php index dafcce663f..57b91b8f06 100644 --- a/tests/Unit/AccessoryTest.php +++ b/tests/Unit/AccessoryTest.php @@ -62,7 +62,7 @@ class AccessoryTest extends BaseTest $accessory = Accessory::factory()->appleBtKeyboard()->create( [ 'category_id' => Category::factory()->create(), - 'category_id' => Manufacturer::factory()->apple()->create() + 'manufacturer_id' => Manufacturer::factory()->apple()->create() ]); $this->assertInstanceOf(Manufacturer::class, $accessory->manufacturer); } From 81cc9f37009db6ef301d46e6d7af3df8588196cf Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Sun, 12 Feb 2023 08:23:50 -0600 Subject: [PATCH 041/554] Adds images to emailed user inventory report --- .../markdown/user-inventory.blade.php | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/resources/views/notifications/markdown/user-inventory.blade.php b/resources/views/notifications/markdown/user-inventory.blade.php index d597338549..1ff0704826 100644 --- a/resources/views/notifications/markdown/user-inventory.blade.php +++ b/resources/views/notifications/markdown/user-inventory.blade.php @@ -9,9 +9,18 @@ ## {{ $assets->count() }} {{ trans('general.assets') }} - + > @foreach($assets as $asset) - + + + + + @if (($snipeSettings->show_images_in_email =='1') && $asset->getImageUrl()) + + @endif + @endforeach
{{ trans('mail.name') }} {{ trans('mail.asset_tag') }}{{ trans('admin/hardware/table.serial') }}
{{ trans('mail.name') }} {{ trans('mail.asset_tag') }}{{ trans('admin/hardware/table.serial') }}
{{ $asset->present()->name }} {{ $asset->asset_tag }} {{ $asset->serial }}
{{ $asset->present()->name }} {{ $asset->asset_tag }} {{ $asset->serial }} + Asset +
@endif @@ -22,7 +31,14 @@ @foreach($accessories as $accessory) - + + + @if (($snipeSettings->show_images_in_email =='1') && $accessory->getImageUrl()) + + @endif + @endforeach
{{ trans('mail.name') }}
{{ $accessory->name }}
{{ $accessory->name }} + Accessory +
@endif @@ -33,7 +49,9 @@ @foreach($licenses as $license) - + + + @endforeach
{{ $license->name }}
{{ $license->name }}
@endif From 9a68a747a0c0bc410c8b90a8cd069c7069a07a30 Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Sun, 12 Feb 2023 11:59:56 -0600 Subject: [PATCH 042/554] Fix uneven tags --- resources/views/notifications/markdown/user-inventory.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/notifications/markdown/user-inventory.blade.php b/resources/views/notifications/markdown/user-inventory.blade.php index 1ff0704826..12bf880ac2 100644 --- a/resources/views/notifications/markdown/user-inventory.blade.php +++ b/resources/views/notifications/markdown/user-inventory.blade.php @@ -9,7 +9,7 @@ ## {{ $assets->count() }} {{ trans('general.assets') }} - > + @foreach($assets as $asset) From f0bf16d7848ff11b639d7573f7f47581d0b900b7 Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Sun, 12 Feb 2023 12:01:40 -0600 Subject: [PATCH 043/554] Fix more uneven tags --- resources/views/notifications/markdown/user-inventory.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/notifications/markdown/user-inventory.blade.php b/resources/views/notifications/markdown/user-inventory.blade.php index 12bf880ac2..c7dfba9a30 100644 --- a/resources/views/notifications/markdown/user-inventory.blade.php +++ b/resources/views/notifications/markdown/user-inventory.blade.php @@ -29,7 +29,7 @@ ## {{ $accessories->count() }} {{ trans('general.accessories') }}
{{ trans('mail.name') }} {{ trans('mail.asset_tag') }}{{ trans('admin/hardware/table.serial') }}
{{ trans('mail.name') }} {{ trans('mail.asset_tag') }}{{ trans('admin/hardware/table.serial') }}
{{ $asset->present()->name }}
- + @foreach($accessories as $accessory) From 228c59e6eda189043b9a0bb18a96eba6b0595990 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 13 Feb 2023 18:55:50 -0800 Subject: [PATCH 044/554] Bring phpunit.xml closer to default --- phpunit.xml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 9706518ab4..2372e19c36 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -6,18 +6,22 @@ - - ./tests/ - ./tests/Browser + + ./tests/Unit + + + ./tests/Feature + + + - - + From 8b183490ba9d0e08d37ed38b5afa585cbaaf879f Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 13 Feb 2023 18:56:22 -0800 Subject: [PATCH 045/554] Use "testing" environment for tests --- phpunit.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit.xml b/phpunit.xml index 2372e19c36..f205566085 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -14,7 +14,7 @@ - + From 3a2b54fd47a64b0f888075285158822766007ff9 Mon Sep 17 00:00:00 2001 From: Brady Wetherington Date: Tue, 31 Jan 2023 16:39:46 -0800 Subject: [PATCH 046/554] Add libsodium shim, and mark the sodium extension as 'optional' Trying to handle some composer.lock conflicts, as savely as possible. --- composer.json | 3 +- composer.lock | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++- upgrade.php | 8 ++++- 3 files changed, 95 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 4e71debc65..abcf675b1a 100644 --- a/composer.json +++ b/composer.json @@ -61,12 +61,13 @@ "nunomaduro/collision": "^5.4", "onelogin/php-saml": "^3.4", "paragonie/constant_time_encoding": "^2.3", - "symfony/polyfill-mbstring": "^1.22", + "paragonie/sodium_compat": "^1.19", "phpdocumentor/reflection-docblock": "^5.1", "phpspec/prophecy": "^1.10", "pragmarx/google2fa-laravel": "^1.3", "rollbar/rollbar-laravel": "^7.0", "spatie/laravel-backup": "^6.16", + "symfony/polyfill-mbstring": "^1.22", "tecnickcom/tc-lib-barcode": "^1.15", "unicodeveloper/laravel-password": "^1.0", "watson/validating": "^6.1" diff --git a/composer.lock b/composer.lock index b9022ba84f..525c6f8669 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,6 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9bd2bbbd4b08d23336364da3d3a4561a", "packages": [ { "name": "alek13/slack", @@ -6299,6 +6298,92 @@ }, "time": "2020-10-15T08:29:30+00:00" }, + { + "name": "paragonie/sodium_compat", + "version": "v1.19.0", + "source": { + "type": "git", + "url": "https://github.com/paragonie/sodium_compat.git", + "reference": "cb15e403ecbe6a6cc515f855c310eb6b1872a933" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/sodium_compat/zipball/cb15e403ecbe6a6cc515f855c310eb6b1872a933", + "reference": "cb15e403ecbe6a6cc515f855c310eb6b1872a933", + "shasum": "" + }, + "require": { + "paragonie/random_compat": ">=1", + "php": "^5.2.4|^5.3|^5.4|^5.5|^5.6|^7|^8" + }, + "require-dev": { + "phpunit/phpunit": "^3|^4|^5|^6|^7|^8|^9" + }, + "suggest": { + "ext-libsodium": "PHP < 7.0: Better performance, password hashing (Argon2i), secure memory management (memzero), and better security.", + "ext-sodium": "PHP >= 7.0: Better performance, password hashing (Argon2i), secure memory management (memzero), and better security." + }, + "type": "library", + "autoload": { + "files": [ + "autoload.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "ISC" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com" + }, + { + "name": "Frank Denis", + "email": "jedisct1@pureftpd.org" + } + ], + "description": "Pure PHP implementation of libsodium; uses the PHP extension if it exists", + "keywords": [ + "Authentication", + "BLAKE2b", + "ChaCha20", + "ChaCha20-Poly1305", + "Chapoly", + "Curve25519", + "Ed25519", + "EdDSA", + "Edwards-curve Digital Signature Algorithm", + "Elliptic Curve Diffie-Hellman", + "Poly1305", + "Pure-PHP cryptography", + "RFC 7748", + "RFC 8032", + "Salpoly", + "Salsa20", + "X25519", + "XChaCha20-Poly1305", + "XSalsa20-Poly1305", + "Xchacha20", + "Xsalsa20", + "aead", + "cryptography", + "ecdh", + "elliptic curve", + "elliptic curve cryptography", + "encryption", + "libsodium", + "php", + "public-key cryptography", + "secret-key cryptography", + "side-channel resistant" + ], + "support": { + "issues": "https://github.com/paragonie/sodium_compat/issues", + "source": "https://github.com/paragonie/sodium_compat/tree/v1.19.0" + }, + "time": "2022-09-26T03:40:35+00:00" + }, { "name": "phenx/php-font-lib", "version": "0.5.4", diff --git a/upgrade.php b/upgrade.php index ca71a61844..69ab2ffdab 100644 --- a/upgrade.php +++ b/upgrade.php @@ -176,6 +176,10 @@ $required_exts_array = 'zip', ]; +$recommended_exts_array = + [ + 'sodium', //note that extensions need to be in BOTH the $required_exts_array and this one to be 'optional' + ]; $ext_missing = ''; $ext_installed = ''; @@ -205,8 +209,10 @@ foreach ($required_exts_array as $required_ext) { } // If this isn't an either/or option, just add it to the string of errors conventionally - } else { + } elseif (!in_array($required_ext, $recommended_exts_array)){ $ext_missing .= '✘ MISSING PHP EXTENSION: '.$required_ext."\n"; + } else { + $ext_installed .= '- '.$required_ext." is *NOT* installed, but is recommended...\n"; } // The required extension string was found in the array of installed extensions - yay! From dfc2aa35f41575a67e77c378c2582566404f9c6a Mon Sep 17 00:00:00 2001 From: akemidx <116301219+akemidx@users.noreply.github.com> Date: Fri, 17 Feb 2023 12:51:58 -0500 Subject: [PATCH 047/554] Update general.php --- resources/lang/en/admin/users/general.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/lang/en/admin/users/general.php b/resources/lang/en/admin/users/general.php index 96e283c159..d58a0bc673 100644 --- a/resources/lang/en/admin/users/general.php +++ b/resources/lang/en/admin/users/general.php @@ -42,8 +42,8 @@ return [ 'remote_help' => 'This can be useful if you need to filter by remote users who never or rarely come into your physical locations.', 'not_remote_label' => 'This is not a remote user', 'create_user' => 'Create a user', - 'create_user_page_explaination' => 'This is the account information you will use to access the site for the first time.', + 'create_user_page_explanation' => 'This is the account information you will use to access the site for the first time.', 'email_credentials' => 'Email credentials', 'email_credentials_text' => 'Email my credentials to the email address above', 'next_save_user' => 'Next: Save User', -]; \ No newline at end of file +]; From f33b6a3e26316a2a1c0a89c02079c39a7f937d91 Mon Sep 17 00:00:00 2001 From: akemidx <116301219+akemidx@users.noreply.github.com> Date: Fri, 17 Feb 2023 12:52:54 -0500 Subject: [PATCH 048/554] Update user.blade.php --- resources/views/setup/user.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/setup/user.blade.php b/resources/views/setup/user.blade.php index b6ff3293dc..a45d37a3e0 100644 --- a/resources/views/setup/user.blade.php +++ b/resources/views/setup/user.blade.php @@ -8,7 +8,7 @@ {{-- Page content --}} @section('content') -

{{ trans('admin/user/general.create_user_page_explaination') }}

+

{{ trans('admin/user/general.create_user_page_explanation') }}

{{ csrf_field() }} From 6e994c209f81b700d2ff628a813972fceda8f915 Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Sun, 19 Feb 2023 12:31:10 -0600 Subject: [PATCH 049/554] Adds setter to model Asset class for expected checkin --- app/Models/Asset.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/Models/Asset.php b/app/Models/Asset.php index e0908c0894..386650cac6 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -186,6 +186,14 @@ class Asset extends Depreciable 'model.manufacturer' => ['name'], ]; + // To properly set the expected checkin as Y-m-d + public function setExpectedCheckinAttribute($value) + { + if ($value == '') { + $value = null; + } + $this->attributes['expected_checkin'] = $value; + } /** * This handles the custom field validation for assets From d2ede75de898a6d765e11319fba32cfa0c46e3bd Mon Sep 17 00:00:00 2001 From: Andrew Savinykh <658865+AndrewSav@users.noreply.github.com> Date: Mon, 20 Feb 2023 22:19:18 +1300 Subject: [PATCH 050/554] fixes #12532 adds version endpoint --- routes/api.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/routes/api.php b/routes/api.php index 37bc3baa8d..2429ffa853 100644 --- a/routes/api.php +++ b/routes/api.php @@ -1162,6 +1162,17 @@ Route::group(['prefix' => 'v1', 'middleware' => ['api', 'throttle:api']], functi )->name('api.activity.index'); }); // end reports api routes + /** + * Version API routes + */ + + Route::get('/version', function () { + return response()->json( + [ + 'version' => config('version.app_version'), + ], 200); + }); // end version api routes + Route::fallback(function () { return response()->json( @@ -1172,5 +1183,4 @@ Route::group(['prefix' => 'v1', 'middleware' => ['api', 'throttle:api']], functi ], 404); }); // end fallback routes - }); // end API routes From d494afcf01a1683a2a712215020ecad1c3e14c45 Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Tue, 21 Feb 2023 21:24:19 -0600 Subject: [PATCH 051/554] Add order by clause, to ensure assets and accessories are in order in the report --- app/Models/User.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/User.php b/app/Models/User.php index 34c0af6b2e..606b83b973 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -285,7 +285,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo */ public function assets() { - return $this->morphMany(\App\Models\Asset::class, 'assigned', 'assigned_type', 'assigned_to')->withTrashed(); + return $this->morphMany(\App\Models\Asset::class, 'assigned', 'assigned_type', 'assigned_to')->withTrashed()->orderBy('id'); } /** @@ -313,7 +313,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo public function accessories() { return $this->belongsToMany(\App\Models\Accessory::class, 'accessories_users', 'assigned_to', 'accessory_id') - ->withPivot('id', 'created_at', 'note')->withTrashed(); + ->withPivot('id', 'created_at', 'note')->withTrashed()->orderBy('accessory_id'); } /** From aae21066585ac11fdfca9b7b8a98a7357f29a310 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 22 Feb 2023 12:02:14 -0800 Subject: [PATCH 052/554] Use existing language translation string --- resources/lang/en/admin/companies/general.php | 1 - resources/views/hardware/checkout.blade.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/resources/lang/en/admin/companies/general.php b/resources/lang/en/admin/companies/general.php index 6ad64db576..37781012ba 100644 --- a/resources/lang/en/admin/companies/general.php +++ b/resources/lang/en/admin/companies/general.php @@ -1,7 +1,6 @@ 'Company', 'select_company' => 'Select Company', 'about_companies' => 'About Companies', 'about_companies_description' => ' You can use companies as a simple informative field, or you can use them to restrict asset visibility and availability to users with a specific company by enabling Full Company Support in your Admin Settings.', diff --git a/resources/views/hardware/checkout.blade.php b/resources/views/hardware/checkout.blade.php index 6b5d337b73..3bfecaa1da 100755 --- a/resources/views/hardware/checkout.blade.php +++ b/resources/views/hardware/checkout.blade.php @@ -28,7 +28,7 @@ {{csrf_field()}} @if ($asset->company && $asset->company->name)
- {{ Form::label('model', trans('admin/companies/general.company'), array('class' => 'col-md-3 control-label')) }} + {{ Form::label('model', trans('general.company'), array('class' => 'col-md-3 control-label')) }}

{{ $asset->company->name }} From 13ed2a05a3b819fd05a328902f197dfe8c822462 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 21 Feb 2023 19:51:31 -0800 Subject: [PATCH 053/554] Add @AndrewSav as a contributor --- .all-contributorsrc | 9 +++++++++ README.md | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 547fd4539e..82ae115c80 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2837,6 +2837,15 @@ "contributions": [ "code" ] + }, + { + "login": "AndrewSav", + "name": "Andrew Savinykh", + "avatar_url": "https://avatars.githubusercontent.com/u/658865?v=4", + "profile": "https://github.com/AndrewSav", + "contributions": [ + "code" + ] } ] } diff --git a/README.md b/README.md index 1818aa1f82..a881f3a3a7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ ![Build Status](https://app.chipperci.com/projects/0e5f8979-31eb-4ee6-9abf-050b76ab0383/status/master) [![Crowdin](https://d322cqt584bo4o.cloudfront.net/snipe-it/localized.svg)](https://crowdin.com/project/snipe-it) [![Docker Pulls](https://img.shields.io/docker/pulls/snipe/snipe-it.svg)](https://hub.docker.com/r/snipe/snipe-it/) [![Twitter Follow](https://img.shields.io/twitter/follow/snipeitapp.svg?style=social)](https://twitter.com/snipeitapp) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/553ce52037fc43ea99149785afcfe641)](https://www.codacy.com/app/snipe/snipe-it?utm_source=github.com&utm_medium=referral&utm_content=snipe/snipe-it&utm_campaign=Badge_Grade) -[![All Contributors](https://img.shields.io/badge/all_contributors-312-orange.svg?style=flat-square)](#contributors) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/yZFtShAcKk) [![huntr](https://cdn.huntr.dev/huntr_security_badge_mono.svg)](https://huntr.dev) +[![All Contributors](https://img.shields.io/badge/all_contributors-313-orange.svg?style=flat-square)](#contributors) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/yZFtShAcKk) [![huntr](https://cdn.huntr.dev/huntr_security_badge_mono.svg)](https://huntr.dev) ## Snipe-IT - Open Source Asset Management System @@ -140,7 +140,7 @@ Thanks goes to all of these wonderful people ([emoji key](https://github.com/ken | [
Christian Weirich](https://github.com/chrisweirich)
[💻](https://github.com/snipe/snipe-it/commits?author=chrisweirich "Code") | [
denzfarid](https://github.com/denzfarid)
| [
ntbutler-nbcs](https://github.com/ntbutler-nbcs)
[💻](https://github.com/snipe/snipe-it/commits?author=ntbutler-nbcs "Code") | [
Naveen](https://naveensrinivasan.dev)
[💻](https://github.com/snipe/snipe-it/commits?author=naveensrinivasan "Code") | [
Mike Roquemore](https://github.com/mikeroq)
[💻](https://github.com/snipe/snipe-it/commits?author=mikeroq "Code") | [
Daniel Reeder](https://github.com/reederda)
[ðŸŒ](#translation-reederda "Translation") [ðŸŒ](#translation-reederda "Translation") [💻](https://github.com/snipe/snipe-it/commits?author=reederda "Code") | [
vickyjaura183](https://github.com/vickyjaura183)
[💻](https://github.com/snipe/snipe-it/commits?author=vickyjaura183 "Code") | | [
Peace](https://github.com/julian-piehl)
[💻](https://github.com/snipe/snipe-it/commits?author=julian-piehl "Code") | [
Kyle Gordon](https://github.com/kylegordon)
[💻](https://github.com/snipe/snipe-it/commits?author=kylegordon "Code") | [
Katharina Drexel](http://www.bfh.ch)
[💻](https://github.com/snipe/snipe-it/commits?author=sunflowerbofh "Code") | [
David Sferruzza](https://david.sferruzza.fr/)
[💻](https://github.com/snipe/snipe-it/commits?author=dsferruzza "Code") | [
Rick Nelson](https://github.com/rnelsonee)
[💻](https://github.com/snipe/snipe-it/commits?author=rnelsonee "Code") | [
BasO12](https://github.com/BasO12)
[💻](https://github.com/snipe/snipe-it/commits?author=BasO12 "Code") | [
Vautia](https://github.com/Vautia)
[💻](https://github.com/snipe/snipe-it/commits?author=Vautia "Code") | | [
Chris Hartjes](http://www.littlehart.net/atthekeyboard)
[💻](https://github.com/snipe/snipe-it/commits?author=chartjes "Code") | [
geo-chen](https://github.com/geo-chen)
[💻](https://github.com/snipe/snipe-it/commits?author=geo-chen "Code") | [
Phan Nguyen](https://github.com/nh314)
[💻](https://github.com/snipe/snipe-it/commits?author=nh314 "Code") | [
Iisakki Jaakkola](https://github.com/StarlessNights)
[💻](https://github.com/snipe/snipe-it/commits?author=StarlessNights "Code") | [
Ikko Ashimine](https://bandism.net/)
[💻](https://github.com/snipe/snipe-it/commits?author=eltociear "Code") | [
Lukas Fehling](https://github.com/lukasfehling)
[💻](https://github.com/snipe/snipe-it/commits?author=lukasfehling "Code") | [
Fernando Almeida](https://github.com/fernando-almeida)
[💻](https://github.com/snipe/snipe-it/commits?author=fernando-almeida "Code") | -| [
akemidx](https://github.com/akemidx)
[💻](https://github.com/snipe/snipe-it/commits?author=akemidx "Code") | [
Oguz Bilgic](http://oguz.site)
[💻](https://github.com/snipe/snipe-it/commits?author=oguzbilgic "Code") | [
Scooter Crawford](https://github.com/scoo73r)
[💻](https://github.com/snipe/snipe-it/commits?author=scoo73r "Code") | [
subdriven](https://github.com/subdriven)
[💻](https://github.com/snipe/snipe-it/commits?author=subdriven "Code") | +| [
akemidx](https://github.com/akemidx)
[💻](https://github.com/snipe/snipe-it/commits?author=akemidx "Code") | [
Oguz Bilgic](http://oguz.site)
[💻](https://github.com/snipe/snipe-it/commits?author=oguzbilgic "Code") | [
Scooter Crawford](https://github.com/scoo73r)
[💻](https://github.com/snipe/snipe-it/commits?author=scoo73r "Code") | [
subdriven](https://github.com/subdriven)
[💻](https://github.com/snipe/snipe-it/commits?author=subdriven "Code") | [
Andrew Savinykh](https://github.com/AndrewSav)
[💻](https://github.com/snipe/snipe-it/commits?author=AndrewSav "Code") | This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome! From 931ca98c02e22fe98c0a15e56383dffcc2d7fd95 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 22 Feb 2023 12:33:55 -0800 Subject: [PATCH 054/554] Remove middleware bypass --- app/Http/Middleware/SecurityHeaders.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/Http/Middleware/SecurityHeaders.php b/app/Http/Middleware/SecurityHeaders.php index f3e7ea7cfa..c9c5fd2872 100644 --- a/app/Http/Middleware/SecurityHeaders.php +++ b/app/Http/Middleware/SecurityHeaders.php @@ -23,9 +23,6 @@ class SecurityHeaders public function handle($request, Closure $next) { - if (App::environment(['testing', 'testing-ci'])) { - return $next($request); - } $this->removeUnwantedHeaders($this->unwantedHeaderList); $response = $next($request); From 7667b0a2167fb8a590da532c1301f0881d1bfd75 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 22 Feb 2023 12:34:35 -0800 Subject: [PATCH 055/554] Remove extra line --- app/Http/Middleware/SecurityHeaders.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Http/Middleware/SecurityHeaders.php b/app/Http/Middleware/SecurityHeaders.php index c9c5fd2872..cc1b5fe016 100644 --- a/app/Http/Middleware/SecurityHeaders.php +++ b/app/Http/Middleware/SecurityHeaders.php @@ -23,7 +23,6 @@ class SecurityHeaders public function handle($request, Closure $next) { - $this->removeUnwantedHeaders($this->unwantedHeaderList); $response = $next($request); From f63710fb5c49eb42ce1830bd8e8679d1b5415f57 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 22 Feb 2023 12:34:56 -0800 Subject: [PATCH 056/554] Remove unused import --- app/Http/Middleware/SecurityHeaders.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Http/Middleware/SecurityHeaders.php b/app/Http/Middleware/SecurityHeaders.php index cc1b5fe016..25f0461fcf 100644 --- a/app/Http/Middleware/SecurityHeaders.php +++ b/app/Http/Middleware/SecurityHeaders.php @@ -3,7 +3,6 @@ namespace App\Http\Middleware; use Closure; -use Illuminate\Support\Facades\App; class SecurityHeaders { From 6c8de181cf319238d7457feaa775a4b064f55760 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 22 Feb 2023 17:52:47 -0800 Subject: [PATCH 057/554] Properly close tag in mail template --- resources/views/notifications/markdown/user-inventory.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/notifications/markdown/user-inventory.blade.php b/resources/views/notifications/markdown/user-inventory.blade.php index c7dfba9a30..7b298dbc32 100644 --- a/resources/views/notifications/markdown/user-inventory.blade.php +++ b/resources/views/notifications/markdown/user-inventory.blade.php @@ -47,7 +47,7 @@ ## {{ $licenses->count() }} {{ trans('general.licenses') }}

{{ trans('mail.name') }}
{{ trans('mail.name') }}
{{ $accessory->name }}
- + @foreach($licenses as $license) From 0b408218b071fdc6aa67e17aabe2036211b1ada6 Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 23 Feb 2023 12:59:04 -0800 Subject: [PATCH 058/554] Update dompdf Signed-off-by: snipe --- composer.lock | 55 ++++++++++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/composer.lock b/composer.lock index 525c6f8669..c34d46ce69 100644 --- a/composer.lock +++ b/composer.lock @@ -4,6 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], + "content-hash": "590171872e4a6a29c78efde99fbbf00e", "packages": [ { "name": "alek13/slack", @@ -1809,24 +1810,24 @@ }, { "name": "dompdf/dompdf", - "version": "v2.0.0", + "version": "v2.0.3", "source": { "type": "git", "url": "https://github.com/dompdf/dompdf.git", - "reference": "79573d8b8a141ec8a17312515de8740eed014fa9" + "reference": "e8d2d5e37e8b0b30f0732a011295ab80680d7e85" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dompdf/dompdf/zipball/79573d8b8a141ec8a17312515de8740eed014fa9", - "reference": "79573d8b8a141ec8a17312515de8740eed014fa9", + "url": "https://api.github.com/repos/dompdf/dompdf/zipball/e8d2d5e37e8b0b30f0732a011295ab80680d7e85", + "reference": "e8d2d5e37e8b0b30f0732a011295ab80680d7e85", "shasum": "" }, "require": { "ext-dom": "*", "ext-mbstring": "*", "masterminds/html5": "^2.0", - "phenx/php-font-lib": "^0.5.4", - "phenx/php-svg-lib": "^0.3.3 || ^0.4.0", + "phenx/php-font-lib": ">=0.5.4 <1.0.0", + "phenx/php-svg-lib": ">=0.3.3 <1.0.0", "php": "^7.1 || ^8.0" }, "require-dev": { @@ -1857,25 +1858,17 @@ ], "authors": [ { - "name": "Fabien Ménager", - "email": "fabien.menager@gmail.com" - }, - { - "name": "Brian Sweeney", - "email": "eclecticgeek@gmail.com" - }, - { - "name": "Gabriel Bull", - "email": "me@gabrielbull.com" + "name": "The Dompdf Community", + "homepage": "https://github.com/dompdf/dompdf/blob/master/AUTHORS.md" } ], "description": "DOMPDF is a CSS 2.1 compliant HTML to PDF converter", "homepage": "https://github.com/dompdf/dompdf", "support": { "issues": "https://github.com/dompdf/dompdf/issues", - "source": "https://github.com/dompdf/dompdf/tree/v2.0.0" + "source": "https://github.com/dompdf/dompdf/tree/v2.0.3" }, - "time": "2022-06-21T21:14:57+00:00" + "time": "2023-02-07T12:51:48+00:00" }, { "name": "dragonmantank/cron-expression", @@ -5130,16 +5123,16 @@ }, { "name": "masterminds/html5", - "version": "2.7.5", + "version": "2.7.6", "source": { "type": "git", "url": "https://github.com/Masterminds/html5-php.git", - "reference": "f640ac1bdddff06ea333a920c95bbad8872429ab" + "reference": "897eb517a343a2281f11bc5556d6548db7d93947" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Masterminds/html5-php/zipball/f640ac1bdddff06ea333a920c95bbad8872429ab", - "reference": "f640ac1bdddff06ea333a920c95bbad8872429ab", + "url": "https://api.github.com/repos/Masterminds/html5-php/zipball/897eb517a343a2281f11bc5556d6548db7d93947", + "reference": "897eb517a343a2281f11bc5556d6548db7d93947", "shasum": "" }, "require": { @@ -5193,9 +5186,9 @@ ], "support": { "issues": "https://github.com/Masterminds/html5-php/issues", - "source": "https://github.com/Masterminds/html5-php/tree/2.7.5" + "source": "https://github.com/Masterminds/html5-php/tree/2.7.6" }, - "time": "2021-07-01T14:25:37+00:00" + "time": "2022-08-18T16:18:26+00:00" }, { "name": "maximebf/debugbar", @@ -6430,21 +6423,21 @@ }, { "name": "phenx/php-svg-lib", - "version": "0.4.1", + "version": "0.5.0", "source": { "type": "git", "url": "https://github.com/dompdf/php-svg-lib.git", - "reference": "4498b5df7b08e8469f0f8279651ea5de9626ed02" + "reference": "76876c6cf3080bcb6f249d7d59705108166a6685" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dompdf/php-svg-lib/zipball/4498b5df7b08e8469f0f8279651ea5de9626ed02", - "reference": "4498b5df7b08e8469f0f8279651ea5de9626ed02", + "url": "https://api.github.com/repos/dompdf/php-svg-lib/zipball/76876c6cf3080bcb6f249d7d59705108166a6685", + "reference": "76876c6cf3080bcb6f249d7d59705108166a6685", "shasum": "" }, "require": { "ext-mbstring": "*", - "php": "^7.1 || ^7.2 || ^7.3 || ^7.4 || ^8.0", + "php": "^7.1 || ^8.0", "sabberworm/php-css-parser": "^8.4" }, "require-dev": { @@ -6470,9 +6463,9 @@ "homepage": "https://github.com/PhenX/php-svg-lib", "support": { "issues": "https://github.com/dompdf/php-svg-lib/issues", - "source": "https://github.com/dompdf/php-svg-lib/tree/0.4.1" + "source": "https://github.com/dompdf/php-svg-lib/tree/0.5.0" }, - "time": "2022-03-07T12:52:04+00:00" + "time": "2022-09-06T12:16:56+00:00" }, { "name": "php-http/message-factory", From bdac0f16ceb5b7ecbf894b3692f09565140c06c6 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 23 Feb 2023 13:39:05 -0800 Subject: [PATCH 059/554] Set purchase date field to the correct format in asset factory --- database/factories/AssetFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/factories/AssetFactory.php b/database/factories/AssetFactory.php index 24021921b3..6f3cce8722 100644 --- a/database/factories/AssetFactory.php +++ b/database/factories/AssetFactory.php @@ -44,7 +44,7 @@ class AssetFactory extends Factory 'user_id' => 1, 'asset_tag' => $this->faker->unixTime('now'), 'notes' => 'Created by DB seeder', - 'purchase_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()), + 'purchase_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get())->format('Y-m-d'), 'purchase_cost' => $this->faker->randomFloat(2, '299.99', '2999.99'), 'order_number' => $this->faker->numberBetween(1000000, 50000000), 'supplier_id' => Supplier::all()->random()->id, From 6bd72125bda8698dc067c1ed914753bbfef917b0 Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Thu, 23 Feb 2023 22:31:41 -0600 Subject: [PATCH 060/554] Deletes problematic cast --- app/Models/License.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Models/License.php b/app/Models/License.php index b715adf180..94263ee0d8 100755 --- a/app/Models/License.php +++ b/app/Models/License.php @@ -36,7 +36,6 @@ class License extends Depreciable 'purchase_date' => 'datetime', 'expiration_date' => 'datetime', 'termination_date' => 'datetime', - 'seats' => 'integer', 'category_id' => 'integer', 'company_id' => 'integer', ]; From 51efd9b4137b1f90677d5d3fa24e0c8bd434b23a Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Fri, 24 Feb 2023 10:59:31 -0600 Subject: [PATCH 061/554] Adjust the date format for purchase_date field --- app/Importer/ItemImporter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Importer/ItemImporter.php b/app/Importer/ItemImporter.php index d332200368..6a8fe07947 100644 --- a/app/Importer/ItemImporter.php +++ b/app/Importer/ItemImporter.php @@ -74,7 +74,7 @@ class ItemImporter extends Importer $this->item['purchase_date'] = null; if ($this->findCsvMatch($row, 'purchase_date') != '') { - $this->item['purchase_date'] = date('Y-m-d 00:00:01', strtotime($this->findCsvMatch($row, 'purchase_date'))); + $this->item['purchase_date'] = date('Y-m-d', strtotime($this->findCsvMatch($row, 'purchase_date'))); } $this->item['last_audit_date'] = null; From 3e47d9e689efead37cfad1f4048d03e70f84d5f1 Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 24 Feb 2023 09:54:46 -0800 Subject: [PATCH 062/554] Pass the existing asset name to the bulk checkout form Signed-off-by: snipe --- app/Http/Controllers/Assets/BulkAssetsController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Assets/BulkAssetsController.php b/app/Http/Controllers/Assets/BulkAssetsController.php index ca48d91f43..bcaa3900b6 100644 --- a/app/Http/Controllers/Assets/BulkAssetsController.php +++ b/app/Http/Controllers/Assets/BulkAssetsController.php @@ -288,7 +288,8 @@ class BulkAssetsController extends Controller foreach ($asset_ids as $asset_id) { $asset = Asset::findOrFail($asset_id); $this->authorize('checkout', $asset); - $error = $asset->checkOut($target, $admin, $checkout_at, $expected_checkin, e($request->get('note')), null); + + $error = $asset->checkOut($target, $admin, $checkout_at, $expected_checkin, e($request->get('note')), $asset->name, null); if ($target->location_id != '') { $asset->location_id = $target->location_id; From 95501bf57cd7fb1ba9c857bc5db00fa68576e6c9 Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 24 Feb 2023 09:57:25 -0800 Subject: [PATCH 063/554] Bumped hash Signed-off-by: snipe --- config/version.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/version.php b/config/version.php index f111cfb8d1..1eeb07c2c5 100644 --- a/config/version.php +++ b/config/version.php @@ -1,10 +1,10 @@ 'v6.0.14', - 'full_app_version' => 'v6.0.14 - build 9161-g799c9c910', - 'build_version' => '9161', + 'full_app_version' => 'v6.0.14 - build 9599-g1415c8c6e', + 'build_version' => '9599', 'prerelease_version' => '', - 'hash_version' => 'g799c9c910', - 'full_hash' => 'v6.0.14-117-g799c9c910', - 'branch' => 'master', + 'hash_version' => 'g1415c8c6e', + 'full_hash' => 'v6.0.14-555-g1415c8c6e', + 'branch' => 'develop', ); \ No newline at end of file From 059190f002346b230e20b924b6be58d6ec69d90e Mon Sep 17 00:00:00 2001 From: Brady Wetherington Date: Sun, 26 Feb 2023 11:29:10 -0800 Subject: [PATCH 064/554] Upgrade Acorn --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index b03e7eb62c..711ca8f2d7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2033,9 +2033,9 @@ } }, "acorn": { - "version": "8.8.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.0.tgz", - "integrity": "sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==" + "version": "8.8.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", + "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==" }, "acorn-import-assertions": { "version": "1.8.0", diff --git a/package.json b/package.json index 27f1b698a9..f64399454f 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ }, "dependencies": { "@fortawesome/fontawesome-free": "^6.2.1", - "acorn": "^8.8.0", + "acorn": "^8.8.2", "acorn-import-assertions": "^1.8.0", "admin-lte": "^2.4.18", "ajv": "^6.12.6", From e8fc895e51584839e06b87fd5949954170d67688 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Mon, 27 Feb 2023 09:19:59 -0800 Subject: [PATCH 065/554] "adds variables, but still not working" --- app/Http/Livewire/SlackSettingsForm.php | 9 +++ resources/lang/en/admin/settings/general.php | 20 ++--- .../livewire/slack-settings-form.blade.php | 81 +++++++++++++++++-- resources/views/settings/slack.blade.php | 36 ++------- 4 files changed, 100 insertions(+), 46 deletions(-) diff --git a/app/Http/Livewire/SlackSettingsForm.php b/app/Http/Livewire/SlackSettingsForm.php index cd34b450a8..6df4bdeea3 100644 --- a/app/Http/Livewire/SlackSettingsForm.php +++ b/app/Http/Livewire/SlackSettingsForm.php @@ -12,6 +12,12 @@ class SlackSettingsForm extends Component public $slack_channel; public $slack_botname; public $isDisabled ='disabled' ; + public $integration_app= 'WORKING'; + public $webhook_link; + public $webhook_selected; + public $webhook_options= ['Slack'=>'fab fa-slack', 'Discord'=>'fab fa-discord', 'Rocket.Chat'=>'fab fa-rocketchat']; + public $webhook; + public $icon; public Setting $setting; @@ -24,6 +30,8 @@ class SlackSettingsForm extends Component public function mount(){ $this->setting = Setting::getSettings(); + $this->icon =''; + $this->webhook = $this->webhook_selected; $this->slack_endpoint = $this->setting->slack_endpoint; $this->slack_channel = $this->setting->slack_channel; $this->slack_botname = $this->setting->slack_botname; @@ -31,6 +39,7 @@ class SlackSettingsForm extends Component } public function updated($field){ + $this->webhook = $this->webhook_selected; $this->validateOnly($field ,$this->rules); } diff --git a/resources/lang/en/admin/settings/general.php b/resources/lang/en/admin/settings/general.php index 70c4932fda..d48714d7dd 100644 --- a/resources/lang/en/admin/settings/general.php +++ b/resources/lang/en/admin/settings/general.php @@ -198,16 +198,16 @@ return [ 'show_images_in_email' => 'Show images in emails', 'show_images_in_email_help' => 'Uncheck this box if your Snipe-IT installation is behind a VPN or closed network and users outside the network will not be able to load images served from this installation in their emails.', 'site_name' => 'Site Name', - 'slack' => 'Slack', - 'slack_title' => 'Update Slack Settings', - 'slack_help' => 'Slack settings', - 'slack_botname' => 'Slack Botname', - 'slack_channel' => 'Slack Channel', - 'slack_endpoint' => 'Slack Endpoint', - 'slack_integration' => 'Slack Settings', - 'slack_integration_help' => 'Slack integration is optional, however the endpoint and channel are required if you wish to use it. To configure Slack integration, you must first create an incoming webhook on your Slack account. Click on the Test Slack Integration button to confirm your settings are correct before saving. ', - 'slack_integration_help_button' => 'Once you have saved your Slack information, a test button will appear.', - 'slack_test_help' => 'Test whether your Slack integration is configured correctly. YOU MUST SAVE YOUR UPDATED SLACK SETTINGS FIRST.', + 'slack' => ':app', + 'slack_title' => 'Update :app Settings', + 'slack_help' => ':app settings', + 'slack_botname' => ':app Botname', + 'slack_channel' => ':app Channel', + 'slack_endpoint' => ':app Endpoint', + 'slack_integration' => ':app Settings', + 'slack_integration_help' => ':app integration is optional, however the endpoint and channel are required if you wish to use it. To configure :app integration, you must first create an incoming webhook on your :app account. Click on the Test :app Integration button to confirm your settings are correct before saving. ', + 'slack_integration_help_button' => 'Once you have saved your :app information, a test button will appear.', + 'slack_test_help' => 'Test whether your :app integration is configured correctly. YOU MUST SAVE YOUR UPDATED :app SETTINGS FIRST.', 'snipe_version' => 'Snipe-IT version', 'support_footer' => 'Support Footer Links ', 'support_footer_help' => 'Specify who sees the links to the Snipe-IT Support info and Users Manual', diff --git a/resources/views/livewire/slack-settings-form.blade.php b/resources/views/livewire/slack-settings-form.blade.php index 6d48220ca8..4878998ec8 100644 --- a/resources/views/livewire/slack-settings-form.blade.php +++ b/resources/views/livewire/slack-settings-form.blade.php @@ -1,4 +1,32 @@ +{{-- Page title --}} +@section('title') + {{ trans('admin/settings/general.slack_title', ['app' => $integration_app ]) }} + @parent +@stop +@section('header_right') + {{ trans('general.back') }} +@stop + + +{{-- Page content --}} +@section('content') + +
+
+
+
+

+ {{ trans('admin/settings/general.slack',['app' => $integration_app ]) }} +

+
+
+
+

+ {!! trans('admin/settings/general.slack_integration_help',array('slack_link' => $webhook_link, 'app' => $integration_app )) !!} +

+
+
@if (session()->has('save')) @@ -22,14 +50,32 @@ {{session('message')}}
@endif - +
+
+ +
+
+ + {{var_dump($webhook_selected)}} +



+
{{csrf_field()}}
- {{ Form::label('slack_endpoint', trans('admin/settings/general.slack_endpoint')) }} + {{ Form::label('slack_endpoint', trans('admin/settings/general.slack_endpoint',['app' => $integration_app ])) }}
@if (config('app.lock_passwords')===true) @@ -45,7 +91,7 @@
- {{ Form::label('slack_channel', trans('admin/settings/general.slack_channel')) }} + {{ Form::label('slack_channel', trans('admin/settings/general.slack_channel',['app' => $integration_app ])) }}
@if (config('app.lock_passwords')===true) @@ -62,7 +108,7 @@
- {{ Form::label('slack_botname', trans('admin/settings/general.slack_botname')) }} + {{ Form::label('slack_botname', trans('admin/settings/general.slack_botname',['app' => $integration_app ])) }}
@if (config('app.lock_passwords')===true) @@ -80,7 +126,7 @@ @if($slack_endpoint != null && $slack_channel != null) @@ -95,5 +141,30 @@
+
+
+ +@stop + +@push('scripts') + +@endpush diff --git a/resources/views/settings/slack.blade.php b/resources/views/settings/slack.blade.php index a5cbd8d0b3..fac07c7ccd 100644 --- a/resources/views/settings/slack.blade.php +++ b/resources/views/settings/slack.blade.php @@ -1,44 +1,18 @@ @extends('layouts/default') -{{-- Page title --}} -@section('title') - {{ trans('admin/settings/general.slack_title') }} - @parent -@stop - -@section('header_right') - {{ trans('general.back') }} -@stop -{{-- Page content --}} -@section('content') -
-
-
-
-

- {{ trans('admin/settings/general.slack') }} -

-
-
-
-

- {!! trans('admin/settings/general.slack_integration_help',array('slack_link' => 'https://my.slack.com/services/new/incoming-webhook')) !!} -

-
-
+ @livewire('slack-settings-form') -
-
- - -@stop + + + + From 96c851468c2f800b4f8002b13376999f2ace7d96 Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 27 Feb 2023 12:04:46 -0800 Subject: [PATCH 066/554] Added max results limit to report index Signed-off-by: snipe --- app/Http/Controllers/Api/ReportsController.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/ReportsController.php b/app/Http/Controllers/Api/ReportsController.php index 7ac704e2f2..f42a2d0f81 100644 --- a/app/Http/Controllers/Api/ReportsController.php +++ b/app/Http/Controllers/Api/ReportsController.php @@ -57,8 +57,12 @@ class ReportsController extends Controller $sort = in_array($request->input('sort'), $allowed_columns) ? e($request->input('sort')) : 'created_at'; $order = ($request->input('order') == 'asc') ? 'asc' : 'desc'; $offset = request('offset', 0); - $limit = request('limit', 50); $total = $actionlogs->count(); + + // Check to make sure the limit is not higher than the max allowed + ((config('app.max_results') >= $request->input('limit')) && ($request->filled('limit'))) ? $limit = $request->input('limit') : $limit = config('app.max_results'); + + $actionlogs = $actionlogs->orderBy($sort, $order)->skip($offset)->take($limit)->get(); return response()->json((new ActionlogsTransformer)->transformActionlogs($actionlogs, $total), 200, ['Content-Type' => 'application/json;charset=utf8'], JSON_UNESCAPED_UNICODE); From c7106a1df285a10808fd8107300dc5f77cd90b27 Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 27 Feb 2023 13:24:09 -0800 Subject: [PATCH 067/554] Added table aliases to fix ambiguous SQL clause Signed-off-by: snipe --- app/Models/Asset.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Models/Asset.php b/app/Models/Asset.php index 725d1eee81..37e932cfa1 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -1641,9 +1641,9 @@ class Asset extends Depreciable */ public function scopeOrderManufacturer($query, $order) { - return $query->join('models', 'assets.model_id', '=', 'models.id') - ->join('manufacturers', 'models.manufacturer_id', '=', 'manufacturers.id') - ->orderBy('manufacturers.name', $order); + return $query->join('models as order_asset_model', 'assets.model_id', '=', 'order_asset_model.id') + ->join('manufacturers as manufacturer_order', 'order_asset_model.manufacturer_id', '=', 'manufacturer_order.id') + ->orderBy('manufacturer_order.name', $order); } /** From 0a085af0a0affd586cceab02e8ca1b2c5e0b9d43 Mon Sep 17 00:00:00 2001 From: Brady Wetherington Date: Thu, 13 Jan 2022 01:19:13 -0800 Subject: [PATCH 068/554] Getting the basic wiring of the importer over into Livewire WIP: Wiring up more and more of the actions on the importer Files now upload okay, a little glitchy on the display-side though add to readmes so i dont forget --- FIXME.txt | 11 + app/Http/Controllers/ImportsController.php | 4 +- app/Http/Livewire/Importer.php | 45 +++ app/Http/Livewire/ImporterFile.php | 151 ++++++++ app/Models/Setting.php | 3 +- resources/assets/js/components/alert.vue | 36 -- .../components/importer/importer-errors.vue | 42 --- .../js/components/importer/importer-file.vue | 325 ------------------ .../js/components/importer/importer.vue | 130 ------- resources/assets/js/vue.js | 9 +- resources/views/importer/import.blade.php | 104 +----- .../views/livewire/importer-file.blade.php | 207 +++++++++++ resources/views/livewire/importer.blade.php | 212 ++++++++++++ 13 files changed, 641 insertions(+), 638 deletions(-) create mode 100644 FIXME.txt create mode 100644 app/Http/Livewire/Importer.php create mode 100644 app/Http/Livewire/ImporterFile.php delete mode 100644 resources/assets/js/components/alert.vue delete mode 100644 resources/assets/js/components/importer/importer-errors.vue delete mode 100644 resources/assets/js/components/importer/importer-file.vue delete mode 100644 resources/assets/js/components/importer/importer.vue create mode 100644 resources/views/livewire/importer-file.blade.php create mode 100644 resources/views/livewire/importer.blade.php diff --git a/FIXME.txt b/FIXME.txt new file mode 100644 index 0000000000..8f95bcb814 --- /dev/null +++ b/FIXME.txt @@ -0,0 +1,11 @@ +remove Ziggy +and ziggy-js too +And what is /public/js/snipeit.js ? That looks like a generated file + +The 'flash' (forced refresh/fake refresh) on uploads is dumb +I'm not sure if the order on the uploaded files is right? +The Livewire.first() thing is still dumb (but Id o'nt know that we can fix it). + +Deletes need to work (I got this working before using $.ajax; it's not even hard) + +Then mapping and so on. \ No newline at end of file diff --git a/app/Http/Controllers/ImportsController.php b/app/Http/Controllers/ImportsController.php index 5c2ca6175b..342203846b 100644 --- a/app/Http/Controllers/ImportsController.php +++ b/app/Http/Controllers/ImportsController.php @@ -15,8 +15,8 @@ class ImportsController extends Controller public function index() { $this->authorize('import'); - $imports = (new ImportsTransformer)->transformImports(Import::latest()->get()); + // $imports = (new ImportsTransformer)->transformImports(Import::latest()->get()); - return view('importer/import')->with('imports', $imports); + return view('importer/import'); //->with('imports', $imports); } } diff --git a/app/Http/Livewire/Importer.php b/app/Http/Livewire/Importer.php new file mode 100644 index 0000000000..1bcd501ba1 --- /dev/null +++ b/app/Http/Livewire/Importer.php @@ -0,0 +1,45 @@ + 'required|string', + 'files.*.created_at' => 'required|string', + 'files.*.filesize' => 'required|integer' + ]; + + public function mount() + { + //$this->files = Import::all(); // this *SHOULD* be how it works, but...it doesn't? + $this->forcerefresh = 0; + } + + public function test() + { + Log::error("Test Button Clicked!!!!"); + } + + public function toggleEvent($id) + { + Log::error("toggled on: ".$id); + $this->processDetails = Import::find($id); + } + + public function render() + { + $this->files = Import::all(); //HACK - slows down renders. + return view('livewire.importer'); + } +} diff --git a/app/Http/Livewire/ImporterFile.php b/app/Http/Livewire/ImporterFile.php new file mode 100644 index 0000000000..552db98371 --- /dev/null +++ b/app/Http/Livewire/ImporterFile.php @@ -0,0 +1,151 @@ + 'Category', + 'company' => 'Company', + 'email' => 'Email', + 'item_name' => 'Item Name', + 'location' => 'Location', + 'maintained' => 'Maintained', + 'manufacturer' => 'Manufacturer', + 'notes' => 'Notes', + 'order_number' => 'Order Number', + 'purchase_cost' => 'Purchase Cost', + 'purchase_date' => 'Purchase Date', + 'quantity' => 'Quantity', + 'requestable' => 'Requestable', + 'serial' => 'Serial Number', + 'supplier' => 'Supplier', + 'username' => 'Username', + 'department' => 'Department', +]; + +$accessories = [ + 'model_number' => 'Model Number', +]; + +$assets = [ + 'asset_tag' => 'Asset Tag', + 'asset_model' => 'Model Name', + 'checkout_class' => 'Checkout Type', + 'checkout_location' => 'Checkout Location', + 'image' => 'Image Filename', + 'model_number' => 'Model Number', + 'full_name' => 'Full Name', + 'status' => 'Status', + 'warranty_months' => 'Warranty Months', +]; + +$consumables = [ + 'item_no' => "Item Number", + 'model_number' => "Model Number", + 'min_amt' => "Minimum Quantity", +]; + +$licenses = [ + 'asset_tag' => 'Assigned To Asset', + 'expiration_date' => 'Expiration Date', + 'full_name' => 'Full Name', + 'license_email' => 'Licensed To Email', + 'license_name' => 'Licensed To Name', + 'purchase_order' => 'Purchase Order', + 'reassignable' => 'Reassignable', + 'seats' => 'Seats', +]; + +$users = [ + 'employee_num' => 'Employee Number', + 'first_name' => 'First Name', + 'jobtitle' => 'Job Title', + 'last_name' => 'Last Name', + 'phone_number' => 'Phone Number', + 'manager_first_name' => 'Manager First Name', + 'manager_last_name' => 'Manager Last Name', + 'activated' => 'Activated', + 'address' => 'Address', + 'city' => 'City', + 'state' => 'State', + 'country' => 'Country', +]; + +class ImporterFile extends Component +{ + public $activeFile; //should this get auto-filled? + public $customFields; + public $importTypes; + public $columnOptions; + public $importType; // too similar to 'TypeS'? + + private function getColumns($type) + { + global $general, $accessories, $assets, $consumables, $licenses, $users; + + $customFields = []; + foreach($this->customFields AS $field) { + $customFields[$field->id] = $field->name; + } + + switch($type) { + case 'asset': + $results = $general + $assets + $customFields; + break; + case 'accessory': + $results = $general + $accessories; + break; + case 'consumable': + $results = $general + $consumables; + break; + case 'license': + $results = $general + $licenses; + break; + case 'user': + $results = $general + $users; + break; + default: + $results = $general; + } + asort($results); // FIXME - this isn't sorting right yet. + return $results; + } + + public function mount() + { + $this->customFields = CustomField::all(); + + $this->importTypes = [ + 'asset' => 'Assets', // TODO - translate! + 'accessory' => 'Accessories', + 'consumable' => 'Consumables', + 'component' => 'Components', + 'license' => 'Licenses', + 'user' => 'Users' + ]; + Log::error("import types: ".print_r($this->importTypes,true)); + + $columnOptions = []; + $this->columnOptions[''] = $this->getColumns(''); //blank mode? I don't know what this is supposed to mean + foreach($this->importTypes AS $type => $name) { + $this->columnOptions[$type] = $this->getColumns($type); + } + } + + public function changeTypes() + { + Log::error("type changed!"); + } + + public function render() + { + return view('livewire.importer-file'); + } +} diff --git a/app/Models/Setting.php b/app/Models/Setting.php index fd02992f75..b0b4f2490f 100755 --- a/app/Models/Setting.php +++ b/app/Models/Setting.php @@ -217,7 +217,7 @@ class Setting extends Model * * @author Mogilev Arseny */ - public static function fileSizeConvert($bytes): string + public static function fileSizeConvert(int $bytes): string { $result = 0; $bytes = floatval($bytes); @@ -244,6 +244,7 @@ class Setting extends Model ], ]; + $result = $bytes; // handles the zero case foreach ($arBytes as $arItem) { if ($bytes >= $arItem['VALUE']) { $result = $bytes / $arItem['VALUE']; diff --git a/resources/assets/js/components/alert.vue b/resources/assets/js/components/alert.vue deleted file mode 100644 index 1a20334656..0000000000 --- a/resources/assets/js/components/alert.vue +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - diff --git a/resources/assets/js/components/importer/importer-errors.vue b/resources/assets/js/components/importer/importer-errors.vue deleted file mode 100644 index adc6841d4d..0000000000 --- a/resources/assets/js/components/importer/importer-errors.vue +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - diff --git a/resources/assets/js/components/importer/importer-file.vue b/resources/assets/js/components/importer/importer-file.vue deleted file mode 100644 index eeeed7c722..0000000000 --- a/resources/assets/js/components/importer/importer-file.vue +++ /dev/null @@ -1,325 +0,0 @@ - - - diff --git a/resources/assets/js/components/importer/importer.vue b/resources/assets/js/components/importer/importer.vue deleted file mode 100644 index 474f8f1451..0000000000 --- a/resources/assets/js/components/importer/importer.vue +++ /dev/null @@ -1,130 +0,0 @@ - - - diff --git a/resources/assets/js/vue.js b/resources/assets/js/vue.js index 65cd4393c1..a5b903e51c 100644 --- a/resources/assets/js/vue.js +++ b/resources/assets/js/vue.js @@ -26,10 +26,11 @@ Vue.component( require('./components/passport/PersonalAccessTokens.vue').default ); -Vue.component( - 'importer', - require('./components/importer/importer.vue').default -); +// This component has been removed and replaced with a Livewire implementation +// Vue.component( +// 'importer', +// require('./components/importer/importer.vue').default +// ); // This component has been removed and replaced with a Livewire implementation // Vue.component( diff --git a/resources/views/importer/import.blade.php b/resources/views/importer/import.blade.php index 950f4d73f6..0ec2137538 100644 --- a/resources/views/importer/import.blade.php +++ b/resources/views/importer/import.blade.php @@ -9,112 +9,20 @@ {{-- Page content --}} @section('content') {{-- Hide importer until vue has rendered it, if we continue using vue for other things we should move this higher in the style --}} - - -
- -
- @{{ alert.message }} - - -
-
-
-
- -
- -
-
-
- @{{ progress.statusText }} -
-
-
- -
- - - @if (!config('app.lock_passwords')) - - {{ trans('button.select_file') }} - - - - - @endif - -
- -
- - - -
-
-
- -
{{ trans('mail.name') }}
{{ $license->name }}
- - - - - - - - - -
{{ trans('general.file_name') }}{{ trans('general.created_at') }}{{ trans('general.filesize') }}{{ trans('general.actions') }}
-

-
-
-
-
-
-

{{ trans('general.importing') }}

-

{!! trans('general.importing_help') !!}

-
- -
- -
+THIS IS VUE STUFF ISNT IT? + --}} +@livewire('importer') {{-- Yes, this is stupid - we should be able to route straight over and not have this, but Livewire doesn't work in this app that way :/ --}} @stop @section('moar_scripts') - + --}} @endsection diff --git a/resources/views/livewire/importer-file.blade.php b/resources/views/livewire/importer-file.blade.php new file mode 100644 index 0000000000..3218648fee --- /dev/null +++ b/resources/views/livewire/importer-file.blade.php @@ -0,0 +1,207 @@ +{{-- --}} diff --git a/resources/views/livewire/importer.blade.php b/resources/views/livewire/importer.blade.php new file mode 100644 index 0000000000..f998d6363f --- /dev/null +++ b/resources/views/livewire/importer.blade.php @@ -0,0 +1,212 @@ +
+ {{-- --}} {{-- like, this, here, that's a literal Vue directive --}} +
+ {{-- @{{ alert.message }} --}} + + +{{-- alert --}} + + + + {{-- errors thing that's built-in maybe? --}} + {{-- --}} + +
+
+
+
+ +
+ + + +
+ + + @if (!config('app.lock_passwords')) + + {{ trans('admin/importer/general.select_import_file') }} + + + + + @endif + +
+ +
+ + + +
+
+
+
+ + + + + + + + + + + {{-- --}} +
{{ trans('admin/importer/table.file') }}{{ trans('admin/importer/table.created') }}{{ trans('admin/importer/table.size') }}{{ trans('admin/importer/table.process') }}{{ trans('admin/importer/table.delete') }}
+
+
+
+
+
+
+

{{ trans('general.importing') }}

+

{!! trans('general.importing_help') !!}

+
+ +
+ {{--
--}} +
+@push('js') + +@endpush \ No newline at end of file From 8009ee79db0599bf762c59876bd78b2c65739c80 Mon Sep 17 00:00:00 2001 From: Brady Wetherington Date: Mon, 19 Sep 2022 21:04:46 -0700 Subject: [PATCH 069/554] I think I have, now, full parity on the base Importer level Meaning that you can upload new files, delete old files, have error messages, have status updates - and all of them seem to work. --- FIXME.txt | 18 +++-- app/Http/Livewire/Importer.php | 37 ++++++++-- resources/views/livewire/importer.blade.php | 82 +++++++++++++-------- 3 files changed, 93 insertions(+), 44 deletions(-) diff --git a/FIXME.txt b/FIXME.txt index 8f95bcb814..1a644d9b51 100644 --- a/FIXME.txt +++ b/FIXME.txt @@ -1,11 +1,15 @@ -remove Ziggy -and ziggy-js too -And what is /public/js/snipeit.js ? That looks like a generated file +X - remove Ziggy +X - and ziggy-js too +X - And what is /public/js/snipeit.js ? That looks like a generated file The 'flash' (forced refresh/fake refresh) on uploads is dumb -I'm not sure if the order on the uploaded files is right? -The Livewire.first() thing is still dumb (but Id o'nt know that we can fix it). +X - the order on the uploaded files is wrong (backwards) +X - (fixed somehow?!) The Livewire.first() thing is still dumb (but Id o'nt know that we can fix it). -Deletes need to work (I got this working before using $.ajax; it's not even hard) +X - Deletes need to work (I got this working before using $.ajax; it's not even hard) -Then mapping and so on. \ No newline at end of file +Then mapping and so on. + +Can we potentially delete whatever that this.$http thing? Or is that some side-effect of Vue.js that we don't get for free? (yes, it was that) + +I suspect the Alert section is not yet wired up - but should be. Doesn't seem too hard? \ No newline at end of file diff --git a/app/Http/Livewire/Importer.php b/app/Http/Livewire/Importer.php index 1bcd501ba1..32f0d50351 100644 --- a/app/Http/Livewire/Importer.php +++ b/app/Http/Livewire/Importer.php @@ -5,6 +5,7 @@ namespace App\Http\Livewire; use Livewire\Component; use App\Models\Import; +use Storage; use Log; @@ -14,6 +15,13 @@ class Importer extends Component public $processDetails; public $forcerefresh; + public $progress; //upload progress - '-1' means don't show + public $progress_message; //progress message + public $progress_bar_class; + + public $message; //status/error message? + public $message_type; //success/error? + protected $rules = [ 'files.*.file_path' => 'required|string', 'files.*.created_at' => 'required|string', @@ -22,13 +30,15 @@ class Importer extends Component public function mount() { - //$this->files = Import::all(); // this *SHOULD* be how it works, but...it doesn't? - $this->forcerefresh = 0; + //$this->files = Import::all(); // this *SHOULD* be how it works, but...it doesn't? (note orderBy/get, below) + //$this->forcerefresh = 0; + $this->progress = -1; // '-1' means 'don't show the progressbar' + $this->progress_bar_class = 'progress-bar-warning'; } - public function test() + public function hideMessages() { - Log::error("Test Button Clicked!!!!"); + $this->message=''; } public function toggleEvent($id) @@ -37,9 +47,26 @@ class Importer extends Component $this->processDetails = Import::find($id); } + public function destroy($id) + { + foreach($this->files as $file) { + \Log::debug("File id is: ".$file->id); + //\Log::debug("File is: ".print_r($file,true)); + if($id == $file->id) { + // FIXME - should I do a try/catch on this and use the file_delete_failure or whatever, if needed? + \Log::debug("I FOUND IT!!!!"); + Storage::delete('imports/'.$file->file_path); // FIXME - last time I ran this, it *didn't* delete the file?! + $file->delete(); + + $this->message = trans('admin/hardware/message.import.file_delete_success'); + $this->message_type = 'success'; // uhm, I mean, I guess? + } + } + } + public function render() { - $this->files = Import::all(); //HACK - slows down renders. + $this->files = Import::orderBy('id','desc')->get(); //HACK - slows down renders. return view('livewire.importer'); } } diff --git a/resources/views/livewire/importer.blade.php b/resources/views/livewire/importer.blade.php index f998d6363f..8a2b3832e4 100644 --- a/resources/views/livewire/importer.blade.php +++ b/resources/views/livewire/importer.blade.php @@ -32,16 +32,18 @@ {{-- alert --}} - + +@endif @endpush \ No newline at end of file From 5c97e45d00ab490ee6cba2bfb70c1c06d3d4c599 Mon Sep 17 00:00:00 2001 From: Brady Wetherington Date: Tue, 27 Sep 2022 16:37:39 -0700 Subject: [PATCH 070/554] WIP - trying to get select2 wired up for importer --- .../views/livewire/importer-file.blade.php | 16 ++++++++++++- resources/views/livewire/importer.blade.php | 23 +------------------ 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/resources/views/livewire/importer-file.blade.php b/resources/views/livewire/importer-file.blade.php index 3218648fee..e2e3440fb4 100644 --- a/resources/views/livewire/importer-file.blade.php +++ b/resources/views/livewire/importer-file.blade.php @@ -10,7 +10,9 @@
- {{ Form::select('importType', $importTypes, 0 /* FIXME whats' the old value? */, ['placeholder' => '', 'wire:model' => 'importType', 'wire:change' => 'changeTypes']) }} + + {{ Form::select('importType', $importTypes, 0 /* FIXME whats' the old value? */, ['class' => 'livewire-select2', 'placeholder' => '', 'data-livewire-model' => 'importType']) }} + {{-- --}} {{-- --}} {{-- --}} @@ -205,3 +207,15 @@ {{-- --}} + \ No newline at end of file diff --git a/resources/views/livewire/importer.blade.php b/resources/views/livewire/importer.blade.php index 8a2b3832e4..ccef721b26 100644 --- a/resources/views/livewire/importer.blade.php +++ b/resources/views/livewire/importer.blade.php @@ -2,7 +2,7 @@ {{-- --}} {{-- like, this, here, that's a literal Vue directive --}}
{{-- @{{ alert.message }} --}} -