<!-- Sidebar -->
<?php $this->load->view('restricted/layout/sidebar_editor'); ?>
<!-- Sidebar -->

<div id="content-wrapper" class="d-flex flex-column">
    <div id="content">

        <!-- NavBar -->
        <?php $this->load->view('restricted/layout/navbar'); ?>
        <!-- Navbar -->

        <!-- Container Fluid-->
        <div class="container-fluid" id="container-wrapper">
            <div class="d-sm-flex align-items-center justify-content-between mb-4">
                <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="./">Home</a></li>
                    <li class="breadcrumb-item active" aria-current="page"><?php echo $title; ?></li>
                </ol>
            </div>

            <!-- Message From Customer-->
            <div class="col-xl-12 col-lg-12 ">
                <div class="card">
                    <div class="card-header py-4 bg-primary d-flex flex-row align-items-center justify-content-between">
                        <h6 class="m-0 font-weight-bold text-light"><?php echo $title; ?></h6>
                    </div>


                    <!-- DataTable with Hover -->
                    <div class="table-responsive p-3">
                        <table class="table align-items-center table-flush table-hover" id="dataTableHover">
                            <thead class="thead-light">
                                <tr>
                                    <th>Data</th>
                                    <th>Mensagem</th>
                                    <th>Visualizado</th>
                                    <th>Ação</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php foreach($messages as $message): ?>
                                <tr>
                                    <td><?php $date = date_create($message->created_at); echo date_format($date, 'd/m/Y'); ?></td>
                                    <td><?php echo $message->message; ?></td>
                                    <td>
                                        <?php if($message->was_read == 1): ?>
                                            <i class="far fa-check-circle text-secondary ml-4"></i></td>
                                        <?php else: ?>
                                            <i class="far fa-check-circle text-success ml-4"></i></td>
                                        <?php endif; ?>
                                    </td>
                                    <td>
                                        <a href="#" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#modalMessage<?php echo $message->id; ?>" data-id="<?php echo $message->id; ?>">
                                            <i class="fas fa-eye"></i>
                                        </a>
                                        <a href="#" class="btn btn-danger btn-sm delete">
                                            <i class="fas fa-trash"></i>
                                        </a>
                                    </td>
                                </tr>
                                <!-- Modal -->
                                <div class="modal fade" id="modalMessage<?php echo $message->id; ?>" tabindex="-1" role="dialog" aria-labelledby="modalMessage" aria-hidden="true">
                                    <div class="modal-dialog modal-dialog-centered" role="document">
                                    <div class="modal-content">
                                        <div class="modal-header bg-primary">
                                        <h5 class="modal-title text-white" id="modalMessage">Detalhes da mensagem</h5>
                                        <button type="button" class="close text-white" data-dismiss="modal" aria-label="Close">
                                            <span aria-hidden="true">&times;</span>
                                        </button>
                                        </div>
                                        <div class="modal-body">
                                            <div class="row">
                                                <div class="col-sm-12 py-3">
                                                    <h5 class="text-primary">Data</h5>
                                                        <p><?php $date = date_create($message->created_at); echo date_format($date, 'd/m/Y'); ?></p>
                                                </div>
                                                <div class="col-sm-12 py-3">
                                                    <h5 class="text-primary">Mensagem</h5>
                                                        <p><?php echo $message->message; ?></p>
                                                </div>
                                            </div>
                                            <!-- /Row -->
                                        </div>
                                        <div class="modal-footer">
                                            <button type="button" class="btn btn-info">Marcar como lida</button>
                                            <button type="button" class="btn btn-outline-primary" data-dismiss="modal">Fechar</button>
                                        </div>
                                    </div>
                                    </div>
                                </div>
                                <!-- /Modal -->
                                <?php endforeach; ?>
                            </tbody>
                        </table>
                    </div>


                </div><!-- /Card -->
            </div><!-- /Col-12 -->


            <!-- Modal Logout -->
            <?php $this->load->view('restricted/layout/modal_logout'); ?>
            <!-- /Modal -->

        </div>
        <!--- /Container Fluid-->
    </div><!-- /Content -->