diff --git a/Nomina/Nomina.aspx b/Nomina/Nomina.aspx
index ca6d5a9d8..4365c23ed 100644
--- a/Nomina/Nomina.aspx
+++ b/Nomina/Nomina.aspx
@@ -304,8 +304,11 @@
Descargar archivos SUA
+
+ Recibos timbrados XML
+
- Recibos timbrados
+ Recibos timbrados PDF
Procesar archivo SUA EBA PDF
@@ -5293,6 +5296,8 @@
+
+
@@ -5367,6 +5372,20 @@
document.body.removeChild(elem);
}
}
+ function Savezip(filename, data) {
+ var blob = new Blob([data], { type: 'application/zip' });
+ if (window.navigator.msSaveOrOpenBlob) {
+ window.navigator.msSaveBlob(blob, filename);
+ }
+ else {
+ var elem = window.document.createElement('a');
+ elem.href = window.URL.createObjectURL(blob);
+ elem.download = filename;
+ document.body.appendChild(elem);
+ elem.click();
+ document.body.removeChild(elem);
+ }
+ }
function SaveCsv(filename, data) {
var blob = new Blob([data], { type: 'text/csv' });
if (window.navigator.msSaveOrOpenBlob) {
diff --git a/Nomina/Nomina.aspx.cs b/Nomina/Nomina.aspx.cs
index de7fe7e14..5d506e66a 100644
--- a/Nomina/Nomina.aspx.cs
+++ b/Nomina/Nomina.aspx.cs
@@ -14,6 +14,7 @@ using Modelos;
using System.Text.RegularExpressions;
using iTextSharp.text.pdf.parser;
using Profact.TimbraCFDI40;
+using Ionic.Zip;
public partial class Nomina_Nomina2 : ClsPaginas
{
@@ -555,6 +556,7 @@ public partial class Nomina_Nomina2 : ClsPaginas
}
private void CargaTiposPeriodo()
{
+ set_GlobalDTTipoPeriodos(UsuarioActual.CveEmpresa, null);
DdlTipoPeriodo.DataSource = get_GlobalDTTipoPeriodos(UsuarioActual.CveEmpresa);
DdlTipoPeriodoCM.DataSource = DdlTipoPeriodo.DataSource;
DdlTipoPeriodoSim.DataSource = DdlTipoPeriodo.DataSource;
@@ -627,6 +629,7 @@ public partial class Nomina_Nomina2 : ClsPaginas
FiltAgrupador = 1;
CveTipoTrabajador = DdlTipoTrabajador.SelectedValue.ToEntero();
HypPDFSTimbrados.Attributes.Add("onclick", string.Format("GETPDF({0},{1})", -1, FiltCvePeriodo));
+ HypXMLSTimbrados.Attributes.Add("onclick", string.Format("GETXML({0},{1})", -1, FiltCvePeriodo));
cargaDatos();
int empleados = 0;
if (dtempleados != null && dtempleados.Rows.Count > 0)
@@ -694,6 +697,7 @@ public partial class Nomina_Nomina2 : ClsPaginas
LnkPersonalizarNomina.Visible = true;
LnkFormatoFiscal.Visible = (UsuarioActual.CveEmpresa == 141 || UsuarioActual.CveRol == 1);
HypPDFSTimbrados.Visible = true;
+ HypXMLSTimbrados.Visible = true;
if (objnom.GetNominaEmpleado(FiltCveProyecto, FiltCveSubProyecto, FiltCveTurno, FiltCvePeriodo, CveEmpresa, FiltAgrupador,
DdlRegimenContratacion.SelectedValue.ToEntero(), CveTipoTrabajador: CveTipoTrabajador, Neto: ddlfiniquito.SelectedValue.ToEntero(),
CvePersonal: CvePersonal)
@@ -9544,66 +9548,138 @@ public partial class Nomina_Nomina2 : ClsPaginas
string Xmlname = "";
string XmlnameF = "";
string empleado = "";
- DataRow dr = dtempleados.FiltroPrimero(string.Format("CvePersonal ={0}", TxtCvePersonal.Text.ToEntero()));
- if (dr != null)
- {
- empleado = string.Format("{0} - {1}", dr["Codigo"], dr["Nombre"]);
- }
- using (ClsNominas ObjNomina = new ClsNominas())
- {
- if (ObjNomina.GetNom_Nominas(-1, TxtCvePersonal.Text.ToEntero(), TxtCvePeriodo.Text.ToEntero(), -1, UsuarioActual.CveEmpresa))
- {
- Ruta = UsuarioActual.Empresa.Ruta;
- PathXML = $"{Ruta}XML\\Nomina\\{ObjNomina.SerieFolio}.xml";
- PathXMLF = $"{Ruta}XML\\Nomina\\{ObjNomina.Serie}F-{ObjNomina.Folio}.xml";
- Xmlname = ObjNomina.SerieFolio;
- XmlnameF = $"{ObjNomina.Serie}F-{ObjNomina.Folio}";
- }
- }
- try
- {
- string script = "";
- if (!string.IsNullOrEmpty(PathXML) && System.IO.File.Exists(PathXML))
- {
- LtlXml.Text = System.IO.File.ReadAllText(PathXML);
- script = string.Format("Savexml(\"{0} {1}.xml\", $('.ltlxml').html());", Xmlname, empleado);
- //System.IO.FileInfo file = new System.IO.FileInfo(PathXML);
- //string mimeType = "text/plain";
- //try
- //{
- // mimeType = MimeMapping.GetMimeMapping(PathXML);
- //}
- //catch (Exception)
- //{
- //}
- //// Response.Write(path)
- //Response.Clear();
- //Response.ClearHeaders();
- //Response.ClearContent();
- //Response.AddHeader("Content-Disposition", $"attachment; filename= {Uri.EscapeDataString(file.Name)}");
- //Response.AddHeader("Content-Length", file.Length.ToString());
- //Response.ContentType = mimeType;
- //Response.Flush();
- //Response.TransmitFile(file.FullName);
- //Response.End();
- }
- if (!string.IsNullOrEmpty(PathXML) && System.IO.File.Exists(PathXMLF))
+ Ruta = UsuarioActual.Empresa.Ruta;
+ if (TxtCvePersonal.Text.ToEntero() != -1)
+ {
+ DataRow dr = dtempleados.FiltroPrimero(string.Format("CvePersonal ={0}", TxtCvePersonal.Text.ToEntero()));
+ if (dr != null)
{
- LtlXmlfin.Text = System.IO.File.ReadAllText(PathXMLF);
- script = string.Format("{1}Savexml(\"{0}(Indemnización) {2}.xml\", $('.ltlxmlfin').html());", Xmlname, script, empleado);
+ empleado = string.Format("{0} - {1}", dr["Codigo"], dr["Nombre"]);
}
- if (script.Trim().Length > 0)
+ using (ClsNominas ObjNomina = new ClsNominas())
{
- RegistraScript(script);
+ if (ObjNomina.GetNom_Nominas(-1, TxtCvePersonal.Text.ToEntero(), TxtCvePeriodo.Text.ToEntero(), -1, UsuarioActual.CveEmpresa))
+ {
+ PathXML = $"{Ruta}XML\\Nomina\\{ObjNomina.SerieFolio}.xml";
+ PathXMLF = $"{Ruta}XML\\Nomina\\{ObjNomina.Serie}F-{ObjNomina.Folio}.xml";
+ Xmlname = ObjNomina.SerieFolio;
+ XmlnameF = $"{ObjNomina.Serie}F-{ObjNomina.Folio}";
+ }
}
- else
+ try
+ {
+ string script = "";
+ if (!string.IsNullOrEmpty(PathXML) && System.IO.File.Exists(PathXML))
+ {
+ LtlXml.Text = System.IO.File.ReadAllText(PathXML);
+ script = string.Format("Savexml(\"{0} {1}.xml\", $('.ltlxml').html());", Xmlname, empleado);
+ //System.IO.FileInfo file = new System.IO.FileInfo(PathXML);
+ //string mimeType = "text/plain";
+ //try
+ //{
+ // mimeType = MimeMapping.GetMimeMapping(PathXML);
+ //}
+ //catch (Exception)
+ //{
+
+ //}
+ //// Response.Write(path)
+ //Response.Clear();
+ //Response.ClearHeaders();
+ //Response.ClearContent();
+ //Response.AddHeader("Content-Disposition", $"attachment; filename= {Uri.EscapeDataString(file.Name)}");
+ //Response.AddHeader("Content-Length", file.Length.ToString());
+ //Response.ContentType = mimeType;
+ //Response.Flush();
+ //Response.TransmitFile(file.FullName);
+ //Response.End();
+ }
+ if (!string.IsNullOrEmpty(PathXMLF) && System.IO.File.Exists(PathXMLF))
+ {
+ LtlXmlfin.Text = System.IO.File.ReadAllText(PathXMLF);
+ script = string.Format("{1}Savexml(\"{0}(Indemnización) {2}.xml\", $('.ltlxmlfin').html());", Xmlname, script, empleado);
+ }
+ if (script.Trim().Length > 0)
+ {
+ RegistraScript(script);
+ }
+ else
+ {
+ Alert("No se encontro el archivo");
+ }
+ }
+ catch (Exception)
{
- Alert("No se encontro el archivo");
}
}
- catch (Exception)
+ else
{
+ using (ClsNominas ObjNomina = new ClsNominas())
+ {
+ if (ObjNomina.GetNom_Nominas(-1, -1, TxtCvePeriodo.Text.ToEntero(), -1, UsuarioActual.CveEmpresa))
+ {
+ string script = "";
+ using (ZipFile descargaZIP = new ZipFile())
+ {
+ descargaZIP.UseZip64WhenSaving = Zip64Option.AsNecessary;
+
+ foreach (DataRow dbrow in ObjNomina.DtResultados.Rows)
+ {
+ Ruta = UsuarioActual.Empresa.Ruta;
+ PathXML = $"{Ruta}XML\\Nomina\\{dbrow["SerieFolio"].ToString()}.xml";
+ PathXMLF = $"{Ruta}XML\\Nomina\\{dbrow["Serie"].ToString()}F-{dbrow["Folio"].ToString()}.xml";
+
+ if (!string.IsNullOrEmpty(PathXML) && System.IO.File.Exists(PathXML))
+ {
+
+ FileInfo file = new FileInfo(PathXML);
+ if (!descargaZIP.Any(x => x.FileName.Contains(file.Name)))
+ {
+ descargaZIP.AddFile(PathXML);
+ }
+
+ }
+ if (!string.IsNullOrEmpty(PathXMLF) && System.IO.File.Exists(PathXMLF))
+ {
+
+ FileInfo file = new FileInfo(PathXMLF);
+ if (!descargaZIP.Any(x => x.FileName.Contains(file.Name)))
+ {
+ descargaZIP.AddFile(PathXMLF);
+ }
+
+ }
+
+ }
+
+ String PathZIP = $"{Ruta}XML\\Nomina\\{TxtCvePeriodo.Text.ToEntero()}.zip";
+ descargaZIP.Save(PathZIP);
+ if (!string.IsNullOrEmpty(PathZIP) && System.IO.File.Exists(PathZIP))
+ {
+ LtlZip.Text = System.IO.File.ReadAllText(PathZIP);
+ script = string.Format("Savezip(\"{0}.zip\", $('.ltlzip').html());", DdlPeriodo.SelectedItem.Text);
+ System.IO.File.Delete(PathZIP);
+ }
+
+ if (script.Trim().Length > 0)
+ {
+ RegistraScript(script);
+ }
+ else
+ {
+ Alert("No se encontro el archivo");
+ }
+
+ //Response.Clear();
+ //Response.AddHeader("Content-Disposition", "attachment; filename=ArchivosXML.zip");
+ //Response.ContentType = "application/zip";
+ //descargaZIP.Save(Response.OutputStream);
+ //Response.End();
+ }
+
+ }
+ }
}
}
@@ -10704,7 +10780,7 @@ public partial class Nomina_Nomina2 : ClsPaginas
StringBuilder SbErrores = new StringBuilder();
bool ErroresValidaciones = false;
int modalidadnomina = 1;
- if (UsuarioActual.CveEmpresa.Contiene(189, 193, 195, 196, 197, 172, 173, 174)) modalidadnomina = 2;
+ if (UsuarioActual.CveEmpresa.Contiene(189, 193, 195, 196, 197, 172, 173,174)) modalidadnomina = 2;
SbErrores.AppendLine("Se detectaron los siguientes errores en la generación del layout:
");