<?php

	include('public/functions.php');

 	$qry = "SELECT * FROM tbl_agenda ORDER BY id ASC";
	$result = mysqli_query($connect, $qry);
?>

<!-- START CONTENT -->
<section id="content">

      <!--breadcrumbs start-->
      <div id="breadcrumbs-wrapper" class=" grey lighten-3">
          <div class="container">
            <div class="row">
                <div class="col s12 m12 l12">
                  <h5 class="breadcrumbs-title">Programação</h5>
                  <ol class="breadcrumb">
                    <li><a href="dashboard.php">Dashboard</a>
                    </li>
                    <li><a class="active">Programação Semanal</a>
                    </li>
                  </ol>
                </div>
            </div>
          </div>
      </div>
      <!--breadcrumbs end-->

      <!--start container-->
      <div class="container">
          <div class="section">
              <div class="row">
                  <div class="col s12 m12 l12">
                      <div class="card-panel">
                        <div class="row">
                          <?php if(isset($_SESSION['msg'])) { ?>
                          <div class='card-panel teal lighten-2'>
                              <span class='white-text text-darken-2'><?php echo $_SESSION['msg'] ?></span>
                          </div>

                          <?php unset($_SESSION['msg']); }?>

                          <div class="col s12 m12 l12">
                              <table>
                                <thead>
                                  <tr>
                                    <th>Dias da semana</th>
                                    <th>Título</th>
                                    <th>Descrição</th>
                                    <th width="10%">Ação</th>
                                  </tr>
                                </thead>
                                <tbody>
                                  <?php while($data = mysqli_fetch_assoc($result)){ ?>
                                  <tr>
                                    <td><?php echo $data['dia']; ?></td>
                                    <td><?php echo $data['titulo'] ?></td>
                                    <td><?php echo substr(strip_tags($data['descricao']),0,100) ?>...</td>
                                    <td><a href="editagenda.php?idevento=<?php echo $data['id'] ?>" class="btn cyan waves-effect waves-light">Editar</a></td>
                                  </tr>
                                  <?php } ?>
                                </tbody>
                              </table>
                          </div>

                          </div>
                      </div>

                  </div>

              </div>
          </div>
      </div>

</section>
