Skip to content

A free open source IT asset/license management system

Added search/sort by Location OU, added to listing

snipe2ea805b7ed52
diff --git a/app/Http/Controllers/Api/LocationsController.php b/app/Http/Controllers/Api/LocationsController.php
index cd2917b4f3..c6fef93041 100644
--- a/app/Http/Controllers/Api/LocationsController.php
+++ b/app/Http/Controllers/Api/LocationsController.php
@@ -26,7 +26,7 @@ class LocationsController extends Controller
$allowed_columns = [
'id','name','address','address2','city','state','country','zip','created_at',
'updated_at','manager_id','image',
- 'assigned_assets_count','users_count','assets_count','currency'];
+ 'assigned_assets_count','users_count','assets_count','currency','ldap_ou'];
$locations = Location::with('parent', 'manager', 'children')->select([
'locations.id',
@@ -42,6 +42,7 @@ class LocationsController extends Controller
'locations.created_at',
'locations.updated_at',
'locations.image',
+ 'locations.ldap_ou',
'locations.currency'
])->withCount('assignedAssets as assigned_assets_count')
->withCount('assets as assets_count')
diff --git a/app/Http/Transformers/LocationsTransformer.php b/app/Http/Transformers/LocationsTransformer.php
index 92f5cc965d..2f7013b21a 100644
--- a/app/Http/Transformers/LocationsTransformer.php
+++ b/app/Http/Transformers/LocationsTransformer.php
@@ -47,6 +47,7 @@ class LocationsTransformer
'assets_count' => (int) $location->assets_count,
'users_count' => (int) $location->users_count,
'currency' => ($location->currency) ? e($location->currency) : null,
+ 'ldap_ou' => ($location->ldap_ou) ? e($location->ldap_ou) : null,
'created_at' => Helper::getFormattedDateObject($location->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($location->updated_at, 'datetime'),
'parent' => ($location->parent) ? [
diff --git a/app/Models/Location.php b/app/Models/Location.php
index dd1a8c5a43..fd7522c241 100755
--- a/app/Models/Location.php
+++ b/app/Models/Location.php
@@ -76,7 +76,7 @@ class Location extends SnipeModel
*
* @var array
*/
- protected $searchableAttributes = ['name', 'address', 'city', 'state', 'zip', 'created_at'];
+ protected $searchableAttributes = ['name', 'address', 'city', 'state', 'zip', 'created_at', 'ldap_ou'];
/**
* The relations and their attributes that should be included when searching the model.
diff --git a/app/Presenters/LocationPresenter.php b/app/Presenters/LocationPresenter.php
index 6a793d24cc..9a91e2af2a 100644
--- a/app/Presenters/LocationPresenter.php
+++ b/app/Presenters/LocationPresenter.php
@@ -123,7 +123,16 @@ class LocationPresenter extends Presenter
"switchable" => true,
"title" => trans('admin/locations/table.country'),
"visible" => false,
- ],[
+ ],
+ [
+ "field" => "ldap_ou",
+ "searchable" => true,
+ "sortable" => true,
+ "switchable" => true,
+ "title" => trans('admin/locations/table.ldap_ou'),
+ "visible" => false,
+ ],
+ [
"field" => "manager",
"searchable" => false,
"sortable" => true,
diff --git a/resources/macros/macros.php b/resources/macros/macros.php
index fc0f9990ad..410275b784 100644
--- a/resources/macros/macros.php
+++ b/resources/macros/macros.php
@@ -512,8 +512,8 @@ Form::macro('customfield_elements', function ($name = "customfield_elements", $s
'text' => 'Text Box',
'listbox' => 'List Box',
'textarea' => 'Textarea (multi-line) ',
- // 'checkbox' => 'Checkbox',
- // 'radio' => 'Radio Buttons',
+ 'checkbox' => 'Checkbox',
+ 'radio' => 'Radio Buttons',
);
$select = '<select name="'.$name.'" class="'.$class.'" style="width: 100%" aria-label="'.$name.'">';
diff --git a/resources/views/locations/view.blade.php b/resources/views/locations/view.blade.php
index d384304587..810635b871 100644
--- a/resources/views/locations/view.blade.php
+++ b/resources/views/locations/view.blade.php
@@ -141,12 +141,15 @@
@if (($location->city!='') || ($location->state!='') || ($location->zip!=''))
<li>{{ $location->city }} {{ $location->state }} {{ $location->zip }}</li>
@endif
- @if (($location->manager))
+ @if ($location->manager)
<li>{{ trans('admin/users/table.manager') }}: {!! $location->manager->present()->nameUrl() !!}</li>
@endif
- @if (($location->parent))
+ @if ($location->parent)
<li>{{ trans('admin/locations/table.parent') }}: {!! $location->parent->present()->nameUrl() !!}</li>
@endif
+ @if ($location->ldap_ou)
+ <li>{{ trans('admin/locations/table.ldap_ou') }}: {{ $location->ldap_ou }}</li>
+ @endif
</ul>
@if (($location->state!='') && ($location->country!='') && (config('services.google.maps_api_key')))