alesnap1
Members-
Content count
7 -
Joined
-
Last visited
About alesnap1
-
Rank
Forum Newbie
-
I noticed that now there's no more legend - category displayed. And I noticed that in the detailed per month/category/articles chart, the chart loads only the first IDCategory. I hope in an answer, as I can see no-one answer frequently.....
-
I found this code and worked fine for me...I'm trying to understand why when you try to open the "month/article detailed chart" by clicking on a month, the chart loads only CatID1.... //getCumulativeSalesByCatXML returns the cumulative sales for each category[/font][/color][color=#6B6B6B][font=verdana, arial, tahoma, sans-serif]//in a given year function getCumulativeSalesByCatXML($intYear, $forDataURL) { // Function to connect to the DB $link = connectToDB(); //To store categories - also flag to check whether category is //already generated //Initialize XML elements //Categories $strCat = "<categories>"; $arrCat =array(); $strSQL = "SELECT distinct Month(o.OrderDate) as MonthNum from FC_Orders as o WHERE year(o.OrderDate)=$intYear order by Month(o.OrderDate)"; $result = mysql_query($strSQL) or die(mysql_error()); if ($result) { $mc=0; while($orsCat = mysql_fetch_array($result)) { //Add this category as dataset $arrCat[$mc++]=date("n",mktime(0,0,0,$orsCat['MonthNum'],2,1994)); $strCat .= "<category label='" . date("F",mktime(0,0,0,$orsCat['MonthNum'],2,1994)) . "' />"; } mysql_free_result($result); } $strCat .= "</categories>"; //First we need to get unique categories in the database $strSQL = "Select CategoryID,CategoryName from FC_Categories GROUP BY CategoryID,CategoryName"; $result = mysql_query($strSQL) or die(mysql_error()); //To store datasets and sets $strDataXML = ""; if ($result) { while($orsCat = mysql_fetch_array($result)) { //Add this category as dataset $strDataXML .= "<dataset seriesName='" . escapeXML($orsCat['CategoryName'],$forDataURL) . "'>"; //Now, we need to get monthly sales data for products in this category $strSQL = "SELECT Month(o.OrderDate) as MonthNum, g.CategoryID, g.CategoryName, ROUND(SUM(d.Quantity),0) as Quantity, SUM(d.Quantity*p.UnitPrice) As Total FROM FC_Categories as g, FC_Products as p, FC_Orders as o, FC_OrderDetails as d WHERE year(o.OrderDate)=" . $intYear ." and g.CategoryID=" . $orsCat['CategoryID'] . " and d.ProductID=p.ProductId and g.CategoryID= p.CategoryID and o.OrderID= d.OrderID GROUP BY g.CategoryID,g.CategoryName,Month(o.OrderDate) order by Month(o.OrderDate)"; //Execute it $result2 = mysql_query($strSQL) or die(mysql_error()); $mc=0; while($ors = mysql_fetch_array($result2)) { //Append <category label=''> if not already done //Generate the link $strLink = urlencode("updateProductChart(" . $intYear . "," . $ors['MonthNum'] . "," . $ors['CategoryID'] . ");"); while($arrCat[$mc++]<$ors["MonthNum"]){ $strDataXML .="<set/>"; } $strDataXML .= "<set value='" . $ors['Total'] . "' link='" . $strLink . "'/>"; } //Clear up objects mysql_free_result($result2); //Close dataset element $strDataXML .= "</dataset>"; } } mysql_close($link); //Create full XML $strXML = $strCat . $strDataXML; //Return return $strXML;
-
Hi, as I haven't seen any answer I tried to rebuild the entire mysql database but I had the same error. I built the entire database as the infosoft database but charts load only the first IDcategory in the "detailed per month sales chart"...and I have also the same error in the "per year and category chart"... In my opinion something goes wrong with the load of the unique category but i'm in stuck..... Any ideas??? Please! Thanks P.S. If I try to make a query as in the code everything goes good!
-
Hi everyone, I'm newbie with fusioncharts and I'm trying to understand how it works by modifing infosot global. I have this problem...when I try to add a sale (for example on July) with no previous sales, fusioncharts put the sale on the first month which is free from previous sale for this specific product sale. Here's my code: function getCumulativeSalesByCatXML($intYear, $forDataURL) { // Function to connect to the DB $link = connectToDB(); //To store categories - also flag to check whether category is //already generated $catXMLDone = false; //Initialize XML elements $strCat = "<categories>"; //First we need to get unique categories in the database $strSQL = "Select id_categoria,categoria from categoria group by id_categoria,categoria"; $result = mysql_query($strSQL) or die(mysql_error()); //To store datasets and sets $strDataXML = ""; if ($result) { while($orsCat = mysql_fetch_array($result)) { //Add this category as dataset $strDataXML .= "<dataset seriesName='" . escapeXML($orsCat['categoria'],$forDataURL) . "'>"; //Now, we need to get monthly sales data for products in this category $strSQL = "SELECT Month(o.data_movimento) as MonthNum, g.id_categoria, g.categoria, ROUND(SUM(o.carichi),0) as Quantity, SUM(o.scarichi) As Total FROM categoria as g, articoli as p, movimenti_magazzino as o, utenti as d WHERE year(o.data_movimento)=" . $intYear ." and g.id_categoria=" . $orsCat['id_categoria'] . " and o.nome_articolo=p.nome_articolo and o.id_categoria=g.id_categoria and o.utente= d.utente GROUP BY g.id_categoria,g.categoria,Month(o.data_movimento)"; $result2 = mysql_query($strSQL) or die(mysql_error()); while($ors = mysql_fetch_array($result2)) { //Append <category label=''> if not already done if (!$catXMLDone) { $strCat .= "<category label='" . MonthName($ors['MonthNum'],true) . "' />"; } //Generate the link $strLink = urlencode("javaScript:updateProductChart(" . $intYear . "," . $ors['MonthNum'] . "," . $ors['categoria'] . ");"); //Append data $strDataXML .= "<set value='" . $ors['Total'] . "' link='" . $strLink . "'/>"; } //Update flag that we've appended categories $catXMLDone = true; //Clear up objects mysql_free_result($result2); //Close dataset element $strDataXML .= "</dataset>"; } } mysql_close($link); //Close </categories> $strCat .= "</categories>"; //Create full XML $strXML = $strCat . $strDataXML; //Return return $strXML; } And in attach the image where, I hope, someone can understand what I mean. Tnaks for help.