A free open source IT asset/license management system
Starter print template for all assets assigned to a user
snipe7efa7ec03f71
diff --git a/app/Http/Controllers/UsersController.php b/app/Http/Controllers/UsersController.phpindex d3ebe34316..4ce47490d7 100755--- a/app/Http/Controllers/UsersController.php+++ b/app/Http/Controllers/UsersController.php@@ -1147,4 +1147,21 @@ class UsersController extends Controllerreturn response()->json(['message' => trans('admin/settings/general.two_factor_reset_error')], 500);}}++ /**+ * LDAP form processing.+ *+ * @author Aladin Alaily+ * @since [v1.8]+ * @return \Illuminate\Http\RedirectResponse+ */+ public function print($id)+ {+ $user = User::where('id',$id)->withTrashed()->first();+ $assets = Asset::where('assigned_to', $id)->where('assigned_type', User::class)->with('model')->get();+ $licenses = $user->licenses()->get();+ return view('users/print')->with('assets', $assets)->with('licenses',$licenses);++ }+}diff --git a/resources/views/users/print.blade.php b/resources/views/users/print.blade.phpnew file mode 100644index 0000000000..e8c4c2df02--- /dev/null+++ b/resources/views/users/print.blade.php@@ -0,0 +1,86 @@+<!doctype html>+<html lang="en">+<head>+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>+ <title>Assigned to {{ $user->present()->fullName() }}</title>+ <style>+ body {+ font-family: "Arial, Helvetica", sans-serif;+ }+ table {+ border: solid #000;+ border-width: 1px 0 0 1px;+ width: 100%;+ }++ @page {+ size: A4;+ }+ th, td {+ border: solid #000;+ border-width: 0 1px 1px 0;+ padding: 3px;+ font-size: 14px;+ }+ </style>+</head>+<body>+<h3>Assigned to {{ $user->present()->fullName() }}</h3>++@if ($assets->count() > 0)+ @php+ $counter = 1;+ @endphp+ <h4>Assets</h4>+ <table>+ <th></th>+ <th>Asset Tag</th>+ <th>Name</th>+ <th>Category</th>+ <th>Model</th>+ <th>Checked Out</th>+ @foreach ($assets as $asset)++ <tr>+ <td>{{ $counter }}</td>+ <td>{{ $asset->asset_tag }}</td>+ <td>{{ $asset->name }}</td>+ <td>{{ $asset->model->category->name }}</td>+ <td>{{ $asset->model->name }}</td>+ <td>+ {{ $asset->last_checkout }}</td>+ </tr>+ @php+ $counter+++ @endphp+ @endforeach+ </table>+@endif++@if ($licenses->count() > 0)+ <h4>Licenses</h4>+ <table>+ <th></th>+ <th>Name</th>+ <th>Checked Out</th>+ @php+ $lcounter = 1;+ @endphp++ @foreach ($licenses as $license)++ <tr>+ <td>{{ $lcounter }}</td>+ <td>{{ $license->name }}</td>+ <td>{{ $license->created_at }}</td>+ </tr>+ @php+ $lcounter+++ @endphp+ @endforeach+ </table>+@endif+++</body>+</html>diff --git a/resources/views/users/view.blade.php b/resources/views/users/view.blade.phpindex c78c576559..a9fe3e3a4e 100755--- a/resources/views/users/view.blade.php+++ b/resources/views/users/view.blade.php@@ -216,6 +216,10 @@<div class="col-md-12" style="padding-top: 5px;"><a href="{{ route('clone/user', $user->id) }}" style="width: 100%;" class="btn btn-sm btn-default hidden-print">{{ trans('admin/users/general.clone') }}</a></div>+ <div class="col-md-12" style="padding-top: 5px;">+ <a href="{{ route('users.print', $user->id) }}" style="width: 100%;" class="btn btn-sm btn-default hidden-print">Print Inventory</a>+ </div>+@can('delete', $user)@if ($user->deleted_at=='')<div class="col-md-12" style="padding-top: 5px;">diff --git a/routes/web/users.php b/routes/web/users.phpindex 56d35cf81c..8e467f14d7 100644--- a/routes/web/users.php+++ b/routes/web/users.php@@ -17,6 +17,13 @@ Route::group([ 'prefix' => 'users', 'middleware' => ['auth']], function () {'{userId}/deletefile/{fileId}',[ 'as' => 'userfile.destroy', 'uses' => 'UsersController@getDeleteFile' ]);++ Route::get(+ '{userId}/print',+ [ 'as' => 'users.print', 'uses' => 'UsersController@print' ]+ );++Route::get('{userId}/showfile/{fileId}',[ 'as' => 'show/userfile', 'uses' => 'UsersController@displayFile' ]