Skip to content

A free open source IT asset/license management system

Added phone, fax to departments, locations, companies

snipe14c61e4c17bd
diff --git a/app/Http/Controllers/Api/CompaniesController.php b/app/Http/Controllers/Api/CompaniesController.php
index d6c8f6e76e..72297440dd 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 cab3991baa..ef988af597 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 4b1feee117..9037d3fc5b 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 396ec5ef68..b02e3194f9 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 4b2b97ce7f..2d456c0a4a 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 39b73a9797..08dc38b3ac 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 4f1de75dec..486fb21672 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 7a0d7647d1..82adc9324c 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 22eade5d6e..59bf525c4f 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 413011b9a7..10b44077ae 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 74e2b23df9..90fde79df4 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 2f4e78dcc7..145d6cef9a 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 a6aaebf7e4..0ab3021b54 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 d4281839a1..bf4ee27bba 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 0000000000..d6835ac295
--- /dev/null
+++ b/database/migrations/2023_07_06_092507_add_phone_fax_to_locations.php
@@ -0,0 +1,54 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddPhoneFaxToLocations extends Migration
+{
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+ Schema::table('locations', function (Blueprint $table) {
+ $table->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 6896cee972..d05a53709b 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 9e6fd40e80..c1a2b38d56 100644
--- a/resources/views/departments/edit.blade.php
+++ b/resources/views/departments/edit.blade.php
@@ -16,6 +16,9 @@
<input id="hidden_company_id" type="hidden" name="company_id" value="{{ Auth::user()->company_id }}">
@endif
+ @include ('partials.forms.edit.phone')
+ @include ('partials.forms.edit.fax')
+
<!-- Manager -->
@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 d147cbc138..95ba245359 100755
--- a/resources/views/locations/edit.blade.php
+++ b/resources/views/locations/edit.blade.php
@@ -17,6 +17,9 @@
<!-- Manager-->
@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')
+
<!-- Currency -->
<div class="form-group {{ $errors->has('currency') ? ' has-error' : '' }}">
<label for="currency" class="col-md-3 control-label">
diff --git a/resources/views/partials/forms/edit/fax.blade.php b/resources/views/partials/forms/edit/fax.blade.php
new file mode 100644
index 0000000000..6e8a1d7fd4
--- /dev/null
+++ b/resources/views/partials/forms/edit/fax.blade.php
@@ -0,0 +1,7 @@
+<div class="form-group {{ $errors->has('fax') ? ' has-error' : '' }}">
+ {{ Form::label('fax', trans('admin/suppliers/table.fax'), array('class' => 'col-md-3 control-label')) }}
+ <div class="col-md-7">
+ {{Form::text('fax', old('fax', $item->fax), array('class' => 'form-control')) }}
+ {!! $errors->first('fax', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
+ </div>
+</div>
\ No newline at end of file
diff --git a/resources/views/suppliers/edit.blade.php b/resources/views/suppliers/edit.blade.php
index aed15fedb1..2f5c7c236f 100755
--- a/resources/views/suppliers/edit.blade.php
+++ b/resources/views/suppliers/edit.blade.php
@@ -22,15 +22,7 @@
</div>
@include ('partials.forms.edit.phone')
-
-<div class="form-group {{ $errors->has('fax') ? ' has-error' : '' }}">
- {{ Form::label('fax', trans('admin/suppliers/table.fax'), array('class' => 'col-md-3 control-label')) }}
- <div class="col-md-7">
- {{Form::text('fax', old('fax', $item->fax), array('class' => 'form-control')) }}
- {!! $errors->first('fax', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
- </div>
-</div>
-
+@include ('partials.forms.edit.fax')
@include ('partials.forms.edit.email')
<div class="form-group {{ $errors->has('url') ? ' has-error' : '' }}">