{% extends 'layout.html.twig' %}

{% block body %}

	{{ parent() }}
	{% for flashMessage in app.session.flashbag.get('mensaje') %}
		<div class="alert alert-success" role="alert">
			<div class="container">{{ flashMessage }}</div>

		</div>

	{% endfor %}

	<br>
    <br>
    
	   <div class="container">
	       <div class="col-md-12">
	           <center><div class="page-header margin-none">
	               <h1 class="padding-none">Alumnos</h1>
	           </div></center>

	           <div class="col-md-6">
	                    <a href="{{ path('cargar_alumno') }}" class="btn btn-primary btn-sm">
	                        
	                            <i class="fa fa-fw fa-plus"></i> Nuevo Alumno
	                        
	                    </a>
	           </div>

	           <div class="row">
	           		
	                <div class="col-md-6">    
	                    <form method="" action="" class="form-inline" role="search">
		           	   		
		           	   		<div class="form-group">
		           	   			<input type="text" name="query" class="form-control" placeholder="Buscar Persona" required>
		           	   		</div>	
		           	   		<input type="submit" value="Buscar" class="btn btn-default">
		           	   
		           	   </form>
		           	</div>   
                </div><br>

                {% if pagination != '' %}

		           <div class="table-responsive">
		           	
		           	   <p>Total de Usuarios: {{ pagination.getTotalItemCount }}</p> 

		           	   
		           	   <br>	

		               <table class="table table-striped table-hover">
		                   <table-hoverad>
		                       <tr>
		                       	   <th>{{ knp_pagination_sortable(pagination, 'N Legajo', 'e.alumno.numeroLegajo') }}</th>                      		
		                       	   <th>{{ knp_pagination_sortable(pagination, 'DNI', 'e.dni') }}</th>
		                           <th>{{ knp_pagination_sortable(pagination, 'Apellido ', 'e.apellido') }}</th>
		                           <th>{{ knp_pagination_sortable(pagination, 'Nombre', 'e.nombre') }}</th>
		                           <th>{{ knp_pagination_sortable(pagination, 'Direccion', 'e.direccion') }}</th>
		                           <th>Acciones</th>
		                       </tr>
		                   </thead>
		                   <tbody>
		                   	  {% for user in pagination %}
		                       <tr>
		                       	   <td>{{ user.alumno.numeroLegajo }}</td>	
		                           <td>{{ user.dni }}</td>
		                           <td>{{ user.apellido }}</td>
		                           <td>{{ user.nombre }}</td>
		                           <td>{{ user.direccion }}</td>
		                           <td>
		                                <a href="{{ path('view_alumno', { id: user.alumno.id}) }}" class="btn btn-sm btn-info">View</a>
		                                <a href="{{ path('update_user', { id: user.id}) }}" class="btn btn-sm btn-primary">Edit</a>
		                                <a href="{{ path('eliminar_alumno',{ id: user.alumno.id}) }}" onclick="confirmDelete()" class="btn btn-sm btn-danger btn-delete">Delete</a>
		                                <a href="{{ path('inscribir_alumno',{ id: user.alumno.id}) }}"  class="btn btn-sm btn-danger btn-delete">Delete</a>
		                           </td>

		                       </tr>
		                       {% endfor %}
		                   </tbody>
		               </table>

		               {# display navigation #}
					    <div class="navigation">
					        {{ knp_pagination_render(pagination) }}
					    </div>

		           </div>   
				{% endif %}
	       </div>
	   </div>
	
<script>
	
	function confirmDelete(){

		bootbox.confirm('Esta Seguro de Realizar Esta Accion', function(result){

			if(result == true){
				document.form.submit();
			}

		});

	}

</script>



{% endblock %}
