Compare commits
4 Commits
master
...
refactor_s
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
53330514ac | ||
|
|
ba226d9ba3 | ||
|
|
95d136284d | ||
|
|
f5aea7b0d5 |
@@ -553,7 +553,7 @@ class Helper
|
|||||||
*/
|
*/
|
||||||
public static function statusLabelList()
|
public static function statusLabelList()
|
||||||
{
|
{
|
||||||
$statuslabel_list = ['' => trans('general.select_statuslabel')] + Statuslabel::orderBy('default_label', 'desc')->orderBy('name', 'asc')->orderBy('deployable', 'desc')
|
$statuslabel_list = ['' => trans('general.select_statuslabel')] + Statuslabel::orderBy('default_label', 'desc')->orderBy('name', 'asc')->orderBy('status_type', 'desc')
|
||||||
->pluck('name', 'id')->toArray();
|
->pluck('name', 'id')->toArray();
|
||||||
|
|
||||||
return $statuslabel_list;
|
return $statuslabel_list;
|
||||||
@@ -572,9 +572,9 @@ class Helper
|
|||||||
*/
|
*/
|
||||||
public static function deployableStatusLabelList()
|
public static function deployableStatusLabelList()
|
||||||
{
|
{
|
||||||
$statuslabel_list = Statuslabel::where('deployable', '=', '1')->orderBy('default_label', 'desc')
|
$statuslabel_list = Statuslabel::where('status_type', 'deployable')->orderBy('default_label', 'desc')
|
||||||
->orderBy('name', 'asc')
|
->orderBy('name', 'asc')
|
||||||
->orderBy('deployable', 'desc')
|
->orderBy('status_type', 'desc')
|
||||||
->pluck('name', 'id')->toArray();
|
->pluck('name', 'id')->toArray();
|
||||||
|
|
||||||
return $statuslabel_list;
|
return $statuslabel_list;
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class AssetsController extends Controller
|
|||||||
if ($action == 'audit') {
|
if ($action == 'audit') {
|
||||||
$action = 'audits';
|
$action = 'audits';
|
||||||
}
|
}
|
||||||
$filter_non_deprecable_assets = false;
|
$filter_non_depreciable_assets = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This looks MAD janky (and it is), but the AssetsController@index does a LOT of heavy lifting throughout the
|
* This looks MAD janky (and it is), but the AssetsController@index does a LOT of heavy lifting throughout the
|
||||||
@@ -75,7 +75,7 @@ class AssetsController extends Controller
|
|||||||
* which would have been far worse of a mess. *sad face* - snipe (Sept 1, 2021)
|
* which would have been far worse of a mess. *sad face* - snipe (Sept 1, 2021)
|
||||||
*/
|
*/
|
||||||
if (Route::currentRouteName()=='api.depreciation-report.index') {
|
if (Route::currentRouteName()=='api.depreciation-report.index') {
|
||||||
$filter_non_deprecable_assets = true;
|
$filter_non_depreciable_assets = true;
|
||||||
$transformer = 'App\Http\Transformers\DepreciationReportTransformer';
|
$transformer = 'App\Http\Transformers\DepreciationReportTransformer';
|
||||||
$this->authorize('reports.view');
|
$this->authorize('reports.view');
|
||||||
} else {
|
} else {
|
||||||
@@ -130,9 +130,9 @@ class AssetsController extends Controller
|
|||||||
'model.category', 'model.manufacturer', 'model.fieldset','supplier'); //it might be tempting to add 'assetlog' here, but don't. It blows up update-heavy users.
|
'model.category', 'model.manufacturer', 'model.fieldset','supplier'); //it might be tempting to add 'assetlog' here, but don't. It blows up update-heavy users.
|
||||||
|
|
||||||
|
|
||||||
if ($filter_non_deprecable_assets) {
|
if ($filter_non_depreciable_assets) {
|
||||||
$non_deprecable_models = AssetModel::select('id')->whereNotNull('depreciation_id')->get();
|
$non_depreciable_models = AssetModel::select('id')->whereNotNull('depreciation_id')->get();
|
||||||
$assets->InModelList($non_deprecable_models->toArray());
|
$assets->InModelList($non_depreciable_models->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -206,18 +206,14 @@ class AssetsController extends Controller
|
|||||||
case 'Pending':
|
case 'Pending':
|
||||||
$assets->join('status_labels AS status_alias', function ($join) {
|
$assets->join('status_labels AS status_alias', function ($join) {
|
||||||
$join->on('status_alias.id', '=', 'assets.status_id')
|
$join->on('status_alias.id', '=', 'assets.status_id')
|
||||||
->where('status_alias.deployable', '=', 0)
|
->where('status_alias.status_type', '=', 'pending');
|
||||||
->where('status_alias.pending', '=', 1)
|
|
||||||
->where('status_alias.archived', '=', 0);
|
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'RTD':
|
case 'RTD':
|
||||||
$assets->whereNull('assets.assigned_to')
|
$assets->whereNull('assets.assigned_to')
|
||||||
->join('status_labels AS status_alias', function ($join) {
|
->join('status_labels AS status_alias', function ($join) {
|
||||||
$join->on('status_alias.id', '=', 'assets.status_id')
|
$join->on('status_alias.id', '=', 'assets.status_id')
|
||||||
->where('status_alias.deployable', '=', 1)
|
->where('status_alias.status_type', '=', 'deployable');
|
||||||
->where('status_alias.pending', '=', 0)
|
|
||||||
->where('status_alias.archived', '=', 0);
|
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'Undeployable':
|
case 'Undeployable':
|
||||||
@@ -226,20 +222,15 @@ class AssetsController extends Controller
|
|||||||
case 'Archived':
|
case 'Archived':
|
||||||
$assets->join('status_labels AS status_alias', function ($join) {
|
$assets->join('status_labels AS status_alias', function ($join) {
|
||||||
$join->on('status_alias.id', '=', 'assets.status_id')
|
$join->on('status_alias.id', '=', 'assets.status_id')
|
||||||
->where('status_alias.deployable', '=', 0)
|
->where('status_alias.status_type', '=', 'archived');
|
||||||
->where('status_alias.pending', '=', 0)
|
|
||||||
->where('status_alias.archived', '=', 1);
|
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'Requestable':
|
case 'Requestable':
|
||||||
$assets->where('assets.requestable', '=', 1)
|
$assets->where('assets.requestable', '=', 1)
|
||||||
->join('status_labels AS status_alias', function ($join) {
|
->join('status_labels AS status_alias', function ($join) {
|
||||||
$join->on('status_alias.id', '=', 'assets.status_id')
|
$join->on('status_alias.id', '=', 'assets.status_id')
|
||||||
->where('status_alias.deployable', '=', 1)
|
->where('status_alias.status_type', '=', 'deployable');
|
||||||
->where('status_alias.pending', '=', 0)
|
|
||||||
->where('status_alias.archived', '=', 0);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'Deployed':
|
case 'Deployed':
|
||||||
// more sad, horrible workarounds for laravel bugs when doing full text searches
|
// more sad, horrible workarounds for laravel bugs when doing full text searches
|
||||||
@@ -256,7 +247,7 @@ class AssetsController extends Controller
|
|||||||
// terrible workaround for complex-query Laravel bug in fulltext
|
// terrible workaround for complex-query Laravel bug in fulltext
|
||||||
$assets->join('status_labels AS status_alias', function ($join) {
|
$assets->join('status_labels AS status_alias', function ($join) {
|
||||||
$join->on('status_alias.id', '=', 'assets.status_id')
|
$join->on('status_alias.id', '=', 'assets.status_id')
|
||||||
->where('status_alias.archived', '=', 0);
|
->where('status_alias.status_type', '!=', 'archived');
|
||||||
});
|
});
|
||||||
|
|
||||||
// If there is a status ID, don't take show_archived_in_list into consideration
|
// If there is a status ID, don't take show_archived_in_list into consideration
|
||||||
@@ -265,6 +256,7 @@ class AssetsController extends Controller
|
|||||||
$join->on('status_alias.id', '=', 'assets.status_id');
|
$join->on('status_alias.id', '=', 'assets.status_id');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -574,8 +566,8 @@ class AssetsController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($asset->assetstatus->getStatuslabelType() == 'pending') {
|
if ($asset->assetstatus->status_label == 'pending') {
|
||||||
$asset->use_text .= '('.$asset->assetstatus->getStatuslabelType().')';
|
$asset->use_text .= '('.$asset->assetstatus->status_label.')';
|
||||||
}
|
}
|
||||||
|
|
||||||
$asset->use_image = ($asset->getImageUrl()) ? $asset->getImageUrl() : null;
|
$asset->use_image = ($asset->getImageUrl()) ? $asset->getImageUrl() : null;
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ class StatuslabelsController extends Controller
|
|||||||
'assets_count',
|
'assets_count',
|
||||||
'color',
|
'color',
|
||||||
'notes',
|
'notes',
|
||||||
'default_label'
|
'default_label',
|
||||||
|
'status_type',
|
||||||
];
|
];
|
||||||
|
|
||||||
$statuslabels = Statuslabel::with('adminuser')->withCount('assets as assets_count');
|
$statuslabels = Statuslabel::with('adminuser')->withCount('assets as assets_count');
|
||||||
@@ -49,13 +50,12 @@ class StatuslabelsController extends Controller
|
|||||||
// if a status_type is passed, filter by that
|
// if a status_type is passed, filter by that
|
||||||
if ($request->filled('status_type')) {
|
if ($request->filled('status_type')) {
|
||||||
if (strtolower($request->input('status_type')) == 'pending') {
|
if (strtolower($request->input('status_type')) == 'pending') {
|
||||||
$statuslabels = $statuslabels->Pending();
|
$statuslabels->where('status_type', '=', 'pending');
|
||||||
} elseif (strtolower($request->input('status_type')) == 'archived') {
|
} elseif (strtolower($request->input('status_type')) == 'archived') $statuslabels->where('status_type', '=', 'archived');
|
||||||
$statuslabels = $statuslabels->Archived();
|
elseif (strtolower($request->input('status_type')) == 'deployable') {
|
||||||
} elseif (strtolower($request->input('status_type')) == 'deployable') {
|
$statuslabels->where('status_type', '=', 'deployable');
|
||||||
$statuslabels = $statuslabels->Deployable();
|
|
||||||
} elseif (strtolower($request->input('status_type')) == 'undeployable') {
|
} elseif (strtolower($request->input('status_type')) == 'undeployable') {
|
||||||
$statuslabels = $statuslabels->Undeployable();
|
$statuslabels->whereNot('status_type', 'deployable');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,20 +92,11 @@ class StatuslabelsController extends Controller
|
|||||||
public function store(Request $request) : JsonResponse
|
public function store(Request $request) : JsonResponse
|
||||||
{
|
{
|
||||||
$this->authorize('create', Statuslabel::class);
|
$this->authorize('create', Statuslabel::class);
|
||||||
$request->except('deployable', 'pending', 'archived');
|
|
||||||
|
|
||||||
if (! $request->filled('type')) {
|
|
||||||
|
|
||||||
return response()->json(Helper::formatStandardApiResponse('error', null, ['type' => ['Status label type is required.']]));
|
|
||||||
}
|
|
||||||
|
|
||||||
$statuslabel = new Statuslabel;
|
$statuslabel = new Statuslabel;
|
||||||
$statuslabel->fill($request->all());
|
$statuslabel->fill($request->all());
|
||||||
|
$statuslabel->status_type = $request->input('status_type');
|
||||||
$statusType = Statuslabel::getStatuslabelTypesForDB($request->input('type'));
|
|
||||||
$statuslabel->deployable = $statusType['deployable'];
|
|
||||||
$statuslabel->pending = $statusType['pending'];
|
|
||||||
$statuslabel->archived = $statusType['archived'];
|
|
||||||
$statuslabel->color = $request->input('color');
|
$statuslabel->color = $request->input('color');
|
||||||
$statuslabel->show_in_nav = $request->input('show_in_nav', 0);
|
$statuslabel->show_in_nav = $request->input('show_in_nav', 0);
|
||||||
$statuslabel->default_label = $request->input('default_label', 0);
|
$statuslabel->default_label = $request->input('default_label', 0);
|
||||||
@@ -146,20 +137,12 @@ class StatuslabelsController extends Controller
|
|||||||
{
|
{
|
||||||
$this->authorize('update', Statuslabel::class);
|
$this->authorize('update', Statuslabel::class);
|
||||||
$statuslabel = Statuslabel::findOrFail($id);
|
$statuslabel = Statuslabel::findOrFail($id);
|
||||||
|
|
||||||
$request->except('deployable', 'pending', 'archived');
|
|
||||||
|
|
||||||
|
|
||||||
if (! $request->filled('type')) {
|
|
||||||
return response()->json(Helper::formatStandardApiResponse('error', null, 'Status label type is required.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$statuslabel->fill($request->all());
|
$statuslabel->fill($request->all());
|
||||||
|
|
||||||
$statusType = Statuslabel::getStatuslabelTypesForDB($request->input('type'));
|
$statusType = Statuslabel::getStatuslabelTypesForDB($request->input('type'));
|
||||||
$statuslabel->deployable = $statusType['deployable'];
|
$statuslabel->status_type = $request->input('status_type');
|
||||||
$statuslabel->pending = $statusType['pending'];
|
|
||||||
$statuslabel->archived = $statusType['archived'];
|
|
||||||
$statuslabel->color = $request->input('color');
|
$statuslabel->color = $request->input('color');
|
||||||
$statuslabel->show_in_nav = $request->input('show_in_nav', 0);
|
$statuslabel->show_in_nav = $request->input('show_in_nav', 0);
|
||||||
$statuslabel->default_label = $request->input('default_label', 0);
|
$statuslabel->default_label = $request->input('default_label', 0);
|
||||||
@@ -207,7 +190,7 @@ class StatuslabelsController extends Controller
|
|||||||
$this->authorize('view', Statuslabel::class);
|
$this->authorize('view', Statuslabel::class);
|
||||||
|
|
||||||
if (Setting::getSettings()->show_archived_in_list == 0 ) {
|
if (Setting::getSettings()->show_archived_in_list == 0 ) {
|
||||||
$statuslabels = Statuslabel::withCount('assets')->where('archived','0')->get();
|
$statuslabels = Statuslabel::withCount('assets')->whereNot('status_type','archived')->get();
|
||||||
} else {
|
} else {
|
||||||
$statuslabels = Statuslabel::withCount('assets')->get();
|
$statuslabels = Statuslabel::withCount('assets')->get();
|
||||||
}
|
}
|
||||||
@@ -301,7 +284,7 @@ class StatuslabelsController extends Controller
|
|||||||
public function checkIfDeployable($id) : string
|
public function checkIfDeployable($id) : string
|
||||||
{
|
{
|
||||||
$statuslabel = Statuslabel::findOrFail($id);
|
$statuslabel = Statuslabel::findOrFail($id);
|
||||||
if ($statuslabel->getStatuslabelType() == 'deployable') {
|
if ($statuslabel->status_type == 'deployable') {
|
||||||
return '1';
|
return '1';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,22 +302,22 @@ class StatuslabelsController extends Controller
|
|||||||
{
|
{
|
||||||
|
|
||||||
$this->authorize('view.selectlists');
|
$this->authorize('view.selectlists');
|
||||||
$statuslabels = Statuslabel::orderBy('default_label', 'desc')->orderBy('name', 'asc')->orderBy('deployable', 'desc');
|
$statuslabels = Statuslabel::orderBy('default_label', 'desc')->orderBy('name', 'asc')->orderBy('status_type', 'desc');
|
||||||
|
|
||||||
if ($request->filled('search')) {
|
if ($request->filled('search')) {
|
||||||
$statuslabels = $statuslabels->where('name', 'LIKE', '%'.$request->get('search').'%');
|
$statuslabels = $statuslabels->where('name', 'LIKE', '%'.$request->get('search').'%');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->filled('deployable')) {
|
if ($request->filled('deployable')) {
|
||||||
$statuslabels = $statuslabels->where('deployable', '=', '1');
|
$statuslabels = $statuslabels->where('status_type', '=', 'deployable');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->filled('pending')) {
|
if ($request->filled('pending')) {
|
||||||
$statuslabels = $statuslabels->where('pending', '=', '1');
|
$statuslabels = $statuslabels->where('status_type', '=', 'pending');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->filled('archived')) {
|
if ($request->filled('archived')) {
|
||||||
$statuslabels = $statuslabels->where('archived', '=', '1');
|
$statuslabels = $statuslabels->where('status_type', '=', 'archived');
|
||||||
}
|
}
|
||||||
|
|
||||||
$statuslabels = $statuslabels->orderBy('name', 'ASC')->paginate(50);
|
$statuslabels = $statuslabels->orderBy('name', 'ASC')->paginate(50);
|
||||||
|
|||||||
@@ -352,7 +352,7 @@ class AssetsController extends Controller
|
|||||||
$status = Statuslabel::find($request->input('status_id'));
|
$status = Statuslabel::find($request->input('status_id'));
|
||||||
|
|
||||||
// This is a non-deployable status label - we should check the asset back in.
|
// This is a non-deployable status label - we should check the asset back in.
|
||||||
if (($status && $status->getStatuslabelType() != 'deployable') && ($target = $asset->assignedTo)) {
|
if (($status && $status->status_type != 'deployable') && ($target = $asset->assignedTo)) {
|
||||||
|
|
||||||
$originalValues = $asset->getRawOriginal();
|
$originalValues = $asset->getRawOriginal();
|
||||||
$asset->assigned_to = null;
|
$asset->assigned_to = null;
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class ModalController extends Controller
|
|||||||
$view = view("modals.${type}");
|
$view = view("modals.${type}");
|
||||||
|
|
||||||
if ($type == "statuslabel") {
|
if ($type == "statuslabel") {
|
||||||
$view->with('statuslabel_types', Helper::statusTypeList());
|
$view->with('status_types', Helper::statusTypeList());
|
||||||
}
|
}
|
||||||
if (in_array($type, ['kit-model', 'kit-license', 'kit-consumable', 'kit-accessory'])) {
|
if (in_array($type, ['kit-model', 'kit-license', 'kit-consumable', 'kit-accessory'])) {
|
||||||
$view->with('kitId', $itemId);
|
$view->with('kitId', $itemId);
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class StatuslabelsController extends Controller
|
|||||||
|
|
||||||
return view('statuslabels/edit')
|
return view('statuslabels/edit')
|
||||||
->with('item', new Statuslabel)
|
->with('item', new Statuslabel)
|
||||||
->with('statuslabel_types', Helper::statusTypeList());
|
->with('status_types', Helper::statusTypeList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,19 +61,11 @@ class StatuslabelsController extends Controller
|
|||||||
// create a new model instance
|
// create a new model instance
|
||||||
$statusLabel = new Statuslabel();
|
$statusLabel = new Statuslabel();
|
||||||
|
|
||||||
if ($request->missing('statuslabel_types')) {
|
|
||||||
return redirect()->back()->withInput()->withErrors(['statuslabel_types' => trans('validation.statuslabel_type')]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$statusType = Statuslabel::getStatuslabelTypesForDB($request->input('statuslabel_types'));
|
|
||||||
|
|
||||||
// Save the Statuslabel data
|
// Save the Statuslabel data
|
||||||
$statusLabel->name = $request->input('name');
|
$statusLabel->name = $request->input('name');
|
||||||
$statusLabel->created_by = auth()->id();
|
$statusLabel->created_by = auth()->id();
|
||||||
$statusLabel->notes = $request->input('notes');
|
$statusLabel->notes = $request->input('notes');
|
||||||
$statusLabel->deployable = $statusType['deployable'];
|
$statusLabel->status_type = $request->input('status_type');
|
||||||
$statusLabel->pending = $statusType['pending'];
|
|
||||||
$statusLabel->archived = $statusType['archived'];
|
|
||||||
$statusLabel->color = $request->input('color');
|
$statusLabel->color = $request->input('color');
|
||||||
$statusLabel->show_in_nav = $request->input('show_in_nav', 0);
|
$statusLabel->show_in_nav = $request->input('show_in_nav', 0);
|
||||||
$statusLabel->default_label = $request->input('default_label', 0);
|
$statusLabel->default_label = $request->input('default_label', 0);
|
||||||
@@ -100,11 +92,7 @@ class StatuslabelsController extends Controller
|
|||||||
return redirect()->route('statuslabels.index')->with('error', trans('admin/statuslabels/message.does_not_exist'));
|
return redirect()->route('statuslabels.index')->with('error', trans('admin/statuslabels/message.does_not_exist'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$use_statuslabel_type = $item->getStatuslabelType();
|
return view('statuslabels/edit', compact('item'))->with('status_types', Helper::statusTypeList());;
|
||||||
|
|
||||||
$statuslabel_types = ['' => trans('admin/hardware/form.select_statustype')] + ['undeployable' => trans('admin/hardware/general.undeployable')] + ['pending' => trans('admin/hardware/general.pending')] + ['archived' => trans('admin/hardware/general.archived')] + ['deployable' => trans('admin/hardware/general.deployable')];
|
|
||||||
|
|
||||||
return view('statuslabels/edit', compact('item', 'statuslabel_types'))->with('use_statuslabel_type', $use_statuslabel_type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -121,17 +109,10 @@ class StatuslabelsController extends Controller
|
|||||||
return redirect()->route('statuslabels.index')->with('error', trans('admin/statuslabels/message.does_not_exist'));
|
return redirect()->route('statuslabels.index')->with('error', trans('admin/statuslabels/message.does_not_exist'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $request->filled('statuslabel_types')) {
|
|
||||||
return redirect()->back()->withInput()->withErrors(['statuslabel_types' => trans('validation.statuslabel_type')]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the Statuslabel data
|
// Update the Statuslabel data
|
||||||
$statustype = Statuslabel::getStatuslabelTypesForDB($request->input('statuslabel_types'));
|
|
||||||
$statuslabel->name = $request->input('name');
|
$statuslabel->name = $request->input('name');
|
||||||
$statuslabel->notes = $request->input('notes');
|
$statuslabel->notes = $request->input('notes');
|
||||||
$statuslabel->deployable = $statustype['deployable'];
|
$statuslabel->status_type = $request->input('status_type');
|
||||||
$statuslabel->pending = $statustype['pending'];
|
|
||||||
$statuslabel->archived = $statustype['archived'];
|
|
||||||
$statuslabel->color = $request->input('color');
|
$statuslabel->color = $request->input('color');
|
||||||
$statuslabel->show_in_nav = $request->input('show_in_nav', 0);
|
$statuslabel->show_in_nav = $request->input('show_in_nav', 0);
|
||||||
$statuslabel->default_label = $request->input('default_label', 0);
|
$statuslabel->default_label = $request->input('default_label', 0);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class AssetMaintenancesTransformer
|
|||||||
'status_label' => ($assetmaintenance->asset->assetstatus) ? [
|
'status_label' => ($assetmaintenance->asset->assetstatus) ? [
|
||||||
'id' => (int) $assetmaintenance->asset->assetstatus->id,
|
'id' => (int) $assetmaintenance->asset->assetstatus->id,
|
||||||
'name'=> e($assetmaintenance->asset->assetstatus->name),
|
'name'=> e($assetmaintenance->asset->assetstatus->name),
|
||||||
'status_type'=> e($assetmaintenance->asset->assetstatus->getStatuslabelType()),
|
'status_type'=> e($assetmaintenance->asset->assetstatus->status_type),
|
||||||
'status_meta' => e($assetmaintenance->asset->present()->statusMeta),
|
'status_meta' => e($assetmaintenance->asset->present()->statusMeta),
|
||||||
] : null,
|
] : null,
|
||||||
'company' => (($assetmaintenance->asset) && ($assetmaintenance->asset->company)) ? [
|
'company' => (($assetmaintenance->asset) && ($assetmaintenance->asset->company)) ? [
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ use App\Models\Setting;
|
|||||||
use Illuminate\Support\Facades\Gate;
|
use Illuminate\Support\Facades\Gate;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
|
|
||||||
class AssetsTransformer
|
class AssetsTransformer
|
||||||
{
|
{
|
||||||
@@ -45,8 +44,8 @@ class AssetsTransformer
|
|||||||
'status_label' => ($asset->assetstatus) ? [
|
'status_label' => ($asset->assetstatus) ? [
|
||||||
'id' => (int) $asset->assetstatus->id,
|
'id' => (int) $asset->assetstatus->id,
|
||||||
'name'=> e($asset->assetstatus->name),
|
'name'=> e($asset->assetstatus->name),
|
||||||
'status_type'=> e($asset->assetstatus->getStatuslabelType()),
|
'status_type'=> e($asset->assetstatus->status_type),
|
||||||
'status_meta' => e($asset->present()->statusMeta),
|
'status_meta' => e($asset->assetstatus->status_type),
|
||||||
] : null,
|
] : null,
|
||||||
'category' => (($asset->model) && ($asset->model->category)) ? [
|
'category' => (($asset->model) && ($asset->model->category)) ? [
|
||||||
'id' => (int) $asset->model->category->id,
|
'id' => (int) $asset->model->category->id,
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ class StatuslabelsTransformer
|
|||||||
$array = [
|
$array = [
|
||||||
'id' => (int) $statuslabel->id,
|
'id' => (int) $statuslabel->id,
|
||||||
'name' => e($statuslabel->name),
|
'name' => e($statuslabel->name),
|
||||||
'type' => $statuslabel->getStatuslabelType(),
|
'type' => $statuslabel->status_type, // legacy - to be removed in later versions
|
||||||
|
'status_type' => $statuslabel->status_type,
|
||||||
'color' => ($statuslabel->color) ? e($statuslabel->color) : null,
|
'color' => ($statuslabel->color) ? e($statuslabel->color) : null,
|
||||||
'show_in_nav' => ($statuslabel->show_in_nav == '1') ? true : false,
|
'show_in_nav' => ($statuslabel->show_in_nav == '1') ? true : false,
|
||||||
'default_label' => ($statuslabel->default_label == '1') ? true : false,
|
'default_label' => ($statuslabel->default_label == '1') ? true : false,
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ class AssetImporter extends ItemImporter
|
|||||||
|
|
||||||
$this->defaultStatusLabelId = Statuslabel::first()->id;
|
$this->defaultStatusLabelId = Statuslabel::first()->id;
|
||||||
|
|
||||||
if (!is_null(Statuslabel::deployable()->first())) {
|
if (!is_null(Statuslabel::where('status_type', 'deployable')->first())) {
|
||||||
$this->defaultStatusLabelId = Statuslabel::deployable()->first()->id;
|
$this->defaultStatusLabelId = Statuslabel::where('status_type', 'deployable')->first()->id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -301,9 +301,9 @@ class Asset extends Depreciable
|
|||||||
// This asset is not currently assigned to anyone and is not deleted...
|
// This asset is not currently assigned to anyone and is not deleted...
|
||||||
if ((! $this->assigned_to) && (! $this->deleted_at)) {
|
if ((! $this->assigned_to) && (! $this->deleted_at)) {
|
||||||
|
|
||||||
// The asset status is not archived and is deployable
|
// The asset is not archived and the status is deployable
|
||||||
if (($this->assetstatus) && ($this->assetstatus->archived == '0')
|
if (($this->assetstatus) && ($this->archived == '0')
|
||||||
&& ($this->assetstatus->deployable == '1'))
|
&& ($this->assetstatus->status_type == 'deployable'))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -1146,9 +1146,7 @@ class Asset extends Depreciable
|
|||||||
public function scopePending($query)
|
public function scopePending($query)
|
||||||
{
|
{
|
||||||
return $query->whereHas('assetstatus', function ($query) {
|
return $query->whereHas('assetstatus', function ($query) {
|
||||||
$query->where('deployable', '=', 0)
|
$query->where('status_type', '=', 'deployable');
|
||||||
->where('pending', '=', 1)
|
|
||||||
->where('archived', '=', 0);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1195,9 +1193,7 @@ class Asset extends Depreciable
|
|||||||
{
|
{
|
||||||
return $query->whereNull('assets.assigned_to')
|
return $query->whereNull('assets.assigned_to')
|
||||||
->whereHas('assetstatus', function ($query) {
|
->whereHas('assetstatus', function ($query) {
|
||||||
$query->where('deployable', '=', 1)
|
$query->where('status_type', '=', 'deployable');
|
||||||
->where('pending', '=', 0)
|
|
||||||
->where('archived', '=', 0);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1212,9 +1208,7 @@ class Asset extends Depreciable
|
|||||||
public function scopeUndeployable($query)
|
public function scopeUndeployable($query)
|
||||||
{
|
{
|
||||||
return $query->whereHas('assetstatus', function ($query) {
|
return $query->whereHas('assetstatus', function ($query) {
|
||||||
$query->where('deployable', '=', 0)
|
$query->where('status_type', '!=', 'deployable');
|
||||||
->where('pending', '=', 0)
|
|
||||||
->where('archived', '=', 0);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1229,7 +1223,7 @@ class Asset extends Depreciable
|
|||||||
public function scopeNotArchived($query)
|
public function scopeNotArchived($query)
|
||||||
{
|
{
|
||||||
return $query->whereHas('assetstatus', function ($query) {
|
return $query->whereHas('assetstatus', function ($query) {
|
||||||
$query->where('archived', '=', 0);
|
$query->where('status_type', '!=', 'archived');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1406,9 +1400,7 @@ class Asset extends Depreciable
|
|||||||
public function scopeArchived($query)
|
public function scopeArchived($query)
|
||||||
{
|
{
|
||||||
return $query->whereHas('assetstatus', function ($query) {
|
return $query->whereHas('assetstatus', function ($query) {
|
||||||
$query->where('deployable', '=', 0)
|
$query->where('status_type', '=', 'archived');
|
||||||
->where('pending', '=', 0)
|
|
||||||
->where('archived', '=', 1);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1440,9 +1432,8 @@ class Asset extends Depreciable
|
|||||||
return Company::scopeCompanyables($query->where($table.'.requestable', '=', 1))
|
return Company::scopeCompanyables($query->where($table.'.requestable', '=', 1))
|
||||||
->whereHas('assetstatus', function ($query) {
|
->whereHas('assetstatus', function ($query) {
|
||||||
$query->where(function ($query) {
|
$query->where(function ($query) {
|
||||||
$query->where('deployable', '=', 1)
|
$query->where('status_type', '!=', 'archived'); // you definitely can't request something that's archived
|
||||||
->where('archived', '=', 0); // you definitely can't request something that's archived
|
}); // we've decided that even though an asset may be 'pending', you can still request it
|
||||||
})->orWhere('pending', '=', 1); // we've decided that even though an asset may be 'pending', you can still request it
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -138,9 +138,7 @@ class Location extends SnipeModel
|
|||||||
{
|
{
|
||||||
return $this->hasMany(\App\Models\Asset::class, 'location_id')
|
return $this->hasMany(\App\Models\Asset::class, 'location_id')
|
||||||
->whereHas('assetstatus', function ($query) {
|
->whereHas('assetstatus', function ($query) {
|
||||||
$query->where('status_labels.deployable', '=', 1)
|
$query->whereNot('status_labels.status_type', '=', 'archived');
|
||||||
->orWhere('status_labels.pending', '=', 1)
|
|
||||||
->orWhere('status_labels.archived', '=', 0);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,17 +23,16 @@ class Statuslabel extends SnipeModel
|
|||||||
protected $rules = [
|
protected $rules = [
|
||||||
'name' => 'required|string|unique_undeleted',
|
'name' => 'required|string|unique_undeleted',
|
||||||
'notes' => 'string|nullable',
|
'notes' => 'string|nullable',
|
||||||
'deployable' => 'required',
|
'status_type' => 'required|in:deployable,pending,archived,undeployable1',
|
||||||
'pending' => 'required',
|
|
||||||
'archived' => 'required',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'archived',
|
'status_type',
|
||||||
'deployable',
|
|
||||||
'name',
|
'name',
|
||||||
'notes',
|
'notes',
|
||||||
'pending',
|
'color',
|
||||||
|
'show_in_nav',
|
||||||
|
'default_label',
|
||||||
];
|
];
|
||||||
|
|
||||||
use Searchable;
|
use Searchable;
|
||||||
@@ -76,54 +75,6 @@ class Statuslabel extends SnipeModel
|
|||||||
* @since [v1.0]
|
* @since [v1.0]
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getStatuslabelType()
|
|
||||||
{
|
|
||||||
if (($this->pending == '1') && ($this->archived == '0') && ($this->deployable == '0')) {
|
|
||||||
return 'pending';
|
|
||||||
} elseif (($this->pending == '0') && ($this->archived == '1') && ($this->deployable == '0')) {
|
|
||||||
return 'archived';
|
|
||||||
} elseif (($this->pending == '0') && ($this->archived == '0') && ($this->deployable == '0')) {
|
|
||||||
return 'undeployable';
|
|
||||||
}
|
|
||||||
|
|
||||||
return 'deployable';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Query builder scope to for pending status types
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Database\Query\Builder Modified query builder
|
|
||||||
*/
|
|
||||||
public function scopePending()
|
|
||||||
{
|
|
||||||
return $this->where('pending', '=', 1)
|
|
||||||
->where('archived', '=', 0)
|
|
||||||
->where('deployable', '=', 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Query builder scope for archived status types
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Database\Query\Builder Modified query builder
|
|
||||||
*/
|
|
||||||
public function scopeArchived()
|
|
||||||
{
|
|
||||||
return $this->where('pending', '=', 0)
|
|
||||||
->where('archived', '=', 1)
|
|
||||||
->where('deployable', '=', 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Query builder scope for deployable status types
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Database\Query\Builder Modified query builder
|
|
||||||
*/
|
|
||||||
public function scopeDeployable()
|
|
||||||
{
|
|
||||||
return $this->where('pending', '=', 0)
|
|
||||||
->where('archived', '=', 0)
|
|
||||||
->where('deployable', '=', 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query builder scope for undeployable status types
|
* Query builder scope for undeployable status types
|
||||||
@@ -132,40 +83,10 @@ class Statuslabel extends SnipeModel
|
|||||||
*/
|
*/
|
||||||
public function scopeUndeployable()
|
public function scopeUndeployable()
|
||||||
{
|
{
|
||||||
return $this->where('pending', '=', 0)
|
return $this->whereNot('status_type', '=', 'deployable');
|
||||||
->where('archived', '=', 0)
|
|
||||||
->where('deployable', '=', 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper function to determine type attributes
|
|
||||||
*
|
|
||||||
* @author A. Gianotto <snipe@snipe.net>
|
|
||||||
* @since [v1.0]
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function getStatuslabelTypesForDB($type)
|
|
||||||
{
|
|
||||||
$statustype['pending'] = 0;
|
|
||||||
$statustype['deployable'] = 0;
|
|
||||||
$statustype['archived'] = 0;
|
|
||||||
|
|
||||||
if ($type == 'pending') {
|
|
||||||
$statustype['pending'] = 1;
|
|
||||||
$statustype['deployable'] = 0;
|
|
||||||
$statustype['archived'] = 0;
|
|
||||||
} elseif ($type == 'deployable') {
|
|
||||||
$statustype['pending'] = 0;
|
|
||||||
$statustype['deployable'] = 1;
|
|
||||||
$statustype['archived'] = 0;
|
|
||||||
} elseif ($type == 'archived') {
|
|
||||||
$statustype['pending'] = 0;
|
|
||||||
$statustype['deployable'] = 0;
|
|
||||||
$statustype['archived'] = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $statustype;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function scopeOrderByCreatedBy($query, $order)
|
public function scopeOrderByCreatedBy($query, $order)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -479,19 +479,6 @@ class AssetPresenter extends Presenter
|
|||||||
return $interval;
|
return $interval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
* This handles the status label "meta" status of "deployed" if
|
|
||||||
* it's assigned. Should maybe deprecate.
|
|
||||||
*/
|
|
||||||
public function statusMeta()
|
|
||||||
{
|
|
||||||
if ($this->model->assigned) {
|
|
||||||
return 'deployed';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->model->assetstatus->getStatuslabelType();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
|
|||||||
@@ -311,7 +311,7 @@ class DepreciationReportPresenter extends Presenter
|
|||||||
if ($this->model->assigned) {
|
if ($this->model->assigned) {
|
||||||
return 'deployed';
|
return 'deployed';
|
||||||
}
|
}
|
||||||
return $this->model->assetstatus->getStatuslabelType();
|
return $this->model->assetstatus->status_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ class StatusLabelPresenter extends Presenter
|
|||||||
'visible' => true,
|
'visible' => true,
|
||||||
'formatter' => 'statuslabelsAssetLinkFormatter',
|
'formatter' => 'statuslabelsAssetLinkFormatter',
|
||||||
],[
|
],[
|
||||||
'field' => 'type',
|
'field' => 'status_type',
|
||||||
'searchable' => false,
|
'searchable' => true,
|
||||||
'sortable' => false,
|
'sortable' => true,
|
||||||
'switchable' => false,
|
'switchable' => false,
|
||||||
'title' => trans('admin/statuslabels/table.status_type'),
|
'title' => trans('admin/statuslabels/table.status_type'),
|
||||||
'visible' => true,
|
'visible' => true,
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class AssetCannotBeCheckedOutToNondeployableStatus implements DataAwareRule, Val
|
|||||||
// Check to see if any of the assign-ish fields are set
|
// Check to see if any of the assign-ish fields are set
|
||||||
if ((isset($this->data['assigned_to'])) || (isset($this->data['assigned_user'])) || (isset($this->data['assigned_location'])) || (isset($this->data['assigned_asset'])) || (isset($this->data['assigned_type']))) {
|
if ((isset($this->data['assigned_to'])) || (isset($this->data['assigned_user'])) || (isset($this->data['assigned_location'])) || (isset($this->data['assigned_asset'])) || (isset($this->data['assigned_type']))) {
|
||||||
|
|
||||||
if (($value) && ($label = Statuslabel::find($value)) && ($label->getStatuslabelType()!='deployable')) {
|
if (($value) && ($label = Statuslabel::find($value)) && ($label->status_type!='deployable')) {
|
||||||
$fail(trans('admin/hardware/form.asset_not_deployable'));
|
$fail(trans('admin/hardware/form.asset_not_deployable'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,8 @@ class AssetFactory extends Factory
|
|||||||
'rtd_location_id' => Location::factory(),
|
'rtd_location_id' => Location::factory(),
|
||||||
'serial' => $this->faker->uuid(),
|
'serial' => $this->faker->uuid(),
|
||||||
'status_id' => function () {
|
'status_id' => function () {
|
||||||
return Statuslabel::where('name', 'Ready to Deploy')->first() ?? Statuslabel::factory()->rtd()->create(['name' => 'Ready to Deploy']);
|
// $status = Statuslabel::factory()->create(); dd($status) ;
|
||||||
|
return Statuslabel::where('status_type', 'deployable')->first() ?? Statuslabel::factory()->create(['name' => 'Ready to Deploy', 'status_type' => 'deployable'])->id;
|
||||||
},
|
},
|
||||||
'created_by' => User::factory()->superuser(),
|
'created_by' => User::factory()->superuser(),
|
||||||
'asset_tag' => $this->faker->unixTime('now'),
|
'asset_tag' => $this->faker->unixTime('now'),
|
||||||
|
|||||||
@@ -28,9 +28,7 @@ class StatuslabelFactory extends Factory
|
|||||||
'updated_at' => $this->faker->dateTime(),
|
'updated_at' => $this->faker->dateTime(),
|
||||||
'created_by' => User::factory()->superuser(),
|
'created_by' => User::factory()->superuser(),
|
||||||
'deleted_at' => null,
|
'deleted_at' => null,
|
||||||
'deployable' => 0,
|
'status_type' => 'deployable',
|
||||||
'pending' => 0,
|
|
||||||
'archived' => 0,
|
|
||||||
'notes' => '',
|
'notes' => '',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -40,7 +38,7 @@ class StatuslabelFactory extends Factory
|
|||||||
return $this->state(function () {
|
return $this->state(function () {
|
||||||
return [
|
return [
|
||||||
'notes' => $this->faker->sentence(),
|
'notes' => $this->faker->sentence(),
|
||||||
'deployable' => 1,
|
'status_type' => 'deployable',
|
||||||
'default_label' => 1,
|
'default_label' => 1,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
@@ -56,7 +54,7 @@ class StatuslabelFactory extends Factory
|
|||||||
return $this->state(function () {
|
return $this->state(function () {
|
||||||
return [
|
return [
|
||||||
'notes' => $this->faker->sentence(),
|
'notes' => $this->faker->sentence(),
|
||||||
'pending' => 1,
|
'status_type' => 'pending',
|
||||||
'default_label' => 1,
|
'default_label' => 1,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
@@ -67,8 +65,8 @@ class StatuslabelFactory extends Factory
|
|||||||
return $this->state(function () {
|
return $this->state(function () {
|
||||||
return [
|
return [
|
||||||
'notes' => 'These assets are permanently undeployable',
|
'notes' => 'These assets are permanently undeployable',
|
||||||
'archived' => 1,
|
|
||||||
'default_label' => 0,
|
'default_label' => 0,
|
||||||
|
'status_type' => 'archived',
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -79,6 +77,7 @@ class StatuslabelFactory extends Factory
|
|||||||
return [
|
return [
|
||||||
'name' => 'Out for Diagnostics',
|
'name' => 'Out for Diagnostics',
|
||||||
'default_label' => 0,
|
'default_label' => 0,
|
||||||
|
'status_type' => 'pending',
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -89,6 +88,7 @@ class StatuslabelFactory extends Factory
|
|||||||
return [
|
return [
|
||||||
'name' => 'Out for Repair',
|
'name' => 'Out for Repair',
|
||||||
'default_label' => 0,
|
'default_label' => 0,
|
||||||
|
'status_type' => 'pending',
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -99,6 +99,7 @@ class StatuslabelFactory extends Factory
|
|||||||
return [
|
return [
|
||||||
'name' => 'Broken - Not Fixable',
|
'name' => 'Broken - Not Fixable',
|
||||||
'default_label' => 0,
|
'default_label' => 0,
|
||||||
|
'status_type' => 'archived',
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -109,6 +110,7 @@ class StatuslabelFactory extends Factory
|
|||||||
return [
|
return [
|
||||||
'name' => 'Lost/Stolen',
|
'name' => 'Lost/Stolen',
|
||||||
'default_label' => 0,
|
'default_label' => 0,
|
||||||
|
'status_type' => 'archived',
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use App\Models\StatusLabel;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!Schema::hasColumn('status_labels', 'status_type')) {
|
||||||
|
|
||||||
|
Schema::table('status_labels', function (Blueprint $table) {
|
||||||
|
$table->string('status_type')->after('name')->default('deployable');
|
||||||
|
});
|
||||||
|
|
||||||
|
DB::table('status_labels')->where('pending', 1)->update(['status_type' => 'pending']);
|
||||||
|
DB::table('status_labels')->where('archived', 1)->update(['status_type' => 'archived']);
|
||||||
|
DB::table('status_labels')->where('deployable', 1)->update(['status_type' => 'deployable']);
|
||||||
|
|
||||||
|
Schema::table('status_labels', function (Blueprint $table) {
|
||||||
|
$table->renameColumn('deployable', 'legacy_deployable');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('status_labels', function (Blueprint $table) {
|
||||||
|
$table->renameColumn('pending', 'legacy_pending');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('status_labels', function (Blueprint $table) {
|
||||||
|
$table->renameColumn('archived', 'legacy_archived');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
|
||||||
|
if (Schema::hasColumn('status_labels', 'status_type')) {
|
||||||
|
|
||||||
|
Schema::table('status_labels', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('status_type');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('status_labels', function (Blueprint $table) {
|
||||||
|
$table->renameColumn('legacy_deployable', 'deployable');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('status_labels', function (Blueprint $table) {
|
||||||
|
$table->renameColumn('legacy_pending', 'pending');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('status_labels', function (Blueprint $table) {
|
||||||
|
$table->renameColumn('legacy_archived', 'archived');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -37,6 +37,7 @@ class SettingsSeeder extends Seeder
|
|||||||
$settings->support_footer = 'on';
|
$settings->support_footer = 'on';
|
||||||
$settings->pwd_secure_min = '8';
|
$settings->pwd_secure_min = '8';
|
||||||
$settings->default_avatar = 'default.png';
|
$settings->default_avatar = 'default.png';
|
||||||
|
$settings->show_archived_in_list = 0;
|
||||||
$settings->save();
|
$settings->save();
|
||||||
|
|
||||||
if ($user = User::where('username', '=', 'admin')->first()) {
|
if ($user = User::where('username', '=', 'admin')->first()) {
|
||||||
|
|||||||
@@ -17,21 +17,27 @@ class StatuslabelSeeder extends Seeder
|
|||||||
Statuslabel::factory()->rtd()->create([
|
Statuslabel::factory()->rtd()->create([
|
||||||
'name' => 'Ready to Deploy',
|
'name' => 'Ready to Deploy',
|
||||||
'created_by' => $admin->id,
|
'created_by' => $admin->id,
|
||||||
|
'status_type' => 'deployable',
|
||||||
|
'legacy_deployable' => 1,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Statuslabel::factory()->pending()->create([
|
Statuslabel::factory()->pending()->create([
|
||||||
'name' => 'Pending',
|
'name' => 'Pending',
|
||||||
'created_by' => $admin->id,
|
'created_by' => $admin->id,
|
||||||
|
'status_type' => 'pending',
|
||||||
|
'legacy_pending' => 1,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Statuslabel::factory()->archived()->create([
|
Statuslabel::factory()->archived()->create([
|
||||||
'name' => 'Archived',
|
'name' => 'Archived',
|
||||||
'created_by' => $admin->id,
|
'created_by' => $admin->id,
|
||||||
|
'status_type' => 'archived',
|
||||||
|
'legacy_archived' => 1,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Statuslabel::factory()->outForDiagnostics()->create(['created_by' => $admin->id]);
|
Statuslabel::factory()->outForDiagnostics()->pending()->create(['created_by' => $admin->id]);
|
||||||
Statuslabel::factory()->outForRepair()->create(['created_by' => $admin->id]);
|
Statuslabel::factory()->outForRepair()->pending()->create(['created_by' => $admin->id]);
|
||||||
Statuslabel::factory()->broken()->create(['created_by' => $admin->id]);
|
Statuslabel::factory()->broken()->archived()->create(['created_by' => $admin->id]);
|
||||||
Statuslabel::factory()->lost()->create(['created_by' => $admin->id]);
|
Statuslabel::factory()->lost()->archived()->create(['created_by' => $admin->id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,13 +22,13 @@
|
|||||||
@include ('partials.forms.edit.name', ['translated_name' => trans('general.name')])
|
@include ('partials.forms.edit.name', ['translated_name' => trans('general.name')])
|
||||||
|
|
||||||
<!-- Label type -->
|
<!-- Label type -->
|
||||||
<div class="form-group{{ $errors->has('statuslabel_types') ? ' has-error' : '' }}">
|
<div class="form-group{{ $errors->has('status_type') ? ' has-error' : '' }}">
|
||||||
<label for="statuslabel_types" class="col-md-3 control-label">
|
<label for="statuslabel_types" class="col-md-3 control-label">
|
||||||
{{ trans('admin/statuslabels/table.status_type') }}
|
{{ trans('admin/statuslabels/table.status_type') }}
|
||||||
</label>
|
</label>
|
||||||
<div class="col-md-7 required">
|
<div class="col-md-7 required">
|
||||||
{{ Form::select('statuslabel_types', $statuslabel_types, $item->getStatuslabelType(), array('class'=>'select2', 'style'=>'width: 100%; min-width:400px', 'aria-label'=>'statuslabel_types')) }}
|
{{ Form::select('status_type', $status_types, $item->status_type, array('class'=>'select2', 'style'=>'width: 100%; min-width:400px', 'aria-label'=>'status_type')) }}
|
||||||
{!! $errors->first('statuslabel_types', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
{!! $errors->first('status_type', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,23 @@ class AssetIndexTest extends TestCase
|
|||||||
{
|
{
|
||||||
public function testAssetApiIndexReturnsExpectedAssets()
|
public function testAssetApiIndexReturnsExpectedAssets()
|
||||||
{
|
{
|
||||||
Asset::factory()->count(3)->create();
|
$this->withoutExceptionHandling();
|
||||||
|
|
||||||
$this->actingAsForApi(User::factory()->superuser()->create())
|
if ($assets = Asset::factory()->count(3)->make()) {
|
||||||
|
//dd($assets);
|
||||||
|
|
||||||
|
foreach ($assets as $asset) {
|
||||||
|
\Log::error($asset->asset_tag);
|
||||||
|
\Log::error($asset->assetstatus->name);
|
||||||
|
\Log::error($asset->assetstatus->status_type);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
\Log::error('No created');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$response = $this->actingAsForApi(User::factory()->superuser()->create())
|
||||||
->getJson(
|
->getJson(
|
||||||
route('api.assets.index', [
|
route('api.assets.index', [
|
||||||
'sort' => 'name',
|
'sort' => 'name',
|
||||||
@@ -29,6 +43,7 @@ class AssetIndexTest extends TestCase
|
|||||||
'rows',
|
'rows',
|
||||||
])
|
])
|
||||||
->assertJson(fn(AssertableJson $json) => $json->has('rows', 3)->etc());
|
->assertJson(fn(AssertableJson $json) => $json->has('rows', 3)->etc());
|
||||||
|
\Log::error($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAssetApiIndexReturnsDisplayUpcomingAuditsDue()
|
public function testAssetApiIndexReturnsDisplayUpcomingAuditsDue()
|
||||||
|
|||||||
Reference in New Issue
Block a user