<%option explicit%> <% ShopCheckAdmin "" '*********************************************************** ' VP-ASP Affiliate List all affiliates that had orders during a certain date period ' Affiliate Reports ' inputs are table, database ' Version 6.50 ' Jan 11, 2004 Fix shopcheckadmin '************************************************************* dim allflag Dim dbtable Dim Capfields(10) dim fieldcount Dim File Dim ScriptResponder Dim Dbc Dim orderdbc dim Action dim fromdate dim todate dim datedelim Dim rs Dim Limit Dim Month Dim Year Dim affid, affdbc, orders Dim affsql, affrs Dim affname, afflogincount, afflogindate, affcommrate Dim ordercount dim orderamount Dim totalorders, totalamount, Totallogins dim fieldvalue dim count totalorders=0 totalamount=0 'dim database dim linksflag dim fromdatex, todatex dim infomsg scriptresponder="shopa_formataff.asp" SetSess "CurrentURL","shopa_orderreport.asp" mypage=request("Page") if mypage<>"" then sql=GetSess("Sqlquery") ' on recursive calls we stored sql in sessikon variable WriteReport else GetInput WriteReport end if '*********************************************** '* see what merchant wants ' all=yes ' affid=n ' If all=yes then ignore dates and affid '********************************************** Sub GetInput Serror="" fromdate=getsess("fromdate") todate=getsess("todate") allflag=request("all") affid=request("affid") action=request("action") dbtable="affiliates" limit=getsess("reportlimit") if limit="" then limit=100 end if mypage=1 SetSess "ReportLimit",limit mypagesize=limit end sub Sub WriteReport Adminpageheader ProducedateReport adminpagetrailer end sub ' '******************************************************** ' Only want affiliates who had orders during those dates '********************************************************* Sub ProduceDateReport ShopOpenOtherDB affdbc, getconfig("xaffiliatedb") ShopOpenOtherDB dbc, getconfig("xorderdb") fromdatex=DateDelimit(fromdate) todatex=DateDelimit(todate) sql="select orders.oaffid, count(orders.orderid) as countoforderid, sum(orders.orderamount) as sumoforderamount " sql=sql & " from orders where orders.odate>=" & fromdatex sql=sql & " and orders.odate<=" & todatex sql=sql & " group by orders.oaffid " sql=sql & " having orders.oaffid>0 order by orders.oaffid" ' debugwrite sql ShopOpenRecordSet SQL,RS, mypagesize, mypage infomsg = getlang("LangAffReport01") GenerateDisplayHeader Infomsg GenerateDisplayBodyHeader 'VP-ASP 6.09 - for print friendly reports response.write "
Print Report
" shopwriteheader getlang("LangAffReport01") If Fromdate<>"" Then shopwriteheader fromdate & " - " & todate & "
" else shopwriteheader " " & getlang("LangAffAllDates") & "
" end if if rs.eof then shopwriteError getlang("LangReportNoSales") else If Action="SUMMARY" then ProduceSummary rs else ProduceDetail rs end if end if Shopclosedatabase affdbc ShopClosedatabase dbc GenerateDisplayBodyFooter end sub ' %>