File: D:/web/homefly/vsadmin/inc/incprods.asp
<%
'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 Session("loggedon") <> "virtualstore" then response.end
Dim sSQL,rs,alldata,success,cnn,rowcounter,allsections,alloptions,errmsg,shipType,iPounds,iOunces,prodoptions,stockManage,adminUnits,subCats,lasttsid,dorefresh
success=true
Set rs = Server.CreateObject("ADODB.RecordSet")
Set cnn=Server.CreateObject("ADODB.Connection")
cnn.open sDSN
sSQL = "SELECT adminShipping,adminStockManage,adminUnits,adminSubCats,adminTweaks FROM admin"
rs.Open sSQL,cnn,0,1
shipType = Int(rs("adminShipping"))
stockManage = Int(rs("adminStockManage"))
adminUnits = Int(rs("adminUnits"))
subCats=(Int(rs("adminSubCats"))=1)
simpleOptions = (Int(rs("adminTweaks")) AND 2)=2
simpleSections = (Int(rs("adminTweaks")) AND 4)=4
rs.Close
if maxprodsects="" then maxprodsects=20
dorefresh=FALSE
if request.form("posted")="1" then
if request.form("act")="delete" then
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
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")) &", " & _
"pExemptions="& Trim(Request.Form("pExemptions")) &", " & _
"pDescription='"& Replace(Trim(Request.Form("pDescription")),"'","''") &"', " & _
"pImage='"& Replace(Trim(Request.Form("pImage")),"'","''") &"', " & _
"pLongDescription='"& Replace(Trim(Request.Form("pLongDescription")),"'","''") &"', " & _
"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 stockManage<>0 then
sSQL = sSQL & "pInStock=" & Trim(request.form("inStock"))&","
else
if Trim(Request.Form("pSell")) = "ON" then
sSQL = sSQL & "pSell=1,"
else
sSQL = sSQL & "pSell=0,"
end if
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=4 then
if NOT IsNumeric(Trim(request.form("pShipping"))) then
sSQL = sSQL & "pWeight=0,"
else
sSQL = sSQL & "pWeight="&Trim(request.form("pShipping"))&","
end if
elseif shipType = 3 then
sSQL = sSQL & "pWeight="&Trim(request.form("pShipping"))&"."
if Int(Trim(request.form("pShipping2"))) < 10 then sSQL = sSQL & "0"
sSQL = sSQL & Trim(request.form("pShipping2")) & ","
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.<br>" & err.description
else
dorefresh=TRUE
end if
on error goto 0
else
errmsg = "Sorry, that product reference is already in use. Please use your browser back button to return and correct the problem."
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,pExemptions,pDescription,pImage,pLongDescription,pLargeImage,pPrice,pListPrice,"
if shipType=1 then sSQL = sSQL & "pShipping,pShipping2,"
sSQL = sSQL & "pDisplay,"
if stockManage<>0 then
sSQL = sSQL & "pInStock,"
else
sSQL = sSQL & "pSell,"
end if
sSQL = sSQL & "pWeight) VALUES (" & _
"'"&Trim(request.form("newID"))&"'," & _
"'"&replace(request.form("pName"),"'","''")&"'," & _
request.form("pSection")&"," & _
request.form("pExemptions")&"," & _
"'"&replace(request.form("pDescription"),"'","''")&"'," & _
"'"&replace(request.form("pImage"),"'","''")&"'," & _
"'"&replace(request.form("pLongDescription"),"'","''")&"'," & _
"'"&replace(request.form("pLargeImage"),"'","''")&"'," & _
Trim(request.form("pPrice"))&","
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 stockManage<>0 then
sSQL = sSQL & Trim(request.form("inStock"))&","
else
if Trim(Request.Form("pSell")) = "ON" then
sSQL = sSQL & "1,"
else
sSQL = sSQL & "0,"
end if
end if
if shipType <= 1 OR NOT IsNumeric(Trim(request.form("pShipping"))) then
sSQL = sSQL & "0"
elseif shipType = 2 OR shipType=4 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 = "There was an error writing to the database.<br>"
if err.number = -2147467259 then
errmsg = errmsg & "Your database does not have write permissions."
else
errmsg = errmsg & err.description
end if
else
dorefresh=TRUE
end if
on error goto 0
else
errmsg = "Sorry, that product reference is already in use. Please use your browser back button to return and correct the problem."
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")="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" 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, sectionName FROM sections ORDER BY sectionName"
rs.Open sSQL,cnn,0,1
allsections=rs.getrows
rs.Close
end if
end if
if dorefresh then
response.write "<meta http-equiv=""refresh"" content=""3; url=adminprods.asp"
if Trim(request.form("ts"))<>"" 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
%>
<script Language="JavaScript">
<!--
var ie=(document.all != (void 0));
var ns6=(document.getElementById&&!document.all);
function formvalidator(theForm)
{
if (theForm.newid.value == "")
{
alert("Please enter a value in the field \"Reference\".");
theForm.newid.focus();
return (false);
}
if (theForm.pSection.options[theForm.pSection.selectedIndex].value == "")
{
alert("Please choose a value in \"Section\".");
theForm.pSection.focus();
return (false);
}
if (theForm.pName.value == "")
{
alert("Please enter a value in the field \"Prod Name\".");
theForm.pName.focus();
return (false);
}
if (theForm.pPrice.value == "")
{
alert("Please enter a value in the field \"Price\".");
theForm.pPrice.focus();
return (false);
}
var checkOK = "'\" ";
var checkStr = theForm.newid.value;
var allValid = true;
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j)){
allValid = false;
break;
}
}
if (!allValid)
{
alert("Please do not use quotes or spaces in the field \"Reference\".");
theForm.newid.focus();
return (false);
}
var checkOK = "0123456789.";
var checkStr = theForm.pPrice.value;
var allValid = true;
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert("Please only enter numbers and decimal points in the field \"Price\".");
theForm.pPrice.focus();
return (false);
}
var checkOK = "0123456789.";
var checkStr = theForm.pListPrice.value;
var allValid = true;
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert("Please only enter numbers and decimal points in the field \"List Price\".");
theForm.pListPrice.focus();
return (false);
}
<% if shipType=1 OR shipType=2 OR shipType=3 OR shipType=4 then %>
<% if shipType=3 then %>
var checkOK = "0123456789";
<% else %>
var checkOK = "0123456789.";
<% end if %>
var checkStr = theForm.pShipping.value;
var allValid = true;
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
<% if shipType=1 then %>
alert("Please only enter numbers and decimal points in the field \"Shipping (first item)\".");
<% elseif shipType=2 OR shipType=4 then %>
alert("Please only enter numbers and decimal points in the field \"Product Weight\".");
<% else %>
alert("Please only enter numbers in the field \"Weight (lbs)\".");
<% end if %>
theForm.pShipping.focus();
return (false);
}
<% end if %>
<% if shipType=1 then %>
var checkOK = "0123456789.";
var checkStr = theForm.pShipping2.value;
var allValid = true;
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert("Please only enter numbers and decimal points in the field \"Shipping (subsequent items)\".");
theForm.pShipping2.focus();
return (false);
}
<% end if %>
<% if stockManage<>0 then %>
if (theForm.inStock.value == "")
{
alert("Please enter a value in the field \"In Stock\".");
theForm.inStock.focus();
return (false);
}
var checkOK = "0123456789";
var checkStr = theForm.inStock.value;
var allValid = true;
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert("Please only enter numbers in the field \"In Stock\".");
theForm.inStock.focus();
return (false);
}
<% end if %>
return (true);
}
var prodOptGrpArr = new Array();
var prodSectGrpArr = new Array();
<%
rowcounter=0
if IsArray(prodoptions) then
for rowcounter=0 to UBOUND(prodoptions,2)
response.write "prodOptGrpArr["&rowcounter&"]="&prodoptions(1,rowcounter)&";"&vbCrLf
next
end if
response.write "for(ii=" & rowcounter & ";ii<" & maxprodsects & ";ii++) prodOptGrpArr[ii]=0;" & vbCrLf
rowcounter=0
if IsArray(prodsections) then
for rowcounter=0 to UBOUND(prodsections,2)
response.write "prodSectGrpArr["&rowcounter&"]="&prodsections(0,rowcounter)&";"&vbCrLf
next
end if
response.write "for(ii=" & rowcounter & ";ii<" & maxprodsects & ";ii++) prodSectGrpArr[ii]=0;" & vbCrLf
%>
function update_opts(index){
var thisOption;
if(ns6)
thisOption = document.getElementById('pOption'+index);
else
thisOption = eval('document.forms.mainform.pOption'+index);
prodOptGrpArr[index] = thisOption.options[thisOption.selectedIndex].value;
}
function update_sects(index){
var thisSection;
if(ns6)
thisSection = document.getElementById('pSection'+index);
else
thisSection = eval('document.forms.mainform.pSection'+index);
prodSectGrpArr[index] = thisSection.options[thisSection.selectedIndex].value;
}
function setprodoptions(){
var noOpts = document.forms.mainform.pNumOptions.selectedIndex;
var theElm;
var theHTMLHead,theHTML="";
var index=0;
if(ns6)
theElm = document.getElementById('prodoptions');
else
theElm = document.all.prodoptions;
theHTMLHead = '<table width="100%" border="0" cellspacing="0" cellpadding="3">';
theHTML = theHTML + '<select size="1" id="pOptionGGREPLACEMExx" name="pOptionGGREPLACEMExx" onChange="update_opts(GGREPLACEMExx);"><option value="0">None</option>';
<% if IsArray(alloptions) then
for rowcounter=0 to UBOUND(alloptions,2)
response.write "theHTML = theHTML +'<option value="""&alloptions(0,rowcounter)&""">"&replace(alloptions(1,rowcounter),"'","\'")&"</option>';" & vbCrLf
next
end if %>
theHTML = theHTML + '</select>';
for (index=0;index<noOpts;index++) {
if(index % 2 == 0) theHTMLHead = theHTMLHead + '<tr>';
theHTMLHead = theHTMLHead + '<td width="25%" align="right">Prod. Option '+(index+1)+':</td><td width="25%">'+theHTML.replace(/GGREPLACEMExx/g,index)+'</td>';
if(index % 2 != 0) theHTMLHead = theHTMLHead + '</tr>';
}
if(index % 2 != 0) theHTMLHead = theHTMLHead + '<td width="50%" colspan="2"> </td></tr>';
theHTMLHead = theHTMLHead + '</table>';
theElm.innerHTML=theHTMLHead;
for (index=0;index<noOpts;index++) {
var thisOption;
if(ns6)
thisOption = document.getElementById('pOption'+index);
else
thisOption = eval('document.forms.mainform.pOption'+index);
for (index2=0;index2<thisOption.length;index2++) {
if (thisOption[index2].value==prodOptGrpArr[index]) {
thisOption.selectedIndex=index2;
thisOption.options[index2].selected = true;
}
else
thisOption.options[index2].selected = false;
}
}
}
function setprodsections(){
var noSects = document.forms.mainform.pNumSections.selectedIndex;
var theElm;
var theHTMLHead,theHTML="";
var index=0;
if(ns6)
theElm = document.getElementById('prodsections');
else
theElm = document.all.prodsections;
theHTMLHead = '<table width="100%" border="0" cellspacing="0" cellpadding="3">';
theHTML = theHTML + '<select size="1" id="pSectionGGREPLACEMExx" name="pSectionGGREPLACEMExx" onChange="update_sects(GGREPLACEMExx);"><option value="0">None</option>';
<% if IsArray(allsections) then
for rowcounter=0 to UBOUND(allsections,2)
response.write "theHTML = theHTML +'<option value="""&allsections(0,rowcounter)&""">"&replace(allsections(1,rowcounter),"'","\'")&"</option>';" & vbCrLf
next
end if %>
theHTML = theHTML + '</select>';
for (index=0;index<noSects;index++) {
if(index % 2 == 0) theHTMLHead = theHTMLHead + '<tr>';
theHTMLHead = theHTMLHead + '<td width="25%" align="right">Prod. Section '+(index+1)+':</td><td width="25%">'+theHTML.replace(/GGREPLACEMExx/g,index)+'</td>';
if(index % 2 != 0) theHTMLHead = theHTMLHead + '</tr>';
}
if(index % 2 != 0) theHTMLHead = theHTMLHead + '<td width="50%" colspan="2"> </td></tr>';
theHTMLHead = theHTMLHead + '</table>';
theElm.innerHTML=theHTMLHead;
for (index=0;index<noSects;index++) {
var thisSection;
if(ns6)
thisSection = document.getElementById('pSection'+index);
else
thisSection = eval('document.forms.mainform.pSection'+index);
for (index2=0;index2<thisSection.length;index2++) {
if (thisSection[index2].value==prodSectGrpArr[index]) {
thisSection.selectedIndex=index2;
thisSection.options[index2].selected = true;
}
else
thisSection.options[index2].selected = false;
}
}
}
//-->
</script>
<% if request.form("posted")="1" AND request.form("act")="modify" then
sSQL = "SELECT pId,pName,pSection,pImage,pPrice,pListPrice,pDisplay,pSell,pShipping,pShipping2,pLargeImage,pWeight,pExemptions,pInStock,pDescription,pLongDescription FROM products WHERE pId='"&Request.Form("id")&"'"
rs.Open sSQL,cnn,0,1
%>
<form name="mainform" method="POST" action="adminprods.asp" onSubmit="return formvalidator(this)">
<table border="0" cellspacing="0" cellpadding="0" width="100%" bgcolor="" align="center">
<tr>
<td width="100%">
<input type="hidden" name="posted" value="1">
<input type="hidden" name="act" value="domodify">
<input type="hidden" name="id" value="<%=rs("pID")%>">
<input type="hidden" name="tt" value="<%=request.form("tt")%>">
<input type="hidden" name="ts" value="<%=request.form("ts")%>">
<table width="100%" border="0" cellspacing="0" cellpadding="3" bgcolor="">
<tr>
<td width="100%" colspan="4" align="center"><br><b>Use this page to update your store products.</b><br> </td>
</tr>
<tr>
<td align="right"><font color="#FF0000">*</font>Reference:</td><td><input type="text" name="newid" size="15" value="<%=rs("pID")%>"></td>
<td align="right"><font color="#FF0000">*</font>Section:</td><td><select size="1" name="pSection"><%
for rowcounter=0 to UBOUND(allsections,2)
response.write "<option value='"&allsections(0,rowcounter)&"'"
if allsections(0,rowcounter)=rs("pSection") then response.write " selected"
response.write ">"&allsections(1,rowcounter)&"</option>" &vbCrLf
next %></select></td>
</tr>
<tr>
<td align="right"><font color="#FF0000">*</font>Prod. Name:</td><td><input type="text" name="pName" size="25" value="<%=Replace(rs("pName"),"""",""")%>"></td>
<td align="right"><font color="#FF0000">*</font>Price:</td><td><input type="text" name="pPrice" size="15" value="<%=rs("pPrice")%>"></td>
</tr>
<tr>
<td align="right">Display Product:</td><td><input type="checkbox" name="pDisplay" value="ON" <% if Int(rs("pDisplay")) <> 0 then response.write "checked" %>></td>
<% if stockManage<>0 then %>
<td align="right">In Stock:</td><td><input type="text" name="inStock" size="10" value="<%=rs("pInStock")%>"></td>
<% else %>
<td align="right">Sell Button:</td><td><input type="checkbox" name="pSell" value="ON" <% if Int(rs("pSell")) <> 0 then response.write "checked" %>></td>
<% end if %>
</tr>
<tr>
<td align="right">Image:</td><td><input type="text" name="pImage" size="25" value="<%=rs("pImage")%>"></td>
<td align="center" colspan="2"><b><%
if shipType=1 OR shipType=2 OR shipType=3 OR shipType=4 then
response.write "Shipping Information"
else
response.write " "
end if %></b></td>
</tr>
<tr>
<td width="25%" align="right">Large Image:</td>
<td width="25%" align="left"><input type="text" name="pLargeImage" size="25" value="<%=rs("pLargeImage")%>"></td>
<td width="25%" align="right"><%
if shipType=1 then
response.write "Shipping:<br>(first item)"
elseif shipType=2 OR shipType=4 then
response.write "Product Weight:"
elseif shipType=3 then
response.write "Weight (lbs):"
iPounds=Int(rs("pWeight"))
iOunces=cInt((cDbl(rs("pWeight"))-cDbl(iPounds))*100)
else
response.write " "
end if
%></td>
<td width="25%" align="left"><%
if shipType=1 then
response.write "<input type=text name='pShipping' size='15' value='"&rs("pShipping")&"'>"
elseif shipType=2 OR shipType=4 then
response.write "<input type=text name='pShipping' size='15' value='"&rs("pWeight")&"'>"
elseif shipType=3 then
response.write "<input type=text name='pShipping' size='15' value='"&iPounds&"'>"
else
response.write " "
end if
%></td>
</tr>
<tr>
<% if simpleOptions then %>
<td colspan="2"> </td>
<% else %>
<td align="right"># Product Options:</td>
<td>
<select size="1" name="pNumOptions" onChange="setprodoptions();">
<option value='0'>None</option>
<% for rowcounter=1 to maxprodopts
response.write "<option value='"&rowcounter&"'>"&rowcounter&"</option>"
next %>
</select></td>
<% end if %>
<td width="25%" align="right"><%
if shipType=1 then
response.write "Shipping:<br>(subsequent items)"
elseif shipType=3 then
response.write "Weight (Oz):"
else
response.write " "
end if
%></td>
<td width="25%" align="left"><%
if shipType=1 then
response.write "<input type=text name='pShipping2' size='15' value='"&rs("pShipping2")&"'>"
elseif shipType=3 then
response.write "<select name='pShipping2' size='1'>"
for rowcounter=0 to 15
response.write "<option value='"&rowcounter&"'"
if iOunces = rowcounter then response.write " selected"
response.write ">"&rowcounter&"</option>"&vbCrLf
next
response.write "</select>"
else
response.write " "
end if
%></td>
</tr>
<% if simpleOptions then
for index=0 to maxprodopts-1
if index MOD 2=0 then response.write "<tr>"
response.write "<td align=""right"">Prod. Option " & index+1 & ":</td><td><select size=""1"" id=""pOption" & index & """ name=""pOption" & index & """><option value=""0"">None</option>"
if IsArray(alloptions) then
for rowcounter=0 to UBOUND(alloptions,2)
response.write "<option value="""&alloptions(0,rowcounter)&""""
if IsArray(prodoptions) then
if index <= UBOUND(prodoptions,2) then
if prodoptions(1,index)=alloptions(0,rowcounter) then response.write " selected"
end if
end if
response.write ">"&alloptions(1,rowcounter)&"</option>"
next
end if
response.write "</select></td>"
if index MOD 2<>0 then response.write "</tr>" & vbCrLf
next
if index MOD 2=0 then
response.write "</tr>" & vbCrLf
else
response.write "<td colspan=""2""> </td></tr>" & vbCrLf
end if
else %>
</table>
<div name="prodoptions" id="prodoptions">
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="3" bgcolor="">
<% end if %>
<tr>
<td align="right">Description:</td>
<td colspan="2"><textarea name="pDescription" cols="30" rows="5" wrap=virtual><%=rs("pDescription")%></textarea></td>
<td align="center"><p>Exemptions:<br>
<select name="pExemptions" size="1">
<option value="0">No Exemptions</option>
<option value="1" <%if rs("pExemptions")=1 then response.write "selected"%>>Tax Exempt</option>
<option value="2" <%if rs("pExemptions")=2 then response.write "selected"%>>Shipping Exempt</option>
<option value="3" <%if rs("pExemptions")=3 then response.write "selected"%>>Tax and Shipping Exempt</option>
</select></p>
<p>List Price (optional):<br>
<input type="text" name="pListPrice" size="15" value="<% if cDbl(rs("pListPrice"))<>0.0 then response.write rs("pListPrice") %>"></p>
</td>
</tr>
<tr>
<td width="25%" align="right">Long Description:</td>
<td colspan="3" align="left"><textarea name="pLongDescription" cols="45" rows="6" wrap=virtual><%=rs("pLongDescription")%></textarea></td>
</tr>
<tr>
<td width="25%" align="right"><strong>Additional Sections:</strong></td>
<td colspan="4" align="left">
<% if NOT simpleSections then %>
<select size="1" name="pNumSections" onChange="setprodsections();">
<option value='0'>None</option>
<% for rowcounter=1 to maxprodsects
response.write "<option value='"&rowcounter&"'>"&rowcounter&"</option>"
next %>
</select>
<% end if %> </td>
</tr>
<% if simpleSections then
for index=0 to maxprodsects-1
if index MOD 2=0 then response.write "<tr>"
response.write "<td align=""right"">Prod. Section " & index+1 & ":</td><td><select size=""1"" id=""pSection" & index & """ name=""pSection" & index & """><option value=""0"">None</option>"
if IsArray(allsections) then
for rowcounter=0 to UBOUND(allsections,2)
response.write "<option value="""&allsections(0,rowcounter)&""""
if IsArray(prodsections) then
if index <= UBOUND(prodsections,2) then
if prodsections(0,index)=allsections(0,rowcounter) then response.write " selected"
end if
end if
response.write ">"&allsections(1,rowcounter)&"</option>"
next
end if
response.write "</select></td>"
if index MOD 2<>0 then response.write "</tr>" & vbCrLf
next
if index MOD 2=0 then
response.write "</tr>" & vbCrLf
else
response.write "<td colspan=""2""> </td></tr>" & vbCrLf
end if
else %>
</table>
<div name="prodsections" id="prodsections">
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="3" bgcolor="">
<% end if %>
<tr>
<td width="100%" colspan="4" align="center">
<p><input type="submit" value="Submit"> <input type="reset" value="Reset"><br> </p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<%
rs.Close
%>
<script Language="JavaScript">
<!--
<% if NOT simpleOptions then %>
document.forms.mainform.pNumOptions.selectedIndex=<% if IsArray(prodoptions) then response.write (UBOUND(prodoptions,2)+1) else response.write "0" %>;
document.forms.mainform.pNumOptions.options[<% if IsArray(prodoptions) then response.write (UBOUND(prodoptions,2)+1) else response.write "0" %>].selected = true;
setprodoptions();
<% end if
if NOT simpleSections then %>
document.forms.mainform.pNumSections.selectedIndex=<% if IsArray(prodsections) then response.write (UBOUND(prodsections,2)+1) else response.write "0" %>;
document.forms.mainform.pNumSections.options[<% if IsArray(prodsections) then response.write (UBOUND(prodsections,2)+1) else response.write "0" %>].selected = true;
setprodsections();
<% end if %>
//-->
</script>
<% elseif request.form("posted")="1" AND request.form("act")="addnew" then %>
<form name="mainform" method="POST" action="adminprods.asp" onSubmit="return formvalidator(this)">
<table border="0" cellspacing="0" cellpadding="0" width="100%" bgcolor="" align="center">
<tr>
<td width="100%">
<input type="hidden" name="posted" value="1">
<input type="hidden" name="act" value="doaddnew">
<input type="hidden" name="tt" value="<%=request.form("tt")%>">
<input type="hidden" name="ts" value="<%=request.form("ts")%>">
<table width="100%" border="0" cellspacing="0" cellpadding="3" bgcolor="">
<tr>
<td width="100%" colspan="4" align="center"><br><b>Use this page to update your store products.</b><br> </td>
</tr>
<tr>
<td align="right"><font color="#FF0000">*</font>Reference:</td><td><input type=text name="newid" size="15" value="" maxlength="50"></td>
<td align="right"><font color="#FF0000">*</font>Section:</td><td><select size="1" name="pSection"><option value="">Please Select</option><%
if IsArray(allsections) then
Dim secid
secid=0
if Trim(request.form("ts"))<>"" then secid=Int(Trim(request.form("ts")))
for rowcounter=0 to UBOUND(allsections,2)
response.write "<option value='"&allsections(0,rowcounter)&"'"
if secid=allsections(0,rowcounter) then response.write " selected"
response.write ">"&allsections(1,rowcounter)&"</option>" &vbCrLf
next
end if %></select></td>
</tr>
<tr>
<td align="right"><font color="#FF0000">*</font>Prod. Name:</td><td><input type=text name="pName" size="25" value="" maxlength="75"></td>
<td align="right"><font color="#FF0000">*</font>Price:</td><td><input type=text name="pPrice" size="15"></td>
</tr>
<tr>
<td align="right">Display Product:</td><td><input type=checkbox name="pDisplay" value="ON" checked></td>
<% if stockManage<>0 then %>
<td align="right">In Stock:</td><td><input type="text" name="inStock" size="10" value="0"></td>
<% else %>
<td align="right">Sell Button:</td><td><input type=checkbox name="pSell" value="ON" checked></td>
<% end if %>
</tr>
<tr>
<td align="right">Image:</td><td><input type=text name="pImage" size="25" value="prodimages/"></td>
<td align="center" colspan="2"><b><%
if shipType=1 OR shipType=2 OR shipType=3 OR shipType=4 then
response.write "Shipping Information"
else
response.write " "
end if %></b></td>
</tr>
<tr>
<td width="25%" align="right">Large Image:</td>
<td width="25%" align="left"><input type=text name="pLargeImage" size="25" value="prodimages/"></td>
<td width="25%" align="right"><%
if shipType=1 then
response.write "Shipping:<br>(first item)"
elseif shipType=2 OR shipType=4 then
response.write "Product Weight:"
elseif shipType=3 then
response.write "Weight (lbs):"
else
response.write " "
end if
%></td>
<td width="25%" align="left"><%
if shipType=1 OR shipType=2 OR shipType=3 OR shipType=4 then
response.write "<input type=text name='pShipping' size='15' value='0'>"
else
response.write " "
end if
%></td>
</tr>
<tr>
<% if simpleOptions then %>
<td colspan="2"> </td>
<% else %>
<td align="right"># Product Options:</td>
<td>
<select size="1" name="pNumOptions" onChange="setprodoptions();">
<option value='0'>None</option>
<% for rowcounter=1 to maxprodopts
response.write "<option value='"&rowcounter&"'>"&rowcounter&"</option>"
next %>
</select></td>
<% end if %>
<td width="25%" align="right"><%
if shipType=1 then
response.write "Shipping:<br>(subsequent items)"
elseif shipType=3 then
response.write "Weight (Oz):"
else
response.write " "
end if
%></td>
<td width="25%" align="left"><%
if shipType=1 then
response.write "<input type=text name='pShipping2' size='15' value='0'>"
elseif shipType=3 then
response.write "<select name='pShipping2' size='1'>"
for rowcounter=0 to 15
response.write "<option value='"&rowcounter&"'"
response.write ">"&rowcounter&"</option>"&vbCrLf
next
response.write "</select>"
else
response.write " "
end if
%></td>
</tr>
<% if simpleOptions then
for index=0 to maxprodopts-1
if index MOD 2=0 then response.write "<tr>"
response.write "<td align=""right"">Prod. Option " & index+1 & ":</td><td><select size=""1"" id=""pOption" & index & """ name=""pOption" & index & """><option value=""0"">None</option>"
if IsArray(alloptions) then
for rowcounter=0 to UBOUND(alloptions,2)
response.write "<option value="""&alloptions(0,rowcounter)&""""
if IsArray(prodoptions) then
if index <= UBOUND(prodoptions,2) then
if prodoptions(1,index)=alloptions(0,rowcounter) then response.write " selected"
end if
end if
response.write ">"&alloptions(1,rowcounter)&"</option>"
next
end if
response.write "</select></td>"
if index MOD 2<>0 then response.write "</tr>" & vbCrLf
next
if index MOD 2=0 then
response.write "</tr>" & vbCrLf
else
response.write "<td colspan=""2""> </td></tr>" & vbCrLf
end if
else %>
</table>
<div name="prodoptions" id="prodoptions">
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="3" bgcolor="">
<% end if %>
<tr>
<td align="right">Description:</td>
<td colspan="2"><textarea name="pDescription" cols="30" rows="4" wrap=virtual></textarea></td>
<td align="center"><p>Exemptions:<br>
<select name="pExemptions" size="1">
<option value="0">No Exemptions</option>
<option value="1">Tax Exempt</option>
<option value="2">Shipping Exempt</option>
<option value="3">Tax and Shipping Exempt</option>
</select></p>
<p>List Price (optional):<br>
<input type="text" name="pListPrice" size="15" value=""></p>
</td>
</tr>
<tr>
<td width="25%" align="right">Long Description:</td>
<td colspan="3" align="left"><textarea name="pLongDescription" cols="45" rows="6" wrap=virtual></textarea></td>
</tr>
<tr>
<td width="25%" align="right"><strong>Additional Sections:</strong></td>
<td colspan="4" align="left">
<% if NOT simpleSections then %>
<select size="1" name="pNumSections" onChange="setprodsections();">
<option value='0'>None</option>
<% for rowcounter=1 to maxprodsects
response.write "<option value='"&rowcounter&"'>"&rowcounter&"</option>"
next %>
</select>
<% end if %> </td>
</tr>
<% if simpleSections then
for index=0 to maxprodsects-1
if index MOD 2=0 then response.write "<tr>"
response.write "<td align=""right"">Prod. Section " & index+1 & ":</td><td><select size=""1"" id=""pSection" & index & """ name=""pSection" & index & """><option value=""0"">None</option>"
if IsArray(allsections) then
for rowcounter=0 to UBOUND(allsections,2)
response.write "<option value="""&allsections(0,rowcounter)&""""
response.write ">"&allsections(1,rowcounter)&"</option>"
next
end if
response.write "</select></td>"
if index MOD 2<>0 then response.write "</tr>" & vbCrLf
next
if index MOD 2=0 then
response.write "</tr>" & vbCrLf
else
response.write "<td colspan=""2""> </td></tr>" & vbCrLf
end if
else %>
</table>
<div name="prodsections" id="prodsections">
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="3" bgcolor="">
<% end if %>
<tr>
<td width="100%" colspan="4" align="center">
<p><input type="submit" value="Submit"> <input type="reset" value="Reset"><br> </p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<% 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
%>
<script language="JavaScript">
<!--
function delrec(id) {
cmsg = "Sure you want to delete this assignment?\n"
if (confirm(cmsg)) {
document.mainform.id.value = id;
document.mainform.act.value = "deletedisc";
document.mainform.submit();
}
}
// -->
</script>
<tr>
<form name="mainform" method="POST" action="adminprods.asp">
<td width="100%">
<input type="hidden" name="posted" value="1">
<input type="hidden" name="act" value="dodiscounts">
<input type="hidden" name="id" value="<%=request.form("id")%>">
<input type="hidden" name="tt" value="<%=request.form("tt")%>">
<input type="hidden" name="ts" value="<%=request.form("ts")%>">
<table width="100%" border="0" cellspacing="0" cellpadding="3" bgcolor="">
<tr>
<td width="100%" colspan="4" align="center"><b>Assign Discounts to Product "<%=thisname%>".</b><br> </td>
</tr>
<% gotone=false
if IsArray(alldata2) then
thestr = "<tr><td colspan='4' align='center'>Assign Discount / Coupon: <select name='assdisc' size='1'>"
for index=0 to UBOUND(alldata2,2)
alreadyassign=false
if IsArray(alldata) then
for index2=0 to UBOUND(alldata,2)
if alldata2(0,index)=alldata(1,index2) then alreadyassign=true
next
end if
if NOT alreadyassign then
thestr = thestr & "<option value='"&alldata2(0,index)&"'>"&alldata2(1,index)&"</option>" & vbCrLf
gotone=true
end if
next
thestr = thestr & "</select> <input type='submit' value='Go'></td></tr>"
end if
if gotone then
response.write thestr
else
%>
<tr>
<td width="100%" colspan="4" align="center"><br><b>No coupons / discounts are available to assign</td>
</tr>
<%
end if
if IsArray(alldata) then
%>
<tr>
<td width="100%" colspan="4" align="center"><br><b>Discounts currently assigned to "<%=thisname%>".</b><br> </td>
</tr>
<tr>
<td><b>Working Name</b></td>
<td><b>Discount Type</b></td>
<td><b>Expires</b></td>
<td align="center"><b>Delete</b></td>
</tr>
<%
for index=0 to UBOUND(alldata,2)
prefont = ""
postfont = ""
if alldata(3,index)=1 OR alldata(4,index)-Date() < 0 then
prefont = "<font color=""#FF0000"">"
postfont = "</font>"
end if
%>
<tr>
<td><%=prefont & alldata(2,index) & postfont %></td>
<td><% if alldata(5,index)=0 then
response.write prefont & "Free Standard Shipping" & postfont
elseif alldata(5,index)=1 then
response.write prefont & "Flat Rate Discount" & postfont
elseif alldata(5,index)=2 then
response.write prefont & "Percentage Discount" & postfont
end if %></td>
<td><%=prefont & alldata(4,index) & postfont%></td>
<td align="center"><input type="button" name="discount" value="Delete Assignment" onClick="delrec('<%=alldata(0,index)%>')"></td>
</tr>
<%
next
else
%>
<tr>
<td width="100%" colspan="4" align="center"><br><b>No coupons / discounts currently assigned</td>
</tr>
<%
end if
%>
<tr>
<td width="100%" colspan="4" align="center"><br> </td>
</tr>
<tr>
<td width="100%" colspan="4" align="center"><br>
<a href="admin.asp"><b>Admin Home</b></a><br>
</td>
</tr>
</table></td>
</form>
</tr>
<% elseif request.form("posted")="1" AND success then %>
<table border="0" cellspacing="0" cellpadding="0" width="100%" bgcolor="" align="center">
<tr>
<td width="100%">
<table width="100%" border="0" cellspacing="0" cellpadding="3" bgcolor="">
<tr>
<td width="100%" colspan="2" align="center"><br><b>Update Successful !</b><br><br>You will now be forwarded
to the products admin page.<br><br>
If that does not happen automatically then please <A href="adminprods.asp<%
if Trim(request.form("ts"))<>"" then
response.write "?ts=" & Trim(request.form("ts"))
elseif Trim(request.form("tt"))<>"" then
response.write "?tt=" & Trim(request.form("tt"))
end if%>"><b>click here</b></a>.<br>
<br>
<img src="../images/clearpixel.gif" width="350" height="3">
</td>
</tr>
</table></td>
</tr>
</table>
<% elseif request.form("posted")="1" then %>
<table border="0" cellspacing="0" cellpadding="0" width="100%" bgcolor="" align="center">
<tr>
<td width="100%">
<table width="100%" border="0" cellspacing="0" cellpadding="3" bgcolor="">
<tr>
<td width="100%" colspan="2" align="center"><br><font color="#FF0000"><b>Operation Failed ! !</b></font><br><br><%=errmsg%><br><br>
<a href="javascript:history.go(-1)"><b>Click here to go back.</b></a></td>
</tr>
</table></td>
</tr>
</table>
<% elseif request.querystring("tt")<>"" OR request.querystring("ts")<>"" then %>
<script language="JavaScript">
<!--
function modrec(id) {
document.mainform.id.value = id;
document.mainform.act.value = "modify";
document.mainform.submit();
}
function newrec(id) {
document.mainform.id.value = id;
document.mainform.act.value = "addnew";
document.mainform.submit();
}
function discounts(id) {
document.mainform.id.value = id;
document.mainform.act.value = "discounts";
document.mainform.submit();
}
function delrec(id) {
cmsg = "Sure you want to delete this record?\n"
if (confirm(cmsg)) {
document.mainform.id.value = id;
document.mainform.act.value = "delete";
document.mainform.submit();
}
}
// -->
</script>
<table border="0" cellspacing="0" cellpadding="0" width="100%" bgcolor="" align="center">
<tr>
<form name="mainform" method="POST" action="adminprods.asp">
<td width="100%">
<input type="hidden" name="posted" value="1">
<input type="hidden" name="act" value="xxxxx">
<input type="hidden" name="id" value="xxxxx">
<input type="hidden" name="tt" value="<%=request.querystring("tt")%>">
<input type="hidden" name="ts" value="<%=request.querystring("ts")%>">
<table width="100%" border="0" cellspacing="0" cellpadding="2" bgcolor="">
<tr>
<td width="100%" colspan="5" align="center"><br><b>Use this page to update your store products</b> <input type="button" value="New Product" onClick="newrec()"><br> </td>
</tr>
<tr>
<td><b>Product ID</b></td>
<td><b>Product Name</b></td>
<td width="8%" align="center"><b>Discounts</b></td>
<td width="8%" align="center"><b>Modify</b></td>
<td width="8%" align="center"><b>Delete</b></td>
</tr>
<%
if stockManage<>0 then
sSQL = "SELECT pID,pName,pDisplay,pInStock FROM products LEFT OUTER JOIN sections ON products.pSection=sections.sectionID "
else
sSQL = "SELECT pID,pName,pDisplay,pSell FROM products LEFT OUTER JOIN sections ON products.pSection=sections.sectionID "
end if
if request.querystring("tt")="ALL" then
' Nothing
elseif request.querystring("tt")<>"" then
sSQL = sSQL & "WHERE topSection="&request.querystring("tt")
else
sSQL = sSQL & "WHERE pSection="&request.querystring("ts")
end if
sSQL = sSQL & " ORDER BY pName"
rs.Open sSQL,cnn,0,1
if NOT rs.EOF then alldata=rs.getrows
rs.Close
allcoupon=""
sSQL = "SELECT DISTINCT cpaAssignment FROM cpnAssign WHERE cpaType=2"
rs.Open sSQL,cnn,0,1
if NOT rs.EOF then allcoupon=rs.getrows
rs.Close
if isArray(alldata) then
for rowcounter=0 to UBOUND(alldata,2) %>
<tr>
<td><b><%=alldata(0,rowcounter)%></b></td>
<td><b><%
if Int(alldata(3,rowcounter)) <= 0 OR Int(alldata(2,rowcounter)) = 0 then response.write "<font color='#FF0000'>"
if Int(alldata(2,rowcounter)) = 0 then response.write "<strike>"
response.write alldata(1,rowcounter)
if Int(alldata(2,rowcounter)) = 0 then response.write "</strike>"
if Int(alldata(3,rowcounter)) <= 0 OR Int(alldata(2,rowcounter)) = 0 then response.write "</font>"
%></b><% if stockManage>0 then response.write " (" & alldata(3,rowcounter) & ")"%></td>
<td><input <%
if IsArray(allcoupon) then
for index=0 to UBOUND(allcoupon,2)
if Trim(allcoupon(0,index))=alldata(0,rowcounter) then
response.write "style=""color: #FF0000"""
exit for
end if
next
end if
%> type="button" name="discount" value="Assign" onClick="discounts('<%=replace(replace(alldata(0,rowcounter),"\","\\"),"'","\'")%>')"></td>
<td><input type=button name=modify value="Modify" onClick="modrec('<%=replace(replace(alldata(0,rowcounter),"\","\\"),"'","\'")%>')"></td>
<td><input type=button name=delete value="Delete" onClick="delrec('<%=replace(replace(alldata(0,rowcounter),"\","\\"),"'","\'")%>')"></td>
</tr>
<%
next
else
%>
<tr>
<td width="100%" colspan="5" align="center"><br>There are currently no products in this section.<br> </td>
</tr>
<%
end if
%>
<tr>
<td width="100%" colspan="5" align="center"><br><b>Click here to add a new product</b> <input type="button" value="New Product" onClick="newrec()"><br> </td>
</tr>
<tr>
<td width="100%" colspan="5" align="center"><br>
<a href="admin.asp"><b>Admin Home</b></a><br>
<img src="../images/clearpixel.gif" width="350" height="3"></td>
</tr>
</table></td>
</form>
</tr>
</table>
<% else %>
<script language="JavaScript">
<!--
function modrec(id){
document.mainform.action="adminprods.asp";
document.mainform.id.value = id;
document.mainform.act.value = "modify";
document.mainform.submit();
}
function newrec(id){
document.mainform.action="adminprods.asp";
document.mainform.id.value = id;
document.mainform.act.value = "addnew";
document.mainform.submit();
}
function dumpinventory(){
document.mainform.action="dumporders.asp";
document.mainform.act.value = "dumpinventory";
document.mainform.submit();
}
function delrec(id){
cmsg = "Sure you want to delete this record?\n"
if (confirm(cmsg)){
document.mainform.action="adminprods.asp";
document.mainform.id.value = id;
document.mainform.act.value = "delete";
document.mainform.submit();
}
}
// -->
</script>
<table border="0" cellspacing="0" cellpadding="0" width="100%" bgcolor="" align="center">
<tr>
<form name="mainform" method="POST" action="adminprods.asp">
<td width="100%">
<input type="hidden" name="posted" value="1">
<input type="hidden" name="act" value="xxxxx">
<input type="hidden" name="id" value="xxxxx">
<table width="100%" border="0" cellspacing="0" cellpadding="3" bgcolor="">
<tr>
<td width="100%" colspan="4" align="center"><br><b>Please click on a category or sub category to list products in that section.</b><br> </td>
</tr>
<tr>
<td colspan='4'><input type="button" value="New Product" onClick="newrec()"> <b><a href="adminprods.asp?tt=ALL">Show all products in all sections</a></td>
</tr>
<%
if subCats then
sSQL = "SELECT DISTINCT sectionID,sectionName,tsID,tsName FROM topsections INNER JOIN sections ON sections.topSection=topsections.tsID ORDER BY tsName,sectionName"
else
sSQL = "SELECT DISTINCT sectionID,sectionName FROM sections INNER JOIN products ON sections.sectionID=products.pSection ORDER BY sectionName"
end if
rs.Open sSQL,cnn,0,1
if rs.eof or rs.bof then
success=false
else
alldata=rs.getrows
success=true
end if
rs.Close
if IsArray(alldata) then
FOR rowcounter=0 TO ubound(alldata,2)
if subCats then
if lasttsid <> alldata(2,rowcounter) then
lasttsid = alldata(2,rowcounter)
response.write "<tr><td colspan='4'><b><a href='adminprods.asp?tt="&alldata(2,rowcounter)
response.write "'>"&alldata(3,rowcounter)&"</a></b></td></tr>"
end if
end if
response.write "<tr><td colspan='4'><b> » <a href='adminprods.asp?ts="&alldata(0,rowcounter)&"'"
response.write ">"&alldata(1,rowcounter)&"</a></b></td></tr>"
next
end if
alldata=""
if stockManage<>0 then
%>
<tr>
<td width="100%" colspan="4" align="center"><br><b>The following products are listed as out of stock.</b><br> </td>
</tr>
<tr>
<td width="100%" colspan="4" align="center"><input type="button" value="Dump Inventory" onClick="dumpinventory()"></td>
</tr>
<%
sSQL = "SELECT pID,pName,pDisplay,pInStock FROM products WHERE pInStock<=0"
rs.Open sSQL,cnn,0,1
if NOT rs.EOF then alldata=rs.getrows
rs.Close
if isArray(alldata) then
for rowcounter=0 to UBOUND(alldata,2) %>
<tr>
<td><b><%=alldata(0,rowcounter)%></b></td>
<td><b><%
if Int(alldata(3,rowcounter)) <= 0 OR Int(alldata(2,rowcounter)) = 0 then response.write "<font color='#FF0000'>"
if Int(alldata(2,rowcounter)) = 0 then response.write "<strike>"
response.write alldata(1,rowcounter)
if Int(alldata(2,rowcounter)) = 0 then response.write "</strike>"
if Int(alldata(3,rowcounter)) <= 0 OR Int(alldata(2,rowcounter)) = 0 then response.write "</font>"
%></b></td>
<td><input type=button name=modify value="Modify" onClick="modrec('<%=replace(replace(alldata(0,rowcounter),"\","\\"),"'","\'")%>')"></td>
<td><input type=button name=delete value="Delete" onClick="delrec('<%=replace(replace(alldata(0,rowcounter),"\","\\"),"'","\'")%>')"></td>
</tr>
<%
next
else
%>
<tr>
<td width="100%" colspan="4" align="center"><br><b>There are currently no products listed as out of stock.</b><br> </td>
</tr>
<%
end if
end if
%>
<tr>
<td width="100%" colspan="4" align="center"><br><b>Click here to add a new product</b> <input type="button" value="New Product" onClick="newrec()"><br> </td>
</tr>
<tr>
<td width="100%" colspan="4" align="center"><br>
<a href="admin.asp"><b>Admin Home</b></a><br>
<img src="../images/clearpixel.gif" width="350" height="3"></td>
</tr>
</table></td>
</form>
</tr>
</table>
<% end if
cnn.Close
%>