<%@language=vbscript%>
<%
'***** SI NO HA INICIADO SESION ***
If Session("Mybussiness") = "" then
Response.redirect("default.asp")
Else
%>
<%Session.LCID=2058%>
<!--#include file="fpdf.asp"-->
<%
Dim Empresa, NumeroNota
Dim Cn1
Dim Rs1, Rs2
Dim Sql1, Sql2
Dim Rs11, Rs12, Rs13, Rs14
Dim Sql11, Sql12, Sql13, Sql14
Empresa = Session("Mybussiness")
NumeroNota = Request("numnot")
Set Cn1 = Server.CreateObject( "ADODB.Connection" )
Cn1.Open "DRIVER={SQL Server};SERVER=172.17.0.5;UID=ADMIMSIS;PWD=ST2108GP;Database=" & Session("Mybussiness") &""
Set Rs1 = Server.CreateObject("ADODB.Recordset")
Sql1 = "SELECT * FROM EMPRESA"
Rs1.Open Sql1,Cn1,1,2
Nombre = Rs1("Nombre")
Direccion = Rs1("Direccion")
Colonia = Rs1("Colonia")
Poblacion = Rs1("Poblacion")
Telefono = Rs1("Telefono")
Fax = Rs1("Fax")
Contacto4 = Rs1("CONTACTO4")
Contacto5 = Rs1("CONTACTO5")
Set Rs2 = Server.CreateObject("ADODB.Recordset")
Sql2 = "select Fecsae, nomprv, Dirprv, Colprv, Pobprv, EdoPrv, ATESAE, notsae, consae, labsae " &_
"from proveedores, csalenc " &_
"where numsae = "& NumeroNota &" and cveprv = prosae;"
Rs2.Open Sql2,Cn1,1,2
Fecha = Cstr(Rs2("Fecsae"))
Proveedor = Rs2("nomprv")
Dire = Rs2("Dirprv")
Col = Rs2("Colprv")
Pob = Rs2("Pobprv")
Edo = Rs2("EdoPrv")
Atencion = Rs2("ATESAE")
Nota = Rs2("notsae")
Condiciones = Rs2("consae")
Entrega = Rs2("labsae")
If E1 = "Toluca" or E1 = "Guadalajara" then
Co1 = 251
Co2 = 85
Co3 = 20
Else if E1 = "Bajio" THEN
Co1 = 215
Co2 = 1
Co3 = 21
else
Co1 = 1
Co2 = 33
Co3 = 254
End If
End If
Data1 = "ORIG-CERT"
Data2 = "UBICACION"
Data3 = "PESO"
Set pdf=CreateJsObject("FPDF")
pdf.CreatePDF "L", "mm", "Letter"
pdf.SetPath("fpdf/")
pdf.SetFont "Arial","",7
'pdf.SetFillColor 197,229,213
pdf.SetFillColor 225,225,225
pdf.Open()
pdf.LoadModels("Notasal")
pdf.AddPage()
pdf.Ln(4)
pdf.SetFont "Arial","B",10
pdf.Cell 262,4,"S A L I D A",0,0,"C",1
pdf.Ln(5)
Set Rs3 = Server.CreateObject("ADODB.Recordset")
Sql3 = "select secsad, sum(cansad) as cantidad, codsad, udmiNV, nominv, orisad, cersad, pedsad, ppisad, fensad, sum(cansad * Pesoinv) as Peso, Ctlmul " &_
"from csaldet, inventarios, Multialmacen " &_
"where numsad = "& NumeroNota &" and cveinv = codsad and tmosad > 49 and Artmul = codsad and almmul = almsad " &_
"group by secsad, codsad, udmiNV, nominv, orisad, cersad, pedsad, ppisad, fensad, Ctlmul " &_
"order by secsad asc;"
Rs3.Open Sql3,Cn1,1,2
Do while Not Rs3.EOF
Secuencia = cstr(Rs3("SECsad"))
Cantidad = cstr(Rs3("cantidad"))
Codigo = Rs3("codsad")
UDM = Rs3("UDMINV")
Descripcion = Rs3("nominv")
Origen = Rs3("orisad")
Certificado = Rs3("cersad")
Pedido = Cstr(Rs3("pedsad"))
Partida = Cstr(Rs3("ppisad"))
Entrega = Cstr(Rs3("FENSAD"))
Ubicacion = Rs3("Ctlmul")
Peso = Cstr(Rs3("Peso"))
If Isnull(Ubicacion) Then
Ubicacion = ""
Else
Ubicacion = Ubicacion
End If
If Origen = 1 then
ori = "X"
Else
ori = " "
End If
If Certificado = 1 then
cert = "X"
Else
cert = " "
End If
pdf.SetFont "Arial","",7
pdf.Cell 5,4,Secuencia,0,0,"C",0
pdf.Cell 10,4,Cantidad,0,0,"C",0
pdf.Cell 25,4,Codigo,0,0,"L",0
pdf.Cell 8,4,UDM,0,0,"L",0
pdf.Cell 112,4,Descripcion,0,0,"L",0
pdf.Cell 20,4,Pedido & " - " & Partida ,0,0,"C",0
pdf.Cell 20,4,Entrega,0,0,"R",0
pdf.Cell 21,4,Ori & " - " & cert,0,0,"C",0
pdf.Cell 25,4,Ubicacion,0,0,"R",0
pdf.Cell 15,4,Peso,0,0,"R",0
pdf.Ln(4)
Rs3.Movenext
loop
pdf.Ln(60)
pdf.SetFont "Arial","B",10
pdf.Cell 262,4,"E N T R A D A",0,0,"C",1
pdf.Ln(5)
Set Rs4 = Server.CreateObject("ADODB.Recordset")
Sql4 = "select secsad, sum(cansad) as cantidad, codsad, udmiNV, nominv, orisad, cersad, pedsad, ppisad, fensad, sum(cansad * Pesoinv) as Peso, Ctlmul " &_
"from csaldet, inventarios, Multialmacen " &_
"where numsad = "& NumeroNota &" and cveinv = codsad and tmosad < 49 and Artmul = codsad and almmul = almsad " &_
"group by secsad, codsad, udmiNV, nominv, orisad, cersad, pedsad, ppisad, fensad, Ctlmul " &_
"order by secsad asc;"
Rs4.Open Sql4,Cn1,1,2
Do while Not Rs4.EOF
Secuencia = cstr(Rs4("secsad"))
Cantidad = cstr(Rs4("cantidad"))
Codigo = Rs4("codsad")
UDM = Rs4("UDMINV")
Descripcion = Rs4("nominv")
Origen = Rs4("orisad")
Certificado = Rs4("cersad")
Pedido = Cstr(Rs4("pedsad"))
Partida = Cstr(Rs4("ppisad"))
Entrega = Cstr(Rs4("FENSAD"))
Ubicacion = Rs4("Ctlmul")
Peso = Cstr(Rs4("Peso"))
If Isnull(Ubicacion) Then
Ubicacion = ""
Else
Ubicacion = Ubicacion
End If
If Origen = 1 then
ori = "X"
Else
ori = " "
End If
If Certificado = 1 then
cert = "X"
Else
cert = " "
End If
pdf.SetFont "Arial","",7
pdf.Cell 5,4,Secuencia,0,0,"C",0
pdf.Cell 10,4,Cantidad,0,0,"C",0
pdf.Cell 25,4,Codigo,0,0,"L",0
pdf.Cell 8,4,UDM,0,0,"L",0
pdf.Cell 112,4,Descripcion,0,0,"L",0
pdf.Cell 20,4,Pedido & " - " & Partida ,0,0,"C",0
pdf.Cell 20,4,Entrega,0,0,"R",0
pdf.Cell 21,4,Ori & " - " & cert,0,0,"C",0
pdf.Cell 25,4,Ubicacion,0,0,"R",0
pdf.Cell 15,4,Peso,0,0,"R",0
pdf.Ln(4)
Rs4.Movenext
loop
'****** HOJA DE COSTOS *****
Data1 = "ORIG-CERT"
Data2 = "COSTO"
Data3 = "IMPORTE"
pdf.AddPage ()
pdf.Ln(4)
pdf.SetFont "Arial","B",10
pdf.Cell 262,4,"S A L I D A",0,0,"C",1
pdf.Ln(5)
Set Rs5 = server.CreateObject("ADODB.Recordset")
Sql5="select secsad, sum(cansad) as cantidad, codsad, udmiNV, nominv, orisad, cersad, pedsad, ppisad, fensad, PROSAD, sum(Cansad * Prosad) as Importe " &_
"from csaldet,inventarios " &_
"where numsad = "& NumeroNota &" and cveinv = codsad and tmosad > 49 " &_
"group by secsad, codsad, udmiNV, nominv, orisad, cersad, pedsad, ppisad, fensad, PROSAD " &_
"order by secsad asc;"
Rs5.Open Sql5,Cn1,1,2
Subtotal = 0
Do while Not Rs5.EOF
Secuencia = cstr(Rs5("secsad"))
Cantidad = cstr(Rs5("cantidad"))
Codigo = Rs5("codsad")
UDM = Rs5("UDMINV")
Descripcion = Rs5("nominv")
Origen = Rs5("orisad")
Certificado = Rs5("cersad")
Pedido = Cstr(Rs5("pedsad"))
Partida = Cstr(Rs5("ppisad"))
Entrega = Cstr(Rs5("FENSAD"))
Promedio = Cstr(Rs5("Prosad"))
Importe = Cstr(Rs5("Importe"))
If Origen = 1 then
ori = "X"
Else
ori = " "
End If
If Certificado = 1 then
cert = "X"
Else
cert = " "
End If
pdf.SetFont "Arial","",7
pdf.Cell 5,4,Secuencia,0,0,"C",0
pdf.Cell 10,4,Cantidad,0,0,"C",0
pdf.Cell 25,4,Codigo,0,0,"L",0
pdf.Cell 8,4,UDM,0,0,"L",0
pdf.Cell 112,4,Descripcion,0,0,"L",0
pdf.Cell 20,4,Pedido & " - " & Partida ,0,0,"C",0
pdf.Cell 20,4,Entrega,0,0,"R",0
pdf.Cell 21,4,Ori & " - " & cert,0,0,"C",0
pdf.Cell 25,4,Formatnumber(Promedio),0,0,"R",0
pdf.Cell 15,4,Formatnumber(Importe),0,0,"R",0
pdf.Ln(4)
Subtotal = Subtotal + Importe
Rs5.Movenext
Loop
pdf.Ln(4)
pdf.SetFont "Arial","",7
pdf.Cell 221,4,"",0,0,"C",0
pdf.Cell 25,4,"Subtotal:",0,0,"R",0
pdf.Cell 15,4,Formatnumber(Subtotal),0,0,"R",0
pdf.Ln(60)
pdf.SetFont "Arial","B",10
pdf.Cell 262,4,"E N T R A D A",0,0,"C",1
pdf.Ln(5)
Set Rs6 = server.CreateObject("ADODB.Recordset")
Sql6="select secsad, sum(cansad) as cantidad, codsad, udmiNV, nominv, orisad, cersad, pedsad, ppisad, fensad, PROSAD, sum(Cansad * Prosad) as Importe " &_
"from csaldet,inventarios " &_
"where numsad = "& NumeroNota &" and cveinv = codsad and tmosad < 49 " &_
"group by secsad, codsad, udmiNV, nominv, orisad, cersad, pedsad, ppisad, fensad, PROSAD " &_
"order by secsad asc;"
Rs6.Open Sql6,Cn1,1,2
Subtotal = 0
Do while Not Rs6.EOF
Secuencia = cstr(Rs6("secsad"))
Cantidad = cstr(Rs6("cantidad"))
Codigo = Rs6("codsad")
UDM = Rs6("UDMINV")
Descripcion = Rs6("nominv")
Origen = Rs6("orisad")
Certificado = Rs6("cersad")
Pedido = Cstr(Rs6("pedsad"))
Partida = Cstr(Rs6("ppisad"))
Entrega = Cstr(Rs6("FENSAD"))
Promedio = Cstr(Rs6("Prosad"))
Importe = Cstr(Rs6("Importe"))
If Origen = 1 then
ori = "X"
Else
ori = " "
End If
If Certificado = 1 then
cert = "X"
Else
cert = " "
End If
pdf.SetFont "Arial","",7
pdf.Cell 5,4,Secuencia,0,0,"C",0
pdf.Cell 10,4,Cantidad,0,0,"C",0
pdf.Cell 25,4,Codigo,0,0,"L",0
pdf.Cell 8,4,UDM,0,0,"L",0
pdf.Cell 112,4,Descripcion,0,0,"L",0
pdf.Cell 20,4,Pedido & " - " & Partida ,0,0,"C",0
pdf.Cell 20,4,Entrega,0,0,"R",0
pdf.Cell 21,4,Ori & " - " & cert,0,0,"C",0
pdf.Cell 25,4,Formatnumber(Promedio),0,0,"R",0
pdf.Cell 15,4,Formatnumber(Importe),0,0,"R",0
pdf.Ln(4)
Subtotal = Subtotal + Importe
Rs6.Movenext
Loop
pdf.Ln(4)
pdf.SetFont "Arial","",7
pdf.Cell 221,4,"",0,0,"C",0
pdf.Cell 25,4,"Subtotal:",0,0,"R",0
pdf.Cell 15,4,Formatnumber(Subtotal),0,0,"R",0
pdf.output()
End If
%>