templates/preparacion/index_terapia.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block title %}Preparacion{% endblock %}
  3. {% block body %}
  4. {{ form_start(form) }}
  5.     <h3><b>Terapias</b></h3>
  6.     <div class="col-md-12">
  7.         {{ include('preparacion/buscar_new.html.twig', {'button_label': 'Buscar'}) }}
  8.     </div>
  9.     <div class="table-responsive">
  10.         <table class="table table-bordered table-hover table-sm">
  11.             <thead class="thead-light">
  12.                 <tr>
  13.                     <th>No</th>
  14.                     <th>{{ knp_pagination_sortable(agendas, 'Hora', 'a.inicio') }}</th>
  15.                     <th>{{ knp_pagination_sortable(agendas, 'Paciente', 'paciente') }}</th>
  16.                     <th>{{ knp_pagination_sortable(agendas, 'Doctor', 'doctor') }}</th>
  17.                     <th>{{ knp_pagination_sortable(agendas, 'Tipo', 'procedimiento') }}</th>
  18.                     <th>Atendido</th>
  19.                 </tr>
  20.             </thead>
  21.             <tbody>
  22.             {% for agenda in agendas %}
  23.                 <tr class="">
  24.                     <td>{{ loop.index }}</td>
  25.                     <td>{{ agenda.inicio|date('d/m/Y H:i') }}</td>
  26.                     <td>{{ agenda.paciente }}</td>
  27.                     <td>{{ agenda.doctor }} </td>
  28.                     <td>{{ agenda.procedimiento }}</td>
  29.                     
  30.                     <td class="text-center">
  31.                         <input type="checkbox"
  32.                             class="chk-realizado"
  33.                             data-id="{{ agenda.agenda.id }}"
  34.                             onchange="marcarRealizado(this)"
  35.                             {% if agenda.agenda.historiaClinica != null %} disabled checked {% endif %}
  36.                         >
  37.                     </td>
  38.                 </tr>
  39.             {% else %}
  40.                 <tr>
  41.                     <td colspan="7" class="text-center text-muted">
  42.                         No hay registros
  43.                     </td>
  44.                 </tr>
  45.             {% endfor %}
  46.             </tbody>
  47.         </table>
  48.     </div>    
  49. <div class="mt-3">
  50.     {{ knp_pagination_render(agendas) }}
  51. </div>
  52. <script>
  53. function marcarRealizado(checkbox) {
  54.     if (!checkbox.checked) {
  55.         return;
  56.     }
  57.     if (!confirm('¿Marcar como realizado?')) {
  58.         checkbox.checked = false;
  59.         return;
  60.     }
  61.     const agendaId = checkbox.dataset.id;
  62.     fetch('{{ path("preparacion_terapia_lista", {id: 0}) }}'.replace('/0', '/' + agendaId), {
  63.         method: 'GET',
  64.         
  65.     })
  66.     .then(response => response.json())
  67.     .then(data => {
  68.         if (data.estado === 'ok') {
  69.             checkbox.disabled = true;
  70.         } else {
  71.             alert('No se pudo marcar como realizado');
  72.             checkbox.checked = false;
  73.         }
  74.     })
  75.     .catch(() => {
  76.         alert('Error de conexión');
  77.         checkbox.checked = false;
  78.     });
  79. }
  80. </script>
  81. {% endblock %}