mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Added more ajax select2 boxes to checkouts, remove helper ->with() methods
This commit is contained in:
parent
82690e1fd7
commit
ea07517ad5
|
@ -271,7 +271,7 @@ class AccessoriesController extends Controller
|
|||
$this->authorize('checkout', $accessory);
|
||||
|
||||
// Get the dropdown of users and then pass it to the checkout view
|
||||
return view('accessories/checkout', compact('accessory'))->with('users_list', Helper::usersList());
|
||||
return view('accessories/checkout', compact('accessory'));
|
||||
|
||||
}
|
||||
|
||||
|
@ -296,7 +296,7 @@ class AccessoriesController extends Controller
|
|||
$this->authorize('checkout', $accessory);
|
||||
|
||||
if (!$user = User::find(Input::get('assigned_to'))) {
|
||||
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.not_found'));
|
||||
return redirect()->route('checkout/accessory', $accessory->id)->with('error', trans('admin/accessories/message.checkout.user_does_not_exist'));
|
||||
}
|
||||
|
||||
// Update the accessory data
|
||||
|
@ -323,6 +323,7 @@ class AccessoriesController extends Controller
|
|||
$data['note'] = $logaction->note;
|
||||
$data['require_acceptance'] = $accessory->requireAcceptance();
|
||||
// TODO: Port this to new mail notifications
|
||||
|
||||
if ((($accessory->requireAcceptance()=='1') || ($accessory->getEula())) && ($user->email!='')) {
|
||||
|
||||
Mail::send('emails.accept-accessory', $data, function ($m) use ($user) {
|
||||
|
|
|
@ -303,6 +303,9 @@ class AssetsController extends Controller
|
|||
'image' => ($asset->getImageUrl()) ? $asset->getImageUrl() : null,
|
||||
];
|
||||
}
|
||||
|
||||
array_unshift($assets_array, ['id'=> '', 'text'=> trans('general.select_asset'), 'image' => null]);
|
||||
|
||||
$results = [
|
||||
'items' => $assets_array,
|
||||
'pagination' =>
|
||||
|
|
|
@ -175,6 +175,9 @@ class LocationsController extends Controller
|
|||
'image' => ($location->image) ? url('/').'/uploads/locations/'.$location->image : null,
|
||||
];
|
||||
}
|
||||
|
||||
array_unshift($locations_array, ['id'=> '', 'text'=> trans('general.select_location'), 'image' => null]);
|
||||
|
||||
$results = [
|
||||
'items' => $locations_array,
|
||||
'pagination' =>
|
||||
|
|
|
@ -165,6 +165,8 @@ class UsersController extends Controller
|
|||
'image' => ($user->present()->gravatar) ? $user->present()->gravatar : null,
|
||||
];
|
||||
}
|
||||
|
||||
array_unshift($users_array, ['id'=> '', 'text'=> trans('general.select_user'), 'image' => null]);
|
||||
$results = [
|
||||
'items' => $users_array,
|
||||
'pagination' =>
|
||||
|
|
|
@ -430,10 +430,7 @@ class AssetsController extends Controller
|
|||
$this->authorize('checkout', $asset);
|
||||
|
||||
// Get the dropdown of users and then pass it to the checkout view
|
||||
return view('hardware/checkout', compact('asset'))
|
||||
->with('users_list', Helper::usersList())
|
||||
->with('assets_list', Helper::detailedAssetList())
|
||||
->with('locations_list', Helper::locationsList());
|
||||
return view('hardware/checkout', compact('asset'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -255,7 +255,7 @@ class ComponentsController extends Controller
|
|||
return redirect()->route('components.index')->with('error', trans('admin/components/message.not_found'));
|
||||
}
|
||||
$this->authorize('checkout', $component);
|
||||
return view('components/checkout', compact('component'))->with('assets_list', Helper::detailedAssetList());
|
||||
return view('components/checkout', compact('component'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -239,7 +239,7 @@ class ConsumablesController extends Controller
|
|||
return redirect()->route('consumables.index')->with('error', trans('admin/consumables/message.does_not_exist'));
|
||||
}
|
||||
$this->authorize('checkout', $consumable);
|
||||
return view('consumables/checkout', compact('consumable'))->with('users_list', Helper::usersList());
|
||||
return view('consumables/checkout', compact('consumable'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -265,7 +265,7 @@ class ConsumablesController extends Controller
|
|||
// Check if the user exists
|
||||
if (is_null($user = User::find($assigned_to))) {
|
||||
// Redirect to the consumable management page with error
|
||||
return redirect()->route('consumables.index')->with('error', trans('admin/consumables/message.user_does_not_exist'));
|
||||
return redirect()->route('checkout/consumable', $consumable)->with('error', trans('admin/consumables/message.checkout.user_does_not_exist'));
|
||||
}
|
||||
|
||||
// Update the consumable data
|
||||
|
@ -286,7 +286,7 @@ class ConsumablesController extends Controller
|
|||
$data['note'] = $logaction->note;
|
||||
$data['require_acceptance'] = $consumable->requireAcceptance();
|
||||
|
||||
if (($consumable->requireAcceptance()=='1') || ($consumable->getEula())) {
|
||||
if ((($consumable->requireAcceptance()=='1') || ($consumable->getEula())) && $user->email!='') {
|
||||
|
||||
Mail::send('emails.accept-asset', $data, function ($m) use ($user) {
|
||||
$m->to($user->email, $user->first_name . ' ' . $user->last_name);
|
||||
|
|
|
@ -51,16 +51,7 @@
|
|||
|
||||
<!-- User -->
|
||||
|
||||
<div class="form-group {{ $errors->has('assigned_to') ? ' has-error' : '' }}">
|
||||
<label for="assigned_to" class="col-md-3 control-label">
|
||||
{{ trans('admin/hardware/form.checkout_to') }}
|
||||
<i class='icon-asterisk'></i>
|
||||
</label>
|
||||
<div class="col-md-9">
|
||||
{{ Form::select('assigned_to', $users_list , Input::old('assigned_to', $accessory->assigned_to), array('class'=>'select2', 'style'=>'min-width:350px')) }}
|
||||
{!! $errors->first('assigned_to', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
@include ('partials.forms.edit.user-select', ['translated_name' => trans('general.select_user'), 'fieldname' => 'assigned_to'])
|
||||
|
||||
@if ($accessory->category->require_acceptance=='1')
|
||||
<div class="form-group">
|
||||
|
|
|
@ -36,23 +36,17 @@
|
|||
@endif
|
||||
|
||||
<!-- Asset -->
|
||||
<div class="form-group {{ $errors->has('asset_id') ? ' has-error' : '' }}">
|
||||
<label for="asset_id" class="col-md-3 control-label">{{ trans('admin/hardware/form.checkout_to') }}
|
||||
<i class='icon-asterisk'></i></label>
|
||||
<div class="col-md-9">
|
||||
{{ Form::select('asset_id', $assets_list , Input::old('asset_id', $component->asset_id), array('class'=>'select2', 'style'=>'width:100%')) }}
|
||||
{!! $errors->first('asset_id', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
@include ('partials.forms.edit.asset-select', ['translated_name' => trans('general.select_asset'), 'fieldname' => 'asset_id'])
|
||||
|
||||
<div class="form-group {{ $errors->has('assigned_qty') ? ' has-error' : '' }}">
|
||||
<label for="assigned_qty" class="col-md-3 control-label">{{ trans('general.qty') }}
|
||||
<i class='icon-asterisk'></i></label>
|
||||
<div class="col-md-9">
|
||||
<input class="form-control" type="text" name="assigned_qty" id="assigned_qty" style="width: 70px;" value="{{ Input::old('assigned_qty') }}" />
|
||||
{!! $errors->first('assigned_qty', '<br><span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}
|
||||
<div class="form-group {{ $errors->has('assigned_qty') ? ' has-error' : '' }}">
|
||||
<label for="assigned_qty" class="col-md-3 control-label">{{ trans('general.qty') }}
|
||||
<i class='icon-asterisk'></i></label>
|
||||
<div class="col-md-9">
|
||||
<input class="form-control" type="text" name="assigned_qty" id="assigned_qty" style="width: 70px;" value="{{ Input::old('assigned_qty') }}" />
|
||||
{!! $errors->first('assigned_qty', '<br><span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div> <!-- .BOX-BODY-->
|
||||
<div class="box-footer">
|
||||
|
|
|
@ -38,14 +38,7 @@
|
|||
@endif
|
||||
|
||||
<!-- User -->
|
||||
<div class="form-group {{ $errors->has('assigned_to') ? ' has-error' : '' }}">
|
||||
<label for="assigned_to" class="col-md-3 control-label">{{ trans('admin/hardware/form.checkout_to') }}
|
||||
<i class='icon-asterisk'></i></label>
|
||||
<div class="col-md-9">
|
||||
{{ Form::select('assigned_to', $users_list , Input::old('assigned_to', $consumable->assigned_to), array('class'=>'select2', 'style'=>'min-width:350px')) }}
|
||||
{!! $errors->first('assigned_to', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
@include ('partials.forms.edit.user-select', ['translated_name' => trans('general.select_user'), 'fieldname' => 'assigned_to'])
|
||||
|
||||
@if ($consumable->category->require_acceptance=='1')
|
||||
<div class="form-group">
|
||||
|
|
|
@ -45,60 +45,16 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
@include ('partials.forms.edit.user-select', ['translated_name' => trans('admin/hardware/form.checkout_to'), 'fieldname' => 'assigned_user'])
|
||||
|
||||
|
||||
<div id="assigned_user" class="form-group{{ $errors->has('assigned_user') ? ' has-error' : '' }}">
|
||||
|
||||
{{ Form::label('assigned_user', trans('admin/hardware/form.checkout_to'), array('class' => 'col-md-3 control-label')) }}
|
||||
|
||||
<div class="col-md-7 required">
|
||||
<select class="js-data-ajax" data-endpoint="users" name="assigned_user" style="width: 100%" id="assigned_user_select">
|
||||
<option value="">{{ trans('general.select_user') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-md-1 col-sm-1 text-left">
|
||||
@can('create', \App\Models\User::class)
|
||||
<a href='{{ route('modal.user') }}' data-toggle="modal" data-target="#createModal" data-dependency="user" data-select='assigned_user_select' class="btn btn-sm btn-default">New</a>
|
||||
@endcan
|
||||
</div>
|
||||
|
||||
{!! $errors->first('assigned_user', '<div class="col-md-8 col-md-offset-3"><span class="alert-msg"><i class="fa fa-times"></i> :message</span></div>') !!}
|
||||
|
||||
</div>
|
||||
|
||||
@if (!$asset->requireAcceptance())
|
||||
|
||||
<!-- Asset -->
|
||||
<div id="assigned_asset" class="form-group{{ $errors->has('assigned_asset') ? ' has-error' : '' }}">
|
||||
{{ Form::label('assigned_asset', trans('admin/hardware/form.checkout_to'), array('class' => 'col-md-3 control-label')) }}
|
||||
<div class="col-md-7 required">
|
||||
<select class="js-data-ajax" data-endpoint="hardware" name="assigned_asset" style="width: 100%" id="assigned_asset_select">
|
||||
<option value="">{{ trans('general.select_asset') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
{!! $errors->first('assigned_asset', '<div class="col-md-8 col-md-offset-3"><span class="alert-msg"><i class="fa fa-times"></i> :message</span></div>') !!}
|
||||
@include ('partials.forms.edit.asset-select', ['translated_name' => trans('admin/hardware/form.checkout_to'), 'fieldname' => 'assigned_asset'])
|
||||
|
||||
</div>
|
||||
@include ('partials.forms.edit.location-select', ['translated_name' => trans('admin/hardware/form.checkout_to'), 'fieldname' => 'assigned_location'])
|
||||
|
||||
<!-- Location -->
|
||||
<div id="assigned_location" class="form-group{{ $errors->has('assigned_location') ? ' has-error' : '' }}">
|
||||
{{ Form::label('assigned_location', trans('admin/hardware/form.checkout_to'), array('class' => 'col-md-3 control-label')) }}
|
||||
<div class="col-md-7 required">
|
||||
<select class="js-data-ajax" data-endpoint="locations" name="assigned_location" style="width: 100%" id="assigned_location_select">
|
||||
<option value="">{{ trans('general.select_location') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-md-1 col-sm-1 text-left">
|
||||
@can('create', \App\Models\Location::class)
|
||||
<a href='{{ route('modal.location') }}' data-toggle="modal" data-target="#createModal" data-dependency="location" data-select='assigned_location_select' class="btn btn-sm btn-default">New</a>
|
||||
@endcan
|
||||
</div>
|
||||
|
||||
{!! $errors->first('assigned_location', '<div class="col-md-8 col-md-offset-3"><span class="alert-msg"><i class="fa fa-times"></i> :message</span></div>') !!}
|
||||
|
||||
</div>
|
||||
@endif
|
||||
<!-- Checkout/Checkin Date -->
|
||||
<div class="form-group {{ $errors->has('checkout_at') ? 'error' : '' }}">
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
<!-- Asset name -->
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">{{ trans('admin/hardware/form.name') }}</label>
|
||||
<label class="col-sm-3 control-label">{{ trans('admin/hardware/form.name') }}</label>
|
||||
<div class="col-md-6">
|
||||
<p class="form-control-static">{{ $licenseSeat->license->name }}</p>
|
||||
</div>
|
||||
|
@ -35,41 +35,24 @@
|
|||
|
||||
<!-- Serial -->
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">{{ trans('admin/hardware/form.serial') }}</label>
|
||||
<div class="col-md-10">
|
||||
<label class="col-sm-3 control-label">{{ trans('admin/hardware/form.serial') }}</label>
|
||||
<div class="col-md-9">
|
||||
<p class="form-control-static" style="word-wrap: break-word;">{{ $licenseSeat->license->serial }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Asset -->
|
||||
<div class="form-group {{ $errors->has('asset_id') ? ' has-error' : '' }}">
|
||||
<label for="asset_id" class="col-md-2 control-label">{{ trans('admin/licenses/form.asset') }}
|
||||
</label>
|
||||
@include ('partials.forms.edit.asset-select', ['translated_name' => trans('admin/licenses/form.asset'), 'fieldname' => 'asset_id'])
|
||||
|
||||
<div class="col-md-10">
|
||||
{{ Form::select('asset_id', $asset_list , Input::old('asset_id', $licenseSeat->asset_id), array('class'=>'select2', 'style'=>'min-width:600px')) }}
|
||||
{!! $errors->first('asset_id', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
@include ('partials.forms.edit.user-select', ['translated_name' => trans('admin/hardware/form.checkout_to'), 'fieldname' => 'assigned_to'])
|
||||
|
||||
<!-- User -->
|
||||
<div class="form-group {{ $errors->has('assigned_to') ? ' has-error' : '' }}">
|
||||
<label for="assigned_to" class="col-md-2 control-label">{{ trans('admin/hardware/form.checkout_to') }}
|
||||
</label>
|
||||
<p class="col-md-offset-3 help-block">
|
||||
{{ trans('admin/licenses/form.checkout_help') }}
|
||||
</p>
|
||||
|
||||
<div class="col-md-9">
|
||||
{{ Form::select('assigned_to', $users_list , Input::old('assigned_to', $licenseSeat->assigned_to), array('class'=>'select2', 'style'=>'min-width:350px')) }}
|
||||
{!! $errors->first('assigned_to', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}
|
||||
|
||||
<p class="help-block">
|
||||
{{ trans('admin/licenses/form.checkout_help') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Note -->
|
||||
<div class="form-group {{ $errors->has('note') ? 'error' : '' }}">
|
||||
<label for="note" class="col-md-2 control-label">{{ trans('admin/hardware/form.notes') }}</label>
|
||||
<label for="note" class="col-md-3 control-label">{{ trans('admin/hardware/form.notes') }}</label>
|
||||
<div class="col-md-7">
|
||||
<textarea class="col-md-6 form-control" id="note" name="note">{{ Input::old('note', $licenseSeat->note) }}</textarea>
|
||||
{!! $errors->first('note', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}
|
||||
|
|
10
resources/views/partials/forms/edit/asset-select.blade.php
Normal file
10
resources/views/partials/forms/edit/asset-select.blade.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<!-- Asset -->
|
||||
<div id="assigned_asset" class="form-group{{ $errors->has($fieldname) ? ' has-error' : '' }}">
|
||||
{{ Form::label($fieldname, $translated_name, array('class' => 'col-md-3 control-label')) }}
|
||||
<div class="col-md-7 required">
|
||||
<select class="js-data-ajax" data-endpoint="hardware" name="{{ $fieldname }}" style="width: 100%" id="assigned_asset_select">
|
||||
</select>
|
||||
</div>
|
||||
{!! $errors->first($fieldname, '<div class="col-md-8 col-md-offset-3"><span class="alert-msg"><i class="fa fa-times"></i> :message</span></div>') !!}
|
||||
|
||||
</div>
|
|
@ -0,0 +1,17 @@
|
|||
<!-- Location -->
|
||||
<div id="assigned_location" class="form-group{{ $errors->has($fieldname) ? ' has-error' : '' }}">
|
||||
{{ Form::label($fieldname, $translated_name, array('class' => 'col-md-3 control-label')) }}
|
||||
<div class="col-md-7 required">
|
||||
<select class="js-data-ajax" data-endpoint="locations" name="{{ $fieldname }}" style="width: 100%" id="assigned_location_select">
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-md-1 col-sm-1 text-left">
|
||||
@can('create', \App\Models\Location::class)
|
||||
<a href='{{ route('modal.location') }}' data-toggle="modal" data-target="#createModal" data-dependency="location" data-select='assigned_location_select' class="btn btn-sm btn-default">New</a>
|
||||
@endcan
|
||||
</div>
|
||||
|
||||
{!! $errors->first($fieldname, '<div class="col-md-8 col-md-offset-3"><span class="alert-msg"><i class="fa fa-times"></i> :message</span></div>') !!}
|
||||
|
||||
</div>
|
18
resources/views/partials/forms/edit/user-select.blade.php
Normal file
18
resources/views/partials/forms/edit/user-select.blade.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<div id="assigned_user" class="form-group{{ $errors->has($fieldname) ? ' has-error' : '' }}">
|
||||
|
||||
{{ Form::label($fieldname, $translated_name, array('class' => 'col-md-3 control-label')) }}
|
||||
|
||||
<div class="col-md-7 required">
|
||||
<select class="js-data-ajax" data-endpoint="users" name="{{ $fieldname }}" style="width: 100%" id="assigned_user_select">
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-md-1 col-sm-1 text-left">
|
||||
@can('create', \App\Models\User::class)
|
||||
<a href='{{ route('modal.user') }}' data-toggle="modal" data-target="#createModal" data-dependency="user" data-select='assigned_user_select' class="btn btn-sm btn-default">New</a>
|
||||
@endcan
|
||||
</div>
|
||||
|
||||
{!! $errors->first($fieldname, '<div class="col-md-8 col-md-offset-3"><span class="alert-msg"><i class="fa fa-times"></i> :message</span></div>') !!}
|
||||
|
||||
</div>
|
Loading…
Reference in a new issue