<?php
/** ensure this file is being included by a parent file */
defined( '_VALID_' ) or die( 'Direct Access to this location is not allowed.' );
include("FusionCharts/FusionCharts.php");
$class_ar[6]="ชั้นประถมศึกษาปีที่ 6";
$class_ar[9]="ชั้นมัธยมศึกษาปีที่ 3";
$class_ar[12]="ชั้นมัธยมศึกษาปีที่ 6";
if(!(isset($_REQUEST['school_code']))){
$_REQUEST['school_code']="";
}
$sql = "select distinct test_class from achievement_main where test_type='1' order by test_class limit 1";
$qury = mysqli_query($connect,$sql);
$result=mysqli_fetch_array($qury);
if(!(isset($_REQUEST['class_index']))){
$_REQUEST['class_index']=$result['test_class'];
}
?>
<SCRIPT LANGUAGE="Javascript" SRC="FusionCharts/FusionCharts.js"></SCRIPT>
<style type="text/css">
<!--
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
.text{
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
-->
</style>
<CENTER>
<h3>คะแนนสอบ O-NET และการประเมิน</h3>
<h3><?php
if(isset($_REQUEST['class_index'])){
echo $class_ar[$_REQUEST['class_index']];
}
?></h3>
<?php
echo "<form id='frm1' name='frm1'>";
echo "<table width='98%'><tr><td align='right'>";
echo "<Select name='class_index' size='1' onchange='goto_display(1)'>";
if($_REQUEST['class_index']=='6'){
$select_class_6="selected";
}
else if($_REQUEST['class_index']=='9'){
$select_class_9="selected";
}
else if($_REQUEST['class_index']=='12'){
$select_class_12="selected";
}
echo "<option value =6 $select_class_6>ชั้น ป.6</option>";
echo "<option value =9 $select_class_9>ชั้น ม.3</option>";
echo "<option value =12 $select_class_12>ชั้น ม.6</option>";
echo "</select>";
echo "</td><tr>";
echo "<tr><td align='right'>";
echo "<Select name='school_code' size='1' onchange='goto_display(1)'>";
echo '<option value ="" >ภาพรวมระดับ สพท. โรงเรียนรัฐบาล</option>' ;
if($_REQUEST['school_code']=="2"){
echo '<option value ="2" selected>ภาพรวมระดับ สพท. โรงเรียนเอกชน</option>' ;
}
else{
echo '<option value ="2" >ภาพรวมระดับ สพท. โรงเรียนเอกชน</option>' ;
}
$sql = "select achievement_main.school ,system_school.school_name from achievement_main left join system_school on achievement_main.school=system_school.school_code where achievement_main.test_type='1' and achievement_main.test_class='$_REQUEST[class_index]' order by system_school.school_type, system_school.school_name ";
$dbquery = mysqli_query($connect,$sql);
While ($result = mysqli_fetch_array($dbquery)){
if($_REQUEST['school_code']==""){
echo "<option value=$result[school]>$result[school_name]</option>";
}
else{
if($_REQUEST['school_code']==$result['school']){
echo "<option value=$result[school] selected>$result[school_name]</option>";
}
else{
echo "<option value=$result[school]>$result[school_name]</option>";
}
}
}
echo "</select>";
//echo " <INPUT TYPE='button' name='smb' value='เลือก' onclick='goto_display(1)' class='entrybutton'>";
echo "</td></tr></table>";
echo "</form>";
//ส่วนของปีการศึกษา
$strQuery = "select distinct ed_year from achievement_main where test_type='1' and test_class='$_REQUEST[class_index]' order by ed_year ";
$result = mysqli_query($connect,$strQuery);
$year_num=1;
while($ors = mysqli_fetch_array($result)) {
$ed_year_ar[$year_num]=$ors['ed_year'];
$year_num++;
}
$year_num=$year_num-1; //จำนวนปีที่แสดง
echo "<Table width='98%' Border='0' Bgcolor='#Fcf9d8'>";
echo "<Tr bgcolor='#FFCCCC'><Td align='center'>ปีการศึกษา</Td><Td align='center'>เฉลี่ย</Td><Td align='center' >การประเมิน</Td></Tr>";
$M=1;
for($x=1;$x<=$year_num;$x++){
if($_REQUEST['school_code']==""){
$strQuery = "select avg(thai) as thai, avg(math) as math, avg(science) as science, avg(social) as social, avg(english) as english, avg(health) as health, avg(art) as art, avg(vocation) as vocation, avg(score_avg) as score_avg from achievement_main left join system_school on achievement_main.school=system_school.school_code where achievement_main.test_type='1' and achievement_main.test_class='$_REQUEST[class_index]' and achievement_main.ed_year='$ed_year_ar[$x]' and achievement_main.score_avg>'0' and system_school.school_type='1' ";
}
else if($_REQUEST['school_code']=="2"){
$strQuery = "select avg(thai) as thai, avg(math) as math, avg(science) as science, avg(social) as social, avg(english) as english, avg(health) as health, avg(art) as art, avg(vocation) as vocation, avg(score_avg) as score_avg from achievement_main left join system_school on achievement_main.school=system_school.school_code where achievement_main.test_type='1' and achievement_main.test_class='$_REQUEST[class_index]' and achievement_main.ed_year='$ed_year_ar[$x]' and achievement_main.score_avg>'0' and system_school.school_type='2' ";
}
else{
$strQuery = "select thai, math, science, social, english, health, art, vocation, score_avg from achievement_main where test_type='1' and test_class='$_REQUEST[class_index]' and ed_year='$ed_year_ar[$x]' and school='$_REQUEST[school_code]' ";
}
$result = mysqli_query($connect,$strQuery);
$ors = mysqli_fetch_array($result);
if(($M%2) == 0)
$color="#CCCCCC";
else $color="#FFFFFF";
$thai=number_format($ors['thai'],2);
$math=number_format($ors['math'],2);
$science=number_format($ors['science'],2);
$social=number_format($ors['social'],2);
$english=number_format($ors['english'],2);
$health=number_format($ors['health'],2);
$art=number_format($ors['art'],2);
$vocation=number_format($ors['vocation'],2);
$score_avg=number_format($ors['score_avg'],2);
if($score_avg>0){
echo "<Tr bgcolor=$color><Td align='center' >$ed_year_ar[$x]</Td><Td align='center' >$score_avg</Td><Td align='left' >";
//คะแนนจุดตัด
$a=60;
$b=30;
$color[2]="#00CC00";
echo "<table border='0' cellspacing='0' cellpadding='0'>";
echo "<tr><td></td>";
$score_ceil=$score_avg/2;
if($score_ceil>50){
$score_ceil=0; //error
}
for($j=0;$j<=$score_ceil;$j++){
if ($j<=($b/2)){
$cl='#FF0000';
}
else if (($j>($b/2)) and ($j<($a/2))){
$cl='#FFFF00';
}
else if ($j>=($a/2)){
$cl='#00CC00';
}
echo "<td bgcolor='$cl' width='1' > </td>";
}
echo "</tr>";
echo "</table>";
echo "</Td></Tr>";
$M++;
}
}
echo "</Table>";
?>
</CENTER>
<script>
function goto_display(val){
if(val==1){
callfrm("?option=achievement&task=main/report1_1_mobile");
}
}
</script>