File: D:/web/homefly/vsadmin/inc/inccountry.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
sub writepos(id,pos)
response.write "<select name='pos"&id&"' size='1'>"
response.write "<option value='0'>Alphabetical</option>"
response.write "<option value='1'"
if pos=1 then response.write " selected"
response.write ">On Top</option>"
response.write "<option value='2'"
if pos=2 then response.write " selected"
response.write ">On Top of Top</option></select>"
end sub
sub writezone(id,zone)
if IsArray(allzones) then
response.write "<select name='zon"&id&"' size='1'>"
for index=0 to UBOUND(allzones,2)
response.write "<option value='"&allzones(0,index)&"'"
if zone=allzones(0,index) then response.write " selected"
response.write ">"&allzones(1,index)&"</option>"
next
response.write "</select>"
else
response.write "No Zones"
end if
end sub
success=true
Set rs = Server.CreateObject("ADODB.RecordSet")
Set cnn=Server.CreateObject("ADODB.Connection")
cnn.open sDSN
sSQL = "SELECT adminShipping,adminTweaks FROM admin"
rs.Open sSQL,cnn,0,1
shipType = Int(rs("adminShipping"))
simpleShipping = (Int(rs("adminTweaks")) AND 1)=1
rs.Close
if request.form("posted")="1" then
for index=1 to 300
if request.form("pos"&index)<>"" then
cena=0
if request.form("ena"&index)<>"" then cena=1
fsa=0
if request.form("fsa"&index)<>"" then fsa=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 shipType=2 OR shipType=5 then
sSQL = "UPDATE countries SET countryEnabled="&cena&",countryTax="&tax&",countryFreeShip="&fsa&",countryOrder="&request.form("pos"&index)&",countryZone="&request.form("zon"&index)&" WHERE countryID="&index
else
sSQL = "UPDATE countries SET countryEnabled="&cena&",countryTax="&tax&",countryFreeShip="&fsa&",countryOrder="&request.form("pos"&index)&" WHERE countryID="&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 countryID,countryName,countryEnabled,countryTax,countryOrder,countryZone,countryFreeShip FROM countries ORDER BY countryOrder DESC,countryName"
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 wposzon(id,pos,zone,fsa) {
// fsa
document.write('<td><input type=checkbox name="fsa'+id+'"');
if(fsa==1) document.write(' checked');
document.write('></td>');
// pos
document.write('<td><select name="pos'+id+'" size="1">');
document.write('<option value="0">Alphabetical</option>');
document.write('<option value="1"');
if(pos==1)document.write(' selected');
document.write('>On Top</option>');
document.write('<option value="2"');
if(pos==2)document.write(' selected');
document.write('>On Top of Top</option></select></td>');
// zone
<% if shipType=2 OR shipType=5 then %>
var foundzone=false;
document.write('<td><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></td>');
<% else %>
document.write('<td> </td>');
<% end if %>
}
//-->
</script>
<tr>
<form name="mainform" method="POST" action="admincountry.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="6" align="center"><br><b>Use this page to update country details for the checkout phase.</b><br> </td>
</tr>
<tr>
<td><b>Country Name</b></td>
<td align=center><b>Enabled</b></td>
<td align=center><b>Tax</b></td>
<td align=center><b><a href="javascript:;" title="Free Shipping Applies">FSA</a></b></td>
<td align=center><b>Position</b></td>
<td align=center><b><% if shipType=2 OR shipType=5 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></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><input type=checkbox name="fsa<%=alldata(0,rowcounter)%>"<% if alldata(6,rowcounter)=1 then response.write " checked"%>></td>
<td><select name="pos<%=alldata(0,rowcounter)%>" size="1">
<option value="0">Alphabetical</option>
<option value="1"<% if alldata(4,rowcounter)=1 then response.write " selected" %>>On Top</option>
<option value="2"<% if alldata(4,rowcounter)=2 then response.write " selected" %>>On Top of Top</option></select></td><%
if shipType=2 OR shipType=5 then
foundzone=false
response.write "<td><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(5,rowcounter)=allzones(0,index) then
response.write " selected"
foundzone=true
end if
response.write ">"&allzones(1,index)&"</option>"&vbCrLf
next
end if
if NOT foundzone then response.write "<option value=""0"" selected>*UNDEFINED*</option>"
response.write "</select></td>"
else
response.write "<td> </td>"
end if
response.write "</tr>"
next
else
for rowcounter=0 to UBOUND(alldata,2)
%><tr align=center>
<td align=left><b><%=alldata(1,rowcounter)%></b></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>
<% response.write "<script language=JavaScript>wposzon("&alldata(0,rowcounter)&","&alldata(4,rowcounter)&","&alldata(5,rowcounter)&","&alldata(6,rowcounter)&");</script>" %>
</tr><%
next
end if
%> <tr>
<td width="100%" colspan="6" align="center">
<p><input type="submit" value="Submit"> <input type="reset" value="Reset"><br> </p>
</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>