mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-10 15:44:11 -08:00
Merge branch 'develop' of https://github.com/snipe/snipe-it into develop
This commit is contained in:
commit
a26119c262
|
@ -54,7 +54,7 @@ class AssetsController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
\Log::debug(Route::currentRouteName());
|
\Log::debug(Route::currentRouteName());
|
||||||
|
$filter_non_deprecable_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
|
||||||
|
@ -68,6 +68,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;
|
||||||
$transformer = 'App\Http\Transformers\DepreciationReportTransformer';
|
$transformer = 'App\Http\Transformers\DepreciationReportTransformer';
|
||||||
$this->authorize('reports.view');
|
$this->authorize('reports.view');
|
||||||
} else {
|
} else {
|
||||||
|
@ -118,6 +119,12 @@ 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) {
|
||||||
|
$non_deprecable_models = AssetModel::select('id')->whereNotNull('depreciation_id')->get();
|
||||||
|
|
||||||
|
$assets->InModelList($non_deprecable_models->toArray());
|
||||||
|
}
|
||||||
|
|
||||||
// These are used by the API to query against specific ID numbers.
|
// These are used by the API to query against specific ID numbers.
|
||||||
// They are also used by the individual searches on detail pages like
|
// They are also used by the individual searches on detail pages like
|
||||||
// locations, etc.
|
// locations, etc.
|
||||||
|
|
|
@ -178,6 +178,7 @@ class ItemImporter extends Importer
|
||||||
*/
|
*/
|
||||||
public function createOrFetchAssetModel(array $row)
|
public function createOrFetchAssetModel(array $row)
|
||||||
{
|
{
|
||||||
|
$condition = array();
|
||||||
$asset_model_name = $this->findCsvMatch($row, 'asset_model');
|
$asset_model_name = $this->findCsvMatch($row, 'asset_model');
|
||||||
$asset_modelNumber = $this->findCsvMatch($row, 'model_number');
|
$asset_modelNumber = $this->findCsvMatch($row, 'model_number');
|
||||||
// TODO: At the moment, this means we can't update the model number if the model name stays the same.
|
// TODO: At the moment, this means we can't update the model number if the model name stays the same.
|
||||||
|
@ -189,8 +190,16 @@ class ItemImporter extends Importer
|
||||||
} elseif ((empty($asset_model_name)) && (empty($asset_modelNumber))) {
|
} elseif ((empty($asset_model_name)) && (empty($asset_modelNumber))) {
|
||||||
$asset_model_name = 'Unknown';
|
$asset_model_name = 'Unknown';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((!empty($asset_model_name)) && (empty($asset_modelNumber))) {
|
||||||
|
$condition[] = ['name', '=', $asset_model_name];
|
||||||
|
} elseif ((!empty($asset_model_name)) && (!empty($asset_modelNumber))) {
|
||||||
|
$condition[] = ['name', '=', $asset_model_name];
|
||||||
|
$condition[] = ['model_number', '=', $asset_modelNumber];
|
||||||
|
}
|
||||||
|
|
||||||
$editingModel = $this->updating;
|
$editingModel = $this->updating;
|
||||||
$asset_model = AssetModel::where(['name' => $asset_model_name, 'model_number' => $asset_modelNumber])->first();
|
$asset_model = AssetModel::where($condition)->first();
|
||||||
|
|
||||||
if ($asset_model) {
|
if ($asset_model) {
|
||||||
if (! $this->updating) {
|
if (! $this->updating) {
|
||||||
|
@ -201,7 +210,11 @@ class ItemImporter extends Importer
|
||||||
$this->log('Matching Model found, updating it.');
|
$this->log('Matching Model found, updating it.');
|
||||||
$item = $this->sanitizeItemForStoring($asset_model, $editingModel);
|
$item = $this->sanitizeItemForStoring($asset_model, $editingModel);
|
||||||
$item['name'] = $asset_model_name;
|
$item['name'] = $asset_model_name;
|
||||||
|
|
||||||
|
if(!empty($asset_modelNumber)){
|
||||||
$item['model_number'] = $asset_modelNumber;
|
$item['model_number'] = $asset_modelNumber;
|
||||||
|
}
|
||||||
|
|
||||||
$asset_model->update($item);
|
$asset_model->update($item);
|
||||||
$asset_model->save();
|
$asset_model->save();
|
||||||
$this->log('Asset Model Updated');
|
$this->log('Asset Model Updated');
|
||||||
|
|
|
@ -34,7 +34,9 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Custom Fieldset -->
|
<!-- Custom Fieldset -->
|
||||||
@livewire('custom-field-set-default-values-for-model',["model_id" => $item->id])
|
@if (isset($item->id))
|
||||||
|
@livewire('custom-field-set-default-values-for-model',["model_id" => $item->id])
|
||||||
|
@endif
|
||||||
|
|
||||||
@include ('partials.forms.edit.notes')
|
@include ('partials.forms.edit.notes')
|
||||||
@include ('partials.forms.edit.requestable', ['requestable_text' => trans('admin/models/general.requestable')])
|
@include ('partials.forms.edit.requestable', ['requestable_text' => trans('admin/models/general.requestable')])
|
||||||
|
|
|
@ -296,7 +296,7 @@ Route::group(['prefix' => 'v1', 'middleware' => 'api'], function () {
|
||||||
); // end depreciations API routes
|
); // end depreciations API routes
|
||||||
|
|
||||||
|
|
||||||
Route::post('reports/depreciation',
|
Route::get('reports/depreciation',
|
||||||
[
|
[
|
||||||
Api\AssetsController::class,
|
Api\AssetsController::class,
|
||||||
'index'
|
'index'
|
||||||
|
@ -368,18 +368,18 @@ Route::group(['prefix' => 'v1', 'middleware' => 'api'], function () {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::resource('fields',
|
Route::resource('fieldsets',
|
||||||
Api\CustomFieldsetsController::class,
|
Api\CustomFieldsetsController::class,
|
||||||
['names' =>
|
['names' =>
|
||||||
[
|
[
|
||||||
'index' => 'api.customfields.index',
|
'index' => 'api.fieldsets.index',
|
||||||
'show' => 'api.customfields.show',
|
'show' => 'api.fieldsets.show',
|
||||||
'update' => 'api.customfields.update',
|
'update' => 'api.fieldsets.update',
|
||||||
'store' => 'api.customfields.store',
|
'store' => 'api.fieldsets.store',
|
||||||
'destroy' => 'api.customfields.destroy',
|
'destroy' => 'api.fieldsets.destroy',
|
||||||
],
|
],
|
||||||
'except' => ['create', 'edit'],
|
'except' => ['create', 'edit'],
|
||||||
'parameters' => ['field' => 'field_id'],
|
'parameters' => ['fieldset' => 'fieldset_id'],
|
||||||
]
|
]
|
||||||
); // end custom fieldsets API routes
|
); // end custom fieldsets API routes
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue