conditionally fixed redirect select option
This commit is contained in:
@@ -1461,8 +1461,9 @@ class Helper
|
||||
}
|
||||
|
||||
|
||||
static public function getRedirectOption($request, $id, $table)
|
||||
static public function getRedirectOption($request, $id, $table, $asset_id = null)
|
||||
{
|
||||
|
||||
$redirect_option = Session::get('redirect_option');
|
||||
$checkout_to_type = Session::get('checkout_to_type');
|
||||
|
||||
@@ -1477,7 +1478,7 @@ class Helper
|
||||
if ($redirect_option == '1') {
|
||||
switch ($table) {
|
||||
case "Assets":
|
||||
return redirect()->route('hardware.show', $id)->with('success', trans('admin/hardware/message.checkout.success'));
|
||||
return redirect()->route('hardware.show', $id ? $id : $asset_id)->with('success', trans('admin/hardware/message.checkout.success'));
|
||||
}
|
||||
}
|
||||
//return to thing being assigned to
|
||||
|
||||
@@ -13,6 +13,7 @@ use App\Models\LicenseSeat;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Facades\View;
|
||||
|
||||
class AssetCheckinController extends Controller
|
||||
@@ -122,10 +123,12 @@ class AssetCheckinController extends Controller
|
||||
$acceptance->delete();
|
||||
});
|
||||
|
||||
Session::put('redirect_option', $request->get('redirect_option'));
|
||||
// Was the asset updated?
|
||||
if ($asset->save()) {
|
||||
|
||||
event(new CheckoutableCheckedIn($asset, $target, Auth::user(), $request->input('note'), $checkin_at, $originalValues));
|
||||
return Helper::getRedirectOption($request, $assetId);
|
||||
return Helper::getRedirectOption($asset, $assetId, 'Assets');
|
||||
}
|
||||
// Redirect to the asset management page with error
|
||||
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.checkin.error').$asset->getErrors());
|
||||
|
||||
@@ -99,13 +99,11 @@ class AssetCheckoutController extends Controller
|
||||
return redirect()->to("hardware/$assetId/checkout")->with('error', trans('general.error_user_company'));
|
||||
}
|
||||
}
|
||||
$redirect_option = $request->get('redirect_option');
|
||||
if($redirect_option != Session::get('redirect_option')) {
|
||||
Session::put(['redirect_option' => $redirect_option, 'checkout_to_type' => $request->get('checkout_to_type')]);
|
||||
}
|
||||
|
||||
Session::put(['redirect_option' => $request->get('redirect_option'), 'checkout_to_type' => $request->get('checkout_to_type')]);
|
||||
|
||||
if ($asset->checkOut($target, $admin, $checkout_at, $expected_checkin, $request->get('note'), $request->get('name'))) {
|
||||
return Helper::getRedirectOption($request, $assetId);
|
||||
return Helper::getRedirectOption($request, $assetId, 'Assets');
|
||||
}
|
||||
// Redirect to the asset management page with error
|
||||
return redirect()->to("hardware/$assetId/checkout")->with('error', trans('admin/hardware/message.checkout.error').$asset->getErrors());
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<div class="box-footer">
|
||||
<a class="btn btn-link" href="{{ route($route) }}">{{ trans('button.cancel') }}</a>
|
||||
<button type="submit" class="btn btn-primary pull-right"><i class="fas fa-check icon-white" aria-hidden="true"></i> {{ trans('general.checkout') }}</button>
|
||||
<button type="submit" class="btn btn-primary pull-right"><i class="fas fa-check icon-white" aria-hidden="true"></i> {{$checkin ? trans('general.checkin') : trans('general.checkout') }}</button>
|
||||
<div class="btn-group pull-right" style="margin-right:5px;">
|
||||
<select class="redirect-options form-control" name="redirect_option">
|
||||
<option {{Session::get('redirect_option')=="0" ? 'selected' : ''}} value="0">{{trans('admin/hardware/form.redirect_to_all', ['type' => $table_name])}}</option>
|
||||
<option {{(Session::get('redirect_option')=="0" || (Session::get('redirect_option')=="2" && $checkin)) ? 'selected' : ''}} value="0">{{trans('admin/hardware/form.redirect_to_all', ['type' => $table_name])}}</option>
|
||||
<option {{Session::get('redirect_option')=="1" ? 'selected' : ''}} value="1">{{trans('admin/hardware/form.redirect_to_type', ['type' => $type])}}</option>
|
||||
<option {{Session::get('redirect_option')=="2" ? 'selected' : ''}} value="2" {{$checkin ? 'hidden' : ''}}>{{trans('admin/hardware/form.redirect_to_checked_out_to')}}</option>
|
||||
<option {{(Session::get('redirect_option')=="2" && !$checkin) ? 'selected' : ''}} value="2" >{{trans('admin/hardware/form.redirect_to_checked_out_to')}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div> <!-- /.box-->
|
||||
Reference in New Issue
Block a user