<%option explicit%> <% shopcheckadmin "" '*********************************************************** ' Version 6.50 ' Affiliate reports by date ' May 26, 2003 ' Octover 26, 2005 Detailed order report ' For system administrator '************************************************************* Dim dbtable Dim fields(10) Dim CapFields(10) dim fieldcount Dim File Dim Dbc dim Action dim fromdate dim todate dim datedelim Dim rs Dim Limit Dim Month Dim Year dim affid dim affsql ' sql to go through orders 'dim database mypagesize=GetSess("ReportLimit") mypage=request("Page") if mypage<>"" then affsql=GetSess("affSqlquery2") ' on recursive calls we stored sql in sessikon variable fromdate=GetSess("Fromdate") todate=GetSess("Todate") WriteReport else GetInput If Action = "" or Serror<>"" Then DisplayForm Else GenerateAffsql WriteReport end if End If '******************************** Sub GetInput Serror="" dbtable="Orders" limit=request("Limit") if limit="" then limit=100 end if SetSess "ReportLimit",limit mypagesize=limit action="" GetActionValues If action<> "" then GetDateValues end if affid=request("affidform") if affid=getlang("langcommonselect") then affid="" end if setsess "fromdate",fromdate setsess "todate",todate end sub ' Sub GetActionValues action=request("summary") if action<>"" then action="SUMMARY" else action=request("Details") if action<>"" then action="DETAILS" end if end if end Sub ' Sub GetDateValues dim datevalue fromdate=request("fromdate") todate=request("todate") If fromdate<>"" then if todate="" then todate=date() end if ValidateDates exit sub end if ' Try month Month=Request("month") Year=Request("Year") If month>"0" then FormatMonth exit sub end if If Year>"0" then FormatYear exit sub end if ' Try Radio Buttons datevalue=request("DateSelect") datevalue=ucase(datevalue) 'debugwrite "datevalue=" & datevalue if datevalue="" then Serror= getlang("langReportDate") exit sub end if If datevalue="TODAY" then fromdate=date() todate=date() exit sub end if If datevalue="YESTERDAY" then fromdate=dateadd("d",-1, date()) todate=fromdate exit sub end if end sub Sub FormatMonth If lcase(getconfig("xenvironment"))="chillisoft" then formatmonthchilli exit sub end if month=cint(month) if Year="0" then Year=Datepart("yyyy",date()) else Year=clng(year) end if fromdate= month & "/" & Year month=month+1 if month = 13 then month=1 Year=Year+1 end if Todate= month & "/" & Year fromdate=cdate(fromdate) todate=cdate(todate) todate = dateadd("d",-1, todate) end sub ' Sub formatYear If lcase(getconfig("xenvironment"))="chillisoft" then formatyearchilli exit sub end if Year=clng(year) month=1 fromdate= month & "/" & Year Year=Year+1 Todate= month & "/" & Year fromdate=cdate(fromdate) todate=cdate(todate) todate=dateadd("d",-1,todate) end sub ' Sub ValidateDates If not Isdate(fromdate) then Serror="
" & getlang("LangReportInvalidDate") & fromdate end if If not Isdate(todate) then Serror="
" & getlang("LangReportInvalidDate") & todate end if end sub ' '*********************************************************************** ' Details ' put out header. '********************************************************************** Sub WriteReport adminpageheader reportadmin="Yes" dim displayfromdate, displaytodate displayfromdate = datepart("d", fromdate) & " " & monthname(datepart("m", fromdate)) & " " & datepart("yyyy", fromdate) displaytodate = datepart("d", todate) & " " & monthname(datepart("m", todate)) & " " & datepart("yyyy", todate ) 'Response.write "" & getlang("LangReport01") & displayfromdate & " to " & displaytodate & "
" GenerateDisplayHeader getlang("LangReport01") & displayfromdate & " to " & displaytodate GenerateDisplayBodyHeader OpenOrderdb dbc WriteaffiliateReport shopclosedatabase dbc GenerateDisplayBodyFooter adminpagetrailer end sub '********************************************************************** ' loop through all affilaites that have an order during these dates '*********************************************************************** Sub WriteAffiliateReport dim rs, loopcount, maxrecs if mypage="" then mypage=1 ShopOpenRecordSet affSQL,RS, mypagesize, mypage if rs.eof then shopwriteError getlang("LangReportNoSales") closerecordset rs exit sub end if loopcount=0 maxrecs=clng(mypagesize) do while not rs.eof and loopcount=maxrecs then PageNavBar affSQL end if closerecordset rs GenerateGrandTotals end sub ' ' Sub Displayform adminPageHeader if sError<> "" then response.write "
" & errorfontstart & "" & SError & "" & errorfontend Serror="" end if generatedisplayheader "Affiliate Order Report" generatedisplaybodyheader %>

<% shopdateform getlang("langadmindisplayorders") Response.write "
" GenerateDisplayBodyFooter gethelp adminPageTrailer end sub Sub Addaffiliates dim straffid, affconn Openaffiliatedb affconn %>
<%=getlang("langaff")%> <%GenerateTableV affconn,"affiliates","affid","company","lastname",straffid,"affidform", "company", Getlang("langcommonselect") %>
<% shopclosedatabase affconn end sub '***************************************************************** ' VP-ASP date form Used in many places ' VP-ASP 6.50 March 26, 2004 '***************************************************************** Sub Shopdateform (header) dim dateprompt dateprompt=getlang("langcommonselect") dateprompt="" & getlang("LangDisplayDate") & "" %> <% dim dateformat ' if (Session.LCID > "") or (getconfig("xlcid") > "") then ' dateformat = 'else if getconfig("xdateformat") > "" then dateformat = replace(getconfig("xdateformat"), " ", "/") dateformat = replace(dateformat, "m", "M") dateformat = replace(dateformat, ".", "/") dateformat = replace(dateformat, "-", "/") else 'default to American format if not otherwise specified dateformat = "mm/dd/yyyy" end if '============================================== %>
<%=getlang("langReportFromdate")%>
<%=dateprompt%>
<%=getlang("langReportToDate")%>
<%=dateprompt%>
<%=getlang("langReportMonth")%>
 
<%=getlang("langReportYear")%>

<%=getlang("langReportToday")%>

<%=getlang("langReportYesterday")%>

<%=getlang("langReportMaxRows")%>

<%Addaffiliates%>

" name="Summary">

" class='submitbtn' name="B2">

" name="Details">

<%addwebsessform end sub Sub Shopdateform_OLD (header) %>
<%=header%>

<%=getlang("langReportFromdate")%>

<%=getlang("langReportToDate")%>

<%=getlang("langReportMonth")%>

<%=getlang("langReportYear")%>

<%=getlang("langReportToday")%>

<%=getlang("langReportYesterday")%>

<%=getlang("langReportMaxRows")%>

<% Addaffiliates %>

" name="Summary">
" class='submitbtn' name="B2">

" name="Details">

<%addwebsessform%> <% end sub Sub GenerateAffsql dim sql, fromdatex, todatex fromdatex=DateDelimit(fromdate) todatex=DateDelimit(todate) sql="select orders.oaffid " sql=sql & " from orders where orders.odate>=" & fromdatex sql=sql & " and orders.odate<=" & todatex sql=sql & " group by orders.oaffid " if affid="" then sql=sql & " having orders.oaffid>0" else sql=sql & " having orders.oaffid=" & affid end if sql=sql & " order by orders.oaffid" affsql=sql setsess "affsqlquery2",affsql end sub %>