Skip to content

Commit

Permalink
Merge pull request #13277 from snipe/features/added_phone_fax_to_loca…
Browse files Browse the repository at this point in the history
…tions

Added phone, fax to departments, locations, companies
  • Loading branch information
snipe committed Jul 11, 2023
2 parents a5555a1 + 9dc7fc9 commit ba37a9d
Show file tree
Hide file tree
Showing 20 changed files with 138 additions and 13 deletions.
2 changes: 2 additions & 0 deletions app/Http/Controllers/Api/CompaniesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public function index(Request $request)
$allowed_columns = [
'id',
'name',
'phone',
'fax',
'created_at',
'updated_at',
'users_count',
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/Api/DepartmentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public function index(Request $request)
$departments = Company::scopeCompanyables(Department::select(
'departments.id',
'departments.name',
'departments.phone',
'departments.fax',
'departments.location_id',
'departments.company_id',
'departments.manager_id',
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/Api/LocationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public function index(Request $request)
'locations.city',
'locations.state',
'locations.zip',
'locations.phone',
'locations.fax',
'locations.country',
'locations.parent_id',
'locations.manager_id',
Expand Down
4 changes: 4 additions & 0 deletions app/Http/Controllers/CompaniesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public function store(ImageUploadRequest $request)

$company = new Company;
$company->name = $request->input('name');
$company->phone = $request->input('phone');
$company->fax = $request->input('fax');

$company = $request->handleImages($company);

Expand Down Expand Up @@ -111,6 +113,8 @@ public function update(ImageUploadRequest $request, $companyId)
$this->authorize('update', $company);

$company->name = $request->input('name');
$company->phone = $request->input('phone');
$company->fax = $request->input('fax');

$company = $request->handleImages($company);

Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/DepartmentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ public function update(ImageUploadRequest $request, $id)
$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);

Expand Down
4 changes: 4 additions & 0 deletions app/Http/Controllers/LocationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public function store(ImageUploadRequest $request)
$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);

Expand Down Expand Up @@ -139,6 +141,8 @@ public function update(ImageUploadRequest $request, $locationId = null)
$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');

Expand Down
2 changes: 2 additions & 0 deletions app/Http/Transformers/CompaniesTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public function transformCompany(Company $company = null)
$array = [
'id' => (int) $company->id,
'name' => e($company->name),
'phone' => ($company->phone!='') ? e($company->phone): null,
'fax' => ($company->fax!='') ? 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'),
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Transformers/DepartmentsTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public function transformDepartment(Department $department = null)
$array = [
'id' => (int) $department->id,
'name' => e($department->name),
'phone' => ($department->phone!='') ? e($department->phone): null,
'fax' => ($department->fax!='') ? 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,
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Transformers/LocationsTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public function transformLocation(Location $location = null)
'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->fax!='') ? 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,
Expand Down
8 changes: 6 additions & 2 deletions app/Models/Company.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -59,7 +59,11 @@ final class Company extends SnipeModel
*
* @var array
*/
protected $fillable = ['name'];
protected $fillable = [
'name',
'phone',
'fax',
];

private static function isFullMultipleCompanySupportEnabled()
{
Expand Down
4 changes: 3 additions & 1 deletion app/Models/Department.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class Department extends SnipeModel
protected $fillable = [
'user_id',
'name',
'phone',
'fax',
'location_id',
'company_id',
'manager_id',
Expand All @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion app/Models/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class Location extends SnipeModel
'state',
'country',
'zip',
'phone',
'fax',
'ldap_ou',
'currency',
'manager_id',
Expand All @@ -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.
Expand Down
16 changes: 16 additions & 0 deletions app/Presenters/CompanyPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ public static function dataTableLayout()
'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.fax'),
'visible' => false,
'formatter' => 'phoneFormatter',
], [
'field' => 'image',
'searchable' => false,
Expand Down
18 changes: 18 additions & 0 deletions app/Presenters/LocationPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,24 @@ public static function dataTableLayout()
'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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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');
});
}
}
2 changes: 2 additions & 0 deletions resources/views/companies/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions resources/views/departments/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])

Expand Down
3 changes: 3 additions & 0 deletions resources/views/locations/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
7 changes: 7 additions & 0 deletions resources/views/partials/forms/edit/fax.blade.php
Original file line number Diff line number Diff line change
@@ -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>
10 changes: 1 addition & 9 deletions resources/views/suppliers/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' : '' }}">
Expand Down

0 comments on commit ba37a9d

Please sign in to comment.