%
Public Sub DisplayPageHeader2 (ByVal PageNo, ByVal PageTitle, ByVal Options)
Dim DemoMsg, TextOnly, WideMode, UseAdminMode, UseCartLogo, LockMsg
DemoMsg = ""
If (gblDemoMode) Then
DemoMsg = "Demonstration Only"
End If
LockMsg = ""
If (isLocked()) Then
LockMsg = "
Your eShop is locked"
End If
TextOnly = CBool(InStr(Options, "t") <> 0)
UseAdminMode = CBool(InStr(Options, "a") <> 0)
WideMode = CBool(InStr(Options, "w") <> 0)
UseCartLogo = CBool(InStr(Options, "c") <> 0)
On Error Resume Next
Select Case isInAdmin OR UseAdminMode
Case True ' Displaying in admin area ...
If (Not TextOnly) Then
wl("
")
End If
wl("
")
wl("| " & DemoMsg & " | ")
wl("" & PageTitle & "" & LockMsg & " | ")
wl("
")
' Display revision warning if needed ...
If (Not isDataBaseCurrent()) Then
wl("| ")
wl("safina eShop: Database Upgrade Needed: ")
wl("To upgrade your database, please click the Maintenance tab then click ")
wl("""Upgrade or Fix"" and follow the instructions therein.")
wl(" |
")
End If
Case False ' Displaying in cart area ...
If (gblDemoMode) Then
wl(DemoMsg & "
")
End If
'If (cstProgressBarEnabled AND (Not TextOnly)) Then
'wl("")
'wl(" |
")
'wl(" |
") ' Spacer
'wl("
")
'End If
End Select
' All pages ...
' Demo expired ...
If (Date() >= TrialExpires) Then
wl("")
wl(" |
") ' Spacer
wl("| ")
wl("
Sorry, this demonstration version of safina eShop has expired. ")
wl("You may purchase a copy by visiting our Web site at: ")
wl("www.cyberstrong.com/eshop ")
wl(" |
")
wl(" |
") ' Spacer
wl("
")
Response.End
End If
' Trial banner ...
If (isTrialMode) Then
Dim ExpireDateFormated, tmpDate
tmpDate = UCase(FormatDateTime(TrialExpires, vbLongDate))
ExpireDateFormated = Mid(tmpDate, Instr(tmpDate, ",") + 1)
wl("")
wl("FREE TRIAL VERSION EXPIRES " & ExpireDateFormated & " |
")
wl("| Click here to purchase safina eShop |
")
wl("| Help us improve safina eShop by taking our one minute survey! Click here. |
")
wl(" |
") ' Spacer
wl("
")
End If
'Running totals ...
If (cstRunningTotalsEnabled AND (PageNo = "10")) Then
wl("")
wl("| " & GetRunningTotal() & " |
")
wl(" |
") ' Spacer
wl("
")
End If
' Display version info on request ...
If ((GetURLValue("AbouteShop")) OR _
(GetURLValue("AbouteShop") = "true")) Then
Call DisplayAbout()
wl("
")
End If
TrialLockOk = True
End Sub
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 & "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("