%
' Copyright (C) 1998-2005 CyberStrong Internet Services, Inc. All Rights Reserved
'
' This file has been seeded with unique information at point of sale and
' is traceable to its purchaser.
'
' Your license agreement forbids the removal of this notice.
'
' Browse.asp - Browse inventory of available items.
'
dim x
Dim rstItem, SQL, ProductCount, iCount, CustomerID, BrowsePosition
Dim SearchString, SearchCategory, ReturnTo, s, i
Dim ColumnWidth, iColumn, BrowserWidth, ColumnsUp, ButtonPress
Dim RecordCountMsg, HideZeroStockItems, ReturnValue, UseSeparator
' Lock cart for maintenance -------------------------------------------
If (isLocked() Or (Not isDataBaseCurrent())) Then
Call DisplayMaintPage()
Response.End
End If
' Initialize shopping cart system -------------------------------------
If (Session(sesInit) = "") Then
OurSession("BrowsePosition") = 1 ' Position indicator for record set browsing
Session(sesInit) = "True" ' Cart is initialized.
End If
' Initialize the shopping cart ...
Call crtCreate()
' Recover session variables ...
BrowsePosition = CLng(OurSession("BrowsePosition"))
' Page event handler --------------------------------------------------
ButtonPress = LCase(GetFormAction())
Select Case True
CASE ButtonPress = "continue"
OurSession("SearchString") = ""
s = OurSession("ReturnTo")
OurSession("ReturnTo") = ""
If (s <> "") Then
dbClose(Conn)
Response.Redirect(s)
Else
dbClose(Conn)
Response.Redirect(cstBrowseStartPageURL)
End If
Case ButtonPress = "home"
OurSession("BrowseSQL") = ""
OurSession("ReturnTo") = ""
OurSession("SearchString") = ""
dbClose(Conn)
Response.Redirect(cstHomeURL)
Case ButtonPress = "viewall"
SearchString = ""
SearchCategory = ""
OurSession("SelectedCategory") = ""
OurSession("BrowseSQL") = ""
OurSession("SearchString") = ""
OurSession("txtSearchStringLast") = ""
OurSession("txtCategoryLast") = ""
Case ButtonPress = "viewcart"
dbClose(Conn)
Response.Redirect("20Review.asp")
Case ButtonPress = "cancelorder"
dbClose(Conn)
Session.Abandon
Response.Redirect(cstCancelURL)
' Previous/Next handling ...
Case (ButtonPress = "previous") Or (ButtonPress = "more")
Select Case ButtonPress
Case "previous"
BrowsePosition = CLng(Request.Form("PreviousPosition"))
Case "more"
BrowsePosition = CLng(Request.Form("NextPosition"))
End Select
If (BrowsePosition < 1) Then
BrowsePosition = CLng(1)
End If
Case Not strIsEmpty(Request.Form("JumpToPage"))
BrowsePosition = CLng(((CInt(Request.Form("JumpToPage")) - 1) * cstBrowsePageCount) + 1)
' URL based category search request ...
Case GetURLValue("Category") <> ""
SearchCategory = GetURLValue("Category")
OurSession("SelectedCategory") = SearchCategory
OurSession("txtCategoryLast") = SearchCategory
SearchString = ""
OurSession("SearchString") = ""
OurSession("txtSearchStringLast") = ""
' Form based category search request ...
Case (Request.Form("txtCategory") <> OurSession("txtCategoryLast")) AND _
(Request.Form("txtCategory") <> "")
SearchCategory = Request.Form("txtCategory")
OurSession("SelectedCategory") = SearchCategory
OurSession("txtCategoryLast") = SearchCategory
SearchString = ""
OurSession("SearchString") = ""
OurSession("txtSearchStringLast") = ""
' Session based category search request ...
Case OurSession("txtCategory") <> ""
SearchCategory = OurSession("txtCategory")
OurSession("SelectedCategory") = SearchCategory
OurSession("txtCategoryLast") = SearchCategory
SearchString = ""
OurSession("SearchString") = ""
OurSession("txtSearchStringLast") = ""
' URL based general search request ...
Case GetURLValue("Search") <> ""
SearchString = GetURLValue("Search")
OurSession("SearchString") = SearchString
SearchCategory = ""
OurSession("SelectedCategory") = ""
OurSession("txtCategoryLast") = ""
OurSession("txtSearchStringLast") = SearchString
' Form based general search request ...
Case (ButtonPress = "search") OR _
((Trim(Request.Form("txtSearchString")) <> OurSession("txtSearchStringLast")) AND _
(Trim(Request.Form("txtSearchString")) <> ""))
SearchString = Trim(Request.Form("txtSearchString"))
OurSession("SearchString") = SearchString
SearchCategory = ""
OurSession("txtCategoryLast") = ""
OurSession("SelectedCategory") = ""
OurSession("txtSearchStringLast") = SearchString
' Session based general search request ...
Case OurSession("txtSearchString") <> ""
SearchString = OurSession("txtSearchString")
OurSession("SearchString") = SearchString
SearchCategory = ""
OurSession("txtCategoryLast") = ""
OurSession("SelectedCategory") = ""
OurSession("txtSearchStringLast") = SearchString
Case Else
'No events, must be initial page load ...
OurSession("BrowsePosition") = BrowsePosition
SearchString = ""
SearchCategory = ""
OurSession("SearchString") = ""
OurSession("txtCategoryLast") = ""
OurSession("SelectedCategory") = ""
OurSession("txtSearchStringLast") = ""
End Select
' "Return to" processing ----------------------------------------------
Select Case True
Case GetURLValue("ReturnTo") <> ""
OurSession("ReturnTo") = GetURLValue("ReturnTo")
ReturnTo = OurSession("ReturnTo")
Case OurSession("ReturnTo") <> ""
ReturnTo = OurSession("ReturnTo")
Case Else
ReturnTo = cstBrowseStartPageURL
End Select
' Begin record set processing -----------------------------------------
Set Conn = dbOpen("rwl")
' Flag controls hiding of products when live inventory installed ...
HideZeroStockItems = _
IsInstalled("Feature:Live Inventory") And cstLiveInvEnabled And cstLiveInvNoStockHide
' Build a SQL query if one does not already exist for this browse ...
Select Case True
' Category select ...
Case SearchCategory <> ""
SQL = ""
SQL = SQL & "SELECT ALL CategoryIndex.Category, Products.* "
SQL = SQL & "FROM CategoryIndex INNER JOIN Products ON CategoryIndex.ProductID = Products.ProductID "
SQL = SQL & "WHERE (CategoryIndex.Category='" & CleanSQL(SearchCategory, "a") & "') AND "
If (IsTrialMode) Then
SQL = SQL & "(Products.ProductID <= 14) AND "
End If
If (cstDisplayDatesEnabled) Then
SQL = SQL & "((ProductStartDate Is Null) OR (ProductStartDate <= {fn Now()})) AND "
SQL = SQL & "((ProductEndDate Is Null) OR (ProductEndDate >= {fn Now()})) AND "
End If
If (cstProductHideEnabled) Then
SQL = SQL & "({fn LCase(ProductHide)} <> 'yes') AND "
End If
If (HideZeroStockItems) Then
SQL = SQL & "((OnHandInv Is Null) OR (OnHandInv >= 1)) AND "
End If
SQL = SQL & "(1 = 1) "
If (cstSortCodeEnabled) Then SQL = SQL & "ORDER BY Products.ProductSortCode"
If Not (cstSortCodeEnabled) Then SQL = SQL & "ORDER BY Products.ProductID"
' Category select partial match ...
Case Request.Form("txtCategoryLike") <> ""
SQL = ""
SQL = SQL & "SELECT * FROM Products WHERE "
If (IsTrialMode) Then
SQL = SQL & "(ProductID <= 14) AND "
End If
If (cstDisplayDatesEnabled) Then
SQL = SQL & "((ProductStartDate Is Null) OR (ProductStartDate <= {fn Now()})) AND "
SQL = SQL & "((ProductEndDate Is Null) OR (ProductEndDate >= {fn Now()})) AND "
End If
If (cstProductHideEnabled) Then
SQL = SQL & "{fn LCase(ProductHide)} <> 'yes' AND "
End If
If (HideZeroStockItems) Then
SQL = SQL & "((OnHandInv Is Null) OR (OnHandInv >= 1)) AND "
End If
SQL = SQL & " ProductCategory LIKE '%" & CleanSQL(Request.Form("txtCategoryLike"), "a") & "%' AND "
SQL = SQL & " (1 = 1) "
If (cstSortCodeEnabled) Then SQL = SQL & "ORDER BY ProductSortCode"
If Not (cstSortCodeEnabled) Then SQL = SQL & "ORDER BY ProductID"
' General search ...
Case SearchString <> ""
SQL = ""
SQL = SQL & "SELECT * FROM Products "
SQL = SQL & " WHERE "
If (IsTrialMode) Then
SQL = SQL & "(ProductID <= 14) AND "
End If
If (cstDisplayDatesEnabled) Then
SQL = SQL & "(((ProductStartDate Is Null) OR (ProductStartDate <= {fn Now()})) AND "
SQL = SQL & " ((ProductEndDate Is Null) OR (ProductEndDate >= {fn Now()}))) AND "
End If
If (cstProductHideEnabled) Then
SQL = SQL & "{fn LCase(ProductHide)} <> 'yes' AND "
End If
If (HideZeroStockItems) Then
SQL = SQL & "((OnHandInv Is Null) OR (OnHandInv >= 1)) AND "
End If
SQL = SQL & "(ProductCode LIKE '%" & CleanSQL(SearchString, "a") & "%' OR "
SQL = SQL & "NSN LIKE '%" & CleanSQL(SearchString, "a") & "%' OR "
SQL = SQL & "SKU LIKE '%" & CleanSQL(SearchString, "a") & "%' OR "
SQL = SQL & "Packaging LIKE '%" & CleanSQL(SearchString, "a") & "%' OR "
SQL = SQL & "ProductName LIKE '%" & CleanSQL(SearchString, "a") & "%' OR "
SQL = SQL & "ProductDescription LIKE '%" & CleanSQL(SearchString, "a") & "%' OR "
If (cstLongDescriptionEnabled) Then
SQL = SQL & "ProductDescriptionLong LIKE '%" & CleanSQL(SearchString, "a") & "%' OR "
End If
If (cstCategoriesEnabled) Then
SQL = SQL & "ProductCategory LIKE '%" & CleanSQL(SearchString, "a") & "%' OR "
End If
If (cstKeywordsEnabled) Then
SQL = SQL & "ProductKeywords LIKE '%" & CleanSQL(SearchString, "a") & "%' OR "
End If
SQL = SQL & "(1 <> 1)) "
If (cstSortCodeEnabled) Then SQL = SQL & "ORDER BY ProductSortCode, ProductID"
If Not (cstSortCodeEnabled) Then SQL = SQL & "ORDER BY ProductID"
' Reuse last search ...
Case OurSession("BrowseSQL") <> ""
SQL = OurSession("BrowseSQL")
' Default search ... view all ...
Case Else
SQL = ""
SQL = SQL & "SELECT * FROM Products"
SQL = SQL & " WHERE "
If (IsTrialMode) Then
SQL = SQL & "(ProductID <= 14) AND "
End If
If (cstDisplayDatesEnabled) Then
SQL = SQL & "((ProductStartDate Is Null) OR (ProductStartDate <= {fn Now()})) AND "
SQL = SQL & "((ProductEndDate Is Null) OR (ProductEndDate >= {fn Now()})) AND "
End If
If (cstProductHideEnabled) Then
SQL = SQL & "{fn LCase(ProductHide)} <> 'yes' AND "
End If
If (HideZeroStockItems) Then
SQL = SQL & "((OnHandInv Is Null) OR (OnHandInv >= 1)) AND "
End If
SQL = SQL & "(1 = 1) "
If (cstSortCodeEnabled) Then SQL = SQL & "ORDER BY ProductSortCode"
If Not (cstSortCodeEnabled) Then SQL = SQL & "ORDER BY ProductID"
End Select
' For debug only ...
' wl("LastSQL: " & OurSession("BrowseSQL") & "
")
' wl("ThisSQL: " & SQL & "
")
' If this is a new query, reset the browse position to 1 ...
If (SQL <> OurSession("BrowseSQL")) Then
BrowsePosition = CLng(1)
End If
' Remember this search for future paging requests ...
OurSession("BrowseSQL") = SQL
' Save browse position for next page load ...
OurSession("BrowsePosition") = BrowsePosition
' Open a record set ...
set rstItem = Server.CreateObject("ADODB.Recordset")
rstItem.Open SQL, Conn, adOpenKeyset, adLockOptimistic
' Set browse position if user has been paging through products ...
If (rstItem.RecordCount <> 0) Then
If (BrowsePosition < 1) Then BrowsePosition = CLng(1)
rstItem.AbsolutePosition = Min(BrowsePosition, rstItem.RecordCount)
End If
' Recover session variables ...
If (Session(sesItemCount) <> "") Then
iCount = Session(sesItemCount)
aryCart = Session(sesShoppingCart)
End If
' Reset session vars for out-of-page calling ...
OurSession("txtSearchString") = ""
OurSession("txtCategory") = ""
' Write the page out ...
wl("
")
End If
End If
Case "ProductName"
wl("" & rstItem("ProductName") & "")
Case "ProductImage"
if session("Username") = "" then
wl("" & _
"
")
'************coded inserted august 21,2005**********start
End if
'************coded inserted august 21,2005**********end
'************coded inserted sept 6,2005**********start
Session.Contents("larrytmpcart")=""
'************coded inserted sept 6,2005**********end
Case "GiftRegistryLink"
Call UserExit(usrLinkToGiftReg, Conn, rstItem, 0, 0, ReturnValue)
Case "UseSeparator"
UseSeparator = True
End Select
End Sub
dbClose(Conn)
%>