diff --git a/app/Http/Controllers/Api/CompaniesController.php b/app/Http/Controllers/Api/CompaniesController.php index d6c8f6e76..72297440d 100644 --- a/app/Http/Controllers/Api/CompaniesController.php +++ b/app/Http/Controllers/Api/CompaniesController.php @@ -27,6 +27,8 @@ class CompaniesController extends Controller $allowed_columns = [ 'id', 'name', + 'phone', + 'fax', 'created_at', 'updated_at', 'users_count', diff --git a/app/Http/Controllers/Api/DepartmentsController.php b/app/Http/Controllers/Api/DepartmentsController.php index cab3991ba..ef988af59 100644 --- a/app/Http/Controllers/Api/DepartmentsController.php +++ b/app/Http/Controllers/Api/DepartmentsController.php @@ -30,6 +30,8 @@ class DepartmentsController extends Controller $departments = Company::scopeCompanyables(Department::select( 'departments.id', 'departments.name', + 'departments.phone', + 'departments.fax', 'departments.location_id', 'departments.company_id', 'departments.manager_id', diff --git a/app/Http/Controllers/Api/LocationsController.php b/app/Http/Controllers/Api/LocationsController.php index 4b1feee11..9037d3fc5 100644 --- a/app/Http/Controllers/Api/LocationsController.php +++ b/app/Http/Controllers/Api/LocationsController.php @@ -37,6 +37,8 @@ class LocationsController extends Controller 'locations.city', 'locations.state', 'locations.zip', + 'locations.phone', + 'locations.fax', 'locations.country', 'locations.parent_id', 'locations.manager_id', diff --git a/app/Http/Controllers/CompaniesController.php b/app/Http/Controllers/CompaniesController.php index 396ec5ef6..b02e3194f 100644 --- a/app/Http/Controllers/CompaniesController.php +++ b/app/Http/Controllers/CompaniesController.php @@ -60,6 +60,8 @@ final class CompaniesController extends Controller $company = new Company; $company->name = $request->input('name'); + $company->phone = $request->input('phone'); + $company->fax = $request->input('fax'); $company = $request->handleImages($company); @@ -111,6 +113,8 @@ final class CompaniesController extends Controller $this->authorize('update', $company); $company->name = $request->input('name'); + $company->phone = $request->input('phone'); + $company->fax = $request->input('fax'); $company = $request->handleImages($company); diff --git a/app/Http/Controllers/DepartmentsController.php b/app/Http/Controllers/DepartmentsController.php index 4b2b97ce7..2d456c0a4 100644 --- a/app/Http/Controllers/DepartmentsController.php +++ b/app/Http/Controllers/DepartmentsController.php @@ -170,6 +170,8 @@ class DepartmentsController extends Controller $department->manager_id = ($request->filled('manager_id') ? $request->input('manager_id') : null); $department->location_id = ($request->filled('location_id') ? $request->input('location_id') : null); $department->company_id = ($request->filled('company_id') ? $request->input('company_id') : null); + $department->phone = $request->input('phone'); + $department->fax = $request->input('fax'); $department = $request->handleImages($department); diff --git a/app/Http/Controllers/LocationsController.php b/app/Http/Controllers/LocationsController.php index 39b73a979..08dc38b3a 100755 --- a/app/Http/Controllers/LocationsController.php +++ b/app/Http/Controllers/LocationsController.php @@ -79,6 +79,8 @@ class LocationsController extends Controller $location->ldap_ou = $request->input('ldap_ou'); $location->manager_id = $request->input('manager_id'); $location->user_id = Auth::id(); + $location->phone = request('phone'); + $location->fax = request('fax'); $location = $request->handleImages($location); @@ -139,6 +141,8 @@ class LocationsController extends Controller $location->state = $request->input('state'); $location->country = $request->input('country'); $location->zip = $request->input('zip'); + $location->phone = request('phone'); + $location->fax = request('fax'); $location->ldap_ou = $request->input('ldap_ou'); $location->manager_id = $request->input('manager_id'); diff --git a/app/Http/Transformers/CompaniesTransformer.php b/app/Http/Transformers/CompaniesTransformer.php index 4f1de75de..486fb2167 100644 --- a/app/Http/Transformers/CompaniesTransformer.php +++ b/app/Http/Transformers/CompaniesTransformer.php @@ -26,6 +26,8 @@ class CompaniesTransformer $array = [ 'id' => (int) $company->id, 'name' => e($company->name), + 'phone' => ($company->phone!='') ? e($company->phone): null, + 'fax' => ($company->phone!='') ? e($company->fax): null, 'image' => ($company->image) ? Storage::disk('public')->url('companies/'.e($company->image)) : null, 'created_at' => Helper::getFormattedDateObject($company->created_at, 'datetime'), 'updated_at' => Helper::getFormattedDateObject($company->updated_at, 'datetime'), diff --git a/app/Http/Transformers/DepartmentsTransformer.php b/app/Http/Transformers/DepartmentsTransformer.php index 7a0d7647d..82adc9324 100644 --- a/app/Http/Transformers/DepartmentsTransformer.php +++ b/app/Http/Transformers/DepartmentsTransformer.php @@ -26,6 +26,8 @@ class DepartmentsTransformer $array = [ 'id' => (int) $department->id, 'name' => e($department->name), + 'phone' => ($department->phone!='') ? e($department->phone): null, + 'fax' => ($department->phone!='') ? e($department->fax): null, 'image' => ($department->image) ? Storage::disk('public')->url(app('departments_upload_url').e($department->image)) : null, 'company' => ($department->company) ? [ 'id' => (int) $department->company->id, diff --git a/app/Http/Transformers/LocationsTransformer.php b/app/Http/Transformers/LocationsTransformer.php index 22eade5d6..59bf525c4 100644 --- a/app/Http/Transformers/LocationsTransformer.php +++ b/app/Http/Transformers/LocationsTransformer.php @@ -43,6 +43,8 @@ class LocationsTransformer 'state' => ($location->state) ? e($location->state) : null, 'country' => ($location->country) ? e($location->country) : null, 'zip' => ($location->zip) ? e($location->zip) : null, + 'phone' => ($location->phone!='') ? e($location->phone): null, + 'fax' => ($location->phone!='') ? e($location->fax): null, 'assigned_assets_count' => (int) $location->assigned_assets_count, 'assets_count' => (int) $location->assets_count, 'rtd_assets_count' => (int) $location->rtd_assets_count, diff --git a/app/Models/Company.php b/app/Models/Company.php index 413011b9a..10b44077a 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -45,7 +45,7 @@ final class Company extends SnipeModel * * @var array */ - protected $searchableAttributes = ['name', 'created_at', 'updated_at']; + protected $searchableAttributes = ['name', 'phone', 'fax', 'created_at', 'updated_at']; /** * The relations and their attributes that should be included when searching the model. @@ -59,7 +59,11 @@ final class Company extends SnipeModel * * @var array */ - protected $fillable = ['name']; + protected $fillable = [ + 'name', + 'phone', + 'fax', + ]; private static function isFullMultipleCompanySupportEnabled() { diff --git a/app/Models/Department.php b/app/Models/Department.php index 74e2b23df..90fde79df 100644 --- a/app/Models/Department.php +++ b/app/Models/Department.php @@ -43,6 +43,8 @@ class Department extends SnipeModel protected $fillable = [ 'user_id', 'name', + 'phone', + 'fax', 'location_id', 'company_id', 'manager_id', @@ -56,7 +58,7 @@ class Department extends SnipeModel * * @var array */ - protected $searchableAttributes = ['name', 'notes']; + protected $searchableAttributes = ['name', 'notes', 'phone', 'fax']; /** * The relations and their attributes that should be included when searching the model. diff --git a/app/Models/Location.php b/app/Models/Location.php index 2f4e78dcc..145d6cef9 100755 --- a/app/Models/Location.php +++ b/app/Models/Location.php @@ -66,6 +66,8 @@ class Location extends SnipeModel 'state', 'country', 'zip', + 'phone', + 'fax', 'ldap_ou', 'currency', 'manager_id', @@ -80,7 +82,7 @@ class Location extends SnipeModel * * @var array */ - protected $searchableAttributes = ['name', 'address', 'city', 'state', 'zip', 'created_at', 'ldap_ou']; + protected $searchableAttributes = ['name', 'address', 'city', 'state', 'zip', 'created_at', 'ldap_ou', 'phone', 'fax']; /** * The relations and their attributes that should be included when searching the model. diff --git a/app/Presenters/CompanyPresenter.php b/app/Presenters/CompanyPresenter.php index a6aaebf7e..0ab3021b5 100644 --- a/app/Presenters/CompanyPresenter.php +++ b/app/Presenters/CompanyPresenter.php @@ -29,6 +29,22 @@ class CompanyPresenter extends Presenter 'title' => trans('admin/companies/table.name'), 'visible' => true, 'formatter' => 'companiesLinkFormatter', + ], [ + 'field' => 'phone', + 'searchable' => true, + 'sortable' => true, + 'switchable' => true, + 'title' => trans('admin/users/table.phone'), + 'visible' => false, + 'formatter' => 'phoneFormatter', + ], [ + 'field' => 'fax', + 'searchable' => true, + 'sortable' => true, + 'switchable' => true, + 'title' => trans('admin/suppliers/table.phone'), + 'visible' => false, + 'formatter' => 'phoneFormatter', ], [ 'field' => 'image', 'searchable' => false, diff --git a/app/Presenters/LocationPresenter.php b/app/Presenters/LocationPresenter.php index d4281839a..bf4ee27bb 100644 --- a/app/Presenters/LocationPresenter.php +++ b/app/Presenters/LocationPresenter.php @@ -141,6 +141,24 @@ class LocationPresenter extends Presenter 'title' => trans('admin/locations/table.country'), 'visible' => false, ], + [ + 'field' => 'phone', + 'searchable' => true, + 'sortable' => true, + 'switchable' => true, + 'title' => trans('admin/users/table.phone'), + 'visible' => false, + 'formatter' => 'phoneFormatter', + ], + [ + 'field' => 'fax', + 'searchable' => true, + 'sortable' => true, + 'switchable' => true, + 'title' => trans('admin/suppliers/table.fax'), + 'visible' => false, + 'formatter' => 'phoneFormatter', + ], [ 'field' => 'ldap_ou', 'searchable' => true, diff --git a/database/migrations/2023_07_06_092507_add_phone_fax_to_locations.php b/database/migrations/2023_07_06_092507_add_phone_fax_to_locations.php new file mode 100644 index 000000000..d6835ac29 --- /dev/null +++ b/database/migrations/2023_07_06_092507_add_phone_fax_to_locations.php @@ -0,0 +1,54 @@ +string('phone', 20)->after('zip')->nullable()->default(null); + $table->string('fax', 20)->after('zip')->nullable()->default(null); + }); + + Schema::table('companies', function (Blueprint $table) { + $table->string('phone', 20)->after('name')->nullable()->default(null); + $table->string('fax', 20)->after('name')->nullable()->default(null); + }); + + Schema::table('departments', function (Blueprint $table) { + $table->string('phone', 20)->after('name')->nullable()->default(null); + $table->string('fax', 20)->after('name')->nullable()->default(null); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('locations', function (Blueprint $table) { + $table->dropColumn('phone'); + $table->dropColumn('fax'); + }); + + Schema::table('companies', function (Blueprint $table) { + $table->dropColumn('phone'); + $table->dropColumn('fax'); + }); + + Schema::table('departments', function (Blueprint $table) { + $table->dropColumn('phone'); + $table->dropColumn('fax'); + }); + } +} diff --git a/resources/views/companies/edit.blade.php b/resources/views/companies/edit.blade.php index 6896cee97..d05a53709 100644 --- a/resources/views/companies/edit.blade.php +++ b/resources/views/companies/edit.blade.php @@ -9,6 +9,8 @@ {{-- Page content --}} @section('inputFields') @include ('partials.forms.edit.name', ['translated_name' => trans('admin/companies/table.name')]) +@include ('partials.forms.edit.phone') +@include ('partials.forms.edit.fax') @include ('partials.forms.edit.image-upload', ['image_path' => app('companies_upload_path')]) @stop diff --git a/resources/views/departments/edit.blade.php b/resources/views/departments/edit.blade.php index 9e6fd40e8..c1a2b38d5 100644 --- a/resources/views/departments/edit.blade.php +++ b/resources/views/departments/edit.blade.php @@ -16,6 +16,9 @@ @endif + @include ('partials.forms.edit.phone') + @include ('partials.forms.edit.fax') + @include ('partials.forms.edit.user-select', ['translated_name' => trans('admin/users/table.manager'), 'fieldname' => 'manager_id']) diff --git a/resources/views/locations/edit.blade.php b/resources/views/locations/edit.blade.php index d147cbc13..95ba24535 100755 --- a/resources/views/locations/edit.blade.php +++ b/resources/views/locations/edit.blade.php @@ -17,6 +17,9 @@ @include ('partials.forms.edit.user-select', ['translated_name' => trans('admin/users/table.manager'), 'fieldname' => 'manager_id']) +@include ('partials.forms.edit.phone') +@include ('partials.forms.edit.fax') +