<%@language=vbscript%>
<%
Response.Buffer=True
If Session("ID")=0 then
Response.Redirect("http://www.grupo-mim.com")
Response.End
Else
%>
<%Session.LCID=2058%>
<!--#include file="fpdf.asp"-->
<%
Dim Cn1
Dim Rs11, Rs12, Rs13, Rs14
Dim Sql11, Sql12, Sql13, Sql14
Dim FolioR, Empresa
Dim OperadoRr, OperadorN, RutaR, Fecha, Celular, Placas
Dim Partida
FolioR = Request("FolioR")
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 &""
'********* RECORDSET PARA LA TABLA EMPRESA *********'
Set Rs11 = server.CreateObject("ADODB.Recordset")
Sql11="Select Nombre, Direccion, Colonia, Poblacion, Telefono, Fax, Website " &_
"From Empresa;"
Rs11.Open Sql11,Cn1,1,2
'********** VARIABLE PARA EL ENCABEZADO DEL DOCUMENTO *******'
NombreE = Rs11("Nombre")
DireccionE = Rs11("Direccion")
ColoniaE = Rs11("Colonia")
PoblacionE = Rs11("Poblacion")
TelefonoE = Rs11("Telefono")
FaxE = Rs11("Fax")
WebsiteE = Rs11("website")
'********* RECORDSET PARA LA TABLA DEL ENCABEZADO DE LA RUTA *********'
Set Rs12 = server.CreateObject("ADODB.Recordset")
Sql12="Select Operenc, NOMOPER, Rutrenc, fecrenc, Celoper, Plaoper " &_
"From rutaenc, RUTAOPER " &_
"Where Numrenc = "& FolioR &" and Operenc = IDOPER;"
Rs12.Open Sql12,Cn1,1,2
'********* RECORDSET PARA LA TABLA DEL ENCABEZADO DE LA RUTA *********'
Set Rs13 = server.CreateObject("ADODB.Recordset")
Sql13="Select docrdet, Numrdet, Tiprdet, Insrdet, cerrdet, Facrdet, Obsrdet " &_
"From Rutadet " &_
"where numrdet = "& FolioR &" Order By Idrdet;"
Rs13.Open Sql13,Cn1,1,2
OperadorR = Rs12("Operenc")
OperadorN = Rs12("Nomoper")
RutaR = Rs12("Rutrenc")
Fecha = Rs12("Fecrenc")
Fecha = Cstr(Fecha)
Celular = Rs12("Celoper")
Placas = Rs12("Plaoper")
Set pdf=CreateJsObject("FPDF")
pdf.CreatePDF "L", "mm", "Letter"
pdf.SetPath("fpdf/")
pdf.SetFont "Arial","",8
pdf.SetFillColor 216,216,216
pdf.setAutoPagebreak true, 17
pdf.Open()
pdf.LoadModels("Ruta")
pdf.AddPage()
pdf.SetFont "Arial","",8
pdf.Ln(4)
Partida = 0
Do While Not Rs13.Eof
Partida = Partida + 1
Partida = Cstr(Partida)
Documento = Rs13("docrdet")
Inspeccion = Rs13("Insrdet")
Certificado = Rs13("cerrdet")
Factura = Rs13("facrdet")
Notas = Rs13("Obsrdet")
TipoD = Rs13("Tiprdet")
If TipoD = 1 Then
TipoD = "REMISION"
Set Rs14 = server.CreateObject("ADODB.Recordset")
Sql14="Select FECFREME, NOMCLI, CERFREME, FACFREME, PECFREME, TipoProd, Kilos " &_
"FROM FREMENC, CLIENTES, Remkilos " &_
"WHERE NUMFREME = "& Documento &" AND CLIFREME = CLACLI and Numfreme = REMISION;"
Rs14.Open Sql14,Cn1,1,2
If Rs14.EOF Then
FechaR = ""
ClienteN = ""
CERTI = "NO"
FACTU = "NO"
PEDI = "NO"
Kilos = 0
TipoProd = 0
Else
FechaR = Rs14("FECFREME")
FechaR = Formatdatetime(FechaR,2)
ClienteN = Rs14("Nomcli")
Kilos = Rs14("Kilos")
CERTI = Rs14("cerfreme")
FACTU = Rs14("Facfreme")
PEDI = Rs14("Pecfreme")
TipoProd = Rs14("TipoProd")
If TipoProd = 0 Then
TipoProd = "TUBERIA"
Else
TipoProd = "CONEXIONES"
eND iF
If Certi = 0 Then
Certi = "NO"
Else
Certi = "SI"
End If
If Factu = 0 Then
Factu = "NO"
Else
Factu = "SI"
End If
If pedi = 0 Then
Pedi = "NO"
Else
Pedi = "SI"
End If
End If
Else If TipoD = 2 Then
TipoD = "O. COMPRA"
Set Rs14 = server.CreateObject("ADODB.Recordset")
Sql14="Select FECORE, NOMPRV " &_
"FROM CORDENC, PROVEEDORES " &_
"WHERE NUMORE = "& Documento &" AND PROORE = CVEPRV ;"
Rs14.Open Sql14,Cn1,1,2
If Rs14.EOF Then
FechaR = ""
ClienteN = ""
CERTI = "NO"
FACTU = "NO"
PEDI = "NO"
Else
FechaR = Rs14("FECORE")
FechaR = Formatdatetime(FechaR,2)
ClienteN = Rs14("NOMPRV")
CERTI = "NO"
FACTU = "NO"
PEDI = "NO"
End If
Else If TipoD = 3 Then
TipoD = "DEV."
Set Rs14 = server.CreateObject("ADODB.Recordset")
Sql14="Select FECRENCD, NOMPRV " &_
"FROM CRecEncd, PROVEEDORES " &_
"WHERE NUMRENCD = "& Documento &" AND PRORENCD = CVEPRV;"
Rs14.Open Sql14,Cn1,1,2
If Rs14.EOF Then
FechaR = ""
ClienteN = ""
Else
FechaR = Rs14("FECRENCD")
FechaR = Formatdatetime(FechaR,2)
ClienteN = Rs14("NOMPRV")
End If
CERTI = "NO"
FACTU = "NO"
PEDI = "NO"
Else If TipoD = 4 Then
TipoD = "NOTA SAL."
Set Rs14 = server.CreateObject("ADODB.Recordset")
Sql14="Select FECSAE, NOMPRV " &_
"FROM CSALENC, PROVEEDORES " &_
"WHERE NUMSAE = "& Documento &" AND PROSAE = CVEPRV;"
Rs14.Open Sql14,Cn1,1,2
If Rs14.EOF Then
FechaR = ""
ClienteN = ""
Else
FechaR = Rs14("FECSAE")
FechaR = Formatdatetime(FechaR,2)
ClienteN = Rs14("NOMPRV")
End If
CERTI = "NO"
FACTU = "NO"
PEDI = "NO"
End If
End If
End If
End If
pdf.Cell 10,4,Partida & " ",0,0,"R",0
pdf.Cell 20,4,FechaR,0,0,"L",0
pdf.Cell 20,4,TipoD & " ",0,0,"L",0
pdf.Cell 10,4,Documento & " ",0,0,"R",0
pdf.Cell 110,4,ClienteN,0,0,"L",0
pdf.Cell 10,4,Cstr(CERTI),0,0,"C",0
pdf.Cell 10,4,Cstr(FACTU),0,0,"C",0
pdf.Cell 10,4,Cstr(PEDI),0,0,"C",0
pdf.Cell 10,4,Cstr(Factura),0,0,"R",0
pdf.Cell 30,4,Cstr(TipoProd),0,0,"L",0
pdf.Cell 10,4,Formatnumber(Kilos),0,0,"R",0
If Notas = "" Or Isnull(Notas) Then
pdf.Ln(4)
Else
pdf.Ln(4)
pdf.Cell 60,4," ",0,0,"L",0
pdf.MultiCell 105,4,Notas,0,"J",0
End If
Rs13.Movenext
Loop
pdf.Ln(4)
pdf.Output()
End If
%>