Merge pull request #16688 from 36864/patch-1
Fixes #14734: Only show signatures for the printed user
This commit is contained in:
commit
5bae74bc1b
3 changed files with 34 additions and 14 deletions
|
@ -594,18 +594,18 @@ class UsersController extends Controller
|
||||||
|
|
||||||
$user = User::where('id', $id)
|
$user = User::where('id', $id)
|
||||||
->with([
|
->with([
|
||||||
'assets.assetlog',
|
'assets.log' => fn($query) => $query->withTrashed()->where('target_type', User::class)->where('target_id', $id)->where('action_type', 'accepted'),
|
||||||
'assets.assignedAssets.assetlog',
|
'assets.assignedAssets.log' => fn($query) => $query->withTrashed()->where('target_type', User::class)->where('target_id', $id)->where('action_type', 'accepted'),
|
||||||
'assets.assignedAssets.defaultLoc',
|
'assets.assignedAssets.defaultLoc',
|
||||||
'assets.assignedAssets.location',
|
'assets.assignedAssets.location',
|
||||||
'assets.assignedAssets.model.category',
|
'assets.assignedAssets.model.category',
|
||||||
'assets.defaultLoc',
|
'assets.defaultLoc',
|
||||||
'assets.location',
|
'assets.location',
|
||||||
'assets.model.category',
|
'assets.model.category',
|
||||||
'accessories.assetlog',
|
'accessories.log' => fn($query) => $query->withTrashed()->where('target_type', User::class)->where('target_id', $id)->where('action_type', 'accepted'),
|
||||||
'accessories.category',
|
'accessories.category',
|
||||||
'accessories.manufacturer',
|
'accessories.manufacturer',
|
||||||
'consumables.assetlog',
|
'consumables.log' => fn($query) => $query->withTrashed()->where('target_type', User::class)->where('target_id', $id)->where('action_type', 'accepted'),
|
||||||
'consumables.category',
|
'consumables.category',
|
||||||
'consumables.manufacturer',
|
'consumables.manufacturer',
|
||||||
'licenses.category',
|
'licenses.category',
|
||||||
|
|
|
@ -343,4 +343,24 @@ trait Loggable
|
||||||
|
|
||||||
return $log;
|
return $log;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get latest signature from a specific user
|
||||||
|
*
|
||||||
|
* This just makes the print view a bit cleaner
|
||||||
|
* Returns the latest acceptance ActionLog that contains a signature
|
||||||
|
* from $user or null if there is none
|
||||||
|
*
|
||||||
|
* @param User $user
|
||||||
|
* @return null|Actionlog
|
||||||
|
**/
|
||||||
|
public function getLatestSignedAcceptance(User $user)
|
||||||
|
{
|
||||||
|
return $this->log->where('target_type', User::class)
|
||||||
|
->where('target_id', $user->id)
|
||||||
|
->where('action_type', 'accepted')
|
||||||
|
->where('accept_signature', '!=', null)
|
||||||
|
->sortByDesc('created_at')
|
||||||
|
->first();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,8 +147,8 @@
|
||||||
<td>
|
<td>
|
||||||
{{ Helper::getFormattedDateObject($asset->last_checkout, 'datetime', false) }}</td>
|
{{ Helper::getFormattedDateObject($asset->last_checkout, 'datetime', false) }}</td>
|
||||||
<td>
|
<td>
|
||||||
@if (($asset->assetlog->firstWhere('action_type', 'accepted')) && ($asset->assetlog->firstWhere('action_type', 'accepted')->accept_signature!=''))
|
@if ($asset->getLatestSignedAcceptance($show_user))
|
||||||
<img style="width:auto;height:100px;" src="{{ asset('/') }}display-sig/{{ $asset->assetlog->firstWhere('action_type', 'accepted')->accept_signature }}">
|
<img style="width:auto;height:100px;" src="{{ asset('/') }}display-sig/{{ $asset->getLatestSignedAcceptance($show_user)->accept_signature }}">
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -175,8 +175,8 @@
|
||||||
{{ Helper::getFormattedDateObject($asset->last_checkout, 'datetime', false) }}
|
{{ Helper::getFormattedDateObject($asset->last_checkout, 'datetime', false) }}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@if (($asset->assetlog->firstWhere('action_type', 'accepted')) && ($asset->assetlog->firstWhere('action_type', 'accepted')->accept_signature!=''))
|
@if ($asset->getLatestSignedAcceptance($show_user))
|
||||||
<img style="width:auto;height:100px;" src="{{ asset('/') }}display-sig/{{ $asset->assetlog->firstWhere('action_type', 'accepted')->accept_signature }}">
|
<img style="width:auto;height:100px;" src="{{ asset('/') }}display-sig/{{ $asset->getLatestSignedAcceptance($show_user)->accept_signature }}">
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -243,8 +243,8 @@
|
||||||
{{ Helper::getFormattedDateObject($license->pivot->updated_at, 'datetime', false) }}
|
{{ Helper::getFormattedDateObject($license->pivot->updated_at, 'datetime', false) }}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@if (($license->assetlog->firstWhere('action_type', 'accepted')) && ($license->assetlog->firstWhere('action_type', 'accepted')->accept_signature!=''))
|
@if ($license->getLatestSignedAcceptance($show_user))
|
||||||
<img style="width:auto;height:100px;" src="{{ asset('/') }}display-sig/{{ $license->assetlog->firstWhere('action_type', 'accepted')->accept_signature }}">
|
<img style="width:auto;height:100px;" src="{{ asset('/') }}display-sig/{{ $license->getLatestSignedAcceptance($show_user)->accept_signature }}">
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -308,8 +308,8 @@
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
@if (($accessory->assetlog->first()) && ($accessory->assetlog->first()->accept_signature!=''))
|
@if ($accessory->getLatestSignedAcceptance($show_user))
|
||||||
<img style="width:auto;height:100px;" src="{{ asset('/') }}display-sig/{{ $accessory->assetlog->first()->accept_signature }}">
|
<img style="width:auto;height:100px;" src="{{ asset('/') }}display-sig/{{ $accessory->getLatestSignedAcceptance($show_user)->accept_signature }}">
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -373,8 +373,8 @@
|
||||||
{{ Helper::getFormattedDateObject($consumable->pivot->created_at, 'datetime', false) }}
|
{{ Helper::getFormattedDateObject($consumable->pivot->created_at, 'datetime', false) }}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@if (($consumable->assetlog->first()) && ($consumable->assetlog->first()->accept_signature!=''))
|
@if ($consumable->getLatestSignedAcceptance($show_user))
|
||||||
<img style="width:auto;height:100px;" src="{{ asset('/') }}display-sig/{{ $consumable->assetlog->first()->accept_signature }}">
|
<img style="width:auto;height:100px;" src="{{ asset('/') }}display-sig/{{ $consumable->getLatestSignedAcceptance($show_user)->accept_signature }}">
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
Loading…
Add table
Reference in a new issue