Skip to content

Commit

Permalink
And still more license route updates
Browse files Browse the repository at this point in the history
  • Loading branch information
snipe committed Dec 15, 2016
1 parent bea1a93 commit ad1bf86
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 34 deletions.
15 changes: 6 additions & 9 deletions app/Http/Controllers/LicensesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class LicensesController extends Controller
*/
public function index()
{
// Show the page
return View::make('licenses/index');
}

Expand Down Expand Up @@ -848,7 +847,7 @@ public function postUpload($licenseId = null)
$error = trans('admin/licenses/message.does_not_exist', compact('id'));

// Redirect to the licence management page
return redirect()->route('licenses')->with('error', $error);
return redirect()->route('licenses.index')->with('error', $error);
}
}

Expand Down Expand Up @@ -888,7 +887,7 @@ public function getDeleteFile($licenseId = null, $fileId = null)
$error = trans('admin/licenses/message.does_not_exist', compact('id'));

// Redirect to the licence management page
return redirect()->route('licenses')->with('error', $error);
return redirect()->route('licenses.index')->with('error', $error);
}
}

Expand Down Expand Up @@ -923,7 +922,7 @@ public function displayFile($licenseId = null, $fileId = null)
$error = trans('admin/licenses/message.does_not_exist', compact('id'));

// Redirect to the licence management page
return redirect()->route('licenses')->with('error', $error);
return redirect()->route('licenses.index')->with('error', $error);
}
}

Expand Down Expand Up @@ -975,7 +974,7 @@ public function getDatatable(Request $request)
$actions = '<span style="white-space: nowrap;">';

if (Gate::allows('licenses.checkout')) {
$actions .= '<a href="' . route('freecheckout/license', $license->id)
$actions .= '<a href="' . route('licenses.freecheckout', $license->id)
. '" class="btn btn-primary btn-sm' . (($license->remaincount() > 0) ? '' : ' disabled') . '" style="margin-right:5px;">' . trans('general.checkout') . '</a> ';
}

Expand Down Expand Up @@ -1010,7 +1009,7 @@ public function getDatatable(Request $request)
'notes' => ($license->notes) ? e($license->notes) : '',
'actions' => $actions,
'company' => is_null($license->company) ? '' : e($license->company->name),
'manufacturer' => $license->manufacturer ? (string) link_to('/admin/settings/manufacturers/'.$license->manufacturer_id.'/view', $license->manufacturer->name) : ''
'manufacturer' => $license->manufacturer ? (string) link_to('settings/manufacturers/'.$license->manufacturer_id.'/view', $license->manufacturer->name) : ''
);
}

Expand All @@ -1034,12 +1033,10 @@ public function getDatatable(Request $request)
*/
public function getFreeLicense($licenseId)
{
// Check if the asset exists
if (is_null($license = License::find($licenseId))) {
// Redirect to the asset management page with error
return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.not_found'));
}
$seatId = $license->freeSeat($licenseId);
return redirect()->to('admin/licenses/'.$seatId.'/checkout');
return redirect()->route('licenses.checkout', $seatId);
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/ManufacturersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ protected function getDataLicensesView(Manufacturer $manufacturer)
$actions = '<span style="white-space: nowrap;">';

if (Gate::allows('licenses.checkout')) {
$actions .= '<a href="' . route('freecheckout/license', $license->id)
$actions .= '<a href="' . route('licenses.freecheckout', $license->id)
. '" class="btn btn-primary btn-sm' . (($license->remaincount() > 0) ? '' : ' disabled') . '" style="margin-right:5px;">' . trans('general.checkout') . '</a> ';
}

Expand Down
2 changes: 1 addition & 1 deletion resources/views/hardware/qr-view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
<tr>
<td><a href="{{ route('view/license', $seat->license->id) }}">{{ $seat->license->name }}</a></td>
<td>{{ $seat->license->serial }}</td>
<td><a href="{{ route('checkin/license', $seat->id) }}" class="btn-flat info">{{ trans('general.checkin') }}</a>
<td><a href="{{ route('licenses.checkin', $seat->id) }}" class="btn-flat info">{{ trans('general.checkin') }}</a>
</td>
</tr>
@endforeach
Expand Down
8 changes: 4 additions & 4 deletions resources/views/hardware/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@
{{ trans('general.months') }}
)
@endif

</td>
</tr>
@endif
Expand Down Expand Up @@ -441,7 +441,7 @@
<td><a href="{{ route('view/license', $seat->license->id) }}">{{ $seat->license->name }}</a></td>
<td>{{ $seat->license->serial }}</td>
<td>
<a href="{{ route('checkin/license', $seat->id) }}" class="btn-flat info btn-sm">{{ trans('general.checkin') }}</a>
<a href="{{ route('licenses.checkin', $seat->id) }}" class="btn-flat info btn-sm">{{ trans('general.checkin') }}</a>
</td>
</tr>
@endforeach
Expand Down Expand Up @@ -489,7 +489,7 @@
{{ trans('general.no_results') }}
</div>
@endif

</div>
</div>
</div> <!-- /.tab-pane components -->
Expand Down Expand Up @@ -612,7 +612,7 @@
@else
<del>{{ $log->target->fullName() }}</del>
@endif
@elseif($log->target instanceof \App\Models\Asset)
@elseif($log->target instanceof \App\Models\Asset)
@if ($log->target->deleted_at=='')
<a href="{{ route('view/hardware', $log->target_id) }}">
{{ $log->target->showAssetName() }}
Expand Down
6 changes: 3 additions & 3 deletions resources/views/licenses/checkin.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
<div class="col-md-10 column">

@if ($backto=='user')
<form class="form-horizontal" method="post" action="{{ route('checkin/license', array('licenseeat_id'=> $licenseseat->id, 'backto'=>'user')) }}" autocomplete="off">
<form class="form-horizontal" method="post" action="{{ route('licenses.checkin', array('licenseeat_id'=> $licenseseat->id, 'backto'=>'user')) }}" autocomplete="off">
@else
<form class="form-horizontal" method="post" action="{{ route('checkin/license', $licenseseat->id) }}" autocomplete="off">
<form class="form-horizontal" method="post" action="{{ route('licenses.checkin', $licenseseat->id) }}" autocomplete="off">
@endif

<!-- CSRF Token -->
Expand Down Expand Up @@ -58,7 +58,7 @@
<div class="form-group">
<label class="col-md-2 control-label"></label>
<div class="col-md-7">
<a class="btn btn-link" href="{{ route('licenses') }}">{{ trans('button.cancel') }}</a>
<a class="btn btn-link" href="{{ route('licenses.index') }}">{{ trans('button.cancel') }}</a>
<button type="submit" class="btn btn-success"><i class="fa fa-check icon-white"></i> {{ trans('general.checkin') }}</button>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/licenses/checkout.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
</div>
</div>
<div class="box-footer">
<a class="btn btn-link" href="{{ route('licenses') }}">{{ trans('button.cancel') }}</a>
<a class="btn btn-link" href="{{ route('licenses.index') }}">{{ trans('button.cancel') }}</a>
<button type="submit" class="btn btn-success pull-right"><i class="fa fa-check icon-white"></i> {{ trans('general.checkout') }}</button>
</div>
</form>
Expand Down
4 changes: 2 additions & 2 deletions resources/views/licenses/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@
@if (($licensedto->assigned_to) || ($licensedto->asset_id))

@if ($license->reassignable)
<a href="{{ route('checkin/license', $licensedto->id) }}" class="btn btn-primary btn-sm">
<a href="{{ route('licenses.checkin', $licensedto->id) }}" class="btn btn-primary btn-sm">
{{ trans('general.checkin') }}
</a>
@else
<span>Assigned</span>
@endif
@else
<a href="{{ route('checkout/license', $licensedto->id) }}" class="btn btn-info btn-sm">
<a href="{{ route('licenses.checkout', $licensedto->id) }}" class="btn btn-info btn-sm">
{{ trans('general.checkout') }}</a>
@endif
@endcan
Expand Down
2 changes: 1 addition & 1 deletion resources/views/users/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
<td><a href="{{ route('view/license', $license->id) }}">{{ mb_strimwidth($license->serial, 0, 50, "...") }}</a></td>
<td class="hidden-print">
@can('licenses.edit')
<a href="{{ route('checkin/license', array('licenseseat_id'=> $license->pivot->id, 'backto'=>'user')) }}" class="btn btn-primary btn-sm">Checkin</a>
<a href="{{ route('licenses.checkin', array('licenseseat_id'=> $license->pivot->id, 'backto'=>'user')) }}" class="btn btn-primary btn-sm">Checkin</a>
@endcan
</td>
</tr>
Expand Down
17 changes: 5 additions & 12 deletions routes/web/licenses.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,30 @@
Route::post('{licenseId}/clone', [ 'as' => 'clone/license', 'middleware' => 'authorize:licenses.create', 'uses' => 'LicensesController@postCreate' ]);

Route::get('{licenseId}/freecheckout', [
'as' => 'freecheckout/license',
'as' => 'licenses.freecheckout',
'middleware' => 'authorize:licenses.checkout',
'uses' => 'LicensesController@getFreeLicense'
]);
Route::get(
'{licenseId}/checkout',
[ 'as' => 'checkout/license', 'middleware' => 'authorize:licenses.checkout','uses' => 'LicensesController@getCheckout' ]
[ 'as' => 'licenses.checkout', 'middleware' => 'authorize:licenses.checkout','uses' => 'LicensesController@getCheckout' ]
);
Route::post(
'{licenseId}/checkout',
[ 'as' => 'checkout/license', 'middleware' => 'authorize:licenses.checkout','uses' => 'LicensesController@postCheckout' ]
[ 'as' => 'licenses.checkout', 'middleware' => 'authorize:licenses.checkout','uses' => 'LicensesController@postCheckout' ]
);
Route::get('{licenseId}/checkin/{backto?}', [
'as' => 'checkin/license',
'as' => 'licenses.checkin',
'middleware' => 'authorize:licenses.checkin',
'uses' => 'LicensesController@getCheckin'
]);

Route::post('{licenseId}/checkin/{backto?}', [
'as' => 'checkin/license',
'as' => 'licenses.checkin',
'middleware' => 'authorize:licenses.checkin',
'uses' => 'LicensesController@postCheckin'
]);

#legacy
Route::get('{licenseId}/view', [
'as' => 'view/license',
'middleware' => 'authorize:licenses.view',
'uses' => 'LicensesController@getView'
]);

Route::post(
'{licenseId}/upload',
[ 'as' => 'upload/license', 'middleware' => 'authorize:licenses.edit','uses' => 'LicensesController@postUpload' ]
Expand Down

0 comments on commit ad1bf86

Please sign in to comment.