Added #2562 - print view of all assigned inventory

This commit is contained in:
snipe 2017-12-05 12:34:16 -08:00
parent c9e6a75ea8
commit a8cc29f062
3 changed files with 93 additions and 21 deletions

View file

@ -1157,10 +1157,12 @@ class UsersController extends Controller
*/
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();
$assets = Asset::where('assigned_to', $id)->where('assigned_type', User::class)->with('model', 'model.category')->get();
$licenses = $user->licenses()->get();
return view('users/print')->with('assets', $assets)->with('licenses',$licenses);
$accessories = $user->accessories()->get();
return view('users/print')->with('assets', $assets)->with('licenses',$licenses)->with('accessories', $accessories);
}

View file

@ -7,20 +7,20 @@
body {
font-family: "Arial, Helvetica", sans-serif;
}
table {
table.inventory {
border: solid #000;
border-width: 1px 0 0 1px;
border-width: 1px 1px 1px 1px;
width: 100%;
}
@page {
size: A4;
}
th, td {
table.inventory th, table.inventory td {
border: solid #000;
border-width: 0 1px 1px 0;
padding: 3px;
font-size: 14px;
font-size: 12px;
}
</style>
</head>
@ -31,14 +31,24 @@
@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>
<table class="inventory">
<thead>
<tr>
<th colspan="7">{{ trans('general.assets') }}</th>
</tr>
</thead>
<thead>
<tr>
<th style="width: 20px;"></th>
<th style="width: 20%;">Asset Tag</th>
<th style="width: 20%;">Name</th>
<th style="width: 10%;">Category</th>
<th style="width: 20%;">Model</th>
<th style="width: 20%;">Serial</th>
<th style="width: 10%;">Checked Out</th>
</tr>
</thead>
@foreach ($assets as $asset)
<tr>
@ -47,6 +57,7 @@
<td>{{ $asset->name }}</td>
<td>{{ $asset->model->category->name }}</td>
<td>{{ $asset->model->name }}</td>
<td>{{ $asset->serial }}</td>
<td>
{{ $asset->last_checkout }}</td>
</tr>
@ -58,11 +69,21 @@
@endif
@if ($licenses->count() > 0)
<h4>Licenses</h4>
<table>
<th></th>
<th>Name</th>
<th>Checked Out</th>
<br><br>
<table class="inventory">
<thead>
<tr>
<th colspan="4">{{ trans('general.licenses') }}</th>
</tr>
</thead>
<thead>
<tr>
<th style="width: 20px;"></th>
<th style="width: 40%;">Name</th>
<th style="width: 50%;">Serial/Product Key</th>
<th style="width: 10%;">Checked Out</th>
</tr>
</thead>
@php
$lcounter = 1;
@endphp
@ -72,7 +93,8 @@
<tr>
<td>{{ $lcounter }}</td>
<td>{{ $license->name }}</td>
<td>{{ $license->created_at }}</td>
<td>{{ $license->serial }}</td>
<td>{{ $license->assetlog->first()->created_at }}</td>
</tr>
@php
$lcounter++
@ -82,5 +104,53 @@
@endif
@if ($accessories->count() > 0)
<br><br>
<table class="inventory">
<thead>
<tr>
<th colspan="4">{{ trans('general.accessories') }}</th>
</tr>
</thead>
<thead>
<tr>
<th style="width: 20px;"></th>
<th style="width: 40%;">Name</th>
<th style="width: 50%;">Category</th>
<th style="width: 10%;">Checked Out</th>
</tr>
</thead>
@php
$acounter = 1;
@endphp
@foreach ($accessories as $accessory)
<tr>
<td>{{ $acounter }}</td>
<td>{{ $accessory->manufacturer->name }} {{ $accessory->name }} {{ $accessory->model_number }}</td>
<td>{{ $accessory->category->name }}</td>
<td>{{ $accessory->assetlog->first()->created_at }}</td>
</tr>
@php
$acounter++
@endphp
@endforeach
</table>
@endif
<br>
<br>
<br>
<table>
<tr>
<td>Signed Off By:</td>
<td>________________________________________________________</td>
<td></td>
<td>Date:</td>
<td>________________________________________________________</td>
</tr>
</table>
</body>
</html>

View file

@ -217,7 +217,7 @@
<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>
<a href="{{ route('users.print', $user->id) }}" style="width: 100%;" class="btn btn-sm btn-default hidden-print">Print All Assigned</a>
</div>
@can('delete', $user)