{% include 'panel/p_header.twig' %}

<!-- Noticias -->
<section>
<div class="col-lg-12">
              <div class="card">
                <div class="card-header d-flex align-items-center">
                  <h2 class="h5 display">Vista rápida de noticias.</h2>
                </div>
              <div class="card">
                <div class="card-header d-flex align-items-center">

                  <button type="button" class="btn btn-info" data-toggle="modal" data-target="#new_{{news.ID_N}}">Nueva noticia</button>
                  <!-- Modal Editar -->
                  <div id="new_{{news.ID_N}}" class="modal fade" role="dialog">
                    <div class="modal-dialog">
                      <!-- Modal content-->
                      <div class="modal-content" role="document">
                        <div class="modal-header">
                            <h5 class="modal-title">Nueva noticia.</h5>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span aria-hidden="true">&times;</span>
                            </button>
                        </div>
                        <form action="?page=newnews" method="POST">
                        <div class="modal-body">
                          <p>Se acepta el uso de MarkDown y/o texto plano.</p>
                          <p><textarea style="width:100%;height:250px;" name="text_new"></textarea></p>
                        </div>
                        <div class="modal-footer">
                          <button type="submit" class="btn btn-primary">Nueva noticia</button>
                        </div>
                      </form>
                      </div>
                    </div>
                  </div>
                  <!-- Fin modal -->
              </div>
                <div class="card-block">
                  <table class="table table-striped table-hover">
                    <thead>
                      <tr>
                        <th>Fecha</th>
                        <th>Noticia</th>
                        <th>Opciones</th>
                      </tr>
                    </thead>
                    <tbody>
                      {% for news in allnews %}
                      <tr>
                        <td>{{news.date}}</td>
                        <td>{{news.text | raw}}</td>
                        <td>
                          
                          <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#edit_{{news.ID_N}}">Editar</button>
                          <!-- Modal Editar -->
                          <div id="edit_{{news.ID_N}}" class="modal fade" role="dialog">
                            <div class="modal-dialog">
                              <!-- Modal content-->
                              <div class="modal-content" role="document">
                                <div class="modal-header">
                                    <h5 class="modal-title">Editando noticia...</h5>
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                        <span aria-hidden="true">&times;</span>
                                    </button>
                                </div>
                                <form action="?page=editnews&ID_N={{news.ID_N}}" method="POST">
                                <div class="modal-body">
                                  <p><textarea style="width:100%;height:250px;" name="text_{{news.ID_N}}">{{news.mdtext}}</textarea></p>
                                </div>
                                <div class="modal-footer">
                                  <button type="submit" class="btn btn-primary">Cambiar</button>
                                </div>
                              </form>
                              </div>
                            </div>
                          </div>
                          <!-- Fin modal -->
                          <button type="button" class="btn btn-danger" data-toggle="modal" data-target="#delnews_{{news.ID_N}}">Borrar</button>
                          <!-- Modal borrar -->
                          <div id="delnews_{{news.ID_N}}" class="modal fade" role="dialog">
                            <div class="modal-dialog">
                              <!-- Modal content-->
                              <div class="modal-content" role="document">
                                <div class="modal-header">
                                    <h5 class="modal-title">Se va a borrar la noticia</h5>
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                        <span aria-hidden="true">&times;</span>
                                    </button>
                                </div>
                                <form action="?page=delnews&ID_N={{news.ID_N}}" method="POST">
                                <div class="modal-body">
                                  <p class="black">Borrar una noticia es irreversible</p>
                                </div>
                                <div class="modal-footer">
                                  <button type="submit" class="btn btn-danger">Borrar</button>
                                </div>
                              </form>
                              </div>
                            </div>
                          </div>
                          <!-- Fin modal -->
                        </td>
                      </tr>
                      {% endfor %}
                    </tbody>
                  </table>
                </div>
              </div>
            </div>
</section>


{% include 'footer.twig' %}