<!-- Sidebar -->
<?php $this->load->view('restricted/layout/sidebar_author'); ?>
<!-- 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>


          <div class="table-responsive">
            <table class="table align-items-center table-flush">
              <thead class="thead-light">
                <tr>
                  <th>Data</th>
                  <th>Mensagem</th>
                  <th>Visualizado</th>
                  <th>Ação</th>
                </tr>
              </thead>
              <tbody>
                <?php foreach ($alerts as $alert) : ?>
                  <tr>
                    <td><?php $date = date_create($alert->created_at);
                        echo date_format($date, 'd/m/Y'); ?></td>
                    <td><?php echo $alert->message ?></td>
                    <td>
                      <?php if($alert->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>
                      <a href="#" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#modalAlerts<?php echo $alert->id; ?>" data-id="<?php echo $alert->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 Alerts -->
                  <div class="modal fade" id="modalAlerts<?php echo $alert->id; ?>" tabindex="-1" role="dialog" aria-labelledby="modalAlertsTitle" 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="modalAlertsTitle">Detalhes do alerta</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">Enviado em</h5>
                              <p><?php $date = date_create($alert->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 $alert->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>
                <?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 -->