|
1 | 1 | {{-- Mostra o icone do usuário e o respectivo card ao clicar --}} |
2 | 2 | <?php |
3 | 3 | $user_detail_id = 'user-detail-' . Str::random(5); |
| 4 | +$usar_foto = config('chamados.usar_foto'); |
| 5 | +$setor_vinculo = $user->setores()->wherePivot('funcao', '!=', 'Gerente')->first(); |
| 6 | +$setor_sigla = $setor_vinculo->sigla ?? 'sem setor'; |
| 7 | +$setor_funcao = $setor_vinculo->pivot->funcao ?? ''; |
| 8 | +
|
| 9 | +$vinculos = array_values(array_filter( |
| 10 | + \Uspdev\Replicado\Pessoa::vinculos($user->codpes), |
| 11 | + function ($vinculo) { |
| 12 | + return trim(explode('-', $vinculo)[0]) !== 'Servidor Designado'; # Exclui o vinculo com o tipo 'Servidor Designado' |
| 13 | + } |
| 14 | +)); |
| 15 | +$ultimo_vinculo = !empty($vinculos) ? end($vinculos) : null; # Nos testes, trazer o último vínculo funcionou bem |
| 16 | +$tipvinext = $ultimo_vinculo |
| 17 | + ? trim(explode('-', $ultimo_vinculo)[0]) |
| 18 | + : $setor_funcao; # Se não houver vínculo, usa a funcao do setor |
| 19 | +
|
| 20 | +if ($usar_foto) { |
| 21 | + $foto_base64 = \Uspdev\Wsfoto::obter((int) $user->codpes); |
| 22 | + $foto_src = 'data:image/png;base64,' . $foto_base64; |
| 23 | +} |
4 | 24 | ?> |
5 | 25 |
|
6 | 26 | <a class="btn btn-sm btn-light text-primary py-0" data-toggle="collapse" href="#{{ $user_detail_id }}" role="button" |
|
11 | 31 | <div class="collapse" id="{{ $user_detail_id }}"> |
12 | 32 | <div class="card card-body"> |
13 | 33 | <span class="text-dark"> |
| 34 | + @if ($usar_foto) |
| 35 | + <div class="mb-2"> |
| 36 | + <img src="{{ $foto_src }}" alt="Foto de {{ $user->name }}" class="img-thumbnail" style="max-width: 120px;"> |
| 37 | + </div> |
| 38 | + @endif |
14 | 39 | <div> |
15 | 40 | {{ $user->codpes }} - {{ $user->name }} |
16 | 41 | </div> |
17 | 42 | <div> |
18 | | - Setor: {{ $user->setores()->wherePivot('funcao', '!=', 'Gerente')->first()->sigla ?? 'sem setor' }} - |
19 | | - {{ $user->setores()->wherePivot('funcao', '!=', 'Gerente')->first()->pivot->funcao ?? '' }} |
| 43 | + Setor: {{ $setor_sigla }} - {{ $tipvinext }} |
20 | 44 | </div> |
21 | 45 | <div> |
22 | 46 | <i class="fas fa-envelope-square mr-2"></i> <a href="mailto:{{ $user->email }}">{{ $user->email }}</a> |
|
0 commit comments