mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-11 22:07:29 -08:00
progress
This commit is contained in:
parent
dc39d2c567
commit
c1daabef08
|
@ -6,6 +6,7 @@ use App\Helpers\Helper;
|
|||
use App\Http\Requests\ImageUploadRequest;
|
||||
use App\Models\AssetModel;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
@ -91,6 +92,9 @@ class AssetModelsController extends Controller
|
|||
|
||||
// Was it created?
|
||||
if ($model->save()) {
|
||||
if ($request->filled('eol')) {
|
||||
$model->assets()->whereNotNull('purchase_date')->whereNull('eol_explicit')->update(['asset_eol_date' => DB::raw('DATE_ADD(purchase_date, INTERVAL '.$model->eol.' MONTH)')]);
|
||||
}
|
||||
if ($this->shouldAddDefaultValues($request->input())) {
|
||||
if (!$this->assignCustomFieldsDefaultValues($model, $request->input('default_values'))){
|
||||
return redirect()->back()->withInput()->with('error', trans('admin/custom_fields/message.fieldset_default_value.error'));
|
||||
|
@ -173,8 +177,13 @@ class AssetModelsController extends Controller
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if ($model->save()) {
|
||||
if ($model->wasChanged('eol')) {
|
||||
$model->assets()->whereNotNull('purchase_date')->whereNull('eol_explicit')->update(['asset_eol_date' => DB::raw('DATE_ADD(purchase_date, INTERVAL '.$model->eol.' MONTH)')]);
|
||||
}
|
||||
return redirect()->route('models.index')->with('success', trans('admin/models/message.update.success'));
|
||||
}
|
||||
|
||||
|
|
|
@ -387,6 +387,9 @@ class AssetsController extends Controller
|
|||
|
||||
|
||||
if ($asset->save()) {
|
||||
if($asset->wasChanged('purchase_date')){
|
||||
$model->assets()->whereNotNull('purchase_date')->whereNull('eol_explicit')->update(['asset_eol_date' => DB::raw('DATE_ADD(purchase_date, INTERVAL '.$model->eol.' MONTH)')]);
|
||||
}
|
||||
return redirect()->route('hardware.show', $assetId)
|
||||
->with('success', trans('admin/hardware/message.update.success'));
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@ class Asset extends Depreciable
|
|||
|
||||
protected $casts = [
|
||||
'purchase_date' => 'date',
|
||||
'asset_eol_date' => 'date',
|
||||
'last_checkout' => 'datetime',
|
||||
'last_checkin' => 'datetime',
|
||||
'expected_checkin' => 'date',
|
||||
|
|
|
@ -429,10 +429,7 @@ class AssetPresenter extends Presenter
|
|||
public function eol_date()
|
||||
{
|
||||
if (($this->purchase_date) && ($this->model->model) && ($this->model->model->eol)) {
|
||||
$date = date_create($this->purchase_date);
|
||||
date_add($date, date_interval_create_from_date_string($this->model->model->eol.' months'));
|
||||
|
||||
return date_format($date, 'Y-m-d');
|
||||
return $this->purchase_date->addMonths($this->model->model->eol)->format('Y-m-d');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue