diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index 21e393bb89..a843aa09db 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -100,6 +100,7 @@ class AssetsController extends Controller 'checkout_counter', 'checkin_counter', 'requests_counter', + 'byod', ]; $filter = []; @@ -189,6 +190,10 @@ class AssetsController extends Controller $assets->ByDepreciationId($request->input('depreciation_id')); } + if ($request->filled('byod')) { + $assets->where('assets.byod', '=', $request->input('byod')); + } + $request->filled('order_number') ? $assets = $assets->where('assets.order_number', '=', e($request->get('order_number'))) : ''; // Set the offset to the API call's offset, unless the offset is higher than the actual count of items in which @@ -266,6 +271,11 @@ class AssetsController extends Controller // more sad, horrible workarounds for laravel bugs when doing full text searches $assets->where('assets.assigned_to', '>', '0'); break; + case 'byod': + // This is kind of redundant, since we already check for byod=1 above, but this keeps the + // sidebar nav links a little less chaotic + $assets->where('assets.byod', '=', '1'); + break; default: if ((! $request->filled('status_id')) && ($settings->show_archived_in_list != '1')) { diff --git a/app/Http/Controllers/Assets/AssetsController.php b/app/Http/Controllers/Assets/AssetsController.php index c845b2cc76..1c7080bd46 100755 --- a/app/Http/Controllers/Assets/AssetsController.php +++ b/app/Http/Controllers/Assets/AssetsController.php @@ -146,6 +146,7 @@ class AssetsController extends Controller $asset->supplier_id = request('supplier_id', null); $asset->requestable = request('requestable', 0); $asset->rtd_location_id = request('rtd_location_id', null); + $asset->byod = request('byod', 0); if (! empty($settings->audit_interval)) { $asset->next_audit_date = Carbon::now()->addMonths($settings->audit_interval)->toDateString(); @@ -318,6 +319,7 @@ class AssetsController extends Controller // If the box isn't checked, it's not in the request at all. $asset->requestable = $request->filled('requestable'); $asset->rtd_location_id = $request->input('rtd_location_id', null); + $asset->byod = $request->input('byod', 0); if ($asset->assigned_to == '') { $asset->location_id = $request->input('rtd_location_id', null); diff --git a/app/Http/Middleware/AssetCountForSidebar.php b/app/Http/Middleware/AssetCountForSidebar.php index 414c10e8a1..5d9656f5c1 100644 --- a/app/Http/Middleware/AssetCountForSidebar.php +++ b/app/Http/Middleware/AssetCountForSidebar.php @@ -52,6 +52,13 @@ class AssetCountForSidebar \Log::debug($e); } + try { + $total_byod_sidebar = Asset::where('byod', '=', '1')->count(); + view()->share('total_byod_sidebar', $total_byod_sidebar); + } catch (\Exception $e) { + \Log::debug($e); + } + return $next($request); } } diff --git a/app/Http/Transformers/AssetsTransformer.php b/app/Http/Transformers/AssetsTransformer.php index 9dfc6d4e7a..a36d0ab89b 100644 --- a/app/Http/Transformers/AssetsTransformer.php +++ b/app/Http/Transformers/AssetsTransformer.php @@ -35,6 +35,8 @@ class AssetsTransformer 'id' => (int) $asset->model->id, 'name'=> e($asset->model->name), ] : null, + 'byod' => ($asset->byod ? true : false), + 'model_number' => (($asset->model) && ($asset->model->model_number)) ? e($asset->model->model_number) : null, 'eol' => ($asset->purchase_date != '') ? Helper::getFormattedDateObject($asset->present()->eol_date(), 'date') : null, 'status_label' => ($asset->assetstatus) ? [ diff --git a/app/Models/Asset.php b/app/Models/Asset.php index d42461a23f..266285677f 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -95,6 +95,7 @@ class Asset extends Depreciable 'location_id' => 'integer', 'rtd_company_id' => 'integer', 'supplier_id' => 'integer', + 'byod' => 'boolean', ]; protected $rules = [ @@ -106,7 +107,6 @@ class Asset extends Depreciable 'physical' => 'numeric|max:1|nullable', 'checkout_date' => 'date|max:10|min:10|nullable', 'checkin_date' => 'date|max:10|min:10|nullable', - 'supplier_id' => 'exists:suppliers,id|numeric|nullable', 'location_id' => 'exists:locations,id|nullable', 'rtd_location_id' => 'exists:locations,id|nullable', 'asset_tag' => 'required|min:1|max:255|unique_undeleted', @@ -144,6 +144,7 @@ class Asset extends Depreciable 'requestable', 'last_checkout', 'expected_checkin', + 'byod', ]; use Searchable; diff --git a/app/Presenters/AssetPresenter.php b/app/Presenters/AssetPresenter.php index 5db653c7cb..ccc4a4cf13 100644 --- a/app/Presenters/AssetPresenter.php +++ b/app/Presenters/AssetPresenter.php @@ -250,6 +250,14 @@ class AssetPresenter extends Presenter 'visible' => false, 'title' => trans('general.next_audit_date'), 'formatter' => 'dateDisplayFormatter', + ], [ + 'field' => 'byod', + 'searchable' => false, + 'sortable' => true, + 'visible' => false, + 'title' => trans('general.byod'), + 'formatter' => 'trueFalseFormatter', + ], ]; diff --git a/database/migrations/2023_01_18_122534_add_byod_to_assets.php b/database/migrations/2023_01_18_122534_add_byod_to_assets.php new file mode 100644 index 0000000000..63c4b70623 --- /dev/null +++ b/database/migrations/2023_01_18_122534_add_byod_to_assets.php @@ -0,0 +1,34 @@ +boolean('byod')->nullable()->default(0); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('assets', function (Blueprint $table) { + if (Schema::hasColumn('assets', 'byod')) { + $table->dropColumn('byod'); + } + }); + } +} diff --git a/resources/lang/en/general.php b/resources/lang/en/general.php index f0b6a3f2cf..acc00501ed 100644 --- a/resources/lang/en/general.php +++ b/resources/lang/en/general.php @@ -39,6 +39,8 @@ return [ 'bulk_delete' => 'Bulk Delete', 'bulk_actions' => 'Bulk Actions', 'bulk_checkin_delete' => 'Bulk Checkin Items from Users', + 'byod' => 'BYOD', + 'byod_help' => 'This device is owned by the user', 'bystatus' => 'by Status', 'cancel' => 'Cancel', 'categories' => 'Categories', diff --git a/resources/views/hardware/edit.blade.php b/resources/views/hardware/edit.blade.php index ed01db3071..07c04d7f8b 100755 --- a/resources/views/hardware/edit.blade.php +++ b/resources/views/hardware/edit.blade.php @@ -120,6 +120,19 @@
@include ('partials.forms.edit.name', ['translated_name' => trans('admin/hardware/form.name')]) @include ('partials.forms.edit.warranty') + + +
+
+ +

{{ trans('general.byod_help') }} +

+
+
diff --git a/resources/views/hardware/index.blade.php b/resources/views/hardware/index.blade.php index ef095c1cef..a73b37f2ce 100755 --- a/resources/views/hardware/index.blade.php +++ b/resources/views/hardware/index.blade.php @@ -25,6 +25,8 @@ {{ trans('general.archived') }} @elseif (Request::get('status')=='Deleted') {{ trans('general.deleted') }} + @elseif (Request::get('status')=='byod') + {{ trans('general.byod') }} @endif @else {{ trans('general.all') }} diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php index 27b410e802..70f25fdca1 100755 --- a/resources/views/hardware/view.blade.php +++ b/resources/views/hardware/view.blade.php @@ -289,7 +289,6 @@ @endif - @if ((isset($audit_log)) && ($audit_log->created_at))
@@ -438,6 +437,16 @@
+ +
+
+ {{ trans('general.byod') }} +
+
+ {!! ($asset->byod=='1') ? ' '.trans('general.yes') : ' '.trans('general.no') !!} +
+
+ @if (($asset->model) && ($asset->model->fieldset)) @foreach($asset->model->fieldset->fields as $field)
diff --git a/resources/views/layouts/default.blade.php b/resources/views/layouts/default.blade.php index f332b6578e..daf4275481 100644 --- a/resources/views/layouts/default.blade.php +++ b/resources/views/layouts/default.blade.php @@ -454,6 +454,12 @@ ({{ (isset($total_undeployable_sidebar)) ? $total_undeployable_sidebar : '' }}) + + {{ trans('general.all') }} + {{ trans('general.byod') }} + ({{ (isset($total_byod_sidebar)) ? $total_byod_sidebar : '' }}) + + {{ trans('general.all') }} {{ trans('admin/hardware/general.archived') }}