Make company field optional
Company field is now optional for the user, although still required in the controllers.
This commit is contained in:
@@ -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')) == '') {
|
||||
|
||||
@@ -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'));
|
||||
|
||||
@@ -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')) == '') {
|
||||
|
||||
@@ -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'));
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'select_company' => 'Select Company',
|
||||
);
|
||||
+12
-1
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Lang;
|
||||
|
||||
final class Company extends Elegant
|
||||
{
|
||||
protected $table = 'companies';
|
||||
@@ -9,6 +11,15 @@ final class Company extends Elegant
|
||||
|
||||
public static function getSelectList()
|
||||
{
|
||||
return array('' => '') + 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; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
<div class="form-group {{ $errors->has('company_id') ? ' has-error' : '' }}">
|
||||
<div class="col-md-3">
|
||||
{{ Form::label('company_id', Lang::get('general.company')) }}
|
||||
<i class='fa fa-asterisk'></i>
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
{{ Form::select('company_id', $company_list , Input::old('company_id', $accessory->company_id), array('class'=>'select2', 'style'=>'width:350px')) }}
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
<div class="form-group {{ $errors->has('company_id') ? ' has-error' : '' }}">
|
||||
<div class="col-md-3">
|
||||
{{ Form::label('company_id', Lang::get('general.company')) }}
|
||||
<i class='fa fa-asterisk'></i>
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
{{ Form::select('company_id', $company_list , Input::old('company_id', $consumable->company_id), array('class'=>'select2', 'style'=>'width:350px')) }}
|
||||
|
||||
@@ -125,7 +125,6 @@
|
||||
<div class="form-group {{ $errors->has('company_id') ? ' has-error' : '' }}">
|
||||
<div class="col-md-2 control-label">
|
||||
{{ Form::label('company_id', Lang::get('general.company')) }}
|
||||
<i class='fa fa-asterisk'></i>
|
||||
</div>
|
||||
<div class="col-md-7 col-sm-12">
|
||||
{{ Form::select('company_id', $company_list , Input::old('company_id', $asset->company_id), array('class'=>'select2', 'style'=>'min-width:350px')) }}
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
<div class="form-group {{ $errors->has('company_id') ? ' has-error' : '' }}">
|
||||
<div class="col-md-3 control-label">
|
||||
{{ Form::label('company_id', Lang::get('general.company')) }}
|
||||
<i class='fa fa-asterisk'></i>
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
{{ Form::select('company_id', $company_list , Input::old('company_id', $license->company_id), array('class'=>'select2', 'style'=>'min-width:350px')) }}
|
||||
|
||||
@@ -55,7 +55,6 @@
|
||||
<div class="form-group {{ $errors->has('company_id') ? 'has-error' : '' }}">
|
||||
<div class="col-md-3 control-label">
|
||||
{{ Form::label('company_id', Lang::get('general.company')) }}
|
||||
<i class='fa fa-asterisk'></i>
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
{{ Form::select('company_id', $company_list , Input::old('company_id', $user->company_id), array('class'=>'select2', 'style'=>'width:350px')) }}
|
||||
|
||||
Reference in New Issue
Block a user