File: D:/web/homefly/vsadmin/inc/incstate.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,allzones,success,cnn,rowcounter,alloptions,errmsg,index,cena,shipType,tax,splitUSZones
success=true
Set rs = Server.CreateObject("ADODB.RecordSet")
Set cnn=Server.CreateObject("ADODB.Connection")
cnn.open sDSN
sSQL = "SELECT adminShipping,adminUSZones,adminTweaks FROM admin"
rs.Open sSQL,cnn,0,1
shipType = Int(rs("adminShipping"))
splitUSZones = (Int(rs("adminUSZones"))=1)
simpleShipping = (Int(rs("adminTweaks")) AND 1)=1
rs.Close
if request.form("posted")="1" then
for index=1 to 100
if request.form("id"&index)<>"" then
cena=0
if request.form("ena"&index)<>"" then cena=1
tax = request.form("tax"&index)
if NOT IsNumeric(tax) then
success=false
errmsg = "Your tax setting needs to be a number between 0 and 100."
elseif tax > 100 OR tax < 0 then
success=false
errmsg = "Your tax setting needs to be a number between 0 and 100."
else
if splitUSZones then
sSQL = "UPDATE states SET stateEnabled="&cena&",stateTax="&tax&",stateZone="&request.form("zon"&index)&" WHERE stateID="&index
else
sSQL = "UPDATE states SET stateEnabled="&cena&",stateTax="&tax&" WHERE stateID="&index
end if
cnn.Execute(sSQL)
end if
end if
next
if success then
response.write "<meta http-equiv=""refresh"" content=""3; url=admin.asp"">"
end if
else
sSQL = "SELECT stateID,stateName,stateEnabled,stateTax,stateZone FROM states ORDER BY stateName"
rs.Open sSQL,cnn,0,1
alldata=rs.getrows
rs.Close
sSQL = "SELECT pzID,pzName FROM postalzones WHERE pzName<>'' AND pzID>100"
rs.Open sSQL,cnn,0,1
allzones=""
if NOT rs.EOF then allzones=rs.getrows
rs.Close
end if
%>
<table border="0" cellspacing="<%=maintablespacing%>" cellpadding="<%=maintablepadding%>" width="<%=maintablewidth%>" bgcolor="<%=maintablebg%>" align="center">
<% if 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 admin home page.<br><br>
If that does not happen automatically then please <A href="admin.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>Some records could not be updated.</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 %>
<script Language="JavaScript">
<!--
function writezone(id,zone) {
var foundzone=false;
document.write('<select name="zon'+id+'" size="1">');
<%
if IsArray(allzones) then
for index=0 to UBOUND(allzones,2)
response.write "document.write('<option value="""&allzones(0,index)&"""');"&vbCrLf
response.write "if(zone=="&allzones(0,index)&"){document.write(' selected');foundzone=true;}"&vbCrLf
response.write "document.write('>"&allzones(1,index)&"</option>');"&vbCrLf
next
end if
%>
if(!foundzone)document.write('<option value="0" selected>*UNDEFINED*</option>');
document.write('</select>');
}
//-->
</script>
<tr>
<form name="mainform" method="POST" action="adminstate.asp">
<td width="100%">
<input type="hidden" name="posted" value="1">
<table width="<%=innertablewidth%>" border="0" cellspacing="<%=innertablespacing%>" cellpadding="<%=innertablepadding%>" bgcolor="<%=innertablebg%>">
<tr>
<td width="100%" colspan="4" align="center"><b>Use this page to update state details for the checkout phase.</b><br> </td>
</tr>
<tr>
<td><b>State Name</b></td>
<td align=center><b>Enabled</b></td>
<td align=center><b>Tax</b></td>
<td align=center><b><% if splitUSZones then
response.write "Postal Zone"
else
response.write " "
end if %></b></td>
</tr><%
if simpleShipping then
for rowcounter=0 to UBOUND(alldata,2)
%><tr align=center>
<td align=left><b><%=alldata(1,rowcounter)%></b><input type="hidden" name="id<%=alldata(0,rowcounter)%>" value="1"></td>
<td><input type=checkbox name="ena<%=alldata(0,rowcounter)%>" <% if Int(alldata(2,rowcounter))=1 then response.write "checked" %>></td>
<td><input type=text name="tax<%=alldata(0,rowcounter)%>" value="<%=alldata(3,rowcounter)%>" size="4">%</td>
<td><% if splitUSZones then
foundzone=false
response.write "<select name=""zon"&alldata(0,rowcounter)&""" size=""1"">"
if IsArray(allzones) then
for index=0 to UBOUND(allzones,2)
response.write "<option value="""&allzones(0,index)&""""
if alldata(4,rowcounter)=allzones(0,index) then
response.write " selected"
foundzone=true
end if
response.write ">"&allzones(1,index)&"</option>"
next
end if
if NOT foundzone then response.write "<option value=""0"" selected>*UNDEFINED*</option>"
response.write "</select>"
else
response.write " "
end if %></td></tr>
<%
next
else
for rowcounter=0 to UBOUND(alldata,2)
%><tr align=center>
<td align=left><b><%=alldata(1,rowcounter)%></b><input type="hidden" name="id<%=alldata(0,rowcounter)%>" value="1"></td>
<td><input type=checkbox name="ena<%=alldata(0,rowcounter)%>" <% if Int(alldata(2,rowcounter))=1 then response.write "checked" %>></td>
<td><input type=text name="tax<%=alldata(0,rowcounter)%>" value="<%=alldata(3,rowcounter)%>" size="4">%</td>
<td><% if splitUSZones then
response.write "<script language=JavaScript>writezone("&alldata(0,rowcounter)&","&alldata(4,rowcounter)&");</script>"
else
response.write " "
end if %></td>
</tr><%
next
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>
<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>
<% end if
cnn.Close
%>
</table>