Skip to content

A free open source IT asset/license management system

need to make variables names uniform

Godfrey Mdc418a70331b
diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php
index b839b287e1..ff67985091 100644
--- a/app/Helpers/Helper.php
+++ b/app/Helpers/Helper.php
@@ -1461,27 +1461,34 @@ class Helper
}
- static public function getRedirectOption($request, $assetId)
- {
+ static public function getRedirectOption($request, $Id, $table)
+ { dd($request);
$redirect_option = session::get('redirect_option');
$checkout_to_type = session::get('checkout_to_type');
if ($redirect_option == '0') {
- return redirect()->route('hardware.index')->with('success', trans('admin/hardware/message.checkout.success'));
+ switch ($table) {
+ case "Assets":
+ return redirect()->route('hardware.index')->with('success', trans('admin/hardware/message.checkout.success'));
+ case "Licenses":
+ return redirect()->route('licenses.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'));
+ switch ($table) {
+ case "Assets":
+ return redirect()->route('hardware.show', $Id)->with('success', trans('admin/hardware/message.checkout.success'));
+ case "Licenses":
+ return redirect()->route('licenses.show', $Id)->with('success', trans('admin/hardware/message.checkout.success'));
+ }
}
if ($redirect_option == '2') {
-
- if ($checkout_to_type == 'user') {
- return redirect()->route('users.show', $request->assigned_user)->with('success', trans('admin/hardware/message.checkout.success'));
- }
- if ($checkout_to_type == 'location') {
-
- return redirect()->route('locations.show', $request->assigned_location)->with('success', trans('admin/hardware/message.checkout.success'));
- }
- if ($checkout_to_type == 'asset') {
+ switch ($checkout_to_type) {
+ case 'user':
+ return redirect()->route('users.show', $request->assigned_user)->with('success', trans('admin/hardware/message.checkout.success'));
+ case 'location':
+ return redirect()->route('locations.show', $request->assigned_location)->with('success', trans('admin/hardware/message.checkout.success'));
+ case 'asset':
return redirect()->route('hardware.show', $request->assigned_asset)->with('success', trans('admin/hardware/message.checkout.success'));
}
}
diff --git a/app/Http/Controllers/Licenses/LicenseCheckoutController.php b/app/Http/Controllers/Licenses/LicenseCheckoutController.php
index d61a1ad819..aa2a32e692 100644
--- a/app/Http/Controllers/Licenses/LicenseCheckoutController.php
+++ b/app/Http/Controllers/Licenses/LicenseCheckoutController.php
@@ -3,6 +3,7 @@
namespace App\Http\Controllers\Licenses;
use App\Events\CheckoutableCheckedOut;
+use App\Helpers\Helper;
use App\Http\Controllers\Controller;
use App\Http\Requests\LicenseCheckoutRequest;
use App\Models\Accessory;
@@ -11,6 +12,7 @@ use App\Models\License;
use App\Models\LicenseSeat;
use App\Models\User;
use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Session;
class LicenseCheckoutController extends Controller
{
@@ -41,7 +43,7 @@ class LicenseCheckoutController extends Controller
}
// Return the checkout view
- return view('licenses/checkout', compact('license'));
+ return view('licenses/checkout', compact('license'))->with('table_name' , 'Licenses');
}
// Invalid category
@@ -77,11 +79,15 @@ class LicenseCheckoutController extends Controller
$licenseSeat = $this->findLicenseSeatToCheckout($license, $seatId);
$licenseSeat->user_id = Auth::id();
$licenseSeat->notes = $request->input('notes');
-
$checkoutMethod = 'checkoutTo'.ucwords(request('checkout_to_type'));
+ $redirect_option = $request->get('redirect_option');
+ Session::put('checkout_to_type', $request->input('checkout_to_type'));
+ if($redirect_option != Session::get('redirect_option')) {
+ Session::put(['redirect_option' => $redirect_option]);
+ }
if ($this->$checkoutMethod($licenseSeat)) {
- return redirect()->route('licenses.index')->with('success', trans('admin/licenses/message.checkout.success'));
+ return Helper::getRedirectOption($request, $licenseId, 'Licenses');
}
return redirect()->route('licenses.index')->with('error', trans('Something went wrong handling this checkout.'));
@@ -112,7 +118,6 @@ class LicenseCheckoutController extends Controller
return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.asset_does_not_exist'));
}
$licenseSeat->asset_id = request('asset_id');
-
// Override asset's assigned user if available
if ($target->checkedOutToUser()) {
$licenseSeat->assigned_to = $target->assigned_to;
diff --git a/resources/views/licenses/checkout.blade.php b/resources/views/licenses/checkout.blade.php
index e85c677420..3bf6350739 100755
--- a/resources/views/licenses/checkout.blade.php
+++ b/resources/views/licenses/checkout.blade.php
@@ -2,8 +2,8 @@
{{-- Page title --}}
@section('title')
- {{ trans('admin/licenses/general.checkout') }}
-@parent
+ {{ trans('admin/licenses/general.checkout') }}
+ @parent
@stop
@section('header_right')
@@ -13,105 +13,104 @@
{{-- Page content --}}
@section('content')
-<div class="row">
+ <div class="row">
<!-- left column -->
- <div class="col-md-7">
- <form class="form-horizontal" method="post" action="" autocomplete="off">
- {{csrf_field()}}
-
- <div class="box box-default">
- <div class="box-header with-border">
- <h2 class="box-title"> {{ $license->name }} ({{ trans('admin/licenses/message.seats_available', ['seat_count' => $license->availCount()->count()]) }})</h2>
- </div>
- <div class="box-body">
-
-
- <!-- Asset name -->
- <div class="form-group">
- <label class="col-sm-3 control-label">{{ trans('admin/hardware/form.name') }}</label>
- <div class="col-md-9">
- <p class="form-control-static">{{ $license->name }}</p>
- </div>
+ <div class="col-md-7">
+ <form class="form-horizontal" method="post" action="" autocomplete="off">
+ {{csrf_field()}}
+
+ <div class="box box-default">
+ <div class="box-header with-border">
+ <h2 class="box-title"> {{ $license->name }}
+ ({{ trans('admin/licenses/message.seats_available', ['seat_count' => $license->availCount()->count()]) }}
+ )</h2>
</div>
- <!-- Category -->
- <div class="form-group">
- <label class="col-sm-3 control-label">{{ trans('general.category') }}</label>
- <div class="col-md-9">
- <p class="form-control-static">{{ $license->category->name }}</p>
+ <div class="box-body">
+
+
+ <!-- Asset name -->
+ <div class="form-group">
+ <label class="col-sm-3 control-label">{{ trans('admin/hardware/form.name') }}</label>
+ <div class="col-md-9">
+ <p class="form-control-static">{{ $license->name }}</p>
+ </div>
+ </div>
+ <!-- Category -->
+ <div class="form-group">
+ <label class="col-sm-3 control-label">{{ trans('general.category') }}</label>
+ <div class="col-md-9">
+ <p class="form-control-static">{{ $license->category->name }}</p>
+ </div>
</div>
- </div>
- <!-- Serial -->
- <div class="form-group">
- <label class="col-sm-3 control-label">{{ trans('admin/licenses/form.license_key') }}</label>
- <div class="col-md-9">
- <p class="form-control-static" style="word-wrap: break-word;">
- @can('viewKeys', $license)
- {{ $license->serial }}
- @else
- ------------
- @endcan
- </p>
+ <!-- Serial -->
+ <div class="form-group">
+ <label class="col-sm-3 control-label">{{ trans('admin/licenses/form.license_key') }}</label>
+ <div class="col-md-9">
+ <p class="form-control-static" style="word-wrap: break-word;">
+ @can('viewKeys', $license)
+ {{ $license->serial }}
+ @else
+ ------------
+ @endcan
+ </p>
+ </div>
</div>
- </div>
- @include ('partials.forms.checkout-selector', ['user_select' => 'true','asset_select' => 'true', 'location_select' => 'false'])
+ @include ('partials.forms.checkout-selector', ['user_select' => 'true','asset_select' => 'true', 'location_select' => 'false'])
- @include ('partials.forms.edit.user-select', ['translated_name' => trans('general.user'), 'fieldname' => 'assigned_to', 'required'=>'true'])
+ @include ('partials.forms.edit.user-select', ['translated_name' => trans('general.user'), 'fieldname' => 'assigned_to', 'required'=>'true'])
- @include ('partials.forms.edit.asset-select', ['translated_name' => trans('admin/licenses/form.asset'), 'fieldname' => 'asset_id', 'style' => 'display:none;'])
+ @include ('partials.forms.edit.asset-select', ['translated_name' => trans('admin/licenses/form.asset'), 'fieldname' => 'asset_id', 'style' => 'display:none;'])
- <!-- Note -->
- <div class="form-group {{ $errors->has('notes') ? 'error' : '' }}">
- <label for="note" class="col-md-3 control-label">{{ trans('admin/hardware/form.notes') }}</label>
- <div class="col-md-8">
- <textarea class="col-md-6 form-control" id="notes" name="notes" style="width: 100%">{{ old('note') }}</textarea>
- {!! $errors->first('note', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
+ <!-- Note -->
+ <div class="form-group {{ $errors->has('notes') ? 'error' : '' }}">
+ <label for="note"
+ class="col-md-3 control-label">{{ trans('admin/hardware/form.notes') }}</label>
+ <div class="col-md-8">
+ <textarea class="col-md-6 form-control" id="notes" name="notes"
+ style="width: 100%">{{ old('note') }}</textarea>
+ {!! $errors->first('note', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
+ </div>
</div>
</div>
- </div>
-
-
- @if ($license->requireAcceptance() || $license->getEula() || ($snipeSettings->webhook_endpoint!=''))
- <div class="form-group notification-callout">
- <div class="col-md-8 col-md-offset-3">
- <div class="callout callout-info">
-
- @if ($license->requireAcceptance())
- <i class="far fa-envelope"></i>
- {{ trans('admin/categories/general.required_acceptance') }}
- <br>
- @endif
-
- @if ($license->getEula())
- <i class="far fa-envelope"></i>
- {{ trans('admin/categories/general.required_eula') }}
- <br>
- @endif
-
- @if (($license->category) && ($license->category->checkin_email))
- <i class="far fa-envelope"></i>
- {{ trans('admin/categories/general.checkin_email_notification') }}
- <br>
- @endif
-
- @if ($snipeSettings->webhook_endpoint!='')
- <i class="fab fa-slack"></i>
- {{ trans('general.webhook_msg_note') }}
- @endif
+
+
+ @if ($license->requireAcceptance() || $license->getEula() || ($snipeSettings->webhook_endpoint!=''))
+ <div class="form-group notification-callout">
+ <div class="col-md-8 col-md-offset-3">
+ <div class="callout callout-info">
+
+ @if ($license->requireAcceptance())
+ <i class="far fa-envelope"></i>
+ {{ trans('admin/categories/general.required_acceptance') }}
+ <br>
+ @endif
+
+ @if ($license->getEula())
+ <i class="far fa-envelope"></i>
+ {{ trans('admin/categories/general.required_eula') }}
+ <br>
+ @endif
+
+ @if (($license->category) && ($license->category->checkin_email))
+ <i class="far fa-envelope"></i>
+ {{ trans('admin/categories/general.checkin_email_notification') }}
+ <br>
+ @endif
+
+ @if ($snipeSettings->webhook_endpoint!='')
+ <i class="fab fa-slack"></i>
+ {{ trans('general.webhook_msg_note') }}
+ @endif
+ </div>
</div>
</div>
- </div>
@endif
-
- <div class="box-footer">
- <a class="btn btn-link" href="{{ route('licenses.index') }}">{{ 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>
- </div> <!-- /.box-->
- </form>
- </div> <!-- /.col-md-7-->
-</div>
+ @include ('partials.forms.redirect_submit_options', ['translated_name' => trans('admin/licenses/form.asset'), 'table_name' => $table_name, 'type' => $license->name])
+ </form>
+ </div> <!-- /.col-md-7-->
+ </div>
@stop
diff --git a/resources/views/partials/forms/redirect_submit_options.blade.php b/resources/views/partials/forms/redirect_submit_options.blade.php
new file mode 100644
index 0000000000..0b98933254
--- /dev/null
+++ b/resources/views/partials/forms/redirect_submit_options.blade.php
@@ -0,0 +1,13 @@
+<div class="box-footer">
+ <a class="btn btn-link" href="{{ route('licenses.index') }}">{{ 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">
+ <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')=="1" ? 'selected' : ''}} value="1">{{trans('admin/hardware/form.redirect_to_type', ['type' => $type])}}</option>
+ <option {{Session::get('redirect_option')=="2" ? 'selected' : ''}} value="2">{{trans('admin/hardware/form.redirect_to_checked_out_to')}}</option>
+ <option value="11">{{Session::get('redirect_option')}}</option>
+ </select>
+ </div>
+ </div>
+</div> <!-- /.box-->
\ No newline at end of file