From 58062ff9f502008c9d8ce964654b872e02e37688 Mon Sep 17 00:00:00 2001
From: Robert-Azelis <82208283+Robert-Azelis@users.noreply.github.com>
Date: Sun, 22 Oct 2023 17:56:38 +0200
Subject: [PATCH 01/35] Update AssetModelsController.php
if EOL of model has been changed and value is >0 assets will be updates with new EOL rate, date
if EOL of model has been changes and value is null or 0 then assets will be updates by null EOL rate, date
*asset with set expilicity market will not be updated
---
app/Http/Controllers/AssetModelsController.php | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/app/Http/Controllers/AssetModelsController.php b/app/Http/Controllers/AssetModelsController.php
index d7a135dd76..1783b33921 100755
--- a/app/Http/Controllers/AssetModelsController.php
+++ b/app/Http/Controllers/AssetModelsController.php
@@ -179,9 +179,14 @@ class AssetModelsController extends Controller
if ($model->save()) {
if ($model->wasChanged('eol')) {
- $newEol = $model->eol;
- $model->assets()->whereNotNull('purchase_date')->where('eol_explicit', false)
- ->update(['asset_eol_date' => DB::raw('DATE_ADD(purchase_date, INTERVAL ' . $newEol . ' MONTH)')]);
+ if ($model->eol > 0) {
+ $newEol = $model->eol;
+ $model->assets()->whereNotNull('purchase_date')->where('eol_explicit', false)
+ ->update(['asset_eol_date' => DB::raw('DATE_ADD(purchase_date, INTERVAL ' . $newEol . ' MONTH)')]);
+ } elseif ($model->eol == 0) {
+ $model->assets()->whereNotNull('purchase_date')->where('eol_explicit', false)
+ ->update(['asset_eol_date' => DB::raw('null')]);
+ }
}
return redirect()->route('models.index')->with('success', trans('admin/models/message.update.success'));
}
From bd195a691161932941e8a4258e9b3a137c498bf2 Mon Sep 17 00:00:00 2001
From: Robert-Azelis <82208283+Robert-Azelis@users.noreply.github.com>
Date: Sun, 22 Oct 2023 18:11:19 +0200
Subject: [PATCH 02/35] Update AssetsController.php
when asset is updated control EOL date change sand set explicit marker depends to setup of model EOL rate
---
app/Http/Controllers/Assets/AssetsController.php | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/app/Http/Controllers/Assets/AssetsController.php b/app/Http/Controllers/Assets/AssetsController.php
index 92922c4cdf..8a12d744ae 100755
--- a/app/Http/Controllers/Assets/AssetsController.php
+++ b/app/Http/Controllers/Assets/AssetsController.php
@@ -137,7 +137,7 @@ class AssetsController extends Controller
$asset->warranty_months = request('warranty_months', null);
$asset->purchase_cost = request('purchase_cost');
$asset->purchase_date = request('purchase_date', null);
- $asset->asset_eol_date = request('asset_eol_date', $asset->present()->eol_date());
+ $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);
@@ -309,14 +309,15 @@ class AssetsController extends Controller
$asset->warranty_months = $request->input('warranty_months', null);
$asset->purchase_cost = $request->input('purchase_cost', null);
$asset->purchase_date = $request->input('purchase_date', null);
- if ($request->filled('purchase_date') && !$request->filled('asset_eol_date') && $asset->model->eol) {
+ if ($request->filled('purchase_date') && !$request->filled('asset_eol_date') && ($asset->model->eol > 0)) {
$asset->purchase_date = $request->input('purchase_date', null);
$asset->asset_eol_date = Carbon::parse($request->input('purchase_date'))->addMonths($asset->model->eol)->format('Y-m-d');
+ $asset->eol_explicit = false;
} elseif ($request->filled('asset_eol_date')) {
$asset->asset_eol_date = $request->input('asset_eol_date', null);
$months = Carbon::parse($asset->asset_eol_date)->diffInMonths($asset->purchase_date);
if($asset->model->eol) {
- if($months != $asset->model->eol) {
+ if($months != $asset->model->eol > 0) {
$asset->eol_explicit = true;
} else {
$asset->eol_explicit = false;
@@ -324,6 +325,9 @@ class AssetsController extends Controller
} else {
$asset->eol_explicit = true;
}
+ } elseif (!$request->filled('asset_eol_date') && (($asset->model->eol) == 0)) {
+ $asset->asset_eol_date = null;
+ $asset->eol_explicit = false;
}
$asset->supplier_id = $request->input('supplier_id', null);
$asset->expected_checkin = $request->input('expected_checkin', null);
From 5ae09b791f32896bd7a91b5c4a897b332873db7d Mon Sep 17 00:00:00 2001
From: Robert-Azelis <82208283+Robert-Azelis@users.noreply.github.com>
Date: Sun, 22 Oct 2023 18:16:49 +0200
Subject: [PATCH 03/35] Update AssetsTransformer.php
on list of assets display EOL rate in months if purchase date and eol date are set, otherwise null (not display anything)
---
app/Http/Transformers/AssetsTransformer.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/Http/Transformers/AssetsTransformer.php b/app/Http/Transformers/AssetsTransformer.php
index 68dc731f07..70b0cfe8d2 100644
--- a/app/Http/Transformers/AssetsTransformer.php
+++ b/app/Http/Transformers/AssetsTransformer.php
@@ -7,6 +7,7 @@ use App\Models\Asset;
use App\Models\Setting;
use Illuminate\Support\Facades\Gate;
use Illuminate\Database\Eloquent\Collection;
+use Carbon\Carbon;
class AssetsTransformer
@@ -38,7 +39,7 @@ class AssetsTransformer
'byod' => ($asset->byod ? true : false),
'model_number' => (($asset->model) && ($asset->model->model_number)) ? e($asset->model->model_number) : null,
- 'eol' => (($asset->model) && ($asset->model->eol != '')) ? $asset->model->eol : null,
+ 'eol' => (($asset->asset_eol_date != '') && ($asset->purchase_date != '')) ? Carbon::parse($asset->asset_eol_date)->diffInMonths($asset->purchase_date).' months' : 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,
From 30cc498a163ca869717c72de9a6b42b337aeef9e Mon Sep 17 00:00:00 2001
From: Robert-Azelis <82208283+Robert-Azelis@users.noreply.github.com>
Date: Sun, 22 Oct 2023 18:23:30 +0200
Subject: [PATCH 04/35] Update AssetObserver.php
update exlicit marker depends if model EOL > 0 , EOL = 0
---
app/Observers/AssetObserver.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/Observers/AssetObserver.php b/app/Observers/AssetObserver.php
index c15c54a568..a440dbf4ff 100644
--- a/app/Observers/AssetObserver.php
+++ b/app/Observers/AssetObserver.php
@@ -137,14 +137,14 @@ class AssetObserver
public function saving(Asset $asset)
{
// 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->purchase_date) && !is_null($asset->model->eol)){
+ if (is_null($asset->asset_eol_date) && !is_null($asset->purchase_date) && ($asset->model->eol > 0)){
$asset->asset_eol_date = $asset->purchase_date->addMonths($asset->model->eol)->format('Y-m-d');
$asset->eol_explicit = false;
}
// determine if explicit and set eol_explicit to true
if (!is_null($asset->asset_eol_date) && !is_null($asset->purchase_date)) {
- if($asset->model->eol) {
+ if($asset->model->eol > 0) {
$months = Carbon::parse($asset->asset_eol_date)->diffInMonths($asset->purchase_date);
if($months != $asset->model->eol) {
$asset->eol_explicit = true;
@@ -153,7 +153,7 @@ class AssetObserver
} elseif (!is_null($asset->asset_eol_date) && is_null($asset->purchase_date)) {
$asset->eol_explicit = true;
}
- if ((!is_null($asset->asset_eol_date)) && (!is_null($asset->purchase_date)) && (is_null($asset->model->eol))) {
+ if ((!is_null($asset->asset_eol_date)) && (!is_null($asset->purchase_date)) && (is_null($asset->model->eol) || ($asset->model->eol == 0))) {
$asset->eol_explicit = true;
}
From 4e20a241ceb41c5910af4382573712dc58240894 Mon Sep 17 00:00:00 2001
From: Robert-Azelis <82208283+Robert-Azelis@users.noreply.github.com>
Date: Sun, 22 Oct 2023 18:26:19 +0200
Subject: [PATCH 05/35] Update AssetPresenter.php
display name 'EOL rate' instead of 'EOL'
---
app/Presenters/AssetPresenter.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/Presenters/AssetPresenter.php b/app/Presenters/AssetPresenter.php
index c570c568da..de7c2c7709 100644
--- a/app/Presenters/AssetPresenter.php
+++ b/app/Presenters/AssetPresenter.php
@@ -173,7 +173,7 @@ class AssetPresenter extends Presenter
'searchable' => false,
'sortable' => true,
'visible' => false,
- 'title' => trans('general.eol'),
+ 'title' => trans('admin/hardware/form.eol_rate'),
],
[
'field' => 'asset_eol_date',
From e62636b3a550dbd528795d26451821beb255e9be Mon Sep 17 00:00:00 2001
From: Robert-Azelis <82208283+Robert-Azelis@users.noreply.github.com>
Date: Sun, 22 Oct 2023 18:27:53 +0200
Subject: [PATCH 06/35] Update AssetModelPresenter.php
display name 'EOL rate' instead of 'EOL'
---
app/Presenters/AssetModelPresenter.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/Presenters/AssetModelPresenter.php b/app/Presenters/AssetModelPresenter.php
index e661b1ab80..85a0fa58ec 100644
--- a/app/Presenters/AssetModelPresenter.php
+++ b/app/Presenters/AssetModelPresenter.php
@@ -104,7 +104,7 @@ class AssetModelPresenter extends Presenter
'searchable' => false,
'sortable' => true,
'switchable' => true,
- 'title' => trans('general.eol'),
+ 'title' => trans('admin/hardware/form.eol_rate'),
'visible' => true,
],
[
From 04a867d12b81e80211e7280b63a4562c6979d64d Mon Sep 17 00:00:00 2001
From: Robert-Azelis <82208283+Robert-Azelis@users.noreply.github.com>
Date: Sun, 22 Oct 2023 18:32:20 +0200
Subject: [PATCH 07/35] Update eol_date.blade.php
read EOL date from database instead calculate on the base model EOL rate
---
resources/views/partials/forms/edit/eol_date.blade.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/resources/views/partials/forms/edit/eol_date.blade.php b/resources/views/partials/forms/edit/eol_date.blade.php
index 88055cfc0e..fb461cf44e 100644
--- a/resources/views/partials/forms/edit/eol_date.blade.php
+++ b/resources/views/partials/forms/edit/eol_date.blade.php
@@ -1,9 +1,9 @@
-
+
-
+
{!! $errors->first('asset_eol_date', ' :message') !!}
From 309f30f630218f4901ca8d8529c2dfd050513e75 Mon Sep 17 00:00:00 2001
From: Robert-Azelis <82208283+Robert-Azelis@users.noreply.github.com>
Date: Sun, 22 Oct 2023 18:38:59 +0200
Subject: [PATCH 08/35] Update view.blade.php
display marker if date of EOL is expired and show real EOL rate as diff between purchase date and eol date
---
resources/views/hardware/view.blade.php | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php
index 7609feb35f..5a043ffc40 100755
--- a/resources/views/hardware/view.blade.php
+++ b/resources/views/hardware/view.blade.php
@@ -631,7 +631,7 @@
From 7ed58a177b0361c73e74ae18ba19792bc55603bd Mon Sep 17 00:00:00 2001
From: Ivan Nieto Vivanco
Date: Wed, 25 Oct 2023 16:31:23 -0600
Subject: [PATCH 09/35] Evaluate if the asset was assigned to a different user
than current target to log a checkin event
---
app/Importer/AssetImporter.php | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/app/Importer/AssetImporter.php b/app/Importer/AssetImporter.php
index 76eae0739a..61cdd3c7b7 100644
--- a/app/Importer/AssetImporter.php
+++ b/app/Importer/AssetImporter.php
@@ -5,6 +5,9 @@ namespace App\Importer;
use App\Models\Asset;
use App\Models\AssetModel;
use App\Models\Statuslabel;
+use App\Models\User;
+use App\Events\CheckoutableCheckedIn;
+use Illuminate\Support\Facades\Auth;
use Carbon\Carbon;
class AssetImporter extends ItemImporter
@@ -142,6 +145,10 @@ class AssetImporter extends ItemImporter
//-- user_id is a property of the abstract class Importer, which this class inherits from and it's setted by
//-- the class that needs to use it (command importer or GUI importer inside the project).
if (isset($target)) {
+ if ($asset->assigned_to != $target->id){
+ event(new CheckoutableCheckedIn($asset, User::find($asset->assigned_to), Auth::user(), $asset->notes, date('Y-m-d H:i:s')));
+ }
+
$asset->fresh()->checkOut($target, $this->user_id, date('Y-m-d H:i:s'), null, $asset->notes, $asset->name);
}
From ca1845efd777d3eb23bb474309a17607253d024e Mon Sep 17 00:00:00 2001
From: Ivan Nieto Vivanco
Date: Wed, 25 Oct 2023 16:41:31 -0600
Subject: [PATCH 10/35] Only log checkin event if the assigned_to property is
not empty
---
app/Importer/AssetImporter.php | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/app/Importer/AssetImporter.php b/app/Importer/AssetImporter.php
index 61cdd3c7b7..5014efac12 100644
--- a/app/Importer/AssetImporter.php
+++ b/app/Importer/AssetImporter.php
@@ -145,8 +145,10 @@ class AssetImporter extends ItemImporter
//-- user_id is a property of the abstract class Importer, which this class inherits from and it's setted by
//-- the class that needs to use it (command importer or GUI importer inside the project).
if (isset($target)) {
- if ($asset->assigned_to != $target->id){
- event(new CheckoutableCheckedIn($asset, User::find($asset->assigned_to), Auth::user(), $asset->notes, date('Y-m-d H:i:s')));
+ if (!is_null($asset->assigned_to)){
+ if ($asset->assigned_to != $target->id){
+ event(new CheckoutableCheckedIn($asset, User::find($asset->assigned_to), Auth::user(), $asset->notes, date('Y-m-d H:i:s')));
+ }
}
$asset->fresh()->checkOut($target, $this->user_id, date('Y-m-d H:i:s'), null, $asset->notes, $asset->name);
From 4a759f0a204dceb596b305d15b4485601572c15c Mon Sep 17 00:00:00 2001
From: snipe
Date: Thu, 26 Oct 2023 01:49:01 +0100
Subject: [PATCH 11/35] Added fingerprint icon for unique
Signed-off-by: snipe
---
resources/views/custom_fields/index.blade.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/resources/views/custom_fields/index.blade.php b/resources/views/custom_fields/index.blade.php
index 7b0c4965d8..08f2fb3845 100644
--- a/resources/views/custom_fields/index.blade.php
+++ b/resources/views/custom_fields/index.blade.php
@@ -151,6 +151,7 @@