Forum Moderators: open
If IsNumeric(User_ProductsPerPage) Then
If User_ProductsPerPage > 0 Then
ProdPerPage = User_ProductsPerPage
Else
ProdPerPage = cfg_ProductsPerPage
End If
Else
ProdPerPage = cfg_ProductsPerPage
End If
If [page]<>"" AND IsNumeric([page]) Then
CurrentPage = CInt([page])
Else
CurrentPage = 1
End If
CacheKey = "CustomProdList:" & CurrentPage & ":" & ProdPerPage & ":" & ProductsPerRow
x = getCachedContent(CacheKey,cfg_ProductList_CacheExpires)
If x = "" Then
query = "SELECT * FROM Products WHERE Code IS NOT Null AND Display=1 AND SubCategory LIKE '%LILE,%' ORDER BY OrderPriority,Code"
sRS.Open query, StoreConnection,3,3
sRS.PageSize = ProdPerPage
sRS.CacheSize = sRS.PageSize
PageCount = sRS.PageCount
RecordCount = sRS.RecordCount
If CurrentPage > CInt(PageCount) Then CurrentPage = PageCount
If CurrentPage <= 0 Then CurrentPage = 1
If RecordCount > 0 Then
x = x & "<table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%""><tr>" & vbCrLf
sRs.AbsolutePage = CurrentPage
intStart = sRs.AbsolutePosition
If intStart=-1 Then
If CurrentPage=1 Then
intStart = 1
Else
intStart = (CurrentPage*ProdPerPage)-(ProdPerPage-1)
End If
End If
If CurrentPage = CInt(PageCount) Then
intFinish = RecordCount
Else
intFinish = intStart + (sRs.PageSize - 1)
End If
i = 1
k=1
Set fso = Server.CreateObject("Scripting.FileSystemObject")
For intRecord=1 To sRs.PageSize
ProductCode = sRS("Code")
ProductDesc = sRS("Description")
ProductPack = sRs("Packing")
ProductAddnl= sRs("AdditionalInfo")
ProductPrice = sRs("L1Price")
ProductUnit = sRs("Unit")
ImgPath = RootPath & "ui\store\images\catalog\thumb\" & xReplace(ProductCode,"-","_") & ".jpg"
If fso.FileExists(ImgPath) Then
DisplayImage = xReplace(ProductCode,"-","_") & ".jpg"
Else
DisplayImage = "noimage.jpg"
End If
If k>ProductsPerRow Then
x = x & "</tr><tr>" & vbCrLf
k=1
End If
x = x & "<td align=""center"" nowrap>" & vbCrLf
x = x & "<a href=""javascript:getProductDetail('" & ProductCode & "','" & SubCat & "');""><img src=""" & RelURL & "ui/store/images/catalog/thumb/" & DisplayImage & """ border=""0"" class=""tnb"" alt=""""><br>" & xHTMLEncode(ProductCode) & "</a><br>" & vbCrLf
x = x & "</form>"
x = x & "</td>" & vbCrLf
k=k+1
i=i+1
sRS.MoveNext
If sRs.EOF Then Exit For
Next
x = x & "</tr></table>" & vbCrLf
y = getPagingLinks("","LILE",CurrentPage,PageCount)
Else
x = x & "<tr>" & vbCrLf
x = x & "<td colspan=""5"">" & vbCrLf
x = x & msg_NoProducts & vbCrLf
x = x & "</td>" & vbCrLf
x = x & "</tr>" & vbCrLf
End If
sRS.Close
Set fso = Nothing
x = "<table width=""100%"" cellpadding=""2"" cellspacing=""0"" border=""0"">" & y & x & y & "</table>"
SetCache = setCachedContent(CacheKey,x)
End If
If cfg_CartQtyInProductList Then
query = "SELECT CartID, Code, Qty FROM Cart WHERE CartID=" & User_CartID & " ORDER BY Code"
sRS.Open query, StoreConnection, adOpenForwardOnly, adLockReadOnly
j = 0
If Not sRS.EOF Then
Do While Not sRs.EOF
ProductsFound = ProductsFound & """" & xReplace(xReplace(sRs("Code"),"&",""),"-","") & ""","
ProductsQty = ProductsQty & """" & sRs("Qty") & ""","
j = j + 1
sRs.MoveNext
Loop
End If
sRS.Close
If j > 0 Then
ProductsFound = Left(ProductsFound,Len(ProductsFound)-1)
ProductsQty = Left(ProductsQty,Len(ProductsQty)-1)
z = z & vbCrLf & "<script language=""javascript"">" & vbCrLf
z = z & "var prodList = Array(" & ProductsFound & ");" & vbCrLf
z = z & "var prodQtyList = Array(" & ProductsQty & ");" & vbCrLf
z = z & "setProductQty(prodList,prodQtyList);" & vbCrLf
z = z & "</script>" & vbCrLf
x = x & z
End If
End If
getCustomList = x