
<?php
    $statusBadge = [
        'not_started' => 'secondary',
        'planning'    => 'info',
        'in_progress' => 'primary',
        'validation'  => 'warning',
        'completed'   => 'success',
        'suspended'   => 'secondary',
        'cancelled'   => 'dark',
        'overdue'     => 'danger',
    ];

    $orderedRows = collect($rows ?? [])->map(fn ($row) => [
        'row' => $row,
        'depth' => empty($row['parent_id']) ? 0 : 1,
    ]);
?>

<div class="table-responsive">
    <table class="table table-sm table-hover align-middle cr-table">
        <thead class="table-light">
            <tr>
                <th scope="col"><?php echo e(__('Item')); ?></th>
                <th scope="col"><?php echo e(__('Atividades')); ?></th>
                <th scope="col"><?php echo e(__('Predecessora')); ?></th>
                <th scope="col" class="cr-col-progress"><?php echo e(__('%')); ?></th>
                <th scope="col" class="cr-col-status"><?php echo e(__('Status')); ?></th>
                <th scope="col"><?php echo e(__('Responsável')); ?></th>
                <th scope="col"><?php echo e(__('Início')); ?></th>
                <th scope="col"><?php echo e(__('Término')); ?></th>
                <th scope="col"><?php echo e(__('Descrição')); ?></th>
                <th scope="col"><?php echo e(__('Observação')); ?></th>
            </tr>
        </thead>
        <tbody>
            <?php $__empty_1 = true; $__currentLoopData = $orderedRows; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <?php
                    $row = $item['row'];
                    $depth = $item['depth'];
                    $dotStatus = $row['is_overdue'] ? 'overdue' : $row['status'];
                    $badge = $statusBadge[$dotStatus] ?? 'secondary';
                ?>
                <tr <?php if($row['is_overdue']): ?> class="table-danger" <?php endif; ?>>
                    <td class="text-nowrap"><code><?php echo e($row['code']); ?></code></td>
                    <td>
                        <span class="<?php if($depth > 0): ?> cr-depth-1 <?php endif; ?>">
                            <?php if($depth > 0): ?><i class="fa-solid fa-turn-up fa-rotate-90 text-muted me-1 small"></i><?php endif; ?>
                            <?php echo e($row['title']); ?>

                        </span>
                    </td>
                    <td class="small text-muted"><?php echo e($row['predecessors'] ?: '-'); ?></td>
                    <td>
                        <div class="d-flex align-items-center gap-2 cr-row-progress-wrap">
                            <div class="progress flex-grow-1 cr-row-progress" role="progressbar" aria-label="<?php echo e(__('Progresso (%)')); ?>" aria-valuenow="<?php echo e((int) $row['completion_percent']); ?>" aria-valuemin="0" aria-valuemax="100">
                                <div class="progress-bar cr-progress-bar-dynamic" style="--cr-w: <?php echo e($row['completion_percent']); ?>%;"></div>
                            </div>
                            <small class="text-muted text-nowrap cr-row-progress-label"><?php echo e((int) $row['completion_percent']); ?>%</small>
                        </div>
                    </td>
                    <td>
                        <span class="badge bg-<?php echo e($badge); ?> cr-status-badge"><?php echo e($row['status_label']); ?></span>
                        <?php if($row['is_overdue']): ?>
                            <span class="badge bg-danger mt-1"><?php echo e(__('Atrasado')); ?></span>
                        <?php endif; ?>
                    </td>
                    <td class="small">
                        <?php if (isset($component)) { $__componentOriginala0dea79f0b80f4bdbefb79367f67c23c = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginala0dea79f0b80f4bdbefb79367f67c23c = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.cronogramas.responsible-badges','data' => ['labels' => $row['responsible_labels'] ?? []]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('cronogramas.responsible-badges'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['labels' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($row['responsible_labels'] ?? [])]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginala0dea79f0b80f4bdbefb79367f67c23c)): ?>
<?php $attributes = $__attributesOriginala0dea79f0b80f4bdbefb79367f67c23c; ?>
<?php unset($__attributesOriginala0dea79f0b80f4bdbefb79367f67c23c); ?>
<?php endif; ?>
<?php if (isset($__componentOriginala0dea79f0b80f4bdbefb79367f67c23c)): ?>
<?php $component = $__componentOriginala0dea79f0b80f4bdbefb79367f67c23c; ?>
<?php unset($__componentOriginala0dea79f0b80f4bdbefb79367f67c23c); ?>
<?php endif; ?>
                    </td>
                    <td class="small text-nowrap"><?php echo e($row['planned_start_date'] ? \Carbon\Carbon::parse($row['planned_start_date'])->format('d/m/Y') : '-'); ?></td>
                    <td class="small text-nowrap"><?php echo e($row['planned_end_date'] ? \Carbon\Carbon::parse($row['planned_end_date'])->format('d/m/Y') : '-'); ?></td>
                    <td class="small text-start"><?php echo e($row['description'] ?: '-'); ?></td>
                    <td class="small text-start"><?php echo e($row['notes'] ?: '-'); ?></td>
                </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <tr>
                    <td colspan="10" class="text-center text-muted py-4"><?php echo e(__('Nenhuma atividade cadastrada.')); ?></td>
                </tr>
            <?php endif; ?>
        </tbody>
    </table>
</div>
<?php /**PATH /var/www/html/portal/resources/views/components/cronogramas/public-activities-table.blade.php ENDPATH**/ ?>