Merge pull request #13799 from inietov/fixes/unlogged_checkin_from_importer

Fixed #13795 Unlogged checkin action post updating the username of an asset through the CSV import
This commit is contained in:
snipe 2023-10-26 13:33:51 +01:00 committed by GitHub
commit 7b9259274c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,6 +5,9 @@ namespace App\Importer;
use App\Models\Asset; use App\Models\Asset;
use App\Models\AssetModel; use App\Models\AssetModel;
use App\Models\Statuslabel; use App\Models\Statuslabel;
use App\Models\User;
use App\Events\CheckoutableCheckedIn;
use Illuminate\Support\Facades\Auth;
use Carbon\Carbon; use Carbon\Carbon;
class AssetImporter extends ItemImporter class AssetImporter extends ItemImporter
@ -142,6 +145,12 @@ class AssetImporter extends ItemImporter
//-- user_id is a property of the abstract class Importer, which this class inherits from and it's setted by //-- 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). //-- the class that needs to use it (command importer or GUI importer inside the project).
if (isset($target)) { if (isset($target)) {
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); $asset->fresh()->checkOut($target, $this->user_id, date('Y-m-d H:i:s'), null, $asset->notes, $asset->name);
} }