%
'This code is copyright (c) Internet Business Solutions SL, all rights reserved.
'The contents of this file are protect under law as the intellectual property
'of Internet Business Solutions SL. Any use, reproduction, disclosure or copying
'of any kind without the express and written permission of Internet Business
'Solutions SL is forbidden.
'Author: Vince Reid, vince@virtualred.net
if storesessionvalue="" then storesessionvalue="virtualstore"
if Session("loggedon") <> storesessionvalue OR disallowlogin=TRUE then response.end
Dim sSQL,rs,alldata,alladmin,success,cnn,rowcounter,errmsg
success=true
maxcatsperpage = 100
if maxloginlevels="" then maxloginlevels=5
Set rs = Server.CreateObject("ADODB.RecordSet")
Set rsCats = Server.CreateObject("ADODB.RecordSet")
Set cnn=Server.CreateObject("ADODB.Connection")
cnn.open sDSN
alreadygotadmin = getadminsettings()
sSQL = ""
if request.form("act")="changepos" then
currentorder = Int(Request.Form("selectedq"))
neworder = Int(Request.Form("newval"))
sSQL = "SELECT sectionID FROM sections ORDER BY sectionOrder"
rs.Open sSQL,cnn,0,1
alldata=rs.getrows
rs.Close
FOR rowcounter=0 TO ubound(alldata,2)
theorder = rowcounter+1
if currentorder = theorder then
theorder = neworder
elseif (currentorder > theorder) AND (neworder <= theorder) then
theorder = theorder + 1
elseif (currentorder < theorder) AND (neworder >= theorder) then
theorder = theorder - 1
end if
sSQL="UPDATE sections SET sectionOrder="&theorder&" WHERE sectionID="&alldata(0,rowcounter)
cnn.Execute(sSQL)
NEXT
response.write ""
elseif request.form("posted")="1" then
if request.form("act")="delete" then
sSQL = "DELETE FROM cpnassign WHERE cpaType=1 AND cpaAssignment='"&request.form("id")&"'"
cnn.Execute(sSQL)
sSQL = "DELETE FROM sections WHERE sectionID=" & request.form("id")
cnn.Execute(sSQL)
sSQL = "DELETE FROM multisections WHERE pSection=" & request.form("id")
cnn.Execute(sSQL)
response.write ""
elseif request.form("act")="domodify" then
sSQL = "UPDATE sections SET sectionName='"&Trim(replace(request.form("secname"),"'","''"))&"',sectionDescription='"&replace(request.form("secdesc"),"'","''")&"',sectionImage='"&replace(request.form("secimage"),"'","''")&"',topSection="&request.form("tsTopSection")&",rootSection="&request.form("catfunction")
workname = Trim(replace(request.form("secworkname"),"'","''"))
if workname<>"" then
sSQL = sSQL & ",sectionWorkingName='"&workname&"'"
else
sSQL = sSQL & ",sectionWorkingName='"&Trim(replace(request.form("secname"),"'","''"))&"'"
end if
for index=2 to adminlanguages+1
if (adminlangsettings AND 256)=256 then
sSQL = sSQL & ",sectionName" & index & "='"&Trim(replace(request.form("secname" & index),"'","''"))&"'"
end if
if (adminlangsettings AND 512)=512 then
sSQL = sSQL & ",sectionDescription" & index & "='"&Trim(replace(request.form("secdesc" & index),"'","''"))&"'"
end if
next
sSQL = sSQL & ",sectionDisabled=" & trim(request.form("sectionDisabled"))
sSQL = sSQL & ",sectionurl='" & replace(trim(request.form("sectionurl")),"'","''") & "'"
sSQL = sSQL & " WHERE sectionID="&Request.Form("id")
cnn.Execute(sSQL)
response.write ""
elseif request.form("act")="doaddnew" then
sSQL = "SELECT MAX(sectionOrder) AS mxOrder FROM sections"
rs.Open sSQL,cnn,0,1
mxOrder = rs("mxOrder")
rs.Close
if IsNull(mxOrder) OR mxOrder="" then mxOrder=1 else mxOrder=mxOrder+1
sSQL = "INSERT INTO sections (sectionName,sectionDescription,sectionImage,sectionOrder,topSection,rootSection,sectionWorkingName"
for index=2 to adminlanguages+1
if (adminlangsettings AND 256)=256 then
sSQL = sSQL & ",sectionName" & index
end if
if (adminlangsettings AND 512)=512 then
sSQL = sSQL & ",sectionDescription" & index
end if
next
sSQL = sSQL & ",sectionDisabled,sectionurl) VALUES ('"&Trim(replace(request.form("secname"),"'","''"))&"','"&replace(request.form("secdesc"),"'","''")&"','"&replace(request.form("secimage"),"'","''")&"',"&mxOrder&","&request.form("tsTopSection")&","&request.form("catfunction")
workname = Trim(replace(request.form("secworkname"),"'","''"))
if workname<>"" then
sSQL = sSQL & ",'"&workname&"'"
else
sSQL = sSQL & ",'"&Trim(replace(request.form("secname"),"'","''"))&"'"
end if
for index=2 to adminlanguages+1
if (adminlangsettings AND 256)=256 then
sSQL = sSQL & ",'"&Trim(replace(request.form("secname" & index),"'","''"))&"'"
end if
if (adminlangsettings AND 512)=512 then
sSQL = sSQL & ",'"&Trim(replace(request.form("secdesc" & index),"'","''"))&"'"
end if
next
sSQL = sSQL & "," & trim(request.form("sectionDisabled"))
sSQL = sSQL & ",'" & replace(trim(request.form("sectionurl")),"'","''") & "')"
cnn.Execute(sSQL)
response.write ""
elseif request.form("act")="dodiscounts" then
sSQL = "INSERT INTO cpnassign (cpaCpnID,cpaType,cpaAssignment) VALUES ("&request.form("assdisc")&",1,'"&request.form("id")&"')"
cnn.Execute(sSQL)
response.write ""
elseif request.form("act")="deletedisc" then
sSQL = "DELETE FROM cpnassign WHERE cpaID="&request.form("id")
cnn.Execute(sSQL)
response.write ""
end if
end if
%>
<% if request.form("posted")="1" AND (request.form("act")="modify" OR request.form("act")="addnew") then
alltopsections=""
if request.form("act")="modify" then
sSQL = "SELECT sectionID,sectionName,sectionName2,sectionName3,rootSection,sectionImage,sectionWorkingName,topSection,sectionDisabled,sectionurl,sectionDescription FROM sections WHERE sectionID="&Request.Form("id")
rs.Open sSQL,cnn,0,1
sectionID = rs("sectionID")
sectionName = rs("sectionName")
sectionName2 = rs("sectionName2")
sectionName3 = rs("sectionName3")
rootSection = rs("rootSection")
sectionImage = rs("sectionImage")
sectionWorkingName = rs("sectionWorkingName")
topSection = rs("topSection")
sectionDisabled = rs("sectionDisabled")
sectionurl = rs("sectionurl")&""
sectionDescription = rs("sectionDescription")
rs.Close
else
sectionID = ""
sectionName = ""
sectionName2 = ""
sectionName3 = ""
rootSection = 1
sectionImage = ""
sectionWorkingName = ""
topSection = 0
sectionDisabled = 0
sectionurl = ""
sectionDescription = ""
end if
sSQL = "SELECT sectionID,sectionWorkingName FROM sections WHERE rootSection=0 ORDER BY sectionWorkingName"
rs.Open sSQL,cnn,0,1
if NOT rs.EOF then
alltopsections=rs.getrows
end if
rs.Close
%>
<% elseif request.form("act")="discounts" then
sSQL = "SELECT sectionName FROM sections WHERE sectionID="&request.form("id")
rs.Open sSQL,cnn,0,1
thisname=rs("sectionName")
rs.Close
alldata=""
sSQL = "SELECT cpaID,cpaCpnID,cpnWorkingName,cpnSitewide,cpnEndDate,cpnType FROM cpnassign INNER JOIN coupons ON cpnassign.cpaCpnID=coupons.cpnID WHERE cpaType=1 AND cpaAssignment='" & request.form("id") & "'"
rs.Open sSQL,cnn,0,1
if NOT rs.EOF then alldata=rs.GetRows
rs.Close
alldata2=""
tdt = Date()
sSQL = "SELECT cpnID,cpnWorkingName,cpnSitewide FROM coupons WHERE (cpnSitewide=0 OR cpnSitewide=3) AND cpnEndDate >="&datedelim&VSUSDate(tdt)&datedelim
rs.Open sSQL,cnn,0,1
if NOT rs.EOF then alldata2=rs.GetRows
rs.Close
%>
<% else
function writeposition(currpos,maxpos)
Dim reqtext,i
reqtext=""
end function
allcoupon=""
sSQL = "SELECT DISTINCT cpaAssignment FROM cpnassign WHERE cpaType=1"
rs.Open sSQL,cnn,0,1
if NOT rs.EOF then allcoupon=rs.getrows
rs.Close
%>
<% end if
cnn.Close
set rs = nothing
set rsCats = nothing
set cnn = nothing
%>