Skip to content

Commit ee4443a

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents 839dcad + f6b21fd commit ee4443a

File tree

9 files changed

+74
-28
lines changed

9 files changed

+74
-28
lines changed

app/Http/Controllers/Assets/AssetCheckinController.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,11 @@ public function create(Asset $asset, $backto = null) : View | RedirectResponse
4242
return redirect()->route('hardware.show', $asset->id)->with('error', trans('admin/hardware/general.model_invalid_fix'));
4343
}
4444

45-
// Validate custom fields on existing asset
46-
$validator = Validator::make($asset->toArray(), $asset->customFieldValidationRules());
45+
// Invoke the validation to see if the audit will complete successfully
46+
$asset->setRules($asset->getRules() + $asset->customFieldValidationRules());
4747

48-
if ($validator->fails()) {
49-
return redirect()->route('hardware.edit', $asset)
50-
->withErrors($validator);
48+
if ($asset->isInvalid()) {
49+
return redirect()->route('hardware.edit', $asset)->withErrors($asset->getErrors());
5150
}
5251

5352
$target_option = match ($asset->assigned_type) {

app/Http/Controllers/Assets/AssetCheckoutController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ public function create(Asset $asset) : View | RedirectResponse
3737
->with('error', trans('admin/hardware/general.model_invalid_fix'));
3838
}
3939

40-
// Validate custom fields on existing asset
41-
$validator = Validator::make($asset->toArray(), $asset->customFieldValidationRules());
40+
// Invoke the validation to see if the audit will complete successfully
41+
$asset->setRules($asset->getRules() + $asset->customFieldValidationRules());
4242

43-
if ($validator->fails()) {
44-
return redirect()->route('hardware.edit', $asset)
45-
->withErrors($validator);
43+
if ($asset->isInvalid()) {
44+
return redirect()->route('hardware.edit', $asset)->withErrors($asset->getErrors());
4645
}
46+
4747

4848
if ($asset->availableForCheckout()) {
4949
return view('hardware/checkout', compact('asset'))

app/Http/Controllers/Assets/AssetsController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -882,12 +882,12 @@ public function audit(Asset $asset): View | RedirectResponse
882882
$this->authorize('audit', Asset::class);
883883
$settings = Setting::getSettings();
884884

885-
// Validate custom fields on existing asset
886-
$validator = Validator::make($asset->toArray(), $asset->customFieldValidationRules());
887885

888-
if ($validator->fails()) {
889-
return redirect()->route('hardware.edit', $asset)
890-
->withErrors($validator);
886+
// Invoke the validation to see if the audit will complete successfully
887+
$asset->setRules($asset->getRules() + $asset->customFieldValidationRules());
888+
889+
if ($asset->isInvalid()) {
890+
return redirect()->route('hardware.edit', $asset)->withErrors($asset->getErrors());
891891
}
892892

893893
$dt = Carbon::now()->addMonths($settings->audit_interval)->toDateString();

app/Http/Controllers/Auth/LoginController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ public function logout(Request $request)
484484
}
485485

486486
$request->session()->regenerate(true);
487+
$request->session()->forget('2fa_authed');
487488

488489
if ($request->session()->has('password_hash_'.Auth::getDefaultDriver())){
489490
$request->session()->remove('password_hash_'.Auth::getDefaultDriver());

app/Http/Controllers/ReportsController.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,11 @@ public function postCustom(CustomAssetReportRequest $request) : StreamedResponse
737737
if (($request->filled('next_audit_start')) && ($request->filled('next_audit_end'))) {
738738
$assets->whereBetween('assets.next_audit_date', [$request->input('next_audit_start'), $request->input('next_audit_end')]);
739739
}
740+
741+
if (($request->filled('last_updated_start')) && ($request->filled('last_updated_end'))) {
742+
$assets->whereBetween('assets.updated_at', [$request->input('last_updated_start'), $request->input('last_updated_end')]);
743+
}
744+
740745
if ($request->filled('exclude_archived')) {
741746
$assets->notArchived();
742747
}

app/Http/Requests/StoreAssetModelRequest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public function authorize(): bool
1919

2020
public function prepareForValidation(): void
2121
{
22+
parent::prepareForValidation();
2223

2324
if ($this->category_id) {
2425
if ($category = Category::find($this->category_id)) {

app/Models/CustomFieldset.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ public function validation_rules()
113113
$rule[] = 'unique_undeleted';
114114
}
115115

116-
array_push($rule, $field->attributes['format']);
116+
if ($field->attributes['format']!='') {
117+
array_push($rule, $field->attributes['format']);
118+
}
119+
117120
$rules[$field->db_column_name()] = $rule;
118121

119122

resources/views/reports/custom.blade.php

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ class="form-control"
411411
<!-- Purchase Date -->
412412
<div class="form-group purchase-range{{ ($errors->has('purchase_start') || $errors->has('purchase_end')) ? ' has-error' : '' }}">
413413
<label for="purchase_start" class="col-md-3 control-label">{{ trans('general.purchase_date') }}</label>
414-
<div class="input-daterange input-group col-md-7" id="datepicker">
414+
<div class="input-daterange input-group col-md-7" id="purchase-range-datepicker">
415415
<input type="text" class="form-control" name="purchase_start" aria-label="purchase_start" value="{{ $template->textValue('purchase_start', old('purchase_start')) }}">
416416
<span class="input-group-addon">{{ strtolower(trans('general.to')) }}</span>
417417
<input type="text" class="form-control" name="purchase_end" aria-label="purchase_end" value="{{ $template->textValue('purchase_end', old('purchase_end')) }}">
@@ -427,9 +427,9 @@ class="form-control"
427427
</div>
428428

429429
<!-- Created Date -->
430-
<div class="form-group purchase-range{{ ($errors->has('created_start') || $errors->has('created_end')) ? ' has-error' : '' }}">
430+
<div class="form-group created-range{{ ($errors->has('created_start') || $errors->has('created_end')) ? ' has-error' : '' }}">
431431
<label for="created_start" class="col-md-3 control-label">{{ trans('general.created_at') }} </label>
432-
<div class="input-daterange input-group col-md-7" id="datepicker">
432+
<div class="input-daterange input-group col-md-7" id="created-range-datepicker">
433433
<input type="text" class="form-control" name="created_start" aria-label="created_start" value="{{ $template->textValue('created_start', old('created_start')) }}">
434434
<span class="input-group-addon">{{ strtolower(trans('general.to')) }}</span>
435435
<input type="text" class="form-control" name="created_end" aria-label="created_end" value="{{ $template->textValue('created_end', old('created_end')) }}">
@@ -446,7 +446,7 @@ class="form-control"
446446
<!-- Checkout Date -->
447447
<div class="form-group checkout-range{{ ($errors->has('checkout_date_start') || $errors->has('checkout_date_end')) ? ' has-error' : '' }}">
448448
<label for="checkout_date" class="col-md-3 control-label">{{ trans('general.checkout') }} </label>
449-
<div class="input-daterange input-group col-md-7" id="datepicker">
449+
<div class="input-daterange input-group col-md-7" id="checkout-range-datepicker">
450450
<input type="text" class="form-control" name="checkout_date_start" aria-label="checkout_date_start" value="{{ $template->textValue('checkout_date_start', old('checkout_date_start')) }}">
451451
<span class="input-group-addon">{{ strtolower(trans('general.to')) }}</span>
452452
<input type="text" class="form-control" name="checkout_date_end" aria-label="checkout_date_end" value="{{ $template->textValue('checkout_date_end', old('checkout_date_end')) }}">
@@ -464,7 +464,7 @@ class="form-control"
464464
<!-- Last Checkin Date -->
465465
<div class="form-group checkin-range{{ ($errors->has('checkin_date_start') || $errors->has('checkin_date_end')) ? ' has-error' : '' }}">
466466
<label for="checkin_date" class="col-md-3 control-label">{{ trans('admin/hardware/table.last_checkin_date') }}</label>
467-
<div class="input-daterange input-group col-md-7" id="datepicker">
467+
<div class="input-daterange input-group col-md-7" id="checkin-range-datepicker">
468468
<input type="text" class="form-control" name="checkin_date_start" aria-label="checkin_date_start" value="{{ $template->textValue('checkin_date_start', old('checkin_date_start')) }}">
469469
<span class="input-group-addon">{{ strtolower(trans('general.to')) }}</span>
470470
<input type="text" class="form-control" name="checkin_date_end" aria-label="checkin_date_end" value="{{ $template->textValue('checkin_date_end', old('checkin_date_end')) }}">
@@ -481,7 +481,7 @@ class="form-control"
481481
<!-- Expected Checkin Date -->
482482
<div class="form-group expected_checkin-range{{ ($errors->has('expected_checkin_start') || $errors->has('expected_checkin_end')) ? ' has-error' : '' }}">
483483
<label for="expected_checkin_start" class="col-md-3 control-label">{{ trans('admin/hardware/form.expected_checkin') }}</label>
484-
<div class="input-daterange input-group col-md-7" id="datepicker">
484+
<div class="input-daterange input-group col-md-7" id="expected_checkin-range-datepicker">
485485
<input type="text" class="form-control" name="expected_checkin_start" aria-label="expected_checkin_start" value="{{ $template->textValue('expected_checkin_start', old('expected_checkin_start')) }}">
486486
<span class="input-group-addon">{{ strtolower(trans('general.to')) }}</span>
487487
<input type="text" class="form-control" name="expected_checkin_end" aria-label="expected_checkin_end" value="{{ $template->textValue('expected_checkin_end', old('expected_checkin_end')) }}">
@@ -499,7 +499,7 @@ class="form-control"
499499
<!-- EoL Date -->
500500
<div class="form-group asset_eol_date-range {{ ($errors->has('asset_eol_date_start') || $errors->has('asset_eol_date_end')) ? ' has-error' : '' }}">
501501
<label for="asset_eol_date" class="col-md-3 control-label">{{ trans('admin/hardware/form.eol_date') }}</label>
502-
<div class="input-daterange input-group col-md-7" id="datepicker">
502+
<div class="input-daterange input-group col-md-7" id="asset_eol_date-range-datepicker">
503503
<input type="text" class="form-control" name="asset_eol_date_start" aria-label="asset_eol_date_start" value="{{ $template->textValue('asset_eol_date_start', old('asset_eol_date_start')) }}">
504504
<span class="input-group-addon">to</span>
505505
<input type="text" class="form-control" name="asset_eol_date_end" aria-label="asset_eol_date_end" value="{{ $template->textValue('asset_eol_date_end', old('asset_eol_date_end')) }}">
@@ -516,7 +516,7 @@ class="form-control"
516516
<!-- Last Audit Date -->
517517
<div class="form-group last_audit-range{{ ($errors->has('last_audit_start') || $errors->has('last_audit_end')) ? ' has-error' : '' }}">
518518
<label for="last_audit_start" class="col-md-3 control-label">{{ trans('general.last_audit') }}</label>
519-
<div class="input-daterange input-group col-md-7" id="datepicker">
519+
<div class="input-daterange input-group col-md-7" id="last_audit-range-datepicker">
520520
<input type="text" class="form-control" name="last_audit_start" aria-label="last_audit_start" value="{{ $template->textValue('last_audit_start', old('last_audit_start')) }}">
521521
<span class="input-group-addon">{{ strtolower(trans('general.to')) }}</span>
522522
<input type="text" class="form-control" name="last_audit_end" aria-label="last_audit_end" value="{{ $template->textValue('last_audit_end', old('last_audit_end')) }}">
@@ -533,7 +533,7 @@ class="form-control"
533533
<!-- Next Audit Date -->
534534
<div class="form-group next_audit-range{{ ($errors->has('next_audit_start') || $errors->has('next_audit_end')) ? ' has-error' : '' }}">
535535
<label for="next_audit_start" class="col-md-3 control-label">{{ trans('general.next_audit_date') }}</label>
536-
<div class="input-daterange input-group col-md-7" id="datepicker">
536+
<div class="input-daterange input-group col-md-7" id="next_audit-range-datepicker">
537537
<input type="text" class="form-control" name="next_audit_start" aria-label="next_audit_start" value="{{ $template->textValue('next_audit_start', old('next_audit_start')) }}">
538538
<span class="input-group-addon">{{ strtolower(trans('general.to')) }}</span>
539539
<input type="text" class="form-control" name="next_audit_end" aria-label="next_audit_end" value="{{ $template->textValue('next_audit_end', old('next_audit_end')) }}">
@@ -547,6 +547,24 @@ class="form-control"
547547
@endif
548548
</div>
549549

550+
<!-- Last updated Date -->
551+
<div class="form-group last_updated-range{{ ($errors->has('last_updated_start') || $errors->has('last_updated_end')) ? ' has-error' : '' }}">
552+
<label for="last_updated_start" class="col-md-3 control-label">{{ trans('general.updated_at') }}</label>
553+
<div class="input-daterange input-group col-md-7" id="last_updated-range-datepicker">
554+
<input type="text" class="form-control" name="last_updated_start" aria-label="last_updated_start" value="{{ $template->textValue('last_updated_start', old('last_updated_start')) }}">
555+
<span class="input-group-addon">{{ strtolower(trans('general.to')) }}</span>
556+
<input type="text" class="form-control" name="last_updated_end" aria-label="last_updated_end" value="{{ $template->textValue('last_updated_end', old('last_updated_end')) }}">
557+
</div>
558+
559+
@if ($errors->has('last_updated_start') || $errors->has('last_updated_end'))
560+
<div class="col-md-9 col-lg-offset-3">
561+
{!! $errors->first('last_updated_start', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
562+
{!! $errors->first('last_updated_end', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
563+
</div>
564+
@endif
565+
566+
</div>
567+
550568
<div class="col-md-9 col-md-offset-3">
551569
<label class="form-control">
552570
<input type="checkbox" name="exclude_archived" value="1" @checked($template->checkmarkValue('exclude_archived', '0')) />
@@ -759,6 +777,14 @@ class="form-control"
759777
format: 'yyyy-mm-dd'
760778
});
761779
780+
$('.last_updated-range .input-daterange').datepicker({
781+
clearBtn: true,
782+
todayHighlight: true,
783+
endDate:'0d',
784+
format: 'yyyy-mm-dd'
785+
});
786+
787+
762788
$("#checkAll").change(function () {
763789
$("#included_fields_wrapper input:checkbox").prop('checked', $(this).prop("checked"));
764790
});

snipeit.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,22 @@ create_user () {
179179

180180
if [[ "$distro" == "Ubuntu" ]] || [[ "$distro" == "Debian" ]] || [[ "$distro" == "Raspbian" ]] ; then
181181
/usr/sbin/adduser --quiet --disabled-password --gecos 'Snipe-IT User' "$APP_USER"
182-
su -c "/usr/sbin/usermod -a -G "$apache_group" "$APP_USER""
183182
else
184-
adduser "$APP_USER"
185-
usermod -a -G "$apache_group" "$APP_USER"
183+
adduser -c "Snipe-IT User" "$APP_USER"
186184
fi
185+
186+
# Add the user to the apache group so the app can write to any files apache
187+
# creates (eg, if apache process creates the log, but then a an app-user-owned
188+
# cron also tries writing
189+
usermod -a -G "$apache_group" "$APP_USER"
190+
191+
# Now do the reverse -- so apache can write to the log that the user may
192+
# have created. This was actively a problem on new installs, hobbling
193+
# imports
194+
# redefining these variables just for clarity
195+
apache_user="$apache_group"
196+
app_group="$APP_USER"
197+
usermod -a -G "$app_group" "$apache_user"
187198
}
188199

189200
run_as_app_user () {

0 commit comments

Comments
 (0)