%option explicit%>
<%
'***********************************************************
' Version 6.50 VP-ASP Affiliate account report
' July 5, 2005
'*************************************************************
Dim totalorders, totalamount, Totalcommission
dim totalProc, totalproccount, totalshipping, totalshippingproc
dim commissionrate
Dim dbcorders
Dim dbcaff
Dim Headnames(10)
Dim Fieldnames(10)
Dim Fieldcount
Dim fromdate
Dim todate
Dim ordercount
dim processed
dim commission
dim commrate
ShopCheckAdmin ""
lngaffid=request("affid")
if lngaffid="" Then
shoperror getlang("LangaffnoID")
end if
'VP-ASP 6.09 - Precautionary security fix
if lngaffid > "" then
if not isnumeric(lngaffid) then
shoperror "Affiliate ID must be numeric"
end if
end if
AdminpageHeader
totalcommission=0
ShopOpenOtherdb dbcorders,getconfig("xorderdb")
FormatAffiliate lngaffid,"Report"
commrate=affmastercommissionrate
if isnumeric(commrate) then
commrate=csng(commrate)
end if
If serror="" then
FormatOrders
If Serror<>"" then
Response.write errorfontstart & serror & errorfontend & "
"
else
FormatSummary
end if
end if
AdminPageTrailer
shopclosedatabase dbcorders
'
Sub FormatOrders
dim forceflag
forceflag=False ' only get real commission
GenerateSQL
dim calculated
'debugwrite sql
Set objRS = Server.CreateObject("ADODB.Recordset")
Set objRS = dbcorders.Execute(SQL)
if objRS.eof then
Serror= getlang("LangAffNoOrders")
objrs.close
set objrs=nothing
exit sub
end if
SetFieldNames
FormatOrderHeader
Do While Not ObjRS.EOF
totalorders=totalorders+1
if not isnull( objrs("orderamount")) then
totalamount=totalamount+ objrs("orderamount")
totalshipping=totalshipping+ objrs("oshipcost")
end if
processed=objrs("oprocessed")
commrate=objrs("mastercommissionrate")
shopaffcommissionMaster dbcorders,objrs, lngaffid, commrate, commission, calculated, forceflag
if calculated=True then
totalcommission=totalcommission+commission
totalproc=totalproc+ objrs("orderamount")
totalproccount=totalproccount+1
totalshippingproc=totalshippingproc + objrs("oshipcost")
end if
FormatSingleOrder
objRS.movenext
loop
Response.write ""
objrs.close
set objrs=nothing
End sub
'
Sub FormatSingleOrder
dim fieldname
dim i, tempfieldname
dim fieldvalue
response.write "
" Response.write FoRderTable Doheader getlang("LangReportNumSales") DoField getlang("LangReportNumSales"),totalOrders DoField getlang("LangReportTotalsales"),shopformatcurrency(totalamount,xdecimalpoint) Dofield getlang("LangProductShippingCost"), shopformatcurrency(totalshipping,xdecimalpoint) Doheader getlang("LangProcessed") dofield getlang("LangReportNumSales"),totalproccount DoField getlang("LangReportTotalSales"),shopformatcurrency(totalproc,xdecimalpoint) dofield getlang("LangProductShippingCost"),shopformatcurrency(totalshippingproc,xdecimalpoint) doheader getlang("langaffcommission") dofield getlang("LangAffCommission"),shopformatcurrency(totalcommission,xdecimalpoint) Response.write "" end sub %>