Merge branch 'fixes/kit_fixes' into develop

This commit is contained in:
snipe 2019-03-13 12:16:20 -07:00
commit 8efbde61c9
10 changed files with 87 additions and 57 deletions

View file

@ -55,7 +55,7 @@ class PredefinedKitsController extends Controller
$kit->fill($request->all());
if ($kit->save()) {
return response()->json(Helper::formatStandardApiResponse('success', $kit, 'Created was successfull')); // TODO: trans
return response()->json(Helper::formatStandardApiResponse('success', $kit, trans('admin/kits/general.create_success')));
}
return response()->json(Helper::formatStandardApiResponse('error', null, $kit->getErrors()));
@ -89,7 +89,7 @@ class PredefinedKitsController extends Controller
$kit->fill($request->all());
if ($kit->save()) {
return response()->json(Helper::formatStandardApiResponse('success', $kit, 'Update was successfull')); // TODO: trans
return response()->json(Helper::formatStandardApiResponse('success', $kit, trans('admin/kits/general.update_success'))); // TODO: trans
}
return response()->json(Helper::formatStandardApiResponse('error', null, $kit->getErrors()));
@ -113,7 +113,7 @@ class PredefinedKitsController extends Controller
$kit->accessories()->detach();
$kit->delete();
return response()->json(Helper::formatStandardApiResponse('success', null, 'Delete was successfull')); // TODO: trans
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/kits/general.delete_success'))); // TODO: trans
}
@ -214,7 +214,7 @@ class PredefinedKitsController extends Controller
$kit = PredefinedKit::findOrFail($kit_id);
$kit->licenses()->detach($license_id);
return response()->json(Helper::formatStandardApiResponse('success', $kit, 'Delete was successfull')); // TODO: trans
return response()->json(Helper::formatStandardApiResponse('success', $kit, trans('admin/kits/general.delete_success')));
}
/**
@ -238,7 +238,7 @@ class PredefinedKitsController extends Controller
*/
public function storeModel(Request $request, $kit_id)
{
//return response()->json(Helper::formatStandardApiResponse('error', 'string11', dd($request))); // TODO: trans
$this->authorize('update', PredefinedKit::class);
@ -256,7 +256,7 @@ class PredefinedKitsController extends Controller
}
$relation->attach($model_id, ['quantity' => $quantity]);
return response()->json(Helper::formatStandardApiResponse('success', $kit, 'Model added successfull')); // TODO: trans
return response()->json(Helper::formatStandardApiResponse('success', $kit, 'Model added successfull'));
}
/**
@ -291,7 +291,7 @@ class PredefinedKitsController extends Controller
$kit = PredefinedKit::findOrFail($kit_id);
$kit->models()->detach($model_id);
return response()->json(Helper::formatStandardApiResponse('success', $kit, 'Delete was successfull')); // TODO: trans
return response()->json(Helper::formatStandardApiResponse('success', $kit, trans('admin/kits/general.model_removed_success')));
}

View file

@ -95,7 +95,7 @@ class PredefinedKitCheckoutService
}
}
if ($quantity > 0) {
$errors[] = "Don't have available assets for model " . $model->name . '. Need ' . $model->pivot->quantity . ' assets.'; // TODO: trans
$errors[] = trans('admin/kits/general.none_models', ['model'=> $model->name, 'qty' => $model->pivot->quantity]);
}
}
@ -111,7 +111,7 @@ class PredefinedKitCheckoutService
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
$errors[] = trans('admin/kits/general.none_licenses', ['license'=> $license->name, 'qty' => $license->pivot->quantity]);
}
for ($i = 0; $i < $quantity; $i++) {
$seats_to_add[] = $license->freeSeats[$i];
@ -122,11 +122,10 @@ class PredefinedKitCheckoutService
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
$errors[] = trans('admin/kits/general.none_consumables', ['consumable'=> $consumable->name, 'qty' => $consumable->pivot->quantity]);
}
}
return $consumables;
@ -135,9 +134,9 @@ class PredefinedKitCheckoutService
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 $accessory) {
if ($accessory->numRemaining() < $accessory->pivot->quantity) {
$errors[] = trans('admin/kits/general.none_accessory', ['consumable'=> $accessory->name, 'qty' => $accessory->pivot->quantity]);
}
}
return $accessories;

View file

@ -252,6 +252,41 @@ return array(
),
'Kits' => array(
array(
'permission' => 'kits.view',
'label' => 'View ',
'note' => 'These are predefined kits that can be used to quickly checkout assets, licenses, etc.',
'display' => true,
),
array(
'permission' => 'kits.create',
'label' => 'Create ',
'note' => '',
'display' => true,
),
array(
'permission' => 'kits.edit',
'label' => 'Edit ',
'note' => '',
'display' => true,
),
array(
'permission' => 'kits.delete',
'label' => 'Delete ',
'note' => '',
'display' => true,
),
array(
'permission' => 'kits.checkout',
'label' => 'Checkout ',
'note' => '',
'display' => true,
),
),
'Users' => array(
array(
'permission' => 'users.view',

View file

@ -0,0 +1,16 @@
<?php
return array(
'about_kits' => 'About Predefined Kits',
'checkout' => 'Checkout Kit ',
'create_success' => 'Kit was successfully created.',
'create' => 'Create Predefined Kit',
'update' => 'Update Predefined Kit',
'delete_success' => 'Kit was successfully deleted.',
'update_success' => 'Kit was successfully updated.',
'none_models' => 'There are not enough available assets for :model to checkout. :qty are required. ',
'none_licenses' => 'There are not enough available seats for :license to checkout. :qty are required. ',
'none_consumables' => 'There are not enough available units of :consumable to checkout. :qty are required. ',
'none_accessory' => 'There are not enough available units of :accessory to checkout. :qty are required. ',
);

View file

@ -112,6 +112,7 @@
'asset_maintenances' => 'Asset Maintenances',
'item' => 'Item',
'insufficient_permissions' => 'Insufficient permissions!',
'kits' => 'Predefined Kits',
'language' => 'Language',
'last' => 'Last',
'last_login' => 'Last Login',

View file

@ -2,7 +2,7 @@
{{-- Page title --}}
@section('title')
Apply predefined kit{{-- TODO: trans --}}
{{ trans('admin/kits/general.checkout') }}
@parent
@stop
@ -20,9 +20,6 @@
<!-- left column -->
<div class="col-md-7">
<div class="box box-default">
<div class="box-header with-border">
<h3 class="box-title"> Apply predefined kit {{ $kit->name }} to user {{-- TODO: trans --}} </h3>
</div>
<div class="box-body">
<form class="form-horizontal" method="post" action="" autocomplete="off">
{{ csrf_field() }}
@ -64,7 +61,7 @@
</div> <!--./box-body-->
<div class="box-footer">
<a class="btn btn-link" href="{{ URL::previous() }}"> {{ trans('button.cancel') }}</a>
<a class="btn btn-link" href="{{ route('kits.index') }}"> {{ trans('button.cancel') }}</a>
<button type="submit" class="btn btn-success pull-right"><i class="fa fa-check icon-white"></i> {{ trans('general.checkout') }}</button>
</div>
</div>

View file

@ -1,10 +1,10 @@
@extends('layouts/edit-form', [
'createText' => 'Create kit',
'updateText' => 'Update kit',
'createText' => trans('admin/kits/general.create'),
'updateText' => trans('admin/kits/general.update'),
'formAction' => ($item) ? route('kits.update', ['kit' => $item->id]) : route('kits.store'),
])
{{-- Page content --}}
@section('inputFields')
@include ('partials.forms.edit.name', ['translated_name' => 'Name']) {{-- TODO: trans --}}
@stop
@include ('partials.forms.edit.name', ['translated_name' => trans('general.name')])
@stop

View file

@ -1,6 +1,6 @@
@extends('layouts/edit-form', [
'createText' => 'Create kit',
'updateText' => 'Update kit',
'createText' => trans('admin/kits/general.create'),
'updateText' => trans('admin/kits/general.update'),
'formAction' => ($item) ? route('kits.update', ['kit' => $item->id]) : route('kits.store'),
])
@ -16,8 +16,7 @@
<div class="col-md-12">
<div class="box box-default">
<div class="box-header with-border">
{{-- <h3 class="box-title"><span>Models </span><a href="{{ route('modal.kit.model', ['kit' => $item->id]) }}" data-toggle="modal" data-target="#createModal" class="btn btn-sm btn-primary"><i class="fa fa-plus icon-white"></i> Append</a></h3> --}}
<h3 class="box-title"><span>Assets (by models){{-- TODO: trans --}}</span></h3>
<h3 class="box-title"><span>{{ trans('general.asset_models') }}</span></h3>
</div>
<div class="box-body">
<div class="table-responsive">
@ -152,4 +151,4 @@
@section('moar_scripts')
@include ('partials.bootstrap-table')
@stop
@stop

View file

@ -2,7 +2,7 @@
{{-- Web site Title --}}
@section('title')
Kits
{{ trans('general.kits') }}
@parent
@stop
@ -39,28 +39,7 @@ Kits
}'>
</table>
</div>
{{-- <h2>Test</h2>
<div class="table-responsive">
<table
data-cookie-id-table="kitModelsTable"
data-columns="{{ \App\Presenters\PredefinedKitPresenter::dataTableModels() }}"
data-pagination="true"
data-search="true"
data-side-pagination="server"
data-show-columns="true"
data-show-export="true"
data-show-refresh="true"
data-sort-order="asc"
data-sort-name="name"
id="kitModelsTable"
class="table table-striped snipe-table"
data-url="{{ route('api.kits.models.index', 1) }}"
data-export-options='{
"fileName": "export-kit-models-{{ date('Y-m-d') }}",
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
}'>
</table>
</div> --}}
</div> <!--.box-body-->
</div> <!-- /.box.box-default-->
</div> <!-- .col-md-12-->

View file

@ -492,6 +492,15 @@
</a>
</li>
@endcan
@can('view', \App\Models\PredefinedKit::class)
<li{!! (Request::is('kits') ? ' class="active"' : '') !!}>
<a href="{{ route('kits.index') }}">
<i class="fa fa-object-group"></i>
<span>{{ trans('general.kits') }}</span>
</a>
</li>
@endcan
@can('view', \App\Models\User::class)
<li{!! (Request::is('users*') ? ' class="active"' : '') !!}>
<a href="{{ route('users.index') }}">
@ -665,12 +674,7 @@
</li>
@endcan
<li{!! (Request::is('kits') ? ' class="active"' : '') !!}>
<a href="{{ route('kits.index') }}">
<i class="fa fa-object-group"></i>
<span>Predefined kits{{-- TODO: trans --}}</span>
</a>
</li>
</ul>
</section>
<!-- /.sidebar -->