diff --git a/GPW.CORE.Data/DTO/PeriodoDTO.cs b/GPW.CORE.Data/DTO/PeriodoDTO.cs new file mode 100644 index 0000000..42ddfa2 --- /dev/null +++ b/GPW.CORE.Data/DTO/PeriodoDTO.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GPW.CORE.Data.DTO +{ + // + // This is here so CodeMaid doesn't reorganize this document + // + public class PeriodoDTO + { + public DateTime Inizio { get; set; } + public DateTime Fine { get; set; } + public TipoPeriodo Tipo { get; set; } = TipoPeriodo.ND; + + public decimal? OreTot { get; set; } + + public TimeSpan Durata + { + get + { + TimeSpan valore = TimeSpan.FromHours(0); + if (OreTot != null) + { + try + { + valore = TimeSpan.FromHours((double)OreTot); + } + catch (Exception exc) + { } + } + return valore; + } + } + } +} diff --git a/GPW.CORE.Data/DbModels/TimbratureModel.cs b/GPW.CORE.Data/DbModels/TimbratureModel.cs index e7f33a2..c6e895f 100644 --- a/GPW.CORE.Data/DbModels/TimbratureModel.cs +++ b/GPW.CORE.Data/DbModels/TimbratureModel.cs @@ -20,6 +20,8 @@ namespace GPW.CORE.Data.DbModels /// public bool? Approv { get; set; } + + /// /// Navigation property to Dipendente /// diff --git a/GPW.CORE.Data/Enum.cs b/GPW.CORE.Data/Enum.cs new file mode 100644 index 0000000..9f68870 --- /dev/null +++ b/GPW.CORE.Data/Enum.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GPW.CORE.Data +{ + public enum TipoPeriodo + { + ND = 0, + Lavoro = 1 + } +} diff --git a/GPW.CORE.UI/Components/DayHoriz.razor b/GPW.CORE.UI/Components/DayHoriz.razor index 681d4de..25bed22 100644 --- a/GPW.CORE.UI/Components/DayHoriz.razor +++ b/GPW.CORE.UI/Components/DayHoriz.razor @@ -13,18 +13,29 @@ }
-
- @if (IsTitle) - { + @if (IsTitle) + { +
@for (int i = StartHour; i <= EndHour; i++) { -
+
@i.ToString("00")
} - } - else - { +
+ } + else + { +
+ @if (@DayDTO != null && @DayDTO.ListTimbr != null) + { + @foreach (var item in ListTimb()) + { + + } + } +
+
@if (@noData) { @@ -36,14 +47,14 @@ } } - } -
+
+ }
@if (IsTitle) { -
Timb
-
Lavo
+
Timb
+
Lavo
} else { diff --git a/GPW.CORE.UI/Components/DayHoriz.razor.cs b/GPW.CORE.UI/Components/DayHoriz.razor.cs index 0b3ae6a..44438ce 100644 --- a/GPW.CORE.UI/Components/DayHoriz.razor.cs +++ b/GPW.CORE.UI/Components/DayHoriz.razor.cs @@ -127,6 +127,80 @@ namespace GPW.CORE.UI.Components get => OkVC19 ? "text-success" : "text-secondary"; } + private List ListTimb() + { + // init + List result = new List(); + if (DayDTO != null) + { + // limiti estremi visualizzazione + DateTime currHour = DayDTO.DtRif.AddHours(StartHour); + DateTime lastHour = DayDTO.DtRif.AddHours(EndHour); + int idxTimb = 0; + if (DayDTO.ListTimbr != null) + { + // divido tra ingressi e uscite + var timbIN = DayDTO.ListTimbr.Where(x => x.Entrata == true).ToList(); + var timbOUT = DayDTO.ListTimbr.Where(x => x.Entrata == false).ToList(); + DateTime fineLav = currHour; + + // ciclo partendo dal primo evento timbratura IN ed aggiungendo eventuali periodi in testa / coda / intermedi + foreach (var item in timbIN) + { + // se evento > ora corrente --> aggiungo vuoto... + if (item.DataOra > currHour) + { + PeriodoDTO emptyPeriod = new PeriodoDTO() + { + Inizio = currHour, + Fine=item.DataOra, + Tipo = CORE.Data.TipoPeriodo.ND, + OreTot = (decimal)item.DataOra.Subtract(currHour).TotalHours + }; + result.Add(emptyPeriod); + } + + // ...processo cercando uscita relativa oppure NOW + if (timbOUT.Count > idxTimb) + { + fineLav = timbOUT[idxTimb].DataOra; + } + else + { + DateTime adesso = DateTime.Now; + int minRound = ((int)Math.Floor((double)adesso.Minute / 5)) * 5; + fineLav = DateTime.Today.AddHours(adesso.Hour).AddMinutes(minRound); + } + PeriodoDTO workPeriod = new PeriodoDTO() + { + Inizio = item.DataOra, + Fine=fineLav, + Tipo = CORE.Data.TipoPeriodo.Lavoro, + OreTot = (decimal)fineLav.Subtract(item.DataOra).TotalHours + }; + result.Add(workPeriod); + idxTimb++; + currHour = fineLav; + } + // se non sono in fondo --> aggiungo! + if (currHour < lastHour) + { + PeriodoDTO emptyPeriod = new PeriodoDTO() + { + Inizio = currHour, + Fine = lastHour, + Tipo = CORE.Data.TipoPeriodo.ND, + OreTot = (decimal)lastHour.Subtract(currHour).TotalHours + }; + result.Add(emptyPeriod); + } + } + } + + return result; + } + + private List ListRegAtt() { // init diff --git a/GPW.CORE.UI/Components/PeriodoLav.razor b/GPW.CORE.UI/Components/PeriodoLav.razor new file mode 100644 index 0000000..feb2428 --- /dev/null +++ b/GPW.CORE.UI/Components/PeriodoLav.razor @@ -0,0 +1,15 @@ +@using CORE.Data.DbModels +@using CORE.Data.DTO +@using UI.Data +@inject GpwDataService GDataServ +@inject MessageService AppMServ +@inject IJSRuntime JSRuntime + + +
@CurrPeriodo.Inizio.ToString("HH:mm")
+ +@code { + + [Parameter] + public PeriodoDTO CurrPeriodo { get; set; } = null!; +} diff --git a/GPW.CORE.UI/GPW.CORE.UI.csproj b/GPW.CORE.UI/GPW.CORE.UI.csproj index 420da7c..faf4183 100644 --- a/GPW.CORE.UI/GPW.CORE.UI.csproj +++ b/GPW.CORE.UI/GPW.CORE.UI.csproj @@ -2,7 +2,7 @@ net6.0 - 3.0.2201.0518 + 3.0.2201.1012 enable enable diff --git a/GPW.CORE.UI/Pages/Test.razor b/GPW.CORE.UI/Pages/Test.razor index 3711b6c..b3cf89d 100644 --- a/GPW.CORE.UI/Pages/Test.razor +++ b/GPW.CORE.UI/Pages/Test.razor @@ -154,7 +154,7 @@
45
30'
-