mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-24 12:17:05 -08:00
dropdown redirect options, helper function and session variable added
This commit is contained in:
parent
19cff25300
commit
c94a7613ca
|
@ -14,6 +14,7 @@ use App\Models\Statuslabel;
|
|||
use App\Models\License;
|
||||
use Crypt;
|
||||
use Illuminate\Contracts\Encryption\DecryptException;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Image;
|
||||
use Carbon\Carbon;
|
||||
|
||||
|
@ -1459,4 +1460,27 @@ class Helper
|
|||
return $new_locale; // better that you have some weird locale that doesn't fit into our mappings anywhere than 'void'
|
||||
}
|
||||
|
||||
|
||||
static public function getRedirectOption($request, $assetId)
|
||||
{
|
||||
$redirect_option = session::get('redirect_option');
|
||||
|
||||
if ($redirect_option == '0') {
|
||||
return redirect()->route('hardware.index')->with('success', trans('admin/hardware/message.checkout.success'));
|
||||
}
|
||||
if ($redirect_option == '1') {
|
||||
return redirect()->route('hardware.show', $assetId)->with('success', trans('admin/hardware/message.checkout.success'));
|
||||
}
|
||||
if ($redirect_option == '2') {
|
||||
if ($request->assigned_location != null) {
|
||||
return redirect()->route('users.show', $request->assigned_user)->with('success', trans('admin/hardware/message.checkout.success'));
|
||||
}
|
||||
}
|
||||
if ($redirect_option == '3') {
|
||||
if ($request->assigned_location != null) {
|
||||
|
||||
return redirect()->route('locations.show', $request->assigned_location)->with('success', trans('admin/hardware/message.checkout.success'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ use App\Http\Requests\AssetCheckoutRequest;
|
|||
use App\Models\Asset;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
|
||||
class AssetCheckoutController extends Controller
|
||||
{
|
||||
|
@ -97,11 +98,14 @@ class AssetCheckoutController extends Controller
|
|||
return redirect()->to("hardware/$assetId/checkout")->with('error', trans('general.error_user_company'));
|
||||
}
|
||||
}
|
||||
|
||||
if ($asset->checkOut($target, $admin, $checkout_at, $expected_checkin, $request->get('note'), $request->get('name'))) {
|
||||
return redirect()->route('hardware.index')->with('success', trans('admin/hardware/message.checkout.success'));
|
||||
$redirect_option = $request->get('redirect_option');
|
||||
if($redirect_option != Session::get('redirect_option')) {
|
||||
Session::put('redirect_option', $redirect_option);
|
||||
}
|
||||
|
||||
if ($asset->checkOut($target, $admin, $checkout_at, $expected_checkin, $request->get('note'), $request->get('name'))) {
|
||||
return Helper::getRedirectOption($request, $assetId);
|
||||
}
|
||||
// Redirect to the asset management page with error
|
||||
return redirect()->to("hardware/$assetId/checkout")->with('error', trans('admin/hardware/message.checkout.error').$asset->getErrors());
|
||||
} catch (ModelNotFoundException $e) {
|
||||
|
|
|
@ -144,6 +144,17 @@
|
|||
<div class="box-footer">
|
||||
<a class="btn btn-link" href="{{ URL::previous() }}"> {{ 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>
|
||||
<div class="btn-group pull-right">
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<select class="redirect-options js-states form-control" name="redirect_option">
|
||||
<option value="0">Return to all Assets</option>
|
||||
<option value="1">Go to Asset</option>
|
||||
<option value="2">Go to User</option>
|
||||
<option value="3">Go to Location</option>
|
||||
</select>
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue