File: D:/web/homefly/inc/incdiscounts.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,alladmin,success,cnn,rowcounter,errmsg,subCats
success=true
Set rs = Server.CreateObject("ADODB.RecordSet")
Set cnn=Server.CreateObject("ADODB.Connection")
cnn.open sDSN
sSQL="SELECT adminSubCats,countryLCID FROM admin INNER JOIN countries ON admin.adminCountry=countries.countryID WHERE adminID=1"
rs.Open sSQL,cnn,0,1
subCats=(Int(rs("adminSubCats"))=1)
if Int(rs("countryLCID"))<>0 then saveLCID = Int(rs("countryLCID")) else saveLCID = 1033
rs.Close
Session.LCID = 1033
sSQL = ""
if request.form("posted")="1" then
if request.form("act")="delete" then
sSQL = "DELETE FROM cpnAssign WHERE cpaCpnID=" & request.form("id")
cnn.Execute(sSQL)
sSQL = "DELETE FROM coupons WHERE cpnID=" & request.form("id")
cnn.Execute(sSQL)
response.write "<meta http-equiv=""refresh"" content=""3; url=admindiscounts.asp"">"
elseif request.form("act")="domodify" then
sSQL = "UPDATE coupons SET cpnWorkingName='" & replace(request.form("cpnWorkingName"),"'","''")
if request.form("cpnIsCoupon")="0" then
sSQL = sSQL & "',cpnNumber='',"
else
sSQL = sSQL & "',cpnNumber='" & replace(request.form("cpnNumber"),"'","''") & "',"
end if
sSQL = sSQL & "cpnType=" & request.form("cpnType") & ","
numdays=0
if IsNumeric(request.form("cpnEndDate")) then numdays = Int(request.form("cpnEndDate"))
if numdays > 0 then
tdt = Date() + Int(request.form("cpnEndDate"))
sSQL = sSQL & "cpnEndDate=" & datedelim & DatePart("m",tdt) & "/" & DatePart("d",tdt) & "/" & DatePart("yyyy",tdt) & datedelim & ","
else
sSQL = sSQL & "cpnEndDate=" & datedelim & "01/01/3000" & datedelim & ","
end if
if IsNumeric(request.form("cpnDiscount")) AND request.form("cpnType")<>"0" then
sSQL = sSQL & "cpnDiscount=" & request.form("cpnDiscount") & ","
else
sSQL = sSQL & "cpnDiscount=0,"
end if
if IsNumeric(request.form("cpnThreshold")) then
sSQL = sSQL & "cpnThreshold=" & request.form("cpnThreshold") & ","
else
sSQL = sSQL & "cpnThreshold=0,"
end if
if IsNumeric(request.form("cpnThresholdMax")) then
sSQL = sSQL & "cpnThresholdMax=" & request.form("cpnThresholdMax") & ","
else
sSQL = sSQL & "cpnThresholdMax=0,"
end if
if IsNumeric(request.form("cpnQuantity")) then
sSQL = sSQL & "cpnQuantity=" & request.form("cpnQuantity") & ","
else
sSQL = sSQL & "cpnQuantity=0,"
end if
if IsNumeric(request.form("cpnQuantityMax")) then
sSQL = sSQL & "cpnQuantityMax=" & request.form("cpnQuantityMax") & ","
else
sSQL = sSQL & "cpnQuantityMax=0,"
end if
if Trim(request.form("cpnNumAvail"))<>"" AND IsNumeric(request.form("cpnNumAvail")) then
sSQL = sSQL & "cpnNumAvail=" & request.form("cpnNumAvail") & ","
else
sSQL = sSQL & "cpnNumAvail=30000000,"
end if
if request.form("cpnType")="0" then
sSQL = sSQL & "cpnCntry=" & request.form("cpnCntry") &","
else
sSQL = sSQL & "cpnCntry=0,"
end if
sSQL = sSQL & "cpnIsCoupon=" & request.form("cpnIsCoupon") &","
if request.form("cpnType")="0" then
sSQL = sSQL & "cpnSitewide=1"
else
sSQL = sSQL & "cpnSitewide=" & request.form("cpnSitewide")
end if
sSQL = sSQL & " WHERE cpnID="&Request.Form("id")
cnn.Execute(sSQL)
response.write "<meta http-equiv=""refresh"" content=""3; url=admindiscounts.asp"">"
elseif request.form("act")="doaddnew" then
sSQL = "INSERT INTO coupons (cpnWorkingName,cpnNumber,cpnType,cpnEndDate,cpnDiscount,cpnThreshold,cpnThresholdMax,cpnQuantity,cpnQuantityMax,cpnNumAvail,cpnCntry,cpnIsCoupon,cpnSitewide) VALUES (" & _
"'"&replace(request.form("cpnWorkingName"),"'","''")&"',"
if request.form("cpnIsCoupon")="0" then
sSQL = sSQL & "'',"
else
sSQL = sSQL & "'"&replace(request.form("cpnNumber"),"'","''")&"',"
end if
sSQL = sSQL & request.form("cpnType") & ","
numdays=0
if IsNumeric(request.form("cpnEndDate")) then numdays = Int(request.form("cpnEndDate"))
if numdays > 0 then
tdt = Date() + Int(request.form("cpnEndDate"))
sSQL = sSQL & datedelim & DatePart("m",tdt) & "/" & DatePart("d",tdt) & "/" & DatePart("yyyy",tdt) & datedelim & ","
else
sSQL = sSQL & datedelim & "01/01/3000" & datedelim & ","
end if
if IsNumeric(request.form("cpnDiscount")) AND request.form("cpnType")<>"0" then
sSQL = sSQL & request.form("cpnDiscount") & ","
else
sSQL = sSQL & "0,"
end if
if IsNumeric(request.form("cpnThreshold")) then
sSQL = sSQL & request.form("cpnThreshold") & ","
else
sSQL = sSQL & "0,"
end if
if IsNumeric(request.form("cpnThresholdMax")) then
sSQL = sSQL & request.form("cpnThresholdMax") & ","
else
sSQL = sSQL & "0,"
end if
if IsNumeric(request.form("cpnQuantity")) then
sSQL = sSQL & request.form("cpnQuantity") & ","
else
sSQL = sSQL & "0,"
end if
if IsNumeric(request.form("cpnQuantityMax")) then
sSQL = sSQL & request.form("cpnQuantityMax") & ","
else
sSQL = sSQL & "0,"
end if
if Trim(request.form("cpnNumAvail"))<>"" AND IsNumeric(request.form("cpnNumAvail")) then
sSQL = sSQL & request.form("cpnNumAvail") & ","
else
sSQL = sSQL & "30000000,"
end if
if request.form("cpnType")="0" then
sSQL = sSQL & request.form("cpnCntry") &","
else
sSQL = sSQL & "0,"
end if
sSQL = sSQL & request.form("cpnIsCoupon") &","
if request.form("cpnType")="0" then
sSQL = sSQL & "1)"
else
sSQL = sSQL & request.form("cpnSitewide") & ")"
end if
cnn.Execute(sSQL)
response.write "<meta http-equiv=""refresh"" content=""3; url=admindiscounts.asp"">"
end if
end if
%>
<script Language="JavaScript">
<!--
var savebg, savebc, savecol;
function formvalidator(theForm)
{
if(theForm.cpnWorkingName.value == "")
{
alert("Please enter a value in the field \"Working Name\".");
theForm.cpnWorkingName.focus();
return (false);
}
if(theForm.cpnWorkingName.value.length > 255)
{
alert("A maximum of 255 characters are allowed in the field \"Working Name\".");
theForm.cpnWorkingName.focus();
return (false);
}
if(theForm.cpnType.selectedIndex!=0){
if(theForm.cpnDiscount.value == "")
{
alert("Please enter a value in the field \"Discount Amount\".");
theForm.cpnDiscount.focus();
return (false);
}
if(theForm.cpnType.selectedIndex==2){
if(theForm.cpnDiscount.value < 0 || theForm.cpnDiscount.value > 100){
alert("Please enter a value between 0 and 100 in the field \"Discount Amount\".");
theForm.cpnDiscount.focus();
return (false);
}
}
}
if(theForm.cpnIsCoupon.selectedIndex==1){
if(theForm.cpnNumber.value == "")
{
alert("Please enter a value in the field \"Coupon Code\".");
theForm.cpnNumber.focus();
return (false);
}
var checkOK = "0123456789abcdefghijklmnopqrstuvwxyz-_";
var checkStr = theForm.cpnNumber.value.toLowerCase();
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 enter only alphanumeric characters, dashes and underscores for the Coupon Code.");
theForm.cpnNumber.focus();
return (false);
}
}
var checkOK = "0123456789";
var checkStr = theForm.cpnNumAvail.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 enter only numbers in \"Number Available\", or leave blank.");
theForm.cpnNumAvail.focus();
return (false);
}
if(theForm.cpnNumAvail.value != "" && theForm.cpnNumAvail.value > 1000000)
{
alert("Please enter a \"Number Available\" between 1 and 1000000, or leave blank.");
theForm.cpnNumAvail.focus();
return (false);
}
var checkOK = "0123456789";
var checkStr = theForm.cpnEndDate.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 enter only numbers in the field \"Number Days Available\".");
theForm.cpnEndDate.focus();
return (false);
}
var checkOK = "0123456789.";
var checkStr = theForm.cpnThreshold.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 enter only numbers and decimal points in the field \"Min Purchase Amount\".");
theForm.cpnThreshold.focus();
return (false);
}
var checkOK = "0123456789.";
var checkStr = theForm.cpnThresholdMax.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 enter only numbers and decimal points in the field \"Max Purchase Amount\".");
theForm.cpnThresholdMax.focus();
return (false);
}
var checkOK = "0123456789";
var checkStr = theForm.cpnQuantity.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 enter only numbers in the field \"Min Quantity\".");
theForm.cpnQuantity.focus();
return (false);
}
var checkOK = "0123456789";
var checkStr = theForm.cpnQuantityMax.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 enter only numbers in the field \"Max Quantity\".");
theForm.cpnQuantityMax.focus();
return (false);
}
var checkOK = "0123456789.";
var checkStr = theForm.cpnDiscount.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 enter only numbers and decimal points in the field \"Discount Amount\".");
theForm.cpnDiscount.focus();
return (false);
}
document.mainform.cpnNumber.disabled=false;
document.mainform.cpnDiscount.disabled=false;
document.mainform.cpnCntry.disabled=false;
document.mainform.cpnSitewide.disabled=false;
return (true);
}
function couponcodeactive(forceactive){
if(document.mainform.cpnIsCoupon.selectedIndex==0){
document.mainform.cpnNumber.style.backgroundColor="#DDDDDD";
document.mainform.cpnNumber.style.borderColor="#aa3300";
document.mainform.cpnNumber.style.color="#aa3300";
document.mainform.cpnNumber.disabled=true;
}
else if(document.mainform.cpnIsCoupon.selectedIndex==1){
document.mainform.cpnNumber.style.backgroundColor=savebg;
document.mainform.cpnNumber.style.borderColor=savebc;
document.mainform.cpnNumber.style.color=savecol;
document.mainform.cpnNumber.disabled=false;
}
}
function changecouponeffect(forceactive){
if(document.mainform.cpnType.selectedIndex==0){
document.mainform.cpnDiscount.style.backgroundColor="#DDDDDD";
document.mainform.cpnDiscount.style.borderColor="#aa3300";
document.mainform.cpnDiscount.style.color="#aa3300";
document.mainform.cpnDiscount.disabled=true;
document.mainform.cpnCntry.style.backgroundColor=savebg;
document.mainform.cpnCntry.style.borderColor=savebc;
document.mainform.cpnCntry.style.color=savecol;
document.mainform.cpnCntry.disabled=false;
document.mainform.cpnSitewide.style.backgroundColor="#DDDDDD";
document.mainform.cpnSitewide.style.borderColor="#aa3300";
document.mainform.cpnSitewide.style.color="#aa3300";
document.mainform.cpnSitewide.disabled=true;
}
else{
document.mainform.cpnDiscount.style.backgroundColor=savebg;
document.mainform.cpnDiscount.style.borderColor=savebc;
document.mainform.cpnDiscount.style.color=savecol;
document.mainform.cpnDiscount.disabled=false;
document.mainform.cpnCntry.style.backgroundColor="#DDDDDD";
document.mainform.cpnCntry.style.borderColor="#aa3300";
document.mainform.cpnCntry.style.color="#aa3300";
document.mainform.cpnCntry.disabled=true;
document.mainform.cpnSitewide.style.backgroundColor=savebg;
document.mainform.cpnSitewide.style.borderColor=savebc;
document.mainform.cpnSitewide.style.color=savecol;
document.mainform.cpnSitewide.disabled=false;
}
}
//-->
</script>
<table border="0" cellspacing="<%=maintablespacing%>" cellpadding="<%=maintablepadding%>" width="<%=maintablewidth%>" bgcolor="<%=maintablebg%>" align="center">
<% if request.form("posted")="1" AND request.form("act")="modify" then
sSQL = "SELECT cpnWorkingName,cpnNumber,cpnType,cpnEndDate,cpnDiscount,cpnThreshold,cpnThresholdMax,cpnQuantity,cpnQuantityMax,cpnNumAvail,cpnCntry,cpnIsCoupon,cpnSitewide FROM coupons WHERE cpnID="&Request.Form("id")
rs.Open sSQL,cnn,0,1
%>
<tr>
<form name="mainform" method="POST" action="admindiscounts.asp" onSubmit="return formvalidator(this)">
<td width="100%">
<input type="hidden" name="posted" value="1">
<input type="hidden" name="act" value="domodify">
<input type="hidden" name="id" value="<%=Request.Form("id")%>">
<table width="<%=innertablewidth%>" border="0" cellspacing="<%=innertablespacing%>" cellpadding="<%=innertablepadding%>" bgcolor="<%=innertablebg%>">
<tr>
<td width="100%" colspan="2" align="center"><b>Enter your new coupon / discount details here.</b><br> </td>
</tr>
<tr>
<td width="40%" align="right"><b>Coupon or Discount:
</td>
<td width="60%"><select name="cpnIsCoupon" size="1" onChange="couponcodeactive(false);">
<option value="0">Discount</option>
<option value="1" <% if Int(rs("cpnIsCoupon"))=1 then response.write "selected" %>>Coupon</option>
</select>
</td>
</tr>
<tr>
<td width="40%" align="right"><b>Coupon / Discount Effect:
</td>
<td width="60%"><select name="cpnType" size="1" onChange="changecouponeffect(false);">
<option value="0">Free Standard Shipping</option>
<option value="1" <% if Int(rs("cpnType"))=1 then response.write "selected" %>>Flat Rate Discount</option>
<option value="2" <% if Int(rs("cpnType"))=2 then response.write "selected" %>>Percentage Discount</option>
</select>
</td>
</tr>
<tr>
<td width="40%" align="right"><b>Working Name:</b>
</td>
<td width="60%"><input type="text" name="cpnWorkingName" size="30" value="<%=Replace(rs("cpnWorkingName"),"""",""")%>">
</td>
</tr>
<tr>
<td width="40%" align="right"><b>Coupon Code:</b>
</td>
<td width="60%"><input type="text" name="cpnNumber" size="30" value="<%=rs("cpnNumber")%>">
</td>
</tr>
<tr>
<td width="40%" align="right"><b>Number Available:</b>
</td>
<td width="60%"><input type="text" name="cpnNumAvail" size="10" value="<% if Int(rs("cpnNumAvail"))<>30000000 then response.write rs("cpnNumAvail")%>">
</td>
</tr>
<tr>
<td width="40%" align="right"><b>Number Days Available:</b>
</td>
<td width="60%"><input type="text" name="cpnEndDate" size="10" value="<%
if rs("cpnEndDate")<>DateSerial(3000,1,1) then
if rs("cpnEndDate")-Date() < 0 then response.write "Expired" else response.write rs("cpnEndDate")-Date()
end if %>">
</td>
</tr>
<tr>
<td width="40%" align="right"><b>Min Purchase Amount:</b>
</td>
<td width="60%"><input type="text" name="cpnThreshold" size="10" value="<% if Int(rs("cpnThreshold"))>0 then response.write rs("cpnThreshold")%>">
</td>
</tr>
<tr>
<td width="40%" align="right"><b>Max Purchase Amount:</b>
</td>
<td width="60%"><input type="text" name="cpnThresholdMax" size="10" value="<% if Int(rs("cpnThresholdMax"))>0 then response.write rs("cpnThresholdMax")%>">
</td>
</tr>
<tr>
<td width="40%" align="right"><b>Min Quantity:</b>
</td>
<td width="60%"><input type="text" name="cpnQuantity" size="10" value="<% if Int(rs("cpnQuantity"))>0 then response.write rs("cpnQuantity")%>">
</td>
</tr>
<tr>
<td width="40%" align="right"><b>Max Quantity:</b>
</td>
<td width="60%"><input type="text" name="cpnQuantityMax" size="10" value="<% if Int(rs("cpnQuantityMax"))>0 then response.write rs("cpnQuantityMax")%>">
</td>
</tr>
<tr>
<td width="40%" align="right"><b>Discount Amount:</b>
</td>
<td width="60%"><input type="text" name="cpnDiscount" size="10" value="<%=rs("cpnDiscount")%>">
</td>
</tr>
<tr>
<td width="40%" align="right"><b>Scope:</b>
</td>
<td width="60%"><select name="cpnSitewide" size="1">
<option value="0">Assign to individual products / cats</option>
<option value="2" <% if Int(rs("cpnSitewide"))=2 then response.write "selected" %>>Applies globally but to individual products</option>
<option value="1" <% if Int(rs("cpnSitewide"))=1 then response.write "selected" %>>Applies globally to product totals</option>
</select>
</td>
</tr>
<tr>
<td width="40%" align="right"><b>Restrict to certain countries:</b>
</td>
<td width="60%"><select name="cpnCntry" size="1">
<option value="0">No - applies to all countries</option>
<option value="1" <% if Int(rs("cpnCntry"))=1 then response.write "selected" %>>Yes, restrict to certain countries</option>
</select>
</td>
</tr>
<tr>
<td width="100%" colspan="2" align="center"><br><input type="submit" value="Submit"><br> </td>
</tr>
<tr>
<td width="100%" colspan="2" align="center"><br>
<a href="admin.asp"><b>Admin Home</b></a><br>
</td>
</tr>
</table>
</td>
</form>
</tr>
<script Language="JavaScript">
<!--
savebg=document.mainform.cpnNumber.style.backgroundColor;
savebc=document.mainform.cpnNumber.style.borderColor;
savecol=document.mainform.cpnNumber.style.color;
couponcodeactive(false);
changecouponeffect(false);
//-->
</script>
<% rs.Close
elseif request.form("posted")="1" AND request.form("act")="addnew" then %>
<tr>
<form name="mainform" method="POST" action="admindiscounts.asp" onSubmit="return formvalidator(this)">
<td width="100%">
<input type="hidden" name="posted" value="1">
<input type="hidden" name="act" value="doaddnew">
<table width="<%=innertablewidth%>" border="0" cellspacing="<%=innertablespacing%>" cellpadding="<%=innertablepadding%>" bgcolor="<%=innertablebg%>">
<tr>
<td width="100%" colspan="2" align="center"><b>Enter your new coupon / discount details here.</b><br> </td>
</tr>
<tr>
<td width="40%" align="right"><b>Coupon or Discount:
</td>
<td width="60%"><select name="cpnIsCoupon" size="1" onChange="couponcodeactive(false);">
<option value="0">Discount</option>
<option value="1">Coupon</option>
</select>
</td>
</tr>
<tr>
<td width="40%" align="right"><b>Coupon / Discount Effect:
</td>
<td width="60%"><select name="cpnType" size="1" onChange="changecouponeffect(false);">
<option value="0">Free Standard Shipping</option>
<option value="1">Flat Rate Discount</option>
<option value="2">Percentage Discount</option>
</select>
</td>
</tr>
<tr>
<td width="40%" align="right"><b>Working Name:</b>
</td>
<td width="60%"><input type="text" name="cpnWorkingName" size="30" value="">
</td>
</tr>
<tr>
<td width="40%" align="right"><b>Coupon Code:</b>
</td>
<td width="60%"><input type="text" name="cpnNumber" size="30" value="">
</td>
</tr>
<tr>
<td width="40%" align="right"><b>Number Available:</b>
</td>
<td width="60%"><input type="text" name="cpnNumAvail" size="10" value="">
</td>
</tr>
<tr>
<td width="40%" align="right"><b>Number Days Available:</b>
</td>
<td width="60%"><input type="text" name="cpnEndDate" size="10" value="">
</td>
</tr>
<tr>
<td width="40%" align="right"><b>Min Purchase Amount:</b>
</td>
<td width="60%"><input type="text" name="cpnThreshold" size="10" value="">
</td>
</tr>
<tr>
<td width="40%" align="right"><b>Max Purchase Amount:</b>
</td>
<td width="60%"><input type="text" name="cpnThresholdMax" size="10" value="">
</td>
</tr>
<tr>
<td width="40%" align="right"><b>Min Quantity:</b>
</td>
<td width="60%"><input type="text" name="cpnQuantity" size="10" value="">
</td>
</tr>
<tr>
<td width="40%" align="right"><b>Max Quantity:</b>
</td>
<td width="60%"><input type="text" name="cpnQuantityMax" size="10" value="">
</td>
</tr>
<tr>
<td width="40%" align="right"><b>Discount Amount:</b>
</td>
<td width="60%"><input type="text" name="cpnDiscount" size="10" value="">
</td>
</tr>
<tr>
<td width="40%" align="right"><b>Scope:</b>
</td>
<td width="60%"><select name="cpnSitewide" size="1">
<option value="0">Assign to individual products / cats</option>
<option value="2">Applies globally but to individual products</option>
<option value="1">Applies globally to product totals</option>
</select>
</td>
</tr>
<tr>
<td width="40%" align="right"><b>Restrict to certain countries:</b>
</td>
<td width="60%"><select name="cpnCntry" size="1">
<option value="0">No - applies to all countries</option>
<option value="1">Yes, restrict to certain countries</option>
</select>
</td>
</tr>
<tr>
<td width="100%" colspan="2" align="center"><br><input type="submit" value="Submit"><br> </td>
</tr>
<tr>
<td width="100%" colspan="2" align="center"><br>
<a href="admin.asp"><b>Admin Home</b></a><br>
</td>
</tr>
</table></td>
</form>
</tr>
<script Language="JavaScript">
<!--
savebg=document.mainform.cpnNumber.style.backgroundColor;
savebc=document.mainform.cpnNumber.style.borderColor;
savecol=document.mainform.cpnNumber.style.color;
couponcodeactive(false);
changecouponeffect(false);
//-->
</script>
<% elseif request.form("posted")="1" AND success then %>
<tr>
<td width="100%">
<table width="<%=innertablewidth%>" border="0" cellspacing="<%=innertablespacing%>" cellpadding="<%=innertablepadding%>" bgcolor="<%=innertablebg%>">
<tr>
<td width="100%" colspan="2" align="center"><br><b>Update Successful !</b><br><br>You will now be forwarded
to the top categories admin page.<br><br>
If that does not happen automatically then please <A href="admindiscounts.asp"><b>click
here</b></a>.<br>
<br>
<img src="../images/clearpixel.gif" width="350" height="3">
</td>
</tr>
</table></td>
</tr>
<% elseif request.form("posted")="1" then %>
<tr>
<td width="100%">
<table width="<%=innertablewidth%>" border="0" cellspacing="<%=innertablespacing%>" cellpadding="<%=innertablepadding%>" bgcolor="<%=innertablebg%>">
<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>
<% else
sSQL = "SELECT cpnID,cpnWorkingName,cpnSitewide,cpnIsCoupon,cpnEndDate FROM coupons ORDER BY cpnIsCoupon,cpnWorkingName"
rs.Open sSQL,cnn,0,1
if NOT rs.EOF then alldata=rs.getrows
rs.Close
%>
<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 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>
<tr>
<form name="mainform" method="POST" action="admindiscounts.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="selectedq" value="1">
<input type="hidden" name="newval" value="1">
<table width="<%=innertablewidth%>" border="0" cellspacing="<%=innertablespacing%>" cellpadding="<%=innertablepadding%>" bgcolor="<%=innertablebg%>">
<tr>
<td width="100%" colspan="6" align="center"><br><b>Use this page to update your coupons / discounts.</b><br> </td>
</tr>
<tr>
<td width="40%" align="left"><b>Working Name</b></td>
<td width="10%" align="center"><b>Type</b></td>
<td width="20%" align="center"><b>Expiry Date</b></td>
<td width="10%" align="center"><b>Global</b></td>
<td width="10%" align="center"><b>Modify</b></td>
<td width="10%" align="center"><b>Delete</b></td>
</tr>
<%
Session.LCID = saveLCID
if IsArray(alldata) then
for rowcounter=0 to UBOUND(alldata,2)
%>
<tr>
<td><%=alldata(1,rowcounter)%>
</td>
<td align="center"><% if alldata(3,rowcounter)=1 then response.write "Coupon" else response.write "Discount"%>
</td>
<td align="center"><% if alldata(4,rowcounter)=DateSerial(3000,1,1) then
response.write "Never"
elseif alldata(4,rowcounter)-Date() < 0 then
response.write "<font color='#FF0000'>Expired</font>"
else
response.write alldata(4,rowcounter)
end if %></td>
<td align="center"><% if alldata(2,rowcounter)=1 OR alldata(2,rowcounter)=2 then response.write "Yes" else response.write "No" %>
</td>
<td align="center"><input type=button name=modify value="Modify" onClick="modrec('<%=alldata(0,rowcounter)%>')">
</td>
<td align="center"><input type=button name=delete value="Delete" onClick="delrec('<%=alldata(0,rowcounter)%>')">
</td>
</tr>
<% next
else
%>
<tr>
<td width="100%" colspan="6" align="center"><br><b>There are no coupons / discounts currently configured.<br> </td>
</tr>
<%
end if
%>
<tr>
<td width="100%" colspan="6" align="center"><br><b>Click here to add a </b> <input type="button" value="New Coupon / Discount" onClick="newrec()"><br> </td>
</tr>
<tr>
<td width="100%" colspan="6" 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>
<% end if
cnn.Close
%>
</table>