index.html.twig
4.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
{% 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-body">
<div class="table-tools">
<a href="{{ path('persona_new') }}">
<button type="button" class="btn btn-red mrs"><i class="fa fa-plus"></i>
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">Nombre</th>
<th class="text-center">Apellido</th>
<th class="text-center">Cedula</th>
<th class="text-center">Genero</th>
<th class="text-center">Direccion</th>
<th class="text-center">Acciones</th>
</tr>
</thead>
<tbody>
{% for persona in personas %}
<tr>
<td class="text-center"><a href="{{ path('persona_show', { 'id': persona.id }) }}">{{ loop.index }}</a></td>
<td class="text-center">{{ persona.nombre | capitalize}}</td>
<td class="text-center">{{ persona.apellido | capitalize}}</td>
<td class="text-center">{{ persona.cedula }}</td>
<td class="text-center">{{ persona.genero | capitalize}}</td>
<td class="text-center">{{ persona.direccion }}</td>
<td>
<ul>
<a href="{{ path('persona_show', { 'id': persona.id }) }}"><span title="Mostrar" class="glyphicon text-info glyphicon-eye-open"></span></a>
<a href="{{ path('persona_edit', { 'id': persona.id }) }}"><span title="Editar" class="glyphicon text-warning glyphicon-edit"></span></a>
<a data-whatever="{{persona.id}}" data-toggle="modal" data-target="#myModal" href="#"><span title="Eliminar" class="glyphicon text-orange glyphicon-trash"></span></a>
</ul>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</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">×</span></button>
<h4 class="modal-title" id="myModalLabel">Eliminar!!!</h4>
</div>
<div class="modal-body">
<h4>¿ Está seguro de querer eliminar este registro?</h4>
</div>
<div class="modal-footer">
<a class="btn btn-default" type="button" class="close" data-dismiss="modal" aria-label="Close" >Cancelar</a>
<a class="btn btn-danger" id="borrar" href="#" >Eliminar</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('persona_delete', { 'id': "borrar_id" })}}";
var borrar = ruta.replace("borrar_id", recipient);
modal.find('#borrar').attr("href", borrar);
});
</script>
{% endblock javascripts %}