diff --git a/routes_admin.py b/routes_admin.py index bfe1d4c..0fb7068 100644 --- a/routes_admin.py +++ b/routes_admin.py @@ -330,7 +330,7 @@ def register_admin_routes(app): r_completa = r + (items, total_calculado, comision_total) rendiciones_completas.append(r_completa) - c.execute("SELECT id, name FROM workers WHERE is_admin = 0 ORDER BY name") + c.execute("SELECT id, name, tipo FROM workers WHERE is_admin = 0 ORDER BY name") workers = c.fetchall() c.execute("SELECT id, name FROM modulos ORDER BY name") diff --git a/templates/admin_rendiciones.html b/templates/admin_rendiciones.html index 520aab8..15d83c7 100644 --- a/templates/admin_rendiciones.html +++ b/templates/admin_rendiciones.html @@ -86,5 +86,42 @@ document.getElementById(`display_nuevo_total_${id}`).innerText = '$' + total.toLocaleString('es-CL'); } + + function updateComisionToggle(selectElement, toggleId) { + const selectedOption = selectElement.options[selectElement.selectedIndex]; + const tipoJornada = selectedOption.getAttribute('data-tipo'); + const toggleSwitch = document.getElementById(toggleId); + + if (toggleSwitch && tipoJornada) { + // Si es Full Time, lo enciende (true). Si es Part Time, lo apaga (false). + toggleSwitch.checked = (tipoJornada === 'Full Time'); + } + } + + document.addEventListener('DOMContentLoaded', function() { + // Escuchar el evento de cierre de cualquier modal que empiece con 'editRendicion' + const editModals = document.querySelectorAll('[id^="editRendicion"]'); + + editModals.forEach(modal => { + modal.addEventListener('hidden.bs.modal', function () { + const form = this.querySelector('form'); + if (form) { + // 1. Resetear campos estándar (inputs, selects, textareas) + form.reset(); + + // 2. Forzar la actualización del total visual (el que calculas por JS) + const rendicionId = this.id.replace('editRendicion', ''); + calcTotalEdit(rendicionId); + + // 3. Manejo especial para el div del acompañante (si aplica) + const companionSelect = form.querySelector('select[name="companion_id"]'); + const compDiv = document.getElementById(`comp_com_div_${rendicionId}`); + if (companionSelect && compDiv) { + compDiv.style.display = companionSelect.value ? 'block' : 'none'; + } + } + }); + }); +}); {% endblock %} \ No newline at end of file diff --git a/templates/macros/modals.html b/templates/macros/modals.html index 6dce675..d4e0aa5 100644 --- a/templates/macros/modals.html +++ b/templates/macros/modals.html @@ -321,9 +321,9 @@
- {% for w in workers %} - + {% endfor %}
@@ -333,10 +333,10 @@
- + {% for w in workers %} - + {% endfor %}