
<form method="GET" action="<?php echo e(route('admin.indicadoresTi.index')); ?>" class="row g-2 mb-3 align-items-end"
    id="form-filtros-chamados">
    <div class="col-12 col-md-4">
        <label class="form-label visually-hidden" for="filtro-busca"><?php echo e(__('Buscar')); ?></label>
        <input type="text" id="filtro-busca" name="busca" class="form-control"
            placeholder="<?php echo e(__('Número ou cliente…')); ?>" value="<?php echo e($filterParams['busca'] ?? ''); ?>" autocomplete="off">
    </div>
    <div class="col-6 col-md-2">
        <label class="form-label visually-hidden" for="filtro-status"><?php echo e(__('Status')); ?></label>
        <select id="filtro-status" name="status" class="form-select">
            <option value=""><?php echo e(__('Todos os status')); ?></option>
            <?php $__currentLoopData = \App\Models\IndicadoresTi\Chamado::STATUS; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $valor => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <option value="<?php echo e($valor); ?>" <?php if(($filterParams['status'] ?? '') === $valor): echo 'selected'; endif; ?>><?php echo e(__($label)); ?></option>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </select>
    </div>
    <div class="col-6 col-md-2">
        <label class="form-label visually-hidden" for="filtro-prioridade"><?php echo e(__('Prioridade')); ?></label>
        <select id="filtro-prioridade" name="prioridade" class="form-select">
            <option value=""><?php echo e(__('Todas as prioridades')); ?></option>
            <?php $__currentLoopData = \App\Models\IndicadoresTi\Chamado::PRIORIDADE; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $valor => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <option value="<?php echo e($valor); ?>" <?php if(($filterParams['prioridade'] ?? '') === $valor): echo 'selected'; endif; ?>><?php echo e(__($label)); ?></option>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </select>
    </div>
    <div class="col-6 col-md-2">
        <label class="form-label visually-hidden" for="filtro-setor"><?php echo e(__('Setor')); ?></label>
        <select id="filtro-setor" name="setor_id" class="form-select">
            <option value=""><?php echo e(__('Todos os setores')); ?></option>
            <?php $__currentLoopData = $setores; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $setor): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <option value="<?php echo e($setor->id); ?>" <?php if((int) ($filterParams['setor_id'] ?? 0) === $setor->id): echo 'selected'; endif; ?>><?php echo e($setor->nome); ?></option>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </select>
    </div>
    <div class="col-6 col-md-2 d-flex gap-2">
        <button type="submit" class="btn btn-primary w-100">
            <i class="fa-solid fa-magnifying-glass me-1"></i><span class="d-none d-sm-inline"><?php echo e(__('Filtrar')); ?></span>
        </button>
        <a href="<?php echo e(route('admin.indicadoresTi.index')); ?>" class="btn btn-outline-secondary"
            title="<?php echo e(__('Limpar filtros')); ?>">
            <i class="fa-solid fa-xmark"></i>
        </a>
    </div>
</form>

<?php
    $theadChamados = [
        __('Número'),
        __('Solicitante'),
        __('Unidade'),
        __('Setor'),
        __('Assunto'),
        __('SubAssunto'),
        __('Status'),
        __('Prioridade'),
        __('Atendente'),
        __('Abertura'),
        __('Fechamento'),
        __('Tempo'),
        __('Ações'),
    ];
?>

<div class="card shadow-sm mb-4">
    <div class="card-header fw-bold bg-primary text-white d-flex justify-content-between align-items-center">
        <span><i class="fa-solid fa-user-tie me-2"></i><?php echo e(__('Meus Chamados')); ?></span>
        <span class="badge bg-white text-primary"><?php echo e($meusChamados->total()); ?> <?php echo e(__('chamados')); ?></span>
    </div>
    <div class="card-body p-0">
        <?php ob_start(); ?>
        <?php $__empty_1 = true; $__currentLoopData = $meusChamados; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <?php echo $__env->make('admin.indicadoresTi._row_chamado', ['item' => $item, 'thead' => $theadChamados], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
            <tr>
                <td colspan="<?php echo e(count($theadChamados)); ?>" class="text-center text-muted py-4">
                    <i class="fa-solid fa-inbox fa-2x mb-2 d-block opacity-50"></i>
                    <?php echo e(__('Nenhum chamado encontrado.')); ?>

                </td>
            </tr>
        <?php endif; ?>
        <?php $body = ob_get_clean(); ?>
        <?php echo $__env->make('components.tables._table', [
            'thead' => $theadChamados,
            'body' => $body,
            'pagination' => $meusChamados->hasPages() ? $meusChamados->links() : null,
        ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
    </div>
</div>


<?php if(isset($outrosChamadosPorSetor)): ?>
    <div class="card shadow-sm">
        <div class="card-header fw-bold bg-secondary text-white d-flex align-items-center justify-content-between">
            <span><i class="fa-solid fa-building me-2"></i><?php echo e(__('Todos Chamados dos Setores')); ?></span>
        </div>
        <div class="card-body p-0">
            <?php $__empty_1 = true; $__currentLoopData = $outrosChamadosPorSetor; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $bloco): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <div class="border-bottom">
                    <button
                        class="btn btn-link w-100 text-start text-decoration-none d-flex justify-content-between align-items-center p-3 js-setor-toggle"
                        type="button" data-bs-target="#setor-<?php echo e($bloco['setor']->id); ?>" aria-expanded="false"
                        aria-controls="setor-<?php echo e($bloco['setor']->id); ?>">
                        <span><i class="fa-solid fa-folder-tree me-2"></i><?php echo e($bloco['setor']->nome); ?></span>
                        <div class="d-flex align-items-center gap-2">
                            <span class="badge bg-info text-dark">
                                <?php echo e($bloco['chamados']->total()); ?> <?php echo e(__('chamados')); ?>

                            </span>
                            <i class="fa-solid fa-chevron-down js-setor-chevron" style="transition:transform .3s"></i>
                        </div>
                    </button>
                    <div class="collapse" id="setor-<?php echo e($bloco['setor']->id); ?>">
                        <?php
                            $theadSetor = [
                                __('Número'),
                                __('Solicitante'),
                                __('Unidade'),
                                __('Assunto'),
                                __('Prioridade'),
                                __('Status'),
                                __('Atendente'),
                                __('Abertura'),
                                __('Fechamento'),
                                __('Ações'),
                            ];
                            ob_start();
                        ?>
                        <?php $__currentLoopData = $bloco['chamados']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr <?php if($item->isEmAndamento()): ?> class="table-warning" <?php endif; ?>>
                                <td class="fw-semibold"><?php echo e($item->numero); ?></td>
                                <td><?php echo e($item->solicitante_nome); ?></td>
                                <td><?php echo e($item->unidade->abbreviation ?? '—'); ?></td>
                                <td><?php echo e($item->assunto_nome ?? $item->assunto?->nome ?? '—'); ?></td>
                                <td>
                                    <span
                                        class="badge bg-<?php echo e(match ($item->prioridade) {'alta', 'critica' => 'danger','media' => 'warning','baixa' => 'success',default => 'secondary'}); ?>">
                                        <?php echo e(__(\App\Models\IndicadoresTi\Chamado::PRIORIDADE[$item->prioridade] ?? $item->prioridade)); ?>

                                    </span>
                                </td>
                                <td>
                                    <span
                                        class="badge bg-<?php echo e(match ($item->status) {'pendente' => 'warning','em_andamento' => 'info','atendido' => 'success',default => 'secondary'}); ?>">
                                        <?php echo e(__(\App\Models\IndicadoresTi\Chamado::STATUS[$item->status] ?? $item->status)); ?>

                                    </span>
                                </td>
                                <td><?php echo e($item->atendente->name ?? '—'); ?></td>
                                <td><?php echo e(optional($item->data_abertura)->format('d/m/Y H:i')); ?></td>
                                <td><?php echo e(optional($item->data_fechamento)->format('d/m/Y H:i')); ?></td>
                                <td>
                                    <a href="<?php echo e(route('admin.indicadoresTi.show', $item->id)); ?>"
                                        class="btn btn-sm btn-primary" title="<?php echo e(__('Abrir')); ?>">
                                        <i class="fa-solid fa-pen-to-square"></i>
                                    </a>
                                </td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        <?php $bodySetor = ob_get_clean(); ?>
                        <?php echo $__env->make('components.tables._table', [
                            'thead' => $theadSetor,
                            'body' => $bodySetor,
                            'pagination' => $bloco['chamados']->hasPages() ? $bloco['chamados']->links() : null,
                        ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                    </div>
                </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <div class="text-center text-muted py-4">
                    <i class="fa-solid fa-inbox fa-2x mb-2 d-block opacity-50"></i>
                    <?php echo e(__('Nenhum chamado de outros usuários no momento.')); ?>

                </div>
            <?php endif; ?>
        </div>
    </div>
<?php elseif(isset($outrosChamadosPorUnidade)): ?>
    <div class="card shadow-sm">
        <div class="card-header fw-bold bg-secondary text-white d-flex align-items-center justify-content-between">
            <span><i class="fa-solid fa-building me-2"></i><?php echo e(__('Outros Chamados')); ?></span>
        </div>
        <div class="card-body p-0">
            <?php $__empty_1 = true; $__currentLoopData = $outrosChamadosPorUnidade; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $bloco): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <div class="border-bottom">
                    <button
                        class="btn btn-link w-100 text-start text-decoration-none d-flex justify-content-between align-items-center p-3 js-setor-toggle"
                        type="button" data-bs-target="#unidade-<?php echo e($bloco['unidade']->id); ?>" aria-expanded="false"
                        aria-controls="unidade-<?php echo e($bloco['unidade']->id); ?>">
                        <span>
                            <i class="fa-solid fa-sitemap me-2"></i>
                            <?php echo e($bloco['unidade']->abbreviation); ?> — <?php echo e($bloco['unidade']->name); ?>

                        </span>
                        <div class="d-flex align-items-center gap-2">
                            <span class="badge bg-info text-dark">
                                <?php echo e($bloco['chamados']->total()); ?> <?php echo e(__('chamados')); ?>

                            </span>
                            <i class="fa-solid fa-chevron-down js-setor-chevron" style="transition:transform .3s"></i>
                        </div>
                    </button>
                    <div class="collapse" id="unidade-<?php echo e($bloco['unidade']->id); ?>">
                        <?php
                            $theadUnidade = [
                                __('Número'),
                                __('Solicitante'),
                                __('Setor'),
                                __('Assunto'),
                                __('Prioridade'),
                                __('Status'),
                                __('Atendente'),
                                __('Abertura'),
                                __('Fechamento'),
                                __('Ações'),
                            ];
                            ob_start();
                        ?>
                        <?php $__currentLoopData = $bloco['chamados']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr <?php if($item->isEmAndamento()): ?> class="table-warning" <?php endif; ?>>
                                <td class="fw-semibold"><?php echo e($item->numero); ?></td>
                                <td><?php echo e($item->solicitante_nome); ?></td>
                                <td><?php echo e($item->setor_nome ?? $item->setor?->nome ?? '—'); ?></td>
                                <td><?php echo e($item->assunto_nome ?? $item->assunto?->nome ?? '—'); ?></td>
                                <td>
                                    <span
                                        class="badge bg-<?php echo e(match ($item->prioridade) {'alta', 'critica' => 'danger','media' => 'warning','baixa' => 'success',default => 'secondary'}); ?>">
                                        <?php echo e(__(\App\Models\IndicadoresTi\Chamado::PRIORIDADE[$item->prioridade] ?? $item->prioridade)); ?>

                                    </span>
                                </td>
                                <td>
                                    <span
                                        class="badge bg-<?php echo e(match ($item->status) {'pendente' => 'warning','em_andamento' => 'info','atendido' => 'success',default => 'secondary'}); ?>">
                                        <?php echo e(__(\App\Models\IndicadoresTi\Chamado::STATUS[$item->status] ?? $item->status)); ?>

                                    </span>
                                </td>
                                <td><?php echo e($item->atendente->name ?? '—'); ?></td>
                                <td><?php echo e(optional($item->data_abertura)->format('d/m/Y H:i')); ?></td>
                                <td><?php echo e(optional($item->data_fechamento)->format('d/m/Y H:i')); ?></td>
                                <td>
                                    <a href="<?php echo e(route('admin.indicadoresTi.show', $item->id)); ?>"
                                        class="btn btn-sm btn-primary" title="<?php echo e(__('Abrir')); ?>">
                                        <i class="fa-solid fa-pen-to-square"></i>
                                    </a>
                                </td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        <?php $bodyUnidade = ob_get_clean(); ?>
                        <?php echo $__env->make('components.tables._table', [
                            'thead' => $theadUnidade,
                            'body' => $bodyUnidade,
                            'pagination' => $bloco['chamados']->hasPages() ? $bloco['chamados']->links() : null,
                        ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                    </div>
                </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <div class="text-center text-muted py-4">
                    <i class="fa-solid fa-inbox fa-2x mb-2 d-block opacity-50"></i>
                    <?php echo e(__('Nenhum chamado de outros usuários no momento.')); ?>

                </div>
            <?php endif; ?>
        </div>
    </div>
<?php else: ?>
    <div class="card shadow-sm">
        <div class="card-header fw-bold bg-secondary text-white d-flex justify-content-between align-items-center">
            <span><i class="fa-solid fa-users me-2"></i><?php echo e(__('Outros Chamados')); ?></span>
            <span class="badge bg-white text-secondary"><?php echo e($outrosChamados->total()); ?> <?php echo e(__('chamados')); ?></span>
        </div>
        <div class="card-body p-0">
            <?php ob_start(); ?>
            <?php $__empty_1 = true; $__currentLoopData = $outrosChamados; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <?php echo $__env->make('admin.indicadoresTi._row_chamado', ['item' => $item, 'thead' => $theadChamados], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <tr>
                    <td colspan="<?php echo e(count($theadChamados)); ?>" class="text-center text-muted py-4">
                        <i class="fa-solid fa-inbox fa-2x mb-2 d-block opacity-50"></i>
                        <?php echo e(__('Nenhum chamado de outros usuários.')); ?>

                    </td>
                </tr>
            <?php endif; ?>
            <?php $body = ob_get_clean(); ?>
            <?php echo $__env->make('components.tables._table', [
                'thead' => $theadChamados,
                'body' => $body,
                'pagination' => $outrosChamados->hasPages() ? $outrosChamados->links() : null,
            ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
        </div>
    </div>
<?php endif; ?>
<?php /**PATH /var/www/html/portal/resources/views/admin/indicadoresTi/list.blade.php ENDPATH**/ ?>