<%@language=vbscript%>
<%
Response.Buffer=True
If Session("ID")=0 then
Response.Redirect("http://www.grupo-mim.com")
Response.End
Else
%>
<!--#include file="fpdf/numeros.asp"-->
<%Session.LCID=2058%>
<!--#include file="fpdf.asp"-->
<%
Dim Cn1, Rs1, Sql1
Dim Rs2, Sql2, Rs3, Sql3
Dim Empresa, FechaI, FechaF, Vendedor
Dim Timpo, Tiva, Ttotal
Dim colorFila, Color
Dim MsgH
Empresa = Request("Empresa")
FechaI = Request("FechaI")
FechaF = Request("FechaF")
Vendedor = Request("Vendedor")
E1= Empresa
Set Cn1 = Server.CreateObject( "ADODB.Connection" )
Cn1.Open "DRIVER={SQL Server};SERVER=172.17.0.5;UID=ADMIMSIS;PWD=ST2108GP;Database=" & Empresa &""
Set Rs1 = server.CreateObject("ADODB.Recordset")
Sql1="Select * from Empresa"
Rs1.open Sql1,Cn1,1,2
If Vendedor = 0 Then
MsgH = "Reporte de Ventas Por Cliente Todos los Vendedores " & " De la fecha " & FechaI & " Al " & FechaF
Set Rs3 = server.CreateObject("ADODB.Recordset")
Sql3="Select clifface as Clave, nomcli as Cliente, Rfccli as RFC, " &_
"sum(subfface * tcafface) as Subtotal, sum(ivtfface * tcafface) as Iva, sum(totfface * tcafface) as Total " &_
"from clientes, ffacenc " &_
"where clacli = clifface and fecfface between '"& FechaI &"' and '"& FechaF &"' and stafface <> 'C' " &_
"group by clifface, nomcli, Rfccli " &_
"order by total desc;"
Rs3.open Sql3,Cn1,1,2
Else
set Rs2 = server.CreateObject("ADODB.Recordset")
Sql2="Select * from Vendedores where Cvevend = '"& Vendedor &"';"
Rs2.open Sql2,Cn1,1,2
MsgH = "Reporte de Ventas Por Cliente Del Vendedor: " & Rs2("Nomvend") & " De la fecha " & FechaI & " Al " & FechaF
Set Rs3 = server.CreateObject("ADODB.Recordset")
Sql3="Select clifface as Clave, nomcli as Cliente, Rfccli as RFC, " &_
"sum(subfface * tcafface) as Subtotal, sum(ivtfface * tcafface) as Iva, sum(totfface * tcafface) as Total " &_
"from clientes, ffacenc " &_
"where clacli = clifface and fecfface between '"& FechaI &"' and '"& FechaF &"' and stafface = 'A' and Vencli = '"& Vendedor &"'" &_
"group by clifface, nomcli, Rfccli " &_
"order by total desc;"
Rs3.open Sql3,Cn1,1,2
End If
B1=rs1("Nombre")
B2=rs1("Direccion")
B3=rs1("Colonia")
B4=rs1("Poblacion")
B5=rs1("Telefono")
B6=rs1("Fax")
B7=rs1("website")
Co1 = 1
Co2 = 33
Co3 = 254
Set pdf=CreateJsObject("FPDF")
pdf.CreatePDF "P", "mm", "Letter"
pdf.SetPath("fpdf/")
pdf.SetFont "Arial","",7
pdf.SetFillColor 216,216,216
pdf.Open()
pdf.LoadModels("FVentaC")
pdf.AddPage()
pdf.SetFont "Arial","",7
Timpo = 0
Tiva = 0
Ttotal = 0
Do while Not(Rs3.EOF)
D1 = Rs3("Clave")
D2 = Rs3("Cliente")
D3 = Rs3("RFC")
D4 = Rs3("SUBTOTAL")
D5 = Rs3("IVA")
D6 = Rs3("TOTAL")
pdf.Cell 10,4,D1,0,0,"L",0
pdf.Cell 100,4,D2,0,0,"L",0
pdf.Cell 25,4,D3,0,0,"L",0
pdf.Cell 20,4,FORMATNUMBER(D4),0,0,"R",0
pdf.Cell 20,4,FORMATNUMBER(D5),0,0,"R",0
pdf.Cell 20,4,FORMATNUMBER(D6),0,0,"R",0
pdf.Ln(4)
Timpo = Cdbl(Timpo) + Cdbl(d4)
Tiva = Cdbl(Tiva) + Cdbl(d5)
Ttotal = Cdbl(Ttotal) + Cdbl(d6)
Rs3.Movenext
loop
pdf.Cell 10,4," ",0,0,"L",0
pdf.Cell 100,4," ",0,0,"L",0
pdf.Cell 25,4," ",0,0,"L",0
pdf.Cell 20,4,FORMATNUMBER(timpo),0,0,"R",0
pdf.Cell 20,4,FORMATNUMBER(tiva),0,0,"R",0
pdf.Cell 20,4,FORMATNUMBER(TTotal),0,0,"R",0
pdf.Ln(4)
pdf.Output ()
End If
%>