File "000index.php"

Full Path: /home/analogde/www/MDPH/Fusion01/000index.php
File size: 16.52 KB
MIME-type: text/x-php
Charset: utf-8

<?php 


	// 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

// php scheduled task

	date_default_timezone_set('Europe/Paris');

	include("fusioncharts/fusioncharts.php");

	$temps_debut = "2024-01-11";
	$temps_fin = "2024-01-25";
	
	
	if (isset($_POST['Submit']))
	{
		echo "Bingo...";
		
		
	}
	//blabla($temps_debut, $temps_fin);
	
?>

<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>
   </head>
   <body>
   
<?php

function blabla($temps_debut, $temps_fin)
{

	// générer les timestamps sur un période donnée
	
	//$start_date = new DateTime("2024-01-11");
	//$end_date = new DateTime("2024-01-25");
	
	$start_date = new DateTime($temps_debut);
	$end_date = new DateTime($temps_fin);
 
	echo $start_date->getTimestamp();
	echo "<BR>";
	echo $end_date->getTimestamp();
	echo "<BR>";
	
	//$plouf = $start_date->modify('+1 day');
	//echo $plouf->getTimestamp();
	
	$nombreSecondParJour = 3600 * 24; 
	
	//$date = new DateTime();
	//$date->setTimestamp($start_date);

	//echo $date->format('Y-m-d');
	
	$timestamp_start = $start_date->getTimestamp();
	
	$timestamp = $timestamp_start ;
	
	$pipo = array();
	
	for ($x = 1; $x <= 10; $x++) 
	{
		$timestamp = $timestamp + $nombreSecondParJour;
		$dateTime = date('d-m-Y ', $timestamp );
		
		//echo gettype($dateTime);
		//echo "<br>";
		
		$item = (string)$x;
		//echo gettype($item);
		//echo "<br>";
		
		echo $item ." " .$dateTime;
		echo "<br>";
		
		$pipo[] = $dateTime;
		
		//$s = $dateTime + " titi";
		//echo $s;
		//echo "<br>";
		
		
		
		//echo $item + " 64644 ";
		
		//$result = $dateTime->format('Y-m-d H:i:s');
		
		//echo $item + $dateTime;
		
	}

	print_r($pipo);
	
	echo count($pipo);

	//$s1 = "John";
	//echo "<br>";
	//$sql = "INSERT INTO MyGuests (firstname, lastname, email) VALUES ( '$s1', 'Doe', 'john@example.com')";

	$hostdb = "localhost";  // MySQl host
	$userdb = "root";  // MySQL username
	$passdb = "";  // MySQL password
	$namedb = "task_manager";  // MySQL database name

	$dbhandle = new mysqli($hostdb, $userdb, $passdb, $namedb);

	if ($dbhandle->connect_error) 
	{
		exit("There was an error with your connection: ".$dbhandle->connect_error);
	}

	

	$val1 = array(250, 220, 200, 180, 160, 135,120, 100, 82, 70);
	$val2 = array(220, 200, 100, 100, 50, 220, 200, 100, 100, 50 );
/*
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;
*/

	echo "<br>";

	for ($i = 1; $i <= count($pipo); $i++)
	{
		$indice = $i - 1;
		
		$sql = "INSERT INTO graph02 (id, jour, val1, val2) VALUES ( '$i', '$pipo[$indice]', '$val1[$indice]', '$val2[$indice]' )";
		//echo $sql;
		//echo "<br>";
		
		//$result = $dbhandle->query($sql) or exit("Error code ({$dbhandle->errno}): {$dbhandle->error}");
		
	}		
	
	$strQuery = "SELECT * FROM graph02; ";

	$result = $dbhandle->query($strQuery) or exit("Error code ({$dbhandle->errno}): {$dbhandle->error}");

	if ($result)
	{

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

		$arrData = array(
        "chart" => array(
        	  "caption"=> "blabla",
            "xAxisname"=> "XXX",
            "yAxisName"=> "YYY",
            "numberPrefix"=> "",
            "plotFillAlpha"=> "80",
        	  "showValues"=> "1",
        	  "placeValuesInside"=> "1",
        	  "usePlotGradientColor"=> "0",
        	  "rotateValues"=> "1",
        	  "valueFontColor"=> "#FFFFFF",
        	  "showHoverEffect"=> "1",
            "rotateValues"=> "1",
			
			"flatScrollBars"=> "1",
			"numVisiblePlot"=> "3",
			
            "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)) 
		{				
			array_push($categoryArray, array( "label" => $row["jour"])	);

			array_push($dataseries1, array(	"value" => $row["val1"]) );
				
			array_push($dataseries2, array(	"value" => $row["val2"])	);

		}
	
		$arrData["categories"]=array(array("category"=>$categoryArray));
	
		$arrData["dataset"] = array(array("seriesName"=> "Prévision", "data"=>$dataseries1), array("seriesName"=> "Avancement", "data"=>$dataseries2));
		
		//echo "<pre>";
		//print_r($arrData["dataset"]);
		//echo "</pre>";

		$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();
		$dbhandle->close();
	}
}
?>   
   
<?php
  
function lulu()
{

	$hostdb = "localhost";  // MySQl host
	$userdb = "root";  // MySQL username
	$passdb = "";  // MySQL password
	$namedb = "task_manager";  // MySQL database name

	$dbhandle = new mysqli($hostdb, $userdb, $passdb, $namedb);

	if ($dbhandle->connect_error) 
	{
		exit("There was an error with your connection: ".$dbhandle->connect_error);
	}

	//$strQuery = "SELECT DISTINCT month, year_a, year_b FROM visitor_data; ";

	$strQuery = "SELECT * FROM visitor_data; ";

	$result = $dbhandle->query($strQuery) or exit("Error code ({$dbhandle->errno}): {$dbhandle->error}");

  if ($result) {
        	
	$arrData = array(
        "chart" => array(
        	  "caption"=> "Comparison of Yearly Visitors",
            "xAxisname"=> "Month",
            "yAxisName"=> "Revenues (In USD)",
            "numberPrefix"=> "$",
            "plotFillAlpha"=> "80",
        	  "showValues"=> "1",
        	  "placeValuesInside"=> "1",
        	  "usePlotGradientColor"=> "0",
        	  "rotateValues"=> "1",
        	  "valueFontColor"=> "#FFFFFF",
        	  "showHoverEffect"=> "1",
            "rotateValues"=> "1",
            "showXAxisLine"=> "1",
            "xAxisLineThickness"=> "1",
            "xAxisLineColor"=> "#999999",
            "showAlternateHGridColor"=> "0",
            "legendBgAlpha"=> "0",
            "legendBorderAlpha"=> "0",
            "legendShadow"=> "0",
            "legendItemFontSize"=> "10",
            "legendItemFontColor"=> "#666666",
            "theme"=> "fint"
          	)
         	);

        	// creating array for categories object
        	
        	$categoryArray=array();
        	$dataseries1=array();
        	$dataseries2=array();
        	
          // pushing category array values
        	while($row = mysqli_fetch_array($result)) {				
				    array_push($categoryArray, array(
					  "label" => $row["month"]
					)
				);

				array_push($dataseries1, array(
					"value" => $row["year_a"]
					) 
				);
			
				array_push($dataseries2, array(
					"value" => $row["year_b"]
					)
				);
    
    	}
        	
    	$arrData["categories"]=array(array("category"=>$categoryArray));

		/*echo "<pre>";
		print_r($categoryArray);
		echo "</pre>";	

		echo "<pre>";
		print_r($dataseries1);
		echo "</pre>";
		
		echo "<pre>";
		print_r($dataseries2);
		echo "</pre>";
		
		echo "<pre>";
		print_r($arrData["categories"]);
		echo "</pre>";*/
		
		// creating dataset object
		$arrData["dataset"] = array(array("seriesName"=> "2014", "data"=>$dataseries1), array("seriesName"=> "2015", "data"=>$dataseries2));
		
		/*echo "<pre>";
		print_r($arrData["dataset"]);
		echo "</pre>";*/

		$jsonEncodedData = json_encode($arrData);
            			
		// chart object
		//$msChart = new FusionCharts("mscolumn2d", "chart1" , "100%", "400", "chart-container", "json", $jsonEncodedData);
		$msChart = new FusionCharts("msline", "chart1" , "100%", "400", "chart-container", "json", $jsonEncodedData);
	
		$msChart->render();
			 
		// closing db connection
		$dbhandle->close();
           
   }
} 
 
	//lulu();
 
	//toto();
	
	blabla($temps_debut, $temps_fin);
 
?>

<center>

 <div id="chart-container">Chart will render here!</div>
 
 <div id="container">Chart will render here!</div>
 
 <div id="contenu">Chart will render here!</div>
 
</center>

<style>
.wrapper {
  overflow-x: scroll;
}

.wrapper table {
  white-space: nowrap;
}

/** Only for demo */
table,
td,
th {
  border-collapse: collapse;
  border: 1px solid #777;
}

input {
            margin: 1px;
            padding: 2px
        }

th {
  padding: 5px;
  background: #ddd;
}

td {
  padding: 5px 10px;
}

</style>

<!--
 https://stackoverflow.com/questions/62532819/html-input-inside-table-cell

https://stackoverflow.com/questions/62532819/html-input-inside-table-cell

https://www.phpzag.com/create-dynamic-bootstrap-tabs-with-php-mysql/ ++++++

https://coderszine.com/editable-html-table-with-jquery-php-mysql/

https://www.phpflow.com/html5/simple-example-of-editable-table-in-html5/

-->


<div class="wrapper">
  <table id="myTable">
    <tr>
      <th>Col1</th>
      <th>Col2</th>
      <th>Col3</th>
      <th>Col4</th>
      <th>Col5</th>
      <th>Col6</th>
      <th>Col7</th>
      <th>Col8</th>
      <th>Col9</th>
      <th>Col10</th>
	  <th>Col11</th>
      <th>Col12</th>
      <th>Col13</th>
      <th>Col14</th>
      <th>Col15</th>
      <th>Col16</th>
      <th>Col17</th>
      <th>Col18</th>
      <th>Col19</th>
      <th>Col20</th>
    </tr>
    <tr>
      <td><input id="indice" type="string" size=5></td>
      <td><input type="string" size=5></td>
      <td><input type="string" size=5></td>
      <td><input type="string" size=5></td>
      <td><input type="string" size=5></td>
      <td><input type="string" size=5></td>
	  <td><input type="string" size=5></td>
      <td><input type="string" size=5></td>
      <td><input type="string" size=5></td>
      <td><input type="string" size=5></td>
      <td><input type="string" size=5></td>
      <td><input type="string" size=5></td>
      <td><input type="string" size=5></td>
      <td><input type="string" size=5></td>
      <td><input type="string" size=5></td>
      <td><input type="string" size=5></td>
	  <td><input type="string" size=5></td>
      <td><input type="string" size=5></td>
      <td><input type="string" size=5></td>
      <td><input type="string" size=5></td>

      
    </tr>
    <tr>
      <td>xxx</td>
      <td>aaa </td>
      <td>bbb </td>
      <td>ccc </td>
      <td>ddd </td>
      <td>eee </td>
      <td>fff </td>
      <td>ggg </td>
      <td>hhh </td>
      <td>iii </td>
	  <td>xxx</td>
      <td>aaa </td>
      <td>bbb </td>
      <td>ccc </td>
      <td>ddd </td>
      <td>eee </td>
      <td>fff </td>
      <td>ggg </td>
      <td>hhh </td>
      <td>iii </td>
    </tr>
    <tr>
      <td>xxx</td>
      <td>aaa </td>
      <td>bbb </td>
      <td>ccc </td>
      <td>ddd </td>
      <td>eee </td>
      <td>fff </td>
      <td>ggg </td>
      <td>hhh </td>
      <td>iii </td>
	  <td>xxx</td>
      <td>aaa </td>
      <td>bbb </td>
      <td>ccc </td>
      <td>ddd </td>
      <td>eee </td>
      <td>fff </td>
      <td>ggg </td>
      <td>hhh </td>
      <td>iii </td>
    </tr>
  </table>
</div>

<br><br><br>

	<form action=""  method="POST">
		<input type="submit" name="Submit" value="send">
    </form>
	
	<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() 
{
  var x = document.getElementById("myTable").rows[1].cells.length;
  document.getElementById("demo").innerHTML = "Found " + x + " cells in the first tr element.";
  
  //var toto = document.getElementById("myTable").rows[2].cells[6].innerHTML;
  
  
  //alert(toto);
  
  //object HTMLTableCellElement
  
  // var toto = document.getElementById("myTable").rows[1].cells[0];
  
  // OK
  //var toto = document.getElementById("myTable").rows[1].cells[0].getElementsByTagName('input')[0].value;
  // OK
  //var toto = document.getElementById("myTable").rows[1].cells[1].getElementsByTagName('input')[0].value;
  
  //var toto = document.getElementById("myTable").rows[1].cells[0].getElementById('indice').value;
  //OK
  var toto = document.getElementById("myTable").rows[1].cells[0].firstChild.value;
  
  alert(toto);
  
  if (isNaN(toto)) 
  {
    alert("Must input numbers");
    return false;
  }
  
}
</script>

</body>
   
   
</html>

<?php  

function toto()
{

	$hostdb = "localhost";  // MySQl host
	$userdb = "root";  // MySQL username
	$passdb = "";  // MySQL password
	$namedb = "task_manager";  // MySQL database name

	$dbhandle = new mysqli($hostdb, $userdb, $passdb, $namedb);

	if ($dbhandle->connect_error) 
	{
		exit("There was an error with your connection: ".$dbhandle->connect_error);
	}

	$strQuery = "SELECT * FROM graph01;";

	$result = $dbhandle->query($strQuery) or exit("Error code ({$dbhandle->errno}): {$dbhandle->error}");

	if ($result) 
	{
        	
			
			$arrData = array(
				"chart" => array(
					  "caption"=> "Graphe d'avancement",
					"xAxisname"=> "Temps écoulé",
					"yAxisName"=> "Effort",
					"numberPrefix"=> "",
					"plotFillAlpha"=> "80",
					  "showValues"=> "1",
					  "placeValuesInside"=> "1",
					  "usePlotGradientColor"=> "0",
					  "rotateValues"=> "1",
					  "valueFontColor"=> "#FFFFFF",
					  "showHoverEffect"=> "1",
					"rotateValues"=> "1",
					"showXAxisLine"=> "1",
					"xAxisLineThickness"=> "1",
					"xAxisLineColor"=> "#999999",
					"showAlternateHGridColor"=> "0",
					"legendBgAlpha"=> "0",
					"legendBorderAlpha"=> "0",
					"legendShadow"=> "0",
					"legendItemFontSize"=> "10",
					"legendItemFontColor"=> "#666666",
					"theme"=> "fint"
					)
					);

        	// creating array for categories object
        	
        	$categoryArray=array();
        	$dataseries1=array();
        	$dataseries2=array();
        	
          // pushing category array values
        	while($row = mysqli_fetch_array($result)) 
			{				
				    array_push($categoryArray, array("label" => $row["jour"]));

					array_push($dataseries1, array(	"value" => $row["val1"]));
			
					array_push($dataseries2, array(	"value" => $row["val2"]));
    
			}
        	
			$arrData["categories"]=array(array("category"=>$categoryArray));
		
			// creating dataset object
			$arrData["dataset"] = array(array("seriesName"=> "Réel", "data"=>$dataseries1), array("seriesName"=> "Prévision", "data"=>$dataseries2));
		
			/*echo "<pre>";
			print_r($arrData["dataset"]);
			echo "</pre>";*/

			$jsonEncodedData = json_encode($arrData);
            			
			// chart object
			$graphique = new FusionCharts("msline", "chart1" , "100%", "400", "container", "json", $jsonEncodedData);
	
			$graphique->render();
			 
			
			$dbhandle->close();
           
   }
}
/*
CREATE TABLE IF NOT EXISTS `burndown` (
  `jour` varchar(255) NOT NULL,
  `valeur` int(11) DEFAULT NULL,
  PRIMARY KEY (`jour`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
*/

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

INSERT INTO `graph01` (`jour`, `val1`, `val2`) VALUES ('01', 200, 100)
INSERT INTO `graph01` (`jour`, `val1`, `val2`) VALUES ('02', 160, 100)
INSERT INTO `graph01` (`jour`, `val1`, `val2`) VALUES ('03', 160, 100)
INSERT INTO `graph01` (`jour`, `val1`, `val2`) VALUES ('04', 140, 100)
INSERT INTO `graph01` (`jour`, `val1`, `val2`) VALUES ('05', 110, 100)
INSERT INTO `graph01` (`jour`, `val1`, `val2`) VALUES ('06', 90, 100)
INSERT INTO `graph01` (`jour`, `val1`, `val2`) VALUES ('07', 68, 100)
*/


?>