diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php index 26a998007..2dd323a10 100644 --- a/app/Http/Controllers/Api/UsersController.php +++ b/app/Http/Controllers/Api/UsersController.php @@ -519,10 +519,14 @@ class UsersController extends Controller { $this->authorize('view', User::class); $this->authorize('view', License::class); - $user = User::where('id', $id)->withTrashed()->first(); - $licenses = $user->licenses()->get(); + + if ($user = User::where('id', $id)->withTrashed()->first()) { + $licenses = $user->licenses()->get(); + return (new LicensesTransformer())->transformLicenses($licenses, $licenses->count()); + } + + return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/users/message.user_not_found', compact('id')))); - return (new LicensesTransformer())->transformLicenses($licenses, $licenses->count()); } /** diff --git a/app/Http/Controllers/LocationsController.php b/app/Http/Controllers/LocationsController.php index 668b8190b..9524abf6e 100755 --- a/app/Http/Controllers/LocationsController.php +++ b/app/Http/Controllers/LocationsController.php @@ -211,23 +211,35 @@ class LocationsController extends Controller public function print_assigned($id) { - $location = Location::where('id', $id)->first(); - $parent = Location::where('id', $location->parent_id)->first(); - $manager = User::where('id', $location->manager_id)->first(); - $users = User::where('location_id', $id)->with('company', 'department', 'location')->get(); - $assets = Asset::where('assigned_to', $id)->where('assigned_type', Location::class)->with('model', 'model.category')->get(); - return view('locations/print')->with('assets', $assets)->with('users', $users)->with('location', $location)->with('parent', $parent)->with('manager', $manager); + if ($location = Location::where('id', $id)->first()) { + $parent = Location::where('id', $location->parent_id)->first(); + $manager = User::where('id', $location->manager_id)->first(); + $users = User::where('location_id', $id)->with('company', 'department', 'location')->get(); + $assets = Asset::where('assigned_to', $id)->where('assigned_type', Location::class)->with('model', 'model.category')->get(); + return view('locations/print')->with('assets', $assets)->with('users', $users)->with('location', $location)->with('parent', $parent)->with('manager', $manager); + + } + + return redirect()->route('locations.index')->with('error', trans('admin/locations/message.does_not_exist')); + + + } public function print_all_assigned($id) { - $location = Location::where('id', $id)->first(); - $parent = Location::where('id', $location->parent_id)->first(); - $manager = User::where('id', $location->manager_id)->first(); - $users = User::where('location_id', $id)->with('company', 'department', 'location')->get(); - $assets = Asset::where('location_id', $id)->with('model', 'model.category')->get(); + if ($location = Location::where('id', $id)->first()) { + $parent = Location::where('id', $location->parent_id)->first(); + $manager = User::where('id', $location->manager_id)->first(); + $users = User::where('location_id', $id)->with('company', 'department', 'location')->get(); + $assets = Asset::where('location_id', $id)->with('model', 'model.category')->get(); + return view('locations/print')->with('assets', $assets)->with('users', $users)->with('location', $location)->with('parent', $parent)->with('manager', $manager); + + } + return redirect()->route('locations.index')->with('error', trans('admin/locations/message.does_not_exist')); + + - return view('locations/print')->with('assets', $assets)->with('users', $users)->with('location', $location)->with('parent', $parent)->with('manager', $manager); } } diff --git a/resources/lang/en/admin/locations/general.php b/resources/lang/en/admin/locations/general.php new file mode 100644 index 000000000..822fd66c8 --- /dev/null +++ b/resources/lang/en/admin/locations/general.php @@ -0,0 +1,9 @@ + 'Assigned to :location Location', + 'asset_management_system' => 'Asset Management System', + 'assigned_to' => 'Assigned To:', + 'manager' => 'Manager', + 'date' => 'Current Date:', +); \ No newline at end of file diff --git a/resources/views/locations/print.blade.php b/resources/views/locations/print.blade.php index b9c664e65..7fc02ea6e 100644 --- a/resources/views/locations/print.blade.php +++ b/resources/views/locations/print.blade.php @@ -156,34 +156,23 @@
{{ trans('admin/locations/table.signed_by_asset_auditor') }} | -___________________________ | -+ | ------------------------------------------------------ |
{{ trans('admin/locations/table.date') }} | -____________________ | +------------------------------ |
{{ trans('admin/locations/table.signed_by_finance_auditor') }} | -____________________ | -+ | ------------------------------------------------------ |
{{ trans('admin/locations/table.date') }} | -____________________ | +------------------------------ |
{{ trans('admin/locations/table.signed_by_location_manager') }} | -_______________________ | -+ | ------------------------------------------------------ |
{{ trans('admin/locations/table.date') }} | -____________________ | +------------------------------ |