<%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 & "

" end sub Sub Formatsupplier (affid, iFlag) supplierid=affid ShopOpendatabase dbc SQL="Select * from suppliers Where supplierid=" & affid Set objRS = dbc.Execute(SQL) If objRS.EOF Then shopwriteerror getlang("LangSupplierNotFound") & supplierid objrs.close set objrs=nothing exit sub else FormatSupplierDetails end if objrs.close set objrs=nothing end sub Sub FormatSupplierDetails Response.write FoRderTable doheader getlang("langsuppliernumber") & " " & objrs("supplierid") dofield getlang("langsuppliername"), objrs("name") dofield getlang("langcustfirstname"), objrs("firstname") dofield getlang("langcustlastname"), objrs("lastname") dofield getlang("langcustaddress") ,objrs("address") dofield getlang("langcustcity"), objrs("city") dofield getlang("langcuststate") , objrs("state") dofield getlang("langcustpostcode"),objrs("postcode") dofield getlang("langcustcountry"),objrs("country") dofield getlang("langcustemail"),objrs("email") dofield getlang("langcustphone"),objrs("phone") dofield getlang("langcustfax"),objrs("fax") dofield getlang("langcustcompany"),objrs("company") response.write "" commissionrate=objrs("commissionrate") if isnull(commissionrate) then commissionrate=0.0 end if end sub ' Sub DoField (fieldname,fieldvalue) if fieldvalue="" or isNull(fieldvalue) then exit sub end if %> <%=ForderFieldRow%> <%=ForderFieldLeft%><%=fieldname%> <%=FOrderFieldRight%><%=fieldvalue%> <% end sub Sub DoHeader (mytext) %> <%=FOrderHeaderColumn%><%=mytext%><%=ForderHeaderColumnEnd%> <% end sub %>