%option explicit%>
<%
shopcheckadmin "shopa_displayorders.asp"
'**************************************************************************
' Version 6.50
' Display RMA
' Nov 22, 2006 HK Created
' Similar to shopa_displayorders
'**************************************************************************
'
dim Selectioncritereontext
dim mysql
Dim Fieldcount
Dim Headnames(6)
Dim Fieldnames(6)
Dim ProcType
Dim SortType
Dim Sortfield
Dim SortUpDown
Dim Sortupdownnames(2)
Dim Sortupdownvalues(2)
dim sortupdowncount
Dim Procnames(3)
dim Procvalues(3)
Dim Pendnames(20)
dim Pendvalues(20)
dim pendingcount
Dim Idfield
Dim SearchFieldvalue, searchfieldname
Dim i
dim orderfieldcount, orderfields
dim oitemsnamescount, oitemsnames, oitemsvalues
Dim item
dim dbtable
Dim scriptresponder
Dim editresponder
Dim dbc
dim fieldname
dim pending, pendtype
dim PendingFieldnames(20),pendingfieldcount, pendingnamescount
dim PaidFieldnames(20),paidfieldcount, paidnamescount, paidnames(20),paidvalues(20)
dim paid, paidtype, ocardtype
dim stockconn, items
dim specialsearchcount
dim prevandor
specialsearchcount=4
setsess "currenturl","shopa_rmadisplay.asp"
if request.form("advanced") > "" then
if request.form("advanced") <> getsess("advanced") then
setsess "advanced", request.form("advanced")
responseredirect "shopa_rmadisplay.asp"
end if
end if
AdminPageHeader ' Admin page headers are different
SetFieldNames ' field names for table
OpenOrderDB dbc ' open database
GetInput ' get all form fields
If Request("Delete")<>"" Then
For each item in Request("DeleteUser")
DeleteRecord Item
Next
End if
If Request("Process")<>"" Then
For each item in Request("Processed")
MarkProcessed Item
Next
End if
If Request("MarkPending")<>"" Then
For each item in Request("Pending")
MarkPending Item
Next
End if
GenerateSearchHeader ' Generate sort button etc
scriptresponder="shopa_rma.asp"
editresponder="shopa_editrecord.asp"
'debugwrite "sql=" & mysql
SetSess "pagenumberaddproduct",mypage
ShopopenRecordSet mysql, rsorder, mypagesize, mypage
Selectioncritereontext = mysql
GenerateTable ' write the tabe
'Call PageNavBar (Mysql) ' put bottom navigation bar
rsOrder.close ' close database
set rsOrder=nothing
shopCloseDatabase dbc
gethelp
AdminPageTrailer ' Write admin trailer
'
Sub GetInput
Idfield="rmaid"
mypage = Request.querystring("page")
if mypage > "" then
If not isnumeric(mypage) then
shoperror "Page size must be numeric"
end if
end if
'first time we need everything, othertimes sql is set up
sortfield=request("Sortfield")
' See how we are sorting
If Sortfield="" then
sortfield="rmaid"
end if
'response.write "sortfield="& sortfield
' see which types processed or unprocessed
Proctype=request("Proctype")
If Proctype="" then
Proctype="0"
end if
'response.write "Proctype=" & proctype
Pendtype=request("Pendtype")
If Pendtype="" then
Pendtype="*"
end if
SortUpdown=request("SortUpdown")
If SortUpdown="" then
sortupdown="DESC"
end if
if mypage="" then
mypage=1
GenerateSQL
else
Mysql=GetSess("rmasqlquery")
Proctype=GetSess("rmaProctype")
sortfield=GetSess("rmasortfield")
sortupdown=GetSess("rmasortupdown")
pendtype=getsess("rmapendtype")
end if
if request.form("showhowmany") > "" then
if request.form("showhowmany") <> getlang("langcommonselect") then
setsess "rmashowhowmany", request.form("showhowmany")
else
setsess "rmashowhowmany", getconfig("xeditdisplaymaxrecords")
end if
else
if getsess("rmashowhowmany") > "" then
else
setsess "rmashowhowmany", getconfig("xeditdisplaymaxrecords")
end if
end if
maxrecs=getsess("rmashowhowmany")
mypagesize=maxrecs
end sub
'
' SQL is generate by using fields on form
Sub GenerateSQL
dim sqlproc
dim dbtable, whereok
dim bracketopen,i, sqladd
sqladd=" Where"
bracketopen=false
dbtable="shoprma"
oitemsnames=request("oitemsnames")
If oitemsnames<>"" and isnumeric(oitemsnames) then
mysql=" SELECT oitems.*, orders.*, shoprma.*"
mysql=mysql & " FROM (oitems INNER JOIN orders ON oitems.orderid = orders.orderid) INNER JOIN shoprma ON orders.orderid = shoprma.rmaorderid "
mysql=mysql & " WHERE oitems.catalogid = " & oitemsnames & " "
sqladd= "AND"
else
MySql = "SELECT * from " & dbtable
mysql="SELECT orders.*, shoprma.* FROM orders INNER JOIN shoprma ON orders.orderid = shoprma.rmaorderid"
end if
dim addAND
addAND = false
for i =1 to specialsearchcount
if (Request("criterionvalue" & i )) > "" then
addAND = true
end if
next
if addAND = true then mysql = mysql & " AND "
for i = 1 to specialsearchcount
specialsearchterm MYSQL,sqladd,Request("criterion" & i),Request("criterionvalue" & i ),Request("Selection" & i),bracketopen
if sqladd = "AND" then
whereok = " AND "
else
whereok =" WHERE "
end if
Next
if bracketopen then MYSQl=MYSQL & ")"
if getsess("advanced") <> "yes" then
if Proctype="" then
sqlproc = whereok & " rmarocessed=0"
whereok= " AND "
else
if Proctype="*" then
sqlproc=""
AddPendingSql sqlproc, whereok
else
If Proctype="0" then
sqlproc = whereok & " rmaprocessed=" & Proctype
whereok=" AND "
AddPendingSql sqlproc, whereok
else
sqlproc = whereok & " rmaprocessed<>0"
whereok=" AND "
end if
end if
end if
end if
Mysql = mysql & sqlproc
Searchfieldvalue=request("searchfieldvalue")
Searchfieldname=request("Searchfieldname")
If searchfieldvalue<>"" and searchfieldname<> getlang("Langcommonselect") then
if searchfieldname = "rmaid" then searchfieldname = "shoprma.rmaid"
searchfieldvalue=Replace(searchfieldvalue,"'","''")
'VP-ASP 6.08 - stop from searching amount on a non-numeric value
if searchfieldname = "orderamount" then
if not isnumeric(left(searchfieldvalue,1)) then
shoperror "Order Amount must be a numeric value"
else
mysql = mysql & whereOK & searchfieldname & " = " & searchfieldvalue
end if
else
mysql = mysql & whereOK & searchfieldname & " LIKE '%" & searchfieldvalue & "%'"
end if
whereok= " and "
end if
If sortfield<>"" then
mysql=mysql & " order by shoprma." & sortfield & " " & sortupdown
end if
'Debugwrite "pendtype=" & pendtype
SetSess "rmasqlquery",MySQL
setSess "rmaProctype",Proctype
SetSess "rmasortfield",sortfield
SetSess "rmasortupdown",sortupdown
SetSess "rmapendtype",pendtype
SetSess "rmaoitemsname",oitemsnames
'debugwrite mysql
End sub
'
Sub GenerateTable
dim howmanyfields
dim howmanyrecs
dim my_link
dim processed
dim pending, orderid, pendingfieldname, fieldname
dim paidyesno
dim realorderid
howmanyfields=fieldcount
GenerateDisplayHeaderFlat
GenerateDisplayBodyHeader
%>
<%'Put Headings On The Table of Field Names
for i=0 to howmanyfields
%>
<% SortHeader Headnames(i), fieldnames(i) %>
<%
next
%>
Processed
<%
If getconfig("xorderpending")="Yes" then
%>
Pending
<%
end if
'============================
'Printer Friendly Link
'============================
%><%
If getconfig("xtracking")="Yes" then
%>
Track
<%
end if
%>
<%=getlang("langcommonview")%>
<%
%>
<%=getlang("LangMenuEdit")%>
<%
%>
<% if request("specialfunction") = "Mail" then
response.write getlang("langcustemail")
elseif request("specialfunction") = "Export" then
response.write getlang("langspecialexport")
else
response.write getlang("langmenudelete")
end if%>
<%
' Now lets grab all the records
howmanyrecs=0
DO UNTIL rsorder.eof OR howmanyrecs=maxrecs
orderid=rsorder(idfield)
realorderid=rsorder("rmaorderid")
processed=rsorder("rmaprocessed")
pending=rsorder("rmamerchantaction")
ocardtype=rsorder("rmacustomeraction")
If isnull(pending) then pending="No"
'VP-ASP 6.50 - broadened defintion of IF statement to cover cases where xmysql hasn't been set
if ucase(xdatabasetype) = "MYSQL" OR ucase(xdatabasetype) = "MYSQL351" OR getconfig("xMYSQL")="Yes" then
if processed then
processed=1
else
processed=0
end if
end if
for i = 0 to howmanyfields
fieldname=fieldnames(i)
Select case ucase(fieldname)
Case "RMAID"
%>
<%
GenerateDisplayBodyFooter
end sub
Sub SetFieldNames
Fieldcount=6
fieldnames(0)="rmaid"
fieldnames(1)="rmaorderid"
fieldnames(2)="rmacreationdate"
fieldnames(3)="rmacustomerid"
fieldnames(4)="rmacustomername"
fieldnames(5)="rmacustomeraction"
fieldnames(6)="rmamerchantaction"
headnames(0)="rmaid"
headnames(1)="orderid"
Headnames(2)=getlang("langDisplayDate")
Headnames(3)="custtomerid"
Headnames(4)=getlang("langCommonName")
HeadNames(5)="Request"
HeadNames(6)="Merchant"
Sortupdownnames(0)=getlang("langAscending")
Sortupdownnames(1)=getlang("langDescending")
Sortupdownvalues(0)="ASC"
Sortupdownvalues(1)="DESC"
Procnames(0)=getlang("langAllOrders")
Procnames(1)=getlang("langProcessed")
Procnames(2)=getlang("langUnprocessed")
ProcValues(0)="*"
ProcValues(1)="1"
ProcValues(2)="0"
'
Pendingcount=0
SetupPending
end sub
'
Sub DeleteRecord(Item)
dim Rowsaffected
dbc.execute "delete from shoprma where rmaid = " & item
end sub
Sub MarkProcessed (Item)
'Response.write "item=" & item
sql= "update shoprma set rmaprocessed = 1 where rmaid =" & item
dbc.Execute sql
End sub
Sub GenerateSearchHeader
%>
<%end sub
'==============================================
' YOURVIRTUALSTORE CODE
' SPECIAL SEARCH CUSTOMISATION
' Write all the fields for that table
' Gavin Thomas
' 12/10/2004
'==============================================
Sub Writetableallfields (num,selecttype)
dim sql,rs,fieldnamestable,fieldcount,strselect,fldName,selected
fieldcount=0
if selecttype="multiple" then
strselect=" type=multiple size=5 "
else
strselect=" size=1"
end if
sql="SELECT orders.*, shoprma.* FROM orders INNER JOIN shoprma ON orders.orderid = shoprma.rmaorderid"
Set rs = dbc.Execute(SQL)
%>
<%
closerecordset rs
End Sub
Sub AddHowMany
%>