mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-24 04:03:34 -08:00
fix conflicts
This commit is contained in:
parent
75d7e3e1a0
commit
78c400e948
|
@ -17,7 +17,6 @@ use App\Models\Statuslabel;
|
|||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\View\Label;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Importer;
|
||||
|
||||
use App\Models\Asset;
|
||||
use App\Models\AssetModel;
|
||||
use App\Models\Statuslabel;
|
||||
use Carbon\Carbon;
|
||||
|
||||
|
@ -121,15 +122,19 @@ class AssetImporter extends ItemImporter
|
|||
|
||||
$item['asset_eol_date'] = null;
|
||||
if (isset($this->item['asset_eol_date'])) {
|
||||
$item['asset_eol_date'] = $this->item['asset_eol_date'];
|
||||
if(!is_null($this->item['model_id'])) {
|
||||
$model = AssetModel::find($this->createOrFetchAssetModel($row, $this->item['model_id']));
|
||||
if(is_null($model->eol)) {
|
||||
$item['asset_eol_date'] = $this->item['asset_eol_date'];
|
||||
$item['eol_explicit'] = true;
|
||||
} else {
|
||||
$item['asset_eol_date'] = Carbon::parse($this->item['asset_eol_date'])->addMonths($model->eol)->format('Y-m-d');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$item['eol_explicit'] = null;
|
||||
if (isset($this->item['eol_explicit'])) {
|
||||
$item['eol_explicit'] = $this->item['eol_explicit'];
|
||||
}
|
||||
|
||||
if(($item['asset_eol_date'] == null) && ($item['eol_explicit'] == null) && ($asset->model->eol != null) && ($asset->asset_purchase_date != null)){
|
||||
if(($item['asset_eol_date'] == null) && ($asset->model->eol != null) && ($asset->asset_purchase_date != null)){
|
||||
$asset->asset_eol_date = Carbon::parse($asset->asset_purchase_date)->addMonths($asset->model->eol)->format('Y-m-d');
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ use App\Models\Actionlog;
|
|||
use App\Models\Asset;
|
||||
use App\Models\Setting;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class AssetObserver
|
||||
{
|
||||
|
@ -122,12 +123,23 @@ class AssetObserver
|
|||
|
||||
public function saving(Asset $asset)
|
||||
{
|
||||
//turning this off for right now so i can check out the note in the migration
|
||||
//determine if calculated eol and then calculate it - this should only happen on a new asset
|
||||
if(is_null($asset->asset_eol_date) && !is_null($asset->asset_purchase_date) && !is_null($asset->model->eol)){
|
||||
$asset->asset_eol_date = $asset->purchase_date->addMonths($asset->model->eol)->format('Y-m-d');
|
||||
}
|
||||
|
||||
//calculate and set the EOL date if it is not already set
|
||||
// if(is_null($asset->asset_eol_date) && !is_null($asset->asset_purchase_date) && !is_null($asset->model()->get()->eol)){
|
||||
// $asset->asset_eol_date = date('Y-m-d', strtotime($asset->asset_purchase_date . ' + ' . $asset->asset_warranty_months . ' months'));
|
||||
// }
|
||||
//determine if explicit and set eol_explit to true
|
||||
if(!is_null($asset->asset_eol_date) && !is_null($asset->purchase_date) || ($asset->isDirty($asset->asset_eol_date) || $asset->isDirty($asset->purchase_date))) {
|
||||
if($asset->model->eol) {
|
||||
$months = Carbon::parse($asset->asset_eol_date)->diffInMonths($asset->purchase_date);
|
||||
if($months != $asset->model->eol) {
|
||||
$asset->eol_explicit = true;
|
||||
}
|
||||
} else {
|
||||
$asset->eol_explicit = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,12 @@ class DenormalizedEolAndAddColumnForExplicitDateToAssets extends Migration
|
|||
foreach($assetsWithEolDates as $asset) {
|
||||
if($asset->asset_eol_date && $asset->purchase_date) {
|
||||
$months = Carbon::parse($asset->asset_eol_date)->diffInMonths($asset->purchase_date);
|
||||
if($months != $asset->model->eol) {
|
||||
$asset->update(['eol_explicit' => true]);
|
||||
if($asset->model->eol) {
|
||||
if($months != $asset->model->eol) {
|
||||
$asset->update(['eol_explicit' => true]);
|
||||
}
|
||||
} else {
|
||||
$asset->update(['eol_explcit' => true]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue