<%@ Language=VBScript %> <% '************************************************************************* ' DO NOT MODIFY THIS SCRIPT IF YOU WANT UPDATES TO WORK! ' Function : Product Maintenance ' Product : CandyPress Store Administration ' Version : 2.5 ' Modified : February 2004 ' Copyright: Copyright (C) 2004 CandyPress.Com ' See "license.txt" for this product for details regarding ' licensing, usage, disclaimers, distribution and general ' copyright requirements. If you don't have a copy of this ' file, you may request one at webmaster@candypress.com '************************************************************************* Option explicit Response.Buffer = true const adminLevel = 1 %> <% 'Database dim mySQL, cn, rs 'Products dim idProduct dim description dim descriptionLong dim details dim relatedKeys dim price dim listPrice dim imageURL dim smallImageURL dim sku dim stock dim weight dim active dim hotDeal dim homePage dim fileName dim noShipCharge dim reviewAllow dim reviewAutoActive dim sortOrder 'Work Fields dim I dim item dim count dim pageSize dim totalPages dim showArr dim sortField dim curPage dim showPhrase dim showField dim showStart dim showCat dim showActive dim showHome dim showSpecial dim showShip dim showReview '************************************************************************* 'Open Database Connection call openDB() 'Store Configuration if loadConfig() = false then response.redirect "sysMsg.asp?errMsg=" & server.URLEncode("Could not load Store Configuration settings.") end if 'Set Row Colors dim rowColor, col1, col2 col1 = "#DDDDDD" col2 = "#EEEEEE" 'Set Number of Items per Page pageSize = 50 'Get Page to show curPage = Request.Form("curPage") 'Form if len(curPage) = 0 then curPage = Request.QueryString("curPage") 'QueryString end if 'Get showPhrase showPhrase = Request.Form("showPhrase") 'Form if len(showPhrase) = 0 then showPhrase = Request.QueryString("showPhrase") 'QueryString end if 'Get showField showField = Request.Form("showField") 'Form if len(showField) = 0 then showField = Request.QueryString("showField") 'QueryString end if 'Get showStart showStart = Request.Form("showStart") 'Form if len(showStart) = 0 then showStart = Request.QueryString("showStart") 'QueryString end if 'Get showCat showCat = Request.Form("showCat") 'Form if len(showCat) = 0 then showCat = Request.QueryString("showCat") 'QueryString end if 'Get showActive showActive = Request.Form("showActive") 'Form if len(showActive) = 0 then showActive = Request.QueryString("showActive") 'QueryString end if 'Get showHome showHome = Request.Form("showHome") 'Form if len(showHome) = 0 then showHome = Request.QueryString("showHome") 'QueryString end if 'Get showSpecial showSpecial = Request.Form("showSpecial") 'Form if len(showSpecial) = 0 then showSpecial = Request.QueryString("showSpecial") 'QueryString end if 'Get showShip showShip = Request.Form("showShip") 'Form if len(showShip) = 0 then showShip = Request.QueryString("showShip") 'QueryString end if 'Get showReview showReview = Request.Form("showReview") 'Form if len(showReview) = 0 then showReview = Request.QueryString("showReview") 'QueryString end if 'Check if a Cookie Reset was requested if Request.QueryString("resetCookie") = "1" then Response.Cookies("ProdSearch").expires = Date() - 30 else 'Check if a Cookie Recall was requested if Request.QueryString("recallCookie") = "1" then for each item in Request.Cookies if item = "ProdSearch" then showArr = Split(Request.Cookies(item),"*|*") curPage = showArr(0) showPhrase = showArr(1) showField = showArr(2) showStart = showArr(3) showActive = showArr(4) showHome = showArr(5) showSpecial = showArr(6) showShip = showArr(7) showReview = showArr(8) showCat = showArr(9) end if next else 'Save Search Criteria in a Cookie Response.Cookies("ProdSearch") = navCookie(curPage) Response.Cookies("ProdSearch").expires = Date() + 30 end if end if 'After attempting to retrieve the search criteria through the various 'mechanisms above (Form/QueryString/Cookie), check that some of the 'critical values are valid. If not, set to default values. if len(curPage) = 0 or not isNumeric(curPage) then curPage = 1 else curPage = CLng(curPage) end if if len(showField) = 0 then showField = "SKU" end if 'Check what we will be sorting the results on sortField = Request.Form("sortField") 'Form if len(sortField) = 0 then sortField = Request.QueryString("sortField") 'QueryString end if if len(sortField) = 0 then sortField = "SKU" end if %>

Product Maintenance

<% if len(trim(Request.QueryString("msg"))) > 0 then %> <%=Request.QueryString("msg")%>

<% end if %>
Add New Product
Show Products containing the phrase   
 
  Start with    Category 
 

<% 'Specify fields and table mySQL="SELECT idProduct,sku,description,price," _ & " stock,active,homePage,taxExempt, " _ & " reviewAllow,sortOrder, " _ & " (SELECT (SUM(revRating)/COUNT(revRating)) " _ & " FROM reviews b " _ & " WHERE b.idProduct = a.idProduct " _ & " AND b.revStatus = 'A') " _ & " AS revRating " _ & "FROM Products a " _ & "WHERE 1=1 " 'Dummy check to set up conditional checks below 'Phrase if len(showPhrase) > 0 then mySQL = mySQL _ & "AND (description LIKE '%" & replace(showPhrase,"'","''") & "%' " _ & "OR descriptionLong LIKE '%" & replace(showPhrase,"'","''") & "%' " _ & "OR SKU LIKE '%" & replace(showPhrase,"'","''") & "%' " _ & "OR details LIKE '%" & replace(showPhrase,"'","''") & "%') " end if 'Field Start if len(showStart) > 0 then mySQL = mySQL & "AND " & showField & " LIKE '" & showStart & "%' " end if 'Category if len(showCat) > 0 then if showCat = "0" then mySQL = mySQL & "AND NOT EXISTS (SELECT idCatProd FROM Categories_Products c WHERE c.idProduct=a.idProduct) " else mySQL = mySQL & "AND EXISTS (SELECT idCatProd FROM Categories_Products c WHERE c.idProduct=a.idProduct AND c.idCategory=" & showCat & ") " end if end if 'Status if len(showActive) > 0 then mySQL = mySQL & "AND active = " & showActive & " " end if 'Featured if len(showHome) > 0 then mySQL = mySQL & "AND homepage = " & showHome & " " end if 'Specials if len(showSpecial) > 0 then mySQL = mySQL & "AND hotDeal = " & showSpecial & " " end if 'Shipping if len(showShip) > 0 then mySQL = mySQL & "AND noShipCharge = '" & showShip & "' " end if 'Reviews if len(showReview) > 0 then mySQL = mySQL & "AND reviewAllow = '" & showReview & "' " end if 'Sort Order (secondary sort key is always SKU) if sortField = "SKU" then mySQL = mySQL & "ORDER BY " & sortField & " " else mySQL = mySQL & "ORDER BY " & sortField & ",SKU " end if set rs = openRSopen(mySQL,0,adOpenStatic,adLockReadOnly,adCmdText,pageSize) if rs.eof then %> <% else rs.MoveFirst rs.PageSize = pageSize totalPages = rs.PageCount rs.AbsolutePage = curPage %> <% rowColor = col1 %> <% rowColor = col2 do while not rs.eof and count < rs.pageSize %> <% count = count + 1 rs.movenext 'Switch Row Color if rowColor = col2 then rowColor = col1 else rowColor = col2 end if loop %> <% end if call closeRS(rs) %>

No Products matched search criteria.

<% call pageNavigation("selectPageTop") %> Sort :
ID SKU Description Price Stock Sort FP AC TE RA RR  
<%=rs("idProduct")%> <%=rs("sku")%>  <%=rs("description")%>  <%=moneyD(rs("price"))%>  <% if rs("stock") <= pHideAddStockLevel then Response.Write "" & rs("stock") & "" else Response.Write rs("stock") end if %> <%=emptyString(rs("SortOrder"),"-")%> <% if rs("homePage") = -1 then Response.Write "Y" else Response.Write "N" end if %>   <% if rs("active") = -1 then Response.Write "Y" else Response.Write "N" end if %>   <%=rs("taxExempt")%>  <%=rs("reviewAllow")%>  <% if isNull(rs("revRating")) then Response.Write "-" else Response.Write round(rs("revRating"),1) end if %>   [ ">edit ] ">
<% call pageNavigation("selectPageBot") %> Delete Selected Products?

Help and Instructions :
Overview - Products are the heart of your store. Each product can be linked to one or more Categories, and can have one or more Option Groups linked to them. You can also set Product Discounts for each product, create Product Groups, and much more.

Abbreviations - To conserve space in the product listing, some of the headings have been shortened.
  • FP - Featured Product? (Yes / No)
  • AC - Active? (Yes / No)
  • TE - Tax Exempt? (Yes / No)
  • RA - Reviews Allowed? (Yes / No)
  • RR - Average Review Rating (1 to 5)
Find Product(s) - You have several options for finding a specific Product.
  • You can list all Products which contain a specific phrase in the Short Description, Long Descripton and Product Detail fields.
  • You can list all Products where the SKU or Description fields start with the specified Alphabetic or Numeric value. You can narrow that down by also selecting a specific category, or only look for products that do not belong to a category.
  • You can list al Products with the Attributes you selected. If you want the search to ignore the setting for an Attribute, select "N/A" for that Attribute. When you select more than one Attribute, the search performs an "AND" operation on the selection. In other words, if you selected "Active" and "Featured", only those Products that are BOTH "Active" AND "Featured" will be listed.
Add Product - Click on "Add New Product" and complete the form as indicated. Once you have added the Product, you will be able to link the product to one or more Categories, add Option Groups, create Product Discounts, set Product Groups, etc.

Edit Product - Change Product information. You can also add or remove the product from a Category, add or remove Option Groups and Product Discounts, and much more.

Delete Product - Check the box(es) next to the Product(s) you want to delete and click "Yes" at the bottom.

<% call closedb() %> <% '********************************************************************* 'Make QueryString for Paging '********************************************************************* function navQueryStr(pageNum) navQueryStr = "?curPage=" & server.URLEncode(pageNum) _ & "&showPhrase=" & server.URLEncode(showPhrase) _ & "&showField=" & server.URLEncode(showField) _ & "&showStart=" & server.URLEncode(showStart) _ & "&showActive=" & server.URLEncode(showActive) _ & "&showHome=" & server.URLEncode(showHome) _ & "&showSpecial=" & server.URLEncode(showSpecial) _ & "&showShip=" & server.URLEncode(showShip) _ & "&showReview=" & server.URLEncode(showReview) _ & "&showCat=" & server.URLEncode(showCat) end function '********************************************************************* 'Make Cookie Value for Paging '********************************************************************* function navCookie(pageNum) navCookie = pageNum & "*|*" _ & showPhrase & "*|*" _ & showField & "*|*" _ & showStart & "*|*" _ & showActive & "*|*" _ & showHome & "*|*" _ & showSpecial & "*|*" _ & showShip & "*|*" _ & showReview & "*|*" _ & showCat end function '********************************************************************* 'Display page navigation '********************************************************************* sub pageNavigation(formFieldName) Response.Write "Page " Response.Write " of " & TotalPages & "  " Response.Write "[ " if curPage > 1 then Response.Write "Back" else Response.Write "Back" end if Response.Write " | " if curPage < TotalPages then Response.Write "Next" else Response.Write "Next" end if Response.Write " ]" end sub %>