mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-26 14:09:43 -08:00
Modify Helper::categoryList() to take a category type parameter.
This allows for centralizing the category fetching code more and fixes an error in asset model viewing (#2118). Also add a few translated strings and standardize on a base of 'Select a *' for the default value in our lists.
This commit is contained in:
parent
9f6eb02afc
commit
cd9cca9c6b
|
@ -117,12 +117,14 @@ class Helper
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function categoryList()
|
public static function categoryList($category_type = null)
|
||||||
{
|
{
|
||||||
$category_list = array('' => '') + Category::orderBy('name', 'asc')
|
$categories = Category::orderBy('name', 'asc')
|
||||||
->whereNull('deleted_at')
|
->whereNull('deleted_at')
|
||||||
->orderBy('name', 'asc')
|
->orderBy('name', 'asc');
|
||||||
->pluck('name', 'id')->toArray();
|
if(!empty($category_type))
|
||||||
|
$categories = $categories->where('category_type', '=', $category_type);
|
||||||
|
$category_list = array('' => trans('general.select_category')) + $categories->pluck('name', 'id')->toArray();
|
||||||
return $category_list;
|
return $category_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +152,7 @@ class Helper
|
||||||
|
|
||||||
public static function manufacturerList()
|
public static function manufacturerList()
|
||||||
{
|
{
|
||||||
$manufacturer_list = array('' => 'Select One') +
|
$manufacturer_list = array('' => trans('general.select_manufacturer')) +
|
||||||
Manufacturer::orderBy('name', 'asc')
|
Manufacturer::orderBy('name', 'asc')
|
||||||
->pluck('name', 'id')->toArray();
|
->pluck('name', 'id')->toArray();
|
||||||
return $manufacturer_list;
|
return $manufacturer_list;
|
||||||
|
@ -164,7 +166,7 @@ class Helper
|
||||||
|
|
||||||
public static function managerList()
|
public static function managerList()
|
||||||
{
|
{
|
||||||
$manager_list = array('' => '') +
|
$manager_list = array('' => trans('general.select_user')) +
|
||||||
User::where('deleted_at', '=', null)
|
User::where('deleted_at', '=', null)
|
||||||
->orderBy('last_name', 'asc')
|
->orderBy('last_name', 'asc')
|
||||||
->orderBy('first_name', 'asc')->get()
|
->orderBy('first_name', 'asc')->get()
|
||||||
|
|
|
@ -52,7 +52,7 @@ class AccessoriesController extends Controller
|
||||||
public function getCreate(Request $request)
|
public function getCreate(Request $request)
|
||||||
{
|
{
|
||||||
// Show the page
|
// Show the page
|
||||||
$category_list = array('' => '') + DB::table('categories')->where('category_type', '=', 'accessory')->whereNull('deleted_at')->orderBy('name', 'ASC')->lists('name', 'id');
|
$category_list = Helper::categoryList('accessory');
|
||||||
$company_list = Helper::companyList();
|
$company_list = Helper::companyList();
|
||||||
$location_list = Helper::locationsList();
|
$location_list = Helper::locationsList();
|
||||||
return View::make('accessories/edit')
|
return View::make('accessories/edit')
|
||||||
|
@ -125,7 +125,7 @@ class AccessoriesController extends Controller
|
||||||
return redirect()->to('admin/accessories')->with('error', trans('general.insufficient_permissions'));
|
return redirect()->to('admin/accessories')->with('error', trans('general.insufficient_permissions'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$category_list = array('' => '') + DB::table('categories')->where('category_type', '=', 'accessory')->whereNull('deleted_at')->orderBy('name', 'ASC')->lists('name', 'id');
|
$category_list = Helper::categoryList('accessory');
|
||||||
$company_list = Helper::companyList();
|
$company_list = Helper::companyList();
|
||||||
$location_list = Helper::locationsList();
|
$location_list = Helper::locationsList();
|
||||||
|
|
||||||
|
|
|
@ -55,9 +55,9 @@ class AssetModelsController extends Controller
|
||||||
public function getCreate()
|
public function getCreate()
|
||||||
{
|
{
|
||||||
// Show the page
|
// Show the page
|
||||||
$depreciation_list = \App\Helpers\Helper::depreciationList();
|
$depreciation_list = Helper::depreciationList();
|
||||||
$manufacturer_list = \App\Helpers\Helper::manufacturerList();
|
$manufacturer_list = Helper::manufacturerList();
|
||||||
$category_list = \App\Helpers\Helper::categoryList();
|
$category_list = Helper::categoryList('asset');
|
||||||
return View::make('models/edit')
|
return View::make('models/edit')
|
||||||
->with('category_list', $category_list)
|
->with('category_list', $category_list)
|
||||||
->with('depreciation_list', $depreciation_list)
|
->with('depreciation_list', $depreciation_list)
|
||||||
|
@ -181,9 +181,9 @@ class AssetModelsController extends Controller
|
||||||
return redirect()->to('assets/models')->with('error', trans('admin/models/message.does_not_exist'));
|
return redirect()->to('assets/models')->with('error', trans('admin/models/message.does_not_exist'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$depreciation_list = \App\Helpers\Helper::depreciationList();
|
$depreciation_list = Helper::depreciationList();
|
||||||
$manufacturer_list = \App\Helpers\Helper::manufacturerList();
|
$manufacturer_list = Helper::manufacturerList();
|
||||||
$category_list = \App\Helpers\Helper::categoryList();
|
$category_list = Helper::categoryList('asset');
|
||||||
$view = View::make('models/edit', compact('model'));
|
$view = View::make('models/edit', compact('model'));
|
||||||
$view->with('category_list', $category_list);
|
$view->with('category_list', $category_list);
|
||||||
$view->with('depreciation_list', $depreciation_list);
|
$view->with('depreciation_list', $depreciation_list);
|
||||||
|
@ -371,9 +371,9 @@ class AssetModelsController extends Controller
|
||||||
$model->id = null;
|
$model->id = null;
|
||||||
|
|
||||||
// Show the page
|
// Show the page
|
||||||
$depreciation_list = array('' => 'Do Not Depreciate') + Depreciation::lists('name', 'id');
|
$depreciation_list = Helper::depreciationList();
|
||||||
$manufacturer_list = array('' => 'Select One') + Manufacturer::lists('name', 'id');
|
$manufacturer_list = Helper::manufacturerList();
|
||||||
$category_list = array('' => '') + DB::table('categories')->whereNull('deleted_at')->lists('name', 'id');
|
$category_list = Helper::categoryList('asset');
|
||||||
$view = View::make('models/edit');
|
$view = View::make('models/edit');
|
||||||
$view->with('category_list', $category_list);
|
$view->with('category_list', $category_list);
|
||||||
$view->with('depreciation_list', $depreciation_list);
|
$view->with('depreciation_list', $depreciation_list);
|
||||||
|
|
|
@ -107,7 +107,7 @@ class AssetsController extends Controller
|
||||||
$statuslabel_list = Helper::statusLabelList();
|
$statuslabel_list = Helper::statusLabelList();
|
||||||
$location_list = Helper::locationsList();
|
$location_list = Helper::locationsList();
|
||||||
$manufacturer_list = Helper::manufacturerList();
|
$manufacturer_list = Helper::manufacturerList();
|
||||||
$category_list = Helper::categoryList();
|
$category_list = Helper::categoryList('asset');
|
||||||
$supplier_list = Helper::suppliersList();
|
$supplier_list = Helper::suppliersList();
|
||||||
$company_list = Helper::companyList();
|
$company_list = Helper::companyList();
|
||||||
$assigned_to = Helper::usersList();
|
$assigned_to = Helper::usersList();
|
||||||
|
@ -269,11 +269,11 @@ class AssetsController extends Controller
|
||||||
$statuslabel_list = Helper::statusLabelList();
|
$statuslabel_list = Helper::statusLabelList();
|
||||||
$location_list = Helper::locationsList();
|
$location_list = Helper::locationsList();
|
||||||
$manufacturer_list = Helper::manufacturerList();
|
$manufacturer_list = Helper::manufacturerList();
|
||||||
$category_list = Helper::categoryList();
|
$category_list = Helper::categoryList('asset');
|
||||||
$supplier_list = Helper::suppliersList();
|
$supplier_list = Helper::suppliersList();
|
||||||
$company_list = Helper::companyList();
|
$company_list = Helper::companyList();
|
||||||
$assigned_to = Helper::usersList();
|
$assigned_to = Helper::usersList();
|
||||||
$statuslabel_types =Helper:: statusTypeList();
|
$statuslabel_types =Helper::statusTypeList();
|
||||||
|
|
||||||
return View::make('hardware/edit', compact('asset'))
|
return View::make('hardware/edit', compact('asset'))
|
||||||
->with('model_list', $model_list)
|
->with('model_list', $model_list)
|
||||||
|
@ -895,7 +895,7 @@ class AssetsController extends Controller
|
||||||
$statuslabel_list = Helper::statusLabelList();
|
$statuslabel_list = Helper::statusLabelList();
|
||||||
$location_list = Helper::locationsList();
|
$location_list = Helper::locationsList();
|
||||||
$manufacturer_list = Helper::manufacturerList();
|
$manufacturer_list = Helper::manufacturerList();
|
||||||
$category_list = Helper::categoryList();
|
$category_list = Helper::categoryList('asset');
|
||||||
$supplier_list = Helper::suppliersList();
|
$supplier_list = Helper::suppliersList();
|
||||||
$assigned_to =Helper::usersList();
|
$assigned_to =Helper::usersList();
|
||||||
$statuslabel_types = Helper::statusTypeList();
|
$statuslabel_types = Helper::statusTypeList();
|
||||||
|
|
|
@ -54,7 +54,7 @@ class ComponentsController extends Controller
|
||||||
public function getCreate()
|
public function getCreate()
|
||||||
{
|
{
|
||||||
// Show the page
|
// Show the page
|
||||||
$category_list = array('' => '') + DB::table('categories')->where('category_type', '=', 'component')->whereNull('deleted_at')->orderBy('name', 'ASC')->lists('name', 'id');
|
$category_list = Helper::categoryList('component');
|
||||||
$company_list = Helper::companyList();
|
$company_list = Helper::companyList();
|
||||||
$location_list = Helper::locationsList();
|
$location_list = Helper::locationsList();
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ class ComponentsController extends Controller
|
||||||
return redirect()->to('admin/components')->with('error', trans('general.insufficient_permissions'));
|
return redirect()->to('admin/components')->with('error', trans('general.insufficient_permissions'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$category_list = Helper::categoryList();
|
$category_list = Helper::categoryList('component');
|
||||||
$company_list = Helper::companyList();
|
$company_list = Helper::companyList();
|
||||||
$location_list = Helper::locationsList();
|
$location_list = Helper::locationsList();
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ class ConsumablesController extends Controller
|
||||||
public function getCreate()
|
public function getCreate()
|
||||||
{
|
{
|
||||||
// Show the page
|
// Show the page
|
||||||
$category_list = array('' => '') + DB::table('categories')->where('category_type', '=', 'consumable')->whereNull('deleted_at')->orderBy('name', 'ASC')->lists('name', 'id');
|
$category_list = Helper::categoryList('consumable');
|
||||||
$company_list = Helper::companyList();
|
$company_list = Helper::companyList();
|
||||||
$location_list = Helper::locationsList();
|
$location_list = Helper::locationsList();
|
||||||
$manufacturer_list = Helper::manufacturerList();
|
$manufacturer_list = Helper::manufacturerList();
|
||||||
|
@ -132,7 +132,7 @@ class ConsumablesController extends Controller
|
||||||
return redirect()->to('admin/consumables')->with('error', trans('general.insufficient_permissions'));
|
return redirect()->to('admin/consumables')->with('error', trans('general.insufficient_permissions'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$category_list = Helper::categoryList();
|
$category_list = Helper::categoryList('consumable');
|
||||||
$company_list = Helper::companyList();
|
$company_list = Helper::companyList();
|
||||||
$location_list = Helper::locationsList();
|
$location_list = Helper::locationsList();
|
||||||
$manufacturer_list = Helper::manufacturerList();
|
$manufacturer_list = Helper::manufacturerList();
|
||||||
|
|
|
@ -121,12 +121,13 @@
|
||||||
'quantity' => 'Quantity',
|
'quantity' => 'Quantity',
|
||||||
'ready_to_deploy' => 'Ready to Deploy',
|
'ready_to_deploy' => 'Ready to Deploy',
|
||||||
'recent_activity' => 'Recent Activity',
|
'recent_activity' => 'Recent Activity',
|
||||||
'remove_company' => 'Remove Company Association',
|
'remove_company' => 'Remove Company Association',
|
||||||
'reports' => 'Reports',
|
'reports' => 'Reports',
|
||||||
'requested' => 'Requested',
|
'requested' => 'Requested',
|
||||||
'save' => 'Save',
|
'save' => 'Save',
|
||||||
'select' => 'Select',
|
'select' => 'Select',
|
||||||
'search' => 'Search',
|
'search' => 'Search',
|
||||||
|
'select_category' => 'Select a Category',
|
||||||
'select_depreciation' => 'Select a Depreciation Type',
|
'select_depreciation' => 'Select a Depreciation Type',
|
||||||
'select_location' => 'Select a Location',
|
'select_location' => 'Select a Location',
|
||||||
'select_manufacturer' => 'Select a Manufacturer',
|
'select_manufacturer' => 'Select a Manufacturer',
|
||||||
|
@ -135,8 +136,8 @@
|
||||||
'select_user' => 'Select a User',
|
'select_user' => 'Select a User',
|
||||||
'select_date' => 'Select Date',
|
'select_date' => 'Select Date',
|
||||||
'select_statuslabel' => 'Select Status',
|
'select_statuslabel' => 'Select Status',
|
||||||
'select_company' => 'Select Company',
|
'select_company' => 'Select Company',
|
||||||
'select_asset' => 'Select Asset',
|
'select_asset' => 'Select Asset',
|
||||||
'settings' => 'Settings',
|
'settings' => 'Settings',
|
||||||
'sign_in' => 'Sign in',
|
'sign_in' => 'Sign in',
|
||||||
'site_name' => 'Site Name',
|
'site_name' => 'Site Name',
|
||||||
|
|
Loading…
Reference in a new issue