<%@language=vbscript%>
<%
Response.Buffer=True
If Session("ID")=0 then
Response.Redirect("http://www.grupo-mim.com")
Response.End
Else
%>
<!--#include file="fpdf.asp"-->
<%
Dim Cn1, Cn2
Dim Rs11, Sql11, Rs12, Sql12, Rs13, Cmd13
Dim Rs21, Sql21, Rs22, Sql22
Dim FInicial, FFinal, Empresa
Dim ClaveC, NombreC, digital, digitalb
Dim FolioFiscal, Nodocumento
Dim Fecha
Fecha = Now()
Fecha = FormatDateTime(Fecha)
Fcorte = Request("Fcorte")
Empresa = Request("Empresa")
Set Cn1 = Server.CreateObject( "ADODB.Connection" )
Cn1.Open "DRIVER={SQL Server};SERVER=172.17.0.5;UID=ADMIMSIS;PWD=ST2108GP;Database=" & Empresa &""
'Set Cn2 = Server.CreateObject( "ADODB.Connection" )
'Cn2.Open "DRIVER={SQL Server};SERVER=172.17.0.5;UID=sa;PWD=LABL2014;Database=PASOMEXICO"
'Set Rs21 = server.CreateObject("ADODB.Recordset")
'Sql21 = "Select NoDocumento, FOLIOFISCAL " &_
' "From CFDENC WHERE TIPODOCUMENTO = '01' and fechaemision > (getdate() - 2) And Empresa = '0000000001' and FOLIOFISCAL IS NOT NULL ;"
'Rs21.Open Sql21,cn2,1,2
' Set Rs22 = server.CreateObject("ADODB.Recordset")
' Do While Not Rs21.Eof
' Digital = Rs21("FolioFiscal")
' Nodocumento = Rs21("NoDocumento")
' Set Rs22 = server.CreateObject("ADODB.Recordset")
'Sql22 = "Update Cxcgen " &_
' "Set CFD = '"& Digital &"' " &_
' "Where RIGHT('0000000000' + LTRIM(NFACXCG), 10) = '"& Nodocumento &"';"
'Cn1.Execute Sql22
'
' Rs21.Movenext
' Loop
Set Rs11 = server.CreateObject("ADODB.Recordset")
Sql11 = "Select Nombre, Direccion, Colonia, Poblacion, Website " &_
"From Empresa;"
Rs11.Open Sql11,Cn1,1,2
Nombre = Rs11("Nombre")
Direccion = Rs11("Direccion")
Colonia = Rs11("Colonia")
Poblacion = Rs11("Poblacion")
Website = Rs11("Website")
Set Rs12 = server.CreateObject("ADODB.Recordset")
Sql12 = "Select Clicxcg, Nomcli " &_
"From Cxcgen, Clientes " &_
"where Clicxcg = Clacli and fpacxcg <= '"& Fcorte &"' and (salcxcg < -0.9 or salcxcg > 0.9) " &_
"group by clicxcg, Nomcli " &_
"order by Nomcli;"
Rs12.Open Sql12,Cn1,1,2
Set pdf=CreateJsObject("FPDF")
pdf.CreatePDF "P", "mm", "Letter"
pdf.SetPath("fpdf/")
pdf.SetFillColor 13,16,121
pdf.Open()
pdf.LoadModels("CXCd")
Pdf.SetLeftMargin(8.0)
pdf.AddPage()
pdf.SetFont "Arial","",8
Pdf.Setautopagebreak true,15
Do while Not Rs12.Eof
ClaveC = Rs12("Clicxcg")
NombreC = Rs12("Nomcli")
pdf.Cell 20,4,ClaveC,0,0,"L",0
pdf.Cell 120,4,NombreC,0,0,"L",0
pdf.ln(4)
'****** PROCEDIMIENTO ALMACENADO DE PARTIDAS DEL DETALLE ****
Set Cmd13 = server.CreateObject("ADODB.Command")
Set Cmd13.ActiveConnection = Cn1
Cmd13.CommandText = "Select clicxcg, nomcli, movcxcg, nfacxcg, frecxcg, fpacxcg, impcxcg, descxcg, pagcxcg, tcacxcg, descxcc, " &_
"salcxcg, imtcxcg, diacli, desdiv, CFD " &_
"From clientes, Cxcgen, Monedas, cxccon " &_
"Where clacli = clicxcg and movcxcg = numcxcc and Fpacxcg <= '"& Fcorte &"' and clicxcg = '"& ClaveC &"' " &_
"and (salcxcg < -0.9 or salcxcg > 0.9) and cladiv = moncxcg " &_
"Group by clicxcg, nomcli, movcxcg, nfacxcg, frecxcg, fpacxcg, salcxcg, impcxcg, descxcg, pagcxcg, imtcxcg, diacli, desdiv, cfd, tcacxcg, descxcc " &_
"Order by nfacxcg;"
Set Rs13 = server.CreateObject("ADODB.Recordset")
Set Rs13 = Cmd13.Execute()
SumaP = 0
SumaD = 0
SumaT = 0
Do While Not Rs13.Eof
digital = Cstr(Rs13("NFACXCG"))
Digitalb = right("0000000000" + Digital, 10 )
FolioFiscal = Rs13("CFD")
FacturaG = Rs13("nfacxcg")
Fpago = Rs13("fpacxcg")
DiasV = date() - Fpago
ImporteG = Rs13("impcxcg")
SaldoG = Rs13("Salcxcg")
MonedaD= Rs13("desdiv")
Tcambio= Rs13("Tcacxcg")
ImporteMx = (Cdbl(SaldoG) * Cdbl(Tcambio))
TipoD = rs13("Descxcc")
If FolioFiscal = "" or Isnull(FolioFiscal) Then
FolioFiscal = 0
Else
FolioFiscal = FolioFiscal
End If
If MonedaD = "PESOS" Then
PesosG = Cdbl(SaldoG)
DolaresG = 0
SumaP = SumaP + Cdbl(SaldoG)
SumaD = SumaD
SumaT = SumaT + Cdbl(ImporteMx)
Else If MonedaD = "DOLARES" Then
DolaresG = Cdbl(SaldoG)
PesosG = 0
SumaP = SumaP
SumaD = SumaD + Cdbl(SaldoG)
SumaT = SumaT + Cdbl(ImporteMx)
End If
End If
pdf.Cell 25,4,TipoD,0,0,"L",0
pdf.Cell 15,4,FacturaG,0,0,"L",0
pdf.Cell 15,4,Cstr(Fpago),0,0,"L",0
pdf.Cell 15,4,Cstr(DiasV),0,0,"R",0
pdf.Cell 25,4,Formatnumber(ImporteG),0,0,"R",0
pdf.Cell 15,4,MonedaD,0,0,"L",0
pdf.Cell 25,4,FormatNumber(PesosG),0,0,"R",0
pdf.Cell 25,4,FormatNumber(DolaresG),0,0,"R",0
pdf.Cell 25,4,FormatNumber(ImporteMx),0,0,"R",0
pdf.ln(4)
Rs13.Movenext
Loop
pdf.Cell 110,4,"TOTALES:",0,0,"R",0
pdf.Cell 25,4,FormatNumber(SumaP),0,0,"R",0
pdf.Cell 25,4,FormatNumber(sumaD),0,0,"R",0
pdf.Cell 25,4,FormatNumber(sumaT),0,0,"R",0
pdf.ln(4)
pdf.ln(4)
PesosT = Cdbl(PesosT) + Cdbl(SumaP)
DolaresT = Cdbl(DolaresT) + Cdbl(SumaD)
MXT = Cdbl(MXT) + Cdbl(SumaT)
Rs12.Movenext
Loop
pdf.Cell 110,4,"TOTALES:",0,0,"R",0
pdf.Cell 25,4,FormatNumber(PesosT),0,0,"R",0
pdf.Cell 25,4,FormatNumber(DolaresT),0,0,"R",0
pdf.Cell 25,4,FormatNumber(Mxt),0,0,"R",0
pdf.ln(4)
pdf.ln(4)
pdf.Output()
End If
%>