%
'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,success,cnn,rowcounter,allsections,alloptions,errmsg,prodoptions,lasttsid,dorefresh
success=true
Set rs = Server.CreateObject("ADODB.RecordSet")
Set rs2 = Server.CreateObject("ADODB.RecordSet")
Set cnn=Server.CreateObject("ADODB.Connection")
cnn.open sDSN
alreadygotadmin = getadminsettings()
Session.LCID=1033
simpleOptions = (adminTweaks AND 2)=2
simpleSections = (adminTweaks AND 4)=4
if maxprodsects="" then maxprodsects=20
dorefresh=FALSE
if request.form("posted")="1" then
pExemptions=0
if Trim(request.form("pExemptions"))<>"" then
pExemptArray=Split(request.form("pExemptions"), ",")
for each pExemptObj in pExemptArray
pExemptions = pExemptions + pExemptObj
next
end if
if request.form("act")="delete" then
sSQL = "DELETE FROM pricebreaks WHERE pbProdID='"&request.form("id")&"'"
cnn.Execute(sSQL)
sSQL = "DELETE FROM cpnassign WHERE cpaType=2 AND cpaAssignment='"&request.form("id")&"'"
cnn.Execute(sSQL)
sSQL = "DELETE FROM products WHERE pID='" & request.form("id")&"'"
cnn.Execute(sSQL)
sSQL = "DELETE FROM prodoptions WHERE poProdID='" & request.form("id")&"'"
cnn.Execute(sSQL)
sSQL = "DELETE FROM multisections WHERE pID='" & request.form("id")&"'"
cnn.Execute(sSQL)
dorefresh=TRUE
elseif request.form("act")="domodify" then
if Trim(Request.Form("newid")) <> Trim(Request.Form("id")) then
sSQL = "SELECT * FROM products WHERE pID='"&Trim(request.form("newID"))&"'"
rs.Open sSQL,cnn,0,1
success = rs.EOF
rs.Close
if success then
cnn.Execute("UPDATE pricebreaks SET pbProdID='"&request.form("newid")&"' WHERE pbProdID='"&request.form("id")&"'")
cnn.Execute("UPDATE cpnassign SET cpaAssignment='"&request.form("newid")&"' WHERE cpaType=2 AND cpaAssignment='"&request.form("id")&"'")
end if
end if
if success then
sSQL = "UPDATE products SET " & _
"pID='"& Trim(Request.Form("newid")) &"', " & _
"pName='"& Replace(Trim(Request.Form("pName")),"'","''") &"', " & _
"pSection="& Trim(Request.Form("pSection")) &", " & _
"pDropship="& Trim(Request.Form("pDropship")) &", " & _
"pExemptions="& pExemptions &", " & _
"pDescription='"& Replace(Trim(Request.Form("pDescription")),"'","''") &"', " & _
"pImage='"& Replace(Trim(Request.Form("pImage")),"'","''") &"', " & _
"pLongDescription='"& Replace(Trim(Request.Form("pLongDescription")),"'","''") &"', "
for index=2 to adminlanguages+1
if (adminlangsettings AND 1)=1 then sSQL = sSQL & "pName"&index&"='"& Replace(Trim(Request.Form("pName"&index)),"'","''") &"', "
if (adminlangsettings AND 2)=2 then sSQL = sSQL & "pDescription"&index&"='"& Replace(Trim(Request.Form("pDescription"&index)),"'","''") &"', "
if (adminlangsettings AND 4)=4 then sSQL = sSQL & "pLongDescription"&index&"='"& Replace(Trim(Request.Form("pLongDescription"&index)),"'","''") &"', "
next
sSQL = sSQL & "pLargeImage='"& Replace(Trim(Request.Form("pLargeImage")),"'","''") &"', "
if Trim(Request.Form("pDisplay")) = "ON" then
sSQL = sSQL & "pDisplay=1,"
else
sSQL = sSQL & "pDisplay=0,"
end if
if perproducttaxrate=true then
sSQL = sSQL & "pTax=" & Trim(Request.Form("pTax")) & ","
end if
if stockManage<>0 AND IsNumeric(Trim(request.form("inStock"))) then
sSQL = sSQL & "pInStock=" & Trim(request.form("inStock"))&","
end if
if Trim(Request.Form("pSell")) = "ON" then pSell=1 else pSell=0
if Trim(Request.Form("stockOptions")) = "1" then pSell=pSell+2
if Trim(Request.Form("staticpage")) = "1" then pSell=pSell+4
sSQL = sSQL & "pSell=" & pSell & ","
if productdimensions=true then
sSQL = sSQL & "pDims='" & Trim(request.form("plen")) & "x" & Trim(request.form("pwid")) & "x" & Trim(request.form("phei")) & "',"
end if
if digidownloads=true then
sSQL = sSQL & "pDownload='" & trim(replace(request.form("pDownload"),"'","''")) & "',"
end if
if shipType=1 then
if NOT IsNumeric(Trim(request.form("pShipping"))) then
sSQL = sSQL & "pShipping=0,"
else
sSQL = sSQL & "pShipping="&Trim(request.form("pShipping"))&","
end if
if NOT IsNumeric(Trim(request.form("pShipping2"))) then
sSQL = sSQL & "pShipping2=0,"
else
sSQL = sSQL & "pShipping2="&Trim(request.form("pShipping2"))&","
end if
elseif shipType=2 OR shipType=3 OR shipType=4 OR shipType=6 then
if NOT IsNumeric(Trim(request.form("pShipping"))) then
sSQL = sSQL & "pWeight=0,"
else
sSQL = sSQL & "pWeight="&Trim(request.form("pShipping"))&","
end if
end if
if Trim(Request.Form("pWholesalePrice"))<>"" then
sSQL = sSQL & "pWholesalePrice="& Trim(Request.Form("pWholesalePrice")) &","
else
sSQL = sSQL & "pWholesalePrice=0,"
end if
if Trim(Request.Form("pListPrice"))<>"" then
sSQL = sSQL & "pListPrice="& Trim(Request.Form("pListPrice")) &","
else
sSQL = sSQL & "pListPrice=0,"
end if
sSQL = sSQL & "pPrice="& Trim(Request.Form("pPrice")) &" " & _
"WHERE pID='"&Request.Form("id")&"'"
on error resume next
cnn.Execute(sSQL)
sSQL = "DELETE FROM prodoptions WHERE poProdID='"&Request.Form("id")&"'"
cnn.Execute(sSQL)
for rowcounter=0 to maxprodopts-1
if request.form("pOption"&rowcounter)<>"" AND request.form("pOption"&rowcounter)<>0 then
sSQL = "INSERT INTO prodoptions (poProdID,poOptionGroup) VALUES ('"&Request.Form("newid")&"',"&request.form("pOption"&rowcounter)&")"
cnn.Execute(sSQL)
end if
next
sSQL = "DELETE FROM multisections WHERE pID='"&Request.Form("id")&"'"
cnn.Execute(sSQL)
for rowcounter=0 to maxprodsects-1
if request.form("pSection"&rowcounter)<>"" AND request.form("pSection"&rowcounter)<>0 AND Request.Form("pSection")<>request.form("pSection"&rowcounter) then
sSQL = "SELECT pID FROM multisections WHERE pID='" & Request.Form("newid") & "' AND pSection="&request.form("pSection"&rowcounter)
rs.Open sSQL,cnn,0,1
if rs.EOF then
sSQL = "INSERT INTO multisections (pID,pSection) VALUES ('"&Request.Form("newid")&"',"&request.form("pSection"&rowcounter)&")"
cnn.Execute(sSQL)
end if
rs.Close
end if
next
if err.number<>0 then
success=false
errmsg = "There was an error writing to the database. " & err.description
else
dorefresh=TRUE
end if
on error goto 0
else
errmsg = yyPrDup
end if
elseif request.form("act")="doaddnew" then
sSQL = "SELECT * FROM products WHERE pID='"&Trim(request.form("newID"))&"'"
rs.Open sSQL,cnn,0,1
success = rs.EOF
rs.Close
if success then
sSQL = "INSERT INTO products (pID,pName,pSection,pDropship,pExemptions,pDescription,pImage,pLongDescription,"
for index=2 to adminlanguages+1
if (adminlangsettings AND 1)=1 then sSQL = sSQL & "pName" & index & ","
if (adminlangsettings AND 2)=2 then sSQL = sSQL & "pDescription" & index & ","
if (adminlangsettings AND 4)=4 then sSQL = sSQL & "pLongDescription" & index & ","
next
sSQL = sSQL & "pLargeImage,pPrice,pWholesalePrice,pListPrice,"
if shipType=1 then sSQL = sSQL & "pShipping,pShipping2,"
sSQL = sSQL & "pDisplay,"
if perproducttaxrate=true then sSQL = sSQL & "pTax,"
if stockManage<>0 AND IsNumeric(Trim(request.form("inStock"))) then sSQL = sSQL & "pInStock,"
if productdimensions=true then sSQL = sSQL & "pDims,"
if digidownloads=true then sSQL = sSQL & "pDownload,"
sSQL = sSQL & "pSell,pWeight) VALUES (" & _
"'"&Trim(request.form("newID"))&"'," & _
"'"&replace(request.form("pName"),"'","''")&"'," & _
request.form("pSection")&"," & _
request.form("pDropship")&"," & _
pExemptions &"," & _
"'"&replace(request.form("pDescription"),"'","''")&"'," & _
"'"&replace(request.form("pImage"),"'","''")&"'," & _
"'"&replace(request.form("pLongDescription"),"'","''")&"',"
for index=2 to adminlanguages+1
if (adminlangsettings AND 1)=1 then sSQL = sSQL & "'"& Replace(Trim(Request.Form("pName"&index)),"'","''") &"',"
if (adminlangsettings AND 2)=2 then sSQL = sSQL & "'"& Replace(Trim(Request.Form("pDescription"&index)),"'","''") &"',"
if (adminlangsettings AND 4)=4 then sSQL = sSQL & "'"& Replace(Trim(Request.Form("pLongDescription"&index)),"'","''") &"',"
next
sSQL = sSQL & "'"&replace(request.form("pLargeImage"),"'","''")&"'," & _
Trim(request.form("pPrice"))&","
if Trim(request.form("pWholesalePrice"))<>"" then
sSQL = sSQL & Trim(request.form("pWholesalePrice")) & ","
else
sSQL = sSQL & "0,"
end if
if Trim(request.form("pListPrice"))<>"" then
sSQL = sSQL & Trim(request.form("pListPrice")) & ","
else
sSQL = sSQL & "0,"
end if
if shipType=1 then
if NOT IsNumeric(Trim(request.form("pShipping"))) then
sSQL = sSQL & "0,"
else
sSQL = sSQL & Trim(request.form("pShipping"))&","
end if
if NOT IsNumeric(Trim(request.form("pShipping2"))) then
sSQL = sSQL & "0,"
else
sSQL = sSQL & Trim(request.form("pShipping2"))&","
end if
end if
if Trim(Request.Form("pDisplay")) = "ON" then
sSQL = sSQL & "1,"
else
sSQL = sSQL & "0,"
end if
if perproducttaxrate=true then sSQL = sSQL & request.form("pTax") & ","
if stockManage<>0 AND IsNumeric(Trim(request.form("inStock"))) then
sSQL = sSQL & Trim(request.form("inStock"))&","
end if
if productdimensions=true then
sSQL = sSQL & "'" & Trim(request.form("plen")) & "x" & Trim(request.form("pwid")) & "x" & Trim(request.form("phei")) & "',"
end if
if digidownloads=true then
sSQL = sSQL & "'" & trim(replace(request.form("pDownload"),"'","''")) & "',"
end if
if Trim(Request.Form("pSell")) = "ON" then pSell=1 else pSell=0
if Trim(Request.Form("stockOptions")) = "1" then pSell=pSell+2
if Trim(Request.Form("staticpage")) = "1" then pSell=pSell+4
sSQL = sSQL & pSell & ","
if shipType <= 1 OR NOT IsNumeric(Trim(request.form("pShipping"))) then
sSQL = sSQL & "0"
elseif shipType=2 OR shipType=3 OR shipType=4 OR shipType=6 then
sSQL = sSQL & Trim(request.form("pShipping"))&""
else
sSQL = sSQL & Trim(request.form("pShipping"))&"."
if Int(Trim(request.form("pShipping2"))) < 10 then sSQL = sSQL & "0"
sSQL = sSQL & Trim(request.form("pShipping2"))
end if
sSQL = sSQL & ")"
on error resume next
cnn.Execute(sSQL)
for rowcounter=0 to maxprodopts-1
if request.form("pOption"&rowcounter)<>"" AND request.form("pOption"&rowcounter)<>0 then
sSQL = "INSERT INTO prodoptions (poProdID,poOptionGroup) VALUES ('"&Request.Form("newid")&"',"&request.form("pOption"&rowcounter)&")"
cnn.Execute(sSQL)
end if
next
sSQL = "DELETE FROM multisections WHERE pID='"&Request.Form("newid")&"'"
cnn.Execute(sSQL)
for rowcounter=0 to maxprodsects-1
if request.form("pSection"&rowcounter)<>"" AND request.form("pSection"&rowcounter)<>0 AND Request.Form("pSection")<>request.form("pSection"&rowcounter) then
sSQL = "SELECT pID FROM multisections WHERE pID='" & Request.Form("newid") & "' AND pSection="&request.form("pSection"&rowcounter)
rs.Open sSQL,cnn,0,1
if rs.EOF then
sSQL = "INSERT INTO multisections (pID,pSection) VALUES ('"&Request.Form("newid")&"',"&request.form("pSection"&rowcounter)&")"
cnn.Execute(sSQL)
end if
rs.Close
end if
next
if err.number<>0 then
success=false
errmsg = errmsg & err.description
else
dorefresh=TRUE
end if
on error goto 0
else
errmsg = yyPrDup
end if
elseif request.form("act")="dodiscounts" then
sSQL = "INSERT INTO cpnassign (cpaCpnID,cpaType,cpaAssignment) VALUES ("&request.form("assdisc")&",2,'"&request.form("id")&"')"
cnn.Execute(sSQL)
dorefresh=TRUE
elseif request.form("act")="deletedisc" then
sSQL = "DELETE FROM cpnassign WHERE cpaID="&request.form("id")
cnn.Execute(sSQL)
dorefresh=TRUE
end if
if request.form("act")="modify" OR request.form("act")="clone" OR request.form("act")="addnew" then
sSQL = "SELECT optGrpID, optGrpWorkingName FROM optiongroup ORDER BY optGrpWorkingName"
rs.Open sSQL,cnn,0,1
if NOT rs.EOF then alloptions=rs.getrows
rs.Close
if request.form("act")="modify" OR request.form("act")="clone" then
sSQL = "SELECT poID, poOptionGroup FROM prodoptions WHERE poProdID='"&Trim(Request.Form("id"))&"'"
rs.Open sSQL,cnn,0,1
if NOT rs.EOF then prodoptions=rs.getrows
rs.Close
sSQL = "SELECT pSection FROM multisections WHERE pID='"&Trim(Request.Form("id"))&"'"
rs.Open sSQL,cnn,0,1
if NOT rs.EOF then prodsections=rs.getrows
rs.Close
end if
sSQL = "SELECT sectionID,sectionWorkingName FROM sections WHERE rootSection=1 ORDER BY sectionWorkingName"
rs.Open sSQL,cnn,0,1
if NOT rs.EOF then allsections=rs.getrows
rs.Close
sSQL = "SELECT dsID,dsName FROM dropshipper ORDER BY dsName"
rs.Open sSQL,cnn,0,1
if NOT rs.EOF then alldropship=rs.getrows
rs.Close
end if
end if
if dorefresh then
response.write """ then
response.write "?ts=" & Trim(request.form("ts"))
elseif Trim(request.form("tt"))<>"" then
response.write "?tt=" & Trim(request.form("tt"))
end if
response.write """>"
end if
%>
<%
sub show_info()
%>
<%=yyPrEx1%>
<%=yyPrEx2%>
<%
end sub
if request.form("posted")="1" AND (request.form("act")="modify" OR request.form("act")="clone" OR request.form("act")="addnew") then
Dim pNames(10)
if request.form("act")="modify" OR request.form("act")="clone" then
doaddnew = false
sSQL = "SELECT pId,pName,pName2,pName3,pSection,pImage,pPrice,pWholesalePrice,pListPrice,pDisplay,pSell,pShipping,pShipping2,pLargeImage,pWeight,pExemptions,pInStock,pDims,pTax,pDropship,"
if digidownloads=true then sSQL = sSQL & "pDownload,"
sSQL = sSQL & "pDescription,pLongDescription FROM products WHERE pId='"&Request.Form("id")&"'"
rs.Open sSQL,cnn,0,1
pName = rs("pName")
for index=2 to adminlanguages+1
pNames(index)=rs("pName" & index)
next
pID = rs("pID")
pSection = rs("pSection")
pImage = rs("pImage")&""
pPrice = rs("pPrice")
pWholesalePrice = rs("pWholesalePrice")
pListPrice = rs("pListPrice")
pDisplay = rs("pDisplay")
pSell = rs("pSell")
pShipping = rs("pShipping")
pShipping2 = rs("pShipping2")
pLargeImage = rs("pLargeImage")&""
pWeight = rs("pWeight")
pExemptions = rs("pExemptions")
pInStock = rs("pInStock")
pDims = rs("pDims")
if digidownloads=true then pDownload = rs("pDownload")
pTax = rs("pTax")
pDropship = rs("pDropship")
pDescription = rs("pDescription")
pLongDescription = rs("pLongDescription")
rs.Close
else
doaddnew = true
pID = ""
if Trim(request.form("ts"))<>"" then pSection=Int(Trim(request.form("ts"))) else pSection = 0
pImage = "prodimages/"
pPrice = ""
pWholesalePrice = ""
pListPrice = 0
pDisplay = 1
pSell = 1
pShipping = ""
pShipping2 = ""
pLargeImage = "prodimages/"
pWeight = ""
pExemptions = 0
pInStock = ""
pDims = ""
pDownload = ""
pTax=0
pDropship = 0
pDescription = ""
pLongDescription = ""
end if
%>
<% if NOT doaddnew then %>
<% end if
elseif request.form("act")="discounts" then
sSQL = "SELECT pName FROM products WHERE pID='"&replace(request.form("id"),"'","''")&"'"
rs.Open sSQL,cnn,0,1
thisname=rs("pName")
rs.Close
alldata=""
sSQL = "SELECT cpaID,cpaCpnID,cpnWorkingName,cpnSitewide,cpnEndDate,cpnType FROM cpnassign INNER JOIN coupons ON cpnassign.cpaCpnID=coupons.cpnID WHERE cpaType=2 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 AND cpnEndDate >="&datedelim&DatePart("m",tdt) & "/" & DatePart("d",tdt) & "/" & DatePart("yyyy",tdt)&datedelim
rs.Open sSQL,cnn,0,1
if NOT rs.EOF then alldata2=rs.GetRows
rs.Close
%>
<% elseif request.form("posted")="1" AND success then %>