{% extends 'consola/panel_admin/base_database.html.twig' %}
{% block body %}
<!-- Content Header (Page header) -->
<div class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1 class="m-0 text-dark">
Familia de {{ empleado_nombre }}
</h1>
</div><!-- /.col -->
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item" ><a href="{{ path("empleado_menu",{'id' : empleado_id}) }}">Menu</a></li>
<li class="breadcrumb-item active">Familia</li>
</ol>
</div><!-- /.col -->
</div><!-- /.row -->
</div><!-- /.container-fluid -->
</div>
<!-- /.content-header -->
<!-- /.content-header -->
<div class="row px-md-5 px-sm-3 px-3 pt-4">
<div class="col">
<a href="javascript:void(0)" onclick="buscar_familiar({{ empleado_id }})" class="btn btn-sm btn-primary rounded-pill px-lg-3 float-right">
<i class="fas fa-plus"></i>
<span class="d-none d-sm-none d-md-none d-lg-inline"> Agregar Familiar</span>
</a>
</br></br>
<table class="table border rounded bg-white" id='tabla'>
<thead>
<tr>
<th>Foto</th>
<th>Nombre</th>
<th>Dni</th>
<th>Parentesco</th>
<th>Estado</th>
<th>Acciones</th>
</tr>
</thead>
<tbody>
{% for familiar in arrayFamiliares %}
<tr>
<td>
{% if familiar['foto'] != null %}
<img src="{{ asset('img/familiar/' ~ familiar['foto']) }}" class="img-circle" width="35" height="35" />
{% else %}
<img src="{{ asset('img/user/user.jpg') }}" class="img-circle" width="35" height="35" />
{% endif %}
</td>
<td>{{ familiar['nombre'] }}</td>
<td>{{ familiar['dni'] }}</td>
<td>{{ familiar['parentesco'] }}</td>
<td>
{% if familiar['estado'] != true %}
Inactivo
{% else %}
Activo
{% endif %}
</td>
<td>
<a href="{{ path('familiar_menu', {'id': familiar['id']}) }}" class="btn btn-sm btn-primary rounded-pill px-lg-3"><span class="d-none d-sm-none d-md-none d-lg-inline"><i class="fas fa-server"></i> Info </span></a>
</td>
</tr>
{% else %}
<tr>
<td colspan="6">No hay resultados</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock %}
{% block javascripts %}
<script type="text/javascript">
async function buscar_familiar(ID){
const { value: text } = await Swal.fire({
input: 'text',
inputLabel: 'DNI',
inputPlaceholder: 'Ingrese el DNI (solo numeros) del familiar.',
inputAttributes: {
'aria-label': 'Ingrese el DNI (solo numeros) del familiar.',
'max_length': 8,
'min_length': 8,
},
showCancelButton: true
})
if (text) {
var path = "{{ path('buscar_familiar') }}";
$.ajax({
url: path,
type: 'POST',
data: 'dni='+text+'&empleado_id='+ID,
success: function(data) {
if(data[0]['status'] == 'success'){
Swal.fire({
position: 'top-center',
icon: 'success',
title: data[0]['text'],
showConfirmButton: false,
timer: 3000
})
location.reload();
}else{
if(data[0]['status'] == 'empty'){
//redirecciono al form
var route = "{{ path('app_familiar_new', { 'id': "PLACEHOLDER" }) }}";
window.location = route.replace("PLACEHOLDER", ID);
}else{
Swal.fire('Oops...', data[0]['text'], 'error');
}
}
}
})
}
}
$(document).ready(function() {
var table = $('#tabla').DataTable( {
"language": {
"url": "https://cdn.datatables.net/plug-ins/1.10.21/i18n/Spanish.json"
},
"dom": 'B<"float-left"i><"float-right"f>t<"float-left"l><"float-right"p><"clearfix">',
buttons: [
{
extend: 'excelHtml5',
text: '<i class="fa fa-file-excel"></i>',
titleArttr: 'Exportar a Excel',
title: 'Familiares',
className: 'btn btn-primary',
exportOptions: {
columns: [ 1, 2, 3, 4 ]
}
},
{
extend: 'pdfHtml5',
text: '<i class="fa fa-file-pdf"></i>',
titleArttr: 'Exportar a PDF',
title: 'Familiares',
orientation: 'landscape',
pageSize: 'LEGAL',
className: 'btn btn-primary',
exportOptions: {
columns: [ 1, 2, 3, 4 ]
}
},
{
extend: 'print',
text: '<i class="fa fa-print"></i>',
titleArttr: 'Imprimir',
title: 'Familiares',
className: 'btn btn-primary',
exportOptions: {
columns: [ 1, 2, 3, 4 ]
},
customize: function ( win ) {
$(win.document.body)
.css( 'font-size', '8pt' )
$(win.document.body).find( 'table' )
.addClass( 'compact' )
.css( 'font-size', 'inherit' );
}
},
],
} );
table.buttons().container()
.appendTo( '#tabla_wrapper .col-md-6:eq(0)' );
} );
</script>
{{ parent() }}
{% endblock javascripts %}