mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-02 08:21:09 -08:00
backend form validation. +cleanup
This commit is contained in:
parent
925aea8531
commit
f45b836010
|
@ -116,6 +116,12 @@ class AssetCheckinController extends Controller
|
||||||
$seat->update(['assigned_to' => null]);
|
$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'));
|
||||||
|
}
|
||||||
|
|
||||||
// Get all pending Acceptances for this asset and delete them
|
// Get all pending Acceptances for this asset and delete them
|
||||||
$acceptances = CheckoutAcceptance::pending()->whereHasMorph('checkoutable',
|
$acceptances = CheckoutAcceptance::pending()->whereHasMorph('checkoutable',
|
||||||
[Asset::class],
|
[Asset::class],
|
||||||
|
|
|
@ -102,6 +102,10 @@ class AssetCheckoutController extends Controller
|
||||||
|
|
||||||
$settings = \App\Models\Setting::getSettings();
|
$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'); //needs translation
|
||||||
|
}
|
||||||
|
|
||||||
// We have to check whether $target->company_id is null here since locations don't have a company yet
|
// 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 (($settings->full_multiple_companies_support) && ((!is_null($target->company_id)) && (!is_null($asset->company_id)))) {
|
||||||
if ($target->company_id != $asset->company_id){
|
if ($target->company_id != $asset->company_id){
|
||||||
|
|
|
@ -14,18 +14,6 @@ class AssetCheckinRequest extends Request
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the validation rules that apply to the request.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
// public function rules()
|
|
||||||
// {
|
|
||||||
// 'note' => 'required|in:asset,',
|
|
||||||
//
|
|
||||||
// return $rules;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public function response(array $errors)
|
public function response(array $errors)
|
||||||
{
|
{
|
||||||
return $this->redirector->back()->withInput()->withErrors($errors, $this->errorBag);
|
return $this->redirector->back()->withInput()->withErrors($errors, $this->errorBag);
|
||||||
|
|
|
@ -27,7 +27,6 @@ class AssetCheckoutRequest extends Request
|
||||||
'assigned_location' => 'required_without_all:assigned_user,assigned_asset',
|
'assigned_location' => 'required_without_all:assigned_user,assigned_asset',
|
||||||
'status_id' => 'exists:status_labels,id,deployable,1',
|
'status_id' => 'exists:status_labels,id,deployable,1',
|
||||||
'checkout_to_type' => 'required|in:asset,location,user',
|
'checkout_to_type' => 'required|in:asset,location,user',
|
||||||
// 'note' => 'required|in:asset,',
|
|
||||||
'checkout_at' => [
|
'checkout_at' => [
|
||||||
'nullable',
|
'nullable',
|
||||||
'date',
|
'date',
|
||||||
|
|
|
@ -23,6 +23,7 @@ return [
|
||||||
'nothing_updated' => 'No fields were selected, so nothing was updated.',
|
'nothing_updated' => 'No fields were selected, so nothing was updated.',
|
||||||
'no_assets_selected' => 'No assets 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.',
|
'assets_do_not_exist_or_are_invalid' => 'Selected assets cannot be updated.',
|
||||||
|
'no_note' => 'Note field is empty',
|
||||||
],
|
],
|
||||||
|
|
||||||
'restore' => [
|
'restore' => [
|
||||||
|
@ -77,6 +78,7 @@ return [
|
||||||
'user_does_not_exist' => 'That user is invalid. Please try again.',
|
'user_does_not_exist' => 'That user is invalid. Please try again.',
|
||||||
'not_available' => 'That asset is not available for checkout!',
|
'not_available' => 'That asset is not available for checkout!',
|
||||||
'no_assets_selected' => 'You must select at least one asset from the list',
|
'no_assets_selected' => 'You must select at least one asset from the list',
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
'checkin' => [
|
'checkin' => [
|
||||||
|
|
|
@ -124,6 +124,7 @@
|
||||||
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>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div> <!--/.box-body-->
|
</div> <!--/.box-body-->
|
||||||
</div> <!--/.box-body-->
|
</div> <!--/.box-body-->
|
||||||
|
|
Loading…
Reference in a new issue