<body id="page-top">

  <!-- Sidebar -->
  <?php $this->load->view('restricted/layout/sidebar_admin'); ?>
  <!-- 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">
          <h1 class="h3 mb-0 text-purple"><?php echo $title; ?></h1>
          <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>


        <div class="row mb-3">
          <!-- Pending Requests Card Example -->
          <div class="col-xl-12 col-md-12 mb-4">
            <div class="card mb-4">
              <div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
                <h6 class="m-0 font-weight-bold text-primary"><?php echo $title; ?></h6>
                <a href="<?php echo base_url('restricted/admin/books/core'); ?>" class="btn btn-primary">Adicionar novo</a>
              </div>
              <div class="table-responsive p-3">
                <table class="table align-items-center table-flush table-hover" id="dataTableHover">
                  <thead class="thead-light">
                    <tr>
                      <th>ID</th>
                      <th>Título</th>
                      <th>Criado em</th>
                      <th>Modificado em</th>
                      <th>Ação</th>
                    </tr>
                  </thead>
                  <tbody>

                    <?php if(isset($books)): ?>
                    <?php foreach ($books as $book) : ?>
                      <tr>
                        <td><?php echo $book->id; ?></td>
                        <td><?php echo $book->title; ?></td>
                        <td><?php $date = date_create($book->created_at); echo date_format($date, 'd/m/Y'); ?></td>
                        <td><?php if($book->modified_at != NULL) : $date = date_create($book->modified_at); echo date_format($date, 'd/m/Y'); endif; ?></td>
                        <td>
                          <a href="<?php echo base_url('restricted/admin/books/core/' . $book->id); ?>" class="btn btn-primary btn-sm">
                            <i class="fas fa-edit"></i>
                          </a>
                          <a href="<?php echo base_url('restricted/admin/books/delete/' . $book->id); ?>" class="btn btn-danger btn-sm delete" data-confirm="Tem certeza que deseja excluir esse registro ?" title="Deletar usuário">
                            <i class="fas fa-trash"></i>
                          </a>
                        </td>
                      </tr>
                    <?php endforeach; ?>
                    <?php else: ?>
                      <tr>
                        <td>Nenhum registro encontrado...</td>
                      </tr>
                    <?php endif; ?>
                  </tbody>
                </table>
              </div>
            </div>
          </div>

        </div>
        <!--/Row-->

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

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