<?php 

	//session_start();

// https://www.fusioncharts.com/dev/chart-attributes/realtimestackedcolumn

// https://www.fusioncharts.com/charts/line-area-charts/line-chart-with-multiple-series?framework=php

// https://www.fusioncharts.com/dev/chart-guide/standard-charts/multi-series-charts

// https://www.fusioncharts.com/fusiontime/examples/plotting-multiple-series-on-time-axis?framework=javascript

	// sur l'axe des y : les tâches
	// sur l'axe des x : la durée pour la réalisation d'une tâche

	// https://www.geeksforgeeks.org/overview-of-burndown-chart-in-agile/
	
	// php diagramme d'avancement d'un projet
	
	// etat d'avancement
	
	// planification de projet
	
	// https://siocours.lycees.nouvelle-aquitaine.pro/doku.php/si7/si7.3
	
	// http://lyc-vaucanson-tours.tice.ac-orleans-tours.fr/php5/Accueil/index.php/gestion-de-projet/927-planifier-un-projet-avec-ganttproject
	
	//https://code.daypilot.org/93862/html5-gantt-chart
	
	// https://github.com/th0liveira/GanttChartPHP
	
	//  php time tracking open source
	
	// https://sourceforge.net/directory/time-tracking/php/
	
	// timeline
	
	// https://hotexamples.com/examples/-/TimeLine/-/php-timeline-class-examples.html
	
	//https://www.techieclues.com/blogs/converting-html-table-to-array-in-php

	// https://www.fusioncharts.com/dev/chart-attributes/scrollline2d

	
	/*
CREATE TABLE IF NOT EXISTS `graph02` (
  `id` int(11) DEFAULT NULL,
  `jour` varchar(255) NOT NULL,
  `val1` int(11) DEFAULT NULL,
  `val2` int(11) DEFAULT NULL,
  PRIMARY KEY (`jour`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
*/

	
	include("fusioncharts.php");
	include("database.php");
		
	/******************************************************************/
/*	
	$site = $_SERVER["SERVER_NAME"];

	$host = "";  
	$user = "";  
	$pass = ""; 
	$name = "";  

	if( ($site == "localhost") || ($site == "127.0.0.1") ) 
	{
		echo "Connexion mode local";
		echo "<br>";
		
		$_SESSION['hostdb']= "localhost"; 
		$_SESSION['userdb']= "root"; 
		$_SESSION['passdb']= "";
		$_SESSION['namedb']= "task_manager";   
	}
	else
	{	
		echo "Connexion hebergeur";
		echo "<br>";
				
		$_SESSION['hostdb']= "analogdepat.mysql.db"; 
		$_SESSION['userdb']= "analogdepat"; 
		$_SESSION['passdb']= "Un92pac007";
		$_SESSION['namedb']= "analogdepat";   
	}
	*/
	
	
	//blabla();
	
	
	
	
?>

<html>
   <head>
      <title>FusionCharts | Multi-Series Chart using PHP and MySQL</title>
	  <!--
        <script src="http://static.fusioncharts.com/code/latest/fusioncharts.js"></script>
        <script src="http://static.fusioncharts.com/code/latest/fusioncharts.charts.js"></script>
        <script src="http://static.fusioncharts.com/code/latest/themes/fusioncharts.theme.fint.js"></script>
	-->	
	
        <script src="js/js/fusioncharts.js"></script>
        <script src="js/js/fusioncharts.charts.js"></script>
        <script src="js/js/themes/fusioncharts.theme.fint.js"></script>
		
	
   </head>
   <body>
   
<?php

/*function graphique()
{
	blabla();
}
*/
//function blabla()
function graphique()
{
	
	$conn = db_connexion();
	
	// connexion
	/*$conn = new mysqli($_SESSION['hostdb'] , $_SESSION['userdb'], $_SESSION['passdb'], $_SESSION['namedb']);
	// gestion erreur de connexion
	if ($conn->connect_error) 
	{
		die("Connection failed: " . $conn->connect_error);
	}
	else
	{
		echo "DB connexion : OK";
		echo "<br>";
		
	}*/
	
	$strQuery = "SELECT * FROM aabbcc; ";
	$result = $conn->query($strQuery) or exit("Error code ({$conn->errno}): {$conn->error}");

	
	if ($result)
	{

		$arrData = array(
        "chart" => array(
        	  "caption"=> "Avancement des travaux",
            "xAxisname"=> "Semaine",
            "yAxisName"=> "YYY",
            "numberPrefix"=> "",
            "plotFillAlpha"=> "80",
        	  "showValues"=> "1",
        	  "placeValuesInside"=> "1",
        	  "usePlotGradientColor"=> "0",
        	  "rotateValues"=> "1",
        	  "valueFontColor"=> "#FFFFFF",
        	  "showHoverEffect"=> "1",
            "rotateValues"=> "1",
			
			"flatScrollBars"=> "1",
			"numVisiblePlot"=> "7",
			
            "showXAxisLine"=> "1",
			"rotateLabels"=> "1",
            "xAxisLineThickness"=> "1",
            "xAxisLineColor"=> "#999999",
            "showAlternateHGridColor"=> "0",
            "legendBgAlpha"=> "0",
            "legendBorderAlpha"=> "0",
            "legendShadow"=> "0",
            "legendItemFontSize"=> "10",
            "legendItemFontColor"=> "#666666",
            "theme"=> "fint"
          	)
         	);

		$categoryArray=array();
		$dataseries1=array();
		$dataseries2=array();
        	
		while($row = mysqli_fetch_array($result)) 
		{				
			$tmp = "210";
			array_push($categoryArray, array( "label" => $row["plage"])	);
			array_push($dataseries1, array(	"value" => $row["valeur"]) );
			array_push($dataseries2, array(	"value" => $tmp )	);
		}
	
		$arrData["categories"]=array(array("category"=>$categoryArray));
		$arrData["dataset"] = array(array("seriesName"=> "Prévision", "data"=>$dataseries1), array("seriesName"=> "Avancement", "data"=>$dataseries2));
		$jsonEncodedData = json_encode($arrData);
            			
		// chart object
		//scrollline2d
		//$burndown = new FusionCharts("msline", "chart1" , "100%", "400", "contenu", "json", $jsonEncodedData);
		$burndown = new FusionCharts("scrollline2d", "chart1" , "100%", "800", "contenu", "json", $jsonEncodedData);
		
		
		//scrollline2d
		
		$burndown->render();
		$conn->close();
	}
}
?>   
   
<?php
	
	//blabla();
	graphique();

?>

<center>
 
<div id="contenu"> 3 Chart will render here!</div>
 
</center>

</body>
   
</html>


