%option explicit%> <% ShopCheckAdmin "" '*********************************************************** ' VP-ASP Affiliate List all affiliates. No dates are involved ' Affiliate Reports ' inputs are table, database ' Version 6.50 July 4, 2004 '************************************************************* Const LangAffSort="Sort Affiliates by " 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 dim affiliatefields, affiliatefieldcount Dim SearchFieldvalue, searchfieldname Dim Headnames(4) Dim Fieldnames(4) Dim SortType Dim Sortfield Dim SortUpDown Dim Sortupdownnames(2) Dim Sortupdownvalues(2) dim idfield totalorders=0 totalamount=0 'dim database dim linksflag dim fromdatex, todatex dim infomsg scriptresponder="shopa_formataff.asp" SetSess "CurrentURL","shopa_afflist.asp" mypage=request("page") ShopOpenOtherDB dbc, getconfig("xaffiliatedb") GetFieldnames setfieldnames GetInput if mypage<>"" then sql=GetSess("affsqlquery") ' on recursive calls we stored sql in sessikon variable sortfield=getsess("affsortfield") WriteReport else Generatesql WriteReport end if shopclosedatabase dbc '*********************************************** '* see what merchant wants ' all=yes ' affid=n ' If all=yes then ignore dates and affid '********************************************** Sub GetInput Idfield="affid" 'first time we need everything, othertimes sql is set up sortfield=request("Sortfield") ' See how we are sorting If Sortfield="" then sortfield="affid" end if 'response.write "sortfield="& sortfield SortUpdown=request("SortUpdown") If SortUpdown="" then sortupdown="ASC" end if 'VP-ASP 6.09 - Security precautions Searchfieldvalue=cleanchars(request("searchfieldvalue")) Searchfieldname=cleanchars(request("Searchfieldname")) Serror="" mypage=request("page") allflag=request("all") affid=request("affid") action=request("action") setsess "fromdate","" setsess "todate","" dbtable="affiliates" limit=getconfig("xeditdisplaymaxrecords") if limit="" then limit=100 end if SetSess "ReportLimit",limit Setsess "affsortfield",sortfield mypagesize=limit end sub ' Sub WriteReport Adminpageheader generatedisplayheader ProduceallReport adminpagetrailer end sub ' '***************************************************** ' Report on all affiliates ' regardless of what they did or a specific affiliate '***************************************************** Sub ProduceAllReport ShopOpenOtherDB dbc, getconfig("xaffiliatedb") ShopOpenOtherDB Orderdbc, getconfig("xorderdb") 'Debugwrite "sql=" & sql 'Debugwrite "mypage=" & mypage 'Debugwrite "mypagesize=" & mypagesize ShopOpenRecordSet SQL,RS, mypagesize, mypage shopwriteHeader getlang("LangAffReport01") if rs.eof then shopwriteError getlang("LangReportNoSales") else ProduceAllDetail rs, orderdbc end if closerecordset rs shopclosedatabase dbc shopclosedatabase orderdbc end sub Sub GenerateSql mypage="1" sql="Select * from affiliates" If searchfieldvalue<>"" and searchfieldname<> getlang("Langcommonselect") then If searchfieldname="affid" then sql = sql & " where " & searchfieldname & "=" & searchfieldvalue else sql = sql & " where " & searchfieldname & " LIKE '%" & searchfieldvalue & "%'" end if end if sql=sql & " order by " & sortfield & " " & sortupdown setsess "affsqlquery",sql end sub Sub GenerateDisplayHeader %>