/** * Returns a view that presents a form to clone an asset. * * @author [A. Gianotto] [<*****@*****.**>] * @param int $assetId * @since [v1.0] * @return View */ public function getClone($assetId = null) { // Check if the asset exists if (is_null($asset_to_clone = Asset::find($assetId))) { // Redirect to the asset management page return redirect()->to('hardware')->with('error', trans('admin/hardware/message.does_not_exist')); } elseif (!Company::isCurrentUserHasAccess($asset_to_clone)) { return redirect()->to('hardware')->with('error', trans('general.insufficient_permissions')); } // Grab the dropdown lists $model_list = Helper::modelList(); $statuslabel_list = Helper::statusLabelList(); $location_list = Helper::locationsList(); $manufacturer_list = Helper::manufacturerList(); $category_list = Helper::categoryList('asset'); $supplier_list = Helper::suppliersList(); $assigned_to = Helper::usersList(); $statuslabel_types = Helper::statusTypeList(); $company_list = Helper::companyList(); $asset = clone $asset_to_clone; $asset->id = null; $asset->asset_tag = ''; $asset->serial = ''; $asset->assigned_to = ''; return View::make('hardware/edit')->with('supplier_list', $supplier_list)->with('model_list', $model_list)->with('statuslabel_list', $statuslabel_list)->with('statuslabel_types', $statuslabel_types)->with('assigned_to', $assigned_to)->with('asset', $asset)->with('location_list', $location_list)->with('manufacturer', $manufacturer_list)->with('category', $category_list)->with('company_list', $company_list); }
/** * Return view for the Accessory update form, prepopulated with existing data * * @author [A. Gianotto] [<*****@*****.**>] * @param int $accessoryId * @return View */ public function getEdit(Request $request, $accessoryId = null) { // Check if the accessory exists if (is_null($accessory = Accessory::find($accessoryId))) { // Redirect to the blogs management page return redirect()->to('admin/accessories')->with('error', trans('admin/accessories/message.does_not_exist')); } elseif (!Company::isCurrentUserHasAccess($accessory)) { return redirect()->to('admin/accessories')->with('error', trans('general.insufficient_permissions')); } $category_list = Helper::categoryList('accessory'); $company_list = Helper::companyList(); $location_list = Helper::locationsList(); return View::make('accessories/edit', compact('accessory'))->with('category_list', $category_list)->with('company_list', $company_list)->with('location_list', $location_list); }
/** * Returns a form view to edit a consumable. * * @author [A. Gianotto] [<*****@*****.**>] * @param int $consumableId * @see ConsumablesController::postEdit() method that stores the form data. * @since [v1.0] * @return View */ public function getEdit($consumableId = null) { // Check if the consumable exists if (is_null($consumable = Consumable::find($consumableId))) { // Redirect to the blogs management page return redirect()->to('admin/consumables')->with('error', trans('admin/consumables/message.does_not_exist')); } elseif (!Company::isCurrentUserHasAccess($consumable)) { return redirect()->to('admin/consumables')->with('error', trans('general.insufficient_permissions')); } $category_list = Helper::categoryList('consumable'); $company_list = Helper::companyList(); $location_list = Helper::locationsList(); $manufacturer_list = Helper::manufacturerList(); return View::make('consumables/edit', compact('consumable'))->with('category_list', $category_list)->with('company_list', $company_list)->with('location_list', $location_list)->with('manufacturer_list', $manufacturer_list); }
/** * Get the clone page to clone a model * * @author [A. Gianotto] [<*****@*****.**>] * @since [v1.0] * @param int $modelId * @return View */ public function getClone($modelId = null) { // Check if the model exists if (is_null($model_to_clone = AssetModel::find($modelId))) { // Redirect to the model management page return redirect()->to('assets/models')->with('error', trans('admin/models/message.does_not_exist')); } $model = clone $model_to_clone; $model->id = null; // Show the page $depreciation_list = Helper::depreciationList(); $manufacturer_list = Helper::manufacturerList(); $category_list = Helper::categoryList('asset'); $view = View::make('models/edit'); $view->with('category_list', $category_list); $view->with('depreciation_list', $depreciation_list); $view->with('manufacturer_list', $manufacturer_list); $view->with('model', $model); $view->with('clone_model', $model_to_clone); return $view; }