202 lines
8.1 KiB
Plaintext
202 lines
8.1 KiB
Plaintext
@using System.Net.Http.Headers
|
|
@using System.Linq.Expressions
|
|
@using Newtonsoft.Json
|
|
@using System.Text
|
|
@using Serialize.Linq.Serializers
|
|
@using GestionPersonalWeb.Models
|
|
@using BlazorBootstrap
|
|
@using bdAntifraude.db
|
|
@using Microsoft.AspNetCore.Components
|
|
@rendermode InteractiveServer
|
|
@inject IJSRuntime JS
|
|
@inject NavigationManager NavigationManager
|
|
@inject IHttpClientFactory HttpClientFactory
|
|
@inject IHttpContextAccessor HttpContextAccessor
|
|
@inject UserState UserState
|
|
|
|
<div class="tablaTabLateral">
|
|
<input type="button" value="Nueva maternidad/riesgo de embarazo" @onclick="@(() => abrirPopupModificacion(new MATERNIDADES(), true))" class="mb-2 btnOAAFBlack" />
|
|
<div style="overflow-x:auto;" class="tablaDesk">
|
|
<Grid TItem="MATERNIDADES"
|
|
Class="table tablaRegPers"
|
|
Data="itmList"
|
|
AllowFiltering="false"
|
|
PageSize="10"
|
|
AllowPaging="true"
|
|
AllowSorting="true"
|
|
EmptyText="No se han encontrado datos"
|
|
Height="100"
|
|
PageSizeSelectorVisible="false"
|
|
PageSizeSelectorItems="@(new int[] { 5, 10, 20, 50 })"
|
|
Responsive="true"
|
|
PaginationItemsTextFormat="{0} - {1} de {2} elementos">
|
|
|
|
<GridColumns>
|
|
<GridColumn TItem="MATERNIDADES" HeaderText="">
|
|
<button @onclick="@(() => abrirPopupModificacion(context, false))" class="btnOAAFAzul">Editar</button>
|
|
</GridColumn>
|
|
<GridColumn TItem="MATERNIDADES" HeaderText="Fecha Inicio">
|
|
@context.FECHAINICIO?.ToString("dd/MM/yyyy")
|
|
</GridColumn>
|
|
<GridColumn TItem="MATERNIDADES" HeaderText="Fecha Fin">
|
|
@context.FECHAFIN?.ToString("dd/MM/yyyy")
|
|
</GridColumn>
|
|
<GridColumn TItem="MATERNIDADES" HeaderText="Base Cotización Seguridad Social">
|
|
@context.BASECOTIZACIONSEGURIDADSOCIAL
|
|
</GridColumn>
|
|
<GridColumn TItem="MATERNIDADES" HeaderText="Porcentaje Reducción Jornada">
|
|
@context.PORCENTAJEREDUCCIONJORNADA
|
|
</GridColumn>
|
|
<GridColumn TItem="MATERNIDADES" HeaderText="Riesgo Embarazo">
|
|
@if (context.RIESGOEMBARAZO)
|
|
{
|
|
<i class="fa-regular fa-square-check"></i>
|
|
}
|
|
</GridColumn>
|
|
<GridColumn TItem="MATERNIDADES" HeaderText="Nómina Normal">
|
|
@if (context.NOMINANORMAL)
|
|
{
|
|
<i class="fa-regular fa-square-check"></i>
|
|
}
|
|
</GridColumn>
|
|
<GridColumn TItem="MATERNIDADES" HeaderText="Nómina Seguridad Social">
|
|
@if (context.NOMINASEGURIDADSOCIAL)
|
|
{
|
|
<i class="fa-regular fa-square-check"></i>
|
|
}
|
|
</GridColumn>
|
|
</GridColumns>
|
|
</Grid>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<Modal @ref="popupGestionDatos" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
|
<BodyTemplate>
|
|
<div class="row">
|
|
|
|
<div class="col-md-6 mb-2">
|
|
<label class="fw-bold">Fecha inicio</label>
|
|
<input class="form-control" type="date" @bind-value="ItemEnEdicion.FECHAINICIO" />
|
|
</div>
|
|
<div class="col-md-6 mb-2">
|
|
<label class="fw-bold">Fecha fin</label>
|
|
<input class="form-control" type="date" @bind-value="ItemEnEdicion.FECHAFIN" />
|
|
</div>
|
|
<div class="col-md-12 mb-2">
|
|
<label for="txtEDesc" class="fw-bold">Base cotización seguridad social: </label>
|
|
<input class="form-control" type="number" @bind-value="@ItemEnEdicion.BASECOTIZACIONSEGURIDADSOCIAL" />
|
|
</div>
|
|
<div class="col-md-12 mb-2">
|
|
<label for="txtEDesc" class="fw-bold">Porcentaje reducción jornada: </label>
|
|
<input class="form-control" type="number" @bind-value="@ItemEnEdicion.PORCENTAJEREDUCCIONJORNADA" />
|
|
</div>
|
|
<div class="col-md-12" style="display:flex; justify-content:space-between">
|
|
<label for="txtEDesc" class="fw-bold">Riesgo embarazo: </label>
|
|
<input class="" type="checkbox" id="chbRiesgoEmbarazo" checked="@ItemEnEdicion.RIESGOEMBARAZO" />
|
|
|
|
<label for="txtEDesc" class="fw-bold">Nomina normal: </label>
|
|
<input class="" type="checkbox" id="chbNominaNormal" checked="@ItemEnEdicion.NOMINANORMAL" />
|
|
|
|
<label for="txtEDesc" class="fw-bold">Nomina seguridad social: </label>
|
|
<input class="" type="checkbox" id="chbNominaSS" checked="@ItemEnEdicion.NOMINASEGURIDADSOCIAL" />
|
|
</div>
|
|
</div>
|
|
</BodyTemplate>
|
|
<FooterTemplate>
|
|
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupModificacion">Cerrar</Button>
|
|
@if (ItemEnEdicion.IDMATERNIDADES != 0)
|
|
{
|
|
<Button Type="ButtonType.Submit" Color="ButtonColor.Primary" @onclick="@(() => GestionarDatos(false))">Modificar</Button>
|
|
}
|
|
else
|
|
{
|
|
<Button Type="ButtonType.Submit" Color="ButtonColor.Primary" @onclick="@(() => GestionarDatos(true))">Crear</Button>
|
|
}
|
|
</FooterTemplate>
|
|
</Modal>
|
|
|
|
|
|
@code {
|
|
[Parameter]
|
|
public PERSONAS Persona { get; set; } = new PERSONAS();
|
|
private HttpClient cliente = new HttpClient();
|
|
private Modal popupGestionDatos = default;
|
|
[Parameter]
|
|
public EventCallback OnPersonaActualizada { get; set; }
|
|
private MATERNIDADES ItemEnEdicion { get; set; } = new MATERNIDADES();
|
|
// private List<int?> meses = new List<int?>();
|
|
private List<MATERNIDADES> itmList = new List<MATERNIDADES>();
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory);
|
|
await CargarListas();
|
|
}
|
|
private async Task CargarListas()
|
|
{
|
|
|
|
itmList.Clear();
|
|
try
|
|
{
|
|
foreach (MATERNIDADES enf in Persona.MATERNIDADES)
|
|
{
|
|
itmList.Add(enf);
|
|
}
|
|
StateHasChanged();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Console.WriteLine($"Error al obtener los datos: {e.Message}");
|
|
}
|
|
}
|
|
private async Task GestionarDatos(bool tipo)
|
|
{
|
|
var inci = ItemEnEdicion;
|
|
if (tipo == true)
|
|
{
|
|
inci.IDMATERNIDADES = 0;
|
|
}
|
|
inci.IDPERSONA = Persona.IDPERSONA;
|
|
|
|
string chbRiesgoEmbarazo = "chbRiesgoEmbarazo";
|
|
inci.RIESGOEMBARAZO = await JS.InvokeAsync<bool>("obtenerCheck", chbRiesgoEmbarazo);
|
|
string chbNominaNormal = "chbNominaNormal";
|
|
inci.NOMINANORMAL = await JS.InvokeAsync<bool>("obtenerCheck", chbNominaNormal);
|
|
string chbNominaSS = "chbNominaSS";
|
|
inci.NOMINASEGURIDADSOCIAL = await JS.InvokeAsync<bool>("obtenerCheck", chbNominaSS);
|
|
|
|
|
|
|
|
if (inci.IDMATERNIDADES != 0)
|
|
{
|
|
var response = await Utilidades.ActualizarObjeto(cliente, "/api/MATERNIDADES/" + inci.IDMATERNIDADES, inci);
|
|
}
|
|
else
|
|
{
|
|
var response = await Utilidades.NuevoObjeto(cliente, "/api/MATERNIDADES/", inci);
|
|
}
|
|
await cerrarPopupModificacion();
|
|
var response1 = await cliente.GetAsync($"/api/PERSONAS/PersonaNominaNif/{Persona.NIF}");
|
|
if (!response1.IsSuccessStatusCode)
|
|
{
|
|
throw new Exception($"Error al obtener los datos de la persona. Código: {response1.StatusCode}");
|
|
}
|
|
|
|
var resultContent = await response1.Content.ReadAsStringAsync();
|
|
Persona = JsonConvert.DeserializeObject<PERSONAS>(resultContent) ?? throw new Exception("Error al deserializar los datos de la persona.");
|
|
await CargarListas();
|
|
|
|
|
|
}
|
|
private async Task abrirPopupModificacion(MATERNIDADES objeto, bool esNuevo)
|
|
{
|
|
ItemEnEdicion = objeto;
|
|
await popupGestionDatos.ShowAsync();
|
|
}
|
|
private async Task cerrarPopupModificacion()
|
|
{
|
|
await popupGestionDatos.HideAsync();
|
|
}
|
|
}
|