templates/consola/panel_admin/empleado/familiar/empleado_familiares.html.twig line 1

Open in your IDE?
  1. {% extends 'consola/panel_admin/base_database.html.twig' %}
  2. {% block body %}
  3.     <!-- Content Header (Page header) -->
  4.     <div class="content-header">
  5.         <div class="container-fluid">
  6.           <div class="row mb-2">
  7.             <div class="col-sm-6">
  8.               <h1 class="m-0 text-dark">
  9.                   Familia de {{ empleado_nombre }}
  10.               </h1>
  11.             </div><!-- /.col -->
  12.             <div class="col-sm-6">
  13.                 <ol class="breadcrumb float-sm-right">
  14.                   <li class="breadcrumb-item" ><a href="{{ path("empleado_menu",{'id' : empleado_id}) }}">Menu</a></li>
  15.                   <li class="breadcrumb-item active">Familia</li>
  16.                 </ol>
  17.               </div><!-- /.col -->
  18.           </div><!-- /.row -->
  19.         </div><!-- /.container-fluid -->
  20.       </div>
  21.       <!-- /.content-header -->
  22.           <!-- /.content-header -->
  23.     <div class="row px-md-5 px-sm-3 px-3 pt-4">
  24.         <div class="col">
  25.             
  26.             <a href="javascript:void(0)" onclick="buscar_familiar({{ empleado_id }})"  class="btn btn-sm btn-primary rounded-pill px-lg-3 float-right">
  27.                 <i class="fas fa-plus"></i>
  28.                 <span class="d-none d-sm-none d-md-none d-lg-inline"> Agregar Familiar</span>
  29.             </a>
  30.         </br></br>
  31.               <table class="table border rounded bg-white" id='tabla'>
  32.                 <thead>
  33.                     <tr>
  34.                         <th>Foto</th>
  35.                         <th>Nombre</th>
  36.                         <th>Dni</th>
  37.                         <th>Parentesco</th>
  38.                         <th>Estado</th>
  39.                         <th>Acciones</th>
  40.                     </tr>
  41.                 </thead>
  42.                 <tbody>
  43.                 {% for familiar in arrayFamiliares %}
  44.                     <tr>
  45.                         <td>
  46.                             {% if familiar['foto'] != null %}
  47.                                 <img src="{{ asset('img/familiar/' ~ familiar['foto']) }}" class="img-circle" width="35" height="35"  />
  48.                             {% else %}   
  49.                                 <img src="{{ asset('img/user/user.jpg') }}" class="img-circle" width="35" height="35" />
  50.                             {% endif %}
  51.                         </td>
  52.                         <td>{{ familiar['nombre'] }}</td>
  53.                         <td>{{ familiar['dni'] }}</td>
  54.                         <td>{{ familiar['parentesco'] }}</td>
  55.                         <td>     
  56.                                 {% if familiar['estado'] != true %}
  57.                                      Inactivo
  58.                                 {% else %}
  59.                                      Activo
  60.                                 {% endif %}
  61.                         </td>
  62.                         <td>
  63.                             <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>
  64.                         </td>
  65.                     </tr>
  66.                 {% else %}
  67.                     <tr>
  68.                         <td colspan="6">No hay resultados</td>
  69.                     </tr>
  70.                 {% endfor %}
  71.                 </tbody>
  72.             </table>
  73.         </div>
  74.     </div>
  75. {% endblock %}
  76. {% block javascripts %}
  77.     <script type="text/javascript">
  78.         async function buscar_familiar(ID){
  79.             const { value: text } = await Swal.fire({
  80.             input: 'text',
  81.             inputLabel: 'DNI',
  82.             inputPlaceholder: 'Ingrese el DNI (solo numeros) del familiar.',
  83.             inputAttributes: {
  84.                 'aria-label': 'Ingrese el DNI (solo numeros) del familiar.',
  85.                 'max_length': 8,
  86.                 'min_length': 8,
  87.             },
  88.             showCancelButton: true
  89.             })
  90.             if (text) {
  91.                 var path = "{{ path('buscar_familiar') }}";
  92.                 $.ajax({
  93.                     url: path,
  94.                     type: 'POST',
  95.                     data: 'dni='+text+'&empleado_id='+ID, 
  96.                     success: function(data) {
  97.                       if(data[0]['status'] == 'success'){
  98.                         Swal.fire({
  99.                             position: 'top-center',
  100.                             icon: 'success',
  101.                             title: data[0]['text'],
  102.                             showConfirmButton: false,
  103.                             timer: 3000
  104.                         })           
  105.                         location.reload();
  106.                       }else{
  107.                         if(data[0]['status'] == 'empty'){
  108.                             //redirecciono al form
  109.                             var route = "{{ path('app_familiar_new', { 'id': "PLACEHOLDER" }) }}";
  110.                             window.location = route.replace("PLACEHOLDER", ID);
  111.                         }else{
  112.                           Swal.fire('Oops...', data[0]['text'], 'error');
  113.                         }
  114.                       }
  115.                     }
  116.                 })
  117.             }
  118.         }
  119.         $(document).ready(function() {
  120.             var table = $('#tabla').DataTable( {
  121.                 "language": {
  122.                     "url": "https://cdn.datatables.net/plug-ins/1.10.21/i18n/Spanish.json"
  123.                 },
  124.                 "dom": 'B<"float-left"i><"float-right"f>t<"float-left"l><"float-right"p><"clearfix">',
  125.                 buttons: [
  126.                     {
  127.                         extend:     'excelHtml5',
  128.                         text:       '<i class="fa fa-file-excel"></i>',
  129.                         titleArttr: 'Exportar a Excel',
  130.                         title: 'Familiares',
  131.                         className:  'btn btn-primary',
  132.                         exportOptions: {
  133.                                 columns: [ 1, 2, 3, 4 ]
  134.                             }
  135.                     },
  136.                     {
  137.                         extend:     'pdfHtml5',
  138.                         text:       '<i class="fa fa-file-pdf"></i>',
  139.                         titleArttr: 'Exportar a PDF',
  140.                         title: 'Familiares',
  141.                         orientation: 'landscape',
  142.                         pageSize: 'LEGAL',
  143.                         className:  'btn btn-primary',
  144.                         exportOptions: {
  145.                             columns: [ 1, 2, 3, 4 ]
  146.                             }
  147.                     },
  148.                     {
  149.                         extend:     'print',
  150.                         text:       '<i class="fa fa-print"></i>',
  151.                         titleArttr: 'Imprimir',
  152.                         title: 'Familiares',
  153.                         className:  'btn btn-primary',
  154.                         exportOptions: {
  155.                             columns: [ 1, 2, 3, 4 ]
  156.                             },
  157.                             customize: function ( win ) {
  158.                                 $(win.document.body)
  159.                                     .css( 'font-size', '8pt' )      
  160.                                 $(win.document.body).find( 'table' )
  161.                                     .addClass( 'compact' )
  162.                                     .css( 'font-size', 'inherit' );
  163.                             }
  164.                     },
  165.                 ],
  166.             } );
  167.         
  168.             table.buttons().container()
  169.                 .appendTo( '#tabla_wrapper .col-md-6:eq(0)' );
  170.         } );
  171.     </script>
  172.     {{ parent() }}
  173. {% endblock javascripts %}