|
|
|
การส่งค่าตัวเลข เดือน และ ปี ใน php ไปให้ใน Javascript ครับ |
|
|
|
|
|
|
|
ทำแล้วไม่ได้ครับพี่ ตอนนี้ กราฟไม่โชว์เลยครับ เดียวผมเอาโค้ดที่เขียนทั้งหมดมาให้ดูครับ
Code (PHP)
<?php require_once("webCarot/includes/template.php") ; show_header("สถิติการแจ้งซ่อมและบริการแต่ละอาคาร") ; ?>
<?php
$nId_kong = $_SESSION['nId_kong'];
$cKongName = $_SESSION["cKongName"];
$year = $_REQUEST['year'];
$nOrder = $_REQUEST['nOrder'];
?>
<div class="page-content-wrapper">
<div class="page-content">
<div class="page-head">
<div class="page-title" >
<h3>สถิติงานแจ้งซ่อมและบริการแต่ละอาคาร</h3>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="portlet light" style="width:100%"> <!-- 990px -->
<div class="portlet-body"><!-- Alert massage -->
<div class="row list-separated">
<?php require ("Sql.php"); ?>
<?php
$data = $db->select($count_all);
$count = count($data);
foreach ($data AS $value){
$TotalAll += $value['TotalJob'];
$kong++;
}
if($count >=1){
echo "<h2>มีงาน $cKongName ทั้งหมด $TotalAll งาน จำนวน $kong กอง</h2>";
}else{
echo" <h1 style='color: #ec4844'> ไม่พบข้อมูล </h1>";
}
?>
<form>
<div class="form-group">
<label for="inputjobtype" class="col-sm-1 control-label">เดือน</label>
<div class="col-md-3">
<div class="col-md-11">
<?php
$conf = array(
"id"=>"nOrder",
"name"=>"nOrder",
"class"=>"form-control filter",
"firstopt"=>"--กรุณาเลือกเดือน--",
"selected"=>"$nOrder"
);
$db->month_select($conf)
?>
</div>
</div>
</div>
<div class="form-group">
<label for="inputjobtype" class="col-sm-1 control-label">ปี</label>
<div class="col-md-3">
<div class="col-md-10">
<?php
$sql = "
SELECT
DATENAME(yyyy, tb_job.dOrder_date) AS year
FROM
tb_job
GROUP BY
DATENAME(yyyy, tb_job.dOrder_date)
";
$conf = array(
"id" => "year",
"name"=>"year",
"class"=>"form-control filter",
"selected"=>"$year",
"firstopt"=>"--กรุณาเลือกปี--",
"value"=>"year",
"text"=>"year"
);
$result = $db->dropdown($sql, $conf);
?>
</div>
</div>
</div>
</form>
<div class="clearfix"></div>
<br>
<table class="table table-responsive table-hover text-center table-bordered" id="table">
<thead>
<tr>
<th class="text-center">ชื่อกอง</th>
<th class="text-center" colspan="2">งานทั้งหมด</th>
<th class="text-center" colspan="2">งานซ่อม</th>
<th class="text-center" colspan="2">ไฟฟ้า</th>
<th class="text-center" colspan="2">ประปา</th>
<th class="text-center" colspan="2">ปรับอากาศและสื่อสาร</th>
<th class="text-center" colspan="2">งานบริการ</th>
<th class="text-center" colspan="2">ดำเนินการเสร็จแล้ว</th>
<th class="text-center" colspan="2">งานที่ค้าง</th>
<th class="text-center" colspan="2">ไม่ดำเนินการ</th>
<th class="text-center" colspan="2">ใบงานซ้ำ</th>
</tr>
</thead>
<tbody>
<?php
if($count>=1){
foreach ($data AS $value) {
$cOwnerName = $value['cOwnerName'];
$TotalJob = $value['TotalJob'];
$repair = $value['repair'];
$EE = $value['EE'];
$SN = $value['SN'];
$ME = $value['ME'];
$service = $value['service'];
$Act = $value['Act'];
$Arr = $value['Arr'];
$Nact = $value['Nact'];
$Dup = $value['Dup'];
//คำนวณงานทั้งหมด
$totalj = ($TotalJob/$TotalAll)*100;
$pertotal = number_format("$totalj");
//คำนวณงานซ่อม และ บริการ
$totalre = ($repair/$TotalJob)*100;
$perrepair = number_format("$totalre");
$totalse = ($service/$TotalJob)*100;
$perser = number_format("$totalse");
//คำนวณ ไฟฟ้า ประปา ปรับอากาศและสื่อสาร
$totalee = ($EE/$repair)*100;
$totalsn = ($SN/$repair)*100;
$totalme = ($ME/$repair)*100;
$perEE = number_format("$totalee");
$perSN = number_format("$totalsn");
$perME = number_format("$totalme");
//คำนวณ Act Arr Nact and Dup
$totalact = ($Act/$TotalJob)*100;
$totalarr = ($Arr/$TotalJob)*100;
$totalnact = ($Nact/$TotalJob)*100;
$totaldup = ($Dup/$TotalJob)*100;
$perAct = number_format("$totalact");
$perArr = number_format("$totalarr");
$perNact = number_format("$totalnact");
$perDup = number_format("$totaldup");
echo "
<tr class='font18 font-grey-gallery'>
<td>$cOwnerName</td>
<td>$pertotal%</td>
<td>$TotalJob</td>
<td>$perrepair%</td>
<td>$repair</td>
<td>$perEE%</td>
<td>$EE</td>
<td>$perSN%</td>
<td>$SN</td>
<td>$perME%</td>
<td>$ME</td>
<td>$perser%</td>
<td>$service</td>
<td>$perAct%</td>
<td>$Act</td>
<td>$perArr%</td>
<td>$Arr</td>
<td>$perNact%</td>
<td>$Nact</td>
<td>$perDup%</td>
<td>$Dup</td>
</tr>
";
}
}else{ echo "
<tr>
<td colspan='21'><FONT COLOR='#FF0000' size='2'>ไม่พบข้อมูล</FONT></td>
</tr>
";
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 col-sm-12">
<!-- BEGIN PORTLET-->
<div class="portlet light ">
<div class="portlet-title">
<div class="caption caption-md">
<i class="icon-bar-chart theme-font-color hide"></i>
<span class="caption-subject theme-font-color bold uppercase">กราฟแสดง</span>
<span class="caption-helper hide">weekly stats...</span>
</div>
</div>
<div class="portlet-body">
<div id="chartdiv" style="width: 100%; height: 400px; background-color: #FFFFFF;" ></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php show_footer() ; ?>
<script>
$(document).ready(function(){
$("body").on("change",".filter",function(e){
e.preventDefault();
$(this).closest("form").submit();
});
});
</script>
<script type="text/javascript" src="http://www.amcharts.com/lib/3/amcharts.js"></script>
<script type="text/javascript" src="http://www.amcharts.com/lib/3/serial.js"></script>
<script src="http://www.amcharts.com/lib/3/plugins/dataloader/dataloader.min.js" type="text/javascript"></script>
<!-- amCharts javascript code -->
<script type="text/javascript">
AmCharts.makeChart("chartdiv",
{
"type": "serial",
"dataLoader": {
"url": "Json/sql_json.php?nOrder="+$("#nOrder").val()+"&year="+$("#year").val()",
},
"categoryField": "cOwnerName",
"angle": 30,
"depth3D": 30,
"startDuration": 1,
"theme": "default",
"categoryAxis": {
"gridPosition": "start"
},
"trendLines": [],
"graphs": [
{
"balloonText": "[[title]] of [[category]]:[[value]]",
"fillAlphas": 1,
"id": "AmGraph-1",
"lineColor": "#F9F147",
"title": "งานทั้งหมดของอาคาร",
"type": "column",
"valueField": "TotalJob"
},
{
"balloonText": "[[title]] of [[category]]:[[value]]",
"fillAlphas": 1,
"id": "AmGraph-2",
"lineColor": "#FF8000",
"title": "งานซ่อม",
"type": "column",
"valueField": "repair"
},
{
"balloonText": "[[title]] of [[category]]:[[value]]",
"fillAlphas": 1,
"id": "AmGraph-3",
"lineColor": "#76F947",
"title": "EE",
"type": "column",
"valueField": "EE"
},
{
"balloonText": "[[title]] of [[category]]:[[value]]",
"fillAlphas": 1,
"id": "AmGraph-4",
"lineColor": "#FF679A",
"title": "SN",
"type": "column",
"valueField": "SN"
},
{
"balloonText": "[[title]] of [[category]]:[[value]]",
"fillAlphas": 1,
"id": "AmGraph-5",
"lineColor": "#41AAF6",
"title": "ME",
"type": "column",
"valueField": "ME"
},
{
"balloonText": "[[title]] of [[category]]:[[value]]",
"fillAlphas": 1,
"id": "AmGraph-6",
"lineColor": "#4B0082",
"title": "งานบริการ",
"type": "column",
"valueField": "service"
},
{
"balloonText": "[[title]] of [[category]]:[[value]]",
"fillAlphas": 1,
"id": "AmGraph-7",
"lineColor": "#4C0B0B",
"title": "ดำเนิการเสร็จแล้ว",
"type": "column",
"valueField": "Act"
},
{
"balloonText": "[[title]] of [[category]]:[[value]]",
"fillAlphas": 1,
"id": "AmGraph-8",
"lineColor": "#FB0000",
"title": "งานที่ค้าง",
"type": "column",
"valueField": "Arr"
},
{
"balloonText": "[[title]] of [[category]]:[[value]]",
"fillAlphas": 1,
"id": "AmGraph-9",
"lineColor": "#00EAFF",
"title": "ไม่ดำเนินการ",
"type": "column",
"valueField": "Nact"
},
{
"balloonText": "[[title]] of [[category]]:[[value]]",
"fillAlphas": 1,
"id": "AmGraph-10",
"lineColor": "#5B6290",
"title": "ใบงานซ้ำ",
"type": "column",
"valueField": "Dup"
}
],
"guides": [],
"valueAxes": [
{
"id": "ValueAxis-1",
"stackType": "none",
"title": "จำนวนงาน"
}
],
"allLabels": [],
"balloon": {},
"legend": {
"enabled": true,
"useGraphSettings": true
},
"titles": [
{
"id": "Title-1",
"size": 15,
"text": "กราฟงานแจ้งซ่อมและบริการ"
}
],
}
);
</script>
ซึ่งผมจะเอาค่า nOrder ที่ผมทำ select และ year เอาค่ามาให้ต่อท้าย url ครับ
|
ประวัติการแก้ไข 2016-02-26 19:09:06
|
|
|
|
Date :
2016-02-26 18:45:24 |
By :
weekung072 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|