This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Ambulatorio;
|
||||
|
||||
use App\Models\Cadastro\Especialidade;
|
||||
use App\Models\Cadastro\Estabelecimento\Infraestrutura;
|
||||
use App\Models\Cadastro\Estabelecimento\Unidade;
|
||||
use App\Models\Sigtap\Ocupacao;
|
||||
use App\Services\Ambulatorio\RelatorioQuantitativoAtendimentoService;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
|
||||
class RelatorioQuantitativoAtendimento implements FromView
|
||||
{
|
||||
private const TITLE = 'RELATÓRIO QUANTITATIVO DE ATENDIMENTO';
|
||||
private const VIEW = 'exportacoes.ambulatorio.relatorio-quantitativo-atendimento';
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$resultado = RelatorioQuantitativoAtendimentoService::index();
|
||||
$itens = $resultado['infraestruturas'];
|
||||
|
||||
$unidade = Unidade::find(request()->unidade_id);
|
||||
$infraestrutura = Infraestrutura::find(request()->infraestrutura_id);
|
||||
$ocupacao = Ocupacao::find(request()->ocupacao_id);
|
||||
$especialidade = Especialidade::find(request()->especialidade_id);
|
||||
|
||||
$data = [
|
||||
'title' => self::TITLE,
|
||||
'ano' => request()->periodo['ano'],
|
||||
'mes' => RelatorioQuantitativoAtendimentoService::getMeses()
|
||||
->where('value', request()->periodo['mes'])
|
||||
->first()['text'],
|
||||
'unidade' => $unidade->nome_fantasia ?? 'Todas',
|
||||
'infraestrutura' => $infraestrutura->nome ?? 'Todos',
|
||||
'ocupacao' => $ocupacao ? "{$ocupacao->codigo} - {$ocupacao->nome}" : 'Todas',
|
||||
'especialidade' => $especialidade->nome ?? 'Todas',
|
||||
'colunas' => collect(request()->columns),
|
||||
'colunasTotalizadores' => collect(request()->columns)
|
||||
->reject(fn ($c) => $c['key'] === 'usuario_nome')
|
||||
->values(),
|
||||
'itens' => $itens,
|
||||
'totalizadores' => $resultado['totalizadores'],
|
||||
];
|
||||
|
||||
return view(self::VIEW, $data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user