mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Update asset location based on user checkout in bulk checkout
This commit is contained in:
parent
9e605e0f79
commit
8fff6a1a06
|
@ -1198,9 +1198,14 @@ class AssetsController extends Controller
|
||||||
$user = User::find(e(Input::get('assigned_to')));
|
$user = User::find(e(Input::get('assigned_to')));
|
||||||
$admin = Auth::user();
|
$admin = Auth::user();
|
||||||
|
|
||||||
|
if (!$user) {
|
||||||
|
return redirect()->route('hardware/bulkcheckout')->withInput()->with('error', trans('admin/hardware/message.checkout.user_does_not_exist'));
|
||||||
|
}
|
||||||
|
|
||||||
if (!is_array(Input::get('selected_assets'))) {
|
if (!is_array(Input::get('selected_assets'))) {
|
||||||
return redirect()->route('hardware/bulkcheckout')->withInput()->with('error', trans('admin/hardware/message.checkout.no_assets_selected'));
|
return redirect()->route('hardware/bulkcheckout')->withInput()->with('error', trans('admin/hardware/message.checkout.no_assets_selected'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$asset_ids = array_filter(Input::get('selected_assets'));
|
$asset_ids = array_filter(Input::get('selected_assets'));
|
||||||
|
|
||||||
if ((Input::has('checkout_at')) && (Input::get('checkout_at')!= date("Y-m-d"))) {
|
if ((Input::has('checkout_at')) && (Input::get('checkout_at')!= date("Y-m-d"))) {
|
||||||
|
@ -1215,6 +1220,7 @@ class AssetsController extends Controller
|
||||||
$expected_checkin = '';
|
$expected_checkin = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$errors = [];
|
$errors = [];
|
||||||
DB::transaction(function () use ($user, $admin, $checkout_at, $expected_checkin, $errors, $asset_ids) {
|
DB::transaction(function () use ($user, $admin, $checkout_at, $expected_checkin, $errors, $asset_ids) {
|
||||||
|
|
||||||
|
@ -1223,6 +1229,14 @@ class AssetsController extends Controller
|
||||||
$this->authorize('checkout', $asset);
|
$this->authorize('checkout', $asset);
|
||||||
$error = $asset->checkOut($user, $admin, $checkout_at, $expected_checkin, e(Input::get('note')), null);
|
$error = $asset->checkOut($user, $admin, $checkout_at, $expected_checkin, e(Input::get('note')), null);
|
||||||
|
|
||||||
|
if ($user->location_id!='') {
|
||||||
|
$asset->location_id = $user->location_id;
|
||||||
|
$asset->unsetEventDispatcher();
|
||||||
|
$asset->save();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($error) {
|
if ($error) {
|
||||||
array_merge_recursive($errors, $asset->getErrors()->toArray());
|
array_merge_recursive($errors, $asset->getErrors()->toArray());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue