Skip to content

Commit cc73b98

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents 548ef97 + 77c978d commit cc73b98

File tree

7 files changed

+30
-19
lines changed

7 files changed

+30
-19
lines changed

app/Console/Commands/SendExpirationAlerts.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct()
4242
public function handle()
4343
{
4444
$settings = Setting::getSettings();
45-
$threshold = $settings->alert_interval;
45+
$alert_interval = $settings->alert_interval;
4646

4747
if (($settings->alert_email != '') && ($settings->alerts_enabled == 1)) {
4848

@@ -51,18 +51,18 @@ public function handle()
5151
->map(fn($item) => trim($item)) // Trim each email
5252
->all();
5353
// Expiring Assets
54-
$assets = Asset::getExpiringWarrantee($threshold);
54+
$assets = Asset::getExpiringWarrantee($alert_interval);
5555

5656
if ($assets->count() > 0) {
57-
$this->info(trans_choice('mail.assets_warrantee_alert', $assets->count(), ['count' => $assets->count(), 'threshold' => $threshold]));
58-
Mail::to($recipients)->send(new ExpiringAssetsMail($assets, $threshold));
57+
$this->info(trans_choice('mail.assets_warrantee_alert', $assets->count(), ['count' => $assets->count(), 'threshold' => $alert_interval]));
58+
Mail::to($recipients)->send(new ExpiringAssetsMail($assets, $alert_interval));
5959
}
6060

6161
// Expiring licenses
62-
$licenses = License::getExpiringLicenses($threshold);
62+
$licenses = License::getExpiringLicenses($alert_interval);
6363
if ($licenses->count() > 0) {
64-
$this->info(trans_choice('mail.license_expiring_alert', $licenses->count(), ['count' => $licenses->count(), 'threshold' => $threshold]));
65-
Mail::to($recipients)->send(new ExpiringLicenseMail($licenses, $threshold));
64+
$this->info(trans_choice('mail.license_expiring_alert', $licenses->count(), ['count' => $licenses->count(), 'threshold' => $alert_interval]));
65+
Mail::to($recipients)->send(new ExpiringLicenseMail($licenses, $alert_interval));
6666
}
6767
} else {
6868
if ($settings->alert_email == '') {

app/Http/Controllers/SettingsController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -850,8 +850,8 @@ public function postLdapSettings(StoreLdapSettings $request) : RedirectResponse
850850
$setting->ldap_fname_field = $request->input('ldap_fname_field');
851851
$setting->ldap_auth_filter_query = $request->input('ldap_auth_filter_query');
852852
$setting->ldap_version = $request->input('ldap_version', 3);
853-
$setting->ldap_active_flag = $request->input('ldap_active_flag');
854-
$setting->ldap_invert_active_flag = $request->input('ldap_invert_active_flag');
853+
$setting->ldap_active_flag = $request->input('ldap_active_flag', 0);
854+
$setting->ldap_invert_active_flag = $request->input('ldap_invert_active_flag', 0);
855855
$setting->ldap_emp_num = $request->input('ldap_emp_num');
856856
$setting->ldap_email = $request->input('ldap_email');
857857
$setting->ldap_manager = $request->input('ldap_manager');

app/Models/Asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ public static function getExpiringWarrantee($days = 30)
785785
->whereNotNull('warranty_months')
786786
->whereNotNull('purchase_date')
787787
->whereNull('deleted_at')
788-
->whereRaw('DATE_ADD(`purchase_date`,INTERVAL `warranty_months` MONTH) <= DATE(NOW() + INTERVAL '
788+
->whereRaw('DATE_ADD(`purchase_date`, INTERVAL `warranty_months` MONTH) <= DATE_ADD(NOW(), INTERVAL '
789789
. $days
790790
. ' DAY) AND DATE_ADD(`purchase_date`, INTERVAL `warranty_months` MONTH) > NOW()')
791791
->orderByRaw('DATE_ADD(`purchase_date`,INTERVAL `warranty_months` MONTH)')

database/migrations/2025_02_26_153413_add_ldap_invert_active_flag_to_setting_table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
public function up(): void
1313
{
1414
Schema::table('settings', function (Blueprint $table) {
15-
$table->boolean('ldap_invert_active_flag')->default(false);
15+
$table->boolean('ldap_invert_active_flag')->default(0);
1616
});
1717
}
1818

resources/views/settings/ldap.blade.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@
171171
<!-- LDAP Client-Side TLS key -->
172172
<div class="form-group {{ $errors->has('ldap_client_tls_key') ? 'error' : '' }}">
173173
<div class="col-md-3">
174-
{{ Form::label('ldap_client_tls_key', trans('admin/settings/general.ldap_client_tls_key')) }}
174+
<label for="ldap_client_tls_key">
175+
{{ trans('admin/settings/general.ldap_client_tls_key') }}
176+
</label>
175177
</div>
176178
<div class="col-md-8">
177179
<x-input.textarea
@@ -557,27 +559,34 @@
557559
<!-- LDAP invert active flag -->
558560
<div class="form-group">
559561
<div class="col-md-3">
560-
{{ Form::label('ldap_invert_active_flag', trans('admin/settings/general.ldap_invert_active_flag')) }}
562+
<label for="ldap_invert_active_flag">
563+
{{ trans('admin/settings/general.ldap_invert_active_flag') }}
564+
</label>
561565
</div>
562566
<div class="col-md-8">
563567
<label class="form-control">
564568
<input type="checkbox" name="ldap_invert_active_flag" value="1" id="ldap_invert_active_flag" @checked(old('ldap_invert_active_flag', $setting->ldap_invert_active_flag)) />
565-
<p class="help-block">{!! trans('admin/settings/general.ldap_invert_active_flag_help') !!}</p>
569+
{{ trans('general.yes') }}
566570
</label>
567571
@error('ldap_invert_active_flag')
568-
<span class="alert-msg">
572+
<span class="alert-msg">
569573
<x-icon type="x" />
570574
{{ $message }}
571575
</span>
572576
@enderror
573577

578+
<p class="help-block">
579+
{!! trans('admin/settings/general.ldap_invert_active_flag_help') !!}
580+
</p>
581+
574582
@if (config('app.lock_passwords')===true)
575583
<p class="text-warning">
576584
<x-icon type="locked" />
577-
{{ trans('general.feature_disabled') }}
585+
{!! trans('general.feature_disabled') !!}
578586
</p>
579587
@endif
580588
</div>
589+
581590
</div>
582591

583592
<!-- LDAP emp number -->

tests/Feature/Notifications/Email/ExpiringAlertsNotificationTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,21 @@ public function testExpiringAssetsEmailNotification()
2626
$alert_email = Setting::first()->alert_email;
2727

2828
$expiringAsset = Asset::factory()->create([
29-
'purchase_date' => now()->subMonths(11)->format('Y-m-d'),
29+
'purchase_date' => now()->subDays(350)->format('Y-m-d'),
3030
'warranty_months' => 12,
3131
'archived' => 0,
3232
'deleted_at' => null,
3333
]);
3434

3535
$expiredAsset = Asset::factory()->create([
36-
'purchase_date' => now()->subMonths(13)->format('Y-m-d'),
36+
'purchase_date' => now()->subDays(370)->format('Y-m-d'),
3737
'warranty_months' => 12,
3838
'archived' => 0,
3939
'deleted_at' => null,
4040
]);
41+
4142
$notExpiringAsset = Asset::factory()->create([
42-
'purchase_date' => now()->subMonths(10)->format('Y-m-d'),
43+
'purchase_date' => now()->subDays(330)->format('Y-m-d'),
4344
'warranty_months' => 12,
4445
'archived' => 0,
4546
'deleted_at' => null,

tests/Feature/Settings/LdapSettingsTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public function testLdapSettingsCanBeSaved()
2828
'ldap_basedn' => 'uid=',
2929
'ldap_fname_field' => 'SomeFirstnameField',
3030
'ldap_server' => 'ldaps://ldap.example.com',
31+
'ldap_invert_active_flag' => 0,
3132
]))
3233
->assertStatus(302)
3334
->assertValid('ldap_enabled')

0 commit comments

Comments
 (0)