ต้องการดึงข้อมูลพนักงานมาคำนวนใน Highchart แต่มันเลือกมาไม่ได้ครับ ช่วยดูให้ทีโปรเจคจบ
ต้องการแสดงค่าในกราฟโดยเลือกชื่อพนักงาน แล้วเลือกเวลา แต่เหมือนมันผิดอะไรซักอย่างตอน query รบกวนช่วยทีได้นะครับ โปรเจคจบใกล้ส่งแล้ว TT
Code (PHP)
<body>
<? include "ConnectDB/DB_Connect.php";?>
<? $id = $_POST[user];?>
<center>
<? $result_user = mysql_query("SELECT id_user,name,lastname FROM user WHERE id_user NOT LIKE '$id' ORDER BY name");
$result_select = mysql_query("SELECT id_user,name,lastname FROM user WHERE id_user=$id " );
$data_select =@mysql_fetch_array($result_select)
?>
<form action="report-engineer.php" method="post">
<h1>Engineer Monthly Report</h1>
<table>
<tr>
<td><b>Name</b> :</td>
<td><select name='user' id='user' class="form-control input-form">
<? if($id!=NULL){?>
<option value='<?=$data_select[id_user]?>'>
<?=$data_select[name].' '.$data_select[lastname]?>
</option>
<? } ?>
<? while($data_user =@mysql_fetch_array($result_user)){?>
<option value='<?=$data_user[id_user]?>'>
<?=$data_user[name].' '.$data_user[lastname]?>
</option>
<? } ?>
</select></td>
<td>
<input type="text" class="form-control " name = "datetime" placeholder="Start Date" value="" id="datetimepicker1"></td> <td>
<input type="text" class="form-control " name = "datetime" placeholder="End Date" value="" id="datetimepicker2"></td>
<script type="text/javascript">
$(function () {
$('#datetimepicker1').datetimepicker({
icons: {
time: "fa fa-clock-o",
date: "fa fa-calendar",
up: "fa fa-arrow-up",
down: "fa fa-arrow-down"
}
,format: 'DD-MM-YYYY'
,pickTime: false
});
$('#datetimepicker2').datetimepicker({
icons: {
time: "fa fa-clock-o",
date: "fa fa-calendar",
up: "fa fa-arrow-up",
down: "fa fa-arrow-down"
}
,format: 'DD-MM-YYYY'
,pickTime: false
});
$("#datetimepicker1").on("dp.change", function (e) {
$('#datetimepicker1').data("DateTimePicker").minDate(e.date);
});
$("#datetimepicker2").on("dp.change", function (e) {
$('#datetimepicker1').data("DateTimePicker").maxDate(e.date);
});
});
</script>
<td>
<button type="submit" class="btn btn-default" value='ประมวลผล'>Confirm</button>
</td>
</tr>
</table>
</form>
<div id="container" style="min-width: 100px;width: 1000px; height: 450px; margin: auto"></div>
</center>
<?
$sql_user = "SELECT jd.id_user, u.name
FROM jobdata jd, jobtype jt
LEFT JOIN user u ON ( jd.id_user = u.id_user )
WHERE jd.id_user = u.id_user
AND jd.id_user = $id
GROUP BY name";
$result_user = mysql_query($sql_user);
?>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
<script>
$(function () {
$('#container').highcharts({
chart: {
type: 'column'
},
title: {
text: 'Engineer Monthly Report'
},
subtitle: {
text: 'Source: WorldClimate.com'
},
xAxis: {
categories: [
'Outsource',
'Phone & Remote Support (CRM)',
'Onsite Support (CRM)',
'Preventive Maintenance',
'Planning Project',
'Tacking Job',
'Meeting',
'New Installation',
'Testing',
'Presale',
'Trainer (internal/external)',
'Training (internal/external)',
'Other'
],
crosshair: true
},
yAxis: {
min: 0,
title: {
text: 'Time Result (Hr)'
}
},
tooltip: {
headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
'<td style="padding:0"><b>{point.y:.1f}Hr</b></td></tr>',
footerFormat: '</table>',
shared: true,
useHTML: true
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
series: [<? while($row_user=mysql_fetch_array($result_user)) {?>
{
<? $sql_report ="SELECT SEC_TO_TIME( SUM(
TIME_TO_SEC( TIMEDIFF( jd.timeend, jd.timestart ) ) ) ) AS SumTime,t.nameType AS nameType
FROM (
SELECT '1' AS nameType UNION
SELECT '2' AS nameType UNION
SELECT '3' AS nameType UNION
SELECT '4' AS nameType UNION
SELECT '5' AS nameType UNION
SELECT '6' AS nameType UNION
SELECT '7' AS nameType UNION
SELECT '8' AS nameType UNION
SELECT '9' AS nameType UNION
SELECT '10' AS nameType UNION
SELECT '11' AS nameType UNION
SELECT '12' AS nameType UNION
SELECT '13' AS nameType ) AS t
LEFT JOIN(jobtype jt,jobdata jd) ON (t.nameType = jt.id_type AND t.nameType=jd.id_type AND id_user=$row_user[id_user] ) GROUP BY nameType ORDER BY (
CASE nameType
WHEN '1' THEN 1 WHEN '2' THEN 2
WHEN '3' THEN 3 WHEN '4' THEN 4
WHEN '5' THEN 5 WHEN '6' THEN 6
WHEN '7' THEN 7 WHEN '8' THEN 8
WHEN '9' THEN 9 WHEN'10' THEN 10
WHEN '11' THEN 11 WHEN '12' THEN 12
ELSE 13 END )";
$result_Sum = mysql_query($sql_report); ?>
name: '<?=$row_user[name]?>',
data: [
<? while($row_Sum=mysql_fetch_array($result_Sum)) {?>
<? if($row_Sum['SumTime']==NULL){
$startDate = 0;
}else{$startDate = date("G.i",strtotime($row_Sum['SumTime']));}?>
<?=$startDate?>, <? } ?>]
},<? } ?>
]
});
});
</script>
</body>
</html>
Tag : PHP
Date :
2015-08-19 11:29:05
By :
kendocfc
View :
910
Reply :
2
Load balance : Server 05