diff --git a/app/Http/Controllers/Assets/BulkAssetsController.php b/app/Http/Controllers/Assets/BulkAssetsController.php index 0e519251ad..4aede02a81 100644 --- a/app/Http/Controllers/Assets/BulkAssetsController.php +++ b/app/Http/Controllers/Assets/BulkAssetsController.php @@ -11,6 +11,7 @@ use App\Models\Setting; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Session; class BulkAssetsController extends Controller { @@ -30,9 +31,17 @@ class BulkAssetsController extends Controller $this->authorize('update', Asset::class); if (! $request->filled('ids')) { - return redirect()->back()->with('error', 'No assets selected'); + return redirect()->back()->with('error', trans('admin/hardware/message.update.no_assets_selected')); + } + // Figure out where we need to send the user after the update is complete, and store that in the session + $bulk_back_url = request()->headers->get('referer'); + session(['bulk_back_url' => $bulk_back_url]); + + \Log::debug('Back to url: '.$bulk_back_url); + + $asset_ids = array_values(array_unique($request->input('ids'))); @@ -73,10 +82,15 @@ class BulkAssetsController extends Controller { $this->authorize('update', Asset::class); - \Log::debug($request->input('ids')); + // Get the back url from the session and then destroy the session + $bulk_back_url = route('hardware'); + if ($request->session()->has('bulk_back_url')) { + $bulk_back_url = $request->session()->pull('bulk_back_url'); + } + if (! $request->filled('ids') || count($request->input('ids')) <= 0) { - return redirect()->route('hardware.index')->with('warning', trans('No assets selected, so nothing was updated.')); + return redirect($bulk_back_url)->with('error', trans('admin/hardware/message.update.no_assets_selected')); } $assets = array_keys($request->input('ids')); @@ -147,11 +161,13 @@ class BulkAssetsController extends Controller ->update($this->update_array); } // endforeach - return redirect()->route('hardware.index')->with('success', trans('admin/hardware/message.update.success')); - // no values given, nothing to update + return redirect($bulk_back_url)->with('success', trans('admin/hardware/message.update.success')); + + } - return redirect()->route('hardware.index')->with('warning', trans('admin/hardware/message.update.nothing_updated')); + // no values given, nothing to update + return redirect($bulk_back_url)->with('warning', trans('admin/hardware/message.update.nothing_updated')); } /** @@ -188,6 +204,11 @@ class BulkAssetsController extends Controller { $this->authorize('delete', Asset::class); + $bulk_back_url = route('hardware'); + if ($request->session()->has('bulk_back_url')) { + $bulk_back_url = $request->session()->pull('bulk_back_url'); + } + if ($request->filled('ids')) { $assets = Asset::find($request->get('ids')); foreach ($assets as $asset) { @@ -199,11 +220,11 @@ class BulkAssetsController extends Controller ->update($update_array); } // endforeach - return redirect()->to('hardware')->with('success', trans('admin/hardware/message.delete.success')); + return redirect($bulk_back_url)->with('success', trans('admin/hardware/message.delete.success')); // no values given, nothing to update } - return redirect()->to('hardware')->with('info', trans('admin/hardware/message.delete.nothing_updated')); + return redirect($bulk_back_url)->with('error', trans('admin/hardware/message.delete.nothing_updated')); } /** @@ -224,6 +245,9 @@ class BulkAssetsController extends Controller */ public function storeCheckout(Request $request) { + + $this->authorize('checkout', Asset::class); + try { $admin = Auth::user(); diff --git a/app/Presenters/AssetAuditPresenter.php b/app/Presenters/AssetAuditPresenter.php index 96cf89b841..4129ea9fd3 100644 --- a/app/Presenters/AssetAuditPresenter.php +++ b/app/Presenters/AssetAuditPresenter.php @@ -17,6 +17,10 @@ class AssetAuditPresenter extends Presenter public static function dataTableLayout() { $layout = [ + [ + 'field' => 'checkbox', + 'checkbox' => true, + ], [ 'field' => 'id', 'searchable' => false, diff --git a/resources/lang/am/admin/hardware/message.php b/resources/lang/am/admin/hardware/message.php index 8c8e323a73..1d8fb1874b 100644 --- a/resources/lang/am/admin/hardware/message.php +++ b/resources/lang/am/admin/hardware/message.php @@ -14,9 +14,10 @@ return [ ], 'update' => [ - 'error' => 'Asset was not updated, please try again', - 'success' => 'Asset updated successfully.', - 'nothing_updated' => 'No fields were selected, so nothing was updated.', + 'error' => 'Asset was not updated, please try again', + 'success' => 'Asset updated successfully.', + 'nothing_updated' => 'No fields were selected, so nothing was updated.', + 'no_assets_selected' => 'No assets were selected, so nothing was updated.', ], 'restore' => [ diff --git a/resources/lang/en/admin/hardware/message.php b/resources/lang/en/admin/hardware/message.php index 8c8e323a73..d2214ce00c 100644 --- a/resources/lang/en/admin/hardware/message.php +++ b/resources/lang/en/admin/hardware/message.php @@ -17,6 +17,7 @@ return [ 'error' => 'Asset was not updated, please try again', 'success' => 'Asset updated successfully.', 'nothing_updated' => 'No fields were selected, so nothing was updated.', + 'no_assets_selected' => 'No assets were selected, so nothing was updated.', ], 'restore' => [ diff --git a/resources/views/categories/view.blade.php b/resources/views/categories/view.blade.php index 304ccbe92b..2cf0960c9b 100644 --- a/resources/views/categories/view.blade.php +++ b/resources/views/categories/view.blade.php @@ -28,6 +28,9 @@
+ @if ($category->category_type=='asset') + @include('partials.asset-bulk-actions') + @endif
- {{ Form::open([ - 'method' => 'POST', - 'route' => ['hardware/bulkedit'], - 'class' => 'form-inline', - 'id' => 'bulkForm']) }} + + @include('partials.asset-bulk-actions') +
diff --git a/resources/views/hardware/bulk.blade.php b/resources/views/hardware/bulk.blade.php index b073a3b74c..b508db0b80 100755 --- a/resources/views/hardware/bulk.blade.php +++ b/resources/views/hardware/bulk.blade.php @@ -143,7 +143,7 @@ {{ trans('general.no')}}
diff --git a/resources/views/hardware/index.blade.php b/resources/views/hardware/index.blade.php index d4bd6fc88a..094c9fc1be 100755 --- a/resources/views/hardware/index.blade.php +++ b/resources/views/hardware/index.blade.php @@ -62,27 +62,10 @@
@if (Request::get('status')!='Deleted') - - - -
- {{ Form::open([ - 'method' => 'POST', - 'route' => ['hardware/bulkedit'], - 'class' => 'form-inline', - 'id' => 'bulkForm']) }} - - - - - - - {{ Form::close() }} -
+ + + + @include('partials.asset-bulk-actions') @endif diff --git a/resources/views/locations/view.blade.php b/resources/views/locations/view.blade.php index 90b100ee41..87eaf7c1ae 100644 --- a/resources/views/locations/view.blade.php +++ b/resources/views/locations/view.blade.php @@ -23,6 +23,7 @@
+
+ + + @include('partials.asset-bulk-actions') +
+ @include('partials.asset-bulk-actions') +
+
diff --git a/resources/views/models/view.blade.php b/resources/views/models/view.blade.php index 2f5c37044a..96fef52f58 100755 --- a/resources/views/models/view.blade.php +++ b/resources/views/models/view.blade.php @@ -42,21 +42,11 @@
@endif
-
-
- {{ Form::open([ - 'method' => 'POST', - 'route' => ['hardware/bulkedit'], - 'class' => 'form-inline', - 'id' => 'bulkForm']) }} -
- - -
+ + @include('partials.asset-bulk-actions') + + +
{{ Form::close() }} -
-
+
diff --git a/resources/views/partials/asset-bulk-actions.blade.php b/resources/views/partials/asset-bulk-actions.blade.php new file mode 100644 index 0000000000..4a24a34ced --- /dev/null +++ b/resources/views/partials/asset-bulk-actions.blade.php @@ -0,0 +1,22 @@ +
+ {{ Form::open([ + 'method' => 'POST', + 'route' => ['hardware/bulkedit'], + 'class' => 'form-inline', + 'id' => 'bulkForm']) }} + + + + + + + {{ Form::close() }} +
\ No newline at end of file diff --git a/resources/views/users/view.blade.php b/resources/views/users/view.blade.php index 3091858ba3..14fbd966df 100755 --- a/resources/views/users/view.blade.php +++ b/resources/views/users/view.blade.php @@ -61,7 +61,8 @@
  • + + @@ -71,7 +72,8 @@
  • + + @@ -81,7 +83,8 @@
  • + +
  • @@ -345,7 +348,7 @@
    - {{ trans('admin/users/table.employee_num') }}< + {{ trans('admin/users/table.employee_num') }}
    {{ $user->employee_num }} @@ -563,10 +566,13 @@
    -
    -
    + + @include('partials.asset-bulk-actions') + +
    +
    +