vacacciones

This commit is contained in:
JORGE LUIS CAUDILLO ESPARZA
2025-02-04 00:47:01 -07:00
parent 78fa879f6d
commit d5c45f2a59
2 changed files with 409 additions and 62 deletions

View File

@@ -1,5 +1,6 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="ReporteVacaciones.aspx.cs" Inherits="Nomina_ReporteVacaciones" %> <%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="ReporteVacaciones.aspx.cs" Inherits="Nomina_ReporteVacaciones" %>
<%@ Import Namespace="Extensiones" %>
<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server"> <asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
</asp:Content> </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Css" runat="Server"> <asp:Content ID="Content2" ContentPlaceHolderID="Css" runat="Server">
@@ -10,6 +11,110 @@
td.borderleft, th.borderleft { td.borderleft, th.borderleft {
border-left: 1px solid black !important; border-left: 1px solid black !important;
} }
.hiddentth, .hiddentth th {
background-color: #fff !important;
}
.showMesDia {
display: none;
}
table tr th.diac {
font-size: 4px;
padding-left: 1px !important;
padding-right: 1px !important;
}
table tr th.mesc{
font-size: 12px;
}
.mes1 {
background-color: #ffcccc;
border-color: #ffcccc;
}
/* Enero - Rojo claro */
.mes2 {
background-color: #ffebcc;
border-color: #ffcccc;
}
/* Febrero - Naranja claro */
.mes3 {
background-color: #ffffcc;
border-color: #ffcccc;
}
/* Marzo - Amarillo claro */
.mes4 {
background-color: #ccffcc;
border-color: #ffcccc;
}
/* Abril - Verde claro */
.mes5 {
background-color: #ccffff;
border-color: #ffcccc;
}
/* Mayo - Azul cielo */
.mes6 {
background-color: #ccccff;
border-color: #ffcccc;
}
/* Junio - Azul suave */
.mes7 {
background-color: #e6ccff;
border-color: #ffcccc;
}
/* Julio - Morado claro */
.mes8 {
background-color: #ffccff;
border-color: #ffcccc;
}
/* Agosto - Rosa claro */
.mes9 {
background-color: #ffb3b3;
border-color: #ffcccc;
}
/* Septiembre - Rojo pastel */
.mes10 {
background-color: #ff9966;
border-color: #ffcccc;
}
/* Octubre - Naranja pastel */
.mes11 {
background-color: #cccc99;
border-color: #ffcccc;
}
/* Noviembre - Verde oliva */
.mes12 {
background-color: #e6e6e6;
border-color: #ffcccc;
}
/* Diciembre - Gris claro */
.TContainer {
width:100%;
height: calc(100vh - 200px);
overflow:scroll;
}
.VacClass{
background-color:darkslateblue;
}
.borderyear{
border-left: 1px solid #FFF !important;
}
.yearclass{
background-color:#444;
color:#FFF;text-align: center;
font-size: 6px;
}
.yearclassB{
background-color:#999;
color:#FFF;text-align: center;
font-size: 6px;
}
tr.aniorow td{
height:8px;
}
</style> </style>
</asp:Content> </asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="E" runat="Server"> <asp:Content ID="Content3" ContentPlaceHolderID="E" runat="Server">
@@ -85,8 +190,93 @@
</div> </div>
</div> </div>
<div class="TContainer">
<table id="gvReporteVacacionesCalendar" class="table table-hover ScrollADig Widthall gvReporteVacacionesCalendar" data-rows="4" data-cols="3" data-heighterror="360">
<tbody>
<div> <tr class="hiddentth">
<th class="showMesDia"></th>
<th class="showMesDia"></th>
<th class="showMesDia"></th>
<%-- Encabezados dinámicos para los ejercicios --%>
<asp:Repeater ID="rptx" runat="server">
<ItemTemplate>
<%--<th class="showMes" runat="server" Visible='<%# Eval("Campo").ToString() == "1" %>'></th>--%>
<th class="showMesDia"></th>
</ItemTemplate>
</asp:Repeater>
</tr>
<tr>
<th></th>
<th></th>
<th></th>
<%-- Encabezados dinámicos para los ejercicios --%>
<asp:Repeater ID="rptanio" runat="server">
<ItemTemplate>
<th class="borderleft" data-toggle="tooltip" title='<%# Eval("Anio") %>' colspan='<%# Eval("DiasEjercicio") %>'><%# Eval("Anio") %></th>
</ItemTemplate>
</asp:Repeater>
</tr>
<tr>
<th></th>
<th></th>
<th></th>
<%-- Encabezados dinámicos para los ejercicios --%>
<%-- data-toggle="tooltip"
title='<%# new System.Globalization.CultureInfo("es-ES").DateTimeFormat.GetMonthName(Eval("Mes").ToString().ToEntero()).ToUpper() %>'--%>
<asp:Repeater ID="rptMeses" runat="server">
<ItemTemplate>
<th class='<%# string.Format("{0} diac mes{1} mesc","borderleft",Eval("Mes")) %>' colspan='<%# Eval("DiasMes") %>'>
<%# new System.Globalization.CultureInfo("es-ES").DateTimeFormat.GetMonthName(Eval("Mes").ToString().ToEntero()).ToUpper() %></th>
</ItemTemplate>
</asp:Repeater>
</tr>
<tr>
<th>Código</th>
<th>Nombre Completo</th>
<th>Fecha Inicio</th>
<%-- Encabezados dinámicos para los ejercicios --%>
<asp:Repeater ID="RepetDias" runat="server">
<ItemTemplate>
<th class='<%# string.Format("{0} diac mes{1}",(Eval("MinMes").ToString().ToUpper()=="1"?"borderleft":""),Eval("Mes")) %>'><%# Eval("Dia") %></th>
</ItemTemplate>
</asp:Repeater>
</tr>
<asp:Repeater ID="RepeaterPrincipalCalendar" runat="server">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<tr class="aniorow">
<%--<td><%# Eval("CvePersonal") %></td>--%>
<td rowspan="3"><asp:HyperLink runat="server" Text='<%# Eval("Codigo") %>' NavigateUrl='<%# Eval("CvePersonal", "~/RH/Personal.aspx?CvePersonal={0}") %>'></asp:HyperLink></td>
<td rowspan="3"><asp:HyperLink runat="server" Text='<%# Eval("NombreCompleto") %>' NavigateUrl='<%# Eval("CvePersonal", "~/RH/Personal.aspx?CvePersonal={0}") %>'></asp:HyperLink></td>
<td rowspan="3"><%# Eval("FechaInicio", "{0:yyyy-MM-dd}") %></td>
<%-- Subrepeater para los ejercicios --%>
<asp:Literal Text='<%# Eval("ColumnasinicioFin" ) %>' runat="server"></asp:Literal>
</tr>
<tr>
<asp:Literal Text='<%# Eval("ColumnasVacaciones" ) %>' runat="server"></asp:Literal>
<%-- <asp:Repeater ID="RepeaterEjercicios" runat="server" DataSource='<%# tabladias %>'>
<ItemTemplate>
<asp:Literal Text='<%# columnapersonal((int)Eval("FechaNum" ),(System.Data.DataTable )Eval("TDiaspersonal")) %>' runat="server"></asp:Literal>
</ItemTemplate>
</asp:Repeater>--%>
</tr>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
</tbody>
</table>
</div>
<div class="hidden">
<table id="gvReporteVacaciones" class="table table-striped table-advance table-hover ScrollAD Widthall gvReporteVacaciones" data-rows="2" data-heighterror="360"> <table id="gvReporteVacaciones" class="table table-striped table-advance table-hover ScrollAD Widthall gvReporteVacaciones" data-rows="2" data-heighterror="360">
<%-- <thead> <%-- <thead>
</thead>--%> </thead>--%>

View File

@@ -1,8 +1,11 @@
using ADSNetLibrary.Helpers; using Extensiones;
using iText.Html2pdf.Attach.Impl.Layout.Form.Element;
using Microsoft.Extensions.Primitives;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Linq; using System.Linq;
using System.Text;
using System.Web; using System.Web;
using System.Web.UI; using System.Web.UI;
using System.Web.UI.WebControls; using System.Web.UI.WebControls;
@@ -34,7 +37,7 @@ public partial class Nomina_ReporteVacaciones : ClsPaginas
{ {
get get
{ {
string fecha = $"{DateTime.Now.Year - 3}-01-01"; string fecha = $"{DateTime.Now.Year - 1}-01-01";
if (ViewState["FiltFechaInicio"] == null) { return fecha; } if (ViewState["FiltFechaInicio"] == null) { return fecha; }
else { return ViewState["FiltFechaInicio"].ToString(); } else { return ViewState["FiltFechaInicio"].ToString(); }
} }
@@ -52,6 +55,18 @@ public partial class Nomina_ReporteVacaciones : ClsPaginas
set { ViewState["FiltFechaFin"] = value; } set { ViewState["FiltFechaFin"] = value; }
} }
protected DataTable tabladias
{
get
{
if (ViewState["tabladias"] == null) { return new DataTable(); }
else { return (DataTable)ViewState["tabladias"]; }
}
set { ViewState["tabladias"] = value; }
}
#endregion #endregion
protected void Page_Load(object sender, EventArgs e) protected void Page_Load(object sender, EventArgs e)
{ {
@@ -68,17 +83,44 @@ public partial class Nomina_ReporteVacaciones : ClsPaginas
{ {
using (ClsNominas objnom = new ClsNominas()) using (ClsNominas objnom = new ClsNominas())
{ {
if (objnom.ReporteVacaciones(FiltCveProyecto, FiltCveSubProyecto, UsuarioActual.CveEmpresa, FiltFechaInicio, FiltFechaFin)) if (objnom.ReporteVacacionesCalendario(FiltCveProyecto, FiltCveSubProyecto, UsuarioActual.CveEmpresa, FiltFechaInicio, FiltFechaFin))
{ {
DataTable tabla1 = objnom.DTSetResultados.Tables[0]; // Simula tu tabla 1 DataTable tabla1 = objnom.DTSetResultados.Tables[0]; //
DataTable tabla2 = objnom.DTSetResultados.Tables[1]; // Simula tu tabla 2 DataTable tabla2 = objnom.DTSetResultados.Tables[1]; //
DataTable tabla3 = objnom.DTSetResultados.Tables[2]; // Simula tu tabla 3 DataTable tabla3 = objnom.DTSetResultados.Tables[2]; //
tabladias = objnom.DTSetResultados.Tables[3];
DataTable tabladiasPersonal = objnom.DTSetResultados.Tables[4];
RepeaterEjerciciosH1.DataSource = tabla3; RepeaterEjerciciosH1.DataSource = tabla3;
RepeaterEjerciciosH2.DataSource = tabla3; RepeaterEjerciciosH2.DataSource = tabla3;
RepeaterEjerciciosH1.DataBind(); RepeaterEjerciciosH1.DataBind();
RepeaterEjerciciosH2.DataBind(); RepeaterEjerciciosH2.DataBind();
// Convertir Tabla 1 a Enumerable con un campo extra // Convertir Tabla 1 a Enumerable con un campo extra
List<Registro> resultado = tabla1.AsEnumerable().Select(row1 => new Registro() List<Registro> resultado = tabla1.AsEnumerable().Select(row1 =>
{
int cvePersonal = Convert.ToInt32(row1["CvePersonal"]);
DataRow[] filasFiltradas = tabladiasPersonal.Select($"CvePersonal = {cvePersonal}");
// Crear un nuevo DataTable con la misma estructura
DataTable TDiaspersonal = tabladiasPersonal.Clone();
// Importar las filas filtradas
foreach (DataRow fila in filasFiltradas)
{
TDiaspersonal.ImportRow(fila);
//DataRow nuevaFila = TDiaspersonal.NewRow();
//// Copiar manualmente cada columna
//foreach (DataColumn columna in tabladiasPersonal.Columns)
//{
// nuevaFila[columna.ColumnName] = fila[columna.ColumnName];
//}
//TDiaspersonal.Rows.Add(nuevaFila);
}
TDiaspersonal.AcceptChanges();
//DataTable TDiaspersonal = tabladiasPersonal.FiltraParametros(string.Format("CvePersonal = '{0}'", row1["CvePersonal"]));
int contador = tabladiasPersonal.Rows.Count;
return new Registro()
{ {
CvePersonal = row1.Field<int>("CvePersonal"), CvePersonal = row1.Field<int>("CvePersonal"),
Codigo = row1.Field<string>("Codigo"), Codigo = row1.Field<string>("Codigo"),
@@ -88,6 +130,8 @@ public partial class Nomina_ReporteVacaciones : ClsPaginas
FechaAntiguedad = row1.Field<DateTime>("FechaAntiguedad"), FechaAntiguedad = row1.Field<DateTime>("FechaAntiguedad"),
Antiguedad = row1.Field<int>("Antiguedad"), Antiguedad = row1.Field<int>("Antiguedad"),
ColumnasinicioFin = strColumnasinicioFin(tabladias, tabla2.FiltraParametros(string.Format("CvePersonal = {0}", row1["CvePersonal"])), row1["anio"].ToString().ToEntero(), row1["Mes"].ToString(), row1["Dia"].ToString()),
ColumnasVacaciones = strColumnasVacaciones(tabladias, TDiaspersonal),
// Campo extra: Enumerable para cada Ejercicio de Tabla 3 // Campo extra: Enumerable para cada Ejercicio de Tabla 3
Ejercicios = tabla3.AsEnumerable().Select(row3 => Ejercicios = tabla3.AsEnumerable().Select(row3 =>
{ {
@@ -125,19 +169,129 @@ public partial class Nomina_ReporteVacaciones : ClsPaginas
}; };
} }
}).ToList() }).ToList()
}).ToList(); };
}
).ToList();
RepeaterPrincipal.DataSource = resultado; RepeaterPrincipal.DataSource = resultado;
RepeaterPrincipal.DataBind(); RepeaterPrincipal.DataBind();
} RepeaterPrincipalCalendar.DataSource = resultado;
RepeaterPrincipalCalendar.DataBind();
rptanio.DataSource = tabladias.FiltraParametros("MinEjercicio = 1");
rptanio.DataBind();
rptMeses.DataSource = tabladias.FiltraParametros("MinMes = 1");
rptMeses.DataBind();
RepetDias.DataSource = tabladias;
RepetDias.DataBind();
rptx.DataSource = tabladias;
rptx.DataBind();
} }
} }
}
public string rightstr(string str,int cantidad)
{
return str.Length >= cantidad ? str.Substring(str.Length - cantidad) : str;
}
public string strColumnasinicioFin(DataTable tabladias, DataTable TEjercicio, int anio, string Mes, string Dia)
{
StringBuilder stringBuilder = new StringBuilder();
StringBuilder strbuilderB = new StringBuilder();
strbuilderB.AppendFormat(" </tr><tr>");
int FechaNum =string.Format("{0}{1}{2}", anio, Mes, Dia).ToEntero();
int Mesdia =string.Format("{0}{1}", Mes, Dia).ToEntero();
foreach (DataRow dr in tabladias.Rows)
{
int colspan = dr["DiasMes"].ToString().ToEntero();
int mesidias = rightstr(dr["FechaNum"].ToString(),4).ToEntero();
int mesa = dr["Mes"].ToString().ToEntero();
int ania = dr["Anio"].ToString().ToEntero()-(mesidias >= Mesdia?0:1);
DataRow hdrow = TEjercicio.FiltroPrimero(string.Format("Ejercicio = {0}", ania));
int drFechaNum = dr["FechaNum"].ToString().ToEntero();
string classtd = drFechaNum < FechaNum ? "": ((ania % 2) > 0 ? "yearclass" : "yearclassB");
string antiguedad = "";
string classvac = "borderleft";
string vacacionestomadas = "";
if(hdrow != null)
{
antiguedad = string.Format("({0})", hdrow["Antiguedad"]);
//DiasVacaciones EJercicio EJercicioVac DiasPagados DiasDisfrutados
int DiasVacaciones = hdrow["DiasVacaciones"].ToString().ToEntero();
int DiasPagados = hdrow["DiasPagados"].ToString().ToEntero();
int DiasDisfrutados = hdrow["DiasDisfrutados"].ToString().ToEntero();
int mitadDiasVacaciones = DiasVacaciones / 2;
classvac = DiasDisfrutados > 0 ? (DiasDisfrutados > mitadDiasVacaciones ? (DiasDisfrutados >= DiasVacaciones ? "success" : "info") : "warning") : "danger";
vacacionestomadas = string.Format("{0}/{1}",DiasDisfrutados, DiasVacaciones);
}
if (dr["MinMes"].ToString() == "1" && Mesdia != mesidias)
{
if(mesa == Mes.ToEntero())
{
colspan = Dia.ToEntero() - 1;
}
string canio = drFechaNum >= FechaNum && colspan>5 ? (ania.ToString()) :"";
stringBuilder.AppendFormat("<td class='{2}' colspan='{0}'>{1} {3}</td>", colspan, canio, classtd, antiguedad);
strbuilderB.AppendFormat("<td class='{1}' colspan='{0}'>{2}</td>", colspan, classvac, vacacionestomadas);
}
if (mesidias == Mesdia)
{
string canio = drFechaNum >= FechaNum && colspan > 5 ? (ania.ToString()) : "";
if (mesa == Mes.ToEntero())
{
colspan = colspan-(Dia.ToEntero() - 1);
}
stringBuilder.AppendFormat("<td class='{2} borderyear' colspan='{0}'>{1} {3}</td>", colspan, canio, classtd, antiguedad);
strbuilderB.AppendFormat("<td class='{1}' colspan='{0}'>{2}</td>", colspan, classvac, vacacionestomadas);
}
}
stringBuilder.AppendFormat("{0}", strbuilderB.ToString());
return stringBuilder.ToString();
}
public string strColumnasVacaciones(DataTable tabladias, DataTable TDiaspersonal)
{
StringBuilder stringBuilder = new StringBuilder();
foreach (DataRow dr in tabladias.Rows)
{
DataRow hdr = TDiaspersonal.FiltroPrimero(string.Format("FechaNum={0}", dr["FechaNum"]));
if (hdr != null)
{
if (hdr["InicioM"].ToString() == "1")
{
stringBuilder.AppendFormat("<td class='VacClass{1}' colspan='{0}'></td>", hdr["DiasMesAnio"], (dr["MinMes"].ToString() == "1" ? " borderleft " : ""));
}
}
else
{
if (TDiaspersonal.FiltroPrimero(string.Format("Anio={0} AND Mes ={1}", dr["Anio"], dr["Mes"])) != null)
{
stringBuilder.AppendFormat("<td class='{0}'></td>", (dr["MinMes"].ToString() == "1" ? " borderleft " : ""));
}
else
{
if (dr["MinMes"].ToString() == "1")
{
stringBuilder.AppendFormat("<td class='borderleft' colspan='{0}'></td>", dr["DiasMes"]);
}
}
}
}
return stringBuilder.ToString();
}
public string columnapersonal(int dia, DataTable TDiaspersonal)
{
return string.Format("<td></td>");
}
protected void LnkConsultar_Click(object sender, EventArgs e) protected void LnkConsultar_Click(object sender, EventArgs e)
@@ -158,6 +312,9 @@ public class Registro
public DateTime FechaAntiguedad { get; set; } public DateTime FechaAntiguedad { get; set; }
public int Antiguedad { get; set; } public int Antiguedad { get; set; }
public List<EjercicioInfo> Ejercicios { get; set; } public List<EjercicioInfo> Ejercicios { get; set; }
//public DataTable TDiaspersonal { get; set; }
public string ColumnasinicioFin { get; set; }
public string ColumnasVacaciones { get; set; }
} }
public class EjercicioInfo public class EjercicioInfo