<% '************************************************************************* ' ASP Scripting: ' Filename: view_products_by_pattern.asp ' Written by: Wilbert Madarang ' Date: February 2, 2003 '************************************************************************* ' Description: View Products By Pattern '************************************************************************* ' Revision History: '************************************************************************* %> <% 'Declare Variables Dim strProductLineId, strPatternId, strSizeId 'Obtain Web Parameters strProductLineId = Request( "product_line_id" ) strPatternId = Request( "patternId" ) strSizeId = Request( "sizeId" ) If strSizeId = "" Then strSizeId = DEFAULT_SIZE_ID End If %> Welcome to Charister.com

   <% 'Print Pattern Images Call PrintPatternImages( strProductLineId, strPatternId ) %>
<% 'Call PrintProductsByPattern() %> <% Call PrintProductsByPatternSortBySize( strProductLineId, strSizeId ) %>
<% '************************************************************************* ' Function: PrintPatternImages() ' Description: prints the pattern Images ' Parameters: patternId ' Returns: none ' Written by: Wilbert Madarang ' Date: February 4, 2003 '************************************************************************* Function PrintPatternImages( strProductLineId, strPatternId ) Dim strSQL, strPatternThumbnailLocation, strPatternImageLocation, strPatternImageDescLocation, rs 'Prepare SQL Statement If strProductLineId = 1 Then strSQL = "Select * FROM dirPatterns WHERE patternId=" & strPatternId ' ay051605 update for lifestyles accessories Elseif strProductLineId = 7 Then strSQL = "Select * FROM TLifestylesProducts WHERE patternId=" & strPatternId End If Call openDataConnection() Set rs = dataConnection.Execute( strSQL ) Call closeDataConnection() 'Get Image Locations If NOT (rs.EOF AND rs.BOF) Then strPatternThumbnailLocation = rs.Fields( "pattern_Thumbnail_Location" ) strPatternImageLocation = rs.Fields( "pattern_Image_Location" ) strPatternImageDescLocation = rs.Fields( "pattern_Image_Desc_Location" ) Else strPatternThumbnailLocation = "" strPatternImageLocation = "" End If 'Write Headers If strProductLineId = 1 Then Response.Write "Bed Linen Collection

  " &vbCrLf ' ay051605 update for lifestyles accessories Elseif strProductLineId = 7 Then Response.Write "Lifestyles Accessories

  " &vbCrLf End If 'Print Images Response.Write "

" & vbCrLf Response.Write "   

" ' Response.Write "   

" Response.Write "   

" ' Response.Write "   " & strPatternImageDescLocation & "

" If strProductLineId = 1 Then Response.Write "   REQUEST fabric swatch / catalogue
" End If End Function '************************************************************************* ' Function: PrintProductsByPatternSortBySize() ' Description: prints the products by pattern provided ' Parameters: none ' Returns: none ' Written by: Wilbert Madarang ' Date: February 4, 2003 '************************************************************************* ' Modified: March 22, 2003 ' Modified constraint of query so that results of search ' 1. Returns even non product line items, as long as they ' Have the same Pattern '************************************************************************* ' Modified: March 29, 2003 ' ' Query STATEMENT ' 1. Added SORT ORDER to strConstraint - SORT BY DESCending ORDER ' 2. remove 'DISTINCT' FROM 'SELECT DISTINC' Query clause ' ' DISPLAY Parameters ' 3. Added Bold Attributes to strProductName. ' 4. Display Product Code instead of Product ID ' 5. Added Font Color Attributes to strProductCode ' 6. Changed logic for displaying Sale price ' - don't use LEN(strProductSalePrice) > 0 ' 7. Changed field names for currency to nProductSalePrice, nProductRegularPrice ' from strProductSalePrice, strProductRegularPrice '************************************************************************* ' Modified: October 19, 2003 ' 1. Added sizeId DESC to SORT ORDER '************************************************************************* Function PrintProductsByPatternSortBySize( strProductLineId, strSizeId ) Dim strSQL, strTable, strConstraint, strLocalPatternId, rs Dim strCurrencyLabel Dim nProductPrice 'Prepare Currency Label strCurrencyLabel = getCurrencyLabel() 'Prepare SQL statements strRegularPriceFieldName = getRegularPriceFieldName() 'US or Cdn Price strSalePriceFieldName = getSalePriceFieldName() 'US or Cdn Price '******************************************************************** 'Start of Modification by WM -March 22, 2003 '******************************************************************** 'strConstraint = " WHERE productLineId=" & strProductLineId & _ ' " AND patternId=" & strPatternId & _ ' " AND (sizeId=" & strSizeId & " OR sizeId IS NULL OR sizeId=0 ) " '******************************************************************** 'End of Modification by WM -March 22, 2003 '******************************************************************** ' Addendum by WM on March 29, 2003 ' 1. Added SORT ORDER to strConstraint - SORT BY DESCending ORDER ' 2. remove 'DISTINCT' FROM 'SELECT DISTINC' clause '******************************************************************** ' End of Addendum by WM -March 29, 2003 '******************************************************************** ' Addendum by WM on April 1, 2003 ' 1. Added SORT ORDER to sort by productCode '******************************************************************** ' End of Addendum by WM - April 1, 2003 '******************************************************************** ' Addendum by WM on November 1, 2003 ' 1. CR to sort by sizeId, productLineCategoryId, productCode '******************************************************************** ' End of Addendum by WM - November 1, 2003 '******************************************************************** ' Addendum by WM on November 5, 2003 ' Request is to sort by ProductLineId, not productLineCategoryId ' 1. CR to sort by sizeId, productLineId, productCode '******************************************************************** ' End of Addendum by WM - November 5, 2003 '******************************************************************** strConstraint = " WHERE patternId=" & strPatternId 'ay051605 comment out next 3 lines for Lifestyles Accessories ' strConstraint = " WHERE patternId=" & strPatternId & _ ' " AND (sizeId=" & strSizeId & " OR sizeId IS NULL OR sizeId=0 ) " & _ ' "ORDER BY sizeId DESC, productLineId, productCode" '"ORDER BY sizeId DESC, productLineCategoryId, productCode" '" ORDER BY sizeId DESC, productCode" '" ORDER BY sizeId DESC" 'ay051605 add below for Lifestyles Accessories If strProductLineId = 7 Then strConstraint = strConstraint + " AND productLineId=7" End If strConstraint = strConstraint + " AND (sizeId=" & strSizeId & " OR sizeId IS NULL OR sizeId=0 )" strConstraint = strConstraint + " ORDER BY sizeId DESC, productLineId, productCode" '******************************************************************** ' Modified by WM - October 19, 2003 ' 1. Added sizeId DESC to Ordering of Query '******************************************************************** strColumnNames = " productId, productCode, productName, " & strRegularPriceFieldName & "," & strSalePriceFieldName strTable = "dirProducts" strSQL = "SELECT " & strColumnNames & " FROM " & strTable & strConstraint 'Open Data Connections Call openDataConnection() Set rs = dataConnection.Execute( strSQL ) Call closeDataConnection() 'Write Main Product Header Response.Write "" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & vbCrLf Call AddLinkToCart() Response.Write "" & vbCrLf Call PrintSizeSelectionHeading( strSizeId ) 'Write Query Headers in Table Format Response.Write "
" & vbCrLf If strProductLineId = 0 Then Response.Write "Bed Linen Collection" & vbCrLf ' ay051605 update for lifestyles accessories Elseif strProductLineId = 7 Then Response.Write "Lifestyles Accessories" & vbCrLf End If Response.Write "
" & vbCrLf Response.Write "
" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & vbCrLf 'Show Query Results DO WHILE NOT rs.EOF '************************************************************************ ' Modified by WM - March 29, 2003 '************************************************************************ ' 1. Added Bold Attributes to strProductName. ' 2. Display Product Code instead of Product ID ' 3. Added Font Color Attributes to strProductCode ' 4. Changed field names for currency to nProductSalePrice, nProductRegularPrice ' from strProductSalePrice, strProductRegularPrice ' 5. Changed logic for displaying Sale price ' - don't use LEN(strProductSalePrice) > 0 ' - use (nProductSalePrice) > 0 '************************************************************************ 'Obtain Fields strProductId = rs.Fields("productId") strProductCode = rs.Fields("productCode") strProductName = rs.Fields( "productName" ) nProductRegularPrice = rs.Fields( strRegularPriceFieldName ) nProductSalePrice = rs.Fields( strSalePriceFieldName ) nProductPrice = getProductPrice( nProductRegularPrice, nProductSalePrice ) 'Define Form Response.Write "" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & vbCrLf 'Response.Write "" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & vbCrLf 'Write Product Information Response.Write "" & vbCrLf Response.Write "" & vbCrLf '************************************************************************ ' End of Modification by WM - March 29, 2003 '************************************************************************ 'Write Color Permutations Response.Write "" & vbCrLf 'Write Quantity Response.Write "" & vbCrLf 'Write Add to Cart Response.Write "" & vbCrLf 'End Row Response.Write "" & vbCrLf Response.Write "" & vbCrLf rs.MoveNext LOOP Response.Write "
ItemsColorsQuantityAdd to Cart
" & vbCrLf 'Print Information Response.Write "" & vbCrLf Response.Write "" & strProductName & "
" & vbCrLf 'Response.Write "Price " & strCurrencyLabel & FormatCurrency( nProductPrice, 2) & "
" & vbCrLf Response.Write "Price: " & strCurrencyLabel & FormatCurrency(nProductRegularPrice, 2) & "
" & vbCrLf If ( nProductSalePrice ) > 0 Then '******************************************** ' Added by WM, November 24, 2003 ' Added Red Color to Sale '******************************************** Response.Write "" & vbCrLf Response.Write "Sale: " & strCurrencyLabel & FormatCurrency(nProductSalePrice, 2) & "
" & vbCrLf Response.Write "
" & vbCrLf '******************************************** ' End of Addition by WM, Nov 24, 2003 '******************************************** End If 'Response.Write "Product ID: " & strProductId & "

" & vbCrLf Response.Write "Product Code: " & strProductCode & "

" & vbCrLf Response.Write "
" & vbCrLf Response.Write "
" & vbCrLf Call PrintColorSelectionListByProduct( strProductId ) Response.Write "" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & vbCrLf Response.Write "
" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & vbCrLf Call AddLinkToCart() Response.Write "" & vbCrLf Response.Write "
" & vbCrLf End Function '************************************************************************* ' Function: PrintSizeSelectionHeading ' Description: prints a Heading Where User can Select Size ' Parameters: strSizeId ' Returns: none ' Written by: Wilbert Madarang ' Date: March 15, 2003 '************************************************************************* Function PrintSizeSelectionHeading( strSizeId ) Dim strSQL, strTable, strConstraint, strLocalPatternId, rs, strSizeSelectionLink Dim strLocalSizeId, strSizeName 'Prepare SQL Statement strSQL = "SELECT * FROM dirSizes ORDER BY sizeId" Call openDataConnection() Set rs = dataConnection.Execute( strSQL ) Call closeDataConnection() Response.Write "" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & vbCrLf Response.Write "
Please select the size that you need:" & vbCrLf DO WHILE NOT rs.EOF strLocalSizeId = rs.Fields( "sizeId" ) strSizeName = rs.Fields( "sizeName" ) strHref = Request.ServerVariables("URL") & "?" & _ "product_line_id=" & strProductLineId & "&" & _ "patternId=" & strPatternId & "&" & _ "sizeId=" & strLocalSizeId If strLocalSizeId = CInt(strSizeId) Then Response.Write "" & _ "" & _ strSizeName & "  " & vbCrLf Else Response.Write "" & _ strSizeName & "  " & vbCrLf End If rs.MoveNext LOOP Response.Write "" & vbCrLf Response.Write "
" & vbCrLf End Function '************************************************************************* ' Function: PrintColorSelectionListByProduct() ' Description: prints the products by pattern provided ' Parameters: none ' Returns: none ' Written by: Wilbert Madarang ' Date: February 4, 2003 '************************************************************************* ' Modified by WM - November 1, 2003 '************************************************************************ ' 1. Added color as a hidden web parameter into the shopping cart form. '************************************************************************ Function PrintColorSelectionListByProduct( strProductId ) Dim strSQL, strTable, strConstraint, rs, strUrl 'Prepare SQL strConstraint = " WHERE rel_Product_Color.productId=" & strProductId strTable = "rel_Product_Color INNER JOIN dirColors ON rel_Product_Color.colorId=dirColors.colorId" strSQL = "SELECT rel_Product_Color.colorId, dirColors.colorName FROM " & strTable & strConstraint 'Call SQL Statement Call openDataConnection() Set rs = dataConnection.Execute( strSQL ) Call closeDataConnection() 'Assess if there are Records If rs.EOF AND rs.BOF Then Response.Write "
 " & vbCrLf Exit Function End If 'Print Colors Selection List Response.Write "" & vbCrLf End Function '************************************************************************* ' Function: getRegularPriceFieldName ' Description: gets the Regular Price FieldName ' Parameters: none ' Returns: none ' Written by: Wilbert Madarang ' Date: February 8, 2003 '************************************************************************* ' Modified: November 8, 2003 ' Changed references from "MyCountry" to "MyCurrency" '************************************************************************* Function getRegularPriceFieldName Dim strFieldName If session( "MyCurrency" ) = "canada" Then strFieldName = "product_Reg_Price_Cdn" Else strFieldName = "product_Reg_Price_US" End If getRegularPriceFieldName = strFieldName End Function '************************************************************************* ' Function: getSalePriceFieldName ' Description: gets the Sale Price FieldName ' Parameters: none ' Returns: the Field Name, in either US or Canadian Currency ' Written by: Wilbert Madarang ' Date: February 8, 2003 '************************************************************************* ' Modified: November 8, 2003 ' Changed references from "MyCountry" to "MyCurrency" '************************************************************************* Function getSalePriceFieldName Dim strFieldName If session( "MyCurrency" ) = "canada" Then strFieldName = "product_Sale_Price_Cdn" Else strFieldName = "product_Sale_Price_US" End If getSalePriceFieldName = strFieldName End Function '************************************************************************* ' Function: getCurrencyLabel ' Description: gets Currency Label ' Parameters: none ' Returns: returns Currency Label ' Written by: Wilbert Madarang ' Date: March 16, 2003 '************************************************************************* ' Modified: November 8, 2003 ' Changed references from "MyCountry" to "MyCurrency" '************************************************************************* Function getCurrencyLabel Dim strCurrency, strCurrencyLabel 'Obtain the Session Information strCurrency = Session("MyCurrency") If strCurrency = "" OR IsNull( strCurrency ) Then strCurrency = DEFAULT_COUNTRY End If 'Get Currency Label If strCurrency = "canada" Then strCurrencyLabel = CURRENCY_LABEL_CANADIAN Else strCurrencyLabel = CURRENCY_LABEL_US End If getCurrencyLabel = strCurrencyLabel End Function '************************************************************************* ' Function: getProductPrice ' Description: gets the Product Price ' Parameters: regular price, sale price ' Returns: returns the price ' Written by: Wilbert Madarang ' Date: May 7, 2003 '************************************************************************* Function getProductPrice( nProductRegularPrice, nProductSalePrice ) Dim nProductPrice If ( nProductSalePrice ) > 0 Then nProductPrice = nProductSalePrice Else nProductPrice = nProductRegularPrice End If getProductPrice = nProductPrice End Function '************************************************************************* ' Function: AddLinkToCart ' Description: Adds a Link to the Shopping Cart ' Parameters: regular price, sale price ' Returns: returns the price ' Written by: Wilbert Madarang ' Date: May 7, 2003 '************************************************************************* Function AddLinkToCart Response.Write "" & vbCrLf 'Response.Write "View Shopping Cart" & vbCrLf Response.Write "
" & vbCrLf Response.Write "" & vbCrLf End Function %>