280 lines
9.4 KiB
C#
280 lines
9.4 KiB
C#
using EgwCoreLib.Razor;
|
|
using EgwCoreLib.Utils;
|
|
using GPW.CORE.Data.DbModels;
|
|
using GPW.CORE.Data.Services;
|
|
using Microsoft.AspNetCore.Components;
|
|
using NLog;
|
|
|
|
namespace GPW.CORE.ADM.Components.Compo
|
|
{
|
|
public partial class TimbMensMan
|
|
{
|
|
|
|
[Inject]
|
|
protected AppAuthService AuthServ { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected MessageService AppMServ { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected GpwDataService GDataServ { get; set; } = null!;
|
|
|
|
protected int IdxDipSel { get; set; } = 0;
|
|
|
|
|
|
protected string Traduci(string lemma)
|
|
{
|
|
return AuthServ.Traduci(lemma, AppMServ.UserLang);
|
|
}
|
|
|
|
|
|
protected async void Recalc()
|
|
{
|
|
await Task.Delay(200);
|
|
}
|
|
|
|
protected async Task ForceReload()
|
|
{
|
|
currPage = 1;
|
|
SelRecord = null;
|
|
await ReloadData();
|
|
}
|
|
protected async Task SortRequested(Sorter.SortCallBack e)
|
|
{
|
|
sortField = e.ParamName;
|
|
sortAsc = e.IsAscending;
|
|
await ReloadData();
|
|
}
|
|
|
|
protected string CssCheckSel(TimbMeseExplModel currRec)
|
|
{
|
|
bool isSel = SelRecord != null && SelRecord.IdxDipendente == currRec.IdxDipendente && SelRecord.Anno == currRec.Anno && SelRecord.Mese == currRec.Mese;
|
|
return isSel ? "table-info" : "";
|
|
}
|
|
|
|
|
|
protected async Task SetNumRec(int newNum)
|
|
{
|
|
numRecord = newNum;
|
|
currPage = 1;
|
|
await AppMServ.NumRowGridSet(gridKey, newNum);
|
|
await InvokeAsync(ReloadData);
|
|
}
|
|
protected async Task SetPage(int newNum)
|
|
{
|
|
currPage = newNum;
|
|
await InvokeAsync(ReloadData);
|
|
}
|
|
|
|
private bool sortAsc = true;
|
|
|
|
private string sortField = "";
|
|
private bool ShowInatt { get; set; } = false;
|
|
private int currPage { get; set; } = 1;
|
|
private TimbMeseExplModel? SelRecord { get; set; } = null;
|
|
private bool isLoading { get; set; } = false;
|
|
private List<TimbMeseExplModel>? ListRecords { get; set; } = null;
|
|
private int numRecord { get; set; } = 10;
|
|
private int totalCount { get; set; } = 0;
|
|
private DtUtils.Periodo CurrPeriodo { get; set; } = new DtUtils.Periodo(DtUtils.PeriodSet.ThisMonth);
|
|
private List<DipendentiModel> ListDipendenti { get; set; } = new List<DipendentiModel>();
|
|
private List<TimbMeseExplModel>? SearchRecords { get; set; } = null;
|
|
|
|
private string gridKey = "TimbMan";
|
|
|
|
private static Logger Log = LogManager.GetCurrentClassLogger();
|
|
|
|
|
|
private string mainDivCss
|
|
{
|
|
get => SelRecord == null ? "col-12" : "col-12 col-lg-9";
|
|
}
|
|
private string detDivCss
|
|
{
|
|
get => SelRecord == null ? "col-0" : "col-12 col-lg-3";
|
|
}
|
|
|
|
private async Task ReloadData()
|
|
{
|
|
isLoading = true;
|
|
ListRecords = null;
|
|
var rawList = await GDataServ.DipendentiGetAll();
|
|
|
|
#if true
|
|
|
|
if (ShowInatt)
|
|
{
|
|
ListDipendenti = rawList;
|
|
}
|
|
else
|
|
{
|
|
ListDipendenti = rawList.Where(x => (x.Attivo ?? false)).ToList();
|
|
}
|
|
try
|
|
{
|
|
SearchRecords = await GDataServ.TimbMeseExplList(IdxDipSel, CurrPeriodo.Inizio, CurrPeriodo.Fine);
|
|
// verifico filtro per IdxDip
|
|
if (IdxDipSel > 0)
|
|
{
|
|
SearchRecords = SearchRecords.Where(x => x.IdxDipendente == IdxDipSel).ToList();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.Error($"Eccezione in recupero dati{Environment.NewLine}{ex}");
|
|
}
|
|
totalCount = SearchRecords.Count;
|
|
SortTable();
|
|
#endif
|
|
|
|
isLoading = false;
|
|
}
|
|
|
|
|
|
private void SortTable()
|
|
{
|
|
if (SearchRecords != null)
|
|
{
|
|
// se ho ordinamento riordino...
|
|
if (!string.IsNullOrEmpty(sortField))
|
|
{
|
|
switch (sortField)
|
|
{
|
|
case "Anno":
|
|
if (sortAsc)
|
|
{
|
|
SearchRecords = SearchRecords.OrderBy(x => x.Anno).ToList();
|
|
}
|
|
else
|
|
{
|
|
SearchRecords = SearchRecords.OrderByDescending(x => x.Anno).ToList();
|
|
}
|
|
break;
|
|
|
|
case "Mese":
|
|
if (sortAsc)
|
|
{
|
|
SearchRecords = SearchRecords.OrderBy(x => x.Mese).ToList();
|
|
}
|
|
else
|
|
{
|
|
SearchRecords = SearchRecords.OrderByDescending(x => x.Mese).ToList();
|
|
}
|
|
break;
|
|
|
|
case "IdxDipendente":
|
|
if (sortAsc)
|
|
{
|
|
SearchRecords = SearchRecords.OrderBy(x => x.IdxDipendente).ToList();
|
|
}
|
|
else
|
|
{
|
|
SearchRecords = SearchRecords.OrderByDescending(x => x.IdxDipendente).ToList();
|
|
}
|
|
break;
|
|
|
|
case "totOreOrd":
|
|
if (sortAsc)
|
|
{
|
|
SearchRecords = SearchRecords.OrderBy(x => x.totOreOrd).ToList();
|
|
}
|
|
else
|
|
{
|
|
SearchRecords = SearchRecords.OrderByDescending(x => x.totOreOrd).ToList();
|
|
}
|
|
break;
|
|
|
|
case "totLav":
|
|
if (sortAsc)
|
|
{
|
|
SearchRecords = SearchRecords.OrderBy(x => x.totLav).ToList();
|
|
}
|
|
else
|
|
{
|
|
SearchRecords = SearchRecords.OrderByDescending(x => x.totLav).ToList();
|
|
}
|
|
break;
|
|
|
|
case "totOreNonLav":
|
|
if (sortAsc)
|
|
{
|
|
SearchRecords = SearchRecords.OrderBy(x => x.totOreNonLav).ToList();
|
|
}
|
|
else
|
|
{
|
|
SearchRecords = SearchRecords.OrderByDescending(x => x.totOreNonLav).ToList();
|
|
}
|
|
break;
|
|
|
|
case "totOrePerm":
|
|
if (sortAsc)
|
|
{
|
|
SearchRecords = SearchRecords.OrderBy(x => x.totOrePerm).ToList();
|
|
}
|
|
else
|
|
{
|
|
SearchRecords = SearchRecords.OrderByDescending(x => x.totOrePerm).ToList();
|
|
}
|
|
break;
|
|
|
|
case "totOreFer":
|
|
if (sortAsc)
|
|
{
|
|
SearchRecords = SearchRecords.OrderBy(x => x.totOreFer).ToList();
|
|
}
|
|
else
|
|
{
|
|
SearchRecords = SearchRecords.OrderByDescending(x => x.totOreFer).ToList();
|
|
}
|
|
break;
|
|
|
|
case "totOreFest":
|
|
if (sortAsc)
|
|
{
|
|
SearchRecords = SearchRecords.OrderBy(x => x.totOreFest).ToList();
|
|
}
|
|
else
|
|
{
|
|
SearchRecords = SearchRecords.OrderByDescending(x => x.totOreFest).ToList();
|
|
}
|
|
break;
|
|
|
|
case "totOreStra":
|
|
if (sortAsc)
|
|
{
|
|
SearchRecords = SearchRecords.OrderBy(x => x.totOreStra).ToList();
|
|
}
|
|
else
|
|
{
|
|
SearchRecords = SearchRecords.OrderByDescending(x => x.totOreStra).ToList();
|
|
}
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
// filtro x display
|
|
ListRecords = SearchRecords
|
|
.Skip(numRecord * (currPage - 1))
|
|
.Take(numRecord)
|
|
.ToList();
|
|
}
|
|
else
|
|
{
|
|
ListRecords = new List<TimbMeseExplModel>();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task SavePeriodo(DtUtils.Periodo newPeiodo)
|
|
{
|
|
CurrPeriodo = newPeiodo;
|
|
await ReloadData();
|
|
}
|
|
|
|
}
|
|
} |