145 lines
4.1 KiB
C#
145 lines
4.1 KiB
C#
using GPW.CORE.Data.DbModels;
|
|
using GPW.CORE.Data.DTO;
|
|
using GPW.CORE.Data.Services;
|
|
using Microsoft.AspNetCore.Components;
|
|
using static EgwCoreLib.Razor.Toggler;
|
|
|
|
namespace GPW.CORE.ADM.Components.Pages
|
|
{
|
|
public partial class RichiesteDip
|
|
{
|
|
#region Protected Fields
|
|
|
|
protected int anno = DateTime.Today.Year;
|
|
|
|
protected DateTime dtMax = DateTime.Today.AddYears(1);
|
|
|
|
protected DateTime dtMin = DateTime.Today;
|
|
|
|
protected int numMesi = 6;
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected MessageService AppMServ { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected GpwDataService DataService { get; set; } = null!;
|
|
|
|
protected int idxDipendente
|
|
{
|
|
get => AppMServ.IdxDipendente;
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
initToggler();
|
|
// recupero mesi da gestire
|
|
var monthConf = await DataService.ConfigGetKey("NumMesiCalAzienda");
|
|
if (monthConf != null)
|
|
{
|
|
int intVal = 0;
|
|
int.TryParse(monthConf.valore, out intVal);
|
|
numMesi = intVal > 0 ? intVal : numMesi;
|
|
}
|
|
// fix iniziale date... setup periodo (da rivedere in funzione eventi cambio mese dei controlli?!?)
|
|
DateTime oggi = DateTime.Today;
|
|
dtMin = new DateTime(oggi.Year - 1, 1, 1);
|
|
dtMax = dtMin.AddYears(3);
|
|
await ReloadData();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private bool isLoading = false;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private List<CalFesteFerieModel> ListFermateAzienda { get; set; } = new List<CalFesteFerieModel>();
|
|
|
|
private List<RegMalattieModel> ListMalattie { get; set; } = new List<RegMalattieModel>();
|
|
|
|
private List<RegRichiesteModel> ListRichiesteDip { get; set; } = new List<RegRichiesteModel>();
|
|
|
|
/// <summary>
|
|
/// Elenco eventi formato originale (EventDTO)
|
|
/// </summary>
|
|
private List<EventDTO> SchedEvList { get; set; } = new List<EventDTO>();
|
|
|
|
private bool OnlyNeedConf { get; set; } = false;
|
|
private SelectGlobalToggle ToggleData { get; set; } = new SelectGlobalToggle();
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private async Task evToggled(SelectGlobalToggle newTogData)
|
|
{
|
|
ToggleData = newTogData;
|
|
OnlyNeedConf = !ToggleData.isActive;
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
private async Task ForceReloadCal()
|
|
{
|
|
await ReloadData();
|
|
}
|
|
|
|
private void initToggler()
|
|
{
|
|
ToggleData = new SelectGlobalToggle()
|
|
{
|
|
leftString = "Da approvare",
|
|
rightString = "Tutti",
|
|
placardCss = "bg-light border-light text-dark",
|
|
};
|
|
}
|
|
|
|
private async Task ReloadData()
|
|
{
|
|
isLoading = true;
|
|
// recupero direttamente da oggetto DB
|
|
SchedEvList = await DataService.EventListPeriodo(idxDipendente, dtMin, dtMax);
|
|
isLoading = false;
|
|
}
|
|
|
|
private async Task SetDate(DateTime newDate)
|
|
{
|
|
// se la data fosse esterna all'intervallo considerato...)
|
|
if (newDate < dtMin || newDate > dtMax)
|
|
{
|
|
// verifico se "allargare" alla minima o alla massima
|
|
if (newDate < dtMin)
|
|
{
|
|
dtMin = new DateTime(newDate.Year - 1, 1, 1);
|
|
}
|
|
else
|
|
{
|
|
dtMax = new DateTime(newDate.Year + 1, 1, 1);
|
|
}
|
|
await ReloadData();
|
|
}
|
|
}
|
|
|
|
private async Task SetMonth(int newNum)
|
|
{
|
|
if (numMesi != newNum)
|
|
{
|
|
numMesi = newNum;
|
|
}
|
|
await ReloadData();
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |