From bbabbe1b879de8a904ce534d2393a20ee1efb511 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 4 Mar 2025 19:21:46 +0000 Subject: [PATCH 01/12] Nicer model name formatting on RMB model not found Signed-off-by: snipe --- app/Exceptions/Handler.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 21d8197eb..e4155d34f 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -125,7 +125,9 @@ class Handler extends ExceptionHandler // This is traaaaash but it handles models that are not found while using route model binding :( // The only alternative is to set that at *each* route, which is crazypants if ($e instanceof \Illuminate\Database\Eloquent\ModelNotFoundException) { - $model_name = last(explode('\\', $e->getModel())); + + // This gets the MVC model name from the exception and formats in a way that's less fugly + $model_name = implode("",preg_split('/(?=[A-Z])/',last(explode('\\', $e->getModel())))); $route = str_plural(strtolower(last(explode('\\', $e->getModel())))).'.index'; // Sigh. From d4e227f003a75030b80cf4011e0fe55ab6a06b94 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 4 Mar 2025 19:29:09 +0000 Subject: [PATCH 02/12] Whitespace Signed-off-by: snipe --- app/Exceptions/Handler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index e4155d34f..180381b1f 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -127,7 +127,7 @@ class Handler extends ExceptionHandler if ($e instanceof \Illuminate\Database\Eloquent\ModelNotFoundException) { // This gets the MVC model name from the exception and formats in a way that's less fugly - $model_name = implode("",preg_split('/(?=[A-Z])/',last(explode('\\', $e->getModel())))); + $model_name = implode(" ", preg_split('/(?=[A-Z])/', last(explode('\\', $e->getModel())))); $route = str_plural(strtolower(last(explode('\\', $e->getModel())))).'.index'; // Sigh. From 63e4c424452ac49fddbc1e33ae4f9464bd4c7e38 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 4 Mar 2025 19:33:17 +0000 Subject: [PATCH 03/12] Added strtolower Signed-off-by: snipe --- app/Exceptions/Handler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 180381b1f..6e35f8217 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -127,7 +127,7 @@ class Handler extends ExceptionHandler if ($e instanceof \Illuminate\Database\Eloquent\ModelNotFoundException) { // This gets the MVC model name from the exception and formats in a way that's less fugly - $model_name = implode(" ", preg_split('/(?=[A-Z])/', last(explode('\\', $e->getModel())))); + $model_name = strtolower(implode(" ", preg_split('/(?=[A-Z])/', last(explode('\\', $e->getModel()))))); $route = str_plural(strtolower(last(explode('\\', $e->getModel())))).'.index'; // Sigh. From 1dacd25e6d910cb401134d7b83fa26b788ade625 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 4 Mar 2025 19:50:11 +0000 Subject: [PATCH 04/12] =?UTF-8?q?Check=20for=20purchase=5Fcost=20before=20?= =?UTF-8?q?adding=20the=20=E2=80=9Ceach=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: snipe --- resources/views/hardware/view.blade.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php index 90469d872..a59b0534b 100755 --- a/resources/views/hardware/view.blade.php +++ b/resources/views/hardware/view.blade.php @@ -1211,7 +1211,11 @@ {{ $component->name }} {{ $component->pivot->assigned_qty }} - {{ trans('general.cost_each', ['amount' => Helper::formatCurrencyOutput($component->purchase_cost)]) }} + + @if ($component->purchase_cost!='') + {{ trans('general.cost_each', ['amount' => Helper::formatCurrencyOutput($component->purchase_cost)]) }} + @endif + {{ $component->serial }} {{ trans('general.checkin') }} From 87916409089bc79915e8b68131a202572e5a6262 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 4 Mar 2025 19:53:25 +0000 Subject: [PATCH 05/12] Add @Fiala06 as a contributor --- .all-contributorsrc | 9 +++++++++ CONTRIBUTORS.md | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index dbec0453f..4ebf2cc1b 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -3298,6 +3298,15 @@ "contributions": [ "code" ] + }, + { + "login": "Fiala06", + "name": "Fiala06", + "avatar_url": "https://avatars.githubusercontent.com/u/5183146?v=4", + "profile": "https://github.com/Fiala06", + "contributions": [ + "code" + ] } ] } diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 4e252554b..74df7b0a7 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -53,7 +53,7 @@ Thanks goes to all of these wonderful people ([emoji key](https://github.com/ken | [
squintfox](https://github.com/squintfox)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=squintfox "Code") | [
Jeff Clay](https://github.com/jeffclay)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=jeffclay "Code") | [
Phil J R](https://github.com/PP-JN-RL)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=PP-JN-RL "Code") | [
i_virus](https://www.corelight.com/)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=chandanchowdhury "Code") | [
Paul Grime](https://github.com/gitgrimbo)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=gitgrimbo "Code") | [
Lee Porte](https://leeporte.co.uk)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=LeePorte "Code") | [
BRYAN ](https://github.com/bryanlopezinc)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=bryanlopezinc "Code") [⚠️](https://github.com/snipe/snipe-it/commits?author=bryanlopezinc "Tests") | | [
U-H-T](https://github.com/U-H-T)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=U-H-T "Code") | [
Matt Tyree](https://github.com/Tyree)
[πŸ“–](https://github.com/snipe/snipe-it/commits?author=Tyree "Documentation") | [
Florent Bervas](http://spoontux.net)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=FlorentDotMe "Code") | [
Daniel Albertsen](https://ditscheri.com)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=dbakan "Code") | [
r-xyz](https://github.com/r-xyz)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=r-xyz "Code") | [
Steven Mainor](https://github.com/DrekiDegga)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=DrekiDegga "Code") | [
arne-kroeger](https://github.com/arne-kroeger)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=arne-kroeger "Code") | | [
Glukose1](https://github.com/Glukose1)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=Glukose1 "Code") | [
Scarzy](https://github.com/Scarzy)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=Scarzy "Code") | [
setpill](https://github.com/setpill)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=setpill "Code") | [
swift2512](https://github.com/swift2512)
[πŸ›](https://github.com/snipe/snipe-it/issues?q=author%3Aswift2512 "Bug reports") | [
Darren Rainey](https://darrenraineys.co.uk)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=DarrenRainey "Code") | [
maciej-poleszczyk](https://github.com/maciej-poleszczyk)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=maciej-poleszczyk "Code") | [
Sebastian Groß](https://github.com/sgross-emlix)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=sgross-emlix "Code") | -| [
Anouar Touati](https://github.com/AnouarTouati)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=AnouarTouati "Code") | [
aHVzY2g](https://github.com/aHVzY2g)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=aHVzY2g "Code") | [
ζž—εšδ» Buo-ren Lin](https://brlin.me)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=brlin-tw "Code") | [
Adugna Gizaw](https://orbalia.pythonanywhere.com/)
[🌍](#translation-addex12 "Translation") | [
Jesse Ostrander](https://github.com/jostrander)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=jostrander "Code") | [
James M](https://github.com/azmcnutt)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=azmcnutt "Code") | +| [
Anouar Touati](https://github.com/AnouarTouati)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=AnouarTouati "Code") | [
aHVzY2g](https://github.com/aHVzY2g)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=aHVzY2g "Code") | [
ζž—εšδ» Buo-ren Lin](https://brlin.me)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=brlin-tw "Code") | [
Adugna Gizaw](https://orbalia.pythonanywhere.com/)
[🌍](#translation-addex12 "Translation") | [
Jesse Ostrander](https://github.com/jostrander)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=jostrander "Code") | [
James M](https://github.com/azmcnutt)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=azmcnutt "Code") | [
Fiala06](https://github.com/Fiala06)
[πŸ’»](https://github.com/snipe/snipe-it/commits?author=Fiala06 "Code") | This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome! From 2b0127ab0c10d0bb7c21bd89193e8a3101242dac Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 4 Mar 2025 19:56:58 +0000 Subject: [PATCH 06/12] Bumped version 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 e8c421fe3..af8add2c6 100644 --- a/config/version.php +++ b/config/version.php @@ -1,10 +1,10 @@ 'v8.0.2', - 'full_app_version' => 'v8.0.2 - build 17048-g44dd06161', - 'build_version' => '17048', + 'app_version' => 'v8.0.3', + 'full_app_version' => 'v8.0.3 - build 17154-ged8a48672', + 'build_version' => '17154', 'prerelease_version' => '', - 'hash_version' => 'g44dd06161', - 'full_hash' => 'v8.0.2-54-g44dd06161', + 'hash_version' => 'ged8a48672', + 'full_hash' => 'v8.0.3-99-ged8a48672', 'branch' => 'develop', ); \ No newline at end of file From 1be420b0e95fbe310b9856d6a03da09c72184adc Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 4 Mar 2025 20:37:45 +0000 Subject: [PATCH 07/12] Fixed test Signed-off-by: snipe --- tests/Feature/Settings/LdapSettingsTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Feature/Settings/LdapSettingsTest.php b/tests/Feature/Settings/LdapSettingsTest.php index 317ccb42d..154a44138 100644 --- a/tests/Feature/Settings/LdapSettingsTest.php +++ b/tests/Feature/Settings/LdapSettingsTest.php @@ -28,6 +28,7 @@ class LdapSettingsTest extends TestCase 'ldap_basedn' => 'uid=', 'ldap_fname_field' => 'SomeFirstnameField', 'ldap_server' => 'ldaps://ldap.example.com', + 'ldap_invert_active_flag' => 0, ])) ->assertStatus(302) ->assertValid('ldap_enabled') From a31a732d38cf947107b09b9bcbc020566d4e426d Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 4 Mar 2025 20:38:15 +0000 Subject: [PATCH 08/12] Nicer UI for invert flag Signed-off-by: snipe --- resources/views/settings/ldap.blade.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/resources/views/settings/ldap.blade.php b/resources/views/settings/ldap.blade.php index 9d4a19b01..62e430616 100644 --- a/resources/views/settings/ldap.blade.php +++ b/resources/views/settings/ldap.blade.php @@ -171,7 +171,9 @@
- {{ Form::label('ldap_client_tls_key', trans('admin/settings/general.ldap_client_tls_key')) }} +
- {{ Form::label('ldap_invert_active_flag', trans('admin/settings/general.ldap_invert_active_flag')) }} +
@error('ldap_invert_active_flag') - + {{ $message }} @enderror +

+ {!! trans('admin/settings/general.ldap_invert_active_flag_help') !!} +

+ @if (config('app.lock_passwords')===true)

- {{ trans('general.feature_disabled') }} + {!! trans('general.feature_disabled') !!}

@endif
+
From 9351cc225295e1a391e45a059d4be83145db0276 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 4 Mar 2025 20:38:22 +0000 Subject: [PATCH 09/12] Set default to 0 Signed-off-by: snipe --- ...2_26_153413_add_ldap_invert_active_flag_to_setting_table.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/migrations/2025_02_26_153413_add_ldap_invert_active_flag_to_setting_table.php b/database/migrations/2025_02_26_153413_add_ldap_invert_active_flag_to_setting_table.php index c435e014c..7ca354bfe 100644 --- a/database/migrations/2025_02_26_153413_add_ldap_invert_active_flag_to_setting_table.php +++ b/database/migrations/2025_02_26_153413_add_ldap_invert_active_flag_to_setting_table.php @@ -12,7 +12,7 @@ return new class extends Migration public function up(): void { Schema::table('settings', function (Blueprint $table) { - $table->boolean('ldap_invert_active_flag')->default(false); + $table->boolean('ldap_invert_active_flag')->default(0); }); } From d89f38bbfb73c5d4fdc276d1e208a16e0c121833 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 4 Mar 2025 20:38:33 +0000 Subject: [PATCH 10/12] Set defaults on save Signed-off-by: snipe --- app/Http/Controllers/SettingsController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index 807c514d0..ecb21e2ab 100644 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -850,8 +850,8 @@ class SettingsController extends Controller $setting->ldap_fname_field = $request->input('ldap_fname_field'); $setting->ldap_auth_filter_query = $request->input('ldap_auth_filter_query'); $setting->ldap_version = $request->input('ldap_version', 3); - $setting->ldap_active_flag = $request->input('ldap_active_flag'); - $setting->ldap_invert_active_flag = $request->input('ldap_invert_active_flag'); + $setting->ldap_active_flag = $request->input('ldap_active_flag', 0); + $setting->ldap_invert_active_flag = $request->input('ldap_invert_active_flag', 0); $setting->ldap_emp_num = $request->input('ldap_emp_num'); $setting->ldap_email = $request->input('ldap_email'); $setting->ldap_manager = $request->input('ldap_manager'); From f4f6dcb885a637987db20ba3f2521564de6641f4 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 4 Mar 2025 20:48:59 +0000 Subject: [PATCH 11/12] Updated test Signed-off-by: snipe --- .../Email/ExpiringAlertsNotificationTest.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/Feature/Notifications/Email/ExpiringAlertsNotificationTest.php b/tests/Feature/Notifications/Email/ExpiringAlertsNotificationTest.php index 5bc034ba5..81cbb3900 100644 --- a/tests/Feature/Notifications/Email/ExpiringAlertsNotificationTest.php +++ b/tests/Feature/Notifications/Email/ExpiringAlertsNotificationTest.php @@ -26,20 +26,21 @@ class ExpiringAlertsNotificationTest extends TestCase $alert_email = Setting::first()->alert_email; $expiringAsset = Asset::factory()->create([ - 'purchase_date' => now()->subMonths(11)->format('Y-m-d'), + 'purchase_date' => now()->subDays(350)->format('Y-m-d'), + 'warranty_months' => 12, + 'archived' => 0, + 'deleted_at' => null, + ]); + + $expiredAsset = Asset::factory()->create([ + 'purchase_date' => now()->subDays(370)->format('Y-m-d'), 'warranty_months' => 12, 'archived' => 0, 'deleted_at' => null, ]); - $expiredAsset = Asset::factory()->create([ - 'purchase_date' => now()->subMonths(13)->format('Y-m-d'), - 'warranty_months' => 12, - 'archived' => 0, - 'deleted_at' => null, - ]); $notExpiringAsset = Asset::factory()->create([ - 'purchase_date' => now()->subMonths(10)->format('Y-m-d'), + 'purchase_date' => now()->subDays(330)->format('Y-m-d'), 'warranty_months' => 12, 'archived' => 0, 'deleted_at' => null, From 4bac509341c2e3a8187bb00fd98f740afcd4bcc4 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Tue, 4 Mar 2025 12:58:04 -0800 Subject: [PATCH 12/12] fix Expiring alert tests --- app/Console/Commands/SendExpirationAlerts.php | 14 +++++++------- app/Models/Asset.php | 5 ++++- .../Email/ExpiringAlertsNotificationTest.php | 7 +++---- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/app/Console/Commands/SendExpirationAlerts.php b/app/Console/Commands/SendExpirationAlerts.php index 1220e0cd9..2e0c2a62f 100644 --- a/app/Console/Commands/SendExpirationAlerts.php +++ b/app/Console/Commands/SendExpirationAlerts.php @@ -42,7 +42,7 @@ class SendExpirationAlerts extends Command public function handle() { $settings = Setting::getSettings(); - $threshold = $settings->alert_interval; + $alert_interval = $settings->alert_interval; if (($settings->alert_email != '') && ($settings->alerts_enabled == 1)) { @@ -51,18 +51,18 @@ class SendExpirationAlerts extends Command ->map(fn($item) => trim($item)) // Trim each email ->all(); // Expiring Assets - $assets = Asset::getExpiringWarrantee($threshold); + $assets = Asset::getExpiringWarrantee($alert_interval); if ($assets->count() > 0) { - $this->info(trans_choice('mail.assets_warrantee_alert', $assets->count(), ['count' => $assets->count(), 'threshold' => $threshold])); - Mail::to($recipients)->send(new ExpiringAssetsMail($assets, $threshold)); + $this->info(trans_choice('mail.assets_warrantee_alert', $assets->count(), ['count' => $assets->count(), 'threshold' => $alert_interval])); + Mail::to($recipients)->send(new ExpiringAssetsMail($assets, $alert_interval)); } // Expiring licenses - $licenses = License::getExpiringLicenses($threshold); + $licenses = License::getExpiringLicenses($alert_interval); if ($licenses->count() > 0) { - $this->info(trans_choice('mail.license_expiring_alert', $licenses->count(), ['count' => $licenses->count(), 'threshold' => $threshold])); - Mail::to($recipients)->send(new ExpiringLicenseMail($licenses, $threshold)); + $this->info(trans_choice('mail.license_expiring_alert', $licenses->count(), ['count' => $licenses->count(), 'threshold' => $alert_interval])); + Mail::to($recipients)->send(new ExpiringLicenseMail($licenses, $alert_interval)); } } else { if ($settings->alert_email == '') { diff --git a/app/Models/Asset.php b/app/Models/Asset.php index c57157817..cc016583c 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -785,9 +785,12 @@ class Asset extends Depreciable ->whereNotNull('warranty_months') ->whereNotNull('purchase_date') ->whereNull('deleted_at') - ->whereRaw('DATE_ADD(`purchase_date`,INTERVAL `warranty_months` MONTH) <= DATE(NOW() + INTERVAL ' + ->whereRaw('DATE_ADD(`purchase_date`, INTERVAL `warranty_months` MONTH) <= DATE_ADD(NOW(), INTERVAL ' . $days . ' DAY) AND DATE_ADD(`purchase_date`, INTERVAL `warranty_months` MONTH) > NOW()') +// ->whereRaw('DATE_ADD(`purchase_date`,INTERVAL `warranty_months` MONTH) <= DATE(NOW() + INTERVAL ' +// . $days +// . ' DAY) AND DATE_ADD(`purchase_date`, INTERVAL `warranty_months` MONTH) > NOW()') ->orderByRaw('DATE_ADD(`purchase_date`,INTERVAL `warranty_months` MONTH)') ->get(); } diff --git a/tests/Feature/Notifications/Email/ExpiringAlertsNotificationTest.php b/tests/Feature/Notifications/Email/ExpiringAlertsNotificationTest.php index 5bc034ba5..09baf26d2 100644 --- a/tests/Feature/Notifications/Email/ExpiringAlertsNotificationTest.php +++ b/tests/Feature/Notifications/Email/ExpiringAlertsNotificationTest.php @@ -26,20 +26,19 @@ class ExpiringAlertsNotificationTest extends TestCase $alert_email = Setting::first()->alert_email; $expiringAsset = Asset::factory()->create([ - 'purchase_date' => now()->subMonths(11)->format('Y-m-d'), + 'purchase_date' => now()->subDays(350)->format('Y-m-d'), 'warranty_months' => 12, 'archived' => 0, 'deleted_at' => null, ]); - $expiredAsset = Asset::factory()->create([ - 'purchase_date' => now()->subMonths(13)->format('Y-m-d'), + 'purchase_date' => now()->subDays(370)->format('Y-m-d'), 'warranty_months' => 12, 'archived' => 0, 'deleted_at' => null, ]); $notExpiringAsset = Asset::factory()->create([ - 'purchase_date' => now()->subMonths(10)->format('Y-m-d'), + 'purchase_date' => now()->subDays(330)->format('Y-m-d'), 'warranty_months' => 12, 'archived' => 0, 'deleted_at' => null,