From f999c797e568f23a60f97164c4e83f2d7d808305 Mon Sep 17 00:00:00 2001 From: Bob Clough Date: Wed, 4 Jan 2017 00:55:21 +0000 Subject: [PATCH] Allow a license to be pre-checked-out to an asset. (#3124) Some licenses, such as windows licenses, are machine specific. This commit allows an extra field to be added to the license importer to allow these licenses to be imported and attached directly to an asset --- app/Console/Commands/LicenseImportCommand.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/Console/Commands/LicenseImportCommand.php b/app/Console/Commands/LicenseImportCommand.php index ffa55ff007..8ba6ece505 100644 --- a/app/Console/Commands/LicenseImportCommand.php +++ b/app/Console/Commands/LicenseImportCommand.php @@ -9,6 +9,7 @@ use App\Models\User; use App\Models\Supplier; use App\Models\License; use App\Models\LicenseSeat; +use App\Models\Asset; class LicenseImportCommand extends Command { @@ -168,6 +169,12 @@ class LicenseImportCommand extends Command $user_license_purchase_date = 0; } + if (array_key_exists('13', $row)) { + $user_licensed_to_asset = trim($row[13]); + } else { + $user_licensed_to_asset = ''; + } + // A number was given instead of a name if (is_numeric($user_name)) { $this->comment('User '.$user_name.' is not a name - assume this user already exists'); @@ -238,6 +245,7 @@ class LicenseImportCommand extends Command $this->comment('Maintained: '.$user_license_maintained); $this->comment('Notes: '.$user_license_notes); $this->comment('Purchase Date: '.$user_license_purchase_date); + $this->comment('Asset ID: '.$user_licensed_to_asset); $this->comment('------------- Action Summary ----------------'); @@ -327,6 +335,13 @@ class LicenseImportCommand extends Command $license_seat->assigned_to = null; } + if($user_licensed_to_asset) { + $asset = Asset::where('asset_tag', $user_licensed_to_asset)->first(); + if($asset) { + $license_seat->asset_id = $asset->id; + } + } + if ($license_seat->save()) { $license_seat_created++; }