Skip to content

A free open source IT asset/license management system

Initial rework of locations display

snipe7c77e03c5ac2
diff --git a/app/Models/Location.php b/app/Models/Location.php
index a85c8905e0..07ca6c8a18 100755
--- a/app/Models/Location.php
+++ b/app/Models/Location.php
@@ -103,6 +103,7 @@ class Location extends SnipeModel
return $this->hasMany(\App\Models\User::class, 'location_id');
}
+
public function assets()
{
return $this->hasMany(\App\Models\Asset::class, 'location_id')
@@ -129,6 +130,23 @@ class Location extends SnipeModel
return $this->hasMany(\App\Models\Asset::class, 'rtd_location_id');
}
+ public function consumables()
+ {
+ return $this->hasMany(\App\Models\Consumable::class, 'location_id');
+ }
+
+ public function components()
+ {
+ return $this->hasMany(\App\Models\Component::class, 'location_id');
+ }
+
+ public function accessories()
+ {
+ return $this->hasMany(\App\Models\Accessory::class, 'location_id');
+ }
+
+
+
public function parent()
{
return $this->belongsTo(self::class, 'parent_id', 'id')
diff --git a/resources/views/locations/view.blade.php b/resources/views/locations/view.blade.php
index 771538df5e..cd9bafc733 100644
--- a/resources/views/locations/view.blade.php
+++ b/resources/views/locations/view.blade.php
@@ -15,178 +15,212 @@
<div class="row">
<div class="col-md-9">
-
- <div class="box box-default">
- <div class="box-header with-border">
- <div class="box-heading">
- <h2 class="box-title">{{ trans('general.users') }}</h2>
- </div>
- </div>
- <div class="box-body">
-
- <div class="table table-responsive">
-
- <table
- data-columns="{{ \App\Presenters\UserPresenter::dataTableLayout() }}"
- data-cookie-id-table="usersTable"
- data-pagination="true"
- data-id-table="usersTable"
- data-search="true"
- data-side-pagination="server"
- data-show-columns="true"
- data-show-export="true"
- data-show-refresh="true"
- data-sort-order="asc"
- id="usersTable"
- class="table table-striped snipe-table"
- data-url="{{route('api.users.index', ['location_id' => $location->id])}}"
- data-export-options='{
+ <div class="nav-tabs-custom">
+ <ul class="nav nav-tabs hidden-print">
+
+ <li class="active">
+ <a href="#users" data-toggle="tab">
+ <span class="hidden-lg hidden-md">
+ <i class="fas fa-info-circle fa-2x"></i>
+ </span>
+ <span class="hidden-xs hidden-sm">
+ {{ trans('general.users') }}
+ {!! (($location->users) && ($location->users->count() > 0 )) ? '<badge class="badge badge-secondary">'.$location->users->count().'</badge>' : '' !!}
+
+ </span>
+ </a>
+ </li>
+
+ <li>
+ <a href="#assets" data-toggle="tab">
+ <span class="hidden-lg hidden-md">
+ <i class="fas fa-barcode fa-2x" aria-hidden="true"></i>
+ </span>
+ <span class="hidden-xs hidden-sm">
+ {{ trans('general.assets') }}
+ {!! (($location->assets) && ($location->assets->count() > 0 )) ? '<badge class="badge badge-secondary">'.$location->assets->count().'</badge>' : '' !!}
+ </span>
+ </a>
+ </li>
+
+ <li>
+ <a href="#accessories" data-toggle="tab">
+ <span class="hidden-lg hidden-md">
+ <i class="fas fa-barcode fa-2x" aria-hidden="true"></i>
+ </span>
+ <span class="hidden-xs hidden-sm">
+ {{ trans('general.accessories') }}
+ {!! (($location->accessories) && ($location->accessories->count() > 0 )) ? '<badge class="badge badge-secondary">'.$location->accessories->count().'</badge>' : '' !!}
+ </span>
+ </a>
+ </li>
+
+ <li>
+ <a href="#consumables" data-toggle="tab">
+ <span class="hidden-lg hidden-md">
+ <i class="fas fa-barcode fa-2x" aria-hidden="true"></i>
+ </span>
+ <span class="hidden-xs hidden-sm">
+ {{ trans('general.consumables') }}
+ {!! (($location->consumables) && ($location->consumables->count() > 0 )) ? '<badge class="badge badge-secondary">'.$location->consumables->count().'</badge>' : '' !!}
+ </span>
+ </a>
+ </li>
+
+ <li>
+ <a href="#components" data-toggle="tab">
+ <span class="hidden-lg hidden-md">
+ <i class="fas fa-barcode fa-2x" aria-hidden="true"></i>
+ </span>
+ <span class="hidden-xs hidden-sm">
+ {{ trans('general.components') }}
+ {!! (($location->components) && ($location->components->count() > 0 )) ? '<badge class="badge badge-secondary">'.$location->components->count().'</badge>' : '' !!}
+ </span>
+ </a>
+ </li>
+ </ul>
+
+
+ <div class="tab-content">
+ <div class="tab-pane active" id="users">
+ <h2 class="box-title">{{ trans('general.users') }}</h2>
+ <div class="table table-responsive">
+ @include('partials.users-bulk-actions')
+ <table
+ data-columns="{{ \App\Presenters\UserPresenter::dataTableLayout() }}"
+ data-cookie-id-table="usersTable"
+ data-pagination="true"
+ data-id-table="usersTable"
+ data-search="true"
+ data-side-pagination="server"
+ data-show-columns="true"
+ data-show-export="true"
+ data-show-refresh="true"
+ data-sort-order="asc"
+ data-toolbar="#toolbar"
+ id="usersTable"
+ class="table table-striped snipe-table"
+ data-url="{{route('api.users.index', ['location_id' => $location->id])}}"
+ data-export-options='{
"fileName": "export-locations-{{ str_slug($location->name) }}-users-{{ date('Y-m-d') }}",
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
}'>
- </table>
- </div><!-- /.table-responsive -->
- </div><!-- /.box-body -->
- </div> <!--/.box-->
-
- <div class="box box-default">
- <div class="box-header with-border">
- <div class="box-heading">
- <h2 class="box-title">{{ trans('general.assets') }}</h2>
- </div>
- </div>
- <div class="box-body">
-
-
- @include('partials.asset-bulk-actions')
-
- <div class="table table-responsive">
-
- <table
- data-columns="{{ \App\Presenters\AssetPresenter::dataTableLayout() }}"
- data-cookie-id-table="assetsListingTable"
- data-pagination="true"
- data-id-table="assetsListingTable"
- data-search="true"
- data-side-pagination="server"
- data-show-columns="true"
- data-show-export="true"
- data-show-refresh="true"
- data-sort-order="asc"
- id="assetsListingTable"
- class="table table-striped snipe-table"
- data-url="{{route('api.assets.index', ['location_id' => $location->id]) }}"
- data-export-options='{
+ </table>
+ </div><!-- /.table-responsive -->
+ </div><!-- /.tab-pane -->
+
+ <div class="tab-pane" id="assets">
+ <h2 class="box-title">{{ trans('general.assets') }}</h2>
+
+ <div class="table table-responsive">
+ @include('partials.asset-bulk-actions')
+ <table
+ data-columns="{{ \App\Presenters\AssetPresenter::dataTableLayout() }}"
+ data-cookie-id-table="assetsListingTable"
+ data-pagination="true"
+ data-id-table="assetsListingTable"
+ data-search="true"
+ data-side-pagination="server"
+ data-show-columns="true"
+ data-show-export="true"
+ data-show-refresh="true"
+ data-sort-order="asc"
+ data-toolbar="#toolbar"
+ id="assetsListingTable"
+ class="table table-striped snipe-table"
+ data-url="{{route('api.assets.index', ['location_id' => $location->id]) }}"
+ data-export-options='{
"fileName": "export-locations-{{ str_slug($location->name) }}-assets-{{ date('Y-m-d') }}",
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
}'>
- </table>
-
- </div><!-- /.table-responsive -->
- </div><!-- /.box-body -->
- </div> <!--/.box-->
-
- <div class="box box-default">
- <div class="box-header with-border">
- <div class="box-heading">
- <h2 class="box-title">{{ trans('general.accessories') }}</h2>
- </div>
- </div>
- <div class="box-body">
- <div class="table table-responsive">
-
- <table
- data-columns="{{ \App\Presenters\AccessoryPresenter::dataTableLayout() }}"
- data-cookie-id-table="accessoriesListingTable"
- data-pagination="true"
- data-id-table="accessoriesListingTable"
- data-search="true"
- data-side-pagination="server"
- data-show-columns="true"
- data-show-export="true"
- data-show-refresh="true"
- data-sort-order="asc"
- id="accessoriesListingTable"
- class="table table-striped snipe-table"
- data-url="{{route('api.accessories.index', ['location_id' => $location->id]) }}"
- data-export-options='{
+ </table>
+
+ </div><!-- /.table-responsive -->
+ </div><!-- /.tab-pane -->
+
+
+
+ <div class="tab-pane" id="accessories">
+ <h2 class="box-title">{{ trans('general.accessories') }}</h2>
+ <div class="table table-responsive">
+ <table
+ data-columns="{{ \App\Presenters\AccessoryPresenter::dataTableLayout() }}"
+ data-cookie-id-table="accessoriesListingTable"
+ data-pagination="true"
+ data-id-table="accessoriesListingTable"
+ data-search="true"
+ data-side-pagination="server"
+ data-show-columns="true"
+ data-show-export="true"
+ data-show-refresh="true"
+ data-sort-order="asc"
+ id="accessoriesListingTable"
+ class="table table-striped snipe-table"
+ data-url="{{route('api.accessories.index', ['location_id' => $location->id]) }}"
+ data-export-options='{
"fileName": "export-locations-{{ str_slug($location->name) }}-accessories-{{ date('Y-m-d') }}",
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
}'>
- </table>
-
- </div><!-- /.table-responsive -->
- </div><!-- /.box-body -->
- </div> <!--/.box-->
-
- <div class="box box-default">
- <div class="box-header with-border">
- <div class="box-heading">
- <h2 class="box-title">{{ trans('general.consumables') }}</h2>
- </div>
- </div>
- <div class="box-body">
- <div class="table table-responsive">
-
- <table
- data-columns="{{ \App\Presenters\ConsumablePresenter::dataTableLayout() }}"
- data-cookie-id-table="consumablesListingTable"
- data-pagination="true"
- data-id-table="consumablesListingTable"
- data-search="true"
- data-side-pagination="server"
- data-show-columns="true"
- data-show-export="true"
- data-show-refresh="true"
- data-sort-order="asc"
- id="consumablesListingTable"
- class="table table-striped snipe-table"
- data-url="{{route('api.consumables.index', ['location_id' => $location->id]) }}"
- data-export-options='{
+ </table>
+ </div><!-- /.table-responsive -->
+ </div><!-- /.tab-pane -->
+
+
+ <div class="tab-pane" id="consumables">
+ <div class="table table-responsive">
+ <table
+ data-columns="{{ \App\Presenters\ConsumablePresenter::dataTableLayout() }}"
+ data-cookie-id-table="consumablesListingTable"
+ data-pagination="true"
+ data-id-table="consumablesListingTable"
+ data-search="true"
+ data-side-pagination="server"
+ data-show-columns="true"
+ data-show-export="true"
+ data-show-refresh="true"
+ data-sort-order="asc"
+ id="consumablesListingTable"
+ class="table table-striped snipe-table"
+ data-url="{{route('api.consumables.index', ['location_id' => $location->id]) }}"
+ data-export-options='{
"fileName": "export-locations-{{ str_slug($location->name) }}-consumables-{{ date('Y-m-d') }}",
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
}'>
- </table>
-
- </div><!-- /.table-responsive -->
- </div><!-- /.box-body -->
- </div> <!--/.box-->
-
- <div class="box box-default">
- <div class="box-header with-border">
- <div class="box-heading">
- <h2 class="box-title">{{ trans('general.components') }}</h2>
- </div>
- </div>
- <div class="box-body">
- <div class="table table-responsive">
-
- <table
- data-columns="{{ \App\Presenters\ComponentPresenter::dataTableLayout() }}"
- data-cookie-id-table="componentsTable"
- data-pagination="true"
- data-id-table="componentsTable"
- data-search="true"
- data-side-pagination="server"
- data-show-columns="true"
- data-show-export="true"
- data-show-refresh="true"
- data-sort-order="asc"
- id="componentsTable"
- class="table table-striped snipe-table"
- data-url="{{route('api.components.index', ['location_id' => $location->id])}}"
- data-export-options='{
+ </table>
+
+ </div><!-- /.table-responsive -->
+ </div><!-- /.tab-pane -->
+
+ <div class="tab-pane" id="components">
+
+ <div class="table table-responsive">
+
+ <table
+ data-columns="{{ \App\Presenters\ComponentPresenter::dataTableLayout() }}"
+ data-cookie-id-table="componentsTable"
+ data-pagination="true"
+ data-id-table="componentsTable"
+ data-search="true"
+ data-side-pagination="server"
+ data-show-columns="true"
+ data-show-export="true"
+ data-show-refresh="true"
+ data-sort-order="asc"
+ id="componentsTable"
+ class="table table-striped snipe-table"
+ data-url="{{route('api.components.index', ['location_id' => $location->id])}}"
+ data-export-options='{
"fileName": "export-locations-{{ str_slug($location->name) }}-components-{{ date('Y-m-d') }}",
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
}'>
- </table>
- </div><!-- /.table-responsive -->
- </div><!-- /.box-body -->
- </div> <!--/.box-->
-
+ </table>
+ </div><!-- /.table-responsive -->
+ </div><!-- /.tab-pane -->
+ </div><!--/.col-md-9-->
+ </div><!--/.col-md-9-->
</div><!--/.col-md-9-->
<div class="col-md-3">
diff --git a/resources/views/partials/asset-bulk-actions.blade.php b/resources/views/partials/asset-bulk-actions.blade.php
index 4a24a34ced..62b185a7b4 100644
--- a/resources/views/partials/asset-bulk-actions.blade.php
+++ b/resources/views/partials/asset-bulk-actions.blade.php
@@ -1,4 +1,4 @@
-<div id="toolbar">
+<div id="assets-toolbar">
{{ Form::open([
'method' => 'POST',
'route' => ['hardware/bulkedit'],
diff --git a/resources/views/partials/users-bulk-actions.blade.php b/resources/views/partials/users-bulk-actions.blade.php
new file mode 100644
index 0000000000..ab66462159
--- /dev/null
+++ b/resources/views/partials/users-bulk-actions.blade.php
@@ -0,0 +1,19 @@
+{{ Form::open([
+ 'method' => 'POST',
+ 'route' => ['users/bulkedit'],
+ 'class' => 'form-inline',
+ 'id' => 'bulkForm']) }}
+
+@if (request('status')!='deleted')
+ @can('delete', \App\Models\User::class)
+ <div id="users-toolbar">
+ <label for="bulk_actions" class="sr-only">{{ trans('general.bulk_actions') }}</label>
+ <select name="bulk_actions" class="form-control select2" style="width: 200px;" aria-label="bulk_actions">
+ <option value="delete">{!! trans('general.bulk_checkin_delete') !!}</option>
+ <option value="edit">{{ trans('general.bulk_edit') }}</option>
+ <option value="bulkpasswordreset">{{ trans('button.send_password_link') }}</option>
+ </select>
+ <button class="btn btn-default" id="bulkEdit" disabled>{{ trans('button.go') }}</button>
+ </div>
+ @endcan
+@endif
\ No newline at end of file
diff --git a/resources/views/users/index.blade.php b/resources/views/users/index.blade.php
index 82d3d81a87..f3a51a6a5d 100755
--- a/resources/views/users/index.blade.php
+++ b/resources/views/users/index.blade.php
@@ -38,26 +38,8 @@
<div class="col-md-12">
<div class="box box-default">
<div class="box-body">
- {{ Form::open([
- 'method' => 'POST',
- 'route' => ['users/bulkedit'],
- 'class' => 'form-inline',
- 'id' => 'bulkForm']) }}
-
- @if (request('status')!='deleted')
- @can('delete', \App\Models\User::class)
- <div id="toolbar">
- <label for="bulk_actions" class="sr-only">{{ trans('general.bulk_actions') }}</label>
- <select name="bulk_actions" class="form-control select2" style="width: 200px;" aria-label="bulk_actions">
- <option value="delete">{!! trans('general.bulk_checkin_delete') !!}</option>
- <option value="edit">{{ trans('general.bulk_edit') }}</option>
- <option value="bulkpasswordreset">{{ trans('button.send_password_link') }}</option>
- </select>
- <button class="btn btn-default" id="bulkEdit" disabled>{{ trans('button.go') }}</button>
- </div>
- @endcan
- @endif
+ @include('partials.users-bulk-actions')
<table
data-click-to-select="true"