Merge branch 'develop' of https://github.com/snipe/snipe-it into develop
Some checks are pending
Crowdin Action / upload-sources-to-crowdin (push) Waiting to run
Docker images (Alpine) / docker (push) Waiting to run
Docker images / docker (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.1) (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.2) (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.3) (push) Waiting to run
Tests in SQLite / PHP ${{ matrix.php-version }} (8.1.1) (push) Waiting to run

This commit is contained in:
snipe 2024-11-26 20:12:14 +00:00
commit 11f83b4cd9
10 changed files with 80 additions and 16 deletions

View file

@ -334,6 +334,8 @@ class SettingsController extends Controller
$setting->depreciation_method = $request->input('depreciation_method'); $setting->depreciation_method = $request->input('depreciation_method');
$setting->dash_chart_type = $request->input('dash_chart_type'); $setting->dash_chart_type = $request->input('dash_chart_type');
$setting->profile_edit = $request->input('profile_edit', 0); $setting->profile_edit = $request->input('profile_edit', 0);
$setting->require_checkinout_notes = $request->input('require_checkinout_notes', 0);
if ($request->input('per_page') != '') { if ($request->input('per_page') != '') {
$setting->per_page = $request->input('per_page'); $setting->per_page = $request->input('per_page');

View file

@ -21,9 +21,14 @@ class AssetCheckinRequest extends Request
*/ */
public function rules() 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) public function response(array $errors)

View file

@ -21,6 +21,8 @@ class AssetCheckoutRequest extends Request
*/ */
public function rules() public function rules()
{ {
$settings = \App\Models\Setting::getSettings();
$rules = [ $rules = [
'assigned_user' => 'required_without_all:assigned_asset,assigned_location', 'assigned_user' => 'required_without_all:assigned_asset,assigned_location',
'assigned_asset' => 'required_without_all:assigned_user,assigned_location', 'assigned_asset' => 'required_without_all:assigned_user,assigned_location',
@ -35,7 +37,11 @@ class AssetCheckoutRequest extends Request
'nullable', 'nullable',
'date' 'date'
], ],
]; ];
if($settings->require_checkinout_notes) {
$rules['note'] = 'required|string';
}
return $rules; return $rules;
} }

View file

@ -70,6 +70,7 @@ class Setting extends Model
protected $casts = [ protected $casts = [
'label2_asset_logo' => 'boolean', 'label2_asset_logo' => 'boolean',
'require_checkinout_notes' => 'boolean',
]; ];
/** /**

View file

@ -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');
}
});
}
};

View file

@ -384,7 +384,7 @@ a.logo.no-hover a:hover {
background-color: transparent; background-color: transparent;
} }
input:required, select:required { input:required, select:required, textarea:required {
border-right: 6px solid orange; border-right: 6px solid orange;
} }

View file

@ -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", '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' => 'Require Signature',
'require_accept_signature_help_text' => 'Enabling this feature will require users to physically sign off on accepting an asset.', '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', 'left' => 'left',
'right' => 'right', 'right' => 'right',
'top' => 'top', 'top' => 'top',

View file

@ -113,17 +113,17 @@
</div> </div>
</div> </div>
<!-- Note --> <!-- Note -->
<div class="form-group {{ $errors->has('note') ? 'error' : '' }}"> <div class="form-group {{ $errors->has('note') ? 'error' : '' }}">
<label for="note" class="col-sm-3 control-label"> <label for="note" class="col-md-3 control-label">
{{ trans('general.notes') }} {{ trans('general.notes') }}
</label> </label>
<div class="col-md-8"> <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> 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>') !!} {!! $errors->first('note', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div> </div>
</div> </div>
</div> <!--/.box-body--> </div> <!--/.box-body-->
</div> <!--/.box-body--> </div> <!--/.box-body-->

View file

@ -141,8 +141,9 @@
<label for="note" class="col-md-3 control-label"> <label for="note" class="col-md-3 control-label">
{{ trans('general.notes') }} {{ trans('general.notes') }}
</label> </label>
<div class="col-md-8"> <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> 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>') !!} {!! $errors->first('note', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div> </div>

View file

@ -215,6 +215,23 @@
</div> </div>
</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 --> <!-- login text -->
<div class="form-group {{ $errors->has('login_note') ? 'error' : '' }}"> <div class="form-group {{ $errors->has('login_note') ? 'error' : '' }}">