/** * Generates the next free seat ID for checkout. * * @todo This is a dumb way to solve this problem. * Author should refactor. And go hide in a hole and * think about what she's done. And perhaps find a new * line of work. And get in the sea. * * @author [A. Gianotto] [<*****@*****.**>] * @since [v1.0] * @param int $licenseId * @return View */ 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()->to('admin/licenses')->with('error', trans('admin/licenses/message.not_found')); } $seatId = $license->freeSeat($licenseId); return redirect()->to('admin/licenses/' . $seatId . '/checkout'); }
public function getAcceptAsset($logID = null) { if (!($findlog = DB::table('asset_logs')->where('id', '=', $logID)->first())) { echo 'no record'; //return redirect()->to('account')->with('error', trans('admin/hardware/message.does_not_exist')); } $user = Auth::user(); if ($user->id != $findlog->checkedout_to) { return redirect()->to('account/view-assets')->with('error', trans('admin/users/message.error.incorrect_user_accepted')); } // Asset if ($findlog->asset_id != '' && $findlog->asset_type == 'hardware') { $item = Asset::find($findlog->asset_id); // software } elseif ($findlog->asset_id != '' && $findlog->asset_type == 'software') { $item = License::find($findlog->asset_id); // accessories } elseif ($findlog->accessory_id != '') { $item = Accessory::find($findlog->accessory_id); // consumable } elseif ($findlog->consumable_id != '') { $item = Consumable::find($findlog->consumable_id); // components } elseif ($findlog->component_id != '') { $item = Component::find($findlog->component_id); } // Check if the asset exists if (is_null($item)) { // Redirect to the asset management page return redirect()->to('account')->with('error', trans('admin/hardware/message.does_not_exist')); } elseif (!Company::isCurrentUserHasAccess($item)) { return redirect()->route('requestable-assets')->with('error', trans('general.insufficient_permissions')); } else { return View::make('account/accept-asset', compact('item'))->with('findlog', $findlog); } }