diff --git a/app/Http/Controllers/Consumables/ConsumablesController.php b/app/Http/Controllers/Consumables/ConsumablesController.php index 5685944a5c..883d5849ee 100644 --- a/app/Http/Controllers/Consumables/ConsumablesController.php +++ b/app/Http/Controllers/Consumables/ConsumablesController.php @@ -200,7 +200,7 @@ class ConsumablesController extends Controller */ public function show($consumableId = null) { - $consumable = Consumable::find($consumableId); + $consumable = Consumable::withCount('users as users_consumables')->find($consumableId); $this->authorize($consumable); if (isset($consumable->id)) { return view('consumables/view', compact('consumable')); @@ -209,4 +209,16 @@ class ConsumablesController extends Controller return redirect()->route('consumables.index') ->with('error', trans('admin/consumables/message.does_not_exist')); } + + public function clone(Consumable $consumable) : View + { + $this->authorize('create', $consumable); + $consumable_to_close = $consumable; + $consumable = clone $consumable_to_close; + $consumable->id = null; + $consumable->image = null; + $consumable->user_id = null; + + return view('consumables/edit')->with('item', $consumable); + } } diff --git a/app/Http/Transformers/ConsumablesTransformer.php b/app/Http/Transformers/ConsumablesTransformer.php index f23ebc0382..d0ae57eef0 100644 --- a/app/Http/Transformers/ConsumablesTransformer.php +++ b/app/Http/Transformers/ConsumablesTransformer.php @@ -55,6 +55,7 @@ class ConsumablesTransformer 'checkin' => Gate::allows('checkin', Consumable::class), 'update' => Gate::allows('update', Consumable::class), 'delete' => Gate::allows('delete', Consumable::class), + 'clone' => (Gate::allows('create', Consumable::class) && ($consumable->deleted_at == '')), ]; $array += $permissions_array; diff --git a/config/app.php b/config/app.php index 44f2d26555..9de8b63c6d 100755 --- a/config/app.php +++ b/config/app.php @@ -427,5 +427,5 @@ return [ */ 'escape_formulas' => env('CSV_ESCAPE_FORMULAS', true), - + ]; diff --git a/package-lock.json b/package-lock.json index fccdd5add6..8ede991415 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "bootstrap-colorpicker": "^2.5.3", "bootstrap-datepicker": "^1.10.0", "bootstrap-less": "^3.3.8", - "bootstrap-table": "1.22.5", + "bootstrap-table": "1.23.0", "chart.js": "^2.9.4", "clipboard": "^2.0.11", "css-loader": "^5.0.0", @@ -3692,9 +3692,9 @@ "license": "MIT" }, "node_modules/bootstrap-table": { - "version": "1.22.5", - "resolved": "https://registry.npmjs.org/bootstrap-table/-/bootstrap-table-1.22.5.tgz", - "integrity": "sha512-iaQBfZzNuMRVughNYdonPGvgL6A7xfsruqYKaSuDuUWqQDTt8WvTBVwV61XiDv2aks7RaAQoZhoi2jo9nF6U7w==", + "version": "1.23.0", + "resolved": "https://registry.npmjs.org/bootstrap-table/-/bootstrap-table-1.23.0.tgz", + "integrity": "sha512-fAIhu2CAqMsZWkzeFxXyh0yQA2DMBdB0tCdr1iF6bKr3c/Hf79cw5PykNt7NdtqLz/a0p192S8EKyT5lG4yrpw==", "peerDependencies": { "jquery": "3" } diff --git a/package.json b/package.json index 9f942c9d27..e933aae374 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "bootstrap-colorpicker": "^2.5.3", "bootstrap-datepicker": "^1.10.0", "bootstrap-less": "^3.3.8", - "bootstrap-table": "1.22.5", + "bootstrap-table": "1.23.0", "chart.js": "^2.9.4", "clipboard": "^2.0.11", "css-loader": "^5.0.0", diff --git a/public/css/dist/all.css b/public/css/dist/all.css index 6288f25f8f..ef7a76dc0b 100644 Binary files a/public/css/dist/all.css and b/public/css/dist/all.css differ diff --git a/public/css/dist/bootstrap-table.css b/public/css/dist/bootstrap-table.css index f2ada1e98f..d49b107a8a 100644 Binary files a/public/css/dist/bootstrap-table.css and b/public/css/dist/bootstrap-table.css differ diff --git a/public/js/dist/bootstrap-table-en-US.min.js b/public/js/dist/bootstrap-table-en-US.min.js new file mode 100644 index 0000000000..a62b1e8812 Binary files /dev/null and b/public/js/dist/bootstrap-table-en-US.min.js differ diff --git a/public/js/dist/bootstrap-table-locale-all.min.js b/public/js/dist/bootstrap-table-locale-all.min.js index a58f1fb4fc..b0ed3c69bd 100644 Binary files a/public/js/dist/bootstrap-table-locale-all.min.js and b/public/js/dist/bootstrap-table-locale-all.min.js differ diff --git a/public/js/dist/bootstrap-table.js b/public/js/dist/bootstrap-table.js index 50835d55ea..842161053b 100644 Binary files a/public/js/dist/bootstrap-table.js and b/public/js/dist/bootstrap-table.js differ diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 6e0d71cdfb..51766c2ecc 100644 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -18,7 +18,7 @@ "/css/dist/skins/skin-green-dark.css": "/css/dist/skins/skin-green-dark.css?id=198553147983f411db55d774009bf481", "/css/dist/skins/skin-green.css": "/css/dist/skins/skin-green.css?id=b48f4d8af0e1ca5621c161e93951109f", "/css/dist/skins/skin-contrast.css": "/css/dist/skins/skin-contrast.css?id=f0fbbb0ac729ea092578fb05ca615460", - "/css/dist/all.css": "/css/dist/all.css?id=a9f493a1d66b45420401f3ae8ee4aab1", + "/css/dist/all.css": "/css/dist/all.css?id=fba2adaeb1f10de7b4f6628260ee6ef2", "/css/dist/signature-pad.css": "/css/dist/signature-pad.css?id=6a89d3cd901305e66ced1cf5f13147f7", "/css/dist/signature-pad.min.css": "/css/dist/signature-pad.min.css?id=6a89d3cd901305e66ced1cf5f13147f7", "/js/select2/i18n/af.js": "/js/select2/i18n/af.js?id=4f6fcd73488ce79fae1b7a90aceaecde", @@ -89,10 +89,11 @@ "/css/webfonts/fa-solid-900.woff2": "/css/webfonts/fa-solid-900.woff2?id=96d16b1bdb177fd796c810b9e706c780", "/css/webfonts/fa-v4compatibility.ttf": "/css/webfonts/fa-v4compatibility.ttf?id=8994b282f9f3b7a00380bb1e2731a4bf", "/css/webfonts/fa-v4compatibility.woff2": "/css/webfonts/fa-v4compatibility.woff2?id=111e341dba724e1df946e8d1f406a7bd", - "/js/dist/bootstrap-table-locale-all.min.js": "/js/dist/bootstrap-table-locale-all.min.js?id=7373e7d7017cceca6c32928080cea0fb", - "/css/dist/bootstrap-table.css": "/css/dist/bootstrap-table.css?id=5f79123a6750afd34dbf565faec3dda3", + "/js/dist/bootstrap-table-locale-all.min.js": "/js/dist/bootstrap-table-locale-all.min.js?id=27eb00f47f9bae70cd630d184b7969f1", + "/js/dist/bootstrap-table-en-US.min.js": "/js/dist/bootstrap-table-en-US.min.js?id=57bdb4770b2924f5efeda100caf3c9b7", + "/css/dist/bootstrap-table.css": "/css/dist/bootstrap-table.css?id=8abbb6aea625ec64cd7ebdad77ebf6e5", "/js/build/vendor.js": "/js/build/vendor.js?id=e27070bdbc5fce3bfd132b952d641fd6", - "/js/dist/bootstrap-table.js": "/js/dist/bootstrap-table.js?id=e5918703a22f8992c4c98f1dbbecb8f7", + "/js/dist/bootstrap-table.js": "/js/dist/bootstrap-table.js?id=859e11e4e6b05c84e4b7302de29bac5e", "/js/dist/all.js": "/js/dist/all.js?id=d4e3181b505407e7bd10b1fd802ae109", "/css/dist/skins/skin-green.min.css": "/css/dist/skins/skin-green.min.css?id=b48f4d8af0e1ca5621c161e93951109f", "/css/dist/skins/skin-green-dark.min.css": "/css/dist/skins/skin-green-dark.min.css?id=198553147983f411db55d774009bf481", diff --git a/resources/lang/en-US/admin/consumables/general.php b/resources/lang/en-US/admin/consumables/general.php index 7c6bb32968..29acfedc1b 100644 --- a/resources/lang/en-US/admin/consumables/general.php +++ b/resources/lang/en-US/admin/consumables/general.php @@ -8,4 +8,5 @@ return array( 'remaining' => 'Remaining', 'total' => 'Total', 'update' => 'Update Consumable', + 'inventory_warning' => 'The inventory of this consumable is below the minimum amount of :min_count', ); diff --git a/resources/lang/en-US/button.php b/resources/lang/en-US/button.php index 22821b8157..51c54bb9b5 100644 --- a/resources/lang/en-US/button.php +++ b/resources/lang/en-US/button.php @@ -7,6 +7,7 @@ return [ 'checkin_and_delete' => 'Checkin All / Delete User', 'delete' => 'Delete', 'edit' => 'Edit', + 'clone' => 'Clone', 'restore' => 'Restore', 'remove' => 'Remove', 'request' => 'Request', @@ -21,4 +22,13 @@ return [ 'add_maintenance' => 'Add Maintenance', 'append' => 'Append', 'new' => 'New', + 'var' => [ + 'clone' => 'Clone :item_type', + 'edit' => 'Edit :item_type', + 'delete' => 'Delete :item_type', + 'restore' => 'Delete :item_type', + 'create' => 'Create New :item_type', + 'checkout' => 'Checkout :item_type', + 'checkin' => 'Checkin :item_type', + ] ]; diff --git a/resources/lang/en-US/general.php b/resources/lang/en-US/general.php index 71bbb05a4f..b3a6b34320 100644 --- a/resources/lang/en-US/general.php +++ b/resources/lang/en-US/general.php @@ -557,5 +557,6 @@ return [ 'close' => 'Close', 'expires' => 'Expires', 'map_fields'=> 'Map :item_type Field', + 'remaining_var' => ':count Remaining', ]; diff --git a/resources/views/accessories/view.blade.php b/resources/views/accessories/view.blade.php index 9a37059b41..e42439bd86 100644 --- a/resources/views/accessories/view.blade.php +++ b/resources/views/accessories/view.blade.php @@ -330,7 +330,7 @@ {{ trans('admin/accessories/general.edit') }} @endcan - @can('update', \App\Models\Accessory::class) + @can('create', \App\Models\Accessory::class)
{{ trans('admin/accessories/general.clone') }}
diff --git a/resources/views/consumables/view.blade.php b/resources/views/consumables/view.blade.php index 5a25659fbe..f6ea14042e 100644 --- a/resources/views/consumables/view.blade.php +++ b/resources/views/consumables/view.blade.php @@ -2,114 +2,520 @@ {{-- Page title --}} @section('title') - {{ $consumable->name }} - {{ trans('general.consumable') }} -@parent -@stop + {{ $consumable->name }} + {{ trans('general.consumable') }} - + ({{ trans('general.remaining_var', ['count' => $consumable->numRemaining()]) }}) + @parent +@endsection @section('header_right') - - {{ trans('general.back') }} -@stop - + + {{ trans('general.back') }} +@endsection {{-- Page content --}} @section('content') -
-
- -