mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-29 07:29:44 -08:00
Merge remote-tracking branch 'origin/develop'
This commit is contained in:
commit
417a1e624a
|
@ -101,6 +101,7 @@ class AssetsController extends Controller
|
|||
'checkin_counter',
|
||||
'requests_counter',
|
||||
'byod',
|
||||
'asset_eol_date',
|
||||
];
|
||||
|
||||
$filter = [];
|
||||
|
@ -128,7 +129,6 @@ class AssetsController extends Controller
|
|||
// They are also used by the individual searches on detail pages like
|
||||
// locations, etc.
|
||||
|
||||
|
||||
// Search custom fields by column name
|
||||
foreach ($all_custom_fields as $field) {
|
||||
if ($request->filled($field->db_column_name())) {
|
||||
|
@ -136,7 +136,6 @@ class AssetsController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if ($request->filled('status_id')) {
|
||||
$assets->where('assets.status_id', '=', $request->input('status_id'));
|
||||
}
|
||||
|
@ -173,6 +172,10 @@ class AssetsController extends Controller
|
|||
$assets->where('assets.supplier_id', '=', $request->input('supplier_id'));
|
||||
}
|
||||
|
||||
if ($request->filled('asset_eol_date')) {
|
||||
$assets->where('assets.asset_eol_date', '=', $request->input('asset_eol_date'));
|
||||
}
|
||||
|
||||
if (($request->filled('assigned_to')) && ($request->filled('assigned_type'))) {
|
||||
$assets->where('assets.assigned_to', '=', $request->input('assigned_to'))
|
||||
->where('assets.assigned_type', '=', $request->input('assigned_type'));
|
||||
|
|
|
@ -142,6 +142,7 @@ class AssetsController extends Controller
|
|||
$asset->warranty_months = request('warranty_months', null);
|
||||
$asset->purchase_cost = Helper::ParseCurrency($request->get('purchase_cost'));
|
||||
$asset->purchase_date = request('purchase_date', null);
|
||||
$asset->asset_eol_date = request('asset_eol_date', null);
|
||||
$asset->assigned_to = request('assigned_to', null);
|
||||
$asset->supplier_id = request('supplier_id', null);
|
||||
$asset->requestable = request('requestable', 0);
|
||||
|
@ -312,6 +313,8 @@ class AssetsController extends Controller
|
|||
$asset->status_id = $request->input('status_id', null);
|
||||
$asset->warranty_months = $request->input('warranty_months', null);
|
||||
$asset->purchase_cost = Helper::ParseCurrency($request->input('purchase_cost', null));
|
||||
$asset->asset_eol_date = request('asset_eol_date', null);
|
||||
|
||||
$asset->purchase_date = $request->input('purchase_date', null);
|
||||
$asset->supplier_id = $request->input('supplier_id', null);
|
||||
$asset->expected_checkin = $request->input('expected_checkin', null);
|
||||
|
|
|
@ -38,7 +38,8 @@ class AssetsTransformer
|
|||
'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,
|
||||
'eol' => ($asset->model->eol != '') ? $asset->model->eol : null,
|
||||
'asset_eol_date' => ($asset->asset_eol_date != '') ? Helper::getFormattedDateObject($asset->asset_eol_date, 'date') : null,
|
||||
'status_label' => ($asset->assetstatus) ? [
|
||||
'id' => (int) $asset->assetstatus->id,
|
||||
'name'=> e($asset->assetstatus->name),
|
||||
|
|
|
@ -114,6 +114,7 @@ class Asset extends Depreciable
|
|||
'serial' => 'unique_serial|nullable',
|
||||
'purchase_cost' => 'numeric|nullable|gte:0',
|
||||
'supplier_id' => 'exists:suppliers,id|nullable',
|
||||
'asset_eol_date' => 'date|max:10|min:10|nullable',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -143,9 +144,9 @@ class Asset extends Depreciable
|
|||
'last_checkout',
|
||||
'expected_checkin',
|
||||
'byod',
|
||||
'asset_eol_date',
|
||||
'last_audit_date',
|
||||
'next_audit_date',
|
||||
|
||||
];
|
||||
|
||||
use Searchable;
|
||||
|
@ -168,6 +169,7 @@ class Asset extends Depreciable
|
|||
'expected_checkin',
|
||||
'next_audit_date',
|
||||
'last_audit_date',
|
||||
'asset_eol_date',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -181,7 +183,7 @@ class Asset extends Depreciable
|
|||
'company' => ['name'],
|
||||
'defaultLoc' => ['name'],
|
||||
'location' => ['name'],
|
||||
'model' => ['name', 'model_number'],
|
||||
'model' => ['name', 'model_number', 'eol'],
|
||||
'model.category' => ['name'],
|
||||
'model.manufacturer' => ['name'],
|
||||
];
|
||||
|
|
|
@ -163,9 +163,16 @@ class AssetPresenter extends Presenter
|
|||
], [
|
||||
'field' => 'eol',
|
||||
'searchable' => false,
|
||||
'sortable' => false,
|
||||
'sortable' => true,
|
||||
'visible' => false,
|
||||
'title' => trans('general.eol'),
|
||||
],
|
||||
[
|
||||
'field' => 'asset_eol_date',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'visible' => false,
|
||||
'title' => trans('admin/hardware/form.eol_date'),
|
||||
'formatter' => 'dateDisplayFormatter',
|
||||
], [
|
||||
'field' => 'warranty_months',
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use App\Models\Asset;
|
||||
use App\Models\AssetModel;
|
||||
|
||||
class AddEolDateOnAssetsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
|
||||
Schema::table('assets', function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('assets', 'asset_eol_date')) {
|
||||
$table->date('asset_eol_date')->after('purchase_date')->nullable()->default(null);
|
||||
}
|
||||
});
|
||||
|
||||
// Chunk the model query to get the models that do have an EOL date
|
||||
AssetModel::whereNotNull('eol')->with('assets')->chunk(200, function ($models) {
|
||||
foreach ($models as $model) {
|
||||
foreach ($model->assets as $asset) {
|
||||
|
||||
if ($asset->purchase_date!='') {
|
||||
$asset->asset_eol_date = $asset->present()->eol_date();
|
||||
$asset->save();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('assets', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('assets', 'asset_eol_date')) {
|
||||
$table->dropColumn('asset_eol_date');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -152,6 +152,7 @@
|
|||
<br>
|
||||
@include ('partials.forms.edit.order_number')
|
||||
@include ('partials.forms.edit.purchase_date')
|
||||
@include ('partials.forms.edit.eol_date')
|
||||
@include ('partials.forms.edit.supplier-select', ['translated_name' => trans('general.supplier'), 'fieldname' => 'supplier_id'])
|
||||
|
||||
@php
|
||||
|
|
|
@ -673,7 +673,8 @@
|
|||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endif
|
||||
@if ($asset->asset_eol_date)
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
<strong>
|
||||
|
@ -681,10 +682,10 @@
|
|||
</strong>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
@if ($asset->purchase_date)
|
||||
{{ Helper::getFormattedDateObject($asset->present()->eol_date(), 'date', false) }}
|
||||
@if ($asset->asset_eol_date)
|
||||
{{ Helper::getFormattedDateObject($asset->asset_eol_date, 'date', false) }}
|
||||
-
|
||||
{{ Carbon::parse($asset->present()->eol_date())->diffForHumans(['parts' => 2]) }}
|
||||
{{ Carbon::parse($asset->asset_eol_date)->diffForHumans(['parts' => 2]) }}
|
||||
@else
|
||||
{{ trans('general.na_no_purchase_date') }}
|
||||
@endif
|
||||
|
|
11
resources/views/partials/forms/edit/eol_date.blade.php
Normal file
11
resources/views/partials/forms/edit/eol_date.blade.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<!-- Purchase Date -->
|
||||
<div class="form-group {{ $errors->has('asset_eol_date') ? ' has-error' : '' }}">
|
||||
<label for="asset_eol_date" class="col-md-3 control-label">{{ trans('admin/hardware/form.eol_date') }}</label>
|
||||
<div class="input-group col-md-4">
|
||||
<div class="input-group date" data-provide="datepicker" data-date-clear-btn="true" data-date-format="yyyy-mm-dd" data-autoclose="true">
|
||||
<input type="text" class="form-control" placeholder="{{ trans('general.select_date') }}" name="asset_eol_date" id="asset_eol_date" readonly value="{{ old('asset_eol_date', $item->asset_eol_date ?? $item->present()->eol_date() ?? '') }}" style="background-color:inherit">
|
||||
<span class="input-group-addon"><i class="fas fa-calendar" aria-hidden="true"></i></span>
|
||||
</div>
|
||||
{!! $errors->first('asset_eol_date', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in a new issue