File: D:/web/homefly/vsadmin/inc/incproducts.asp
<%
Dim rs,alldata,useEuro,cnn,rowcounter,iNumOfPages,CurPage,Count,sectionName,weburl,startlink,endlink,catid,aOption()
tsName=""
catid = Trim(Request.QueryString("id"))
tcatid = Trim(Request.QueryString("tc"))
if NOT IsNumeric(catid) then catid=""
if NOT IsNumeric(tcatid) then tcatid=""
if explicitid<>"" AND IsNumeric(explicitid) then catid=explicitid
if explicittid<>"" AND IsNumeric(explicittid) then tcatid=explicittid
Redim aOption(2,maxprodopts)
iNumOfPages = 0
for rowcounter=0 to maxprodopts-1
aOption(0,maxprodopts)=0
next
Function writepagebar(CurPage, iNumPages)
Dim sLink, i, sStr, startPage, endPage
if tcatid<>"" then
sLink = "<a href='"&request.servervariables("url")&"?tc="&tcatid&"&pg="
else
sLink = "<a href='"&request.servervariables("url")&"?id="&catid&"&pg="
end if
startPage = Max(1,CInt(Int(CDbl(CurPage)/10.0)*10))
endPage = Min(iNumPages,CInt(Int(CDbl(CurPage)/10.0)*10)+10)
if CurPage > 1 then
sStr = sLink & "1" & "'><b><font face='Verdana'>«</font></b></a> " & sLink & CurPage-1 & "'>"&xxPrev&"</a> | "
else
sStr = "<b><font face='Verdana'>«</font></b> "&xxPrev&" | "
end if
for i=startPage to endPage
if i=CurPage then
sStr = sStr & i & " | "
else
sStr = sStr & sLink & i & "'>"
if i=startPage AND i > 1 then sStr=sStr&"..."
sStr = sStr & i
if i=endPage AND i < iNumPages then sStr=sStr&"..."
sStr = sStr & "</a> | "
end if
next
if CurPage < iNumPages then
writepagebar = sStr & sLink & CurPage+1 & "'>"&xxNext&"</a> " & sLink & iNumPages & "'><b><font face='Verdana'>»</font></b></a>"
else
writepagebar = sStr & " "&xxNext&" <b><font face='Verdana'>»</font></b>"
end if
End function
Set rs = Server.CreateObject("ADODB.RecordSet")
Set rs2 = Server.CreateObject("ADODB.RecordSet")
Set cnn=Server.CreateObject("ADODB.Connection")
cnn.open sDSN
sSQL = "SELECT adminEmail,adminStoreURL,adminProdsPerPage,adminSubCats,countryLCID,countryCurrency,countryTax,countryCode,adminStockManage,currRate1,currSymbol1,currRate2,currSymbol2,currRate3,currSymbol3,currConvUser,currConvPw,currLastUpdate FROM admin INNER JOIN countries ON admin.adminCountry=countries.countryID WHERE adminID=1"
rs.Open sSQL,cnn,0,1
countryCurrency = rs("countryCurrency")
useEuro = (countryCurrency="EUR")
subCats=(Int(rs("adminSubCats"))=1)
useStockManagement = rs("adminStockManage")<>0
adminProdsPerPage = rs("adminProdsPerPage")
if rs("countryLCID")<>0 then Session.LCID = rs("countryLCID")
countryTax=cDbl(rs("countryTax"))
currRate1=cDbl(rs("currRate1"))
currSymbol1=trim(rs("currSymbol1"))
currRate2=cDbl(rs("currRate2"))
currSymbol2=trim(rs("currSymbol2"))
currRate3=cDbl(rs("currRate3"))
currSymbol3=trim(rs("currSymbol3"))
currConvUser=rs("currConvUser")
currConvPw=rs("currConvPw")
currLastUpdate=rs("currLastUpdate")
rs.Close
Call checkCurrencyRates(currConvUser,currConvPw,currLastUpdate,currRate1,currSymbol1,currRate2,currSymbol2,currRate3,currSymbol3)
if subCats AND tcatid<>"" then
sSQL = "SELECT tsName,tsID FROM topsections WHERE tsID = " & tcatid
rs.Open sSQL,cnn,0,1
if NOT rs.EOF then
tsName = rs("tsName")
tsID = rs("tsID")
end if
rs.Close
sectionName = xxAlProd
sectionids="0"
sSQL = "SELECT sectionID FROM sections where topSection=" & tcatid
rs.Open sSQL,cnn,0,1
do while NOT rs.EOF
sectionids = sectionids & "," & rs("sectionID")
rs.MoveNext
loop
rs.Close
sSQL = "SELECT DISTINCT products.pId,pName,pPrice FROM multiSections RIGHT JOIN (products LEFT OUTER JOIN sections ON products.pSection=sections.sectionID) ON products.pId=multiSections.pId WHERE pDisplay<>0 AND (topSection=" & tcatid & " OR multiSections.pSection IN (" & sectionids & "))"
elseif catid="" then
sectionName = xxAlProd
sSQL = "SELECT pId FROM products WHERE pDisplay<>0"
else
if subCats then
sSQL = "SELECT tsName,tsID FROM sections INNER JOIN topsections ON sections.topSection=topsections.tsID WHERE sectionID = " & catid
rs.Open sSQL,cnn,0,1
if NOT rs.EOF then
tsName = rs("tsName")
tsID = rs("tsID")
end if
rs.Close
end if
sSQL = "SELECT sectionName FROM sections WHERE sectionID="&catid
rs.Open sSQL,cnn,0,1
if NOT rs.EOF then
sectionName = rs("sectionName")
else
sectionName = "<font color='#FF0000'><b>Specified category does not exist !</b></font>"
end if
rs.Close
sSQL = "SELECT DISTINCT products.pId,pName,pPrice FROM multiSections RIGHT JOIN (products LEFT OUTER JOIN sections ON products.pSection=sections.sectionID) ON products.pId=multiSections.pId WHERE pDisplay<>0 AND (products.pSection="&catid&" OR multiSections.pSection="&catid&")"
end if
if sortBy=2 then
sSortBy = " ORDER BY products.pID"
elseif sortBy=3 then
sSortBy = " ORDER BY pPrice"
elseif sortBy=4 then
sSortBy = " ORDER BY pPrice DESC"
elseif sortBy=5 then
sSortBy = ""
else
sSortBy = " ORDER BY pName"
end if
rs.CursorLocation = 3 ' adUseClient
rs.CacheSize = adminProdsPerPage
rs.Open sSQL & sSortBy, cnn
if NOT rs.EOF then
rs.MoveFirst
rs.PageSize = adminProdsPerPage
If Request.QueryString("pg") = "" Then
CurPage = 1
Else
CurPage = Int(Request.QueryString("pg"))
End If
iNumOfPages = Int((rs.RecordCount + (adminProdsPerPage-1)) / adminProdsPerPage)
rs.AbsolutePage = CurPage
end if
Count = 0
if NOT rs.EOF then
prodlist = ""
addcomma=""
Do While Not rs.EOF And Count < rs.PageSize
prodlist = prodlist & addcomma & "'" & rs("pId") & "'"
rs.MoveNext
Count = Count + 1
addcomma=","
loop
rs.Close
Count = 0
sSQL = "SELECT pId,pName,pImage,pPrice,pListPrice,pSection,pSell,pInStock,pLargeImage,topSection,pDescription,pLongDescription FROM products LEFT OUTER JOIN sections ON products.pSection=sections.sectionID WHERE pId IN (" & prodlist & ")" & sSortBy
' response.write sSQL & "<BR>"
' response.flush
rs.Open sSQL, cnn, 0, 1
end if
%>
<table border="0" cellspacing="<%=maintablespacing%>" cellpadding="<%=maintablepadding%>" width="<%=maintablewidth%>" bgcolor="<%=maintablebg%>" align="center">
<tr>
<td colspan="3" width="100%">
<% if useproductbodyformat=2 then %>
<!--#include file="incproductbody2.asp"-->
<% else %>
<!--#include file="incproductbody.asp"-->
<% end if %>
</td>
</tr>
</table>
<%
rs.Close
cnn.Close
%>