diff --git a/app/controllers/admin/AccessoriesController.php b/app/controllers/admin/AccessoriesController.php index 4a5a2ef1ff..8e7a72747e 100755 --- a/app/controllers/admin/AccessoriesController.php +++ b/app/controllers/admin/AccessoriesController.php @@ -73,7 +73,7 @@ class AccessoriesController extends AdminController // Update the accessory data $accessory->name = e(Input::get('name')); $accessory->category_id = e(Input::get('category_id')); - $accessory->company_id = e(Input::get('company_id')); + $accessory->company_id = Company::getIdFromInput(Input::get('company_id')); $accessory->order_number = e(Input::get('order_number')); if (e(Input::get('purchase_date')) == '') { @@ -160,7 +160,7 @@ class AccessoriesController extends AdminController // Update the accessory data $accessory->name = e(Input::get('name')); $accessory->category_id = e(Input::get('category_id')); - $accessory->company_id = e(Input::get('company_id')); + $accessory->company_id = Company::getIdFromInput(Input::get('company_id')); $accessory->order_number = e(Input::get('order_number')); if (e(Input::get('purchase_date')) == '') { diff --git a/app/controllers/admin/AssetsController.php b/app/controllers/admin/AssetsController.php index 940c64b316..3e62ec2ab2 100755 --- a/app/controllers/admin/AssetsController.php +++ b/app/controllers/admin/AssetsController.php @@ -165,7 +165,7 @@ class AssetsController extends AdminController // Save the asset data $asset->name = e(Input::get('name')); $asset->serial = e(Input::get('serial')); - $asset->company_id = e(Input::get('company_id')); + $asset->company_id = Company::getIdFromInput(Input::get('company_id')); $asset->model_id = e(Input::get('model_id')); $asset->order_number = e(Input::get('order_number')); $asset->notes = e(Input::get('notes')); @@ -322,7 +322,7 @@ class AssetsController extends AdminController // Update the asset data $asset->name = e(Input::get('name')); $asset->serial = e(Input::get('serial')); - $asset->company_id = e(Input::get('company_id')); + $asset->company_id = Company::getIdFromInput(Input::get('company_id')); $asset->model_id = e(Input::get('model_id')); $asset->order_number = e(Input::get('order_number')); $asset->asset_tag = e(Input::get('asset_tag')); diff --git a/app/controllers/admin/ConsumablesController.php b/app/controllers/admin/ConsumablesController.php index 20b2a955e0..237962ca7f 100644 --- a/app/controllers/admin/ConsumablesController.php +++ b/app/controllers/admin/ConsumablesController.php @@ -74,7 +74,7 @@ class ConsumablesController extends AdminController // Update the consumable data $consumable->name = e(Input::get('name')); $consumable->category_id = e(Input::get('category_id')); - $consumable->company_id = e(Input::get('company_id')); + $consumable->company_id = Company::getIdFromInput(Input::get('company_id')); $consumable->order_number = e(Input::get('order_number')); if (e(Input::get('purchase_date')) == '') { @@ -161,7 +161,7 @@ class ConsumablesController extends AdminController // Update the consumable data $consumable->name = e(Input::get('name')); $consumable->category_id = e(Input::get('category_id')); - $consumable->company_id = e(Input::get('company_id')); + $consumable->company_id = Company::getIdFromInput(Input::get('company_id')); $consumable->order_number = e(Input::get('order_number')); if (e(Input::get('purchase_date')) == '') { diff --git a/app/controllers/admin/LicensesController.php b/app/controllers/admin/LicensesController.php index 7dfdc88911..dab8894590 100755 --- a/app/controllers/admin/LicensesController.php +++ b/app/controllers/admin/LicensesController.php @@ -128,7 +128,7 @@ class LicensesController extends AdminController $license->purchase_date = e(Input::get('purchase_date')); $license->purchase_order = e(Input::get('purchase_order')); $license->depreciation_id = e(Input::get('depreciation_id')); - $license->company_id = e(Input::get('company_id')); + $license->company_id = Company::getIdFromInput(Input::get('company_id')); $license->expiration_date = e(Input::get('expiration_date')); $license->user_id = Sentry::getId(); @@ -242,7 +242,7 @@ class LicensesController extends AdminController $license->notes = e(Input::get('notes')); $license->order_number = e(Input::get('order_number')); $license->depreciation_id = e(Input::get('depreciation_id')); - $license->company_id = e(Input::get('company_id')); + $license->company_id = Company::getIdFromInput(Input::get('company_id')); $license->purchase_order = e(Input::get('purchase_order')); $license->maintained = e(Input::get('maintained')); $license->reassignable = e(Input::get('reassignable')); diff --git a/app/controllers/admin/UsersController.php b/app/controllers/admin/UsersController.php index 12799f28f7..7db9741715 100755 --- a/app/controllers/admin/UsersController.php +++ b/app/controllers/admin/UsersController.php @@ -124,6 +124,8 @@ class UsersController extends AdminController { // Get the inputs, with some exceptions $inputs = Input::except('csrf_token', 'password_confirm', 'groups', 'email_user'); + $inputs['company_id'] = Company::getIdFromInput($inputs['company_id']); + // @TODO: Figure out WTF I need to do this. if ($inputs['manager_id'] == '') { unset($inputs['manager_id']); @@ -363,7 +365,7 @@ class UsersController extends AdminController { $user->jobtitle = Input::get('jobtitle'); $user->phone = Input::get('phone'); $user->location_id = Input::get('location_id'); - $user->company_id = Input::get('company_id'); + $user->company_id = Company::getIdFromInput(Input::get('company_id')); $user->manager_id = Input::get('manager_id'); $user->notes = Input::get('notes'); diff --git a/app/lang/en/admin/companies/general.php b/app/lang/en/admin/companies/general.php new file mode 100644 index 0000000000..a1fd775c56 --- /dev/null +++ b/app/lang/en/admin/companies/general.php @@ -0,0 +1,5 @@ + 'Select Company', +); diff --git a/app/models/Company.php b/app/models/Company.php index b616dc7663..4e967a2e32 100644 --- a/app/models/Company.php +++ b/app/models/Company.php @@ -1,5 +1,7 @@ '') + DB::table('companies')->orderBy('name', 'ASC')->lists('name', 'id'); + $select_company = Lang::get('admin/companies/general.select_company'); + return ['0' => $select_company] + DB::table('companies')->orderBy('name', 'ASC')->lists('name', 'id'); + } + + public static function getIdFromInput($input) + { + $escapedInput = e($input); + + if ($escapedInput == '0') { return NULL; } + else { return $escapedInput; } } } diff --git a/app/views/backend/accessories/edit.blade.php b/app/views/backend/accessories/edit.blade.php index 5f23291fc3..1d0e1464d0 100755 --- a/app/views/backend/accessories/edit.blade.php +++ b/app/views/backend/accessories/edit.blade.php @@ -39,7 +39,6 @@
{{ Form::label('company_id', Lang::get('general.company')) }} -
{{ Form::select('company_id', $company_list , Input::old('company_id', $accessory->company_id), array('class'=>'select2', 'style'=>'width:350px')) }} diff --git a/app/views/backend/consumables/edit.blade.php b/app/views/backend/consumables/edit.blade.php index 2e829f05f1..2864923c06 100644 --- a/app/views/backend/consumables/edit.blade.php +++ b/app/views/backend/consumables/edit.blade.php @@ -39,7 +39,6 @@
{{ Form::label('company_id', Lang::get('general.company')) }} -
{{ Form::select('company_id', $company_list , Input::old('company_id', $consumable->company_id), array('class'=>'select2', 'style'=>'width:350px')) }} diff --git a/app/views/backend/hardware/edit.blade.php b/app/views/backend/hardware/edit.blade.php index ff9cc06a2e..36d49efa84 100755 --- a/app/views/backend/hardware/edit.blade.php +++ b/app/views/backend/hardware/edit.blade.php @@ -125,7 +125,6 @@
{{ Form::label('company_id', Lang::get('general.company')) }} -
{{ Form::select('company_id', $company_list , Input::old('company_id', $asset->company_id), array('class'=>'select2', 'style'=>'min-width:350px')) }} diff --git a/app/views/backend/licenses/edit.blade.php b/app/views/backend/licenses/edit.blade.php index b3388c426b..e096f697ba 100755 --- a/app/views/backend/licenses/edit.blade.php +++ b/app/views/backend/licenses/edit.blade.php @@ -37,7 +37,6 @@
{{ Form::label('company_id', Lang::get('general.company')) }} -
{{ Form::select('company_id', $company_list , Input::old('company_id', $license->company_id), array('class'=>'select2', 'style'=>'min-width:350px')) }} diff --git a/app/views/backend/users/edit.blade.php b/app/views/backend/users/edit.blade.php index 1aac727b7d..c7aa657504 100755 --- a/app/views/backend/users/edit.blade.php +++ b/app/views/backend/users/edit.blade.php @@ -55,7 +55,6 @@
{{ Form::label('company_id', Lang::get('general.company')) }} -
{{ Form::select('company_id', $company_list , Input::old('company_id', $user->company_id), array('class'=>'select2', 'style'=>'width:350px')) }}