Beispiel #1
0
 /**
  * Asset clone.
  *
  * @param  int  $assetId
  * @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', Lang::get('admin/hardware/message.does_not_exist'));
     } else {
         if (!Company::isCurrentUserHasAccess($asset_to_clone)) {
             return Redirect::to('hardware')->with('error', Lang::get('general.insufficient_permissions'));
         }
     }
     // Grab the dropdown lists
     $model_list = modelList();
     $statuslabel_list = statusLabelList();
     $location_list = locationsList();
     $manufacturer_list = manufacturerList();
     $category_list = categoryList();
     $supplier_list = suppliersList();
     $assigned_to = usersList();
     $statuslabel_types = statusTypeList();
     $company_list = Company::getSelectList();
     $asset = clone $asset_to_clone;
     $asset->id = null;
     $asset->asset_tag = '';
     $asset->serial = '';
     $asset->assigned_to = '';
     return View::make('backend/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);
 }
 /**
  *  Display bulk edit screen
  *
  * @return View
  **/
 public function postBulkEdit($assets = null)
 {
     if (!Company::isCurrentUserAuthorized()) {
         return Redirect::to('hardware')->with('error', Lang::get('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();
             if ($settings->qr_code == '1') {
                 $assets = Asset::find($asset_ids);
                 $assetcount = count($assets);
                 $count = 0;
                 return View::make('backend/hardware/labels')->with('assets', $assets)->with('settings', $settings)->with('count', $count);
             } else {
                 // QR codes are not enabled
                 return Redirect::to("hardware")->with('error', 'Barcodes are not enabled in Admin > Settings');
             }
         } elseif (Input::get('bulk_actions') == 'delete') {
             $assets = Asset::with('assigneduser', 'assetloc')->find($asset_ids);
             return View::make('backend/hardware/bulk-delete')->with('assets', $assets);
             // Bulk edit
         } elseif (Input::get('bulk_actions') == 'edit') {
             $assets = Input::get('edit_asset');
             $supplier_list = array('' => '') + suppliersList();
             $statuslabel_list = array('' => '') + statusLabelList();
             $location_list = array('' => '') + locationsList();
             $models_list = array('' => '') + modelList();
             $companies_list = array('' => '') + array('clear' => Lang::get('general.remove_company')) + companyList();
             return View::make('backend/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');
     }
 }