mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-21 03:15:45 -08:00
Codestyle & bug fixes
This commit is contained in:
parent
d3c320e56f
commit
16bb784e78
|
@ -186,13 +186,13 @@ class PredefinedKitsController extends Controller
|
|||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @param int $kit_id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function updateLicense(Request $request, $kit_id, $license_id)
|
||||
{
|
||||
$this->authorize('update', PredefinedKit::class);
|
||||
$kit = PredefinedKit::findOrFail($id);
|
||||
$kit = PredefinedKit::findOrFail($kit_id);
|
||||
$quantity = $request->input('quantity', 1);
|
||||
if( $quantity < 1) {
|
||||
$quantity = 1;
|
||||
|
@ -211,7 +211,7 @@ class PredefinedKitsController extends Controller
|
|||
public function detachLicense($kit_id, $license_id)
|
||||
{
|
||||
$this->authorize('update', PredefinedKit::class);
|
||||
$kit = PredefinedKit::findOrFail($id);
|
||||
$kit = PredefinedKit::findOrFail($kit_id);
|
||||
|
||||
$kit->licenses()->detach($license_id);
|
||||
return response()->json(Helper::formatStandardApiResponse('success', $kit, 'Delete was successfull')); // TODO: trans
|
||||
|
@ -220,7 +220,7 @@ class PredefinedKitsController extends Controller
|
|||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $kit_id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function indexModels($kit_id) {
|
||||
|
@ -263,13 +263,13 @@ class PredefinedKitsController extends Controller
|
|||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @param int $kit_id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function updateModel(Request $request, $kit_id, $model_id)
|
||||
{
|
||||
$this->authorize('update', PredefinedKit::class);
|
||||
$kit = PredefinedKit::findOrFail($id);
|
||||
$kit = PredefinedKit::findOrFail($kit_id);
|
||||
$quantity = $request->input('quantity', 1);
|
||||
if( $quantity < 1) {
|
||||
$quantity = 1;
|
||||
|
@ -288,7 +288,7 @@ class PredefinedKitsController extends Controller
|
|||
public function detachModel($kit_id, $model_id)
|
||||
{
|
||||
$this->authorize('update', PredefinedKit::class);
|
||||
$kit = PredefinedKit::findOrFail($id);
|
||||
$kit = PredefinedKit::findOrFail($kit_id);
|
||||
|
||||
$kit->models()->detach($model_id);
|
||||
return response()->json(Helper::formatStandardApiResponse('success', $kit, 'Delete was successfull')); // TODO: trans
|
||||
|
@ -299,7 +299,7 @@ class PredefinedKitsController extends Controller
|
|||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $kit_id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function indexConsumables($kit_id) {
|
||||
|
@ -340,13 +340,13 @@ class PredefinedKitsController extends Controller
|
|||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @param int $kit_id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function updateConsumable(Request $request, $kit_id, $consumable_id)
|
||||
{
|
||||
$this->authorize('update', PredefinedKit::class);
|
||||
$kit = PredefinedKit::findOrFail($id);
|
||||
$kit = PredefinedKit::findOrFail($kit_id);
|
||||
$quantity = $request->input('quantity', 1);
|
||||
if( $quantity < 1) {
|
||||
$quantity = 1;
|
||||
|
@ -365,7 +365,7 @@ class PredefinedKitsController extends Controller
|
|||
public function detachConsumable($kit_id, $consumable_id)
|
||||
{
|
||||
$this->authorize('update', PredefinedKit::class);
|
||||
$kit = PredefinedKit::findOrFail($id);
|
||||
$kit = PredefinedKit::findOrFail($kit_id);
|
||||
|
||||
$kit->consumables()->detach($consumable_id);
|
||||
return response()->json(Helper::formatStandardApiResponse('success', $kit, 'Delete was successfull')); // TODO: trans
|
||||
|
@ -375,7 +375,7 @@ class PredefinedKitsController extends Controller
|
|||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $kit_id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function indexAccessories($kit_id) {
|
||||
|
@ -389,7 +389,7 @@ class PredefinedKitsController extends Controller
|
|||
/**
|
||||
* Store the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $kit_id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function storeAccessory(Request $request, $kit_id)
|
||||
|
@ -416,13 +416,13 @@ class PredefinedKitsController extends Controller
|
|||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @param int $kit_id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function updateAccessory(Request $request, $kit_id, $accessory_id)
|
||||
{
|
||||
$this->authorize('update', PredefinedKit::class);
|
||||
$kit = PredefinedKit::findOrFail($id);
|
||||
$kit = PredefinedKit::findOrFail($kit_id);
|
||||
$quantity = $request->input('quantity', 1);
|
||||
if( $quantity < 1) {
|
||||
$quantity = 1;
|
||||
|
@ -441,7 +441,7 @@ class PredefinedKitsController extends Controller
|
|||
public function detachAccessory($kit_id, $accessory_id)
|
||||
{
|
||||
$this->authorize('update', PredefinedKit::class);
|
||||
$kit = PredefinedKit::findOrFail($id);
|
||||
$kit = PredefinedKit::findOrFail($kit_id);
|
||||
|
||||
$kit->accessories()->detach($accessory_id);
|
||||
return response()->json(Helper::formatStandardApiResponse('success', $kit, 'Delete was successfull')); // TODO: trans
|
||||
|
|
|
@ -65,7 +65,7 @@ class PredefinedKit extends SnipeModel
|
|||
* @param int $accessoriy_id
|
||||
* @param bool $new = true if append a new element to kit
|
||||
*/
|
||||
public function makeAccessoriesRules($accessory_id, $new = false)
|
||||
public function makeAccessoryRules($accessory_id, $new=false)
|
||||
{
|
||||
return $this->_makeRuleHelper('accessories', 'kits_accessories', 'accessory_id', $accessory_id, $new);
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ class PredefinedKit extends SnipeModel
|
|||
* @param int $consumable_id
|
||||
* @param bool $new = true if append a new element to kit
|
||||
*/
|
||||
public function makeConsumablesRules($consumable_id, $new = false)
|
||||
public function makeConsumableRules($consumable_id, $new=false)
|
||||
{
|
||||
return $this->_makeRuleHelper('consumables', 'kits_consumables', 'consumable_id', $consumable_id, $new);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,8 @@ class PredefinedKitCheckoutService
|
|||
* @param User $user checkout target
|
||||
* @return array Empty array if all ok, else [string_error1, string_error2...]
|
||||
*/
|
||||
public function checkout(Request $request, PredefinedKit $kit, User $user) {
|
||||
public function checkout(Request $request, PredefinedKit $kit, User $user)
|
||||
{
|
||||
try {
|
||||
|
||||
// Check if the user exists
|
||||
|
@ -36,9 +37,9 @@ class PredefinedKitCheckoutService
|
|||
$errors = [];
|
||||
|
||||
$assets_to_add = $this->getAssetsToAdd($kit, $user, $errors);
|
||||
$license_seats_to_add = $this->getLicenseSeatsToAdd($kit, $user, $errors);
|
||||
$consumables_to_add = $this->getConsumablesToAdd($kit, $user, $errors);
|
||||
$accessories_to_add = $this->getAccessoriesToAdd($kit, $user, $errors);
|
||||
$license_seats_to_add = $this->getLicenseSeatsToAdd($kit, $errors);
|
||||
$consumables_to_add = $this->getConsumablesToAdd($kit, $errors);
|
||||
$accessories_to_add = $this->getAccessoriesToAdd($kit, $errors);
|
||||
|
||||
if (count($errors) > 0) {
|
||||
return $errors;
|
||||
|
@ -58,6 +59,92 @@ class PredefinedKitCheckoutService
|
|||
|
||||
$note = e($request->get('note'));
|
||||
|
||||
$errors = $this->saveToDb($user, $admin, $checkout_at, $expected_checkin, $errors, $assets_to_add, $license_seats_to_add, $consumables_to_add, $accessories_to_add, $note);
|
||||
return $errors;
|
||||
} catch (ModelNotFoundException $e) {
|
||||
return [$e->getMessage()];
|
||||
} catch (CheckoutNotAllowed $e) {
|
||||
return [$e->getMessage()];
|
||||
}
|
||||
}
|
||||
|
||||
protected function getAssetsToAdd($kit, $user, &$errors)
|
||||
{
|
||||
$models = $kit->models()
|
||||
->with(['assets' => function ($hasMany) {
|
||||
$hasMany->RTD();
|
||||
}])
|
||||
->get();
|
||||
$assets_to_add = [];
|
||||
foreach ($models as $model) {
|
||||
$assets = $model->assets;
|
||||
$quantity = $model->pivot->quantity;
|
||||
foreach ($assets as $asset) {
|
||||
|
||||
if (
|
||||
$asset->availableForCheckout()
|
||||
&& !$asset->is($user)
|
||||
) {
|
||||
|
||||
$this->authorize('checkout', $asset);
|
||||
$quantity -= 1;
|
||||
$assets_to_add[] = $asset;
|
||||
if ($quantity <= 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($quantity > 0) {
|
||||
$errors[] = "Don't have available assets for model " . $model->name . '. Need ' . $model->pivot->quantity . ' assets.'; // TODO: trans
|
||||
}
|
||||
}
|
||||
|
||||
return $assets_to_add;
|
||||
}
|
||||
|
||||
protected function getLicenseSeatsToAdd($kit, &$errors)
|
||||
{
|
||||
$seats_to_add = [];
|
||||
$licenses = $kit->licenses()
|
||||
->with('freeSeats')
|
||||
->get();
|
||||
foreach ($licenses as $license) {
|
||||
$quantity = $license->pivot->quantity;
|
||||
if ($quantity > count($license->freeSeats)) {
|
||||
$errors[] = "Don't have free seats for license " . $license->name . '. Need ' . $quantity . ' seats.'; // TODO: trans
|
||||
}
|
||||
for ($i = 0; $i < $quantity; $i++) {
|
||||
$seats_to_add[] = $license->freeSeats[$i];
|
||||
}
|
||||
}
|
||||
return $seats_to_add;
|
||||
}
|
||||
|
||||
protected function getConsumablesToAdd($kit, &$errors)
|
||||
{
|
||||
// $consumables = $kit->consumables()->withCount('consumableAssignments as consumable_assignments_count')->get();
|
||||
$consumables = $kit->consumables()->with('users')->get();
|
||||
foreach ($consumables as $consumable) {
|
||||
if ($consumable->numRemaining() < $consumable->pivot->quantity) {
|
||||
$errors[] = "Don't have available consumable " . $consumable->name . '. Need ' . $consumable->pivot->quantity; // TODO: trans
|
||||
}
|
||||
}
|
||||
return $consumables;
|
||||
}
|
||||
|
||||
protected function getAccessoriesToAdd($kit, &$errors)
|
||||
{
|
||||
$accessories = $kit->accessories()->with('users')->get();
|
||||
foreach ($accessories as $accossory) {
|
||||
if ($accossory->numRemaining() < $accossory->pivot->quantity) {
|
||||
$errors[] = "Don't have available accossory " . $accossory->name . '. Need ' . $accossory->pivot->quantity; // TODO: trans
|
||||
}
|
||||
}
|
||||
return $accessories;
|
||||
}
|
||||
|
||||
protected function saveToDb($user, $admin, $checkout_at, $expected_checkin, $errors, $assets_to_add, $license_seats_to_add, $consumables_to_add, $accessories_to_add, $note)
|
||||
{
|
||||
$errors = DB::transaction(
|
||||
function () use ($user, $admin, $checkout_at, $expected_checkin, $errors, $assets_to_add, $license_seats_to_add, $consumables_to_add, $accessories_to_add, $note) {
|
||||
// assets
|
||||
|
@ -74,8 +161,7 @@ class PredefinedKitCheckoutService
|
|||
$licenseSeat->assigned_to = $user->id;
|
||||
if ($licenseSeat->save()) {
|
||||
event(new CheckoutableCheckedOut($licenseSeat, $user, $admin, $note));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$errors[] = 'Something went wrong saving a license seat';
|
||||
}
|
||||
}
|
||||
|
@ -100,81 +186,9 @@ class PredefinedKitCheckoutService
|
|||
event(new CheckoutableCheckedOut($accessory, $user, $admin, $note));
|
||||
}
|
||||
return $errors;
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
return $errors;
|
||||
|
||||
} catch (ModelNotFoundException $e) {
|
||||
return [$e->getMessage()];
|
||||
} catch (CheckoutNotAllowed $e) {
|
||||
return [$e->getMessage()];
|
||||
}
|
||||
}
|
||||
|
||||
protected function getAssetsToAdd($kit, $user, &$errors) {
|
||||
$models = $kit->models()
|
||||
->with( ['assets' => function($hasMany) { $hasMany->RTD(); }] )
|
||||
->get();
|
||||
$assets_to_add = [];
|
||||
foreach($models as $model) {
|
||||
$assets = $model->assets;
|
||||
$quantity = $model->pivot->quantity;
|
||||
foreach($assets as $asset) {
|
||||
|
||||
if ($asset->availableForCheckout()
|
||||
&& !$asset->is($user)) {
|
||||
|
||||
$this->authorize('checkout', $asset);
|
||||
$quantity -= 1;
|
||||
$assets_to_add []= $asset;
|
||||
if($quantity <= 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($quantity > 0) {
|
||||
$errors []= "Don't have available assets for model " . $model->name . '. Need ' . $model->pivot->quantity . ' assets.'; // TODO: trans
|
||||
}
|
||||
}
|
||||
|
||||
return $assets_to_add;
|
||||
}
|
||||
|
||||
protected function getLicenseSeatsToAdd($kit, $user, &$errors) {
|
||||
$seats_to_add = [];
|
||||
$licenses = $kit->licenses()
|
||||
->with('freeSeats')
|
||||
->get();
|
||||
foreach($licenses as $license) {
|
||||
$quantity = $license->pivot->quantity;
|
||||
if( $quantity > count($license->freeSeats) ) {
|
||||
$errors []= "Don't have free seats for license " . $license->name . '. Need ' . $quantity . ' seats.'; // TODO: trans
|
||||
}
|
||||
for($i=0; $i < $quantity; $i++) {
|
||||
$seats_to_add []= $license->freeSeats[$i];
|
||||
}
|
||||
}
|
||||
return $seats_to_add;
|
||||
}
|
||||
|
||||
protected function getConsumablesToAdd($kit, $user, &$errors) {
|
||||
// $consumables = $kit->consumables()->withCount('consumableAssignments as consumable_assignments_count')->get();
|
||||
$consumables = $kit->consumables()->with('users')->get();
|
||||
foreach($consumables as $consumable) {
|
||||
if( $consumable->numRemaining() < $consumable->pivot->quantity ) {
|
||||
$errors []= "Don't have available consumable " . $consumable->name . '. Need ' . $consumable->pivot->quantity; // TODO: trans
|
||||
}
|
||||
}
|
||||
return $consumables;
|
||||
}
|
||||
|
||||
protected function getAccessoriesToAdd($kit, $user, &$errors) {
|
||||
$accessories = $kit->accessories()->with('users')->get();
|
||||
foreach($accessories as $accossory) {
|
||||
if( $accossory->numRemaining() < $accossory->pivot->quantity ) {
|
||||
$errors []= "Don't have available accossory " . $accossory->name . '. Need ' . $accossory->pivot->quantity; // TODO: trans
|
||||
}
|
||||
}
|
||||
return $accessories;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,42 +6,7 @@
|
|||
|
||||
{{-- Page content --}}
|
||||
@section('inputFields')
|
||||
{{-- <div class="form-group {{ $errors->has('name') ? ' has-error' : '' }}">
|
||||
<label for="accessory_id">{{ trans('general.accessory') }}:</label>
|
||||
<div class="col-md-8 col-xs-12 required">
|
||||
<select class="js-data-ajax select2" data-endpoint="accessories" name="accessory" style="width: 100%" id="accessory_id" value="{{ Input::old('name', $pivot->accessory_id) }}" data-validation="required" />
|
||||
{{ Form::select('accessory_id', [] , Input::old('name', $pivot->accessory_id), array('class'=>'select2', 'style'=>'width:100%')) }}
|
||||
</div>
|
||||
</div> --}}
|
||||
{{-- At first, I tried to use partials.forms.edit.accessory-select. But, it required ValidatingTrait (rules method). Pivot class doesn't have it. --}}
|
||||
@include ('partials.forms.edit.accessory-select', ['translated_name' => trans('admin/hardware/form.accessory'), 'fieldname' => 'accessory_id', 'required' => 'true'])
|
||||
{{-- <div id="accessory_id" class="form-group{{ $errors->has('accessory_id') ? ' has-error' : '' }}">
|
||||
|
||||
{{ Form::label('accessory_id', trans('admin/hardware/form.accessory'), array('class' => 'col-md-3 control-label')) }}
|
||||
|
||||
<div class="col-md-7 required">
|
||||
<select class="js-data-ajax" data-endpoint="accessories" data-placeholder="{{ trans('general.select_accessory') }}" name="accessory_id" style="width: 100%" id="accessory_select_id" data-validation="required">
|
||||
@if ($accessory_id = Input::old('accessory_id', (isset($item)) ? $item->accessory_id : ''))
|
||||
<option value="{{ $accessory_id }}" selected="selected">
|
||||
{{ (\App\Accessories\Accessory::find($accessory_id)) ? \App\Accessories\Accessory::find($accessory_id)->name : '' }}
|
||||
</option>
|
||||
@else
|
||||
<option value="">{{ trans('general.select_accessory') }}</option>
|
||||
@endif
|
||||
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-1 col-sm-1 text-left">
|
||||
@can('create', \App\Accessories\Accessory::class)
|
||||
@if ((!isset($hide_new)) || ($hide_new!='true'))
|
||||
<a href='{{ route('modal.accessory') }}' data-toggle="modal" data-target="#createModal" data-select='accessory_select_id' class="btn btn-sm btn-default">New</a>
|
||||
<span class="mac_spinner" style="padding-left: 10px; color: green; display:none; width: 30px;"><i class="fa fa-spinner fa-spin"></i> </span>
|
||||
@endif
|
||||
@endcan
|
||||
</div>
|
||||
|
||||
{!! $errors->first('accessory_id', '<div class="col-md-8 col-md-offset-3"><span class="alert-msg"><i class="fa fa-times"></i> :message</span></div>') !!}
|
||||
</div> --}}
|
||||
@include ('partials.forms.edit.accessory-select', ['translated_name' => 'Accessory', 'fieldname' => 'accessory_id', 'required' => 'true']){{-- TODO: trans --}}
|
||||
<div class="form-group {{ $errors->has('quantity') ? ' has-error' : '' }}">
|
||||
<label for="quantity" class="col-md-3 control-label">{{ trans('general.quantity') }}</label>
|
||||
<div class="col-md-7 required">
|
||||
|
|
|
@ -6,42 +6,8 @@
|
|||
|
||||
{{-- Page content --}}
|
||||
@section('inputFields')
|
||||
{{-- <div class="form-group {{ $errors->has('name') ? ' has-error' : '' }}">
|
||||
<label for="consumable_id">{{ trans('general.consumable') }}:</label>
|
||||
<div class="col-md-8 col-xs-12 required">
|
||||
<select class="js-data-ajax select2" data-endpoint="consumables" name="consumable" style="width: 100%" id="consumable_id" value="{{ Input::old('name', $pivot->consumable_id) }}" data-validation="required" />
|
||||
{{ Form::select('consumable_id', [] , Input::old('name', $pivot->consumable_id), array('class'=>'select2', 'style'=>'width:100%')) }}
|
||||
</div>
|
||||
</div> --}}
|
||||
{{-- At first, I tried to use partials.forms.edit.consumable-select. But, it required ValidatingTrait (rules method). Pivot class doesn't have it. --}}
|
||||
@include ('partials.forms.edit.consumable-select', ['translated_name' => trans('admin/hardware/form.consumable'), 'fieldname' => 'consumable_id', 'required' => 'true'])
|
||||
{{-- <div id="consumable_id" class="form-group{{ $errors->has('consumable_id') ? ' has-error' : '' }}">
|
||||
@include ('partials.forms.edit.consumable-select', ['translated_name' => 'Consumable', 'fieldname' => 'consumable_id', 'required' => 'true']){{-- TODO: trans --}}
|
||||
|
||||
{{ Form::label('consumable_id', trans('admin/hardware/form.consumable'), array('class' => 'col-md-3 control-label')) }}
|
||||
|
||||
<div class="col-md-7 required">
|
||||
<select class="js-data-ajax" data-endpoint="consumables" data-placeholder="{{ trans('general.select_consumable') }}" name="consumable_id" style="width: 100%" id="consumable_select_id" data-validation="required">
|
||||
@if ($consumable_id = Input::old('consumable_id', (isset($item)) ? $item->consumable_id : ''))
|
||||
<option value="{{ $consumable_id }}" selected="selected">
|
||||
{{ (\App\Consumables\Consumable::find($consumable_id)) ? \App\Consumables\Consumable::find($consumable_id)->name : '' }}
|
||||
</option>
|
||||
@else
|
||||
<option value="">{{ trans('general.select_consumable') }}</option>
|
||||
@endif
|
||||
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-1 col-sm-1 text-left">
|
||||
@can('create', \App\Consumables\Consumable::class)
|
||||
@if ((!isset($hide_new)) || ($hide_new!='true'))
|
||||
<a href='{{ route('modal.consumable') }}' data-toggle="modal" data-target="#createModal" data-select='consumable_select_id' class="btn btn-sm btn-default">New</a>
|
||||
<span class="mac_spinner" style="padding-left: 10px; color: green; display:none; width: 30px;"><i class="fa fa-spinner fa-spin"></i> </span>
|
||||
@endif
|
||||
@endcan
|
||||
</div>
|
||||
|
||||
{!! $errors->first('consumable_id', '<div class="col-md-8 col-md-offset-3"><span class="alert-msg"><i class="fa fa-times"></i> :message</span></div>') !!}
|
||||
</div> --}}
|
||||
<div class="form-group {{ $errors->has('quantity') ? ' has-error' : '' }}">
|
||||
<label for="quantity" class="col-md-3 control-label">{{ trans('general.quantity') }}</label>
|
||||
<div class="col-md-7 required">
|
||||
|
|
|
@ -6,42 +6,7 @@
|
|||
|
||||
{{-- Page content --}}
|
||||
@section('inputFields')
|
||||
{{-- <div class="form-group {{ $errors->has('name') ? ' has-error' : '' }}">
|
||||
<label for="license_id">{{ trans('general.license') }}:</label>
|
||||
<div class="col-md-8 col-xs-12 required">
|
||||
<select class="js-data-ajax select2" data-endpoint="licenses" name="license" style="width: 100%" id="license_id" value="{{ Input::old('name', $pivot->license_id) }}" data-validation="required" />
|
||||
{{ Form::select('license_id', [] , Input::old('name', $pivot->license_id), array('class'=>'select2', 'style'=>'width:100%')) }}
|
||||
</div>
|
||||
</div> --}}
|
||||
{{-- At first, I tried to use partials.forms.edit.license-select. But, it required ValidatingTrait (rules method). Pivot class doesn't have it. --}}
|
||||
@include ('partials.forms.edit.license-select', ['translated_name' => trans('general.license'), 'fieldname' => 'license_id', 'required' => 'true'])
|
||||
{{-- <div id="license_id" class="form-group{{ $errors->has('license_id') ? ' has-error' : '' }}">
|
||||
|
||||
{{ Form::label('license_id', trans('general.license'), array('class' => 'col-md-3 control-label')) }}
|
||||
|
||||
<div class="col-md-7 required">
|
||||
<select class="js-data-ajax" data-endpoint="licenses" data-placeholder="{{ trans('general.select_license') }}" name="license_id" style="width: 100%" id="license_select_id" data-validation="required">
|
||||
@if ($license_id = Input::old('license_id', (isset($item)) ? $item->license_id : ''))
|
||||
<option value="{{ $license_id }}" selected="selected">
|
||||
{{ (\App\Licenses\License::find($license_id)) ? \App\Licenses\License::find($license_id)->name : '' }}
|
||||
</option>
|
||||
@else
|
||||
<option value="">{{ trans('general.select_license') }}</option>
|
||||
@endif
|
||||
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-1 col-sm-1 text-left">
|
||||
@can('create', \App\Licenses\License::class)
|
||||
@if ((!isset($hide_new)) || ($hide_new!='true'))
|
||||
<a href='{{ route('modal.license') }}' data-toggle="modal" data-target="#createModal" data-select='license_select_id' class="btn btn-sm btn-default">New</a>
|
||||
<span class="mac_spinner" style="padding-left: 10px; color: green; display:none; width: 30px;"><i class="fa fa-spinner fa-spin"></i> </span>
|
||||
@endif
|
||||
@endcan
|
||||
</div>
|
||||
|
||||
{!! $errors->first('license_id', '<div class="col-md-8 col-md-offset-3"><span class="alert-msg"><i class="fa fa-times"></i> :message</span></div>') !!}
|
||||
</div> --}}
|
||||
<div class="form-group {{ $errors->has('quantity') ? ' has-error' : '' }}">
|
||||
<label for="quantity" class="col-md-3 control-label">{{ trans('general.quantity') }}</label>
|
||||
<div class="col-md-7 required">
|
||||
|
|
|
@ -6,42 +6,7 @@
|
|||
|
||||
{{-- Page content --}}
|
||||
@section('inputFields')
|
||||
{{-- <div class="form-group {{ $errors->has('name') ? ' has-error' : '' }}">
|
||||
<label for="model_id">{{ trans('general.asset_model') }}:</label>
|
||||
<div class="col-md-8 col-xs-12 required">
|
||||
<select class="js-data-ajax select2" data-endpoint="models" name="model" style="width: 100%" id="model_id" value="{{ Input::old('name', $pivot->model_id) }}" data-validation="required" />
|
||||
{{ Form::select('model_id', [] , Input::old('name', $pivot->model_id), array('class'=>'select2', 'style'=>'width:100%')) }}
|
||||
</div>
|
||||
</div> --}}
|
||||
{{-- At first, I tried to use partials.forms.edit.model-select. But, it required ValidatingTrait (rules method). Pivot class doesn't have it. --}}
|
||||
@include ('partials.forms.edit.model-select', ['translated_name' => trans('admin/hardware/form.model'), 'fieldname' => 'model_id', 'required' => 'true'])
|
||||
{{-- <div id="model_id" class="form-group{{ $errors->has('model_id') ? ' has-error' : '' }}">
|
||||
|
||||
{{ Form::label('model_id', trans('admin/hardware/form.model'), array('class' => 'col-md-3 control-label')) }}
|
||||
|
||||
<div class="col-md-7 required">
|
||||
<select class="js-data-ajax" data-endpoint="models" data-placeholder="{{ trans('general.select_model') }}" name="model_id" style="width: 100%" id="model_select_id" data-validation="required">
|
||||
@if ($model_id = Input::old('model_id', (isset($item)) ? $item->model_id : ''))
|
||||
<option value="{{ $model_id }}" selected="selected">
|
||||
{{ (\App\Models\AssetModel::find($model_id)) ? \App\Models\AssetModel::find($model_id)->name : '' }}
|
||||
</option>
|
||||
@else
|
||||
<option value="">{{ trans('general.select_model') }}</option>
|
||||
@endif
|
||||
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-1 col-sm-1 text-left">
|
||||
@can('create', \App\Models\AssetModel::class)
|
||||
@if ((!isset($hide_new)) || ($hide_new!='true'))
|
||||
<a href='{{ route('modal.model') }}' data-toggle="modal" data-target="#createModal" data-select='model_select_id' class="btn btn-sm btn-default">New</a>
|
||||
<span class="mac_spinner" style="padding-left: 10px; color: green; display:none; width: 30px;"><i class="fa fa-spinner fa-spin"></i> </span>
|
||||
@endif
|
||||
@endcan
|
||||
</div>
|
||||
|
||||
{!! $errors->first('model_id', '<div class="col-md-8 col-md-offset-3"><span class="alert-msg"><i class="fa fa-times"></i> :message</span></div>') !!}
|
||||
</div> --}}
|
||||
<div class="form-group {{ $errors->has('quantity') ? ' has-error' : '' }}">
|
||||
<label for="quantity" class="col-md-3 control-label">{{ trans('general.quantity') }}</label>
|
||||
<div class="col-md-7 required">
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
@if ((!isset($unselect)) && ($accessory_id = Input::old($fieldname, (isset($accessory) ? $accessory->id : (isset($item) ? $item->{$fieldname} : '')))))
|
||||
<option value="{{ $accessory_id }}" selected="selected">
|
||||
{{ (\App\Models\Accessory::find($accessory_id)) ? \App\Models\Accessory::find($accessory_id)->present()->fullName : '' }}
|
||||
{{ (\App\Models\Accessory::find($accessory_id)) ? \App\Models\Accessory::find($accessory_id)->present()->name : '' }}
|
||||
</option>
|
||||
@else
|
||||
@if(!isset($multiple))
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
@if ((!isset($unselect)) && ($consumable_id = Input::old($fieldname, (isset($consumable) ? $consumable->id : (isset($item) ? $item->{$fieldname} : '')))))
|
||||
<option value="{{ $consumable_id }}" selected="selected">
|
||||
{{ (\App\Models\Consumable::find($consumable_id)) ? \App\Models\Consumable::find($consumable_id)->present()->fullName : '' }}
|
||||
{{ (\App\Models\Consumable::find($consumable_id)) ? \App\Models\Consumable::find($consumable_id)->present()->name : '' }}
|
||||
</option>
|
||||
@else
|
||||
@if(!isset($multiple))
|
||||
|
|
Loading…
Reference in a new issue