Added more ajax select2 boxes to checkouts, remove helper ->with() methods

This commit is contained in:
snipe
2017-10-26 03:43:28 -07:00
parent 82690e1fd7
commit ea07517ad5
15 changed files with 84 additions and 116 deletions
@@ -271,7 +271,7 @@ class AccessoriesController extends Controller
$this->authorize('checkout', $accessory);
// Get the dropdown of users and then pass it to the checkout view
return view('accessories/checkout', compact('accessory'))->with('users_list', Helper::usersList());
return view('accessories/checkout', compact('accessory'));
}
@@ -296,7 +296,7 @@ class AccessoriesController extends Controller
$this->authorize('checkout', $accessory);
if (!$user = User::find(Input::get('assigned_to'))) {
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.not_found'));
return redirect()->route('checkout/accessory', $accessory->id)->with('error', trans('admin/accessories/message.checkout.user_does_not_exist'));
}
// Update the accessory data
@@ -323,6 +323,7 @@ class AccessoriesController extends Controller
$data['note'] = $logaction->note;
$data['require_acceptance'] = $accessory->requireAcceptance();
// TODO: Port this to new mail notifications
if ((($accessory->requireAcceptance()=='1') || ($accessory->getEula())) && ($user->email!='')) {
Mail::send('emails.accept-accessory', $data, function ($m) use ($user) {
@@ -303,6 +303,9 @@ class AssetsController extends Controller
'image' => ($asset->getImageUrl()) ? $asset->getImageUrl() : null,
];
}
array_unshift($assets_array, ['id'=> '', 'text'=> trans('general.select_asset'), 'image' => null]);
$results = [
'items' => $assets_array,
'pagination' =>
@@ -175,6 +175,9 @@ class LocationsController extends Controller
'image' => ($location->image) ? url('/').'/uploads/locations/'.$location->image : null,
];
}
array_unshift($locations_array, ['id'=> '', 'text'=> trans('general.select_location'), 'image' => null]);
$results = [
'items' => $locations_array,
'pagination' =>
@@ -165,6 +165,8 @@ class UsersController extends Controller
'image' => ($user->present()->gravatar) ? $user->present()->gravatar : null,
];
}
array_unshift($users_array, ['id'=> '', 'text'=> trans('general.select_user'), 'image' => null]);
$results = [
'items' => $users_array,
'pagination' =>
+1 -4
View File
@@ -430,10 +430,7 @@ class AssetsController extends Controller
$this->authorize('checkout', $asset);
// Get the dropdown of users and then pass it to the checkout view
return view('hardware/checkout', compact('asset'))
->with('users_list', Helper::usersList())
->with('assets_list', Helper::detailedAssetList())
->with('locations_list', Helper::locationsList());
return view('hardware/checkout', compact('asset'));
}
/**
@@ -255,7 +255,7 @@ class ComponentsController extends Controller
return redirect()->route('components.index')->with('error', trans('admin/components/message.not_found'));
}
$this->authorize('checkout', $component);
return view('components/checkout', compact('component'))->with('assets_list', Helper::detailedAssetList());
return view('components/checkout', compact('component'));
}
/**
@@ -239,7 +239,7 @@ class ConsumablesController extends Controller
return redirect()->route('consumables.index')->with('error', trans('admin/consumables/message.does_not_exist'));
}
$this->authorize('checkout', $consumable);
return view('consumables/checkout', compact('consumable'))->with('users_list', Helper::usersList());
return view('consumables/checkout', compact('consumable'));
}
/**
@@ -265,7 +265,7 @@ class ConsumablesController extends Controller
// Check if the user exists
if (is_null($user = User::find($assigned_to))) {
// Redirect to the consumable management page with error
return redirect()->route('consumables.index')->with('error', trans('admin/consumables/message.user_does_not_exist'));
return redirect()->route('checkout/consumable', $consumable)->with('error', trans('admin/consumables/message.checkout.user_does_not_exist'));
}
// Update the consumable data
@@ -286,7 +286,7 @@ class ConsumablesController extends Controller
$data['note'] = $logaction->note;
$data['require_acceptance'] = $consumable->requireAcceptance();
if (($consumable->requireAcceptance()=='1') || ($consumable->getEula())) {
if ((($consumable->requireAcceptance()=='1') || ($consumable->getEula())) && $user->email!='') {
Mail::send('emails.accept-asset', $data, function ($m) use ($user) {
$m->to($user->email, $user->first_name . ' ' . $user->last_name);