diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index 822a0c58dc..642ca8c08a 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -524,11 +524,23 @@ class AssetsController extends Controller return 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.php index 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 page return redirect()->route("hardware.index")->with('success', trans('admin/hardware/message.checkout.success'));