A free open source IT asset/license management system
Added update to asset location id on checkout/checkin
snipe108ac794424c
diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.phpindex 822a0c58dc..642ca8c08a 100644--- a/app/Http/Controllers/Api/AssetsController.php+++ b/app/Http/Controllers/Api/AssetsController.php@@ -524,11 +524,23 @@ class AssetsController extends Controllerreturn response()->json(Helper::formatStandardApiResponse('error', $error_payload, 'No valid checkout target specified for asset '.e($asset->asset_tag).'.'));}++$checkout_at = request('checkout_at', date("Y-m-d H:i:s"));$expected_checkin = request('expected_checkin', null);$note = request('note', null);$asset_name = request('name', null);+ // Set the location ID to the RTD location id if there is one+ if ($asset->rtd_location_id!='') {+ $asset->location_id = $target->rtd_location_id;+ }++ // Overwrite that if the target has a location ID though+ if ($target->location_id!='') {+ $asset->location_id = $target->location_id;+ }+if ($asset->checkOut($target, Auth::user(), $checkout_at, $expected_checkin, $note, $asset_name)) {return response()->json(Helper::formatStandardApiResponse('success', ['asset'=> e($asset->asset_tag)], trans('admin/hardware/message.checkout.success')));diff --git a/app/Http/Controllers/AssetsController.php b/app/Http/Controllers/AssetsController.phpindex 8ffb1535f6..b87544f8ca 100755--- a/app/Http/Controllers/AssetsController.php+++ b/app/Http/Controllers/AssetsController.php@@ -468,6 +468,17 @@ class AssetsController extends Controller} else {$expected_checkin = '';}++ // Set the location ID to the RTD location id if there is one+ if ($asset->rtd_location_id!='') {+ $asset->location_id = $target->rtd_location_id;+ }++ // Overwrite that if the target has a location ID though+ if ($target->location_id!='') {+ $asset->location_id = $target->location_id;+ }+if ($asset->checkOut($target, $admin, $checkout_at, $expected_checkin, e(Input::get('note')), Input::get('name'))) {// Redirect to the new asset pagereturn redirect()->route("hardware.index")->with('success', trans('admin/hardware/message.checkout.success'));