359 lines
11 KiB
C#
359 lines
11 KiB
C#
using EgwCoreLib.Razor.Data;
|
|
using GPW.CORE.Data;
|
|
using GPW.CORE.Data.DbModels;
|
|
using GPW.CORE.Data.DTO;
|
|
using GPW.CORE.Smart8.Data;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace GPW.CORE.Smart8.Components.Compo
|
|
{
|
|
public partial class Calendario : IDisposable
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public CalendarModeEnum.modoControllo currMode { get; set; } = CalendarModeEnum.modoControllo.showCalendar;
|
|
|
|
[Parameter]
|
|
public int IdxDipendente { get; set; } = -1;
|
|
|
|
[Parameter]
|
|
public List<CalFesteFerieModel>? ListFermateAzienda { get; set; }
|
|
|
|
[Parameter]
|
|
public List<DailyDataDTO>? ListRecords { get; set; }
|
|
|
|
[Parameter]
|
|
public List<RegRichiesteModel>? ListRecordsRichieste
|
|
{
|
|
get => listRecordsRichieste;
|
|
set => listRecordsRichieste = value;
|
|
}
|
|
|
|
[Parameter]
|
|
public EventCallback<bool> ReqReload { get; set; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
public void Dispose()
|
|
{
|
|
DateCheck = new Dictionary<DateTime, string>();
|
|
DateCFF = new Dictionary<DateTime, string>();
|
|
ListRecords = null;
|
|
listRecordsRichieste = null;
|
|
GC.Collect();
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Fields
|
|
|
|
protected DailyDataDTO? datiGiorno = null;
|
|
protected string emptyTime = "--/--";
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Properties
|
|
|
|
protected string baseUrl
|
|
{
|
|
get => configuration.GetValue<string>("OptConf:BaseUrl") ?? "~/";
|
|
}
|
|
|
|
[Inject]
|
|
protected IConfiguration configuration { get; set; } = null!;
|
|
|
|
protected DateTime dtMancTimb { get; set; } = Utils.InitDatetime(DateTime.Now, 5);
|
|
protected bool isApprovedEntr { get; set; } = true;
|
|
protected bool isApprovedEsc { get; set; } = true;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
ReloadData();
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private Dictionary<DateTime, string> DateCFF = new Dictionary<DateTime, string>();
|
|
private Dictionary<DateTime, string> DateCheck = new Dictionary<DateTime, string>();
|
|
|
|
private Dictionary<DateTime, string> DateFerFestCheck = new Dictionary<DateTime, string>();
|
|
|
|
private Dictionary<DateTime, string> DatePermCheck = new Dictionary<DateTime, string>();
|
|
|
|
private List<RegAttivitaModel>? listaP = new List<RegAttivitaModel>();
|
|
|
|
private List<List<RegAttivitaModel>?> listRA = null!;
|
|
|
|
private List<TimbratureModel>? listTimb = null;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
[Inject]
|
|
private CoreSmartDataService CDService { get; set; } = null!;
|
|
|
|
private DateTime dtCurr { get; set; } = DateTime.Today;
|
|
|
|
private List<CalFesteFerieModel>? listCFF { get; set; } = null;
|
|
private List<DailyDataDTO>? listRecords { get; set; } = null;
|
|
private List<RegRichiesteModel>? listRecordsRichieste { get; set; } = null;
|
|
|
|
[Inject]
|
|
private MessageService MService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private NavigationManager navManager { get; set; } = null!;
|
|
|
|
private bool showDetail { get; set; } = false;
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private async Task backToGauge()
|
|
{
|
|
setModeDetail();
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
private string cssChooseEntr(DateTime? dtRif)
|
|
{
|
|
string answ = "";
|
|
try
|
|
{
|
|
answ = (isApprovedEntr) ? "text-entrata" : "text-danger";
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
|
|
private string cssChooseEsc(DateTime? dtRif)
|
|
{
|
|
string answ = "";
|
|
try
|
|
{
|
|
answ = (isApprovedEsc) ? "text-uscita" : "text-danger";
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
|
|
private void DisplayDate(DateTime dtSel)
|
|
{
|
|
dtCurr = dtSel;
|
|
MService.targetDate = dtSel;
|
|
MService.targetDateMancTimb = dtCurr;
|
|
showDetail = true;
|
|
// se sono in calendario --> mostro dettagli...
|
|
if (currMode == CalendarModeEnum.modoControllo.showCalendar)
|
|
{
|
|
setModeDetail();
|
|
}
|
|
updateDetail();
|
|
MService.ReportDateChange();
|
|
}
|
|
|
|
/// <summary> Richiesta evento reload --> lo passa al componente superiore <param name="doForce"></param>
|
|
private async Task ForceReload(bool doForce)
|
|
{
|
|
await ReqReload.InvokeAsync(doForce);
|
|
}
|
|
|
|
private void ReloadData()
|
|
{
|
|
DateCheck = new Dictionary<DateTime, string>();
|
|
DateCFF = new Dictionary<DateTime, string>();
|
|
string cssOkComm = "bg-success text-light rounded-circle p-2";
|
|
string cssOkLav = "bg-warning text-light rounded-circle p-2";
|
|
string cssToday = "bg-info text-dark rounded-circle p-2";
|
|
string cssFest = "bg-danger text-warning rounded-pill2 px-0 opacity-50";
|
|
string cssChius = "bg-warning text-dark rounded-pill2 px-0 opacity-50";
|
|
string cssFerie = "bg-success text-light px-0 opacity-50";
|
|
|
|
// recupero le fermate aziendali
|
|
if (ListFermateAzienda != null && ListFermateAzienda.Count > 0)
|
|
{
|
|
string cssSpec = "";
|
|
foreach (var item in ListFermateAzienda)
|
|
{
|
|
cssSpec = item.codGiust == "FEST" ? cssFest : cssChius;
|
|
if (!DateCFF.ContainsKey(item.data))
|
|
{
|
|
if (item.data.DayOfWeek != DayOfWeek.Saturday && item.data.DayOfWeek != DayOfWeek.Sunday)
|
|
{
|
|
DateCFF.Add(item.data, cssSpec);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// aggiungo ferie dipendente
|
|
if (ListRecordsRichieste != null && ListRecordsRichieste.Count > 0)
|
|
{
|
|
string cssSpec = "";
|
|
foreach (var item in ListRecordsRichieste)
|
|
{
|
|
cssSpec = item.CodGiust == "FER" ? cssFerie : "";
|
|
// creo il set di date
|
|
int numDay = item.DtEnd.Subtract(item.DtStart).Days;
|
|
for (int i = 0; i <= numDay; i++)
|
|
{
|
|
DateTime currDay = item.DtStart.AddDays(i);
|
|
if (!DateCFF.ContainsKey(currDay))
|
|
{
|
|
if (currDay.DayOfWeek != DayOfWeek.Saturday && currDay.DayOfWeek != DayOfWeek.Sunday)
|
|
{
|
|
DateCFF.Add(currDay, cssSpec);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (ListRecords != null)
|
|
{
|
|
string currCss = "";
|
|
foreach (var giorno in ListRecords)
|
|
{
|
|
currCss = giorno.OreLav == 0 ? "" : cssOkLav;
|
|
if (giorno.DtRif == DateTime.Today)
|
|
{
|
|
currCss = cssToday;
|
|
}
|
|
else if (Math.Abs((giorno.OreLav - giorno.OreComm)) < 0.5 && giorno.OreLav > 0)
|
|
{
|
|
currCss = cssOkComm;
|
|
}
|
|
DateCheck.Add(giorno.DtRif, currCss);
|
|
}
|
|
// aggiorno dettagli
|
|
updateDetail();
|
|
}
|
|
}
|
|
|
|
private async Task ReloadMonth(DateTime dtSel)
|
|
{
|
|
dtCurr = dtSel;
|
|
MService.targetDate = dtSel;
|
|
showDetail = false;
|
|
await Task.Delay(1);
|
|
MService.ReportDateChange();
|
|
}
|
|
|
|
// richiesta update + ritorno a gauge...
|
|
private async Task ReloadTimb(bool doForce)
|
|
{
|
|
await ForceReload(doForce);
|
|
await backToGauge();
|
|
}
|
|
|
|
private async Task resetCal()
|
|
{
|
|
showDetail = false;
|
|
MService.isRicTimb = false;
|
|
MService.setModeCalendar();
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Imposta modalit� dettaglio (mostra i gauge)
|
|
/// </summary>
|
|
private void setModeDetail()
|
|
{
|
|
MService.isRicTimb = false;
|
|
MService.setModeGauge();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Imposta modalit� progetti (x ora rimanda a pagina progetti)
|
|
/// </summary>
|
|
private void setModeProgetti()
|
|
{
|
|
MService.isRicTimb = false;
|
|
MService.setModeProj();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Imposta modalit� mancate timbrature
|
|
/// </summary>
|
|
private void setModeRichTimb()
|
|
{
|
|
MService.isRicTimb = true;
|
|
MService.setModeRichTimb();
|
|
}
|
|
|
|
private void ShowTemp()
|
|
{
|
|
MService.targetDate = dtCurr;
|
|
navManager.NavigateTo($"{baseUrl}TempRil");
|
|
}
|
|
|
|
private void showTempRil()
|
|
{
|
|
MService.isRicTimb = false;
|
|
MService.setModeTempRil();
|
|
}
|
|
|
|
private async void updateDetail()
|
|
{
|
|
isApprovedEntr = true;
|
|
isApprovedEsc = true;
|
|
listaP.Clear();
|
|
if (ListRecords != null)
|
|
{
|
|
datiGiorno = ListRecords.Where(x => x.DtRif == dtCurr).FirstOrDefault();
|
|
listRA = ListRecords.Select(x => x.ListRA).ToList();
|
|
|
|
foreach (var item in listRA)
|
|
{
|
|
if (item != null)
|
|
{
|
|
foreach (var k in item)
|
|
{
|
|
if (k != null)
|
|
{
|
|
if (k.Inizio.Date == dtCurr.Date)
|
|
{
|
|
listaP.Add(k);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
listTimb = await CDService.TimbratureDay(dtCurr, IdxDipendente);
|
|
if (listTimb != null)
|
|
{
|
|
if (listTimb.Count != 0)
|
|
{
|
|
foreach (var item in listTimb)
|
|
{
|
|
if (item.Approv == false && item.Entrata == true)
|
|
{
|
|
isApprovedEntr = false;
|
|
}
|
|
else if (item.Approv == false && item.Entrata == false)
|
|
{
|
|
isApprovedEsc = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |