index.html.twig 4.6 KB
{% extends 'base.html.twig' %}

{% block body %}
{% for type, flashMessage in app.session.flashbag.all() %}
    <div class="alert alert-{{ type }} fade in">
      <button class="close" data-dismiss="alert" type="button">×</button>
      {% if flashMessage.title is defined %}
        <strong>{{ flashMessage.title }}</strong>
        {{ flashMessage.message }}
      {% else %}
        {{ type }}
      {% endif %}
    </div>
  {% endfor %}
  <div class="row">
    <div class="col-lg-12">
      <div class="portlet">
        <div class="portlet-header">
          <div class="caption">Listado de Estados</div>
        </div>
        <div class="portlet-body">
          <div class="table-tools">
            <div class="row">  
              <div class="col-lg-12">
                <div class="portlet-body">
                  <div class="table-tools">
                    <a href="{{ path('estado_new') }}">
                      <button type="button" class="btn btn-red mrs"><i class="fa fa-plus"></i>&nbsp;
                        Agregar
                      </button>
                    </a>          
                  </div>
                  <div class="table-responsive mtl">
                    <table class="table table-striped table-bordered table-hover">
                      <thead>
                        <tr>
                          <th class="text-center">ID</th>
                          <th class="text-center">Descripcón</th>
                          <th class="text-center">Código</th>
                          <th class="text-center">Acciones</th>
                        </tr>
                      </thead>
                      <tbody>
                        {% for estado in estados %}
                          <tr>
                            <td class="text-center "><a href="{{ path('estado_show', { 'id': estado.id }) }}">{{ loop.index  }}</a></td>
                            <td class="text-center">{{ estado.descripcion | capitalize }}</td>
                            <td class="text-center">{{ estado.codigo }}</td>
                            <td class="text-center">
                              <ul>
                                <a href="{{ path('estado_show', { 'id': estado.id }) }}"><span  title="Mostrar" class="glyphicon text-info glyphicon-eye-open"></span></a>&nbsp;&nbsp;
                                <a href="{{ path('estado_edit', { 'id': estado.id }) }}"<span title="Editar" class="glyphicon text-warning glyphicon-edit"></span></a>&nbsp;&nbsp;
                                <a data-whatever="{{estado.id}}" data-toggle="modal" data-target="#myModal" href="#"><span title="Eliminar" class="glyphicon text-orange glyphicon-trash"></span></a>&nbsp;&nbsp;
                              </ul>
                            </td>
                          </tr>
                        {% endfor %}
                      </tbody>
                    </table>
                  </div>     
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <!--modal para eliminar -->
  <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
          <h4 class="modal-title" id="myModalLabel">Eliminar!!!</h4>
        </div>
        <div class="modal-body">
          <h4>El Registro no se puede Eliminar. Esta siendo referido en otra tabla.</h4>
        </div>
        <div class="modal-footer">
          <a class="btn btn-default" type="button" class="close" data-dismiss="modal" aria-label="Close" >volver</a>                               
        </div>
      </div>
    </div>
  </div>
  <!--fin del modal--> 
{% endblock %}

{% block javascripts %}
  {{ parent() }}
  <script>
    $('#myModal').on('show.bs.modal', function (event) {
      var button = $(event.relatedTarget) // Button that triggered the modal
      var recipient = button.data('whatever') // Extract info from data-* attributes

      // If necessary, you could initiate an AJAX request here (and then do the updating in a callback).
      // Update the modal's content. We'll use jQuery here, but you could use a data binding library or other methods instead.
      var modal = $(this)
      var ruta = "{{path('estado_delete', { 'id': "borrar_id" })}}";

      var borrar = ruta.replace("borrar_id", recipient);
      modal.find('#borrar').attr("href", borrar);


    });
  </script>
  {% endblock javascripts %}