<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>تعديل الخطة الساعية - <?= e($date) ?><?php $__template->endSection(); ?>
<?php $__template->section('content'); ?>
<div class="container-fluid">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h4>الخطة الساعية ليوم <?= e($date) ?></h4>
        <a href="/facility-grids/<?= $grid_id ?>/plans/<?= $plan_id ?>/hours" class="btn btn-outline-secondary">← العودة</a>
    </div>

    <div class="row">
        <?php foreach ($working_hours as $wh): ?>
        <div class="col-md-3 mb-3">
            <div class="card <?= $wh['period'] === 'night' ? 'border-info' : 'border-warning' ?>">
                <div class="card-header d-flex justify-content-between align-items-center">
                    <span><?= e($wh['time']) ?> <small class="badge bg-<?= $wh['period'] === 'night' ? 'info' : 'warning' ?>"><?= $wh['period'] === 'night' ? 'مسائي' : 'صباحي' ?></small></span>
                    <?php
                    $hasData = false;
                    foreach ($hours as $h) {
                        if ($h['hour_slot'] === $wh['time']) { $hasData = true; break; }
                    }
                    ?>
                    <span class="badge bg-<?= $hasData ? 'success' : 'secondary' ?>"><?= $hasData ? 'محدد' : 'فارغ' ?></span>
                </div>
                <div class="card-body text-center">
                    <a href="/facility-grids/<?= $grid_id ?>/plans/<?= $plan_id ?>/hours/<?= $date ?>/<?= substr($wh['time'], 0, 5) ?>"
                       class="btn btn-sm btn-outline-primary">تعديل الشبكة</a>
                </div>
            </div>
        </div>
        <?php endforeach; ?>
    </div>
</div>
<?php $__template->endSection(); ?>
