mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
Merge pull request #12369 from snipe/features/add_byod_to_assets
Added BYOD to assets
This commit is contained in:
commit
fa9116b184
|
@ -100,6 +100,7 @@ class AssetsController extends Controller
|
||||||
'checkout_counter',
|
'checkout_counter',
|
||||||
'checkin_counter',
|
'checkin_counter',
|
||||||
'requests_counter',
|
'requests_counter',
|
||||||
|
'byod',
|
||||||
];
|
];
|
||||||
|
|
||||||
$filter = [];
|
$filter = [];
|
||||||
|
@ -189,6 +190,10 @@ class AssetsController extends Controller
|
||||||
$assets->ByDepreciationId($request->input('depreciation_id'));
|
$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'))) : '';
|
$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
|
// 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
|
// more sad, horrible workarounds for laravel bugs when doing full text searches
|
||||||
$assets->where('assets.assigned_to', '>', '0');
|
$assets->where('assets.assigned_to', '>', '0');
|
||||||
break;
|
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:
|
default:
|
||||||
|
|
||||||
if ((! $request->filled('status_id')) && ($settings->show_archived_in_list != '1')) {
|
if ((! $request->filled('status_id')) && ($settings->show_archived_in_list != '1')) {
|
||||||
|
|
|
@ -146,6 +146,7 @@ class AssetsController extends Controller
|
||||||
$asset->supplier_id = request('supplier_id', null);
|
$asset->supplier_id = request('supplier_id', null);
|
||||||
$asset->requestable = request('requestable', 0);
|
$asset->requestable = request('requestable', 0);
|
||||||
$asset->rtd_location_id = request('rtd_location_id', null);
|
$asset->rtd_location_id = request('rtd_location_id', null);
|
||||||
|
$asset->byod = request('byod', 0);
|
||||||
|
|
||||||
if (! empty($settings->audit_interval)) {
|
if (! empty($settings->audit_interval)) {
|
||||||
$asset->next_audit_date = Carbon::now()->addMonths($settings->audit_interval)->toDateString();
|
$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.
|
// If the box isn't checked, it's not in the request at all.
|
||||||
$asset->requestable = $request->filled('requestable');
|
$asset->requestable = $request->filled('requestable');
|
||||||
$asset->rtd_location_id = $request->input('rtd_location_id', null);
|
$asset->rtd_location_id = $request->input('rtd_location_id', null);
|
||||||
|
$asset->byod = $request->input('byod', 0);
|
||||||
|
|
||||||
if ($asset->assigned_to == '') {
|
if ($asset->assigned_to == '') {
|
||||||
$asset->location_id = $request->input('rtd_location_id', null);
|
$asset->location_id = $request->input('rtd_location_id', null);
|
||||||
|
|
|
@ -52,6 +52,13 @@ class AssetCountForSidebar
|
||||||
\Log::debug($e);
|
\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);
|
return $next($request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,8 @@ class AssetsTransformer
|
||||||
'id' => (int) $asset->model->id,
|
'id' => (int) $asset->model->id,
|
||||||
'name'=> e($asset->model->name),
|
'name'=> e($asset->model->name),
|
||||||
] : null,
|
] : null,
|
||||||
|
'byod' => ($asset->byod ? true : false),
|
||||||
|
|
||||||
'model_number' => (($asset->model) && ($asset->model->model_number)) ? e($asset->model->model_number) : null,
|
'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,
|
'eol' => ($asset->purchase_date != '') ? Helper::getFormattedDateObject($asset->present()->eol_date(), 'date') : null,
|
||||||
'status_label' => ($asset->assetstatus) ? [
|
'status_label' => ($asset->assetstatus) ? [
|
||||||
|
|
|
@ -95,6 +95,7 @@ class Asset extends Depreciable
|
||||||
'location_id' => 'integer',
|
'location_id' => 'integer',
|
||||||
'rtd_company_id' => 'integer',
|
'rtd_company_id' => 'integer',
|
||||||
'supplier_id' => 'integer',
|
'supplier_id' => 'integer',
|
||||||
|
'byod' => 'boolean',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $rules = [
|
protected $rules = [
|
||||||
|
@ -106,7 +107,6 @@ class Asset extends Depreciable
|
||||||
'physical' => 'numeric|max:1|nullable',
|
'physical' => 'numeric|max:1|nullable',
|
||||||
'checkout_date' => 'date|max:10|min:10|nullable',
|
'checkout_date' => 'date|max:10|min:10|nullable',
|
||||||
'checkin_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',
|
'location_id' => 'exists:locations,id|nullable',
|
||||||
'rtd_location_id' => 'exists:locations,id|nullable',
|
'rtd_location_id' => 'exists:locations,id|nullable',
|
||||||
'asset_tag' => 'required|min:1|max:255|unique_undeleted',
|
'asset_tag' => 'required|min:1|max:255|unique_undeleted',
|
||||||
|
@ -144,6 +144,7 @@ class Asset extends Depreciable
|
||||||
'requestable',
|
'requestable',
|
||||||
'last_checkout',
|
'last_checkout',
|
||||||
'expected_checkin',
|
'expected_checkin',
|
||||||
|
'byod',
|
||||||
];
|
];
|
||||||
|
|
||||||
use Searchable;
|
use Searchable;
|
||||||
|
|
|
@ -250,6 +250,14 @@ class AssetPresenter extends Presenter
|
||||||
'visible' => false,
|
'visible' => false,
|
||||||
'title' => trans('general.next_audit_date'),
|
'title' => trans('general.next_audit_date'),
|
||||||
'formatter' => 'dateDisplayFormatter',
|
'formatter' => 'dateDisplayFormatter',
|
||||||
|
], [
|
||||||
|
'field' => 'byod',
|
||||||
|
'searchable' => false,
|
||||||
|
'sortable' => true,
|
||||||
|
'visible' => false,
|
||||||
|
'title' => trans('general.byod'),
|
||||||
|
'formatter' => 'trueFalseFormatter',
|
||||||
|
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
34
database/migrations/2023_01_18_122534_add_byod_to_assets.php
Normal file
34
database/migrations/2023_01_18_122534_add_byod_to_assets.php
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddByodToAssets extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('assets', function (Blueprint $table) {
|
||||||
|
$table->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');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -39,6 +39,8 @@ return [
|
||||||
'bulk_delete' => 'Bulk Delete',
|
'bulk_delete' => 'Bulk Delete',
|
||||||
'bulk_actions' => 'Bulk Actions',
|
'bulk_actions' => 'Bulk Actions',
|
||||||
'bulk_checkin_delete' => 'Bulk Checkin Items from Users',
|
'bulk_checkin_delete' => 'Bulk Checkin Items from Users',
|
||||||
|
'byod' => 'BYOD',
|
||||||
|
'byod_help' => 'This device is owned by the user',
|
||||||
'bystatus' => 'by Status',
|
'bystatus' => 'by Status',
|
||||||
'cancel' => 'Cancel',
|
'cancel' => 'Cancel',
|
||||||
'categories' => 'Categories',
|
'categories' => 'Categories',
|
||||||
|
|
|
@ -120,6 +120,19 @@
|
||||||
<br>
|
<br>
|
||||||
@include ('partials.forms.edit.name', ['translated_name' => trans('admin/hardware/form.name')])
|
@include ('partials.forms.edit.name', ['translated_name' => trans('admin/hardware/form.name')])
|
||||||
@include ('partials.forms.edit.warranty')
|
@include ('partials.forms.edit.warranty')
|
||||||
|
|
||||||
|
<!-- byod checkbox -->
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-7 col-md-offset-3">
|
||||||
|
<label for="byod">
|
||||||
|
<input type="checkbox" value="1" name="byod" class="minimal" {{ (old('remote', $item->byod)) == '1' ? ' checked="checked"' : '' }} aria-label="byod">
|
||||||
|
{{ trans('general.byod') }}
|
||||||
|
|
||||||
|
</label>
|
||||||
|
<p class="help-block">{{ trans('general.byod_help') }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
{{ trans('general.archived') }}
|
{{ trans('general.archived') }}
|
||||||
@elseif (Request::get('status')=='Deleted')
|
@elseif (Request::get('status')=='Deleted')
|
||||||
{{ trans('general.deleted') }}
|
{{ trans('general.deleted') }}
|
||||||
|
@elseif (Request::get('status')=='byod')
|
||||||
|
{{ trans('general.byod') }}
|
||||||
@endif
|
@endif
|
||||||
@else
|
@else
|
||||||
{{ trans('general.all') }}
|
{{ trans('general.all') }}
|
||||||
|
|
|
@ -289,7 +289,6 @@
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
|
||||||
@if ((isset($audit_log)) && ($audit_log->created_at))
|
@if ((isset($audit_log)) && ($audit_log->created_at))
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-2">
|
<div class="col-md-2">
|
||||||
|
@ -438,6 +437,16 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- byod -->
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-2">
|
||||||
|
<strong>{{ trans('general.byod') }}</strong>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-9">
|
||||||
|
{!! ($asset->byod=='1') ? '<i class="fas fa-check text-success" aria-hidden="true"></i> '.trans('general.yes') : '<i class="fas fa-times text-danger" aria-hidden="true"></i> '.trans('general.no') !!}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
@if (($asset->model) && ($asset->model->fieldset))
|
@if (($asset->model) && ($asset->model->fieldset))
|
||||||
@foreach($asset->model->fieldset->fields as $field)
|
@foreach($asset->model->fieldset->fields as $field)
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
|
@ -454,6 +454,12 @@
|
||||||
({{ (isset($total_undeployable_sidebar)) ? $total_undeployable_sidebar : '' }})
|
({{ (isset($total_undeployable_sidebar)) ? $total_undeployable_sidebar : '' }})
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li{!! (Request::query('status') == 'byod' ? ' class="active"' : '') !!}><a href="{{ url('hardware?status=byod') }}"><i class="fas fa-times text-red fa-fw"></i>
|
||||||
|
{{ trans('general.all') }}
|
||||||
|
{{ trans('general.byod') }}
|
||||||
|
({{ (isset($total_byod_sidebar)) ? $total_byod_sidebar : '' }})
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
<li{!! (Request::query('status') == 'Archived' ? ' class="active"' : '') !!}><a href="{{ url('hardware?status=Archived') }}"><i class="fas fa-times text-red fa-fw"></i>
|
<li{!! (Request::query('status') == 'Archived' ? ' class="active"' : '') !!}><a href="{{ url('hardware?status=Archived') }}"><i class="fas fa-times text-red fa-fw"></i>
|
||||||
{{ trans('general.all') }}
|
{{ trans('general.all') }}
|
||||||
{{ trans('admin/hardware/general.archived') }}
|
{{ trans('admin/hardware/general.archived') }}
|
||||||
|
|
Loading…
Reference in a new issue