HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/xampp/htdocs/FograCT1/lineGraphDTcr10.php
<?php
extract($_REQUEST);
//session_start();
//error_reporting(E_ALL ^ E_NOTICE);?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>PSA Production Report--</title>

</head>
<?php
session_destroy();
//echo "session_destroy";
$po=$_GET['po'];
$servername = "localhost:3306";
$username = "root";
$password = "fredsql";
$DBNAME = "ntua";

// $link = mysql_connect("127.0.0.1", "root", "fredsql") or die ("Unable to connect!");

$conn = new mysqli($servername, $username, $password);

// Check connection
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}
//echo "Connected successfully";

if( !mysqli_select_db($conn, $DBNAME)) {
  die ("無法選擇資料庫");
}

// generate and execute query
$query = "SELECT * from stdrecord where stid='$po' order by id";
//echo $query;
$result =  mysqli_query($conn, $query);
// if records present
$i=0;
	// iterate iii through resultset
	// print title with links to edit and delete scripts
	
	$timear= array();


	$fscorear= array();

$num = mysqli_num_rows($result);
$i=0;
echo "num:".$num;
		while ($i < $num)
		{		
		$row = mysqli_fetch_object($result);	
		$name=$row->name;
	
	//while($row = mysqli_fetch_object($result))
	//{
	$i=$i+1;
			
	$tm=$row->ddate;

	//echo "line45:".$i."-".$tm."__";
	array_push($timear, $tm);
	
		$file=$row->filename;
	array_push($filear, $file);
	
	$Fsc=$row->score;
	array_push($fscorear, $Fsc);
	
	}
	$max=$i;
	//echo "maxi:".$i."-__";
	
//print_r($fscorear);
	
	date_default_timezone_set('Asia/Taipei'); 
	function timeDiff($firstTime,$lastTime)
	{

// convert to unix timestamps
$firstTime=strtotime($firstTime);
$lastTime=strtotime($lastTime);

// perform subtraction to get the difference (in seconds) between times
$timeDiff=$lastTime-$firstTime;

// return the difference
return $timeDiff;
}


/*
$queryc = "SELECT Cscore from production where po='$po' and sNo>'$sn' order by id";
$resultc = mysql_query($queryc) or die ("Error in query: $query. " . mysql_error());
	while($row = mysql_fetch_object($resultc))
	{
	$Cscore=$row->Cscore;
	$Csum=$Csum+$Cscore;
	//$Fscore=$row->Fscore;
	//$Fsum=$Fsum+$Fscore;
	$c=$c+1;
	}	
	$Favg=round($Fsum/$f,2);
	$Cavg=round($Csum/$c,2);
	//echo "cc:".$c;
	//echo "cc:".$Cavg;
		echo "工單號碼:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$po."<br>";	
	echo "開始時間:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$timear[0]."<br>";
	if ($ok<>'') {
	echo "OK sheet 時間:&nbsp;"."[".$ok."]-&nbsp;".$timear[$ok-1]."&nbsp;&nbsp;**OK sheet 工時:".gmdate("H:i:s", timeDiff($timear[0],$timear[$ok-1]))."<br>";}
	
	if ($ok<>'') {
	echo "結束時間:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".end($timear)."&nbsp;&nbsp;********生產工時:".gmdate("H:i:s", timeDiff($timear[$ok-1],end($timear)))."<br>";}
	else {
	echo "結束時間:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".end($timear)."&nbsp;&nbsp;********生產工時:".gmdate("H:i:s", timeDiff($timear[0],end($timear)))."<br>";}
	
	echo "總工作時間:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
	echo  gmdate("H:i:s", timeDiff($timear[0],end($timear)));
	echo "<br>OK sheet 分數:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
	echo  $fscore;
	echo "<br>生產分數:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
	echo  $Cavg;
*/	
?>

<table width="300"  align="center"> <font color="green">
<tr>
<td> Date of press run: </td><td><?php echo $tm;?></td></tr><tr>

<td> Job id: </td><td><?php echo $po;?></td>
</tr>
</table>

<p>
<table width="200" border="1" align="center"> <font color="green">

<tr>
<td><div align="center">
<?php 
for ( $j = 1; $j <= $i; $j += 1) {
?><a href="tvireportx.php?target=Fogra39&f321=upload/<?php print $filear[$j-1]."&okfile="; 
 
echo  $filear[1];
?>"><?php  echo $j." ";?></font></a>
 

<?php
//echo print_r ($filear);
///http://127.0.0.1/fogra627/tvireport.php?tvifile=H3_627TT_627_2013-11-28_163409_18.csv
}

?>
</td></tr>

<tr>
<td><div align="center">
<?php // content="text/plain; charset=utf-8" 
require_once ('../jpgraph/jpgraph.php');
require_once ('../jpgraph/jpgraph_line.php');
require_once ('../jpgraph/jpgraph_plotline.php'); 

unlink('CMYSID.png');


$datay1 = $fscorear;
//$datay1 = array(32,56,77,83,92,99);



// Setup the graph
$graph = new Graph(550,430);
//$graph->SetScale("textint",0,6,0,0);
$graph->SetScale("textint");

$theme_class= new UniversalTheme;
$graph->SetTheme($theme_class);

$graph->title->Set('score');
$graph->SetBox(false);

$graph->yaxis->HideZeroLabel();
$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false,false);
//$graph->xaxis->SetTickLabels(array('0','2','4','6','8','10'));
//$graph->xaxis->SetTickLabels(array(1,2,3,4,5,6,7,8));
$graph->ygrid->SetFill(false);
//$graph->SetBackgroundImage("tiger_bkg.png",BGIMG_FILLFRAME);

$p1 = new LinePlot($datay1);
$graph->Add($p1);




$p1->SetColor("#55bbdd");
$p1->SetLegend('score');
$p1->mark->SetType(MARK_FILLEDCIRCLE,'',1.0);
$p1->mark->SetColor('#55bbdd');
$p1->mark->SetFillColor('#55bbdd');
$p1->SetCenter();





$graph->legend->SetFrameWeight(1);
$graph->legend->SetColor('#4E4E4E','#00A78A');
$graph->legend->SetMarkAbsSize(8);


// Output line
$graph->Stroke('CMYSID.png');
?>
<img src="CMYSID.png?nocache=<?php echo time(); ?>">
</div></td></tr>
</table>

  <p><p>  <p><p>  <p><p>
  <table width="200" border="1" align="center">

</tr>
</table>

<p>

</div></td></tr>
</table>

  <p><p>  <p><p>  <p><p>

  <p>&nbsp;</p>
  <p>&nbsp;</p>
 
    <?php
  $chl = "http://fredkuo.idv.tw/FograCT1/lineGraphDTcr10.php?po=".$po; //vcard尾資訊
echo "<img src='https://chart.googleapis.com/chart?cht=qr&chl=".urlencode($chl)."&choe=UTF8&chs=200x200' />"; //要對內容urlencode()
?>
  <p>&nbsp;</p>

<!-- graph code ends here-->