hakkatil
VP-CART New User
109 Posts |
Posted - June 13 2002 : 16:54:54
|
Hi guys. I like vpasp very much. I have been using this product over 2 years now. Good Job.
I needed to display top ten products on my website and VPASP does not have one as you all know (it should have been included on a great product like VPASP without charging money). Anyway, I decided to spend a couple hours on this project and here it is. I changed shop_productreport.asp to display top ten products on a page. You can change the number as you like (line 101).
This is straight forward. Just copy this code and paste on a page say "topten.asp". then include this page on whatever page you want. Ex. <!--#include file="topten.asp"--> Note: if you include this file on a page, delete these line below, otherwise just copy and paste the code for linking this page from another page <%option explicit%> <!--#include file="shop$db.asp"--> <!--#include file="shop$language2.asp"-->
---------------------------------
<%option explicit%> <!--#include file="shop$db.asp"--> <!--#include file="shop$language2.asp"--> <% '*********************************************************** ' VP-ASP Product/Supplier Report ' Supplier Reports ' inputs are table, database ' Version 4.00 ' Nov 17, 2001 ' Modified by Hakan '*************************************************************
dim allflag Dim Capfields(10) dim fieldcount Dim ScriptResponder Dim Dbc dim Action Dim rs Dim Limit Dim Month Dim productdbc Dim affid, affdbc, orders Dim affsql, affrs Dim unitprice,supplierid, prevsupplier Dim ordercount dim orderamount Dim count dim fieldvalue GetInput GenerateSQL WriteReport
'******************************** Sub GetInput Serror="" allflag="" limit=request("Limit") if limit="" then limit=100 end if SetSess "ReportLimit",limit mypagesize=limit action="" end sub ' Sub GenerateSQL dim datesql,strsql, whereok Dim newsql mypage=1 ' first time through whereok=" and " strsql="select oitems.supplierid, oitems.catalogid, oitems.unitprice,oitems.itemname, sum(oitems.numitems) as sumofnumitems " strsql=strsql & " from orders,oitems " strsql=strsql & " where orders.orderid = oitems.orderid " strsql=strsql & " GROUP BY oitems.supplierid, oitems.catalogid, oitems.unitprice,oitems.itemname " strsql=strsql & " ORDER BY sum(oitems.numitems) DESC" sql=strsql end sub ' Sub WriteReport ShopOpenOtherDB dbc, getconfig("xorderdb") Shopopendatabase productdbc ShopOpenRecordSet SQL,RS, mypagesize, mypage ProduceDetail Shopclosedatabase Productdbc ShopClosedatabase dbc end sub '
Sub GetOrderDetails ordercount=rs("SumOfNumItems") unitprice=rs("unitprice") orderamount=ordercount*Unitprice lngcatalogid=rs("Catalogid") supplierid=rs("Supplierid") if isnull(supplierid) then supplierid=0 end if affsql="select * from products where catalogid=" & lngcatalogid set affrs=productdbc.execute(affsql) If affrs.eof then strcname="" else strcname=affrs("cname") end if affrs.close set affrs=nothing end sub
Sub ProduceDetail dim count count=0 limit=clng(mypagesize) prevsupplier="" Formattablestart While Not rs.EOF and count<10 ' changing 10 to a different number will cause to display that many products GetOrderDetails If PrevSupplier<>supplierid then FormattableEnd prevsupplier=supplierid FormatTableStart end if FormatRow count=count+1 rs.movenext wend FormattableEnd rs.close set rs=nothing end sub ' Sub FormatRow dim i, name, kes, item dim fieldvalue Response.write "<tr>" FormatAffid name=rs("itemname") 'in oitems field itemname also inludes name of products. this will take products name away 'from itemname field kes=Instr(name, ">") ' here item takes all the text itemname contains 'if you want just certain size of text lets say 100 chars, uncomment below line 'item=Mid(name,kes+1,100) 'and comment this line item=Mid(name,kes+1) Writecolumn item '& "..." response.write "</tr>" end sub
Sub FormatAffid scriptresponder="shopaddtocart.asp?catalogid=" & rs("catalogid")& "&quantity=1" fieldvalue="<a HREF=" & scriptresponder &">" & strcname & "</a>" writecolumn fieldvalue end sub
Sub WriteColumn (fieldvalue) response.write ReportDEtailColumn & fieldvalue & ReportDEtailColumnEnd end sub
Sub FormattableStart dim i if prevsupplier="" then exit sub CapFields(0)=LangProductName CapFields(1)="Description" fieldcount=1 response.write ReportTableDef response.write ReportHeadRow for i = 0 to fieldcount response.write ReportHeadColumn & capfields(i) & ReportHeadColumnEnd next
response.write ReportRowEnd end sub Sub FormatTableEnd response.write ReportTableEnd end sub %>
Edited by - hakkatil on June 13 2002 17:10:11
Edited by - hakkatil on June 13 2002 17:11:58
Edited by - hakkatil on June 13 2002 18:13:46 |
|