diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index aa773d9ee..2186a3fc7 100755 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -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'); diff --git a/app/Http/Requests/AssetCheckinRequest.php b/app/Http/Requests/AssetCheckinRequest.php index 116b8b39f..8980cea09 100644 --- a/app/Http/Requests/AssetCheckinRequest.php +++ b/app/Http/Requests/AssetCheckinRequest.php @@ -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) diff --git a/app/Http/Requests/AssetCheckoutRequest.php b/app/Http/Requests/AssetCheckoutRequest.php index f48a7d5e5..c8245682a 100644 --- a/app/Http/Requests/AssetCheckoutRequest.php +++ b/app/Http/Requests/AssetCheckoutRequest.php @@ -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; } diff --git a/app/Models/Setting.php b/app/Models/Setting.php index 6f585b95f..232285fbd 100755 --- a/app/Models/Setting.php +++ b/app/Models/Setting.php @@ -70,6 +70,7 @@ class Setting extends Model protected $casts = [ 'label2_asset_logo' => 'boolean', + 'require_checkinout_notes' => 'boolean', ]; /** diff --git a/database/migrations/2024_08_01_201721_add_required_notes_setting.php b/database/migrations/2024_08_01_201721_add_required_notes_setting.php new file mode 100644 index 000000000..38fdd38c1 --- /dev/null +++ b/database/migrations/2024_08_01_201721_add_required_notes_setting.php @@ -0,0 +1,30 @@ +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'); + } + }); + } +}; diff --git a/resources/assets/less/app.less b/resources/assets/less/app.less index 37514e5cf..259172bae 100644 --- a/resources/assets/less/app.less +++ b/resources/assets/less/app.less @@ -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; } diff --git a/resources/lang/en-US/admin/settings/general.php b/resources/lang/en-US/admin/settings/general.php index d656391ed..db8340246 100644 --- a/resources/lang/en-US/admin/settings/general.php +++ b/resources/lang/en-US/admin/settings/general.php @@ -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', diff --git a/resources/views/hardware/checkin.blade.php b/resources/views/hardware/checkin.blade.php index 5686e74dd..9188d81ea 100755 --- a/resources/views/hardware/checkin.blade.php +++ b/resources/views/hardware/checkin.blade.php @@ -113,17 +113,17 @@ - -
- -
- - {!! $errors->first('note', '') !!} -
-
+ +
+ +
+ + {!! $errors->first('note', '') !!} +
+
diff --git a/resources/views/hardware/checkout.blade.php b/resources/views/hardware/checkout.blade.php index 943b4ba79..e0dc8ef51 100755 --- a/resources/views/hardware/checkout.blade.php +++ b/resources/views/hardware/checkout.blade.php @@ -141,8 +141,9 @@ +
- {!! $errors->first('note', '') !!}
diff --git a/resources/views/settings/general.blade.php b/resources/views/settings/general.blade.php index 17c0a8ec8..1de5d4035 100644 --- a/resources/views/settings/general.blade.php +++ b/resources/views/settings/general.blade.php @@ -215,6 +215,23 @@ + +
+
+ +
+
+ +

{{ trans('admin/settings/general.require_checkinout_notes_help_text') }}

+
+
+ +