need to make variables names uniform

This commit is contained in:
Godfrey M 2024-05-14 14:09:54 -07:00
parent 15cc4345ab
commit dc418a7033
4 changed files with 130 additions and 106 deletions

View file

@ -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') {
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') {
switch ($checkout_to_type) {
case 'user':
return redirect()->route('users.show', $request->assigned_user)->with('success', trans('admin/hardware/message.checkout.success'));
}
if ($checkout_to_type == 'location') {
case 'location':
return redirect()->route('locations.show', $request->assigned_location)->with('success', trans('admin/hardware/message.checkout.success'));
}
if ($checkout_to_type == 'asset') {
case 'asset':
return redirect()->route('hardware.show', $request->assigned_asset)->with('success', trans('admin/hardware/message.checkout.success'));
}
}

View file

@ -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
@ -78,10 +80,14 @@ class LicenseCheckoutController extends Controller
$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;

View file

@ -3,7 +3,7 @@
{{-- Page title --}}
@section('title')
{{ trans('admin/licenses/general.checkout') }}
@parent
@parent
@stop
@section('header_right')
@ -13,7 +13,7 @@
{{-- 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">
@ -21,7 +21,9 @@
<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>
<h2 class="box-title"> {{ $license->name }}
({{ trans('admin/licenses/message.seats_available', ['seat_count' => $license->availCount()->count()]) }}
)</h2>
</div>
<div class="box-body">
@ -64,9 +66,11 @@
<!-- Note -->
<div class="form-group {{ $errors->has('notes') ? 'error' : '' }}">
<label for="note" class="col-md-3 control-label">{{ trans('admin/hardware/form.notes') }}</label>
<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>
<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>
@ -104,14 +108,9 @@
</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-->
@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>
</div>
@stop

View file

@ -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-->