%
'***************************************************************************
' Display all categories and their subcategories
' VP-ASP 6.50
' Dec 4, 2004 add logic for logon required
'*****************************************************************************
dim listdbc
sub NavigateCatJavaList
If getconfig("xlogonrequired")="Yes" then
If getsess("login")="" then
exit sub
end if
end if
dim sql, rs, level, rc, catdescription, categoryid
dim highercategoryid, hassubcategory,catcount,menusuffix,catcounter
shopopendatabase listdbc
highercategoryid=0
GenerateCatCountSql sql, highercategoryid
set rs=listdbc.execute(sql)
catcount=rs("catcount")
rs.close
set rs=nothing
Generatejavasql sql, highercategoryid
set rs=listdbc.execute(sql)
display_menu_config(catcount)
catcounter=0
do while not rs.eof
Getcategoryfields rs,categoryid, hassubcategory, catdescription, rc
If rc=0 then
catcounter=catcounter+1
menusuffix="Menu" & catcounter 'each menu needs a counter for each menu element/subelement, this var is used to keep track
Formatjavasubcategories categoryid, catdescription,hassubcategory, menusuffix
end if
rs.movenext
loop
closerecordset rs
display_menu_termination
shopclosedatabase listdbc
end sub
'
Sub Getcategoryfields (rs, categoryid, hassubcategory, strcategory, rc)
dim strcathide
categoryid=rs("categoryid")
strcategory=rs("catdescription")
hassubcategory=rs("hassubcategory")
If isnull(hassubcategory) then
hassubcategory=""
end if
strcathide=rs("cathide") ' hide field
if isnull(strcathide) then
rc=0
else
rc=4
end if
end sub
Sub Generatejavasql (sql, highercategoryid)
SQL="Select * from categories "
sql = Sql & " where highercategoryid=" & highercategoryid
if getconfig("xproductmatch")="Yes" then
'VP-ASP 6.50 - enhanced product matching
'sql=sql & " and productmatch='" & xproductmatch & "'"
GenerateProductmatchsqlsubs sql ' in shopproductsubs
end if
if getconfig("xproductmatchcustomer")="Yes" then
if GetSess("CustomerProductGroup")<>"" then
sql=sql & " and customermatch='" & getsess("customerProductgroup") & "'"
end if
end if
doselectcategoriesbylanguage sql
sql=sql & " order by " & Getconfig("xsortcategories")
end sub
Sub GenerateCatCountSql (sql, highercategoryid)
SQL="Select COUNT(categoryid) AS catcount from categories "
sql = Sql & " where highercategoryid=" & highercategoryid
if getconfig("xproductmatch")="Yes" then
'VP-ASP 6.50 - enhanced product matching
GenerateProductmatchsqlsubs sql ' in shopproductsubs
'sql=sql & " and productmatch='" & xproductmatch & "'"
end if
sql=sql & " and cathide is null"
if getconfig("xproductmatchcustomer")="Yes" then
if GetSess("CustomerProductGroup")<>"" then
sql=sql & " and customermatch='" & getsess("customerProductgroup") & "'"
end if
end if
doselectcategoriesbylanguage sql
end sub
Sub Formatjavacategory (id, name, catcount, menusuffix)
response.write menusuffix & "=new Array(""" & name & """,""shopdisplayproducts.asp?id=" & id & "&cat=" & Server.URLEncode(name) & """,""""," & catcount & ",20,150);" & vbcrlf
end sub
Sub Formatjavasubcategories (categoryid, highercatdescription, hassubcategory, menusuffix)
dim sql, rs, rc, catdescription, catcount,catcounter,submenusuffix
GenerateCatCountSql sql, categoryid
set rs=listdbc.execute(sql)
catcount=rs("catcount")
rs.close
set rs=nothing
Generatejavasql sql, categoryid
Set rs=listdbc.execute(sql)
if hassubcategory="" then
catcount=0
end if
Formatjavacategory categoryid, highercatdescription, catcount, menusuffix
if cint(catcount)=0 then
rs.close
set rs=nothing
exit sub 'no subcategories to process
end if
catcounter=0
do while not rs.eof
Getcategoryfields rs,categoryid, hassubcategory, catdescription, rc
If rc=0 then
catcounter=catcounter+1
submenusuffix=menusuffix & "_" & catcounter
Formatjavasubcategories categoryid, catdescription, hassubcategory, submenusuffix
end if
rs.movenext
loop
closerecordset rs
end sub
sub doselectcategoriesbylanguage (sql)
If getconfig("xselectproductsbylanguage")="Yes" and getsess("language")<>"" then
sql=sql & " and (catlanguage='" & getsess("language") & "'"
sql=sql & " or catlanguage is null)"
end if
end sub
sub display_menu_config( numberofmenuitems )
%>
<%
end sub
%>