示例#1
0
 /**
  * Display the bulk edit page.
  *
  * @author [A. Gianotto] [<*****@*****.**>]
  * @param  int  $assetId
  * @since [v2.0]
  * @return View
  */
 public function postBulkEdit($assets = null)
 {
     if (!Company::isCurrentUserAuthorized()) {
         return redirect()->to('hardware')->with('error', trans('general.insufficient_permissions'));
     } elseif (!Input::has('edit_asset')) {
         return redirect()->back()->with('error', 'No assets selected');
     } else {
         $asset_raw_array = Input::get('edit_asset');
         foreach ($asset_raw_array as $asset_id => $value) {
             $asset_ids[] = $asset_id;
         }
     }
     if (Input::has('bulk_actions')) {
         // Create labels
         if (Input::get('bulk_actions') == 'labels') {
             $settings = Setting::getSettings();
             $assets = Asset::find($asset_ids);
             $count = 0;
             return View::make('hardware/labels')->with('assets', $assets)->with('settings', $settings)->with('count', $count)->with('settings', $settings);
         } elseif (Input::get('bulk_actions') == 'delete') {
             $assets = Asset::with('assigneduser', 'assetloc')->find($asset_ids);
             return View::make('hardware/bulk-delete')->with('assets', $assets);
             // Bulk edit
         } elseif (Input::get('bulk_actions') == 'edit') {
             $assets = Input::get('edit_asset');
             $supplier_list = Helper::suppliersList();
             $statuslabel_list = Helper::statusLabelList();
             $location_list = Helper::locationsList();
             $models_list = Helper::modelList();
             $companies_list = array('' => '') + array('clear' => trans('general.remove_company')) + Helper::companyList();
             return View::make('hardware/bulk')->with('assets', $assets)->with('supplier_list', $supplier_list)->with('statuslabel_list', $statuslabel_list)->with('location_list', $location_list)->with('models_list', $models_list)->with('companies_list', $companies_list);
         }
     } else {
         return redirect()->back()->with('error', 'No action selected');
     }
 }
 /**
  * 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);
 }
 /**
  * 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);
 }
示例#4
0
 public function getClone($licenseId = null)
 {
     // Check if the license exists
     if (is_null($license_to_clone = License::find($licenseId))) {
         // Redirect to the blogs management page
         return redirect()->to('admin/licenses')->with('error', trans('admin/licenses/message.does_not_exist'));
     } elseif (!Company::isCurrentUserHasAccess($license_to_clone)) {
         return redirect()->to('admin/licenses')->with('error', trans('general.insufficient_permissions'));
     }
     // Show the page
     $license_options = array('0' => 'Top Level') + License::pluck('name', 'id')->toArray();
     $maintained_list = array('' => 'Maintained', '1' => 'Yes', '0' => 'No');
     $company_list = Helper::companyList();
     //clone the orig
     $license = clone $license_to_clone;
     $license->id = null;
     $license->serial = null;
     // Show the page
     $depreciation_list = Helper::depreciationList();
     $supplier_list = Helper::suppliersList();
     return View::make('licenses/edit')->with('license_options', $license_options)->with('depreciation_list', $depreciation_list)->with('supplier_list', $supplier_list)->with('license', $license)->with('maintained_list', $maintained_list)->with('company_list', $company_list);
 }
示例#5
0
 /**
  * Return a view containing a pre-populated new user form,
  * populated with some fields from an existing user.
  *
  * @author [A. Gianotto] [<*****@*****.**>]
  * @since [v1.0]
  * @param  int  $id
  * @return Redirect
  */
 public function getClone($id = null)
 {
     // We need to reverse the UI specific logic for our
     // permissions here before we update the user.
     $permissions = Input::get('permissions', array());
     //$this->decodePermissions($permissions);
     app('request')->request->set('permissions', $permissions);
     try {
         // Get the user information
         $user_to_clone = User::withTrashed()->find($id);
         $user = clone $user_to_clone;
         $user->first_name = '';
         $user->last_name = '';
         $user->email = substr($user->email, ($pos = strpos($user->email, '@')) !== false ? $pos : 0);
         $user->id = null;
         // Get this user groups
         $userGroups = $user_to_clone->groups()->lists('name', 'id');
         // Get a list of all the available groups
         $groups = Group::pluck('name', 'id');
         // Get all the available permissions
         $permissions = config('permissions');
         $clonedPermissions = $user_to_clone->decodePermissions();
         $userPermissions = Helper::selectedPermissionsArray($permissions, $clonedPermissions);
         //$this->encodeAllPermissions($permissions);
         $location_list = Helper::locationsList();
         $company_list = Helper::companyList();
         $manager_list = Helper::managerList();
         // Show the page
         return View::make('users/edit', compact('groups', 'userGroups', 'permissions', 'userPermissions'))->with('location_list', $location_list)->with('company_list', $company_list)->with('manager_list', $manager_list)->with('user', $user)->with('groups', $groups)->with('userGroups', $userGroups)->with('clone_user', $user_to_clone);
     } catch (UserNotFoundException $e) {
         // Prepare the error message
         $error = trans('admin/users/message.user_not_found', compact('id'));
         // Redirect to the user management page
         return redirect()->route('users')->with('error', $error);
     }
 }