first commit

This commit is contained in:
2026-01-10 23:14:51 -06:00
commit 389715b4b4
503 changed files with 98244 additions and 0 deletions

View File

@@ -0,0 +1,262 @@
@model Rs_system.Models.ViewModels.RegistroCultoViewModel
@{
ViewData["Title"] = "Nuevo Registro de Ofrendas";
}
<div class="d-flex justify-content-between align-items-center mb-4">
<div>
<h4 class="mb-1">Nuevo Registro de Ofrendas</h4>
<p class="text-muted mb-0">Registrar ofrendas de un culto</p>
</div>
<a asp-action="Index" class="btn btn-outline-secondary">
<i class="bi bi-arrow-left me-1"></i> Volver
</a>
</div>
<form asp-action="Create" method="post" id="ofrendaForm">
<div asp-validation-summary="ModelOnly" class="alert alert-danger"></div>
<div class="row">
<!-- Left Column: Basic Info -->
<div class="col-lg-4">
<div class="card-custom">
<h6 class="mb-3"><i class="bi bi-calendar-event me-2"></i>Información del Culto</h6>
<div class="mb-3">
<label asp-for="Fecha" class="form-label"></label>
<input asp-for="Fecha" class="form-control" type="date" />
<span asp-validation-for="Fecha" class="text-danger"></span>
</div>
<div class="mb-3">
<label asp-for="Observaciones" class="form-label"></label>
<textarea asp-for="Observaciones" class="form-control" rows="3" placeholder="Notas adicionales..."></textarea>
<span asp-validation-for="Observaciones" class="text-danger"></span>
</div>
</div>
<!-- Summary -->
<div class="card-custom mt-3">
<h6 class="mb-3"><i class="bi bi-calculator me-2"></i>Resumen</h6>
<div class="d-flex justify-content-between mb-2">
<span>Total Ofrendas:</span>
<strong id="totalOfrendas">$ 0.00</strong>
</div>
<div class="d-flex justify-content-between mb-2">
<span>Total Descuentos:</span>
<strong id="totalDescuentos" class="text-warning">$ 0.00</strong>
</div>
<hr>
<div class="d-flex justify-content-between">
<span class="fw-bold">Monto Neto:</span>
<strong id="montoNeto" class="text-success fs-5">$ 0.00</strong>
</div>
</div>
</div>
<!-- Right Column: Offerings -->
<div class="col-lg-8">
<div class="card-custom">
<div class="d-flex justify-content-between align-items-center mb-3">
<h6 class="mb-0"><i class="bi bi-cash-stack me-2"></i>Ofrendas</h6>
<button type="button" class="btn btn-sm btn-primary-custom" onclick="addOfrenda()">
<i class="bi bi-plus-lg me-1"></i> Agregar Ofrenda
</button>
</div>
<div id="ofrendasContainer">
<!-- Offerings will be added here dynamically -->
</div>
<div id="emptyState" class="text-center text-muted py-4">
<i class="bi bi-plus-circle fs-1 d-block mb-2"></i>
Haga clic en "Agregar Ofrenda" para comenzar
</div>
</div>
</div>
</div>
<div class="mt-4 text-end">
<a asp-action="Index" class="btn btn-outline-secondary me-2">Cancelar</a>
<button type="submit" class="btn btn-primary-custom">
<i class="bi bi-check-lg me-1"></i> Guardar Registro
</button>
</div>
</form>
<!-- Ofrenda Template -->
<template id="ofrendaTemplate">
<div class="ofrenda-item card mb-3" data-index="0">
<div class="card-header bg-light d-flex justify-content-between align-items-center py-2">
<span class="fw-semibold">Ofrenda #<span class="ofrenda-number">1</span></span>
<button type="button" class="btn btn-sm btn-outline-danger" onclick="removeOfrenda(this)">
<i class="bi bi-trash"></i>
</button>
</div>
<div class="card-body">
<div class="row mb-3">
<div class="col-md-6">
<label class="form-label">Concepto *</label>
<input type="text" name="Ofrendas[0].Concepto" class="form-control" placeholder="Ej: Ofrenda general" required />
</div>
<div class="col-md-6">
<label class="form-label">Monto *</label>
<div class="input-group">
<span class="input-group-text">$</span>
<input type="number" step="0.01" min="0.01" name="Ofrendas[0].Monto" class="form-control ofrenda-monto" placeholder="0.00" required onchange="calculateTotals()" />
</div>
</div>
</div>
<div class="descuentos-section">
<div class="d-flex justify-content-between align-items-center mb-2">
<small class="text-muted"><i class="bi bi-dash-circle me-1"></i>Descuentos</small>
<button type="button" class="btn btn-sm btn-outline-warning" onclick="addDescuento(this)">
<i class="bi bi-plus"></i> Agregar Descuento
</button>
</div>
<div class="descuentos-container">
<!-- Descuentos will be added here -->
</div>
</div>
<div class="mt-3 pt-2 border-top d-flex justify-content-end">
<span class="text-muted me-2">Neto:</span>
<strong class="ofrenda-neto text-success">$ 0.00</strong>
</div>
</div>
</div>
</template>
<!-- Descuento Template -->
<template id="descuentoTemplate">
<div class="descuento-item row g-2 mb-2">
<div class="col-md-5">
<input type="text" name="Ofrendas[0].Descuentos[0].Concepto" class="form-control form-control-sm" placeholder="Concepto descuento" required />
</div>
<div class="col-md-5">
<div class="input-group input-group-sm">
<span class="input-group-text">$</span>
<input type="number" step="0.01" min="0.01" name="Ofrendas[0].Descuentos[0].Monto" class="form-control descuento-monto" placeholder="0.00" required onchange="calculateTotals()" />
</div>
</div>
<div class="col-md-2">
<button type="button" class="btn btn-sm btn-outline-danger w-100" onclick="removeDescuento(this)">
<i class="bi bi-x"></i>
</button>
</div>
</div>
</template>
@section Scripts {
<script>
let ofrendaIndex = 0;
function addOfrenda() {
const container = document.getElementById('ofrendasContainer');
const template = document.getElementById('ofrendaTemplate');
const clone = template.content.cloneNode(true);
// Update indices
const ofrendaItem = clone.querySelector('.ofrenda-item');
ofrendaItem.dataset.index = ofrendaIndex;
ofrendaItem.querySelector('.ofrenda-number').textContent = ofrendaIndex + 1;
// Update input names
clone.querySelectorAll('[name]').forEach(input => {
input.name = input.name.replace('[0]', `[${ofrendaIndex}]`);
});
container.appendChild(clone);
document.getElementById('emptyState').style.display = 'none';
ofrendaIndex++;
calculateTotals();
}
function removeOfrenda(btn) {
btn.closest('.ofrenda-item').remove();
updateOfrendaIndices();
calculateTotals();
if (document.querySelectorAll('.ofrenda-item').length === 0) {
document.getElementById('emptyState').style.display = 'block';
}
}
function addDescuento(btn) {
const ofrendaItem = btn.closest('.ofrenda-item');
const ofrendaIdx = ofrendaItem.dataset.index;
const container = ofrendaItem.querySelector('.descuentos-container');
const descuentoIdx = container.querySelectorAll('.descuento-item').length;
const template = document.getElementById('descuentoTemplate');
const clone = template.content.cloneNode(true);
// Update input names
clone.querySelectorAll('[name]').forEach(input => {
input.name = input.name.replace('Ofrendas[0]', `Ofrendas[${ofrendaIdx}]`);
input.name = input.name.replace('Descuentos[0]', `Descuentos[${descuentoIdx}]`);
});
container.appendChild(clone);
calculateTotals();
}
function removeDescuento(btn) {
btn.closest('.descuento-item').remove();
updateDescuentoIndices();
calculateTotals();
}
function updateOfrendaIndices() {
document.querySelectorAll('.ofrenda-item').forEach((item, idx) => {
item.dataset.index = idx;
item.querySelector('.ofrenda-number').textContent = idx + 1;
item.querySelectorAll('[name^="Ofrendas["]').forEach(input => {
input.name = input.name.replace(/Ofrendas\[\d+\]/, `Ofrendas[${idx}]`);
});
});
ofrendaIndex = document.querySelectorAll('.ofrenda-item').length;
}
function updateDescuentoIndices() {
document.querySelectorAll('.ofrenda-item').forEach((ofrendaItem) => {
ofrendaItem.querySelectorAll('.descuento-item').forEach((descItem, descIdx) => {
descItem.querySelectorAll('[name*="Descuentos["]').forEach(input => {
input.name = input.name.replace(/Descuentos\[\d+\]/, `Descuentos[${descIdx}]`);
});
});
});
}
function calculateTotals() {
let totalOfrendas = 0;
let totalDescuentos = 0;
document.querySelectorAll('.ofrenda-item').forEach(item => {
const monto = parseFloat(item.querySelector('.ofrenda-monto').value) || 0;
let descuentosSum = 0;
item.querySelectorAll('.descuento-monto').forEach(descInput => {
descuentosSum += parseFloat(descInput.value) || 0;
});
const neto = monto - descuentosSum;
item.querySelector('.ofrenda-neto').textContent = `$ ${neto.toFixed(2)}`;
totalOfrendas += monto;
totalDescuentos += descuentosSum;
});
document.getElementById('totalOfrendas').textContent = `$ ${totalOfrendas.toFixed(2)}`;
document.getElementById('totalDescuentos').textContent = `$ ${totalDescuentos.toFixed(2)}`;
document.getElementById('montoNeto').textContent = `$ ${(totalOfrendas - totalDescuentos).toFixed(2)}`;
}
// Add first ofrenda on page load
document.addEventListener('DOMContentLoaded', function() {
addOfrenda();
});
</script>
}

View File

@@ -0,0 +1,120 @@
@model Rs_system.Models.RegistroCulto
@{
ViewData["Title"] = "Detalles del Registro";
}
<div class="d-flex justify-content-between align-items-center mb-4">
<div>
<h4 class="mb-1">Detalles del Registro</h4>
<p class="text-muted mb-0">@Model.Fecha.ToString("dddd, dd 'de' MMMM 'de' yyyy")</p>
</div>
<div>
<a asp-action="Edit" asp-route-id="@Model.Id" class="btn btn-outline-primary me-2">
<i class="bi bi-pencil me-1"></i> Editar
</a>
<a asp-action="Index" class="btn btn-outline-secondary">
<i class="bi bi-arrow-left me-1"></i> Volver
</a>
</div>
</div>
<div class="row">
<!-- Left Column: Summary -->
<div class="col-lg-4">
<div class="card-custom">
<h6 class="mb-3"><i class="bi bi-info-circle me-2"></i>Información General</h6>
<dl class="mb-0">
<dt class="text-muted">Fecha</dt>
<dd>@Model.Fecha.ToString("dd/MM/yyyy")</dd>
<dt class="text-muted">Observaciones</dt>
<dd>@(string.IsNullOrEmpty(Model.Observaciones) ? "Sin observaciones" : Model.Observaciones)</dd>
<dt class="text-muted">Registrado por</dt>
<dd>@(Model.CreadoPor ?? "Sistema")</dd>
<dt class="text-muted">Fecha de Registro</dt>
<dd>@Model.CreadoEn.ToString("dd/MM/yyyy HH:mm")</dd>
</dl>
</div>
<!-- Summary Card -->
<div class="card-custom mt-3">
<h6 class="mb-3"><i class="bi bi-calculator me-2"></i>Resumen</h6>
<div class="d-flex justify-content-between mb-2">
<span>Total Ofrendas:</span>
<strong>$ @Model.TotalOfrendas.ToString("N2")</strong>
</div>
<div class="d-flex justify-content-between mb-2">
<span>Total Descuentos:</span>
<strong class="text-warning">$ @Model.TotalDescuentos.ToString("N2")</strong>
</div>
<hr>
<div class="d-flex justify-content-between">
<span class="fw-bold">Monto Neto:</span>
<strong class="text-success fs-5">$ @Model.MontoNeto.ToString("N2")</strong>
</div>
</div>
</div>
<!-- Right Column: Offerings Detail -->
<div class="col-lg-8">
<div class="card-custom">
<h6 class="mb-3"><i class="bi bi-cash-stack me-2"></i>Detalle de Ofrendas</h6>
@if (!Model.Ofrendas.Any())
{
<div class="text-center text-muted py-4">
<i class="bi bi-inbox fs-1 d-block mb-2"></i>
No hay ofrendas registradas
</div>
}
else
{
@foreach (var ofrenda in Model.Ofrendas)
{
<div class="card mb-3">
<div class="card-header bg-light d-flex justify-content-between align-items-center py-2">
<span class="fw-semibold">@ofrenda.Concepto</span>
<span class="badge bg-primary">$ @ofrenda.Monto.ToString("N2")</span>
</div>
<div class="card-body py-2">
@if (ofrenda.Descuentos.Any())
{
<table class="table table-sm mb-0">
<thead>
<tr class="text-muted">
<th>Descuento</th>
<th class="text-end">Monto</th>
</tr>
</thead>
<tbody>
@foreach (var descuento in ofrenda.Descuentos)
{
<tr>
<td>@descuento.Concepto</td>
<td class="text-end text-warning">-$ @descuento.Monto.ToString("N2")</td>
</tr>
}
</tbody>
<tfoot>
<tr class="border-top">
<th>Neto</th>
<th class="text-end text-success">$ @ofrenda.MontoNeto.ToString("N2")</th>
</tr>
</tfoot>
</table>
}
else
{
<p class="text-muted mb-0 small">Sin descuentos aplicados</p>
}
</div>
</div>
}
}
</div>
</div>
</div>

View File

@@ -0,0 +1,294 @@
@model Rs_system.Models.ViewModels.RegistroCultoViewModel
@{
ViewData["Title"] = "Editar Registro de Ofrendas";
}
<div class="d-flex justify-content-between align-items-center mb-4">
<div>
<h4 class="mb-1">Editar Registro de Ofrendas</h4>
<p class="text-muted mb-0">Modificar registro del @Model.Fecha.ToString("dd/MM/yyyy")</p>
</div>
<a asp-action="Index" class="btn btn-outline-secondary">
<i class="bi bi-arrow-left me-1"></i> Volver
</a>
</div>
<form asp-action="Edit" method="post" id="ofrendaForm">
<input type="hidden" asp-for="Id" />
<div asp-validation-summary="ModelOnly" class="alert alert-danger"></div>
<div class="row">
<!-- Left Column: Basic Info -->
<div class="col-lg-4">
<div class="card-custom">
<h6 class="mb-3"><i class="bi bi-calendar-event me-2"></i>Información del Culto</h6>
<div class="mb-3">
<label asp-for="Fecha" class="form-label"></label>
<input asp-for="Fecha" class="form-control" type="date" />
<span asp-validation-for="Fecha" class="text-danger"></span>
</div>
<div class="mb-3">
<label asp-for="Observaciones" class="form-label"></label>
<textarea asp-for="Observaciones" class="form-control" rows="3" placeholder="Notas adicionales..."></textarea>
<span asp-validation-for="Observaciones" class="text-danger"></span>
</div>
</div>
<!-- Summary -->
<div class="card-custom mt-3">
<h6 class="mb-3"><i class="bi bi-calculator me-2"></i>Resumen</h6>
<div class="d-flex justify-content-between mb-2">
<span>Total Ofrendas:</span>
<strong id="totalOfrendas">$ 0.00</strong>
</div>
<div class="d-flex justify-content-between mb-2">
<span>Total Descuentos:</span>
<strong id="totalDescuentos" class="text-warning">$ 0.00</strong>
</div>
<hr>
<div class="d-flex justify-content-between">
<span class="fw-bold">Monto Neto:</span>
<strong id="montoNeto" class="text-success fs-5">$ 0.00</strong>
</div>
</div>
</div>
<!-- Right Column: Offerings -->
<div class="col-lg-8">
<div class="card-custom">
<div class="d-flex justify-content-between align-items-center mb-3">
<h6 class="mb-0"><i class="bi bi-cash-stack me-2"></i>Ofrendas</h6>
<button type="button" class="btn btn-sm btn-primary-custom" onclick="addOfrenda()">
<i class="bi bi-plus-lg me-1"></i> Agregar Ofrenda
</button>
</div>
<div id="ofrendasContainer">
<!-- Existing offerings will be loaded here -->
</div>
<div id="emptyState" class="text-center text-muted py-4" style="display: none;">
<i class="bi bi-plus-circle fs-1 d-block mb-2"></i>
Haga clic en "Agregar Ofrenda" para comenzar
</div>
</div>
</div>
</div>
<div class="mt-4 text-end">
<a asp-action="Index" class="btn btn-outline-secondary me-2">Cancelar</a>
<button type="submit" class="btn btn-primary-custom">
<i class="bi bi-check-lg me-1"></i> Guardar Cambios
</button>
</div>
</form>
<!-- Ofrenda Template -->
<template id="ofrendaTemplate">
<div class="ofrenda-item card mb-3" data-index="0">
<div class="card-header bg-light d-flex justify-content-between align-items-center py-2">
<span class="fw-semibold">Ofrenda #<span class="ofrenda-number">1</span></span>
<button type="button" class="btn btn-sm btn-outline-danger" onclick="removeOfrenda(this)">
<i class="bi bi-trash"></i>
</button>
</div>
<div class="card-body">
<div class="row mb-3">
<div class="col-md-6">
<label class="form-label">Concepto *</label>
<input type="text" name="Ofrendas[0].Concepto" class="form-control ofrenda-concepto" placeholder="Ej: Ofrenda general" required />
</div>
<div class="col-md-6">
<label class="form-label">Monto *</label>
<div class="input-group">
<span class="input-group-text">$</span>
<input type="number" step="0.01" min="0.01" name="Ofrendas[0].Monto" class="form-control ofrenda-monto" placeholder="0.00" required onchange="calculateTotals()" />
</div>
</div>
</div>
<div class="descuentos-section">
<div class="d-flex justify-content-between align-items-center mb-2">
<small class="text-muted"><i class="bi bi-dash-circle me-1"></i>Descuentos</small>
<button type="button" class="btn btn-sm btn-outline-warning" onclick="addDescuento(this)">
<i class="bi bi-plus"></i> Agregar Descuento
</button>
</div>
<div class="descuentos-container">
<!-- Descuentos will be added here -->
</div>
</div>
<div class="mt-3 pt-2 border-top d-flex justify-content-end">
<span class="text-muted me-2">Neto:</span>
<strong class="ofrenda-neto text-success">$ 0.00</strong>
</div>
</div>
</div>
</template>
<!-- Descuento Template -->
<template id="descuentoTemplate">
<div class="descuento-item row g-2 mb-2">
<div class="col-md-5">
<input type="text" name="Ofrendas[0].Descuentos[0].Concepto" class="form-control form-control-sm descuento-concepto" placeholder="Concepto descuento" required />
</div>
<div class="col-md-5">
<div class="input-group input-group-sm">
<span class="input-group-text">$</span>
<input type="number" step="0.01" min="0.01" name="Ofrendas[0].Descuentos[0].Monto" class="form-control descuento-monto" placeholder="0.00" required onchange="calculateTotals()" />
</div>
</div>
<div class="col-md-2">
<button type="button" class="btn btn-sm btn-outline-danger w-100" onclick="removeDescuento(this)">
<i class="bi bi-x"></i>
</button>
</div>
</div>
</template>
@section Scripts {
<script>
let ofrendaIndex = 0;
// Existing data from model
const existingData = @Html.Raw(System.Text.Json.JsonSerializer.Serialize(Model.Ofrendas));
function addOfrenda(concepto = '', monto = 0, descuentos = []) {
const container = document.getElementById('ofrendasContainer');
const template = document.getElementById('ofrendaTemplate');
const clone = template.content.cloneNode(true);
// Update indices
const ofrendaItem = clone.querySelector('.ofrenda-item');
ofrendaItem.dataset.index = ofrendaIndex;
ofrendaItem.querySelector('.ofrenda-number').textContent = ofrendaIndex + 1;
// Update input names and values
clone.querySelectorAll('[name]').forEach(input => {
input.name = input.name.replace('[0]', `[${ofrendaIndex}]`);
});
// Set values
clone.querySelector('.ofrenda-concepto').value = concepto;
clone.querySelector('.ofrenda-monto').value = monto || '';
container.appendChild(clone);
// Add existing descuentos
const addedItem = container.lastElementChild;
descuentos.forEach(d => {
addDescuentoToItem(addedItem, d.concepto, d.monto);
});
document.getElementById('emptyState').style.display = 'none';
ofrendaIndex++;
calculateTotals();
}
function removeOfrenda(btn) {
btn.closest('.ofrenda-item').remove();
updateOfrendaIndices();
calculateTotals();
if (document.querySelectorAll('.ofrenda-item').length === 0) {
document.getElementById('emptyState').style.display = 'block';
}
}
function addDescuento(btn) {
addDescuentoToItem(btn.closest('.ofrenda-item'));
}
function addDescuentoToItem(ofrendaItem, concepto = '', monto = 0) {
const ofrendaIdx = ofrendaItem.dataset.index;
const container = ofrendaItem.querySelector('.descuentos-container');
const descuentoIdx = container.querySelectorAll('.descuento-item').length;
const template = document.getElementById('descuentoTemplate');
const clone = template.content.cloneNode(true);
// Update input names
clone.querySelectorAll('[name]').forEach(input => {
input.name = input.name.replace('Ofrendas[0]', `Ofrendas[${ofrendaIdx}]`);
input.name = input.name.replace('Descuentos[0]', `Descuentos[${descuentoIdx}]`);
});
// Set values
clone.querySelector('.descuento-concepto').value = concepto;
clone.querySelector('.descuento-monto').value = monto || '';
container.appendChild(clone);
calculateTotals();
}
function removeDescuento(btn) {
btn.closest('.descuento-item').remove();
updateDescuentoIndices();
calculateTotals();
}
function updateOfrendaIndices() {
document.querySelectorAll('.ofrenda-item').forEach((item, idx) => {
item.dataset.index = idx;
item.querySelector('.ofrenda-number').textContent = idx + 1;
item.querySelectorAll('[name^="Ofrendas["]').forEach(input => {
input.name = input.name.replace(/Ofrendas\[\d+\]/, `Ofrendas[${idx}]`);
});
});
ofrendaIndex = document.querySelectorAll('.ofrenda-item').length;
}
function updateDescuentoIndices() {
document.querySelectorAll('.ofrenda-item').forEach((ofrendaItem) => {
ofrendaItem.querySelectorAll('.descuento-item').forEach((descItem, descIdx) => {
descItem.querySelectorAll('[name*="Descuentos["]').forEach(input => {
input.name = input.name.replace(/Descuentos\[\d+\]/, `Descuentos[${descIdx}]`);
});
});
});
}
function calculateTotals() {
let totalOfrendas = 0;
let totalDescuentos = 0;
document.querySelectorAll('.ofrenda-item').forEach(item => {
const monto = parseFloat(item.querySelector('.ofrenda-monto').value) || 0;
let descuentosSum = 0;
item.querySelectorAll('.descuento-monto').forEach(descInput => {
descuentosSum += parseFloat(descInput.value) || 0;
});
const neto = monto - descuentosSum;
item.querySelector('.ofrenda-neto').textContent = `$ ${neto.toFixed(2)}`;
totalOfrendas += monto;
totalDescuentos += descuentosSum;
});
document.getElementById('totalOfrendas').textContent = `$ ${totalOfrendas.toFixed(2)}`;
document.getElementById('totalDescuentos').textContent = `$ ${totalDescuentos.toFixed(2)}`;
document.getElementById('montoNeto').textContent = `$ ${(totalOfrendas - totalDescuentos).toFixed(2)}`;
}
// Load existing data on page load
document.addEventListener('DOMContentLoaded', function() {
if (existingData && existingData.length > 0) {
existingData.forEach(ofrenda => {
addOfrenda(
ofrenda.concepto,
ofrenda.monto,
ofrenda.descuentos.map(d => ({ concepto: d.concepto, monto: d.monto }))
);
});
} else {
addOfrenda();
}
});
</script>
}

View File

@@ -0,0 +1,152 @@
@model IEnumerable<Rs_system.Models.RegistroCulto>
@{
ViewData["Title"] = "Registro de Ofrendas";
}
<div class="d-flex justify-content-between align-items-center mb-4">
<div>
<h4 class="mb-1">Registro de Ofrendas</h4>
<p class="text-muted mb-0">Gestión de ofrendas por culto</p>
</div>
<a asp-action="Create" class="btn btn-primary-custom">
<i class="bi bi-plus-lg me-1"></i> Nuevo Registro
</a>
</div>
<!-- Filters -->
<div class="card-custom mb-4">
<form method="get" class="row g-3 align-items-end">
<div class="col-md-3">
<label class="form-label">Mes</label>
<select name="mes" class="form-select" asp-items="@(ViewBag.Meses as List<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>)">
</select>
</div>
<div class="col-md-3">
<label class="form-label">Año</label>
<select name="anio" class="form-select" asp-items="@(ViewBag.Anios as List<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>)">
</select>
</div>
<div class="col-md-3">
<button type="submit" class="btn btn-outline-primary">
<i class="bi bi-funnel me-1"></i> Filtrar
</button>
</div>
</form>
</div>
<script>
document.querySelector('select[name="mes"]').value = '@ViewBag.MesActual';
document.querySelector('select[name="anio"]').value = '@ViewBag.AnioActual';
</script>
<!-- Summary Cards -->
<div class="row mb-4">
<div class="col-md-4">
<div class="card-custom text-center">
<h6 class="text-muted mb-2">Total Ofrendas</h6>
<h3 class="text-primary mb-0">$ @Model.Sum(r => r.TotalOfrendas).ToString("N2")</h3>
</div>
</div>
<div class="col-md-4">
<div class="card-custom text-center">
<h6 class="text-muted mb-2">Total Descuentos</h6>
<h3 class="text-warning mb-0">$ @Model.Sum(r => r.TotalDescuentos).ToString("N2")</h3>
</div>
</div>
<div class="col-md-4">
<div class="card-custom text-center">
<h6 class="text-muted mb-2">Monto Neto</h6>
<h3 class="text-success mb-0">$ @Model.Sum(r => r.MontoNeto).ToString("N2")</h3>
</div>
</div>
</div>
<!-- Records Table -->
<div class="card-custom">
<div class="table-responsive">
<table class="table-custom">
<thead>
<tr>
<th>Fecha</th>
<th>Ofrendas</th>
<th class="text-end">Total</th>
<th class="text-end">Descuentos</th>
<th class="text-end">Neto</th>
<th class="text-center">Acciones</th>
</tr>
</thead>
<tbody>
@if (!Model.Any())
{
<tr>
<td colspan="6" class="text-center text-muted py-4">
<i class="bi bi-inbox fs-1 d-block mb-2"></i>
No hay registros para el período seleccionado
</td>
</tr>
}
@foreach (var registro in Model)
{
<tr>
<td>
<strong>@registro.Fecha.ToString("dd/MM/yyyy")</strong>
<br>
<small class="text-muted">@registro.Fecha.DayOfWeek</small>
</td>
<td>
@foreach (var ofrenda in registro.Ofrendas.Take(3))
{
<span class="badge bg-light text-dark me-1">@ofrenda.Concepto</span>
}
@if (registro.Ofrendas.Count > 3)
{
<span class="badge bg-secondary">+@(registro.Ofrendas.Count - 3) más</span>
}
</td>
<td class="text-end">$ @registro.TotalOfrendas.ToString("N2")</td>
<td class="text-end text-warning">$ @registro.TotalDescuentos.ToString("N2")</td>
<td class="text-end text-success fw-bold">$ @registro.MontoNeto.ToString("N2")</td>
<td class="text-center">
<a asp-action="Details" asp-route-id="@registro.Id" class="btn btn-sm btn-outline-primary" title="Ver detalles">
<i class="bi bi-eye"></i>
</a>
<a asp-action="Edit" asp-route-id="@registro.Id" class="btn btn-sm btn-outline-secondary" title="Editar">
<i class="bi bi-pencil"></i>
</a>
<button type="button" class="btn btn-sm btn-outline-danger" onclick="confirmDelete(@registro.Id)" title="Eliminar">
<i class="bi bi-trash"></i>
</button>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
<!-- Delete Form -->
<form id="deleteForm" asp-action="Delete" method="post" style="display: none;">
<input type="hidden" name="id" id="deleteId" />
</form>
@section Scripts {
<script>
function confirmDelete(id) {
Swal.fire({
title: '¿Eliminar registro?',
text: 'Esta acción no se puede deshacer.',
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#d33',
cancelButtonColor: '#6c757d',
confirmButtonText: 'Sí, eliminar',
cancelButtonText: 'Cancelar'
}).then((result) => {
if (result.isConfirmed) {
document.getElementById('deleteId').value = id;
document.getElementById('deleteForm').submit();
}
});
}
</script>
}