From a80ade1bf553c33c822c34cd816e1eee225c79c6 Mon Sep 17 00:00:00 2001 From: Eirik Wulff Date: Wed, 19 Jun 2024 15:27:58 +0200 Subject: [PATCH] Jamf2Pureservice: Bruker lastEnrollment som memberSince hvis den ikke eksisterer --- app/Console/Commands/Jamf2Pureservice.php | 27 ++++++++++++++--------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/app/Console/Commands/Jamf2Pureservice.php b/app/Console/Commands/Jamf2Pureservice.php index b3e6d5b..3f84713 100644 --- a/app/Console/Commands/Jamf2Pureservice.php +++ b/app/Console/Commands/Jamf2Pureservice.php @@ -282,12 +282,15 @@ public function getJamfAssetsAsPsAssets() { if ($dev['general']['osVersion'] != null): $psAsset[$fn['OsVersion']] = $dev['general']['osVersion']; endif; + if (isset($dev['general']['initialEntryTimestamp']) && $dev['general']['initialEntryTimestamp'] != ''): + $memberSinceData = $dev['general']['initialEntryTimestamp']; + else: + $memberSinceData = $dev['general']['lastEnrolledDate']; + endif; + $memberSince = Carbon::create($memberSinceData)->timezone(config('app.timezone')); - $psAsset[$fn['memberSince']] = Carbon::create($dev['general']['initialEntryTimestamp']) - ->timezone(config('app.timezone')) - ->toJSON(); - $psAsset[$fn['EOL']] = Carbon::create($dev['general']['initialEntryTimestamp']) - ->timezone(config('app.timezone')) + $psAsset[$fn['memberSince']] = $memberSince->copy()->toJSON(); + $psAsset[$fn['EOL']] = $memberSince->copy() ->addYears(config('pureservice.mobile.lifespan', 3)) ->toJSON(); if ($dev['general']['lastInventoryUpdateDate'] != null): @@ -326,11 +329,15 @@ public function getJamfAssetsAsPsAssets() { $psAsset[$fn['OsVersion']] = $mac['operatingSystem']['version']; endif; - $psAsset[$fn['memberSince']] = Carbon::create($mac['general']['initialEntryDate']) - ->timezone(config('app.timezone')) - ->toJSON(); - $psAsset[$fn['EOL']] = Carbon::create($mac['general']['initialEntryDate']) - ->timezone(config('app.timezone')) + if (isset($mac['general']['initialEntryDate']) && $mac['general']['initialEntryDate'] != ''): + $memberSinceData = $dev['general']['initialEntryDate']; + else: + $memberSinceData = $dev['general']['lastEnrolledDate']; + endif; + $memberSince = Carbon::create($memberSinceData)->timezone(config('app.timezone')); + + $psAsset[$fn['memberSince']] = $memberSince->copy()->toJSON(); + $psAsset[$fn['EOL']] = $memberSince->copy() ->addYears(config('pureservice.computer.lifespan', 4)) ->toJSON(); if ($mac['general']['lastContactTime'] != null):