<%@ LANGUAGE="VBSCRIPT" %> <% PageStrings = "333, 364, 366, 368, 370, 371, 931, 370, 641, 933, 934" %> <% '=============================================== ' CactuShop ASP Shopping Cart ' ©1999-2004 Cactusoft Ltd. www.cactusoft.com '=============================================== ' All rights reserved. ' Use of this code is covered by the terms and ' conditions in the license agreement. No ' unauthorized duplication or distribution is ' permitted. Cactusoft's copyright notices must ' remain in the ASP sections of the code. '=============================================== '----------------------------------------------- 'PAGE HIT STATS - VERSIONS '----------------------------------------------- 'CHECK FOR VALID MONTH/YEAR 'Just check that the given month and year is 'valid. If not, set to current month/year. '----------------------------------------------- P_ID = Request.QueryString("P_ID") PT_ID = request.QueryString("PT_ID") numGivenMonth = Request.QueryString("numGivenMonth") numGivenYear = Request.QueryString("numGivenYear") If Not IsNumeric(P_ID) Or P_ID = "" Then Response.Redirect("_salesstats_main.asp") If Not IsNumeric(numGivenMonth) Or numGivenMonth = "" Or Not IsNumeric(numGivenYear) Or numGivenYear = "" Then numGivenMonth = Month(Date()) numGivenYear = Year(Date()) ElseIf DateDiff("m", numGivenYear & "/" & numGivenMonth & "/1", Year(Date) & "/" & Month(Date) & "/1") < 0 Or DateDiff("m", numGivenYear & "/" & numGivenMonth & "/1", DateAdd("m", -11, Year(Date) & "/" & Month(Date) & "/1")) > 0 Then numGivenMonth = Month(Date()) numGivenYear = Year(Date()) End If '----------------------------------------------- 'MySQL can't sort by a COUNT field it seems. 'Because we need to get the max-count value to 'draw the graphs correctly, we have to put all 'the values into an array, and then use that for 'drawing out the bars instead. '----------------------------------------------- 'Grab comma-list of all PT_Name's and P_Name's, used in SELECT and GROUP BYs of the queries numCounter = 0 For numCounter = 1 to numTotalLanguages if aryLangLiveBack(numCounter) = "y" then strNames = strNames & "tblCactuShopProducts.P_Name" & CStr(numCounter) & ", tblCactuShopVersions.V_Name" & CStr(numCounter) & ", " end if next strQuery = "SELECT SUM(tblCactuShopVersionSalesStats.VSS_Quantity) AS VersionHits, " & strNames & " tblCactuShopVersions.V_ID FROM (tblCactuShopVersionSalesStats INNER JOIN tblCactuShopVersions ON tblCactuShopVersionSalesStats.VSS_VersionNo = tblCactuShopVersions.V_ID) INNER JOIN tblCactuShopProducts ON tblCactuShopVersions.V_Product = tblCactuShopProducts.P_ID WHERE tblCactuShopProducts.P_ID = " & P_ID & " AND MONTH(tblCactuShopVersionSalesStats.VSS_Date) = " & numGivenMonth & " AND YEAR(tblCactuShopVersionSalesStats.VSS_Date)=" & numGivenYear & " GROUP BY " & strNames & " tblCactuShopProducts.P_ID, tblCactuShopVersions.V_ID ORDER BY tblCactuShopVersions.V_Name" & CStr(numLanguageID) Call ExecuteSQL(strQuery, numCursorType, objRecordSet) numRecordCount = objRecordSet.RecordCount If numRecordCount = 0 Then objRecordSet.Close Response.Redirect("_salesstats_main.asp?numGivenMonth=" & numGivenMonth & "&numGivenYear=" & numGivenYear) End If ReDim aryHitCount(numRecordCount, 2) numHits = 1 numMaxValue = 0 numTotalHits = 0 ProdType = objRecordSet(1) Do Until objRecordSet.EOF aryHitCount(numHits, 0) = CInt(objRecordSet("VersionHits")) aryHitCount(numHits, 1) = CInt(objRecordSet("V_ID")) 'get a non-blank name of the category - start with default aryHitCount(numHits, 2) = objRecordSet("V_Name" & CStr(numLanguageID)) If aryHitCount(numHits, 2) & "" = "" then 'if that's blank, loop around all languages till we find a non-blank numCounter = 0 For numCounter = 1 to numTotalLanguages if objRecordSet("V_Name" & cstr(numCounter)) & "" <> "" then aryHitCount(numHits, 2) = objRecordSet("V_Name" & CStr(numCounter)) exit for end if Next end if If aryHitCount(numHits, 0) > numMaxValue Then numMaxValue = aryHitCount(numHits, 0) numTotalHits = numTotalHits + aryHitCount(numHits, 0) numHits = numHits + 1 objRecordSet.MoveNext Loop objRecordSet.Close %> <% =GetString("Config_headtitle") %>
<% WriteString("PageTitle_VersionSales") %>
<% Response.Write(ProdType & " - " & MonthName(numGivenMonth) & " " & numGivenYear) %>
<% numHits = 1 Do Until numHits > numRecordCount '----------------------------------------------- 'TOTAL HITS FOR EACH PRODUCT 'This cycles through each product, calculates 'the hits for each and formulates the graphic 'display bars as a percentage of the best hit 'product. '----------------------------------------------- numBackgroundCounter = numBackgroundCounter + 1 If numBackgroundCounter mod 2 = 0 then strBgColour="#EEEEEE" Else strBgColour="#DDDDDD" End If If numMaxValue = 0 Then numDisplayWidth = 0 Else numDisplayWidth = Int((aryHitCount(numHits, 0) / numMaxValue) * 100) End If %> <% numHits = numHits + 1 Loop %>
<% WriteString("ContentText_ID") %> <% WriteString("ContentText_ShareOfHits") %>   <% WriteString("ContentText_Product") %>
<% =aryHitCount(numHits, 1) %> <% =aryHitCount(numHits, 0) %> <% =aryHitCount(numHits, 2) %>
  <% WriteString("ContentText_Total") %>: <% WriteString("ContentText_numTotalHitsForAboveMonth") %><% =numTotalHits %>  
<% WriteString("ContentText_BackToLink") %> <% WriteString("ContentText_Product") %>
<% objDataConn.Close %>