<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Iniciar sesi&oacute;n</title>
    <link rel="stylesheet" href="<?=base_url()?>assets/bootstrap/css/bootstrap.min.css">
</head>
<body>
    <div class="container">
        <div class="row my-3">
            <div class="col">
                <a href="<?=base_url()?>admin/appointments/">Citas</a> &nbsp; / 
                <a href="<?=base_url()?>admin/available/" class="ml-2">Fecha disponible</a>
            </div>
            <div class="col text-right">
                <a href="<?=base_url()?>admin/logout">Salir</a>
            </div>
        </div>
        <div class="row justify-content-center my-3">
            <div class="col-md-5 text-center">
                <h4>Citas</h4>
            </div>
        </div>
        <div class="row justify-content-center my-3">
            <div class="col-md-6 border border-secondary p-5">
                <form action="<?=base_url()?>admin/search_appointment" method="POST">
                    <div class="form-group">
                        <label>Fecha</label>
                        <input type="date" name="search_date" class="form-control" 
                            value="<?= !empty($search_date) ? $search_date : date('Y-m-d') ?>"
                             required>
                    </div>
                    <div class="form-group">
                        <button type="submit" class="btn btn-primary col-12 my-2">
                            Buscar
                        </button>
                    </div>
                </form>
            </div>            
        </div>
        <div class="row">
        <?php if ($appointments) { ?>
            <?php foreach ($appointments as $key => $appointment) { ?>
                <div class="col-sm-4">
                    <ul>
                        <li><?=$key?>
                            <ul>
                            <?php foreach ($appointment as $item) { ?>
                                <li><?=$item['name'];?></li>
                                <li><?=$item['phone'];?></li>
                                <li><?=$item['email'];?></li>
                                <br>
                            <?php } ?>
                            </ul>
                        </li>
                    </ul>
                </div>  
            <?php }
        } ?>
        </div>
    
    </div>
</body>
</html>
<script src="<?=base_url()?>assets/js/jquery.min.js"></script>