diff --git a/GPW.CORE.ADM/Components/Compo/CalendarioAziendale.razor b/GPW.CORE.ADM/Components/Compo/CalendarioAziendale.razor new file mode 100644 index 0000000..3a3bad9 --- /dev/null +++ b/GPW.CORE.ADM/Components/Compo/CalendarioAziendale.razor @@ -0,0 +1,56 @@ + +
+
+
+
+ +
+
+ Calendario Aziendale +
+
+
+ @if (currView == "year" || currView == "planner") + { +
+ + + + +
+ } +
+
+
+
+
+
+ + + + + + + + @* *@ + + + +
+
+
\ No newline at end of file diff --git a/GPW.CORE.ADM/Components/Compo/CalendarioAziendale.razor.cs b/GPW.CORE.ADM/Components/Compo/CalendarioAziendale.razor.cs new file mode 100644 index 0000000..0f3d44e --- /dev/null +++ b/GPW.CORE.ADM/Components/Compo/CalendarioAziendale.razor.cs @@ -0,0 +1,265 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.Identity.Client; +using Radzen.Blazor.Rendering; +using Radzen.Blazor; +using static EgwCoreLib.Razor.Toggler; +using Radzen; +using System; +using static System.Runtime.InteropServices.JavaScript.JSType; +using GPW.CORE.Data.DTO; +using System.Diagnostics; + +namespace GPW.CORE.ADM.Components.Compo +{ + public partial class CalendarioAziendale + { + #region Public Properties + + [Parameter] + public EventCallback DtReq { get; set; } + + [Parameter] + public List EvDtoList { get; set; } = null!; + + [Parameter] + public DateTime firstDate { get; set; } = new DateTime(DateTime.Today.Year, 1, 1); + + [Parameter] + public int IdxDip { get; set; } = 0; + + [Parameter] + public DateTime maxDate { get; set; } = new DateTime(DateTime.Today.Year + 1, 1, 1); + + [Parameter] + public DateTime minDate { get; set; } = new DateTime(DateTime.Today.Year, 1, 1); + + [Parameter] + public int MonthDispl + { + get => cMonth; + set => cMonth = value; + } + + [Parameter] + public EventCallback MonthReq { get; set; } + + #endregion Public Properties + + #region Protected Fields + + protected RadzenScheduler scheduler = null!; + + #endregion Protected Fields + + #region Protected Enums + + protected enum Viste + { + Day, + Week, + Month, + Planner, + Year + } + + #endregion Protected Enums + + #region Protected Properties + + protected int currMonth + { + get => cMonth; + set + { + if (cMonth != value) + { + cMonth = value; + MonthReq.InvokeAsync(value); + } + } + } + + [Inject] + protected DialogService DialogService { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + protected async Task addMonth(int numMesi) + { + firstDate = firstDate.AddMonths(numMesi); + // verifico limiti... + if (numMesi > 0) + { + firstDate = firstDate > maxDate ? maxDate : firstDate; + } + else + { + firstDate = firstDate < minDate ? minDate : firstDate; + } + await Task.Delay(1); + } + + protected override async Task OnInitializedAsync() + { + await Task.Delay(1); + // il mese viene preimpostato sul trimestre corrente... + startMonth = (Month)((DateTime.Today.Month / 6) * 6); + ToggleData = new SelectGlobalToggle() + { + leftString = "Personali", + rightString = "Tutti", + placardCss = "bg-dark border-dark text-light" + }; + } + + protected override void OnParametersSet() + { + FilterData(); + scheduler.Reload(); + } + + protected async Task StartMonthChange() + { + await scheduler.Reload(); + } + + #endregion Protected Methods + + #region Private Fields + + private int selectedIndex = 2; + + #endregion Private Fields + + #region Private Properties + + private int cMonth { get; set; } = 3; + private string currView { get; set; } = ""; + private List EvDtoFilt { get; set; } = new List(); + private string schedHeight { get; set; } = "height: 50rem;"; + private DateTime SelDate { get; set; } = DateTime.Today; + private Month startMonth { get; set; } = Month.January; + private SelectGlobalToggle ToggleData { get; set; } = new SelectGlobalToggle(); + + #endregion Private Properties + + #region Private Methods + + private async Task evToggled(SelectGlobalToggle newTogData) + { + ToggleData = newTogData; + await Task.Delay(1); + FilterData(); + } + + private void FilterData() + { + // filtro risultati richiesti... + if (ToggleData.isActive) + { + EvDtoFilt = EvDtoList; + } + else + { + EvDtoFilt = EvDtoList + .Where(x => x.IdxDipendente == IdxDip || x.IdxDipendente == 0) + .ToList(); + } + } + + private void OnAppointmentRender(SchedulerAppointmentRenderEventArgs args) + { + // Never call StateHasChanged in AppointmentRender - would lead to infinite loop + args.Attributes["style"] = $"background: {args.Data.Color}; color: {args.Data.ForeColor};"; + } + + private async Task OnAppointmentSelect(SchedulerAppointmentSelectEventArgs selEv) + { + var copy = selEv.Data.Clone(); + await Task.Delay(1); + var data = await DialogService.OpenAsync("", new Dictionary { { "ThisTask", copy } }); + } + + private async Task OnLoadData(SchedulerLoadDataEventArgs args) + { + await Task.Delay(1); + currView = scheduler.SelectedView.Text.ToLowerInvariant(); + + // controllo se sia cambiata data... di almeno 1 anno in questo caso... + if (SelDate != scheduler.Date || Math.Abs(scheduler.Date.Subtract(args.Start).TotalDays) > 365) + { + SelDate = args.Start.AddMonths(1); + // riporto data al controller parent... + await DtReq.InvokeAsync(SelDate); + } + + //schedHeight = (currView == "year" || currView == "planner") ? "height: 60rem;" : "height: 50rem;"; + // // Get the appointments for between the Start and End + // data = await MyAppointmentService.GetData(selEv.Start, selEv.End); + } + + private void OnSlotRender(SchedulerSlotRenderEventArgs args) + { + // Highlight today in month view + if (args.View.Text == "Month" && args.Start.Date == DateTime.Today) + { + args.Attributes["style"] = "background: var(--rz-scheduler-highlight-background-color, rgba(255,220,40,.2));"; + } + + // Highlight working hours (9-18) + if ((args.View.Text == "Week" || args.View.Text == "Day") && args.Start.Hour > 8 && args.Start.Hour < 19) + { + args.Attributes["style"] = "background: var(--rz-scheduler-highlight-background-color, rgba(255,220,40,.2));"; + } + } + + private async Task OnSlotSelect(SchedulerSlotSelectEventArgs args) + { + int prevIdx = selectedIndex; + await Task.Delay(1); + // verifico indice corretto della vista... + switch (args.View.Text) + { + case "Day": + selectedIndex = 0; + break; + + case "Week": + selectedIndex = 1; + break; + + case "Month": + selectedIndex = 2; + break; + + case "Planner": + selectedIndex = 3; + break; + + case "Year": + selectedIndex = 4; + break; + + default: + break; + } + if (prevIdx != selectedIndex) + { + await scheduler.Reload(); + } + await Task.Delay(1); + if (selectedIndex > 0) + { + selectedIndex--; + } + // imposto al data selezionata + SelDate = args.Start; + // riporto data al controller parent... + await DtReq.InvokeAsync(SelDate); + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/GPW.CORE.ADM/Components/Compo/ProgettiMan.razor b/GPW.CORE.ADM/Components/Compo/ProgettiMan.razor index 91ed6ee..75504ac 100644 --- a/GPW.CORE.ADM/Components/Compo/ProgettiMan.razor +++ b/GPW.CORE.ADM/Components/Compo/ProgettiMan.razor @@ -78,7 +78,7 @@ - @foreach (var item in ListGruppi) { @@ -101,7 +101,7 @@ - @foreach (var item in ListClienti) { diff --git a/GPW.CORE.ADM/Components/Compo/ProgettiMan.razor.cs b/GPW.CORE.ADM/Components/Compo/ProgettiMan.razor.cs index 9ff2d9b..cb21eb6 100644 --- a/GPW.CORE.ADM/Components/Compo/ProgettiMan.razor.cs +++ b/GPW.CORE.ADM/Components/Compo/ProgettiMan.razor.cs @@ -131,10 +131,8 @@ namespace GPW.CORE.ADM.Components.Compo protected async Task ForceReload() { - // salvo le preferenze... - await AppMServ.UserPrefSet("ShowPrjArc", $"{ShowPrjArc}"); - await AppMServ.UserPrefSet("ShowPrjStr", $"{ShowPrjStr}"); - await AppMServ.UserPrefSet("ShowPrjZH", $"{ShowPrjZH}"); + await salvaFiltToggle(); + await salvaFiltGrpCli(); FullEdit = false; ShowFasi = false; RecordEdit = null; @@ -215,13 +213,21 @@ namespace GPW.CORE.ADM.Components.Compo #region Private Fields private static Logger Log = LogManager.GetCurrentClassLogger(); + private bool FullEdit = false; + private string gridKey = "ProgettiMan"; + private AnagProgettiModel? RecordEdit = null; + private CalcOreProgettiModel? RecordSel = null; + private bool ShowFasi = false; + private bool sortAsc = true; + private string sortField = ""; + private double warnRatio = 50; #endregion Private Fields @@ -229,11 +235,17 @@ namespace GPW.CORE.ADM.Components.Compo #region Private Properties private int currPage { get; set; } = 1; + private string CurrSearch { get; set; } = ""; + private string Gruppo { get; set; } = ""; + private int IdxCliente { get; set; } = 0; + private bool isLoading { get; set; } = false; + private List? ListFasiSel { get; set; } = null; + private List? ListRecords { get; set; } = null; private string modalSize @@ -325,6 +337,7 @@ namespace GPW.CORE.ADM.Components.Compo IdxCliente = 0; } currPage = 1; + await salvaFiltGrpCli(); await ReloadData(); } @@ -340,8 +353,12 @@ namespace GPW.CORE.ADM.Components.Compo ShowPrjArc = await AppMServ.UserPrefGet("ShowPrjArc"); ShowPrjStr = await AppMServ.UserPrefGet("ShowPrjStr"); ShowPrjZH = await AppMServ.UserPrefGet("ShowPrjZH"); + ShowGruppo = await AppMServ.UserPrefGet("ShowGruppo"); + ShowCli = await AppMServ.UserPrefGet("ShowCli"); + Gruppo = await AppMServ.UserPrefGet("Gruppo") ?? ""; + IdxCliente = await AppMServ.UserPrefGet("IdxCliente"); } - catch(Exception exc) + catch (Exception exc) { Log.Error($"Eccezione in InitUserPref{Environment.NewLine}{exc}"); } @@ -374,6 +391,23 @@ namespace GPW.CORE.ADM.Components.Compo isLoading = false; } + private async Task salvaFiltGrpCli() + { + // salvo + await AppMServ.UserPrefSet("ShowGruppo", $"{ShowGruppo}"); + await AppMServ.UserPrefSet("ShowCli", $"{ShowCli}"); + await AppMServ.UserPrefSet("Gruppo", $"{Gruppo}"); + await AppMServ.UserPrefSet("IdxCliente", $"{IdxCliente}"); + } + + private async Task salvaFiltToggle() + { + // salvo le preferenze... + await AppMServ.UserPrefSet("ShowPrjArc", $"{ShowPrjArc}"); + await AppMServ.UserPrefSet("ShowPrjStr", $"{ShowPrjStr}"); + await AppMServ.UserPrefSet("ShowPrjZH", $"{ShowPrjZH}"); + } + private void SortTable() { if (SearchRecords != null) diff --git a/GPW.CORE.ADM/Components/Compo/RegMalattia.razor b/GPW.CORE.ADM/Components/Compo/RegMalattia.razor new file mode 100644 index 0000000..d9f8453 --- /dev/null +++ b/GPW.CORE.ADM/Components/Compo/RegMalattia.razor @@ -0,0 +1,120 @@ +@if (isLoading) +{ + +} +else +{ @if (isSendingData) + { + + } + @if (ListRecords == null) + { + + } + else + { + @if (showAdd) + { +
    +
  • +
    +
    + Inizio Malattia +
    +
    + +
    +
    +
  • +
  • +
    +
    + Giorni Malattia +
    +
    + +
    +
    +
  • +
  • +
    +
    + Codice Certificato (INPS) +
    +
    + +
    +
    +
  • +
  • +
    +
    + +
    +
    + @if (currRecord.CodCert != "") + { + + } + else + { + + } +
    +
    +
  • +
+ } + @if (ListRecords.Count == 0) + { +
+

Nessu record registrato!

+ +
+ } + else + { + + + + + + + + + + + + @foreach (var item in ListRecords.OrderByDescending(x => x.DtInizio)) + { + + + + + + + + } + +
+ + DataGiorniCodice
+ @if (!item.Conf) + { + + } + + @item.DtInizio.ToString("dd MMM yyyy"), @item.DtInizio.ToString("dddd") + + @item.NumGG + + @item.CodCert + + @if (!item.Conf) + { + + } +
+ } + } +} \ No newline at end of file diff --git a/GPW.CORE.ADM/Components/Compo/RegMalattia.razor.cs b/GPW.CORE.ADM/Components/Compo/RegMalattia.razor.cs new file mode 100644 index 0000000..7df9a80 --- /dev/null +++ b/GPW.CORE.ADM/Components/Compo/RegMalattia.razor.cs @@ -0,0 +1,159 @@ +using GPW.CORE.Data.DbModels; +using GPW.CORE.Data.Services; +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; + +namespace GPW.CORE.ADM.Components.Compo +{ + public partial class RegMalattia + { + #region Public Properties + + [Parameter] + public int IdxDipendente { get; set; } + + [Parameter] + public bool isLoading { get; set; } + + [Parameter] + public EventCallback ReportUpdate { get; set; } + + #endregion Public Properties + + #region Protected Properties + + [Inject] + protected MessageService AppMServ { get; set; } = null!; + + [Inject] + protected GpwDataService DataService { get; set; } = null!; + + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + protected override async Task OnParametersSetAsync() + { + await ReloadData(); + } + + #endregion Protected Methods + + #region Private Fields + + private bool isSendingData = false; + private List? ListRecords = null; + private int sendDataMaxVal = 100; + private int sendDataNextVal = 0; + private int sendDataVal = 0; + private bool showAdd = false; + + #endregion Private Fields + + #region Private Properties + + private RegMalattieModel currRecord { get; set; } = new RegMalattieModel(); + + private string NomeDip + { + get + { + string answ = "per cortesia"; + if (AppMServ != null && AppMServ.RigaDip != null) + { + answ = $"{AppMServ.RigaDip.Nome}"; + } + return answ; + } + } + + #endregion Private Properties + + #region Private Methods + + private async Task DeleteRec(RegMalattieModel selItem) + { + // chiedo verifica + if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler eliminare il record selezionato??")) + return; + + isSendingData = true; + sendDataVal = 0; + sendDataNextVal = 90; + await InvokeAsync(StateHasChanged); + await Task.Delay(1); + var updTask = Task.Run(async () => + await DataService.RegMalattieDelete(selItem) + ); + await updTask; + sendDataVal = 100; + sendDataNextVal = 100; + await Task.Delay(1); + await ReloadData(); + await ReportUpdate.InvokeAsync(true); + isSendingData = false; + } + + private void editRec(RegMalattieModel selItem) + { + currRecord = selItem; + showAdd = true; + } + + /// + /// Registra il record + /// + /// + private async Task insertRecord() + { + isSendingData = true; + sendDataVal = 0; + sendDataNextVal = 5; + await Task.Delay(1); + // forzo dipendente + currRecord.IdxDipendente = AppMServ.IdxDipendente; + await Task.Delay(1); + // effettuo insert... + sendDataVal = 5; + sendDataNextVal = 90; + await Task.Delay(1); + var updTask = Task.Run(async () => + await DataService.RegMalattieUpsert(currRecord) + ); + await updTask; + // effettuo insert... + sendDataVal = 100; + sendDataNextVal = 100; + // aggiorno display... + await Task.Delay(1); + showAdd = false; + await ReloadData(); + await ReportUpdate.InvokeAsync(true); + isSendingData = false; + } + + private async Task ReloadData() + { + ListRecords = null; + await Task.Delay(1); + ListRecords = await DataService.RegMalattieGetByDip(IdxDipendente, 10); + await Task.Delay(1); + await InvokeAsync(StateHasChanged); + } + + private async Task toggleAddNew() + { + showAdd = !showAdd; + await Task.Delay(1); + if (showAdd) + { + currRecord = new RegMalattieModel() { IdxDipendente = AppMServ.IdxDipendente }; + } + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/GPW.CORE.ADM/Components/Compo/RegRichieste.razor b/GPW.CORE.ADM/Components/Compo/RegRichieste.razor new file mode 100644 index 0000000..7a99530 --- /dev/null +++ b/GPW.CORE.ADM/Components/Compo/RegRichieste.razor @@ -0,0 +1,219 @@ +@if (isLoading) +{ + +} +else +{ + @if (isSendingData) + { + + } + @if (ListRecords == null) + { + + } + else + { + @if (showAdd) + { +
    +
  • +
    +
    + Causale +
    +
    +
    + +
    +
    +
    +
  • +
  • +
    +
    + Inizio Periodo +
    min: @($"{minDate(currRecord.CodGiust):dd.MM.yyyy}")
    +
    +
    + @if (@CodGiust == "PERM" || @CodGiust == "104") + { + + } + else + { + + } +
    +
    +
  • +
  • +
    +
    + Fine Periodo +
    max: @($"{maxDate(currRecord.CodGiust):dd.MM.yyyy}")
    +
    +
    + + @if (@CodGiust == "PERM" || @CodGiust == "104") + { + + } + else + { + + } +
    +
    +
  • +
  • +
    +
    + Note +
    (opzionali)
    +
    +
    + +
    +
    +
  • +
  • +
    +
    + Stato +
    (conferma)
    +
    +
    +
    + +
    +
    +
    +
  • +
  • +
    +
    + +
    +
    + @if (CodGiust != "") + { + + } + else + { + + } +
    +
    +
  • +
+ } + @if (ListRecords.Count == 0) + { +
+
+ Nessu record registrato +
+
+ +
+
+ } + else + { + + + + + + + + + + + @foreach (var item in ListRecords) + { + + + + + + + } + +
+ @* *@ + DipendentePeriodo +
+ @if (!item.Conf) + { + + } + else + { +
+ @item.CodGiustTrim +
+ } +
+
@item.DipNav.Abbrev
+
+
+ @if (item.CodGiust == "PERM") + { +
+
+ @item.DtStart.ToString("dd MMM yyyy"), @item.DtStart.ToString("HH:mm") + + @item.DtEnd.ToString("HH:mm") +
+
+ @item.Durata +
+
+ } + else + { +
+
+ @item.DtStart.ToString("dd MMM") @item.DtStart.ToString("yyyy") + + @item.DtEnd.ToString("dd MMM") @item.DtEnd.ToString("yyyy") +
+
+ @item.Durata +
+
+ } +
+
+ @item.Note +
+
+ @if (!item.Conf) + { + + } + else + { + + } +
+ } + } +} + diff --git a/GPW.CORE.ADM/Components/Compo/RegRichieste.razor.cs b/GPW.CORE.ADM/Components/Compo/RegRichieste.razor.cs new file mode 100644 index 0000000..fc2b8c6 --- /dev/null +++ b/GPW.CORE.ADM/Components/Compo/RegRichieste.razor.cs @@ -0,0 +1,358 @@ +using GPW.CORE.Data.DbModels; +using GPW.CORE.Data.Services; +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; + +namespace GPW.CORE.ADM.Components.Compo +{ + public partial class RegRichieste + { + #region Public Properties + + + protected int IdxDipendente { get; set; } = 0; + + [Parameter] + public bool isLoading + { + get => loading; + set => loading = value; + } + + [Parameter] + public int months { get; set; } + + [Parameter] + public EventCallback ReportUpdate { get; set; } + + #endregion Public Properties + + #region Protected Properties + + [Inject] + protected MessageService AppMServ { get; set; } = null!; + + [Inject] + protected GpwDataService GDataServ { get; set; } = null!; + + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; + + protected bool loading + { + get => _loading; + set + { + if (_loading != value) + { + _loading = value; + var pUpd = Task.Run(async () => await ReloadData()); + pUpd.Wait(); + } + } + } + + #endregion Protected Properties + + #region Protected Methods + + protected override async Task OnInitializedAsync() + { + dtInizio = new DateTime(DateTime.Today.Year, 1, 1); + dtFine = dtInizio.AddYears(2); + currRecord.IdxDipendente = AppMServ.IdxDipendente; + CodGiust = ""; + var rawGiust = await GDataServ.AnagGiust(); + if (rawGiust != null) + { + ListGiust = rawGiust.Where(x => x.showReq).ToList(); + } + await ReloadData(); + } + + #endregion Protected Methods + + #region Private Fields + + private bool isSendingData = false; + private List? ListGiust = null; + private List? ListRecords = null; + + /// + /// Numero giorni minimo per richiesta ferie + /// + private int NumDayFerieRichAntic = 14; + + /// + /// NUmero giorni massimo per richiesta permessi + /// + private int NumDayPermMax = 21; + + private int sendDataMaxVal = 100; + private int sendDataNextVal = 0; + private int sendDataVal = 0; + private bool showAdd = false; + + #endregion Private Fields + + #region Private Properties + + private bool _loading { get; set; } = false; + + private string CodGiust + { + get => currRecord.CodGiust; + set + { + currRecord.CodGiust = value; + // imposto dataOra min/max da tipo cod Giust + if (value == "FER") + { + dtStart = minDate(value); + dtEnd = minDate(value); + } + else + { + int ora = DateTime.Now.Hour; + dtStart = minDate(value).AddHours(ora); + dtEnd = minDate(value).AddHours(ora + 4); + } + } + } + + private RegRichiesteModel currRecord { get; set; } = new RegRichiesteModel(); + + private DateTime dtEnd + { + get => currRecord.DtEnd; + set + { + currRecord.DtEnd = value; + // verifico coerenza date... + if (dtStart > dtEnd) + { + dtStart = dtEnd; + } + } + } + + private DateTime dtFine { get; set; } = DateTime.Today; + + private DateTime dtInizio { get; set; } = DateTime.Today; + + private DateTime dtStart + { + get => currRecord.DtStart; + set + { + currRecord.DtStart = value; + // verifico coerenza date... + if (dtEnd < dtStart) + { + dtEnd = dtStart; + } + } + } + + private string NomeDip + { + get + { + string answ = "per cortesia"; + if (AppMServ != null && AppMServ.RigaDip != null) + { + answ = $"{AppMServ.RigaDip.Nome}"; + } + return answ; + } + } + + #endregion Private Properties + + #region Private Methods + +#if false + private async Task DeleteRec(RegRichiesteModel selItem) + { + // chiedo verifica + if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler eliminare il record selezionato??")) + return; + + await Task.Delay(1); + isSendingData = true; + isSendingData = true; + sendDataVal = 0; + sendDataNextVal = 90; + await Task.Delay(1); + await InvokeAsync(StateHasChanged); + var updTask = Task.Run(async () => + await GDataServ.RegRichiesteDelete(selItem) + ); + await updTask; + sendDataVal = 100; + sendDataNextVal = 100; + await Task.Delay(1); + await ReloadData(); + await ReportUpdate.InvokeAsync(true); + isSendingData = false; + } +#endif + + private async Task DoApprove(RegRichiesteModel selItem) + { + // chiedo verifica + if (!await JSRuntime.InvokeAsync("confirm", "Confermi approvazione?")) + return; + + await Task.Delay(1); + isSendingData = true; + sendDataVal = 0; + sendDataNextVal = 90; + await Task.Delay(1); + await InvokeAsync(StateHasChanged); + await GDataServ.RegRichiesteApprova(selItem); + //var updTask = Task.Run(async () => + // await GDataServ.RegRichiesteApprova(selItem) + // ); + //await updTask; + sendDataVal = 100; + sendDataNextVal = 100; + await ReloadData(); + await Task.Delay(1); + await ReportUpdate.InvokeAsync(true); + isSendingData = false; + } + + + private void editRec(RegRichiesteModel selItem) + { + currRecord = selItem; + showAdd = true; + } + + /// + /// init valori da config + /// + /// + private async Task initConf() + { + // leggo conf standard giorni permessi/ferie + var sNumDayFerieRichAntic = await GDataServ.ConfigGetKey("NumDayFerieRichAntic"); + if (sNumDayFerieRichAntic != null) + { + int.TryParse(sNumDayFerieRichAntic.valore, out NumDayFerieRichAntic); + } + var sNumDayPermMax = await GDataServ.ConfigGetKey("NumDayPermMax"); + if (sNumDayPermMax != null) + { + int.TryParse(sNumDayPermMax.valore, out NumDayPermMax); + } + } + + /// + /// Registra il record + /// + /// + private async Task insertRecord() + { + isSendingData = true; + sendDataVal = 0; + sendDataNextVal = 5; + await Task.Delay(1); + // verifica preliminare delle date compatibili... + var dtCheckMin = minDate(currRecord.CodGiust); + var dtCheckMax = maxDate(currRecord.CodGiust); + if (currRecord.DtStart < dtCheckMin) + { + currRecord.DtStart = dtCheckMin; + } + else if (currRecord.DtStart > dtCheckMax) + { + currRecord.DtStart = dtCheckMax; + currRecord.DtEnd = dtCheckMax; + } + if (currRecord.DtEnd > dtCheckMax) + { + currRecord.DtEnd = dtCheckMax; + } + else if (currRecord.DtEnd < dtCheckMin) + { + currRecord.DtStart = dtCheckMin; + currRecord.DtEnd = dtCheckMin; + } + // effettuo insert... + sendDataVal = 5; + sendDataNextVal = 90; + await Task.Delay(1); + var updTask = Task.Run(async () => + await GDataServ.RegRichiesteUpsert(currRecord) + ); + await updTask; + // effettuo insert... + sendDataVal = 100; + sendDataNextVal = 100; + await Task.Delay(1); + showAdd = false; + await ReloadData(); + await ReportUpdate.InvokeAsync(true); + isSendingData = false; + } + + private DateTime maxDate(string codGiust) + { + DateTime answ = DateTime.Today.AddDays(NumDayPermMax); + switch (codGiust) + { + case "FER": + answ = new DateTime(answ.Year, answ.Month, 1).AddMonths(months); + break; + + case "104": + case "PERM": + default: + DateTime.Today.AddDays(NumDayPermMax); + break; + } + return answ; + } + + private DateTime minDate(string codGiust) + { + DateTime answ = DateTime.Today; + switch (codGiust) + { + case "FER": + answ = DateTime.Today.AddDays(NumDayFerieRichAntic); + break; + + case "104": + case "PERM": + default: + answ = DateTime.Today; + break; + } + return answ; + } + + private async Task ReloadData() + { + ListRecords = null; + await initConf(); + await Task.Delay(1); + // carico richieste di TUTTI + ListRecords = await GDataServ.RegRichiesteGetByDip(0, dtInizio, dtFine); + } + + private async Task toggleAddNew() + { + showAdd = !showAdd; + await Task.Delay(1); + if (showAdd) + { + currRecord = new RegRichiesteModel() { IdxDipendente = AppMServ.IdxDipendente }; + } + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/GPW.CORE.ADM/Components/Compo/TaskDetail.razor b/GPW.CORE.ADM/Components/Compo/TaskDetail.razor new file mode 100644 index 0000000..4b65318 --- /dev/null +++ b/GPW.CORE.ADM/Components/Compo/TaskDetail.razor @@ -0,0 +1,74 @@ +@inject DialogService DialogService + +
+
+
+
Tipologia:
+
@model.CodTipo
+
+
+
    +
  • +
    +
    Nome:
    + @if (@model.IdxDipendente > 0) + { +
    @model.Abbrev
    + } + else + { +
    @model.Descrizione
    + } +
    +
  • + @if (model.DtEnd.Subtract(model.DtStart).TotalHours < 24) + { +
  • +
    +
    Data:
    +
    @($"{model.DtStart:ddd yyyy-MM-dd}")
    +
    +
  • + } +
  • +
    +
    Inizio:
    +
    @(EventDTO.DateForm(model.CodTipo, model.DtStart))
    +
    +
  • +
  • +
    +
    Fine:
    +
    @(EventDTO.DateForm(model.CodTipo, model.DtEnd))
    +
    +
  • + @if (model.IdxDipendente == idxDipendente) + { +
  • +
    +
    Note:
    +
    @model.Note
    +
    +
  • + } +
+
+ +@code { + [Parameter] + public EventDTO ThisTask { get; set; } = null!; + + [Inject] + protected MessageService AppMServ { get; set; } = null!; + + EventDTO model = new EventDTO(); + + protected override void OnParametersSet() + { + model = ThisTask; + } + protected int idxDipendente + { + get => AppMServ.IdxDipendente; + } +} \ No newline at end of file diff --git a/GPW.CORE.ADM/Components/Pages/RichiesteDip.razor b/GPW.CORE.ADM/Components/Pages/RichiesteDip.razor index f8a7d66..ecbb700 100644 --- a/GPW.CORE.ADM/Components/Pages/RichiesteDip.razor +++ b/GPW.CORE.ADM/Components/Pages/RichiesteDip.razor @@ -1,7 +1,41 @@ @page "/RichiesteDip" - +
+
+
+

Gestione Permessi, Ferie e Malattie

+
+
+ +
+
+
+
+
+ @if (isLoading) + { + + } + else + { + @if (showMalattie) + { + + } + else + { + + } + } +
+
+ +
+
+
+
+ + + -@code { -} diff --git a/GPW.CORE.ADM/Components/Pages/RichiesteDip.razor.cs b/GPW.CORE.ADM/Components/Pages/RichiesteDip.razor.cs new file mode 100644 index 0000000..51c5966 --- /dev/null +++ b/GPW.CORE.ADM/Components/Pages/RichiesteDip.razor.cs @@ -0,0 +1,145 @@ +using GPW.CORE.Data.DbModels; +using GPW.CORE.Data.DTO; +using GPW.CORE.Data.Services; +using Microsoft.AspNetCore.Components; +using static EgwCoreLib.Razor.Toggler; + +namespace GPW.CORE.ADM.Components.Pages +{ + public partial class RichiesteDip + { + #region Protected Fields + + protected int anno = DateTime.Today.Year; + + protected DateTime dtMax = DateTime.Today.AddYears(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 async Task OnInitializedAsync() + { + initToggler(); + // 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; + } + // fix iniziale date... setup periodo (da rivedere in funzione eventi cambio mese dei controlli?!?) + DateTime oggi = DateTime.Today; + dtMin = new DateTime(oggi.Year - 1, 1, 1); + dtMax = dtMin.AddYears(3); + await ReloadData(); + } + + #endregion Protected Methods + + #region Private Fields + + private bool isLoading = false; + + #endregion Private Fields + + #region Private Properties + + private List ListFermateAzienda { get; set; } = new List(); + + private List ListMalattie { get; set; } = new List(); + + private List ListRichiesteDip { get; set; } = new List(); + + /// + /// Elenco eventi formato originale (EventDTO) + /// + private List SchedEvList { get; set; } = new List(); + + 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 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; + // recupero direttamente da oggetto DB + SchedEvList = await DataService.EventListPeriodo(idxDipendente, dtMin, dtMax); + isLoading = false; + } + + 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 ReloadData(); + } + } + + private async Task SetMonth(int newNum) + { + if (numMesi != newNum) + { + numMesi = newNum; + } + await ReloadData(); + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/GPW.CORE.ADM/GPW.CORE.ADM.csproj b/GPW.CORE.ADM/GPW.CORE.ADM.csproj index 7cbf0f4..42adffb 100644 --- a/GPW.CORE.ADM/GPW.CORE.ADM.csproj +++ b/GPW.CORE.ADM/GPW.CORE.ADM.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 4.1.2409.1117 + 4.1.2409.1118 diff --git a/GPW.CORE.ADM/Properties/PublishProfiles/IIS-PROD.pubxml.user b/GPW.CORE.ADM/Properties/PublishProfiles/IIS-PROD.pubxml.user index 370d143..1563daa 100644 --- a/GPW.CORE.ADM/Properties/PublishProfiles/IIS-PROD.pubxml.user +++ b/GPW.CORE.ADM/Properties/PublishProfiles/IIS-PROD.pubxml.user @@ -7,7 +7,7 @@ by editing this MSBuild file. In order to learn more about this please visit htt AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAw3dMMgC4FUywyOTV2xvCRgAAAAACAAAAAAADZgAAwAAAABAAAADrbAogtj/xpZqylbgs9Hb3AAAAAASAAACgAAAAEAAAAFm1lcdH7oj+NFy4QgZ7q18YAAAAROPsyRR12dhPTKfMEQ5yNCAZJ5K7C4pvFAAAAEFBVTwItjyYP2BlOTsuK1g9myQ8 - True|2024-09-10T15:58:48.6965236Z||;True|2024-09-10T15:56:39.2931971+02:00||;True|2024-09-10T12:27:20.6683309+02:00||;True|2024-09-07T10:37:21.9427027+02:00||;True|2024-09-06T19:01:32.2132061+02:00||;True|2024-09-06T18:20:28.3994458+02:00||;True|2024-09-05T10:43:51.3246848+02:00||;True|2024-09-05T10:26:17.6114175+02:00||;True|2024-09-05T09:25:03.5122942+02:00||;True|2024-09-04T18:21:49.9717603+02:00||;True|2023-04-11T10:12:15.0154900+02:00||;False|2023-04-11T10:11:47.1977827+02:00||;True|2023-04-11T09:18:55.4555319+02:00||;True|2023-04-11T09:16:05.8827677+02:00||;True|2022-06-06T12:56:03.5790550+02:00||;False|2022-06-06T12:54:19.4739620+02:00||;False|2022-06-06T12:53:46.4246554+02:00||; + True|2024-09-11T15:21:29.6285775Z||;True|2024-09-11T17:06:36.9651346+02:00||;True|2024-09-10T17:58:48.6965236+02:00||;True|2024-09-10T15:56:39.2931971+02:00||;True|2024-09-10T12:27:20.6683309+02:00||;True|2024-09-07T10:37:21.9427027+02:00||;True|2024-09-06T19:01:32.2132061+02:00||;True|2024-09-06T18:20:28.3994458+02:00||;True|2024-09-05T10:43:51.3246848+02:00||;True|2024-09-05T10:26:17.6114175+02:00||;True|2024-09-05T09:25:03.5122942+02:00||;True|2024-09-04T18:21:49.9717603+02:00||;True|2023-04-11T10:12:15.0154900+02:00||;False|2023-04-11T10:11:47.1977827+02:00||;True|2023-04-11T09:18:55.4555319+02:00||;True|2023-04-11T09:16:05.8827677+02:00||;True|2022-06-06T12:56:03.5790550+02:00||;False|2022-06-06T12:54:19.4739620+02:00||;False|2022-06-06T12:53:46.4246554+02:00||; \ No newline at end of file diff --git a/GPW.CORE.Data/Controllers/GPWController.cs b/GPW.CORE.Data/Controllers/GPWController.cs index 77065de..b397bbe 100644 --- a/GPW.CORE.Data/Controllers/GPWController.cs +++ b/GPW.CORE.Data/Controllers/GPWController.cs @@ -2031,6 +2031,40 @@ namespace GPW.CORE.Data.Controllers return answ; } + /// + /// Aggiorna record registro richieste approvando la richiesta + /// + /// + public bool RegRichiesteApprova(RegRichiesteModel currItem) + { + bool answ = false; + using (GPWContext localDbCtx = new GPWContext(_configuration)) + { + try + { + var currRec = localDbCtx + .DbSetRegRichieste + .FirstOrDefault(x => x.IdxRegRich == currItem.IdxRegRich); + if (currRec != null) + { + currRec.Conf = true; + + localDbCtx + .DbSetRegRichieste + .Update(currRec); + + localDbCtx.SaveChanges(); + answ = true; + } + } + catch (Exception exc) + { + Log.Error($"Eccezione in RegRichiesteApprova{Environment.NewLine}{exc}"); + } + } + return answ; + } + /// /// Elimina record registro richieste (SE non confermato) /// diff --git a/GPW.CORE.Data/Services/GpwDataService.cs b/GPW.CORE.Data/Services/GpwDataService.cs index 88fbe2b..77a1c27 100644 --- a/GPW.CORE.Data/Services/GpwDataService.cs +++ b/GPW.CORE.Data/Services/GpwDataService.cs @@ -2,6 +2,7 @@ using GPW.CORE.Data.DbModels; using GPW.CORE.Data.DTO; using Microsoft.AspNetCore.Identity.UI.Services; +using Microsoft.EntityFrameworkCore.Update; using Microsoft.Extensions.Configuration; using Newtonsoft.Json; using NLog; @@ -1896,6 +1897,71 @@ namespace GPW.CORE.Data.Services return answ; } + /// + /// Registra approvazione x la richiesta indicata + /// + /// + /// + public async Task RegRichiesteApprova(RegRichiesteModel currItem) + { + bool answ = false; + try + { + // modifico approvata sul record + currItem.Conf = true; + // scrivo su DB + answ = dbController.RegRichiesteApprova(currItem); + if (answ) + { + // recupero info dipendente + var listDip = await DipendentiGetAll(); + var currDip = listDip.FirstOrDefault(x => x.IdxDipendente == currItem.IdxDipendente); + // gestisco email notifica... + string emailDest = _configuration.GetValue("MailDest:InfoRich") ?? "info@egalware.com"; + if (!emailDest.Contains(currDip.Email)) + { + emailDest += $",{currDip.Email}"; + } + if (currDip.idxResp > 0) + { + string mailResp = await emailResp(currDip.idxResp); + if (!string.IsNullOrEmpty(mailResp) && !emailDest.Contains(mailResp)) + { + emailDest += $",{mailResp}"; + } + } + string urlRedir = _configuration.GetValue("AdmApp:LinkRich") ?? ""; + DateTime adesso = DateTime.Now; + StringBuilder sbMain = new StringBuilder(); + sbMain.AppendLine($"Il giorno {adesso:yyyy.MM.dd} alle ore {adesso:HH:mm:ss} è stata modificata la richiesta in oggetto."); + sbMain.AppendLine(""); + sbMain.Append("
"); + sbMain.Append($"{currDip.Cognome} {currDip.Nome} ({currDip.Matricola})"); + sbMain.Append("
"); + sbMain.AppendLine("
"); + sbMain.AppendLine($"Richiesta: {currItem.CodGiust}"); + string stato = currItem.Conf ? "CONFERMATA" : "RIFIUTATA"; + sbMain.AppendLine($"Stato: {stato}"); + sbMain.AppendLine($"Inizio: {currItem.DtStart}"); + sbMain.AppendLine($"Fine: {currItem.DtEnd}"); + sbMain.AppendLine($"Note: {currItem.Note}"); + sbMain.AppendLine("
"); + + string msgBody = sbMain.ToString().Replace($"{Environment.NewLine}", "
"); + await sendEmail(emailDest, $"Aggiornamento Richiesta n.{currItem.IdxRegRich} ({currItem.CodGiust})", msgBody); + } + // invalido la cache... + await ExecFlushRedisPattern($"{rKeyDipendenti}:*"); + await ExecFlushRedisPattern($"{rKeyDailyData}:*"); + await ExecFlushRedisPattern($"{rKeyLastRegAtt}:*"); + await ExecFlushRedisPattern($"{rKeyParetoRegAtt}:*"); + await ExecFlushRedisPattern($"{rKeyWeekStats}:*"); + } + catch + { } + return answ; + } + /// /// Effettua eliminazione record registro richieste dipendente (SE non confermato) /// @@ -2006,6 +2072,7 @@ namespace GPW.CORE.Data.Services bool answ = false; try { + bool isNew = currItem.IdxRegRich == 0; // scrivo su DB answ = dbController.RegRichiesteUpsert(currItem); if (answ) @@ -2015,6 +2082,10 @@ namespace GPW.CORE.Data.Services var currDip = listDip.FirstOrDefault(x => x.IdxDipendente == currItem.IdxDipendente); // gestisco email notifica... string emailDest = _configuration.GetValue("MailDest:InfoRich") ?? "info@egalware.com"; + if (!emailDest.Contains(currDip.Email)) + { + emailDest += $",{currDip.Email}"; + } if (currDip.idxResp > 0) { string mailResp = await emailResp(currDip.idxResp); @@ -2033,13 +2104,19 @@ namespace GPW.CORE.Data.Services sbMain.Append(""); sbMain.AppendLine("
"); sbMain.AppendLine($"Richiesta: {currItem.CodGiust}"); + if(!isNew) + { + string stato = currItem.Conf ? "CONFERMATA" : "RIFIUTATA"; + sbMain.AppendLine($"Stato: {stato}"); + } sbMain.AppendLine($"Periodo: {currItem.DtStart} --> {currItem.DtEnd}"); sbMain.AppendLine($"Note: {currItem.Note}"); sbMain.AppendLine("
"); sbMain.AppendLine($"Cliccare sul seguente link per accedere alla pagina di gestione"); string msgBody = sbMain.ToString(); - await sendEmail(emailDest, $"Nuovo record Richiesta {currItem.CodGiust} Dipendente", msgBody.Replace($"{Environment.NewLine}", "
")); + string subj = isNew ? $"Nuovo record Richiesta {currItem.CodGiust} Dipendente" : $"Aggiornamento Richiesta n.{currItem.IdxRegRich} ({currItem.CodGiust})"; + await sendEmail(emailDest, subj, msgBody.Replace($"{Environment.NewLine}", "
")); } // invalido la cache... await ExecFlushRedisPattern($"{rKeyDipendenti}:*"); diff --git a/GPW.CORE.WRKLOG/Components/Compo/RegRichieste.razor.cs b/GPW.CORE.WRKLOG/Components/Compo/RegRichieste.razor.cs index f38c538..ffec43d 100644 --- a/GPW.CORE.WRKLOG/Components/Compo/RegRichieste.razor.cs +++ b/GPW.CORE.WRKLOG/Components/Compo/RegRichieste.razor.cs @@ -179,7 +179,6 @@ namespace GPW.CORE.WRKLOG.Components.Compo await Task.Delay(1); isSendingData = true; - isSendingData = true; sendDataVal = 0; sendDataNextVal = 90; await Task.Delay(1); diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 49a331b..3274dba 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ GPW - Gestione Presenze Web -

Versione: 4.1.2409.1117

+

Versione: 4.1.2409.1118


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index 5bbd126..6e3aab2 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -4.1.2409.1117 +4.1.2409.1118 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 170dba3..649081f 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 4.1.2409.1117 + 4.1.2409.1118 http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html false