<% ' 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("
") wl("
") ' Page position table start ... ' Display top of form pull down boxes ... Call DisplayPageHeader("10", "", "") If ((cstDisplayCategoryDDB AND cstCategoriesEnabled) OR cstDisplaySearchBox) Then wl("") wl("") wl("") If (Not BrowserIsMSIE) Then ' IE forces space after ... wl("") ' Spacer ... End If wl("
") Call catDisplayDDB() wl("") If (cstDisplaySearchBox) Then wl(" ") wl(" ") If (cstViewAllButtonEnabled) Then wl("") End If End If wl("
") End If wl("") wl("") wl("") wl("") wl("") wl("") ' Row spacing wl("
") If (rstItem.RecordCount <> 0) Then RecordCountMsg = cstRecordCountMsg RecordCountMsg = Replace(RecordCountMsg, "$(First)", Min(BrowsePosition, rstItem.RecordCount)) RecordCountMsg = Replace(RecordCountMsg, "$(Last)", Min(BrowsePosition + (cstBrowsePageCount - 1), rstItem.RecordCount)) RecordCountMsg = Replace(RecordCountMsg, "$(Total)", rstItem.RecordCount) wl(RecordCountMsg) Else wl("Nothing matched this search, please try again.") End If wl("
") ' Begin product display table ' Check for this common user error, extra delimiter on end ... 'stop If (Right(cstBrowseColumnProfile, 1) = ";") Then cstBrowseColumnProfile = Mid(cstBrowseColumnProfile, 1, Len(cstBrowseColumnProfile) - 1) End If ColumnWidth = Split(cstBrowseColumnProfile, ";") ColumnsUp = UBound(ColumnWidth) + 1 BrowserWidth = 0 For i = 0 To UBound(ColumnWidth) Step 1 BrowserWidth = BrowserWidth + ColumnWidth(i) Next iColumn = 0 wl("") wl("") ProductCount = 1 : UseSeparator = False Do While (ProductCount <= cstBrowsePageCount) AND (Not rstItem.EOF) ' Break before new row, but not the first row... If (((ProductCount - 1) MOD ColumnsUp) = 0) Then Select Case UseSeparator Case True : wl("

") 'break the row Case False : wl("
") 'break the row End Select iColumn = 0 Else iColumn = iColumn + 1 End If ' Embedd the user's template here... wl("") ProductCount = ProductCount + 1 rstItem.MoveNext Loop ' Add more cells to right to complete last row if needed... ProductCount = ProductCount - 1 Do While (Not ((ProductCount MOD ColumnsUp) = 0)) Response.Write("" & vbCrLf) ProductCount = ProductCount + 1 Loop wl("
") Select Case LCase(cstBrowseTemplate) Case "image left" : %><% Case "image top" : %><% Case "compact" : %><% Case "custom" : %><% End Select wl("
") ' Begin end-of-page controls ... wl("
") wl("") wl("") wl("") wl("") wl("") wl("") wl("") wl("") wl("") wl("") wl("
") If (BrowsePosition > 1) Then wl("  ") End If If ((LCase(ReturnTo) <> "10browse.asp") AND (LCase(Left(ReturnTo, 10)) <> "msetup.asp")) Then wl("  ") End If wl("  ") If (iCount > 0) Then wl("  ") wl("  ") End If If (Not rstItem.EOF) Then wl("") End If wl("
Top" & JumpToPage() & "

") Call DisplayAffiliateLink() wl("
") wl("
") ' Page position table end. ' Pass forward values for paging ... wl("") wl("") wl("") ' Local support routines.. ' JumpToPage() - Returns jump to page selection box... Private Function JumpToPage() Dim CurrentPage, TotalPages, ws, i CurrentPage = GetPageNo(Min(BrowsePosition, rstItem.RecordCount)) TotalPages = GetPageNo(rstItem.RecordCount) Set ws = New clsWS ws("Page: of " & TotalPages & "") JumpToPage = ws.Gets() End Function ' GetPageNo() - Get the page number displaying given record... Private Function GetPageNo(ByVal argRecordNo) GetPageNo = Int(argRecordNo / cstBrowsePageCount) + _ IIF(argRecordNo Mod cstBrowsePageCount <> 0, 1, 0) End Function ' usrInsert() - Call back from user editable template page... Private Sub usrInsert(ByVal argWhat) If (rstItem.RecordCount = 0) Then Exit Sub Select Case argWhat Case "NewFlag" If ((cstNewUntilDateEnabled) AND (Not IsNull(rstItem("NewUntil")))) Then If (rstItem("NewUntil") > Now()) Then wl("New!") End If End If Case "ProductName" wl("" & rstItem("ProductName") & "") Case "ProductImage" if session("Username") = "" then wl("" & _ "") else wl("" & _ "") end if Case "ProductDescription" wl("" & GetShortDescription(rstItem("ProductDescription"), rstItem("ProductDescription")) & "") Case "ProductDescriptionLong" wl("" & GetLongDescription(rstItem("ProductDescription"), rstItem("ProductDescriptionLong")) & "") Case "MinimumQty" If ((cstMinOrderQtyEnabled) AND (rstItem("MinQty") <> 1)) Then wl("(Minimum order: " & rstItem("MinQty") & ")
") End If Case "ProductCode" wl("Product Code: " & rstItem("ProductCode") & "") Case "NSN" if rstItem("NSN") <> "" And rstItem("NSN") <> " " then wl("NSN: " & rstItem("NSN") & "") End If Case "SKU" if rstItem("SKU") <> "" And rstItem("SKU") <> " " then wl("SKU: " & rstItem("SKU") & "") End If Case "Packaging" if rstItem("Packaging") <> "" And rstItem("Packaging") <> " "then wl("Packaging: " & rstItem("Packaging") & "") End If Case "StockStatus" Call DisplayStockStatus(rstItem) Case "Pricing" ' if instr(rstItem("ProductDescription"),"Satin") = 0 and instr(rstItem("ProductDescription"),"Woodgrains") = 0 and instr(rstItem("ProductDescription"),"Matte") = 0 and instr(rstItem("ProductDescription"),"Nomark") = 0 then if rstItem("Customize") <> 4 then Call DisplayProductPrices(rstItem) end if Case "DiscountLink" If ((cstDiscountsEnabled) AND ((Trim(rstItem("DiscountName") & "")) <> "")) Then wl("" & _ "Discount Schedule" & _ "") End If Case "OrderButton" '************coded inserted august 21,2005**********start sqllar="SELECT Customize FROM Products WHERE ProductCode='" & rstItem("ProductCode") & "'" set rslar = Server.CreateObject("ADODB.Recordset") rslar.Open sqllar, Conn, 0,1 If not rslar.EOF and (rslar("Customize")="1" or rslar("Customize")="2" or rslar("Customize")="3" or rslar("Customize")="4") then if session("Username") = "" then wl("" & _ "Customize") else wl("" & _ "Customize") end if Else '************coded inserted august 21,2005**********end wl("" & _ "Order") '************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) %>