diff --git a/MieSystem/Controllers/ExpedientesController.cs b/MieSystem/Controllers/ExpedientesController.cs index 302e880..63a84ee 100644 --- a/MieSystem/Controllers/ExpedientesController.cs +++ b/MieSystem/Controllers/ExpedientesController.cs @@ -1,9 +1,6 @@ using Microsoft.AspNetCore.Mvc; -using System.Linq; -using System.Threading.Tasks; -using MieSystem.Models; using MieSystem.Data.Interfaces; -using AspNetCoreGeneratedDocument; +using MieSystem.Models; using MieSystem.Models.ViewModels; namespace MieSystem.Controllers @@ -20,24 +17,14 @@ namespace MieSystem.Controllers _hostingEnvironment = hostingEnvironment; _expedienteRepository = expedienteRepository; - - // Datos de prueba iniciales - /*if (_expedientes.Count == 0) - { - _ = InitializeTestData(); - }*/ } - private async Task InitializeTestData() + // GET: Expedientes + public async Task Index() { var today = DateTime.Today; var lst = await _expedienteRepository.GetAllAsync(); _expedientes = [.. lst]; - } - - // GET: Expedientes - public IActionResult Index() - { return View(); } @@ -45,7 +32,6 @@ namespace MieSystem.Controllers [HttpGet] public IActionResult GetDashboardStats() { - _ = InitializeTestData(); var totalNinos = _expedientes.Count; var mesActual = DateTime.Now.Month; @@ -78,9 +64,6 @@ namespace MieSystem.Controllers [HttpGet] public IActionResult GetExpedientes(int page = 1, int pageSize = 10) { - if (_expedientes.Count == 0) - _ = InitializeTestData(); - var query = _expedientes .Where(e => e.Activo) .OrderBy(e => e.Apellidos) @@ -122,7 +105,6 @@ namespace MieSystem.Controllers // POST: Expedientes/Create [HttpPost] - // [ValidateAntiForgeryToken] public async Task Create(ExpedienteViewModel model) { diff --git a/MieSystem/Views/Asistencia/Index.cshtml b/MieSystem/Views/Asistencia/Index.cshtml index 99a9270..3a8262d 100644 --- a/MieSystem/Views/Asistencia/Index.cshtml +++ b/MieSystem/Views/Asistencia/Index.cshtml @@ -19,7 +19,7 @@
-
+
Filtros
@@ -71,8 +71,8 @@
-
@@ -101,82 +101,125 @@
- - - - +
- Niño -
+ + + + @foreach (var dia in Model.DiasDelMes) + { + var diaSemana = ((int)dia.DayOfWeek).ToString(); + var isChecked = Model.DiasSemanaSeleccionados?.Contains(diaSemana) ?? true; + + if (!string.IsNullOrEmpty(Model.DiasSemanaSeleccionados) && !isChecked) + { + continue; + } + + var nombreDia = dia.ToString("ddd", new System.Globalization.CultureInfo("es-ES")); + var esFinDeSemana = dia.DayOfWeek == DayOfWeek.Saturday || dia.DayOfWeek == DayOfWeek.Sunday; + + + } + + + + @foreach (var expediente in Model.Expedientes) + { + + + var nombreCompleto = $"{expediente.Nombre} {expediente.Apellidos}".Trim(); + var edad = 0; + if (expediente.FechaNacimiento != DateTime.MinValue) + { + var today = DateTime.Today; + edad = today.Year - expediente.FechaNacimiento.Year; + if (expediente.FechaNacimiento.Date > today.AddYears(-edad)) + { + edad--; + } + } + + + + + @foreach (var dia in Model.DiasDelMes) + { + var diaSemana = ((int)dia.DayOfWeek).ToString(); + var isChecked = Model.DiasSemanaSeleccionados?.Contains(diaSemana) ?? true; + + if (!string.IsNullOrEmpty(Model.DiasSemanaSeleccionados) && !isChecked) + { + continue; + } + + var key = $"{expediente.Id}_{dia:yyyy-MM-dd}"; + var estadoActual = Model.Asistencias.ContainsKey(key) + ? Model.Asistencias[key] + : ""; + + // Determinar clase CSS según estado + var claseEstado = estadoActual switch + { + "P" => "celda-presente", + "T" => "celda-tarde", + "F" => "celda-falta", + _ => "" + }; + + var esFinDeSemana = dia.DayOfWeek == DayOfWeek.Saturday || dia.DayOfWeek == DayOfWeek.Sunday; + + + } - - - - @foreach (var expediente in Model.Expedientes) - { - - - - @foreach (var dia in diasAMostrar) - { - var key = $"{expediente.Id}_{dia:yyyy-MM-dd}"; - var estadoActual = Model.Asistencias.ContainsKey(key) - ? Model.Asistencias[key] - : ""; - - + } + + } + +
+
Nombre
+
Edad
+
+
@dia.Day
+
@nombreDia
+
+
@nombreCompleto
+
Edad: @edad años
+
+ + -
@dia.ToString("ddd")
-
@dia.Day
-
-
@expediente.NombreCompleto
-
Edad: @expediente.Edad años
-
- +
- @if (estadoActual == "P") - { - - } - else - { - - } - - @if (estadoActual == "T") - { - - } - else - { - - } - - @if (estadoActual == "F") - { - - } - else - { - - } - - - - } - - } - -
@@ -216,123 +259,286 @@ @section Styles { } @section Scripts { } diff --git a/MieSystem/Views/Expedientes/Details.cshtml b/MieSystem/Views/Expedientes/Details.cshtml index d875137..f7b13c1 100644 --- a/MieSystem/Views/Expedientes/Details.cshtml +++ b/MieSystem/Views/Expedientes/Details.cshtml @@ -530,7 +530,7 @@ -
diff --git a/MieSystem/Views/Expedientes/Index.cshtml b/MieSystem/Views/Expedientes/Index.cshtml index 4f76755..23f43a4 100644 --- a/MieSystem/Views/Expedientes/Index.cshtml +++ b/MieSystem/Views/Expedientes/Index.cshtml @@ -323,10 +323,8 @@ ); renderExpedientesTable(filtered); - $('#pagination').empty(); // Limpiar paginación en búsqueda + $('#pagination').empty(); } - - // Guardar nuevo expediente function saveExpediente() { const formData = new FormData($('#createForm')[0]); @@ -337,7 +335,6 @@ processData: false, contentType: false, success: function(response) { - // Mostrar siempre el mensaje que viene en response.message const message = response.message || (response.success ? 'Operación completada' : 'Error en la operación'); @@ -351,7 +348,6 @@ } }, error: function(xhr) { - // Extraer el message del JSON si existe let message = 'Error en la solicitud'; try { const jsonResponse = JSON.parse(xhr.responseText); @@ -359,7 +355,6 @@ message = jsonResponse.message; } } catch (e) { - // Si no es JSON válido, usar el texto de respuesta if (xhr.responseText) { message = xhr.responseText; } @@ -378,7 +373,6 @@ $('#editModalBody').html(data); $('#editModal').modal('show'); - // Mostrar/ocultar botón de eliminar imagen según si hay imagen personalizada const fotoUrl = $('#editForm input[name="FotoUrl"]').val(); const deleteBtn = $('#deleteFotoEdit'); if (fotoUrl && fotoUrl !== '/images/default-avatar.png') { @@ -441,8 +435,6 @@ } } - // ========== FUNCIONES PARA MANEJO DE IMÁGENES ========== - // Mostrar vista previa de imagen function previewImage(input, previewId) { const preview = document.getElementById(previewId); @@ -519,16 +511,13 @@ } } showAlert('error', message); - // Restaurar imagen predeterminada preview.src = '/images/default-avatar.png'; - // Ocultar botón de eliminar const deleteBtnId = isEdit ? 'deleteFotoEdit' : 'deleteFoto'; $(`#${deleteBtnId}`).hide(); } }); } - // Eliminar imagen function deleteImage(isEdit = false) { const formId = isEdit ? 'editForm' : 'createForm'; const hiddenInput = $(`#${formId} input[name="FotoUrl"]`); @@ -544,7 +533,6 @@ data: { imageUrl: imageUrl }, success: function(response) { if (response.success) { - // Restaurar imagen predeterminada $(`#${previewId}`).attr('src', '/images/default-avatar.png'); hiddenInput.val('/images/default-avatar.png'); $(`#${deleteBtnId}`).hide(); @@ -561,9 +549,6 @@ } } - // ========== FUNCIONES UTILITARIAS ========== - - // Calcular edad function calculateAge(birthDate) { const today = new Date(); const birth = new Date(birthDate); @@ -577,7 +562,6 @@ return age; } - // Formatear fecha function formatDate(dateString) { const date = new Date(dateString); return date.toLocaleDateString('es-ES', { @@ -587,9 +571,7 @@ }); } - // Mostrar alerta function showAlert(type, message) { - // Crear elemento de alerta const alertDiv = document.createElement('div'); alertDiv.className = `alert alert-${type} alert-dismissible fade show position-fixed`; alertDiv.style.cssText = 'top: 20px; right: 20px; z-index: 1050; min-width: 300px;'; @@ -598,10 +580,8 @@ `; - // Agregar al body document.body.appendChild(alertDiv); - // Auto-eliminar después de 5 segundos setTimeout(() => { if (alertDiv.parentNode) { alertDiv.remove(); diff --git a/MieSystem/Views/Shared/_Layout.cshtml b/MieSystem/Views/Shared/_Layout.cshtml index 7607026..3cdfc5f 100644 --- a/MieSystem/Views/Shared/_Layout.cshtml +++ b/MieSystem/Views/Shared/_Layout.cshtml @@ -257,32 +257,32 @@ -
  • +
  • -
  • +
  • Niños
  • -
  • +
  • Maestros
  • -
  • +
  • - Personal + Personal
  • -
  • +
  • Reportes
  • -
  • +
  • Privacidad