%option explicit%> <% '*********************************************************** ' Version 6.50 ' Jan 5, 2003 ' VP-ASP Supplier account report '************************************************************* Dim totalorders, totalamount, Totalcommission dim totalProc, totalproccount, totalshipping, totalshippingproc dim commissionrate Dim dbcorders Dim dbc Dim Headnames(10) Dim Fieldnames(10) Dim Fieldcount Dim fromdate Dim todate Dim ordercount dim processed dim supplierid, unitprice dim orderamount, count ShopCheckAdmin "shopa_supplieraccount.asp" setsess "currenturl","shopa_supplieraccount" supplierid=request("id") 'VP-ASP 6.09 - Precautionary security fix if supplierid > "" then if not isnumeric(supplierid) then supplierid = "" end if end if if supplierid="" Then shoperror getlang("langaffnoaffid") end if AdminpageHeader ShopOpenOtherdb dbcorders,getconfig("xorderdb") FormatSupplier supplierid,"Report" If serror="" then FormatOrders If Serror<>"" then shopwriteerror sError else FormatSummary end if end if AdminPageTrailer shopclosedatabase dbcorders ' Sub FormatOrders GenerateSQL 'debugwrite sql Set objRS = dbcorders.Execute(SQL) if objRS.eof then Serror= getlang("LangReportNoSales") objrs.close set objrs=nothing exit sub end if Do While Not ObjRS.EOF GetOrderDetails count=count+1 TotalOrders=Totalorders+Ordercount Totalamount=Totalamount+Orderamount objrs.movenext loop objrs.close set objrs=nothing End sub ' Sub GetOrderDetails ordercount=objrs("SumOfNumItems") unitprice=objrs("unitprice") orderamount=ordercount*Unitprice end sub Sub GenerateSQL dim fromdatex, todatex dim datesql,strsql, whereok Dim newsql Fromdatex=GetSess("Fromdate") Todatex=GetSess("Todate") whereok=" Where " strsql="select oitems.supplierid, oitems.catalogid, oitems.unitprice, sum(oitems.numitems) as sumofnumitems " strsql=strsql & " from orders inner join oitems on orders.orderid = oitems.orderid " if fromdatex<>"" and todatex<>"" then datesql = " orders.odate>= " & datedelimit(fromdatex) datesql = datesql & " and orders.odate<= " & datedelimit(todatex) strsql=strsql & whereok & datesql whereok=" and " end if strsql=strsql & whereok & " oitems.supplierid=" & supplierid strsql=strsql & " group by oitems.supplierid, oitems.catalogid, oitems.unitprice " strsql=strsql & " order by oitems.supplierid" sql=strsql 'debugwrite sql end sub ' Sub FormatSummary dim comtotal, infomsg ' Commission amount Comtotal=totalamount Fromdate=GetSess("Fromdate") Todate=GetSess("Todate") response.write "
" & ReportInfoFont
Infomsg=Infomsg & fromdate & " - " & todate & ReportInfoFontEnd
Response.write Infomsg
Response.write "
" & getlang("LangReportTotalsales") & shopformatcurrency(totalamount,getconfig("xdecimalpoint"))
Response.write "
" & getlang("LangReportNumSales") & totalOrders
Response.write "
"
totalCommission=Comtotal*commissionrate
Response.write "
" & getlang("LangAffCommission") & shopformatcurrency(totalcommission,getconfig("xdecimalpoint"))
response.write ReportInfoFontEnd & "