Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: Option for Notes to be Required on Asset Checkin/Checkout #15208

Merged
merged 32 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
552f90a
required, but not optional
akemidx Aug 1, 2024
3ff1745
setting created
akemidx Aug 1, 2024
0f0baa2
note field optional
akemidx Aug 1, 2024
4e43fa6
Merge remote-tracking branch 'upstream/develop' into feature/sc-26415
akemidx Aug 20, 2024
27c120a
front end changes/updates from gh
akemidx Aug 20, 2024
2901ecb
more test work
akemidx Sep 3, 2024
77c5035
fixing some formatting
akemidx Sep 4, 2024
bebb72a
back to having tests pass. needed to comment out the notes rules() i …
akemidx Sep 4, 2024
d262638
backend form validation. +cleanup
akemidx Sep 4, 2024
73a059c
missing closing )
akemidx Oct 1, 2024
081c570
required, but not optional
akemidx Aug 1, 2024
700647c
setting created
akemidx Aug 1, 2024
8b643cb
note field optional
akemidx Aug 1, 2024
5e74b10
front end changes/updates from gh
akemidx Aug 20, 2024
515f59f
more test work
akemidx Sep 3, 2024
bd6698d
fixing some formatting
akemidx Sep 4, 2024
925aea8
back to having tests pass. needed to comment out the notes rules() i …
akemidx Sep 4, 2024
f45b836
backend form validation. +cleanup
akemidx Sep 4, 2024
6fef127
missing closing )
akemidx Oct 1, 2024
17706f1
requested changes
akemidx Oct 2, 2024
492e686
Merge remote-tracking branch 'origin/feature/sc-26415' into feature/s…
akemidx Oct 2, 2024
06e3bb7
requested changes
akemidx Oct 2, 2024
e00a1ae
note box is now missing when unchecking setting
akemidx Oct 2, 2024
0c84904
un'required'ing the rule. not sure what's breaking here but looking
akemidx Oct 2, 2024
299e743
weird requesting
akemidx Oct 8, 2024
5cb940c
Merge branch 'refs/heads/upstream/dev' into feature/sc-26415
akemidx Oct 16, 2024
f0d3a6e
removing some comments/merging in develop
akemidx Oct 16, 2024
9cb411c
removing required form div container
akemidx Nov 13, 2024
dd223fc
commit for testing
akemidx Nov 22, 2024
0d60855
orange bar for requirednessness
akemidx Nov 22, 2024
2727210
requested changes from pr
akemidx Nov 26, 2024
a7dae10
fixing line
akemidx Nov 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/Http/Controllers/Assets/AssetCheckinController.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ public function store(AssetCheckinRequest $request, $assetId = null, $backto = n
$seat->update(['assigned_to' => null]);
});

$settings = \App\Models\Setting::getSettings();

if($settings->require_checkinout_notes=="1" && (is_null($request->note))) {
return redirect()->to("hardware/$assetId/checkin")->with('error', trans('admin/hardware/message.update.no_note'));
}
akemidx marked this conversation as resolved.
Show resolved Hide resolved

// Get all pending Acceptances for this asset and delete them
$acceptances = CheckoutAcceptance::pending()->whereHasMorph('checkoutable',
[Asset::class],
Expand Down
4 changes: 4 additions & 0 deletions app/Http/Controllers/Assets/AssetCheckoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ public function store(AssetCheckoutRequest $request, $assetId) : RedirectRespons

$settings = \App\Models\Setting::getSettings();

if($settings->require_checkinout_notes=="1" && (is_null($request->note))) {
return redirect()->to("hardware/$assetId/checkout")->with('error', trans('admin/hardware/message.update.no_note'));
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above but it'll go in AssetCheckoutRequest.

// We have to check whether $target->company_id is null here since locations don't have a company yet
if (($settings->full_multiple_companies_support) && ((!is_null($target->company_id)) && (!is_null($asset->company_id)))) {
if ($target->company_id != $asset->company_id){
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ public function postSettings(Request $request) : RedirectResponse
$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');
Expand Down
12 changes: 0 additions & 12 deletions app/Http/Requests/AssetCheckinRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,6 @@ public function authorize()
return true;
}

/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [

];
}

akemidx marked this conversation as resolved.
Show resolved Hide resolved
public function response(array $errors)
{
return $this->redirector->back()->withInput()->withErrors($errors, $this->errorBag);
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
akemidx marked this conversation as resolved.
Show resolved Hide resolved
});
}

/**
* 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');
}
});
}
};
2 changes: 2 additions & 0 deletions resources/lang/en-US/admin/hardware/message.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
'nothing_updated' => 'No fields were selected, so nothing was updated.',
'no_assets_selected' => 'No assets were selected, so nothing was updated.',
'assets_do_not_exist_or_are_invalid' => 'Selected assets cannot be updated.',
'no_note' => 'Note field is empty',
akemidx marked this conversation as resolved.
Show resolved Hide resolved
],

'restore' => [
Expand Down Expand Up @@ -76,6 +77,7 @@
'user_does_not_exist' => 'That user is invalid. Please try again.',
'not_available' => 'That asset is not available for checkout!',
'no_assets_selected' => 'You must select at least one asset from the list',

],

'checkin' => [
Expand Down
2 changes: 2 additions & 0 deletions resources/lang/en-US/admin/settings/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@
'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',
Expand Down
24 changes: 13 additions & 11 deletions resources/views/hardware/checkin.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,19 @@
</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>
@if($snipeSettings->require_checkinout_notes=="1")
<div class="col-md-8 required">
akemidx marked this conversation as resolved.
Show resolved Hide resolved
<textarea class="col-md-6 form-control" id="note" required="true"
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>
@endif
</div>
</div> <!--/.box-body-->
</div> <!--/.box-body-->

Expand Down
8 changes: 8 additions & 0 deletions resources/views/hardware/checkout.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,19 @@
<label for="note" class="col-md-3 control-label">
{{ trans('general.notes') }}
</label>
@if($snipeSettings->require_checkinout_notes=="1")
<div class="col-md-8 required">
<textarea class="col-md-6 form-control" id="note" required="true"
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>
@else
<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>
@endif
</div>

@if ($asset->requireAcceptance() || $asset->getEula() || ($snipeSettings->webhook_endpoint!=''))
Expand Down
17 changes: 17 additions & 0 deletions resources/views/settings/general.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' : '' }}">
Expand Down
Loading