diff --git a/app/Models/Location.php b/app/Models/Location.php index a85c8905e..07ca6c8a1 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/account/requestable-assets.blade.php b/resources/views/account/requestable-assets.blade.php index 4ed4ae274..27aad2c97 100644 --- a/resources/views/account/requestable-assets.blade.php +++ b/resources/views/account/requestable-assets.blade.php @@ -47,7 +47,9 @@ data-show-refresh="true" data-sort-order="asc" data-sort-name="name" - data-toolbar="#toolbar" + data-toolbar="#assetsBulkEditToolbar" + data-bulk-button-id="#bulkAssetEditButton" + data-bulk-form-id="#assetsBulkForm" id="assetsListingTable" class="table table-striped snipe-table" data-url="{{ route('api.assets.requestable', ['requestable' => true]) }}"> diff --git a/resources/views/components/index.blade.php b/resources/views/components/index.blade.php index 1b905ebff..203609dcf 100644 --- a/resources/views/components/index.blade.php +++ b/resources/views/components/index.blade.php @@ -21,7 +21,6 @@
- {{ Form::open([ - 'method' => 'POST', - 'route' => ['hardware/bulkedit'], - 'class' => 'form-inline', - 'id' => 'bulkForm']) }} + @include('partials.asset-bulk-actions')
@@ -45,7 +41,9 @@ data-show-refresh="true" data-sort-order="asc" data-sort-name="name" - data-toolbar="#toolbar" + data-toolbar="#assetsBulkEditToolbar" + data-bulk-button-id="#bulkAssetEditButton" + data-bulk-form-id="#assetsBulkForm" id="assetsAuditListingTable" class="table table-striped snipe-table" data-url="{{ route('api.asset.to-audit', ['audit' => 'overdue']) }}" diff --git a/resources/views/hardware/index.blade.php b/resources/views/hardware/index.blade.php index 094c9fc1b..78abec91e 100755 --- a/resources/views/hardware/index.blade.php +++ b/resources/views/hardware/index.blade.php @@ -84,7 +84,9 @@ data-show-refresh="true" data-sort-order="asc" data-sort-name="name" - data-toolbar="#toolbar" + data-toolbar="#assetsBulkEditToolbar" + data-bulk-button-id="#bulkAssetEditButton" + data-bulk-form-id="#assetsBulkForm" id="assetsListingTable" class="table table-striped snipe-table" data-url="{{ route('api.assets.index', diff --git a/resources/views/locations/view.blade.php b/resources/views/locations/view.blade.php index 771538df5..cd203fb90 100644 --- a/resources/views/locations/view.blade.php +++ b/resources/views/locations/view.blade.php @@ -15,178 +15,218 @@
assets) && ($location->assets->count() > 0 )) ? ''.$location->assets->count().'' : '' !!} + + + + +
  • + + + + +
  • + +
  • + + + + +
  • + +
  • + + + + +
  • + + + +
    +
    +

    {{ trans('general.users') }}

    +
    + @include('partials.users-bulk-actions') +
    -
    - - - + + + -
    -
    -
    -

    {{ trans('general.assets') }}

    -
    -
    -
    +
    +

    {{ trans('general.assets') }}

    - - @include('partials.asset-bulk-actions') - -
    - - -
    + -
    -
    -
    +
    + -
    -
    -
    -

    {{ trans('general.accessories') }}

    -
    -
    -
    -
    - +
    +
    -
    + +
    +
    -
    - - -
    -
    -
    -

    {{ trans('general.consumables') }}

    -
    -
    -
    -
    +
    +

    {{ trans('general.consumables') }}

    - $location->id]) }}" + data-export-options='{ "fileName": "export-locations-{{ str_slug($location->name) }}-consumables-{{ date('Y-m-d') }}", "ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"] }'> -
    + -
    -
    -
    +
    + -
    -
    -
    +

    {{ trans('general.components') }}

    -
    -
    -
    -
    +
    - $location->id])}}" + data-export-options='{ "fileName": "export-locations-{{ str_slug($location->name) }}-components-{{ date('Y-m-d') }}", "ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"] }'> -
    -
    -
    -
    - + +
    +
    + +
    diff --git a/resources/views/models/index.blade.php b/resources/views/models/index.blade.php index bcc1d5f6f..8cda15ca4 100755 --- a/resources/views/models/index.blade.php +++ b/resources/views/models/index.blade.php @@ -35,22 +35,23 @@
    + {{ Form::open([ 'method' => 'POST', 'route' => ['models.bulkedit.index'], 'class' => 'form-inline', - 'id' => 'bulkForm']) }} + 'id' => 'modelsBulkForm']) }}
    @if (Request::get('status')!='deleted') -
    +
    - +
    @endif
    @@ -63,7 +64,9 @@ data-show-footer="true" data-side-pagination="server" data-show-columns="true" - data-toolbar="#toolbar" + data-toolbar="#modelsBulkEditToolbar" + data-bulk-button-id="#bulkModelsEditButton" + data-bulk-form-id="#modelsBulkForm" data-show-export="true" data-show-refresh="true" data-sort-order="asc" diff --git a/resources/views/models/view.blade.php b/resources/views/models/view.blade.php index 3a4ddca44..0027f61cd 100755 --- a/resources/views/models/view.blade.php +++ b/resources/views/models/view.blade.php @@ -56,7 +56,9 @@ data-search="true" data-side-pagination="server" data-show-columns="true" - data-toolbar="#toolbar" + data-toolbar="#assetsBulkEditToolbar" + data-bulk-button-id="#bulkAssetEditButton" + data-bulk-form-id="#assetsBulkForm" data-show-export="true" data-show-refresh="true" data-sort-order="asc" diff --git a/resources/views/partials/asset-bulk-actions.blade.php b/resources/views/partials/asset-bulk-actions.blade.php index f6678d447..3ee60cbc5 100644 --- a/resources/views/partials/asset-bulk-actions.blade.php +++ b/resources/views/partials/asset-bulk-actions.blade.php @@ -1,9 +1,9 @@ -
    +
    {{ Form::open([ 'method' => 'POST', 'route' => ['hardware/bulkedit'], 'class' => 'form-inline', - 'id' => 'bulkForm']) }} + 'id' => 'assetsBulkForm']) }}
    diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.php index 1dc35df6b..9a63ca58b 100644 --- a/resources/views/partials/bootstrap-table.blade.php +++ b/resources/views/partials/bootstrap-table.blade.php @@ -114,8 +114,12 @@ // These methods dynamically add/remove hidden input values in the bulk actions form $('.snipe-table').on('check.bs.table .btSelectItem', function (row, $element) { - $('#bulkEdit').removeAttr('disabled'); - $('#bulkEdit').prepend(''); + var buttonName = $(this).data('bulk-button-id'); + var formName = $(this).data('bulk-form-id'); + var tableId = $(this).data('id-table'); + + $(buttonName).removeAttr('disabled'); + $(formName).prepend(''); }); $('.snipe-table').on('uncheck.bs.table .btSelectItem', function (row, $element) { @@ -123,33 +127,42 @@ }); + $('.snipe-table').on('check-all.bs.table', function (event, rowsAfter, rowsBefore) { + + var buttonName = $(this).data('bulk-button-id'); + $(buttonName).removeAttr('disabled'); + var formName = $(this).data('bulk-form-id'); + var tableId = $(this).data('id-table'); + + for (var i in rowsAfter) { + $(formName).prepend(''); + } + }); + + // Handle whether or not the edit button should be disabled $('.snipe-table').on('uncheck.bs.table', function () { - if ($('.snipe-table').bootstrapTable('getSelections').length == 0) { - $('#bulkEdit').attr('disabled', 'disabled'); + + var buttonName = $(this).data('bulk-button-id'); + + if ($(this).bootstrapTable('getSelections').length == 0) { + $(buttonName).attr('disabled', 'disabled'); } }); $('.snipe-table').on('uncheck-all.bs.table', function (event, rowsAfter, rowsBefore) { - $('#bulkEdit').attr('disabled', 'disabled'); - //console.dir(rowsBefore); + + var buttonName = $(this).data('bulk-button-id'); + $(buttonName).attr('disabled', 'disabled'); + var tableId = $(this).data('id-table'); for (var i in rowsBefore) { - $( "#checkbox_" + rowsBefore[i].id).remove(); + $( tableId + "_checkbox_" + rowsBefore[i].id).remove(); } }); - $('.snipe-table').on('check-all.bs.table', function (event, rowsAfter, rowsBefore) { - - $('#bulkEdit').removeAttr('disabled'); - //console.dir(rowsAfter); - - for (var i in rowsAfter) { - // console.log(rowsAfter[i].id); - $('#bulkEdit').prepend(''); - } - }); + 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 000000000..016f54921 --- /dev/null +++ b/resources/views/partials/users-bulk-actions.blade.php @@ -0,0 +1,22 @@ +
    + {{ Form::open([ + 'method' => 'POST', + 'route' => ['users/bulkedit'], + 'class' => 'form-inline', + 'id' => 'usersBulkForm']) }} + +@if (request('status')!='deleted') + @can('delete', \App\Models\User::class) +
    + + + +
    + @endcan +@endif + {{ Form::close() }} +
    \ No newline at end of file diff --git a/resources/views/reports/asset.blade.php b/resources/views/reports/asset.blade.php index fd78405aa..b70d69efe 100644 --- a/resources/views/reports/asset.blade.php +++ b/resources/views/reports/asset.blade.php @@ -22,7 +22,6 @@
    - {{ Form::open([ - 'method' => 'POST', - 'route' => ['users/bulkedit'], - 'class' => 'form-inline', - 'id' => 'bulkForm']) }} - - @if (request('status')!='deleted') - @can('delete', \App\Models\User::class) -
    - - - -
    - @endcan - @endif + @include('partials.users-bulk-actions')