Path : /var/www/html/smart_kpp2_bk17 มีค 69/rss/
File Upload :
Current File : /var/www/html/smart_kpp2_bk17 มีค 69/rss/report_supervision.php

<style>
.button {
    background-color: #4CAF50; /* Green */
    border: none;
    color: white;
    padding: 5px 12px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 13px;
    margin: 2px 1px;
    cursor: pointer;
}

.button2 {background-color: #008CBA;} /* Blue */
.button3 {background-color: #f44336;} /* Red */ 
.button4 {background-color: #e7e7e7; color: black;} /* Gray */ 
.button5 {background-color: #555555;} /* Black */
</style>

<?php
$sql_item = "select id from supervision_item where item_active='1'";
$dbquery_item = mysqli_query($connect,$sql_item);
if($result_item = mysqli_fetch_array($dbquery_item)){
$supervision_item=$result_item['id'];
}
else{
$sql_item = "select id from supervision_item order by id desc";
$dbquery_item = mysqli_query($connect,$sql_item);
$result_item = mysqli_fetch_array($dbquery_item);
$supervision_item=$result_item['id'];
}
if(!(isset($_REQUEST['item_index']))){
$_REQUEST['item_index']=$supervision_item;
}
?>

<script>
function showResult(str) {
var item_index=<?php echo $_REQUEST['item_index'] ?>;
  if (str.length==0) { 
    document.getElementById("livesearch").innerHTML="";
    document.getElementById("livesearch").style.border="0px";
    return;
  }
  if (window.XMLHttpRequest) {
    // code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  } else {  // code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function() {
    if (this.readyState==4 && this.status==200) {
      document.getElementById("livesearch").innerHTML=this.responseText;
      document.getElementById("livesearch").style.border="1px solid #A5ACB2";
    }
  }
  xmlhttp.open("GET","modules/supervision/main/livesearch1.php?q="+str+"&on=report_supervision"+"&item_index="+item_index,true);
  xmlhttp.send();
}

function showResult_2(str) {
var item_index=<?php echo $_REQUEST['item_index'] ?>;
  if (str.length==0) { 
    document.getElementById("livesearch_2").innerHTML="";
    document.getElementById("livesearch_2").style.border="0px";
    return;
  }
  if (window.XMLHttpRequest) {
    // code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  } else {  // code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function() {
    if (this.readyState==4 && this.status==200) {
      document.getElementById("livesearch").innerHTML=this.responseText;
      document.getElementById("livesearch").style.border="1px solid #A5ACB2";
    }
  }
  xmlhttp.open("GET","modules/supervision/main/livesearch2.php?q="+str+"&on=report_supervision"+"&item_index="+item_index,true);
  xmlhttp.send();
}

function e_show(){
document.getElementById("person_display").style.display="block";
}
</script>
<script type="text/javascript" src="./css/js/calendarDateInput2.js"></script> 

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="../css/mm_training.css">
<script src="css/scrolltop/jquery-1.4.2.min.js" type='text/javascript'></SCRIPT>
<script type="text/javascript" src="css/scrolltop/scrolltopcontrol.js"></script>	
<?php
include("../amssplus_connect.php");
require_once("../include/time_inc.php");
require_once("../include/switchmenu.js");
/*
echo "<br><br><br><br>";
$x=1;
echo "<input type=\"radio\" name=\"standard_code\" value=\"standard_code\" onclick=\"SwitchMenu('sub".$x."')\">";
//echo "<table width=100% border=1>";
echo "test";
echo "<span class=submenu_post id=sub".$x.">";
	echo "$x xxxxxxxxxxxx";
echo "</span>";
//echo "</table>";
*/
echo "<br><br><br><br>";
//ส่วนหัว
//ส่วนหัว
echo "<br />";
echo "<table width='100%' border='0' align='center'>";
echo "<tr align='center'><td><font color='#006666' size='3'><strong>รายงานภาพรวม - การประเมินผลการจัดการศึกษา</strong></font></td></tr>";
echo "</table>";
		echo "<form id='frm1' name='frm1'>";
		echo "<input type='hidden' name='level_index' value='$level_index'>";

		echo  "<table width=90% border='0' align='center'>";
		echo "<Tr><td align='right'>";
		echo "รอบการนิเทศฯ&nbsp;&nbsp;<Select  name='item_index' size='1' style='color: #009900' onchange='goto_index(1)'>";
		$sql_item = "select * from supervision_item order by id desc";
		$dbquery_item = mysqli_query($connect,$sql_item);
		While ($result_item = mysqli_fetch_array($dbquery_item))
		   {
				if($_REQUEST['item_index']==$result_item['id']){
				echo "<option value=$result_item[id] selected>$result_item[item]</option>"; 
				}
				else{
				echo "<option value=$result_item[id]>$result_item[item]</option>"; 
				}
			}
		echo "</select>";
		echo "</td></Tr>";
		
		echo  "<table width=90% border='0' align='center'>";
		echo "<Tr><td align='right'>";
/*		
	//เลือก	โรงเรียน
		echo "<Select  name='school_index' size='1' style='color: #009900' onchange='goto_index(1)'>";
		echo  "<option  value = ''>เลือกโรงเรียน</option>" ;
		$sql = "select * from supervision_main a, system_school b where a.school_id=b.school_code order by  b.school_type, b.school_code";
		$dbquery = mysqli_query($connect,$sql);
		While ($result = mysqli_fetch_array($dbquery))
		   {
					if(($_SESSION['login_status']>10) and ($_SESSION['login_status']<=14)){
								if($_SESSION['user_school']==$result['school_code']){
								echo "<option value=$result[school_code] selected>$result[school_code] $result[school_name]</option>"; 
								}
					}
					else{
								if($_REQUEST['school_index']==$result['school_code']){
								echo "<option value=$result[school_code] selected>$result[school_code] $result[school_name]</option>"; 
								}
								else{
								echo "<option value=$result[school_code]>$result[school_code] $result[school_name]</option>"; 
								}
					}	
			}
		echo "</select>";
*/		
		if($_SESSION['login_status']<=4){
		?>
		<!-- พิมพ์ค้นหาโรงเรียน <input type="text" size="15" style="background: #C0F9BD" onkeyup="showResult(this.value)">&nbsp;หรือพิมพ์ค้นหาครูฯ <input type="text" size="15" style="background: #C0F9BD" onkeyup="showResult_2(this.value)">
		<div id="livesearch"></div><div id="livesearch_2"></div> -->		
		<?php
		}
	
		echo "</td></Tr>";
		echo "<Tr><td align='right'>";

		//เลือกบุคลากร
		if(($_SESSION['login_status']>10) and ($_SESSION['login_status']<=14)){
		echo "<Select  name='person_index' size='1' style='color: #009900' onchange='goto_index(2)'>";
		echo  "<option  value = ''>เลือกครูและบุคลากร</option>" ;
		$sql = "select * from  person_sch_main where school_code='$_SESSION[user_school]' and status='0' order by name";
		$dbquery = mysqli_query($connect,$sql);
		$name="";  $surname="";
		While ($result = mysqli_fetch_array($dbquery))
		   {
		   			if($_SESSION['login_status']>=14){
							if($result['person_id']==$_SESSION['login_user_id']){
							echo  "<option value = $result[person_id] selected>$result[name] $result[surname]</option>";
							$name=$result['name']; 
							$surname=$result['surname'];
							}
					}
					else{
							if($result['person_id']==$_REQUEST['person_index']){
							echo  "<option value = $result[person_id] selected>$result[name] $result[surname]</option>";
							$name=$result['name']; 
							$surname=$result['surname'];
							}
							else{
							echo  "<option value = $result[person_id]>$result[name] $result[surname]</option>";
						   }
					}	   
			}
		echo "</select>";
		}
		else{
		echo "<div id='person_display' style='display:none' align='right'>";
		echo "<Select  name='person_index' size='1' style='color: #009900' onchange='goto_index(2)'>";
		echo  "<option  value = ''>เลือกครูและบุคลากร</option>" ;
		$sql = "select * from  person_sch_main where school_code='$_REQUEST[school_index]' and status='0' order by  name";
		$dbquery = mysqli_query($connect,$sql);
		$name="";  $surname="";
		While ($result = mysqli_fetch_array($dbquery))
		   {
					if($result['person_id']==$_REQUEST['person_index']){
					echo  "<option value = $result[person_id] selected>$result[name] $result[surname]</option>";
					$name=$result['name']; 
					$surname=$result['surname'];
					}
					else{
					echo  "<option value = $result[person_id]>$result[name] $result[surname]</option>";
				   }
			}
		echo "</select>";
		echo "</div>";
		}
		echo "</td></Tr>";
		echo "</Table>";
		if($_REQUEST['school_index']!=""){
		echo "<script>e_show();</script>"; 
		}
		//จบ
		

$school_index_ok=0;		
if(isset($_REQUEST['school_index'])){		
		if($_REQUEST['school_index']!=""){
		$school_index_ok=1;
		}
}

$person_index_ok=0;		
if(isset($_REQUEST['person_index'])){		
		if($_REQUEST['person_index']!=""){
		$person_index_ok=2;
		}
}
$sum_index=$school_index_ok+$person_index_ok;
//เริ่มต้นรายงาน
		$ref_id=1;
		
//ส่วนการคำนวณ ///////////////////////
//หารายการนิเทศปัจจุบัน
$item=$_REQUEST['item_index'];

$total_num=0;
$total_value=0;
$total_weight=0;
$sql_1 = "select *,supervision_standard.id from supervision_standard inner join supervision_year on supervision_standard.year=supervision_year.year where supervision_year.year_active='1' order by supervision_standard.standard_code";
$dbquery_1 = mysqli_query($connect,$sql_1);
While ($result_1 = mysqli_fetch_array($dbquery_1))	{
$standard_num=0;
$standard_value=0;
$standard_weight=0;
$standard_code= $result_1['standard_code'];
$standard_ar[$standard_code]=0;
				$sql_2 = "select * from supervision_subject where standard_code=$standard_code order by subject_code ";
				$dbquery_2 = mysqli_query($connect,$sql_2);
				While ($result_2 = mysqli_fetch_array($dbquery_2)) {
				$subject_num=0;
				$subject_value=0;
				$subject_weight=0;
				$subject_code= $result_2['subject_code']; 
				$subject_ar[$subject_code]=0;
								$sql_3 = "select * from supervision_indicator where subject_code=$subject_code order by indicator_code ";
								$dbquery_3 = mysqli_query($connect,$sql_3);
								While ($result_3 = mysqli_fetch_array($dbquery_3)) {
								$indicator_code= $result_3['indicator_code'];
								$weight= $result_3['weight'];
											$indicator_value=0;
											$indicator_num=0;
											$indicator_weight=0;
											if($sum_index>1){
											$sql_31 = "select supervision_main_2.quality from supervision_main_2 inner join supervision_main on supervision_main_2.ref_id=supervision_main.ref_id where supervision_main_2.indicator_code='$indicator_code' and supervision_main_2.quality>='1' and supervision_main.item='$item' and supervision_main_2.person_id='$_REQUEST[person_index]' ";
											}
											else if($sum_index==1){
											$sql_31 = "select supervision_main_2.quality from supervision_main_2 inner join supervision_main on supervision_main_2.ref_id=supervision_main.ref_id where supervision_main_2.indicator_code='$indicator_code' and supervision_main_2.quality>='1' and supervision_main.item='$item' and supervision_main.school_id='$_REQUEST[school_index]' ";
											}
											else{
											$sql_31 = "select supervision_main_2.quality from supervision_main_2 inner join supervision_main on supervision_main_2.ref_id=supervision_main.ref_id where supervision_main_2.indicator_code='$indicator_code' and supervision_main_2.quality>='1' and supervision_main.item='$item' ";
											}
											if($level_index==1){
											$sql_31=$sql_31." and supervision_main.level='1' ";
											}
											else if($level_index==2){
											$sql_31=$sql_31." and supervision_main.level='2' ";
											}
											else if($level_index==3){
											$sql_31=$sql_31." and supervision_main.level='3' ";
											}
											$dbquery_31 = mysqli_query($connect,$sql_31); 
											while($result_31 = mysqli_fetch_array($dbquery_31)){
											$indicator_value=$indicator_value+$result_31['quality'];
											$indicator_num++;
											}	
											//ค่าตัวชี้วัด
											if($indicator_num!=0){
											$indicator_q_ar[$indicator_code]=$indicator_value/$indicator_num;
											$subject_num++;
											$standard_num++;
											$total_num++;
											$indicator_weight=$indicator_weight+$weight;
											$subject_weight=$subject_weight+$weight;
											$standard_weight=$standard_weight+$weight;
											$total_weight=$total_weight+$weight;
											}
											else{
											$indicator_q_ar[$indicator_code]=0;
											}

											$subject_value=$subject_value+($indicator_q_ar[$indicator_code]*$weight);  //ผลรวมประเด็น
											$standard_value=$standard_value+($indicator_q_ar[$indicator_code]*$weight);  //ผลรวมมาตรฐาน
											$total_value=$total_value+($indicator_q_ar[$indicator_code]*$weight);  //ผลรวมทั้งหมด
											
											if($sum_index>1){
											$sql_32 = "select count(act) as act1 from supervision_main_2 inner join supervision_main on supervision_main_2.ref_id=supervision_main.ref_id where supervision_main_2.indicator_code='$indicator_code' and supervision_main_2.act='1' and supervision_main.item='$item' and supervision_main_2.person_id='$_REQUEST[person_index]'";
											}
											else if($sum_index==1){
											$sql_32 = "select count(act) as act1 from supervision_main_2 inner join supervision_main on supervision_main_2.ref_id=supervision_main.ref_id where supervision_main_2.indicator_code='$indicator_code' and supervision_main_2.act='1' and supervision_main.item='$item' and supervision_main.school_id='$_REQUEST[school_index]' ";
											}
											else{
											$sql_32 = "select count(act) as act1 from supervision_main_2 inner join supervision_main on supervision_main_2.ref_id=supervision_main.ref_id where supervision_main_2.indicator_code='$indicator_code' and supervision_main_2.act='1' and supervision_main.item='$item'";
											} 
											if($level_index==1){
											$sql_32=$sql_32." and supervision_main.level='1' ";
											}
											else if($level_index==2){
											$sql_32=$sql_32." and supervision_main.level='2' ";
											}
											else if($level_index==3){
											$sql_32=$sql_32." and supervision_main.level='3' ";
											}
											$dbquery_32 = mysqli_query($connect,$sql_32);
											$result_32 = mysqli_fetch_array($dbquery_32);
											$indicator_a1_ar[$indicator_code]=$result_32['act1'];
											 
											 if($sum_index>1){
											$sql_33 = "select count(act) as act2 from supervision_main_2 inner join supervision_main on supervision_main_2.ref_id=supervision_main.ref_id where supervision_main_2.indicator_code='$indicator_code' and supervision_main_2.act='2' and supervision_main.item='$item' and supervision_main_2.person_id='$_REQUEST[person_index]' ";
											}
											else if($sum_index==1){
											$sql_33 = "select count(act) as act2 from supervision_main_2 inner join supervision_main on supervision_main_2.ref_id=supervision_main.ref_id where supervision_main_2.indicator_code='$indicator_code' and supervision_main_2.act='2' and supervision_main.item='$item' and supervision_main.school_id='$_REQUEST[school_index]' ";
											}
											else{
											$sql_33 = "select count(act) as act2 from supervision_main_2 inner join supervision_main on supervision_main_2.ref_id=supervision_main.ref_id where supervision_main_2.indicator_code='$indicator_code' and supervision_main_2.act='2' and supervision_main.item='$item'";
											}
											if($level_index==1){
											$sql_33=$sql_33." and supervision_main.level='1' ";
											}
											else if($level_index==2){
											$sql_33=$sql_33." and supervision_main.level='2' ";
											}
											else if($level_index==3){
											$sql_33=$sql_33." and supervision_main.level='3' ";
											}
											$dbquery_33 = mysqli_query($connect,$sql_33);
											$result_33 = mysqli_fetch_array($dbquery_33);
											$indicator_a2_ar[$indicator_code]=$result_33['act2'];
											
								} //end while $result_3
							
				//ค่าประเด็นตัวชี้วัด			
				if($subject_num!=0){				
				$subject_ar[$subject_code]=$subject_value/$subject_weight;		
				}
				else{
				$subject_ar[$subject_code]=0;
				}		
				
				} //end if subject
//ค่ามาตรฐาน
if($standard_num!=0){				
$standard_ar[$standard_code]=$standard_value/$standard_weight;		
}
else{
$standard_ar[$standard_code]=0;
}		

} //end if standrad		

//ค่ารวม
if($total_num!=0){				
$total_value=$total_value/$total_weight;		
}
else{
$total_value=0;
}		

//หาจำนวนรายการ
if($sum_index>1){
$sql = "select id from supervision_main where item='$item' and person_id='$_REQUEST[person_index]'";  
}
else if($sum_index==1){
$sql = "select id from supervision_main where item='$item' and school_id='$_REQUEST[school_index]' ";
}
else{
$sql = "select id from supervision_main where item='$item' ";
}
if($level_index==1){
$sql=$sql." and supervision_main.level='1' ";
}
else if($level_index==2){
$sql=$sql." and supervision_main.level='2' ";
}
else if($level_index==3){
$sql=$sql." and supervision_main.level='3' ";
}
$dbquery = mysqli_query($connect,$sql);
$person_num = mysqli_num_rows($dbquery);
////////////////

////////////////////// จบคำนวณ
		
		echo "<table width='90%' border='0' align='center'>";
		if($sum_index==0){
		echo "<tr align='left'><td width='30%'><font color='#271DA9'><strong>ภาพรวมระดับเขตพื้นที่การศึกษา</strong></font></td>";
		}
		else if($sum_index==1){
		echo "<tr align='left'><td width='30%'><font color='#271DA9'><strong>ภาพรวมระดับโรงเรียน</strong></font></td>";
		}
		else if($sum_index>1){
		$sql_person = "select * from person_sch_main left join person_sch_position on person_sch_main.position_code=person_sch_position.position_code where person_sch_main.person_id='$_REQUEST[person_index]' ";
		$dbquery_person = mysqli_query($connect,$sql_person);
		$result_person  = mysqli_fetch_array($dbquery_person);
		$prename=$result_person['prename']; 
		$name=$result_person['name']; 
		$surname=$result_person['surname']; 
		$position_name=$result_person['position_name']; 

		echo "<tr align='left'><td><font color='#271DA9'><strong>ระดับบุคคล : $prename$name $surname ตำแหน่ง : $position_name</strong></font></td>";
		}
		
		if($total_value>=1){
		echo "<td align='left'>จำนวน $person_num ชุด</td>";
		}
		else{
		echo "<td align='left'></td>";
		}
		
		echo "<td align='right'>";
		
		if(isset($_REQUEST['person_index'])){
		$person_link="&person_index=".$_REQUEST['person_index'];
		}
		else{
		$person_link="";
		}
/*	
		if($level_index==1){
		echo ">><a href=?option=supervision&task=main/report_2.1&level_index=1&school_index=$_REQUEST[school_index]$person_link><font  size='3'><b>ตนเอง</b></font></a><<";
		}
		else{
		echo "&nbsp;<a href=?option=supervision&task=main/report_2.1&level_index=1&school_index=$_REQUEST[school_index]$person_link&item_index=$_REQUEST[item_index]>ตนเอง</a>";
		}
		
		if($level_index==2){
		echo "&nbsp;>><a href=?option=supervision&task=main/report_2.1&level_index=2&school_index=$_REQUEST[school_index]$person_link&item_index=$_REQUEST[item_index]><font  size='3'><b>โรงเรียน</b></font></a><<";
		}
		else{
		echo "&nbsp;<a href=?option=supervision&task=main/report_2.1&level_index=2&school_index=$_REQUEST[school_index]$person_link&item_index=$_REQUEST[item_index]>โรงเรียน</a>";
		}
		
		if($level_index==3){
		echo "&nbsp;>><a href=?option=supervision&task=main/report_2.1&level_index=3&school_index=$_REQUEST[school_index]$person_link&item_index=$_REQUEST[item_index]><font  size='3'><b>สพท.</b></font></a><<";
		}
		else{
		echo "&nbsp;<a href=?option=supervision&task=main/report_2.1&level_index=3&school_index=$_REQUEST[school_index]$person_link&item_index=$_REQUEST[item_index]>สพท.</a>";
		}
		
		if($level_index==9){
		echo "&nbsp;>><a href=?option=supervision&task=main/report_2.1&level_index=9&school_index=$_REQUEST[school_index]$person_link&item_index=$_REQUEST[item_index]><font  size='3'><b>ทุกระดับ</b></font></a><<";
		}
		else{
		echo "<a href=?option=supervision&task=main/report_2.1&level_index=9&school_index=$_REQUEST[school_index]$person_link&item_index=$_REQUEST[item_index]>ทุกระดับ</a>";
		}
*/		
		echo "</td>";
		echo "</tr>";
		echo "</table>";
		
if($total_value<1){
echo "<br>";
echo "<div align='center'><font color='#FF0000' size='3'><strong>ไม่มีการประเมิน</strong></font></div>";
echo "<div style='display:none'>";	
}		
else{
echo "<div style='display:block'>";	
}
		
		echo  "<table width='90%' border='1' align='center' style='border-collapse: collapse'>";
		echo "<Tr bgcolor='#FBD562' align='center' height='30' class='subHeader'><Td width='80' rowspan='2' colspan='5'>มาตรฐาน</Td><Td align='center' colspan='2'>ระดับคุณภาพ</Td></Tr>";
		echo "<Tr><Td width='100' align='center'>ค่าคะแนน<br><font color='#271DA9'></font></td><Td width='100' align='center'>ระดับ<br><font color='#271DA9'></font></td></Tr>";
$M=1;
echo "<div id=\"masterdiv\">";
$sql_1 = "select *,supervision_standard.id from supervision_standard inner join supervision_year on supervision_standard.year=supervision_year.year where supervision_year.year_active='1' order by supervision_standard.standard_code";
$dbquery_1 = mysqli_query($connect,$sql_1);
While ($result_1 = mysqli_fetch_array($dbquery_1))	{

		$id_standard = $result_1['id'];
		$standard_code= $result_1['standard_code'];
		$standard_name= $result_1['standard_name'];
		echo "<Tr bgcolor='#ddd' align='center'><Td align='center' width='50'>$M</td><td align='left' colspan=2>  $standard_name <td colspan=2 width=240><input type=\"radio\" name=\"standard_code\" value=\"$M\" onclick=\"SwitchMenu('sub".$M."')\">แสดงรายละเอียด</td></Td>";
		echo "<td align='center'>";
		if($standard_ar[$standard_code]>=1){
		echo number_format($standard_ar[$standard_code],2);
		}
		echo "</td>";
		echo "<td align='center'>";
		if($standard_ar[$standard_code]>0){
		echo  cal_3($standard_ar[$standard_code]);
		}
		echo "</td></tr>";
		echo "<tr><td colspan=7>";
		echo "<span class=submenu_post id=sub".$M.">";
		echo  "<table width='100%' border='1' align='center' style='border-collapse: collapse'>";
				$sql_2 = "select * from supervision_subject where standard_code=$standard_code order by subject_code ";
				$dbquery_2 = mysqli_query($connect,$sql_2);
				$N=1; 
				While ($result_2 = mysqli_fetch_array($dbquery_2)) {
						$id_subject = $result_2['id'];
						$subject_code= $result_2['subject_code']; 
						$subject_name= $result_2['subject_name'];
					//  เริ่มการทำงานSwitch_Main-Menuเลือกหน่วยงานส่งถึง      |----------------------------------------------------
					echo "<Tr align='center'><Td align='left' bgcolor='#FFFFB' colspan='5'>$M.$N $subject_name</Td>";
					echo "<td bgcolor='#FFFFB' align='right'>";
					if($subject_ar[$subject_code]>0){	
					echo  number_format($subject_ar[$subject_code],2);
					}
					echo "</td>";
					echo "<td bgcolor='#FFFFB'>";
					if($subject_ar[$subject_code]>0){	
					echo  cal_3($subject_ar[$subject_code]);
					}
					echo "</td>";
					echo "</tr>";
					
								$sql_3 = "select * from supervision_indicator where subject_code=$subject_code order by indicator_code ";
								$dbquery_3 = mysqli_query($connect,$sql_3);
								$X=1;
								While ($result_3 = mysqli_fetch_array($dbquery_3)) {
										$id_indicator = $result_3['id'];
										$indicator_code= $result_3['indicator_code'];
										$indicator_name= $result_3['indicator_name'];
										$type= $result_3['type']; 
										$unit= $result_3['unit'];
										$min= $result_3['min'];
										$max= $result_3['max'];
										$weight= $result_3['weight'];
										$g1= $result_3['g1'];
										$g2= $result_3['g2'];
										$g3= $result_3['g3'];
										$g4= $result_3['g4'];
										$g5= $result_3['g5'];
										$function_number= $result_3['function_number'];
										$indicator_explain= $result_3['indicator_explain'];
										
									echo "<Tr align='center'><td colspan='2' width=45></td><Td align='left'>$M.$N.$X $indicator_name";
									echo " (น้ำหนัก ";
									echo $weight;
									echo " ) ";
									
if($indicator_explain!="" or $type==2){
?>
<a href="modules/supervision/main/detail.php?id=<?php echo $id_indicator;?>" class="dialogify" title="คำอธิบาย"><?php echo "<font size='1'>คำอธิบาย</font>" ?></a>
<?php
}									
									echo "</Td>";
									
									$a1_check="";  $a2_check="";
									
									if($indicator_a1_ar[$indicator_code]>=1 and $indicator_a2_ar[$indicator_code]==0){
									$a1_check="checked";
									}
									else if($indicator_a2_ar[$indicator_code]>=1){
									$a2_check="checked";
									}
									
									echo "<td bgcolor='#B4E4BB' align='center' width=120><input type='radio' name='a_$indicator_code' $a1_check disabled> ยังไม่ดำเนินการ</td>";
									echo "<td bgcolor='#B4E4BB' align='center' width=120><input type='radio' name='a_$indicator_code' $a2_check disabled> ดำเนินการ</td>";
									echo "<td align='center' width=98>";
									//if($indicator_q_ar[$indicator_code]>0){
									echo  number_format($indicator_q_ar[$indicator_code],2);
									//}
									echo "</Td>";
									echo "<td align='center' width=98>";
									if($indicator_q_ar[$indicator_code]>0){
									echo  cal_3($indicator_q_ar[$indicator_code]);
									}
									echo "</Td>";
									echo "</Tr>";
									$X++;
									}
					$N++;
					}
					echo "</table>";
					echo "</span>";
	$M++;
	}        
		echo "<Tr bgcolor='#FBD562' align='center'><Td colspan='5'><b>ผลรวม</b></Td>";
		echo "<td align='center'><b>";
		if($total_value>=1){
		echo  number_format($total_value,2);
		}
		echo "</b></td>";
		echo "<td align='center'><b>";
		if($total_value>=1){
		echo  cal_3($total_value);
		}
		echo "</b></td></tr>";
		echo "</Table>";
		echo "</form>";
echo "</div>";		


function cal_3($score){
			if($score>=1 and $score<=1.5){
			$z="<font color='#ff0000'>น้อยที่สุด</font>";
			}
			else if($score>1.5 and $score<=2.5){
			$z="<font color='#ff8080'>น้อย</font>";
			}
			else if($score>2.5 and $score<=3.5){
			$z="ปานกลาง";
			}
			else if($score>3.5 and $score<=4.5){
			$z="<font color='#00bfff'>มาก</font>";
			}
			else if($score>4.5 and $score<=5){
			$z="<font color='#00ff40'>มากที่สุด</font>";
			}
			else{
			$z="";
			}
return $z;
}
?>

<script>
function goto_index(val){
	if(val==1){
		callfrm("?on=report_supervision"); 
	}
	if(val==2){
		callfrm("?on=report_supervision"); 
	}
}


function goto_url(val){
	if(val==0){
		callfrm("?on=report_supervision"); 
	}else if(val==1){
			callfrm("?on=report_supervision&index=4");
	}
}

function goto_update(val){
	if(val==0){
		callfrm("?on=report_supervision");  
	}else if(val==1){
		callfrm("?on=report_supervision&index=6");  
	}
}


function explain(val,swith) {
		if(swith==1){
		document.getElementById(val).style.display="block";
		document.getElementById("start"+val).style.display="none";
		document.getElementById("stop"+val).style.display="block";
		}
		if(swith==2){
		document.getElementById(val).style.display="none";
		document.getElementById("start"+val).style.display="block";
		document.getElementById("stop"+val).style.display="none";
		}
}
</script>

	<link rel="stylesheet" href="./jquery/themes/ui-lightness/jquery.ui.all.css">
	<script src="./jquery/jquery-1.5.1.js"></script>
	<script src="./jquery/external/jquery.bgiframe-2.1.2.js"></script>
	<script src="./jquery/ui/jquery.ui.core.js"></script>
	<script src="./jquery/ui/jquery.ui.widget.js"></script>
	<script src="./jquery/ui/jquery.ui.mouse.js"></script>
	<script src="./jquery/ui/jquery.ui.draggable.js"></script>
	<script src="./jquery/ui/jquery.ui.position.js"></script>
	<script src="./jquery/ui/jquery.ui.resizable.js"></script>
	<script src="./jquery/ui/jquery.ui.dialog.js"></script>

	<script>

		$(function() {
			$("#dialog").dialog({
			height: 500,
			width: 500,
			minHeight: 500,
			minWidth: 500,
			autoOpen: false,
			show: "blind",
			hide: "explode",
				modal: true,
				resizable: false,
				buttons: {
					"Close": function() {
						$(this).dialog("close");
					}
				}
			});
			$(".dialogify").click(function(e) {
				e.preventDefault();
				$("#dialog").html("");
				$("#dialog").dialog("option", "title", "Loading...").dialog("open");
				$("#dialog").load(this.href, function() {
					$(this).dialog("option", "title", "คำอธิบาย");
				});
			});
		});	
</script>

<div id="dialog"></div>