5722ad4167
- porting blazor 8.0 - riorganizzazione area components - add componenti da 6 - spostamento ver 6 a old (migrata comunque)
222 lines
7.2 KiB
C#
222 lines
7.2 KiB
C#
using BlazorCalendar.Models;
|
|
using GPW.CORE.Data.DbModels;
|
|
using GPW.CORE.WRKLOG.Data;
|
|
using Microsoft.AspNetCore.Components;
|
|
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 dtMax = DateTime.Today.AddMonths(3);
|
|
|
|
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();
|
|
await ReloadData();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private bool isLoading = false;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
/// <summary>
|
|
/// Elenco dei Task da inviare al calendario
|
|
/// </summary>
|
|
private List<Tasks> CalendarTasksList { get; set; } = new List<Tasks>();
|
|
|
|
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>();
|
|
private bool showMalattie { get; set; } = false;
|
|
private SelectGlobalToggle ToggleData { get; set; } = new SelectGlobalToggle();
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private string colorByGiustStato(string codGiust, bool conf)
|
|
{
|
|
string answ = "#EDEDED";
|
|
switch (codGiust)
|
|
{
|
|
case "PERM":
|
|
answ = conf ? "#9966DE" : "#CDAAFF";
|
|
break;
|
|
|
|
case "FER":
|
|
answ = conf ? "#11CD44" : "#AAFFCD";
|
|
break;
|
|
|
|
case "104":
|
|
answ = conf ? "#DE00AB" : "#FFAACD";
|
|
break;
|
|
|
|
case "MAL":
|
|
answ = conf ? "#000" : "#696969";
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
private string colorTextByGiustStato(string codGiust, bool conf)
|
|
{
|
|
string answ = "#EDEDED";
|
|
switch (codGiust)
|
|
{
|
|
case "PERM":
|
|
answ = conf ? "#DEDEDE" : "#000000";
|
|
break;
|
|
|
|
case "FER":
|
|
answ = conf ? "#FFFFFF" : "#000000";
|
|
break;
|
|
|
|
case "104":
|
|
answ = conf ? "#DEDEDE" : "#000000";
|
|
break;
|
|
|
|
case "MAL":
|
|
answ = conf ? "#DEDEDE" : "#ABABAB";
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
private async Task evToggled(SelectGlobalToggle newTogData)
|
|
{
|
|
ToggleData = newTogData;
|
|
showMalattie = !ToggleData.isActive;
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
private async Task ForceReloadCal()
|
|
{
|
|
await ReloadData();
|
|
}
|
|
|
|
private void initToggler()
|
|
{
|
|
ToggleData = new SelectGlobalToggle()
|
|
{
|
|
leftString = "Malattie",
|
|
rightString = "Ferie e Permessi",
|
|
placardCss = "bg-light border-light text-dark",
|
|
};
|
|
}
|
|
|
|
private async Task ReloadData()
|
|
{
|
|
isLoading = true;
|
|
CalendarTasksList = new List<Tasks>();
|
|
DateTime oggi = DateTime.Today;
|
|
dtMin = new DateTime(oggi.Year, oggi.Month, 1);
|
|
// 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;
|
|
}
|
|
dtMax = dtMin.AddMonths(numMesi);
|
|
|
|
// recupero le fermate aziendali
|
|
ListFermateAzienda = await DataService.CalFestFeriePeriodo(dtMin, dtMax);
|
|
if (ListFermateAzienda.Count > 0)
|
|
{
|
|
// conversione fermate in elenco task x calendario...
|
|
var taskAzienda = ListFermateAzienda.Select(x => new BlazorCalendar.Models.Tasks
|
|
{
|
|
DateStart = x.data,
|
|
DateEnd = x.data,
|
|
Caption = x.descrizione,
|
|
Comment = x.descrizione,
|
|
Code = x.codGiust,
|
|
Color = x.codGiust == "FEST" ? "#DD0033" : "#EEDD11",
|
|
ForeColor = x.codGiust == "FEST" ? "#EEDD11" : "#000000",
|
|
NotBeDraggable = true
|
|
}).ToList();
|
|
CalendarTasksList.AddRange(taskAzienda);
|
|
}
|
|
// recupero e converto le richieste dipendente...
|
|
ListRichiesteDip = await DataService.RegRichiesteGetByDip(0, dtMin, dtMax);
|
|
if (ListRichiesteDip.Count > 0)
|
|
{
|
|
// conversione fermate in elenco task x calendario...
|
|
var taskDip = ListRichiesteDip.Select(x => new BlazorCalendar.Models.Tasks
|
|
{
|
|
DateStart = x.DtStart,
|
|
DateEnd = x.DtEnd,
|
|
Caption = x.DipNav.Sigla,
|
|
Comment = x.CodGiust == "PERM" ? $"{x.DipNav.Sigla} {x.DtStart:HH:mm}--> {x.DtEnd:HH:mm}" : x.DipNav.Sigla,
|
|
Code = x.CodGiust,
|
|
Color = colorByGiustStato(x.CodGiust, x.Conf),
|
|
ForeColor = colorTextByGiustStato(x.CodGiust, x.Conf),
|
|
NotBeDraggable = x.IdxDipendente != idxDipendente
|
|
}).ToList();
|
|
CalendarTasksList.AddRange(taskDip);
|
|
}
|
|
// recupero e converto le malattie...
|
|
ListMalattie = await DataService.RegMalattieGetAll(100);
|
|
if (ListMalattie.Count > 0)
|
|
{
|
|
// conversione fermate in elenco task x calendario...
|
|
var taskDip = ListMalattie.Select(x => new BlazorCalendar.Models.Tasks
|
|
{
|
|
DateStart = x.DtInizio,
|
|
DateEnd = x.DtInizio.AddDays(x.NumGG - 1),
|
|
Caption = x.DipNav.Sigla,
|
|
Comment = x.DipNav.Sigla,
|
|
Code = "MAL",
|
|
Color = colorByGiustStato("MAL", x.Conf),
|
|
ForeColor = colorTextByGiustStato("MAL", x.Conf),
|
|
NotBeDraggable = x.IdxDipendente != idxDipendente
|
|
}).ToList();
|
|
CalendarTasksList.AddRange(taskDip);
|
|
}
|
|
isLoading = false;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |