diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 38d4226dfa..665a455c81 100755 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -3,7 +3,10 @@ namespace App\Http\Controllers; use App\Http\Requests\ImageUploadRequest; +use App\Models\Asset; use App\Models\Setting; +use App\Models\User; +use App\Notifications\CurrentInventory; use Illuminate\Support\Facades\Auth; use Gate; use Illuminate\Http\Request; @@ -216,4 +219,47 @@ class ProfileController extends Controller $request->session()->put('menu_state', 'closed'); } } + + + /** + * Print inventory + * + * @author A. Gianotto + * @since [v6.0.12] + * @return Illuminate\View\View + */ + public function printInventory() + { + $show_user = Auth::user(); + + return view('users/print') + ->with('assets', Auth::user()->assets) + ->with('licenses', $show_user->licenses()->get()) + ->with('accessories', $show_user->accessories()->get()) + ->with('consumables', $show_user->consumables()->get()) + ->with('show_user', $show_user) + ->with('settings', Setting::getSettings()); + } + + /** + * Emails user a list of assigned assets + * + * @author A. Gianotto + * @since [v6.0.12] + * @return \Illuminate\Http\RedirectResponse + */ + public function emailAssetList() + { + + if (!$user = User::find(Auth::user()->id)) { + return redirect()->back() + ->with('error', trans('admin/users/message.user_not_found', ['id' => $id])); + } + if (empty($user->email)) { + return redirect()->back()->with('error', trans('admin/users/message.user_has_no_email')); + } + + $user->notify((new CurrentInventory($user))); + return redirect()->back()->with('success', trans('admin/users/general.user_notified')); + } } diff --git a/app/Http/Controllers/Users/UsersController.php b/app/Http/Controllers/Users/UsersController.php index 7cbbbdb10b..8582ace158 100755 --- a/app/Http/Controllers/Users/UsersController.php +++ b/app/Http/Controllers/Users/UsersController.php @@ -594,7 +594,7 @@ class UsersController extends Controller } /** - * LDAP form processing. + * Print inventory * * @author Aladin Alaily * @since [v1.8] diff --git a/resources/lang/en/general.php b/resources/lang/en/general.php index ba2cb77a6d..0f82492428 100644 --- a/resources/lang/en/general.php +++ b/resources/lang/en/general.php @@ -376,6 +376,8 @@ return [ 'assets_by_status' => 'Assets by Status', 'assets_by_status_type' => 'Assets by Status Type', 'pie_chart_type' => 'Dashboard Pie Chart Type', + 'hello_name' => 'Hello, :name!', + 'unaccepted_profile_warning' => 'You have :count items requiring acceptance. Click here to accept or decline them', ]; \ No newline at end of file diff --git a/resources/views/account/view-assets.blade.php b/resources/views/account/view-assets.blade.php index f5dc07eb84..a83be17755 100755 --- a/resources/views/account/view-assets.blade.php +++ b/resources/views/account/view-assets.blade.php @@ -2,338 +2,622 @@ {{-- Page title --}} @section('title') -{{ trans('general.viewassetsfor', array('name' => $user->present()->fullName())) }} +{{ trans('general.hello_name', array('name' => $user->present()->fullName())) }} @parent @stop {{-- Account page content --}} @section('content') -
+@if ($acceptances = \App\Models\CheckoutAcceptance::forUser(Auth::user())->pending()->count())
-
+
+ - @if ($user->id) -
-
-

{{ trans('admin/users/general.assets_user', array('name' => $user->first_name)) }}

-
-
- @endif + + + {{ trans('general.unaccepted_profile_warning', array('count' => $acceptances)) }} + + +
+
+@endif -
- -
+
+
+ +
+
+
+
+ +
+ + + + + + + + + + @foreach ($user->licenses as $license) + + + + + @endforeach - -
{{ trans('general.name') }}{{ trans('admin/hardware/form.serial') }}{{ trans('general.category') }}
{{ $license->name }} + @can('viewKeys', $license) + {{ $license->serial }} + @else + ------------ + @endcan + {{ $license->category->name }}
-
-
-
-
-
- -
-
-
- @if ($user->id) -
-
-

{{ trans('admin/users/general.software_user', array('name' => $user->first_name)) }}

+ + +
-
- @endif -
- +
+
+ + + + + + + + + + @foreach ($user->accessories as $accessory) + + + + + + @endforeach + +
{{ trans('general.name') }}{{ trans('general.purchase_cost') }}{{ trans('general.action') }}
{!! $accessory->name !!} + {!! Helper::formatCurrencyOutput($accessory->purchase_cost) !!} + + @can('checkin', $accessory) + {{ trans('general.checkin') }} + @endcan +
+
+
-
- - - - - - - - - - @foreach ($user->licenses as $license) - - - - - - @endforeach - -
{{ trans('general.name') }}{{ trans('admin/hardware/form.serial') }}{{ trans('general.category') }}
{{ $license->name }} - @can('viewKeys', $license) - {{ $license->serial }} - @else - ------------ - @endcan - {{ $license->category->name }}
-
-
-
-
- +
+
+ + + + + + + + + + + @foreach ($user->consumables as $consumable) + + + + + + + @endforeach + +
{{ trans('general.name') }}{{ trans('general.purchase_cost') }}{{ trans('general.date') }}{{ trans('general.notes') }}
{!! $consumable->name !!} + {!! Helper::formatCurrencyOutput($consumable->purchase_cost) !!} + {{ Helper::getFormattedDateObject($consumable->pivot->created_at, 'datetime', false) }}{{ $consumable->pivot->note }}
+
+
-
-
-
- @if ($user->id) -
-
-

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

-
-
- @endif - -
- -
- - - - - - - - - @foreach ($user->consumables as $consumable) - - - - - @endforeach - -
{{ trans('general.name') }}{{ trans('general.category') }}
{{ $consumable->name }}{{ (($consumable->category) ? $consumable->category->name : 'deleted category') }}
-
+
+
+
+
- - - - -
-
-
- @if ($user->id) -
-
-

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

-
-
- @endif -
- -
- - - - - - - - - @foreach ($user->accessories as $accessory) - - - - - @endforeach - -
{{ trans('general.name') }}{{ trans('general.category') }}
{{ $accessory->name }}{{ $accessory->category->name }}
-
- -
-
-
-
- -
-
-
- @if ($user->id) -
-
-

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

-
-
- @endif - -
-
- - - - - - - - - - -
{{ trans('general.date') }}{{ trans('general.admin') }}{{ trans('general.action') }}{{ trans('general.item') }}
-
- -
-
-
-
@stop diff --git a/routes/web.php b/routes/web.php index 249e02a367..4c52918f8e 100644 --- a/routes/web.php +++ b/routes/web.php @@ -279,6 +279,23 @@ Route::group(['prefix' => 'account', 'middleware' => ['auth']], function () { ->name('account.accept.item'); Route::post('accept/{id}', [Account\AcceptanceController::class, 'store']); + + Route::get( + 'print', + [ + ProfileController::class, + 'printInventory' + ] + )->name('profile.print'); + + Route::post( + 'email', + [ + ProfileController::class, + 'emailAssetList' + ] + )->name('profile.email_assets'); + }); Route::group(['middleware' => ['auth']], function () {