%
ShopCheckAdmin "shopa_reports.asp"
'***********************************************************
' Version 6.50 Fix English words Oct 2, 2004
' Sales Reports
' Modified to display summary report table
' Minor fixes for null values
'*************************************************************
'VP-ASP 6.50 - Graphical reports
dim summaryarray(50), maxorders, maxtotal
dim howmanytoshow
Dim dbtable
Dim fields(10)
Dim CapFields(10)
dim fieldcount
Dim File
Dim ScriptResponder
Dim Dbc
dim Action
dim fromdate
dim todate
dim datedelim
Dim rs
Dim Limit
Dim Month
'VP-ASP 6.50 - allow filtering by payment type
dim paymenttype
Dim Year
dim monthnames(12)
'dim database
dim xdecimalpoint
xdecimalpoint=getconfig("xdecimalpoint")
const MaxShippingTypes=50
const cShipName=1
const cShipCost=2
const cShipCount=3
dim varrshipping()
dim taxcount,totaltaxcost
dim count
dim total
taxcount=0
totaltaxcost=0
dim ctgrssal1, ctgrssal2
dim ctprdsal1, ctprdsal2
dim ctshpcst1, ctshpcst2
dim cthdlfee1, cthdlfee2
dim cttax1, cttax2
dim ctgcprch1, ctgcprch2
dim ctgcrdm1, ctgcrdm2
dim ctdisapl1, ctdisapl2
dim ctcpnrdm1, ctcpnrdm2
dim ctproj1, ctproj2
xdecimalpoint=getconfig("xdecimalpoint")
scriptresponder="shopa_formatorder.asp"
mypagesize=GetSess("ReportLimit")
mypage=request("Page")
AdminPageHeader
if mypage<>"" then
sql=GetSess("Sqlquery") ' on recursive calls we stored sql in sessikon variable
fromdate=GetSess("Fromdate")
todate=GetSess("Todate")
WriteReport
else
GetInput
If Action = "" or Serror<>"" Then
DisplayForm
gethelp
Else
GenerateSQL
WriteReport
end if
End If
AdminPageTrailer
'********************************
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
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")
'VP-ASP 6.50 - allow filtering by payment type
paymenttype = request("saletype")
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
Sub GenerateSQL
dim datesql
Dim newsql
mypage=1 ' first time through
Sql="select * from orders where "
datesql = " odate>= " & DateDelimit(fromdate)
datesql = datesql & " AND odate<= " & datedelimit(todate)
'VP-ASP 6.50 - option to show processed orders only
if request("processedonly") = "true" then
if (ucase(xdatabasetype)="SQLSERVER") or (getconfig("xmysql")="Yes") OR (instr(ucase(xdatabasetype), "MYSQL") > 0) then
datesql = datesql & " AND oprocessed = 1"
else
datesql = datesql & " AND oprocessed = TRUE "
end if
end if
'VP-ASP 6.50 - allow filtering by payment type
if paymenttype > "" then
select case paymenttype
case "valid"
datesql = datesql & "AND ocardtype IN ("
if instr(getconfig("xendofordervalidpayments"), ",") > 0 then
dim payments, ii
payments = split(getconfig("xendofordervalidpayments"),",")
for ii = 0 to ubound(payments)
datesql = datesql & "'" & payments(ii) & "',"
next
datesql = left(datesql, len(datesql) - 1) & ")"
else
datesql = datesql & "'" & getconfig("xendofordervalidpayments") & "')"
end if
case "cancel"
if ucase(xdatabasetype) = "MYSQL" OR ucase(xdatabasetype) = "MYSQL351" OR ucase(xdatabasetype) = "SQLSERVER" then
datesql = datesql & " AND ((ocardtype IS NULL) OR (canceled = 1)) "
else
datesql = datesql & " AND ((ocardtype IS NULL) OR (canceled = TRUE)) "
end if
case else
datesql = datesql & " AND ocardtype = '" & paymenttype & "' "
end select
end if
'Added for summary reports to make cycling through records easier
If Action="SUMMARY" then
datesql=datesql & " order by odate"
end if
sql = sql & datesql
newSql= replace (SQL, ".", "/")
Sql=NewSql
SetSess "Fromdate",fromdate
SetSess "todate",Todate
if Getconfig("xdebug")="Yes" then
debugwrite sql
end if
end sub
'
Sub WriteReport
' Generate table
GetMonthnames monthnames
OpenOrderDB dbc
ShopOpenRecordSet SQL,RS, mypagesize, mypage
GenerateDisplayHeader getlang("langreport02")
GenerateDisplayBodyHeader
response.write "
| " & largeInfofont & getlang("langReport01")
response.write "" & day(fromdate) & " " & ucase(left(monthname(datepart("m",fromdate)),3)) & " " & datepart("yyyy", fromdate) & ""
response.write " to "
response.write "" & day(todate) & " " & ucase(left(monthname(datepart("m",todate)),3)) & " " & datepart("yyyy", todate) & ""
response.write Largeinfoend & " " & reportinfofontend 'VP-ASP 6.09 - for print friendly reports response.write " | Print Report |
" & largeinfofont 'displayshipping varrshipping response.write largeinfoend & "
" displayTotals end sub ' Sub ProduceDetail dim nopayment FormatTableStart limit=clng(mypagesize) While Not rs.EOF and ctgrssal1" Response.write largeinfofont & getlang("langReport03") & largeinfoend response.write "
" if sError<> "" then response.write "" & capfields(i) & ReportHeadColumnEnd
next
response.write ReportRowEnd
end sub
Sub FormatTableEnd
response.write ReportTableEnd
end sub
sub displaysummaryheader(bigdatename,littledatename)
'VP-ASP 6.50 - Graphical reports
response.write "
|