From 9316ecb8d63b1a8b7074b090d03ef8553424b15d Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 14 Nov 2023 16:14:39 +0000 Subject: [PATCH 01/63] CLarified upload error text Signed-off-by: snipe --- resources/lang/en/general.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/lang/en/general.php b/resources/lang/en/general.php index fba828839..f0eda87d0 100644 --- a/resources/lang/en/general.php +++ b/resources/lang/en/general.php @@ -485,7 +485,7 @@ return [ ], 'percent_complete' => '% complete', 'uploading' => 'Uploading... ', - 'upload_error' => 'Error uploading file. Please check that there are no empty trailing rows.', + 'upload_error' => 'Error uploading file. Please check that there are no empty rows and that no column names are duplicated.', 'copy_to_clipboard' => 'Copy to Clipboard', 'copied' => 'Copied!', From 0924a53789ea197493fd65acb6b1ca864c49c4fb Mon Sep 17 00:00:00 2001 From: spencerrlongg Date: Wed, 15 Nov 2023 12:28:30 -0600 Subject: [PATCH 02/63] quick fix --- app/Http/Requests/StoreAssetRequest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Http/Requests/StoreAssetRequest.php b/app/Http/Requests/StoreAssetRequest.php index 254895f13..4216cf7cb 100644 --- a/app/Http/Requests/StoreAssetRequest.php +++ b/app/Http/Requests/StoreAssetRequest.php @@ -35,6 +35,9 @@ class StoreAssetRequest extends ImageUploadRequest parent::rules(), ); + // temporary fix for unique serials + unset($rules['serial']); + return $rules; } } From c7f90ad86d0546bd30ecb04148699b222eac720c Mon Sep 17 00:00:00 2001 From: spencerrlongg Date: Wed, 15 Nov 2023 12:50:40 -0600 Subject: [PATCH 03/63] tested, working --- app/Http/Requests/StoreAssetRequest.php | 3 --- app/Http/Traits/UniqueSerialTrait.php | 25 --------------------- app/Models/Asset.php | 5 ++--- app/Providers/ValidationServiceProvider.php | 13 +++++++++++ resources/lang/en/validation.php | 1 + 5 files changed, 16 insertions(+), 31 deletions(-) delete mode 100644 app/Http/Traits/UniqueSerialTrait.php diff --git a/app/Http/Requests/StoreAssetRequest.php b/app/Http/Requests/StoreAssetRequest.php index 4216cf7cb..254895f13 100644 --- a/app/Http/Requests/StoreAssetRequest.php +++ b/app/Http/Requests/StoreAssetRequest.php @@ -35,9 +35,6 @@ class StoreAssetRequest extends ImageUploadRequest parent::rules(), ); - // temporary fix for unique serials - unset($rules['serial']); - return $rules; } } diff --git a/app/Http/Traits/UniqueSerialTrait.php b/app/Http/Traits/UniqueSerialTrait.php deleted file mode 100644 index b5529d7cf..000000000 --- a/app/Http/Traits/UniqueSerialTrait.php +++ /dev/null @@ -1,25 +0,0 @@ -unique_serial == '1') { - return 'unique_undeleted:'.$this->table.','.$this->getKey(); - } - } - } -} diff --git a/app/Models/Asset.php b/app/Models/Asset.php index a7d4d7442..ea436f013 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -6,7 +6,6 @@ use App\Events\AssetCheckedOut; use App\Events\CheckoutableCheckedOut; use App\Exceptions\CheckoutNotAllowed; use App\Helpers\Helper; -use App\Http\Traits\UniqueSerialTrait; use App\Http\Traits\UniqueUndeletedTrait; use App\Models\Traits\Acceptable; use App\Models\Traits\Searchable; @@ -32,7 +31,7 @@ class Asset extends Depreciable protected $presenter = \App\Presenters\AssetPresenter::class; use CompanyableTrait; - use HasFactory, Loggable, Requestable, Presentable, SoftDeletes, ValidatingTrait, UniqueUndeletedTrait, UniqueSerialTrait; + use HasFactory, Loggable, Requestable, Presentable, SoftDeletes, ValidatingTrait, UniqueUndeletedTrait; public const LOCATION = 'location'; public const ASSET = 'asset'; @@ -100,7 +99,7 @@ class Asset extends Depreciable 'expected_checkin' => 'date|nullable', 'location_id' => 'exists:locations,id|nullable', 'rtd_location_id' => 'exists:locations,id|nullable', - 'asset_tag' => 'required|min:1|max:255|unique_undeleted:assets,asset_tag', + 'asset_tag' => 'required|min:1|max:255|unique_undeleted:assets,asset_tag|not_array', 'purchase_date' => 'date|date_format:Y-m-d|nullable', 'serial' => 'unique_serial|nullable', 'purchase_cost' => 'numeric|nullable|gte:0', diff --git a/app/Providers/ValidationServiceProvider.php b/app/Providers/ValidationServiceProvider.php index 30c5a0197..37866208d 100644 --- a/app/Providers/ValidationServiceProvider.php +++ b/app/Providers/ValidationServiceProvider.php @@ -2,7 +2,9 @@ namespace App\Providers; +use App\Models\Asset; use App\Models\Department; +use App\Models\Setting; use DB; use Illuminate\Support\ServiceProvider; use Illuminate\Validation\Rule; @@ -72,6 +74,17 @@ class ValidationServiceProvider extends ServiceProvider } }); + + Validator::extend('unique_serial', function ($attribute, $value, $parameters, $validator) { + if(Setting::getSettings()->unique_serial == '1') { + $count = DB::table('assets')->select('id')->where('serial', '=', $value)->whereNull('deleted_at')->count(); + + return $count < 1; + } else { + return true; + } + }); + // Prevent circular references // // Example usage in Location model where parent_id references another Location: diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php index bb35515fd..85e844781 100644 --- a/resources/lang/en/validation.php +++ b/resources/lang/en/validation.php @@ -96,6 +96,7 @@ return [ 'unique_undeleted' => 'The :attribute must be unique.', 'non_circular' => 'The :attribute must not create a circular reference.', 'not_array' => 'The :attribute field cannot be an array.', + 'unique_serial' => 'The :attribute must be unique.', 'disallow_same_pwd_as_user_fields' => 'Password cannot be the same as the username.', 'letters' => 'Password must contain at least one letter.', 'numbers' => 'Password must contain at least one number.', From b1f75a3bb31e89233a0687e558d6118982026388 Mon Sep 17 00:00:00 2001 From: spencerrlongg Date: Wed, 15 Nov 2023 13:20:17 -0600 Subject: [PATCH 04/63] remove unused import --- app/Providers/ValidationServiceProvider.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Providers/ValidationServiceProvider.php b/app/Providers/ValidationServiceProvider.php index 37866208d..55d8efa3e 100644 --- a/app/Providers/ValidationServiceProvider.php +++ b/app/Providers/ValidationServiceProvider.php @@ -2,7 +2,6 @@ namespace App\Providers; -use App\Models\Asset; use App\Models\Department; use App\Models\Setting; use DB; From 2f12a9cfe2d5a666abe5fdbd805d264993dba9cc Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Thu, 16 Nov 2023 09:52:44 -0800 Subject: [PATCH 05/63] add a conditional around location_id to fix bug --- app/Console/Commands/LdapSync.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Console/Commands/LdapSync.php b/app/Console/Commands/LdapSync.php index edb29614e..e11d269ef 100755 --- a/app/Console/Commands/LdapSync.php +++ b/app/Console/Commands/LdapSync.php @@ -83,7 +83,7 @@ class LdapSync extends Command $summary = []; try { - if ( $this->option('location_id') != '') { + if ( !empty($this->option('location_id')) != '') { $location_ou= Location::where('id', '=', $this->option('location_id'))->value('ldap_ou'); $search_base = $location_ou; Log::debug('Importing users from specified location OU: \"'.$search_base.'\".'); From 2c62a7e78d4b07efc6dd10f0867a9bb770c75db9 Mon Sep 17 00:00:00 2001 From: Abdelaziz Faki Date: Sun, 19 Nov 2023 19:59:01 +0300 Subject: [PATCH 06/63] Fixing #13850 UserImporter bug --- app/Importer/UserImporter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Importer/UserImporter.php b/app/Importer/UserImporter.php index 040f34f9e..263287e3b 100644 --- a/app/Importer/UserImporter.php +++ b/app/Importer/UserImporter.php @@ -61,7 +61,7 @@ class UserImporter extends ItemImporter $this->item['activated'] = ($this->fetchHumanBoolean(trim($this->findCsvMatch($row, 'activated'))) == 1) ? '1' : 0; $this->item['employee_num'] = trim($this->findCsvMatch($row, 'employee_num')); $this->item['department_id'] = trim($this->createOrFetchDepartment(trim($this->findCsvMatch($row, 'department')))); - $this->item['manager_id'] = $this->fetchManager($this->findCsvMatch($row, 'manager_first_name'), $this->findCsvMatch($row, 'manager_last_name')); + $this->item['manager_id'] = $this->fetchManager(trim($this->findCsvMatch($row, 'manager_first_name')), trim($this->findCsvMatch($row, 'manager_last_name'))); $this->item['remote'] = ($this->fetchHumanBoolean(trim($this->findCsvMatch($row, 'remote'))) == 1 ) ? '1' : 0; $this->item['vip'] = ($this->fetchHumanBoolean(trim($this->findCsvMatch($row, 'vip'))) ==1 ) ? '1' : 0; $this->item['autoassign_licenses'] = ($this->fetchHumanBoolean(trim($this->findCsvMatch($row, 'autoassign_licenses'))) ==1 ) ? '1' : 0; From fe2cfa0d385db4c094b59541aecfb2f65e8c9cb5 Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 20 Nov 2023 15:28:44 +0000 Subject: [PATCH 07/63] Redirect if category is missing or invalid Signed-off-by: snipe --- .../Controllers/Consumables/ConsumableCheckoutController.php | 5 +++++ resources/lang/en/general.php | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Consumables/ConsumableCheckoutController.php b/app/Http/Controllers/Consumables/ConsumableCheckoutController.php index 6585624d8..d1c3d22eb 100644 --- a/app/Http/Controllers/Consumables/ConsumableCheckoutController.php +++ b/app/Http/Controllers/Consumables/ConsumableCheckoutController.php @@ -34,6 +34,11 @@ class ConsumableCheckoutController extends Controller return redirect()->route('consumables.index')->with('error', trans('admin/consumables/message.checkout.unavailable')); } + // Make sure there is a valid category + if (!$consumable->category){ + return redirect()->route('consumables.index')->with('error', trans('general.invalid_item_category_single', ['type' => trans('general.consumable')])); + } + $this->authorize('checkout', $consumable); return view('consumables/checkout', compact('consumable')); diff --git a/resources/lang/en/general.php b/resources/lang/en/general.php index f0eda87d0..2deb8cb55 100644 --- a/resources/lang/en/general.php +++ b/resources/lang/en/general.php @@ -353,7 +353,8 @@ return [ 'synchronize' => 'Synchronize', 'sync_results' => 'Synchronization Results', 'license_serial' => 'Serial/Product Key', - 'invalid_category' => 'Invalid category', + 'invalid_category' => 'Invalid or missing category', + 'invalid_item_category_single' => 'Invalid or missing :type category. Please update the category of this :type to include a valid category before checking out.', 'dashboard_info' => 'This is your dashboard. There are many like it, but this one is yours.', '60_percent_warning' => '60% Complete (warning)', 'dashboard_empty' => 'It looks like you have not added anything yet, so we do not have anything awesome to display. Get started by adding some assets, accessories, consumables, or licenses now!', From 7c8860106666d3a1da508b658e38852d5fd3650e Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 20 Nov 2023 15:31:39 +0000 Subject: [PATCH 08/63] Grab the API Signed-off-by: snipe --- app/Http/Controllers/Api/ConsumablesController.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/Http/Controllers/Api/ConsumablesController.php b/app/Http/Controllers/Api/ConsumablesController.php index b9b48328f..1f3a347fb 100644 --- a/app/Http/Controllers/Api/ConsumablesController.php +++ b/app/Http/Controllers/Api/ConsumablesController.php @@ -266,6 +266,14 @@ class ConsumablesController extends Controller \Log::debug('No enough remaining'); } + // Make sure there is a valid category + if (!$consumable->category){ + return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.invalid_item_category_single', ['type' => trans('general.consumable')]))); + + return redirect()->route('consumables.index')->with('error', trans('general.invalid_item_category_single', ['type' => trans('general.consumable')])); + } + + // Check if the user exists - @TODO: this should probably be handled via validation, not here?? if (!$user = User::find($request->input('assigned_to'))) { // Return error message From 01fec1d6bb3f018c2dc2c9cf31495ca3e8b2f610 Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 20 Nov 2023 15:39:39 +0000 Subject: [PATCH 09/63] Redirect back to the specific consumable for correction Signed-off-by: snipe --- .../Controllers/Consumables/ConsumableCheckoutController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Consumables/ConsumableCheckoutController.php b/app/Http/Controllers/Consumables/ConsumableCheckoutController.php index d1c3d22eb..5723c2c7e 100644 --- a/app/Http/Controllers/Consumables/ConsumableCheckoutController.php +++ b/app/Http/Controllers/Consumables/ConsumableCheckoutController.php @@ -36,7 +36,7 @@ class ConsumableCheckoutController extends Controller // Make sure there is a valid category if (!$consumable->category){ - return redirect()->route('consumables.index')->with('error', trans('general.invalid_item_category_single', ['type' => trans('general.consumable')])); + return redirect()->route('consumables.edit', ['consumable' => $consumable->id])->with('error', trans('general.invalid_item_category_single', ['type' => trans('general.consumable')])); } $this->authorize('checkout', $consumable); From a2031897241e7bb00bd57a0a6c88e7c1c48a2362 Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 20 Nov 2023 15:41:36 +0000 Subject: [PATCH 10/63] Add @Azooz2014 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 3684e2e26..f5085f95e 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2979,6 +2979,15 @@ "contributions": [ "code" ] + }, + { + "login": "Azooz2014", + "name": "Abdelaziz Faki", + "avatar_url": "https://avatars.githubusercontent.com/u/7429229?v=4", + "profile": "https://azooz2014.github.io/", + "contributions": [ + "code" + ] } ] } diff --git a/README.md b/README.md index 71aba22b5..f1ea60974 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [![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-328-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-329-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 @@ -145,7 +145,7 @@ Thanks goes to all of these wonderful people ([emoji key](https://github.com/ken | [
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") | [
Andrew Savinykh](https://github.com/AndrewSav)
[💻](https://github.com/snipe/snipe-it/commits?author=AndrewSav "Code") | [
Tadayuki Onishi](https://kenchan0130.github.io)
[💻](https://github.com/snipe/snipe-it/commits?author=kenchan0130 "Code") | [
Florian](https://github.com/floschoepfer)
[💻](https://github.com/snipe/snipe-it/commits?author=floschoepfer "Code") | | [
Spencer Long](http://spencerlong.com)
[💻](https://github.com/snipe/snipe-it/commits?author=spencerrlongg "Code") | [
Marcus Moore](https://github.com/marcusmoore)
[💻](https://github.com/snipe/snipe-it/commits?author=marcusmoore "Code") | [
Martin Meredith](https://github.com/Mezzle)
| [
dboth](http://dboth.de)
[💻](https://github.com/snipe/snipe-it/commits?author=dboth "Code") | [
Zachary Fleck](https://github.com/zacharyfleck)
[💻](https://github.com/snipe/snipe-it/commits?author=zacharyfleck "Code") | [
VIKAAS-A](https://github.com/vikaas-cyper)
[💻](https://github.com/snipe/snipe-it/commits?author=vikaas-cyper "Code") | [
Abdul Kareem](https://github.com/ak-piracha)
[💻](https://github.com/snipe/snipe-it/commits?author=ak-piracha "Code") | -| [
NojoudAlshehri](https://github.com/NojoudAlshehri)
[💻](https://github.com/snipe/snipe-it/commits?author=NojoudAlshehri "Code") | [
Stefan Stidl](https://github.com/stefanstidlffg)
[💻](https://github.com/snipe/snipe-it/commits?author=stefanstidlffg "Code") | [
Quentin Aymard](https://github.com/qay21)
[💻](https://github.com/snipe/snipe-it/commits?author=qay21 "Code") | [
Grant Le Roux](https://github.com/cram42)
[💻](https://github.com/snipe/snipe-it/commits?author=cram42 "Code") | [
Bogdan](http://@singrity)
[💻](https://github.com/snipe/snipe-it/commits?author=Singrity "Code") | [
mmanjos](https://github.com/mmanjos)
[💻](https://github.com/snipe/snipe-it/commits?author=mmanjos "Code") | +| [
NojoudAlshehri](https://github.com/NojoudAlshehri)
[💻](https://github.com/snipe/snipe-it/commits?author=NojoudAlshehri "Code") | [
Stefan Stidl](https://github.com/stefanstidlffg)
[💻](https://github.com/snipe/snipe-it/commits?author=stefanstidlffg "Code") | [
Quentin Aymard](https://github.com/qay21)
[💻](https://github.com/snipe/snipe-it/commits?author=qay21 "Code") | [
Grant Le Roux](https://github.com/cram42)
[💻](https://github.com/snipe/snipe-it/commits?author=cram42 "Code") | [
Bogdan](http://@singrity)
[💻](https://github.com/snipe/snipe-it/commits?author=Singrity "Code") | [
mmanjos](https://github.com/mmanjos)
[💻](https://github.com/snipe/snipe-it/commits?author=mmanjos "Code") | [
Abdelaziz Faki](https://azooz2014.github.io/)
[💻](https://github.com/snipe/snipe-it/commits?author=Azooz2014 "Code") | This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome! From e5a4214b8b05baf47e556da79ececdb8d0890974 Mon Sep 17 00:00:00 2001 From: akemidx Date: Mon, 20 Nov 2023 20:32:14 -0500 Subject: [PATCH 11/63] hiding all order stuff --- resources/views/custom_fields/fieldsets/view.blade.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/views/custom_fields/fieldsets/view.blade.php b/resources/views/custom_fields/fieldsets/view.blade.php index 003ee0cd8..ec25697e1 100644 --- a/resources/views/custom_fields/fieldsets/view.blade.php +++ b/resources/views/custom_fields/fieldsets/view.blade.php @@ -29,7 +29,7 @@ @can('update', $custom_fieldset) {{ trans('admin/custom_fields/general.reorder') }} @endcan - {{ trans('admin/custom_fields/general.order') }} + {{ trans('admin/custom_fields/general.order') }} {{ trans('admin/custom_fields/general.field_name') }} {{ trans('admin/custom_fields/general.field_format') }} {{ trans('admin/custom_fields/general.field_element') }} @@ -51,7 +51,7 @@ @endcan - {{$field->pivot->order + 1}} + {{$field->pivot->order + 1}} {{--this +1 needs to exist to keep the first row from reverting to 0 if you edit/delete fields in/from a fielset--}} {{$field->name}} {{$field->format}} {{$field->element}} @@ -110,7 +110,7 @@ -
+