Path : /var/www/html/smart_kpp2_bk17 มีค 69/modules/supervision/main/
File Upload :
Current File : /var/www/html/smart_kpp2_bk17 มีค 69/modules/supervision/main/indicator.php

<?php
/** ensure this file is being included by a parent file */
defined( '_VALID_' ) or die( 'Direct Access to this location is not allowed.' );
if($result_permission['p1']!=1){
exit();
}
?>
<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

$officer=$_SESSION['login_user_id'];

if(!(isset($_REQUEST['group_index']))){
$_REQUEST['group_index']="";
}

$sql = "select * from  supervision_year where year_active='1' order by year desc limit 1";
$dbquery = mysqli_query($connect,$sql);
$year_active_result = mysqli_fetch_array($dbquery);
if(!($year_active_result)){
echo "<script>alert('ยังไม่ได้กำหนดปีมาตรฐาน ไปที่เมนูจัดการระบบ รายการกำหนดปีมาตรฐานปัจจุบัน'); </script>";
exit();
}

//ส่วนหัว
echo "<br />";
if(!(($index==1) or ($index==1.1) or ($index==2) or ($index==2.1) or ($index==5) or ($index==5.1))){
echo "<table width='50%' border='0' align='center'>";
echo "<tr align='center'><td><font color='#006666' size='3'><strong>รายการตัวชี้วัด มาตรฐานการจัดการศึกษาของสถานศึกษา ($year_active_result[year])</strong></font></td></tr>";
echo "</table>";
}

//ส่วนฟอร์มรับข้อมูล
if($index==1){
echo "<Table width='80%' align='center'>";
echo "<tr><td>";
echo  "<fieldset>";
echo "<legend>&nbsp; <B>กรอกข้อมูล</B>: &nbsp;</legend>";

echo "<form id='frm1' name='frm1'>";
echo "<Center>";
echo "<Font color='#006666' Size='3'><B>ประเด็นตัวชี้วัด</B></Font>";
echo "</Cener>";
echo "<Br>";
echo "<Table width='85%' Border='0' align='center'>";
echo "<Tr align='left'><Td ></Td><Td align='right'>มาตรฐาน&nbsp;&nbsp;</Td>";
echo "<td><div align='left'><Select  name='standard_code'  size='1'>";
echo  "<option  value = ''>เลือก</option>" ;
$sql = "select * from supervision_standard order by standard_code";
$dbquery = mysqli_query($connect,$sql);
while($result = mysqli_fetch_array($dbquery)){
		$standard_code = $result['standard_code']; 
		$standard_name = $result['standard_name'];
		if($_GET['standard']==$standard_code){
		echo  "<option value=$standard_code selected>$standard_code $standard_name</option>" ;
		}
}				
echo "</select>";
echo "</div></td></tr>";

				$sql_2 = "select * from supervision_subject where standard_code='$_GET[standard]' order by id desc";
				$dbquery_2 = mysqli_query($connect,$sql_2);
				$result_2 = mysqli_fetch_array($dbquery_2);
				$subject_num=$result_2['subject_code']; 
				if($subject_num!=0){
				$subject_num=$subject_num+1;
				}
				else{
				$subject_num=($_GET['standard']*100)+1;
				}

echo "<Tr align='left'><Td ></Td><Td align='right'>รหัสประเด็น&nbsp;&nbsp;</Td><Td><Input Type='Text' Name='subject_code'  Size='8' value='$subject_num'> * ควรใช้เลข 8 หลัก ชุดแรก 6 หลักเป็นรหัสมาตรฐาน ต่อด้วยลำดับประเด็น 01, 02</Td></Tr>";

echo "<Tr align='left'><Td ></Td><Td align='right'>ชื่อประเด็น&nbsp;&nbsp;</Td><Td><Input Type='Text' Name='subject_name' Size='50'></Td></Tr>";
echo "<Br>";
echo "</Table>";
echo "<Br>";
echo "<INPUT TYPE='button' name='smb' value='ตกลง' onclick='goto_url(1)'>
		&nbsp;&nbsp;<INPUT TYPE='button' name='back' value='ย้อนกลับ' onclick='goto_url(0)'>";
echo "</form>";

echo "</fieldset>";
echo "</td></tr>";
echo "</table>";
}

if($index==1.1){
echo "<Table width='80%' align='center'>";
echo "<tr><td>";
echo  "<fieldset>";
echo "<legend>&nbsp; <B>กรอกข้อมูล</B>: &nbsp;</legend>";

echo "<form id='frm1' name='frm1'>";
echo "<Center>";
echo "<Font color='#006666' Size='3'><B>รายการตัวชี้วัด</B></Font>";
echo "</Cener>";
echo "<Br>";
echo "<Table width='85%' Border='0' align='center'>";
echo "<Tr align='left'><Td ></Td><Td align='right'>ปรเะเด็นตัวชี้วัด&nbsp;&nbsp;</Td>";
echo "<td><div align='left'><Select  name='subject_code'  size='1'>";
echo  "<option  value = ''>เลือก</option>" ;
$sql = "select * from supervision_subject where subject_code='$_GET[subject]' ";
$dbquery = mysqli_query($connect,$sql);
while($result = mysqli_fetch_array($dbquery)){
		$subject_code = $result['subject_code']; 
		$subject_name = $result['subject_name'];
		echo  "<option value=$subject_code selected>$subject_code $subject_name</option>" ;
}				
echo "</select>";
echo "</div></td></tr>";

								$sql_3 = "select * from supervision_indicator where subject_code='$_GET[subject]' order by id desc";
								$dbquery_3 = mysqli_query($connect,$sql_3);
								$result_3 = mysqli_fetch_array($dbquery_3);
								$indicator_num=$result_3['indicator_code']; 
								if($indicator_num!=0){
								$indicator_num=$indicator_num+1;
								}
								else{
								$indicator_num=($_GET['subject']*100)+1;
								}
							echo "<Tr align='left'><Td ></Td><Td align='right'>รหัสรายการ&nbsp;&nbsp;</Td><Td><Input Type='Text' Name='indicator_code' Size='10' value='$indicator_num'> * ควรใช้เลข 10  หลัก  ชุดแรก 8 หลักเป็นรหัสประเด็น ต่อด้วยลำดับตัวชี้วัดในประเด็น 01, 02  </Td></Tr>";

echo "<Tr align='left'><Td ></Td><Td align='right'>ชื่อรายการตัวชี้วัด&nbsp;&nbsp;</Td><Td><Input Type='Text' Name='indicator_name' Size='80'></Td></Tr>";
echo "<Tr align='left'><Td ></Td><Td align='right'>น้ำหนัก&nbsp;&nbsp;</Td><Td><Input Type='Text' Name='weight'  Size='4' value='1'></Td></Tr>";

echo "<Tr><Td></Td><Td align='right'>ประเภทตัวชี้วัด&nbsp;&nbsp;</Td>";
echo "<td><div align='left'><Select  name='type'  id='type' size='1' onchange='e_show()'>";
echo  "<option value = ''>เลือก</option>" ;
echo  "<option value='1' selected>คุณภาพ (ปรับปรุงมาก ปรับปรุง พอใช้ ดี ดีมาก)</option>" ;
echo  "<option value='2'>ปริมาณ (จำนวน , ร้อยละ)</option>" ;
echo "</select>";
echo "</div></td></tr>";

echo "<Tr align='left'><Td ></Td><Td align='right'><span id='t_unit' style='display:none'>หน่วยวัด&nbsp;&nbsp;</span></Td><Td><span id='unit' style='display:none'><Input Type='Text' Name='unit' Size='10'></span></Td></Tr>";
echo "<Tr align='left'><Td ></Td><Td align='right'><span id='t_min' style='display:none'>ค่าต่ำสุด&nbsp;&nbsp;</span></Td><Td><span id='min' style='display:none'><Input Type='Text' Name='min' Size='4' value='0'></span></Td></Tr>";
echo "<Tr align='left'><Td></Td><Td align='right'><span id='t_max' style='display:none'>ค่าสูงสุด&nbsp;&nbsp;</span></Td><Td><span id='max' style='display:none'><Input Type='Text' Name='max' Size='4' value='100'></span></Td></Tr>";

echo "<Tr align='left'><Td ></Td><Td align='right' valign='top'><span id='t1' style='display:none'>เกณฑ์ระดับ 1&nbsp;&nbsp;</span></Td><Td><span id='g1' style='display:none'><Input Type='Text' Name='g1' Size='4' value='0'></span></Td></Tr>";
echo "<Tr align='left'><Td ></Td><Td align='right' valign='top'><span id='t2' style='display:none'>เกณฑ์ระดับ 2&nbsp;&nbsp;</span></Td><Td><span id='g2' style='display:none'><Input Type='Text' Name='g2' Size='4' value='0'></span></Td></Tr>";
echo "<Tr align='left'><Td ></Td><Td align='right' valign='top'><span id='t3' style='display:none'>เกณฑ์ระดับ 3&nbsp;&nbsp;</span></Td><Td><span id='g3' style='display:none'><Input Type='Text' Name='g3' Size='4' value='0'></span></Td></Tr>";
echo "<Tr align='left'><Td ></Td><Td align='right' valign='top'><span id='t4' style='display:none'>เกณฑ์ระดับ 4&nbsp;&nbsp;</span></Td><Td><span id='g4' style='display:none'><Input Type='Text' Name='g4' Size='4' value='0'></span></Td></Tr>";
echo "<Tr align='left'><Td ></Td><Td align='right' valign='top'><span id='t5' style='display:none'>เกณฑ์ระดับ 5&nbsp;&nbsp;</span></Td><Td><span id='g5' style='display:none'><Input Type='Text' Name='g5' Size='4' value='0'></span></Td></Tr>";
echo "<Tr><Td></Td><Td align='right'><span id='t_function' style='display:none'>Function คำนวณ&nbsp;&nbsp;</span></Td>";
echo "<td><div align='left'><span id='function_number' style='display:none'><Select  name='function_number' size='1'>";
echo  "<option value = '0'>เลือก</option>" ;
echo  "<option value='1' selected>Function1 หลัก (ปริมาณมาก ได้คะแนนมาก)</option>" ;
echo  "<option value='2'>Function2 (ปริมาณมาก ได้คะแนนน้อย)</option>" ;
echo "</select>";
echo "</div></span></td></tr>";
echo "<Tr align='left'><Td ></Td><Td align='right'>คำอธิบายตัวชี้วัด&nbsp;&nbsp;</Td><Td><textarea rows='10' cols='80' name='indicator_explain'></textarea></Td></Tr>";
echo "<Br>";
echo "</Table>";
echo "<Br>";
echo "<INPUT TYPE='button' name='smb' value='ตกลง' onclick='goto_url(2)'>
		&nbsp;&nbsp;<INPUT TYPE='button' name='back' value='ย้อนกลับ' onclick='goto_url(0)'>";
echo "</form>";

echo "</fieldset>";
echo "</td></tr>";
echo "</table>";
}

//ส่วนยืนยันการลบข้อมูล
if($index==2) {
echo "<table width='500' border='0' align='center'>";
echo "<tr><td align='center'><font color='#990000' size='4'>โปรดยืนยันความต้องการลบข้อมูลอีกครั้ง</font><br></td></tr>";
echo "<tr><td align=center>";
echo "<INPUT TYPE='button' name='smb' value='ยืนยัน' onclick='location.href=\"?option=supervision&task=main/indicator&index=3&id=$_GET[id]\"'>
		&nbsp;&nbsp;<INPUT TYPE='button' name='back' value='ยกเลิก' onclick='location.href=\"?option=supervision&task=main/indicator\"'";
echo "</td></tr></table>";
}

if($index==2.1) {
echo "<table width='500' border='0' align='center'>";
echo "<tr><td align='center'><font color='#990000' size='4'>โปรดยืนยันความต้องการลบข้อมูลอีกครั้ง</font><br></td></tr>";
echo "<tr><td align=center>";
echo "<INPUT TYPE='button' name='smb' value='ยืนยัน' onclick='location.href=\"?option=supervision&task=main/indicator&index=3.1&id=$_GET[id]\"'>
		&nbsp;&nbsp;<INPUT TYPE='button' name='back' value='ยกเลิก' onclick='location.href=\"?option=supervision&task=main/indicator\"'";
echo "</td></tr></table>";
}

//ส่วนลบข้อมูล
if($index==3){
$sql = "select * from supervision_indicator where supervision_indicator.subject_code='$_GET[id]' ";
$dbquery = mysqli_query($connect,$sql);
$result_ref = mysqli_fetch_array($dbquery);
		if($result_ref){
		echo "<script>alert('มีรายการตัวชี้วัดภายใต้ประเด็นนี้ ต้องลบรายการต้วชี้วัดให้หมดก่อน');</script>\n";
		}
		else{
				$sql = "delete from supervision_subject where subject_code=$_GET[id]";
				$dbquery = mysqli_query($connect,$sql);
		}		
}

if($index==3.1){
$sql = "delete from supervision_indicator where indicator_code=$_GET[id]";
$dbquery = mysqli_query($connect,$sql);
}

//ส่วนบันทึกข้อมูล
if($index==4){
$rec_date = date("Y-m-d");
$sql = "insert into supervision_subject(subject_code,standard_code,subject_name,officer,rec_date) values ('$_POST[subject_code]','$_POST[standard_code]', '$_POST[subject_name]','$officer','$rec_date')";
$dbquery = mysqli_query($connect,$sql);
}

if($index==4.1){
$rec_date = date("Y-m-d");
$sql = "insert into supervision_indicator(indicator_code,subject_code,indicator_name,weight,type,unit,min,max,g1,g2,g3,g4,g5,function_number,indicator_explain,officer,rec_date) values ('$_POST[indicator_code]','$_POST[subject_code]', '$_POST[indicator_name]','$_POST[weight]','$_POST[type]','$_POST[unit]','$_POST[min]','$_POST[max]','$_POST[g1]','$_POST[g2]','$_POST[g3]','$_POST[g4]','$_POST[g5]','$_POST[function_number]','$_POST[indicator_explain]','$officer','$rec_date')";
$dbquery = mysqli_query($connect,$sql);
}

//ส่วนฟอร์มแก้ไขข้อมูล
if($index==5){
$sql = "select * from supervision_subject where id='$_GET[id]' ";
$dbquery = mysqli_query($connect,$sql);
$result_ref = mysqli_fetch_array($dbquery);

echo "<Table width='70%' align='center'>";
echo "<tr><td>";
echo  "<fieldset>";
echo "<legend>&nbsp; <B>แก้ไขข้อมูลประเด็นตัวชี้วัด</B>: &nbsp;</legend>";

echo "<form id='frm1' name='frm1'>";
echo "<Table width='70%' Border='0' align='center'>";
echo "<Tr align='left'><Td ></Td><Td align='right'>มาตรฐาน&nbsp;&nbsp;</Td>";
echo "<td><div align='left'><Select  name='standard_code'  size='1'>";
$sql = "select * from supervision_standard where standard_code='$result_ref[standard_code]'";
$dbquery = mysqli_query($connect,$sql);
while($result = mysqli_fetch_array($dbquery)){
		$standard_code = $result['standard_code']; 
		$standard_name = $result['standard_name'];
		echo  "<option value=$standard_code>$standard_code $standard_name</option>" ;
}				
echo "</select>";
echo "</div></td></tr>";

echo "<Tr align='left'><Td ></Td><Td align='right'>รหัสประเด็น&nbsp;&nbsp;</Td><Td><Input Type='Text' Name='subject_code'  Size='5' value='$result_ref[subject_code]' readonly></Td></Tr>";

echo "<Tr align='left'><Td ></Td><Td align='right'>ชื่อประเด็น&nbsp;&nbsp;</Td><Td><Input Type='Text' Name='subject_name' Size='50' value='$result_ref[subject_name]'></Td></Tr>";
echo "</Table>";
echo "<Br>";
echo "<div align='center'>";
echo "<INPUT TYPE='Hidden' name='id' value='$_GET[id]'>";
echo "<INPUT TYPE='button' name='smb' value='ตกลง' onclick='goto_url_update(1)'>
		&nbsp;&nbsp;<INPUT TYPE='button' name='back' value='ย้อนกลับ' onclick='goto_url_update(0)'>";
echo "</form>";
echo "</div>";

echo "</fieldset>";
echo "</td></tr>";
echo "</table>";
}

if($index==5.1){
$sql = "select * from supervision_indicator where id='$_GET[id]' ";
$dbquery = mysqli_query($connect,$sql);
$result_ref = mysqli_fetch_array($dbquery);
$type = $result_ref['type'];
$unit = $result_ref['unit'];
$min = $result_ref['min'];
$max = $result_ref['max'];
$g1 = $result_ref['g1'];
$g2 = $result_ref['g2'];
$g3 = $result_ref['g3'];
$g4 = $result_ref['g4'];
$g5 = $result_ref['g5'];
$function_number = $result_ref['function_number'];
$indicator_explain = $result_ref['indicator_explain'];

echo "<Table width='70%' align='center'>";
echo "<tr><td>";
echo  "<fieldset>";
echo "<legend>&nbsp; <B>แก้ไขข้อมูลรายการตัวชี้วัด</B>: &nbsp;</legend>";

echo "<form id='frm1' name='frm1'>";
echo "<Table width='70%' Border='0' align='center'>";
echo "<Tr align='left'><Td ></Td><Td align='right'>ประเด็นตัวชี้วัด&nbsp;&nbsp;</Td>";
echo "<td><div align='left'><Select  name='subject_code'  size='1'>";
$sql = "select * from supervision_subject where subject_code='$result_ref[subject_code]'";
$dbquery = mysqli_query($connect,$sql);
while($result = mysqli_fetch_array($dbquery)){
		$subject_code = $result['subject_code']; 
		$subject_name = $result['subject_name'];
		
		echo  "<option value=$subject_code>$subject_code $subject_name</option>" ;
}				
echo "</select>";
echo "</div></td></tr>";

echo "<Tr align='left'><Td ></Td><Td align='right'>รหัสรายการตัวชี้วัด&nbsp;&nbsp;</Td><Td><Input Type='Text' Name='indicator_code'  Size='10' value='$result_ref[indicator_code]' readonly></Td></Tr>";

echo "<Tr align='left'><Td ></Td><Td align='right'>ชื่อรายการตัวชี้วัด&nbsp;&nbsp;</Td><Td><Input Type='Text' Name='indicator_name' Size='50' value='$result_ref[indicator_name]'></Td></Tr>";
echo "<Tr align='left'><Td ></Td><Td align='right'>น้ำหนัก&nbsp;&nbsp;</Td><Td><Input Type='Text' Name='weight'  Size='4' value='$result_ref[weight]'></Td></Tr>";
echo "<Tr><Td></Td><Td align='right'>ประเภทตัวชี้วัด&nbsp;&nbsp;</Td>";
echo "<td><div align='left'><Select  name='type'  id='type' size='1' onchange='e_show()'>";
echo  "<option value = ''>เลือก</option>" ;
if($type==1){
echo  "<option value='1' selected>คุณภาพ (ปรับปรุงมาก ปรับปรุง พอใช้ ดี ดีมาก)</option>" ;
}
else{
echo  "<option value='1'>คุณภาพ (ปรับปรุงมาก ปรับปรุง พอใช้ ดี ดีมาก)</option>" ;
}
if($type==2){
echo  "<option value='2' selected>ปริมาณ (จำนวน , ร้อยละ)</option>" ;
}
else{
echo  "<option value='2'>ปริมาณ (จำนวน , ร้อยละ)</option>" ;
}
echo "</select>";
echo "</div></td></tr>";

echo "<Tr align='left'><Td ></Td><Td align='right'><span id='t_unit'>หน่วยวัด&nbsp;&nbsp;</span></Td><Td><span id='unit'><Input Type='Text' Name='unit' Size='10' value='$unit'></span></Td></Tr>";
echo "<Tr align='left'><Td ></Td><Td align='right'><span id='t_min'>ค่าต่ำสุด&nbsp;&nbsp;</span></Td><Td><span id='min'><Input Type='Text' Name='min' Size='4' value='$min'></span></Td></Tr>";
echo "<Tr align='left'><Td></Td><Td align='right'><span id='t_max'>ค่าสูงสุด&nbsp;&nbsp;</span></Td><Td><span id='max'><Input Type='Text' Name='max' Size='4' value='$max'></span></Td></Tr>";

echo "<Tr align='left'><Td ></Td><Td align='right' valign='top'><span id='t1'>เกณฑ์ระดับ 1&nbsp;&nbsp;</span></Td><Td><span id='g1'><Input Type='Text' Name='g1' Size='4' value='$g1'></span></Td></Tr>";
echo "<Tr align='left'><Td ></Td><Td align='right' valign='top'><span id='t2'>เกณฑ์ระดับ 2&nbsp;&nbsp;</span></Td><Td><span id='g2'><Input Type='Text' Name='g2' Size='4' value='$g2'></span></Td></Tr>";
echo "<Tr align='left'><Td ></Td><Td align='right' valign='top'><span id='t3'>เกณฑ์ระดับ 3&nbsp;&nbsp;</span></Td><Td><span id='g3'><Input Type='Text' Name='g3' Size='4' value='$g3'></span></Td></Tr>";
echo "<Tr align='left'><Td ></Td><Td align='right' valign='top'><span id='t4'>เกณฑ์ระดับ 4&nbsp;&nbsp;</span></Td><Td><span id='g4'><Input Type='Text' Name='g4' Size='4' value='$g4'></span></Td></Tr>";
echo "<Tr align='left'><Td ></Td><Td align='right' valign='top'><span id='t5'>เกณฑ์ระดับ 5&nbsp;&nbsp;</span></Td><Td><span id='g5'><Input Type='Text' Name='g5' Size='4' value='$g5'></span></Td></Tr>";
echo "<Tr><Td></Td><Td align='right'><span id='t_function'>Function คำนวณ&nbsp;&nbsp;</span></Td>";
echo "<td><div align='left'><span id='function_number'><Select  name='function_number' size='1'>";
echo  "<option value = '0'>เลือก</option>" ;
if($function_number==1){
echo  "<option value='1' selected>Function1 หลัก (ปริมาณมากได้คะแนนมาก)</option>" ;
}
else{
echo  "<option value='1'>Function1 หลัก (ปริมาณมากได้คะแนนมาก)</option>" ;
}
if($function_number==2){
echo  "<option value='2' selected>Function2 (ปริมาณมากได้คะแนนน้อย) </option>" ;
}
else{
echo  "<option value='2'>Function2 (ปริมาณมาก ได้คะแนนน้อย)</option>" ;
}
echo "</select>";
echo "</div></span></td></tr>";
echo "<Tr align='left'><Td ></Td><Td align='right'>คำอธิบายตัวชี้วัด&nbsp;&nbsp;</Td><Td><textarea rows='10' cols='60' name='indicator_explain'>$indicator_explain</textarea></Td></Tr>";
echo "</Table>";
echo "<Br>";
echo "<div align='center'>";
echo "<INPUT TYPE='Hidden' name='id' value='$_GET[id]'>";
echo "<INPUT TYPE='button' name='smb' value='ตกลง' onclick='goto_url_update(2)'>
		&nbsp;&nbsp;<INPUT TYPE='button' name='back' value='ย้อนกลับ' onclick='goto_url_update(0)'>";
echo "</form>";
echo "</div>";

echo "</fieldset>";
echo "</td></tr>";
echo "</table>";
}

//ส่วนปรับปรุงข้อมูล
if ($index==6){
$rec_date = date("Y-m-d");
$sql = "update supervision_subject set subject_name='$_POST[subject_name]', officer='$officer', rec_date='$rec_date' where id='$_POST[id]'";
$dbquery = mysqli_query($connect,$sql);
}

if ($index==6.1){
$rec_date = date("Y-m-d");
$sql = "update supervision_indicator set indicator_name='$_POST[indicator_name]', 
weight='$_POST[weight]', 
type='$_POST[type]', 
unit='$_POST[unit]', 
min='$_POST[min]', 
max='$_POST[max]', 
g1='$_POST[g1]', 
g2='$_POST[g2]', 
g3='$_POST[g3]', 
g4='$_POST[g4]', 
g5='$_POST[g5]', 
function_number='$_POST[function_number]', 
indicator_explain='$_POST[indicator_explain]', 
officer='$officer', rec_date='$rec_date' 
where id='$_POST[id]'";
$dbquery = mysqli_query($connect,$sql);
}

//ส่วนแสดงผล
if(!(($index==1) or ($index==1.1) or ($index==2) or ($index==2.1) or ($index==5) or ($index==5.1))){
echo "<br>";
echo  "<table width='90%' border='1' align='center' style='border-collapse: collapse'>";
echo "<Tr bgcolor='#FBD562' align='center' height='40' class='subHeader'><Td width='50'>ที่</Td><Td width='100'>มาตรฐาน</Td><Td width='250'>ประเด็นตัวชี้วัด</Td><Td>รายการตัวชี้วัด [น้ำหนัก]</Td><td width='40' align='center'>ลบ</td><Td width='40' align='center'>แก้ไข</Td></Tr>";

$M=1;
$N=1; 
$X=1;
$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>$M</td><Td align='left' colspan='2'><font color='#473CE7'>$standard_code</font> $standard_name</Td><td align='right'><INPUT TYPE='button' name='smb' value='เพิ่มประเด็นตัวชี้วัด' onclick='location.href=\"?option=supervision&task=main/indicator&index=1&standard=$standard_code\"' class='button button2'></td><td colspan='2'></td></tr>";
				$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)) {
						$id_subject = $result_2['id'];
						$subject_code= $result_2['subject_code'];
						$subject_name= $result_2['subject_name'];
					echo "<Tr align='center'><td colspan='2'></td><Td align='left' bgcolor='#FFFFB'><font color='#473CE7'>$subject_code</font> $subject_name</Td><td align='right' bgcolor='#FFFFB'><INPUT TYPE='button' name='smb' value='เพิ่มรายการตัวชี้วัด' onclick='location.href=\"?option=supervision&task=main/indicator&index=1.1&subject=$subject_code\"' class='button button4'></td>";
					echo "<td bgcolor='#FFFFB'><a href=?option=supervision&task=main/indicator&id=$subject_code&index=2><img src=./images/drop.png border='0'></a></td>";
					echo "<td bgcolor='#FFFFB'><a href=?option=supervision&task=main/indicator&id=$id_subject&index=5><img src=./images/edit.png border='0'></a></Td</Tr>";
					
								$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)) {
										$id_indicator = $result_3['id'];
										$type= $result_3['type']; 
										$indicator_code= $result_3['indicator_code'];
										$indicator_name= $result_3['indicator_name'];
										$weight= $result_3['weight'];
										$indicator_explain= $result_3['indicator_explain'];
									echo "<Tr align='center'><td colspan='3'></td><Td align='left'><font color='#473CE7'>$indicator_code</font> $indicator_name [$weight]";
									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>";
									echo "<td><a href=?option=supervision&task=main/indicator&id=$indicator_code&index=2.1><img src=./images/drop.png border='0'></a></td>";
									echo "<td><a href=?option=supervision&task=main/indicator&id=$id_indicator&index=5.1><img src=./images/edit.png border='0'></a></Td></Tr>";
									$X++;
									}
						
					$N++;
					}
	$M++;
	}
echo "</Table>";
} // end if
?>

<script>
function goto_url(val){
	if(val==0){
		callfrm("?option=supervision&task=main/indicator");   // page ย้อนกลับ 
	}else if(val==1){
		if(frm1.standard_code.value == ""){
			alert("กรุณาเลือกมาตรฐาน");
		}else if(frm1.subject_code.value==""){
			alert("กรุณากรอกรหัสประเด็นตัวชี้วัด");
		}else if(frm1.subject_name.value==""){
			alert("กรุณากรอกชื่อประเด็นตัวชี้วัด");
		}else{
			callfrm("?option=supervision&task=main/indicator&index=4");   //page ประมวลผล
		}
	}
	else if(val==2){
		if(frm1.subject_code.value == ""){
			alert("กรุณาเลือกประเด็นตัวชี้วัด");
		}else if(frm1.indicator_code.value==""){
			alert("กรุณากรอกรหัสรายการตัวชี้วัด");
		}else if(frm1.indicator_name.value==""){
			alert("กรุณากรอกชื่อรายการตัวชี้วัด");
		}else{
			callfrm("?option=supervision&task=main/indicator&index=4.1");   //page ประมวลผล
		}
	}
}

function goto_url_update(val){
	if(val==0){
		callfrm("?option=supervision&task=main/indicator");   // page ย้อนกลับ 
	}else if(val==1){
		if(frm1.subject_name.value==""){
			alert("กรุณากรอกชื่อประเด็นตัวชี้วัด");
		}else{
			callfrm("?option=supervision&task=main/indicator&index=6");   //page ประมวลผล
		}
	}else if(val==2){
		 if(frm1.indicator_name.value==""){
			alert("กรุณากรอกชื่อรายการตัวชี้วัด");
		}else{
			callfrm("?option=supervision&task=main/indicator&index=6.1");   //page ประมวลผล
		}
	}
}

function goto_index(val){
	if(val==1){
		callfrm("?option=supervision&task=main/indicator");  
		}
}

function e_show(){
		if(document.getElementById("type").value=="2"){
		document.getElementById("t_unit").style.display="block";
		document.getElementById("t_min").style.display="block";
		document.getElementById("t_max").style.display="block";
		
		document.getElementById("unit").style.display="block";
		document.getElementById("min").style.display="block";
		document.getElementById("max").style.display="block";
		
		document.getElementById("t1").style.display="block";
		document.getElementById("t2").style.display="block";
		document.getElementById("t3").style.display="block";
		document.getElementById("t4").style.display="block";
		document.getElementById("t5").style.display="block";

		document.getElementById("g1").style.display="block";
		document.getElementById("g2").style.display="block";
		document.getElementById("g3").style.display="block";
		document.getElementById("g4").style.display="block";
		document.getElementById("g5").style.display="block";
		
		document.getElementById("t_function").style.display="block";
		document.getElementById("function_number").style.display="block";
		}
		else if(document.getElementById("type").value=="1"){
		document.getElementById("t_unit").style.display="none";		
		document.getElementById("t_min").style.display="none";		
		document.getElementById("t_max").style.display="none";	
		
		document.getElementById("unit").style.display="none";		
		document.getElementById("min").style.display="none";		
		document.getElementById("max").style.display="none";		

		document.getElementById("t1").style.display="none";
		document.getElementById("t2").style.display="none";
		document.getElementById("t3").style.display="none";
		document.getElementById("t4").style.display="none";
		document.getElementById("t5").style.display="none";
		
		document.getElementById("g1").style.display="none";
		document.getElementById("g2").style.display="none";
		document.getElementById("g3").style.display="none";
		document.getElementById("g4").style.display="none";
		document.getElementById("g5").style.display="none";
		
		document.getElementById("t_function").style.display="none";
		document.getElementById("function_number").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>