A free open source IT asset/license management system
Codestyle & bug fixes
Dmitrii Minaev16bb784e7890
diff --git a/app/Http/Controllers/Api/PredefinedKitsController.php b/app/Http/Controllers/Api/PredefinedKitsController.phpindex f84c868453..6cf0f7bca1 100644--- a/app/Http/Controllers/Api/PredefinedKitsController.php+++ b/app/Http/Controllers/Api/PredefinedKitsController.php@@ -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 Controllerpublic 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 Controllerpublic 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 Controllerpublic 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 Controllerpublic 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: transdiff --git a/app/Http/Controllers/Kits/PredefinedKitsController.php b/app/Http/Controllers/Kits/PredefinedKitsController.phpindex 533d6d2cb5..2ae5ca0111 100644--- a/app/Http/Controllers/Kits/PredefinedKitsController.php+++ b/app/Http/Controllers/Kits/PredefinedKitsController.php@@ -76,7 +76,7 @@ class PredefinedKitsController extends Controller* @param int $kit_id* @return View*/- public function edit($kit_id = null)+ public function edit($kit_id=null){$this->authorize('update', PredefinedKit::class);if ($kit = PredefinedKit::find($kit_id)) {@@ -98,7 +98,7 @@ class PredefinedKitsController extends Controller* @param int $kit_id* @return Redirect*/- public function update(ImageUploadRequest $request, $kit_id = null)+ public function update(ImageUploadRequest $request, $kit_id=null){$this->authorize('update', PredefinedKit::class);// Check if the kit exists@@ -152,7 +152,7 @@ class PredefinedKitsController extends Controller* @param int $modelId* @return View*/- public function show($kit_id = null)+ public function show($kit_id=null){return $this->edit($kit_id);}diff --git a/app/Models/PredefinedKit.php b/app/Models/PredefinedKit.phpindex 81169aa75b..71b7340d38 100644--- a/app/Models/PredefinedKit.php+++ b/app/Models/PredefinedKit.php@@ -43,7 +43,7 @@ class PredefinedKit extends SnipeModel* @param int $model_id* @param bool $new = true if append a new element to kit*/- public function makeModelRules($model_id, $new = false)+ public function makeModelRules($model_id, $new=false){return $this->_makeRuleHelper('models', 'kits_models', 'model_id', $model_id, $new);}@@ -54,7 +54,7 @@ class PredefinedKit extends SnipeModel* @param int $license_id* @param bool $new = true if append a new element to kit*/- public function makeLicenseRules($license_id, $new = false)+ public function makeLicenseRules($license_id, $new=false){return $this->_makeRuleHelper('licenses', 'kits_licenses', 'license_id', $license_id, $new);}@@ -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);}diff --git a/app/Services/PredefinedKitCheckoutService.php b/app/Services/PredefinedKitCheckoutService.phpindex 096d806863..abc95b31a9 100644--- a/app/Services/PredefinedKitCheckoutService.php+++ b/app/Services/PredefinedKitCheckoutService.php@@ -25,27 +25,28 @@ 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- if (is_null($user) ) {+ if (is_null($user)) {return [trans('admin/users/message.user_not_found')];}$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 ) {+ if (count($errors) > 0) {return $errors;}$checkout_at = date("Y-m-d H:i:s");- if (($request->filled('checkout_at')) && ($request->get('checkout_at')!= date("Y-m-d"))) {+ if (($request->filled('checkout_at')) && ($request->get('checkout_at') != date("Y-m-d"))) {$checkout_at = $request->get('checkout_at');}@@ -58,52 +59,8 @@ class PredefinedKitCheckoutService$note = e($request->get('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- foreach ($assets_to_add as $asset) {- $asset->location_id = $user->location_id;- $error = $asset->checkOut($user, $admin, $checkout_at, $expected_checkin, $note, null);- if ($error) {- array_merge_recursive($errors, $asset->getErrors()->toArray());- }- }- // licenses- foreach ($license_seats_to_add as $licenseSeat) {- $licenseSeat->user_id = $admin->id;- $licenseSeat->assigned_to = $user->id;- if ($licenseSeat->save()) {- event(new CheckoutableCheckedOut($licenseSeat, $user, $admin, $note));- }- else {- $errors []= 'Something went wrong saving a license seat';- }- }- // consumables- foreach($consumables_to_add as $consumable) {- $consumable->assigned_to = $user->id;- $consumable->users()->attach($consumable->id, [- 'consumable_id' => $consumable->id,- 'user_id' => $admin->id,- 'assigned_to' => $user->id- ]);- event(new CheckoutableCheckedOut($consumable, $user, $admin, $note));- }- //accessories- foreach($accessories_to_add as $accessory) {- $accessory->assigned_to = $user->id;- $accessory->users()->attach($accessory->id, [- 'accessory_id' => $accessory->id,- 'user_id' => $admin->id,- 'assigned_to' => $user->id- ]);- event(new CheckoutableCheckedOut($accessory, $user, $admin, $note));- }- return $errors;- });-+ $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) {@@ -111,70 +68,127 @@ class PredefinedKitCheckoutService}}- protected function getAssetsToAdd($kit, $user, &$errors) {+ protected function getAssetsToAdd($kit, $user, &$errors)+ {$models = $kit->models()- ->with( ['assets' => function($hasMany) { $hasMany->RTD(); }] )- ->get();+ ->with(['assets' => function ($hasMany) {+ $hasMany->RTD();+ }])+ ->get();$assets_to_add = [];- foreach($models as $model) {+ foreach ($models as $model) {$assets = $model->assets;$quantity = $model->pivot->quantity;- foreach($assets as $asset) {+ foreach ($assets as $asset) {- if ($asset->availableForCheckout()- && !$asset->is($user)) {+ if (+ $asset->availableForCheckout()+ && !$asset->is($user)+ ) {$this->authorize('checkout', $asset);$quantity -= 1;- $assets_to_add []= $asset;- if($quantity <= 0) {+ $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+ 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) {+ protected function getLicenseSeatsToAdd($kit, &$errors)+ {$seats_to_add = [];$licenses = $kit->licenses()- ->with('freeSeats')- ->get();- foreach($licenses as $license) {+ ->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+ 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];+ for ($i = 0; $i < $quantity; $i++) {+ $seats_to_add[] = $license->freeSeats[$i];}}return $seats_to_add;}- protected function getConsumablesToAdd($kit, $user, &$errors) {+ 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+ 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) {+ 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+ 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+ foreach ($assets_to_add as $asset) {+ $asset->location_id = $user->location_id;+ $error = $asset->checkOut($user, $admin, $checkout_at, $expected_checkin, $note, null);+ if ($error) {+ array_merge_recursive($errors, $asset->getErrors()->toArray());+ }+ }+ // licenses+ foreach ($license_seats_to_add as $licenseSeat) {+ $licenseSeat->user_id = $admin->id;+ $licenseSeat->assigned_to = $user->id;+ if ($licenseSeat->save()) {+ event(new CheckoutableCheckedOut($licenseSeat, $user, $admin, $note));+ } else {+ $errors[] = 'Something went wrong saving a license seat';+ }+ }+ // consumables+ foreach ($consumables_to_add as $consumable) {+ $consumable->assigned_to = $user->id;+ $consumable->users()->attach($consumable->id, [+ 'consumable_id' => $consumable->id,+ 'user_id' => $admin->id,+ 'assigned_to' => $user->id+ ]);+ event(new CheckoutableCheckedOut($consumable, $user, $admin, $note));+ }+ //accessories+ foreach ($accessories_to_add as $accessory) {+ $accessory->assigned_to = $user->id;+ $accessory->users()->attach($accessory->id, [+ 'accessory_id' => $accessory->id,+ 'user_id' => $admin->id,+ 'assigned_to' => $user->id+ ]);+ event(new CheckoutableCheckedOut($accessory, $user, $admin, $note));+ }+ return $errors;+ }+ );++ return $errors;+ }}diff --git a/resources/views/kits/accessory-edit.blade.php b/resources/views/kits/accessory-edit.blade.phpindex 807cd7fa76..e25966f7f5 100644--- a/resources/views/kits/accessory-edit.blade.php+++ b/resources/views/kits/accessory-edit.blade.php@@ -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">diff --git a/resources/views/kits/consumable-edit.blade.php b/resources/views/kits/consumable-edit.blade.phpindex 857850e8b7..896b8c37d4 100644--- a/resources/views/kits/consumable-edit.blade.php+++ b/resources/views/kits/consumable-edit.blade.php@@ -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">diff --git a/resources/views/kits/license-edit.blade.php b/resources/views/kits/license-edit.blade.phpindex 5a5e6858dc..f64678d9d6 100644--- a/resources/views/kits/license-edit.blade.php+++ b/resources/views/kits/license-edit.blade.php@@ -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">diff --git a/resources/views/kits/model-edit.blade.php b/resources/views/kits/model-edit.blade.phpindex 7a283c580d..61a419c958 100644--- a/resources/views/kits/model-edit.blade.php+++ b/resources/views/kits/model-edit.blade.php@@ -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">diff --git a/resources/views/partials/forms/edit/accessory-select.blade.php b/resources/views/partials/forms/edit/accessory-select.blade.phpindex d8c919c0fd..e786717ed8 100644--- a/resources/views/partials/forms/edit/accessory-select.blade.php+++ b/resources/views/partials/forms/edit/accessory-select.blade.php@@ -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))diff --git a/resources/views/partials/forms/edit/consumable-select.blade.php b/resources/views/partials/forms/edit/consumable-select.blade.phpindex 82fb54f537..28cc56415d 100644--- a/resources/views/partials/forms/edit/consumable-select.blade.php+++ b/resources/views/partials/forms/edit/consumable-select.blade.php@@ -3,10 +3,10 @@{{ Form::label($fieldname, $translated_name, array('class' => 'col-md-3 control-label')) }}<div class="col-md-7{{ ((isset($required) && ($required =='true'))) ? ' required' : '' }}"><select class="js-data-ajax select2" data-endpoint="consumables" data-placeholder="{{ trans('general.select_consumable') }}" name="{{ $fieldname }}" style="width: 100%" id="{{ (isset($select_id)) ? $select_id : 'assigned_consumable_select' }}"{{ (isset($multiple)) ? ' multiple' : '' }}>-+@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))