183 lines
5.4 KiB
C#
183 lines
5.4 KiB
C#
using GPW.CORE.Data.DbModels;
|
|
using GPW.CORE.Data.DTO;
|
|
using GPW.CORE.Data.Services;
|
|
using GPW.CORE.WRKLOG.Components.Compo;
|
|
using Microsoft.AspNetCore.Components;
|
|
using System.Threading.Tasks;
|
|
using static EgwCoreLib.Razor.Toggler;
|
|
|
|
namespace GPW.CORE.WRKLOG.Components.Pages
|
|
{
|
|
public partial class DayOff
|
|
{
|
|
#region Protected Fields
|
|
|
|
protected int anno = DateTime.Today.Year;
|
|
|
|
protected DateTime oggi = DateTime.Today;
|
|
|
|
protected DateTime dtMax = DateTime.Today.AddMonths(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 void OnInitialized()
|
|
{
|
|
isLoading = true;
|
|
initToggler();
|
|
// recupero mesi da gestire
|
|
var monthConf = DataService.ConfigGetKey("NumMesiCalAzienda");
|
|
if (monthConf != null)
|
|
{
|
|
int intVal = 0;
|
|
int.TryParse(monthConf.valore, out intVal);
|
|
numMesi = intVal > 0 ? intVal : numMesi;
|
|
}
|
|
oggi = DateTime.Today;
|
|
dtMin = new DateTime(oggi.Year, 1, 1);
|
|
dtMax = dtMin.AddYears(1);
|
|
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 showMalattie { get; set; } = false;
|
|
private SelectGlobalToggle ToggleData { get; set; } = new SelectGlobalToggle();
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private async Task evToggled(SelectGlobalToggle newTogData)
|
|
{
|
|
ToggleData = newTogData;
|
|
showMalattie = !ToggleData.isActive;
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
private void ForceReloadCal()
|
|
{
|
|
ReloadData();
|
|
}
|
|
|
|
private void initToggler()
|
|
{
|
|
ToggleData = new SelectGlobalToggle()
|
|
{
|
|
leftString = "Malattie",
|
|
rightString = "Ferie e Permessi",
|
|
placardCss = "bg-light border-light text-dark",
|
|
};
|
|
}
|
|
|
|
private void ReloadData()
|
|
{
|
|
isLoading = true;
|
|
if (idxDipendente > 0)
|
|
{
|
|
// recupero direttamente da oggetto DB
|
|
SchedEvList = DataService.EventListPeriodo(idxDipendente, dtMin, dtMax);
|
|
listRecordsRichieste = DataService.RegRichiesteGetByDip(idxDipendente, dtMin, dtMax);
|
|
listCFF = DataService.CalFestFeriePeriodo(dtMin, dtMax);
|
|
}
|
|
PrepareDataset();
|
|
isLoading = false;
|
|
}
|
|
|
|
private List<RegRichiesteModel>? listRecordsRichieste = null;
|
|
private List<CalFesteFerieModel>? listCFF { get; set; } = null;
|
|
/// <summary>
|
|
/// Preparazione dataset da inviare all'obj
|
|
/// </summary>
|
|
private void PrepareDataset()
|
|
{
|
|
CurPar = new CalendarioAziendaleOld.ParamSet()
|
|
{
|
|
CalType = 1,
|
|
EvDtoList = SchedEvList,
|
|
ListRecordsRichieste = listRecordsRichieste,
|
|
ListFermateAzienda = listCFF,
|
|
firstDate = oggi,
|
|
IdxDip = idxDipendente,
|
|
minDate = dtMin,
|
|
maxDate = dtMax,
|
|
MonthDispl = numMesi,
|
|
ModoDisplay = BlazorCalendar.DisplayedView.Monthly
|
|
};
|
|
}
|
|
|
|
private CalendarioAziendaleOld.ParamSet CurPar = new CalendarioAziendaleOld.ParamSet();
|
|
|
|
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 Task.Delay(10);
|
|
ReloadData();
|
|
await Task.Delay(10);
|
|
}
|
|
}
|
|
|
|
private async Task SetMonth(int newNum)
|
|
{
|
|
if (numMesi != newNum)
|
|
{
|
|
numMesi = newNum;
|
|
}
|
|
await Task.Delay(10);
|
|
ReloadData();
|
|
await Task.Delay(10);
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |