Skip to content

Commit 82108f8

Browse files
authored
Merge pull request #15208 from akemidx/feature/sc-26415
FEATURE: Option for Notes to be Required on Asset Checkin/Checkout
2 parents fa80716 + a7dae10 commit 82108f8

File tree

10 files changed

+80
-16
lines changed

10 files changed

+80
-16
lines changed

app/Http/Controllers/SettingsController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ public function postSettings(Request $request) : RedirectResponse
334334
$setting->depreciation_method = $request->input('depreciation_method');
335335
$setting->dash_chart_type = $request->input('dash_chart_type');
336336
$setting->profile_edit = $request->input('profile_edit', 0);
337+
$setting->require_checkinout_notes = $request->input('require_checkinout_notes', 0);
338+
337339

338340
if ($request->input('per_page') != '') {
339341
$setting->per_page = $request->input('per_page');

app/Http/Requests/AssetCheckinRequest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,14 @@ public function authorize()
2121
*/
2222
public function rules()
2323
{
24-
return [
24+
$settings = \App\Models\Setting::getSettings();
2525

26-
];
26+
$rules = [];
27+
28+
if($settings->require_checkinout_notes) {
29+
$rules['note'] = 'string|required';
30+
}
31+
return $rules;
2732
}
2833

2934
public function response(array $errors)

app/Http/Requests/AssetCheckoutRequest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public function authorize()
2121
*/
2222
public function rules()
2323
{
24+
$settings = \App\Models\Setting::getSettings();
25+
2426
$rules = [
2527
'assigned_user' => 'required_without_all:assigned_asset,assigned_location',
2628
'assigned_asset' => 'required_without_all:assigned_user,assigned_location',
@@ -35,7 +37,11 @@ public function rules()
3537
'nullable',
3638
'date'
3739
],
38-
];
40+
];
41+
42+
if($settings->require_checkinout_notes) {
43+
$rules['note'] = 'required|string';
44+
}
3945

4046
return $rules;
4147
}

app/Models/Setting.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class Setting extends Model
7070

7171
protected $casts = [
7272
'label2_asset_logo' => 'boolean',
73+
'require_checkinout_notes' => 'boolean',
7374
];
7475

7576
/**
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::table('settings', function (Blueprint $table) {
15+
$table->boolean('require_checkinout_notes')->nullable()->default(0);
16+
});
17+
}
18+
19+
/**
20+
* Reverse the migrations.
21+
*/
22+
public function down(): void
23+
{
24+
Schema::table('settings', function (Blueprint $table) {
25+
if (Schema::hasColumn('settings', 'require_checkinout_notes')) {
26+
$table->dropColumn('require_checkinout_notes');
27+
}
28+
});
29+
}
30+
};

resources/assets/less/app.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ a.logo.no-hover a:hover {
384384
background-color: transparent;
385385
}
386386

387-
input:required, select:required {
387+
input:required, select:required, textarea:required {
388388
border-right: 6px solid orange;
389389
}
390390

resources/lang/en-US/admin/settings/general.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@
280280
'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",
281281
'require_accept_signature' => 'Require Signature',
282282
'require_accept_signature_help_text' => 'Enabling this feature will require users to physically sign off on accepting an asset.',
283+
'require_checkinout_notes' => 'Require Notes on Checkin/Checkout',
284+
'require_checkinout_notes_help_text' => 'Enabling this feature will require the note fields to be populated when checking in or checking out an asset.',
283285
'left' => 'left',
284286
'right' => 'right',
285287
'top' => 'top',

resources/views/hardware/checkin.blade.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,17 +113,17 @@
113113
</div>
114114
</div>
115115

116-
<!-- Note -->
117-
<div class="form-group {{ $errors->has('note') ? 'error' : '' }}">
118-
<label for="note" class="col-sm-3 control-label">
119-
{{ trans('general.notes') }}
120-
</label>
121-
<div class="col-md-8">
122-
<textarea class="col-md-6 form-control" id="note"
123-
name="note">{{ old('note', $asset->note) }}</textarea>
124-
{!! $errors->first('note', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
125-
</div>
126-
</div>
116+
<!-- Note -->
117+
<div class="form-group {{ $errors->has('note') ? 'error' : '' }}">
118+
<label for="note" class="col-md-3 control-label">
119+
{{ trans('general.notes') }}
120+
</label>
121+
<div class="col-md-8">
122+
<textarea class="col-md-6 form-control" id="note" @required($snipeSettings->require_checkinout_notes)
123+
name="note">{{ old('note', $asset->note) }}</textarea>
124+
{!! $errors->first('note', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
125+
</div>
126+
</div>
127127
</div> <!--/.box-body-->
128128
</div> <!--/.box-body-->
129129

resources/views/hardware/checkout.blade.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,9 @@
141141
<label for="note" class="col-md-3 control-label">
142142
{{ trans('general.notes') }}
143143
</label>
144+
144145
<div class="col-md-8">
145-
<textarea class="col-md-6 form-control" id="note"
146+
<textarea class="col-md-6 form-control" id="note" @required($snipeSettings->require_checkinout_notes)
146147
name="note">{{ old('note', $asset->note) }}</textarea>
147148
{!! $errors->first('note', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
148149
</div>

resources/views/settings/general.blade.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,23 @@
215215
</div>
216216
</div>
217217

218+
<!-- Require Notes on checkin/checkout checkbox -->
219+
<div class="form-group">
220+
<div class="col-md-3">
221+
<label>
222+
{{ trans('admin/settings/general.require_checkinout_notes') }}
223+
</label>
224+
</div>
225+
<div class="col-md-8">
226+
<label class="form-control">
227+
<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">
228+
{{ trans('general.yes') }}
229+
</label>
230+
<p class="help-block">{{ trans('admin/settings/general.require_checkinout_notes_help_text') }}</p>
231+
</div>
232+
</div>
233+
<!-- /.form-group -->
234+
218235

219236
<!-- login text -->
220237
<div class="form-group {{ $errors->has('login_note') ? 'error' : '' }}">

0 commit comments

Comments
 (0)