diff --git a/TecniStamp/TecniStamp/Components/Pages/Carico/Carico.razor b/TecniStamp/TecniStamp/Components/Pages/Carico/Carico.razor new file mode 100644 index 0000000..0bc9fda --- /dev/null +++ b/TecniStamp/TecniStamp/Components/Pages/Carico/Carico.razor @@ -0,0 +1,148 @@ +@page "/Carico" +@using TecniStamp.Model.Carico + + + + + + + + + @foreach (var settimana in settimane) + { + + + + } + + + + + +@code { + private List settimane = new(); + private List righe = new(); + protected override async Task OnInitializedAsync() + { + await base.OnInitializedAsync(); + settimane = GeneraSettimaneAnno(2026); + var settimanePerMese = settimane + .GroupBy(s => new { s.Anno, Mese = s.Inizio.Month }) + .Select(g => new + { + Mese = g.Key.Mese, + Nome = new DateTime(2026, g.Key.Mese, 1).ToString("MMMM").ToUpper(), + Count = g.Count() + }) + .ToList(); + + + righe = new List + { + new() + { + Id = 1, + Lavorazione = "Taglio laser – Commessa A", + Settimane = new Dictionary + { + [6] = new() { Ore = 16, Stato = "InCorso", Percentuale = 50 }, + [7] = new() { Ore = 24, Stato = "InCorso", Percentuale = 75 } + } + }, + new() + { + Id = 2, + Lavorazione = "Saldatura – Commessa A", + Settimane = new Dictionary + { + [7] = new() { Ore = 32, Stato = "Pianificato", Percentuale = 40}, + [8] = new() { Ore = 16, Stato = "Pianificato", Percentuale = 60} + } + }, + new() + { + Id = 3, + Lavorazione = "Verniciatura – Commessa B", + Settimane = new Dictionary + { + [8] = new() { Ore = 40, Stato = "Pianificato", Percentuale = 90} + } + } + }; + } + + public static List GeneraSettimaneAnno(int anno) + { + var settimane = new List(); + + // ISO: settimana 1 = quella che contiene il 4 gennaio + var jan4 = new DateTime(anno, 1, 4); + + // lunedì della settimana 1 + var startOfWeek1 = jan4.AddDays(-(int)(jan4.DayOfWeek == DayOfWeek.Sunday + ? 6 + : jan4.DayOfWeek - DayOfWeek.Monday)); + + var currentStart = startOfWeek1; + var weekNumber = 1; + + while (currentStart.Year <= anno) + { + var currentEnd = currentStart.AddDays(6); + + settimane.Add(new SettimanaViewModel + { + Anno = anno, + Numero = weekNumber, + Inizio = currentStart, + Fine = currentEnd + }); + + currentStart = currentStart.AddDays(7); + weekNumber++; + } + + return settimane; + } + + object GetColor(int valuePercentuale) + { + return "Red"; + } +} \ No newline at end of file diff --git a/TecniStamp/TecniStamp/Components/Pages/Carico/Carico.razor.css b/TecniStamp/TecniStamp/Components/Pages/Carico/Carico.razor.css new file mode 100644 index 0000000..fac4719 --- /dev/null +++ b/TecniStamp/TecniStamp/Components/Pages/Carico/Carico.razor.css @@ -0,0 +1,35 @@ +.calendar-month-header { + display: grid; + grid-template-columns: 250px repeat(53, 120px); + border-bottom: 1px solid #ddd; + background: #f5f5f5; +} + +.month-header { + text-align: center; + font-weight: 600; + padding: 8px 0; + border-left: 1px solid #ddd; +} + +.month-spacer { + border-right: 1px solid #ddd; +} + +.calendar-card { + background: #f7f7f7; + border-radius: 6px; + padding: 6px; + box-shadow: inset 0 0 0 1px #ddd; +} + +.card-header { + display: flex; + justify-content: space-between; + font-size: 12px; + margin-bottom: 4px; +} + +.status { + font-weight: 600; +} diff --git a/TecniStamp/TecniStamp/Model/Carico/CalendarioCellaViewModel.cs b/TecniStamp/TecniStamp/Model/Carico/CalendarioCellaViewModel.cs new file mode 100644 index 0000000..f9be146 --- /dev/null +++ b/TecniStamp/TecniStamp/Model/Carico/CalendarioCellaViewModel.cs @@ -0,0 +1,8 @@ +namespace TecniStamp.Model.Carico; + +public class CalendarioCellaViewModel +{ + public int Ore { get; set; } + public string Stato { get; set; } + public int Percentuale { get; set; } +} \ No newline at end of file diff --git a/TecniStamp/TecniStamp/Model/Carico/CalendarioRigaVm.cs b/TecniStamp/TecniStamp/Model/Carico/CalendarioRigaVm.cs new file mode 100644 index 0000000..125fbc5 --- /dev/null +++ b/TecniStamp/TecniStamp/Model/Carico/CalendarioRigaVm.cs @@ -0,0 +1,9 @@ +namespace TecniStamp.Model.Carico; + +public class CalendarioRigaViewModel +{ + public int Id { get; set; } + public string Lavorazione { get; set; } + public Dictionary Settimane { get; set; } + = new(); +} \ No newline at end of file diff --git a/TecniStamp/TecniStamp/Model/Carico/SettimanaViewModel.cs b/TecniStamp/TecniStamp/Model/Carico/SettimanaViewModel.cs new file mode 100644 index 0000000..0226520 --- /dev/null +++ b/TecniStamp/TecniStamp/Model/Carico/SettimanaViewModel.cs @@ -0,0 +1,11 @@ +namespace TecniStamp.Model.Carico; + +public class SettimanaViewModel +{ + public int Anno { get; set; } + public int Numero { get; set; } + public DateTime Inizio { get; set; } + public DateTime Fine { get; set; } + + public string Label => $"W{Numero}"; +} diff --git a/TecniStamp/TecniStamp/Model/UserViewModel.cs b/TecniStamp/TecniStamp/Model/UserViewModel.cs index b2e38df..8310148 100644 --- a/TecniStamp/TecniStamp/Model/UserViewModel.cs +++ b/TecniStamp/TecniStamp/Model/UserViewModel.cs @@ -1,4 +1,5 @@ -using TecniStamp.Domain; +using System.ComponentModel.DataAnnotations; +using TecniStamp.Domain; namespace TecniStamp.Model; @@ -7,7 +8,9 @@ public class UserViewModel : BaseViewModel public string Username { get; set; } public string Email { get; set; } public string Password { get; set; } + [Required(ErrorMessage = "Il nome è obbligatorio")] public string Nome { get; set; } + [Required(ErrorMessage = "Il cognome è obbligatorio")] public string Cognome { get; set; } public Guid RuoloId { get; set; } public string Ruolo { get; set; }