Merge pull request #15208 from akemidx/feature/sc-26415

FEATURE: Option for Notes to be Required on Asset Checkin/Checkout
This commit is contained in:
snipe
2024-11-26 20:11:04 +00:00
committed by GitHub
10 changed files with 80 additions and 16 deletions
@@ -334,6 +334,8 @@ class SettingsController extends Controller
$setting->depreciation_method = $request->input('depreciation_method');
$setting->dash_chart_type = $request->input('dash_chart_type');
$setting->profile_edit = $request->input('profile_edit', 0);
$setting->require_checkinout_notes = $request->input('require_checkinout_notes', 0);
if ($request->input('per_page') != '') {
$setting->per_page = $request->input('per_page');
+7 -2
View File
@@ -21,9 +21,14 @@ class AssetCheckinRequest extends Request
*/
public function rules()
{
return [
$settings = \App\Models\Setting::getSettings();
];
$rules = [];
if($settings->require_checkinout_notes) {
$rules['note'] = 'string|required';
}
return $rules;
}
public function response(array $errors)
+7 -1
View File
@@ -21,6 +21,8 @@ class AssetCheckoutRequest extends Request
*/
public function rules()
{
$settings = \App\Models\Setting::getSettings();
$rules = [
'assigned_user' => 'required_without_all:assigned_asset,assigned_location',
'assigned_asset' => 'required_without_all:assigned_user,assigned_location',
@@ -35,7 +37,11 @@ class AssetCheckoutRequest extends Request
'nullable',
'date'
],
];
];
if($settings->require_checkinout_notes) {
$rules['note'] = 'required|string';
}
return $rules;
}
+1
View File
@@ -70,6 +70,7 @@ class Setting extends Model
protected $casts = [
'label2_asset_logo' => 'boolean',
'require_checkinout_notes' => 'boolean',
];
/**
@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('settings', function (Blueprint $table) {
$table->boolean('require_checkinout_notes')->nullable()->default(0);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('settings', function (Blueprint $table) {
if (Schema::hasColumn('settings', 'require_checkinout_notes')) {
$table->dropColumn('require_checkinout_notes');
}
});
}
};
+1 -1
View File
@@ -384,7 +384,7 @@ a.logo.no-hover a:hover {
background-color: transparent;
}
input:required, select:required {
input:required, select:required, textarea:required {
border-right: 6px solid orange;
}
@@ -280,6 +280,8 @@ return [
'two_factor_enrollment_text' => "Two factor authentication is required, however your device has not been enrolled yet. Open your Google Authenticator app and scan the QR code below to enroll your device. Once you've enrolled your device, enter the code below",
'require_accept_signature' => 'Require Signature',
'require_accept_signature_help_text' => 'Enabling this feature will require users to physically sign off on accepting an asset.',
'require_checkinout_notes' => 'Require Notes on Checkin/Checkout',
'require_checkinout_notes_help_text' => 'Enabling this feature will require the note fields to be populated when checking in or checking out an asset.',
'left' => 'left',
'right' => 'right',
'top' => 'top',
+11 -11
View File
@@ -113,17 +113,17 @@
</div>
</div>
<!-- Note -->
<div class="form-group {{ $errors->has('note') ? 'error' : '' }}">
<label for="note" class="col-sm-3 control-label">
{{ trans('general.notes') }}
</label>
<div class="col-md-8">
<textarea class="col-md-6 form-control" id="note"
name="note">{{ old('note', $asset->note) }}</textarea>
{!! $errors->first('note', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
</div>
<!-- Note -->
<div class="form-group {{ $errors->has('note') ? 'error' : '' }}">
<label for="note" class="col-md-3 control-label">
{{ trans('general.notes') }}
</label>
<div class="col-md-8">
<textarea class="col-md-6 form-control" id="note" @required($snipeSettings->require_checkinout_notes)
name="note">{{ old('note', $asset->note) }}</textarea>
{!! $errors->first('note', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
</div>
</div> <!--/.box-body-->
</div> <!--/.box-body-->
+2 -1
View File
@@ -141,8 +141,9 @@
<label for="note" class="col-md-3 control-label">
{{ trans('general.notes') }}
</label>
<div class="col-md-8">
<textarea class="col-md-6 form-control" id="note"
<textarea class="col-md-6 form-control" id="note" @required($snipeSettings->require_checkinout_notes)
name="note">{{ old('note', $asset->note) }}</textarea>
{!! $errors->first('note', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
@@ -215,6 +215,23 @@
</div>
</div>
<!-- Require Notes on checkin/checkout checkbox -->
<div class="form-group">
<div class="col-md-3">
<label>
{{ trans('admin/settings/general.require_checkinout_notes') }}
</label>
</div>
<div class="col-md-8">
<label class="form-control">
<input type="checkbox" value="1" name="require_checkinout_notes" {{ (old('require_checkinout_notes', $setting->require_checkinout_notes)) == '1' ? ' checked="checked"' : '' }} aria-label="require_checkinout_notes">
{{ trans('general.yes') }}
</label>
<p class="help-block">{{ trans('admin/settings/general.require_checkinout_notes_help_text') }}</p>
</div>
</div>
<!-- /.form-group -->
<!-- login text -->
<div class="form-group {{ $errors->has('login_note') ? 'error' : '' }}">