File: D:/web/homefly/vsadmin/inc/inccategories.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
Dim sSQL,rs,alldata,cnn,rowcounter,success,subCats,startlink,tsName,secdesc,tsID
tsName=""
tsID = ""
theid=Trim(Replace(Request.QueryString("id"),"'",""))
Set rs = Server.CreateObject("ADODB.RecordSet")
Set cnn=Server.CreateObject("ADODB.Connection")
cnn.open sDSN
sSQL = "SELECT adminSubCats FROM admin"
rs.Open sSQL,cnn,0,1
subCats=(Int(rs("adminSubCats"))=1)
rs.Close
if subCats AND theid="" then
sSQL = "SELECT DISTINCT tsID,tsName,tsDescription,tsImage,tsOrder FROM topsections INNER JOIN sections ON sections.topSection=topsections.tsID ORDER BY tsOrder"
else
if subCats then
sSQL = "SELECT tsName,tsID FROM topsections WHERE tsID=" & theid
rs.Open sSQL,cnn,0,1
if NOT rs.EOF then
tsName = rs("tsName") & " » "
tsID = "?tc="&rs("tsID")
end if
rs.Close
end if
sSQL = "SELECT sectionID,sectionName,sectionDescription,sectionImage,sectionOrder FROM sections "
if theid<>"" AND theid<>"ALL" then sSQL = sSQL & "WHERE topSection=" & theid & " "
sSQL = sSQL & "ORDER BY sectionOrder"
end if
rs.Open sSQL,cnn,0,1
if rs.eof or rs.bof then
success=false
if subCats AND theid="" then
mess1 = "<p> </p>" & xxNoCats
else
mess1 = "<p> </p>" & xxNoPrds
end if
else
alldata=rs.getrows
success=true
if subCats AND theid="" then
mess1 = xxClkCat & "<br> "
else
mess1 = xxClkPrd & "<br> "
end if
end if
rs.Close
%>
<table border="0" cellspacing="<%=maintablespacing%>" cellpadding="<%=maintablepadding%>" width="<%=maintablewidth%>" bgcolor="<%=maintablebg%>" align="center">
<tr>
<td width="100%">
<table width="<%=innertablewidth%>" border="0" cellspacing="<%=innertablespacing%>" cellpadding="<%=innertablepadding%>" bgcolor="<%=innertablebg%>">
<tr>
<td align="center" <% if usecategoryformat="2" then response.write "colspan='2'"%>>
<p><b><%=mess1%></b></p>
</td>
</tr>
<%
tdt = Date()
if theid="" then
sSQL = "SELECT DISTINCT cpnWorkingName FROM coupons WHERE (cpnSitewide=1 OR cpnSitewide=2) AND cpnNumAvail>0 AND cpnEndDate>="&datedelim&DatePart("m",tdt) & "/" & DatePart("d",tdt) & "/" & DatePart("yyyy",tdt)&datedelim&" AND cpnIsCoupon=0"
else
sSQL = "SELECT DISTINCT cpnWorkingName FROM coupons LEFT OUTER JOIN cpnAssign ON coupons.cpnID=cpnAssign.cpaCpnID WHERE ((cpnSitewide=0 AND cpaType=0 AND cpaAssignment='"&theid&"') OR cpnSitewide=1 OR cpnSitewide=2) AND cpnNumAvail>0 AND cpnEndDate>="&datedelim&DatePart("m",tdt) & "/" & DatePart("d",tdt) & "/" & DatePart("yyyy",tdt)&datedelim&" AND cpnIsCoupon=0"
end if
rs.Open sSQL,cnn,0,1
if NOT rs.EOF then
%>
<tr>
<td align="left" <% if usecategoryformat="2" then response.write "colspan='2'"%>>
<p><b><%=xxDsCat%></b><br><font color="#FF0000" size="1">
<% do while NOT rs.EOF
response.write rs("cpnWorkingName") & "<br>"
rs.MoveNext
loop %> </font></p>
</td>
</tr>
<%
end if
rs.Close
if success then
%>
<tr>
<% if usecategoryformat="2" AND allproductsimage<>"" then %>
<td width="5%" align="right"><% response.write "<a href='products.asp'><img src='"&allproductsimage&"' border='0'></a>"%> </td>
<% end if %>
<td <% if usecategoryformat="2" AND allproductsimage="" then response.write "colspan='2'" %>>
<p><% if usecategoryformat<>"2" AND allproductsimage<>"" then response.write "<a href='products.asp'><img src='"&allproductsimage&"' border='0'></a> "%><b><%
if subCats AND theid<>"" then
response.write "<a href=""categories.asp"">"&xxHome&"</a> » " & tsName
end if %><a href="products.asp<%=tsID%>"><%=xxAlProd%></a></b></p>
<p><%=xxAlPrCa%><br> </p>
</td>
</tr>
<% tdt = Date()
FOR rowcounter= 0 TO ubound(alldata,2)
if subCats AND theid="" then
startlink="<a href='categories.asp?id="&alldata(0,rowcounter)&"'>"
sSQL = "SELECT DISTINCT cpnWorkingName FROM coupons LEFT OUTER JOIN cpnAssign ON coupons.cpnID=cpnAssign.cpaCpnID WHERE cpnSitewide=0 AND cpnNumAvail>0 AND cpnEndDate>="&datedelim&DatePart("m",tdt) & "/" & DatePart("d",tdt) & "/" & DatePart("yyyy",tdt)&datedelim&" AND cpnIsCoupon=0 AND cpaType=0 AND cpaAssignment='"&alldata(0,rowcounter)&"'"
else
startlink="<a href='products.asp?id="&alldata(0,rowcounter)&"'>"
sSQL = "SELECT DISTINCT cpnWorkingName FROM coupons LEFT OUTER JOIN cpnAssign ON coupons.cpnID=cpnAssign.cpaCpnID WHERE cpnSitewide=0 AND cpnNumAvail>0 AND cpnEndDate>="&datedelim&DatePart("m",tdt) & "/" & DatePart("d",tdt) & "/" & DatePart("yyyy",tdt)&datedelim&" AND cpnIsCoupon=0 AND cpaType=1 AND cpaAssignment='"&alldata(0,rowcounter)&"'"
end if
alldiscounts = ""
rs.Open sSQL,cnn,0,1
do while NOT rs.EOF
alldiscounts = alldiscounts & rs("cpnWorkingName") & "<br>"
rs.MoveNext
loop
rs.Close
secdesc = Trim(alldata(2,rowcounter)) %>
<tr>
<% if usecategoryformat="2" AND Trim(alldata(3,rowcounter))<>"" then %>
<td width="5%" align="right"><% response.write startlink&"<img src='"&alldata(3,rowcounter)&"' border='0'></a> "%></td>
<% end if %>
<td <% if usecategoryformat="2" AND Trim(alldata(3,rowcounter))="" then response.write "colspan='2'" %>>
<p><% if usecategoryformat<>"2" AND Trim(alldata(3,rowcounter))<>"" then response.write startlink&"<img src='"&alldata(3,rowcounter)&"' border='0'></a> "
response.write "<b>"&startlink&alldata(1,rowcounter)&"</a>"&xxDot&"</b>"
if alldiscounts<>"" then response.write " <font color=""#FF0000""><strong>"&xxDsApp&"</strong><br><font size=""1"">" & alldiscounts & "</font></font>" %>
<% if secdesc <> "" then response.write "</p><p>" & secdesc %>
<br> </p>
</td>
</tr><%
next
end if
cnn.Close
%>
<tr>
<td <% if usecategoryformat="2" then response.write "colspan='2'"%>><p align="center"><img src="images/clearpixel.gif" width="350" height="1"></p></td>
</tr>
</table>
</td>
</tr>
</table>