%option explicit%>
<%
Const EbayDisplay="No"
ShopCheckAdmin "shopa_editdisplay.asp"
'**************************************************************************
' Shop administration Only
' Format list of Records in any table so that they can be viewed or deleted
' add sort facility, fields to display
' Version 4.00 Feb 2, 2002 Fix default delete for non english
' Default
' 4.50 a Oct 16, 2002
'**************************************************************************
dim mysql
Dim Fieldcount
Dim Headnames(6)
Dim ProcType
Dim SortType
Dim Sortfield
Dim SortUpDown
Dim Sortupdownnames(2)
Dim Sortupdownvalues(2)
Dim Sortupdowncount
Dim Procnames(3)
dim Procvalues(3)
Dim Fieldnames
Dim Fieldnamecount
Dim DisplayFields
Dim displayFieldCount
Dim DisplayField
Dim Idfield
Dim SelectField
Dim SelectValue
Dim maxfields
Dim i
Dim item
dim dbtable
Dim scriptresponder
dim fieldname
Dim rstemp
Dim dbc
dim SpecialFunction
Dim Continue
Dim SelectAll
'
'
SelectAll=""
SetSess "CurrentURL","shopa_editdisplay.asp"
AdminPageHeader
GetDatabase
GetTableName
If dbtable<>"" then ' no valid table
GetSpecialFunction
EditOpenDatabase dbc,database,dbtable
GetInput ' get all form fields
maxfields=6
ProcessSpecialRequests ' delete or mail requests
GenerateDisplayHeader ' Generate sort button etc
SetupResponders ' Different Responders for different tables
ShopopenRecordSet mysql, rstemp, mypagesize, mypage
GenerateTable ' write the tabe
Call PageNavBar (Mysql) ' put bottom navigation bar
rsTemp.close ' close database
set rstemp=nothing
ShopCloseDatabase dbc
end if
AdminPageTrailer ' Write admin trailer
'
Sub GetDatabase
Database=request("database")
if database="" then
database=GetSess("db")
else
SetSess "db",database
end if
if database="" then
Debugwrite "No database specified"
end if
end sub
Sub GetTableName
dbtable=Request("Table")
if dbtable="" then
dbtable=GetSess("table")
else
ValidateTable
end if
if dbtable="" then
Response.write LangEditSelectFail & "
"
exit sub
end if
SetSess "table",dbtable
'Response.write LangEdittablename & " = " & dbtable & "
"
end sub
Sub GetSpecialFunction
specialfunction=Request("Specialfunction")
if specialfunction="" then
specialfunction=GetSess("specialfunction")
If Specialfunction="" then
specialfunction=LangCommonDelete
setsess("specialfunction"),specialfunction
end if
else
If ucase(Specialfunction)="NULL" then
SpecialFunction=""
end if
end if
SetSess "specialfunction",specialfunction
end sub
'**************************************************************************
Sub GetInput
mypage = Request("page")
'first time we need everything, othertimes sql is set up
sortfield=request("Sortfield")
' See how we are sorting
If Sortfield="" or Sortfield=LangCommonSelect then
sortfield=IdField
end if
SelectValue=request("Selectvalue")
SelectField=request("selectField")
If SelectField=LangCommonselect then
selectvalue=""
end if
'response.write "sortfield="& sortfield & "
"
' see which types processed or unprocessed
SortUpdown=request("SortUpdown")
If SortUpdown="" then
sortupdown="ASC"
end if
if mypage="" then
SetFieldNames ' field names for table
GetDisplayfields
mypage=1
GenerateSQL
else
Mysql=Getsess("sqlquery")
Fieldcount=GetSess("Fieldcount")
Fieldnames=GetsessA("Fieldnames")
sortfield=GetSess("sortfield")
sortupdown=GetSess("sortupdown")
IDfield=GetSess("IDfield")
dbtable=GetSess("table")
DisplayFields=GetSess("DisplayFields")
DisplayFieldCount=GetSess("DisplayFieldCount")
end if
maxrecs=getconfig("xeditdisplaymaxrecords")
mypagesize=maxrecs
SetUpDown
' see if mail of export
If Request("SelectAll")<>"" then
SelectAll=" checked "
end if
database=Getsess("db")
end sub
'
' SQL is generate by using fields on form
Sub GenerateSQL
dim sqlproc
dim key
dim sqladd
sqladd=" Where"
MySql = "SELECT * from " & lcase(dbtable)
if Selectvalue<> "" then
key = SelectValue & "%"
mySQL = MySQL & " where " & SelectField & " like '" & key & "'"
sqladd=" AND "
end if
If ucase(dbtable)="PRODUCTS" then
DoRestrictProducts MySQL, sqladd
end if
If sortfield="" then sortfield=idfield
If sortfield<>"" then
mysql=mysql & " order by " & sortfield & " " & sortupdown
end if
SetSess "sqlquery",MySQL
Setsess "sortfield",sortfield
Setsess "sortupdown",sortupdown
'response.write "generated sql=" & mysql & "
"
End sub
'
Sub DorestrictProducts (isql, sqladd)
if getconfig("XAdminRestrictProducts")<>"Yes" then exit sub
If GetSess("Admintype")="" then exit sub
If GetSess("Admintype")="SUPER" then exit sub
iSql = isql & sqladd & " userid='" & GetSess("shopadmin") & "'"
end sub
Sub GenerateTable()
dim howmanyfields
dim my_link
Dim howmanyrecs
Dim ArrayFields
Dim fieldvalue
SetSess "Table",dbtable
SetSess "Dbname",dbname
SetSess "Idfield",idfield
SetSess "Fieldcount",fieldcount
If DisplayFieldcount> 0 then
howmanyfields=DisplayFieldCount-1
ArrayFields=DisplayFields
else
howmanyfields=fieldcount-1
ArrayFields=Fieldnames
end if
'DebugWrite "fieldcount = " & fieldcount & "howmany=" & howmanyfields
if howmanyfields > maxfields then
howmanyfields = maxfields
end if
response.write "" & LangCommonPage & mypage & LangCommonOf & maxpages & ""
response.write "