%
strID = Request("id")
strPorL = Request("PorL")
strPrimCat = Request("primcat")
strSubCat = Request("subcat")
StrSearch = Request.FOrm("searchval")
StrAdvanced = Request("adv")
StrSort = Request("sort")
StrOrder = Request("order")
if strID = "" then
strID = "1"
end if
if strPorL = "" then
strPorL = "1"
end if
if strPrimCat = "" then
strPrimCat = "0"
end if
if strSubCat = "" then
strSubCat = "1"
end if
if StrSort = "" then
StrSort = "Name"
end if
if StrOrder = "" then
StrOrder = "Ascending"
end if
%>
")
rs.MoveNext 'Next record
loop
else
response.write("
Empty Catagory
")
end if
response.write("
")
my_conn.close ' Close database connection
Set my_conn = nothing 'obj variable released
' #OLD# Response.write("")
elseif StrPorL = "0" then ' Display Items in a list
%>
<%
strSQL = "SELECT * FROM gllists where id=" & strID
Set rs = my_conn.Execute(strSQL)
strTitle = "[ DB ERROR ]"
strDesc = "Database error - If problem persists please contact the Administrator."
if not rs.eof then
strTitle = rs("Title")
strSingleTitle = strTitle
strDesc = rs("Descrip")
end if
Set rs = nothing
TLevel = strPrimCat
do until TLevel = 0
strSQL = "SELECT * FROM gllists where SeconTree=" & TLevel
Set rs = my_conn.Execute(strSQL)
strTitle = "" & rs("Title") & " \ " & strTitle
TLevel = rs("PrimTree")
Set rs = nothing
loop
Response.write("
")
if (strHappyHour = true) then
response.write(" ")
end if
Response.write(StrTitle & "
")
' #OLD# Response.write("
" & StrDesc & "
")
Response.write("
" & StrDesc)
Response.write("
Note: Click on any product name to get more information about it
")
strSQL = "SELECT * FROM glitems where catid=" & strSubCat & " ORDER BY Name"
Set rs = my_conn.Execute(strSQL)
response.write("
")
response.write("
" & strSingleTitle & " (Products)
" & vbnewline)
response.write("
Product Name
Price
Brand
Availability
Pic
Add to Cart
" & vbnewline)
StrHighlight = "shop1"
%>
<%
if not rs.eof then
Do while not rs.eof ' Do until it reaches end of db
bSeed = int(rs("SeedProduct"))
bHHProduct = int(rs("HHProduct"))
iInStock = rs("InStock")
iMaxStock = rs("MaxStock")
iDelDays = rs("DelDays")
if iDelDays < 1 then
iDelDays = 1
end if
strAddText = " "
' Calculate avaliablity
if (bSeed = 1) then
strAddText = " per Kg"
'if int(iMaxStock) > 0 then
' iPercent = int(iInStock) / int(iMaxStock)
' iPercent = iPercent * 100
' if iPercent => 90 and iPercent <= 100 then
' StrAv = StrDesc9
' elseif iPercent => 80 and iPercent < 90 then
' StrAv = StrDesc8
' elseif iPercent => 70 and iPercent < 80 then
' StrAv = StrDesc7
' elseif iPercent => 60 and iPercent < 70 then
' StrAv = StrDesc6
' elseif iPercent => 50 and iPercent < 60 then
' StrAv = StrDesc5
' elseif iPercent => 40 and iPercent < 50 then
' StrAv = StrDesc4
' elseif iPercent => 30 and iPercent < 40 then
' StrAv = StrDesc3
' elseif iPercent => 20 and iPercent < 30 then
' StrAv = StrDesc2
' elseif iPercent => 10 and iPercent < 20 then
' StrAv = StrDesc1
' elseif iPercent => 0 and iPercent < 10 then
' StrAv = StrDesc0
' else
' StrAv = ""
' end if
'else
' StrAv = ".."
'end if
StrAv = iInStock & " Kg"
elseif (bHHProduct = 1) then ' Happyhour
if iInStock < 0 then
iInStock = 0
end if
StrAv = iInStock & " left"
else ' Standard product
if iInStock = "-1" then
StrAv = "1-" & iDelDays & " days"
else
StrAv = iInStock & " left"
end if
end if
Response.write("
")
if rs("ImageURL") <> "no_product.JPG" then
Response.write("
")
end if
Response.write("
")
Response.write("
")
if StrHighlight = "shop1" then
StrHighlight = "shop2"
else
StrHighlight = "shop1"
end if
rs.MoveNext 'Next record
loop
end if
my_conn.close ' Close database connection
Set my_conn = nothing 'obj variable released
Response.write("")
response.write("
")
elseif StrPorL = "3" then ' We are viewing an item
%>
<%
strSQL = "SELECT * FROM glitems where id=" & strID
Set rs = my_conn.Execute(strSQL)
if not rs.eof then
TLevel = rs("CatID")
StrTitle = rs("Name")
do until TLevel = 0
strSQL = "SELECT * FROM gllists where SeconTree=" & TLevel
Set rs = my_conn.Execute(strSQL)
strTitle = "" & rs("Title") & " \ " & strTitle
TLevel = rs("PrimTree")
Set rs = nothing
loop
strSQL = "SELECT * FROM glitems where id=" & strID
Set rs = my_conn.Execute(strSQL)
strProduct = rs("Name")
StrImage = rs("ImageURL")
StrBrand = rs("Brand")
StrPrice = rs("Price")
StrDeliverDays = rs("DelDays")
StrWeight = rs("Weight")
StrGLCode = rs("ITCode")
Set fs = CreateObject("Scripting.FileSystemObject")
ImagePath = server.MapPath("shopping") & "\images\products\" & strImage
if strImage = "" OR (fs.FileExists(ImagePath)) = false Then
StrImage = "no_product.JPG"
end if
Set fs = nothing
%>
<%
bSeed = int(rs("SeedProduct"))
bHHProduct = int(rs("HHProduct"))
iHHPrice = rs("HHPrice")
iInStock = rs("InStock")
iMaxStock = rs("MaxStock")
iDelDays = rs("DelDays")
strAddText = " "
if iDelDays < 1 then
iDelDays = 1
end if
' Calculate avaliablity
if (bSeed = 1) then
strAddText = " per Kg"
StrAv = iInStock & " Kg"
elseif (bHHProduct = 1) then
if iInStock < 0 then
iInStock = 0
end if
StrAv = "Availability: " & iInStock & " left"
else ' Standard product
if iInStock = "-1" then
StrAv = "Usually ships: 1-" & iDelDays & " days"
else
StrAv = "Availability: " & iInStock & " left"
end if
end if
if (bHHProduct = 1 and strHappyHour = true) then
strPrice = rs("HHPrice")
else
' If they are a whole saler
if strDWS = "1" then
strPrice = rs("WSPrice")
else
strPrice = rs("Price")
end if
end if
strPrice = Round(strPrice, 2)
Response.write("
" & StrTitle & "
")
Response.write("
")
Response.write(strProduct)
Response.write("
")
Response.write("
")
Response.write("")
Response.write("
")
if(bSeed = 0) then
Response.write("
Our Price: $" & Round(strPrice, 2) & "
")
else
Response.write("
Our Price: $" & Round(strPrice, 2) & " per Kg
")
end if
if (bHHProduct = 1 and strHappyHour = true) then
Response.write("
")
Response.write("Brand: " & strBrand & " ")
if(bSeed = 0) then
Response.write(StrAv & " ")
else
Response.write("Availability: " & StrAv)
Response.write(" Note: Customer to arrange transport ")
end if
if (bSeed = 0) then
Response.write("Shipping Weight: " & strWeight & " Kg ")
end if
Response.write("
")
' Product features
strSQL = "SELECT * FROM glitems2 where id=" & strID
Set rs = my_conn.Execute(strSQL)
if not rs.eof then
StrCat = rs("Features")
if(StrCat <> "") then
Response.write("
Product Features
")
if (StrCat = "") then
Response.Write("
[No product information]
")
else
Response.write("
")
SplitCat = Split(StrCat, "^") ' Features seperated by newline and :
for Index = 0 to ubound(SplitCat)
'SplitFeat = split(SplitCat(Index), ":")
'if ubound(SplitFeat) > 0 then
' Response.write("
" & SplitFeat(0) & ": " & SplitFeat(1) & "
")
'else
Response.write("
" & SplitCat(Index) & "
")
'end if
next
Response.write("
")
end if
Response.write("
")
end if
StrCat2 = rs("Descrip")
' Product description
if(StrCat2 <> "") then
Response.write("
Product Description
")
Response.write("
")
if (StrCat2 = "") then
Response.Write("[No product description]")
else
Response.Write(StrCat2)
end if
Response.write("
")
end if
' Product warranty
StrWarranty = rs("Warranty")
if strWarranty <> "" then
Response.write("
Product Warranty
")
Response.write("
" & strWarranty & "
")
end if
else
Response.write("
Database Error #2: If problem persists please contact the administrator.
")
end if
my_conn.close ' Close database connection
Set my_conn = nothing 'obj variable released
Response.write("")
else
response.redirect ("shopping.asp")
end if
end if
Response.write("
")
if StrPorL <> "3" and StrPorL <> "0" then ' Display a random special
%>
<%
strSQL = "SELECT Count(*) As myCount FROM glspecials"
Set rs = my_conn.Execute(strSQL)
Randomize()
' Find range size
intRangeSize = rs("myCount").value & vbnewline
intRangeSize = int(intRangeSize)
'response.write("=" & intRangeSize & "=")
if isnumeric(intRangeSize) = true then
' Get a random number from 0 to the size of the range
sngRandomValue = intRangeSize * Rnd()
' Convert our value to an integer
intRandomInteger = Int(sngRandomValue) + 1
strSQL = "SELECT * FROM glspecials"
Set rs = my_conn.Execute(strSQL)
iToDisplay = iNumSpecials
if intRangeSize < iToDisplay then
iToDisplay = intRangeSize
end if
iDisplayed = 0
response.write("
")
do until iDisplayed >= iToDisplay
if not rs.eof then
iCount = 1
do until iCount = intRandomInteger
if rs.eof then
iDisplayed = iToDisplay
iCount = intRandomInteger
else
rs.movenext
iCount = iCount + 1
end if
loop
if iDisplayed <> iToDisplay then
Set fs = CreateObject("Scripting.FileSystemObject")
strImage = rs("ImageURL")
if strImage = "" OR (fs.FileExists(server.MapPath("shopping") & "\images\specials\" & strImage)) = false Then
StrImage = "no_product2.jpg"
end if
set fs = Nothing
response.write("
")
response.write("
" & rs("Title") & "
")
response.write("
")
response.write("")
response.write("
")
if (rs("OldPrice") <> "0" and rs("NewPrice") <> "0") then
response.write("
")
set Img = nothing
end if
else ' There are no more specials
iDisplayed = iToDisplay
end if
response.write(" ")
intRandomInteger = intRandomInteger + 1
iDisplayed = iDisplayed + 1
loop
response.write("
")
end if
my_conn.close ' Close database connection
Set my_conn = nothing 'obj variable released
end if
%>