309 lines
11 KiB
C#
309 lines
11 KiB
C#
using GPW_data;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace GPW_Admin.WebUserControls
|
|
{
|
|
public partial class cmp_calAnnuale : BaseUserControl
|
|
{
|
|
#region Public Properties
|
|
|
|
public int anno
|
|
{
|
|
get => _anno;
|
|
set
|
|
{
|
|
_anno = value;
|
|
//odsMesi.DataBind();
|
|
repCal.DataBind();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Mostra anche richieste (permessi/ferie/104) confermate o solo da confermare
|
|
/// </summary>
|
|
public bool showAlsoConf { get; set; } = true;
|
|
|
|
/// <summary>
|
|
/// Mostrare/Colorare sul calendario le chiusure aziendali programmate
|
|
/// </summary>
|
|
public bool showCalAz
|
|
{
|
|
get => _showCalAz;
|
|
set
|
|
{
|
|
_showCalAz = value;
|
|
divCalAz.Visible = value;
|
|
divFes.Visible = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Mostrare/Colorare sul calendario le malattie ricevute
|
|
/// </summary>
|
|
public bool showMal
|
|
{
|
|
get => _showMal;
|
|
set
|
|
{
|
|
_showMal = value;
|
|
divMal.Visible = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Mostrare/Colorare sul calendario le richieste dipendente
|
|
/// </summary>
|
|
public bool showRichDip
|
|
{
|
|
get => _showRichDip;
|
|
set
|
|
{
|
|
_showRichDip = value;
|
|
divRichDip.Visible = value;
|
|
}
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Properties
|
|
|
|
protected DS_Applicazione.DipendentiDataTable listaDip { get; set; }
|
|
|
|
protected List<DS_Applicazione.CalendFesteFerieRow> listCFF { get; set; }
|
|
|
|
protected List<DS_Applicazione.RegistroMalattieRow> listRM { get; set; }
|
|
protected List<DS_Applicazione.RegistroRichiesteRow> listRR { get; set; }
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
/// <summary>
|
|
/// colorazione calendario da eventi registrati....
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void calDisplay_DayRender(object sender, System.Web.UI.WebControls.DayRenderEventArgs e)
|
|
{
|
|
bool isColored = false;
|
|
if (showCalAz)
|
|
{
|
|
// coloro se fa parte delle festività/ferie...
|
|
if (listCFF != null && listCFF.Count > 0)
|
|
{
|
|
// cerco riga...
|
|
var thisDate = listCFF.Where(x => x.data == e.Day.Date).FirstOrDefault();
|
|
if (thisDate != null && e.Cell.CssClass != "text-light")
|
|
{
|
|
isColored = true;
|
|
e.Cell.CssClass = thisDate.codGiust == "FEST" ? "bg-danger text-warning" : "bg-warning";
|
|
e.Cell.ToolTip = $"{thisDate.descrizione}";
|
|
}
|
|
}
|
|
}
|
|
if (showMal)
|
|
{
|
|
// coloro se fa parte delle festività/ferie...
|
|
if (listRM != null && listRM.Count > 0)
|
|
{
|
|
// cerco riga...
|
|
var listMal = listRM.Where(x => e.Day.Date >= x.DtInizio && e.Day.Date < x.DtInizio.AddDays(x.NumGG)).ToList();
|
|
var thisDate = listMal.FirstOrDefault();
|
|
if (thisDate != null && e.Cell.CssClass != "text-light")
|
|
{
|
|
isColored = true;
|
|
e.Cell.CssClass = "bg-dark text-light";
|
|
// se ho 1 sola riga --> metto 1, altrimenti compilo multiplo...
|
|
string toolTip = "";
|
|
if (listMal.Count == 1)
|
|
{
|
|
toolTip = $"{datiDip(thisDate.IdxDipendente)}";
|
|
}
|
|
else
|
|
{
|
|
foreach (var item in listMal)
|
|
{
|
|
toolTip += $"{datiDip(item.IdxDipendente)} | ";
|
|
}
|
|
// elimino ultimo
|
|
// <br />
|
|
toolTip = toolTip.Substring(0, toolTip.Length - 3);
|
|
}
|
|
e.Cell.ToolTip = toolTip;
|
|
}
|
|
}
|
|
}
|
|
if (showRichDip)
|
|
{
|
|
// coloro se fa parte delle richieste dipendenti...
|
|
if (listRR != null && listRR.Count > 0)
|
|
{
|
|
if (e.Day.Date.DayOfWeek != DayOfWeek.Saturday && e.Day.Date.DayOfWeek != DayOfWeek.Sunday)
|
|
{
|
|
// cerco righe...
|
|
var listReq = listRR.Where(x => e.Day.Date >= x.DtStart.Date && e.Day.Date <= x.DtEnd.Date).ToList();
|
|
if (listReq != null && listReq.Count > 0)
|
|
{
|
|
var thisDate = listReq.FirstOrDefault();
|
|
if (thisDate != null && e.Cell.CssClass != "text-light")
|
|
{
|
|
isColored = true;
|
|
switch (thisDate.CodGiust)
|
|
{
|
|
case "104":
|
|
e.Cell.CssClass = thisDate.Conf ? "g104Conf" : "g104NC";
|
|
break;
|
|
|
|
case "FER":
|
|
e.Cell.CssClass = thisDate.Conf ? "gFerConf" : "gFerNC";
|
|
break;
|
|
|
|
case "PERM":
|
|
e.Cell.CssClass = thisDate.Conf ? "gPerConf" : "gPerNC";
|
|
break;
|
|
|
|
default:
|
|
e.Cell.CssClass = "bg-dark text-light";
|
|
break;
|
|
}
|
|
}
|
|
// se ho 1 sola riga --> metto 1, altrimenti compilo multiplo...
|
|
string toolTip = "";
|
|
if (listReq.Count == 1)
|
|
{
|
|
toolTip = $"{thisDate.CodGiust}, {datiDip(thisDate.IdxDipendente)}";
|
|
}
|
|
else
|
|
{
|
|
foreach (var item in listReq)
|
|
{
|
|
toolTip += $"{item.CodGiust}, {datiDip(item.IdxDipendente)} | ";
|
|
}
|
|
// elimino ultimo
|
|
// <br />
|
|
toolTip = toolTip.Substring(0, toolTip.Length - 3);
|
|
}
|
|
e.Cell.ToolTip = toolTip;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// se sab/dom --> grigio
|
|
if (!isColored && e.Cell.CssClass != "text-light")
|
|
{
|
|
if (e.Day.Date.DayOfWeek == DayOfWeek.Saturday || e.Day.Date.DayOfWeek == DayOfWeek.Sunday)
|
|
{
|
|
e.Cell.CssClass = "bg-secondary text-light";
|
|
}
|
|
}
|
|
}
|
|
|
|
protected string datiDip(object idxDip)
|
|
{
|
|
int idxDipendente = 0;
|
|
int.TryParse($"{idxDip}", out idxDipendente);
|
|
string answ = "NA";
|
|
var rigaDip = listaDip.FirstOrDefault(x => x.idxDipendente == idxDipendente);
|
|
if (rigaDip != null)
|
|
{
|
|
answ = $"{rigaDip.Cognome} {rigaDip.Nome}";
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
protected void doUpdateCal()
|
|
{
|
|
if (showCalAz)
|
|
{
|
|
listCFF = CffListByAnno(anno);
|
|
}
|
|
if (showRichDip)
|
|
{
|
|
listRR = RRListByAnno(anno);
|
|
}
|
|
if (showMal)
|
|
{
|
|
listRM = RMListByAnno(anno);
|
|
}
|
|
}
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
repCal.Visible = chkLicOk;
|
|
listaDip = licenzeGPW.getDipAttivi();
|
|
divRichDip.Visible = showRichDip;
|
|
}
|
|
|
|
protected void repCal_PreRender(object sender, EventArgs e)
|
|
{
|
|
doUpdateCal();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Properties
|
|
|
|
private int _anno
|
|
{
|
|
get
|
|
{
|
|
int answ = 0;
|
|
int.TryParse(hfAnno.Value, out answ);
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
hfAnno.Value = $"{value}";
|
|
}
|
|
}
|
|
|
|
private bool _showCalAz { get; set; } = true;
|
|
private bool _showMal { get; set; } = false;
|
|
private bool _showRichDip { get; set; } = true;
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
/// <summary>
|
|
/// Elenco Festività / Ferie x anno
|
|
/// </summary>
|
|
/// <param name="reqYear"></param>
|
|
private List<DS_Applicazione.CalendFesteFerieRow> CffListByAnno(int reqYear)
|
|
{
|
|
DateTime inizio = new DateTime(reqYear, 1, 1);
|
|
DateTime fine = inizio.AddYears(1);
|
|
List<DS_Applicazione.CalendFesteFerieRow> result = DataProxy.DP.taCFF.getPeriod(inizio, fine).ToList();
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Elenco Richieste Dipendenti x anno
|
|
/// </summary>
|
|
/// <param name="reqYear"></param>
|
|
private List<DS_Applicazione.RegistroMalattieRow> RMListByAnno(int reqYear)
|
|
{
|
|
DateTime inizio = new DateTime(reqYear, 1, 1);
|
|
DateTime fine = inizio.AddYears(1);
|
|
List<DS_Applicazione.RegistroMalattieRow> result = DataProxy.DP.taRM.getPeriod(0, inizio, fine).ToList();
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Elenco Richieste Dipendenti x anno
|
|
/// </summary>
|
|
/// <param name="reqYear"></param>
|
|
private List<DS_Applicazione.RegistroRichiesteRow> RRListByAnno(int reqYear)
|
|
{
|
|
DateTime inizio = new DateTime(reqYear, 1, 1);
|
|
DateTime fine = inizio.AddYears(1);
|
|
List<DS_Applicazione.RegistroRichiesteRow> result = DataProxy.DP.taRR.getPeriod(0, inizio, fine, showAlsoConf).ToList();
|
|
return result;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |