A free open source IT asset/license management system
Fix bulk actions with new bootstrap tables checkboxes
snipeea3d45882d0d
diff --git a/app/Http/Controllers/AssetsController.php b/app/Http/Controllers/AssetsController.phpindex d9065aae52..64c5fe91c9 100755--- a/app/Http/Controllers/AssetsController.php+++ b/app/Http/Controllers/AssetsController.php@@ -1145,35 +1145,46 @@ class AssetsController extends Controller* @internal param int $assetId* @since [v2.0]*/- public function postBulkEdit()+ public function postBulkEdit(Request $request){$this->authorize('update', Asset::class);- if (!Input::has('edit_asset')) {++++ if (!$request->has('ids')) {return redirect()->back()->with('error', 'No assets selected');}- $asset_raw_array = Input::get('edit_asset');++ $asset_raw_array = $request->input('ids');foreach ($asset_raw_array as $asset_id => $value) {$asset_ids[] = $asset_id;}- if (Input::has('bulk_actions')) {- // Create labels- if (Input::get('bulk_actions')=='labels') {++ if ($request->has('bulk_actions')) {++ if ($request->input('bulk_actions')=='labels') {+$count = 0;- return View::make('hardware/labels')->with('assets', Asset::find($asset_ids))->with('settings', Setting::getSettings())->with('count', $count)->with(- 'settings',+ return View::make('hardware/labels')+ ->with('assets', Asset::find($asset_ids))+ ->with('settings', Setting::getSettings())+ ->with('count', $count)+ ->with('settings',Setting::getSettings());- } elseif (Input::get('bulk_actions')=='delete') {++ } elseif ($request->input('bulk_actions')=='delete') {$assets = Asset::with('assignedTo', 'assetloc')->find($asset_ids);$assets->each(function($asset) {$this->authorize('delete',$asset);});return View::make('hardware/bulk-delete')->with('assets', $assets);+// Bulk edit- } elseif (Input::get('bulk_actions')=='edit') {+ } elseif ($request->input('bulk_actions')=='edit') {return View::make('hardware/bulk')- ->with('assets', request('edit_asset'))+ ->with('assets', request('ids'))->with('supplier_list', Helper::suppliersList())->with('statuslabel_list', Helper::statusLabelList())->with('location_list', Helper::locationsList())@@ -1198,8 +1209,8 @@ class AssetsController extends Controllerpublic function postBulkSave(){$this->authorize('update', Asset::class);- if (Input::has('bulk_edit')) {- $assets = Input::get('bulk_edit');+ if (Input::has('ids')) {+ $assets = Input::get('ids');if ((Input::has('purchase_date'))|| (Input::has('purchase_cost'))|| (Input::has('supplier_id'))diff --git a/app/Http/Controllers/UsersController.php b/app/Http/Controllers/UsersController.phpindex 0c4ea9a4ef..8a9ba4e13e 100755--- a/app/Http/Controllers/UsersController.php+++ b/app/Http/Controllers/UsersController.php@@ -408,14 +408,14 @@ class UsersController extends Controllerpublic function postBulkEdit(){$this->authorize('update', User::class);- if ((!Input::has('edit_user')) || (count(Input::has('edit_user')) == 0)) {+ if ((!Input::has('ids')) || (count(Input::has('ids')) == 0)) {return redirect()->back()->with('error', 'No users selected');} else {$statuslabel_list = Helper::statusLabelList();- $user_raw_array = array_keys(Input::get('edit_user'));+ $user_raw_array = array_keys(Input::get('ids'));$licenses = DB::table('license_seats')->whereIn('assigned_to', $user_raw_array)->get();- $users = User::whereIn('id', $user_raw_array)->with('groups', 'assets', 'licenses', 'accessories')->get();+ $users = User::whereIn('id', $user_raw_array)->with('groups', 'assignedAssets', 'licenses', 'accessories')->get();// $users = Company::scopeCompanyables($users)->get();return View::make('users/confirm-bulk-delete', compact('users', 'statuslabel_list'));@@ -433,13 +433,13 @@ class UsersController extends Controller{$this->authorize('update', User::class);- if ((!Input::has('edit_user')) || (count(Input::has('edit_user')) == 0)) {+ if ((!Input::has('ids')) || (count(Input::has('ids')) == 0)) {return redirect()->back()->with('error', 'No users selected');} elseif ((!Input::has('status_id')) || (count(Input::has('status_id')) == 0)) {return redirect()->route('users.index')->with('error', 'No status selected');} else {- $user_raw_array = Input::get('edit_user');+ $user_raw_array = Input::get('ids');$asset_array = array();if (($key = array_search(Auth::user()->id, $user_raw_array)) !== false) {